notform 2.0.0 → 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 CHANGED
@@ -1,13 +1,12 @@
1
1
  # notform
2
2
 
3
- [![npm version](https://img.shields.io/npm/v/notform.svg?style=flat-square)](https://www.npmjs.com/package/notform)
4
- [![npm downloads](https://img.shields.io/npm/dm/notform.svg?style=flat-square)](https://www.npmjs.com/package/notform)
5
- [![license](https://img.shields.io/github/license/favorodera/notform.svg?style=flat-square)](https://github.com/favorodera/notform/blob/main/LICENSE)
6
- [![Bundle Size](https://img.shields.io/bundlephobia/minzip/notform.svg?style=flat-square)](https://bundlephobia.com/package/notform)
3
+ [![npm version](https://img.shields.io/npm/v/notform.svg?style=plastic)](https://npmx.dev/package/notform)
4
+ [![npm downloads](https://img.shields.io/npm/dm/notform.svg?style=plastic)](https://npmx.dev/package/notform)
5
+ [![NPM Unpacked Size](https://img.shields.io/npm/unpacked-size/notform?style=plastic)](https://npmx.dev/package/notform)
7
6
 
8
- **The core engine for "Vue Forms Without the Friction."**
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
- * <input v-model="form.values.email" />
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
- * <p>{{ form.errorsMap['address.city'] }}</p>
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
- * <form @submit="form.submit">
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
- * <NotField :form="form" path="email" v-slot="{ events }">
248
- * <input v-bind="events" />
249
- * </NotField>
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
- * <!-- form validates on blur only, but this field also validates on every input -->
259
- * <NotField :validateOn="{ onInput: true }" path="username" />
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
- * <!-- validate 400ms after the user stops typing -->
276
- * <NotField path="username" :debounce="400" v-slot="{ events }">
277
- * <input v-model="form.values.username" v-bind="events" />
278
- * </NotField>
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
- * All event handlers combined spread directly onto native inputs.
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
- * <input v-bind="events" />
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: NotFieldEvents; /** Triggered when the field loses focus. */
315
- onBlur: NotFieldEvents['onBlur']; /** Triggered on every keystroke or value change. */
316
- onInput: NotFieldEvents['onInput']; /** Triggered when the field value is committed. */
317
- onChange: NotFieldEvents['onChange']; /** Triggered when the field gains focus. */
318
- onFocus: NotFieldEvents['onFocus'];
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
- * <NotMessage :form="form" path="email" />
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
- * <NotArrayField path="tags" :item-schema="z.string()">
392
- * <!-- append now expects a string -->
393
- * </NotArrayField>
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
- * <NotArrayField path="tags" v-slot="{ items }">
415
- * <NotField v-for="item in items" :key="item.key" :path="item.path" v-slot="{ events }">
416
- * <input v-model="form.values.tags[item.index]" v-bind="events" />
417
- * </NotField>
418
- * </NotArrayField>
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, NotFieldEvents, NotFieldProps, NotFieldSlotProps, NotFieldSlots, _default$2 as NotForm, NotFormInstance, NotFormProps, NotFormSlots, _default$3 as NotMessage, NotMessageProps, NotMessageSlotProps, NotMessageSlots, ObjectSchema, Paths, UseNotFormConfig, ValidationMode, ValidationTrigger, useNotForm };
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: events.value,
418
- onBlur,
419
- onInput,
420
- onChange,
421
- onFocus
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)));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "notform",
3
- "version": "2.0.0",
3
+ "version": "2.1.0-alpha.0",
4
4
  "type": "module",
5
5
  "private": false,
6
6
  "description": "Vue Forms Without the Friction",