@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
@@ -1,9 +1,8 @@
1
- /// <reference types="lodash" />
2
1
  import type { PropType } from 'vue';
3
- import type { PopperOptions } from '../../types/popper';
2
+ import type { PopperOptions } from '../../types';
4
3
  declare const _default: import("vue").DefineComponent<{
5
4
  modelValue: {
6
- type: (ObjectConstructor | ArrayConstructor | StringConstructor | NumberConstructor)[];
5
+ type: (ObjectConstructor | NumberConstructor | ArrayConstructor | StringConstructor)[];
7
6
  default: string;
8
7
  };
9
8
  by: {
@@ -17,6 +16,10 @@ declare const _default: import("vue").DefineComponent<{
17
16
  }[]>;
18
17
  default: () => never[];
19
18
  };
19
+ id: {
20
+ type: StringConstructor;
21
+ default: null;
22
+ };
20
23
  name: {
21
24
  type: StringConstructor;
22
25
  default: null;
@@ -90,17 +93,17 @@ declare const _default: import("vue").DefineComponent<{
90
93
  default: boolean;
91
94
  };
92
95
  size: {
93
- type: StringConstructor;
94
- default: () => any;
96
+ type: PropType<string | number | symbol>;
97
+ default: null;
95
98
  validator(value: string): boolean;
96
99
  };
97
100
  color: {
98
- type: StringConstructor;
101
+ type: PropType<any>;
99
102
  default: () => any;
100
103
  validator(value: string): boolean;
101
104
  };
102
105
  variant: {
103
- type: StringConstructor;
106
+ type: PropType<any>;
104
107
  default: () => any;
105
108
  validator(value: string): boolean;
106
109
  };
@@ -124,24 +127,31 @@ declare const _default: import("vue").DefineComponent<{
124
127
  type: StringConstructor;
125
128
  default: null;
126
129
  };
127
- ui: {
130
+ class: {
128
131
  type: PropType<any>;
129
- default: () => {};
132
+ default: undefined;
133
+ };
134
+ ui: {
135
+ type: PropType<Partial<any>>;
136
+ default: undefined;
130
137
  };
131
138
  uiMenu: {
132
- type: PropType<any>;
133
- default: () => {};
139
+ type: PropType<Partial<any>>;
140
+ default: undefined;
134
141
  };
135
142
  }, {
136
- attrs: import("lodash").Omit<{
137
- [x: string]: unknown;
138
- }, "class">;
143
+ ui: import("vue").ComputedRef<any>;
139
144
  uiMenu: import("vue").ComputedRef<any>;
145
+ attrs: import("vue").ComputedRef<Pick<{
146
+ [x: string]: unknown;
147
+ }, string>>;
148
+ name: import("vue").ComputedRef<string | undefined>;
149
+ inputId: import("vue").Ref<string | undefined>;
150
+ popper: import("vue").ComputedRef<PopperOptions>;
140
151
  trigger: import("vue").Ref<import("@vueuse/core").MaybeElement>;
141
152
  container: import("vue").Ref<import("@vueuse/core").MaybeElement>;
142
153
  isLeading: import("vue").ComputedRef<string | true>;
143
154
  isTrailing: import("vue").ComputedRef<string | true | undefined>;
144
- wrapperClass: import("vue").ComputedRef<string>;
145
155
  selectClass: import("vue").ComputedRef<string>;
146
156
  leadingIconName: import("vue").ComputedRef<string | undefined>;
147
157
  leadingIconClass: import("vue").ComputedRef<string>;
@@ -155,9 +165,9 @@ declare const _default: import("vue").DefineComponent<{
155
165
  } | null>;
156
166
  query: import("vue").Ref<string>;
157
167
  onUpdate: (event: any) => void;
158
- }, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("change" | "close" | "open" | "update:modelValue")[], "change" | "close" | "open" | "update:modelValue", import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
168
+ }, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("change" | "close" | "update:modelValue" | "open")[], "change" | "close" | "update:modelValue" | "open", import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
159
169
  modelValue: {
160
- type: (ObjectConstructor | ArrayConstructor | StringConstructor | NumberConstructor)[];
170
+ type: (ObjectConstructor | NumberConstructor | ArrayConstructor | StringConstructor)[];
161
171
  default: string;
162
172
  };
163
173
  by: {
@@ -171,6 +181,10 @@ declare const _default: import("vue").DefineComponent<{
171
181
  }[]>;
172
182
  default: () => never[];
173
183
  };
184
+ id: {
185
+ type: StringConstructor;
186
+ default: null;
187
+ };
174
188
  name: {
175
189
  type: StringConstructor;
176
190
  default: null;
@@ -244,17 +258,17 @@ declare const _default: import("vue").DefineComponent<{
244
258
  default: boolean;
245
259
  };
246
260
  size: {
247
- type: StringConstructor;
248
- default: () => any;
261
+ type: PropType<string | number | symbol>;
262
+ default: null;
249
263
  validator(value: string): boolean;
250
264
  };
251
265
  color: {
252
- type: StringConstructor;
266
+ type: PropType<any>;
253
267
  default: () => any;
254
268
  validator(value: string): boolean;
255
269
  };
256
270
  variant: {
257
- type: StringConstructor;
271
+ type: PropType<any>;
258
272
  default: () => any;
259
273
  validator(value: string): boolean;
260
274
  };
@@ -278,37 +292,43 @@ declare const _default: import("vue").DefineComponent<{
278
292
  type: StringConstructor;
279
293
  default: null;
280
294
  };
281
- ui: {
295
+ class: {
282
296
  type: PropType<any>;
283
- default: () => {};
297
+ default: undefined;
298
+ };
299
+ ui: {
300
+ type: PropType<Partial<any>>;
301
+ default: undefined;
284
302
  };
285
303
  uiMenu: {
286
- type: PropType<any>;
287
- default: () => {};
304
+ type: PropType<Partial<any>>;
305
+ default: undefined;
288
306
  };
289
307
  }>> & {
290
- onClose?: ((...args: any[]) => any) | undefined;
291
- onOpen?: ((...args: any[]) => any) | undefined;
292
308
  "onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
293
309
  onChange?: ((...args: any[]) => any) | undefined;
310
+ onClose?: ((...args: any[]) => any) | undefined;
311
+ onOpen?: ((...args: any[]) => any) | undefined;
294
312
  }, {
313
+ id: string;
295
314
  icon: string;
296
- color: string;
297
- ui: any;
298
- name: string;
315
+ color: any;
316
+ ui: Partial<any>;
299
317
  options: string[] | {
300
318
  [key: string]: any;
301
319
  disabled?: boolean | undefined;
302
320
  }[];
303
321
  popper: PopperOptions;
322
+ name: string;
323
+ class: any;
304
324
  modelValue: string | number | unknown[] | Record<string, any>;
305
325
  by: string;
306
326
  loading: boolean;
307
327
  disabled: boolean;
308
328
  multiple: boolean;
309
- variant: string;
329
+ variant: any;
310
330
  required: boolean;
311
- size: string;
331
+ size: string | number | symbol;
312
332
  placeholder: string;
313
333
  padded: boolean;
314
334
  loadingIcon: string;
@@ -325,6 +345,6 @@ declare const _default: import("vue").DefineComponent<{
325
345
  debounce: number;
326
346
  creatable: boolean;
327
347
  searchAttributes: unknown[];
328
- uiMenu: any;
348
+ uiMenu: Partial<any>;
329
349
  }, {}>;
330
350
  export default _default;
@@ -1,6 +1,7 @@
1
1
  <template>
2
- <div :class="wrapperClass">
2
+ <div :class="ui.wrapper">
3
3
  <textarea
4
+ :id="inputId"
4
5
  ref="textarea"
5
6
  :value="modelValue"
6
7
  :name="name"
@@ -18,13 +19,14 @@
18
19
  </template>
19
20
 
20
21
  <script>
21
- import { ref, computed, watch, onMounted, nextTick, defineComponent } from "vue";
22
- import { omit } from "lodash-es";
22
+ import { ref, computed, toRef, watch, onMounted, nextTick, defineComponent } from "vue";
23
23
  import { twMerge, twJoin } from "tailwind-merge";
24
- import { defuTwMerge } from "../../utils";
24
+ import { useUI } from "../../composables/useUI";
25
25
  import { useFormGroup } from "../../composables/useFormGroup";
26
- import { useAppConfig } from "#imports";
26
+ import { mergeConfig } from "../../utils";
27
27
  import appConfig from "#build/app.config";
28
+ import { textarea } from "#ui/ui.config";
29
+ const config = mergeConfig(appConfig.ui.strategy, appConfig.ui.textarea, textarea);
28
30
  export default defineComponent({
29
31
  inheritAttrs: false,
30
32
  props: {
@@ -32,6 +34,10 @@ export default defineComponent({
32
34
  type: [String, Number],
33
35
  default: ""
34
36
  },
37
+ id: {
38
+ type: String,
39
+ default: null
40
+ },
35
41
  name: {
36
42
  type: String,
37
43
  default: null
@@ -60,6 +66,10 @@ export default defineComponent({
60
66
  type: Boolean,
61
67
  default: false
62
68
  },
69
+ autofocusDelay: {
70
+ type: Number,
71
+ default: 100
72
+ },
63
73
  resize: {
64
74
  type: Boolean,
65
75
  default: false
@@ -70,25 +80,25 @@ export default defineComponent({
70
80
  },
71
81
  size: {
72
82
  type: String,
73
- default: () => appConfig.ui.textarea.default.size,
83
+ default: null,
74
84
  validator(value) {
75
- return Object.keys(appConfig.ui.textarea.size).includes(value);
85
+ return Object.keys(config.size).includes(value);
76
86
  }
77
87
  },
78
88
  color: {
79
89
  type: String,
80
- default: () => appConfig.ui.textarea.default.color,
90
+ default: () => config.default.color,
81
91
  validator(value) {
82
- return [...appConfig.ui.colors, ...Object.keys(appConfig.ui.textarea.color)].includes(value);
92
+ return [...appConfig.ui.colors, ...Object.keys(config.color)].includes(value);
83
93
  }
84
94
  },
85
95
  variant: {
86
96
  type: String,
87
- default: () => appConfig.ui.textarea.default.variant,
97
+ default: () => config.default.variant,
88
98
  validator(value) {
89
99
  return [
90
- ...Object.keys(appConfig.ui.textarea.variant),
91
- ...Object.values(appConfig.ui.textarea.color).flatMap((value2) => Object.keys(value2))
100
+ ...Object.keys(config.variant),
101
+ ...Object.values(config.color).flatMap((value2) => Object.keys(value2))
92
102
  ].includes(value);
93
103
  }
94
104
  },
@@ -96,39 +106,40 @@ export default defineComponent({
96
106
  type: String,
97
107
  default: null
98
108
  },
109
+ class: {
110
+ type: [String, Object, Array],
111
+ default: void 0
112
+ },
99
113
  ui: {
100
114
  type: Object,
101
- default: () => ({})
115
+ default: void 0
102
116
  }
103
117
  },
104
118
  emits: ["update:modelValue", "blur"],
105
- setup(props, { emit, attrs }) {
106
- const textarea = ref(null);
107
- const appConfig2 = useAppConfig();
108
- const ui = computed(() => defuTwMerge({}, props.ui, appConfig2.ui.textarea));
109
- const { emitFormBlur, emitFormInput, formGroup } = useFormGroup();
110
- const color = computed(() => formGroup?.error?.value ? "red" : props.color);
111
- const size = computed(() => formGroup?.size?.value ?? props.size);
119
+ setup(props, { emit }) {
120
+ const { ui, attrs } = useUI("textarea", toRef(props, "ui"), config, toRef(props, "class"));
121
+ const { emitFormBlur, emitFormInput, inputId, color, size, name } = useFormGroup(props, config);
122
+ const textarea2 = ref(null);
112
123
  const autoFocus = () => {
113
124
  if (props.autofocus) {
114
- textarea.value?.focus();
125
+ textarea2.value?.focus();
115
126
  }
116
127
  };
117
128
  const autoResize = () => {
118
129
  if (props.autoresize) {
119
- if (!textarea.value) {
130
+ if (!textarea2.value) {
120
131
  return;
121
132
  }
122
- textarea.value.rows = props.rows;
123
- const styles = window.getComputedStyle(textarea.value);
133
+ textarea2.value.rows = props.rows;
134
+ const styles = window.getComputedStyle(textarea2.value);
124
135
  const paddingTop = parseInt(styles.paddingTop);
125
136
  const paddingBottom = parseInt(styles.paddingBottom);
126
137
  const padding = paddingTop + paddingBottom;
127
138
  const lineHeight = parseInt(styles.lineHeight);
128
- const { scrollHeight } = textarea.value;
139
+ const { scrollHeight } = textarea2.value;
129
140
  const newRows = (scrollHeight - padding) / lineHeight;
130
141
  if (newRows > props.rows) {
131
- textarea.value.rows = newRows;
142
+ textarea2.value.rows = newRows;
132
143
  }
133
144
  }
134
145
  };
@@ -144,7 +155,7 @@ export default defineComponent({
144
155
  onMounted(() => {
145
156
  setTimeout(() => {
146
157
  autoFocus();
147
- }, 100);
158
+ }, props.autofocusDelay);
148
159
  });
149
160
  watch(() => props.modelValue, () => {
150
161
  nextTick(autoResize);
@@ -155,7 +166,6 @@ export default defineComponent({
155
166
  autoResize();
156
167
  }, 100);
157
168
  });
158
- const wrapperClass = computed(() => twMerge(ui.value.wrapper, attrs.class));
159
169
  const textareaClass = computed(() => {
160
170
  const variant = ui.value.color?.[color.value]?.[props.variant] || ui.value.variant[props.variant];
161
171
  return twMerge(twJoin(
@@ -169,11 +179,13 @@ export default defineComponent({
169
179
  ), props.textareaClass);
170
180
  });
171
181
  return {
172
- attrs: omit(attrs, ["class"]),
173
182
  // eslint-disable-next-line vue/no-dupe-keys
174
183
  ui,
175
- textarea,
176
- wrapperClass,
184
+ attrs,
185
+ // eslint-disable-next-line vue/no-dupe-keys
186
+ name,
187
+ inputId,
188
+ textarea: textarea2,
177
189
  // eslint-disable-next-line vue/no-dupe-keys
178
190
  textareaClass,
179
191
  onInput,
@@ -1,10 +1,13 @@
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
  };
7
+ id: {
8
+ type: StringConstructor;
9
+ default: null;
10
+ };
8
11
  name: {
9
12
  type: StringConstructor;
10
13
  default: null;
@@ -33,6 +36,10 @@ declare const _default: import("vue").DefineComponent<{
33
36
  type: BooleanConstructor;
34
37
  default: boolean;
35
38
  };
39
+ autofocusDelay: {
40
+ type: NumberConstructor;
41
+ default: number;
42
+ };
36
43
  resize: {
37
44
  type: BooleanConstructor;
38
45
  default: boolean;
@@ -42,17 +49,17 @@ declare const _default: import("vue").DefineComponent<{
42
49
  default: boolean;
43
50
  };
44
51
  size: {
45
- type: StringConstructor;
46
- default: () => any;
52
+ type: PropType<string | number | symbol>;
53
+ default: null;
47
54
  validator(value: string): boolean;
48
55
  };
49
56
  color: {
50
- type: StringConstructor;
57
+ type: PropType<any>;
51
58
  default: () => any;
52
59
  validator(value: string): boolean;
53
60
  };
54
61
  variant: {
55
- type: StringConstructor;
62
+ type: PropType<any>;
56
63
  default: () => any;
57
64
  validator(value: string): boolean;
58
65
  };
@@ -60,25 +67,34 @@ declare const _default: import("vue").DefineComponent<{
60
67
  type: StringConstructor;
61
68
  default: null;
62
69
  };
63
- ui: {
70
+ class: {
64
71
  type: PropType<any>;
65
- default: () => {};
72
+ default: undefined;
73
+ };
74
+ ui: {
75
+ type: PropType<Partial<any>>;
76
+ default: undefined;
66
77
  };
67
78
  }, {
68
- attrs: import("lodash").Omit<{
69
- [x: string]: unknown;
70
- }, "class">;
71
79
  ui: import("vue").ComputedRef<any>;
80
+ attrs: import("vue").ComputedRef<Pick<{
81
+ [x: string]: unknown;
82
+ }, string>>;
83
+ name: import("vue").ComputedRef<string | undefined>;
84
+ inputId: import("vue").Ref<string | undefined>;
72
85
  textarea: import("vue").Ref<HTMLTextAreaElement | null>;
73
- wrapperClass: import("vue").ComputedRef<string>;
74
86
  textareaClass: import("vue").ComputedRef<string>;
75
87
  onInput: (event: InputEvent) => void;
76
88
  onBlur: (event: FocusEvent) => void;
77
89
  }, 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<{
78
90
  modelValue: {
79
- type: (StringConstructor | NumberConstructor)[];
91
+ type: (NumberConstructor | StringConstructor)[];
80
92
  default: string;
81
93
  };
94
+ id: {
95
+ type: StringConstructor;
96
+ default: null;
97
+ };
82
98
  name: {
83
99
  type: StringConstructor;
84
100
  default: null;
@@ -107,6 +123,10 @@ declare const _default: import("vue").DefineComponent<{
107
123
  type: BooleanConstructor;
108
124
  default: boolean;
109
125
  };
126
+ autofocusDelay: {
127
+ type: NumberConstructor;
128
+ default: number;
129
+ };
110
130
  resize: {
111
131
  type: BooleanConstructor;
112
132
  default: boolean;
@@ -116,17 +136,17 @@ declare const _default: import("vue").DefineComponent<{
116
136
  default: boolean;
117
137
  };
118
138
  size: {
119
- type: StringConstructor;
120
- default: () => any;
139
+ type: PropType<string | number | symbol>;
140
+ default: null;
121
141
  validator(value: string): boolean;
122
142
  };
123
143
  color: {
124
- type: StringConstructor;
144
+ type: PropType<any>;
125
145
  default: () => any;
126
146
  validator(value: string): boolean;
127
147
  };
128
148
  variant: {
129
- type: StringConstructor;
149
+ type: PropType<any>;
130
150
  default: () => any;
131
151
  validator(value: string): boolean;
132
152
  };
@@ -134,27 +154,34 @@ declare const _default: import("vue").DefineComponent<{
134
154
  type: StringConstructor;
135
155
  default: null;
136
156
  };
137
- ui: {
157
+ class: {
138
158
  type: PropType<any>;
139
- default: () => {};
159
+ default: undefined;
160
+ };
161
+ ui: {
162
+ type: PropType<Partial<any>>;
163
+ default: undefined;
140
164
  };
141
165
  }>> & {
142
166
  "onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
143
167
  onBlur?: ((...args: any[]) => any) | undefined;
144
168
  }, {
145
169
  resize: boolean;
146
- color: string;
147
- ui: any;
170
+ id: string;
171
+ color: any;
172
+ ui: Partial<any>;
148
173
  name: string;
174
+ class: any;
149
175
  modelValue: string | number;
150
176
  rows: number;
151
177
  disabled: boolean;
152
- variant: string;
178
+ variant: any;
153
179
  required: boolean;
154
- size: string;
180
+ size: string | number | symbol;
155
181
  placeholder: string;
156
182
  padded: boolean;
157
183
  autofocus: boolean;
184
+ autofocusDelay: number;
158
185
  autoresize: boolean;
159
186
  textareaClass: string;
160
187
  }, {}>;
@@ -1,5 +1,6 @@
1
1
  <template>
2
2
  <HSwitch
3
+ :id="inputId"
3
4
  v-model="active"
4
5
  :name="name"
5
6
  :disabled="disabled"
@@ -18,15 +19,16 @@
18
19
  </template>
19
20
 
20
21
  <script>
21
- import { computed, defineComponent } from "vue";
22
+ import { computed, toRef, defineComponent } from "vue";
22
23
  import { Switch as HSwitch } from "@headlessui/vue";
23
- import { omit } from "lodash-es";
24
24
  import { twMerge, twJoin } from "tailwind-merge";
25
25
  import UIcon from "../elements/Icon.vue";
26
- import { defuTwMerge } from "../../utils";
26
+ import { useUI } from "../../composables/useUI";
27
27
  import { useFormGroup } from "../../composables/useFormGroup";
28
- import { useAppConfig } from "#imports";
28
+ import { mergeConfig } from "../../utils";
29
29
  import appConfig from "#build/app.config";
30
+ import { toggle } from "#ui/ui.config";
31
+ const config = mergeConfig(appConfig.ui.strategy, appConfig.ui.toggle, toggle);
30
32
  export default defineComponent({
31
33
  components: {
32
34
  HSwitch,
@@ -34,6 +36,10 @@ export default defineComponent({
34
36
  },
35
37
  inheritAttrs: false,
36
38
  props: {
39
+ id: {
40
+ type: String,
41
+ default: null
42
+ },
37
43
  name: {
38
44
  type: String,
39
45
  default: null
@@ -48,30 +54,32 @@ export default defineComponent({
48
54
  },
49
55
  onIcon: {
50
56
  type: String,
51
- default: () => appConfig.ui.toggle.default.onIcon
57
+ default: () => config.default.onIcon
52
58
  },
53
59
  offIcon: {
54
60
  type: String,
55
- default: () => appConfig.ui.toggle.default.offIcon
61
+ default: () => config.default.offIcon
56
62
  },
57
63
  color: {
58
64
  type: String,
59
- default: () => appConfig.ui.toggle.default.color,
65
+ default: () => config.default.color,
60
66
  validator(value) {
61
67
  return appConfig.ui.colors.includes(value);
62
68
  }
63
69
  },
70
+ class: {
71
+ type: [String, Object, Array],
72
+ default: void 0
73
+ },
64
74
  ui: {
65
75
  type: Object,
66
- default: () => ({})
76
+ default: void 0
67
77
  }
68
78
  },
69
79
  emits: ["update:modelValue"],
70
- setup(props, { emit, attrs }) {
71
- const appConfig2 = useAppConfig();
72
- const ui = computed(() => defuTwMerge({}, props.ui, appConfig2.ui.toggle));
73
- const { emitFormChange, formGroup } = useFormGroup();
74
- const color = computed(() => formGroup?.error?.value ? "red" : props.color);
80
+ setup(props, { emit }) {
81
+ const { ui, attrs } = useUI("toggle", toRef(props, "ui"), config);
82
+ const { emitFormChange, color, inputId, name } = useFormGroup(props);
75
83
  const active = computed({
76
84
  get() {
77
85
  return props.modelValue;
@@ -87,7 +95,7 @@ export default defineComponent({
87
95
  ui.value.rounded,
88
96
  ui.value.ring.replaceAll("{color}", color.value),
89
97
  (active.value ? ui.value.active : ui.value.inactive).replaceAll("{color}", color.value)
90
- ), attrs.class);
98
+ ), props.class);
91
99
  });
92
100
  const onIconClass = computed(() => {
93
101
  return twJoin(
@@ -100,9 +108,12 @@ export default defineComponent({
100
108
  );
101
109
  });
102
110
  return {
103
- attrs: omit(attrs, ["class"]),
104
111
  // eslint-disable-next-line vue/no-dupe-keys
105
112
  ui,
113
+ attrs,
114
+ // eslint-disable-next-line vue/no-dupe-keys
115
+ name,
116
+ inputId,
106
117
  active,
107
118
  switchClass,
108
119
  onIconClass,