Skip to content

Commit a6133f0

Browse files
committed
chore: update knip and packages
1 parent 8295379 commit a6133f0

File tree

7 files changed

+50
-245
lines changed

7 files changed

+50
-245
lines changed

knip.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,7 @@
165165
"@vue/repl",
166166
"@vuetify/paper",
167167
"conventional-changelog-vuetify",
168+
"@vue/compiler-dom",
168169
"@flagsmith/flagsmith",
169170
"launchdarkly-js-client-sdk",
170171
"posthog-js"

package.json

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -68,13 +68,6 @@
6868
"vitest": "catalog:",
6969
"vue-tsc": "catalog:"
7070
},
71-
"pnpm": {
72-
"peerDependencyRules": {
73-
"allowedVersions": {
74-
"vite": "8"
75-
}
76-
}
77-
},
7871
"packageManager": "pnpm@10.26.1",
7972
"web-types": "dist/json/web-types.json"
8073
}

packages/0/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@
103103
"@ant-design/colors": "catalog:",
104104
"@flagsmith/flagsmith": "catalog:",
105105
"@material/material-color-utilities": "catalog:",
106+
"@vue/compiler-dom": "catalog:",
106107
"@vue/test-utils": "catalog:",
107108
"launchdarkly-js-client-sdk": "catalog:",
108109
"posthog-js": "catalog:",

packages/0/src/composables/createForm/index.test.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { beforeEach, describe, expect, it, vi } from 'vitest'
44
import { createValidation } from '#v0/composables/createValidation'
55

66
// Utilities
7-
import { inject, nextTick, provide, shallowRef } from 'vue'
7+
import { inject, nextTick, provide, shallowRef, toValue } from 'vue'
88

99
import { createForm, createFormContext, useForm } from './index'
1010

@@ -42,18 +42,18 @@ describe('createForm', () => {
4242
expect(form.size).toBe(0)
4343
})
4444

45-
it('should have disabled and readonly refs', () => {
45+
it('should have disabled and readonly options', () => {
4646
const form = createForm({ disabled: true, readonly: true })
4747

48-
expect(form.disabled.value).toBe(true)
49-
expect(form.readonly.value).toBe(true)
48+
expect(toValue(form.disabled)).toBe(true)
49+
expect(toValue(form.readonly)).toBe(true)
5050
})
5151

5252
it('should default disabled and readonly to false', () => {
5353
const form = createForm()
5454

55-
expect(form.disabled.value).toBe(false)
56-
expect(form.readonly.value).toBe(false)
55+
expect(toValue(form.disabled)).toBe(false)
56+
expect(toValue(form.readonly)).toBe(false)
5757
})
5858

5959
describe('isValid computation', () => {

packages/0/src/composables/createForm/index.ts

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ import { createTrinity } from '#v0/composables/createTrinity'
2323
import { createRegistry } from '#v0/composables/createRegistry'
2424

2525
// Utilities
26-
import { isNull, isNullOrUndefined } from '#v0/utilities'
27-
import { computed, shallowRef, toValue } from 'vue'
26+
import { isNull } from '#v0/utilities'
27+
import { computed } from 'vue'
2828

2929
// Transformers
3030
import { toArray } from '#v0/composables/toArray'
@@ -34,7 +34,7 @@ import type { RegistryContext, RegistryOptions, RegistryTicket, RegistryTicketIn
3434
import type { ContextTrinity } from '#v0/composables/createTrinity'
3535
import type { ValidationContext } from '#v0/composables/createValidation'
3636
import type { ID } from '#v0/types'
37-
import type { App, ComputedRef, MaybeRefOrGetter, ShallowRef } from 'vue'
37+
import type { App, ComputedRef, MaybeRefOrGetter } from 'vue'
3838

3939
export type FormValidationResult = string | boolean | Promise<string | boolean>
4040

@@ -71,9 +71,9 @@ export interface FormContext<
7171
/** Reset all registered validations. */
7272
reset: () => void
7373
/** Whether the form is disabled. Components can read this to conditionally disable inputs. */
74-
disabled: ShallowRef<boolean>
74+
disabled: MaybeRefOrGetter<boolean>
7575
/** Whether the form is readonly. Components can read this to conditionally disable inputs. */
76-
readonly: ShallowRef<boolean>
76+
readonly: MaybeRefOrGetter<boolean>
7777
/** Aggregate: true if all validations valid, false if any invalid, null if any unvalidated. */
7878
isValid: ComputedRef<boolean | null>
7979
/** Aggregate: true if any validation is in progress. */
@@ -127,13 +127,14 @@ export function createForm<
127127
Z extends FormTicketInput = FormTicketInput,
128128
E extends FormTicket<Z> = FormTicket<Z>,
129129
R extends FormContext<Z, E> = FormContext<Z, E>,
130-
> (options?: FormOptions): R {
131-
const registry = createRegistry<E>(options)
132-
const disabled = shallowRef(false)
133-
const readonly = shallowRef(false)
134-
135-
if (!isNullOrUndefined(options?.disabled)) disabled.value = toValue(options.disabled) ?? false
136-
if (!isNullOrUndefined(options?.readonly)) readonly.value = toValue(options.readonly) ?? false
130+
> (options: FormOptions = {}): R {
131+
const {
132+
disabled = false,
133+
readonly = false,
134+
..._options
135+
} = options
136+
137+
const registry = createRegistry<E>({ ..._options, reactive: true })
137138

138139
const isValidating = computed(() => {
139140
for (const ticket of registry.values()) {

0 commit comments

Comments
 (0)