@sfxcode/formkit-nuxt-ui 0.7.3 → 0.7.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
@@ -16,6 +16,8 @@ FormKit Nuxt UI bridges the gap between [FormKit](https://formkit.com/)'s powerf
16
16
  - [📖  FormKit Documentation](https://formkit.com/)
17
17
  - [🎨  Nuxt UI Documentation](https://ui.nuxt.com/)
18
18
 
19
+ <img src="./formkit-nuxt-ui.png" alt="FormKit Nuxt UI Screenshot" width="70%" />
20
+
19
21
  ## Features
20
22
 
21
23
  ✨ **16 Input Components** - Complete set of FormKit-wrapped Nuxt UI input components
package/dist/module.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "compatibility": {
5
5
  "nuxt": ">=4.0.0"
6
6
  },
7
- "version": "0.7.3",
7
+ "version": "0.7.5",
8
8
  "builder": {
9
9
  "@nuxt/module-builder": "1.0.2",
10
10
  "unbuild": "3.6.1"
@@ -1,8 +1,8 @@
1
1
  import type { FormKitSchemaDefinition } from '@formkit/core';
2
2
  import type { PropType } from 'vue';
3
- declare var __VLS_6: {};
3
+ declare var __VLS_12: {};
4
4
  type __VLS_Slots = {} & {
5
- default?: (props: typeof __VLS_6) => any;
5
+ default?: (props: typeof __VLS_12) => any;
6
6
  };
7
7
  declare const __VLS_base: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
8
8
  data: {
@@ -30,11 +30,19 @@ if (props.data) {
30
30
  </script>
31
31
 
32
32
  <template>
33
- <FormKitSchema
34
- v-if="schema"
35
- :schema="schema"
36
- :data="formData"
37
- />
33
+ <FormKit
34
+ v-model="formData"
35
+ :actions="false"
36
+ :form-class="formClass"
37
+ type="form"
38
+ >
39
+ <FormKitSchema
40
+ v-if="schema"
41
+ :schema="schema"
42
+ :data="formData"
43
+ />
44
+ </FormKit>
45
+
38
46
  <slot />
39
47
  <FuDataDebug
40
48
  v-if="debugData"
@@ -1,8 +1,8 @@
1
1
  import type { FormKitSchemaDefinition } from '@formkit/core';
2
2
  import type { PropType } from 'vue';
3
- declare var __VLS_6: {};
3
+ declare var __VLS_12: {};
4
4
  type __VLS_Slots = {} & {
5
- default?: (props: typeof __VLS_6) => any;
5
+ default?: (props: typeof __VLS_12) => any;
6
6
  };
7
7
  declare const __VLS_base: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
8
8
  data: {
@@ -6,7 +6,7 @@ const props = defineProps({
6
6
  required: true
7
7
  }
8
8
  });
9
- const { handleInput, handleChange, styleClass, modelValue, color } = useFormKitInput(props.context);
9
+ const { handleInput, handleChange, styleClass, modelValue, color, validSlotNames } = useFormKitInput(props.context);
10
10
  </script>
11
11
 
12
12
  <template>
@@ -29,5 +29,16 @@ const { handleInput, handleChange, styleClass, modelValue, color } = useFormKitI
29
29
  :ui="context.ui"
30
30
  @change="handleChange"
31
31
  @update:model-value="handleInput"
32
- />
32
+ >
33
+ <template
34
+ v-for="slotName in validSlotNames"
35
+ :key="slotName"
36
+ #[slotName]="slotProps"
37
+ >
38
+ <component
39
+ :is="context?.slots[slotName]"
40
+ v-bind="{ ...context, ...slotProps }"
41
+ />
42
+ </template>
43
+ </UCheckbox>
33
44
  </template>
@@ -6,7 +6,7 @@ const props = defineProps({
6
6
  required: true
7
7
  }
8
8
  });
9
- const { handleInput, handleChange, styleClass, color, modelValue, items } = useFormKitInput(props.context);
9
+ const { handleInput, handleChange, styleClass, color, modelValue, items, validSlotNames } = useFormKitInput(props.context);
10
10
  </script>
11
11
 
12
12
  <template>
@@ -30,5 +30,16 @@ const { handleInput, handleChange, styleClass, color, modelValue, items } = useF
30
30
  :name="context.name"
31
31
  @change="handleChange"
32
32
  @update:model-value="handleInput"
33
- />
33
+ >
34
+ <template
35
+ v-for="slotName in validSlotNames"
36
+ :key="slotName"
37
+ #[slotName]="slotProps"
38
+ >
39
+ <component
40
+ :is="context?.slots[slotName]"
41
+ v-bind="{ ...context, ...slotProps }"
42
+ />
43
+ </template>
44
+ </UCheckboxGroup>
34
45
  </template>
@@ -6,7 +6,7 @@ const props = defineProps({
6
6
  required: true
7
7
  }
8
8
  });
9
- const { handleInput, handleChange, isInvalid, styleClass, color, modelValue } = useFormKitInput(props.context);
9
+ const { handleInput, handleChange, isInvalid, styleClass, color, modelValue, validSlotNames } = useFormKitInput(props.context);
10
10
  </script>
11
11
 
12
12
  <template>
@@ -46,5 +46,16 @@ const { handleInput, handleChange, isInvalid, styleClass, color, modelValue } =
46
46
  :ui="context.ui"
47
47
  @change="handleChange"
48
48
  @update:model-value="handleInput"
49
- />
49
+ >
50
+ <template
51
+ v-for="slotName in validSlotNames"
52
+ :key="slotName"
53
+ #[slotName]="slotProps"
54
+ >
55
+ <component
56
+ :is="context?.slots[slotName]"
57
+ v-bind="{ ...context, ...slotProps }"
58
+ />
59
+ </template>
60
+ </UInput>
50
61
  </template>
@@ -6,7 +6,7 @@ const props = defineProps({
6
6
  required: true
7
7
  }
8
8
  });
9
- const { handleInput, handleChange, isInvalid, styleClass, color, modelValue } = useFormKitInput(props.context);
9
+ const { handleInput, handleChange, isInvalid, styleClass, color, modelValue, validSlotNames } = useFormKitInput(props.context);
10
10
  </script>
11
11
 
12
12
  <template>
@@ -48,5 +48,16 @@ const { handleInput, handleChange, isInvalid, styleClass, color, modelValue } =
48
48
  :ui="context.ui"
49
49
  @change="handleChange"
50
50
  @update:model-value="handleInput"
51
- />
51
+ >
52
+ <template
53
+ v-for="slotName in validSlotNames"
54
+ :key="slotName"
55
+ #[slotName]="slotProps"
56
+ >
57
+ <component
58
+ :is="context?.slots[slotName]"
59
+ v-bind="{ ...context, ...slotProps }"
60
+ />
61
+ </template>
62
+ </UInputDate>
52
63
  </template>
@@ -6,7 +6,7 @@ const props = defineProps({
6
6
  required: true
7
7
  }
8
8
  });
9
- const { handleInput, handleChange, isInvalid, styleClass, color, modelValue, items } = useFormKitInput(props.context);
9
+ const { handleInput, handleChange, isInvalid, styleClass, color, modelValue, items, validSlotNames } = useFormKitInput(props.context);
10
10
  </script>
11
11
 
12
12
  <template>
@@ -61,5 +61,16 @@ const { handleInput, handleChange, isInvalid, styleClass, color, modelValue, ite
61
61
  :ui="context.ui"
62
62
  @change="handleChange"
63
63
  @update:model-value="handleInput"
64
- />
64
+ >
65
+ <template
66
+ v-for="slotName in validSlotNames"
67
+ :key="slotName"
68
+ #[slotName]="slotProps"
69
+ >
70
+ <component
71
+ :is="context?.slots[slotName]"
72
+ v-bind="{ ...context, ...slotProps }"
73
+ />
74
+ </template>
75
+ </UInputMenu>
65
76
  </template>
@@ -6,7 +6,7 @@ const props = defineProps({
6
6
  required: true
7
7
  }
8
8
  });
9
- const { handleInput, handleChange, isInvalid, styleClass, color, modelValue } = useFormKitInput(props.context);
9
+ const { handleInput, handleChange, isInvalid, styleClass, color, modelValue, validSlotNames } = useFormKitInput(props.context);
10
10
  </script>
11
11
 
12
12
  <template>
@@ -45,5 +45,16 @@ const { handleInput, handleChange, isInvalid, styleClass, color, modelValue } =
45
45
  :ui="context.ui"
46
46
  @change="handleChange"
47
47
  @update:model-value="handleInput"
48
- />
48
+ >
49
+ <template
50
+ v-for="slotName in validSlotNames"
51
+ :key="slotName"
52
+ #[slotName]="slotProps"
53
+ >
54
+ <component
55
+ :is="context?.slots[slotName]"
56
+ v-bind="{ ...context, ...slotProps }"
57
+ />
58
+ </template>
59
+ </UInputNumber>
49
60
  </template>
@@ -6,7 +6,7 @@ const props = defineProps({
6
6
  required: true
7
7
  }
8
8
  });
9
- const { handleInput, handleChange, isInvalid, styleClass, color, modelValue } = useFormKitInput(props.context);
9
+ const { handleInput, handleChange, isInvalid, styleClass, color, modelValue, validSlotNames } = useFormKitInput(props.context);
10
10
  </script>
11
11
 
12
12
  <template>
@@ -49,5 +49,16 @@ const { handleInput, handleChange, isInvalid, styleClass, color, modelValue } =
49
49
  :ui="context.ui"
50
50
  @change="handleChange"
51
51
  @update:model-value="handleInput"
52
- />
52
+ >
53
+ <template
54
+ v-for="slotName in validSlotNames"
55
+ :key="slotName"
56
+ #[slotName]="slotProps"
57
+ >
58
+ <component
59
+ :is="context?.slots[slotName]"
60
+ v-bind="{ ...context, ...slotProps }"
61
+ />
62
+ </template>
63
+ </UInputTags>
53
64
  </template>
@@ -6,7 +6,7 @@ const props = defineProps({
6
6
  required: true
7
7
  }
8
8
  });
9
- const { handleInput, handleChange, isInvalid, styleClass, color, modelValue } = useFormKitInput(props.context);
9
+ const { handleInput, handleChange, isInvalid, styleClass, color, modelValue, validSlotNames } = useFormKitInput(props.context);
10
10
  </script>
11
11
 
12
12
  <template>
@@ -46,5 +46,16 @@ const { handleInput, handleChange, isInvalid, styleClass, color, modelValue } =
46
46
  :ui="context.ui"
47
47
  @change="handleChange"
48
48
  @update:model-value="handleInput"
49
- />
49
+ >
50
+ <template
51
+ v-for="slotName in validSlotNames"
52
+ :key="slotName"
53
+ #[slotName]="slotProps"
54
+ >
55
+ <component
56
+ :is="context?.slots[slotName]"
57
+ v-bind="{ ...context, ...slotProps }"
58
+ />
59
+ </template>
60
+ </UInputTime>
50
61
  </template>
@@ -6,7 +6,7 @@ const props = defineProps({
6
6
  required: true
7
7
  }
8
8
  });
9
- const { handleInput, handleChange, styleClass, color, modelValue, items } = useFormKitInput(props.context);
9
+ const { handleInput, handleChange, styleClass, color, modelValue, items, validSlotNames } = useFormKitInput(props.context);
10
10
  </script>
11
11
 
12
12
  <template>
@@ -31,5 +31,16 @@ const { handleInput, handleChange, styleClass, color, modelValue, items } = useF
31
31
  :ui="context.ui"
32
32
  @change="handleChange"
33
33
  @update:model-value="handleInput"
34
- />
34
+ >
35
+ <template
36
+ v-for="slotName in validSlotNames"
37
+ :key="slotName"
38
+ #[slotName]="slotProps"
39
+ >
40
+ <component
41
+ :is="context?.slots[slotName]"
42
+ v-bind="{ ...context, ...slotProps }"
43
+ />
44
+ </template>
45
+ </URadioGroup>
35
46
  </template>
@@ -6,7 +6,7 @@ const props = defineProps({
6
6
  required: true
7
7
  }
8
8
  });
9
- const { handleInput, handleChange, isInvalid, color, styleClass, modelValue, items } = useFormKitInput(props.context);
9
+ const { handleInput, handleChange, isInvalid, color, styleClass, modelValue, items, validSlotNames } = useFormKitInput(props.context);
10
10
  </script>
11
11
 
12
12
  <template>
@@ -47,5 +47,16 @@ const { handleInput, handleChange, isInvalid, color, styleClass, modelValue, ite
47
47
  :ui="context.ui"
48
48
  @change="handleChange"
49
49
  @update:model-value="handleInput"
50
- />
50
+ >
51
+ <template
52
+ v-for="slotName in validSlotNames"
53
+ :key="slotName"
54
+ #[slotName]="slotProps"
55
+ >
56
+ <component
57
+ :is="context?.slots[slotName]"
58
+ v-bind="{ ...context, ...slotProps }"
59
+ />
60
+ </template>
61
+ </USelect>
51
62
  </template>
@@ -6,7 +6,7 @@ const props = defineProps({
6
6
  required: true
7
7
  }
8
8
  });
9
- const { handleInput, handleChange, isInvalid, styleClass, color, modelValue, items } = useFormKitInput(props.context);
9
+ const { handleInput, handleChange, isInvalid, styleClass, color, modelValue, items, validSlotNames } = useFormKitInput(props.context);
10
10
  </script>
11
11
 
12
12
  <template>
@@ -58,5 +58,16 @@ const { handleInput, handleChange, isInvalid, styleClass, color, modelValue, ite
58
58
  :ui="context.ui"
59
59
  @change="handleChange"
60
60
  @update:model-value="handleInput"
61
- />
61
+ >
62
+ <template
63
+ v-for="slotName in validSlotNames"
64
+ :key="slotName"
65
+ #[slotName]="slotProps"
66
+ >
67
+ <component
68
+ :is="context?.slots[slotName]"
69
+ v-bind="{ ...context, ...slotProps }"
70
+ />
71
+ </template>
72
+ </USelectMenu>
62
73
  </template>
@@ -6,7 +6,7 @@ const props = defineProps({
6
6
  required: true
7
7
  }
8
8
  });
9
- const { handleInput, handleChange, styleClass, color, modelValue } = useFormKitInput(props.context);
9
+ const { handleInput, handleChange, styleClass, color, modelValue, validSlotNames } = useFormKitInput(props.context);
10
10
  </script>
11
11
 
12
12
  <template>
@@ -30,5 +30,16 @@ const { handleInput, handleChange, styleClass, color, modelValue } = useFormKitI
30
30
  :ui="context.ui"
31
31
  @change="handleChange"
32
32
  @update:model-value="handleInput"
33
- />
33
+ >
34
+ <template
35
+ v-for="slotName in validSlotNames"
36
+ :key="slotName"
37
+ #[slotName]="slotProps"
38
+ >
39
+ <component
40
+ :is="context?.slots[slotName]"
41
+ v-bind="{ ...context, ...slotProps }"
42
+ />
43
+ </template>
44
+ </USwitch>
34
45
  </template>
@@ -6,7 +6,7 @@ const props = defineProps({
6
6
  required: true
7
7
  }
8
8
  });
9
- const { handleInput, handleChange, styleClass, color, isInvalid, modelValue } = useFormKitInput(props.context);
9
+ const { handleInput, handleChange, styleClass, color, isInvalid, modelValue, validSlotNames } = useFormKitInput(props.context);
10
10
  </script>
11
11
 
12
12
  <template>
@@ -46,5 +46,16 @@ const { handleInput, handleChange, styleClass, color, isInvalid, modelValue } =
46
46
  :ui="context.ui"
47
47
  @change="handleChange"
48
48
  @update:model-value="handleInput"
49
- />
49
+ >
50
+ <template
51
+ v-for="slotName in validSlotNames"
52
+ :key="slotName"
53
+ #[slotName]="slotProps"
54
+ >
55
+ <component
56
+ :is="context?.slots[slotName]"
57
+ v-bind="{ ...context, ...slotProps }"
58
+ />
59
+ </template>
60
+ </UTextarea>
50
61
  </template>
@@ -1,4 +1,9 @@
1
- import type { FormKitInputs } from '@formkit/inputs';
1
+ import type { FormKitBaseSlots, FormKitInputs } from '@formkit/inputs';
2
+ import type { CheckboxSlots, CheckboxGroupSlots, RadioGroupSlots, InputSlots, TextareaSlots, SelectSlots, SelectMenuSlots, InputDateSlots, InputMenuSlots, InputNumberSlots, InputTagsSlots, InputTimeSlots, SwitchSlots } from '@nuxt/ui';
3
+ /**
4
+ * Keeps all slots from 1st argument, add any slots from 2nd type which do not collide with the 1st's names.
5
+ */
6
+ type MergeSlots<A, B> = A & Omit<B, keyof A>;
2
7
  declare module '@formkit/inputs' {
3
8
  interface FormKitInputProps<Props extends FormKitInputs<Props>> {
4
9
  nuxtUICheckbox: {
@@ -68,4 +73,20 @@ declare module '@formkit/inputs' {
68
73
  type: 'nuxtUIOutputList';
69
74
  };
70
75
  }
76
+ interface FormKitInputSlots<Props extends FormKitInputs<Props>> {
77
+ nuxtUICheckbox: MergeSlots<FormKitBaseSlots<Props>, CheckboxSlots>;
78
+ nuxtUICheckboxGroup: MergeSlots<FormKitBaseSlots<Props>, CheckboxGroupSlots>;
79
+ nuxtUIInput: MergeSlots<FormKitBaseSlots<Props>, InputSlots>;
80
+ nuxtUIInputDate: MergeSlots<FormKitBaseSlots<Props>, InputDateSlots>;
81
+ nuxtUIInputMenu: MergeSlots<FormKitBaseSlots<Props>, InputMenuSlots>;
82
+ nuxtUIInputNumber: MergeSlots<FormKitBaseSlots<Props>, InputNumberSlots>;
83
+ nuxtUIInputTags: MergeSlots<FormKitBaseSlots<Props>, InputTagsSlots>;
84
+ nuxtUIInputTime: MergeSlots<FormKitBaseSlots<Props>, InputTimeSlots>;
85
+ nuxtUIRadioGroup: MergeSlots<FormKitBaseSlots<Props>, RadioGroupSlots>;
86
+ nuxtUISelect: MergeSlots<FormKitBaseSlots<Props>, SelectSlots>;
87
+ nuxtUISelectMenu: MergeSlots<FormKitBaseSlots<Props>, SelectMenuSlots>;
88
+ nuxtUISwitch: MergeSlots<FormKitBaseSlots<Props>, SwitchSlots>;
89
+ nuxtUITextarea: MergeSlots<FormKitBaseSlots<Props>, TextareaSlots>;
90
+ }
71
91
  }
92
+ export {};
@@ -1,2 +1,2 @@
1
- declare const _default: import("nuxt/app").Plugin<Record<string, unknown>> & import("nuxt/app").ObjectPlugin<Record<string, unknown>>;
1
+ declare const _default: import("#app").Plugin<Record<string, unknown>> & import("#app").ObjectPlugin<Record<string, unknown>>;
2
2
  export default _default;
@@ -1,5 +1,5 @@
1
1
  export function addNuxtAsteriskPlugin(node) {
2
- if (!node.props.type.startsWith("nuxtUI") || node.props.type.startsWith("UFOutput"))
2
+ if (!node.props.type.startsWith("nuxtUI") || node.props.type.startsWith("FUOutput"))
3
3
  return;
4
4
  node.on("created", () => {
5
5
  if (node.props.definition?.schema) {
@@ -5,16 +5,16 @@ export function convertColorToHex(color) {
5
5
  if (trimmedColor.startsWith("#")) {
6
6
  return normalizeHex(trimmedColor);
7
7
  }
8
- if (trimmedColor.startsWith("rgb")) {
8
+ if (trimmedColor.toLowerCase().startsWith("rgb")) {
9
9
  return rgbToHex(trimmedColor);
10
10
  }
11
- if (trimmedColor.startsWith("hsl")) {
11
+ if (trimmedColor.toLowerCase().startsWith("hsl")) {
12
12
  return hslToHex(trimmedColor);
13
13
  }
14
- if (trimmedColor.startsWith("cmyk")) {
14
+ if (trimmedColor.toLowerCase().startsWith("cmyk")) {
15
15
  return cmykToHex(trimmedColor);
16
16
  }
17
- if (trimmedColor.startsWith("lab")) {
17
+ if (trimmedColor.toLowerCase().startsWith("lab")) {
18
18
  return labToHex(trimmedColor);
19
19
  }
20
20
  if (/^[\da-f]{3,8}$/i.test(trimmedColor)) {
@@ -23,7 +23,10 @@ export function convertColorToHex(color) {
23
23
  return "#000000";
24
24
  }
25
25
  function normalizeHex(hex) {
26
- const cleaned = hex.replace("#", "");
26
+ const cleaned = hex.replace("#", "").toLowerCase();
27
+ if (!/^[\da-f]+$/i.test(cleaned) || cleaned.length === 0) {
28
+ return "#000000";
29
+ }
27
30
  if (cleaned.length === 3) {
28
31
  return `#${cleaned[0]}${cleaned[0]}${cleaned[1]}${cleaned[1]}${cleaned[2]}${cleaned[2]}`;
29
32
  }
@@ -33,10 +36,16 @@ function normalizeHex(hex) {
33
36
  if (cleaned.length === 8) {
34
37
  return `#${cleaned.substring(0, 6)}`;
35
38
  }
36
- return `#${cleaned.substring(0, 6).padEnd(6, "0")}`;
39
+ if (cleaned.length === 6) {
40
+ return `#${cleaned}`;
41
+ }
42
+ if (cleaned.length < 6) {
43
+ return `#${cleaned.padEnd(6, "0")}`;
44
+ }
45
+ return `#${cleaned.substring(0, 6)}`;
37
46
  }
38
47
  function rgbToHex(rgb) {
39
- const match = rgb.match(/rgba?\((\d+),\s*(\d+),\s*(\d+)(?:,\s*[\d.]+)?\)/);
48
+ const match = rgb.match(/rgba?\((\d+),\s*(\d+),\s*(\d+)(?:,\s*[\d.]+)?\)/i);
40
49
  if (!match)
41
50
  return "#000000";
42
51
  const r = Number.parseInt(match[1], 10);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sfxcode/formkit-nuxt-ui",
3
- "version": "0.7.3",
3
+ "version": "0.7.5",
4
4
  "description": "FormKit integration for Nuxt UI - Seamlessly connect FormKit form handling with Nuxt UI components",
5
5
  "author": {
6
6
  "name": "Tom",
@@ -40,14 +40,17 @@
40
40
  ".": {
41
41
  "types": "./dist/types.d.mts",
42
42
  "import": "./dist/module.mjs"
43
+ },
44
+ "./runtime": {
45
+ "types": "./dist/runtime/index.d.ts",
46
+ "import": "./dist/runtime/index.js"
43
47
  }
44
48
  },
45
49
  "main": "./dist/module.mjs",
46
50
  "typesVersions": {
47
51
  "*": {
48
52
  ".": [
49
- "./dist/types.d.mts",
50
- "./dist/runtime/index.d.ts"
53
+ "./dist/types.d.mts"
51
54
  ]
52
55
  }
53
56
  },