@sfxcode/nuxt-ui-formkit 1.2.1 → 1.2.3

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.
Files changed (44) hide show
  1. package/README.md +24 -0
  2. package/dist/module.json +1 -1
  3. package/dist/module.mjs +1 -1
  4. package/dist/runtime/components/FUAutoForm.d.vue.ts +65 -0
  5. package/dist/runtime/components/FUAutoForm.vue +59 -0
  6. package/dist/runtime/components/FUAutoForm.vue.d.ts +65 -0
  7. package/dist/runtime/components/FUDataEdit.d.vue.ts +11 -1
  8. package/dist/runtime/components/FUDataEdit.vue +13 -2
  9. package/dist/runtime/components/FUDataEdit.vue.d.ts +11 -1
  10. package/dist/runtime/components/FUDataView.d.vue.ts +1 -1
  11. package/dist/runtime/components/FUDataView.vue.d.ts +1 -1
  12. package/dist/runtime/composables/useFormKitAutoForm.d.ts +38 -0
  13. package/dist/runtime/composables/useFormKitAutoForm.js +349 -0
  14. package/dist/runtime/composables/useFormKitForm.d.ts +15 -0
  15. package/dist/runtime/composables/useFormKitForm.js +44 -0
  16. package/dist/runtime/composables/useFormKitMultiStep.d.ts +5 -0
  17. package/dist/runtime/composables/useFormKitMultiStep.js +65 -0
  18. package/dist/runtime/composables/useFormKitRepeater.d.ts +4 -0
  19. package/dist/runtime/composables/useFormKitRepeater.js +138 -0
  20. package/dist/runtime/composables/useFormKitStandardSchema.d.ts +20 -0
  21. package/dist/runtime/composables/useFormKitStandardSchema.js +68 -0
  22. package/dist/runtime/formkit/createNuxtUiFormkitConfig.d.ts +19 -0
  23. package/dist/runtime/formkit/createNuxtUiFormkitConfig.js +12 -0
  24. package/dist/runtime/formkit/createNuxtUiFormkitConfig.mjs +12 -0
  25. package/dist/runtime/formkit/definitions/index.d.ts +3 -0
  26. package/dist/runtime/formkit/definitions/index.js +4 -0
  27. package/dist/runtime/formkit/definitions/index.mjs +4 -0
  28. package/dist/runtime/formkit/definitions/multiStep.d.ts +3 -0
  29. package/dist/runtime/formkit/definitions/multiStep.js +90 -0
  30. package/dist/runtime/formkit/definitions/multiStep.mjs +90 -0
  31. package/dist/runtime/formkit/definitions/repeater.js +3 -119
  32. package/dist/runtime/formkit/definitions/repeater.mjs +3 -119
  33. package/dist/runtime/formkit/index.d.ts +10 -0
  34. package/dist/runtime/formkit/index.js +1 -0
  35. package/dist/runtime/formkit/index.mjs +1 -0
  36. package/dist/runtime/formkit/plugins/index.d.ts +1 -0
  37. package/dist/runtime/formkit/plugins/index.js +1 -0
  38. package/dist/runtime/formkit/plugins/index.mjs +1 -0
  39. package/dist/runtime/plugin.js +2 -1
  40. package/dist/runtime/utils/dateValueConversion.d.ts +8 -7
  41. package/dist/runtime/utils/dateValueConversion.js +1 -1
  42. package/dist/runtime/utils/standardSchemaErrors.d.ts +14 -0
  43. package/dist/runtime/utils/standardSchemaErrors.js +15 -0
  44. package/package.json +6 -2
package/README.md CHANGED
@@ -43,6 +43,10 @@ FormKit Nuxt UI bridges the gap between [FormKit](https://formkit.com/)'s powerf
43
43
  🔁 **Repeater Component** - Dynamic repeatable form sections
44
44
  - `nuxtUIRepeater` - Create dynamic lists with add, remove, clone, and reorder functionality
45
45
 
46
+ 🧭 **Multi-Step Forms** - Wizard-style forms with tab navigation and validation gating
47
+ - `nuxtUIMultiStep` - Tab-strip wizard container built on `@formkit/addons`' `createMultiStepPlugin`
48
+ - `nuxtUIStep` - A single step's content, with Nuxt UI-styled previous/next actions
49
+
46
50
  📊 **6 Output Components** - Display-only components for read-only data
47
51
  - `nuxtUIOutputBoolean` - Boolean display with custom icons
48
52
  - `nuxtUIOutputDate` - Formatted date/time display
@@ -55,11 +59,22 @@ FormKit Nuxt UI bridges the gap between [FormKit](https://formkit.com/)'s powerf
55
59
  - `FUDataEdit` - Edit forms with schema-based configuration
56
60
  - `FUDataView` - Read-only data display with schema support
57
61
  - `FUDataDebug` - Development tool for form debugging
62
+ - `FUAutoForm` - Schema-free forms: inputs inferred from your data's value shapes, or a Valibot/Zod schema, with an override map for fine-tuning
63
+
64
+ 🛡️ **Standard Schema Validation** - Validate against Zod/Valibot/ArkType instead of hand-written validation strings
65
+ - `FUDataEdit`'s `standardSchema` prop, or `useFormKitForm`'s `standardSchema` option - errors land on the exact field (including inside a repeater row), respecting each field's own validation-visibility timing
66
+
67
+ ⚙️ **Config Helper** - One-line `formkit.config.ts` setup
68
+ - `createNuxtUiFormkitConfig` - Assembles all `nuxtUIXxx` inputs/outputs and this module's plugins into `{ inputs, plugins }` you spread into your own config
58
69
 
59
70
  🔧 **Composables & Utilities** - Reusable form logic
60
71
  - `useFormKitSchema` - Schema-based form generation with element builders
61
72
  - `useFormKitInput` - Input component utilities and prop handling
62
73
  - `useFormKitOutput` - Output component utilities and prop handling
74
+ - `useFormKitRepeater` - Repeater insert/remove/clone/move/drag handlers
75
+ - `useFormKitMultiStep` - Multi-step tab-item mapping and navigation bridging
76
+ - `useFormKitForm` - Submit/reset/error-management wrapper for a form's imperative APIs, callable from outside the form
77
+ - `useFormKitAutoForm` - Schema inference from data value shapes, Valibot, or Zod schemas (`inferFormSchema`/`inferFormSchemaFromValibot`/`inferFormSchemaFromZod`)
63
78
  - `colorConverter` - Color format conversion utilities
64
79
  - `durationConverter` - Duration format conversion utilities
65
80
 
@@ -321,6 +336,15 @@ The playground includes comprehensive examples for all components:
321
336
  - [Repeater](./playground/app/pages/form/repeater-sample.vue)
322
337
  - [Drag-and-Drop Repeater](./playground/app/pages/form/repeater-drag.vue)
323
338
 
339
+ ### Multi-Step
340
+ - [Multi-Step Form](./playground/app/pages/form/multi-step.vue)
341
+
342
+ ### Form Composable
343
+ - [useFormKitForm](./playground/app/pages/form/form-composable.vue)
344
+
345
+ ### Standard Schema Validation
346
+ - [Standard Schema Validation](./playground/app/pages/form/standard-schema.vue)
347
+
324
348
  ## Development
325
349
 
326
350
  <details>
package/dist/module.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "compatibility": {
5
5
  "nuxt": ">=4.0.0"
6
6
  },
7
- "version": "1.2.1",
7
+ "version": "1.2.3",
8
8
  "builder": {
9
9
  "@nuxt/module-builder": "1.0.2",
10
10
  "unbuild": "3.6.1"
package/dist/module.mjs CHANGED
@@ -15,7 +15,7 @@ const module$1 = defineNuxtModule({
15
15
  addPlugin(resolver.resolve("./runtime/plugin"));
16
16
  addImportsDir(resolver.resolve("./runtime/composables"));
17
17
  const NPM_PCK_FORMKIT_NUXT_UI = "@sfxcode/nuxt-ui-formkit";
18
- const componentNames = ["FUDataView", "FUDataEdit", "FUDataDebug"];
18
+ const componentNames = ["FUDataView", "FUDataEdit", "FUDataDebug", "FUAutoForm"];
19
19
  componentNames.forEach(
20
20
  (name) => addComponent({
21
21
  name,
@@ -0,0 +1,65 @@
1
+ import type { FormKitSchemaDefinition } from '@formkit/core';
2
+ import type { PropType } from 'vue';
3
+ import type { AutoFormOverrides, ValibotLikeSchema, ZodLikeSchema } from '../composables/useFormKitAutoForm.js';
4
+ declare var __VLS_10: string, __VLS_11: any;
5
+ type __VLS_Slots = {} & {
6
+ [K in NonNullable<typeof __VLS_10>]?: (props: typeof __VLS_11) => any;
7
+ };
8
+ declare const __VLS_base: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
9
+ data: {
10
+ type: ObjectConstructor;
11
+ default: null;
12
+ };
13
+ overrides: {
14
+ type: PropType<AutoFormOverrides>;
15
+ default: undefined;
16
+ };
17
+ valibotSchema: {
18
+ type: PropType<ValibotLikeSchema>;
19
+ default: undefined;
20
+ };
21
+ zodSchema: {
22
+ type: PropType<ZodLikeSchema>;
23
+ default: undefined;
24
+ };
25
+ modelValue: {
26
+ type: PropType<FormKitSchemaDefinition>;
27
+ };
28
+ }>, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
29
+ "update:modelValue": (value: FormKitSchemaDefinition | undefined) => any;
30
+ }, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
31
+ data: {
32
+ type: ObjectConstructor;
33
+ default: null;
34
+ };
35
+ overrides: {
36
+ type: PropType<AutoFormOverrides>;
37
+ default: undefined;
38
+ };
39
+ valibotSchema: {
40
+ type: PropType<ValibotLikeSchema>;
41
+ default: undefined;
42
+ };
43
+ zodSchema: {
44
+ type: PropType<ZodLikeSchema>;
45
+ default: undefined;
46
+ };
47
+ modelValue: {
48
+ type: PropType<FormKitSchemaDefinition>;
49
+ };
50
+ }>> & Readonly<{
51
+ "onUpdate:modelValue"?: ((value: FormKitSchemaDefinition | undefined) => any) | undefined;
52
+ }>, {
53
+ data: Record<string, any>;
54
+ overrides: AutoFormOverrides;
55
+ valibotSchema: ValibotLikeSchema;
56
+ zodSchema: ZodLikeSchema;
57
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
58
+ declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
59
+ declare const _default: typeof __VLS_export;
60
+ export default _default;
61
+ type __VLS_WithSlots<T, S> = T & {
62
+ new (): {
63
+ $slots: S;
64
+ };
65
+ };
@@ -0,0 +1,59 @@
1
+ <script setup>
2
+ import { ref, watch } from "vue";
3
+ import { inferFormSchema, inferFormSchemaFromValibot, inferFormSchemaFromZod } from "../composables/useFormKitAutoForm";
4
+ import FUDataEdit from "./FUDataEdit.vue";
5
+ defineOptions({ inheritAttrs: false });
6
+ const props = defineProps({
7
+ data: {
8
+ type: Object,
9
+ default: null
10
+ },
11
+ overrides: {
12
+ type: Object,
13
+ default: void 0
14
+ },
15
+ valibotSchema: {
16
+ type: Object,
17
+ default: void 0
18
+ },
19
+ zodSchema: {
20
+ type: Object,
21
+ default: void 0
22
+ }
23
+ });
24
+ const formData = defineModel({ type: [Object, String, Array] });
25
+ if (!formData.value && props.data) {
26
+ formData.value = props.data;
27
+ }
28
+ function buildSchema(data) {
29
+ if (props.valibotSchema) {
30
+ return inferFormSchemaFromValibot(props.valibotSchema, props.overrides);
31
+ }
32
+ if (props.zodSchema) {
33
+ return inferFormSchemaFromZod(props.zodSchema, props.overrides);
34
+ }
35
+ return inferFormSchema(data ?? formData.value ?? {}, props.overrides);
36
+ }
37
+ const formSchema = ref(buildSchema(props.data));
38
+ watch([() => props.data, () => props.overrides, () => props.valibotSchema, () => props.zodSchema], ([data]) => {
39
+ formSchema.value = buildSchema(data);
40
+ });
41
+ </script>
42
+
43
+ <template>
44
+ <FUDataEdit
45
+ v-bind="$attrs"
46
+ v-model="formData"
47
+ :schema="formSchema"
48
+ >
49
+ <template
50
+ v-for="(_, name) in $slots"
51
+ #[name]="slotProps"
52
+ >
53
+ <slot
54
+ :name="name"
55
+ v-bind="slotProps ?? {}"
56
+ />
57
+ </template>
58
+ </FUDataEdit>
59
+ </template>
@@ -0,0 +1,65 @@
1
+ import type { FormKitSchemaDefinition } from '@formkit/core';
2
+ import type { PropType } from 'vue';
3
+ import type { AutoFormOverrides, ValibotLikeSchema, ZodLikeSchema } from '../composables/useFormKitAutoForm.js';
4
+ declare var __VLS_10: string, __VLS_11: any;
5
+ type __VLS_Slots = {} & {
6
+ [K in NonNullable<typeof __VLS_10>]?: (props: typeof __VLS_11) => any;
7
+ };
8
+ declare const __VLS_base: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
9
+ data: {
10
+ type: ObjectConstructor;
11
+ default: null;
12
+ };
13
+ overrides: {
14
+ type: PropType<AutoFormOverrides>;
15
+ default: undefined;
16
+ };
17
+ valibotSchema: {
18
+ type: PropType<ValibotLikeSchema>;
19
+ default: undefined;
20
+ };
21
+ zodSchema: {
22
+ type: PropType<ZodLikeSchema>;
23
+ default: undefined;
24
+ };
25
+ modelValue: {
26
+ type: PropType<FormKitSchemaDefinition>;
27
+ };
28
+ }>, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
29
+ "update:modelValue": (value: FormKitSchemaDefinition | undefined) => any;
30
+ }, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
31
+ data: {
32
+ type: ObjectConstructor;
33
+ default: null;
34
+ };
35
+ overrides: {
36
+ type: PropType<AutoFormOverrides>;
37
+ default: undefined;
38
+ };
39
+ valibotSchema: {
40
+ type: PropType<ValibotLikeSchema>;
41
+ default: undefined;
42
+ };
43
+ zodSchema: {
44
+ type: PropType<ZodLikeSchema>;
45
+ default: undefined;
46
+ };
47
+ modelValue: {
48
+ type: PropType<FormKitSchemaDefinition>;
49
+ };
50
+ }>> & Readonly<{
51
+ "onUpdate:modelValue"?: ((value: FormKitSchemaDefinition | undefined) => any) | undefined;
52
+ }>, {
53
+ data: Record<string, any>;
54
+ overrides: AutoFormOverrides;
55
+ valibotSchema: ValibotLikeSchema;
56
+ zodSchema: ZodLikeSchema;
57
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
58
+ declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
59
+ declare const _default: typeof __VLS_export;
60
+ export default _default;
61
+ type __VLS_WithSlots<T, S> = T & {
62
+ new (): {
63
+ $slots: S;
64
+ };
65
+ };
@@ -1,4 +1,5 @@
1
1
  import type { FormKitSchemaDefinition } from '@formkit/core';
2
+ import type { StandardSchemaV1 } from '@standard-schema/spec';
2
3
  import type { PropType } from 'vue';
3
4
  declare var __VLS_15: {}, __VLS_18: {}, __VLS_26: {};
4
5
  type __VLS_Slots = {} & {
@@ -21,6 +22,10 @@ declare const __VLS_base: import("vue").DefineComponent<import("vue").ExtractPro
21
22
  type: PropType<FormKitSchemaDefinition>;
22
23
  default: null;
23
24
  };
25
+ standardSchema: {
26
+ type: PropType<StandardSchemaV1>;
27
+ default: null;
28
+ };
24
29
  formClass: {
25
30
  type: StringConstructor;
26
31
  default: string;
@@ -91,6 +96,10 @@ declare const __VLS_base: import("vue").DefineComponent<import("vue").ExtractPro
91
96
  type: PropType<FormKitSchemaDefinition>;
92
97
  default: null;
93
98
  };
99
+ standardSchema: {
100
+ type: PropType<StandardSchemaV1>;
101
+ default: null;
102
+ };
94
103
  formClass: {
95
104
  type: StringConstructor;
96
105
  default: string;
@@ -149,9 +158,10 @@ declare const __VLS_base: import("vue").DefineComponent<import("vue").ExtractPro
149
158
  }>> & Readonly<{
150
159
  "onUpdate:modelValue"?: ((value: FormKitSchemaDefinition | undefined) => any) | undefined;
151
160
  }>, {
161
+ schema: FormKitSchemaDefinition;
152
162
  data: Record<string, any>;
153
163
  id: string;
154
- schema: FormKitSchemaDefinition;
164
+ standardSchema: StandardSchemaV1<unknown, unknown>;
155
165
  formClass: string;
156
166
  actionsClass: string;
157
167
  submitSeverity: string;
@@ -1,7 +1,8 @@
1
1
  <script setup>
2
2
  import { reset } from "@formkit/core";
3
- import { FormKit, FormKitMessages, FormKitSchema } from "@formkit/vue";
4
- import { ref, watch } from "vue";
3
+ import { FormKit, FormKitMessages, FormKitSchema, useFormKitContextById } from "@formkit/vue";
4
+ import { onScopeDispose, ref, watch } from "vue";
5
+ import { attachStandardSchema } from "../composables/useFormKitStandardSchema";
5
6
  import FUDataDebug from "./FUDataDebug.vue";
6
7
  const props = defineProps({
7
8
  id: {
@@ -16,6 +17,10 @@ const props = defineProps({
16
17
  type: Object,
17
18
  default: null
18
19
  },
20
+ standardSchema: {
21
+ type: Object,
22
+ default: null
23
+ },
19
24
  formClass: {
20
25
  type: String,
21
26
  default: ""
@@ -70,6 +75,12 @@ const props = defineProps({
70
75
  }
71
76
  });
72
77
  const emit = defineEmits(["dataSaved", "onReset"]);
78
+ let detachStandardSchema;
79
+ useFormKitContextById(props.id, (context) => {
80
+ if (props.standardSchema)
81
+ detachStandardSchema = attachStandardSchema(context.node, props.standardSchema);
82
+ });
83
+ onScopeDispose(() => detachStandardSchema?.());
73
84
  const formSchema = ref(props.schema);
74
85
  const formData = defineModel({ type: [Object, String, Array] });
75
86
  watch(() => props.schema, (newSchema) => {
@@ -1,4 +1,5 @@
1
1
  import type { FormKitSchemaDefinition } from '@formkit/core';
2
+ import type { StandardSchemaV1 } from '@standard-schema/spec';
2
3
  import type { PropType } from 'vue';
3
4
  declare var __VLS_15: {}, __VLS_18: {}, __VLS_26: {};
4
5
  type __VLS_Slots = {} & {
@@ -21,6 +22,10 @@ declare const __VLS_base: import("vue").DefineComponent<import("vue").ExtractPro
21
22
  type: PropType<FormKitSchemaDefinition>;
22
23
  default: null;
23
24
  };
25
+ standardSchema: {
26
+ type: PropType<StandardSchemaV1>;
27
+ default: null;
28
+ };
24
29
  formClass: {
25
30
  type: StringConstructor;
26
31
  default: string;
@@ -91,6 +96,10 @@ declare const __VLS_base: import("vue").DefineComponent<import("vue").ExtractPro
91
96
  type: PropType<FormKitSchemaDefinition>;
92
97
  default: null;
93
98
  };
99
+ standardSchema: {
100
+ type: PropType<StandardSchemaV1>;
101
+ default: null;
102
+ };
94
103
  formClass: {
95
104
  type: StringConstructor;
96
105
  default: string;
@@ -149,9 +158,10 @@ declare const __VLS_base: import("vue").DefineComponent<import("vue").ExtractPro
149
158
  }>> & Readonly<{
150
159
  "onUpdate:modelValue"?: ((value: FormKitSchemaDefinition | undefined) => any) | undefined;
151
160
  }>, {
161
+ schema: FormKitSchemaDefinition;
152
162
  data: Record<string, any>;
153
163
  id: string;
154
- schema: FormKitSchemaDefinition;
164
+ standardSchema: StandardSchemaV1<unknown, unknown>;
155
165
  formClass: string;
156
166
  actionsClass: string;
157
167
  submitSeverity: string;
@@ -57,8 +57,8 @@ declare const __VLS_base: import("vue").DefineComponent<import("vue").ExtractPro
57
57
  }>> & Readonly<{
58
58
  "onUpdate:modelValue"?: ((value: FormKitSchemaDefinition | undefined) => any) | undefined;
59
59
  }>, {
60
- data: Record<string, any>;
61
60
  schema: FormKitSchemaDefinition;
61
+ data: Record<string, any>;
62
62
  formClass: string;
63
63
  debugData: boolean;
64
64
  debugSchema: boolean;
@@ -57,8 +57,8 @@ declare const __VLS_base: import("vue").DefineComponent<import("vue").ExtractPro
57
57
  }>> & Readonly<{
58
58
  "onUpdate:modelValue"?: ((value: FormKitSchemaDefinition | undefined) => any) | undefined;
59
59
  }>, {
60
- data: Record<string, any>;
61
60
  schema: FormKitSchemaDefinition;
61
+ data: Record<string, any>;
62
62
  formClass: string;
63
63
  debugData: boolean;
64
64
  debugSchema: boolean;
@@ -0,0 +1,38 @@
1
+ import type { FormKitSchemaNode } from '@formkit/core';
2
+ export type AutoFormOverrides = Record<string, Record<string, unknown> | boolean>;
3
+ export declare function inferFormSchema(data: Record<string, unknown>, overrides?: AutoFormOverrides): FormKitSchemaNode[];
4
+ export interface ValibotLikePipeEntry {
5
+ kind: string;
6
+ type: string;
7
+ requirement?: unknown;
8
+ }
9
+ export interface ValibotLikeSchema {
10
+ kind: 'schema';
11
+ type: string;
12
+ entries?: Record<string, ValibotLikeSchema>;
13
+ item?: ValibotLikeSchema;
14
+ wrapped?: ValibotLikeSchema;
15
+ default?: unknown;
16
+ pipe?: readonly ValibotLikePipeEntry[];
17
+ }
18
+ export declare function inferFormSchemaFromValibot(schema: object, overrides?: AutoFormOverrides): FormKitSchemaNode[];
19
+ export interface ZodLikeSchema {
20
+ type: string;
21
+ shape?: Record<string, ZodLikeSchema>;
22
+ element?: ZodLikeSchema;
23
+ minLength?: number | null;
24
+ maxLength?: number | null;
25
+ minValue?: number | null;
26
+ maxValue?: number | null;
27
+ format?: string | null;
28
+ unwrap?: () => ZodLikeSchema;
29
+ def?: {
30
+ defaultValue?: unknown;
31
+ };
32
+ }
33
+ export declare function inferFormSchemaFromZod(schema: object, overrides?: AutoFormOverrides): FormKitSchemaNode[];
34
+ export declare function useFormKitAutoForm(): {
35
+ inferFormSchema: typeof inferFormSchema;
36
+ inferFormSchemaFromValibot: typeof inferFormSchemaFromValibot;
37
+ inferFormSchemaFromZod: typeof inferFormSchemaFromZod;
38
+ };