@nuxt/ui 2.8.1 → 2.10.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 (120) hide show
  1. package/README.md +1 -0
  2. package/dist/module.d.mts +1411 -1092
  3. package/dist/module.d.ts +1411 -1092
  4. package/dist/module.json +1 -1
  5. package/dist/module.mjs +55 -11
  6. package/dist/runtime/components/data/Table.vue +47 -32
  7. package/dist/runtime/components/data/Table.vue.d.ts +22 -14
  8. package/dist/runtime/components/elements/Accordion.vue +33 -28
  9. package/dist/runtime/components/elements/Accordion.vue.d.ts +25 -18
  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 +28 -19
  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 +45 -37
  23. package/dist/runtime/components/elements/Dropdown.vue.d.ts +22 -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/elements/Meter.vue +166 -0
  28. package/dist/runtime/components/elements/Meter.vue.d.ts +123 -0
  29. package/dist/runtime/components/elements/MeterGroup.d.ts +78 -0
  30. package/dist/runtime/components/elements/MeterGroup.mjs +172 -0
  31. package/dist/runtime/components/elements/Progress.vue +284 -0
  32. package/dist/runtime/components/elements/Progress.vue.d.ts +2 -0
  33. package/dist/runtime/components/forms/Checkbox.vue +27 -17
  34. package/dist/runtime/components/forms/Checkbox.vue.d.ts +33 -15
  35. package/dist/runtime/components/forms/Form.vue +34 -9
  36. package/dist/runtime/components/forms/Form.vue.d.ts +2 -1
  37. package/dist/runtime/components/forms/FormGroup.vue +51 -27
  38. package/dist/runtime/components/forms/FormGroup.vue.d.ts +23 -15
  39. package/dist/runtime/components/forms/Input.vue +41 -29
  40. package/dist/runtime/components/forms/Input.vue.d.ts +51 -24
  41. package/dist/runtime/components/forms/Radio.vue +32 -21
  42. package/dist/runtime/components/forms/Radio.vue.d.ts +36 -18
  43. package/dist/runtime/components/forms/RadioGroup.vue +136 -0
  44. package/dist/runtime/components/forms/RadioGroup.vue.d.ts +118 -0
  45. package/dist/runtime/components/forms/Range.vue +26 -16
  46. package/dist/runtime/components/forms/Range.vue.d.ts +37 -18
  47. package/dist/runtime/components/forms/Select.vue +34 -26
  48. package/dist/runtime/components/forms/Select.vue.d.ts +42 -24
  49. package/dist/runtime/components/forms/SelectMenu.vue +104 -89
  50. package/dist/runtime/components/forms/SelectMenu.vue.d.ts +53 -33
  51. package/dist/runtime/components/forms/Textarea.vue +43 -31
  52. package/dist/runtime/components/forms/Textarea.vue.d.ts +50 -23
  53. package/dist/runtime/components/forms/Toggle.vue +26 -15
  54. package/dist/runtime/components/forms/Toggle.vue.d.ts +31 -12
  55. package/dist/runtime/components/layout/Card.vue +15 -10
  56. package/dist/runtime/components/layout/Card.vue.d.ts +17 -9
  57. package/dist/runtime/components/layout/Container.vue +15 -10
  58. package/dist/runtime/components/layout/Container.vue.d.ts +17 -9
  59. package/dist/runtime/components/layout/Divider.vue +107 -0
  60. package/dist/runtime/components/layout/Divider.vue.d.ts +82 -0
  61. package/dist/runtime/components/layout/Skeleton.vue +15 -10
  62. package/dist/runtime/components/layout/Skeleton.vue.d.ts +17 -9
  63. package/dist/runtime/components/navigation/CommandPalette.vue +57 -38
  64. package/dist/runtime/components/navigation/CommandPalette.vue.d.ts +24 -23
  65. package/dist/runtime/components/navigation/CommandPaletteGroup.vue +1 -1
  66. package/dist/runtime/components/navigation/CommandPaletteGroup.vue.d.ts +3 -4
  67. package/dist/runtime/components/navigation/Pagination.vue +129 -64
  68. package/dist/runtime/components/navigation/Pagination.vue.d.ts +70 -25
  69. package/dist/runtime/components/navigation/Tabs.vue +17 -14
  70. package/dist/runtime/components/navigation/Tabs.vue.d.ts +18 -11
  71. package/dist/runtime/components/navigation/VerticalNavigation.vue +15 -13
  72. package/dist/runtime/components/navigation/VerticalNavigation.vue.d.ts +20 -16
  73. package/dist/runtime/components/overlays/ContextMenu.vue +21 -11
  74. package/dist/runtime/components/overlays/ContextMenu.vue.d.ts +20 -11
  75. package/dist/runtime/components/overlays/Modal.vue +16 -14
  76. package/dist/runtime/components/overlays/Modal.vue.d.ts +18 -11
  77. package/dist/runtime/components/overlays/Notification.vue +25 -15
  78. package/dist/runtime/components/overlays/Notification.vue.d.ts +25 -19
  79. package/dist/runtime/components/overlays/Notifications.vue +19 -13
  80. package/dist/runtime/components/overlays/Notifications.vue.d.ts +22 -14
  81. package/dist/runtime/components/overlays/Popover.vue +39 -22
  82. package/dist/runtime/components/overlays/Popover.vue.d.ts +32 -11
  83. package/dist/runtime/components/overlays/Slideover.vue +15 -13
  84. package/dist/runtime/components/overlays/Slideover.vue.d.ts +18 -11
  85. package/dist/runtime/components/overlays/Tooltip.vue +31 -23
  86. package/dist/runtime/components/overlays/Tooltip.vue.d.ts +19 -11
  87. package/dist/runtime/composables/useFormGroup.d.ts +12 -2
  88. package/dist/runtime/composables/useFormGroup.mjs +21 -4
  89. package/dist/runtime/composables/usePopper.d.ts +3 -3
  90. package/dist/runtime/composables/usePopper.mjs +47 -31
  91. package/dist/runtime/composables/useToast.d.ts +3 -3
  92. package/dist/runtime/composables/useUI.d.ts +10 -0
  93. package/dist/runtime/composables/useUI.mjs +24 -0
  94. package/dist/runtime/types/avatar.d.ts +10 -4
  95. package/dist/runtime/types/badge.d.ts +14 -0
  96. package/dist/runtime/types/button.d.ts +10 -3
  97. package/dist/runtime/types/command-palette.d.ts +3 -1
  98. package/dist/runtime/types/form.d.ts +18 -4
  99. package/dist/runtime/types/index.d.ts +4 -0
  100. package/dist/runtime/types/link.d.ts +1 -0
  101. package/dist/runtime/types/meter.d.ts +5 -0
  102. package/dist/runtime/types/notification.d.ts +5 -3
  103. package/dist/runtime/types/popper.d.ts +1 -0
  104. package/dist/runtime/types/progress.d.ts +4 -0
  105. package/dist/runtime/types/tabs.d.ts +1 -0
  106. package/dist/runtime/types/utils.d.ts +11 -0
  107. package/dist/runtime/ui.config.d.ts +1470 -0
  108. package/dist/runtime/{app.config.mjs → ui.config.mjs} +313 -97
  109. package/dist/runtime/utils/index.d.ts +5 -11
  110. package/dist/runtime/utils/index.mjs +21 -9
  111. package/dist/runtime/utils/lodash.d.ts +2 -0
  112. package/dist/runtime/utils/lodash.mjs +23 -0
  113. package/dist/runtime/utils/uid.d.ts +1 -0
  114. package/dist/runtime/utils/uid.mjs +4 -0
  115. package/dist/types.d.mts +1 -1
  116. package/dist/types.d.ts +1 -1
  117. package/package.json +27 -29
  118. package/dist/runtime/app.config.d.ts +0 -1203
  119. package/dist/runtime/utils/StateEmitter.d.ts +0 -17
  120. package/dist/runtime/utils/StateEmitter.mjs +0 -21
@@ -7,6 +7,14 @@
7
7
  <script>
8
8
  import { provide, ref, defineComponent } from "vue";
9
9
  import { useEventBus } from "@vueuse/core";
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
+ }
10
18
  export default defineComponent({
11
19
  props: {
12
20
  schema: {
@@ -26,10 +34,9 @@ export default defineComponent({
26
34
  default: () => ["blur", "input", "change", "submit"]
27
35
  }
28
36
  },
29
- emits: ["submit"],
37
+ emits: ["submit", "error"],
30
38
  setup(props, { expose, emit }) {
31
- const seed = Math.random().toString(36).substring(7);
32
- const bus = useEventBus(`form-${seed}`);
39
+ const bus = useEventBus(`form-${uid()}`);
33
40
  bus.on(async (event) => {
34
41
  if (event.type !== "submit" && props.validateOn?.includes(event.type)) {
35
42
  await validate(event.path, { silent: true });
@@ -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>;
@@ -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
@@ -73,13 +79,17 @@ export default defineComponent({
73
79
  type: Boolean,
74
80
  default: false
75
81
  },
82
+ autofocusDelay: {
83
+ type: Number,
84
+ default: 100
85
+ },
76
86
  icon: {
77
87
  type: String,
78
88
  default: null
79
89
  },
80
90
  loadingIcon: {
81
91
  type: String,
82
- default: () => appConfig.ui.input.default.loadingIcon
92
+ default: () => config.default.loadingIcon
83
93
  },
84
94
  leadingIcon: {
85
95
  type: String,
@@ -107,25 +117,25 @@ export default defineComponent({
107
117
  },
108
118
  size: {
109
119
  type: String,
110
- default: () => appConfig.ui.input.default.size,
120
+ default: null,
111
121
  validator(value) {
112
- return Object.keys(appConfig.ui.input.size).includes(value);
122
+ return Object.keys(config.size).includes(value);
113
123
  }
114
124
  },
115
125
  color: {
116
126
  type: String,
117
- default: () => appConfig.ui.input.default.color,
127
+ default: () => config.default.color,
118
128
  validator(value) {
119
- return [...appConfig.ui.colors, ...Object.keys(appConfig.ui.input.color)].includes(value);
129
+ return [...appConfig.ui.colors, ...Object.keys(config.color)].includes(value);
120
130
  }
121
131
  },
122
132
  variant: {
123
133
  type: String,
124
- default: () => appConfig.ui.input.default.variant,
134
+ default: () => config.default.variant,
125
135
  validator(value) {
126
136
  return [
127
- ...Object.keys(appConfig.ui.input.variant),
128
- ...Object.values(appConfig.ui.input.color).flatMap((value2) => Object.keys(value2))
137
+ ...Object.keys(config.variant),
138
+ ...Object.values(config.color).flatMap((value2) => Object.keys(value2))
129
139
  ].includes(value);
130
140
  }
131
141
  },
@@ -133,22 +143,23 @@ export default defineComponent({
133
143
  type: String,
134
144
  default: null
135
145
  },
146
+ class: {
147
+ type: [String, Object, Array],
148
+ default: void 0
149
+ },
136
150
  ui: {
137
151
  type: Object,
138
- default: () => ({})
152
+ default: void 0
139
153
  }
140
154
  },
141
155
  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);
156
+ setup(props, { emit, slots }) {
157
+ const { ui, attrs } = useUI("input", toRef(props, "ui"), config, toRef(props, "class"));
158
+ const { emitFormBlur, emitFormInput, size, color, inputId, name } = useFormGroup(props, config);
159
+ const input2 = ref(null);
149
160
  const autoFocus = () => {
150
161
  if (props.autofocus) {
151
- input.value?.focus();
162
+ input2.value?.focus();
152
163
  }
153
164
  };
154
165
  const onInput = (event) => {
@@ -162,9 +173,8 @@ export default defineComponent({
162
173
  onMounted(() => {
163
174
  setTimeout(() => {
164
175
  autoFocus();
165
- }, 100);
176
+ }, props.autofocusDelay);
166
177
  });
167
- const wrapperClass = computed(() => twMerge(ui.value.wrapper, attrs.class));
168
178
  const inputClass = computed(() => {
169
179
  const variant = ui.value.color?.[color.value]?.[props.variant] || ui.value.variant[props.variant];
170
180
  return twMerge(twJoin(
@@ -206,7 +216,7 @@ export default defineComponent({
206
216
  const leadingIconClass = computed(() => {
207
217
  return twJoin(
208
218
  ui.value.icon.base,
209
- appConfig2.ui.colors.includes(color.value) && ui.value.icon.color.replaceAll("{color}", color.value),
219
+ appConfig.ui.colors.includes(color.value) && ui.value.icon.color.replaceAll("{color}", color.value),
210
220
  ui.value.icon.size[size.value],
211
221
  props.loading && "animate-spin"
212
222
  );
@@ -221,19 +231,21 @@ export default defineComponent({
221
231
  const trailingIconClass = computed(() => {
222
232
  return twJoin(
223
233
  ui.value.icon.base,
224
- appConfig2.ui.colors.includes(color.value) && ui.value.icon.color.replaceAll("{color}", color.value),
234
+ appConfig.ui.colors.includes(color.value) && ui.value.icon.color.replaceAll("{color}", color.value),
225
235
  ui.value.icon.size[size.value],
226
236
  props.loading && !isLeading.value && "animate-spin"
227
237
  );
228
238
  });
229
239
  return {
230
- attrs: omit(attrs, ["class"]),
231
240
  // eslint-disable-next-line vue/no-dupe-keys
232
241
  ui,
233
- input,
242
+ attrs,
243
+ // eslint-disable-next-line vue/no-dupe-keys
244
+ name,
245
+ inputId,
246
+ input: input2,
234
247
  isLeading,
235
248
  isTrailing,
236
- wrapperClass,
237
249
  // eslint-disable-next-line vue/no-dupe-keys
238
250
  inputClass,
239
251
  leadingIconName,
@@ -1,14 +1,17 @@
1
- /// <reference types="lodash" />
2
1
  import type { PropType } from 'vue';
3
2
  declare const _default: import("vue").DefineComponent<{
4
3
  modelValue: {
5
- type: (StringConstructor | NumberConstructor)[];
4
+ type: (NumberConstructor | StringConstructor)[];
6
5
  default: string;
7
6
  };
8
7
  type: {
9
8
  type: StringConstructor;
10
9
  default: string;
11
10
  };
11
+ id: {
12
+ type: StringConstructor;
13
+ default: null;
14
+ };
12
15
  name: {
13
16
  type: StringConstructor;
14
17
  default: null;
@@ -29,6 +32,10 @@ declare const _default: import("vue").DefineComponent<{
29
32
  type: BooleanConstructor;
30
33
  default: boolean;
31
34
  };
35
+ autofocusDelay: {
36
+ type: NumberConstructor;
37
+ default: number;
38
+ };
32
39
  icon: {
33
40
  type: StringConstructor;
34
41
  default: null;
@@ -62,17 +69,17 @@ declare const _default: import("vue").DefineComponent<{
62
69
  default: boolean;
63
70
  };
64
71
  size: {
65
- type: StringConstructor;
66
- default: () => any;
72
+ type: PropType<string | number | symbol>;
73
+ default: null;
67
74
  validator(value: string): boolean;
68
75
  };
69
76
  color: {
70
- type: StringConstructor;
77
+ type: PropType<any>;
71
78
  default: () => any;
72
79
  validator(value: string): boolean;
73
80
  };
74
81
  variant: {
75
- type: StringConstructor;
82
+ type: PropType<any>;
76
83
  default: () => any;
77
84
  validator(value: string): boolean;
78
85
  };
@@ -80,19 +87,24 @@ declare const _default: import("vue").DefineComponent<{
80
87
  type: StringConstructor;
81
88
  default: null;
82
89
  };
83
- ui: {
90
+ class: {
84
91
  type: PropType<any>;
85
- default: () => {};
92
+ default: undefined;
93
+ };
94
+ ui: {
95
+ type: PropType<Partial<any>>;
96
+ default: undefined;
86
97
  };
87
98
  }, {
88
- attrs: import("lodash").Omit<{
89
- [x: string]: unknown;
90
- }, "class">;
91
99
  ui: import("vue").ComputedRef<any>;
100
+ attrs: import("vue").ComputedRef<Pick<{
101
+ [x: string]: unknown;
102
+ }, string>>;
103
+ name: import("vue").ComputedRef<string | undefined>;
104
+ inputId: import("vue").Ref<string | undefined>;
92
105
  input: import("vue").Ref<HTMLInputElement | null>;
93
106
  isLeading: import("vue").ComputedRef<string | true>;
94
107
  isTrailing: import("vue").ComputedRef<string | true>;
95
- wrapperClass: import("vue").ComputedRef<string>;
96
108
  inputClass: import("vue").ComputedRef<string>;
97
109
  leadingIconName: import("vue").ComputedRef<string | undefined>;
98
110
  leadingIconClass: import("vue").ComputedRef<string>;
@@ -104,13 +116,17 @@ declare const _default: import("vue").DefineComponent<{
104
116
  onBlur: (event: FocusEvent) => void;
105
117
  }, 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<{
106
118
  modelValue: {
107
- type: (StringConstructor | NumberConstructor)[];
119
+ type: (NumberConstructor | StringConstructor)[];
108
120
  default: string;
109
121
  };
110
122
  type: {
111
123
  type: StringConstructor;
112
124
  default: string;
113
125
  };
126
+ id: {
127
+ type: StringConstructor;
128
+ default: null;
129
+ };
114
130
  name: {
115
131
  type: StringConstructor;
116
132
  default: null;
@@ -131,6 +147,10 @@ declare const _default: import("vue").DefineComponent<{
131
147
  type: BooleanConstructor;
132
148
  default: boolean;
133
149
  };
150
+ autofocusDelay: {
151
+ type: NumberConstructor;
152
+ default: number;
153
+ };
134
154
  icon: {
135
155
  type: StringConstructor;
136
156
  default: null;
@@ -164,17 +184,17 @@ declare const _default: import("vue").DefineComponent<{
164
184
  default: boolean;
165
185
  };
166
186
  size: {
167
- type: StringConstructor;
168
- default: () => any;
187
+ type: PropType<string | number | symbol>;
188
+ default: null;
169
189
  validator(value: string): boolean;
170
190
  };
171
191
  color: {
172
- type: StringConstructor;
192
+ type: PropType<any>;
173
193
  default: () => any;
174
194
  validator(value: string): boolean;
175
195
  };
176
196
  variant: {
177
- type: StringConstructor;
197
+ type: PropType<any>;
178
198
  default: () => any;
179
199
  validator(value: string): boolean;
180
200
  };
@@ -182,25 +202,31 @@ declare const _default: import("vue").DefineComponent<{
182
202
  type: StringConstructor;
183
203
  default: null;
184
204
  };
185
- ui: {
205
+ class: {
186
206
  type: PropType<any>;
187
- default: () => {};
207
+ default: undefined;
208
+ };
209
+ ui: {
210
+ type: PropType<Partial<any>>;
211
+ default: undefined;
188
212
  };
189
213
  }>> & {
190
214
  "onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
191
215
  onBlur?: ((...args: any[]) => any) | undefined;
192
216
  }, {
217
+ id: string;
193
218
  icon: string;
194
- color: string;
195
- ui: any;
219
+ color: any;
220
+ ui: Partial<any>;
196
221
  name: string;
197
- type: string;
222
+ class: any;
198
223
  modelValue: string | number;
199
224
  loading: boolean;
225
+ type: string;
200
226
  disabled: boolean;
201
- variant: string;
227
+ variant: any;
202
228
  required: boolean;
203
- size: string;
229
+ size: string | number | symbol;
204
230
  placeholder: string;
205
231
  padded: boolean;
206
232
  loadingIcon: string;
@@ -210,5 +236,6 @@ declare const _default: import("vue").DefineComponent<{
210
236
  leading: boolean;
211
237
  autofocus: boolean;
212
238
  inputClass: string;
239
+ autofocusDelay: number;
213
240
  }, {}>;
214
241
  export default _default;