@nuxt/ui 2.10.0 → 2.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (172) hide show
  1. package/README.md +11 -0
  2. package/dist/module.d.mts +191 -82
  3. package/dist/module.d.ts +191 -82
  4. package/dist/module.json +1 -1
  5. package/dist/module.mjs +12 -5
  6. package/dist/runtime/components/elements/Alert.vue +7 -6
  7. package/dist/runtime/components/elements/Alert.vue.d.ts +6 -5
  8. package/dist/runtime/components/elements/Avatar.vue.d.ts +5 -4
  9. package/dist/runtime/components/elements/AvatarGroup.d.ts +4 -3
  10. package/dist/runtime/components/elements/Badge.vue +4 -2
  11. package/dist/runtime/components/elements/Badge.vue.d.ts +5 -5
  12. package/dist/runtime/components/elements/Button.vue +8 -6
  13. package/dist/runtime/components/elements/Button.vue.d.ts +6 -6
  14. package/dist/runtime/components/elements/ButtonGroup.d.ts +5 -4
  15. package/dist/runtime/components/elements/ButtonGroup.mjs +19 -32
  16. package/dist/runtime/components/elements/Chip.vue +85 -0
  17. package/dist/runtime/components/elements/Chip.vue.d.ts +90 -0
  18. package/dist/runtime/components/elements/Dropdown.vue +31 -17
  19. package/dist/runtime/components/elements/Dropdown.vue.d.ts +6 -0
  20. package/dist/runtime/components/elements/Icon.vue +16 -2
  21. package/dist/runtime/components/elements/Icon.vue.d.ts +14 -2
  22. package/dist/runtime/components/elements/Kbd.vue.d.ts +5 -4
  23. package/dist/runtime/components/elements/Link.vue +2 -5
  24. package/dist/runtime/components/elements/Meter.vue.d.ts +3 -3
  25. package/dist/runtime/components/elements/MeterGroup.d.ts +2 -2
  26. package/dist/runtime/components/elements/Progress.vue +1 -1
  27. package/dist/runtime/components/forms/Checkbox.vue +2 -4
  28. package/dist/runtime/components/forms/Checkbox.vue.d.ts +5 -5
  29. package/dist/runtime/components/forms/FormGroup.vue +7 -3
  30. package/dist/runtime/components/forms/FormGroup.vue.d.ts +15 -5
  31. package/dist/runtime/components/forms/Input.vue +36 -5
  32. package/dist/runtime/components/forms/Input.vue.d.ts +32 -9
  33. package/dist/runtime/components/forms/Radio.vue +12 -6
  34. package/dist/runtime/components/forms/Radio.vue.d.ts +5 -4
  35. package/dist/runtime/components/forms/RadioGroup.vue +1 -1
  36. package/dist/runtime/components/forms/RadioGroup.vue.d.ts +1 -1
  37. package/dist/runtime/components/forms/Range.vue.d.ts +6 -5
  38. package/dist/runtime/components/forms/Select.vue +5 -2
  39. package/dist/runtime/components/forms/Select.vue.d.ts +9 -8
  40. package/dist/runtime/components/forms/SelectMenu.vue +24 -7
  41. package/dist/runtime/components/forms/SelectMenu.vue.d.ts +18 -9
  42. package/dist/runtime/components/forms/Textarea.vue +33 -3
  43. package/dist/runtime/components/forms/Textarea.vue.d.ts +31 -8
  44. package/dist/runtime/components/forms/Toggle.vue +19 -1
  45. package/dist/runtime/components/forms/Toggle.vue.d.ts +15 -2
  46. package/dist/runtime/components/layout/Divider.vue.d.ts +3 -3
  47. package/dist/runtime/components/navigation/Breadcrumb.vue +78 -0
  48. package/dist/runtime/components/navigation/Breadcrumb.vue.d.ts +50 -0
  49. package/dist/runtime/components/navigation/CommandPalette.vue +8 -4
  50. package/dist/runtime/components/navigation/CommandPalette.vue.d.ts +1 -1
  51. package/dist/runtime/components/navigation/Pagination.vue.d.ts +4 -4
  52. package/dist/runtime/components/navigation/Tabs.vue.d.ts +1 -1
  53. package/dist/runtime/components/overlays/Notification.vue +27 -28
  54. package/dist/runtime/components/overlays/Notification.vue.d.ts +4 -3
  55. package/dist/runtime/components/overlays/Notifications.vue +16 -14
  56. package/dist/runtime/components/overlays/Popover.vue +9 -0
  57. package/dist/runtime/components/overlays/Popover.vue.d.ts +13 -2
  58. package/dist/runtime/composables/defineShortcuts.d.ts +1 -1
  59. package/dist/runtime/composables/defineShortcuts.mjs +8 -4
  60. package/dist/runtime/composables/useButtonGroup.d.ts +20 -0
  61. package/dist/runtime/composables/useButtonGroup.mjs +52 -0
  62. package/dist/runtime/composables/useFormGroup.d.ts +4 -2
  63. package/dist/runtime/composables/useFormGroup.mjs +3 -2
  64. package/dist/runtime/composables/useShortcuts.d.ts +2 -2
  65. package/dist/runtime/types/alert.d.ts +7 -0
  66. package/dist/runtime/types/avatar.d.ts +3 -1
  67. package/dist/runtime/types/badge.d.ts +5 -4
  68. package/dist/runtime/types/breadcrumb.d.ts +7 -0
  69. package/dist/runtime/types/button.d.ts +5 -4
  70. package/dist/runtime/types/chip.d.ts +11 -0
  71. package/dist/runtime/types/dropdown.d.ts +2 -2
  72. package/dist/runtime/types/form-group.d.ts +5 -0
  73. package/dist/runtime/types/form.d.ts +2 -1
  74. package/dist/runtime/types/index.d.ts +10 -0
  75. package/dist/runtime/types/input.d.ts +8 -0
  76. package/dist/runtime/types/kbd.d.ts +5 -0
  77. package/dist/runtime/types/range.d.ts +5 -0
  78. package/dist/runtime/types/select.d.ts +8 -0
  79. package/dist/runtime/types/textarea.d.ts +8 -0
  80. package/dist/runtime/types/toggle.d.ts +5 -0
  81. package/dist/runtime/types/utils.d.ts +22 -5
  82. package/dist/runtime/ui.config/_popperArrow.d.ts +9 -0
  83. package/dist/runtime/ui.config/_popperArrow.mjs +8 -0
  84. package/dist/runtime/ui.config/data/table.d.ts +60 -0
  85. package/dist/runtime/ui.config/data/table.mjs +59 -0
  86. package/dist/runtime/ui.config/elements/accordion.d.ts +21 -0
  87. package/dist/runtime/ui.config/elements/accordion.mjs +20 -0
  88. package/dist/runtime/ui.config/elements/alert.d.ts +40 -0
  89. package/dist/runtime/ui.config/elements/alert.mjs +39 -0
  90. package/dist/runtime/ui.config/elements/avatar.d.ts +60 -0
  91. package/dist/runtime/ui.config/elements/avatar.mjs +59 -0
  92. package/dist/runtime/ui.config/elements/avatarGroup.d.ts +6 -0
  93. package/dist/runtime/ui.config/elements/avatarGroup.mjs +5 -0
  94. package/dist/runtime/ui.config/elements/badge.d.ts +34 -0
  95. package/dist/runtime/ui.config/elements/badge.mjs +33 -0
  96. package/dist/runtime/ui.config/elements/button.d.ts +77 -0
  97. package/dist/runtime/ui.config/elements/button.mjs +76 -0
  98. package/dist/runtime/ui.config/elements/buttonGroup.d.ts +9 -0
  99. package/dist/runtime/ui.config/elements/buttonGroup.mjs +8 -0
  100. package/dist/runtime/ui.config/elements/chip.d.ts +35 -0
  101. package/dist/runtime/ui.config/elements/chip.mjs +34 -0
  102. package/dist/runtime/ui.config/elements/dropdown.d.ts +53 -0
  103. package/dist/runtime/ui.config/elements/dropdown.mjs +51 -0
  104. package/dist/runtime/ui.config/elements/kbd.d.ts +17 -0
  105. package/dist/runtime/ui.config/elements/kbd.mjs +16 -0
  106. package/dist/runtime/ui.config/elements/meter.d.ts +77 -0
  107. package/dist/runtime/ui.config/elements/meter.mjs +76 -0
  108. package/dist/runtime/ui.config/elements/meterGroup.d.ts +12 -0
  109. package/dist/runtime/ui.config/elements/meterGroup.mjs +11 -0
  110. package/dist/runtime/ui.config/elements/progress.d.ts +75 -0
  111. package/dist/runtime/ui.config/elements/progress.mjs +74 -0
  112. package/dist/runtime/ui.config/forms/checkbox.d.ts +16 -0
  113. package/dist/runtime/ui.config/forms/checkbox.mjs +15 -0
  114. package/dist/runtime/ui.config/forms/formGroup.d.ts +25 -0
  115. package/dist/runtime/ui.config/forms/formGroup.mjs +25 -0
  116. package/dist/runtime/ui.config/forms/input.d.ts +105 -0
  117. package/dist/runtime/ui.config/forms/input.mjs +104 -0
  118. package/dist/runtime/ui.config/forms/radio.d.ts +15 -0
  119. package/dist/runtime/ui.config/forms/radio.mjs +14 -0
  120. package/dist/runtime/ui.config/forms/radioGroup.d.ts +8 -0
  121. package/dist/runtime/ui.config/forms/radioGroup.mjs +7 -0
  122. package/dist/runtime/ui.config/forms/range.d.ts +64 -0
  123. package/dist/runtime/ui.config/forms/range.mjs +63 -0
  124. package/dist/runtime/ui.config/forms/select.d.ts +106 -0
  125. package/dist/runtime/ui.config/forms/select.mjs +12 -0
  126. package/dist/runtime/ui.config/forms/selectMenu.d.ts +63 -0
  127. package/dist/runtime/ui.config/forms/selectMenu.mjs +61 -0
  128. package/dist/runtime/ui.config/forms/textarea.d.ts +104 -0
  129. package/dist/runtime/ui.config/forms/textarea.mjs +9 -0
  130. package/dist/runtime/ui.config/forms/toggle.d.ts +61 -0
  131. package/dist/runtime/ui.config/forms/toggle.mjs +60 -0
  132. package/dist/runtime/ui.config/index.d.ts +40 -0
  133. package/dist/runtime/ui.config/index.mjs +40 -0
  134. package/dist/runtime/ui.config/layout/card.d.ts +24 -0
  135. package/dist/runtime/ui.config/layout/card.mjs +23 -0
  136. package/dist/runtime/ui.config/layout/container.d.ts +6 -0
  137. package/dist/runtime/ui.config/layout/container.mjs +5 -0
  138. package/dist/runtime/ui.config/layout/divider.d.ts +30 -0
  139. package/dist/runtime/ui.config/layout/divider.mjs +29 -0
  140. package/dist/runtime/ui.config/layout/skeleton.d.ts +6 -0
  141. package/dist/runtime/ui.config/layout/skeleton.mjs +5 -0
  142. package/dist/runtime/ui.config/navigation/breadcrumb.d.ts +20 -0
  143. package/dist/runtime/ui.config/navigation/breadcrumb.mjs +19 -0
  144. package/dist/runtime/ui.config/navigation/commandPalette.d.ts +68 -0
  145. package/dist/runtime/ui.config/navigation/commandPalette.mjs +67 -0
  146. package/dist/runtime/ui.config/navigation/pagination.d.ts +35 -0
  147. package/dist/runtime/ui.config/navigation/pagination.mjs +34 -0
  148. package/dist/runtime/ui.config/navigation/tabs.d.ts +34 -0
  149. package/dist/runtime/ui.config/navigation/tabs.mjs +33 -0
  150. package/dist/runtime/ui.config/navigation/verticalNavigation.d.ts +28 -0
  151. package/dist/runtime/ui.config/navigation/verticalNavigation.mjs +27 -0
  152. package/dist/runtime/ui.config/overlays/contextMenu.d.ts +31 -0
  153. package/dist/runtime/ui.config/overlays/contextMenu.mjs +25 -0
  154. package/dist/runtime/ui.config/overlays/modal.d.ts +35 -0
  155. package/dist/runtime/ui.config/overlays/modal.mjs +36 -0
  156. package/dist/runtime/ui.config/overlays/notification.d.ts +49 -0
  157. package/dist/runtime/ui.config/overlays/notification.mjs +49 -0
  158. package/dist/runtime/ui.config/overlays/notifications.d.ts +7 -0
  159. package/dist/runtime/ui.config/overlays/notifications.mjs +6 -0
  160. package/dist/runtime/ui.config/overlays/popover.d.ts +42 -0
  161. package/dist/runtime/ui.config/overlays/popover.mjs +36 -0
  162. package/dist/runtime/ui.config/overlays/slideover.d.ts +27 -0
  163. package/dist/runtime/ui.config/overlays/slideover.mjs +28 -0
  164. package/dist/runtime/ui.config/overlays/tooltip.d.ts +32 -0
  165. package/dist/runtime/ui.config/overlays/tooltip.mjs +26 -0
  166. package/dist/runtime/utils/index.d.ts +5 -0
  167. package/dist/runtime/utils/index.mjs +6 -2
  168. package/dist/types.d.mts +3 -2
  169. package/dist/types.d.ts +3 -2
  170. package/package.json +32 -19
  171. package/dist/runtime/ui.config.d.ts +0 -1470
  172. package/dist/runtime/ui.config.mjs +0 -1273
@@ -1,4 +1,5 @@
1
1
  import type { PropType } from 'vue';
2
+ import type { RangeSize } from '../../types';
2
3
  declare const _default: import("vue").DefineComponent<{
3
4
  modelValue: {
4
5
  type: NumberConstructor;
@@ -29,7 +30,7 @@ declare const _default: import("vue").DefineComponent<{
29
30
  default: number;
30
31
  };
31
32
  size: {
32
- type: PropType<string | number | symbol>;
33
+ type: PropType<RangeSize>;
33
34
  default: null;
34
35
  validator(value: string): boolean;
35
36
  };
@@ -56,7 +57,7 @@ declare const _default: import("vue").DefineComponent<{
56
57
  [x: string]: unknown;
57
58
  }, string>>;
58
59
  name: import("vue").ComputedRef<string | undefined>;
59
- inputId: import("vue").Ref<string | undefined>;
60
+ inputId: import("vue").Ref<string | null | undefined>;
60
61
  value: import("vue").WritableComputedRef<number>;
61
62
  wrapperClass: import("vue").ComputedRef<string>;
62
63
  inputClass: import("vue").ComputedRef<string>;
@@ -97,7 +98,7 @@ declare const _default: import("vue").DefineComponent<{
97
98
  default: number;
98
99
  };
99
100
  size: {
100
- type: PropType<string | number | symbol>;
101
+ type: PropType<RangeSize>;
101
102
  default: null;
102
103
  validator(value: string): boolean;
103
104
  };
@@ -122,14 +123,14 @@ declare const _default: import("vue").DefineComponent<{
122
123
  "onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
123
124
  onChange?: ((...args: any[]) => any) | undefined;
124
125
  }, {
126
+ size: RangeSize;
127
+ ui: Partial<any>;
125
128
  id: string;
126
129
  color: any;
127
- ui: Partial<any>;
128
130
  name: string;
129
131
  class: any;
130
132
  modelValue: number;
131
133
  disabled: boolean;
132
- size: string | number | symbol;
133
134
  max: number;
134
135
  min: number;
135
136
  inputClass: string;
@@ -60,6 +60,7 @@ import UIcon from "../elements/Icon.vue";
60
60
  import { useUI } from "../../composables/useUI";
61
61
  import { useFormGroup } from "../../composables/useFormGroup";
62
62
  import { mergeConfig, get } from "../../utils";
63
+ import { useInjectButtonGroup } from "../../composables/useButtonGroup";
63
64
  import appConfig from "#build/app.config";
64
65
  import { select } from "#ui/ui.config";
65
66
  const config = mergeConfig(appConfig.ui.strategy, appConfig.ui.select, select);
@@ -177,7 +178,9 @@ export default defineComponent({
177
178
  emits: ["update:modelValue", "change"],
178
179
  setup(props, { emit, slots }) {
179
180
  const { ui, attrs } = useUI("select", toRef(props, "ui"), config, toRef(props, "class"));
180
- const { emitFormChange, inputId, color, size, name } = useFormGroup(props, config);
181
+ const { size: sizeButtonGroup, rounded } = useInjectButtonGroup({ ui, props });
182
+ const { emitFormChange, inputId, color, size: sizeFormGroup, name } = useFormGroup(props, config);
183
+ const size = computed(() => sizeButtonGroup.value || sizeFormGroup.value);
181
184
  const onInput = (event) => {
182
185
  emit("update:modelValue", event.target.value);
183
186
  };
@@ -232,7 +235,7 @@ export default defineComponent({
232
235
  const variant = ui.value.color?.[color.value]?.[props.variant] || ui.value.variant[props.variant];
233
236
  return twMerge(twJoin(
234
237
  ui.value.base,
235
- ui.value.rounded,
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),
@@ -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
  };
@@ -101,7 +102,7 @@ declare const _default: import("vue").DefineComponent<{
101
102
  [x: string]: unknown;
102
103
  }, string>>;
103
104
  name: ComputedRef<string | undefined>;
104
- inputId: import("vue").Ref<string | undefined>;
105
+ inputId: import("vue").Ref<string | null | undefined>;
105
106
  normalizedOptionsWithPlaceholder: ComputedRef<{
106
107
  disabled?: boolean | undefined;
107
108
  children: {
@@ -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
  };
@@ -220,19 +221,19 @@ declare const _default: import("vue").DefineComponent<{
220
221
  "onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
221
222
  onChange?: ((...args: any[]) => any) | undefined;
222
223
  }, {
224
+ size: SelectSize;
225
+ ui: Partial<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;
@@ -86,17 +86,17 @@
86
86
  aria-hidden="true"
87
87
  />
88
88
  <span v-else-if="option.chip" :class="uiMenu.option.chip.base" :style="{ background: `#${option.chip}` }" />
89
-
89
+
90
90
  <span class="truncate">{{ ['string', 'number'].includes(typeof option) ? option : option[optionAttribute] }}</span>
91
91
  </slot>
92
92
  </div>
93
-
93
+
94
94
  <span v-if="selected" :class="[uiMenu.option.selectedIcon.wrapper, uiMenu.option.selectedIcon.padding]">
95
95
  <UIcon :name="selectedIcon" :class="uiMenu.option.selectedIcon.base" aria-hidden="true" />
96
96
  </span>
97
97
  </li>
98
98
  </component>
99
-
99
+
100
100
  <component :is="searchable ? 'HComboboxOption' : 'HListboxOption'" v-if="creatable && queryOption && !filteredOptions.length" v-slot="{ active, selected }" :value="queryOption" as="template">
101
101
  <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
102
  <div :class="uiMenu.option.container">
@@ -139,7 +139,8 @@ import UAvatar from "../elements/Avatar.vue";
139
139
  import { useUI } from "../../composables/useUI";
140
140
  import { usePopper } from "../../composables/usePopper";
141
141
  import { useFormGroup } from "../../composables/useFormGroup";
142
- import { mergeConfig } from "../../utils";
142
+ import { get, mergeConfig } from "../../utils";
143
+ import { useInjectButtonGroup } from "../../composables/useButtonGroup";
143
144
  import appConfig from "#build/app.config";
144
145
  import { select, selectMenu } from "#ui/ui.config";
145
146
  const config = mergeConfig(appConfig.ui.strategy, appConfig.ui.select, select);
@@ -232,6 +233,10 @@ export default defineComponent({
232
233
  type: String,
233
234
  default: "Search..."
234
235
  },
236
+ clearSearchOnClose: {
237
+ type: Boolean,
238
+ default: () => configMenu.default.clearOnClose
239
+ },
235
240
  debounce: {
236
241
  type: Number,
237
242
  default: 200
@@ -311,14 +316,16 @@ export default defineComponent({
311
316
  const { ui: uiMenu } = useUI("selectMenu", toRef(props, "uiMenu"), configMenu);
312
317
  const popper = computed(() => defu({}, props.popper, uiMenu.value.popper));
313
318
  const [trigger, container] = usePopper(popper.value);
314
- const { emitFormBlur, emitFormChange, inputId, color, size, name } = useFormGroup(props, config);
319
+ const { size: sizeButtonGroup, rounded } = useInjectButtonGroup({ ui, props });
320
+ const { emitFormBlur, emitFormChange, inputId, color, size: sizeFormGroup, name } = useFormGroup(props, config);
321
+ const size = computed(() => sizeButtonGroup.value || sizeFormGroup.value);
315
322
  const query = ref("");
316
323
  const searchInput = ref();
317
324
  const selectClass = computed(() => {
318
325
  const variant = ui.value.color?.[color.value]?.[props.variant] || ui.value.variant[props.variant];
319
326
  return twMerge(twJoin(
320
327
  ui.value.base,
321
- ui.value.rounded,
328
+ rounded.value,
322
329
  "text-left cursor-default",
323
330
  ui.value.size[size.value],
324
331
  ui.value.gap[size.value],
@@ -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
  };
@@ -146,7 +150,7 @@ declare const _default: import("vue").DefineComponent<{
146
150
  [x: string]: unknown;
147
151
  }, string>>;
148
152
  name: import("vue").ComputedRef<string | undefined>;
149
- inputId: import("vue").Ref<string | undefined>;
153
+ inputId: import("vue").Ref<string | null | undefined>;
150
154
  popper: import("vue").ComputedRef<PopperOptions>;
151
155
  trigger: import("vue").Ref<import("@vueuse/core").MaybeElement>;
152
156
  container: import("vue").Ref<import("@vueuse/core").MaybeElement>;
@@ -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
  };
@@ -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: Partial<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,6 +350,7 @@ 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[];
@@ -14,16 +14,20 @@
14
14
  v-bind="attrs"
15
15
  @input="onInput"
16
16
  @blur="onBlur"
17
+ @change="onChange"
17
18
  />
19
+
20
+ <slot />
18
21
  </div>
19
22
  </template>
20
23
 
21
24
  <script>
22
25
  import { ref, computed, toRef, watch, onMounted, nextTick, defineComponent } from "vue";
23
26
  import { twMerge, twJoin } from "tailwind-merge";
27
+ import { defu } from "defu";
24
28
  import { useUI } from "../../composables/useUI";
25
29
  import { useFormGroup } from "../../composables/useFormGroup";
26
- import { mergeConfig } from "../../utils";
30
+ import { mergeConfig, looseToNumber } from "../../utils";
27
31
  import appConfig from "#build/app.config";
28
32
  import { textarea } from "#ui/ui.config";
29
33
  const config = mergeConfig(appConfig.ui.strategy, appConfig.ui.textarea, textarea);
@@ -113,12 +117,17 @@ export default defineComponent({
113
117
  ui: {
114
118
  type: Object,
115
119
  default: void 0
120
+ },
121
+ modelModifiers: {
122
+ type: Object,
123
+ default: () => ({})
116
124
  }
117
125
  },
118
126
  emits: ["update:modelValue", "blur"],
119
127
  setup(props, { emit }) {
120
128
  const { ui, attrs } = useUI("textarea", toRef(props, "ui"), config, toRef(props, "class"));
121
129
  const { emitFormBlur, emitFormInput, inputId, color, size, name } = useFormGroup(props, config);
130
+ const modelModifiers = ref(defu({}, props.modelModifiers, { trim: false, lazy: false, number: false }));
122
131
  const textarea2 = ref(null);
123
132
  const autoFocus = () => {
124
133
  if (props.autofocus) {
@@ -143,10 +152,30 @@ export default defineComponent({
143
152
  }
144
153
  }
145
154
  };
155
+ const updateInput = (value) => {
156
+ if (modelModifiers.value.trim) {
157
+ value = value.trim();
158
+ }
159
+ if (modelModifiers.value.number) {
160
+ value = looseToNumber(value);
161
+ }
162
+ emit("update:modelValue", value);
163
+ emitFormInput();
164
+ };
146
165
  const onInput = (event) => {
147
166
  autoResize();
148
- emit("update:modelValue", event.target.value);
149
- emitFormInput();
167
+ if (!modelModifiers.value.lazy) {
168
+ updateInput(event.target.value);
169
+ }
170
+ };
171
+ const onChange = (event) => {
172
+ const value = event.target.value;
173
+ if (modelModifiers.value.lazy) {
174
+ updateInput(value);
175
+ }
176
+ if (modelModifiers.value.trim) {
177
+ event.target.value = value.trim();
178
+ }
150
179
  };
151
180
  const onBlur = (event) => {
152
181
  emit("blur", event);
@@ -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
  }
@@ -1,4 +1,5 @@
1
1
  import type { PropType } from 'vue';
2
+ import type { TextareaSize, TextareaVariant } from '../../types';
2
3
  declare const _default: import("vue").DefineComponent<{
3
4
  modelValue: {
4
5
  type: (NumberConstructor | StringConstructor)[];
@@ -49,7 +50,7 @@ declare const _default: import("vue").DefineComponent<{
49
50
  default: boolean;
50
51
  };
51
52
  size: {
52
- type: PropType<string | number | symbol>;
53
+ type: PropType<TextareaSize>;
53
54
  default: null;
54
55
  validator(value: string): boolean;
55
56
  };
@@ -59,7 +60,7 @@ declare const _default: import("vue").DefineComponent<{
59
60
  validator(value: string): boolean;
60
61
  };
61
62
  variant: {
62
- type: PropType<any>;
63
+ type: PropType<TextareaVariant>;
63
64
  default: () => any;
64
65
  validator(value: string): boolean;
65
66
  };
@@ -75,16 +76,25 @@ declare const _default: import("vue").DefineComponent<{
75
76
  type: PropType<Partial<any>>;
76
77
  default: undefined;
77
78
  };
79
+ modelModifiers: {
80
+ type: PropType<{
81
+ trim?: boolean | undefined;
82
+ lazy?: boolean | undefined;
83
+ number?: boolean | undefined;
84
+ }>;
85
+ default: () => {};
86
+ };
78
87
  }, {
79
88
  ui: import("vue").ComputedRef<any>;
80
89
  attrs: import("vue").ComputedRef<Pick<{
81
90
  [x: string]: unknown;
82
91
  }, string>>;
83
92
  name: import("vue").ComputedRef<string | undefined>;
84
- inputId: import("vue").Ref<string | undefined>;
93
+ inputId: import("vue").Ref<string | null | undefined>;
85
94
  textarea: import("vue").Ref<HTMLTextAreaElement | null>;
86
95
  textareaClass: import("vue").ComputedRef<string>;
87
96
  onInput: (event: InputEvent) => void;
97
+ onChange: (event: InputEvent) => void;
88
98
  onBlur: (event: FocusEvent) => void;
89
99
  }, 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<{
90
100
  modelValue: {
@@ -136,7 +146,7 @@ declare const _default: import("vue").DefineComponent<{
136
146
  default: boolean;
137
147
  };
138
148
  size: {
139
- type: PropType<string | number | symbol>;
149
+ type: PropType<TextareaSize>;
140
150
  default: null;
141
151
  validator(value: string): boolean;
142
152
  };
@@ -146,7 +156,7 @@ declare const _default: import("vue").DefineComponent<{
146
156
  validator(value: string): boolean;
147
157
  };
148
158
  variant: {
149
- type: PropType<any>;
159
+ type: PropType<TextareaVariant>;
150
160
  default: () => any;
151
161
  validator(value: string): boolean;
152
162
  };
@@ -162,26 +172,39 @@ declare const _default: import("vue").DefineComponent<{
162
172
  type: PropType<Partial<any>>;
163
173
  default: undefined;
164
174
  };
175
+ modelModifiers: {
176
+ type: PropType<{
177
+ trim?: boolean | undefined;
178
+ lazy?: boolean | undefined;
179
+ number?: boolean | undefined;
180
+ }>;
181
+ default: () => {};
182
+ };
165
183
  }>> & {
166
184
  "onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
167
185
  onBlur?: ((...args: any[]) => any) | undefined;
168
186
  }, {
169
187
  resize: boolean;
188
+ size: TextareaSize;
189
+ ui: Partial<any>;
170
190
  id: string;
171
191
  color: any;
172
- ui: Partial<any>;
173
192
  name: string;
174
193
  class: any;
175
194
  modelValue: string | number;
176
195
  rows: number;
177
196
  disabled: boolean;
178
- variant: any;
197
+ variant: TextareaVariant;
179
198
  required: boolean;
180
- size: string | number | symbol;
181
199
  placeholder: string;
182
200
  padded: boolean;
183
201
  autofocus: boolean;
184
202
  autofocusDelay: number;
203
+ modelModifiers: {
204
+ trim?: boolean | undefined;
205
+ lazy?: boolean | undefined;
206
+ number?: boolean | undefined;
207
+ };
185
208
  autoresize: boolean;
186
209
  textareaClass: string;
187
210
  }, {}>;
@@ -7,7 +7,7 @@
7
7
  :class="switchClass"
8
8
  v-bind="attrs"
9
9
  >
10
- <span :class="[active ? ui.container.active : ui.container.inactive, ui.container.base]">
10
+ <span :class="containerClass">
11
11
  <span v-if="onIcon" :class="[active ? ui.icon.active : ui.icon.inactive, ui.icon.base]" aria-hidden="true">
12
12
  <UIcon :name="onIcon" :class="onIconClass" />
13
13
  </span>
@@ -71,6 +71,13 @@ export default defineComponent({
71
71
  type: [String, Object, Array],
72
72
  default: void 0
73
73
  },
74
+ size: {
75
+ type: String,
76
+ default: config.default.size,
77
+ validator(value) {
78
+ return Object.keys(config.size).includes(value);
79
+ }
80
+ },
74
81
  ui: {
75
82
  type: Object,
76
83
  default: void 0
@@ -92,18 +99,28 @@ export default defineComponent({
92
99
  const switchClass = computed(() => {
93
100
  return twMerge(twJoin(
94
101
  ui.value.base,
102
+ ui.value.size[props.size],
95
103
  ui.value.rounded,
96
104
  ui.value.ring.replaceAll("{color}", color.value),
97
105
  (active.value ? ui.value.active : ui.value.inactive).replaceAll("{color}", color.value)
98
106
  ), props.class);
99
107
  });
108
+ const containerClass = computed(() => {
109
+ return twJoin(
110
+ ui.value.container.base,
111
+ ui.value.container.size[props.size],
112
+ active.value ? ui.value.container.active[props.size] : ui.value.container.inactive
113
+ );
114
+ });
100
115
  const onIconClass = computed(() => {
101
116
  return twJoin(
117
+ ui.value.icon.size[props.size],
102
118
  ui.value.icon.on.replaceAll("{color}", color.value)
103
119
  );
104
120
  });
105
121
  const offIconClass = computed(() => {
106
122
  return twJoin(
123
+ ui.value.icon.size[props.size],
107
124
  ui.value.icon.off.replaceAll("{color}", color.value)
108
125
  );
109
126
  });
@@ -116,6 +133,7 @@ export default defineComponent({
116
133
  inputId,
117
134
  active,
118
135
  switchClass,
136
+ containerClass,
119
137
  onIconClass,
120
138
  offIconClass
121
139
  };
@@ -1,4 +1,5 @@
1
1
  import type { PropType } from 'vue';
2
+ import type { ToggleSize } from '../../types';
2
3
  declare const _default: import("vue").DefineComponent<{
3
4
  id: {
4
5
  type: StringConstructor;
@@ -33,6 +34,11 @@ declare const _default: import("vue").DefineComponent<{
33
34
  type: PropType<any>;
34
35
  default: undefined;
35
36
  };
37
+ size: {
38
+ type: PropType<ToggleSize>;
39
+ default: any;
40
+ validator(value: string): boolean;
41
+ };
36
42
  ui: {
37
43
  type: PropType<Partial<any>>;
38
44
  default: undefined;
@@ -43,9 +49,10 @@ declare const _default: import("vue").DefineComponent<{
43
49
  [x: string]: unknown;
44
50
  }, string>>;
45
51
  name: import("vue").ComputedRef<string | undefined>;
46
- inputId: import("vue").Ref<string | undefined>;
52
+ inputId: import("vue").Ref<string | null | undefined>;
47
53
  active: import("vue").WritableComputedRef<boolean>;
48
54
  switchClass: import("vue").ComputedRef<string>;
55
+ containerClass: import("vue").ComputedRef<string>;
49
56
  onIconClass: import("vue").ComputedRef<string>;
50
57
  offIconClass: import("vue").ComputedRef<string>;
51
58
  }, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, "update:modelValue"[], "update:modelValue", import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
@@ -82,6 +89,11 @@ declare const _default: import("vue").DefineComponent<{
82
89
  type: PropType<any>;
83
90
  default: undefined;
84
91
  };
92
+ size: {
93
+ type: PropType<ToggleSize>;
94
+ default: any;
95
+ validator(value: string): boolean;
96
+ };
85
97
  ui: {
86
98
  type: PropType<Partial<any>>;
87
99
  default: undefined;
@@ -89,9 +101,10 @@ declare const _default: import("vue").DefineComponent<{
89
101
  }>> & {
90
102
  "onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
91
103
  }, {
104
+ size: ToggleSize;
105
+ ui: Partial<any>;
92
106
  id: string;
93
107
  color: any;
94
- ui: Partial<any>;
95
108
  name: string;
96
109
  class: any;
97
110
  modelValue: boolean;
@@ -71,12 +71,12 @@ declare const _default: import("vue").DefineComponent<{
71
71
  default: undefined;
72
72
  };
73
73
  }>>, {
74
+ orientation: "horizontal" | "vertical";
75
+ ui: Partial<any>;
74
76
  icon: string;
75
77
  avatar: Avatar;
76
- ui: Partial<any>;
78
+ type: "solid" | "dotted" | "dashed";
77
79
  class: any;
78
80
  label: string;
79
- type: "solid" | "dotted" | "dashed";
80
- orientation: "horizontal" | "vertical";
81
81
  }, {}>;
82
82
  export default _default;