notform 2.0.0-alpha.4 → 2.0.0-alpha.5

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,29 +1,16 @@
1
- # vue-components-starter
1
+ # notform
2
2
 
3
- A starter for creating a Vue component library.
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)
4
7
 
5
- ## Development
8
+ **The core engine for "Vue Forms Without the Friction."**
6
9
 
7
- - Install dependencies:
10
+ `notform` is the backbone of the NotForm ecosystem, providing the core composables and state management logic for building robust forms in Vue 3.
8
11
 
9
- ```bash
10
- npm install
11
- ```
12
+ ## Documentation
12
13
 
13
- - Run the playground:
14
+ For detailed guides, API reference, and examples, visit:
15
+ **[notform-docs.vercel.app](https://notform-docs.vercel.app/)**
14
16
 
15
- ```bash
16
- npm run playground
17
- ```
18
-
19
- - Run the unit tests:
20
-
21
- ```bash
22
- npm run test
23
- ```
24
-
25
- - Build the library:
26
-
27
- ```bash
28
- npm run build
29
- ```
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as _$vue from "vue";
2
- import { ComputedRef, MaybeRefOrGetter, Raw, Ref } from "vue";
2
+ import { ComputedRef, MaybeRefOrGetter, Raw, Ref, useAttrs } from "vue";
3
3
  import { StandardSchemaV1 } from "@standard-schema/spec";
4
4
  import { Get, PartialDeep, Paths as Paths$1 } from "type-fest";
5
5
 
@@ -217,11 +217,11 @@ type NotFormSlots = {
217
217
  declare function useNotForm<TSchema extends ObjectSchema>(config: UseNotFormConfig<TSchema>): NotFormInstance<TSchema>;
218
218
  //#endregion
219
219
  //#region src/components/not-form.vue.d.ts
220
- type __VLS_Slots = NotFormSlots;
221
- declare const __VLS_base: _$vue.DefineComponent<NotFormProps, {}, {}, {}, {}, _$vue.ComponentOptionsMixin, _$vue.ComponentOptionsMixin, {}, string, _$vue.PublicProps, Readonly<NotFormProps> & Readonly<{}>, {}, {}, {}, {}, string, _$vue.ComponentProvideOptions, false, {}, any>;
222
- declare const __VLS_export$1: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
223
- declare const _default$1: typeof __VLS_export$1;
224
- type __VLS_WithSlots<T, S> = T & {
220
+ type __VLS_Slots$1 = NotFormSlots;
221
+ declare const __VLS_base$1: _$vue.DefineComponent<NotFormProps, {}, {}, {}, {}, _$vue.ComponentOptionsMixin, _$vue.ComponentOptionsMixin, {}, string, _$vue.PublicProps, Readonly<NotFormProps> & Readonly<{}>, {}, {}, {}, {}, string, _$vue.ComponentProvideOptions, false, {}, any>;
222
+ declare const __VLS_export$2: __VLS_WithSlots$1<typeof __VLS_base$1, __VLS_Slots$1>;
223
+ declare const _default$1: typeof __VLS_export$2;
224
+ type __VLS_WithSlots$1<T, S> = T & {
225
225
  new (): {
226
226
  $slots: S;
227
227
  };
@@ -316,7 +316,7 @@ type NotFieldSlots<TSchema extends ObjectSchema> = {
316
316
  };
317
317
  //#endregion
318
318
  //#region src/components/not-field.vue.d.ts
319
- declare const __VLS_export: <TSchema extends ObjectSchema>(__VLS_props: NonNullable<Awaited<typeof __VLS_setup>>["props"], __VLS_ctx?: __VLS_PrettifyLocal<Pick<NonNullable<Awaited<typeof __VLS_setup>>, "attrs" | "emit" | "slots">>, __VLS_exposed?: NonNullable<Awaited<typeof __VLS_setup>>["expose"], __VLS_setup?: Promise<{
319
+ declare const __VLS_export$1: <TSchema extends ObjectSchema>(__VLS_props: NonNullable<Awaited<typeof __VLS_setup>>["props"], __VLS_ctx?: __VLS_PrettifyLocal<Pick<NonNullable<Awaited<typeof __VLS_setup>>, "attrs" | "emit" | "slots">>, __VLS_exposed?: NonNullable<Awaited<typeof __VLS_setup>>["expose"], __VLS_setup?: Promise<{
320
320
  props: _$vue.PublicProps & __VLS_PrettifyLocal<NotFieldProps> & (typeof globalThis extends {
321
321
  __VLS_PROPS_FALLBACK: infer P;
322
322
  } ? P : {});
@@ -327,7 +327,46 @@ declare const __VLS_export: <TSchema extends ObjectSchema>(__VLS_props: NonNulla
327
327
  }>) => _$vue.VNode & {
328
328
  __ctx?: Awaited<typeof __VLS_setup>;
329
329
  };
330
- declare const _default: typeof __VLS_export;
330
+ declare const _default: typeof __VLS_export$1;
331
331
  type __VLS_PrettifyLocal<T> = (T extends any ? { [K in keyof T]: T[K] } : { [K in keyof T as K]: T[K] }) & {};
332
332
  //#endregion
333
- export { ArraySchema, DeepPartial, _default as NotField, NotFieldEvents, NotFieldProps, NotFieldSlotProps, NotFieldSlots, _default$1 as NotForm, NotFormInstance, NotFormProps, NotFormSlots, ObjectSchema, Paths, UseNotFormConfig, ValidationMode, ValidationTrigger, useNotForm };
333
+ //#region src/types/not-message.d.ts
334
+ /** Props for the `NotMessage` component. */
335
+ type NotMessageProps = {
336
+ /** The name/path of the field whose error message should be displayed */path: string; /** HTML Tag `NotMessage` should render as - default is `span`. */
337
+ as?: string;
338
+ /**
339
+ * Explicit form instance override.
340
+ * Takes priority over the instance provided by a `NotForm` ancestor.
341
+ * Required when using `NotMessage` outside of a `NotForm` (singleton fields).
342
+ *
343
+ * ```vue
344
+ * <NotMessage :form="form" path="email" />
345
+ * ```
346
+ */
347
+ form?: NotFormInstance<any>;
348
+ };
349
+ /** Everything available inside the `NotMessage` default slot. */
350
+ type NotMessageSlotProps = {
351
+ /** The first active validation error message for the specified field */message?: string; /** Attributes passed to the `NotMessage` component */
352
+ attributes?: ReturnType<typeof useAttrs>;
353
+ };
354
+ /** Slots for the `NotMessage` component. */
355
+ type NotMessageSlots = {
356
+ /** The default slot receives the error message context for custom rendering */default: (props: NotMessageSlotProps) => [];
357
+ };
358
+ //#endregion
359
+ //#region src/components/not-message.vue.d.ts
360
+ type __VLS_Slots = NotMessageSlots;
361
+ declare const __VLS_base: _$vue.DefineComponent<NotMessageProps, {}, {}, {}, {}, _$vue.ComponentOptionsMixin, _$vue.ComponentOptionsMixin, {}, string, _$vue.PublicProps, Readonly<NotMessageProps> & Readonly<{}>, {
362
+ as: string;
363
+ }, {}, {}, {}, string, _$vue.ComponentProvideOptions, false, {}, any>;
364
+ declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
365
+ declare const _default$2: typeof __VLS_export;
366
+ type __VLS_WithSlots<T, S> = T & {
367
+ new (): {
368
+ $slots: S;
369
+ };
370
+ };
371
+ //#endregion
372
+ export { ArraySchema, DeepPartial, _default as NotField, NotFieldEvents, NotFieldProps, NotFieldSlotProps, NotFieldSlots, _default$1 as NotForm, NotFormInstance, NotFormProps, NotFormSlots, _default$2 as NotMessage, NotMessageProps, NotMessageSlotProps, NotMessageSlots, ObjectSchema, Paths, UseNotFormConfig, ValidationMode, ValidationTrigger, useNotForm };
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { computed, createElementBlock, defineComponent, guardReactiveProps, inject, markRaw, nextTick, normalizeProps, onMounted, openBlock, provide, reactive, ref, renderSlot, toValue, unref, useAttrs } from "vue";
1
+ import { computed, createBlock, createElementBlock, createTextVNode, defineComponent, guardReactiveProps, inject, markRaw, nextTick, normalizeProps, onMounted, openBlock, provide, reactive, ref, renderSlot, resolveDynamicComponent, toDisplayString, toValue, unref, useAttrs, vShow, withCtx, withDirectives } from "vue";
2
2
  import { klona } from "klona/full";
3
3
  import { dequal } from "dequal";
4
4
  import { deepKeys, deleteProperty, getProperty, hasProperty, parsePath, setProperty } from "dot-prop";
@@ -365,4 +365,41 @@ var not_field_default = /* @__PURE__ */ defineComponent({
365
365
  }
366
366
  });
367
367
  //#endregion
368
- export { not_field_default as NotField, not_form_default as NotForm, useNotForm };
368
+ //#region src/components/not-message.vue
369
+ var not_message_default = /* @__PURE__ */ defineComponent({
370
+ inheritAttrs: false,
371
+ __name: "not-message",
372
+ props: {
373
+ path: {
374
+ type: String,
375
+ required: true
376
+ },
377
+ as: {
378
+ type: String,
379
+ required: false,
380
+ default: "span"
381
+ },
382
+ form: {
383
+ type: null,
384
+ required: false
385
+ }
386
+ },
387
+ setup(__props) {
388
+ const attributes = useAttrs();
389
+ const props = __props;
390
+ const form = useNotFormInstance(props.form);
391
+ const message = computed(() => form.errorsMap.value[props.path]);
392
+ const slotProps = computed(() => ({
393
+ message: message.value,
394
+ attributes
395
+ }));
396
+ return (_ctx, _cache) => {
397
+ return renderSlot(_ctx.$slots, "default", normalizeProps(guardReactiveProps(slotProps.value)), () => [withDirectives((openBlock(), createBlock(resolveDynamicComponent(props.as), normalizeProps(guardReactiveProps(unref(attributes))), {
398
+ default: withCtx(() => [createTextVNode(toDisplayString(message.value), 1)]),
399
+ _: 1
400
+ }, 16)), [[vShow, message.value]])]);
401
+ };
402
+ }
403
+ });
404
+ //#endregion
405
+ export { not_field_default as NotField, not_form_default as NotForm, not_message_default as NotMessage, useNotForm };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "notform",
3
- "version": "2.0.0-alpha.4",
3
+ "version": "2.0.0-alpha.5",
4
4
  "type": "module",
5
5
  "private": false,
6
6
  "description": "Vue Forms Without the Friction",