@nuxt/ui 2.8.0 → 2.9.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 (104) hide show
  1. package/README.md +1 -0
  2. package/dist/module.d.mts +1147 -1096
  3. package/dist/module.d.ts +1147 -1096
  4. package/dist/module.json +1 -1
  5. package/dist/module.mjs +35 -10
  6. package/dist/runtime/components/data/Table.vue +42 -29
  7. package/dist/runtime/components/data/Table.vue.d.ts +20 -13
  8. package/dist/runtime/components/elements/Accordion.vue +25 -22
  9. package/dist/runtime/components/elements/Accordion.vue.d.ts +21 -17
  10. package/dist/runtime/components/elements/Alert.vue +22 -18
  11. package/dist/runtime/components/elements/Alert.vue.d.ts +26 -19
  12. package/dist/runtime/components/elements/Avatar.vue +22 -16
  13. package/dist/runtime/components/elements/Avatar.vue.d.ts +28 -19
  14. package/dist/runtime/components/elements/AvatarGroup.d.ts +17 -8
  15. package/dist/runtime/components/elements/AvatarGroup.mjs +18 -13
  16. package/dist/runtime/components/elements/Badge.vue +21 -17
  17. package/dist/runtime/components/elements/Badge.vue.d.ts +28 -19
  18. package/dist/runtime/components/elements/Button.vue +22 -18
  19. package/dist/runtime/components/elements/Button.vue.d.ts +26 -17
  20. package/dist/runtime/components/elements/ButtonGroup.d.ts +17 -8
  21. package/dist/runtime/components/elements/ButtonGroup.mjs +22 -15
  22. package/dist/runtime/components/elements/Dropdown.vue +15 -13
  23. package/dist/runtime/components/elements/Dropdown.vue.d.ts +20 -17
  24. package/dist/runtime/components/elements/Kbd.vue +16 -12
  25. package/dist/runtime/components/elements/Kbd.vue.d.ts +20 -12
  26. package/dist/runtime/components/elements/Link.vue +18 -5
  27. package/dist/runtime/components/forms/Checkbox.vue +27 -17
  28. package/dist/runtime/components/forms/Checkbox.vue.d.ts +33 -15
  29. package/dist/runtime/components/forms/Form.vue +4 -5
  30. package/dist/runtime/components/forms/Form.vue.d.ts +1 -1
  31. package/dist/runtime/components/forms/FormGroup.vue +51 -27
  32. package/dist/runtime/components/forms/FormGroup.vue.d.ts +23 -15
  33. package/dist/runtime/components/forms/Input.vue +36 -28
  34. package/dist/runtime/components/forms/Input.vue.d.ts +41 -23
  35. package/dist/runtime/components/forms/Radio.vue +27 -17
  36. package/dist/runtime/components/forms/Radio.vue.d.ts +35 -17
  37. package/dist/runtime/components/forms/Range.vue +26 -16
  38. package/dist/runtime/components/forms/Range.vue.d.ts +36 -17
  39. package/dist/runtime/components/forms/Select.vue +34 -26
  40. package/dist/runtime/components/forms/Select.vue.d.ts +42 -24
  41. package/dist/runtime/components/forms/SelectMenu.vue +43 -33
  42. package/dist/runtime/components/forms/SelectMenu.vue.d.ts +49 -30
  43. package/dist/runtime/components/forms/Textarea.vue +38 -30
  44. package/dist/runtime/components/forms/Textarea.vue.d.ts +41 -23
  45. package/dist/runtime/components/forms/Toggle.vue +26 -15
  46. package/dist/runtime/components/forms/Toggle.vue.d.ts +31 -12
  47. package/dist/runtime/components/layout/Card.vue +15 -10
  48. package/dist/runtime/components/layout/Card.vue.d.ts +17 -9
  49. package/dist/runtime/components/layout/Container.vue +15 -10
  50. package/dist/runtime/components/layout/Container.vue.d.ts +17 -9
  51. package/dist/runtime/components/layout/Skeleton.vue +15 -10
  52. package/dist/runtime/components/layout/Skeleton.vue.d.ts +17 -9
  53. package/dist/runtime/components/navigation/CommandPalette.vue +50 -38
  54. package/dist/runtime/components/navigation/CommandPalette.vue.d.ts +23 -22
  55. package/dist/runtime/components/navigation/CommandPaletteGroup.vue +1 -1
  56. package/dist/runtime/components/navigation/CommandPaletteGroup.vue.d.ts +3 -4
  57. package/dist/runtime/components/navigation/Pagination.vue +65 -56
  58. package/dist/runtime/components/navigation/Pagination.vue.d.ts +29 -22
  59. package/dist/runtime/components/navigation/Tabs.vue +16 -13
  60. package/dist/runtime/components/navigation/Tabs.vue.d.ts +18 -11
  61. package/dist/runtime/components/navigation/VerticalNavigation.vue +15 -13
  62. package/dist/runtime/components/navigation/VerticalNavigation.vue.d.ts +20 -16
  63. package/dist/runtime/components/overlays/ContextMenu.vue +14 -9
  64. package/dist/runtime/components/overlays/ContextMenu.vue.d.ts +18 -10
  65. package/dist/runtime/components/overlays/Modal.vue +15 -13
  66. package/dist/runtime/components/overlays/Modal.vue.d.ts +17 -10
  67. package/dist/runtime/components/overlays/Notification.vue +18 -14
  68. package/dist/runtime/components/overlays/Notification.vue.d.ts +25 -19
  69. package/dist/runtime/components/overlays/Notifications.vue +18 -12
  70. package/dist/runtime/components/overlays/Notifications.vue.d.ts +22 -14
  71. package/dist/runtime/components/overlays/Popover.vue +18 -16
  72. package/dist/runtime/components/overlays/Popover.vue.d.ts +18 -11
  73. package/dist/runtime/components/overlays/Slideover.vue +15 -13
  74. package/dist/runtime/components/overlays/Slideover.vue.d.ts +17 -10
  75. package/dist/runtime/components/overlays/Tooltip.vue +15 -13
  76. package/dist/runtime/components/overlays/Tooltip.vue.d.ts +18 -11
  77. package/dist/runtime/composables/useFormGroup.d.ts +12 -2
  78. package/dist/runtime/composables/useFormGroup.mjs +10 -4
  79. package/dist/runtime/composables/usePopper.mjs +40 -30
  80. package/dist/runtime/composables/useToast.d.ts +3 -3
  81. package/dist/runtime/composables/useUI.d.ts +10 -0
  82. package/dist/runtime/composables/useUI.mjs +24 -0
  83. package/dist/runtime/types/avatar.d.ts +10 -4
  84. package/dist/runtime/types/badge.d.ts +14 -0
  85. package/dist/runtime/types/button.d.ts +10 -3
  86. package/dist/runtime/types/command-palette.d.ts +2 -1
  87. package/dist/runtime/types/form.d.ts +8 -1
  88. package/dist/runtime/types/index.d.ts +2 -0
  89. package/dist/runtime/types/link.d.ts +1 -0
  90. package/dist/runtime/types/notification.d.ts +5 -3
  91. package/dist/runtime/types/tabs.d.ts +1 -0
  92. package/dist/runtime/types/utils.d.ts +11 -0
  93. package/dist/runtime/ui.config.d.ts +1207 -0
  94. package/dist/runtime/{app.config.mjs → ui.config.mjs} +52 -80
  95. package/dist/runtime/utils/index.d.ts +5 -11
  96. package/dist/runtime/utils/index.mjs +21 -9
  97. package/dist/runtime/utils/lodash.d.ts +2 -0
  98. package/dist/runtime/utils/lodash.mjs +23 -0
  99. package/dist/runtime/utils/uid.d.ts +1 -0
  100. package/dist/runtime/utils/uid.mjs +4 -0
  101. package/dist/types.d.mts +1 -1
  102. package/dist/types.d.ts +1 -1
  103. package/package.json +19 -21
  104. package/dist/runtime/app.config.d.ts +0 -1203
@@ -1,8 +1,8 @@
1
1
  <template>
2
- <div :class="wrapperClass">
2
+ <div :class="ui.wrapper">
3
3
  <div class="flex items-center h-5">
4
4
  <input
5
- :id="name"
5
+ :id="inputId"
6
6
  v-model="toggle"
7
7
  :name="name"
8
8
  :required="required"
@@ -18,7 +18,7 @@
18
18
  >
19
19
  </div>
20
20
  <div v-if="label || $slots.label" class="ms-3 text-sm">
21
- <label :for="name" :class="ui.label">
21
+ <label :for="inputId" :class="ui.label">
22
22
  <slot name="label">{{ label }}</slot>
23
23
  <span v-if="required" :class="ui.required">*</span>
24
24
  </label>
@@ -30,16 +30,23 @@
30
30
  </template>
31
31
 
32
32
  <script>
33
- import { computed, defineComponent } from "vue";
34
- import { omit } from "lodash-es";
33
+ import { computed, toRef, defineComponent } from "vue";
35
34
  import { twMerge, twJoin } from "tailwind-merge";
36
- import { defuTwMerge } from "../../utils";
35
+ import { useUI } from "../../composables/useUI";
37
36
  import { useFormGroup } from "../../composables/useFormGroup";
38
- import { useAppConfig } from "#imports";
37
+ import { mergeConfig } from "../../utils";
38
+ import { uid } from "../../utils/uid";
39
39
  import appConfig from "#build/app.config";
40
+ import { checkbox } from "#ui/ui.config";
41
+ const config = mergeConfig(appConfig.ui.strategy, appConfig.ui.checkbox, checkbox);
40
42
  export default defineComponent({
41
43
  inheritAttrs: false,
42
44
  props: {
45
+ id: {
46
+ type: String,
47
+ // A default value is needed here to bind the label
48
+ default: () => uid()
49
+ },
43
50
  value: {
44
51
  type: [String, Number, Boolean, Object],
45
52
  default: null
@@ -78,7 +85,7 @@ export default defineComponent({
78
85
  },
79
86
  color: {
80
87
  type: String,
81
- default: () => appConfig.ui.checkbox.default.color,
88
+ default: () => config.default.color,
82
89
  validator(value) {
83
90
  return appConfig.ui.colors.includes(value);
84
91
  }
@@ -87,17 +94,19 @@ export default defineComponent({
87
94
  type: String,
88
95
  default: ""
89
96
  },
97
+ class: {
98
+ type: [String, Object, Array],
99
+ default: void 0
100
+ },
90
101
  ui: {
91
102
  type: Object,
92
- default: () => ({})
103
+ default: void 0
93
104
  }
94
105
  },
95
106
  emits: ["update:modelValue", "change"],
96
- setup(props, { emit, attrs }) {
97
- const appConfig2 = useAppConfig();
98
- const ui = computed(() => defuTwMerge({}, props.ui, appConfig2.ui.checkbox));
99
- const { emitFormChange, formGroup } = useFormGroup();
100
- const color = computed(() => formGroup?.error?.value ? "red" : props.color);
107
+ setup(props, { emit }) {
108
+ const { ui, attrs } = useUI("checkbox", toRef(props, "ui"), config, toRef(props, "class"));
109
+ const { emitFormChange, color, name, inputId } = useFormGroup(props);
101
110
  const toggle = computed({
102
111
  get() {
103
112
  return props.modelValue;
@@ -110,7 +119,6 @@ export default defineComponent({
110
119
  emit("change", event);
111
120
  emitFormChange();
112
121
  };
113
- const wrapperClass = computed(() => twMerge(ui.value.wrapper, attrs.class));
114
122
  const inputClass = computed(() => {
115
123
  return twMerge(twJoin(
116
124
  ui.value.base,
@@ -122,11 +130,13 @@ export default defineComponent({
122
130
  ), props.inputClass);
123
131
  });
124
132
  return {
125
- attrs: omit(attrs, ["class"]),
126
133
  // eslint-disable-next-line vue/no-dupe-keys
127
134
  ui,
135
+ attrs,
128
136
  toggle,
129
- wrapperClass,
137
+ inputId,
138
+ // eslint-disable-next-line vue/no-dupe-keys
139
+ name,
130
140
  // eslint-disable-next-line vue/no-dupe-keys
131
141
  inputClass,
132
142
  onChange
@@ -1,8 +1,11 @@
1
- /// <reference types="lodash" />
2
1
  import type { PropType } from 'vue';
3
2
  declare const _default: import("vue").DefineComponent<{
3
+ id: {
4
+ type: StringConstructor;
5
+ default: () => string;
6
+ };
4
7
  value: {
5
- type: (ObjectConstructor | BooleanConstructor | StringConstructor | NumberConstructor)[];
8
+ type: (ObjectConstructor | BooleanConstructor | NumberConstructor | StringConstructor)[];
6
9
  default: null;
7
10
  };
8
11
  modelValue: {
@@ -38,7 +41,7 @@ declare const _default: import("vue").DefineComponent<{
38
41
  default: boolean;
39
42
  };
40
43
  color: {
41
- type: StringConstructor;
44
+ type: PropType<any>;
42
45
  default: () => any;
43
46
  validator(value: string): any;
44
47
  };
@@ -46,22 +49,31 @@ declare const _default: import("vue").DefineComponent<{
46
49
  type: StringConstructor;
47
50
  default: string;
48
51
  };
49
- ui: {
52
+ class: {
50
53
  type: PropType<any>;
51
- default: () => {};
54
+ default: undefined;
55
+ };
56
+ ui: {
57
+ type: PropType<Partial<any>>;
58
+ default: undefined;
52
59
  };
53
60
  }, {
54
- attrs: import("lodash").Omit<{
55
- [x: string]: unknown;
56
- }, "class">;
57
61
  ui: import("vue").ComputedRef<any>;
62
+ attrs: import("vue").ComputedRef<Pick<{
63
+ [x: string]: unknown;
64
+ }, string>>;
58
65
  toggle: import("vue").WritableComputedRef<boolean | unknown[]>;
59
- wrapperClass: import("vue").ComputedRef<string>;
66
+ inputId: import("vue").ComputedRef<any>;
67
+ name: import("vue").ComputedRef<any>;
60
68
  inputClass: import("vue").ComputedRef<string>;
61
69
  onChange: (event: Event) => void;
62
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
+ id: {
72
+ type: StringConstructor;
73
+ default: () => string;
74
+ };
63
75
  value: {
64
- type: (ObjectConstructor | BooleanConstructor | StringConstructor | NumberConstructor)[];
76
+ type: (ObjectConstructor | BooleanConstructor | NumberConstructor | StringConstructor)[];
65
77
  default: null;
66
78
  };
67
79
  modelValue: {
@@ -97,7 +109,7 @@ declare const _default: import("vue").DefineComponent<{
97
109
  default: boolean;
98
110
  };
99
111
  color: {
100
- type: StringConstructor;
112
+ type: PropType<any>;
101
113
  default: () => any;
102
114
  validator(value: string): any;
103
115
  };
@@ -105,17 +117,23 @@ declare const _default: import("vue").DefineComponent<{
105
117
  type: StringConstructor;
106
118
  default: string;
107
119
  };
108
- ui: {
120
+ class: {
109
121
  type: PropType<any>;
110
- default: () => {};
122
+ default: undefined;
123
+ };
124
+ ui: {
125
+ type: PropType<Partial<any>>;
126
+ default: undefined;
111
127
  };
112
128
  }>> & {
113
129
  "onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
114
130
  onChange?: ((...args: any[]) => any) | undefined;
115
131
  }, {
116
- color: string;
117
- ui: any;
132
+ id: string;
133
+ color: any;
134
+ ui: Partial<any>;
118
135
  name: string;
136
+ class: any;
119
137
  value: string | number | boolean | Record<string, any>;
120
138
  label: string;
121
139
  modelValue: boolean | unknown[];
@@ -7,7 +7,7 @@
7
7
  <script>
8
8
  import { provide, ref, defineComponent } from "vue";
9
9
  import { useEventBus } from "@vueuse/core";
10
- import { safeParseAsync } from "valibot";
10
+ import { uid } from "../../utils/uid";
11
11
  export default defineComponent({
12
12
  props: {
13
13
  schema: {
@@ -29,8 +29,7 @@ export default defineComponent({
29
29
  },
30
30
  emits: ["submit"],
31
31
  setup(props, { expose, emit }) {
32
- const seed = Math.random().toString(36).substring(7);
33
- const bus = useEventBus(`form-${seed}`);
32
+ const bus = useEventBus(`form-${uid()}`);
34
33
  bus.on(async (event) => {
35
34
  if (event.type !== "submit" && props.validateOn?.includes(event.type)) {
36
35
  await validate(event.path, { silent: true });
@@ -174,8 +173,8 @@ function isValibotSchema(schema) {
174
173
  return schema._parse !== void 0;
175
174
  }
176
175
  async function getValibotError(state, schema) {
177
- const result = await safeParseAsync(schema, state);
178
- if (result.success === false) {
176
+ const result = await schema._parse(state);
177
+ if (result.issues) {
179
178
  return result.issues.map((issue) => ({
180
179
  path: issue.path.map((p) => p.key).join("."),
181
180
  message: issue.message
@@ -2,7 +2,7 @@ import { type PropType } from 'vue';
2
2
  import type { ZodSchema } from 'zod';
3
3
  import type { Schema as JoiSchema } from 'joi';
4
4
  import type { ObjectSchema as YupObjectSchema } from 'yup';
5
- import type { ObjectSchema as ValibotObjectSchema } from 'valibot';
5
+ import type { ObjectSchemaAsync as ValibotObjectSchema } from 'valibot';
6
6
  import type { FormError, FormEventType } from '../../types/form';
7
7
  declare const _default: import("vue").DefineComponent<{
8
8
  schema: {
@@ -1,30 +1,50 @@
1
1
  <template>
2
- <div :class="wrapperClass" v-bind="attrs">
3
- <label>
4
- <div v-if="label" :class="[ui.label.wrapper, size]">
5
- <p :class="[ui.label.base, required ? ui.label.required : '']">{{ label }}</p>
6
- <span v-if="hint" :class="[ui.hint]">{{ hint }}</span>
7
- </div>
2
+ <div :class="ui.wrapper" v-bind="attrs">
3
+ <div v-if="label || $slots.label" :class="[ui.label.wrapper, size]">
4
+ <label :for="inputId" :class="[ui.label.base, required ? ui.label.required : '']">
5
+ <slot v-if="$slots.label" name="label" v-bind="{ error, label, name, hint, description, help }" />
6
+ <template v-else>{{ label }}</template>
7
+ </label>
8
+ <span v-if="hint || $slots.hint" :class="[ui.hint]">
9
+ <slot v-if="$slots.hint" name="hint" v-bind="{ error, label, name, hint, description, help }" />
10
+ <template v-else>{{ hint }}</template>
11
+ </span>
12
+ </div>
8
13
 
9
- <p v-if="description" :class="[ui.description, size]">{{ description }}</p>
14
+ <p v-if="description || $slots.description" :class="[ui.description, size]">
15
+ <slot v-if="$slots.description" name="description" v-bind="{ error, label, name, hint, description, help }" />
16
+ <template v-else>
17
+ {{ description }}
18
+ </template>
19
+ </p>
10
20
 
11
- <div :class="[label ? ui.container : '']">
12
- <slot v-bind="{ error }" />
21
+ <div :class="[label ? ui.container : '']">
22
+ <slot v-bind="{ error }" />
13
23
 
14
- <p v-if="error && typeof error !== 'boolean'" :class="[ui.error, size]">{{ error }}</p>
15
- <p v-else-if="help" :class="[ui.help, size]">{{ help }}</p>
16
- </div>
17
- </label>
24
+ <p v-if="(typeof error === 'string' && error) || $slots.error" :class="[ui.error, size]">
25
+ <slot v-if="$slots.error" name="error" v-bind="{ error, label, name, hint, description, help }" />
26
+ <template v-else>
27
+ {{ error }}
28
+ </template>
29
+ </p>
30
+ <p v-else-if="help || $slots.help" :class="[ui.help, size]">
31
+ <slot v-if="$slots.help" name="help" v-bind="{ error, label, name, hint, description, help }" />
32
+ <template v-else>
33
+ {{ help }}
34
+ </template>
35
+ </p>
36
+ </div>
18
37
  </div>
19
38
  </template>
20
39
 
21
40
  <script>
22
- import { computed, defineComponent, provide, inject } from "vue";
23
- import { omit } from "lodash-es";
24
- import { twMerge } from "tailwind-merge";
25
- import { defuTwMerge } from "../../utils";
26
- import { useAppConfig } from "#imports";
41
+ import { computed, defineComponent, provide, inject, ref, toRef } from "vue";
42
+ import { useUI } from "../../composables/useUI";
43
+ import { mergeConfig } from "../../utils";
27
44
  import appConfig from "#build/app.config";
45
+ import { formGroup } from "#ui/ui.config";
46
+ import { uid } from "../../utils/uid";
47
+ const config = mergeConfig(appConfig.ui.strategy, appConfig.ui.formGroup, formGroup);
28
48
  export default defineComponent({
29
49
  inheritAttrs: false,
30
50
  props: {
@@ -36,7 +56,7 @@ export default defineComponent({
36
56
  type: String,
37
57
  default: null,
38
58
  validator(value) {
39
- return Object.keys(appConfig.ui.formGroup.size).includes(value);
59
+ return Object.keys(config.size).includes(value);
40
60
  }
41
61
  },
42
62
  label: {
@@ -63,30 +83,34 @@ export default defineComponent({
63
83
  type: String,
64
84
  default: null
65
85
  },
86
+ class: {
87
+ type: [String, Object, Array],
88
+ default: void 0
89
+ },
66
90
  ui: {
67
91
  type: Object,
68
- default: () => ({})
92
+ default: void 0
69
93
  }
70
94
  },
71
- setup(props, { attrs }) {
72
- const appConfig2 = useAppConfig();
73
- const ui = computed(() => defuTwMerge({}, props.ui, appConfig2.ui.formGroup));
74
- const wrapperClass = computed(() => twMerge(ui.value.wrapper, attrs.class));
95
+ setup(props) {
96
+ const { ui, attrs } = useUI("formGroup", toRef(props, "ui"), config, toRef(props, "class"));
75
97
  const formErrors = inject("form-errors", null);
76
98
  const error = computed(() => {
77
99
  return props.error && typeof props.error === "string" || typeof props.error === "boolean" ? props.error : formErrors?.value?.find((error2) => error2.path === props.name)?.message;
78
100
  });
79
- const size = computed(() => ui.value.size[props.size ?? appConfig2.ui.input.default.size]);
101
+ const size = computed(() => ui.value.size[props.size ?? config.default.size]);
102
+ const inputId = ref(uid());
80
103
  provide("form-group", {
81
104
  error,
105
+ inputId,
82
106
  name: computed(() => props.name),
83
107
  size: computed(() => props.size)
84
108
  });
85
109
  return {
86
- attrs: omit(attrs, ["class"]),
87
110
  // eslint-disable-next-line vue/no-dupe-keys
88
111
  ui,
89
- wrapperClass,
112
+ attrs,
113
+ inputId,
90
114
  // eslint-disable-next-line vue/no-dupe-keys
91
115
  size,
92
116
  // eslint-disable-next-line vue/no-dupe-keys
@@ -1,12 +1,11 @@
1
- /// <reference types="lodash" />
2
- import type { PropType } from 'vue';
1
+ import type { Ref, PropType } from 'vue';
3
2
  declare const _default: import("vue").DefineComponent<{
4
3
  name: {
5
4
  type: StringConstructor;
6
5
  default: null;
7
6
  };
8
7
  size: {
9
- type: StringConstructor;
8
+ type: PropType<string | number | symbol>;
10
9
  default: null;
11
10
  validator(value: string): boolean;
12
11
  };
@@ -34,25 +33,29 @@ declare const _default: import("vue").DefineComponent<{
34
33
  type: StringConstructor;
35
34
  default: null;
36
35
  };
37
- ui: {
36
+ class: {
38
37
  type: PropType<any>;
39
- default: () => {};
38
+ default: undefined;
39
+ };
40
+ ui: {
41
+ type: PropType<Partial<any>>;
42
+ default: undefined;
40
43
  };
41
44
  }, {
42
- attrs: import("lodash").Omit<{
43
- [x: string]: unknown;
44
- }, "class">;
45
45
  ui: import("vue").ComputedRef<any>;
46
- wrapperClass: import("vue").ComputedRef<string>;
46
+ attrs: import("vue").ComputedRef<Pick<{
47
+ [x: string]: unknown;
48
+ }, string>>;
49
+ inputId: Ref<string>;
47
50
  size: import("vue").ComputedRef<any>;
48
- error: import("vue").ComputedRef<any>;
51
+ error: import("vue").ComputedRef<string | boolean | undefined>;
49
52
  }, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
50
53
  name: {
51
54
  type: StringConstructor;
52
55
  default: null;
53
56
  };
54
57
  size: {
55
- type: StringConstructor;
58
+ type: PropType<string | number | symbol>;
56
59
  default: null;
57
60
  validator(value: string): boolean;
58
61
  };
@@ -80,18 +83,23 @@ declare const _default: import("vue").DefineComponent<{
80
83
  type: StringConstructor;
81
84
  default: null;
82
85
  };
83
- ui: {
86
+ class: {
84
87
  type: PropType<any>;
85
- default: () => {};
88
+ default: undefined;
89
+ };
90
+ ui: {
91
+ type: PropType<Partial<any>>;
92
+ default: undefined;
86
93
  };
87
94
  }>>, {
88
95
  error: string | boolean;
89
96
  description: string;
90
- ui: any;
97
+ ui: Partial<any>;
91
98
  name: string;
99
+ class: any;
92
100
  label: string;
93
101
  required: boolean;
94
- size: string;
102
+ size: string | number | symbol;
95
103
  help: string;
96
104
  hint: string;
97
105
  }, {}>;
@@ -1,6 +1,7 @@
1
1
  <template>
2
- <div :class="wrapperClass">
2
+ <div :class="ui.wrapper">
3
3
  <input
4
+ :id="inputId"
4
5
  ref="input"
5
6
  :name="name"
6
7
  :value="modelValue"
@@ -31,14 +32,15 @@
31
32
  </template>
32
33
 
33
34
  <script>
34
- import { ref, computed, onMounted, defineComponent } from "vue";
35
- import { omit } from "lodash-es";
35
+ import { ref, computed, toRef, onMounted, defineComponent } from "vue";
36
36
  import { twMerge, twJoin } from "tailwind-merge";
37
37
  import UIcon from "../elements/Icon.vue";
38
- import { defuTwMerge } from "../../utils";
38
+ import { useUI } from "../../composables/useUI";
39
39
  import { useFormGroup } from "../../composables/useFormGroup";
40
- import { useAppConfig } from "#imports";
40
+ import { mergeConfig } from "../../utils";
41
41
  import appConfig from "#build/app.config";
42
+ import { input } from "#ui/ui.config";
43
+ const config = mergeConfig(appConfig.ui.strategy, appConfig.ui.input, input);
42
44
  export default defineComponent({
43
45
  components: {
44
46
  UIcon
@@ -53,6 +55,10 @@ export default defineComponent({
53
55
  type: String,
54
56
  default: "text"
55
57
  },
58
+ id: {
59
+ type: String,
60
+ default: null
61
+ },
56
62
  name: {
57
63
  type: String,
58
64
  default: null
@@ -79,7 +85,7 @@ export default defineComponent({
79
85
  },
80
86
  loadingIcon: {
81
87
  type: String,
82
- default: () => appConfig.ui.input.default.loadingIcon
88
+ default: () => config.default.loadingIcon
83
89
  },
84
90
  leadingIcon: {
85
91
  type: String,
@@ -107,25 +113,25 @@ export default defineComponent({
107
113
  },
108
114
  size: {
109
115
  type: String,
110
- default: () => appConfig.ui.input.default.size,
116
+ default: null,
111
117
  validator(value) {
112
- return Object.keys(appConfig.ui.input.size).includes(value);
118
+ return Object.keys(config.size).includes(value);
113
119
  }
114
120
  },
115
121
  color: {
116
122
  type: String,
117
- default: () => appConfig.ui.input.default.color,
123
+ default: () => config.default.color,
118
124
  validator(value) {
119
- return [...appConfig.ui.colors, ...Object.keys(appConfig.ui.input.color)].includes(value);
125
+ return [...appConfig.ui.colors, ...Object.keys(config.color)].includes(value);
120
126
  }
121
127
  },
122
128
  variant: {
123
129
  type: String,
124
- default: () => appConfig.ui.input.default.variant,
130
+ default: () => config.default.variant,
125
131
  validator(value) {
126
132
  return [
127
- ...Object.keys(appConfig.ui.input.variant),
128
- ...Object.values(appConfig.ui.input.color).flatMap((value2) => Object.keys(value2))
133
+ ...Object.keys(config.variant),
134
+ ...Object.values(config.color).flatMap((value2) => Object.keys(value2))
129
135
  ].includes(value);
130
136
  }
131
137
  },
@@ -133,22 +139,23 @@ export default defineComponent({
133
139
  type: String,
134
140
  default: null
135
141
  },
142
+ class: {
143
+ type: [String, Object, Array],
144
+ default: void 0
145
+ },
136
146
  ui: {
137
147
  type: Object,
138
- default: () => ({})
148
+ default: void 0
139
149
  }
140
150
  },
141
151
  emits: ["update:modelValue", "blur"],
142
- setup(props, { emit, attrs, slots }) {
143
- const appConfig2 = useAppConfig();
144
- const ui = computed(() => defuTwMerge({}, props.ui, appConfig2.ui.input));
145
- const { emitFormBlur, emitFormInput, formGroup } = useFormGroup();
146
- const color = computed(() => formGroup?.error?.value ? "red" : props.color);
147
- const size = computed(() => formGroup?.size?.value ?? props.size);
148
- const input = ref(null);
152
+ setup(props, { emit, slots }) {
153
+ const { ui, attrs } = useUI("input", toRef(props, "ui"), config, toRef(props, "class"));
154
+ const { emitFormBlur, emitFormInput, size, color, inputId, name } = useFormGroup(props, config);
155
+ const input2 = ref(null);
149
156
  const autoFocus = () => {
150
157
  if (props.autofocus) {
151
- input.value?.focus();
158
+ input2.value?.focus();
152
159
  }
153
160
  };
154
161
  const onInput = (event) => {
@@ -164,7 +171,6 @@ export default defineComponent({
164
171
  autoFocus();
165
172
  }, 100);
166
173
  });
167
- const wrapperClass = computed(() => twMerge(ui.value.wrapper, attrs.class));
168
174
  const inputClass = computed(() => {
169
175
  const variant = ui.value.color?.[color.value]?.[props.variant] || ui.value.variant[props.variant];
170
176
  return twMerge(twJoin(
@@ -206,7 +212,7 @@ export default defineComponent({
206
212
  const leadingIconClass = computed(() => {
207
213
  return twJoin(
208
214
  ui.value.icon.base,
209
- appConfig2.ui.colors.includes(color.value) && ui.value.icon.color.replaceAll("{color}", color.value),
215
+ appConfig.ui.colors.includes(color.value) && ui.value.icon.color.replaceAll("{color}", color.value),
210
216
  ui.value.icon.size[size.value],
211
217
  props.loading && "animate-spin"
212
218
  );
@@ -221,19 +227,21 @@ export default defineComponent({
221
227
  const trailingIconClass = computed(() => {
222
228
  return twJoin(
223
229
  ui.value.icon.base,
224
- appConfig2.ui.colors.includes(color.value) && ui.value.icon.color.replaceAll("{color}", color.value),
230
+ appConfig.ui.colors.includes(color.value) && ui.value.icon.color.replaceAll("{color}", color.value),
225
231
  ui.value.icon.size[size.value],
226
232
  props.loading && !isLeading.value && "animate-spin"
227
233
  );
228
234
  });
229
235
  return {
230
- attrs: omit(attrs, ["class"]),
231
236
  // eslint-disable-next-line vue/no-dupe-keys
232
237
  ui,
233
- input,
238
+ attrs,
239
+ // eslint-disable-next-line vue/no-dupe-keys
240
+ name,
241
+ inputId,
242
+ input: input2,
234
243
  isLeading,
235
244
  isTrailing,
236
- wrapperClass,
237
245
  // eslint-disable-next-line vue/no-dupe-keys
238
246
  inputClass,
239
247
  leadingIconName,