@volverjs/ui-vue 0.0.11 → 0.0.13-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (98) 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 +7 -2
  4. package/dist/components/VvAccordionGroup/VvAccordionGroup.es.js +2 -702
  5. package/dist/components/VvAccordionGroup/VvAccordionGroup.vue.d.ts +5 -2
  6. package/dist/components/VvAction/VvAction.es.js +1 -302
  7. package/dist/components/VvAction/VvAction.umd.js +1 -1
  8. package/dist/components/VvAction/VvAction.vue.d.ts +3 -2
  9. package/dist/components/VvAlert/VvAlert.es.js +1 -527
  10. package/dist/components/VvAlert/VvAlert.vue.d.ts +3 -2
  11. package/dist/components/VvAlertGroup/VvAlertGroup.es.js +1 -730
  12. package/dist/components/VvAlertGroup/VvAlertGroup.vue.d.ts +3 -3
  13. package/dist/components/VvAvatar/VvAvatar.es.js +1 -132
  14. package/dist/components/VvAvatar/VvAvatar.vue.d.ts +2 -2
  15. package/dist/components/VvAvatarGroup/VvAvatarGroup.es.js +1 -250
  16. package/dist/components/VvAvatarGroup/VvAvatarGroup.vue.d.ts +2 -2
  17. package/dist/components/VvBadge/VvBadge.es.js +1 -131
  18. package/dist/components/VvBadge/VvBadge.vue.d.ts +2 -2
  19. package/dist/components/VvBreadcrumb/VvBreadcrumb.es.js +1 -410
  20. package/dist/components/VvBreadcrumb/VvBreadcrumb.umd.js +1 -1
  21. package/dist/components/VvBreadcrumb/VvBreadcrumb.vue.d.ts +2 -2
  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 +3 -2
  25. package/dist/components/VvButtonGroup/VvButtonGroup.es.js +1 -214
  26. package/dist/components/VvButtonGroup/VvButtonGroup.vue.d.ts +2 -2
  27. package/dist/components/VvCard/VvCard.es.js +1 -152
  28. package/dist/components/VvCard/VvCard.vue.d.ts +2 -2
  29. package/dist/components/VvCheckbox/VvCheckbox.es.js +1 -741
  30. package/dist/components/VvCheckbox/VvCheckbox.vue.d.ts +2 -2
  31. package/dist/components/VvCheckboxGroup/VvCheckboxGroup.es.js +1 -981
  32. package/dist/components/VvCheckboxGroup/VvCheckboxGroup.vue.d.ts +2 -2
  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 +16 -7
  36. package/dist/components/VvDialog/VvDialog.es.js +1 -317
  37. package/dist/components/VvDialog/VvDialog.vue.d.ts +4 -2
  38. package/dist/components/VvDropdown/VvDropdown.es.js +1 -750
  39. package/dist/components/VvDropdown/VvDropdown.vue.d.ts +14 -2
  40. package/dist/components/VvDropdown/VvDropdownAction.vue.d.ts +2 -2
  41. package/dist/components/VvDropdown/VvDropdownItem.vue.d.ts +2 -2
  42. package/dist/components/VvDropdown/VvDropdownOptgroup.vue.d.ts +11 -4
  43. package/dist/components/VvDropdown/VvDropdownOption.vue.d.ts +2 -2
  44. package/dist/components/VvDropdownAction/VvDropdownAction.es.js +1 -448
  45. package/dist/components/VvDropdownAction/VvDropdownAction.umd.js +1 -1
  46. package/dist/components/VvDropdownItem/VvDropdownItem.es.js +1 -149
  47. package/dist/components/VvDropdownOptgroup/VvDropdownOptgroup.es.js +1 -104
  48. package/dist/components/VvDropdownOptgroup/VvDropdownOptgroup.umd.js +1 -1
  49. package/dist/components/VvDropdownOption/VvDropdownOption.es.js +1 -281
  50. package/dist/components/VvIcon/VvIcon.es.js +1 -143
  51. package/dist/components/VvIcon/VvIcon.vue.d.ts +2 -2
  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 +34 -4
  55. package/dist/components/VvInputFile/index.d.ts +7 -0
  56. package/dist/components/VvInputText/VvInputText.es.js +4 -2790
  57. package/dist/components/VvInputText/VvInputText.umd.js +1 -1
  58. package/dist/components/VvInputText/VvInputText.vue.d.ts +8 -3
  59. package/dist/components/VvNav/VvNav.es.js +1 -438
  60. package/dist/components/VvNav/VvNav.umd.js +1 -1
  61. package/dist/components/VvNav/VvNav.vue.d.ts +2 -2
  62. package/dist/components/VvNav/VvNavItem.vue.d.ts +2 -2
  63. package/dist/components/VvNav/VvNavSeparator.vue.d.ts +1 -1
  64. package/dist/components/VvNavItem/VvNavItem.es.js +1 -337
  65. package/dist/components/VvNavItem/VvNavItem.umd.js +1 -1
  66. package/dist/components/VvNavSeparator/VvNavSeparator.es.js +1 -24
  67. package/dist/components/VvProgress/VvProgress.es.js +1 -163
  68. package/dist/components/VvProgress/VvProgress.vue.d.ts +2 -2
  69. package/dist/components/VvRadio/VvRadio.es.js +1 -661
  70. package/dist/components/VvRadio/VvRadio.vue.d.ts +2 -2
  71. package/dist/components/VvRadioGroup/VvRadioGroup.es.js +1 -901
  72. package/dist/components/VvRadioGroup/VvRadioGroup.vue.d.ts +2 -2
  73. package/dist/components/VvSelect/VvSelect.es.js +1 -1103
  74. package/dist/components/VvSelect/VvSelect.vue.d.ts +11 -7
  75. package/dist/components/VvTab/VvTab.es.js +1 -558
  76. package/dist/components/VvTab/VvTab.umd.js +1 -1
  77. package/dist/components/VvTab/VvTab.vue.d.ts +2 -2
  78. package/dist/components/VvTextarea/VvTextarea.es.js +2 -1989
  79. package/dist/components/VvTextarea/VvTextarea.vue.d.ts +3 -3
  80. package/dist/components/VvTooltip/VvTooltip.es.js +1 -154
  81. package/dist/components/VvTooltip/VvTooltip.vue.d.ts +2 -2
  82. package/dist/components/index.es.js +6 -8558
  83. package/dist/components/index.umd.js +1 -1
  84. package/dist/composables/index.es.js +2 -247
  85. package/dist/composables/index.umd.js +1 -1
  86. package/dist/directives/index.es.js +2 -311
  87. package/dist/directives/index.umd.js +1 -1
  88. package/dist/directives/v-contextmenu.es.js +2 -142
  89. package/dist/directives/v-contextmenu.umd.js +1 -1
  90. package/dist/directives/v-tooltip.es.js +1 -172
  91. package/dist/icons.es.js +1 -39
  92. package/dist/icons.umd.js +1 -1
  93. package/dist/index.es.js +1 -219
  94. package/dist/props/index.d.ts +7 -0
  95. package/dist/resolvers/unplugin.es.js +1 -187
  96. package/dist/stories/AccordionGroup/AccordionGroupSlots.stories.d.ts +2 -2
  97. package/dist/stories/Avatar/Avatar.settings.d.ts +1 -1
  98. package/package.json +47 -40
@@ -1,1704 +1 @@
1
- import { computed, isRef, defineComponent, h, inject, toRef, toRefs, getCurrentInstance, ref, watch, resolveComponent, createBlock, openBlock, resolveDynamicComponent, unref, mergeProps, withCtx, renderSlot, createTextVNode, toDisplayString, mergeDefaults, createCommentVNode, useId, useAttrs, useSlots, createElementBlock, Fragment, onBeforeUnmount, normalizeClass, createElementVNode, createVNode, withModifiers, normalizeProps, guardReactiveProps, createSlots } from "vue";
2
- import { useVModel } from "@vueuse/core";
3
- import Sortable from "vuedraggable";
4
- import { iconLoaded, Icon, addIcon } from "@iconify/vue";
5
- const ACTION_ICONS = {
6
- add: "add",
7
- edit: "edit",
8
- download: "download"
9
- };
10
- const VvIconPropsDefaults = {
11
- prefix: "normal"
12
- /* normal */
13
- };
14
- var StorageType = /* @__PURE__ */ ((StorageType2) => {
15
- StorageType2["local"] = "local";
16
- StorageType2["session"] = "session";
17
- return StorageType2;
18
- })(StorageType || {});
19
- var Side = /* @__PURE__ */ ((Side2) => {
20
- Side2["left"] = "left";
21
- Side2["right"] = "right";
22
- Side2["top"] = "top";
23
- Side2["bottom"] = "bottom";
24
- return Side2;
25
- })(Side || {});
26
- var Position = /* @__PURE__ */ ((Position2) => {
27
- Position2["before"] = "before";
28
- Position2["after"] = "after";
29
- return Position2;
30
- })(Position || {});
31
- var ButtonType = /* @__PURE__ */ ((ButtonType2) => {
32
- ButtonType2["button"] = "button";
33
- ButtonType2["submit"] = "submit";
34
- ButtonType2["reset"] = "reset";
35
- return ButtonType2;
36
- })(ButtonType || {});
37
- var ActionTag = /* @__PURE__ */ ((ActionTag2) => {
38
- ActionTag2["nuxtLink"] = "nuxt-link";
39
- ActionTag2["routerLink"] = "router-link";
40
- ActionTag2["a"] = "a";
41
- ActionTag2["button"] = "button";
42
- return ActionTag2;
43
- })(ActionTag || {});
44
- const INJECTION_KEY_VOLVER = Symbol.for("volver");
45
- const INJECTION_KEY_BUTTON_GROUP = Symbol.for(
46
- "buttonGroup"
47
- );
48
- const INJECTION_KEY_DROPDOWN_TRIGGER = Symbol.for(
49
- "dropdownTrigger"
50
- );
51
- const INJECTION_KEY_DROPDOWN_ACTION = Symbol.for(
52
- "dropdownAction"
53
- );
54
- const LinkProps = {
55
- /**
56
- * The router-link/nuxt-link property, if it is defined the button is rendered as a ruouter-link or nuxt-link.
57
- * @see Documentation of [router-link](https://router.vuejs.org/api/#router-link) and [nuxt-link](https://nuxtjs.org/api/components-nuxt-link/)
58
- */
59
- to: {
60
- type: [String, Object]
61
- },
62
- /**
63
- * Anchor href
64
- */
65
- href: String,
66
- /**
67
- * Anchor target
68
- */
69
- target: String,
70
- /**
71
- * Anchor rel
72
- */
73
- rel: {
74
- type: String,
75
- default: "noopener noreferrer"
76
- }
77
- };
78
- const ValidProps = {
79
- /**
80
- * Valid status
81
- */
82
- valid: { type: Boolean, default: false },
83
- /**
84
- * Valid label
85
- */
86
- validLabel: { type: [String, Array], default: void 0 }
87
- };
88
- const InvalidProps = {
89
- /**
90
- * Invalid status
91
- */
92
- invalid: {
93
- type: Boolean,
94
- default: false
95
- },
96
- /**
97
- * Invalid label
98
- */
99
- invalidLabel: { type: [String, Array], default: void 0 }
100
- };
101
- const LoadingProps = {
102
- /**
103
- * Loading status
104
- */
105
- loading: {
106
- type: Boolean,
107
- default: false
108
- },
109
- /**
110
- * Loading label
111
- */
112
- loadingLabel: {
113
- type: String,
114
- default: "Loading..."
115
- }
116
- };
117
- const DisabledProps = {
118
- /**
119
- * Whether the form control is disabled
120
- */
121
- disabled: {
122
- type: Boolean,
123
- default: false
124
- }
125
- };
126
- const RequiredProps = {
127
- /**
128
- * Whether the form control is required
129
- */
130
- required: {
131
- type: Boolean,
132
- default: false
133
- }
134
- };
135
- const ActiveProps = {
136
- /**
137
- * Whether the item is active
138
- */
139
- active: {
140
- type: Boolean,
141
- default: false
142
- }
143
- };
144
- const CurrentProps = {
145
- /**
146
- * Whether the item is current
147
- */
148
- current: {
149
- type: Boolean,
150
- default: false
151
- }
152
- };
153
- const PressedProps = {
154
- /**
155
- * Whether the item is pressed
156
- */
157
- pressed: {
158
- type: Boolean,
159
- default: false
160
- }
161
- };
162
- const LabelProps = {
163
- /**
164
- * The item label
165
- */
166
- label: {
167
- type: [String, Number],
168
- default: void 0
169
- }
170
- };
171
- const ReadonlyProps = {
172
- /**
173
- * The value is not editable
174
- */
175
- readonly: {
176
- type: Boolean,
177
- default: false
178
- }
179
- };
180
- const ModifiersProps = {
181
- /**
182
- * Component BEM modifiers
183
- */
184
- modifiers: {
185
- type: [String, Array],
186
- default: void 0
187
- }
188
- };
189
- const HintProps = {
190
- hintLabel: { type: String, default: "" }
191
- };
192
- const IconProps = {
193
- /**
194
- * VvIcon name or props
195
- * @see VvIcon
196
- */
197
- icon: {
198
- type: [String, Object],
199
- default: void 0
200
- },
201
- /**
202
- * VvIcon position
203
- */
204
- iconPosition: {
205
- type: String,
206
- default: Position.before,
207
- validation: (value) => Object.values(Position).includes(value)
208
- }
209
- };
210
- const UnselectableProps = {
211
- /**
212
- * If true the input will be unselectable
213
- */
214
- unselectable: { type: Boolean, default: true }
215
- };
216
- const IdProps = {
217
- /**
218
- * Global attribute id
219
- * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/id
220
- */
221
- id: [String, Number]
222
- };
223
- ({
224
- /**
225
- * Dropdown placement
226
- */
227
- placement: {
228
- default: Side.bottom
229
- }
230
- });
231
- const IdNameProps = {
232
- ...IdProps,
233
- /**
234
- * Input / Textarea name
235
- * Name of the form control. Submitted with the form as part of a name/value pair
236
- * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#name
237
- */
238
- name: { type: String, required: true }
239
- };
240
- const ActionProps = {
241
- ...DisabledProps,
242
- ...LabelProps,
243
- ...PressedProps,
244
- ...ActiveProps,
245
- ...CurrentProps,
246
- ...LinkProps,
247
- /**
248
- * Button type
249
- */
250
- type: {
251
- type: String,
252
- default: ButtonType.button,
253
- validator: (value) => Object.values(ButtonType).includes(value)
254
- },
255
- /**
256
- * Button aria-label
257
- */
258
- ariaLabel: {
259
- type: String,
260
- default: void 0
261
- },
262
- /**
263
- * Default tag for the action
264
- */
265
- defaultTag: {
266
- type: String,
267
- default: ActionTag.button
268
- }
269
- };
270
- ({
271
- storageType: {
272
- default: StorageType.local
273
- }
274
- });
275
- const VvInputFileProps = {
276
- ...IdNameProps,
277
- ...ModifiersProps,
278
- ...ValidProps,
279
- ...InvalidProps,
280
- ...HintProps,
281
- ...LabelProps,
282
- ...LoadingProps,
283
- ...ReadonlyProps,
284
- ...DisabledProps,
285
- ...RequiredProps,
286
- ...IconProps,
287
- /**
288
- * Input value
289
- */
290
- modelValue: {
291
- type: Object
292
- },
293
- /**
294
- * Whether to show progress bar
295
- */
296
- progress: { type: [Number, String], default: void 0 },
297
- /**
298
- * Input
299
- * Text that appears in the form control when it has no value set
300
- * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#placeholder
301
- */
302
- placeholder: { type: String, default: void 0 },
303
- /**
304
- * File types to accept
305
- * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/accept
306
- */
307
- accept: { type: String, default: "*" },
308
- /**
309
- * Whether to allow multiple values
310
- * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#multiple
311
- */
312
- multiple: { type: Boolean, default: false },
313
- /**
314
- * Front or rear camera
315
- * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/capture
316
- */
317
- capture: {
318
- type: String,
319
- default: void 0,
320
- validation: (value) => {
321
- if (value === void 0) {
322
- return true;
323
- }
324
- return ["user", "environment"].includes(value);
325
- }
326
- },
327
- /**
328
- * Max number of files
329
- */
330
- max: { type: [Number, String], default: void 0 },
331
- /**
332
- * Show drop area
333
- */
334
- dropArea: { type: Boolean, default: false },
335
- /**
336
- * Enable sorting
337
- */
338
- sortable: { type: Boolean, default: false },
339
- /**
340
- * Label for add button
341
- */
342
- labelAdd: {
343
- type: String,
344
- default: "Add file"
345
- },
346
- /**
347
- * VvIcon name for add button
348
- * @see VvIcon
349
- */
350
- iconAdd: {
351
- type: [String, Object],
352
- default: ACTION_ICONS.add
353
- },
354
- /**
355
- * Label for replace button
356
- */
357
- labelReplace: {
358
- type: String,
359
- default: "Replace file"
360
- },
361
- /**
362
- * VvIcon name for replace button
363
- * @see VvIcon
364
- */
365
- iconReplace: {
366
- type: [String, Object],
367
- default: ACTION_ICONS.edit
368
- },
369
- /**
370
- * Label for download button
371
- */
372
- labelDownload: {
373
- type: String,
374
- default: "Downlaod file"
375
- },
376
- /**
377
- * VvIcon name for download button
378
- * @see VvIcon
379
- */
380
- iconDownload: {
381
- type: [String, Object],
382
- default: ACTION_ICONS.download
383
- },
384
- /**
385
- * Label for remove button
386
- */
387
- labelRemove: {
388
- type: String,
389
- default: "Remove file"
390
- }
391
- };
392
- function acceptedMimeTypes(acceptValue) {
393
- const mimeTypes = [];
394
- const extensions = [];
395
- const wildcards = [];
396
- const acceptedTypes = acceptValue?.split(",").map((type) => type.trim().toLowerCase());
397
- if (acceptedTypes?.length) {
398
- acceptedTypes.forEach((type) => {
399
- if (type.startsWith(".")) {
400
- extensions.push(type);
401
- } else if (type.includes("/*")) {
402
- wildcards.push(type.replace("/*", ""));
403
- } else {
404
- mimeTypes.push(type);
405
- }
406
- });
407
- }
408
- return {
409
- mimeTypes,
410
- extensions,
411
- wildcards
412
- };
413
- }
414
- function filterFileList(fileList, acceptValue) {
415
- if (!acceptValue || acceptValue.trim() === "" || acceptValue === "*") {
416
- return Array.from(fileList);
417
- }
418
- const { mimeTypes, extensions, wildcards } = acceptedMimeTypes(acceptValue);
419
- return Array.from(fileList).filter((file) => {
420
- const fileType = file.type.toLowerCase();
421
- const fileExtension = `.${file.name.split(".").pop()?.toLowerCase()}`;
422
- const mimeMatches = mimeTypes.includes(fileType);
423
- const wildcardMatches = wildcards.some((wildcard) => fileType.startsWith(`${wildcard}/`));
424
- const extensionMatches = extensions.some((ext) => fileExtension === ext.toLowerCase());
425
- return mimeMatches || wildcardMatches || extensionMatches;
426
- });
427
- }
428
- function equals(obj1, obj2, field) {
429
- return deepEquals(obj1, obj2);
430
- }
431
- function deepEquals(a, b) {
432
- if (a === b)
433
- return true;
434
- if (a && b && typeof a == "object" && typeof b == "object") {
435
- const arrA = Array.isArray(a);
436
- const arrB = Array.isArray(b);
437
- let i, length, key;
438
- if (arrA && arrB) {
439
- length = a.length;
440
- if (length !== b.length)
441
- return false;
442
- for (i = length; i-- !== 0; ) {
443
- if (!deepEquals(a[i], b[i]))
444
- return false;
445
- }
446
- return true;
447
- }
448
- if (arrA !== arrB)
449
- return false;
450
- const dateA = a instanceof Date;
451
- const dateB = b instanceof Date;
452
- if (dateA !== dateB)
453
- return false;
454
- if (dateA && dateB)
455
- return a.getTime() === b.getTime();
456
- const regexpA = a instanceof RegExp;
457
- const regexpB = b instanceof RegExp;
458
- if (regexpA !== regexpB)
459
- return false;
460
- if (regexpA && regexpB)
461
- return a.toString() === b.toString();
462
- const keys = Object.keys(a);
463
- length = keys.length;
464
- if (length !== Object.keys(b).length)
465
- return false;
466
- for (i = length; i-- !== 0; ) {
467
- if (!Object.prototype.hasOwnProperty.call(b, keys[i]))
468
- return false;
469
- }
470
- for (i = length; i-- !== 0; ) {
471
- key = keys[i];
472
- if (!deepEquals(a[key], b[key]))
473
- return false;
474
- }
475
- return true;
476
- }
477
- return Number.isNaN(a) && Number.isNaN(b);
478
- }
479
- function contains(value, list) {
480
- if (value != null && list && list.length) {
481
- for (const val of list) {
482
- if (equals(value, val)) {
483
- return true;
484
- }
485
- }
486
- }
487
- return false;
488
- }
489
- function isString(value) {
490
- return typeof value === "string";
491
- }
492
- function joinLines(items) {
493
- if (Array.isArray(items)) {
494
- return items.filter((item) => isString(item)).join(" ");
495
- }
496
- return items;
497
- }
498
- function HintSlotFactory(propsOrRef, slots) {
499
- const props = computed(() => {
500
- if (isRef(propsOrRef)) {
501
- return propsOrRef.value;
502
- }
503
- return propsOrRef;
504
- });
505
- const invalidLabel = computed(() => joinLines(props.value.invalidLabel));
506
- const validLabel = computed(() => joinLines(props.value.validLabel));
507
- const loadingLabel = computed(() => props.value.loadingLabel);
508
- const hintLabel = computed(() => props.value.hintLabel);
509
- const hasLoadingLabelOrSlot = computed(
510
- () => Boolean(props.value.loading && (slots.loading || loadingLabel.value))
511
- );
512
- const hasInvalidLabelOrSlot = computed(
513
- () => !hasLoadingLabelOrSlot.value && Boolean(
514
- props.value.invalid && (slots.invalid || invalidLabel.value)
515
- )
516
- );
517
- const hasValidLabelOrSlot = computed(
518
- () => !hasLoadingLabelOrSlot.value && !hasInvalidLabelOrSlot.value && Boolean(props.value.valid && (slots.valid || validLabel.value))
519
- );
520
- const hasHintLabelOrSlot = computed(
521
- () => !hasLoadingLabelOrSlot.value && !hasInvalidLabelOrSlot.value && !hasValidLabelOrSlot.value && Boolean(slots.hint || hintLabel.value)
522
- );
523
- const isVisible = computed(
524
- () => hasInvalidLabelOrSlot.value || hasValidLabelOrSlot.value || hasLoadingLabelOrSlot.value || hasHintLabelOrSlot.value
525
- );
526
- const hintSlotScope = computed(() => ({
527
- modelValue: props.value.modelValue,
528
- valid: props.value.valid,
529
- invalid: props.value.invalid,
530
- loading: props.value.loading
531
- }));
532
- const HintSlot = defineComponent({
533
- name: "HintSlot",
534
- props: {
535
- tag: {
536
- type: String,
537
- default: "small"
538
- }
539
- },
540
- setup() {
541
- return {
542
- isVisible,
543
- invalidLabel,
544
- validLabel,
545
- loadingLabel,
546
- hintLabel,
547
- hasInvalidLabelOrSlot,
548
- hasValidLabelOrSlot,
549
- hasLoadingLabelOrSlot,
550
- hasHintLabelOrSlot
551
- };
552
- },
553
- render() {
554
- if (this.isVisible) {
555
- let role;
556
- if (this.hasInvalidLabelOrSlot) {
557
- role = "alert";
558
- }
559
- if (this.hasValidLabelOrSlot) {
560
- role = "status";
561
- }
562
- if (this.hasLoadingLabelOrSlot) {
563
- return h(
564
- this.tag,
565
- {
566
- role
567
- },
568
- this.$slots.loading?.() ?? this.loadingLabel
569
- );
570
- }
571
- if (this.hasInvalidLabelOrSlot) {
572
- return h(
573
- this.tag,
574
- {
575
- role
576
- },
577
- this.$slots.invalid?.() ?? this.$slots.invalid ?? this.invalidLabel
578
- );
579
- }
580
- if (this.hasValidLabelOrSlot) {
581
- return h(
582
- this.tag,
583
- {
584
- role
585
- },
586
- this.$slots.valid?.() ?? this.validLabel
587
- );
588
- }
589
- return h(
590
- this.tag,
591
- {
592
- role
593
- },
594
- this.$slots.hint?.() ?? this.$slots.hint ?? this.hintLabel
595
- );
596
- }
597
- return null;
598
- }
599
- });
600
- return {
601
- hasInvalidLabelOrSlot,
602
- hasHintLabelOrSlot,
603
- hasValidLabelOrSlot,
604
- hasLoadingLabelOrSlot,
605
- hintSlotScope,
606
- HintSlot
607
- };
608
- }
609
- function useGroupStateInject(groupKey) {
610
- const group = inject(groupKey, void 0);
611
- const isInGroup = computed(() => group !== void 0);
612
- function getGroupOrLocalRef(propName, props, emit) {
613
- const groupPropValue = group?.[propName];
614
- if (groupPropValue) {
615
- return computed({
616
- get() {
617
- return groupPropValue.value;
618
- },
619
- set(value) {
620
- groupPropValue.value = value;
621
- }
622
- });
623
- }
624
- const propRef = toRef(props, propName);
625
- return computed({
626
- get() {
627
- return propRef.value;
628
- },
629
- set(value) {
630
- if (emit) {
631
- emit(`update:${propName}`, value);
632
- }
633
- }
634
- });
635
- }
636
- return {
637
- group,
638
- isInGroup,
639
- getGroupOrLocalRef
640
- };
641
- }
642
- const VvButtonEvents = ["update:modelValue"];
643
- const VvButtonProps = {
644
- ...ActionProps,
645
- ...IdProps,
646
- ...ModifiersProps,
647
- ...UnselectableProps,
648
- ...LoadingProps,
649
- ...IconProps,
650
- /**
651
- * Button icon position
652
- */
653
- iconPosition: {
654
- type: String,
655
- default: Side.left,
656
- validator: (value) => Object.values(Side).includes(value)
657
- },
658
- /**
659
- * Loading icon
660
- */
661
- loadingIcon: { type: String, default: "eos-icons:bubble-loading" },
662
- /**
663
- * Enable button toggle
664
- */
665
- toggle: {
666
- type: Boolean,
667
- default: false
668
- },
669
- /**
670
- * Button toggle value
671
- */
672
- value: {
673
- type: [String, Number, Boolean],
674
- default: void 0
675
- },
676
- /**
677
- * Value associated with the unchecked state
678
- */
679
- uncheckedValue: {
680
- type: [String, Number, Boolean],
681
- default: void 0
682
- },
683
- /**
684
- * Button toggle model value
685
- */
686
- modelValue: {
687
- type: [String, Number, Boolean],
688
- default: void 0
689
- }
690
- };
691
- function useGroupProps(props, emit) {
692
- const { group, isInGroup, getGroupOrLocalRef } = useGroupStateInject(INJECTION_KEY_BUTTON_GROUP);
693
- const { id, iconPosition, icon, label, pressed } = toRefs(props);
694
- const modelValue = getGroupOrLocalRef("modelValue", props, emit);
695
- const toggle = getGroupOrLocalRef("toggle", props);
696
- const unselectable = getGroupOrLocalRef("unselectable", props);
697
- const multiple = computed(() => group?.multiple.value ?? false);
698
- const modifiers = computed(() => {
699
- let localModifiers = props.modifiers;
700
- let groupModifiers = group?.modifiers.value;
701
- const toReturn = /* @__PURE__ */ new Set();
702
- if (localModifiers) {
703
- if (!Array.isArray(localModifiers)) {
704
- localModifiers = localModifiers.split(" ");
705
- }
706
- localModifiers.forEach((modifier) => toReturn.add(modifier));
707
- }
708
- if (groupModifiers) {
709
- if (!Array.isArray(groupModifiers)) {
710
- groupModifiers = groupModifiers.split(" ");
711
- }
712
- groupModifiers.forEach((modifier) => toReturn.add(modifier));
713
- }
714
- return Array.from(toReturn);
715
- });
716
- const disabled = computed(
717
- () => Boolean(props.disabled || group?.disabled.value)
718
- );
719
- return {
720
- // group props
721
- group,
722
- isInGroup,
723
- modelValue,
724
- toggle,
725
- unselectable,
726
- multiple,
727
- modifiers,
728
- disabled,
729
- // local props
730
- id,
731
- pressed,
732
- iconPosition,
733
- icon,
734
- label
735
- };
736
- }
737
- const VvActionEvents = ["click", "mouseover", "mouseleave"];
738
- const VvActionProps = ActionProps;
739
- function useVolver() {
740
- return inject(INJECTION_KEY_VOLVER, void 0);
741
- }
742
- function useInjectedDropdownTrigger() {
743
- return inject(INJECTION_KEY_DROPDOWN_TRIGGER, {});
744
- }
745
- function useInjectedDropdownAction() {
746
- return inject(INJECTION_KEY_DROPDOWN_ACTION, {});
747
- }
748
- const __default__$3 = {
749
- name: "VvAction"
750
- };
751
- const _sfc_main$3 = /* @__PURE__ */ defineComponent({
752
- ...__default__$3,
753
- props: VvActionProps,
754
- emits: VvActionEvents,
755
- setup(__props, { expose: __expose, emit: __emit }) {
756
- const props = __props;
757
- const emit = __emit;
758
- const instance = getCurrentInstance();
759
- const volver = useVolver();
760
- const element = ref(null);
761
- __expose({ $el: element });
762
- const {
763
- reference: dropdownTriggerReference,
764
- bus: dropdownEventBus,
765
- aria: dropdownAria,
766
- expanded: dropdownExpanded
767
- } = useInjectedDropdownTrigger();
768
- watch(
769
- () => element.value,
770
- (newValue) => {
771
- if (dropdownTriggerReference) {
772
- dropdownTriggerReference.value = newValue;
773
- }
774
- }
775
- );
776
- const pressed = computed(() => {
777
- return props.pressed || dropdownExpanded?.value;
778
- });
779
- const { role } = useInjectedDropdownAction();
780
- const hasTag = computed(() => {
781
- switch (true) {
782
- case props.disabled:
783
- return ActionTag.button;
784
- case props.to !== void 0:
785
- return volver?.nuxt ? resolveComponent(ActionTag.nuxtLink) : ActionTag.routerLink;
786
- case props.href !== void 0:
787
- return ActionTag.a;
788
- default:
789
- return props.defaultTag;
790
- }
791
- });
792
- const hasProps = computed(() => {
793
- const toReturn = {
794
- ...dropdownAria?.value,
795
- ariaPressed: pressed.value ? true : void 0,
796
- ariaLabel: props.ariaLabel,
797
- role: role?.value
798
- };
799
- switch (hasTag.value) {
800
- case ActionTag.a:
801
- return {
802
- ...toReturn,
803
- href: props.href,
804
- target: props.target,
805
- rel: props.rel
806
- };
807
- case ActionTag.routerLink:
808
- case ActionTag.nuxtLink:
809
- return {
810
- ...toReturn,
811
- to: props.to,
812
- target: props.target
813
- };
814
- case ActionTag.button:
815
- return {
816
- ...toReturn,
817
- type: props.type,
818
- disabled: props.disabled
819
- };
820
- default:
821
- return toReturn;
822
- }
823
- });
824
- function onClick(e) {
825
- if (props.disabled) {
826
- e.preventDefault();
827
- return;
828
- }
829
- if (instance?.vnode.props?.onClick) {
830
- emit("click", e);
831
- return;
832
- }
833
- dropdownEventBus?.emit("click", e);
834
- }
835
- function onMouseover(e) {
836
- if (instance?.vnode.props?.onMouseover) {
837
- emit("mouseover", e);
838
- return;
839
- }
840
- dropdownEventBus?.emit("mouseover", e);
841
- }
842
- function onMouseleave(e) {
843
- if (instance?.vnode.props?.onMouseleave) {
844
- emit("mouseleave", e);
845
- return;
846
- }
847
- dropdownEventBus?.emit("mouseleave", e);
848
- }
849
- return (_ctx, _cache) => {
850
- return openBlock(), createBlock(resolveDynamicComponent(unref(hasTag)), mergeProps(unref(hasProps), {
851
- ref_key: "element",
852
- ref: element,
853
- class: {
854
- active: _ctx.active,
855
- pressed: unref(pressed),
856
- disabled: _ctx.disabled,
857
- current: _ctx.current
858
- },
859
- onClickPassive: onClick,
860
- onMouseoverPassive: onMouseover,
861
- onMouseleavePassive: onMouseleave
862
- }), {
863
- default: withCtx(() => [
864
- renderSlot(_ctx.$slots, "default", {}, () => [
865
- createTextVNode(
866
- toDisplayString(_ctx.label),
867
- 1
868
- /* TEXT */
869
- )
870
- ])
871
- ]),
872
- _: 3
873
- /* FORWARDED */
874
- }, 16, ["class"]);
875
- };
876
- }
877
- });
878
- function useModifiers(prefix, modifiers, others) {
879
- return computed(() => {
880
- const toReturn = {
881
- [prefix]: true
882
- };
883
- const modifiersArray = typeof modifiers?.value === "string" ? modifiers.value.split(" ") : modifiers?.value;
884
- if (modifiersArray) {
885
- if (Array.isArray(modifiersArray)) {
886
- modifiersArray.forEach((modifier) => {
887
- if (modifier) {
888
- toReturn[`${prefix}--${modifier}`] = true;
889
- }
890
- });
891
- }
892
- }
893
- if (others) {
894
- Object.keys(others.value).forEach((key) => {
895
- toReturn[`${prefix}--${key}`] = unref(others.value[key]);
896
- });
897
- }
898
- return toReturn;
899
- });
900
- }
901
- const __default__$2 = {
902
- name: "VvIcon"
903
- };
904
- const _sfc_main$2 = /* @__PURE__ */ defineComponent({
905
- ...__default__$2,
906
- props: /* @__PURE__ */ mergeDefaults({
907
- name: {},
908
- color: {},
909
- width: {},
910
- height: {},
911
- provider: {},
912
- prefix: {},
913
- src: {},
914
- horizontalFlip: { type: Boolean },
915
- verticalFlip: { type: Boolean },
916
- flip: {},
917
- mode: {},
918
- inline: { type: Boolean },
919
- rotate: {},
920
- onLoad: { type: Function },
921
- svg: {},
922
- modifiers: {}
923
- }, VvIconPropsDefaults),
924
- setup(__props) {
925
- const props = __props;
926
- const hasRotate = computed(() => {
927
- if (typeof props.rotate === "string") {
928
- return Number.parseFloat(props.rotate);
929
- }
930
- return props.rotate;
931
- });
932
- const show = ref(true);
933
- const volver = useVolver();
934
- const { modifiers } = toRefs(props);
935
- const bemCssClasses = useModifiers("vv-icon", modifiers);
936
- const provider = computed(() => {
937
- return props.provider || volver?.iconsProvider;
938
- });
939
- const icon = computed(() => {
940
- const name = props.name ?? "";
941
- const iconName = `@${provider.value}:${props.prefix}:${name}`;
942
- if (iconLoaded(iconName)) {
943
- return iconName;
944
- }
945
- const iconsCollection = volver?.iconsCollections.find(
946
- (iconsCollection2) => {
947
- const icon2 = `@${provider.value}:${iconsCollection2.prefix}:${name}`;
948
- return iconLoaded(icon2);
949
- }
950
- );
951
- if (iconsCollection) {
952
- return `@${provider.value}:${iconsCollection.prefix}:${name}`;
953
- }
954
- return name;
955
- });
956
- function getSvgContent(svg) {
957
- let dom;
958
- if (typeof window === "undefined") {
959
- const { JSDOM } = require("jsdom");
960
- dom = new JSDOM().window;
961
- }
962
- const domParser = dom ? new dom.DOMParser() : new window.DOMParser();
963
- const svgDomString = domParser.parseFromString(svg, "text/html");
964
- const svgEl = svgDomString.querySelector("svg");
965
- return svgEl;
966
- }
967
- function addIconFromSvg(svg) {
968
- const svgContentEl = getSvgContent(svg);
969
- const svgContent = svgContentEl?.innerHTML.trim() || "";
970
- if (svgContentEl && svgContent) {
971
- addIcon(`@${provider.value}:${props.prefix}:${props.name}`, {
972
- body: svgContent,
973
- // Set height and width from svg content
974
- height: svgContentEl.viewBox.baseVal.height,
975
- width: svgContentEl.viewBox.baseVal.width
976
- });
977
- }
978
- }
979
- if (volver) {
980
- if (props.src && !iconLoaded(`@${provider.value}:${props.prefix}:${props.name}`)) {
981
- show.value = false;
982
- volver.fetchIcon(props.src).then((svg) => {
983
- if (svg) {
984
- addIconFromSvg(svg);
985
- show.value = true;
986
- }
987
- }).catch((e) => {
988
- throw new Error(`Error during fetch icon: ${e?.message}`);
989
- });
990
- }
991
- }
992
- if (props.svg) {
993
- addIconFromSvg(props.svg);
994
- }
995
- return (_ctx, _cache) => {
996
- return unref(show) ? (openBlock(), createBlock(unref(Icon), mergeProps({
997
- key: 0,
998
- class: unref(bemCssClasses)
999
- }, {
1000
- inline: __props.inline,
1001
- width: __props.width,
1002
- height: __props.height,
1003
- horizontalFlip: __props.horizontalFlip,
1004
- verticalFlip: __props.verticalFlip,
1005
- flip: __props.flip,
1006
- rotate: unref(hasRotate),
1007
- color: __props.color,
1008
- icon: unref(icon)
1009
- }, { onLoad: __props.onLoad }), null, 16, ["class", "onLoad"])) : createCommentVNode("v-if", true);
1010
- };
1011
- }
1012
- });
1013
- function useUniqueId(id) {
1014
- return computed(() => String(id?.value || useId()));
1015
- }
1016
- function useComponentIcon(icon, iconPosition) {
1017
- const hasIcon = computed(() => {
1018
- if (typeof icon?.value === "string") {
1019
- return { name: icon?.value };
1020
- }
1021
- return icon?.value;
1022
- });
1023
- const hasIconBefore = computed(
1024
- () => iconPosition?.value === Position.before ? hasIcon.value : void 0
1025
- );
1026
- const hasIconAfter = computed(
1027
- () => iconPosition?.value === Position.after ? hasIcon.value : void 0
1028
- );
1029
- const hasIconLeft = computed(
1030
- () => iconPosition?.value === Side.left ? hasIcon.value : void 0
1031
- );
1032
- const hasIconRight = computed(
1033
- () => iconPosition?.value === Side.right ? hasIcon.value : void 0
1034
- );
1035
- const hasIconTop = computed(
1036
- () => iconPosition?.value === Side.top ? hasIcon.value : void 0
1037
- );
1038
- const hasIconBottom = computed(
1039
- () => iconPosition?.value === Side.bottom ? hasIcon.value : void 0
1040
- );
1041
- return {
1042
- hasIcon,
1043
- hasIconLeft,
1044
- hasIconRight,
1045
- hasIconTop,
1046
- hasIconBottom,
1047
- hasIconBefore,
1048
- hasIconAfter
1049
- };
1050
- }
1051
- const _hoisted_1$1 = {
1052
- key: 1,
1053
- class: "vv-button__label"
1054
- };
1055
- const _hoisted_2$1 = {
1056
- key: 1,
1057
- class: "vv-button__label"
1058
- };
1059
- const __default__$1 = {
1060
- name: "VvButton",
1061
- inheritAttrs: false
1062
- };
1063
- const _sfc_main$1 = /* @__PURE__ */ defineComponent({
1064
- ...__default__$1,
1065
- props: VvButtonProps,
1066
- emits: VvButtonEvents,
1067
- setup(__props, { expose: __expose, emit: __emit }) {
1068
- const props = __props;
1069
- const emit = __emit;
1070
- const attrs = useAttrs();
1071
- const slots = useSlots();
1072
- const {
1073
- id,
1074
- modifiers,
1075
- iconPosition,
1076
- icon,
1077
- label,
1078
- modelValue,
1079
- disabled,
1080
- toggle,
1081
- unselectable
1082
- } = useGroupProps(props, emit);
1083
- const hasId = useUniqueId(id);
1084
- const name = computed(() => attrs?.name || hasId.value);
1085
- const element = ref(null);
1086
- const $el = computed(() => element.value?.$el);
1087
- __expose({ $el });
1088
- const pressed = computed(() => {
1089
- if (!toggle.value) {
1090
- return props.pressed;
1091
- }
1092
- if (Array.isArray(modelValue.value)) {
1093
- return contains(name.value, modelValue.value);
1094
- }
1095
- return equals(name.value, modelValue.value);
1096
- });
1097
- const bemCssClasses = useModifiers(
1098
- "vv-button",
1099
- modifiers,
1100
- computed(() => ({
1101
- "reverse": [Side.right, Side.bottom].includes(
1102
- iconPosition.value
1103
- ),
1104
- "column": [Side.top, Side.bottom].includes(
1105
- iconPosition.value
1106
- ),
1107
- "icon-only": Boolean(
1108
- icon?.value && !label?.value && !slots.default
1109
- )
1110
- }))
1111
- );
1112
- const { hasIcon } = useComponentIcon(icon);
1113
- const toggleValue = computed(() => {
1114
- return props.value !== void 0 ? props.value : name.value;
1115
- });
1116
- const hasListeners = computed(() => {
1117
- if (!toggle.value) {
1118
- return void 0;
1119
- }
1120
- return {
1121
- onClick
1122
- };
1123
- });
1124
- function onClick() {
1125
- if (toggle.value) {
1126
- if (Array.isArray(modelValue.value)) {
1127
- if (contains(toggleValue.value, modelValue.value)) {
1128
- if (unselectable.value) {
1129
- modelValue.value = modelValue.value.filter(
1130
- (n) => n !== toggleValue.value
1131
- );
1132
- }
1133
- return;
1134
- }
1135
- modelValue.value.push(toggleValue.value);
1136
- return;
1137
- }
1138
- if (toggleValue.value === modelValue.value && unselectable.value) {
1139
- modelValue.value = props.uncheckedValue;
1140
- return;
1141
- }
1142
- modelValue.value = toggleValue.value;
1143
- }
1144
- }
1145
- return (_ctx, _cache) => {
1146
- return openBlock(), createBlock(_sfc_main$3, mergeProps({
1147
- ...unref(attrs),
1148
- ...unref(hasListeners),
1149
- disabled: unref(disabled),
1150
- pressed: unref(pressed),
1151
- active: _ctx.active,
1152
- type: _ctx.type,
1153
- to: _ctx.to,
1154
- href: _ctx.href,
1155
- target: _ctx.target,
1156
- rel: _ctx.rel,
1157
- ariaLabel: _ctx.ariaLabel
1158
- }, {
1159
- id: unref(hasId),
1160
- ref_key: "element",
1161
- ref: element,
1162
- class: unref(bemCssClasses)
1163
- }), {
1164
- default: withCtx(() => [
1165
- renderSlot(_ctx.$slots, "default", {}, () => [
1166
- _ctx.loading ? renderSlot(_ctx.$slots, "loading", { key: 0 }, () => [
1167
- _ctx.loadingIcon ? (openBlock(), createBlock(_sfc_main$2, {
1168
- key: 0,
1169
- class: "vv-button__loading-icon",
1170
- name: _ctx.loadingIcon
1171
- }, null, 8, ["name"])) : createCommentVNode("v-if", true),
1172
- _ctx.loadingLabel ? (openBlock(), createElementBlock(
1173
- "span",
1174
- _hoisted_1$1,
1175
- toDisplayString(_ctx.loadingLabel),
1176
- 1
1177
- /* TEXT */
1178
- )) : createCommentVNode("v-if", true)
1179
- ]) : (openBlock(), createElementBlock(
1180
- Fragment,
1181
- { key: 1 },
1182
- [
1183
- renderSlot(_ctx.$slots, "before"),
1184
- unref(hasIcon) ? (openBlock(), createBlock(
1185
- _sfc_main$2,
1186
- mergeProps({ key: 0 }, unref(hasIcon), { class: "vv-button__icon" }),
1187
- null,
1188
- 16
1189
- /* FULL_PROPS */
1190
- )) : createCommentVNode("v-if", true),
1191
- unref(label) ? (openBlock(), createElementBlock("span", _hoisted_2$1, [
1192
- renderSlot(_ctx.$slots, "label", {}, () => [
1193
- createTextVNode(
1194
- toDisplayString(unref(label)),
1195
- 1
1196
- /* TEXT */
1197
- )
1198
- ])
1199
- ])) : createCommentVNode("v-if", true),
1200
- renderSlot(_ctx.$slots, "after")
1201
- ],
1202
- 64
1203
- /* STABLE_FRAGMENT */
1204
- ))
1205
- ])
1206
- ]),
1207
- _: 3
1208
- /* FORWARDED */
1209
- }, 16, ["id", "class"]);
1210
- };
1211
- }
1212
- });
1213
- function useDefaults(componentName, propsDefinition, props) {
1214
- const volver = useVolver();
1215
- const volverComponentDefaults = computed(() => {
1216
- if (!volver || !volver.defaults.value?.[componentName]) {
1217
- return void 0;
1218
- }
1219
- return volver.defaults.value[componentName];
1220
- });
1221
- return computed(() => {
1222
- if (volverComponentDefaults.value === void 0) {
1223
- return props;
1224
- }
1225
- const componentDefaults = volverComponentDefaults.value;
1226
- const simplifiedPropsDefinition = propsDefinition;
1227
- const simplifiedProps = props;
1228
- return Object.keys(simplifiedPropsDefinition).reduce((acc, key) => {
1229
- const propValue = simplifiedProps[key];
1230
- acc[key] = propValue;
1231
- if (key in componentDefaults) {
1232
- if (Array.isArray(simplifiedPropsDefinition[key])) {
1233
- const typeArray = simplifiedPropsDefinition[key];
1234
- if (typeArray.length) {
1235
- const typeFunction = typeArray[0];
1236
- if (typeFunction === propValue) {
1237
- acc[key] = componentDefaults[key];
1238
- }
1239
- }
1240
- }
1241
- if (typeof simplifiedPropsDefinition[key] === "function") {
1242
- const typeFunction = simplifiedPropsDefinition[key];
1243
- if (typeFunction() === propValue) {
1244
- acc[key] = componentDefaults[key];
1245
- }
1246
- }
1247
- if (typeof simplifiedPropsDefinition[key] === "object") {
1248
- let defaultValue = simplifiedPropsDefinition[key].default;
1249
- if (typeof defaultValue === "function") {
1250
- defaultValue = defaultValue();
1251
- }
1252
- if (typeof defaultValue === "object") {
1253
- if (JSON.stringify(defaultValue) === JSON.stringify(propValue)) {
1254
- acc[key] = componentDefaults[key];
1255
- }
1256
- } else if (defaultValue === propValue) {
1257
- acc[key] = componentDefaults[key];
1258
- }
1259
- }
1260
- }
1261
- return acc;
1262
- }, {});
1263
- });
1264
- }
1265
- const _hoisted_1 = ["for"];
1266
- const _hoisted_2 = { class: "vv-input-file__preview" };
1267
- const _hoisted_3 = ["src", "alt"];
1268
- const _hoisted_4 = { class: "vv-input-file__wrapper" };
1269
- const _hoisted_5 = ["id", "readonly", "disabled", "required", "placeholder", "aria-describedby", "aria-invalid", "aria-errormessage", "multiple", "accept", "capture", "name"];
1270
- const _hoisted_6 = ["value"];
1271
- const _hoisted_7 = ["onClick"];
1272
- const _hoisted_8 = ["title", "onClick"];
1273
- const _hoisted_9 = { class: "vv-input-file__item-name" };
1274
- const _hoisted_10 = { class: "vv-input-file__item-info" };
1275
- const _hoisted_11 = ["title", "disabled", "onClick"];
1276
- const __default__ = {
1277
- name: "VvInputFile"
1278
- };
1279
- const _sfc_main = /* @__PURE__ */ defineComponent({
1280
- ...__default__,
1281
- props: VvInputFileProps,
1282
- emits: ["remove", "download", "update:modelValue"],
1283
- setup(__props, { emit: __emit }) {
1284
- const props = __props;
1285
- const emit = __emit;
1286
- const slots = useSlots();
1287
- const propsDefaults = useDefaults(
1288
- "VvInputFile",
1289
- VvInputFileProps,
1290
- props
1291
- );
1292
- const { modifiers, id, readonly, disabled, icon, iconPosition, iconDownload } = toRefs(props);
1293
- const hasId = useUniqueId(id);
1294
- const hasHintId = computed(() => `${hasId.value}-hint`);
1295
- const hasProgress = computed(() => {
1296
- if (!props.progress) {
1297
- return false;
1298
- }
1299
- const progress = typeof props.progress === "string" ? Number.parseInt(props.progress) : props.progress;
1300
- return progress > 0 && progress < 100;
1301
- });
1302
- const { hasIconBefore, hasIconAfter } = useComponentIcon(icon, iconPosition);
1303
- const { hasIcon: hasIconDownload } = useComponentIcon(iconDownload);
1304
- const bemCssClasses = useModifiers(
1305
- "vv-input-file",
1306
- modifiers,
1307
- computed(() => ({
1308
- "valid": props.valid === true,
1309
- "invalid": props.invalid === true,
1310
- "loading": props.loading && !hasProgress.value,
1311
- "disabled": props.disabled,
1312
- "required": props.required,
1313
- "readonly": props.readonly,
1314
- "dragging": isDragging.value,
1315
- "icon-before": !!hasIconBefore.value,
1316
- "icon-after": !!hasIconAfter.value,
1317
- "drop-area": hasDropArea.value
1318
- }))
1319
- );
1320
- const {
1321
- HintSlot,
1322
- hasHintLabelOrSlot,
1323
- hasInvalidLabelOrSlot,
1324
- hintSlotScope
1325
- } = HintSlotFactory(propsDefaults, slots);
1326
- const localModelValue = useVModel(props, "modelValue", emit);
1327
- const files = computed({
1328
- get: () => {
1329
- if (!localModelValue.value || !Array.isArray(localModelValue.value) && !localModelValue.value?.name) {
1330
- return [];
1331
- }
1332
- return Array.isArray(localModelValue.value) ? localModelValue.value : [localModelValue.value];
1333
- },
1334
- set: (value) => {
1335
- if (isMultiple.value) {
1336
- localModelValue.value = value;
1337
- return;
1338
- }
1339
- localModelValue.value = value?.[0];
1340
- }
1341
- });
1342
- const isDisabledOrReadonly = computed(() => props.disabled || props.readonly);
1343
- const hasMax = computed(() => {
1344
- return typeof props.max === "string" ? Number.parseInt(props.max) : props.max;
1345
- });
1346
- const hasDropArea = computed(() => {
1347
- return props.dropArea && !isDisabledOrReadonly.value;
1348
- });
1349
- const isMultiple = computed(() => {
1350
- if (!props.multiple) {
1351
- return false;
1352
- }
1353
- if (!hasMax.value) {
1354
- return true;
1355
- }
1356
- return hasMax.value - files.value.length > 1;
1357
- });
1358
- const isDragging = ref(false);
1359
- const inputEl = ref();
1360
- function onDragenter() {
1361
- isDragging.value = true;
1362
- }
1363
- function onDragleave() {
1364
- isDragging.value = false;
1365
- }
1366
- function onDrop(event) {
1367
- if (!event.dataTransfer?.files) {
1368
- return;
1369
- }
1370
- isDragging.value = false;
1371
- addFiles(event.dataTransfer?.files);
1372
- }
1373
- function onChange() {
1374
- if (!inputEl.value?.files) {
1375
- return;
1376
- }
1377
- addFiles(inputEl.value.files);
1378
- inputEl.value.value = "";
1379
- }
1380
- function addFiles(uploadedFiles) {
1381
- const filteredFiles = filterFileList(uploadedFiles, props.accept);
1382
- if (!props.multiple) {
1383
- if (Array.isArray(localModelValue.value)) {
1384
- localModelValue.value = filteredFiles;
1385
- return;
1386
- }
1387
- localModelValue.value = filteredFiles[0];
1388
- return;
1389
- }
1390
- let toReturn = [];
1391
- if (!Array.isArray(localModelValue.value) && localModelValue.value) {
1392
- toReturn = [localModelValue.value];
1393
- } else {
1394
- toReturn = localModelValue.value && Array.isArray(localModelValue.value) ? [...localModelValue.value] : toReturn;
1395
- }
1396
- for (const file of filteredFiles) {
1397
- if (hasMax.value && toReturn.length >= hasMax.value) {
1398
- break;
1399
- }
1400
- toReturn.push(file);
1401
- }
1402
- localModelValue.value = toReturn;
1403
- selectedFileIndex.value = toReturn.length - 1;
1404
- }
1405
- function onClickDropArea() {
1406
- if (!inputEl.value) {
1407
- return;
1408
- }
1409
- if (!isDisabledOrReadonly.value) {
1410
- inputEl.value.click();
1411
- }
1412
- }
1413
- function onClickRemoveFile(index) {
1414
- const toRemove = !Array.isArray(localModelValue.value) ? localModelValue.value : localModelValue.value[index];
1415
- if (!toRemove) {
1416
- return;
1417
- }
1418
- emit("remove", toRemove);
1419
- if (!Array.isArray(localModelValue.value)) {
1420
- localModelValue.value = void 0;
1421
- return;
1422
- }
1423
- if (selectedFileIndex.value === index) {
1424
- selectedFileIndex.value = 0;
1425
- }
1426
- const newModelValue = [...localModelValue.value];
1427
- newModelValue.splice(index, 1);
1428
- localModelValue.value = newModelValue;
1429
- }
1430
- const selectedFileIndex = ref(0);
1431
- const PREVIEW_MIME_TYPES = ["image/jpeg", "image/png"];
1432
- const previewSrc = computed(() => {
1433
- if (files.value.length === 0) {
1434
- return;
1435
- }
1436
- if (!files.value[selectedFileIndex.value]) {
1437
- return void 0;
1438
- }
1439
- if (files.value[selectedFileIndex.value] instanceof File) {
1440
- const currentFile2 = files.value[selectedFileIndex.value];
1441
- if (!PREVIEW_MIME_TYPES.includes(currentFile2.type)) {
1442
- return void 0;
1443
- }
1444
- return URL.createObjectURL(currentFile2);
1445
- }
1446
- const currentFile = files.value[selectedFileIndex.value];
1447
- if (currentFile.thumbnailUrl) {
1448
- return currentFile.thumbnailUrl;
1449
- }
1450
- if (!PREVIEW_MIME_TYPES.includes(currentFile.type)) {
1451
- return void 0;
1452
- }
1453
- return currentFile.url;
1454
- });
1455
- watch(previewSrc, (_newValue, oldValue) => {
1456
- if (oldValue) {
1457
- URL.revokeObjectURL(oldValue);
1458
- }
1459
- });
1460
- onBeforeUnmount(() => {
1461
- if (previewSrc.value) {
1462
- URL.revokeObjectURL(previewSrc.value);
1463
- }
1464
- });
1465
- function formatBytes(bytes, decimals) {
1466
- if (!bytes) {
1467
- return;
1468
- }
1469
- if (bytes === 0)
1470
- return "0 Bytes";
1471
- const k = 1024;
1472
- const dm = 2;
1473
- const sizes = ["Bytes", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"];
1474
- const i = Math.floor(Math.log(bytes) / Math.log(k));
1475
- return `${Number.parseFloat((bytes / k ** i).toFixed(dm))} ${sizes[i]}`;
1476
- }
1477
- function onClickDownloadFile(file) {
1478
- emit("download", file);
1479
- const href = file instanceof File ? URL.createObjectURL(file) : file.url;
1480
- if (!href) {
1481
- return;
1482
- }
1483
- const link = document.createElement("a");
1484
- link.href = href;
1485
- link.setAttribute("download", file.name);
1486
- document.body.appendChild(link);
1487
- link.click();
1488
- document.body.removeChild(link);
1489
- URL.revokeObjectURL(link.href);
1490
- }
1491
- function onClickSelectFile(index) {
1492
- selectedFileIndex.value = index;
1493
- }
1494
- const dropdAreaActionLabel = computed(() => {
1495
- if (files.value.length === 0 || isMultiple.value) {
1496
- return props.labelAdd;
1497
- }
1498
- return props.labelReplace;
1499
- });
1500
- const dropAreaActionIcon = computed(() => {
1501
- if (files.value.length === 0 || isMultiple.value) {
1502
- return props.iconAdd;
1503
- }
1504
- return props.iconReplace;
1505
- });
1506
- function onSortEnd({ newIndex }) {
1507
- if (newIndex !== null) {
1508
- selectedFileIndex.value = newIndex;
1509
- }
1510
- }
1511
- return (_ctx, _cache) => {
1512
- return openBlock(), createElementBlock(
1513
- "div",
1514
- {
1515
- class: normalizeClass(unref(bemCssClasses))
1516
- },
1517
- [
1518
- _ctx.label ? (openBlock(), createElementBlock("label", {
1519
- key: 0,
1520
- for: unref(hasId)
1521
- }, toDisplayString(_ctx.label), 9, _hoisted_1)) : createCommentVNode("v-if", true),
1522
- hasDropArea.value ? (openBlock(), createElementBlock(
1523
- "div",
1524
- {
1525
- key: 1,
1526
- class: "vv-input-file__drop-area",
1527
- onDragenter: withModifiers(onDragenter, ["prevent", "stop"]),
1528
- onDragleave: withModifiers(onDragleave, ["prevent", "stop"]),
1529
- onDrop: withModifiers(onDrop, ["prevent", "stop"]),
1530
- onDragover: _cache[0] || (_cache[0] = withModifiers(() => {
1531
- }, ["prevent", "stop"])),
1532
- onClick: withModifiers(onClickDropArea, ["stop"])
1533
- },
1534
- [
1535
- renderSlot(_ctx.$slots, "drop-area", {}, () => [
1536
- createElementVNode("picture", _hoisted_2, [
1537
- previewSrc.value ? (openBlock(), createElementBlock("img", {
1538
- key: 0,
1539
- src: previewSrc.value,
1540
- alt: files.value[selectedFileIndex.value].name
1541
- }, null, 8, _hoisted_3)) : createCommentVNode("v-if", true)
1542
- ]),
1543
- !unref(readonly) ? (openBlock(), createBlock(_sfc_main$1, {
1544
- key: 0,
1545
- modifiers: "action",
1546
- label: !previewSrc.value ? dropdAreaActionLabel.value : void 0,
1547
- title: previewSrc.value ? dropdAreaActionLabel.value : void 0,
1548
- disabled: unref(disabled),
1549
- class: normalizeClass({
1550
- "vv-input-file__drop-area-action": previewSrc.value
1551
- }),
1552
- icon: dropAreaActionIcon.value,
1553
- onClick: withModifiers(onClickDropArea, ["stop"])
1554
- }, null, 8, ["label", "title", "disabled", "class", "icon"])) : createCommentVNode("v-if", true)
1555
- ])
1556
- ],
1557
- 32
1558
- /* NEED_HYDRATION */
1559
- )) : createCommentVNode("v-if", true),
1560
- createElementVNode("div", _hoisted_4, [
1561
- unref(hasIconBefore) ? (openBlock(), createBlock(
1562
- _sfc_main$2,
1563
- normalizeProps(mergeProps({ key: 0 }, unref(hasIconBefore))),
1564
- null,
1565
- 16
1566
- /* FULL_PROPS */
1567
- )) : createCommentVNode("v-if", true),
1568
- createElementVNode("input", {
1569
- id: unref(hasId),
1570
- ref_key: "inputEl",
1571
- ref: inputEl,
1572
- type: "file",
1573
- readonly: unref(readonly),
1574
- disabled: unref(disabled),
1575
- required: _ctx.required,
1576
- placeholder: _ctx.placeholder,
1577
- "aria-describedby": unref(hasHintLabelOrSlot) ? hasHintId.value : void 0,
1578
- "aria-invalid": _ctx.invalid,
1579
- "aria-errormessage": unref(hasInvalidLabelOrSlot) ? hasHintId.value : void 0,
1580
- multiple: isMultiple.value,
1581
- accept: _ctx.accept,
1582
- capture: _ctx.capture,
1583
- name: _ctx.name,
1584
- onChange
1585
- }, null, 40, _hoisted_5),
1586
- hasProgress.value ? (openBlock(), createElementBlock("progress", {
1587
- key: 1,
1588
- class: "vv-input-file__progress",
1589
- value: _ctx.progress,
1590
- max: "100"
1591
- }, toDisplayString(_ctx.progress) + "% ", 9, _hoisted_6)) : createCommentVNode("v-if", true),
1592
- unref(hasIconAfter) ? (openBlock(), createBlock(
1593
- _sfc_main$2,
1594
- normalizeProps(mergeProps({ key: 2 }, unref(hasIconAfter))),
1595
- null,
1596
- 16
1597
- /* FULL_PROPS */
1598
- )) : createCommentVNode("v-if", true)
1599
- ]),
1600
- createVNode(unref(Sortable), {
1601
- modelValue: files.value,
1602
- "onUpdate:modelValue": _cache[1] || (_cache[1] = ($event) => files.value = $event),
1603
- tag: "ul",
1604
- class: "vv-input-file__list",
1605
- "item-key": "name",
1606
- move: () => _ctx.sortable,
1607
- onEnd: onSortEnd
1608
- }, {
1609
- item: withCtx(({ element: file, index }) => [
1610
- createElementVNode("li", {
1611
- class: normalizeClass(["vv-input-file__item", {
1612
- "active": index === selectedFileIndex.value && hasDropArea.value && files.value.length > 1,
1613
- "cursor-move": _ctx.sortable
1614
- }]),
1615
- onClick: withModifiers(($event) => onClickSelectFile(index), ["stop"])
1616
- }, [
1617
- unref(hasIconDownload) ? (openBlock(), createElementBlock("button", {
1618
- key: 0,
1619
- type: "button",
1620
- class: "vv-input-file__item-action",
1621
- title: _ctx.labelDownload,
1622
- onClick: withModifiers(($event) => onClickDownloadFile(file), ["stop"])
1623
- }, [
1624
- createVNode(
1625
- _sfc_main$2,
1626
- normalizeProps(guardReactiveProps(unref(hasIconDownload))),
1627
- null,
1628
- 16
1629
- /* FULL_PROPS */
1630
- )
1631
- ], 8, _hoisted_8)) : createCommentVNode("v-if", true),
1632
- createElementVNode(
1633
- "div",
1634
- _hoisted_9,
1635
- toDisplayString(file.name),
1636
- 1
1637
- /* TEXT */
1638
- ),
1639
- createElementVNode(
1640
- "small",
1641
- _hoisted_10,
1642
- toDisplayString(formatBytes(file.size)),
1643
- 1
1644
- /* TEXT */
1645
- ),
1646
- !unref(readonly) ? (openBlock(), createElementBlock("button", {
1647
- key: 1,
1648
- type: "button",
1649
- class: "vv-input-file__item-remove",
1650
- title: _ctx.labelRemove,
1651
- disabled: unref(disabled),
1652
- onClick: withModifiers(($event) => onClickRemoveFile(index), ["stop"])
1653
- }, null, 8, _hoisted_11)) : createCommentVNode("v-if", true)
1654
- ], 10, _hoisted_7)
1655
- ]),
1656
- _: 1
1657
- /* STABLE */
1658
- }, 8, ["modelValue", "move"]),
1659
- createVNode(unref(HintSlot), {
1660
- id: hasHintId.value,
1661
- class: "vv-input-file__hint"
1662
- }, createSlots({
1663
- _: 2
1664
- /* DYNAMIC */
1665
- }, [
1666
- _ctx.$slots.hint ? {
1667
- name: "hint",
1668
- fn: withCtx(() => [
1669
- renderSlot(_ctx.$slots, "hint", normalizeProps(guardReactiveProps(unref(hintSlotScope))))
1670
- ]),
1671
- key: "0"
1672
- } : void 0,
1673
- _ctx.$slots.loading ? {
1674
- name: "loading",
1675
- fn: withCtx(() => [
1676
- renderSlot(_ctx.$slots, "loading", normalizeProps(guardReactiveProps(unref(hintSlotScope))))
1677
- ]),
1678
- key: "1"
1679
- } : void 0,
1680
- _ctx.$slots.valid ? {
1681
- name: "valid",
1682
- fn: withCtx(() => [
1683
- renderSlot(_ctx.$slots, "valid", normalizeProps(guardReactiveProps(unref(hintSlotScope))))
1684
- ]),
1685
- key: "2"
1686
- } : void 0,
1687
- _ctx.$slots.invalid ? {
1688
- name: "invalid",
1689
- fn: withCtx(() => [
1690
- renderSlot(_ctx.$slots, "invalid", normalizeProps(guardReactiveProps(unref(hintSlotScope))))
1691
- ]),
1692
- key: "3"
1693
- } : void 0
1694
- ]), 1032, ["id"])
1695
- ],
1696
- 2
1697
- /* CLASS */
1698
- );
1699
- };
1700
- }
1701
- });
1702
- export {
1703
- _sfc_main as default
1704
- };
1
+ import{computed as e,isRef as l,defineComponent as t,h as a,inject as i,toRef as o,toRefs as n,getCurrentInstance as r,ref as u,watch as s,resolveComponent as v,createBlock as d,openBlock as c,resolveDynamicComponent as f,unref as p,mergeProps as b,withCtx as y,renderSlot as m,createTextVNode as g,toDisplayString as h,mergeDefaults as S,createCommentVNode as L,useId as k,useAttrs as A,useSlots as $,createElementBlock as w,Fragment as B,onBeforeUnmount as O,normalizeClass as _,createElementVNode as x,createVNode as I,withModifiers as V,normalizeProps as j,guardReactiveProps as R,createSlots as C}from"vue";import{useVModel as N}from"@vueuse/core";import D from"vuedraggable";import{iconLoaded as F,Icon as P,addIcon as E}from"@iconify/vue";const U="add",M="edit",T="download",q={prefix:"normal"};var G=/* @__PURE__ */(e=>(e.local="local",e.session="session",e))(G||{}),H=/* @__PURE__ */(e=>(e.left="left",e.right="right",e.top="top",e.bottom="bottom",e))(H||{}),z=/* @__PURE__ */(e=>(e.before="before",e.after="after",e))(z||{}),J=/* @__PURE__ */(e=>(e.button="button",e.submit="submit",e.reset="reset",e))(J||{}),W=/* @__PURE__ */(e=>(e.nuxtLink="nuxt-link",e.routerLink="router-link",e.a="a",e.button="button",e))(W||{});const K=/* @__PURE__ */Symbol.for("volver"),Y=/* @__PURE__ */Symbol.for("buttonGroup"),Z=/* @__PURE__ */Symbol.for("dropdownTrigger"),Q=/* @__PURE__ */Symbol.for("dropdownAction"),X={to:{type:[String,Object]},href:String,target:String,rel:{type:String,default:"noopener noreferrer"}},ee={valid:{type:Boolean,default:!1},validLabel:{type:[String,Array],default:void 0}},le={invalid:{type:Boolean,default:!1},invalidLabel:{type:[String,Array],default:void 0}},te={loading:{type:Boolean,default:!1},loadingLabel:{type:String,default:"Loading..."}},ae={disabled:{type:Boolean,default:!1}},ie={required:{type:Boolean,default:!1}},oe={active:{type:Boolean,default:!1}},ne={current:{type:Boolean,default:!1}},re={pressed:{type:Boolean,default:!1}},ue={label:{type:[String,Number],default:void 0}},se={readonly:{type:Boolean,default:!1}},ve={modifiers:{type:[String,Array],default:void 0}},de={hintLabel:{type:String,default:""}},ce={icon:{type:[String,Object],default:void 0},iconPosition:{type:String,default:z.before,validation:e=>Object.values(z).includes(e)}},fe={unselectable:{type:Boolean,default:!0}},pe={id:[String,Number]};H.bottom;const be={...pe,name:{type:String,required:!0}},ye={...ae,...ue,...re,...oe,...ne,...X,type:{type:String,default:J.button,validator:e=>Object.values(J).includes(e)},ariaLabel:{type:String,default:void 0},defaultTag:{type:String,default:W.button}};G.local;const me={...be,...ve,...ee,...le,...de,...ue,...te,...se,...ae,...ie,...ce,modelValue:{type:Object},progress:{type:[Number,String],default:void 0},placeholder:{type:String,default:void 0},accept:{type:String,default:"*"},multiple:{type:Boolean,default:!1},capture:{type:String,default:void 0,validation:e=>void 0===e||["user","environment"].includes(e)},max:{type:[Number,String],default:void 0},dropArea:{type:Boolean,default:!1},sortable:{type:Boolean,default:!1},hidePreview:{type:Boolean,default:!1},labelAdd:{type:String,default:"Add file"},iconAdd:{type:[String,Object],default:U},labelReplace:{type:String,default:"Replace file"},iconReplace:{type:[String,Object],default:M},labelDownload:{type:String,default:"Downlaod file"},iconDownload:{type:[String,Object],default:T},labelRemove:{type:String,default:"Remove file"}};function ge(e,l,t){return he(e,l)}function he(e,l){if(e===l)return!0;if(e&&l&&"object"==typeof e&&"object"==typeof l){const t=Array.isArray(e),a=Array.isArray(l);let i,o,n;if(t&&a){if(o=e.length,o!==l.length)return!1;for(i=o;0!==i--;)if(!he(e[i],l[i]))return!1;return!0}if(t!==a)return!1;const r=e instanceof Date,u=l instanceof Date;if(r!==u)return!1;if(r&&u)return e.getTime()===l.getTime();const s=e instanceof RegExp,v=l instanceof RegExp;if(s!==v)return!1;if(s&&v)return e.toString()===l.toString();const d=Object.keys(e);if(o=d.length,o!==Object.keys(l).length)return!1;for(i=o;0!==i--;)if(!Object.prototype.hasOwnProperty.call(l,d[i]))return!1;for(i=o;0!==i--;)if(n=d[i],!he(e[n],l[n]))return!1;return!0}return Number.isNaN(e)&&Number.isNaN(l)}function Se(e,l){if(null!=e&&l&&l.length)for(const t of l)if(ge(e,t))return!0;return!1}function Le(e){return Array.isArray(e)?e.filter(e=>"string"==typeof e).join(" "):e}const ke={...ye,...pe,...ve,...fe,...te,...ce,iconPosition:{type:String,default:H.left,validator:e=>Object.values(H).includes(e)},loadingIcon:{type:String,default:"eos-icons:bubble-loading"},toggle:{type:Boolean,default:!1},value:{type:[String,Number,Boolean],default:void 0},uncheckedValue:{type:[String,Number,Boolean],default:void 0},modelValue:{type:[String,Number,Boolean],default:void 0}};function Ae(l,t){const{group:a,isInGroup:r,getGroupOrLocalRef:u}=function(l){const t=i(l,void 0),a=e(()=>void 0!==t);return{group:t,isInGroup:a,getGroupOrLocalRef:function(l,a,i){const n=t?.[l];if(n)return e({get:()=>n.value,set(e){n.value=e}});const r=o(a,l);return e({get:()=>r.value,set(e){i&&i(`update:${l}`,e)}})}}}(Y),{id:s,iconPosition:v,icon:d,label:c,pressed:f}=n(l),p=u("modelValue",l,t),b=u("toggle",l),y=u("unselectable",l),m=e(()=>a?.multiple.value??!1),g=e(()=>{let e=l.modifiers,t=a?.modifiers.value;const i=/* @__PURE__ */new Set;return e&&(Array.isArray(e)||(e=e.split(" ")),e.forEach(e=>i.add(e))),t&&(Array.isArray(t)||(t=t.split(" ")),t.forEach(e=>i.add(e))),Array.from(i)}),h=e(()=>Boolean(l.disabled||a?.disabled.value));return{group:a,isInGroup:r,modelValue:p,toggle:b,unselectable:y,multiple:m,modifiers:g,disabled:h,id:s,pressed:f,iconPosition:v,icon:d,label:c}}function $e(){return i(K,void 0)}const we=/* @__PURE__ */t({name:"VvAction",props:ye,emits:["click","mouseover","mouseleave"],setup(l,{expose:t,emit:a}){const o=l,n=a,S=r(),L=$e(),k=u(null);t({$el:k});const{reference:A,bus:$,aria:w,expanded:B}=i(Z,{});s(()=>k.value,e=>{A&&(A.value=e)});const O=e(()=>o.pressed||B?.value),{role:_}=i(Q,{}),x=e(()=>{switch(!0){case o.disabled:return W.button;case void 0!==o.to:return L?.nuxt?v(W.nuxtLink):W.routerLink;case void 0!==o.href:return W.a;default:return o.defaultTag}}),I=e(()=>{const e={...w?.value,ariaPressed:!!O.value||void 0,ariaLabel:o.ariaLabel,role:_?.value};switch(x.value){case W.a:return{...e,href:o.href,target:o.target,rel:o.rel};case W.routerLink:case W.nuxtLink:return{...e,to:o.to,target:o.target};case W.button:return{...e,type:o.type,disabled:o.disabled};default:return e}});function V(e){o.disabled?e.preventDefault():S?.vnode.props?.onClick?n("click",e):$?.emit("click",e)}function j(e){S?.vnode.props?.onMouseover?n("mouseover",e):$?.emit("mouseover",e)}function R(e){S?.vnode.props?.onMouseleave?n("mouseleave",e):$?.emit("mouseleave",e)}return(e,l)=>(c(),d(f(p(x)),b(p(I),{ref_key:"rootEl",ref:k,class:{active:e.active,pressed:p(O),disabled:e.disabled,current:e.current},onClickPassive:V,onMouseoverPassive:j,onMouseleavePassive:R}),{default:y(()=>[m(e.$slots,"default",{},()=>[g(h(e.label),1)])]),_:3},16,["class"]))}});function Be(l,t,a){return e(()=>{const e={[l]:!0},i="string"==typeof t?.value?t.value.split(" "):t?.value;return i&&Array.isArray(i)&&i.forEach(t=>{t&&(e[`${l}--${t}`]=!0)}),a&&Object.keys(a.value).forEach(t=>{e[`${l}--${t}`]=p(a.value[t])}),e})}const Oe=/* @__PURE__ */t({name:"VvIcon",props:/* @__PURE__ */S({name:{},color:{},width:{},height:{},provider:{},prefix:{},src:{},horizontalFlip:{type:Boolean},verticalFlip:{type:Boolean},flip:{},mode:{},inline:{type:Boolean},rotate:{},onLoad:{type:Function},svg:{},modifiers:{}},q),setup(l){const t=l,a=e(()=>"string"==typeof t.rotate?Number.parseFloat(t.rotate):t.rotate),i=u(!0),o=$e(),{modifiers:r}=n(t),s=Be("vv-icon",r),v=e(()=>t.provider||o?.iconsProvider),f=e(()=>{const e=t.name??"",l=`@${v.value}:${t.prefix}:${e}`;if(F(l))return l;const a=o?.iconsCollections.find(l=>{const t=`@${v.value}:${l.prefix}:${e}`;return F(t)});return a?`@${v.value}:${a.prefix}:${e}`:e});function y(e){const l=function(e){let l;if("undefined"==typeof window){const{JSDOM:e}=require("jsdom");l=(new e).window}return(l?new l.DOMParser:new window.DOMParser).parseFromString(e,"text/html").querySelector("svg")}(e),a=l?.innerHTML.trim()||"";l&&a&&E(`@${v.value}:${t.prefix}:${t.name}`,{body:a,height:l.viewBox.baseVal.height,width:l.viewBox.baseVal.width})}return o&&t.src&&!F(`@${v.value}:${t.prefix}:${t.name}`)&&(i.value=!1,o.fetchIcon(t.src).then(e=>{e&&(y(e),i.value=!0)}).catch(e=>{throw new Error(`Error during fetch icon: ${e?.message}`)})),t.svg&&y(t.svg),(e,t)=>p(i)?(c(),d(p(P),b({key:0,class:p(s)},{inline:l.inline,width:l.width,height:l.height,horizontalFlip:l.horizontalFlip,verticalFlip:l.verticalFlip,flip:l.flip,rotate:p(a),color:l.color,icon:p(f)},{onLoad:l.onLoad}),null,16,["class","onLoad"])):L("v-if",!0)}});function _e(l){return e(()=>String(l?.value||k()))}function xe(l,t){const a=e(()=>"string"==typeof l?.value?{name:l?.value}:l?.value),i=e(()=>t?.value===z.before?a.value:void 0),o=e(()=>t?.value===z.after?a.value:void 0),n=e(()=>t?.value===H.left?a.value:void 0),r=e(()=>t?.value===H.right?a.value:void 0),u=e(()=>t?.value===H.top?a.value:void 0),s=e(()=>t?.value===H.bottom?a.value:void 0);return{hasIcon:a,hasIconLeft:n,hasIconRight:r,hasIconTop:u,hasIconBottom:s,hasIconBefore:i,hasIconAfter:o}}const Ie={key:1,class:"vv-button__label"},Ve={key:1,class:"vv-button__label"},je=/* @__PURE__ */t({name:"VvButton",inheritAttrs:!1,props:ke,emits:["update:modelValue"],setup(l,{expose:t,emit:a}){const i=l,o=a,n=A(),r=$(),{id:s,modifiers:v,iconPosition:f,icon:S,label:k,modelValue:O,disabled:_,toggle:x,unselectable:I}=Ae(i,o),V=_e(s),j=e(()=>n?.name||V.value),R=u(null);t({$el:e(()=>R.value?.$el)});const C=e(()=>x.value?Array.isArray(O.value)?Se(j.value,O.value):ge(j.value,O.value):i.pressed),N=Be("vv-button",v,e(()=>({reverse:[H.right,H.bottom].includes(f.value),column:[H.top,H.bottom].includes(f.value),"icon-only":Boolean(S?.value&&!k?.value&&!r.default)}))),{hasIcon:D}=xe(S),F=e(()=>void 0!==i.value?i.value:j.value),P=e(()=>{if(x.value)return{onClick:E}});function E(){if(x.value){if(Array.isArray(O.value))return Se(F.value,O.value)?void(I.value&&(O.value=O.value.filter(e=>e!==F.value))):void O.value.push(F.value);if(F.value===O.value&&I.value)return void(O.value=i.uncheckedValue);O.value=F.value}}return(e,l)=>(c(),d(we,b({...p(n),...p(P),disabled:p(_),pressed:p(C),active:e.active,type:e.type,to:e.to,href:e.href,target:e.target,rel:e.rel,ariaLabel:e.ariaLabel},{id:p(V),ref_key:"rootEl",ref:R,class:p(N)}),{default:y(()=>[m(e.$slots,"default",{},()=>[e.loading?m(e.$slots,"loading",{key:0},()=>[e.loadingIcon?(c(),d(Oe,{key:0,class:"vv-button__loading-icon",name:e.loadingIcon},null,8,["name"])):L("v-if",!0),e.loadingLabel?(c(),w("span",Ie,h(e.loadingLabel),1)):L("v-if",!0)]):(c(),w(B,{key:1},[m(e.$slots,"before"),p(D)?(c(),d(Oe,b({key:0},p(D),{class:"vv-button__icon"}),null,16)):L("v-if",!0),p(k)?(c(),w("span",Ve,[m(e.$slots,"label",{},()=>[g(h(p(k)),1)])])):L("v-if",!0),m(e.$slots,"after")],64))])]),_:3},16,["id","class"]))}});const Re=["for"],Ce={class:"vv-input-file__preview"},Ne=["src","alt"],De={class:"vv-input-file__wrapper"},Fe=["id","readonly","disabled","required","placeholder","aria-describedby","aria-invalid","aria-errormessage","multiple","accept","capture","name"],Pe=["value"],Ee=["onClick"],Ue=["title","onClick"],Me={class:"vv-input-file__item-name"},Te={class:"vv-input-file__item-info"},qe=["title","disabled","onClick"],Ge=/* @__PURE__ */t({name:"VvInputFile",props:me,emits:["remove","download","update:modelValue"],setup(i,{emit:o}){const r=i,v=o,f=$(),g=function(l,t,a){const i=$e(),o=e(()=>{if(i&&i.defaults.value?.[l])return i.defaults.value[l]});return e(()=>{if(void 0===o.value)return a;const e=o.value,l=t,i=a;return Object.keys(l).reduce((t,a)=>{const o=i[a];if(t[a]=o,a in e){if(Array.isArray(l[a])){const i=l[a];i.length&&i[0]===o&&(t[a]=e[a])}if("function"==typeof l[a]&&(0,l[a])()===o&&(t[a]=e[a]),"object"==typeof l[a]){let i=l[a].default;"function"==typeof i&&(i=i()),"object"==typeof i?JSON.stringify(i)===JSON.stringify(o)&&(t[a]=e[a]):i===o&&(t[a]=e[a])}}return t},{})})}("VvInputFile",me,r),{modifiers:S,id:k,readonly:A,disabled:B,icon:F,iconPosition:P,iconDownload:E}=n(r),U=_e(k),M=e(()=>`${U.value}-hint`),T=e(()=>{if(!r.progress)return!1;const e="string"==typeof r.progress?Number.parseInt(r.progress):r.progress;return e>0&&e<100}),{hasIconBefore:q,hasIconAfter:G}=xe(F,P),{hasIcon:H}=xe(E),z=Be("vv-input-file",S,e(()=>({valid:!0===r.valid,invalid:!0===r.invalid,loading:r.loading&&!T.value,disabled:r.disabled,required:r.required,readonly:r.readonly,dragging:ae.value,"icon-before":!!q.value,"icon-after":!!G.value,"drop-area":le.value}))),{HintSlot:J,hasHintLabelOrSlot:W,hasInvalidLabelOrSlot:K,hintSlotScope:Y}=function(i,o){const n=e(()=>l(i)?i.value:i),r=e(()=>Le(n.value.invalidLabel)),u=e(()=>Le(n.value.validLabel)),s=e(()=>n.value.loadingLabel),v=e(()=>n.value.hintLabel),d=e(()=>Boolean(n.value.loading&&(o.loading||s.value))),c=e(()=>!d.value&&Boolean(n.value.invalid&&(o.invalid||r.value))),f=e(()=>!d.value&&!c.value&&Boolean(n.value.valid&&(o.valid||u.value))),p=e(()=>!d.value&&!c.value&&!f.value&&Boolean(o.hint||v.value)),b=e(()=>c.value||f.value||d.value||p.value),y=e(()=>({modelValue:n.value.modelValue,valid:n.value.valid,invalid:n.value.invalid,loading:n.value.loading})),m=t({name:"HintSlot",props:{tag:{type:String,default:"small"}},setup:()=>({isVisible:b,invalidLabel:r,validLabel:u,loadingLabel:s,hintLabel:v,hasInvalidLabelOrSlot:c,hasValidLabelOrSlot:f,hasLoadingLabelOrSlot:d,hasHintLabelOrSlot:p}),render(){if(this.isVisible){let e;return this.hasInvalidLabelOrSlot&&(e="alert"),this.hasValidLabelOrSlot&&(e="status"),this.hasLoadingLabelOrSlot?a(this.tag,{role:e},this.$slots.loading?.()??this.loadingLabel):this.hasInvalidLabelOrSlot?a(this.tag,{role:e},this.$slots.invalid?.()??this.$slots.invalid??this.invalidLabel):this.hasValidLabelOrSlot?a(this.tag,{role:e},this.$slots.valid?.()??this.validLabel):a(this.tag,{role:e},this.$slots.hint?.()??this.$slots.hint??this.hintLabel)}return null}});return{hasInvalidLabelOrSlot:c,hasHintLabelOrSlot:p,hasValidLabelOrSlot:f,hasLoadingLabelOrSlot:d,hintSlotScope:y,HintSlot:m}}(g,f),Z=N(r,"modelValue",v),Q=e({get:()=>Z.value&&(Array.isArray(Z.value)||Z.value?.name)?Array.isArray(Z.value)?Z.value:[Z.value]:[],set:e=>{te.value?Z.value=e:Z.value=e?.[0]}}),X=e(()=>r.disabled||r.readonly),ee=e(()=>"string"==typeof r.max?Number.parseInt(r.max):r.max),le=e(()=>r.dropArea&&!X.value),te=e(()=>!!r.multiple&&(!ee.value||ee.value-Q.value.length>1)),ae=u(!1),ie=u();function oe(){ae.value=!0}function ne(){ae.value=!1}function re(e){e.dataTransfer?.files&&(ae.value=!1,se(e.dataTransfer?.files))}function ue(){ie.value?.files&&(se(ie.value.files),ie.value.value="")}function se(e){const l=function(e,l){if(!l||""===l.trim()||"*"===l)return Array.from(e);const{mimeTypes:t,extensions:a,wildcards:i}=function(e){const l=[],t=[],a=[],i=e?.split(",").map(e=>e.trim().toLowerCase());return i?.length&&i.forEach(e=>{e.startsWith(".")?t.push(e):e.includes("/*")?a.push(e.replace("/*","")):l.push(e)}),{mimeTypes:l,extensions:t,wildcards:a}}(l);return Array.from(e).filter(e=>{const l=e.type.toLowerCase(),o=`.${e.name.split(".").pop()?.toLowerCase()}`,n=t.includes(l),r=i.some(e=>l.startsWith(`${e}/`)),u=a.some(e=>o===e.toLowerCase());return n||r||u})}(e,r.accept);if(!r.multiple)return Array.isArray(Z.value)?void(Z.value=l):void(Z.value=l[0]);let t=[];t=!Array.isArray(Z.value)&&Z.value?[Z.value]:Z.value&&Array.isArray(Z.value)?[...Z.value]:t;for(const a of l){if(ee.value&&t.length>=ee.value)break;t.push(a)}Z.value=t,ce.value=t.length-1}function ve(){ie.value&&(X.value||ie.value.click())}function de(e){const l=Array.isArray(Z.value)?Z.value[e]:Z.value;if(!l)return;if(v("remove",l),!Array.isArray(Z.value))return void(Z.value=void 0);ce.value===e&&(ce.value=0);const t=[...Z.value];t.splice(e,1),Z.value=t}const ce=u(0),fe=["image/jpeg","image/png"],pe=e(()=>{if(r.hidePreview)return;if(0===Q.value.length)return;if(!Q.value[ce.value])return;if(Q.value[ce.value]instanceof File){const e=Q.value[ce.value];if(!fe.includes(e.type))return;return URL.createObjectURL(e)}const e=Q.value[ce.value];return e.thumbnailUrl?e.thumbnailUrl:fe.includes(e.type)?e.url:void 0});function be(e,l){if(!e)return;if(0===e)return"0 Bytes";const t=l?l<=0?0:l:2,a=Math.floor(Math.log(e)/Math.log(1024));return`${Number.parseFloat((e/1024**a).toFixed(t))} ${["Bytes","KB","MB","GB","TB","PB","EB","ZB","YB"][a]}`}function ye(e){v("download",e);const l=e instanceof File?URL.createObjectURL(e):e.url;if(!l)return;const t=document.createElement("a");t.href=l,t.setAttribute("download",e.name),document.body.appendChild(t),t.click(),document.body.removeChild(t),URL.revokeObjectURL(t.href)}function ge(e){ce.value=e}s(pe,(e,l)=>{l&&URL.revokeObjectURL(l)}),O(()=>{pe.value&&URL.revokeObjectURL(pe.value)});const he=e(()=>0===Q.value.length||te.value?r.labelAdd:r.labelReplace),Se=e(()=>0===Q.value.length||te.value?r.iconAdd:r.iconReplace);function ke({newIndex:e}){null!==e&&(ce.value=e)}return(e,l)=>(c(),w("div",{class:_(p(z))},[e.label?(c(),w("label",{key:0,for:p(U)},h(e.label),9,Re)):L("v-if",!0),le.value?(c(),w("div",{key:1,class:"vv-input-file__drop-area",onDragenter:V(oe,["prevent","stop"]),onDragleave:V(ne,["prevent","stop"]),onDrop:V(re,["prevent","stop"]),onDragover:l[0]||(l[0]=V(()=>{},["prevent","stop"])),onClick:V(ve,["stop"])},[m(e.$slots,"drop-area",j(R({previewSrc:pe.value,onClickDropArea:ve})),()=>[x("picture",Ce,[pe.value?(c(),w("img",{key:0,src:pe.value,alt:Q.value[ce.value].name},null,8,Ne)):L("v-if",!0)]),p(A)?L("v-if",!0):(c(),d(je,{key:0,modifiers:"action",label:pe.value?void 0:he.value,title:pe.value?he.value:void 0,disabled:p(B),class:_({"vv-input-file__drop-area-action":pe.value}),icon:Se.value,onClick:V(ve,["stop"])},null,8,["label","title","disabled","class","icon"]))])],32)):L("v-if",!0),x("div",De,[p(q)?(c(),d(Oe,j(b({key:0},p(q))),null,16)):L("v-if",!0),x("input",{id:p(U),ref_key:"inputEl",ref:ie,type:"file",readonly:p(A),disabled:p(B),required:e.required,placeholder:e.placeholder,"aria-describedby":p(W)?M.value:void 0,"aria-invalid":e.invalid,"aria-errormessage":p(K)?M.value:void 0,multiple:te.value,accept:e.accept,capture:e.capture,name:e.name,onChange:ue},null,40,Fe),T.value?(c(),w("progress",{key:1,class:"vv-input-file__progress",value:e.progress,max:"100"},h(e.progress)+"% ",9,Pe)):L("v-if",!0),p(G)?(c(),d(Oe,j(b({key:2},p(G))),null,16)):L("v-if",!0)]),m(e.$slots,"file-list",j(R({files:Q.value,selectedFileIndex:ce.value,onSelectIndex:ge,onRemoveIndex:de,onDownloadFile:ye,formatBytes:be})),()=>[I(p(D),{modelValue:Q.value,"onUpdate:modelValue":l[1]||(l[1]=e=>Q.value=e),tag:"ul",class:"vv-input-file__list","item-key":"name",move:()=>e.sortable,onEnd:ke},{item:y(({element:l,index:t})=>[x("li",{class:_(["vv-input-file__item",{active:t===ce.value&&le.value&&Q.value.length>1,"cursor-move":e.sortable}]),onClick:V(e=>ge(t),["stop"])},[m(e.$slots,"file-item",j(R({file:l,index:t,isSelected:t===ce.value,onRemoveIndex:de,onDownloadFile:ye,formatBytes:be})),()=>[p(H)?(c(),w("button",{key:0,type:"button",class:"vv-input-file__item-action",title:e.labelDownload,onClick:V(e=>ye(l),["stop"])},[I(Oe,j(R(p(H))),null,16)],8,Ue)):L("v-if",!0),x("div",Me,h(l.name),1),x("small",Te,h(be(l.size)),1),p(A)?L("v-if",!0):(c(),w("button",{key:1,type:"button",class:"vv-input-file__item-remove",title:e.labelRemove,disabled:p(B),onClick:V(e=>de(t),["stop"])},null,8,qe))])],10,Ee)]),_:3},8,["modelValue","move"])]),I(p(J),{id:M.value,class:"vv-input-file__hint"},C({_:2},[e.$slots.hint?{name:"hint",fn:y(()=>[m(e.$slots,"hint",j(R(p(Y))))]),key:"0"}:void 0,e.$slots.loading?{name:"loading",fn:y(()=>[m(e.$slots,"loading",j(R(p(Y))))]),key:"1"}:void 0,e.$slots.valid?{name:"valid",fn:y(()=>[m(e.$slots,"valid",j(R(p(Y))))]),key:"2"}:void 0,e.$slots.invalid?{name:"invalid",fn:y(()=>[m(e.$slots,"invalid",j(R(p(Y))))]),key:"3"}:void 0]),1032,["id"])],2))}});export{Ge as default};