@nuxt/ui 2.11.1 → 2.12.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 (74) hide show
  1. package/dist/module.d.mts +100 -28
  2. package/dist/module.d.ts +100 -28
  3. package/dist/module.json +1 -1
  4. package/dist/module.mjs +2 -2
  5. package/dist/runtime/components/data/Table.vue +26 -18
  6. package/dist/runtime/components/data/Table.vue.d.ts +21 -12
  7. package/dist/runtime/components/elements/Accordion.vue +8 -4
  8. package/dist/runtime/components/elements/Accordion.vue.d.ts +4 -4
  9. package/dist/runtime/components/elements/Alert.vue +8 -2
  10. package/dist/runtime/components/elements/Alert.vue.d.ts +5 -10
  11. package/dist/runtime/components/elements/Button.vue +6 -3
  12. package/dist/runtime/components/elements/Button.vue.d.ts +119 -1
  13. package/dist/runtime/components/elements/Chip.vue.d.ts +2 -2
  14. package/dist/runtime/components/elements/Dropdown.vue +66 -17
  15. package/dist/runtime/components/elements/Dropdown.vue.d.ts +31 -4
  16. package/dist/runtime/components/elements/Link.vue +9 -4
  17. package/dist/runtime/components/elements/Link.vue.d.ts +194 -4
  18. package/dist/runtime/components/forms/Form.vue +16 -7
  19. package/dist/runtime/components/forms/Form.vue.d.ts +1 -1
  20. package/dist/runtime/components/forms/Input.vue +1 -1
  21. package/dist/runtime/components/forms/Input.vue.d.ts +1 -1
  22. package/dist/runtime/components/forms/InputMenu.vue +419 -0
  23. package/dist/runtime/components/forms/InputMenu.vue.d.ts +332 -0
  24. package/dist/runtime/components/forms/RadioGroup.vue +1 -1
  25. package/dist/runtime/components/forms/Select.vue +1 -1
  26. package/dist/runtime/components/forms/Select.vue.d.ts +1 -1
  27. package/dist/runtime/components/forms/SelectMenu.vue +70 -21
  28. package/dist/runtime/components/forms/SelectMenu.vue.d.ts +31 -10
  29. package/dist/runtime/components/forms/Toggle.vue +1 -1
  30. package/dist/runtime/components/forms/Toggle.vue.d.ts +2 -1
  31. package/dist/runtime/components/layout/Divider.vue +4 -5
  32. package/dist/runtime/components/navigation/Breadcrumb.vue +8 -5
  33. package/dist/runtime/components/navigation/Breadcrumb.vue.d.ts +4 -2
  34. package/dist/runtime/components/navigation/CommandPalette.vue.d.ts +3 -3
  35. package/dist/runtime/components/navigation/Pagination.vue +9 -4
  36. package/dist/runtime/components/navigation/Pagination.vue.d.ts +9 -0
  37. package/dist/runtime/components/navigation/VerticalNavigation.vue +53 -38
  38. package/dist/runtime/components/navigation/VerticalNavigation.vue.d.ts +8 -5
  39. package/dist/runtime/components/overlays/Modal.vue.d.ts +1 -1
  40. package/dist/runtime/components/overlays/Popover.vue +49 -13
  41. package/dist/runtime/components/overlays/Popover.vue.d.ts +14 -4
  42. package/dist/runtime/components/overlays/Slideover.vue.d.ts +1 -1
  43. package/dist/runtime/components/overlays/Tooltip.vue +1 -1
  44. package/dist/runtime/composables/useShortcuts.mjs +3 -1
  45. package/dist/runtime/types/alert.d.ts +5 -0
  46. package/dist/runtime/types/breadcrumb.d.ts +1 -0
  47. package/dist/runtime/types/chip.d.ts +4 -0
  48. package/dist/runtime/types/dropdown.d.ts +2 -0
  49. package/dist/runtime/types/form.d.ts +1 -0
  50. package/dist/runtime/types/index.d.ts +1 -0
  51. package/dist/runtime/types/link.d.ts +3 -0
  52. package/dist/runtime/types/tooltip.d.ts +7 -0
  53. package/dist/runtime/types/vertical-navigation.d.ts +1 -0
  54. package/dist/runtime/ui.config/forms/input.mjs +12 -12
  55. package/dist/runtime/ui.config/forms/inputMenu.d.ts +64 -0
  56. package/dist/runtime/ui.config/forms/inputMenu.mjs +62 -0
  57. package/dist/runtime/ui.config/forms/selectMenu.d.ts +14 -12
  58. package/dist/runtime/ui.config/forms/selectMenu.mjs +7 -41
  59. package/dist/runtime/ui.config/index.d.ts +1 -0
  60. package/dist/runtime/ui.config/index.mjs +1 -0
  61. package/dist/runtime/ui.config/layout/card.mjs +1 -1
  62. package/dist/runtime/ui.config/navigation/breadcrumb.d.ts +1 -0
  63. package/dist/runtime/ui.config/navigation/breadcrumb.mjs +1 -0
  64. package/dist/runtime/ui.config/navigation/verticalNavigation.d.ts +5 -0
  65. package/dist/runtime/ui.config/navigation/verticalNavigation.mjs +5 -0
  66. package/dist/runtime/ui.config/popper.mjs +2 -1
  67. package/dist/runtime/utils/index.d.ts +1 -0
  68. package/dist/runtime/utils/index.mjs +12 -3
  69. package/dist/runtime/utils/link.d.ts +58 -0
  70. package/dist/runtime/utils/link.mjs +111 -0
  71. package/dist/runtime/utils/uid.mjs +2 -1
  72. package/dist/types.d.mts +2 -2
  73. package/dist/types.d.ts +1 -1
  74. package/package.json +31 -28
@@ -0,0 +1,332 @@
1
+ import type { PropType } from 'vue';
2
+ import type { InputSize, InputVariant, PopperOptions } from '../../types';
3
+ declare const _default: import("vue").DefineComponent<{
4
+ modelValue: {
5
+ type: (ObjectConstructor | NumberConstructor | StringConstructor | ArrayConstructor)[];
6
+ default: string;
7
+ };
8
+ query: {
9
+ type: StringConstructor;
10
+ default: null;
11
+ };
12
+ by: {
13
+ type: StringConstructor;
14
+ default: undefined;
15
+ };
16
+ options: {
17
+ type: PropType<string[] | {
18
+ [key: string]: any;
19
+ disabled?: boolean | undefined;
20
+ }[]>;
21
+ default: () => never[];
22
+ };
23
+ id: {
24
+ type: StringConstructor;
25
+ default: null;
26
+ };
27
+ name: {
28
+ type: StringConstructor;
29
+ default: null;
30
+ };
31
+ required: {
32
+ type: BooleanConstructor;
33
+ default: boolean;
34
+ };
35
+ icon: {
36
+ type: StringConstructor;
37
+ default: null;
38
+ };
39
+ loadingIcon: {
40
+ type: StringConstructor;
41
+ default: () => any;
42
+ };
43
+ leadingIcon: {
44
+ type: StringConstructor;
45
+ default: null;
46
+ };
47
+ trailingIcon: {
48
+ type: StringConstructor;
49
+ default: () => any;
50
+ };
51
+ trailing: {
52
+ type: BooleanConstructor;
53
+ default: boolean;
54
+ };
55
+ leading: {
56
+ type: BooleanConstructor;
57
+ default: boolean;
58
+ };
59
+ loading: {
60
+ type: BooleanConstructor;
61
+ default: boolean;
62
+ };
63
+ selectedIcon: {
64
+ type: StringConstructor;
65
+ default: () => any;
66
+ };
67
+ disabled: {
68
+ type: BooleanConstructor;
69
+ default: boolean;
70
+ };
71
+ placeholder: {
72
+ type: StringConstructor;
73
+ default: null;
74
+ };
75
+ padded: {
76
+ type: BooleanConstructor;
77
+ default: boolean;
78
+ };
79
+ size: {
80
+ type: PropType<InputSize>;
81
+ default: null;
82
+ validator(value: string): boolean;
83
+ };
84
+ color: {
85
+ type: PropType<any>;
86
+ default: () => any;
87
+ validator(value: string): boolean;
88
+ };
89
+ variant: {
90
+ type: PropType<InputVariant>;
91
+ default: () => any;
92
+ validator(value: string): boolean;
93
+ };
94
+ optionAttribute: {
95
+ type: StringConstructor;
96
+ default: string;
97
+ };
98
+ valueAttribute: {
99
+ type: StringConstructor;
100
+ default: null;
101
+ };
102
+ search: {
103
+ type: PropType<(query: string) => Promise<any[]> | any[]>;
104
+ default: undefined;
105
+ };
106
+ searchAttributes: {
107
+ type: ArrayConstructor;
108
+ default: null;
109
+ };
110
+ debounce: {
111
+ type: NumberConstructor;
112
+ default: number;
113
+ };
114
+ popper: {
115
+ type: PropType<PopperOptions>;
116
+ default: () => {};
117
+ };
118
+ inputClass: {
119
+ type: StringConstructor;
120
+ default: null;
121
+ };
122
+ class: {
123
+ type: PropType<any>;
124
+ default: () => "";
125
+ };
126
+ ui: {
127
+ type: PropType<any>;
128
+ default: () => {};
129
+ };
130
+ uiMenu: {
131
+ type: PropType<any>;
132
+ default: () => {};
133
+ };
134
+ }, {
135
+ ui: import("vue").ComputedRef<any>;
136
+ uiMenu: import("vue").ComputedRef<any>;
137
+ attrs: import("vue").ComputedRef<Pick<{
138
+ [x: string]: unknown;
139
+ }, string>>;
140
+ name: import("vue").ComputedRef<string | undefined>;
141
+ inputId: import("vue").Ref<string | undefined>;
142
+ popper: import("vue").ComputedRef<PopperOptions>;
143
+ trigger: import("vue").Ref<import("@vueuse/core").MaybeElement>;
144
+ container: import("vue").Ref<import("@vueuse/core").MaybeElement>;
145
+ label: import("vue").ComputedRef<any>;
146
+ isLeading: import("vue").ComputedRef<string | true>;
147
+ isTrailing: import("vue").ComputedRef<string | true | undefined>;
148
+ inputClass: import("vue").ComputedRef<string>;
149
+ leadingIconName: import("vue").ComputedRef<string | undefined>;
150
+ leadingIconClass: import("vue").ComputedRef<string>;
151
+ leadingWrapperIconClass: import("vue").ComputedRef<string>;
152
+ trailingIconName: import("vue").ComputedRef<string | undefined>;
153
+ trailingIconClass: import("vue").ComputedRef<string>;
154
+ trailingWrapperIconClass: import("vue").ComputedRef<string>;
155
+ filteredOptions: import("vue").Ref<any[]>;
156
+ query: import("vue").WritableComputedRef<string>;
157
+ onUpdate: (event: any) => void;
158
+ onChange: (event: any) => void;
159
+ }, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("change" | "close" | "update:modelValue" | "open" | "update:query")[], "change" | "close" | "update:modelValue" | "open" | "update:query", import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
160
+ modelValue: {
161
+ type: (ObjectConstructor | NumberConstructor | StringConstructor | ArrayConstructor)[];
162
+ default: string;
163
+ };
164
+ query: {
165
+ type: StringConstructor;
166
+ default: null;
167
+ };
168
+ by: {
169
+ type: StringConstructor;
170
+ default: undefined;
171
+ };
172
+ options: {
173
+ type: PropType<string[] | {
174
+ [key: string]: any;
175
+ disabled?: boolean | undefined;
176
+ }[]>;
177
+ default: () => never[];
178
+ };
179
+ id: {
180
+ type: StringConstructor;
181
+ default: null;
182
+ };
183
+ name: {
184
+ type: StringConstructor;
185
+ default: null;
186
+ };
187
+ required: {
188
+ type: BooleanConstructor;
189
+ default: boolean;
190
+ };
191
+ icon: {
192
+ type: StringConstructor;
193
+ default: null;
194
+ };
195
+ loadingIcon: {
196
+ type: StringConstructor;
197
+ default: () => any;
198
+ };
199
+ leadingIcon: {
200
+ type: StringConstructor;
201
+ default: null;
202
+ };
203
+ trailingIcon: {
204
+ type: StringConstructor;
205
+ default: () => any;
206
+ };
207
+ trailing: {
208
+ type: BooleanConstructor;
209
+ default: boolean;
210
+ };
211
+ leading: {
212
+ type: BooleanConstructor;
213
+ default: boolean;
214
+ };
215
+ loading: {
216
+ type: BooleanConstructor;
217
+ default: boolean;
218
+ };
219
+ selectedIcon: {
220
+ type: StringConstructor;
221
+ default: () => any;
222
+ };
223
+ disabled: {
224
+ type: BooleanConstructor;
225
+ default: boolean;
226
+ };
227
+ placeholder: {
228
+ type: StringConstructor;
229
+ default: null;
230
+ };
231
+ padded: {
232
+ type: BooleanConstructor;
233
+ default: boolean;
234
+ };
235
+ size: {
236
+ type: PropType<InputSize>;
237
+ default: null;
238
+ validator(value: string): boolean;
239
+ };
240
+ color: {
241
+ type: PropType<any>;
242
+ default: () => any;
243
+ validator(value: string): boolean;
244
+ };
245
+ variant: {
246
+ type: PropType<InputVariant>;
247
+ default: () => any;
248
+ validator(value: string): boolean;
249
+ };
250
+ optionAttribute: {
251
+ type: StringConstructor;
252
+ default: string;
253
+ };
254
+ valueAttribute: {
255
+ type: StringConstructor;
256
+ default: null;
257
+ };
258
+ search: {
259
+ type: PropType<(query: string) => Promise<any[]> | any[]>;
260
+ default: undefined;
261
+ };
262
+ searchAttributes: {
263
+ type: ArrayConstructor;
264
+ default: null;
265
+ };
266
+ debounce: {
267
+ type: NumberConstructor;
268
+ default: number;
269
+ };
270
+ popper: {
271
+ type: PropType<PopperOptions>;
272
+ default: () => {};
273
+ };
274
+ inputClass: {
275
+ type: StringConstructor;
276
+ default: null;
277
+ };
278
+ class: {
279
+ type: PropType<any>;
280
+ default: () => "";
281
+ };
282
+ ui: {
283
+ type: PropType<any>;
284
+ default: () => {};
285
+ };
286
+ uiMenu: {
287
+ type: PropType<any>;
288
+ default: () => {};
289
+ };
290
+ }>> & {
291
+ "onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
292
+ onChange?: ((...args: any[]) => any) | undefined;
293
+ onClose?: ((...args: any[]) => any) | undefined;
294
+ onOpen?: ((...args: any[]) => any) | undefined;
295
+ "onUpdate:query"?: ((...args: any[]) => any) | undefined;
296
+ }, {
297
+ size: InputSize;
298
+ ui: any;
299
+ id: string;
300
+ icon: string;
301
+ color: any;
302
+ options: string[] | {
303
+ [key: string]: any;
304
+ disabled?: boolean | undefined;
305
+ }[];
306
+ popper: PopperOptions;
307
+ name: string;
308
+ leading: boolean;
309
+ search: (query: string) => Promise<any[]> | any[];
310
+ class: any;
311
+ modelValue: string | number | unknown[] | Record<string, any>;
312
+ by: string;
313
+ loading: boolean;
314
+ disabled: boolean;
315
+ variant: InputVariant;
316
+ required: boolean;
317
+ placeholder: string;
318
+ padded: boolean;
319
+ loadingIcon: string;
320
+ leadingIcon: string;
321
+ trailingIcon: string;
322
+ trailing: boolean;
323
+ inputClass: string;
324
+ query: string;
325
+ selectedIcon: string;
326
+ optionAttribute: string;
327
+ valueAttribute: string;
328
+ searchAttributes: unknown[];
329
+ debounce: number;
330
+ uiMenu: any;
331
+ }, {}>;
332
+ export default _default;
@@ -12,7 +12,7 @@
12
12
  :label="option.label"
13
13
  :model-value="modelValue"
14
14
  :value="option.value"
15
- :disabled="disabled"
15
+ :disabled="option.disabled || disabled"
16
16
  :ui="uiRadio"
17
17
  @change="onUpdate(option.value)"
18
18
  >
@@ -5,7 +5,7 @@
5
5
  :name="name"
6
6
  :value="modelValue"
7
7
  :required="required"
8
- :disabled="disabled || loading"
8
+ :disabled="disabled"
9
9
  :class="selectClass"
10
10
  v-bind="attrs"
11
11
  @input="onInput"
@@ -228,6 +228,7 @@ declare const _default: import("vue").DefineComponent<{
228
228
  color: any;
229
229
  options: unknown[];
230
230
  name: string;
231
+ leading: boolean;
231
232
  class: any;
232
233
  modelValue: string | number | Record<string, any>;
233
234
  loading: boolean;
@@ -240,7 +241,6 @@ declare const _default: import("vue").DefineComponent<{
240
241
  leadingIcon: string;
241
242
  trailingIcon: string;
242
243
  trailing: boolean;
243
- leading: boolean;
244
244
  optionAttribute: string;
245
245
  valueAttribute: string;
246
246
  selectClass: string;
@@ -6,7 +6,7 @@
6
6
  :name="name"
7
7
  :model-value="modelValue"
8
8
  :multiple="multiple"
9
- :disabled="disabled || loading"
9
+ :disabled="disabled"
10
10
  as="div"
11
11
  :class="ui.wrapper"
12
12
  @update:model-value="onUpdate"
@@ -28,7 +28,7 @@
28
28
  :class="uiMenu.trigger"
29
29
  >
30
30
  <slot :open="open" :disabled="disabled" :loading="loading">
31
- <button :id="inputId" :class="selectClass" :disabled="disabled || loading" type="button" v-bind="attrs">
31
+ <button :id="inputId" :class="selectClass" :disabled="disabled" type="button" v-bind="attrs">
32
32
  <span v-if="(isLeading && leadingIconName) || $slots.leading" :class="leadingWrapperIconClass">
33
33
  <slot name="leading" :disabled="disabled" :loading="loading">
34
34
  <UIcon :name="leadingIconName" :class="leadingIconClass" />
@@ -36,8 +36,7 @@
36
36
  </span>
37
37
 
38
38
  <slot name="label">
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>
39
+ <span v-if="label" :class="uiMenu.label">{{ label }}</span>
41
40
  <span v-else :class="uiMenu.label">{{ placeholder || '&nbsp;' }}</span>
42
41
  </slot>
43
42
 
@@ -58,14 +57,13 @@
58
57
  <component :is="searchable ? 'HComboboxOptions' : 'HListboxOptions'" static :class="[uiMenu.base, uiMenu.ring, uiMenu.rounded, uiMenu.shadow, uiMenu.background, uiMenu.padding, uiMenu.height]">
59
58
  <HComboboxInput
60
59
  v-if="searchable"
61
- ref="searchInput"
62
60
  :display-value="() => query"
63
61
  name="q"
64
62
  :placeholder="searchablePlaceholder"
65
63
  autofocus
66
64
  autocomplete="off"
67
65
  :class="uiMenu.input"
68
- @change="query = $event.target.value"
66
+ @change="onChange"
69
67
  />
70
68
  <component
71
69
  :is="searchable ? 'HComboboxOption' : 'HListboxOption'"
@@ -98,11 +96,11 @@
98
96
  </li>
99
97
  </component>
100
98
 
101
- <component :is="searchable ? 'HComboboxOption' : 'HListboxOption'" v-if="creatable && queryOption && !filteredOptions.length" v-slot="{ active, selected }" :value="queryOption" as="template">
99
+ <component :is="searchable ? 'HComboboxOption' : 'HListboxOption'" v-if="creatable && createOption" v-slot="{ active, selected }" :value="createOption" as="template">
102
100
  <li :class="[uiMenu.option.base, uiMenu.option.rounded, uiMenu.option.padding, uiMenu.option.size, uiMenu.option.color, active ? uiMenu.option.active : uiMenu.option.inactive]">
103
101
  <div :class="uiMenu.option.container">
104
- <slot name="option-create" :option="queryOption" :active="active" :selected="selected">
105
- <span :class="uiMenu.option.create">Create "{{ queryOption[optionAttribute] }}"</span>
102
+ <slot name="option-create" :option="createOption" :active="active" :selected="selected">
103
+ <span :class="uiMenu.option.create">Create "{{ createOption[optionAttribute] }}"</span>
106
104
  </slot>
107
105
  </div>
108
106
  </li>
@@ -112,6 +110,11 @@
112
110
  No results for "{{ query }}".
113
111
  </slot>
114
112
  </p>
113
+ <p v-else-if="!filteredOptions.length" :class="uiMenu.empty">
114
+ <slot name="empty" :query="query">
115
+ No options.
116
+ </slot>
117
+ </p>
115
118
  </component>
116
119
  </div>
117
120
  </Transition>
@@ -166,6 +169,10 @@ export default defineComponent({
166
169
  type: [String, Number, Object, Array],
167
170
  default: ""
168
171
  },
172
+ query: {
173
+ type: String,
174
+ default: null
175
+ },
169
176
  by: {
170
177
  type: String,
171
178
  default: void 0
@@ -236,7 +243,7 @@ export default defineComponent({
236
243
  },
237
244
  clearSearchOnClose: {
238
245
  type: Boolean,
239
- default: () => configMenu.default.clearOnClose
246
+ default: () => configMenu.default.clearSearchOnClose
240
247
  },
241
248
  debounce: {
242
249
  type: Number,
@@ -246,6 +253,10 @@ export default defineComponent({
246
253
  type: Boolean,
247
254
  default: false
248
255
  },
256
+ showCreateOptionWhen: {
257
+ type: String,
258
+ default: () => configMenu.default.showCreateOptionWhen
259
+ },
249
260
  placeholder: {
250
261
  type: String,
251
262
  default: null
@@ -311,7 +322,7 @@ export default defineComponent({
311
322
  default: () => ({})
312
323
  }
313
324
  },
314
- emits: ["update:modelValue", "open", "close", "change"],
325
+ emits: ["update:modelValue", "update:query", "open", "close", "change"],
315
326
  setup(props, { emit, slots }) {
316
327
  const { ui, attrs } = useUI("select", toRef(props, "ui"), config, toRef(props, "class"));
317
328
  const { ui: uiMenu } = useUI("selectMenu", toRef(props, "uiMenu"), configMenu);
@@ -320,8 +331,32 @@ export default defineComponent({
320
331
  const { size: sizeButtonGroup, rounded } = useInjectButtonGroup({ ui, props });
321
332
  const { emitFormBlur, emitFormChange, inputId, color, size: sizeFormGroup, name } = useFormGroup(props, config);
322
333
  const size = computed(() => sizeButtonGroup.value || sizeFormGroup.value);
323
- const query = ref("");
324
- const searchInput = ref();
334
+ const internalQuery = ref("");
335
+ const query = computed({
336
+ get() {
337
+ return props.query ?? internalQuery.value;
338
+ },
339
+ set(value) {
340
+ internalQuery.value = value;
341
+ emit("update:query", value);
342
+ }
343
+ });
344
+ const label = computed(() => {
345
+ if (props.multiple) {
346
+ if (Array.isArray(props.modelValue) && props.modelValue.length) {
347
+ return `${props.modelValue.length} selected`;
348
+ } else {
349
+ return null;
350
+ }
351
+ } else {
352
+ if (props.valueAttribute) {
353
+ const option = props.options.find((option2) => option2[props.valueAttribute] === props.modelValue);
354
+ return option ? option[props.optionAttribute] : null;
355
+ } else {
356
+ return ["string", "number"].includes(typeof props.modelValue) ? props.modelValue : props.modelValue[props.optionAttribute];
357
+ }
358
+ }
359
+ });
325
360
  const selectClass = computed(() => {
326
361
  const variant = ui.value.color?.[color.value]?.[props.variant] || ui.value.variant[props.variant];
327
362
  return twMerge(twJoin(
@@ -402,8 +437,20 @@ export default defineComponent({
402
437
  });
403
438
  });
404
439
  });
405
- const queryOption = computed(() => {
406
- return query.value === "" ? null : { [props.optionAttribute]: query.value };
440
+ const createOption = computed(() => {
441
+ if (query.value === "") {
442
+ return null;
443
+ }
444
+ if (props.showCreateOptionWhen === "empty" && filteredOptions.value.length) {
445
+ return null;
446
+ }
447
+ if (props.showCreateOptionWhen === "always") {
448
+ const existingOption = filteredOptions.value.find((option) => ["string", "number"].includes(typeof option) ? option === query.value : option[props.optionAttribute] === query.value);
449
+ if (existingOption) {
450
+ return null;
451
+ }
452
+ }
453
+ return ["string", "number"].includes(typeof props.modelValue) ? query.value : { [props.optionAttribute]: query.value };
407
454
  });
408
455
  function clearOnClose() {
409
456
  if (props.clearSearchOnClose) {
@@ -420,14 +467,13 @@ export default defineComponent({
420
467
  }
421
468
  });
422
469
  function onUpdate(event) {
423
- if (query.value && searchInput.value?.$el) {
424
- query.value = "";
425
- searchInput.value.$el.value = "";
426
- }
427
470
  emit("update:modelValue", event);
428
471
  emit("change", event);
429
472
  emitFormChange();
430
473
  }
474
+ function onChange(event) {
475
+ query.value = event.target.value;
476
+ }
431
477
  return {
432
478
  // eslint-disable-next-line vue/no-dupe-keys
433
479
  ui,
@@ -441,6 +487,7 @@ export default defineComponent({
441
487
  popper,
442
488
  trigger,
443
489
  container,
490
+ label,
444
491
  isLeading,
445
492
  isTrailing,
446
493
  // eslint-disable-next-line vue/no-dupe-keys
@@ -452,9 +499,11 @@ export default defineComponent({
452
499
  trailingIconClass,
453
500
  trailingWrapperIconClass,
454
501
  filteredOptions,
455
- queryOption,
502
+ createOption,
503
+ // eslint-disable-next-line vue/no-dupe-keys
456
504
  query,
457
- onUpdate
505
+ onUpdate,
506
+ onChange
458
507
  };
459
508
  }
460
509
  });
@@ -2,9 +2,13 @@ import type { PropType } from 'vue';
2
2
  import type { SelectSize, SelectVariant, PopperOptions } from '../../types';
3
3
  declare const _default: import("vue").DefineComponent<{
4
4
  modelValue: {
5
- type: (ObjectConstructor | NumberConstructor | ArrayConstructor | StringConstructor)[];
5
+ type: (ObjectConstructor | NumberConstructor | StringConstructor | ArrayConstructor)[];
6
6
  default: string;
7
7
  };
8
+ query: {
9
+ type: StringConstructor;
10
+ default: null;
11
+ };
8
12
  by: {
9
13
  type: StringConstructor;
10
14
  default: undefined;
@@ -88,6 +92,10 @@ declare const _default: import("vue").DefineComponent<{
88
92
  type: BooleanConstructor;
89
93
  default: boolean;
90
94
  };
95
+ showCreateOptionWhen: {
96
+ type: PropType<"empty" | "always">;
97
+ default: () => any;
98
+ };
91
99
  placeholder: {
92
100
  type: StringConstructor;
93
101
  default: null;
@@ -154,6 +162,7 @@ declare const _default: import("vue").DefineComponent<{
154
162
  popper: import("vue").ComputedRef<PopperOptions>;
155
163
  trigger: import("vue").Ref<import("@vueuse/core").MaybeElement>;
156
164
  container: import("vue").Ref<import("@vueuse/core").MaybeElement>;
165
+ label: import("vue").ComputedRef<any>;
157
166
  isLeading: import("vue").ComputedRef<string | true>;
158
167
  isTrailing: import("vue").ComputedRef<string | true | undefined>;
159
168
  selectClass: import("vue").ComputedRef<string>;
@@ -164,16 +173,21 @@ declare const _default: import("vue").DefineComponent<{
164
173
  trailingIconClass: import("vue").ComputedRef<string>;
165
174
  trailingWrapperIconClass: import("vue").ComputedRef<string>;
166
175
  filteredOptions: import("vue").Ref<any[]>;
167
- queryOption: import("vue").ComputedRef<{
176
+ createOption: import("vue").ComputedRef<string | {
168
177
  [x: string]: string;
169
178
  } | null>;
170
- query: import("vue").Ref<string>;
179
+ query: import("vue").WritableComputedRef<string>;
171
180
  onUpdate: (event: any) => void;
172
- }, 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<{
181
+ onChange: (event: any) => void;
182
+ }, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("change" | "close" | "update:modelValue" | "open" | "update:query")[], "change" | "close" | "update:modelValue" | "open" | "update:query", import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
173
183
  modelValue: {
174
- type: (ObjectConstructor | NumberConstructor | ArrayConstructor | StringConstructor)[];
184
+ type: (ObjectConstructor | NumberConstructor | StringConstructor | ArrayConstructor)[];
175
185
  default: string;
176
186
  };
187
+ query: {
188
+ type: StringConstructor;
189
+ default: null;
190
+ };
177
191
  by: {
178
192
  type: StringConstructor;
179
193
  default: undefined;
@@ -257,6 +271,10 @@ declare const _default: import("vue").DefineComponent<{
257
271
  type: BooleanConstructor;
258
272
  default: boolean;
259
273
  };
274
+ showCreateOptionWhen: {
275
+ type: PropType<"empty" | "always">;
276
+ default: () => any;
277
+ };
260
278
  placeholder: {
261
279
  type: StringConstructor;
262
280
  default: null;
@@ -317,6 +335,7 @@ declare const _default: import("vue").DefineComponent<{
317
335
  onChange?: ((...args: any[]) => any) | undefined;
318
336
  onClose?: ((...args: any[]) => any) | undefined;
319
337
  onOpen?: ((...args: any[]) => any) | undefined;
338
+ "onUpdate:query"?: ((...args: any[]) => any) | undefined;
320
339
  }, {
321
340
  size: SelectSize;
322
341
  ui: any;
@@ -329,6 +348,7 @@ declare const _default: import("vue").DefineComponent<{
329
348
  }[];
330
349
  popper: PopperOptions;
331
350
  name: string;
351
+ leading: boolean;
332
352
  class: any;
333
353
  modelValue: string | number | unknown[] | Record<string, any>;
334
354
  by: string;
@@ -343,17 +363,18 @@ declare const _default: import("vue").DefineComponent<{
343
363
  leadingIcon: string;
344
364
  trailingIcon: string;
345
365
  trailing: boolean;
346
- leading: boolean;
366
+ query: string;
367
+ selectedIcon: string;
347
368
  optionAttribute: string;
348
369
  valueAttribute: string;
370
+ searchAttributes: unknown[];
371
+ debounce: number;
372
+ uiMenu: any;
349
373
  selectClass: string;
350
- selectedIcon: string;
351
374
  searchable: boolean | ((query: string) => Promise<any[]> | any[]);
352
375
  searchablePlaceholder: string;
353
376
  clearSearchOnClose: boolean;
354
- debounce: number;
355
377
  creatable: boolean;
356
- searchAttributes: unknown[];
357
- uiMenu: any;
378
+ showCreateOptionWhen: "empty" | "always";
358
379
  }, {}>;
359
380
  export default _default;
@@ -83,7 +83,7 @@ export default defineComponent({
83
83
  default: () => ({})
84
84
  }
85
85
  },
86
- emits: ["update:modelValue"],
86
+ emits: ["update:modelValue", "change"],
87
87
  setup(props, { emit }) {
88
88
  const { ui, attrs } = useUI("toggle", toRef(props, "ui"), config);
89
89
  const { emitFormChange, color, inputId, name } = useFormGroup(props);