@volverjs/ui-vue 0.0.10-beta.11 → 0.0.10-beta.13

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 (47) hide show
  1. package/auto-imports.d.ts +1 -0
  2. package/dist/components/VvInputFile/VvInputFile.es.js +1529 -0
  3. package/dist/components/VvInputFile/VvInputFile.umd.js +1 -0
  4. package/dist/components/VvInputFile/VvInputFile.vue.d.ts +141 -0
  5. package/dist/components/VvInputFile/index.d.ts +52 -0
  6. package/dist/components/VvTab/VvTab.es.js +2 -2
  7. package/dist/components/VvTab/VvTab.umd.js +1 -1
  8. package/dist/components/VvTab/VvTab.vue.d.ts +1 -0
  9. package/dist/components/index.d.ts +1 -0
  10. package/dist/components/index.es.js +635 -312
  11. package/dist/components/index.umd.js +1 -1
  12. package/dist/composables/index.d.ts +1 -0
  13. package/dist/composables/index.es.js +77 -1
  14. package/dist/composables/index.umd.js +1 -1
  15. package/dist/composables/useBlurhash.d.ts +7 -0
  16. package/dist/icons.es.js +3 -3
  17. package/dist/icons.umd.js +1 -1
  18. package/dist/stories/AlertGroup/AlertGroupWithComposable.stories.d.ts +1 -1
  19. package/dist/stories/Blurhash/BlurhashComposable.stories.d.ts +4 -0
  20. package/dist/stories/InputFile/InputFile.settings.d.ts +56 -0
  21. package/dist/stories/InputFile/InputFile.stories.d.ts +12 -0
  22. package/dist/stories/InputFile/InputFileModifiers.stories.d.ts +9 -0
  23. package/dist/stories/InputFile/InputFileSlots.stories.d.ts +6 -0
  24. package/dist/types/blurhash.d.ts +12 -0
  25. package/dist/types/index.d.ts +2 -0
  26. package/dist/types/input-file.d.ts +14 -0
  27. package/dist/workers/blurhash.d.ts +1 -0
  28. package/package.json +13 -1
  29. package/src/assets/icons/detailed.json +1 -1
  30. package/src/assets/icons/normal.json +1 -1
  31. package/src/assets/icons/simple.json +1 -1
  32. package/src/components/VvInputFile/VvInputFile.vue +274 -0
  33. package/src/components/VvInputFile/index.ts +36 -0
  34. package/src/components/VvTab/VvTab.vue +2 -2
  35. package/src/components/index.ts +1 -0
  36. package/src/composables/index.ts +1 -0
  37. package/src/composables/useBlurhash.ts +76 -0
  38. package/src/stories/AlertGroup/AlertGroupWithComposable.stories.ts +2 -2
  39. package/src/stories/Blurhash/BlurhashComposable.stories.ts +195 -0
  40. package/src/stories/InputFile/InputFile.settings.ts +36 -0
  41. package/src/stories/InputFile/InputFile.stories.ts +90 -0
  42. package/src/stories/InputFile/InputFileModifiers.stories.ts +51 -0
  43. package/src/stories/InputFile/InputFileSlots.stories.ts +25 -0
  44. package/src/types/blurhash.ts +21 -0
  45. package/src/types/index.ts +2 -0
  46. package/src/types/input-file.ts +16 -0
  47. package/src/workers/blurhash.ts +9 -0
@@ -0,0 +1,1529 @@
1
+ import { inject, computed, unref, defineComponent, ref, toRefs, openBlock, createBlock, mergeProps, createCommentVNode, watch, resolveDynamicComponent, withCtx, renderSlot, createTextVNode, toDisplayString, toRef, useAttrs, useSlots, createElementBlock, Fragment, isRef, h, onBeforeUnmount, normalizeClass, withModifiers, createVNode, createElementVNode, renderList, createSlots, normalizeProps, guardReactiveProps } from "vue";
2
+ import { useVModel } from "@vueuse/core";
3
+ import { iconExists, Icon, addIcon } from "@iconify/vue";
4
+ import { uid } from "uid";
5
+ const VvIconProps = {
6
+ /**
7
+ * Color
8
+ */
9
+ color: String,
10
+ /**
11
+ * Width
12
+ */
13
+ width: {
14
+ type: [String, Number]
15
+ },
16
+ /**
17
+ * Height
18
+ */
19
+ height: {
20
+ type: [String, Number]
21
+ },
22
+ /**
23
+ * Icon name
24
+ * Can be the full composition of iconify name "@{provider}:{prefix}:{name}" or "{prefix}:{name}" or "{name}"
25
+ * https://docs.iconify.design/api/providers.html#provider-in-icon-name
26
+ */
27
+ name: {
28
+ type: String,
29
+ required: true
30
+ },
31
+ /**
32
+ * By default 'vv'
33
+ * If custom collection is not added with "addCollection" DS class method, this prop could not be used
34
+ * Icon provider: https://docs.iconify.design/api/providers.html#provider-in-icon-name
35
+ */
36
+ provider: {
37
+ type: String
38
+ },
39
+ /**
40
+ * The name of icon set.
41
+ * Icon default options prefix: simple | normal | detailed
42
+ */
43
+ prefix: {
44
+ type: String,
45
+ default: "normal"
46
+ },
47
+ /**
48
+ * Url remote SVG icon
49
+ */
50
+ src: String,
51
+ /**
52
+ * Horizontal flip
53
+ */
54
+ horizontalFlip: Boolean,
55
+ /**
56
+ * Vertical flip
57
+ */
58
+ verticalFlip: Boolean,
59
+ /**
60
+ * String alternative to "horizontalFlip" and "verticalFlip".
61
+ * Example: https://docs.iconify.design/icon-components/vue/transform.html
62
+ */
63
+ flip: String,
64
+ /**
65
+ * Icon render mode
66
+ * 'style' = 'bg' or 'mask', depending on icon content
67
+ * 'bg' = span with style using `background`
68
+ * 'mask' = span with style using `mask`
69
+ * 'svg' = svg
70
+ * Iconify doc: https://docs.iconify.design/iconify-icon/modes.html
71
+ */
72
+ mode: String,
73
+ /**
74
+ * Toggles inline or block mode
75
+ * Example https://docs.iconify.design/icon-components/vue/inline.html
76
+ */
77
+ inline: Boolean,
78
+ /**
79
+ * rotates icon
80
+ * Example https://docs.iconify.design/icon-components/vue/transform.html
81
+ */
82
+ rotate: [Number, String],
83
+ /**
84
+ * A callback that is called when icon data has been loaded
85
+ */
86
+ onLoad: Function,
87
+ /**
88
+ * SVG icon string
89
+ */
90
+ svg: String,
91
+ /**
92
+ * Icon modifiers: vv-icon css helper classes, value/s are concatened with prefix 'vv-icon--'
93
+ * @values string | string[]
94
+ */
95
+ modifiers: {
96
+ type: [String, Array]
97
+ }
98
+ };
99
+ var Strategy = /* @__PURE__ */ ((Strategy2) => {
100
+ Strategy2["absolute"] = "absolute";
101
+ Strategy2["fixed"] = "fixed";
102
+ return Strategy2;
103
+ })(Strategy || {});
104
+ var Side = /* @__PURE__ */ ((Side2) => {
105
+ Side2["left"] = "left";
106
+ Side2["right"] = "right";
107
+ Side2["top"] = "top";
108
+ Side2["bottom"] = "bottom";
109
+ return Side2;
110
+ })(Side || {});
111
+ var Placement = /* @__PURE__ */ ((Placement2) => {
112
+ Placement2["topStart"] = "top-start";
113
+ Placement2["topEnd"] = "top-end";
114
+ Placement2["bottomStart"] = "bottom-start";
115
+ Placement2["bottomEnd"] = "bottom-end";
116
+ Placement2["leftStart"] = "left-start";
117
+ Placement2["leftEnd"] = "left-end";
118
+ Placement2["rightStart"] = "right-start";
119
+ Placement2["rightEnd"] = "right-end";
120
+ return Placement2;
121
+ })(Placement || {});
122
+ var Position = /* @__PURE__ */ ((Position2) => {
123
+ Position2["before"] = "before";
124
+ Position2["after"] = "after";
125
+ return Position2;
126
+ })(Position || {});
127
+ var ButtonType = /* @__PURE__ */ ((ButtonType2) => {
128
+ ButtonType2["button"] = "button";
129
+ ButtonType2["submit"] = "submit";
130
+ ButtonType2["reset"] = "reset";
131
+ return ButtonType2;
132
+ })(ButtonType || {});
133
+ var ActionTag = /* @__PURE__ */ ((ActionTag2) => {
134
+ ActionTag2["nuxtLink"] = "nuxt-link";
135
+ ActionTag2["routerLink"] = "router-link";
136
+ ActionTag2["a"] = "a";
137
+ ActionTag2["button"] = "button";
138
+ return ActionTag2;
139
+ })(ActionTag || {});
140
+ var AnchorTarget = /* @__PURE__ */ ((AnchorTarget2) => {
141
+ AnchorTarget2["_blank"] = "_blank";
142
+ AnchorTarget2["_self"] = "_self";
143
+ AnchorTarget2["_parent"] = "_parent";
144
+ AnchorTarget2["_top"] = "_top";
145
+ return AnchorTarget2;
146
+ })(AnchorTarget || {});
147
+ const INJECTION_KEY_VOLVER = Symbol.for("volver");
148
+ const INJECTION_KEY_BUTTON_GROUP = Symbol.for("buttonGroup");
149
+ const INJECTION_KEY_DROPDOWN_TRIGGER = Symbol.for(
150
+ "dropdownTrigger"
151
+ );
152
+ const INJECTION_KEY_DROPDOWN_ACTION = Symbol.for(
153
+ "dropdownAction"
154
+ );
155
+ function useVolver() {
156
+ return inject(INJECTION_KEY_VOLVER);
157
+ }
158
+ function useModifiers(prefix, modifiers, others) {
159
+ return computed(() => {
160
+ const toReturn = {
161
+ [prefix]: true
162
+ };
163
+ const modifiersArray = typeof (modifiers == null ? void 0 : modifiers.value) === "string" ? modifiers.value.split(" ") : modifiers == null ? void 0 : modifiers.value;
164
+ if (modifiersArray) {
165
+ if (Array.isArray(modifiersArray)) {
166
+ modifiersArray.forEach((modifier) => {
167
+ if (modifier) {
168
+ toReturn[`${prefix}--${modifier}`] = true;
169
+ }
170
+ });
171
+ }
172
+ }
173
+ if (others) {
174
+ Object.keys(others.value).forEach((key) => {
175
+ toReturn[`${prefix}--${key}`] = unref(others.value[key]);
176
+ });
177
+ }
178
+ return toReturn;
179
+ });
180
+ }
181
+ const __default__$3 = {
182
+ name: "VvIcon"
183
+ };
184
+ const _sfc_main$3 = /* @__PURE__ */ defineComponent({
185
+ ...__default__$3,
186
+ props: VvIconProps,
187
+ setup(__props) {
188
+ const props = __props;
189
+ const hasRotate = computed(() => {
190
+ if (typeof props.rotate === "string") {
191
+ return parseFloat(props.rotate);
192
+ }
193
+ return props.rotate;
194
+ });
195
+ const show = ref(true);
196
+ const volver = useVolver();
197
+ const { modifiers } = toRefs(props);
198
+ const bemCssClasses = useModifiers("vv-icon", modifiers);
199
+ const provider = computed(() => {
200
+ return props.provider || (volver == null ? void 0 : volver.iconsProvider);
201
+ });
202
+ const icon = computed(() => {
203
+ const name = props.name ?? "";
204
+ const iconName = `@${provider.value}:${props.prefix}:${name}`;
205
+ if (iconExists(iconName)) {
206
+ return iconName;
207
+ }
208
+ const iconsCollection = volver == null ? void 0 : volver.iconsCollections.find(
209
+ (iconsCollection2) => {
210
+ const icon2 = `@${provider.value}:${iconsCollection2.prefix}:${name}`;
211
+ return iconExists(icon2);
212
+ }
213
+ );
214
+ if (iconsCollection) {
215
+ return `@${provider.value}:${iconsCollection.prefix}:${name}`;
216
+ }
217
+ return name;
218
+ });
219
+ function getSvgContent(svg) {
220
+ let dom;
221
+ if (typeof window === "undefined") {
222
+ const { JSDOM } = require("jsdom");
223
+ dom = new JSDOM().window;
224
+ }
225
+ const domParser = dom ? new dom.DOMParser() : new window.DOMParser();
226
+ const svgDomString = domParser.parseFromString(svg, "text/html");
227
+ const svgEl = svgDomString.querySelector("svg");
228
+ return svgEl;
229
+ }
230
+ function addIconFromSvg(svg) {
231
+ const svgContentEl = getSvgContent(svg);
232
+ const svgContent = (svgContentEl == null ? void 0 : svgContentEl.innerHTML.trim()) || "";
233
+ if (svgContentEl && svgContent) {
234
+ addIcon(`@${provider.value}:${props.prefix}:${props.name}`, {
235
+ body: svgContent,
236
+ // Set height and width from svg content
237
+ height: svgContentEl.viewBox.baseVal.height,
238
+ width: svgContentEl.viewBox.baseVal.width
239
+ });
240
+ }
241
+ }
242
+ if (volver) {
243
+ if (props.src && !iconExists(`@${provider.value}:${props.prefix}:${props.name}`)) {
244
+ show.value = false;
245
+ volver.fetchIcon(props.src).then((svg) => {
246
+ if (svg) {
247
+ addIconFromSvg(svg);
248
+ show.value = true;
249
+ }
250
+ }).catch((e) => {
251
+ throw new Error(`Error during fetch icon: ${e == null ? void 0 : e.message}`);
252
+ });
253
+ }
254
+ }
255
+ if (props.svg) {
256
+ addIconFromSvg(props.svg);
257
+ }
258
+ return (_ctx, _cache) => {
259
+ return unref(show) ? (openBlock(), createBlock(unref(Icon), mergeProps({
260
+ key: 0,
261
+ class: unref(bemCssClasses)
262
+ }, {
263
+ inline: _ctx.inline,
264
+ width: _ctx.width,
265
+ height: _ctx.height,
266
+ horizontalFlip: _ctx.horizontalFlip,
267
+ verticalFlip: _ctx.verticalFlip,
268
+ flip: _ctx.flip,
269
+ rotate: unref(hasRotate),
270
+ color: _ctx.color,
271
+ onLoad: _ctx.onLoad,
272
+ icon: unref(icon)
273
+ }), null, 16, ["class"])) : createCommentVNode("v-if", true);
274
+ };
275
+ }
276
+ });
277
+ const LinkProps = {
278
+ /**
279
+ * The router-link/nuxt-link property, if it is defined the button is rendered as a ruouter-link or nuxt-link.
280
+ * @see Documentation of [router-link](https://router.vuejs.org/api/#router-link) and [nuxt-link](https://nuxtjs.org/api/components-nuxt-link/)
281
+ */
282
+ to: {
283
+ type: [String, Object]
284
+ },
285
+ /**
286
+ * Anchor href
287
+ */
288
+ href: String,
289
+ /**
290
+ * Anchor target
291
+ */
292
+ target: {
293
+ type: String,
294
+ validator: (value) => Object.values(AnchorTarget).includes(value)
295
+ },
296
+ /**
297
+ * Anchor rel
298
+ */
299
+ rel: {
300
+ type: String,
301
+ default: "noopener noreferrer"
302
+ }
303
+ };
304
+ const ValidProps = {
305
+ /**
306
+ * Valid status
307
+ */
308
+ valid: Boolean,
309
+ /**
310
+ * Valid label
311
+ */
312
+ validLabel: [String, Array]
313
+ };
314
+ const InvalidProps = {
315
+ /**
316
+ * Invalid status
317
+ */
318
+ invalid: Boolean,
319
+ /**
320
+ * Invalid label
321
+ */
322
+ invalidLabel: [String, Array]
323
+ };
324
+ const LoadingProps = {
325
+ /**
326
+ * Loading status
327
+ */
328
+ loading: Boolean,
329
+ /**
330
+ * Loading label
331
+ */
332
+ loadingLabel: {
333
+ type: String,
334
+ default: "Loading..."
335
+ }
336
+ };
337
+ const DisabledProps = {
338
+ /**
339
+ * Whether the form control is disabled
340
+ */
341
+ disabled: Boolean
342
+ };
343
+ const ActiveProps = {
344
+ /**
345
+ * Whether the item is active
346
+ */
347
+ active: Boolean
348
+ };
349
+ const CurrentProps = {
350
+ /**
351
+ * Whether the item is current
352
+ */
353
+ current: Boolean
354
+ };
355
+ const PressedProps = {
356
+ /**
357
+ * Whether the item is pressed
358
+ */
359
+ pressed: Boolean
360
+ };
361
+ const LabelProps = {
362
+ /**
363
+ * The item label
364
+ */
365
+ label: [String, Number]
366
+ };
367
+ const ModifiersProps = {
368
+ /**
369
+ * Component BEM modifiers
370
+ */
371
+ modifiers: [String, Array]
372
+ };
373
+ const HintProps = {
374
+ hintLabel: { type: String, default: "" }
375
+ };
376
+ ({
377
+ /**
378
+ * VvIcon name or props
379
+ * @see VVIcon
380
+ */
381
+ icon: { type: [String, Object] },
382
+ /**
383
+ * VvIcon position
384
+ */
385
+ iconPosition: {
386
+ type: String,
387
+ default: Position.before,
388
+ validation: (value) => Object.values(Position).includes(value)
389
+ }
390
+ });
391
+ const UnselectableProps = {
392
+ /**
393
+ * If true the input will be unselectable
394
+ */
395
+ unselectable: { type: Boolean, default: true }
396
+ };
397
+ const IdProps = {
398
+ /**
399
+ * Global attribute id
400
+ * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/id
401
+ */
402
+ id: [String, Number]
403
+ };
404
+ ({
405
+ /**
406
+ * Dropdown placement
407
+ */
408
+ placement: {
409
+ type: String,
410
+ default: Side.bottom,
411
+ validator: (value) => Object.values(Side).includes(value) || Object.values(Placement).includes(value)
412
+ },
413
+ /**
414
+ * Dropdown strategy
415
+ */
416
+ strategy: {
417
+ type: String,
418
+ default: void 0,
419
+ validator: (value) => Object.values(Strategy).includes(value)
420
+ },
421
+ /**
422
+ * Dropdown show / hide transition name
423
+ */
424
+ transitionName: {
425
+ type: String
426
+ },
427
+ /**
428
+ * Offset of the dropdown from the trigger
429
+ * @see https://floating-ui.com/docs/offset
430
+ */
431
+ offset: {
432
+ type: [Number, String, Object],
433
+ default: 0
434
+ },
435
+ /**
436
+ * Move dropdown to the side if there is no space in the default position
437
+ * @see https://floating-ui.com/docs/shift
438
+ */
439
+ shift: {
440
+ type: [Boolean, Object],
441
+ default: false
442
+ },
443
+ /**
444
+ * Flip dropdown position if there is no space in the default position
445
+ * @see https://floating-ui.com/docs/flip
446
+ */
447
+ flip: {
448
+ type: [Boolean, Object],
449
+ default: true
450
+ },
451
+ /**
452
+ * Size of the dropdown
453
+ * @see https://floating-ui.com/docs/size
454
+ */
455
+ size: {
456
+ type: [Boolean, Object],
457
+ default: () => ({ padding: 10 })
458
+ },
459
+ /**
460
+ * Automatically change the position of the dropdown
461
+ * @see https://floating-ui.com/docs/autoPlacement
462
+ */
463
+ autoPlacement: {
464
+ type: [Boolean, Object],
465
+ default: false
466
+ },
467
+ /**
468
+ * Add arrow to the dropdown
469
+ * @see https://floating-ui.com/docs/arrow
470
+ */
471
+ arrow: {
472
+ type: Boolean,
473
+ default: false
474
+ },
475
+ /**
476
+ * Keep open dropdown on click outside
477
+ */
478
+ keepOpen: {
479
+ type: Boolean,
480
+ default: false
481
+ },
482
+ /**
483
+ * Autofocus first item on dropdown open
484
+ */
485
+ autofocusFirst: {
486
+ type: Boolean,
487
+ default: true
488
+ },
489
+ /**
490
+ * Set dropdown width to the same as the trigger
491
+ */
492
+ triggerWidth: {
493
+ type: Boolean
494
+ }
495
+ });
496
+ const ActionProps = {
497
+ ...DisabledProps,
498
+ ...LabelProps,
499
+ ...PressedProps,
500
+ ...ActiveProps,
501
+ ...CurrentProps,
502
+ ...LinkProps,
503
+ /**
504
+ * Button type
505
+ */
506
+ type: {
507
+ type: String,
508
+ default: ButtonType.button,
509
+ validator: (value) => Object.values(ButtonType).includes(value)
510
+ },
511
+ /**
512
+ * Button aria-label
513
+ */
514
+ ariaLabel: {
515
+ type: String,
516
+ default: void 0
517
+ },
518
+ /**
519
+ * Default tag for the action
520
+ */
521
+ defaultTag: {
522
+ type: String,
523
+ default: ActionTag.button
524
+ }
525
+ };
526
+ const VvActionEvents = ["click", "mouseover", "mouseleave"];
527
+ const VvActionProps = ActionProps;
528
+ function useInjectedDropdownTrigger() {
529
+ return inject(INJECTION_KEY_DROPDOWN_TRIGGER, {});
530
+ }
531
+ function useInjectedDropdownAction() {
532
+ return inject(INJECTION_KEY_DROPDOWN_ACTION, {});
533
+ }
534
+ const __default__$2 = {
535
+ name: "VvAction"
536
+ };
537
+ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
538
+ ...__default__$2,
539
+ props: VvActionProps,
540
+ emits: VvActionEvents,
541
+ setup(__props, { expose: __expose, emit }) {
542
+ const props = __props;
543
+ const volver = useVolver();
544
+ const element = ref(null);
545
+ __expose({ $el: element });
546
+ const {
547
+ reference: dropdownTriggerReference,
548
+ bus: dropdownEventBus,
549
+ aria: dropdownAria,
550
+ expanded: dropdownExpanded
551
+ } = useInjectedDropdownTrigger();
552
+ watch(
553
+ () => element.value,
554
+ (newValue) => {
555
+ if (dropdownTriggerReference) {
556
+ dropdownTriggerReference.value = newValue;
557
+ }
558
+ }
559
+ );
560
+ const pressed = computed(() => {
561
+ return props.pressed || (dropdownExpanded == null ? void 0 : dropdownExpanded.value);
562
+ });
563
+ const { role } = useInjectedDropdownAction();
564
+ const hasTag = computed(() => {
565
+ switch (true) {
566
+ case props.disabled:
567
+ return ActionTag.button;
568
+ case props.to !== void 0:
569
+ return (volver == null ? void 0 : volver.nuxt) ? ActionTag.nuxtLink : ActionTag.routerLink;
570
+ case props.href !== void 0:
571
+ return ActionTag.a;
572
+ default:
573
+ return props.defaultTag;
574
+ }
575
+ });
576
+ const hasProps = computed(() => {
577
+ const toReturn = {
578
+ ...dropdownAria == null ? void 0 : dropdownAria.value,
579
+ ariaPressed: pressed.value ? true : void 0,
580
+ ariaLabel: props.ariaLabel,
581
+ role: role == null ? void 0 : role.value
582
+ };
583
+ switch (hasTag.value) {
584
+ case ActionTag.a:
585
+ return {
586
+ ...toReturn,
587
+ href: props.href,
588
+ target: props.target,
589
+ rel: props.rel
590
+ };
591
+ case ActionTag.routerLink:
592
+ case ActionTag.nuxtLink:
593
+ return {
594
+ ...toReturn,
595
+ to: props.to,
596
+ target: props.target
597
+ };
598
+ case ActionTag.button:
599
+ return {
600
+ ...toReturn,
601
+ type: props.type,
602
+ disabled: props.disabled
603
+ };
604
+ default:
605
+ return toReturn;
606
+ }
607
+ });
608
+ const onClick = (e) => {
609
+ if (props.disabled) {
610
+ e.preventDefault();
611
+ return;
612
+ }
613
+ dropdownEventBus == null ? void 0 : dropdownEventBus.emit("click", e);
614
+ emit("click", e);
615
+ };
616
+ const onMouseover = (e) => {
617
+ dropdownEventBus == null ? void 0 : dropdownEventBus.emit("mouseover", e);
618
+ emit("mouseover", e);
619
+ };
620
+ const onMouseleave = (e) => {
621
+ dropdownEventBus == null ? void 0 : dropdownEventBus.emit("mouseleave", e);
622
+ emit("mouseleave", e);
623
+ };
624
+ return (_ctx, _cache) => {
625
+ return openBlock(), createBlock(resolveDynamicComponent(unref(hasTag)), mergeProps(unref(hasProps), {
626
+ ref_key: "element",
627
+ ref: element,
628
+ class: {
629
+ active: _ctx.active,
630
+ pressed: unref(pressed),
631
+ disabled: _ctx.disabled,
632
+ current: _ctx.current
633
+ },
634
+ onClickPassive: onClick,
635
+ onMouseoverPassive: onMouseover,
636
+ onMouseleavePassive: onMouseleave
637
+ }), {
638
+ default: withCtx(() => [
639
+ renderSlot(_ctx.$slots, "default", {}, () => [
640
+ createTextVNode(
641
+ toDisplayString(_ctx.label),
642
+ 1
643
+ /* TEXT */
644
+ )
645
+ ])
646
+ ]),
647
+ _: 3
648
+ /* FORWARDED */
649
+ }, 16, ["class"]);
650
+ };
651
+ }
652
+ });
653
+ function equals(obj1, obj2, field) {
654
+ if (field) {
655
+ return resolveFieldData(obj1, field) === resolveFieldData(obj2, field);
656
+ }
657
+ return deepEquals(obj1, obj2);
658
+ }
659
+ function deepEquals(a, b) {
660
+ if (a === b)
661
+ return true;
662
+ if (a && b && typeof a == "object" && typeof b == "object") {
663
+ const arrA = Array.isArray(a);
664
+ const arrB = Array.isArray(b);
665
+ let i, length, key;
666
+ if (arrA && arrB) {
667
+ length = a.length;
668
+ if (length != b.length)
669
+ return false;
670
+ for (i = length; i-- !== 0; )
671
+ if (!deepEquals(a[i], b[i]))
672
+ return false;
673
+ return true;
674
+ }
675
+ if (arrA != arrB)
676
+ return false;
677
+ const dateA = a instanceof Date, dateB = b instanceof Date;
678
+ if (dateA != dateB)
679
+ return false;
680
+ if (dateA && dateB)
681
+ return a.getTime() == b.getTime();
682
+ const regexpA = a instanceof RegExp, regexpB = b instanceof RegExp;
683
+ if (regexpA != regexpB)
684
+ return false;
685
+ if (regexpA && regexpB)
686
+ return a.toString() == b.toString();
687
+ const keys = Object.keys(a);
688
+ length = keys.length;
689
+ if (length !== Object.keys(b).length)
690
+ return false;
691
+ for (i = length; i-- !== 0; )
692
+ if (!Object.prototype.hasOwnProperty.call(b, keys[i]))
693
+ return false;
694
+ for (i = length; i-- !== 0; ) {
695
+ key = keys[i];
696
+ if (!deepEquals(a[key], b[key]))
697
+ return false;
698
+ }
699
+ return true;
700
+ }
701
+ return a !== a && b !== b;
702
+ }
703
+ function resolveFieldData(data, field) {
704
+ if (data && Object.keys(data).length && field) {
705
+ if (field.indexOf(".") === -1) {
706
+ return data[field];
707
+ } else {
708
+ const fields = field.split(".");
709
+ let value = data;
710
+ for (let i = 0, len = fields.length; i < len; ++i) {
711
+ if (data == null) {
712
+ return null;
713
+ }
714
+ value = value[fields[i]];
715
+ }
716
+ return value;
717
+ }
718
+ } else {
719
+ return null;
720
+ }
721
+ }
722
+ function contains(value, list) {
723
+ if (value != null && list && list.length) {
724
+ for (const val of list) {
725
+ if (equals(value, val)) {
726
+ return true;
727
+ }
728
+ }
729
+ }
730
+ return false;
731
+ }
732
+ function isEmpty(value) {
733
+ 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));
734
+ }
735
+ function isString(value) {
736
+ return typeof value === "string" || value instanceof String;
737
+ }
738
+ function useInjectedGroupState(groupKey) {
739
+ const group = inject(groupKey, void 0);
740
+ const isInGroup = computed(() => !isEmpty(group));
741
+ function getGroupOrLocalRef(propName, props, emit) {
742
+ if (group == null ? void 0 : group.value) {
743
+ const groupPropValue = unref(group.value)[propName];
744
+ return computed({
745
+ get() {
746
+ return groupPropValue == null ? void 0 : groupPropValue.value;
747
+ },
748
+ set(value) {
749
+ groupPropValue.value = value;
750
+ }
751
+ });
752
+ }
753
+ const propRef = toRef(props, propName);
754
+ return computed({
755
+ get() {
756
+ return propRef.value;
757
+ },
758
+ set(value) {
759
+ if (emit)
760
+ emit(`update:${propName}`, value);
761
+ }
762
+ });
763
+ }
764
+ return {
765
+ group,
766
+ isInGroup,
767
+ getGroupOrLocalRef
768
+ };
769
+ }
770
+ const VvButtonEvents = ["update:modelValue"];
771
+ const VvButtonProps = {
772
+ ...ActionProps,
773
+ ...IdProps,
774
+ ...ModifiersProps,
775
+ ...UnselectableProps,
776
+ ...LoadingProps,
777
+ /**
778
+ * Button icon
779
+ */
780
+ icon: [String, Object],
781
+ /**
782
+ * Button icon position
783
+ */
784
+ iconPosition: {
785
+ type: String,
786
+ default: Side.left,
787
+ validator: (value) => Object.values(Side).includes(value)
788
+ },
789
+ /**
790
+ * Loading icon
791
+ */
792
+ loadingIcon: { type: String, default: "eos-icons:bubble-loading" },
793
+ /**
794
+ * Enable button toggle
795
+ */
796
+ toggle: {
797
+ type: Boolean,
798
+ default: false
799
+ },
800
+ /**
801
+ * Button toggle value
802
+ */
803
+ value: {
804
+ type: [String, Number, Boolean],
805
+ default: void 0
806
+ },
807
+ /**
808
+ * Value associated with the unchecked state
809
+ */
810
+ uncheckedValue: {
811
+ type: [String, Number, Boolean],
812
+ default: void 0
813
+ },
814
+ /**
815
+ * Button toggle model value
816
+ */
817
+ modelValue: {
818
+ type: [String, Number, Boolean],
819
+ default: void 0
820
+ }
821
+ };
822
+ function useGroupProps(props, emit) {
823
+ const { group, isInGroup, getGroupOrLocalRef } = useInjectedGroupState(INJECTION_KEY_BUTTON_GROUP);
824
+ const { id, iconPosition, icon, label, pressed } = toRefs(props);
825
+ const modelValue = getGroupOrLocalRef("modelValue", props, emit);
826
+ const toggle = getGroupOrLocalRef("toggle", props);
827
+ const unselectable = getGroupOrLocalRef(
828
+ "unselectable",
829
+ props
830
+ );
831
+ const multiple = computed(() => (group == null ? void 0 : group.value.multiple.value) ?? false);
832
+ const modifiers = computed(() => {
833
+ let localModifiers = props.modifiers;
834
+ let groupModifiers = group == null ? void 0 : group.value.modifiers.value;
835
+ const toReturn = /* @__PURE__ */ new Set();
836
+ if (localModifiers) {
837
+ if (!Array.isArray(localModifiers)) {
838
+ localModifiers = localModifiers.split(" ");
839
+ }
840
+ localModifiers.forEach((modifier) => toReturn.add(modifier));
841
+ }
842
+ if (groupModifiers) {
843
+ if (!Array.isArray(groupModifiers)) {
844
+ groupModifiers = groupModifiers.split(" ");
845
+ }
846
+ groupModifiers.forEach((modifier) => toReturn.add(modifier));
847
+ }
848
+ return Array.from(toReturn);
849
+ });
850
+ const disabled = computed(
851
+ () => {
852
+ var _a;
853
+ return Boolean(props.disabled || ((_a = group == null ? void 0 : group.value) == null ? void 0 : _a.disabled.value));
854
+ }
855
+ );
856
+ return {
857
+ // group props
858
+ group,
859
+ isInGroup,
860
+ modelValue,
861
+ toggle,
862
+ unselectable,
863
+ multiple,
864
+ modifiers,
865
+ disabled,
866
+ // local props
867
+ id,
868
+ pressed,
869
+ iconPosition,
870
+ icon,
871
+ label
872
+ };
873
+ }
874
+ const useUniqueId = (id) => computed(() => String((id == null ? void 0 : id.value) || uid()));
875
+ const _hoisted_1$1 = {
876
+ key: 1,
877
+ class: "vv-button__label"
878
+ };
879
+ const _hoisted_2$1 = {
880
+ key: 1,
881
+ class: "vv-button__label"
882
+ };
883
+ const __default__$1 = {
884
+ name: "VvButton"
885
+ };
886
+ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
887
+ ...__default__$1,
888
+ props: VvButtonProps,
889
+ emits: VvButtonEvents,
890
+ setup(__props, { expose: __expose, emit }) {
891
+ const props = __props;
892
+ const attrs = useAttrs();
893
+ const slots = useSlots();
894
+ const {
895
+ id,
896
+ modifiers,
897
+ iconPosition,
898
+ icon,
899
+ label,
900
+ modelValue,
901
+ disabled,
902
+ toggle,
903
+ unselectable
904
+ } = useGroupProps(props, emit);
905
+ const hasId = useUniqueId(id);
906
+ const name = computed(() => (attrs == null ? void 0 : attrs.name) || hasId.value);
907
+ const element = ref(null);
908
+ const $el = computed(() => {
909
+ var _a;
910
+ return (_a = element.value) == null ? void 0 : _a.$el;
911
+ });
912
+ __expose({ $el });
913
+ const pressed = computed(() => {
914
+ if (!toggle.value) {
915
+ return props.pressed;
916
+ }
917
+ if (Array.isArray(modelValue.value)) {
918
+ return contains(name.value, modelValue.value);
919
+ }
920
+ return equals(name.value, modelValue.value);
921
+ });
922
+ const bemCssClasses = useModifiers(
923
+ "vv-button",
924
+ modifiers,
925
+ computed(() => ({
926
+ reverse: [Side.right, Side.bottom].includes(
927
+ iconPosition.value
928
+ ),
929
+ column: [Side.top, Side.bottom].includes(
930
+ iconPosition.value
931
+ ),
932
+ "icon-only": Boolean(
933
+ (icon == null ? void 0 : icon.value) && !(label == null ? void 0 : label.value) && !slots.default
934
+ )
935
+ }))
936
+ );
937
+ const hasIconProps = computed(
938
+ () => typeof (icon == null ? void 0 : icon.value) === "string" ? { name: icon == null ? void 0 : icon.value } : icon == null ? void 0 : icon.value
939
+ );
940
+ const toggleValue = computed(() => {
941
+ return props.value !== void 0 ? props.value : name.value;
942
+ });
943
+ const onClick = () => {
944
+ if (toggle.value) {
945
+ if (Array.isArray(modelValue.value)) {
946
+ if (contains(toggleValue.value, modelValue.value)) {
947
+ if (unselectable.value) {
948
+ modelValue.value = modelValue.value.filter(
949
+ (n) => n !== toggleValue.value
950
+ );
951
+ }
952
+ return;
953
+ }
954
+ modelValue.value.push(toggleValue.value);
955
+ return;
956
+ }
957
+ if (toggleValue.value === modelValue.value && unselectable.value) {
958
+ modelValue.value = props.uncheckedValue;
959
+ return;
960
+ }
961
+ modelValue.value = toggleValue.value;
962
+ }
963
+ };
964
+ return (_ctx, _cache) => {
965
+ return openBlock(), createBlock(_sfc_main$2, mergeProps({
966
+ disabled: unref(disabled),
967
+ pressed: unref(pressed),
968
+ active: _ctx.active,
969
+ type: _ctx.type,
970
+ to: _ctx.to,
971
+ href: _ctx.href,
972
+ target: _ctx.target,
973
+ rel: _ctx.rel,
974
+ ariaLabel: _ctx.ariaLabel
975
+ }, {
976
+ id: unref(hasId),
977
+ ref_key: "element",
978
+ ref: element,
979
+ class: unref(bemCssClasses),
980
+ onClick
981
+ }), {
982
+ default: withCtx(() => [
983
+ renderSlot(_ctx.$slots, "default", {}, () => [
984
+ _ctx.loading ? renderSlot(_ctx.$slots, "loading", { key: 0 }, () => [
985
+ _ctx.loadingIcon ? (openBlock(), createBlock(_sfc_main$3, {
986
+ key: 0,
987
+ class: "vv-button__loading-icon",
988
+ name: _ctx.loadingIcon
989
+ }, null, 8, ["name"])) : createCommentVNode("v-if", true),
990
+ _ctx.loadingLabel ? (openBlock(), createElementBlock(
991
+ "span",
992
+ _hoisted_1$1,
993
+ toDisplayString(_ctx.loadingLabel),
994
+ 1
995
+ /* TEXT */
996
+ )) : createCommentVNode("v-if", true)
997
+ ]) : (openBlock(), createElementBlock(
998
+ Fragment,
999
+ { key: 1 },
1000
+ [
1001
+ renderSlot(_ctx.$slots, "before"),
1002
+ unref(icon) ? (openBlock(), createBlock(
1003
+ _sfc_main$3,
1004
+ mergeProps({
1005
+ key: 0,
1006
+ class: "vv-button__icon"
1007
+ }, unref(hasIconProps)),
1008
+ null,
1009
+ 16
1010
+ /* FULL_PROPS */
1011
+ )) : createCommentVNode("v-if", true),
1012
+ unref(label) ? (openBlock(), createElementBlock("span", _hoisted_2$1, [
1013
+ renderSlot(_ctx.$slots, "label", {}, () => [
1014
+ createTextVNode(
1015
+ toDisplayString(unref(label)),
1016
+ 1
1017
+ /* TEXT */
1018
+ )
1019
+ ])
1020
+ ])) : createCommentVNode("v-if", true),
1021
+ renderSlot(_ctx.$slots, "after")
1022
+ ],
1023
+ 64
1024
+ /* STABLE_FRAGMENT */
1025
+ ))
1026
+ ])
1027
+ ]),
1028
+ _: 3
1029
+ /* FORWARDED */
1030
+ }, 16, ["id", "class"]);
1031
+ };
1032
+ }
1033
+ });
1034
+ function joinLines(items) {
1035
+ if (Array.isArray(items)) {
1036
+ return items.filter((item) => isString(item)).join(" ");
1037
+ }
1038
+ return items;
1039
+ }
1040
+ function HintSlotFactory(propsOrRef, slots) {
1041
+ const props = computed(() => {
1042
+ if (isRef(propsOrRef)) {
1043
+ return propsOrRef.value;
1044
+ }
1045
+ return propsOrRef;
1046
+ });
1047
+ const invalidLabel = computed(() => joinLines(props.value.invalidLabel));
1048
+ const validLabel = computed(() => joinLines(props.value.validLabel));
1049
+ const loadingLabel = computed(() => props.value.loadingLabel);
1050
+ const hintLabel = computed(() => props.value.hintLabel);
1051
+ const hasLoadingLabelOrSlot = computed(
1052
+ () => Boolean(props.value.loading && (slots.loading || loadingLabel.value))
1053
+ );
1054
+ const hasInvalidLabelOrSlot = computed(
1055
+ () => !hasLoadingLabelOrSlot.value && Boolean(
1056
+ props.value.invalid && (slots.invalid || invalidLabel.value)
1057
+ )
1058
+ );
1059
+ const hasValidLabelOrSlot = computed(
1060
+ () => !hasLoadingLabelOrSlot.value && !hasInvalidLabelOrSlot.value && Boolean(props.value.valid && (slots.valid || validLabel.value))
1061
+ );
1062
+ const hasHintLabelOrSlot = computed(
1063
+ () => !hasLoadingLabelOrSlot.value && !hasInvalidLabelOrSlot.value && !hasValidLabelOrSlot.value && Boolean(slots.hint || hintLabel.value)
1064
+ );
1065
+ const isVisible = computed(
1066
+ () => hasInvalidLabelOrSlot.value || hasValidLabelOrSlot.value || hasLoadingLabelOrSlot.value || hasHintLabelOrSlot.value
1067
+ );
1068
+ const hintSlotScope = computed(() => ({
1069
+ modelValue: props.value.modelValue,
1070
+ valid: props.value.valid,
1071
+ invalid: props.value.invalid,
1072
+ loading: props.value.loading
1073
+ }));
1074
+ const HintSlot = defineComponent({
1075
+ name: "HintSlot",
1076
+ props: {
1077
+ tag: {
1078
+ type: String,
1079
+ default: "small"
1080
+ }
1081
+ },
1082
+ setup() {
1083
+ return {
1084
+ isVisible,
1085
+ invalidLabel,
1086
+ validLabel,
1087
+ loadingLabel,
1088
+ hintLabel,
1089
+ hasInvalidLabelOrSlot,
1090
+ hasValidLabelOrSlot,
1091
+ hasLoadingLabelOrSlot,
1092
+ hasHintLabelOrSlot
1093
+ };
1094
+ },
1095
+ render() {
1096
+ var _a, _b, _c, _d, _e, _f, _g, _h;
1097
+ if (this.isVisible) {
1098
+ let role;
1099
+ if (this.hasInvalidLabelOrSlot) {
1100
+ role = "alert";
1101
+ }
1102
+ if (this.hasValidLabelOrSlot) {
1103
+ role = "status";
1104
+ }
1105
+ if (this.hasLoadingLabelOrSlot) {
1106
+ return h(
1107
+ this.tag,
1108
+ {
1109
+ role
1110
+ },
1111
+ ((_b = (_a = this.$slots).loading) == null ? void 0 : _b.call(_a)) ?? this.loadingLabel
1112
+ );
1113
+ }
1114
+ if (this.hasInvalidLabelOrSlot) {
1115
+ return h(
1116
+ this.tag,
1117
+ {
1118
+ role
1119
+ },
1120
+ ((_d = (_c = this.$slots).invalid) == null ? void 0 : _d.call(_c)) ?? this.$slots.invalid ?? this.invalidLabel
1121
+ );
1122
+ }
1123
+ if (this.hasValidLabelOrSlot) {
1124
+ return h(
1125
+ this.tag,
1126
+ {
1127
+ role
1128
+ },
1129
+ ((_f = (_e = this.$slots).valid) == null ? void 0 : _f.call(_e)) ?? this.validLabel
1130
+ );
1131
+ }
1132
+ return h(
1133
+ this.tag,
1134
+ {
1135
+ role
1136
+ },
1137
+ ((_h = (_g = this.$slots).hint) == null ? void 0 : _h.call(_g)) ?? this.$slots.hint ?? this.hintLabel
1138
+ );
1139
+ }
1140
+ return null;
1141
+ }
1142
+ });
1143
+ return {
1144
+ hasInvalidLabelOrSlot,
1145
+ hasHintLabelOrSlot,
1146
+ hasValidLabelOrSlot,
1147
+ hasLoadingLabelOrSlot,
1148
+ hintSlotScope,
1149
+ HintSlot
1150
+ };
1151
+ }
1152
+ const VvInputFileProps = {
1153
+ ...ModifiersProps,
1154
+ ...ValidProps,
1155
+ ...InvalidProps,
1156
+ ...HintProps,
1157
+ ...LabelProps,
1158
+ ...LoadingProps,
1159
+ name: { type: String },
1160
+ id: { type: String },
1161
+ modelValue: {
1162
+ type: Object,
1163
+ required: true
1164
+ },
1165
+ max: [Number, String],
1166
+ labelButton: { type: String, default: "Image" },
1167
+ loading: Boolean,
1168
+ accept: String,
1169
+ placeholder: String,
1170
+ multiple: Boolean,
1171
+ iconLeft: String,
1172
+ iconRight: String
1173
+ };
1174
+ function useDefaults(componentName, propsDefinition, props) {
1175
+ const volver = useVolver();
1176
+ const volverComponentDefaults = computed(() => {
1177
+ var _a;
1178
+ if (!volver || !((_a = volver.defaults.value) == null ? void 0 : _a[componentName])) {
1179
+ return void 0;
1180
+ }
1181
+ return volver.defaults.value[componentName];
1182
+ });
1183
+ return computed(() => {
1184
+ if (volverComponentDefaults.value === void 0) {
1185
+ return props;
1186
+ }
1187
+ const componentDefaults = volverComponentDefaults.value;
1188
+ const simplifiedPropsDefinition = propsDefinition;
1189
+ const simplifiedProps = props;
1190
+ return Object.keys(simplifiedPropsDefinition).reduce((acc, key) => {
1191
+ const propValue = simplifiedProps[key];
1192
+ acc[key] = propValue;
1193
+ if (key in componentDefaults) {
1194
+ if (Array.isArray(simplifiedPropsDefinition[key])) {
1195
+ const typeArray = simplifiedPropsDefinition[key];
1196
+ if (typeArray.length) {
1197
+ const typeFunction = typeArray[0];
1198
+ if (typeFunction === propValue) {
1199
+ acc[key] = componentDefaults[key];
1200
+ }
1201
+ }
1202
+ }
1203
+ if (typeof simplifiedPropsDefinition[key] === "function") {
1204
+ const typeFunction = simplifiedPropsDefinition[key];
1205
+ if (typeFunction() === propValue) {
1206
+ acc[key] = componentDefaults[key];
1207
+ }
1208
+ }
1209
+ if (typeof simplifiedPropsDefinition[key] === "object") {
1210
+ let defaultValue = simplifiedPropsDefinition[key].default;
1211
+ if (typeof defaultValue === "function") {
1212
+ defaultValue = defaultValue();
1213
+ }
1214
+ if (typeof defaultValue === "object") {
1215
+ if (JSON.stringify(defaultValue) === JSON.stringify(propValue)) {
1216
+ acc[key] = componentDefaults[key];
1217
+ }
1218
+ } else if (defaultValue === propValue) {
1219
+ acc[key] = componentDefaults[key];
1220
+ }
1221
+ }
1222
+ }
1223
+ return acc;
1224
+ }, {});
1225
+ });
1226
+ }
1227
+ const _hoisted_1 = ["for"];
1228
+ const _hoisted_2 = ["onDragenter", "onDragleave", "onDrop", "onClick"];
1229
+ const _hoisted_3 = { class: "vv-input-file__preview" };
1230
+ const _hoisted_4 = ["src", "alt"];
1231
+ const _hoisted_5 = { class: "vv-input-file__wrapper" };
1232
+ const _hoisted_6 = ["id", "placeholder", "aria-describedby", "aria-invalid", "aria-errormessage", "multiple", "accept", "name"];
1233
+ const _hoisted_7 = { class: "vv-input-file__list" };
1234
+ const _hoisted_8 = { class: "vv-input-file__item-name" };
1235
+ const _hoisted_9 = { class: "vv-input-file__item-info" };
1236
+ const _hoisted_10 = ["onClick"];
1237
+ const __default__ = {
1238
+ name: "VvInputFile"
1239
+ };
1240
+ const _sfc_main = /* @__PURE__ */ defineComponent({
1241
+ ...__default__,
1242
+ props: VvInputFileProps,
1243
+ emits: ["update:modelValue"],
1244
+ setup(__props, { emit }) {
1245
+ const props = __props;
1246
+ const slots = useSlots();
1247
+ const propsDefaults = useDefaults(
1248
+ "VvInputFile",
1249
+ VvInputFileProps,
1250
+ props
1251
+ );
1252
+ const { modifiers, id } = toRefs(props);
1253
+ const hasId = useUniqueId(id);
1254
+ const hasHintId = computed(() => `${hasId.value}-hint`);
1255
+ const bemCssClasses = useModifiers(
1256
+ "vv-input-file",
1257
+ modifiers,
1258
+ computed(() => ({
1259
+ dragging: isDragging.value,
1260
+ loading: props.loading,
1261
+ valid: props.valid === true,
1262
+ invalid: props.invalid === true,
1263
+ "icon-before": !!props.iconLeft,
1264
+ "icon-after": !!props.iconRight
1265
+ }))
1266
+ );
1267
+ const {
1268
+ HintSlot,
1269
+ hasHintLabelOrSlot,
1270
+ hasInvalidLabelOrSlot,
1271
+ hintSlotScope
1272
+ } = HintSlotFactory(propsDefaults, slots);
1273
+ const localModelValue = useVModel(props, "modelValue", emit);
1274
+ const files = computed(() => {
1275
+ var _a;
1276
+ if (!localModelValue.value || !Array.isArray(localModelValue.value) && !((_a = localModelValue.value) == null ? void 0 : _a.name)) {
1277
+ return [];
1278
+ }
1279
+ return Array.isArray(localModelValue.value) ? localModelValue.value : [localModelValue.value];
1280
+ });
1281
+ const hasMax = computed(() => {
1282
+ return typeof props.max === "string" ? parseInt(props.max) : props.max;
1283
+ });
1284
+ const hasDropArea = computed(() => {
1285
+ var _a;
1286
+ return (_a = modifiers == null ? void 0 : modifiers.value) == null ? void 0 : _a.includes("drop-area");
1287
+ });
1288
+ const isMultiple = computed(() => {
1289
+ if (!props.multiple) {
1290
+ return false;
1291
+ }
1292
+ if (!hasMax.value) {
1293
+ return true;
1294
+ }
1295
+ return hasMax.value - files.value.length > 1;
1296
+ });
1297
+ const isDragging = ref(false);
1298
+ const inputEl = ref();
1299
+ const onDragenter = () => {
1300
+ isDragging.value = true;
1301
+ };
1302
+ const onDragleave = () => {
1303
+ isDragging.value = false;
1304
+ };
1305
+ const onDrop = (event) => {
1306
+ var _a, _b;
1307
+ if (!((_a = event.dataTransfer) == null ? void 0 : _a.files)) {
1308
+ return;
1309
+ }
1310
+ isDragging.value = false;
1311
+ addFiles((_b = event.dataTransfer) == null ? void 0 : _b.files);
1312
+ };
1313
+ const onChange = () => {
1314
+ var _a;
1315
+ if (!((_a = inputEl.value) == null ? void 0 : _a.files)) {
1316
+ return;
1317
+ }
1318
+ addFiles(inputEl.value.files);
1319
+ inputEl.value.value = "";
1320
+ };
1321
+ const addFiles = (uploadedFiles) => {
1322
+ if (!props.multiple) {
1323
+ if (Array.isArray(localModelValue.value)) {
1324
+ localModelValue.value = [...uploadedFiles];
1325
+ return;
1326
+ }
1327
+ localModelValue.value = uploadedFiles[0];
1328
+ return;
1329
+ }
1330
+ let toReturn = [];
1331
+ if (!Array.isArray(localModelValue.value) && localModelValue.value) {
1332
+ toReturn = [localModelValue.value];
1333
+ } else {
1334
+ toReturn = localModelValue.value && Array.isArray(localModelValue.value) ? [...localModelValue.value] : toReturn;
1335
+ }
1336
+ for (const file of uploadedFiles) {
1337
+ if (hasMax.value && toReturn.length >= hasMax.value) {
1338
+ break;
1339
+ }
1340
+ toReturn.push(file);
1341
+ }
1342
+ localModelValue.value = toReturn;
1343
+ };
1344
+ const onClick = () => {
1345
+ if (!inputEl.value) {
1346
+ return;
1347
+ }
1348
+ inputEl.value.click();
1349
+ };
1350
+ const onClickRemoveFile = (index) => {
1351
+ if (!Array.isArray(localModelValue.value)) {
1352
+ localModelValue.value = void 0;
1353
+ return;
1354
+ }
1355
+ const toReturn = [...localModelValue.value];
1356
+ toReturn.splice(index, 1);
1357
+ localModelValue.value = toReturn;
1358
+ };
1359
+ const previewSrc = computed(() => {
1360
+ if (files.value.length === 0) {
1361
+ return;
1362
+ }
1363
+ if (files.value[0] instanceof File) {
1364
+ return URL.createObjectURL(files.value[0]);
1365
+ }
1366
+ return files.value[0].url;
1367
+ });
1368
+ onBeforeUnmount(() => {
1369
+ if (previewSrc.value) {
1370
+ URL.revokeObjectURL(previewSrc.value);
1371
+ }
1372
+ });
1373
+ const sizeInKiB = (size) => {
1374
+ if (!size) {
1375
+ return;
1376
+ }
1377
+ return Math.floor(size / 1024);
1378
+ };
1379
+ return (_ctx, _cache) => {
1380
+ return openBlock(), createElementBlock(
1381
+ "div",
1382
+ {
1383
+ class: normalizeClass(unref(bemCssClasses))
1384
+ },
1385
+ [
1386
+ _ctx.label ? (openBlock(), createElementBlock("label", {
1387
+ key: 0,
1388
+ for: unref(hasId)
1389
+ }, toDisplayString(_ctx.label), 9, _hoisted_1)) : createCommentVNode("v-if", true),
1390
+ hasDropArea.value ? (openBlock(), createElementBlock("div", {
1391
+ key: 1,
1392
+ class: "vv-input-file__drop-area",
1393
+ onDragenter: withModifiers(onDragenter, ["prevent", "stop"]),
1394
+ onDragleave: withModifiers(onDragleave, ["prevent", "stop"]),
1395
+ onDrop: withModifiers(onDrop, ["prevent", "stop"]),
1396
+ onDragover: _cache[0] || (_cache[0] = withModifiers(() => {
1397
+ }, ["prevent", "stop"])),
1398
+ onClick: withModifiers(onClick, ["stop"])
1399
+ }, [
1400
+ renderSlot(_ctx.$slots, "drop-area", {}, () => [
1401
+ createVNode(_sfc_main$1, {
1402
+ modifiers: "action",
1403
+ "aria-label": "upload",
1404
+ label: !previewSrc.value ? _ctx.labelButton : void 0,
1405
+ class: normalizeClass([{
1406
+ "absolute top-8 right-8": previewSrc.value
1407
+ }, "z-1"]),
1408
+ icon: !previewSrc.value ? "image" : "edit",
1409
+ onClick: withModifiers(onClick, ["stop"])
1410
+ }, null, 8, ["label", "class", "icon", "onClick"]),
1411
+ createElementVNode("picture", _hoisted_3, [
1412
+ previewSrc.value ? (openBlock(), createElementBlock("img", {
1413
+ key: 0,
1414
+ src: previewSrc.value,
1415
+ alt: files.value[0].name
1416
+ }, null, 8, _hoisted_4)) : createCommentVNode("v-if", true)
1417
+ ])
1418
+ ])
1419
+ ], 40, _hoisted_2)) : createCommentVNode("v-if", true),
1420
+ createElementVNode("div", _hoisted_5, [
1421
+ _ctx.iconLeft ? (openBlock(), createBlock(_sfc_main$3, {
1422
+ key: 0,
1423
+ name: _ctx.iconLeft
1424
+ }, null, 8, ["name"])) : createCommentVNode("v-if", true),
1425
+ createElementVNode("input", {
1426
+ id: unref(hasId),
1427
+ ref_key: "inputEl",
1428
+ ref: inputEl,
1429
+ placeholder: _ctx.placeholder,
1430
+ "aria-describedby": unref(hasHintLabelOrSlot) ? hasHintId.value : void 0,
1431
+ "aria-invalid": _ctx.invalid,
1432
+ "aria-errormessage": unref(hasInvalidLabelOrSlot) ? hasHintId.value : void 0,
1433
+ multiple: isMultiple.value,
1434
+ accept: _ctx.accept,
1435
+ type: "file",
1436
+ name: _ctx.name,
1437
+ onChange
1438
+ }, null, 40, _hoisted_6),
1439
+ _ctx.iconRight ? (openBlock(), createBlock(_sfc_main$3, {
1440
+ key: 1,
1441
+ name: _ctx.iconRight
1442
+ }, null, 8, ["name"])) : createCommentVNode("v-if", true)
1443
+ ]),
1444
+ createElementVNode("ul", _hoisted_7, [
1445
+ (openBlock(true), createElementBlock(
1446
+ Fragment,
1447
+ null,
1448
+ renderList(files.value, (file, index) => {
1449
+ return openBlock(), createElementBlock("li", {
1450
+ key: index,
1451
+ class: "vv-input-file__item"
1452
+ }, [
1453
+ createVNode(_sfc_main$3, {
1454
+ class: "vv-input-file__item-icon",
1455
+ name: "akar-icons:file"
1456
+ }),
1457
+ createElementVNode(
1458
+ "div",
1459
+ _hoisted_8,
1460
+ toDisplayString(file.name),
1461
+ 1
1462
+ /* TEXT */
1463
+ ),
1464
+ createElementVNode(
1465
+ "small",
1466
+ _hoisted_9,
1467
+ toDisplayString(sizeInKiB(file.size)) + " KB ",
1468
+ 1
1469
+ /* TEXT */
1470
+ ),
1471
+ createElementVNode("button", {
1472
+ type: "button",
1473
+ class: "vv-input-file__item-remove",
1474
+ title: "Remove",
1475
+ "aria-label": "remove-file",
1476
+ onClick: withModifiers(($event) => onClickRemoveFile(index), ["stop"])
1477
+ }, null, 8, _hoisted_10)
1478
+ ]);
1479
+ }),
1480
+ 128
1481
+ /* KEYED_FRAGMENT */
1482
+ ))
1483
+ ]),
1484
+ createVNode(unref(HintSlot), {
1485
+ id: hasHintId.value,
1486
+ class: "vv-input-file__hint"
1487
+ }, createSlots({
1488
+ _: 2
1489
+ /* DYNAMIC */
1490
+ }, [
1491
+ _ctx.$slots.hint ? {
1492
+ name: "hint",
1493
+ fn: withCtx(() => [
1494
+ renderSlot(_ctx.$slots, "hint", normalizeProps(guardReactiveProps(unref(hintSlotScope))))
1495
+ ]),
1496
+ key: "0"
1497
+ } : void 0,
1498
+ _ctx.$slots.loading ? {
1499
+ name: "loading",
1500
+ fn: withCtx(() => [
1501
+ renderSlot(_ctx.$slots, "loading", normalizeProps(guardReactiveProps(unref(hintSlotScope))))
1502
+ ]),
1503
+ key: "1"
1504
+ } : void 0,
1505
+ _ctx.$slots.valid ? {
1506
+ name: "valid",
1507
+ fn: withCtx(() => [
1508
+ renderSlot(_ctx.$slots, "valid", normalizeProps(guardReactiveProps(unref(hintSlotScope))))
1509
+ ]),
1510
+ key: "2"
1511
+ } : void 0,
1512
+ _ctx.$slots.invalid ? {
1513
+ name: "invalid",
1514
+ fn: withCtx(() => [
1515
+ renderSlot(_ctx.$slots, "invalid", normalizeProps(guardReactiveProps(unref(hintSlotScope))))
1516
+ ]),
1517
+ key: "3"
1518
+ } : void 0
1519
+ ]), 1032, ["id"])
1520
+ ],
1521
+ 2
1522
+ /* CLASS */
1523
+ );
1524
+ };
1525
+ }
1526
+ });
1527
+ export {
1528
+ _sfc_main as default
1529
+ };