@volverjs/ui-vue 0.0.10 → 0.0.12

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 (94) hide show
  1. package/bin/icons.js +1 -93
  2. package/dist/components/VvAccordion/VvAccordion.es.js +1 -366
  3. package/dist/components/VvAccordion/VvAccordion.vue.d.ts +2 -1
  4. package/dist/components/VvAccordionGroup/VvAccordionGroup.es.js +2 -702
  5. package/dist/components/VvAccordionGroup/VvAccordionGroup.vue.d.ts +3 -2
  6. package/dist/components/VvAction/VvAction.es.js +1 -302
  7. package/dist/components/VvAction/VvAction.vue.d.ts +2 -1
  8. package/dist/components/VvAlert/VvAlert.es.js +1 -527
  9. package/dist/components/VvAlert/VvAlert.umd.js +1 -1
  10. package/dist/components/VvAlert/VvAlert.vue.d.ts +2 -1
  11. package/dist/components/VvAlertGroup/VvAlertGroup.es.js +1 -730
  12. package/dist/components/VvAlertGroup/VvAlertGroup.umd.js +1 -1
  13. package/dist/components/VvAlertGroup/VvAlertGroup.vue.d.ts +2 -1
  14. package/dist/components/VvAvatar/VvAvatar.es.js +1 -132
  15. package/dist/components/VvAvatar/VvAvatar.vue.d.ts +2 -1
  16. package/dist/components/VvAvatarGroup/VvAvatarGroup.es.js +1 -250
  17. package/dist/components/VvAvatarGroup/VvAvatarGroup.vue.d.ts +2 -1
  18. package/dist/components/VvBadge/VvBadge.es.js +1 -131
  19. package/dist/components/VvBadge/VvBadge.vue.d.ts +2 -1
  20. package/dist/components/VvBreadcrumb/VvBreadcrumb.es.js +1 -410
  21. package/dist/components/VvBreadcrumb/VvBreadcrumb.vue.d.ts +2 -1
  22. package/dist/components/VvButton/VvButton.es.js +1 -882
  23. package/dist/components/VvButton/VvButton.umd.js +1 -1
  24. package/dist/components/VvButton/VvButton.vue.d.ts +2 -1
  25. package/dist/components/VvButtonGroup/VvButtonGroup.es.js +1 -214
  26. package/dist/components/VvButtonGroup/VvButtonGroup.vue.d.ts +2 -1
  27. package/dist/components/VvCard/VvCard.es.js +1 -152
  28. package/dist/components/VvCard/VvCard.vue.d.ts +2 -1
  29. package/dist/components/VvCheckbox/VvCheckbox.es.js +1 -741
  30. package/dist/components/VvCheckbox/VvCheckbox.vue.d.ts +3 -2
  31. package/dist/components/VvCheckboxGroup/VvCheckboxGroup.es.js +1 -981
  32. package/dist/components/VvCheckboxGroup/VvCheckboxGroup.vue.d.ts +2 -1
  33. package/dist/components/VvCombobox/VvCombobox.es.js +1 -3463
  34. package/dist/components/VvCombobox/VvCombobox.umd.js +1 -1
  35. package/dist/components/VvCombobox/VvCombobox.vue.d.ts +263 -317
  36. package/dist/components/VvDialog/VvDialog.es.js +1 -317
  37. package/dist/components/VvDialog/VvDialog.vue.d.ts +2 -1
  38. package/dist/components/VvDropdown/VvDropdown.es.js +1 -750
  39. package/dist/components/VvDropdown/VvDropdown.vue.d.ts +2 -1
  40. package/dist/components/VvDropdown/VvDropdownAction.vue.d.ts +5 -4
  41. package/dist/components/VvDropdown/VvDropdownItem.vue.d.ts +2 -1
  42. package/dist/components/VvDropdown/VvDropdownOptgroup.vue.d.ts +10 -2
  43. package/dist/components/VvDropdown/VvDropdownOption.vue.d.ts +2 -1
  44. package/dist/components/VvDropdownAction/VvDropdownAction.es.js +1 -448
  45. package/dist/components/VvDropdownItem/VvDropdownItem.es.js +1 -149
  46. package/dist/components/VvDropdownOptgroup/VvDropdownOptgroup.es.js +1 -104
  47. package/dist/components/VvDropdownOptgroup/VvDropdownOptgroup.umd.js +1 -1
  48. package/dist/components/VvDropdownOption/VvDropdownOption.es.js +1 -281
  49. package/dist/components/VvIcon/VvIcon.es.js +1 -143
  50. package/dist/components/VvIcon/VvIcon.umd.js +1 -1
  51. package/dist/components/VvIcon/VvIcon.vue.d.ts +2 -1
  52. package/dist/components/VvInputFile/VvInputFile.es.js +1 -1704
  53. package/dist/components/VvInputFile/VvInputFile.umd.js +1 -1
  54. package/dist/components/VvInputFile/VvInputFile.vue.d.ts +2 -1
  55. package/dist/components/VvInputText/VvInputText.es.js +4 -2790
  56. package/dist/components/VvInputText/VvInputText.umd.js +1 -1
  57. package/dist/components/VvInputText/VvInputText.vue.d.ts +2 -1
  58. package/dist/components/VvNav/VvNav.es.js +1 -438
  59. package/dist/components/VvNav/VvNav.vue.d.ts +2 -1
  60. package/dist/components/VvNav/VvNavItem.vue.d.ts +2 -1
  61. package/dist/components/VvNav/VvNavSeparator.vue.d.ts +2 -1
  62. package/dist/components/VvNavItem/VvNavItem.es.js +1 -337
  63. package/dist/components/VvNavSeparator/VvNavSeparator.es.js +1 -24
  64. package/dist/components/VvProgress/VvProgress.es.js +1 -163
  65. package/dist/components/VvProgress/VvProgress.vue.d.ts +2 -1
  66. package/dist/components/VvRadio/VvRadio.es.js +1 -661
  67. package/dist/components/VvRadio/VvRadio.vue.d.ts +3 -2
  68. package/dist/components/VvRadioGroup/VvRadioGroup.es.js +1 -901
  69. package/dist/components/VvRadioGroup/VvRadioGroup.vue.d.ts +2 -1
  70. package/dist/components/VvSelect/VvSelect.es.js +1 -1103
  71. package/dist/components/VvSelect/VvSelect.umd.js +1 -1
  72. package/dist/components/VvSelect/VvSelect.vue.d.ts +130 -71
  73. package/dist/components/VvTab/VvTab.es.js +1 -558
  74. package/dist/components/VvTab/VvTab.vue.d.ts +2 -1
  75. package/dist/components/VvTextarea/VvTextarea.es.js +2 -1989
  76. package/dist/components/VvTextarea/VvTextarea.umd.js +1 -1
  77. package/dist/components/VvTextarea/VvTextarea.vue.d.ts +2 -1
  78. package/dist/components/VvTooltip/VvTooltip.es.js +1 -154
  79. package/dist/components/VvTooltip/VvTooltip.vue.d.ts +2 -1
  80. package/dist/components/index.es.js +6 -8558
  81. package/dist/components/index.umd.js +1 -1
  82. package/dist/composables/index.es.js +2 -247
  83. package/dist/composables/index.umd.js +1 -1
  84. package/dist/directives/index.es.js +2 -311
  85. package/dist/directives/index.umd.js +1 -1
  86. package/dist/directives/v-contextmenu.es.js +2 -142
  87. package/dist/directives/v-contextmenu.umd.js +1 -1
  88. package/dist/directives/v-tooltip.es.js +1 -172
  89. package/dist/icons.es.js +1 -39
  90. package/dist/icons.umd.js +1 -1
  91. package/dist/index.es.js +1 -219
  92. package/dist/resolvers/unplugin.es.js +1 -187
  93. package/dist/stories/AccordionGroup/AccordionGroupSlots.stories.d.ts +14 -14
  94. package/package.json +37 -37
@@ -1,2790 +1,4 @@
1
- import { unref, computed, isRef, defineComponent, h, useId, Fragment, provide, ref, toRefs, useAttrs, onMounted, watch, createElementBlock, openBlock, createVNode, withCtx, renderSlot, normalizeProps, guardReactiveProps, Transition, mergeProps, toHandlers, withDirectives, createElementVNode, normalizeClass, normalizeStyle, createCommentVNode, vShow, nextTick, inject, createBlock, createTextVNode, toDisplayString, mergeDefaults, useSlots, withModifiers, createSlots, renderList } from "vue";
2
- import { useIMask } from "vue-imask";
3
- import { autoPlacement, flip, shift, size, offset, arrow, useFloating, autoUpdate } from "@floating-ui/vue";
4
- import { useMutationObserver, useVModel, onClickOutside, useFocusWithin, useElementHover, onKeyStroke, useFocus, useStorage, useElementVisibility } from "@vueuse/core";
5
- import mitt from "mitt";
6
- import { iconLoaded, Icon, addIcon } from "@iconify/vue";
7
- const padTwoDigits = (num) => num.toString().padStart(2, "0");
8
- function isDateIsoString(dateString) {
9
- if (typeof dateString !== "string") {
10
- return false;
11
- }
12
- if (!/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d{1,3})?(?:Z|[+-]\d{2}:?\d{2})?$/.test(dateString)) {
13
- return false;
14
- }
15
- const d = new Date(dateString);
16
- return !Number.isNaN(d.getTime()) && d.toISOString() === dateString;
17
- }
18
- function getInputValueFromDate(date, typeOfInput = "date", withSeconds) {
19
- if (typeof date === "string") {
20
- if (!isDateIsoString(date)) {
21
- return "";
22
- }
23
- }
24
- const currentDate = new Date(date);
25
- if (Number.isNaN(currentDate.getTime())) {
26
- return "";
27
- }
28
- let toReturn = `${currentDate.getFullYear()}-${padTwoDigits(currentDate.getMonth() + 1)}`;
29
- if (typeOfInput === "month") {
30
- return toReturn;
31
- }
32
- toReturn += `-${padTwoDigits(currentDate.getDate())}`;
33
- if (typeOfInput === "date") {
34
- return toReturn;
35
- }
36
- const time = withSeconds ? `${padTwoDigits(currentDate.getHours())}:${padTwoDigits(currentDate.getMinutes())}:${padTwoDigits(currentDate.getSeconds())}` : `${padTwoDigits(currentDate.getHours())}:${padTwoDigits(currentDate.getMinutes())}`;
37
- if (typeOfInput === "time") {
38
- return time;
39
- }
40
- return `${toReturn}T${time}`;
41
- }
42
- function getDateFromInputValue(value, typeOfInput = "date") {
43
- if (!value?.trim()) {
44
- return null;
45
- }
46
- const today = /* @__PURE__ */ new Date();
47
- const currentYear = today.getFullYear();
48
- const currentMonth = today.getMonth();
49
- const currentDate = today.getDate();
50
- if (typeOfInput === "date") {
51
- if (!/^\d{4}-\d{2}-\d{2}$/.test(value)) {
52
- throw new Error("Invalid date format. Expected: YYYY-MM-DD");
53
- }
54
- return /* @__PURE__ */ new Date(`${value}T00:00:00`);
55
- }
56
- if (typeOfInput === "month") {
57
- if (!/^\d{4}-\d{2}$/.test(value)) {
58
- throw new Error("Invalid month format. Expected: YYYY-MM");
59
- }
60
- return /* @__PURE__ */ new Date(`${value}-01T00:00:00`);
61
- }
62
- if (typeOfInput === "time") {
63
- if (!/^(?:[01]\d|2[0-3]):[0-5]\d(?::[0-5]\d)?$/.test(value)) {
64
- throw new Error("Invalid time format. Expected: HH:mm or HH:mm:ss");
65
- }
66
- if (value.length === 8) {
67
- return /* @__PURE__ */ new Date(`${currentYear}-${padTwoDigits(currentMonth + 1)}-${padTwoDigits(currentDate)}T${value}`);
68
- }
69
- return /* @__PURE__ */ new Date(`${currentYear}-${padTwoDigits(currentMonth + 1)}-${padTwoDigits(currentDate)}T${value}:00`);
70
- }
71
- if (!/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}(?::\d{2})?$/.test(value)) {
72
- throw new Error("Invalid datetime format. Expected: YYYY-MM-DDThh:mm or YYYY-MM-DDThh:mm:ss");
73
- }
74
- if (value.length === 16) {
75
- return /* @__PURE__ */ new Date(`${value}:00`);
76
- }
77
- return /* @__PURE__ */ new Date(`${value}`);
78
- }
79
- function isEmpty(value) {
80
- return ((value2) => value2 === null || value2 === void 0 || value2 === "" || Array.isArray(value2) && value2.length === 0 || !(value2 instanceof Date) && typeof value2 === "object" && Object.keys(value2).length === 0)(unref(value));
81
- }
82
- function isString(value) {
83
- return typeof value === "string";
84
- }
85
- function joinLines(items) {
86
- if (Array.isArray(items)) {
87
- return items.filter((item) => isString(item)).join(" ");
88
- }
89
- return items;
90
- }
91
- function HintSlotFactory(propsOrRef, slots) {
92
- const props = computed(() => {
93
- if (isRef(propsOrRef)) {
94
- return propsOrRef.value;
95
- }
96
- return propsOrRef;
97
- });
98
- const invalidLabel = computed(() => joinLines(props.value.invalidLabel));
99
- const validLabel = computed(() => joinLines(props.value.validLabel));
100
- const loadingLabel = computed(() => props.value.loadingLabel);
101
- const hintLabel = computed(() => props.value.hintLabel);
102
- const hasLoadingLabelOrSlot = computed(
103
- () => Boolean(props.value.loading && (slots.loading || loadingLabel.value))
104
- );
105
- const hasInvalidLabelOrSlot = computed(
106
- () => !hasLoadingLabelOrSlot.value && Boolean(
107
- props.value.invalid && (slots.invalid || invalidLabel.value)
108
- )
109
- );
110
- const hasValidLabelOrSlot = computed(
111
- () => !hasLoadingLabelOrSlot.value && !hasInvalidLabelOrSlot.value && Boolean(props.value.valid && (slots.valid || validLabel.value))
112
- );
113
- const hasHintLabelOrSlot = computed(
114
- () => !hasLoadingLabelOrSlot.value && !hasInvalidLabelOrSlot.value && !hasValidLabelOrSlot.value && Boolean(slots.hint || hintLabel.value)
115
- );
116
- const isVisible = computed(
117
- () => hasInvalidLabelOrSlot.value || hasValidLabelOrSlot.value || hasLoadingLabelOrSlot.value || hasHintLabelOrSlot.value
118
- );
119
- const hintSlotScope = computed(() => ({
120
- modelValue: props.value.modelValue,
121
- valid: props.value.valid,
122
- invalid: props.value.invalid,
123
- loading: props.value.loading
124
- }));
125
- const HintSlot = defineComponent({
126
- name: "HintSlot",
127
- props: {
128
- tag: {
129
- type: String,
130
- default: "small"
131
- }
132
- },
133
- setup() {
134
- return {
135
- isVisible,
136
- invalidLabel,
137
- validLabel,
138
- loadingLabel,
139
- hintLabel,
140
- hasInvalidLabelOrSlot,
141
- hasValidLabelOrSlot,
142
- hasLoadingLabelOrSlot,
143
- hasHintLabelOrSlot
144
- };
145
- },
146
- render() {
147
- if (this.isVisible) {
148
- let role;
149
- if (this.hasInvalidLabelOrSlot) {
150
- role = "alert";
151
- }
152
- if (this.hasValidLabelOrSlot) {
153
- role = "status";
154
- }
155
- if (this.hasLoadingLabelOrSlot) {
156
- return h(
157
- this.tag,
158
- {
159
- role
160
- },
161
- this.$slots.loading?.() ?? this.loadingLabel
162
- );
163
- }
164
- if (this.hasInvalidLabelOrSlot) {
165
- return h(
166
- this.tag,
167
- {
168
- role
169
- },
170
- this.$slots.invalid?.() ?? this.$slots.invalid ?? this.invalidLabel
171
- );
172
- }
173
- if (this.hasValidLabelOrSlot) {
174
- return h(
175
- this.tag,
176
- {
177
- role
178
- },
179
- this.$slots.valid?.() ?? this.validLabel
180
- );
181
- }
182
- return h(
183
- this.tag,
184
- {
185
- role
186
- },
187
- this.$slots.hint?.() ?? this.$slots.hint ?? this.hintLabel
188
- );
189
- }
190
- return null;
191
- }
192
- });
193
- return {
194
- hasInvalidLabelOrSlot,
195
- hasHintLabelOrSlot,
196
- hasValidLabelOrSlot,
197
- hasLoadingLabelOrSlot,
198
- hintSlotScope,
199
- HintSlot
200
- };
201
- }
202
- var StorageType = /* @__PURE__ */ ((StorageType2) => {
203
- StorageType2["local"] = "local";
204
- StorageType2["session"] = "session";
205
- return StorageType2;
206
- })(StorageType || {});
207
- var Strategy = /* @__PURE__ */ ((Strategy2) => {
208
- Strategy2["absolute"] = "absolute";
209
- Strategy2["fixed"] = "fixed";
210
- return Strategy2;
211
- })(Strategy || {});
212
- var Side = /* @__PURE__ */ ((Side2) => {
213
- Side2["left"] = "left";
214
- Side2["right"] = "right";
215
- Side2["top"] = "top";
216
- Side2["bottom"] = "bottom";
217
- return Side2;
218
- })(Side || {});
219
- var Placement = /* @__PURE__ */ ((Placement2) => {
220
- Placement2["topStart"] = "top-start";
221
- Placement2["topEnd"] = "top-end";
222
- Placement2["bottomStart"] = "bottom-start";
223
- Placement2["bottomEnd"] = "bottom-end";
224
- Placement2["leftStart"] = "left-start";
225
- Placement2["leftEnd"] = "left-end";
226
- Placement2["rightStart"] = "right-start";
227
- Placement2["rightEnd"] = "right-end";
228
- return Placement2;
229
- })(Placement || {});
230
- var Position = /* @__PURE__ */ ((Position2) => {
231
- Position2["before"] = "before";
232
- Position2["after"] = "after";
233
- return Position2;
234
- })(Position || {});
235
- var ButtonType = /* @__PURE__ */ ((ButtonType2) => {
236
- ButtonType2["button"] = "button";
237
- ButtonType2["submit"] = "submit";
238
- ButtonType2["reset"] = "reset";
239
- return ButtonType2;
240
- })(ButtonType || {});
241
- var ActionTag = /* @__PURE__ */ ((ActionTag2) => {
242
- ActionTag2["nuxtLink"] = "nuxt-link";
243
- ActionTag2["routerLink"] = "router-link";
244
- ActionTag2["a"] = "a";
245
- ActionTag2["button"] = "button";
246
- return ActionTag2;
247
- })(ActionTag || {});
248
- var ActionRoles = /* @__PURE__ */ ((ActionRoles2) => {
249
- ActionRoles2["button"] = "button";
250
- ActionRoles2["link"] = "link";
251
- ActionRoles2["menuitem"] = "menuitem";
252
- return ActionRoles2;
253
- })(ActionRoles || {});
254
- var DropdownRole = /* @__PURE__ */ ((DropdownRole2) => {
255
- DropdownRole2["listbox"] = "listbox";
256
- DropdownRole2["menu"] = "menu";
257
- return DropdownRole2;
258
- })(DropdownRole || {});
259
- var DropdownItemRole = /* @__PURE__ */ ((DropdownItemRole2) => {
260
- DropdownItemRole2["option"] = "option";
261
- DropdownItemRole2["presentation"] = "presentation";
262
- return DropdownItemRole2;
263
- })(DropdownItemRole || {});
264
- const INJECTION_KEY_VOLVER = Symbol.for("volver");
265
- const INJECTION_KEY_DROPDOWN_TRIGGER = Symbol.for(
266
- "dropdownTrigger"
267
- );
268
- const INJECTION_KEY_DROPDOWN_ITEM = Symbol.for(
269
- "dropdownItem"
270
- );
271
- const INJECTION_KEY_DROPDOWN_ACTION = Symbol.for(
272
- "dropdownAction"
273
- );
274
- const ACTION_ICONS = {
275
- showPassword: "eye-on",
276
- hidePassword: "eye-off",
277
- showDatePicker: "calendar",
278
- showTimePicker: "time",
279
- showColorPicker: "color",
280
- clear: "close",
281
- remove: "trash"
282
- };
283
- const VvIconPropsDefaults = {
284
- prefix: "normal"
285
- /* normal */
286
- };
287
- const ValidProps = {
288
- /**
289
- * Valid status
290
- */
291
- valid: { type: Boolean, default: false },
292
- /**
293
- * Valid label
294
- */
295
- validLabel: { type: [String, Array], default: void 0 }
296
- };
297
- const InvalidProps = {
298
- /**
299
- * Invalid status
300
- */
301
- invalid: {
302
- type: Boolean,
303
- default: false
304
- },
305
- /**
306
- * Invalid label
307
- */
308
- invalidLabel: { type: [String, Array], default: void 0 }
309
- };
310
- const LoadingProps = {
311
- /**
312
- * Loading status
313
- */
314
- loading: {
315
- type: Boolean,
316
- default: false
317
- },
318
- /**
319
- * Loading label
320
- */
321
- loadingLabel: {
322
- type: String,
323
- default: "Loading..."
324
- }
325
- };
326
- const DisabledProps = {
327
- /**
328
- * Whether the form control is disabled
329
- */
330
- disabled: {
331
- type: Boolean,
332
- default: false
333
- }
334
- };
335
- const RequiredProps = {
336
- /**
337
- * Whether the form control is required
338
- */
339
- required: {
340
- type: Boolean,
341
- default: false
342
- }
343
- };
344
- const SelectedProps = {
345
- /**
346
- * Whether the item is selected
347
- */
348
- selected: {
349
- type: Boolean,
350
- default: false
351
- }
352
- };
353
- const LabelProps = {
354
- /**
355
- * The item label
356
- */
357
- label: {
358
- type: [String, Number],
359
- default: void 0
360
- }
361
- };
362
- const ReadonlyProps = {
363
- /**
364
- * The value is not editable
365
- */
366
- readonly: {
367
- type: Boolean,
368
- default: false
369
- }
370
- };
371
- const ModifiersProps = {
372
- /**
373
- * Component BEM modifiers
374
- */
375
- modifiers: {
376
- type: [String, Array],
377
- default: void 0
378
- }
379
- };
380
- const HintProps = {
381
- hintLabel: { type: String, default: "" }
382
- };
383
- const CountProps = {
384
- /**
385
- * Show character limit
386
- */
387
- count: {
388
- type: [Boolean, String],
389
- default: false,
390
- validator: (value) => [true, false, "limit", "countdown"].includes(value)
391
- }
392
- };
393
- const DebounceProps = {
394
- /**
395
- * Milliseconds to wait before emitting the input event
396
- */
397
- debounce: {
398
- type: [Number, String],
399
- default: void 0
400
- }
401
- };
402
- const IconProps = {
403
- /**
404
- * VvIcon name or props
405
- * @see VvIcon
406
- */
407
- icon: {
408
- type: [String, Object],
409
- default: void 0
410
- },
411
- /**
412
- * VvIcon position
413
- */
414
- iconPosition: {
415
- type: String,
416
- default: Position.before,
417
- validation: (value) => Object.values(Position).includes(value)
418
- }
419
- };
420
- const TabindexProps = {
421
- /**
422
- * Global attribute tabindex
423
- * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/tabindex
424
- */
425
- tabindex: { type: [String, Number], default: 0 }
426
- };
427
- const FloatingLabelProps = {
428
- /**
429
- * If true the label will be floating
430
- */
431
- floating: {
432
- type: Boolean,
433
- default: false
434
- }
435
- };
436
- const UnselectableProps = {
437
- /**
438
- * If true the input will be unselectable
439
- */
440
- unselectable: { type: Boolean, default: true }
441
- };
442
- const IdProps = {
443
- /**
444
- * Global attribute id
445
- * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/id
446
- */
447
- id: [String, Number]
448
- };
449
- const DropdownProps = {
450
- /**
451
- * Dropdown placement
452
- */
453
- placement: {
454
- type: String,
455
- default: Side.bottom,
456
- validator: (value) => Object.values(Side).includes(value) || Object.values(Placement).includes(value)
457
- },
458
- /**
459
- * Dropdown strategy
460
- */
461
- strategy: {
462
- type: String,
463
- default: void 0,
464
- validator: (value) => Object.values(Strategy).includes(value)
465
- },
466
- /**
467
- * Dropdown show / hide transition name
468
- */
469
- transitionName: {
470
- type: String,
471
- default: void 0
472
- },
473
- /**
474
- * Offset of the dropdown from the trigger
475
- * @see https://floating-ui.com/docs/offset
476
- */
477
- offset: {
478
- type: [Number, String, Object],
479
- default: 0
480
- },
481
- /**
482
- * Move dropdown to the side if there is no space in the default position
483
- * @see https://floating-ui.com/docs/shift
484
- */
485
- shift: {
486
- type: [Boolean, Object],
487
- default: false
488
- },
489
- /**
490
- * Flip dropdown position if there is no space in the default position
491
- * @see https://floating-ui.com/docs/flip
492
- */
493
- flip: {
494
- type: [Boolean, Object],
495
- default: true
496
- },
497
- /**
498
- * Size of the dropdown
499
- * @see https://floating-ui.com/docs/size
500
- */
501
- size: {
502
- type: [Boolean, Object],
503
- default: () => ({ padding: 10 })
504
- },
505
- /**
506
- * Automatically change the position of the dropdown
507
- * @see https://floating-ui.com/docs/autoPlacement
508
- */
509
- autoPlacement: {
510
- type: [Boolean, Object],
511
- default: false
512
- },
513
- /**
514
- * Add arrow to the dropdown
515
- * @see https://floating-ui.com/docs/arrow
516
- */
517
- arrow: {
518
- type: Boolean,
519
- default: false
520
- },
521
- /**
522
- * Keep open dropdown on click outside
523
- */
524
- keepOpen: {
525
- type: Boolean,
526
- default: false
527
- },
528
- /**
529
- * Autofocus first item on dropdown open
530
- */
531
- autofocusFirst: {
532
- type: Boolean,
533
- default: true
534
- },
535
- /**
536
- * Set dropdown width to the same as the trigger
537
- */
538
- triggerWidth: {
539
- type: Boolean,
540
- default: false
541
- }
542
- };
543
- const IdNameProps = {
544
- ...IdProps,
545
- /**
546
- * Input / Textarea name
547
- * Name of the form control. Submitted with the form as part of a name/value pair
548
- * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#name
549
- */
550
- name: { type: String, required: true }
551
- };
552
- const AutofocusProps = {
553
- /**
554
- * Global attribute autofocus
555
- * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/autofocus
556
- */
557
- autofocus: {
558
- type: Boolean,
559
- default: false
560
- }
561
- };
562
- const AutocompleteProps = {
563
- /**
564
- * Global attribute autocomplete
565
- * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/autocomplete
566
- */
567
- autocomplete: { type: String, default: "off" }
568
- };
569
- const InputTextareaProps = {
570
- ...IdNameProps,
571
- ...AutofocusProps,
572
- ...AutocompleteProps,
573
- ...TabindexProps,
574
- ...DisabledProps,
575
- ...ReadonlyProps,
576
- ...ValidProps,
577
- ...InvalidProps,
578
- ...HintProps,
579
- ...LoadingProps,
580
- ...ModifiersProps,
581
- ...CountProps,
582
- ...DebounceProps,
583
- ...IconProps,
584
- ...FloatingLabelProps,
585
- ...LabelProps,
586
- /**
587
- * Input / Textarea minlength
588
- * Minimum length (number of characters) of value
589
- * Available for input types: text, search, url, tel, email, password
590
- * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#minlength
591
- */
592
- minlength: { type: [String, Number], default: void 0 },
593
- /**
594
- * Input / Textarea maxlength
595
- * Maximum length (number of characters) of value
596
- * Available for input types: text, search, url, tel, email, password
597
- * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#maxlength
598
- */
599
- maxlength: { type: [String, Number], default: void 0 },
600
- /**
601
- * Input / Textarea placeholder
602
- * Text that appears in the form control when it has no value set
603
- * Available for input types: text, search, url, tel, email, password, number
604
- * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#placeholder
605
- */
606
- placeholder: {
607
- type: String,
608
- default: void 0
609
- },
610
- /**
611
- * Input / Textarea required
612
- * A value is required or must be check for the form to be submittable
613
- * Available for all input types except color
614
- * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#required
615
- */
616
- ...RequiredProps
617
- };
618
- ({
619
- /**
620
- * Button type
621
- */
622
- type: {
623
- default: ButtonType.button
624
- },
625
- /**
626
- * Default tag for the action
627
- */
628
- defaultTag: {
629
- default: ActionTag.button
630
- }
631
- });
632
- const StorageProps = {
633
- storageType: {
634
- type: String,
635
- default: StorageType.local,
636
- validator: (value) => Object.values(StorageType).includes(value)
637
- },
638
- storageKey: String
639
- };
640
- const VvDropdownProps = {
641
- ...IdProps,
642
- ...DropdownProps,
643
- ...ModifiersProps,
644
- /**
645
- * Show / hide dropdown programmatically
646
- */
647
- modelValue: {
648
- type: Boolean,
649
- default: void 0
650
- },
651
- /**
652
- * Dropdown trigger element
653
- */
654
- reference: {
655
- type: Object,
656
- default: null
657
- },
658
- /**
659
- * Dropdown role
660
- */
661
- role: {
662
- type: String,
663
- default: DropdownRole.menu,
664
- validator: (value) => Object.values(DropdownRole).includes(value)
665
- }
666
- };
667
- const VvDropdownItemProps = {
668
- focusOnHover: {
669
- type: Boolean,
670
- default: false
671
- }
672
- };
673
- const VvDropdownOptionProps = {
674
- ...DisabledProps,
675
- ...SelectedProps,
676
- ...UnselectableProps,
677
- ...ModifiersProps,
678
- deselectHintLabel: {
679
- type: String
680
- },
681
- selectHintLabel: {
682
- type: String
683
- },
684
- selectedHintLabel: {
685
- type: String
686
- },
687
- focusOnHover: {
688
- type: Boolean,
689
- default: false
690
- }
691
- };
692
- function useUniqueId(id) {
693
- return computed(() => String(id?.value || useId()));
694
- }
695
- function useDropdownProvideTrigger({
696
- reference,
697
- id,
698
- expanded,
699
- aria
700
- }) {
701
- const bus = mitt();
702
- const component = defineComponent({
703
- name: "VvDropdownTriggerProvider",
704
- setup() {
705
- provide(INJECTION_KEY_DROPDOWN_TRIGGER, {
706
- reference,
707
- id,
708
- expanded,
709
- aria,
710
- bus
711
- });
712
- },
713
- render() {
714
- return h(Fragment, {}, this.$slots.default?.());
715
- }
716
- });
717
- return {
718
- bus,
719
- component
720
- };
721
- }
722
- function useDropdownProvideItem({
723
- role,
724
- ...others
725
- }) {
726
- const itemRole = computed(
727
- () => role.value === DropdownRole.listbox ? DropdownItemRole.option : DropdownItemRole.presentation
728
- );
729
- provide(INJECTION_KEY_DROPDOWN_ITEM, {
730
- role: itemRole,
731
- ...others
732
- });
733
- return { itemRole };
734
- }
735
- function useDropdownProvideAction({
736
- expanded
737
- }) {
738
- provide(INJECTION_KEY_DROPDOWN_ACTION, {
739
- role: ref(ActionRoles.menuitem),
740
- expanded
741
- });
742
- }
743
- function useModifiers(prefix, modifiers, others) {
744
- return computed(() => {
745
- const toReturn = {
746
- [prefix]: true
747
- };
748
- const modifiersArray = typeof modifiers?.value === "string" ? modifiers.value.split(" ") : modifiers?.value;
749
- if (modifiersArray) {
750
- if (Array.isArray(modifiersArray)) {
751
- modifiersArray.forEach((modifier) => {
752
- if (modifier) {
753
- toReturn[`${prefix}--${modifier}`] = true;
754
- }
755
- });
756
- }
757
- }
758
- if (others) {
759
- Object.keys(others.value).forEach((key) => {
760
- toReturn[`${prefix}--${key}`] = unref(others.value[key]);
761
- });
762
- }
763
- return toReturn;
764
- });
765
- }
766
- const _hoisted_1$2 = ["id", "tabindex", "role", "aria-labelledby"];
767
- const __default__$4 = {
768
- name: "VvDropdown",
769
- inheritAttrs: false
770
- };
771
- const _sfc_main$4 = /* @__PURE__ */ defineComponent({
772
- ...__default__$4,
773
- props: VvDropdownProps,
774
- emits: [
775
- "update:modelValue",
776
- "beforeEnter",
777
- "afterLeave",
778
- "beforeExpand",
779
- "beforeCollapse",
780
- "afterExpand",
781
- "afterCollapse",
782
- "before-enter",
783
- "after-leave",
784
- "enter",
785
- "afterEnter",
786
- "enterCancelled",
787
- "beforeLeave",
788
- "leave",
789
- "leaveCancelled"
790
- ],
791
- setup(__props, { expose: __expose, emit: __emit }) {
792
- const props = __props;
793
- const emit = __emit;
794
- const { id } = toRefs(props);
795
- const hasId = useUniqueId(id);
796
- const attrs = useAttrs();
797
- const maxWidth = ref("auto");
798
- const maxHeight = ref("auto");
799
- const localReferenceEl = ref();
800
- const floatingEl = ref();
801
- const arrowEl = ref();
802
- const listEl = ref();
803
- const referenceEl = computed({
804
- get: () => props.reference ?? localReferenceEl.value,
805
- set: (newValue) => {
806
- localReferenceEl.value = newValue;
807
- }
808
- });
809
- const hasCustomPosition = ref(false);
810
- onMounted(() => {
811
- useMutationObserver(
812
- floatingEl.value,
813
- () => {
814
- hasCustomPosition.value = window.getComputedStyle(floatingEl.value).getPropertyValue("--dropdown-custom-position")?.trim() === "true";
815
- },
816
- {
817
- attributeFilter: ["style"],
818
- window
819
- }
820
- );
821
- });
822
- const middleware = computed(() => {
823
- const toReturn = [];
824
- if (props.autoPlacement) {
825
- if (typeof props.autoPlacement === "boolean") {
826
- toReturn.push(autoPlacement());
827
- } else {
828
- toReturn.push(
829
- autoPlacement(props.autoPlacement)
830
- );
831
- }
832
- } else if (props.flip) {
833
- if (typeof props.flip === "boolean") {
834
- toReturn.push(flip({ fallbackStrategy: "initialPlacement" }));
835
- } else {
836
- toReturn.push(flip(props.flip));
837
- }
838
- }
839
- if (props.shift) {
840
- if (typeof props.shift === "boolean") {
841
- toReturn.push(shift());
842
- } else {
843
- toReturn.push(shift(props.shift));
844
- }
845
- }
846
- if (props.size) {
847
- const apply = ({
848
- availableWidth,
849
- availableHeight
850
- }) => {
851
- maxWidth.value = `${availableWidth}px`;
852
- maxHeight.value = `${availableHeight}px`;
853
- };
854
- if (typeof props.size === "boolean") {
855
- toReturn.push(
856
- size({
857
- apply
858
- })
859
- );
860
- } else {
861
- toReturn.push(
862
- size({
863
- ...props.size,
864
- apply
865
- })
866
- );
867
- }
868
- }
869
- if (props.offset) {
870
- toReturn.push(offset(Number(props.offset)));
871
- if (["string", "number"].includes(typeof props.offset)) {
872
- toReturn.push(offset(Number(props.offset)));
873
- } else {
874
- toReturn.push(offset(props.offset));
875
- }
876
- }
877
- if (props.arrow) {
878
- toReturn.push(
879
- arrow({
880
- element: arrowEl
881
- })
882
- );
883
- }
884
- return toReturn;
885
- });
886
- const { x, y, middlewareData, placement, strategy } = useFloating(
887
- referenceEl,
888
- floatingEl,
889
- {
890
- whileElementsMounted: (...args) => {
891
- return autoUpdate(...args, {
892
- animationFrame: props.strategy === Strategy.fixed
893
- });
894
- },
895
- placement: computed(() => props.placement),
896
- strategy: computed(() => props.strategy),
897
- middleware
898
- }
899
- );
900
- const dropdownPlacement = computed(() => {
901
- if (hasCustomPosition.value) {
902
- return void 0;
903
- }
904
- const width = props.triggerWidth && referenceEl.value ? `${referenceEl.value?.offsetWidth}px` : void 0;
905
- return {
906
- position: strategy.value,
907
- top: `${y.value ?? 0}px`,
908
- left: `${x.value ?? 0}px`,
909
- maxWidth: width ? void 0 : maxWidth.value,
910
- maxHeight: maxHeight.value,
911
- width
912
- };
913
- });
914
- const side = computed(
915
- () => placement.value.split("-")[0]
916
- );
917
- const arrowPlacement = computed(() => {
918
- if (hasCustomPosition.value) {
919
- return void 0;
920
- }
921
- const staticSide = {
922
- [Side.top]: Side.bottom,
923
- [Side.right]: Side.left,
924
- [Side.bottom]: Side.top,
925
- [Side.left]: Side.right
926
- }[side.value];
927
- return {
928
- left: middlewareData.value.arrow?.x !== void 0 ? `${middlewareData.value.arrow?.x}px` : void 0,
929
- top: middlewareData.value.arrow?.y !== void 0 ? `${middlewareData.value.arrow?.y}px` : void 0,
930
- [staticSide]: `${-(arrowEl.value?.offsetWidth ?? 0) / 2}px`
931
- };
932
- });
933
- const modelValue = useVModel(props, "modelValue", emit);
934
- const localModelValue = ref(false);
935
- const expanded = computed({
936
- get: () => modelValue.value ?? localModelValue.value,
937
- set: (newValue) => {
938
- if (modelValue.value === void 0) {
939
- localModelValue.value = newValue;
940
- return;
941
- }
942
- modelValue.value = newValue;
943
- }
944
- });
945
- function show() {
946
- expanded.value = true;
947
- }
948
- function hide() {
949
- expanded.value = false;
950
- }
951
- function toggle() {
952
- expanded.value = !expanded.value;
953
- }
954
- function init(el) {
955
- referenceEl.value = el;
956
- }
957
- onClickOutside(
958
- floatingEl,
959
- () => {
960
- if (!props.keepOpen && expanded.value) {
961
- expanded.value = false;
962
- }
963
- },
964
- { ignore: [referenceEl] }
965
- );
966
- const hasAriaLabelledby = computed(() => {
967
- return referenceEl.value?.getAttribute?.("id") ?? void 0;
968
- });
969
- const referenceAria = computed(() => ({
970
- "aria-controls": hasId.value,
971
- "aria-haspopup": true,
972
- "aria-expanded": expanded.value
973
- }));
974
- const { component: VvDropdownTriggerProvider, bus } = useDropdownProvideTrigger({
975
- reference: referenceEl,
976
- id: hasId,
977
- expanded,
978
- aria: referenceAria
979
- });
980
- bus.on("click", toggle);
981
- const { role, modifiers } = toRefs(props);
982
- const bemCssClasses = useModifiers(
983
- "vv-dropdown",
984
- modifiers,
985
- computed(() => ({
986
- arrow: props.arrow
987
- }))
988
- );
989
- const { focused } = useFocusWithin(floatingEl);
990
- function getKeyboardFocusableElements(element) {
991
- if (!element) {
992
- return [];
993
- }
994
- return [
995
- ...element.querySelectorAll(
996
- 'a[href], button, input, textarea, select, details, [tabindex]:not([tabindex="-1"])'
997
- )
998
- ].filter(
999
- (el) => !el.hasAttribute("disabled") && !el.getAttribute("aria-hidden")
1000
- );
1001
- }
1002
- function focusFirst() {
1003
- nextTick(() => {
1004
- const focusableElements = getKeyboardFocusableElements(
1005
- floatingEl.value
1006
- );
1007
- if (focusableElements.length > 0) {
1008
- focusableElements[0].focus({
1009
- preventScroll: true
1010
- });
1011
- }
1012
- });
1013
- }
1014
- function focusFirstListElement() {
1015
- nextTick(() => {
1016
- const focusableElements = getKeyboardFocusableElements(
1017
- listEl.value
1018
- );
1019
- if (focusableElements.length > 0) {
1020
- focusableElements[0].focus({
1021
- preventScroll: true
1022
- });
1023
- }
1024
- });
1025
- }
1026
- function focusNext() {
1027
- nextTick(() => {
1028
- if (focused.value) {
1029
- const focusableElements = getKeyboardFocusableElements(
1030
- floatingEl.value
1031
- );
1032
- if (focusableElements.length === 0 || !document.activeElement) {
1033
- return;
1034
- }
1035
- const activeElementIndex = focusableElements.indexOf(
1036
- document.activeElement
1037
- );
1038
- if (activeElementIndex < focusableElements.length - 1) {
1039
- focusableElements[activeElementIndex + 1].focus({
1040
- preventScroll: true
1041
- });
1042
- } else {
1043
- focusableElements[0].focus({
1044
- preventScroll: true
1045
- });
1046
- }
1047
- }
1048
- });
1049
- }
1050
- function focusPrev() {
1051
- nextTick(() => {
1052
- if (focused.value) {
1053
- const focusableElements = getKeyboardFocusableElements(
1054
- floatingEl.value
1055
- );
1056
- if (focusableElements.length === 0 || !document.activeElement) {
1057
- return;
1058
- }
1059
- const activeElementIndex = focusableElements.indexOf(
1060
- document.activeElement
1061
- );
1062
- if (activeElementIndex > 0) {
1063
- focusableElements[activeElementIndex - 1].focus({
1064
- preventScroll: true
1065
- });
1066
- } else {
1067
- focusableElements[focusableElements.length - 1].focus({
1068
- preventScroll: true
1069
- });
1070
- }
1071
- }
1072
- });
1073
- }
1074
- watch(expanded, (newValue) => {
1075
- if (newValue && props.autofocusFirst) {
1076
- focusFirst();
1077
- }
1078
- });
1079
- __expose({
1080
- toggle,
1081
- show,
1082
- hide,
1083
- init,
1084
- focusFirst,
1085
- focusFirstListElement,
1086
- focusNext,
1087
- focusPrev,
1088
- customPosition: hasCustomPosition
1089
- });
1090
- const hovered = useElementHover(floatingEl);
1091
- const { itemRole } = useDropdownProvideItem({
1092
- role,
1093
- expanded,
1094
- focused,
1095
- hovered
1096
- });
1097
- onKeyStroke("Escape", (e) => {
1098
- if (expanded.value) {
1099
- e.preventDefault();
1100
- hide();
1101
- }
1102
- });
1103
- onKeyStroke("ArrowDown", (e) => {
1104
- if (expanded.value && focused.value) {
1105
- e.preventDefault();
1106
- focusNext();
1107
- }
1108
- });
1109
- onKeyStroke("ArrowUp", (e) => {
1110
- if (expanded.value && focused.value) {
1111
- e.preventDefault();
1112
- focusPrev();
1113
- }
1114
- });
1115
- onKeyStroke([" ", "Enter"], (e) => {
1116
- const htmlEl = e.target;
1117
- if (expanded.value && focused.value && htmlEl) {
1118
- htmlEl?.click();
1119
- }
1120
- });
1121
- const dropdownTransitionHandlers = {
1122
- "before-enter": () => {
1123
- emit(expanded.value ? "beforeExpand" : "beforeCollapse");
1124
- emit("beforeEnter");
1125
- },
1126
- "after-leave": () => {
1127
- emit(expanded.value ? "afterExpand" : "afterCollapse");
1128
- emit("afterLeave");
1129
- },
1130
- "enter": () => {
1131
- emit("enter");
1132
- },
1133
- "after-enter": () => {
1134
- emit("afterEnter");
1135
- },
1136
- "enter-cancelled": () => {
1137
- emit("enterCancelled");
1138
- },
1139
- "before-leave": () => {
1140
- emit("beforeLeave");
1141
- },
1142
- "leave": () => {
1143
- emit("leave");
1144
- },
1145
- "leave-cancelled": () => {
1146
- emit("leaveCancelled");
1147
- }
1148
- };
1149
- return (_ctx, _cache) => {
1150
- return openBlock(), createElementBlock(
1151
- Fragment,
1152
- null,
1153
- [
1154
- createVNode(unref(VvDropdownTriggerProvider), null, {
1155
- default: withCtx(() => [
1156
- renderSlot(_ctx.$slots, "default", normalizeProps(guardReactiveProps({ init, show, hide, toggle, expanded: unref(expanded), aria: unref(referenceAria) })))
1157
- ]),
1158
- _: 3
1159
- /* FORWARDED */
1160
- }),
1161
- createVNode(Transition, mergeProps({ name: _ctx.transitionName }, toHandlers(dropdownTransitionHandlers), { persisted: "" }), {
1162
- default: withCtx(() => [
1163
- withDirectives(createElementVNode(
1164
- "div",
1165
- {
1166
- ref_key: "floatingEl",
1167
- ref: floatingEl,
1168
- style: normalizeStyle(unref(dropdownPlacement)),
1169
- class: normalizeClass(unref(bemCssClasses))
1170
- },
1171
- [
1172
- props.arrow ? (openBlock(), createElementBlock(
1173
- "div",
1174
- {
1175
- key: 0,
1176
- ref_key: "arrowEl",
1177
- ref: arrowEl,
1178
- style: normalizeStyle(unref(arrowPlacement)),
1179
- class: "vv-dropdown__arrow"
1180
- },
1181
- null,
1182
- 4
1183
- /* STYLE */
1184
- )) : createCommentVNode("v-if", true),
1185
- renderSlot(_ctx.$slots, "before", normalizeProps(guardReactiveProps({ expanded: unref(expanded) }))),
1186
- createElementVNode("div", mergeProps(unref(attrs), {
1187
- id: unref(hasId),
1188
- ref_key: "listEl",
1189
- ref: listEl,
1190
- tabindex: !unref(expanded) ? -1 : void 0,
1191
- role: unref(role),
1192
- "aria-labelledby": unref(hasAriaLabelledby),
1193
- class: "vv-dropdown__list"
1194
- }), [
1195
- renderSlot(_ctx.$slots, "items", normalizeProps(guardReactiveProps({
1196
- role: unref(itemRole)
1197
- })))
1198
- ], 16, _hoisted_1$2),
1199
- renderSlot(_ctx.$slots, "after", normalizeProps(guardReactiveProps({ expanded: unref(expanded) })))
1200
- ],
1201
- 6
1202
- /* CLASS, STYLE */
1203
- ), [
1204
- [vShow, unref(expanded)]
1205
- ])
1206
- ]),
1207
- _: 3
1208
- /* FORWARDED */
1209
- }, 16, ["name"])
1210
- ],
1211
- 64
1212
- /* STABLE_FRAGMENT */
1213
- );
1214
- };
1215
- }
1216
- });
1217
- function useInjectedDropdownItem() {
1218
- return inject(INJECTION_KEY_DROPDOWN_ITEM, {});
1219
- }
1220
- const __default__$3 = {
1221
- name: "VvDropdownItem"
1222
- };
1223
- const _sfc_main$3 = /* @__PURE__ */ defineComponent({
1224
- ...__default__$3,
1225
- props: VvDropdownItemProps,
1226
- setup(__props) {
1227
- const props = __props;
1228
- const { role, expanded } = useInjectedDropdownItem();
1229
- const element = ref(null);
1230
- useDropdownProvideAction({ expanded });
1231
- const hovered = useElementHover(element);
1232
- const { focused } = useFocus(element);
1233
- const { focused: focusedWithin } = useFocusWithin(element);
1234
- watch(hovered, (newValue) => {
1235
- if (newValue && props.focusOnHover) {
1236
- focused.value = true;
1237
- }
1238
- });
1239
- return (_ctx, _cache) => {
1240
- return openBlock(), createElementBlock(
1241
- "div",
1242
- mergeProps({ role: unref(role) }, {
1243
- ref_key: "element",
1244
- ref: element,
1245
- class: ["vv-dropdown__item", { "focus-visible": unref(focused) || unref(focusedWithin) }]
1246
- }),
1247
- [
1248
- renderSlot(_ctx.$slots, "default")
1249
- ],
1250
- 16
1251
- /* FULL_PROPS */
1252
- );
1253
- };
1254
- }
1255
- });
1256
- const _hoisted_1$1 = ["title"];
1257
- const __default__$2 = {
1258
- name: "VvDropdownOption"
1259
- };
1260
- const _sfc_main$2 = /* @__PURE__ */ defineComponent({
1261
- ...__default__$2,
1262
- props: VvDropdownOptionProps,
1263
- setup(__props) {
1264
- const props = __props;
1265
- const { modifiers } = toRefs(props);
1266
- const bemCssClasses = useModifiers(
1267
- "vv-dropdown-option",
1268
- modifiers,
1269
- computed(() => ({
1270
- disabled: props.disabled,
1271
- selected: props.selected,
1272
- unselectable: props.unselectable && props.selected
1273
- }))
1274
- );
1275
- const hintLabel = computed(() => {
1276
- if (props.selected) {
1277
- return props.unselectable ? props.deselectHintLabel : props.selectedHintLabel;
1278
- }
1279
- if (!props.disabled) {
1280
- return props.selectHintLabel;
1281
- }
1282
- return "";
1283
- });
1284
- return (_ctx, _cache) => {
1285
- return openBlock(), createBlock(_sfc_main$3, {
1286
- class: normalizeClass(unref(bemCssClasses)),
1287
- tabindex: _ctx.disabled ? -1 : 0,
1288
- "aria-selected": _ctx.selected,
1289
- "aria-disabled": _ctx.disabled,
1290
- "focus-on-hover": _ctx.focusOnHover
1291
- }, {
1292
- default: withCtx(() => [
1293
- renderSlot(_ctx.$slots, "default"),
1294
- createElementVNode("span", {
1295
- class: "vv-dropdown-option__hint",
1296
- title: unref(hintLabel)
1297
- }, [
1298
- renderSlot(_ctx.$slots, "hint", normalizeProps(guardReactiveProps({ disabled: _ctx.disabled, selected: _ctx.selected, unselectable: _ctx.unselectable })), () => [
1299
- createTextVNode(
1300
- toDisplayString(unref(hintLabel)),
1301
- 1
1302
- /* TEXT */
1303
- )
1304
- ])
1305
- ], 8, _hoisted_1$1)
1306
- ]),
1307
- _: 3
1308
- /* FORWARDED */
1309
- }, 8, ["class", "tabindex", "aria-selected", "aria-disabled", "focus-on-hover"]);
1310
- };
1311
- }
1312
- });
1313
- function useVolver() {
1314
- return inject(INJECTION_KEY_VOLVER, void 0);
1315
- }
1316
- const __default__$1 = {
1317
- name: "VvIcon"
1318
- };
1319
- const _sfc_main$1 = /* @__PURE__ */ defineComponent({
1320
- ...__default__$1,
1321
- props: /* @__PURE__ */ mergeDefaults({
1322
- name: {},
1323
- color: {},
1324
- width: {},
1325
- height: {},
1326
- provider: {},
1327
- prefix: {},
1328
- src: {},
1329
- horizontalFlip: { type: Boolean },
1330
- verticalFlip: { type: Boolean },
1331
- flip: {},
1332
- mode: {},
1333
- inline: { type: Boolean },
1334
- rotate: {},
1335
- onLoad: { type: Function },
1336
- svg: {},
1337
- modifiers: {}
1338
- }, VvIconPropsDefaults),
1339
- setup(__props) {
1340
- const props = __props;
1341
- const hasRotate = computed(() => {
1342
- if (typeof props.rotate === "string") {
1343
- return Number.parseFloat(props.rotate);
1344
- }
1345
- return props.rotate;
1346
- });
1347
- const show = ref(true);
1348
- const volver = useVolver();
1349
- const { modifiers } = toRefs(props);
1350
- const bemCssClasses = useModifiers("vv-icon", modifiers);
1351
- const provider = computed(() => {
1352
- return props.provider || volver?.iconsProvider;
1353
- });
1354
- const icon = computed(() => {
1355
- const name = props.name ?? "";
1356
- const iconName = `@${provider.value}:${props.prefix}:${name}`;
1357
- if (iconLoaded(iconName)) {
1358
- return iconName;
1359
- }
1360
- const iconsCollection = volver?.iconsCollections.find(
1361
- (iconsCollection2) => {
1362
- const icon2 = `@${provider.value}:${iconsCollection2.prefix}:${name}`;
1363
- return iconLoaded(icon2);
1364
- }
1365
- );
1366
- if (iconsCollection) {
1367
- return `@${provider.value}:${iconsCollection.prefix}:${name}`;
1368
- }
1369
- return name;
1370
- });
1371
- function getSvgContent(svg) {
1372
- let dom;
1373
- if (typeof window === "undefined") {
1374
- const { JSDOM } = require("jsdom");
1375
- dom = new JSDOM().window;
1376
- }
1377
- const domParser = dom ? new dom.DOMParser() : new window.DOMParser();
1378
- const svgDomString = domParser.parseFromString(svg, "text/html");
1379
- const svgEl = svgDomString.querySelector("svg");
1380
- return svgEl;
1381
- }
1382
- function addIconFromSvg(svg) {
1383
- const svgContentEl = getSvgContent(svg);
1384
- const svgContent = svgContentEl?.innerHTML.trim() || "";
1385
- if (svgContentEl && svgContent) {
1386
- addIcon(`@${provider.value}:${props.prefix}:${props.name}`, {
1387
- body: svgContent,
1388
- // Set height and width from svg content
1389
- height: svgContentEl.viewBox.baseVal.height,
1390
- width: svgContentEl.viewBox.baseVal.width
1391
- });
1392
- }
1393
- }
1394
- if (volver) {
1395
- if (props.src && !iconLoaded(`@${provider.value}:${props.prefix}:${props.name}`)) {
1396
- show.value = false;
1397
- volver.fetchIcon(props.src).then((svg) => {
1398
- if (svg) {
1399
- addIconFromSvg(svg);
1400
- show.value = true;
1401
- }
1402
- }).catch((e) => {
1403
- throw new Error(`Error during fetch icon: ${e?.message}`);
1404
- });
1405
- }
1406
- }
1407
- if (props.svg) {
1408
- addIconFromSvg(props.svg);
1409
- }
1410
- return (_ctx, _cache) => {
1411
- return unref(show) ? (openBlock(), createBlock(unref(Icon), mergeProps({
1412
- key: 0,
1413
- class: unref(bemCssClasses)
1414
- }, {
1415
- inline: _ctx.inline,
1416
- width: _ctx.width,
1417
- height: _ctx.height,
1418
- horizontalFlip: _ctx.horizontalFlip,
1419
- verticalFlip: _ctx.verticalFlip,
1420
- flip: _ctx.flip,
1421
- rotate: unref(hasRotate),
1422
- color: _ctx.color,
1423
- icon: unref(icon)
1424
- }, { onLoad: _ctx.onLoad }), null, 16, ["class", "onLoad"])) : createCommentVNode("v-if", true);
1425
- };
1426
- }
1427
- });
1428
- const INPUT_TYPES = {
1429
- TEXT: "text",
1430
- PASSWORD: "password",
1431
- NUMBER: "number",
1432
- EMAIL: "email",
1433
- TEL: "tel",
1434
- URL: "url",
1435
- COLOR: "color",
1436
- SEARCH: "search",
1437
- DATE: "date",
1438
- TIME: "time",
1439
- DATETIME_LOCAL: "datetime-local",
1440
- MONTH: "month",
1441
- WEEK: "week"
1442
- };
1443
- const VvInputTextEvents = [
1444
- "update:modelValue",
1445
- "update:masked",
1446
- "accept",
1447
- "accept:typed",
1448
- "accept:masked",
1449
- "accept:unmasked",
1450
- "complete",
1451
- "complete:typed",
1452
- "complete:masked",
1453
- "complete:unmasked",
1454
- "suggestion:selected",
1455
- "suggestion:removed",
1456
- "focus",
1457
- "blur",
1458
- "keyup",
1459
- "keydown",
1460
- "keypress",
1461
- "clear"
1462
- ];
1463
- const VvInputTextProps = {
1464
- ...InputTextareaProps,
1465
- ...StorageProps,
1466
- /**
1467
- * Input value
1468
- * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#value
1469
- */
1470
- modelValue: [String, Number, Date],
1471
- /**
1472
- * Type of form control
1473
- * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#type
1474
- */
1475
- type: {
1476
- type: String,
1477
- default: INPUT_TYPES.TEXT,
1478
- validator: (value) => Object.values(INPUT_TYPES).includes(value)
1479
- },
1480
- /**
1481
- * Minimum value
1482
- * Available for input types: date, month, week, time, datetime-local, number, range.
1483
- * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#min
1484
- */
1485
- min: [Number, Date, String],
1486
- /**
1487
- * Maximum value
1488
- * Available for input types: date, month, week, time, datetime-local, number, range.
1489
- * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#max
1490
- */
1491
- max: [Number, Date, String],
1492
- /**
1493
- * Incremental values that are valid
1494
- * Available for input types: date, month, week, time, datetime-local and number
1495
- * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#step
1496
- */
1497
- step: { type: [String, Number], default: 1 },
1498
- /**
1499
- * Pattern the value must match to be valid
1500
- * Available for input types: text, search, url, tel, email and password
1501
- * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#pattern
1502
- */
1503
- pattern: String,
1504
- /**
1505
- * Whether to allow multiple values
1506
- * Available for input type email
1507
- * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#multiple
1508
- */
1509
- multiple: Boolean,
1510
- /**
1511
- * VvIcon name for show password button
1512
- * @see VvIcon
1513
- */
1514
- iconShowPassword: {
1515
- type: [String, Object],
1516
- default: ACTION_ICONS.showPassword
1517
- },
1518
- /**
1519
- * VvIcon name for hide password button
1520
- * @see VvIcon
1521
- */
1522
- iconHidePassword: {
1523
- type: [String, Object],
1524
- default: ACTION_ICONS.hidePassword
1525
- },
1526
- /**
1527
- * VvIcon name for clear button
1528
- * @see VvIcon
1529
- */
1530
- iconClear: {
1531
- type: [String, Object],
1532
- default: ACTION_ICONS.clear
1533
- },
1534
- /**
1535
- * VvIcon name for remove suggestion button
1536
- * @see VvIcon
1537
- */
1538
- iconRemoveSuggestion: {
1539
- type: [String, Object],
1540
- default: ACTION_ICONS.remove
1541
- },
1542
- /**
1543
- * Label for step up button
1544
- */
1545
- labelStepUp: {
1546
- type: String,
1547
- default: "Increase value"
1548
- },
1549
- /**
1550
- * Label for step down button
1551
- */
1552
- labelStepDown: {
1553
- type: String,
1554
- default: "Decrease value"
1555
- },
1556
- /**
1557
- * Label for show password button
1558
- */
1559
- labelShowPassword: {
1560
- type: String,
1561
- default: "Show password"
1562
- },
1563
- /**
1564
- * Label for hide password button
1565
- */
1566
- labelHidePassword: {
1567
- type: String,
1568
- default: "Hide password"
1569
- },
1570
- /**
1571
- * Label for clear button
1572
- */
1573
- labelClear: {
1574
- type: String,
1575
- default: "Clear"
1576
- },
1577
- /**
1578
- * Label for remove suggestion button
1579
- */
1580
- labelRemoveSuggestion: {
1581
- type: String,
1582
- default: "Remove suggestion"
1583
- },
1584
- /**
1585
- * iMask options
1586
- * @see https://imask.js.org/guide.html
1587
- */
1588
- iMask: {
1589
- type: Object,
1590
- default: void 0
1591
- },
1592
- /**
1593
- * Masked value
1594
- */
1595
- masked: {
1596
- type: String,
1597
- default: void 0
1598
- },
1599
- /**
1600
- * Adjust input width to content
1601
- */
1602
- autoWidth: {
1603
- type: Boolean,
1604
- default: false
1605
- },
1606
- /**
1607
- * Hide type number, password and search actions
1608
- */
1609
- hideActions: {
1610
- type: Boolean,
1611
- default: false
1612
- },
1613
- /**
1614
- * Add unit label to input
1615
- */
1616
- unit: {
1617
- type: String
1618
- },
1619
- /**
1620
- * Select input text on focus
1621
- */
1622
- selectOnFocus: {
1623
- type: Boolean,
1624
- default: false
1625
- },
1626
- /**
1627
- * Maximum number of suggestions
1628
- */
1629
- maxSuggestions: {
1630
- type: Number,
1631
- default: 5
1632
- },
1633
- /**
1634
- * The input mode to use for the input
1635
- * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/inputmode
1636
- */
1637
- inputMode: {
1638
- type: String,
1639
- default: "text"
1640
- }
1641
- };
1642
- function useComponentIcon(icon, iconPosition) {
1643
- const hasIcon = computed(() => {
1644
- if (typeof icon?.value === "string") {
1645
- return { name: icon?.value };
1646
- }
1647
- return icon?.value;
1648
- });
1649
- const hasIconBefore = computed(
1650
- () => iconPosition?.value === Position.before ? hasIcon.value : void 0
1651
- );
1652
- const hasIconAfter = computed(
1653
- () => iconPosition?.value === Position.after ? hasIcon.value : void 0
1654
- );
1655
- const hasIconLeft = computed(
1656
- () => iconPosition?.value === Side.left ? hasIcon.value : void 0
1657
- );
1658
- const hasIconRight = computed(
1659
- () => iconPosition?.value === Side.right ? hasIcon.value : void 0
1660
- );
1661
- const hasIconTop = computed(
1662
- () => iconPosition?.value === Side.top ? hasIcon.value : void 0
1663
- );
1664
- const hasIconBottom = computed(
1665
- () => iconPosition?.value === Side.bottom ? hasIcon.value : void 0
1666
- );
1667
- return {
1668
- hasIcon,
1669
- hasIconLeft,
1670
- hasIconRight,
1671
- hasIconTop,
1672
- hasIconBottom,
1673
- hasIconBefore,
1674
- hasIconAfter
1675
- };
1676
- }
1677
- const VvInputClearAction = defineComponent({
1678
- components: {
1679
- VvIcon: _sfc_main$1
1680
- },
1681
- props: {
1682
- inputType: {
1683
- type: String,
1684
- default: "input-text"
1685
- },
1686
- disabled: {
1687
- type: Boolean,
1688
- default: false
1689
- },
1690
- label: {
1691
- type: String,
1692
- default: "Clear"
1693
- },
1694
- icon: {
1695
- type: [String, Object],
1696
- default: "close"
1697
- }
1698
- },
1699
- emits: ["clear"],
1700
- setup(props, { emit }) {
1701
- const { hasIcon } = useComponentIcon(computed(() => props.icon));
1702
- function onClick(e) {
1703
- e?.stopPropagation();
1704
- if (!props.disabled) {
1705
- emit("clear");
1706
- }
1707
- }
1708
- return {
1709
- hasIcon,
1710
- onClick
1711
- };
1712
- },
1713
- render() {
1714
- const icon = this.hasIcon ? h(_sfc_main$1, {
1715
- ...this.hasIcon,
1716
- class: `vv-${this.inputType}__icon`
1717
- }) : void 0;
1718
- return h(
1719
- "button",
1720
- {
1721
- disabled: this.disabled,
1722
- class: `vv-${this.inputType}__action`,
1723
- ariaLabel: this.label,
1724
- type: "button",
1725
- onClick: this.onClick
1726
- },
1727
- icon
1728
- );
1729
- }
1730
- });
1731
- const VvInputPasswordAction = defineComponent({
1732
- components: {
1733
- VvIcon: _sfc_main$1
1734
- },
1735
- props: {
1736
- inputType: {
1737
- type: String,
1738
- default: "input-text"
1739
- },
1740
- disabled: {
1741
- type: Boolean,
1742
- default: false
1743
- },
1744
- labelShow: {
1745
- type: String,
1746
- default: "Show password"
1747
- },
1748
- labelHide: {
1749
- type: String,
1750
- default: "Hide password"
1751
- },
1752
- iconShow: {
1753
- type: [String, Object],
1754
- default: ACTION_ICONS.showPassword
1755
- },
1756
- iconHide: {
1757
- type: [String, Object],
1758
- default: ACTION_ICONS.hidePassword
1759
- }
1760
- },
1761
- emits: ["toggle-password"],
1762
- setup(props, { emit }) {
1763
- const active = ref(false);
1764
- const activeIcon = computed(
1765
- () => active.value ? props.iconHide : props.iconShow
1766
- );
1767
- const { hasIcon } = useComponentIcon(activeIcon);
1768
- function onClick(e) {
1769
- e?.stopPropagation();
1770
- if (!props.disabled) {
1771
- active.value = !active.value;
1772
- emit("toggle-password", active.value);
1773
- }
1774
- }
1775
- return {
1776
- active,
1777
- activeIcon,
1778
- hasIcon,
1779
- onClick
1780
- };
1781
- },
1782
- render() {
1783
- const icon = this.hasIcon ? h(_sfc_main$1, {
1784
- ...this.hasIcon,
1785
- class: `vv-${this.inputType}__icon`
1786
- }) : void 0;
1787
- return h(
1788
- "button",
1789
- {
1790
- disabled: this.disabled,
1791
- class: `vv-${this.inputType}__action`,
1792
- ariaLabel: this.active ? this.labelHide : this.labelShow,
1793
- type: "button",
1794
- onClick: this.onClick
1795
- },
1796
- icon
1797
- );
1798
- }
1799
- });
1800
- const VvInputStepAction = defineComponent({
1801
- components: {
1802
- VvIcon: _sfc_main$1
1803
- },
1804
- props: {
1805
- inputType: {
1806
- type: String,
1807
- default: "input-text"
1808
- },
1809
- disabled: {
1810
- type: Boolean,
1811
- default: false
1812
- },
1813
- label: {
1814
- type: String
1815
- },
1816
- mode: {
1817
- type: String,
1818
- validator: (v) => ["up", "down"].includes(v),
1819
- default: "up"
1820
- }
1821
- },
1822
- emits: ["step-up", "step-down"],
1823
- setup(props, { emit }) {
1824
- const isUp = computed(() => props.mode === "up");
1825
- const onClick = (e) => {
1826
- e?.stopPropagation();
1827
- if (!props.disabled) {
1828
- emit(isUp.value ? "step-up" : "step-down");
1829
- }
1830
- };
1831
- return {
1832
- isUp,
1833
- onClick
1834
- };
1835
- },
1836
- render() {
1837
- return h("button", {
1838
- class: [
1839
- `vv-${this.inputType}__action`,
1840
- `vv-${this.inputType}__action-chevron`,
1841
- this.isUp ? `vv-${this.inputType}__action-chevron-up` : void 0
1842
- ],
1843
- disabled: this.disabled,
1844
- ariaLabel: this.label,
1845
- type: "button",
1846
- onClick: this.onClick
1847
- });
1848
- }
1849
- });
1850
- function VvInputTextActionsFactory(type, parentProps, isDirty) {
1851
- return {
1852
- name: "VvInputTextActions",
1853
- components: {
1854
- VvIcon: _sfc_main$1,
1855
- VvInputPasswordAction,
1856
- VvInputStepAction,
1857
- VvInputClearAction
1858
- },
1859
- setup() {
1860
- const isDisabled = computed(() => {
1861
- return parentProps.disabled || parentProps.readonly;
1862
- });
1863
- return {
1864
- isDirty,
1865
- isDisabled,
1866
- labelStepUp: parentProps.labelStepUp,
1867
- labelStepDown: parentProps.labelStepDown,
1868
- labelShowPassword: parentProps.labelShowPassword,
1869
- labelHidePassword: parentProps.labelHidePassword,
1870
- labelClear: parentProps.labelClear,
1871
- iconShowPassword: parentProps.iconShowPassword,
1872
- iconHidePassword: parentProps.iconHidePassword
1873
- };
1874
- },
1875
- render() {
1876
- let actions = null;
1877
- switch (type) {
1878
- case INPUT_TYPES.SEARCH: {
1879
- const { onClear } = this.$attrs;
1880
- actions = [
1881
- h(VvInputClearAction, {
1882
- disabled: this.isDisabled || !this.isDirty,
1883
- label: this.labelClear,
1884
- onClear
1885
- })
1886
- ];
1887
- break;
1888
- }
1889
- case INPUT_TYPES.PASSWORD: {
1890
- const { onTogglePassword } = this.$attrs;
1891
- actions = [
1892
- h(VvInputPasswordAction, {
1893
- disabled: this.isDisabled,
1894
- onTogglePassword,
1895
- labelShow: this.labelShowPassword,
1896
- labelHide: this.labelHidePassword,
1897
- iconShow: this.iconShowPassword,
1898
- iconHide: this.iconHidePassword
1899
- })
1900
- ];
1901
- break;
1902
- }
1903
- case INPUT_TYPES.NUMBER: {
1904
- const { onStepUp, onStepDown } = this.$attrs;
1905
- actions = [
1906
- h(VvInputStepAction, {
1907
- mode: "up",
1908
- disabled: this.isDisabled || parentProps.max !== void 0 && parentProps.modelValue === parentProps.max,
1909
- label: this.labelStepUp,
1910
- onStepUp,
1911
- onStepDown
1912
- }),
1913
- h(VvInputStepAction, {
1914
- mode: "down",
1915
- disabled: this.isDisabled || parentProps.min !== void 0 && parentProps.modelValue === parentProps.min,
1916
- label: this.labelStepDown,
1917
- onStepUp,
1918
- onStepDown
1919
- })
1920
- ];
1921
- break;
1922
- }
1923
- }
1924
- return Array.isArray(actions) ? h("div", { class: "vv-input-text__actions-group" }, actions) : actions;
1925
- }
1926
- };
1927
- }
1928
- function useDefaults(componentName, propsDefinition, props) {
1929
- const volver = useVolver();
1930
- const volverComponentDefaults = computed(() => {
1931
- if (!volver || !volver.defaults.value?.[componentName]) {
1932
- return void 0;
1933
- }
1934
- return volver.defaults.value[componentName];
1935
- });
1936
- return computed(() => {
1937
- if (volverComponentDefaults.value === void 0) {
1938
- return props;
1939
- }
1940
- const componentDefaults = volverComponentDefaults.value;
1941
- const simplifiedPropsDefinition = propsDefinition;
1942
- const simplifiedProps = props;
1943
- return Object.keys(simplifiedPropsDefinition).reduce((acc, key) => {
1944
- const propValue = simplifiedProps[key];
1945
- acc[key] = propValue;
1946
- if (key in componentDefaults) {
1947
- if (Array.isArray(simplifiedPropsDefinition[key])) {
1948
- const typeArray = simplifiedPropsDefinition[key];
1949
- if (typeArray.length) {
1950
- const typeFunction = typeArray[0];
1951
- if (typeFunction === propValue) {
1952
- acc[key] = componentDefaults[key];
1953
- }
1954
- }
1955
- }
1956
- if (typeof simplifiedPropsDefinition[key] === "function") {
1957
- const typeFunction = simplifiedPropsDefinition[key];
1958
- if (typeFunction() === propValue) {
1959
- acc[key] = componentDefaults[key];
1960
- }
1961
- }
1962
- if (typeof simplifiedPropsDefinition[key] === "object") {
1963
- let defaultValue = simplifiedPropsDefinition[key].default;
1964
- if (typeof defaultValue === "function") {
1965
- defaultValue = defaultValue();
1966
- }
1967
- if (typeof defaultValue === "object") {
1968
- if (JSON.stringify(defaultValue) === JSON.stringify(propValue)) {
1969
- acc[key] = componentDefaults[key];
1970
- }
1971
- } else if (defaultValue === propValue) {
1972
- acc[key] = componentDefaults[key];
1973
- }
1974
- }
1975
- }
1976
- return acc;
1977
- }, {});
1978
- });
1979
- }
1980
- function useDebouncedInput(modelValue, emit, ms = 0, {
1981
- getter = (value) => value,
1982
- setter = (value) => value
1983
- } = {}) {
1984
- let timeout;
1985
- if (typeof ms === "string") {
1986
- ms = Number.parseInt(ms);
1987
- }
1988
- return computed({
1989
- get: () => getter(modelValue?.value),
1990
- set: (value) => {
1991
- if (timeout) {
1992
- clearTimeout(timeout);
1993
- }
1994
- timeout = setTimeout(() => {
1995
- emit("update:modelValue", setter(value));
1996
- }, ms);
1997
- }
1998
- });
1999
- }
2000
- function useComponentFocus(inputTemplateRef, emit) {
2001
- const { focused } = useFocus(inputTemplateRef);
2002
- watch(focused, (newValue) => {
2003
- emit(newValue ? "focus" : "blur", unref(inputTemplateRef));
2004
- });
2005
- return {
2006
- focused
2007
- };
2008
- }
2009
- function useTextCount(text, options) {
2010
- const length = computed(() => {
2011
- return (unref(text) ?? "").length;
2012
- });
2013
- const gap = computed(() => {
2014
- if (options?.lowerLimit !== void 0 && length.value < options?.lowerLimit) {
2015
- return length.value - options.lowerLimit;
2016
- }
2017
- if (options?.upperLimit !== void 0 && length.value < options?.upperLimit) {
2018
- return options.upperLimit - length.value;
2019
- }
2020
- return 0;
2021
- });
2022
- const formatted = computed(() => {
2023
- if (options?.mode === false) {
2024
- return "";
2025
- }
2026
- if (options?.mode === "limit" && options?.upperLimit) {
2027
- return `${length.value} / ${options.lowerLimit ? `${options.lowerLimit}-` : ""}${options.upperLimit}`;
2028
- }
2029
- if (options?.mode === "countdown") {
2030
- if (gap.value === 0) {
2031
- return void 0;
2032
- }
2033
- return gap;
2034
- }
2035
- return length.value;
2036
- });
2037
- return {
2038
- length,
2039
- gap,
2040
- formatted
2041
- };
2042
- }
2043
- function usePersistence(storageKey, storageType = StorageType.local, defaultValue) {
2044
- const localValue = ref();
2045
- if (defaultValue) {
2046
- localValue.value = defaultValue;
2047
- }
2048
- let storageValue;
2049
- onMounted(() => {
2050
- if (storageKey) {
2051
- watch(
2052
- storageKey,
2053
- (newKey, oldKey) => {
2054
- const storage = unref(storageType) === StorageType.session ? sessionStorage : localStorage;
2055
- if (oldKey && oldKey !== newKey) {
2056
- storage.removeItem(oldKey);
2057
- }
2058
- if (newKey) {
2059
- storageValue = useStorage(
2060
- newKey,
2061
- storageValue?.value ?? localValue.value,
2062
- storage
2063
- );
2064
- if (storageValue.value) {
2065
- localValue.value = storageValue.value;
2066
- }
2067
- return;
2068
- }
2069
- storageValue = void 0;
2070
- },
2071
- {
2072
- immediate: true
2073
- }
2074
- );
2075
- }
2076
- if (isRef(storageType)) {
2077
- watch(storageType, (newType, oldType) => {
2078
- if (storageKey?.value) {
2079
- if (newType) {
2080
- const storage = newType === StorageType.session ? sessionStorage : localStorage;
2081
- storageValue = useStorage(
2082
- storageKey.value,
2083
- storageValue?.value ?? localValue.value,
2084
- storage
2085
- );
2086
- }
2087
- if (oldType && oldType !== newType) {
2088
- const oldStorage = oldType === StorageType.session ? sessionStorage : localStorage;
2089
- oldStorage.removeItem(storageKey.value);
2090
- }
2091
- }
2092
- });
2093
- }
2094
- });
2095
- watch(localValue, (newValue) => {
2096
- if (storageValue) {
2097
- storageValue.value = newValue;
2098
- }
2099
- }, {
2100
- deep: true,
2101
- immediate: true
2102
- });
2103
- return localValue;
2104
- }
2105
- const _hoisted_1 = ["for"];
2106
- const _hoisted_2 = {
2107
- key: 0,
2108
- class: "vv-input-text__input-before"
2109
- };
2110
- const _hoisted_3 = ["id"];
2111
- const _hoisted_4 = {
2112
- key: 1,
2113
- class: "vv-input-text__unit"
2114
- };
2115
- const _hoisted_5 = {
2116
- key: 5,
2117
- class: "vv-input-text__input-after"
2118
- };
2119
- const _hoisted_6 = {
2120
- key: 6,
2121
- class: "vv-input-text__limit"
2122
- };
2123
- const _hoisted_7 = { class: "flex-1" };
2124
- const _hoisted_8 = ["title", "onClick"];
2125
- const __default__ = {
2126
- name: "VvInputText"
2127
- };
2128
- const _sfc_main = /* @__PURE__ */ defineComponent({
2129
- ...__default__,
2130
- props: VvInputTextProps,
2131
- emits: VvInputTextEvents,
2132
- setup(__props, { expose: __expose, emit: __emit }) {
2133
- const props = __props;
2134
- const emit = __emit;
2135
- const slots = useSlots();
2136
- const volver = useVolver();
2137
- const propsDefaults = useDefaults(
2138
- "VvInputText",
2139
- VvInputTextProps,
2140
- props
2141
- );
2142
- const {
2143
- count,
2144
- debounce,
2145
- icon,
2146
- iconPosition,
2147
- iconRemoveSuggestion,
2148
- id,
2149
- invalid,
2150
- label,
2151
- loading,
2152
- maxlength,
2153
- minlength,
2154
- modelValue,
2155
- step,
2156
- storageType,
2157
- type,
2158
- valid
2159
- } = toRefs(props);
2160
- const hasId = useUniqueId(id);
2161
- const hasHintId = computed(() => `${hasId.value}-hint`);
2162
- const inputTextPlaceholder = computed(
2163
- () => props.floating && isEmpty(props.placeholder) ? " " : props.placeholder
2164
- );
2165
- const localModelValue = useDebouncedInput(
2166
- modelValue,
2167
- emit,
2168
- debounce?.value ?? 0
2169
- );
2170
- const hasSeconds = computed(() => {
2171
- const stepValue = typeof step.value === "number" ? step.value : Number.parseInt(step.value);
2172
- if (Number.isNaN(stepValue)) {
2173
- return false;
2174
- }
2175
- return stepValue % 60 !== 0;
2176
- });
2177
- const NEGATIVE_ZERO_REGEX = /^-0?[.,]?[0*]?$/;
2178
- const maskReady = ref(false);
2179
- const modelValueDate = ref();
2180
- const modelValueDateIsoString = ref();
2181
- const { el, mask, typed, masked, unmasked } = useIMask(
2182
- computed(
2183
- () => {
2184
- if (!props.iMask) {
2185
- return {
2186
- mask: /./
2187
- };
2188
- }
2189
- if (props.iMask.mask === Number) {
2190
- const toReturn = { ...props.iMask };
2191
- if (props.min) {
2192
- toReturn.min = Number(props.min);
2193
- }
2194
- if (props.max) {
2195
- toReturn.max = Number(props.max);
2196
- }
2197
- return toReturn;
2198
- }
2199
- return props.iMask;
2200
- }
2201
- ),
2202
- {
2203
- emit,
2204
- onAccept: () => {
2205
- if (!maskReady.value) {
2206
- return;
2207
- }
2208
- emit("update:masked", masked.value);
2209
- if (type.value === INPUT_TYPES.NUMBER) {
2210
- if (/^-$|^$/.test(unmasked.value)) {
2211
- if (localModelValue.value === null || localModelValue.value === void 0) {
2212
- return;
2213
- }
2214
- localModelValue.value = void 0;
2215
- return;
2216
- }
2217
- if (NEGATIVE_ZERO_REGEX.test(unmasked.value)) {
2218
- localModelValue.value = 0;
2219
- return;
2220
- }
2221
- if (typeof typed.value !== "number") {
2222
- localModelValue.value = Number(typed.value);
2223
- return;
2224
- }
2225
- localModelValue.value = typed.value;
2226
- return;
2227
- }
2228
- if (type.value === INPUT_TYPES.DATETIME_LOCAL || type.value === INPUT_TYPES.DATE || type.value === INPUT_TYPES.TIME || type.value === INPUT_TYPES.MONTH) {
2229
- if (!typed.value) {
2230
- if (!localModelValue.value) {
2231
- return;
2232
- }
2233
- if (modelValueDate.value) {
2234
- localModelValue.value = void 0;
2235
- return;
2236
- }
2237
- localModelValue.value = "";
2238
- return;
2239
- }
2240
- if (!(typed.value instanceof Date) && !modelValueDate.value && !modelValueDateIsoString.value) {
2241
- localModelValue.value = typed.value;
2242
- return;
2243
- }
2244
- let date = typed.value;
2245
- if (!(date instanceof Date)) {
2246
- date = getDateFromInputValue(typed.value, type.value);
2247
- }
2248
- if (modelValueDate.value || modelValueDateIsoString.value) {
2249
- const toReturn = new Date(modelValueDate.value || modelValueDateIsoString.value);
2250
- if (type.value === INPUT_TYPES.DATETIME_LOCAL || type.value === INPUT_TYPES.DATE || type.value === INPUT_TYPES.MONTH) {
2251
- toReturn.setFullYear(date.getFullYear());
2252
- toReturn.setMonth(date.getMonth());
2253
- }
2254
- if (type.value === INPUT_TYPES.DATETIME_LOCAL || type.value === INPUT_TYPES.DATE) {
2255
- toReturn.setDate(date.getDate());
2256
- }
2257
- if (type.value === INPUT_TYPES.DATETIME_LOCAL || type.value === INPUT_TYPES.TIME) {
2258
- toReturn.setHours(date.getHours());
2259
- toReturn.setMinutes(date.getMinutes());
2260
- toReturn.setSeconds(date.getSeconds());
2261
- }
2262
- if (modelValueDate.value instanceof Date) {
2263
- if (localModelValue.value?.getTime() === toReturn.getTime()) {
2264
- return;
2265
- }
2266
- localModelValue.value = toReturn;
2267
- return;
2268
- }
2269
- localModelValue.value = toReturn.toISOString();
2270
- return;
2271
- }
2272
- localModelValue.value = getInputValueFromDate(date, type.value, hasSeconds.value);
2273
- return;
2274
- }
2275
- if (!localModelValue.value && !unmasked.value) {
2276
- return;
2277
- }
2278
- localModelValue.value = unmasked.value;
2279
- }
2280
- }
2281
- );
2282
- function updateMaskValue(newValue) {
2283
- if (newValue === void 0 || newValue === null) {
2284
- typed.value = "";
2285
- unmasked.value = "";
2286
- return;
2287
- }
2288
- if (props.iMask?.mask === Date) {
2289
- typed.value = newValue instanceof Date ? newValue : new Date(newValue);
2290
- return;
2291
- }
2292
- if (type.value === INPUT_TYPES.NUMBER && NEGATIVE_ZERO_REGEX.test(unmasked.value) && newValue === 0) {
2293
- return;
2294
- }
2295
- if (type.value === INPUT_TYPES.DATE || type.value === INPUT_TYPES.MONTH || type.value === INPUT_TYPES.DATETIME_LOCAL || type.value === INPUT_TYPES.TIME) {
2296
- if (newValue instanceof Date || isDateIsoString(newValue)) {
2297
- if (newValue instanceof Date) {
2298
- modelValueDate.value = newValue;
2299
- modelValueDateIsoString.value = void 0;
2300
- } else {
2301
- modelValueDateIsoString.value = newValue;
2302
- modelValueDate.value = void 0;
2303
- }
2304
- const newDate = new Date(newValue);
2305
- typed.value = getInputValueFromDate(newDate, type.value, hasSeconds.value);
2306
- unmasked.value = typed.value;
2307
- return;
2308
- }
2309
- modelValueDate.value = void 0;
2310
- modelValueDateIsoString.value = void 0;
2311
- }
2312
- typed.value = newValue;
2313
- unmasked.value = `${typed.value}`;
2314
- }
2315
- onMounted(() => {
2316
- if (mask.value) {
2317
- maskReady.value = true;
2318
- updateMaskValue(props.modelValue);
2319
- }
2320
- });
2321
- watch(
2322
- () => props.modelValue,
2323
- (newValue) => {
2324
- if (mask.value) {
2325
- updateMaskValue(newValue);
2326
- }
2327
- }
2328
- );
2329
- watch(
2330
- () => props.masked,
2331
- (newValue) => {
2332
- masked.value = newValue ?? "";
2333
- }
2334
- );
2335
- const inputEl = el;
2336
- const innerEl = ref();
2337
- const wrapperEl = ref();
2338
- const suggestionsDropdownEl = ref();
2339
- __expose({ $inner: innerEl });
2340
- const { focused } = useComponentFocus(inputEl, emit);
2341
- const isFocused = computed(
2342
- () => focused.value && !props.disabled && !props.readonly
2343
- );
2344
- watch(isFocused, (newValue) => {
2345
- if (newValue && propsDefaults.value.selectOnFocus && inputEl.value) {
2346
- inputEl.value.select();
2347
- }
2348
- if (newValue && suggestions.value?.size) {
2349
- suggestionsDropdownEl.value?.show();
2350
- return;
2351
- }
2352
- if (isDirty.value && suggestions.value) {
2353
- const suggestionsLimit = props.maxSuggestions;
2354
- if (suggestions.value.size >= suggestionsLimit && !suggestions.value.has(localModelValue.value)) {
2355
- suggestions.value = new Set(
2356
- [...suggestions.value].slice(
2357
- suggestions.value.size - suggestionsLimit + 1
2358
- )
2359
- );
2360
- }
2361
- suggestions.value.add(localModelValue.value);
2362
- }
2363
- });
2364
- const isVisible = useElementVisibility(inputEl);
2365
- watch(isVisible, (newValue) => {
2366
- if (newValue && props.autofocus && !props.disabled && !props.readonly) {
2367
- focused.value = true;
2368
- }
2369
- });
2370
- const showPassword = ref(false);
2371
- const isPassword = computed(() => props.type === INPUT_TYPES.PASSWORD);
2372
- function onTogglePassword() {
2373
- showPassword.value = !showPassword.value;
2374
- }
2375
- const isDateTime = computed(
2376
- () => props.type === INPUT_TYPES.TIME || props.type === INPUT_TYPES.DATETIME_LOCAL || props.type === INPUT_TYPES.DATE || props.type === INPUT_TYPES.WEEK || props.type === INPUT_TYPES.MONTH
2377
- );
2378
- const isNumber = computed(() => props.type === INPUT_TYPES.NUMBER);
2379
- function onStepUp() {
2380
- if (!isDisabledOrReadonly.value) {
2381
- if (props.iMask) {
2382
- typed.value = Number(typed.value) + Number(step?.value ?? 1);
2383
- return;
2384
- }
2385
- inputEl.value.stepUp();
2386
- localModelValue.value = Number(unref(inputEl).value);
2387
- }
2388
- }
2389
- function onStepDown() {
2390
- if (!isDisabledOrReadonly.value) {
2391
- if (props.iMask) {
2392
- typed.value = Number(typed.value) - Number(step?.value ?? 1);
2393
- return;
2394
- }
2395
- inputEl.value.stepDown();
2396
- localModelValue.value = Number(unref(inputEl).value);
2397
- }
2398
- }
2399
- const isSearch = computed(() => props.type === INPUT_TYPES.SEARCH);
2400
- function onClear() {
2401
- localModelValue.value = "";
2402
- emit("clear");
2403
- }
2404
- const { hasIconBefore, hasIconAfter } = useComponentIcon(icon, iconPosition);
2405
- const iconAfter = computed(() => {
2406
- if (hasIconAfter.value !== void 0) {
2407
- return hasIconAfter.value;
2408
- }
2409
- switch (props.type) {
2410
- case INPUT_TYPES.COLOR:
2411
- return { name: ACTION_ICONS.showColorPicker };
2412
- case INPUT_TYPES.DATE:
2413
- case INPUT_TYPES.DATETIME_LOCAL:
2414
- case INPUT_TYPES.WEEK:
2415
- case INPUT_TYPES.MONTH:
2416
- return { name: ACTION_ICONS.showDatePicker };
2417
- case INPUT_TYPES.TIME:
2418
- return { name: ACTION_ICONS.showTimePicker };
2419
- }
2420
- return void 0;
2421
- });
2422
- const { hasIcon: hasIconRemoveSuggestion } = useComponentIcon(iconRemoveSuggestion);
2423
- const { formatted: countFormatted } = useTextCount(localModelValue, {
2424
- mode: count.value,
2425
- upperLimit: Number(maxlength?.value),
2426
- lowerLimit: Number(minlength?.value)
2427
- });
2428
- const isDisabledOrReadonly = computed(() => props.disabled || props.readonly);
2429
- const hasTabindex = computed(() => {
2430
- return isDisabledOrReadonly.value ? -1 : props.tabindex;
2431
- });
2432
- const isDirty = computed(() => !isEmpty(modelValue));
2433
- const isInvalid = computed(() => {
2434
- if (invalid.value === true) {
2435
- return true;
2436
- }
2437
- if (valid.value === true) {
2438
- return false;
2439
- }
2440
- return void 0;
2441
- });
2442
- const storageKey = computed(() => props.storageKey ?? (volver?.experimentalFeatures.forceInputSuggestions ? props.name : void 0));
2443
- const suggestions = usePersistence(
2444
- storageKey,
2445
- storageType,
2446
- /* @__PURE__ */ new Set()
2447
- );
2448
- const filteredSuggestions = computed(() => {
2449
- if (!suggestions.value) {
2450
- return [];
2451
- }
2452
- return [...suggestions.value].filter(
2453
- (suggestion) => isEmpty(localModelValue.value) || `${suggestion}`.toLowerCase().includes(`${localModelValue.value}`.toLowerCase()) && suggestion !== localModelValue.value
2454
- ).reverse();
2455
- });
2456
- const hasSuggestions = computed(
2457
- () => storageKey?.value && suggestions.value && suggestions.value.size > 0
2458
- );
2459
- function onSuggestionSelect(suggestion) {
2460
- localModelValue.value = suggestion;
2461
- suggestionsDropdownEl.value?.hide();
2462
- emit("suggestion:selected", suggestion);
2463
- }
2464
- function onSuggestionRemove(suggestion) {
2465
- suggestions.value?.delete(suggestion);
2466
- emit("suggestion:removed", suggestion);
2467
- }
2468
- const { modifiers } = toRefs(props);
2469
- const bemCssClasses = useModifiers(
2470
- "vv-input-text",
2471
- modifiers,
2472
- computed(() => ({
2473
- "valid": valid.value,
2474
- "invalid": invalid.value,
2475
- "loading": loading.value,
2476
- "disabled": props.disabled,
2477
- "required": props.required,
2478
- "readonly": props.readonly,
2479
- "icon-before": !!hasIconBefore.value,
2480
- "icon-after": !!iconAfter.value,
2481
- "floating": props.floating && !isEmpty(props.label),
2482
- "dirty": isDirty.value,
2483
- "focus": isFocused.value && !isDisabledOrReadonly.value,
2484
- "auto-width": props.autoWidth
2485
- }))
2486
- );
2487
- const hasAttrs = computed(() => {
2488
- const type2 = (() => {
2489
- if (isPassword.value && showPassword.value) {
2490
- return INPUT_TYPES.TEXT;
2491
- }
2492
- if (isDateTime.value && !isDirty.value && !focused.value) {
2493
- return INPUT_TYPES.TEXT;
2494
- }
2495
- if (props.iMask) {
2496
- return INPUT_TYPES.TEXT;
2497
- }
2498
- return props.type;
2499
- })();
2500
- const toReturn = {
2501
- type: type2,
2502
- "name": props.name,
2503
- "tabindex": hasTabindex.value,
2504
- "disabled": props.disabled,
2505
- "readonly": props.readonly,
2506
- "required": props.required,
2507
- "autocomplete": props.autocomplete,
2508
- "aria-invalid": isInvalid.value,
2509
- "aria-describedby": hasHintLabelOrSlot.value ? hasHintId.value : void 0,
2510
- "aria-errormessage": hasInvalidLabelOrSlot.value ? hasHintId.value : void 0,
2511
- "inputMode": props.inputMode
2512
- };
2513
- if (type2 === INPUT_TYPES.DATE || type2 === INPUT_TYPES.MONTH || type2 === INPUT_TYPES.WEEK || type2 === INPUT_TYPES.TIME || type2 === INPUT_TYPES.DATETIME_LOCAL || type2 === INPUT_TYPES.NUMBER) {
2514
- let max = props.max;
2515
- if (type2 === INPUT_TYPES.DATE && !max) {
2516
- max = "9999-12-31";
2517
- }
2518
- toReturn.step = props.step;
2519
- toReturn.max = max !== void 0 ? String(max) : void 0;
2520
- toReturn.min = props.min !== void 0 ? String(props.min) : void 0;
2521
- }
2522
- if (type2 === INPUT_TYPES.TEXT || type2 === INPUT_TYPES.SEARCH || type2 === INPUT_TYPES.URL || type2 === INPUT_TYPES.TEL || type2 === INPUT_TYPES.EMAIL || type2 === INPUT_TYPES.PASSWORD || type2 === INPUT_TYPES.NUMBER) {
2523
- toReturn.placeholder = inputTextPlaceholder.value;
2524
- }
2525
- if (type2 === INPUT_TYPES.TEXT || type2 === INPUT_TYPES.SEARCH || type2 === INPUT_TYPES.URL || type2 === INPUT_TYPES.TEL || type2 === INPUT_TYPES.EMAIL || type2 === INPUT_TYPES.PASSWORD) {
2526
- toReturn.minlength = props.minlength;
2527
- toReturn.maxlength = props.maxlength;
2528
- toReturn.pattern = props.pattern;
2529
- }
2530
- if (type2 === INPUT_TYPES.EMAIL) {
2531
- toReturn.multiple = props.multiple;
2532
- }
2533
- return toReturn;
2534
- });
2535
- const slotProps = computed(() => ({
2536
- valid: props.valid,
2537
- invalid: props.invalid,
2538
- modelValue: props.modelValue,
2539
- togglePassword: onTogglePassword,
2540
- stepUp: onStepUp,
2541
- stepDown: onStepDown,
2542
- clear: onClear
2543
- }));
2544
- const {
2545
- HintSlot,
2546
- hasHintLabelOrSlot,
2547
- hasInvalidLabelOrSlot,
2548
- hintSlotScope
2549
- } = HintSlotFactory(propsDefaults, slots);
2550
- const PasswordInputActions = VvInputTextActionsFactory(
2551
- INPUT_TYPES.PASSWORD,
2552
- props,
2553
- isDirty
2554
- );
2555
- const NumberInputActions = VvInputTextActionsFactory(
2556
- INPUT_TYPES.NUMBER,
2557
- props,
2558
- isDirty
2559
- );
2560
- const SearchInputActions = VvInputTextActionsFactory(
2561
- INPUT_TYPES.SEARCH,
2562
- props,
2563
- isDirty
2564
- );
2565
- function onClickInner() {
2566
- if (!isDisabledOrReadonly.value) {
2567
- focused.value = true;
2568
- }
2569
- }
2570
- const hasStyle = computed(() => {
2571
- if (!props.autoWidth) {
2572
- return void 0;
2573
- }
2574
- return {
2575
- width: localModelValue.value !== void 0 ? `${String(localModelValue.value).length + 1}ch` : void 0
2576
- };
2577
- });
2578
- function onKeyDown(event) {
2579
- switch (event.code) {
2580
- case "ArrowUp":
2581
- if (isNumber.value) {
2582
- onStepUp();
2583
- event.preventDefault();
2584
- }
2585
- break;
2586
- case "ArrowDown":
2587
- if (isNumber.value) {
2588
- onStepDown();
2589
- event.preventDefault();
2590
- }
2591
- break;
2592
- }
2593
- emit("keydown", event);
2594
- }
2595
- return (_ctx, _cache) => {
2596
- return openBlock(), createElementBlock(
2597
- "div",
2598
- {
2599
- class: normalizeClass(unref(bemCssClasses))
2600
- },
2601
- [
2602
- unref(label) ? (openBlock(), createElementBlock("label", {
2603
- key: 0,
2604
- for: unref(hasId),
2605
- class: "vv-input-text__label"
2606
- }, toDisplayString(unref(label)), 9, _hoisted_1)) : createCommentVNode("v-if", true),
2607
- createElementVNode(
2608
- "div",
2609
- {
2610
- ref_key: "wrapperEl",
2611
- ref: wrapperEl,
2612
- class: "vv-input-text__wrapper"
2613
- },
2614
- [
2615
- _ctx.$slots.before ? (openBlock(), createElementBlock("div", _hoisted_2, [
2616
- renderSlot(_ctx.$slots, "before", normalizeProps(guardReactiveProps(unref(slotProps))))
2617
- ])) : createCommentVNode("v-if", true),
2618
- createElementVNode(
2619
- "div",
2620
- {
2621
- ref_key: "innerEl",
2622
- ref: innerEl,
2623
- class: "vv-input-text__inner",
2624
- onClick: withModifiers(onClickInner, ["stop"])
2625
- },
2626
- [
2627
- unref(hasIconBefore) ? (openBlock(), createBlock(
2628
- _sfc_main$1,
2629
- mergeProps({ key: 0 }, unref(hasIconBefore), { class: "vv-input-text__icon" }),
2630
- null,
2631
- 16
2632
- /* FULL_PROPS */
2633
- )) : createCommentVNode("v-if", true),
2634
- createElementVNode("input", mergeProps({
2635
- id: unref(hasId),
2636
- ref_key: "inputEl",
2637
- ref: inputEl
2638
- }, unref(hasAttrs), {
2639
- style: unref(hasStyle),
2640
- onKeyup: _cache[0] || (_cache[0] = ($event) => emit("keyup", $event)),
2641
- onKeydown: onKeyDown,
2642
- onKeypress: _cache[1] || (_cache[1] = ($event) => emit("keypress", $event))
2643
- }), null, 16, _hoisted_3),
2644
- (_ctx.unit || _ctx.$slots.unit) && unref(isDirty) ? (openBlock(), createElementBlock("div", _hoisted_4, [
2645
- renderSlot(_ctx.$slots, "unit", normalizeProps(guardReactiveProps(unref(slotProps))), () => [
2646
- createTextVNode(
2647
- toDisplayString(_ctx.unit),
2648
- 1
2649
- /* TEXT */
2650
- )
2651
- ])
2652
- ])) : createCommentVNode("v-if", true)
2653
- ],
2654
- 512
2655
- /* NEED_PATCH */
2656
- ),
2657
- unref(iconAfter) ? (openBlock(), createBlock(
2658
- _sfc_main$1,
2659
- mergeProps({ key: 1 }, unref(iconAfter), { class: "vv-input-text__icon vv-input-text__icon-after" }),
2660
- null,
2661
- 16
2662
- /* FULL_PROPS */
2663
- )) : unref(isPassword) && !_ctx.hideActions && !unref(isDisabledOrReadonly) ? (openBlock(), createBlock(unref(PasswordInputActions), {
2664
- key: 2,
2665
- onTogglePassword
2666
- })) : unref(isNumber) && !_ctx.hideActions && !unref(isDisabledOrReadonly) ? (openBlock(), createBlock(unref(NumberInputActions), {
2667
- key: 3,
2668
- onStepUp,
2669
- onStepDown
2670
- })) : unref(isSearch) && !_ctx.hideActions && !unref(isDisabledOrReadonly) ? (openBlock(), createBlock(unref(SearchInputActions), {
2671
- key: 4,
2672
- onClear
2673
- })) : createCommentVNode("v-if", true),
2674
- _ctx.$slots.after ? (openBlock(), createElementBlock("div", _hoisted_5, [
2675
- renderSlot(_ctx.$slots, "after", normalizeProps(guardReactiveProps(unref(slotProps))))
2676
- ])) : createCommentVNode("v-if", true),
2677
- unref(count) ? (openBlock(), createElementBlock("span", _hoisted_6, [
2678
- renderSlot(_ctx.$slots, "count", normalizeProps(guardReactiveProps(unref(slotProps))), () => [
2679
- createTextVNode(
2680
- toDisplayString(unref(countFormatted)),
2681
- 1
2682
- /* TEXT */
2683
- )
2684
- ])
2685
- ])) : createCommentVNode("v-if", true)
2686
- ],
2687
- 512
2688
- /* NEED_PATCH */
2689
- ),
2690
- createVNode(unref(HintSlot), {
2691
- id: unref(hasHintId),
2692
- class: "vv-input-text__hint"
2693
- }, createSlots({
2694
- _: 2
2695
- /* DYNAMIC */
2696
- }, [
2697
- _ctx.$slots.hint ? {
2698
- name: "hint",
2699
- fn: withCtx(() => [
2700
- renderSlot(_ctx.$slots, "hint", normalizeProps(guardReactiveProps(unref(hintSlotScope))))
2701
- ]),
2702
- key: "0"
2703
- } : void 0,
2704
- _ctx.$slots.loading ? {
2705
- name: "loading",
2706
- fn: withCtx(() => [
2707
- renderSlot(_ctx.$slots, "loading", normalizeProps(guardReactiveProps(unref(hintSlotScope))))
2708
- ]),
2709
- key: "1"
2710
- } : void 0,
2711
- _ctx.$slots.valid ? {
2712
- name: "valid",
2713
- fn: withCtx(() => [
2714
- renderSlot(_ctx.$slots, "valid", normalizeProps(guardReactiveProps(unref(hintSlotScope))))
2715
- ]),
2716
- key: "2"
2717
- } : void 0,
2718
- _ctx.$slots.invalid ? {
2719
- name: "invalid",
2720
- fn: withCtx(() => [
2721
- renderSlot(_ctx.$slots, "invalid", normalizeProps(guardReactiveProps(unref(hintSlotScope))))
2722
- ]),
2723
- key: "3"
2724
- } : void 0
2725
- ]), 1032, ["id"]),
2726
- unref(hasSuggestions) ? (openBlock(), createBlock(_sfc_main$4, {
2727
- key: 1,
2728
- ref_key: "suggestionsDropdownEl",
2729
- ref: suggestionsDropdownEl,
2730
- reference: unref(wrapperEl),
2731
- "autofocus-first": false,
2732
- "trigger-width": true
2733
- }, {
2734
- items: withCtx(() => [
2735
- (openBlock(true), createElementBlock(
2736
- Fragment,
2737
- null,
2738
- renderList(unref(filteredSuggestions), (value) => {
2739
- return openBlock(), createBlock(_sfc_main$2, {
2740
- key: value,
2741
- onClick: withModifiers(($event) => onSuggestionSelect(value), ["stop"])
2742
- }, {
2743
- default: withCtx(() => [
2744
- createElementVNode("div", _hoisted_7, [
2745
- renderSlot(_ctx.$slots, "suggestion", mergeProps({ ref_for: true }, { value }), () => [
2746
- createTextVNode(
2747
- toDisplayString(value),
2748
- 1
2749
- /* TEXT */
2750
- )
2751
- ])
2752
- ]),
2753
- unref(suggestions) && unref(hasIconRemoveSuggestion) ? (openBlock(), createElementBlock("button", {
2754
- key: 0,
2755
- type: "button",
2756
- tabindex: "-1",
2757
- class: "cursor-pointer",
2758
- title: _ctx.labelRemoveSuggestion,
2759
- onClick: withModifiers(($event) => onSuggestionRemove(value), ["stop"])
2760
- }, [
2761
- createVNode(
2762
- _sfc_main$1,
2763
- mergeProps({ ref_for: true }, unref(hasIconRemoveSuggestion)),
2764
- null,
2765
- 16
2766
- /* FULL_PROPS */
2767
- )
2768
- ], 8, _hoisted_8)) : createCommentVNode("v-if", true)
2769
- ]),
2770
- _: 2
2771
- /* DYNAMIC */
2772
- }, 1032, ["onClick"]);
2773
- }),
2774
- 128
2775
- /* KEYED_FRAGMENT */
2776
- ))
2777
- ]),
2778
- _: 3
2779
- /* FORWARDED */
2780
- }, 8, ["reference"])) : createCommentVNode("v-if", true)
2781
- ],
2782
- 2
2783
- /* CLASS */
2784
- );
2785
- };
2786
- }
2787
- });
2788
- export {
2789
- _sfc_main as default
2790
- };
1
+ import{unref as e,computed as t,isRef as a,defineComponent as l,h as o,useId as i,Fragment as n,provide as r,ref as u,toRefs as s,useAttrs as d,onMounted as v,watch as c,createElementBlock as p,openBlock as f,createVNode as m,withCtx as b,renderSlot as h,normalizeProps as g,guardReactiveProps as y,Transition as S,mergeProps as w,toHandlers as E,withDirectives as $,createElementVNode as x,normalizeClass as L,normalizeStyle as T,createCommentVNode as D,vShow as k,nextTick as O,inject as A,createBlock as _,createTextVNode as I,toDisplayString as M,mergeDefaults as N,useSlots as H,withModifiers as C,createSlots as B,renderList as P}from"vue";import{useIMask as V}from"vue-imask";import{autoPlacement as R,flip as j,shift as U,size as F,offset as Y,arrow as W,useFloating as z,autoUpdate as q}from"@floating-ui/vue";import{useMutationObserver as K,useVModel as X,onClickOutside as J,useFocusWithin as Z,useElementHover as G,onKeyStroke as Q,useFocus as ee,useStorage as te,useElementVisibility as ae}from"@vueuse/core";import le from"mitt";import{iconLoaded as oe,Icon as ie,addIcon as ne}from"@iconify/vue";const re=e=>e.toString().padStart(2,"0");function ue(e){if("string"!=typeof e)return!1;if(!/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d{1,3})?(?:Z|[+-]\d{2}:?\d{2})?$/.test(e))return!1;const t=new Date(e);return!Number.isNaN(t.getTime())&&t.toISOString()===e}function se(e,t="date",a){if("string"==typeof e&&!ue(e))return"";const l=new Date(e);if(Number.isNaN(l.getTime()))return"";let o=`${l.getFullYear()}-${re(l.getMonth()+1)}`;if("month"===t)return o;if(o+=`-${re(l.getDate())}`,"date"===t)return o;const i=a?`${re(l.getHours())}:${re(l.getMinutes())}:${re(l.getSeconds())}`:`${re(l.getHours())}:${re(l.getMinutes())}`;return"time"===t?i:`${o}T${i}`}function de(t){return null==(a=e(t))||""===a||Array.isArray(a)&&0===a.length||!(a instanceof Date)&&"object"==typeof a&&0===Object.keys(a).length;var a}function ve(e){return Array.isArray(e)?e.filter(e=>"string"==typeof e).join(" "):e}var ce=/* @__PURE__ */(e=>(e.local="local",e.session="session",e))(ce||{}),pe=/* @__PURE__ */(e=>(e.absolute="absolute",e.fixed="fixed",e))(pe||{}),fe=/* @__PURE__ */(e=>(e.left="left",e.right="right",e.top="top",e.bottom="bottom",e))(fe||{}),me=/* @__PURE__ */(e=>(e.topStart="top-start",e.topEnd="top-end",e.bottomStart="bottom-start",e.bottomEnd="bottom-end",e.leftStart="left-start",e.leftEnd="left-end",e.rightStart="right-start",e.rightEnd="right-end",e))(me||{}),be=/* @__PURE__ */(e=>(e.before="before",e.after="after",e))(be||{}),he=/* @__PURE__ */(e=>(e.button="button",e.submit="submit",e.reset="reset",e))(he||{}),ge=/* @__PURE__ */(e=>(e.nuxtLink="nuxt-link",e.routerLink="router-link",e.a="a",e.button="button",e))(ge||{}),ye=/* @__PURE__ */(e=>(e.button="button",e.link="link",e.menuitem="menuitem",e))(ye||{}),Se=/* @__PURE__ */(e=>(e.listbox="listbox",e.menu="menu",e))(Se||{}),we=/* @__PURE__ */(e=>(e.option="option",e.presentation="presentation",e))(we||{});const Ee=Symbol.for("volver"),$e=Symbol.for("dropdownTrigger"),xe=Symbol.for("dropdownItem"),Le=Symbol.for("dropdownAction"),Te="eye-on",De="eye-off",ke="calendar",Oe="time",Ae="color",_e="close",Ie="trash",Me={prefix:"normal"},Ne={valid:{type:Boolean,default:!1},validLabel:{type:[String,Array],default:void 0}},He={invalid:{type:Boolean,default:!1},invalidLabel:{type:[String,Array],default:void 0}},Ce={loading:{type:Boolean,default:!1},loadingLabel:{type:String,default:"Loading..."}},Be={disabled:{type:Boolean,default:!1}},Pe={required:{type:Boolean,default:!1}},Ve={selected:{type:Boolean,default:!1}},Re={label:{type:[String,Number],default:void 0}},je={readonly:{type:Boolean,default:!1}},Ue={modifiers:{type:[String,Array],default:void 0}},Fe={hintLabel:{type:String,default:""}},Ye={count:{type:[Boolean,String],default:!1,validator:e=>[!0,!1,"limit","countdown"].includes(e)}},We={debounce:{type:[Number,String],default:void 0}},ze={icon:{type:[String,Object],default:void 0},iconPosition:{type:String,default:be.before,validation:e=>Object.values(be).includes(e)}},qe={tabindex:{type:[String,Number],default:0}},Ke={floating:{type:Boolean,default:!1}},Xe={unselectable:{type:Boolean,default:!0}},Je={id:[String,Number]},Ze={placement:{type:String,default:fe.bottom,validator:e=>Object.values(fe).includes(e)||Object.values(me).includes(e)},strategy:{type:String,default:void 0,validator:e=>Object.values(pe).includes(e)},transitionName:{type:String,default:void 0},offset:{type:[Number,String,Object],default:0},shift:{type:[Boolean,Object],default:!1},flip:{type:[Boolean,Object],default:!0},size:{type:[Boolean,Object],default:()=>({padding:10})},autoPlacement:{type:[Boolean,Object],default:!1},arrow:{type:Boolean,default:!1},keepOpen:{type:Boolean,default:!1},autofocusFirst:{type:Boolean,default:!0},triggerWidth:{type:Boolean,default:!1}},Ge={...{...Je,name:{type:String,required:!0}},...{autofocus:{type:Boolean,default:!1}},...{autocomplete:{type:String,default:"off"}},...qe,...Be,...je,...Ne,...He,...Fe,...Ce,...Ue,...Ye,...We,...ze,...Ke,...Re,minlength:{type:[String,Number],default:void 0},maxlength:{type:[String,Number],default:void 0},placeholder:{type:String,default:void 0},...Pe};he.button,ge.button;const Qe={storageType:{type:String,default:ce.local,validator:e=>Object.values(ce).includes(e)},storageKey:String},et={...Je,...Ze,...Ue,modelValue:{type:Boolean,default:void 0},reference:{type:Object,default:null},role:{type:String,default:Se.menu,validator:e=>Object.values(Se).includes(e)}},tt={focusOnHover:{type:Boolean,default:!1}},at={...Be,...Ve,...Xe,...Ue,deselectHintLabel:{type:String},selectHintLabel:{type:String},selectedHintLabel:{type:String},focusOnHover:{type:Boolean,default:!1}};function lt(e){return t(()=>String(e?.value||i()))}function ot(a,l,o){return t(()=>{const t={[a]:!0},i="string"==typeof l?.value?l.value.split(" "):l?.value;return i&&Array.isArray(i)&&i.forEach(e=>{e&&(t[`${a}--${e}`]=!0)}),o&&Object.keys(o.value).forEach(l=>{t[`${a}--${l}`]=e(o.value[l])}),t})}const it=["id","tabindex","role","aria-labelledby"],nt=/* @__PURE__ */l({name:"VvDropdown",inheritAttrs:!1,props:et,emits:["update:modelValue","beforeEnter","afterLeave","beforeExpand","beforeCollapse","afterExpand","afterCollapse","before-enter","after-leave","enter","afterEnter","enterCancelled","beforeLeave","leave","leaveCancelled"],setup(a,{expose:i,emit:A}){const _=a,I=A,{id:M}=s(_),N=lt(M),H=d(),C=u("auto"),B=u("auto"),P=u(),V=u(),ee=u(),te=u(),ae=t({get:()=>_.reference??P.value,set:e=>{P.value=e}}),oe=u(!1);v(()=>{K(V.value,()=>{oe.value="true"===window.getComputedStyle(V.value).getPropertyValue("--dropdown-custom-position")?.trim()},{attributeFilter:["style"],window:window})});const ie=t(()=>{const e=[];if(_.autoPlacement?"boolean"==typeof _.autoPlacement?e.push(R()):e.push(R(_.autoPlacement)):_.flip&&("boolean"==typeof _.flip?e.push(j({fallbackStrategy:"initialPlacement"})):e.push(j(_.flip))),_.shift&&("boolean"==typeof _.shift?e.push(U()):e.push(U(_.shift))),_.size){const t=({availableWidth:e,availableHeight:t})=>{C.value=`${e}px`,B.value=`${t}px`};"boolean"==typeof _.size?e.push(F({apply:t})):e.push(F({..._.size,apply:t}))}return _.offset&&(e.push(Y(Number(_.offset))),["string","number"].includes(typeof _.offset)?e.push(Y(Number(_.offset))):e.push(Y(_.offset))),_.arrow&&e.push(W({element:ee})),e}),{x:ne,y:re,middlewareData:ue,placement:se,strategy:de}=z(ae,V,{whileElementsMounted:(...e)=>q(...e,{animationFrame:_.strategy===pe.fixed}),placement:t(()=>_.placement),strategy:t(()=>_.strategy),middleware:ie}),ve=t(()=>{if(oe.value)return;const e=_.triggerWidth&&ae.value?`${ae.value?.offsetWidth}px`:void 0;return{position:de.value,top:`${re.value??0}px`,left:`${ne.value??0}px`,maxWidth:e?void 0:C.value,maxHeight:B.value,width:e}}),ce=t(()=>se.value.split("-")[0]),me=t(()=>{if(oe.value)return;const e={[fe.top]:fe.bottom,[fe.right]:fe.left,[fe.bottom]:fe.top,[fe.left]:fe.right}[ce.value];return{left:void 0!==ue.value.arrow?.x?`${ue.value.arrow?.x}px`:void 0,top:void 0!==ue.value.arrow?.y?`${ue.value.arrow?.y}px`:void 0,[e]:-(ee.value?.offsetWidth??0)/2+"px"}}),be=X(_,"modelValue",I),he=u(!1),ge=t({get:()=>be.value??he.value,set:e=>{void 0!==be.value?be.value=e:he.value=e}});function ye(){ge.value=!0}function Ee(){ge.value=!1}function Le(){ge.value=!ge.value}function Te(e){ae.value=e}J(V,()=>{!_.keepOpen&&ge.value&&(ge.value=!1)},{ignore:[ae]});const De=t(()=>ae.value?.getAttribute?.("id")??void 0),ke=t(()=>({"aria-controls":N.value,"aria-haspopup":!0,"aria-expanded":ge.value})),{component:Oe,bus:Ae}=function({reference:e,id:t,expanded:a,aria:i}){const u=le(),s=l({name:"VvDropdownTriggerProvider",setup(){r($e,{reference:e,id:t,expanded:a,aria:i,bus:u})},render(){return o(n,{},this.$slots.default?.())}});return{bus:u,component:s}}({reference:ae,id:N,expanded:ge,aria:ke});Ae.on("click",Le);const{role:_e,modifiers:Ie}=s(_),Me=ot("vv-dropdown",Ie,t(()=>({arrow:_.arrow}))),{focused:Ne}=Z(V);function He(e){return e?[...e.querySelectorAll('a[href], button, input, textarea, select, details, [tabindex]:not([tabindex="-1"])')].filter(e=>!e.hasAttribute("disabled")&&!e.getAttribute("aria-hidden")):[]}function Ce(){O(()=>{const e=He(V.value);e.length>0&&e[0].focus({preventScroll:!0})})}function Be(){O(()=>{if(Ne.value){const e=He(V.value);if(0===e.length||!document.activeElement)return;const t=e.indexOf(document.activeElement);t<e.length-1?e[t+1].focus({preventScroll:!0}):e[0].focus({preventScroll:!0})}})}function Pe(){O(()=>{if(Ne.value){const e=He(V.value);if(0===e.length||!document.activeElement)return;const t=e.indexOf(document.activeElement);t>0?e[t-1].focus({preventScroll:!0}):e[e.length-1].focus({preventScroll:!0})}})}c(ge,e=>{e&&_.autofocusFirst&&Ce()}),i({toggle:Le,show:ye,hide:Ee,init:Te,focusFirst:Ce,focusFirstListElement:function(){O(()=>{const e=He(te.value);e.length>0&&e[0].focus({preventScroll:!0})})},focusNext:Be,focusPrev:Pe,customPosition:oe});const Ve=G(V),{itemRole:Re}=function({role:e,...a}){const l=t(()=>e.value===Se.listbox?we.option:we.presentation);return r(xe,{role:l,...a}),{itemRole:l}}({role:_e,expanded:ge,focused:Ne,hovered:Ve});Q("Escape",e=>{ge.value&&(e.preventDefault(),Ee())}),Q("ArrowDown",e=>{ge.value&&Ne.value&&(e.preventDefault(),Be())}),Q("ArrowUp",e=>{ge.value&&Ne.value&&(e.preventDefault(),Pe())}),Q([" ","Enter"],e=>{const t=e.target;ge.value&&Ne.value&&t&&t?.click()});const je={"before-enter":()=>{I(ge.value?"beforeExpand":"beforeCollapse"),I("beforeEnter")},"after-leave":()=>{I(ge.value?"afterExpand":"afterCollapse"),I("afterLeave")},enter:()=>{I("enter")},"after-enter":()=>{I("afterEnter")},"enter-cancelled":()=>{I("enterCancelled")},"before-leave":()=>{I("beforeLeave")},leave:()=>{I("leave")},"leave-cancelled":()=>{I("leaveCancelled")}};return(t,a)=>(f(),p(n,null,[m(e(Oe),null,{default:b(()=>[h(t.$slots,"default",g(y({init:Te,show:ye,hide:Ee,toggle:Le,expanded:e(ge),aria:e(ke)})))]),_:3}),m(S,w({name:t.transitionName},E(je),{persisted:""}),{default:b(()=>[$(x("div",{ref_key:"floatingEl",ref:V,style:T(e(ve)),class:L(e(Me))},[_.arrow?(f(),p("div",{key:0,ref_key:"arrowEl",ref:ee,style:T(e(me)),class:"vv-dropdown__arrow"},null,4)):D("v-if",!0),h(t.$slots,"before",g(y({expanded:e(ge)}))),x("div",w(e(H),{id:e(N),ref_key:"listEl",ref:te,tabindex:e(ge)?void 0:-1,role:e(_e),"aria-labelledby":e(De),class:"vv-dropdown__list"}),[h(t.$slots,"items",g(y({role:e(Re)})))],16,it),h(t.$slots,"after",g(y({expanded:e(ge)})))],6),[[k,e(ge)]])]),_:3},16,["name"])],64))}});const rt=/* @__PURE__ */l({name:"VvDropdownItem",props:tt,setup(t){const a=t,{role:l,expanded:o}=A(xe,{}),i=u(null);!function({expanded:e}){r(Le,{role:u(ye.menuitem),expanded:e})}({expanded:o});const n=G(i),{focused:s}=ee(i),{focused:d}=Z(i);return c(n,e=>{e&&a.focusOnHover&&(s.value=!0)}),(t,a)=>(f(),p("div",w({role:e(l)},{ref_key:"element",ref:i,class:["vv-dropdown__item",{"focus-visible":e(s)||e(d)}]}),[h(t.$slots,"default")],16))}}),ut=["title"],st=/* @__PURE__ */l({name:"VvDropdownOption",props:at,setup(a){const l=a,{modifiers:o}=s(l),i=ot("vv-dropdown-option",o,t(()=>({disabled:l.disabled,selected:l.selected,unselectable:l.unselectable&&l.selected}))),n=t(()=>l.selected?l.unselectable?l.deselectHintLabel:l.selectedHintLabel:l.disabled?"":l.selectHintLabel);return(t,a)=>(f(),_(rt,{class:L(e(i)),tabindex:t.disabled?-1:0,"aria-selected":t.selected,"aria-disabled":t.disabled,"focus-on-hover":t.focusOnHover},{default:b(()=>[h(t.$slots,"default"),x("span",{class:"vv-dropdown-option__hint",title:e(n)},[h(t.$slots,"hint",g(y({disabled:t.disabled,selected:t.selected,unselectable:t.unselectable})),()=>[I(M(e(n)),1)])],8,ut)]),_:3},8,["class","tabindex","aria-selected","aria-disabled","focus-on-hover"]))}});function dt(){return A(Ee,void 0)}const vt=/* @__PURE__ */l({name:"VvIcon",props:/* @__PURE__ */N({name:{},color:{},width:{},height:{},provider:{},prefix:{},src:{},horizontalFlip:{type:Boolean},verticalFlip:{type:Boolean},flip:{},mode:{},inline:{type:Boolean},rotate:{},onLoad:{type:Function},svg:{},modifiers:{}},Me),setup(a){const l=a,o=t(()=>"string"==typeof l.rotate?Number.parseFloat(l.rotate):l.rotate),i=u(!0),n=dt(),{modifiers:r}=s(l),d=ot("vv-icon",r),v=t(()=>l.provider||n?.iconsProvider),c=t(()=>{const e=l.name??"",t=`@${v.value}:${l.prefix}:${e}`;if(oe(t))return t;const a=n?.iconsCollections.find(t=>{const a=`@${v.value}:${t.prefix}:${e}`;return oe(a)});return a?`@${v.value}:${a.prefix}:${e}`:e});function p(e){const t=function(e){let t;if("undefined"==typeof window){const{JSDOM:e}=require("jsdom");t=(new e).window}return(t?new t.DOMParser:new window.DOMParser).parseFromString(e,"text/html").querySelector("svg")}(e),a=t?.innerHTML.trim()||"";t&&a&&ne(`@${v.value}:${l.prefix}:${l.name}`,{body:a,height:t.viewBox.baseVal.height,width:t.viewBox.baseVal.width})}return n&&l.src&&!oe(`@${v.value}:${l.prefix}:${l.name}`)&&(i.value=!1,n.fetchIcon(l.src).then(e=>{e&&(p(e),i.value=!0)}).catch(e=>{throw new Error(`Error during fetch icon: ${e?.message}`)})),l.svg&&p(l.svg),(t,l)=>e(i)?(f(),_(e(ie),w({key:0,class:e(d)},{inline:a.inline,width:a.width,height:a.height,horizontalFlip:a.horizontalFlip,verticalFlip:a.verticalFlip,flip:a.flip,rotate:e(o),color:a.color,icon:e(c)},{onLoad:a.onLoad}),null,16,["class","onLoad"])):D("v-if",!0)}}),ct={TEXT:"text",PASSWORD:"password",NUMBER:"number",EMAIL:"email",TEL:"tel",URL:"url",COLOR:"color",SEARCH:"search",DATE:"date",TIME:"time",DATETIME_LOCAL:"datetime-local",MONTH:"month",WEEK:"week"},pt={...Ge,...Qe,modelValue:[String,Number,Date],type:{type:String,default:ct.TEXT,validator:e=>Object.values(ct).includes(e)},min:[Number,Date,String],max:[Number,Date,String],step:{type:[String,Number],default:1},pattern:String,multiple:Boolean,iconShowPassword:{type:[String,Object],default:Te},iconHidePassword:{type:[String,Object],default:De},iconClear:{type:[String,Object],default:_e},iconRemoveSuggestion:{type:[String,Object],default:Ie},labelStepUp:{type:String,default:"Increase value"},labelStepDown:{type:String,default:"Decrease value"},labelShowPassword:{type:String,default:"Show password"},labelHidePassword:{type:String,default:"Hide password"},labelClear:{type:String,default:"Clear"},labelRemoveSuggestion:{type:String,default:"Remove suggestion"},iMask:{type:Object,default:void 0},masked:{type:String,default:void 0},autoWidth:{type:Boolean,default:!1},hideActions:{type:Boolean,default:!1},unit:{type:String},selectOnFocus:{type:Boolean,default:!1},maxSuggestions:{type:Number,default:5},inputMode:{type:String,default:"text"}};function ft(e,a){const l=t(()=>"string"==typeof e?.value?{name:e?.value}:e?.value),o=t(()=>a?.value===be.before?l.value:void 0),i=t(()=>a?.value===be.after?l.value:void 0),n=t(()=>a?.value===fe.left?l.value:void 0),r=t(()=>a?.value===fe.right?l.value:void 0),u=t(()=>a?.value===fe.top?l.value:void 0),s=t(()=>a?.value===fe.bottom?l.value:void 0);return{hasIcon:l,hasIconLeft:n,hasIconRight:r,hasIconTop:u,hasIconBottom:s,hasIconBefore:o,hasIconAfter:i}}const mt=l({components:{VvIcon:vt},props:{inputType:{type:String,default:"input-text"},disabled:{type:Boolean,default:!1},label:{type:String,default:"Clear"},icon:{type:[String,Object],default:"close"}},emits:["clear"],setup(e,{emit:a}){const{hasIcon:l}=ft(t(()=>e.icon));return{hasIcon:l,onClick:function(t){t?.stopPropagation(),e.disabled||a("clear")}}},render(){const e=this.hasIcon?o(vt,{...this.hasIcon,class:`vv-${this.inputType}__icon`}):void 0;return o("button",{disabled:this.disabled,class:`vv-${this.inputType}__action`,ariaLabel:this.label,type:"button",onClick:this.onClick},e)}}),bt=l({components:{VvIcon:vt},props:{inputType:{type:String,default:"input-text"},disabled:{type:Boolean,default:!1},labelShow:{type:String,default:"Show password"},labelHide:{type:String,default:"Hide password"},iconShow:{type:[String,Object],default:Te},iconHide:{type:[String,Object],default:De}},emits:["toggle-password"],setup(e,{emit:a}){const l=u(!1),o=t(()=>l.value?e.iconHide:e.iconShow),{hasIcon:i}=ft(o);return{active:l,activeIcon:o,hasIcon:i,onClick:function(t){t?.stopPropagation(),e.disabled||(l.value=!l.value,a("toggle-password",l.value))}}},render(){const e=this.hasIcon?o(vt,{...this.hasIcon,class:`vv-${this.inputType}__icon`}):void 0;return o("button",{disabled:this.disabled,class:`vv-${this.inputType}__action`,ariaLabel:this.active?this.labelHide:this.labelShow,type:"button",onClick:this.onClick},e)}}),ht=l({components:{VvIcon:vt},props:{inputType:{type:String,default:"input-text"},disabled:{type:Boolean,default:!1},label:{type:String},mode:{type:String,validator:e=>["up","down"].includes(e),default:"up"}},emits:["step-up","step-down"],setup(e,{emit:a}){const l=t(()=>"up"===e.mode);return{isUp:l,onClick:t=>{t?.stopPropagation(),e.disabled||a(l.value?"step-up":"step-down")}}},render(){return o("button",{class:[`vv-${this.inputType}__action`,`vv-${this.inputType}__action-chevron`,this.isUp?`vv-${this.inputType}__action-chevron-up`:void 0],disabled:this.disabled,ariaLabel:this.label,type:"button",onClick:this.onClick})}});function gt(e,a,l){return{name:"VvInputTextActions",components:{VvIcon:vt,VvInputPasswordAction:bt,VvInputStepAction:ht,VvInputClearAction:mt},setup(){const e=t(()=>a.disabled||a.readonly);return{isDirty:l,isDisabled:e,labelStepUp:a.labelStepUp,labelStepDown:a.labelStepDown,labelShowPassword:a.labelShowPassword,labelHidePassword:a.labelHidePassword,labelClear:a.labelClear,iconShowPassword:a.iconShowPassword,iconHidePassword:a.iconHidePassword}},render(){let t=null;switch(e){case ct.SEARCH:{const{onClear:e}=this.$attrs;t=[o(mt,{disabled:this.isDisabled||!this.isDirty,label:this.labelClear,onClear:e})];break}case ct.PASSWORD:{const{onTogglePassword:e}=this.$attrs;t=[o(bt,{disabled:this.isDisabled,onTogglePassword:e,labelShow:this.labelShowPassword,labelHide:this.labelHidePassword,iconShow:this.iconShowPassword,iconHide:this.iconHidePassword})];break}case ct.NUMBER:{const{onStepUp:e,onStepDown:l}=this.$attrs;t=[o(ht,{mode:"up",disabled:this.isDisabled||void 0!==a.max&&a.modelValue===a.max,label:this.labelStepUp,onStepUp:e,onStepDown:l}),o(ht,{mode:"down",disabled:this.isDisabled||void 0!==a.min&&a.modelValue===a.min,label:this.labelStepDown,onStepUp:e,onStepDown:l})];break}}return Array.isArray(t)?o("div",{class:"vv-input-text__actions-group"},t):t}}}const yt=["for"],St={key:0,class:"vv-input-text__input-before"},wt=["id"],Et={key:1,class:"vv-input-text__unit"},$t={key:5,class:"vv-input-text__input-after"},xt={key:6,class:"vv-input-text__limit"},Lt={class:"flex-1"},Tt=["title","onClick"],Dt=/* @__PURE__ */l({name:"VvInputText",props:pt,emits:["update:modelValue","update:masked","accept","accept:typed","accept:masked","accept:unmasked","complete","complete:typed","complete:masked","complete:unmasked","suggestion:selected","suggestion:removed","focus","blur","keyup","keydown","keypress","clear"],setup(i,{expose:r,emit:d}){const S=i,E=d,$=H(),T=dt(),k=function(e,a,l){const o=dt(),i=t(()=>{if(o&&o.defaults.value?.[e])return o.defaults.value[e]});return t(()=>{if(void 0===i.value)return l;const e=i.value,t=a,o=l;return Object.keys(t).reduce((a,l)=>{const i=o[l];if(a[l]=i,l in e){if(Array.isArray(t[l])){const o=t[l];o.length&&o[0]===i&&(a[l]=e[l])}if("function"==typeof t[l]&&(0,t[l])()===i&&(a[l]=e[l]),"object"==typeof t[l]){let o=t[l].default;"function"==typeof o&&(o=o()),"object"==typeof o?JSON.stringify(o)===JSON.stringify(i)&&(a[l]=e[l]):o===i&&(a[l]=e[l])}}return a},{})})}("VvInputText",pt,S),{count:O,debounce:A,icon:N,iconPosition:R,iconRemoveSuggestion:j,id:U,invalid:F,label:Y,loading:W,maxlength:z,minlength:q,modelValue:K,step:X,storageType:J,type:Z,valid:G}=s(S),Q=lt(U),le=t(()=>`${Q.value}-hint`),oe=t(()=>S.floating&&de(S.placeholder)?" ":S.placeholder),ie=function(e,a,l=0,{getter:o=e=>e,setter:i=e=>e}={}){let n;return"string"==typeof l&&(l=Number.parseInt(l)),t({get:()=>o(e?.value),set:e=>{n&&clearTimeout(n),n=setTimeout(()=>{a("update:modelValue",i(e))},l)}})}(K,E,A?.value??0),ne=t(()=>{const e="number"==typeof X.value?X.value:Number.parseInt(X.value);return!Number.isNaN(e)&&e%60!=0}),pe=/^-0?[.,]?[0*]?$/,fe=u(!1),me=u(),be=u(),{el:he,mask:ge,typed:ye,masked:Se,unmasked:we}=V(t(()=>{if(!S.iMask)return{mask:/./};if(S.iMask.mask===Number){const e={...S.iMask};return S.min&&(e.min=Number(S.min)),S.max&&(e.max=Number(S.max)),e}return S.iMask}),{emit:E,onAccept:()=>{if(fe.value){if(E("update:masked",Se.value),Z.value===ct.NUMBER){if(/^-$|^$/.test(we.value)){if(null===ie.value||void 0===ie.value)return;return void(ie.value=void 0)}return pe.test(we.value)?void(ie.value=0):"number"!=typeof ye.value?void(ie.value=Number(ye.value)):void(ie.value=ye.value)}if(Z.value===ct.DATETIME_LOCAL||Z.value===ct.DATE||Z.value===ct.TIME||Z.value===ct.MONTH){if(!ye.value){if(!ie.value)return;return me.value?void(ie.value=void 0):void(ie.value="")}if(!(ye.value instanceof Date||me.value||be.value))return void(ie.value=ye.value);let e=ye.value;if(e instanceof Date||(e=function(e,t="date"){if(!e?.trim())return null;const a=/* @__PURE__ */new Date,l=a.getFullYear(),o=a.getMonth(),i=a.getDate();if("date"===t){if(!/^\d{4}-\d{2}-\d{2}$/.test(e))throw new Error("Invalid date format. Expected: YYYY-MM-DD");/* @__PURE__ */
2
+ return new Date(`${e}T00:00:00`)}if("month"===t){if(!/^\d{4}-\d{2}$/.test(e))throw new Error("Invalid month format. Expected: YYYY-MM");/* @__PURE__ */
3
+ return new Date(`${e}-01T00:00:00`)}if("time"===t){if(!/^(?:[01]\d|2[0-3]):[0-5]\d(?::[0-5]\d)?$/.test(e))throw new Error("Invalid time format. Expected: HH:mm or HH:mm:ss");return 8===e.length?/* @__PURE__ */new Date(`${l}-${re(o+1)}-${re(i)}T${e}`):/* @__PURE__ */new Date(`${l}-${re(o+1)}-${re(i)}T${e}:00`)}if(!/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}(?::\d{2})?$/.test(e))throw new Error("Invalid datetime format. Expected: YYYY-MM-DDThh:mm or YYYY-MM-DDThh:mm:ss");return 16===e.length?/* @__PURE__ */new Date(`${e}:00`):/* @__PURE__ */new Date(`${e}`)}(ye.value,Z.value)),me.value||be.value){const t=new Date(me.value||be.value);if(Z.value!==ct.DATETIME_LOCAL&&Z.value!==ct.DATE&&Z.value!==ct.MONTH||(t.setFullYear(e.getFullYear()),t.setMonth(e.getMonth())),Z.value!==ct.DATETIME_LOCAL&&Z.value!==ct.DATE||t.setDate(e.getDate()),Z.value!==ct.DATETIME_LOCAL&&Z.value!==ct.TIME||(t.setHours(e.getHours()),t.setMinutes(e.getMinutes()),t.setSeconds(e.getSeconds())),me.value instanceof Date){if(ie.value?.getTime()===t.getTime())return;return void(ie.value=t)}return void(ie.value=t.toISOString())}return void(ie.value=se(e,Z.value,ne.value))}(ie.value||we.value)&&(ie.value=we.value)}}});function Ee(e){if(null==e)return ye.value="",void(we.value="");if(S.iMask?.mask!==Date){if(Z.value!==ct.NUMBER||!pe.test(we.value)||0!==e){if(Z.value===ct.DATE||Z.value===ct.MONTH||Z.value===ct.DATETIME_LOCAL||Z.value===ct.TIME){if(e instanceof Date||ue(e)){e instanceof Date?(me.value=e,be.value=void 0):(be.value=e,me.value=void 0);const t=new Date(e);return ye.value=se(t,Z.value,ne.value),void(we.value=ye.value)}me.value=void 0,be.value=void 0}ye.value=e,we.value=`${ye.value}`}}else ye.value=e instanceof Date?e:new Date(e)}v(()=>{ge.value&&(fe.value=!0,Ee(S.modelValue))}),c(()=>S.modelValue,e=>{ge.value&&Ee(e)}),c(()=>S.masked,e=>{Se.value=e??""});const $e=he,xe=u(),Le=u(),Te=u();r({$inner:xe});const{focused:De}=function(t,a){const{focused:l}=ee(t);return c(l,l=>{a(l?"focus":"blur",e(t))}),{focused:l}}($e,E),_e=t(()=>De.value&&!S.disabled&&!S.readonly);c(_e,e=>{if(e&&k.value.selectOnFocus&&$e.value&&$e.value.select(),e&&Ge.value?.size)Te.value?.show();else if(Xe.value&&Ge.value){const e=S.maxSuggestions;Ge.value.size>=e&&!Ge.value.has(ie.value)&&(Ge.value=new Set([...Ge.value].slice(Ge.value.size-e+1))),Ge.value.add(ie.value)}});const Ie=ae($e);c(Ie,e=>{e&&S.autofocus&&!S.disabled&&!S.readonly&&(De.value=!0)});const Me=u(!1),Ne=t(()=>S.type===ct.PASSWORD);function He(){Me.value=!Me.value}const Ce=t(()=>S.type===ct.TIME||S.type===ct.DATETIME_LOCAL||S.type===ct.DATE||S.type===ct.WEEK||S.type===ct.MONTH),Be=t(()=>S.type===ct.NUMBER);function Pe(){if(!qe.value){if(S.iMask)return void(ye.value=Number(ye.value)+Number(X?.value??1));$e.value.stepUp(),ie.value=Number(e($e).value)}}function Ve(){if(!qe.value){if(S.iMask)return void(ye.value=Number(ye.value)-Number(X?.value??1));$e.value.stepDown(),ie.value=Number(e($e).value)}}const Re=t(()=>S.type===ct.SEARCH);function je(){ie.value="",E("clear")}const{hasIconBefore:Ue,hasIconAfter:Fe}=ft(N,R),Ye=t(()=>{if(void 0!==Fe.value)return Fe.value;switch(S.type){case ct.COLOR:return{name:Ae};case ct.DATE:case ct.DATETIME_LOCAL:case ct.WEEK:case ct.MONTH:return{name:ke};case ct.TIME:return{name:Oe}}}),{hasIcon:We}=ft(j),{formatted:ze}=function(a,l){const o=t(()=>(e(a)??"").length),i=t(()=>void 0!==l?.lowerLimit&&o.value<l?.lowerLimit?o.value-l.lowerLimit:void 0!==l?.upperLimit&&o.value<l?.upperLimit?l.upperLimit-o.value:0),n=t(()=>{if(!1===l?.mode)return"";if("limit"===l?.mode&&l?.upperLimit)return`${o.value} / ${l.lowerLimit?`${l.lowerLimit}-`:""}${l.upperLimit}`;if("countdown"===l?.mode){if(0===i.value)return;return i}return o.value});return{length:o,gap:i,formatted:n}}(ie,{mode:O.value,upperLimit:Number(z?.value),lowerLimit:Number(q?.value)}),qe=t(()=>S.disabled||S.readonly),Ke=t(()=>qe.value?-1:S.tabindex),Xe=t(()=>!de(K)),Je=t(()=>!0===F.value||!0!==G.value&&void 0),Ze=t(()=>S.storageKey??(T?.experimentalFeatures.forceInputSuggestions?S.name:void 0)),Ge=function(t,l=ce.local,o){const i=u();let n;return o&&(i.value=o),v(()=>{t&&c(t,(t,a)=>{const o=e(l)===ce.session?sessionStorage:localStorage;if(a&&a!==t&&o.removeItem(a),t)return n=te(t,n?.value??i.value,o),void(n.value&&(i.value=n.value));n=void 0},{immediate:!0}),a(l)&&c(l,(e,a)=>{if(t?.value){if(e){const a=e===ce.session?sessionStorage:localStorage;n=te(t.value,n?.value??i.value,a)}a&&a!==e&&(a===ce.session?sessionStorage:localStorage).removeItem(t.value)}})}),c(i,e=>{n&&(n.value=e)},{deep:!0,immediate:!0}),i}(Ze,J,
4
+ /* @__PURE__ */new Set),Qe=t(()=>Ge.value?[...Ge.value].filter(e=>de(ie.value)||`${e}`.toLowerCase().includes(`${ie.value}`.toLowerCase())&&e!==ie.value).reverse():[]),et=t(()=>Ze?.value&&Ge.value&&Ge.value.size>0);const{modifiers:tt}=s(S),at=ot("vv-input-text",tt,t(()=>({valid:G.value,invalid:F.value,loading:W.value,disabled:S.disabled,required:S.required,readonly:S.readonly,"icon-before":!!Ue.value,"icon-after":!!Ye.value,floating:S.floating&&!de(S.label),dirty:Xe.value,focus:_e.value&&!qe.value,"auto-width":S.autoWidth}))),it=t(()=>{const e=Ne.value&&Me.value?ct.TEXT:!Ce.value||Xe.value||De.value?S.iMask?ct.TEXT:S.type:ct.TEXT,t={type:e,name:S.name,tabindex:Ke.value,disabled:S.disabled,readonly:S.readonly,required:S.required,autocomplete:S.autocomplete,"aria-invalid":Je.value,"aria-describedby":mt.value?le.value:void 0,"aria-errormessage":bt.value?le.value:void 0,inputMode:S.inputMode};if(e===ct.DATE||e===ct.MONTH||e===ct.WEEK||e===ct.TIME||e===ct.DATETIME_LOCAL||e===ct.NUMBER){let a=S.max;e!==ct.DATE||a||(a="9999-12-31"),t.step=S.step,t.max=void 0!==a?String(a):void 0,t.min=void 0!==S.min?String(S.min):void 0}return e!==ct.TEXT&&e!==ct.SEARCH&&e!==ct.URL&&e!==ct.TEL&&e!==ct.EMAIL&&e!==ct.PASSWORD&&e!==ct.NUMBER||(t.placeholder=oe.value),e!==ct.TEXT&&e!==ct.SEARCH&&e!==ct.URL&&e!==ct.TEL&&e!==ct.EMAIL&&e!==ct.PASSWORD||(t.minlength=S.minlength,t.maxlength=S.maxlength,t.pattern=S.pattern),e===ct.EMAIL&&(t.multiple=S.multiple),t}),rt=t(()=>({valid:S.valid,invalid:S.invalid,modelValue:S.modelValue,togglePassword:He,stepUp:Pe,stepDown:Ve,clear:je})),{HintSlot:ut,hasHintLabelOrSlot:mt,hasInvalidLabelOrSlot:bt,hintSlotScope:ht}=function(e,i){const n=t(()=>a(e)?e.value:e),r=t(()=>ve(n.value.invalidLabel)),u=t(()=>ve(n.value.validLabel)),s=t(()=>n.value.loadingLabel),d=t(()=>n.value.hintLabel),v=t(()=>Boolean(n.value.loading&&(i.loading||s.value))),c=t(()=>!v.value&&Boolean(n.value.invalid&&(i.invalid||r.value))),p=t(()=>!v.value&&!c.value&&Boolean(n.value.valid&&(i.valid||u.value))),f=t(()=>!v.value&&!c.value&&!p.value&&Boolean(i.hint||d.value)),m=t(()=>c.value||p.value||v.value||f.value),b=t(()=>({modelValue:n.value.modelValue,valid:n.value.valid,invalid:n.value.invalid,loading:n.value.loading})),h=l({name:"HintSlot",props:{tag:{type:String,default:"small"}},setup:()=>({isVisible:m,invalidLabel:r,validLabel:u,loadingLabel:s,hintLabel:d,hasInvalidLabelOrSlot:c,hasValidLabelOrSlot:p,hasLoadingLabelOrSlot:v,hasHintLabelOrSlot:f}),render(){if(this.isVisible){let e;return this.hasInvalidLabelOrSlot&&(e="alert"),this.hasValidLabelOrSlot&&(e="status"),this.hasLoadingLabelOrSlot?o(this.tag,{role:e},this.$slots.loading?.()??this.loadingLabel):this.hasInvalidLabelOrSlot?o(this.tag,{role:e},this.$slots.invalid?.()??this.$slots.invalid??this.invalidLabel):this.hasValidLabelOrSlot?o(this.tag,{role:e},this.$slots.valid?.()??this.validLabel):o(this.tag,{role:e},this.$slots.hint?.()??this.$slots.hint??this.hintLabel)}return null}});return{hasInvalidLabelOrSlot:c,hasHintLabelOrSlot:f,hasValidLabelOrSlot:p,hasLoadingLabelOrSlot:v,hintSlotScope:b,HintSlot:h}}(k,$),Dt=gt(ct.PASSWORD,S,Xe),kt=gt(ct.NUMBER,S,Xe),Ot=gt(ct.SEARCH,S,Xe);function At(){qe.value||(De.value=!0)}const _t=t(()=>{if(S.autoWidth)return{width:void 0!==ie.value?`${String(ie.value).length+1}ch`:void 0}});function It(e){switch(e.code){case"ArrowUp":Be.value&&(Pe(),e.preventDefault());break;case"ArrowDown":Be.value&&(Ve(),e.preventDefault())}E("keydown",e)}return(t,a)=>(f(),p("div",{class:L(e(at))},[e(Y)?(f(),p("label",{key:0,for:e(Q),class:"vv-input-text__label"},M(e(Y)),9,yt)):D("v-if",!0),x("div",{ref_key:"wrapperEl",ref:Le,class:"vv-input-text__wrapper"},[t.$slots.before?(f(),p("div",St,[h(t.$slots,"before",g(y(e(rt))))])):D("v-if",!0),x("div",{ref_key:"innerEl",ref:xe,class:"vv-input-text__inner",onClick:C(At,["stop"])},[e(Ue)?(f(),_(vt,w({key:0},e(Ue),{class:"vv-input-text__icon"}),null,16)):D("v-if",!0),x("input",w({id:e(Q),ref_key:"inputEl",ref:$e},e(it),{style:e(_t),onKeyup:a[0]||(a[0]=e=>E("keyup",e)),onKeydown:It,onKeypress:a[1]||(a[1]=e=>E("keypress",e))}),null,16,wt),(t.unit||t.$slots.unit)&&e(Xe)?(f(),p("div",Et,[h(t.$slots,"unit",g(y(e(rt))),()=>[I(M(t.unit),1)])])):D("v-if",!0)],512),e(Ye)?(f(),_(vt,w({key:1},e(Ye),{class:"vv-input-text__icon vv-input-text__icon-after"}),null,16)):!e(Ne)||t.hideActions||e(qe)?!e(Be)||t.hideActions||e(qe)?!e(Re)||t.hideActions||e(qe)?D("v-if",!0):(f(),_(e(Ot),{key:4,onClear:je})):(f(),_(e(kt),{key:3,onStepUp:Pe,onStepDown:Ve})):(f(),_(e(Dt),{key:2,onTogglePassword:He})),t.$slots.after?(f(),p("div",$t,[h(t.$slots,"after",g(y(e(rt))))])):D("v-if",!0),e(O)?(f(),p("span",xt,[h(t.$slots,"count",g(y(e(rt))),()=>[I(M(e(ze)),1)])])):D("v-if",!0)],512),m(e(ut),{id:e(le),class:"vv-input-text__hint"},B({_:2},[t.$slots.hint?{name:"hint",fn:b(()=>[h(t.$slots,"hint",g(y(e(ht))))]),key:"0"}:void 0,t.$slots.loading?{name:"loading",fn:b(()=>[h(t.$slots,"loading",g(y(e(ht))))]),key:"1"}:void 0,t.$slots.valid?{name:"valid",fn:b(()=>[h(t.$slots,"valid",g(y(e(ht))))]),key:"2"}:void 0,t.$slots.invalid?{name:"invalid",fn:b(()=>[h(t.$slots,"invalid",g(y(e(ht))))]),key:"3"}:void 0]),1032,["id"]),e(et)?(f(),_(nt,{key:1,ref_key:"suggestionsDropdownEl",ref:Te,reference:e(Le),"autofocus-first":!1,"trigger-width":!0},{items:b(()=>[(f(!0),p(n,null,P(e(Qe),a=>(f(),_(st,{key:a,onClick:C(e=>{return t=a,ie.value=t,Te.value?.hide(),void E("suggestion:selected",t);var t},["stop"])},{default:b(()=>[x("div",Lt,[h(t.$slots,"suggestion",w({ref_for:!0},{value:a}),()=>[I(M(a),1)])]),e(Ge)&&e(We)?(f(),p("button",{key:0,type:"button",tabindex:"-1",class:"cursor-pointer",title:t.labelRemoveSuggestion,onClick:C(e=>{return t=a,Ge.value?.delete(t),void E("suggestion:removed",t);var t},["stop"])},[m(vt,w({ref_for:!0},e(We)),null,16)],8,Tt)):D("v-if",!0)]),_:2},1032,["onClick"]))),128))]),_:3},8,["reference"])):D("v-if",!0)],2))}});export{Dt as default};