@nuxt/ui 2.10.0 → 2.11.1

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 (208) hide show
  1. package/README.md +11 -0
  2. package/dist/module.d.mts +387 -104
  3. package/dist/module.d.ts +387 -104
  4. package/dist/module.json +1 -1
  5. package/dist/module.mjs +16 -7
  6. package/dist/runtime/components/data/Table.vue +3 -3
  7. package/dist/runtime/components/data/Table.vue.d.ts +7 -7
  8. package/dist/runtime/components/elements/Accordion.vue +2 -2
  9. package/dist/runtime/components/elements/Accordion.vue.d.ts +7 -7
  10. package/dist/runtime/components/elements/Alert.vue +13 -12
  11. package/dist/runtime/components/elements/Alert.vue.d.ts +12 -11
  12. package/dist/runtime/components/elements/Avatar.vue +2 -2
  13. package/dist/runtime/components/elements/Avatar.vue.d.ts +11 -10
  14. package/dist/runtime/components/elements/AvatarGroup.d.ts +11 -10
  15. package/dist/runtime/components/elements/AvatarGroup.mjs +2 -2
  16. package/dist/runtime/components/elements/Badge.vue +6 -4
  17. package/dist/runtime/components/elements/Badge.vue.d.ts +11 -11
  18. package/dist/runtime/components/elements/Button.vue +16 -12
  19. package/dist/runtime/components/elements/Button.vue.d.ts +13 -12
  20. package/dist/runtime/components/elements/ButtonGroup.d.ts +12 -11
  21. package/dist/runtime/components/elements/ButtonGroup.mjs +8 -34
  22. package/dist/runtime/components/elements/Chip.vue +85 -0
  23. package/dist/runtime/components/elements/Chip.vue.d.ts +90 -0
  24. package/dist/runtime/components/elements/Dropdown.vue +35 -21
  25. package/dist/runtime/components/elements/Dropdown.vue.d.ts +13 -7
  26. package/dist/runtime/components/elements/Icon.vue +16 -2
  27. package/dist/runtime/components/elements/Icon.vue.d.ts +14 -2
  28. package/dist/runtime/components/elements/Kbd.vue +2 -2
  29. package/dist/runtime/components/elements/Kbd.vue.d.ts +12 -11
  30. package/dist/runtime/components/elements/Link.vue +2 -5
  31. package/dist/runtime/components/elements/Meter.vue +2 -2
  32. package/dist/runtime/components/elements/Meter.vue.d.ts +9 -9
  33. package/dist/runtime/components/elements/MeterGroup.d.ts +10 -10
  34. package/dist/runtime/components/elements/MeterGroup.mjs +8 -21
  35. package/dist/runtime/components/elements/Progress.vue +6 -95
  36. package/dist/runtime/components/elements/Progress.vue.d.ts +123 -1
  37. package/dist/runtime/components/forms/Checkbox.vue +8 -10
  38. package/dist/runtime/components/forms/Checkbox.vue.d.ts +10 -10
  39. package/dist/runtime/components/forms/Form.vue +1 -1
  40. package/dist/runtime/components/forms/FormGroup.vue +9 -5
  41. package/dist/runtime/components/forms/FormGroup.vue.d.ts +21 -11
  42. package/dist/runtime/components/forms/Input.vue +43 -12
  43. package/dist/runtime/components/forms/Input.vue.d.ts +38 -15
  44. package/dist/runtime/components/forms/Radio.vue +18 -12
  45. package/dist/runtime/components/forms/Radio.vue.d.ts +11 -10
  46. package/dist/runtime/components/forms/RadioGroup.vue +3 -3
  47. package/dist/runtime/components/forms/RadioGroup.vue.d.ts +13 -13
  48. package/dist/runtime/components/forms/Range.vue +5 -5
  49. package/dist/runtime/components/forms/Range.vue.d.ts +11 -10
  50. package/dist/runtime/components/forms/Select.vue +12 -9
  51. package/dist/runtime/components/forms/Select.vue.d.ts +15 -14
  52. package/dist/runtime/components/forms/SelectMenu.vue +42 -25
  53. package/dist/runtime/components/forms/SelectMenu.vue.d.ts +28 -19
  54. package/dist/runtime/components/forms/Textarea.vue +36 -6
  55. package/dist/runtime/components/forms/Textarea.vue.d.ts +37 -14
  56. package/dist/runtime/components/forms/Toggle.vue +25 -7
  57. package/dist/runtime/components/forms/Toggle.vue.d.ts +20 -7
  58. package/dist/runtime/components/layout/Card.vue +2 -2
  59. package/dist/runtime/components/layout/Card.vue.d.ts +7 -7
  60. package/dist/runtime/components/layout/Container.vue +2 -2
  61. package/dist/runtime/components/layout/Container.vue.d.ts +7 -7
  62. package/dist/runtime/components/layout/Divider.vue +3 -8
  63. package/dist/runtime/components/layout/Divider.vue.d.ts +9 -9
  64. package/dist/runtime/components/layout/Skeleton.vue +2 -2
  65. package/dist/runtime/components/layout/Skeleton.vue.d.ts +7 -7
  66. package/dist/runtime/components/navigation/Breadcrumb.vue +78 -0
  67. package/dist/runtime/components/navigation/Breadcrumb.vue.d.ts +50 -0
  68. package/dist/runtime/components/navigation/CommandPalette.vue +50 -37
  69. package/dist/runtime/components/navigation/CommandPalette.vue.d.ts +15 -8
  70. package/dist/runtime/components/navigation/CommandPaletteGroup.vue +1 -3
  71. package/dist/runtime/components/navigation/Pagination.vue +7 -7
  72. package/dist/runtime/components/navigation/Pagination.vue.d.ts +11 -11
  73. package/dist/runtime/components/navigation/Tabs.vue +8 -5
  74. package/dist/runtime/components/navigation/Tabs.vue.d.ts +10 -10
  75. package/dist/runtime/components/navigation/VerticalNavigation.vue +2 -2
  76. package/dist/runtime/components/navigation/VerticalNavigation.vue.d.ts +7 -7
  77. package/dist/runtime/components/overlays/ContextMenu.vue +4 -3
  78. package/dist/runtime/components/overlays/ContextMenu.vue.d.ts +7 -7
  79. package/dist/runtime/components/overlays/Modal.vue +3 -6
  80. package/dist/runtime/components/overlays/Modal.vue.d.ts +7 -7
  81. package/dist/runtime/components/overlays/Notification.vue +30 -31
  82. package/dist/runtime/components/overlays/Notification.vue.d.ts +10 -9
  83. package/dist/runtime/components/overlays/Notifications.vue +18 -16
  84. package/dist/runtime/components/overlays/Notifications.vue.d.ts +7 -7
  85. package/dist/runtime/components/overlays/Popover.vue +14 -4
  86. package/dist/runtime/components/overlays/Popover.vue.d.ts +20 -9
  87. package/dist/runtime/components/overlays/Slideover.vue +6 -6
  88. package/dist/runtime/components/overlays/Slideover.vue.d.ts +7 -7
  89. package/dist/runtime/components/overlays/Tooltip.vue +6 -5
  90. package/dist/runtime/components/overlays/Tooltip.vue.d.ts +7 -7
  91. package/dist/runtime/composables/defineShortcuts.d.ts +1 -1
  92. package/dist/runtime/composables/defineShortcuts.mjs +8 -4
  93. package/dist/runtime/composables/useButtonGroup.d.ts +20 -0
  94. package/dist/runtime/composables/useButtonGroup.mjs +52 -0
  95. package/dist/runtime/composables/useFormGroup.d.ts +2 -0
  96. package/dist/runtime/composables/useFormGroup.mjs +3 -2
  97. package/dist/runtime/composables/useShortcuts.d.ts +2 -2
  98. package/dist/runtime/composables/useUI.d.ts +3 -3
  99. package/dist/runtime/types/alert.d.ts +7 -0
  100. package/dist/runtime/types/avatar.d.ts +3 -1
  101. package/dist/runtime/types/badge.d.ts +5 -4
  102. package/dist/runtime/types/breadcrumb.d.ts +9 -0
  103. package/dist/runtime/types/button.d.ts +5 -4
  104. package/dist/runtime/types/chip.d.ts +11 -0
  105. package/dist/runtime/types/dropdown.d.ts +2 -2
  106. package/dist/runtime/types/form-group.d.ts +5 -0
  107. package/dist/runtime/types/form.d.ts +3 -2
  108. package/dist/runtime/types/index.d.ts +10 -0
  109. package/dist/runtime/types/input.d.ts +8 -0
  110. package/dist/runtime/types/kbd.d.ts +5 -0
  111. package/dist/runtime/types/popper.d.ts +2 -0
  112. package/dist/runtime/types/range.d.ts +5 -0
  113. package/dist/runtime/types/select.d.ts +8 -0
  114. package/dist/runtime/types/textarea.d.ts +8 -0
  115. package/dist/runtime/types/toggle.d.ts +5 -0
  116. package/dist/runtime/types/utils.d.ts +24 -7
  117. package/dist/runtime/ui.config/data/table.d.ts +60 -0
  118. package/dist/runtime/ui.config/data/table.mjs +59 -0
  119. package/dist/runtime/ui.config/elements/accordion.d.ts +21 -0
  120. package/dist/runtime/ui.config/elements/accordion.mjs +20 -0
  121. package/dist/runtime/ui.config/elements/alert.d.ts +41 -0
  122. package/dist/runtime/ui.config/elements/alert.mjs +40 -0
  123. package/dist/runtime/ui.config/elements/avatar.d.ts +60 -0
  124. package/dist/runtime/ui.config/elements/avatar.mjs +59 -0
  125. package/dist/runtime/ui.config/elements/avatarGroup.d.ts +6 -0
  126. package/dist/runtime/ui.config/elements/avatarGroup.mjs +5 -0
  127. package/dist/runtime/ui.config/elements/badge.d.ts +34 -0
  128. package/dist/runtime/ui.config/elements/badge.mjs +33 -0
  129. package/dist/runtime/ui.config/elements/button.d.ts +81 -0
  130. package/dist/runtime/ui.config/elements/button.mjs +80 -0
  131. package/dist/runtime/ui.config/elements/buttonGroup.d.ts +101 -0
  132. package/dist/runtime/ui.config/elements/buttonGroup.mjs +19 -0
  133. package/dist/runtime/ui.config/elements/chip.d.ts +35 -0
  134. package/dist/runtime/ui.config/elements/chip.mjs +34 -0
  135. package/dist/runtime/ui.config/elements/dropdown.d.ts +55 -0
  136. package/dist/runtime/ui.config/elements/dropdown.mjs +53 -0
  137. package/dist/runtime/ui.config/elements/kbd.d.ts +17 -0
  138. package/dist/runtime/ui.config/elements/kbd.mjs +16 -0
  139. package/dist/runtime/ui.config/elements/meter.d.ts +77 -0
  140. package/dist/runtime/ui.config/elements/meter.mjs +76 -0
  141. package/dist/runtime/ui.config/elements/meterGroup.d.ts +52 -0
  142. package/dist/runtime/ui.config/elements/meterGroup.mjs +24 -0
  143. package/dist/runtime/ui.config/elements/progress.d.ts +75 -0
  144. package/dist/runtime/ui.config/elements/progress.mjs +74 -0
  145. package/dist/runtime/ui.config/forms/checkbox.d.ts +19 -0
  146. package/dist/runtime/ui.config/forms/checkbox.mjs +18 -0
  147. package/dist/runtime/ui.config/forms/formGroup.d.ts +25 -0
  148. package/dist/runtime/ui.config/forms/formGroup.mjs +25 -0
  149. package/dist/runtime/ui.config/forms/input.d.ts +107 -0
  150. package/dist/runtime/ui.config/forms/input.mjs +106 -0
  151. package/dist/runtime/ui.config/forms/radio.d.ts +18 -0
  152. package/dist/runtime/ui.config/forms/radio.mjs +17 -0
  153. package/dist/runtime/ui.config/forms/radioGroup.d.ts +8 -0
  154. package/dist/runtime/ui.config/forms/radioGroup.mjs +7 -0
  155. package/dist/runtime/ui.config/forms/range.d.ts +64 -0
  156. package/dist/runtime/ui.config/forms/range.mjs +63 -0
  157. package/dist/runtime/ui.config/forms/select.d.ts +108 -0
  158. package/dist/runtime/ui.config/forms/select.mjs +13 -0
  159. package/dist/runtime/ui.config/forms/selectMenu.d.ts +68 -0
  160. package/dist/runtime/ui.config/forms/selectMenu.mjs +66 -0
  161. package/dist/runtime/ui.config/forms/textarea.d.ts +106 -0
  162. package/dist/runtime/ui.config/forms/textarea.mjs +10 -0
  163. package/dist/runtime/ui.config/forms/toggle.d.ts +61 -0
  164. package/dist/runtime/ui.config/forms/toggle.mjs +60 -0
  165. package/dist/runtime/ui.config/index.d.ts +40 -0
  166. package/dist/runtime/ui.config/index.mjs +40 -0
  167. package/dist/runtime/ui.config/layout/card.d.ts +24 -0
  168. package/dist/runtime/ui.config/layout/card.mjs +23 -0
  169. package/dist/runtime/ui.config/layout/container.d.ts +6 -0
  170. package/dist/runtime/ui.config/layout/container.mjs +5 -0
  171. package/dist/runtime/ui.config/layout/divider.d.ts +35 -0
  172. package/dist/runtime/ui.config/layout/divider.mjs +34 -0
  173. package/dist/runtime/ui.config/layout/skeleton.d.ts +6 -0
  174. package/dist/runtime/ui.config/layout/skeleton.mjs +5 -0
  175. package/dist/runtime/ui.config/navigation/breadcrumb.d.ts +20 -0
  176. package/dist/runtime/ui.config/navigation/breadcrumb.mjs +19 -0
  177. package/dist/runtime/ui.config/navigation/commandPalette.d.ts +72 -0
  178. package/dist/runtime/ui.config/navigation/commandPalette.mjs +71 -0
  179. package/dist/runtime/ui.config/navigation/pagination.d.ts +35 -0
  180. package/dist/runtime/ui.config/navigation/pagination.mjs +34 -0
  181. package/dist/runtime/ui.config/navigation/tabs.d.ts +34 -0
  182. package/dist/runtime/ui.config/navigation/tabs.mjs +33 -0
  183. package/dist/runtime/ui.config/navigation/verticalNavigation.d.ts +28 -0
  184. package/dist/runtime/ui.config/navigation/verticalNavigation.mjs +27 -0
  185. package/dist/runtime/ui.config/overlays/contextMenu.d.ts +31 -0
  186. package/dist/runtime/ui.config/overlays/contextMenu.mjs +25 -0
  187. package/dist/runtime/ui.config/overlays/modal.d.ts +36 -0
  188. package/dist/runtime/ui.config/overlays/modal.mjs +37 -0
  189. package/dist/runtime/ui.config/overlays/notification.d.ts +50 -0
  190. package/dist/runtime/ui.config/overlays/notification.mjs +50 -0
  191. package/dist/runtime/ui.config/overlays/notifications.d.ts +7 -0
  192. package/dist/runtime/ui.config/overlays/notifications.mjs +6 -0
  193. package/dist/runtime/ui.config/overlays/popover.d.ts +43 -0
  194. package/dist/runtime/ui.config/overlays/popover.mjs +37 -0
  195. package/dist/runtime/ui.config/overlays/slideover.d.ts +32 -0
  196. package/dist/runtime/ui.config/overlays/slideover.mjs +33 -0
  197. package/dist/runtime/ui.config/overlays/tooltip.d.ts +33 -0
  198. package/dist/runtime/ui.config/overlays/tooltip.mjs +27 -0
  199. package/dist/runtime/ui.config/popper.d.ts +8 -0
  200. package/dist/runtime/ui.config/popper.mjs +8 -0
  201. package/dist/runtime/ui.css +1 -13
  202. package/dist/runtime/utils/index.d.ts +5 -0
  203. package/dist/runtime/utils/index.mjs +7 -3
  204. package/dist/types.d.mts +3 -2
  205. package/dist/types.d.ts +3 -2
  206. package/package.json +32 -21
  207. package/dist/runtime/ui.config.d.ts +0 -1470
  208. package/dist/runtime/ui.config.mjs +0 -1273
@@ -6,7 +6,6 @@
6
6
  :value="modelValue"
7
7
  :required="required"
8
8
  :disabled="disabled || loading"
9
- class="form-select"
10
9
  :class="selectClass"
11
10
  v-bind="attrs"
12
11
  @input="onInput"
@@ -60,6 +59,7 @@ import UIcon from "../elements/Icon.vue";
60
59
  import { useUI } from "../../composables/useUI";
61
60
  import { useFormGroup } from "../../composables/useFormGroup";
62
61
  import { mergeConfig, get } from "../../utils";
62
+ import { useInjectButtonGroup } from "../../composables/useButtonGroup";
63
63
  import appConfig from "#build/app.config";
64
64
  import { select } from "#ui/ui.config";
65
65
  const config = mergeConfig(appConfig.ui.strategy, appConfig.ui.select, select);
@@ -167,17 +167,19 @@ export default defineComponent({
167
167
  },
168
168
  class: {
169
169
  type: [String, Object, Array],
170
- default: void 0
170
+ default: () => ""
171
171
  },
172
172
  ui: {
173
173
  type: Object,
174
- default: void 0
174
+ default: () => ({})
175
175
  }
176
176
  },
177
177
  emits: ["update:modelValue", "change"],
178
178
  setup(props, { emit, slots }) {
179
179
  const { ui, attrs } = useUI("select", toRef(props, "ui"), config, toRef(props, "class"));
180
- const { emitFormChange, inputId, color, size, name } = useFormGroup(props, config);
180
+ const { size: sizeButtonGroup, rounded } = useInjectButtonGroup({ ui, props });
181
+ const { emitFormChange, inputId, color, size: sizeFormGroup, name } = useFormGroup(props, config);
182
+ const size = computed(() => sizeButtonGroup.value || sizeFormGroup.value);
181
183
  const onInput = (event) => {
182
184
  emit("update:modelValue", event.target.value);
183
185
  };
@@ -232,7 +234,8 @@ export default defineComponent({
232
234
  const variant = ui.value.color?.[color.value]?.[props.variant] || ui.value.variant[props.variant];
233
235
  return twMerge(twJoin(
234
236
  ui.value.base,
235
- ui.value.rounded,
237
+ ui.value.form,
238
+ rounded.value,
236
239
  ui.value.size[size.value],
237
240
  props.padded ? ui.value.padding[size.value] : "p-0",
238
241
  variant?.replaceAll("{color}", color.value),
@@ -268,9 +271,9 @@ export default defineComponent({
268
271
  const leadingIconClass = computed(() => {
269
272
  return twJoin(
270
273
  ui.value.icon.base,
271
- appConfig.ui.colors.includes(color.value) && ui.value.icon.color.replaceAll("{color}", color.value),
274
+ color.value && appConfig.ui.colors.includes(color.value) && ui.value.icon.color.replaceAll("{color}", color.value),
272
275
  ui.value.icon.size[size.value],
273
- props.loading && "animate-spin"
276
+ props.loading && ui.value.icon.loading
274
277
  );
275
278
  });
276
279
  const trailingWrapperIconClass = computed(() => {
@@ -283,9 +286,9 @@ export default defineComponent({
283
286
  const trailingIconClass = computed(() => {
284
287
  return twJoin(
285
288
  ui.value.icon.base,
286
- appConfig.ui.colors.includes(color.value) && ui.value.icon.color.replaceAll("{color}", color.value),
289
+ color.value && appConfig.ui.colors.includes(color.value) && ui.value.icon.color.replaceAll("{color}", color.value),
287
290
  ui.value.icon.size[size.value],
288
- props.loading && !isLeading.value && "animate-spin"
291
+ props.loading && !isLeading.value && ui.value.icon.loading
289
292
  );
290
293
  });
291
294
  return {
@@ -1,4 +1,5 @@
1
1
  import type { PropType, ComputedRef } from 'vue';
2
+ import type { SelectSize, SelectVariant } from '../../types';
2
3
  declare const _default: import("vue").DefineComponent<{
3
4
  modelValue: {
4
5
  type: (ObjectConstructor | NumberConstructor | StringConstructor)[];
@@ -61,7 +62,7 @@ declare const _default: import("vue").DefineComponent<{
61
62
  default: () => never[];
62
63
  };
63
64
  size: {
64
- type: PropType<string | number | symbol>;
65
+ type: PropType<SelectSize>;
65
66
  default: null;
66
67
  validator(value: string): boolean;
67
68
  };
@@ -71,7 +72,7 @@ declare const _default: import("vue").DefineComponent<{
71
72
  validator(value: string): boolean;
72
73
  };
73
74
  variant: {
74
- type: PropType<any>;
75
+ type: PropType<SelectVariant>;
75
76
  default: () => any;
76
77
  validator(value: string): boolean;
77
78
  };
@@ -89,11 +90,11 @@ declare const _default: import("vue").DefineComponent<{
89
90
  };
90
91
  class: {
91
92
  type: PropType<any>;
92
- default: undefined;
93
+ default: () => "";
93
94
  };
94
95
  ui: {
95
- type: PropType<Partial<any>>;
96
- default: undefined;
96
+ type: PropType<any>;
97
+ default: () => {};
97
98
  };
98
99
  }, {
99
100
  ui: ComputedRef<any>;
@@ -118,7 +119,7 @@ declare const _default: import("vue").DefineComponent<{
118
119
  trailingIconName: ComputedRef<string | undefined>;
119
120
  trailingIconClass: ComputedRef<string>;
120
121
  trailingWrapperIconClass: ComputedRef<string>;
121
- onInput: (event: InputEvent) => void;
122
+ onInput: (event: Event) => void;
122
123
  onChange: (event: Event) => void;
123
124
  }, 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<{
124
125
  modelValue: {
@@ -182,7 +183,7 @@ declare const _default: import("vue").DefineComponent<{
182
183
  default: () => never[];
183
184
  };
184
185
  size: {
185
- type: PropType<string | number | symbol>;
186
+ type: PropType<SelectSize>;
186
187
  default: null;
187
188
  validator(value: string): boolean;
188
189
  };
@@ -192,7 +193,7 @@ declare const _default: import("vue").DefineComponent<{
192
193
  validator(value: string): boolean;
193
194
  };
194
195
  variant: {
195
- type: PropType<any>;
196
+ type: PropType<SelectVariant>;
196
197
  default: () => any;
197
198
  validator(value: string): boolean;
198
199
  };
@@ -210,29 +211,29 @@ declare const _default: import("vue").DefineComponent<{
210
211
  };
211
212
  class: {
212
213
  type: PropType<any>;
213
- default: undefined;
214
+ default: () => "";
214
215
  };
215
216
  ui: {
216
- type: PropType<Partial<any>>;
217
- default: undefined;
217
+ type: PropType<any>;
218
+ default: () => {};
218
219
  };
219
220
  }>> & {
220
221
  "onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
221
222
  onChange?: ((...args: any[]) => any) | undefined;
222
223
  }, {
224
+ size: SelectSize;
225
+ ui: any;
223
226
  id: string;
224
227
  icon: string;
225
228
  color: any;
226
- ui: Partial<any>;
227
229
  options: unknown[];
228
230
  name: string;
229
231
  class: any;
230
232
  modelValue: string | number | Record<string, any>;
231
233
  loading: boolean;
232
234
  disabled: boolean;
233
- variant: any;
235
+ variant: SelectVariant;
234
236
  required: boolean;
235
- size: string | number | symbol;
236
237
  placeholder: string;
237
238
  padded: boolean;
238
239
  loadingIcon: string;
@@ -15,7 +15,7 @@
15
15
  v-if="required"
16
16
  :value="modelValue"
17
17
  :required="required"
18
- class="absolute inset-0 w-px opacity-0 cursor-default"
18
+ :class="uiMenu.required"
19
19
  tabindex="-1"
20
20
  aria-hidden="true"
21
21
  >
@@ -25,7 +25,7 @@
25
25
  ref="trigger"
26
26
  as="div"
27
27
  role="button"
28
- class="inline-flex w-full"
28
+ :class="uiMenu.trigger"
29
29
  >
30
30
  <slot :open="open" :disabled="disabled" :loading="loading">
31
31
  <button :id="inputId" :class="selectClass" :disabled="disabled || loading" type="button" v-bind="attrs">
@@ -36,9 +36,9 @@
36
36
  </span>
37
37
 
38
38
  <slot name="label">
39
- <span v-if="multiple && Array.isArray(modelValue) && modelValue.length" class="block truncate">{{ modelValue.length }} selected</span>
40
- <span v-else-if="!multiple && modelValue" class="block truncate">{{ ['string', 'number'].includes(typeof modelValue) ? modelValue : modelValue[optionAttribute] }}</span>
41
- <span v-else class="block truncate" :class="uiMenu.placeholder">{{ placeholder || '&nbsp;' }}</span>
39
+ <span v-if="multiple && Array.isArray(modelValue) && modelValue.length" :class="uiMenu.label">{{ modelValue.length }} selected</span>
40
+ <span v-else-if="!multiple && modelValue" :class="uiMenu.label">{{ ['string', 'number'].includes(typeof modelValue) ? modelValue : modelValue[optionAttribute] }}</span>
41
+ <span v-else :class="uiMenu.label">{{ placeholder || '&nbsp;' }}</span>
42
42
  </slot>
43
43
 
44
44
  <span v-if="(isTrailing && trailingIconName) || $slots.trailing" :class="trailingWrapperIconClass">
@@ -53,8 +53,9 @@
53
53
  <div v-if="open" ref="container" :class="[uiMenu.container, uiMenu.width]">
54
54
  <Transition appear v-bind="uiMenu.transition">
55
55
  <div>
56
- <div v-if="popper.arrow" data-popper-arrow :class="['invisible before:visible before:block before:rotate-45 before:z-[-1]', Object.values(uiMenu.arrow)]" />
57
- <component :is="searchable ? 'HComboboxOptions' : 'HListboxOptions'" static :class="[uiMenu.base, uiMenu.divide, uiMenu.ring, uiMenu.rounded, uiMenu.shadow, uiMenu.background, uiMenu.padding, uiMenu.height]">
56
+ <div v-if="popper.arrow" data-popper-arrow :class="Object.values(uiMenu.arrow)" />
57
+
58
+ <component :is="searchable ? 'HComboboxOptions' : 'HListboxOptions'" static :class="[uiMenu.base, uiMenu.ring, uiMenu.rounded, uiMenu.shadow, uiMenu.background, uiMenu.padding, uiMenu.height]">
58
59
  <HComboboxInput
59
60
  v-if="searchable"
60
61
  ref="searchInput"
@@ -86,22 +87,22 @@
86
87
  aria-hidden="true"
87
88
  />
88
89
  <span v-else-if="option.chip" :class="uiMenu.option.chip.base" :style="{ background: `#${option.chip}` }" />
89
-
90
+
90
91
  <span class="truncate">{{ ['string', 'number'].includes(typeof option) ? option : option[optionAttribute] }}</span>
91
92
  </slot>
92
93
  </div>
93
-
94
+
94
95
  <span v-if="selected" :class="[uiMenu.option.selectedIcon.wrapper, uiMenu.option.selectedIcon.padding]">
95
96
  <UIcon :name="selectedIcon" :class="uiMenu.option.selectedIcon.base" aria-hidden="true" />
96
97
  </span>
97
98
  </li>
98
99
  </component>
99
-
100
+
100
101
  <component :is="searchable ? 'HComboboxOption' : 'HListboxOption'" v-if="creatable && queryOption && !filteredOptions.length" v-slot="{ active, selected }" :value="queryOption" as="template">
101
102
  <li :class="[uiMenu.option.base, uiMenu.option.rounded, uiMenu.option.padding, uiMenu.option.size, uiMenu.option.color, active ? uiMenu.option.active : uiMenu.option.inactive]">
102
103
  <div :class="uiMenu.option.container">
103
104
  <slot name="option-create" :option="queryOption" :active="active" :selected="selected">
104
- <span class="block truncate">Create "{{ queryOption[optionAttribute] }}"</span>
105
+ <span :class="uiMenu.option.create">Create "{{ queryOption[optionAttribute] }}"</span>
105
106
  </slot>
106
107
  </div>
107
108
  </li>
@@ -139,7 +140,8 @@ import UAvatar from "../elements/Avatar.vue";
139
140
  import { useUI } from "../../composables/useUI";
140
141
  import { usePopper } from "../../composables/usePopper";
141
142
  import { useFormGroup } from "../../composables/useFormGroup";
142
- import { mergeConfig } from "../../utils";
143
+ import { get, mergeConfig } from "../../utils";
144
+ import { useInjectButtonGroup } from "../../composables/useButtonGroup";
143
145
  import appConfig from "#build/app.config";
144
146
  import { select, selectMenu } from "#ui/ui.config";
145
147
  const config = mergeConfig(appConfig.ui.strategy, appConfig.ui.select, select);
@@ -232,6 +234,10 @@ export default defineComponent({
232
234
  type: String,
233
235
  default: "Search..."
234
236
  },
237
+ clearSearchOnClose: {
238
+ type: Boolean,
239
+ default: () => configMenu.default.clearOnClose
240
+ },
235
241
  debounce: {
236
242
  type: Number,
237
243
  default: 200
@@ -294,15 +300,15 @@ export default defineComponent({
294
300
  },
295
301
  class: {
296
302
  type: [String, Object, Array],
297
- default: void 0
303
+ default: () => ""
298
304
  },
299
305
  ui: {
300
306
  type: Object,
301
- default: void 0
307
+ default: () => ({})
302
308
  },
303
309
  uiMenu: {
304
310
  type: Object,
305
- default: void 0
311
+ default: () => ({})
306
312
  }
307
313
  },
308
314
  emits: ["update:modelValue", "open", "close", "change"],
@@ -311,22 +317,23 @@ export default defineComponent({
311
317
  const { ui: uiMenu } = useUI("selectMenu", toRef(props, "uiMenu"), configMenu);
312
318
  const popper = computed(() => defu({}, props.popper, uiMenu.value.popper));
313
319
  const [trigger, container] = usePopper(popper.value);
314
- const { emitFormBlur, emitFormChange, inputId, color, size, name } = useFormGroup(props, config);
320
+ const { size: sizeButtonGroup, rounded } = useInjectButtonGroup({ ui, props });
321
+ const { emitFormBlur, emitFormChange, inputId, color, size: sizeFormGroup, name } = useFormGroup(props, config);
322
+ const size = computed(() => sizeButtonGroup.value || sizeFormGroup.value);
315
323
  const query = ref("");
316
324
  const searchInput = ref();
317
325
  const selectClass = computed(() => {
318
326
  const variant = ui.value.color?.[color.value]?.[props.variant] || ui.value.variant[props.variant];
319
327
  return twMerge(twJoin(
320
328
  ui.value.base,
321
- ui.value.rounded,
322
- "text-left cursor-default",
329
+ uiMenu.value.select,
330
+ rounded.value,
323
331
  ui.value.size[size.value],
324
332
  ui.value.gap[size.value],
325
333
  props.padded ? ui.value.padding[size.value] : "p-0",
326
334
  variant?.replaceAll("{color}", color.value),
327
335
  (isLeading.value || slots.leading) && ui.value.leading.padding[size.value],
328
- (isTrailing.value || slots.trailing) && ui.value.trailing.padding[size.value],
329
- "inline-flex items-center"
336
+ (isTrailing.value || slots.trailing) && ui.value.trailing.padding[size.value]
330
337
  ), props.selectClass);
331
338
  });
332
339
  const isLeading = computed(() => {
@@ -357,9 +364,9 @@ export default defineComponent({
357
364
  const leadingIconClass = computed(() => {
358
365
  return twJoin(
359
366
  ui.value.icon.base,
360
- appConfig.ui.colors.includes(color.value) && ui.value.icon.color.replaceAll("{color}", color.value),
367
+ color.value && appConfig.ui.colors.includes(color.value) && ui.value.icon.color.replaceAll("{color}", color.value),
361
368
  ui.value.icon.size[size.value],
362
- props.loading && "animate-spin"
369
+ props.loading && ui.value.icon.loading
363
370
  );
364
371
  });
365
372
  const trailingWrapperIconClass = computed(() => {
@@ -372,9 +379,9 @@ export default defineComponent({
372
379
  const trailingIconClass = computed(() => {
373
380
  return twJoin(
374
381
  ui.value.icon.base,
375
- appConfig.ui.colors.includes(color.value) && ui.value.icon.color.replaceAll("{color}", color.value),
382
+ color.value && appConfig.ui.colors.includes(color.value) && ui.value.icon.color.replaceAll("{color}", color.value),
376
383
  ui.value.icon.size[size.value],
377
- props.loading && !isLeading.value && "animate-spin"
384
+ props.loading && !isLeading.value && ui.value.icon.loading
378
385
  );
379
386
  });
380
387
  const debouncedSearch = typeof props.searchable === "function" ? useDebounceFn(props.searchable, props.debounce) : void 0;
@@ -387,17 +394,27 @@ export default defineComponent({
387
394
  }
388
395
  return props.options.filter((option) => {
389
396
  return (props.searchAttributes?.length ? props.searchAttributes : [props.optionAttribute]).some((searchAttribute) => {
390
- return ["string", "number"].includes(typeof option) ? option.toString().search(new RegExp(query.value, "i")) !== -1 : option[searchAttribute] && option[searchAttribute].search(new RegExp(query.value, "i")) !== -1;
397
+ if (["string", "number"].includes(typeof option)) {
398
+ return String(option).search(new RegExp(query.value, "i")) !== -1;
399
+ }
400
+ const child = get(option, searchAttribute);
401
+ return child !== null && child !== void 0 && String(child).search(new RegExp(query.value, "i")) !== -1;
391
402
  });
392
403
  });
393
404
  });
394
405
  const queryOption = computed(() => {
395
406
  return query.value === "" ? null : { [props.optionAttribute]: query.value };
396
407
  });
408
+ function clearOnClose() {
409
+ if (props.clearSearchOnClose) {
410
+ query.value = "";
411
+ }
412
+ }
397
413
  watch(container, (value) => {
398
414
  if (value) {
399
415
  emit("open");
400
416
  } else {
417
+ clearOnClose();
401
418
  emit("close");
402
419
  emitFormBlur();
403
420
  }
@@ -1,5 +1,5 @@
1
1
  import type { PropType } from 'vue';
2
- import type { PopperOptions } from '../../types';
2
+ import type { SelectSize, SelectVariant, PopperOptions } from '../../types';
3
3
  declare const _default: import("vue").DefineComponent<{
4
4
  modelValue: {
5
5
  type: (ObjectConstructor | NumberConstructor | ArrayConstructor | StringConstructor)[];
@@ -76,6 +76,10 @@ declare const _default: import("vue").DefineComponent<{
76
76
  type: StringConstructor;
77
77
  default: string;
78
78
  };
79
+ clearSearchOnClose: {
80
+ type: BooleanConstructor;
81
+ default: () => any;
82
+ };
79
83
  debounce: {
80
84
  type: NumberConstructor;
81
85
  default: number;
@@ -93,7 +97,7 @@ declare const _default: import("vue").DefineComponent<{
93
97
  default: boolean;
94
98
  };
95
99
  size: {
96
- type: PropType<string | number | symbol>;
100
+ type: PropType<SelectSize>;
97
101
  default: null;
98
102
  validator(value: string): boolean;
99
103
  };
@@ -103,7 +107,7 @@ declare const _default: import("vue").DefineComponent<{
103
107
  validator(value: string): boolean;
104
108
  };
105
109
  variant: {
106
- type: PropType<any>;
110
+ type: PropType<SelectVariant>;
107
111
  default: () => any;
108
112
  validator(value: string): boolean;
109
113
  };
@@ -129,15 +133,15 @@ declare const _default: import("vue").DefineComponent<{
129
133
  };
130
134
  class: {
131
135
  type: PropType<any>;
132
- default: undefined;
136
+ default: () => "";
133
137
  };
134
138
  ui: {
135
- type: PropType<Partial<any>>;
136
- default: undefined;
139
+ type: PropType<any>;
140
+ default: () => {};
137
141
  };
138
142
  uiMenu: {
139
- type: PropType<Partial<any>>;
140
- default: undefined;
143
+ type: PropType<any>;
144
+ default: () => {};
141
145
  };
142
146
  }, {
143
147
  ui: import("vue").ComputedRef<any>;
@@ -241,6 +245,10 @@ declare const _default: import("vue").DefineComponent<{
241
245
  type: StringConstructor;
242
246
  default: string;
243
247
  };
248
+ clearSearchOnClose: {
249
+ type: BooleanConstructor;
250
+ default: () => any;
251
+ };
244
252
  debounce: {
245
253
  type: NumberConstructor;
246
254
  default: number;
@@ -258,7 +266,7 @@ declare const _default: import("vue").DefineComponent<{
258
266
  default: boolean;
259
267
  };
260
268
  size: {
261
- type: PropType<string | number | symbol>;
269
+ type: PropType<SelectSize>;
262
270
  default: null;
263
271
  validator(value: string): boolean;
264
272
  };
@@ -268,7 +276,7 @@ declare const _default: import("vue").DefineComponent<{
268
276
  validator(value: string): boolean;
269
277
  };
270
278
  variant: {
271
- type: PropType<any>;
279
+ type: PropType<SelectVariant>;
272
280
  default: () => any;
273
281
  validator(value: string): boolean;
274
282
  };
@@ -294,15 +302,15 @@ declare const _default: import("vue").DefineComponent<{
294
302
  };
295
303
  class: {
296
304
  type: PropType<any>;
297
- default: undefined;
305
+ default: () => "";
298
306
  };
299
307
  ui: {
300
- type: PropType<Partial<any>>;
301
- default: undefined;
308
+ type: PropType<any>;
309
+ default: () => {};
302
310
  };
303
311
  uiMenu: {
304
- type: PropType<Partial<any>>;
305
- default: undefined;
312
+ type: PropType<any>;
313
+ default: () => {};
306
314
  };
307
315
  }>> & {
308
316
  "onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
@@ -310,10 +318,11 @@ declare const _default: import("vue").DefineComponent<{
310
318
  onClose?: ((...args: any[]) => any) | undefined;
311
319
  onOpen?: ((...args: any[]) => any) | undefined;
312
320
  }, {
321
+ size: SelectSize;
322
+ ui: any;
313
323
  id: string;
314
324
  icon: string;
315
325
  color: any;
316
- ui: Partial<any>;
317
326
  options: string[] | {
318
327
  [key: string]: any;
319
328
  disabled?: boolean | undefined;
@@ -326,9 +335,8 @@ declare const _default: import("vue").DefineComponent<{
326
335
  loading: boolean;
327
336
  disabled: boolean;
328
337
  multiple: boolean;
329
- variant: any;
338
+ variant: SelectVariant;
330
339
  required: boolean;
331
- size: string | number | symbol;
332
340
  placeholder: string;
333
341
  padded: boolean;
334
342
  loadingIcon: string;
@@ -342,9 +350,10 @@ declare const _default: import("vue").DefineComponent<{
342
350
  selectedIcon: string;
343
351
  searchable: boolean | ((query: string) => Promise<any[]> | any[]);
344
352
  searchablePlaceholder: string;
353
+ clearSearchOnClose: boolean;
345
354
  debounce: number;
346
355
  creatable: boolean;
347
356
  searchAttributes: unknown[];
348
- uiMenu: Partial<any>;
357
+ uiMenu: any;
349
358
  }, {}>;
350
359
  export default _default;
@@ -9,21 +9,24 @@
9
9
  :required="required"
10
10
  :disabled="disabled"
11
11
  :placeholder="placeholder"
12
- class="form-textarea"
13
12
  :class="textareaClass"
14
13
  v-bind="attrs"
15
14
  @input="onInput"
16
15
  @blur="onBlur"
16
+ @change="onChange"
17
17
  />
18
+
19
+ <slot />
18
20
  </div>
19
21
  </template>
20
22
 
21
23
  <script>
22
24
  import { ref, computed, toRef, watch, onMounted, nextTick, defineComponent } from "vue";
23
25
  import { twMerge, twJoin } from "tailwind-merge";
26
+ import { defu } from "defu";
24
27
  import { useUI } from "../../composables/useUI";
25
28
  import { useFormGroup } from "../../composables/useFormGroup";
26
- import { mergeConfig } from "../../utils";
29
+ import { mergeConfig, looseToNumber } from "../../utils";
27
30
  import appConfig from "#build/app.config";
28
31
  import { textarea } from "#ui/ui.config";
29
32
  const config = mergeConfig(appConfig.ui.strategy, appConfig.ui.textarea, textarea);
@@ -108,17 +111,22 @@ export default defineComponent({
108
111
  },
109
112
  class: {
110
113
  type: [String, Object, Array],
111
- default: void 0
114
+ default: () => ""
112
115
  },
113
116
  ui: {
114
117
  type: Object,
115
- default: void 0
118
+ default: () => ({})
119
+ },
120
+ modelModifiers: {
121
+ type: Object,
122
+ default: () => ({})
116
123
  }
117
124
  },
118
125
  emits: ["update:modelValue", "blur"],
119
126
  setup(props, { emit }) {
120
127
  const { ui, attrs } = useUI("textarea", toRef(props, "ui"), config, toRef(props, "class"));
121
128
  const { emitFormBlur, emitFormInput, inputId, color, size, name } = useFormGroup(props, config);
129
+ const modelModifiers = ref(defu({}, props.modelModifiers, { trim: false, lazy: false, number: false }));
122
130
  const textarea2 = ref(null);
123
131
  const autoFocus = () => {
124
132
  if (props.autofocus) {
@@ -143,10 +151,30 @@ export default defineComponent({
143
151
  }
144
152
  }
145
153
  };
154
+ const updateInput = (value) => {
155
+ if (modelModifiers.value.trim) {
156
+ value = value.trim();
157
+ }
158
+ if (modelModifiers.value.number) {
159
+ value = looseToNumber(value);
160
+ }
161
+ emit("update:modelValue", value);
162
+ emitFormInput();
163
+ };
146
164
  const onInput = (event) => {
147
165
  autoResize();
148
- emit("update:modelValue", event.target.value);
149
- emitFormInput();
166
+ if (!modelModifiers.value.lazy) {
167
+ updateInput(event.target.value);
168
+ }
169
+ };
170
+ const onChange = (event) => {
171
+ const value = event.target.value;
172
+ if (modelModifiers.value.lazy) {
173
+ updateInput(value);
174
+ }
175
+ if (modelModifiers.value.trim) {
176
+ event.target.value = value.trim();
177
+ }
150
178
  };
151
179
  const onBlur = (event) => {
152
180
  emit("blur", event);
@@ -170,6 +198,7 @@ export default defineComponent({
170
198
  const variant = ui.value.color?.[color.value]?.[props.variant] || ui.value.variant[props.variant];
171
199
  return twMerge(twJoin(
172
200
  ui.value.base,
201
+ ui.value.form,
173
202
  ui.value.rounded,
174
203
  ui.value.placeholder,
175
204
  ui.value.size[size.value],
@@ -189,6 +218,7 @@ export default defineComponent({
189
218
  // eslint-disable-next-line vue/no-dupe-keys
190
219
  textareaClass,
191
220
  onInput,
221
+ onChange,
192
222
  onBlur
193
223
  };
194
224
  }