notform 2.0.0-beta.2 → 2.1.0-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -6
- package/dist/index.d.ts +56 -47
- package/dist/index.js +6 -11
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
# notform
|
|
2
2
|
|
|
3
|
-
[](https://bundlephobia.com/package/notform)
|
|
3
|
+
[](https://npmx.dev/package/notform)
|
|
4
|
+
[](https://npmx.dev/package/notform)
|
|
5
|
+
[](https://npmx.dev/package/notform)
|
|
7
6
|
|
|
8
|
-
**The core engine for
|
|
7
|
+
**The core engine for NotForm**
|
|
9
8
|
|
|
10
|
-
`notform` is the backbone of the NotForm ecosystem, providing the core composables and state management logic for building robust forms in Vue 3.
|
|
9
|
+
`notform` is the backbone of the NotForm ecosystem, providing the core composables, components and state management logic for building robust forms in Vue 3.
|
|
11
10
|
|
|
12
11
|
## Documentation
|
|
13
12
|
|
package/dist/index.d.ts
CHANGED
|
@@ -92,7 +92,9 @@ type NotFormInstance<TSchema extends ObjectSchema> = Raw<{
|
|
|
92
92
|
*
|
|
93
93
|
* Use with `v-model` for two-way binding:
|
|
94
94
|
* ```vue
|
|
95
|
-
* <
|
|
95
|
+
* <template>
|
|
96
|
+
* <input v-model="form.values.email" />
|
|
97
|
+
* </template>
|
|
96
98
|
* ```
|
|
97
99
|
*/
|
|
98
100
|
values: StandardSchemaV1.InferInput<TSchema>;
|
|
@@ -133,7 +135,9 @@ type NotFormInstance<TSchema extends ObjectSchema> = Raw<{
|
|
|
133
135
|
*
|
|
134
136
|
* Convenient for direct template access without calling `getFieldErrors`:
|
|
135
137
|
* ```vue
|
|
136
|
-
* <
|
|
138
|
+
* <template>
|
|
139
|
+
* <p>{{ form.errorsMap['address.city'] }}</p>
|
|
140
|
+
* </template>
|
|
137
141
|
* ```
|
|
138
142
|
*/
|
|
139
143
|
errorsMap: ComputedRef<Partial<Record<Paths<StandardSchemaV1.InferInput<TSchema>>, string>>>;
|
|
@@ -173,7 +177,10 @@ type NotFormInstance<TSchema extends ObjectSchema> = Raw<{
|
|
|
173
177
|
* Bind to the native form's `@submit` event:
|
|
174
178
|
*
|
|
175
179
|
* ```vue
|
|
176
|
-
* <
|
|
180
|
+
* <template>
|
|
181
|
+
* <form @submit="form.submit">
|
|
182
|
+
* </form>
|
|
183
|
+
* </template>
|
|
177
184
|
* ```
|
|
178
185
|
*/
|
|
179
186
|
submit: (event: Event) => Promise<void>;
|
|
@@ -217,24 +224,6 @@ type __VLS_WithSlots$1<T, S> = T & {
|
|
|
217
224
|
};
|
|
218
225
|
//#endregion
|
|
219
226
|
//#region src/types/not-field.d.ts
|
|
220
|
-
/**
|
|
221
|
-
* Native DOM event handlers exposed by a field.
|
|
222
|
-
* Spread onto a native input or bind individually to custom components.
|
|
223
|
-
*
|
|
224
|
-
* ```vue
|
|
225
|
-
* <!-- spread -->
|
|
226
|
-
* <input v-bind="events" />
|
|
227
|
-
*
|
|
228
|
-
* <!-- individual -->
|
|
229
|
-
* <CustomCombobox @focusout="onBlur" @pick="onChange" />
|
|
230
|
-
* ```
|
|
231
|
-
*/
|
|
232
|
-
type NotFieldEvents = {
|
|
233
|
-
/** Triggered when the field loses focus. */onBlur: () => void; /** Triggered on every keystroke or value change. */
|
|
234
|
-
onInput: () => void; /** Triggered when the field value is committed. */
|
|
235
|
-
onChange: () => void; /** Triggered when the field gains focus. */
|
|
236
|
-
onFocus: () => void;
|
|
237
|
-
};
|
|
238
227
|
/** Props for the `NotField` component. */
|
|
239
228
|
type NotFieldProps = {
|
|
240
229
|
/** Dot-separated path to this field within the form values. */path: string;
|
|
@@ -244,9 +233,11 @@ type NotFieldProps = {
|
|
|
244
233
|
* Required when using `NotField` outside of a `NotForm` (singleton fields).
|
|
245
234
|
*
|
|
246
235
|
* ```vue
|
|
247
|
-
* <
|
|
248
|
-
* <
|
|
249
|
-
*
|
|
236
|
+
* <template>
|
|
237
|
+
* <NotField :form="form" path="email" v-slot="{ events }">
|
|
238
|
+
* <input v-bind="events" />
|
|
239
|
+
* </NotField>
|
|
240
|
+
* </template>
|
|
250
241
|
* ```
|
|
251
242
|
*/
|
|
252
243
|
form?: NotFormInstance<any>;
|
|
@@ -255,8 +246,10 @@ type NotFieldProps = {
|
|
|
255
246
|
* Merged over the form-wide `validateOn` — only the keys you specify are overridden.
|
|
256
247
|
*
|
|
257
248
|
* ```vue
|
|
258
|
-
*
|
|
259
|
-
*
|
|
249
|
+
* <template>
|
|
250
|
+
* <!-- form validates on blur only, but this field also validates on every input -->
|
|
251
|
+
* <NotField :validateOn="{ onInput: true }" path="username" />
|
|
252
|
+
* </template>
|
|
260
253
|
* ```
|
|
261
254
|
*/
|
|
262
255
|
validateOn?: Partial<Record<ValidationTrigger, boolean>>;
|
|
@@ -272,10 +265,12 @@ type NotFieldProps = {
|
|
|
272
265
|
* of this setting, so the field never feels unresponsive when the user leaves.
|
|
273
266
|
*
|
|
274
267
|
* ```vue
|
|
275
|
-
*
|
|
276
|
-
*
|
|
277
|
-
* <
|
|
278
|
-
*
|
|
268
|
+
* <template>
|
|
269
|
+
* <!-- validate 400ms after the user stops typing -->
|
|
270
|
+
* <NotField path="username" :debounce="400" v-slot="{ events }">
|
|
271
|
+
* <input v-model="form.values.username" v-bind="events" />
|
|
272
|
+
* </NotField>
|
|
273
|
+
* </template>
|
|
279
274
|
* ```
|
|
280
275
|
*
|
|
281
276
|
* Omit or set to `0` to disable debouncing (default behaviour).
|
|
@@ -305,17 +300,25 @@ type NotFieldSlotProps<TSchema extends ObjectSchema> = {
|
|
|
305
300
|
*/
|
|
306
301
|
validate: () => ReturnType<NotFormInstance<TSchema>['validateField']>;
|
|
307
302
|
/**
|
|
308
|
-
*
|
|
303
|
+
* Native DOM event handlers exposed by a field.
|
|
304
|
+
* Spread onto a native input or bind individually to custom components.
|
|
309
305
|
*
|
|
310
306
|
* ```vue
|
|
311
|
-
* <
|
|
307
|
+
* <template>
|
|
308
|
+
* <!-- spread -->
|
|
309
|
+
* <input v-bind="events" />
|
|
310
|
+
*
|
|
311
|
+
* <!-- individual -->
|
|
312
|
+
* <CustomCombobox @focusout="events.onBlur" @pick="events.onChange" />
|
|
313
|
+
* </template>
|
|
312
314
|
* ```
|
|
313
315
|
*/
|
|
314
|
-
events:
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
316
|
+
events: {
|
|
317
|
+
/** Triggered when the field loses focus. */onBlur: () => void; /** Triggered on every keystroke or value change. */
|
|
318
|
+
onInput: () => void; /** Triggered when the field value is committed. */
|
|
319
|
+
onChange: () => void; /** Triggered when the field gains focus. */
|
|
320
|
+
onFocus: () => void;
|
|
321
|
+
};
|
|
319
322
|
};
|
|
320
323
|
/**
|
|
321
324
|
* Slots for the `NotField` component.
|
|
@@ -351,7 +354,9 @@ type NotMessageProps = {
|
|
|
351
354
|
* Required when using `NotMessage` outside of a `NotForm` (singleton fields).
|
|
352
355
|
*
|
|
353
356
|
* ```vue
|
|
354
|
-
* <
|
|
357
|
+
* <template>
|
|
358
|
+
* <NotMessage :form="form" path="email" />
|
|
359
|
+
* </template>
|
|
355
360
|
* ```
|
|
356
361
|
*/
|
|
357
362
|
form?: NotFormInstance<any>;
|
|
@@ -388,9 +393,11 @@ type NotArrayFieldProps<TItemSchema extends StandardSchemaV1 = StandardSchemaV1>
|
|
|
388
393
|
* Enables typed `append`, `prepend`, `insert`, and `update` methods in the slot.
|
|
389
394
|
*
|
|
390
395
|
* ```vue
|
|
391
|
-
* <
|
|
392
|
-
*
|
|
393
|
-
*
|
|
396
|
+
* <template>
|
|
397
|
+
* <NotArrayField path="tags" :item-schema="z.string()">
|
|
398
|
+
* <!-- append now expects a string -->
|
|
399
|
+
* </NotArrayField>
|
|
400
|
+
* </template>
|
|
394
401
|
* ```
|
|
395
402
|
*/
|
|
396
403
|
itemSchema?: TItemSchema;
|
|
@@ -411,11 +418,13 @@ type NotArrayFieldProps<TItemSchema extends StandardSchemaV1 = StandardSchemaV1>
|
|
|
411
418
|
* Use `key` for `v-for` tracking and `path` to pass to a nested `NotField`.
|
|
412
419
|
*
|
|
413
420
|
* ```vue
|
|
414
|
-
* <
|
|
415
|
-
* <
|
|
416
|
-
* <
|
|
417
|
-
*
|
|
418
|
-
*
|
|
421
|
+
* <template>
|
|
422
|
+
* <NotArrayField path="tags" v-slot="{ items }">
|
|
423
|
+
* <NotField v-for="item in items" :key="item.key" :path="item.path" v-slot="{ events }">
|
|
424
|
+
* <input v-model="form.values.tags[item.index]" v-bind="events" />
|
|
425
|
+
* </NotField>
|
|
426
|
+
* </NotArrayField>
|
|
427
|
+
* </template>
|
|
419
428
|
* ```
|
|
420
429
|
*/
|
|
421
430
|
type NotArrayFieldItem = {
|
|
@@ -513,4 +522,4 @@ declare const __VLS_export: <TSchema extends ObjectSchema, TItemSchema extends S
|
|
|
513
522
|
declare const _default: typeof __VLS_export;
|
|
514
523
|
type __VLS_PrettifyLocal<T> = (T extends any ? { [K in keyof T]: T[K] } : { [K in keyof T as K]: T[K] }) & {};
|
|
515
524
|
//#endregion
|
|
516
|
-
export { DeepPartial, _default as NotArrayField, NotArrayFieldItem, NotArrayFieldProps, NotArrayFieldSlotProps, NotArrayFieldSlots, _default$1 as NotField,
|
|
525
|
+
export { DeepPartial, _default as NotArrayField, NotArrayFieldItem, NotArrayFieldProps, NotArrayFieldSlotProps, NotArrayFieldSlots, _default$1 as NotField, NotFieldProps, NotFieldSlotProps, NotFieldSlots, _default$2 as NotForm, NotFormInstance, NotFormProps, NotFormSlots, _default$3 as NotMessage, NotMessageProps, NotMessageSlotProps, NotMessageSlots, ObjectSchema, Paths, UseNotFormConfig, ValidationMode, ValidationTrigger, useNotForm };
|
package/dist/index.js
CHANGED
|
@@ -394,12 +394,6 @@ var not_field_default = /* @__PURE__ */ defineComponent({
|
|
|
394
394
|
const onFocus = () => {
|
|
395
395
|
if (validateOn.value.onFocus) scheduleValidation();
|
|
396
396
|
};
|
|
397
|
-
const events = computed(() => ({
|
|
398
|
-
onBlur,
|
|
399
|
-
onInput,
|
|
400
|
-
onChange,
|
|
401
|
-
onFocus
|
|
402
|
-
}));
|
|
403
397
|
onMounted(async () => {
|
|
404
398
|
await nextTick();
|
|
405
399
|
if (validateOn.value.onMount) validate();
|
|
@@ -414,11 +408,12 @@ var not_field_default = /* @__PURE__ */ defineComponent({
|
|
|
414
408
|
isDirty: isDirty.value,
|
|
415
409
|
isValidating: isValidating.value,
|
|
416
410
|
validate,
|
|
417
|
-
events:
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
411
|
+
events: {
|
|
412
|
+
onBlur,
|
|
413
|
+
onInput,
|
|
414
|
+
onChange,
|
|
415
|
+
onFocus
|
|
416
|
+
}
|
|
422
417
|
}));
|
|
423
418
|
return (_ctx, _cache) => {
|
|
424
419
|
return renderSlot(_ctx.$slots, "default", normalizeProps(guardReactiveProps(slotProps.value)));
|