@nuxt/ui 2.9.0 → 2.11.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.
Files changed (201) hide show
  1. package/README.md +11 -0
  2. package/dist/module.d.mts +449 -72
  3. package/dist/module.d.ts +449 -72
  4. package/dist/module.json +1 -1
  5. package/dist/module.mjs +32 -6
  6. package/dist/runtime/components/data/Table.vue +8 -6
  7. package/dist/runtime/components/data/Table.vue.d.ts +2 -1
  8. package/dist/runtime/components/elements/Accordion.vue +15 -13
  9. package/dist/runtime/components/elements/Accordion.vue.d.ts +5 -2
  10. package/dist/runtime/components/elements/Alert.vue +7 -6
  11. package/dist/runtime/components/elements/Alert.vue.d.ts +6 -5
  12. package/dist/runtime/components/elements/Avatar.vue.d.ts +5 -4
  13. package/dist/runtime/components/elements/AvatarGroup.d.ts +4 -3
  14. package/dist/runtime/components/elements/Badge.vue +4 -2
  15. package/dist/runtime/components/elements/Badge.vue.d.ts +5 -5
  16. package/dist/runtime/components/elements/Button.vue +8 -6
  17. package/dist/runtime/components/elements/Button.vue.d.ts +7 -7
  18. package/dist/runtime/components/elements/ButtonGroup.d.ts +5 -4
  19. package/dist/runtime/components/elements/ButtonGroup.mjs +19 -32
  20. package/dist/runtime/components/elements/Chip.vue +85 -0
  21. package/dist/runtime/components/elements/Chip.vue.d.ts +90 -0
  22. package/dist/runtime/components/elements/Dropdown.vue +45 -25
  23. package/dist/runtime/components/elements/Dropdown.vue.d.ts +8 -0
  24. package/dist/runtime/components/elements/Icon.vue +16 -2
  25. package/dist/runtime/components/elements/Icon.vue.d.ts +14 -2
  26. package/dist/runtime/components/elements/Kbd.vue.d.ts +5 -4
  27. package/dist/runtime/components/elements/Link.vue +2 -5
  28. package/dist/runtime/components/elements/Meter.vue +166 -0
  29. package/dist/runtime/components/elements/Meter.vue.d.ts +123 -0
  30. package/dist/runtime/components/elements/MeterGroup.d.ts +78 -0
  31. package/dist/runtime/components/elements/MeterGroup.mjs +172 -0
  32. package/dist/runtime/components/elements/Progress.vue +284 -0
  33. package/dist/runtime/components/elements/Progress.vue.d.ts +2 -0
  34. package/dist/runtime/components/forms/Checkbox.vue +2 -4
  35. package/dist/runtime/components/forms/Checkbox.vue.d.ts +6 -6
  36. package/dist/runtime/components/forms/Form.vue +32 -7
  37. package/dist/runtime/components/forms/Form.vue.d.ts +2 -1
  38. package/dist/runtime/components/forms/FormGroup.vue +7 -3
  39. package/dist/runtime/components/forms/FormGroup.vue.d.ts +15 -5
  40. package/dist/runtime/components/forms/Input.vue +41 -6
  41. package/dist/runtime/components/forms/Input.vue.d.ts +42 -10
  42. package/dist/runtime/components/forms/Radio.vue +16 -9
  43. package/dist/runtime/components/forms/Radio.vue.d.ts +8 -7
  44. package/dist/runtime/components/forms/RadioGroup.vue +136 -0
  45. package/dist/runtime/components/forms/RadioGroup.vue.d.ts +118 -0
  46. package/dist/runtime/components/forms/Range.vue.d.ts +8 -7
  47. package/dist/runtime/components/forms/Select.vue +5 -2
  48. package/dist/runtime/components/forms/Select.vue.d.ts +10 -9
  49. package/dist/runtime/components/forms/SelectMenu.vue +80 -58
  50. package/dist/runtime/components/forms/SelectMenu.vue.d.ts +23 -13
  51. package/dist/runtime/components/forms/Textarea.vue +38 -4
  52. package/dist/runtime/components/forms/Textarea.vue.d.ts +41 -9
  53. package/dist/runtime/components/forms/Toggle.vue +19 -1
  54. package/dist/runtime/components/forms/Toggle.vue.d.ts +16 -3
  55. package/dist/runtime/components/layout/Divider.vue +107 -0
  56. package/dist/runtime/components/layout/Divider.vue.d.ts +82 -0
  57. package/dist/runtime/components/navigation/Breadcrumb.vue +78 -0
  58. package/dist/runtime/components/navigation/Breadcrumb.vue.d.ts +50 -0
  59. package/dist/runtime/components/navigation/CommandPalette.vue +18 -7
  60. package/dist/runtime/components/navigation/CommandPalette.vue.d.ts +2 -2
  61. package/dist/runtime/components/navigation/Pagination.vue +65 -9
  62. package/dist/runtime/components/navigation/Pagination.vue.d.ts +45 -7
  63. package/dist/runtime/components/navigation/Tabs.vue +1 -1
  64. package/dist/runtime/components/navigation/Tabs.vue.d.ts +1 -1
  65. package/dist/runtime/components/overlays/ContextMenu.vue +7 -2
  66. package/dist/runtime/components/overlays/ContextMenu.vue.d.ts +2 -1
  67. package/dist/runtime/components/overlays/Modal.vue +1 -1
  68. package/dist/runtime/components/overlays/Modal.vue.d.ts +1 -1
  69. package/dist/runtime/components/overlays/Notification.vue +32 -27
  70. package/dist/runtime/components/overlays/Notification.vue.d.ts +4 -3
  71. package/dist/runtime/components/overlays/Notifications.vue +16 -14
  72. package/dist/runtime/components/overlays/Popover.vue +31 -7
  73. package/dist/runtime/components/overlays/Popover.vue.d.ts +27 -2
  74. package/dist/runtime/components/overlays/Slideover.vue.d.ts +1 -1
  75. package/dist/runtime/components/overlays/Tooltip.vue +16 -10
  76. package/dist/runtime/components/overlays/Tooltip.vue.d.ts +1 -0
  77. package/dist/runtime/composables/defineShortcuts.d.ts +1 -1
  78. package/dist/runtime/composables/defineShortcuts.mjs +8 -4
  79. package/dist/runtime/composables/useButtonGroup.d.ts +20 -0
  80. package/dist/runtime/composables/useButtonGroup.mjs +52 -0
  81. package/dist/runtime/composables/useFormGroup.d.ts +6 -4
  82. package/dist/runtime/composables/useFormGroup.mjs +19 -7
  83. package/dist/runtime/composables/usePopper.d.ts +3 -3
  84. package/dist/runtime/composables/usePopper.mjs +7 -1
  85. package/dist/runtime/composables/useShortcuts.d.ts +2 -2
  86. package/dist/runtime/composables/useUI.d.ts +2 -2
  87. package/dist/runtime/composables/useUI.mjs +2 -2
  88. package/dist/runtime/types/alert.d.ts +7 -0
  89. package/dist/runtime/types/avatar.d.ts +3 -1
  90. package/dist/runtime/types/badge.d.ts +5 -4
  91. package/dist/runtime/types/breadcrumb.d.ts +7 -0
  92. package/dist/runtime/types/button.d.ts +5 -4
  93. package/dist/runtime/types/chip.d.ts +11 -0
  94. package/dist/runtime/types/command-palette.d.ts +1 -0
  95. package/dist/runtime/types/dropdown.d.ts +2 -2
  96. package/dist/runtime/types/form-group.d.ts +5 -0
  97. package/dist/runtime/types/form.d.ts +14 -6
  98. package/dist/runtime/types/index.d.ts +12 -0
  99. package/dist/runtime/types/input.d.ts +8 -0
  100. package/dist/runtime/types/kbd.d.ts +5 -0
  101. package/dist/runtime/types/meter.d.ts +5 -0
  102. package/dist/runtime/types/popper.d.ts +1 -0
  103. package/dist/runtime/types/progress.d.ts +4 -0
  104. package/dist/runtime/types/range.d.ts +5 -0
  105. package/dist/runtime/types/select.d.ts +8 -0
  106. package/dist/runtime/types/textarea.d.ts +8 -0
  107. package/dist/runtime/types/toggle.d.ts +5 -0
  108. package/dist/runtime/types/utils.d.ts +22 -5
  109. package/dist/runtime/ui.config/_popperArrow.d.ts +9 -0
  110. package/dist/runtime/ui.config/_popperArrow.mjs +8 -0
  111. package/dist/runtime/ui.config/data/table.d.ts +60 -0
  112. package/dist/runtime/ui.config/data/table.mjs +59 -0
  113. package/dist/runtime/ui.config/elements/accordion.d.ts +21 -0
  114. package/dist/runtime/ui.config/elements/accordion.mjs +20 -0
  115. package/dist/runtime/ui.config/elements/alert.d.ts +40 -0
  116. package/dist/runtime/ui.config/elements/alert.mjs +39 -0
  117. package/dist/runtime/ui.config/elements/avatar.d.ts +60 -0
  118. package/dist/runtime/ui.config/elements/avatar.mjs +59 -0
  119. package/dist/runtime/ui.config/elements/avatarGroup.d.ts +6 -0
  120. package/dist/runtime/ui.config/elements/avatarGroup.mjs +5 -0
  121. package/dist/runtime/ui.config/elements/badge.d.ts +34 -0
  122. package/dist/runtime/ui.config/elements/badge.mjs +33 -0
  123. package/dist/runtime/ui.config/elements/button.d.ts +77 -0
  124. package/dist/runtime/ui.config/elements/button.mjs +76 -0
  125. package/dist/runtime/ui.config/elements/buttonGroup.d.ts +9 -0
  126. package/dist/runtime/ui.config/elements/buttonGroup.mjs +8 -0
  127. package/dist/runtime/ui.config/elements/chip.d.ts +35 -0
  128. package/dist/runtime/ui.config/elements/chip.mjs +34 -0
  129. package/dist/runtime/ui.config/elements/dropdown.d.ts +53 -0
  130. package/dist/runtime/ui.config/elements/dropdown.mjs +51 -0
  131. package/dist/runtime/ui.config/elements/kbd.d.ts +17 -0
  132. package/dist/runtime/ui.config/elements/kbd.mjs +16 -0
  133. package/dist/runtime/ui.config/elements/meter.d.ts +77 -0
  134. package/dist/runtime/ui.config/elements/meter.mjs +76 -0
  135. package/dist/runtime/ui.config/elements/meterGroup.d.ts +12 -0
  136. package/dist/runtime/ui.config/elements/meterGroup.mjs +11 -0
  137. package/dist/runtime/ui.config/elements/progress.d.ts +75 -0
  138. package/dist/runtime/ui.config/elements/progress.mjs +74 -0
  139. package/dist/runtime/ui.config/forms/checkbox.d.ts +16 -0
  140. package/dist/runtime/ui.config/forms/checkbox.mjs +15 -0
  141. package/dist/runtime/ui.config/forms/formGroup.d.ts +25 -0
  142. package/dist/runtime/ui.config/forms/formGroup.mjs +25 -0
  143. package/dist/runtime/ui.config/forms/input.d.ts +105 -0
  144. package/dist/runtime/ui.config/forms/input.mjs +104 -0
  145. package/dist/runtime/ui.config/forms/radio.d.ts +15 -0
  146. package/dist/runtime/ui.config/forms/radio.mjs +14 -0
  147. package/dist/runtime/ui.config/forms/radioGroup.d.ts +8 -0
  148. package/dist/runtime/ui.config/forms/radioGroup.mjs +7 -0
  149. package/dist/runtime/ui.config/forms/range.d.ts +64 -0
  150. package/dist/runtime/ui.config/forms/range.mjs +63 -0
  151. package/dist/runtime/ui.config/forms/select.d.ts +106 -0
  152. package/dist/runtime/ui.config/forms/select.mjs +12 -0
  153. package/dist/runtime/ui.config/forms/selectMenu.d.ts +63 -0
  154. package/dist/runtime/ui.config/forms/selectMenu.mjs +61 -0
  155. package/dist/runtime/ui.config/forms/textarea.d.ts +104 -0
  156. package/dist/runtime/ui.config/forms/textarea.mjs +9 -0
  157. package/dist/runtime/ui.config/forms/toggle.d.ts +61 -0
  158. package/dist/runtime/ui.config/forms/toggle.mjs +60 -0
  159. package/dist/runtime/ui.config/index.d.ts +40 -0
  160. package/dist/runtime/ui.config/index.mjs +40 -0
  161. package/dist/runtime/ui.config/layout/card.d.ts +24 -0
  162. package/dist/runtime/ui.config/layout/card.mjs +23 -0
  163. package/dist/runtime/ui.config/layout/container.d.ts +6 -0
  164. package/dist/runtime/ui.config/layout/container.mjs +5 -0
  165. package/dist/runtime/ui.config/layout/divider.d.ts +30 -0
  166. package/dist/runtime/ui.config/layout/divider.mjs +29 -0
  167. package/dist/runtime/ui.config/layout/skeleton.d.ts +6 -0
  168. package/dist/runtime/ui.config/layout/skeleton.mjs +5 -0
  169. package/dist/runtime/ui.config/navigation/breadcrumb.d.ts +20 -0
  170. package/dist/runtime/ui.config/navigation/breadcrumb.mjs +19 -0
  171. package/dist/runtime/ui.config/navigation/commandPalette.d.ts +68 -0
  172. package/dist/runtime/ui.config/navigation/commandPalette.mjs +67 -0
  173. package/dist/runtime/ui.config/navigation/pagination.d.ts +35 -0
  174. package/dist/runtime/ui.config/navigation/pagination.mjs +34 -0
  175. package/dist/runtime/ui.config/navigation/tabs.d.ts +34 -0
  176. package/dist/runtime/ui.config/navigation/tabs.mjs +33 -0
  177. package/dist/runtime/ui.config/navigation/verticalNavigation.d.ts +28 -0
  178. package/dist/runtime/ui.config/navigation/verticalNavigation.mjs +27 -0
  179. package/dist/runtime/ui.config/overlays/contextMenu.d.ts +31 -0
  180. package/dist/runtime/ui.config/overlays/contextMenu.mjs +25 -0
  181. package/dist/runtime/ui.config/overlays/modal.d.ts +35 -0
  182. package/dist/runtime/ui.config/overlays/modal.mjs +36 -0
  183. package/dist/runtime/ui.config/overlays/notification.d.ts +49 -0
  184. package/dist/runtime/ui.config/overlays/notification.mjs +49 -0
  185. package/dist/runtime/ui.config/overlays/notifications.d.ts +7 -0
  186. package/dist/runtime/ui.config/overlays/notifications.mjs +6 -0
  187. package/dist/runtime/ui.config/overlays/popover.d.ts +42 -0
  188. package/dist/runtime/ui.config/overlays/popover.mjs +36 -0
  189. package/dist/runtime/ui.config/overlays/slideover.d.ts +27 -0
  190. package/dist/runtime/ui.config/overlays/slideover.mjs +28 -0
  191. package/dist/runtime/ui.config/overlays/tooltip.d.ts +32 -0
  192. package/dist/runtime/ui.config/overlays/tooltip.mjs +26 -0
  193. package/dist/runtime/utils/index.d.ts +5 -0
  194. package/dist/runtime/utils/index.mjs +6 -2
  195. package/dist/types.d.mts +3 -2
  196. package/dist/types.d.ts +3 -2
  197. package/package.json +41 -28
  198. package/dist/runtime/ui.config.d.ts +0 -1207
  199. package/dist/runtime/ui.config.mjs +0 -1029
  200. package/dist/runtime/utils/StateEmitter.d.ts +0 -17
  201. package/dist/runtime/utils/StateEmitter.mjs +0 -21
@@ -2,7 +2,7 @@ import type { PropType } from 'vue';
2
2
  declare const _default: import("vue").DefineComponent<{
3
3
  id: {
4
4
  type: StringConstructor;
5
- default: () => string;
5
+ default: () => null;
6
6
  };
7
7
  value: {
8
8
  type: (ObjectConstructor | BooleanConstructor | NumberConstructor | StringConstructor)[];
@@ -63,14 +63,14 @@ declare const _default: import("vue").DefineComponent<{
63
63
  [x: string]: unknown;
64
64
  }, string>>;
65
65
  toggle: import("vue").WritableComputedRef<boolean | unknown[]>;
66
- inputId: import("vue").ComputedRef<any>;
67
- name: import("vue").ComputedRef<any>;
66
+ inputId: import("vue").Ref<string | null | undefined>;
67
+ name: import("vue").ComputedRef<string | undefined>;
68
68
  inputClass: import("vue").ComputedRef<string>;
69
69
  onChange: (event: Event) => void;
70
70
  }, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("change" | "update:modelValue")[], "change" | "update:modelValue", import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
71
71
  id: {
72
72
  type: StringConstructor;
73
- default: () => string;
73
+ default: () => null;
74
74
  };
75
75
  value: {
76
76
  type: (ObjectConstructor | BooleanConstructor | NumberConstructor | StringConstructor)[];
@@ -129,12 +129,12 @@ declare const _default: import("vue").DefineComponent<{
129
129
  "onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
130
130
  onChange?: ((...args: any[]) => any) | undefined;
131
131
  }, {
132
+ ui: Partial<any>;
133
+ value: string | number | boolean | Record<string, any>;
132
134
  id: string;
133
135
  color: any;
134
- ui: Partial<any>;
135
136
  name: string;
136
137
  class: any;
137
- value: string | number | boolean | Record<string, any>;
138
138
  label: string;
139
139
  modelValue: boolean | unknown[];
140
140
  indeterminate: boolean;
@@ -8,6 +8,13 @@
8
8
  import { provide, ref, defineComponent } from "vue";
9
9
  import { useEventBus } from "@vueuse/core";
10
10
  import { uid } from "../../utils/uid";
11
+ class FormException extends Error {
12
+ constructor(message) {
13
+ super(message);
14
+ this.message = message;
15
+ Object.setPrototypeOf(this, FormException.prototype);
16
+ }
17
+ }
11
18
  export default defineComponent({
12
19
  props: {
13
20
  schema: {
@@ -27,7 +34,7 @@ export default defineComponent({
27
34
  default: () => ["blur", "input", "change", "submit"]
28
35
  }
29
36
  },
30
- emits: ["submit"],
37
+ emits: ["submit", "error"],
31
38
  setup(props, { expose, emit }) {
32
39
  const bus = useEventBus(`form-${uid()}`);
33
40
  bus.on(async (event) => {
@@ -38,6 +45,8 @@ export default defineComponent({
38
45
  const errors = ref([]);
39
46
  provide("form-errors", errors);
40
47
  provide("form-events", bus);
48
+ const inputs = ref({});
49
+ provide("form-inputs", inputs);
41
50
  async function getErrors() {
42
51
  let errs = await props.validate(props.state);
43
52
  if (props.schema) {
@@ -68,19 +77,35 @@ export default defineComponent({
68
77
  errors.value = await getErrors();
69
78
  }
70
79
  if (!opts.silent && errors.value.length > 0) {
71
- throw new Error(
80
+ throw new FormException(
72
81
  `Form validation failed: ${JSON.stringify(errors.value, null, 2)}`
73
82
  );
74
83
  }
75
84
  return props.state;
76
85
  }
77
86
  async function onSubmit(event) {
78
- if (props.validateOn?.includes("submit")) {
79
- await validate();
87
+ try {
88
+ if (props.validateOn?.includes("submit")) {
89
+ await validate();
90
+ }
91
+ const submitEvent = {
92
+ ...event,
93
+ data: props.state
94
+ };
95
+ emit("submit", submitEvent);
96
+ } catch (error) {
97
+ if (!(error instanceof FormException)) {
98
+ throw error;
99
+ }
100
+ const errorEvent = {
101
+ ...event,
102
+ errors: errors.value.map((err) => ({
103
+ ...err,
104
+ id: inputs.value[err.path]
105
+ }))
106
+ };
107
+ emit("error", errorEvent);
80
108
  }
81
- const submitEvent = event;
82
- submitEvent.data = props.state;
83
- emit("submit", event);
84
109
  }
85
110
  expose({
86
111
  validate,
@@ -23,7 +23,7 @@ declare const _default: import("vue").DefineComponent<{
23
23
  };
24
24
  }, {
25
25
  onSubmit: (event: SubmitEvent) => Promise<void>;
26
- }, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, "submit"[], "submit", import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
26
+ }, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("error" | "submit")[], "error" | "submit", import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
27
27
  schema: {
28
28
  type: PropType<ZodSchema<any, import("zod").ZodTypeDef, any>> | PropType<YupObjectSchema<any, import("yup").AnyObject, any, "">> | PropType<JoiSchema> | PropType<ValibotObjectSchema<any>>;
29
29
  default: undefined;
@@ -41,6 +41,7 @@ declare const _default: import("vue").DefineComponent<{
41
41
  default: () => string[];
42
42
  };
43
43
  }>> & {
44
+ onError?: ((...args: any[]) => any) | undefined;
44
45
  onSubmit?: ((...args: any[]) => any) | undefined;
45
46
  }, {
46
47
  schema: ZodSchema<any, import("zod").ZodTypeDef, any> | YupObjectSchema<any, import("yup").AnyObject, any, ""> | import("joi").AnySchema<any> | ValibotObjectSchema<any>;
@@ -43,7 +43,6 @@ import { useUI } from "../../composables/useUI";
43
43
  import { mergeConfig } from "../../utils";
44
44
  import appConfig from "#build/app.config";
45
45
  import { formGroup } from "#ui/ui.config";
46
- import { uid } from "../../utils/uid";
47
46
  const config = mergeConfig(appConfig.ui.strategy, appConfig.ui.formGroup, formGroup);
48
47
  export default defineComponent({
49
48
  inheritAttrs: false,
@@ -90,6 +89,10 @@ export default defineComponent({
90
89
  ui: {
91
90
  type: Object,
92
91
  default: void 0
92
+ },
93
+ eagerValidation: {
94
+ type: Boolean,
95
+ default: false
93
96
  }
94
97
  },
95
98
  setup(props) {
@@ -99,12 +102,13 @@ export default defineComponent({
99
102
  return props.error && typeof props.error === "string" || typeof props.error === "boolean" ? props.error : formErrors?.value?.find((error2) => error2.path === props.name)?.message;
100
103
  });
101
104
  const size = computed(() => ui.value.size[props.size ?? config.default.size]);
102
- const inputId = ref(uid());
105
+ const inputId = ref();
103
106
  provide("form-group", {
104
107
  error,
105
108
  inputId,
106
109
  name: computed(() => props.name),
107
- size: computed(() => props.size)
110
+ size: computed(() => props.size),
111
+ eagerValidation: computed(() => props.eagerValidation)
108
112
  });
109
113
  return {
110
114
  // eslint-disable-next-line vue/no-dupe-keys
@@ -1,11 +1,12 @@
1
1
  import type { Ref, PropType } from 'vue';
2
+ import type { FormGroupSize } from '../../types';
2
3
  declare const _default: import("vue").DefineComponent<{
3
4
  name: {
4
5
  type: StringConstructor;
5
6
  default: null;
6
7
  };
7
8
  size: {
8
- type: PropType<string | number | symbol>;
9
+ type: PropType<FormGroupSize>;
9
10
  default: null;
10
11
  validator(value: string): boolean;
11
12
  };
@@ -41,12 +42,16 @@ declare const _default: import("vue").DefineComponent<{
41
42
  type: PropType<Partial<any>>;
42
43
  default: undefined;
43
44
  };
45
+ eagerValidation: {
46
+ type: BooleanConstructor;
47
+ default: boolean;
48
+ };
44
49
  }, {
45
50
  ui: import("vue").ComputedRef<any>;
46
51
  attrs: import("vue").ComputedRef<Pick<{
47
52
  [x: string]: unknown;
48
53
  }, string>>;
49
- inputId: Ref<string>;
54
+ inputId: Ref<any>;
50
55
  size: import("vue").ComputedRef<any>;
51
56
  error: import("vue").ComputedRef<string | boolean | undefined>;
52
57
  }, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
@@ -55,7 +60,7 @@ declare const _default: import("vue").DefineComponent<{
55
60
  default: null;
56
61
  };
57
62
  size: {
58
- type: PropType<string | number | symbol>;
63
+ type: PropType<FormGroupSize>;
59
64
  default: null;
60
65
  validator(value: string): boolean;
61
66
  };
@@ -91,16 +96,21 @@ declare const _default: import("vue").DefineComponent<{
91
96
  type: PropType<Partial<any>>;
92
97
  default: undefined;
93
98
  };
99
+ eagerValidation: {
100
+ type: BooleanConstructor;
101
+ default: boolean;
102
+ };
94
103
  }>>, {
95
104
  error: string | boolean;
96
- description: string;
105
+ size: FormGroupSize;
97
106
  ui: Partial<any>;
107
+ description: string;
98
108
  name: string;
99
109
  class: any;
100
110
  label: string;
101
111
  required: boolean;
102
- size: string | number | symbol;
103
112
  help: string;
104
113
  hint: string;
114
+ eagerValidation: boolean;
105
115
  }, {}>;
106
116
  export default _default;
@@ -14,6 +14,7 @@
14
14
  v-bind="attrs"
15
15
  @input="onInput"
16
16
  @blur="onBlur"
17
+ @change="onChange"
17
18
  >
18
19
  <slot />
19
20
 
@@ -35,9 +36,11 @@
35
36
  import { ref, computed, toRef, onMounted, defineComponent } from "vue";
36
37
  import { twMerge, twJoin } from "tailwind-merge";
37
38
  import UIcon from "../elements/Icon.vue";
39
+ import { defu } from "defu";
38
40
  import { useUI } from "../../composables/useUI";
39
41
  import { useFormGroup } from "../../composables/useFormGroup";
40
- import { mergeConfig } from "../../utils";
42
+ import { mergeConfig, looseToNumber } from "../../utils";
43
+ import { useInjectButtonGroup } from "../../composables/useButtonGroup";
41
44
  import appConfig from "#build/app.config";
42
45
  import { input } from "#ui/ui.config";
43
46
  const config = mergeConfig(appConfig.ui.strategy, appConfig.ui.input, input);
@@ -79,6 +82,10 @@ export default defineComponent({
79
82
  type: Boolean,
80
83
  default: false
81
84
  },
85
+ autofocusDelay: {
86
+ type: Number,
87
+ default: 100
88
+ },
82
89
  icon: {
83
90
  type: String,
84
91
  default: null
@@ -146,22 +153,49 @@ export default defineComponent({
146
153
  ui: {
147
154
  type: Object,
148
155
  default: void 0
156
+ },
157
+ modelModifiers: {
158
+ type: Object,
159
+ default: () => ({})
149
160
  }
150
161
  },
151
162
  emits: ["update:modelValue", "blur"],
152
163
  setup(props, { emit, slots }) {
153
164
  const { ui, attrs } = useUI("input", toRef(props, "ui"), config, toRef(props, "class"));
154
- const { emitFormBlur, emitFormInput, size, color, inputId, name } = useFormGroup(props, config);
165
+ const { size: sizeButtonGroup, rounded } = useInjectButtonGroup({ ui, props });
166
+ const { emitFormBlur, emitFormInput, size: sizeFormGroup, color, inputId, name } = useFormGroup(props, config);
167
+ const size = computed(() => sizeButtonGroup.value || sizeFormGroup.value);
168
+ const modelModifiers = ref(defu({}, props.modelModifiers, { trim: false, lazy: false, number: false }));
155
169
  const input2 = ref(null);
156
170
  const autoFocus = () => {
157
171
  if (props.autofocus) {
158
172
  input2.value?.focus();
159
173
  }
160
174
  };
161
- const onInput = (event) => {
162
- emit("update:modelValue", event.target.value);
175
+ const updateInput = (value) => {
176
+ if (modelModifiers.value.trim) {
177
+ value = value.trim();
178
+ }
179
+ if (modelModifiers.value.number || props.type === "number") {
180
+ value = looseToNumber(value);
181
+ }
182
+ emit("update:modelValue", value);
163
183
  emitFormInput();
164
184
  };
185
+ const onInput = (event) => {
186
+ if (!modelModifiers.value.lazy) {
187
+ updateInput(event.target.value);
188
+ }
189
+ };
190
+ const onChange = (event) => {
191
+ const value = event.target.value;
192
+ if (modelModifiers.value.lazy) {
193
+ updateInput(value);
194
+ }
195
+ if (modelModifiers.value.trim) {
196
+ event.target.value = value.trim();
197
+ }
198
+ };
165
199
  const onBlur = (event) => {
166
200
  emitFormBlur();
167
201
  emit("blur", event);
@@ -169,13 +203,13 @@ export default defineComponent({
169
203
  onMounted(() => {
170
204
  setTimeout(() => {
171
205
  autoFocus();
172
- }, 100);
206
+ }, props.autofocusDelay);
173
207
  });
174
208
  const inputClass = computed(() => {
175
209
  const variant = ui.value.color?.[color.value]?.[props.variant] || ui.value.variant[props.variant];
176
210
  return twMerge(twJoin(
177
211
  ui.value.base,
178
- ui.value.rounded,
212
+ rounded.value,
179
213
  ui.value.placeholder,
180
214
  ui.value.size[size.value],
181
215
  props.padded ? ui.value.padding[size.value] : "p-0",
@@ -251,6 +285,7 @@ export default defineComponent({
251
285
  trailingIconClass,
252
286
  trailingWrapperIconClass,
253
287
  onInput,
288
+ onChange,
254
289
  onBlur
255
290
  };
256
291
  }
@@ -1,4 +1,5 @@
1
1
  import type { PropType } from 'vue';
2
+ import type { InputSize, InputVariant } from '../../types';
2
3
  declare const _default: import("vue").DefineComponent<{
3
4
  modelValue: {
4
5
  type: (NumberConstructor | StringConstructor)[];
@@ -32,6 +33,10 @@ declare const _default: import("vue").DefineComponent<{
32
33
  type: BooleanConstructor;
33
34
  default: boolean;
34
35
  };
36
+ autofocusDelay: {
37
+ type: NumberConstructor;
38
+ default: number;
39
+ };
35
40
  icon: {
36
41
  type: StringConstructor;
37
42
  default: null;
@@ -65,7 +70,7 @@ declare const _default: import("vue").DefineComponent<{
65
70
  default: boolean;
66
71
  };
67
72
  size: {
68
- type: PropType<string | number | symbol>;
73
+ type: PropType<InputSize>;
69
74
  default: null;
70
75
  validator(value: string): boolean;
71
76
  };
@@ -75,7 +80,7 @@ declare const _default: import("vue").DefineComponent<{
75
80
  validator(value: string): boolean;
76
81
  };
77
82
  variant: {
78
- type: PropType<any>;
83
+ type: PropType<InputVariant>;
79
84
  default: () => any;
80
85
  validator(value: string): boolean;
81
86
  };
@@ -91,13 +96,21 @@ declare const _default: import("vue").DefineComponent<{
91
96
  type: PropType<Partial<any>>;
92
97
  default: undefined;
93
98
  };
99
+ modelModifiers: {
100
+ type: PropType<{
101
+ trim?: boolean | undefined;
102
+ lazy?: boolean | undefined;
103
+ number?: boolean | undefined;
104
+ }>;
105
+ default: () => {};
106
+ };
94
107
  }, {
95
108
  ui: import("vue").ComputedRef<any>;
96
109
  attrs: import("vue").ComputedRef<Pick<{
97
110
  [x: string]: unknown;
98
111
  }, string>>;
99
- name: import("vue").ComputedRef<any>;
100
- inputId: import("vue").ComputedRef<any>;
112
+ name: import("vue").ComputedRef<string | undefined>;
113
+ inputId: import("vue").Ref<string | null | undefined>;
101
114
  input: import("vue").Ref<HTMLInputElement | null>;
102
115
  isLeading: import("vue").ComputedRef<string | true>;
103
116
  isTrailing: import("vue").ComputedRef<string | true>;
@@ -109,6 +122,7 @@ declare const _default: import("vue").DefineComponent<{
109
122
  trailingIconClass: import("vue").ComputedRef<string>;
110
123
  trailingWrapperIconClass: import("vue").ComputedRef<string>;
111
124
  onInput: (event: InputEvent) => void;
125
+ onChange: (event: InputEvent) => void;
112
126
  onBlur: (event: FocusEvent) => void;
113
127
  }, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("blur" | "update:modelValue")[], "blur" | "update:modelValue", import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
114
128
  modelValue: {
@@ -143,6 +157,10 @@ declare const _default: import("vue").DefineComponent<{
143
157
  type: BooleanConstructor;
144
158
  default: boolean;
145
159
  };
160
+ autofocusDelay: {
161
+ type: NumberConstructor;
162
+ default: number;
163
+ };
146
164
  icon: {
147
165
  type: StringConstructor;
148
166
  default: null;
@@ -176,7 +194,7 @@ declare const _default: import("vue").DefineComponent<{
176
194
  default: boolean;
177
195
  };
178
196
  size: {
179
- type: PropType<string | number | symbol>;
197
+ type: PropType<InputSize>;
180
198
  default: null;
181
199
  validator(value: string): boolean;
182
200
  };
@@ -186,7 +204,7 @@ declare const _default: import("vue").DefineComponent<{
186
204
  validator(value: string): boolean;
187
205
  };
188
206
  variant: {
189
- type: PropType<any>;
207
+ type: PropType<InputVariant>;
190
208
  default: () => any;
191
209
  validator(value: string): boolean;
192
210
  };
@@ -202,23 +220,31 @@ declare const _default: import("vue").DefineComponent<{
202
220
  type: PropType<Partial<any>>;
203
221
  default: undefined;
204
222
  };
223
+ modelModifiers: {
224
+ type: PropType<{
225
+ trim?: boolean | undefined;
226
+ lazy?: boolean | undefined;
227
+ number?: boolean | undefined;
228
+ }>;
229
+ default: () => {};
230
+ };
205
231
  }>> & {
206
232
  "onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
207
233
  onBlur?: ((...args: any[]) => any) | undefined;
208
234
  }, {
235
+ size: InputSize;
236
+ ui: Partial<any>;
209
237
  id: string;
210
238
  icon: string;
211
239
  color: any;
212
- ui: Partial<any>;
240
+ type: string;
213
241
  name: string;
214
242
  class: any;
215
- type: string;
216
243
  modelValue: string | number;
217
244
  loading: boolean;
218
245
  disabled: boolean;
219
- variant: any;
246
+ variant: InputVariant;
220
247
  required: boolean;
221
- size: string | number | symbol;
222
248
  placeholder: string;
223
249
  padded: boolean;
224
250
  loadingIcon: string;
@@ -228,5 +254,11 @@ declare const _default: import("vue").DefineComponent<{
228
254
  leading: boolean;
229
255
  autofocus: boolean;
230
256
  inputClass: string;
257
+ autofocusDelay: number;
258
+ modelModifiers: {
259
+ trim?: boolean | undefined;
260
+ lazy?: boolean | undefined;
261
+ number?: boolean | undefined;
262
+ };
231
263
  }, {}>;
232
264
  export default _default;
@@ -14,7 +14,7 @@
14
14
  v-bind="attrs"
15
15
  >
16
16
  </div>
17
- <div v-if="label || $slots.label" class="ms-3 text-sm">
17
+ <div v-if="label || $slots.label" class="ms-3 flex flex-col">
18
18
  <label :for="inputId" :class="ui.label">
19
19
  <slot name="label">{{ label }}</slot>
20
20
  <span v-if="required" :class="ui.required">*</span>
@@ -27,22 +27,21 @@
27
27
  </template>
28
28
 
29
29
  <script>
30
- import { computed, toRef, defineComponent } from "vue";
30
+ import { computed, defineComponent, inject, toRef, onMounted, ref } from "vue";
31
31
  import { twMerge, twJoin } from "tailwind-merge";
32
32
  import { useUI } from "../../composables/useUI";
33
- import { useFormGroup } from "../../composables/useFormGroup";
34
33
  import { mergeConfig } from "../../utils";
35
34
  import appConfig from "#build/app.config";
36
35
  import { radio } from "#ui/ui.config";
37
36
  import { uid } from "../../utils/uid";
37
+ import { useFormGroup } from "../../composables/useFormGroup";
38
38
  const config = mergeConfig(appConfig.ui.strategy, appConfig.ui.radio, radio);
39
39
  export default defineComponent({
40
40
  inheritAttrs: false,
41
41
  props: {
42
42
  id: {
43
43
  type: String,
44
- // A default value is needed here to bind the label
45
- default: () => uid()
44
+ default: () => null
46
45
  },
47
46
  value: {
48
47
  type: [String, Number, Boolean],
@@ -92,17 +91,25 @@ export default defineComponent({
92
91
  default: void 0
93
92
  }
94
93
  },
95
- emits: ["update:modelValue"],
94
+ emits: ["update:modelValue", "change"],
96
95
  setup(props, { emit }) {
97
96
  const { ui, attrs } = useUI("radio", toRef(props, "ui"), config, toRef(props, "class"));
98
- const { emitFormChange, color, name, inputId } = useFormGroup(props);
97
+ const radioGroup = inject("radio-group", null);
98
+ const { emitFormChange, color, name } = radioGroup ?? useFormGroup(props, config);
99
+ const inputId = ref(props.id);
100
+ onMounted(() => {
101
+ if (!inputId.value) {
102
+ inputId.value = uid();
103
+ }
104
+ });
99
105
  const pick = computed({
100
106
  get() {
101
107
  return props.modelValue;
102
108
  },
103
109
  set(value) {
104
110
  emit("update:modelValue", value);
105
- if (value) {
111
+ emit("change", value);
112
+ if (!radioGroup) {
106
113
  emitFormChange();
107
114
  }
108
115
  }
@@ -117,9 +124,9 @@ export default defineComponent({
117
124
  ), props.inputClass);
118
125
  });
119
126
  return {
127
+ inputId,
120
128
  // eslint-disable-next-line vue/no-dupe-keys
121
129
  ui,
122
- inputId,
123
130
  attrs,
124
131
  pick,
125
132
  // eslint-disable-next-line vue/no-dupe-keys
@@ -2,7 +2,7 @@ import type { PropType } from 'vue';
2
2
  declare const _default: import("vue").DefineComponent<{
3
3
  id: {
4
4
  type: StringConstructor;
5
- default: () => string;
5
+ default: () => null;
6
6
  };
7
7
  value: {
8
8
  type: (BooleanConstructor | NumberConstructor | StringConstructor)[];
@@ -50,18 +50,18 @@ declare const _default: import("vue").DefineComponent<{
50
50
  default: undefined;
51
51
  };
52
52
  }, {
53
+ inputId: import("vue").Ref<string>;
53
54
  ui: import("vue").ComputedRef<any>;
54
- inputId: import("vue").ComputedRef<any>;
55
55
  attrs: import("vue").ComputedRef<Pick<{
56
56
  [x: string]: unknown;
57
57
  }, string>>;
58
58
  pick: import("vue").WritableComputedRef<string | number | boolean | Record<string, any>>;
59
- name: import("vue").ComputedRef<any>;
59
+ name: import("vue").ComputedRef<string | undefined>;
60
60
  inputClass: import("vue").ComputedRef<string>;
61
- }, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, "update:modelValue"[], "update:modelValue", import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
61
+ }, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("change" | "update:modelValue")[], "change" | "update:modelValue", import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
62
62
  id: {
63
63
  type: StringConstructor;
64
- default: () => string;
64
+ default: () => null;
65
65
  };
66
66
  value: {
67
67
  type: (BooleanConstructor | NumberConstructor | StringConstructor)[];
@@ -110,13 +110,14 @@ declare const _default: import("vue").DefineComponent<{
110
110
  };
111
111
  }>> & {
112
112
  "onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
113
+ onChange?: ((...args: any[]) => any) | undefined;
113
114
  }, {
115
+ ui: Partial<any>;
116
+ value: string | number | boolean;
114
117
  id: string;
115
118
  color: any;
116
- ui: Partial<any>;
117
119
  name: string;
118
120
  class: any;
119
- value: string | number | boolean;
120
121
  label: string;
121
122
  modelValue: string | number | boolean | Record<string, any>;
122
123
  disabled: boolean;