@volverjs/ui-vue 0.0.10-beta.50 → 0.0.10-beta.52

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.
@@ -1,6 +1,134 @@
1
1
  import { unref, computed, isRef, defineComponent, h, inject, mergeDefaults, ref, toRefs, openBlock, createBlock, mergeProps, createCommentVNode, useId, watch, useSlots, createElementBlock, normalizeClass, toDisplayString, createElementVNode, renderSlot, normalizeProps, guardReactiveProps, withDirectives, vModelText, createTextVNode, createVNode, createSlots, withCtx } from "vue";
2
2
  import { iconExists, Icon, addIcon } from "@iconify/vue";
3
3
  import { useFocus, useElementVisibility } from "@vueuse/core";
4
+ function isEmpty(value) {
5
+ 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));
6
+ }
7
+ function isString(value) {
8
+ return typeof value === "string" || value instanceof String;
9
+ }
10
+ function joinLines(items) {
11
+ if (Array.isArray(items)) {
12
+ return items.filter((item) => isString(item)).join(" ");
13
+ }
14
+ return items;
15
+ }
16
+ function HintSlotFactory(propsOrRef, slots) {
17
+ const props = computed(() => {
18
+ if (isRef(propsOrRef)) {
19
+ return propsOrRef.value;
20
+ }
21
+ return propsOrRef;
22
+ });
23
+ const invalidLabel = computed(() => joinLines(props.value.invalidLabel));
24
+ const validLabel = computed(() => joinLines(props.value.validLabel));
25
+ const loadingLabel = computed(() => props.value.loadingLabel);
26
+ const hintLabel = computed(() => props.value.hintLabel);
27
+ const hasLoadingLabelOrSlot = computed(
28
+ () => Boolean(props.value.loading && (slots.loading || loadingLabel.value))
29
+ );
30
+ const hasInvalidLabelOrSlot = computed(
31
+ () => !hasLoadingLabelOrSlot.value && Boolean(
32
+ props.value.invalid && (slots.invalid || invalidLabel.value)
33
+ )
34
+ );
35
+ const hasValidLabelOrSlot = computed(
36
+ () => !hasLoadingLabelOrSlot.value && !hasInvalidLabelOrSlot.value && Boolean(props.value.valid && (slots.valid || validLabel.value))
37
+ );
38
+ const hasHintLabelOrSlot = computed(
39
+ () => !hasLoadingLabelOrSlot.value && !hasInvalidLabelOrSlot.value && !hasValidLabelOrSlot.value && Boolean(slots.hint || hintLabel.value)
40
+ );
41
+ const isVisible = computed(
42
+ () => hasInvalidLabelOrSlot.value || hasValidLabelOrSlot.value || hasLoadingLabelOrSlot.value || hasHintLabelOrSlot.value
43
+ );
44
+ const hintSlotScope = computed(() => ({
45
+ modelValue: props.value.modelValue,
46
+ valid: props.value.valid,
47
+ invalid: props.value.invalid,
48
+ loading: props.value.loading
49
+ }));
50
+ const HintSlot = defineComponent({
51
+ name: "HintSlot",
52
+ props: {
53
+ tag: {
54
+ type: String,
55
+ default: "small"
56
+ }
57
+ },
58
+ setup() {
59
+ return {
60
+ isVisible,
61
+ invalidLabel,
62
+ validLabel,
63
+ loadingLabel,
64
+ hintLabel,
65
+ hasInvalidLabelOrSlot,
66
+ hasValidLabelOrSlot,
67
+ hasLoadingLabelOrSlot,
68
+ hasHintLabelOrSlot
69
+ };
70
+ },
71
+ render() {
72
+ var _a, _b, _c, _d, _e, _f, _g, _h;
73
+ if (this.isVisible) {
74
+ let role;
75
+ if (this.hasInvalidLabelOrSlot) {
76
+ role = "alert";
77
+ }
78
+ if (this.hasValidLabelOrSlot) {
79
+ role = "status";
80
+ }
81
+ if (this.hasLoadingLabelOrSlot) {
82
+ return h(
83
+ this.tag,
84
+ {
85
+ role
86
+ },
87
+ ((_b = (_a = this.$slots).loading) == null ? void 0 : _b.call(_a)) ?? this.loadingLabel
88
+ );
89
+ }
90
+ if (this.hasInvalidLabelOrSlot) {
91
+ return h(
92
+ this.tag,
93
+ {
94
+ role
95
+ },
96
+ ((_d = (_c = this.$slots).invalid) == null ? void 0 : _d.call(_c)) ?? this.$slots.invalid ?? this.invalidLabel
97
+ );
98
+ }
99
+ if (this.hasValidLabelOrSlot) {
100
+ return h(
101
+ this.tag,
102
+ {
103
+ role
104
+ },
105
+ ((_f = (_e = this.$slots).valid) == null ? void 0 : _f.call(_e)) ?? this.validLabel
106
+ );
107
+ }
108
+ return h(
109
+ this.tag,
110
+ {
111
+ role
112
+ },
113
+ ((_h = (_g = this.$slots).hint) == null ? void 0 : _h.call(_g)) ?? this.$slots.hint ?? this.hintLabel
114
+ );
115
+ }
116
+ return null;
117
+ }
118
+ });
119
+ return {
120
+ hasInvalidLabelOrSlot,
121
+ hasHintLabelOrSlot,
122
+ hasValidLabelOrSlot,
123
+ hasLoadingLabelOrSlot,
124
+ hintSlotScope,
125
+ HintSlot
126
+ };
127
+ }
128
+ const VvIconPropsDefaults = {
129
+ prefix: "normal"
130
+ /* normal */
131
+ };
4
132
  var StorageType = /* @__PURE__ */ ((StorageType2) => {
5
133
  StorageType2["local"] = "local";
6
134
  StorageType2["session"] = "session";
@@ -48,107 +176,255 @@ var ActionTag = /* @__PURE__ */ ((ActionTag2) => {
48
176
  return ActionTag2;
49
177
  })(ActionTag || {});
50
178
  const INJECTION_KEY_VOLVER = Symbol.for("volver");
51
- const LinkProps = {
52
- /**
53
- * The router-link/nuxt-link property, if it is defined the button is rendered as a ruouter-link or nuxt-link.
54
- * @see Documentation of [router-link](https://router.vuejs.org/api/#router-link) and [nuxt-link](https://nuxtjs.org/api/components-nuxt-link/)
55
- */
56
- to: {
57
- type: [String, Object]
58
- },
59
- /**
60
- * Anchor href
61
- */
62
- href: String,
63
- /**
64
- * Anchor target
65
- */
66
- target: String,
67
- /**
68
- * Anchor rel
69
- */
70
- rel: {
71
- type: String,
72
- default: "noopener noreferrer"
73
- }
74
- };
75
- const ValidProps = {
76
- /**
77
- * Valid status
78
- */
79
- valid: { type: Boolean, default: false },
80
- /**
81
- * Valid label
82
- */
83
- validLabel: { type: [String, Array], default: void 0 }
84
- };
85
- const InvalidProps = {
86
- /**
87
- * Invalid status
88
- */
89
- invalid: {
90
- type: Boolean,
91
- default: false
92
- },
93
- /**
94
- * Invalid label
95
- */
96
- invalidLabel: { type: [String, Array], default: void 0 }
97
- };
98
- const LoadingProps = {
99
- /**
100
- * Loading status
101
- */
102
- loading: {
103
- type: Boolean,
104
- default: false
105
- },
106
- /**
107
- * Loading label
108
- */
109
- loadingLabel: {
110
- type: String,
111
- default: "Loading..."
112
- }
113
- };
114
- const DisabledProps = {
115
- /**
116
- * Whether the form control is disabled
117
- */
118
- disabled: {
119
- type: Boolean,
120
- default: false
121
- }
122
- };
123
- const ActiveProps = {
124
- /**
125
- * Whether the item is active
126
- */
127
- active: {
128
- type: Boolean,
129
- default: false
130
- }
131
- };
132
- const CurrentProps = {
133
- /**
134
- * Whether the item is current
135
- */
136
- current: {
137
- type: Boolean,
138
- default: false
139
- }
140
- };
141
- const PressedProps = {
142
- /**
143
- * Whether the item is pressed
144
- */
145
- pressed: {
146
- type: Boolean,
147
- default: false
148
- }
179
+ function useVolver() {
180
+ return inject(INJECTION_KEY_VOLVER);
181
+ }
182
+ function useModifiers(prefix, modifiers, others) {
183
+ return computed(() => {
184
+ const toReturn = {
185
+ [prefix]: true
186
+ };
187
+ const modifiersArray = typeof (modifiers == null ? void 0 : modifiers.value) === "string" ? modifiers.value.split(" ") : modifiers == null ? void 0 : modifiers.value;
188
+ if (modifiersArray) {
189
+ if (Array.isArray(modifiersArray)) {
190
+ modifiersArray.forEach((modifier) => {
191
+ if (modifier) {
192
+ toReturn[`${prefix}--${modifier}`] = true;
193
+ }
194
+ });
195
+ }
196
+ }
197
+ if (others) {
198
+ Object.keys(others.value).forEach((key) => {
199
+ toReturn[`${prefix}--${key}`] = unref(others.value[key]);
200
+ });
201
+ }
202
+ return toReturn;
203
+ });
204
+ }
205
+ const __default__$1 = {
206
+ name: "VvIcon"
149
207
  };
150
- const LabelProps = {
151
- /**
208
+ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
209
+ ...__default__$1,
210
+ props: /* @__PURE__ */ mergeDefaults({
211
+ name: {},
212
+ color: {},
213
+ width: {},
214
+ height: {},
215
+ provider: {},
216
+ prefix: {},
217
+ src: {},
218
+ horizontalFlip: { type: Boolean },
219
+ verticalFlip: { type: Boolean },
220
+ flip: {},
221
+ mode: {},
222
+ inline: { type: Boolean },
223
+ rotate: {},
224
+ onLoad: { type: Function },
225
+ svg: {},
226
+ modifiers: {}
227
+ }, VvIconPropsDefaults),
228
+ setup(__props) {
229
+ const props = __props;
230
+ const hasRotate = computed(() => {
231
+ if (typeof props.rotate === "string") {
232
+ return Number.parseFloat(props.rotate);
233
+ }
234
+ return props.rotate;
235
+ });
236
+ const show = ref(true);
237
+ const volver = useVolver();
238
+ const { modifiers } = toRefs(props);
239
+ const bemCssClasses = useModifiers("vv-icon", modifiers);
240
+ const provider = computed(() => {
241
+ return props.provider || (volver == null ? void 0 : volver.iconsProvider);
242
+ });
243
+ const icon = computed(() => {
244
+ const name = props.name ?? "";
245
+ const iconName = `@${provider.value}:${props.prefix}:${name}`;
246
+ if (iconExists(iconName)) {
247
+ return iconName;
248
+ }
249
+ const iconsCollection = volver == null ? void 0 : volver.iconsCollections.find(
250
+ (iconsCollection2) => {
251
+ const icon2 = `@${provider.value}:${iconsCollection2.prefix}:${name}`;
252
+ return iconExists(icon2);
253
+ }
254
+ );
255
+ if (iconsCollection) {
256
+ return `@${provider.value}:${iconsCollection.prefix}:${name}`;
257
+ }
258
+ return name;
259
+ });
260
+ function getSvgContent(svg) {
261
+ let dom;
262
+ if (typeof window === "undefined") {
263
+ const { JSDOM } = require("jsdom");
264
+ dom = new JSDOM().window;
265
+ }
266
+ const domParser = dom ? new dom.DOMParser() : new window.DOMParser();
267
+ const svgDomString = domParser.parseFromString(svg, "text/html");
268
+ const svgEl = svgDomString.querySelector("svg");
269
+ return svgEl;
270
+ }
271
+ function addIconFromSvg(svg) {
272
+ const svgContentEl = getSvgContent(svg);
273
+ const svgContent = (svgContentEl == null ? void 0 : svgContentEl.innerHTML.trim()) || "";
274
+ if (svgContentEl && svgContent) {
275
+ addIcon(`@${provider.value}:${props.prefix}:${props.name}`, {
276
+ body: svgContent,
277
+ // Set height and width from svg content
278
+ height: svgContentEl.viewBox.baseVal.height,
279
+ width: svgContentEl.viewBox.baseVal.width
280
+ });
281
+ }
282
+ }
283
+ if (volver) {
284
+ if (props.src && !iconExists(`@${provider.value}:${props.prefix}:${props.name}`)) {
285
+ show.value = false;
286
+ volver.fetchIcon(props.src).then((svg) => {
287
+ if (svg) {
288
+ addIconFromSvg(svg);
289
+ show.value = true;
290
+ }
291
+ }).catch((e) => {
292
+ throw new Error(`Error during fetch icon: ${e == null ? void 0 : e.message}`);
293
+ });
294
+ }
295
+ }
296
+ if (props.svg) {
297
+ addIconFromSvg(props.svg);
298
+ }
299
+ return (_ctx, _cache) => {
300
+ return unref(show) ? (openBlock(), createBlock(unref(Icon), mergeProps({
301
+ key: 0,
302
+ class: unref(bemCssClasses)
303
+ }, {
304
+ inline: _ctx.inline,
305
+ width: _ctx.width,
306
+ height: _ctx.height,
307
+ horizontalFlip: _ctx.horizontalFlip,
308
+ verticalFlip: _ctx.verticalFlip,
309
+ flip: _ctx.flip,
310
+ rotate: unref(hasRotate),
311
+ color: _ctx.color,
312
+ onLoad: _ctx.onLoad,
313
+ icon: unref(icon)
314
+ }), null, 16, ["class"])) : createCommentVNode("v-if", true);
315
+ };
316
+ }
317
+ });
318
+ const LinkProps = {
319
+ /**
320
+ * The router-link/nuxt-link property, if it is defined the button is rendered as a ruouter-link or nuxt-link.
321
+ * @see Documentation of [router-link](https://router.vuejs.org/api/#router-link) and [nuxt-link](https://nuxtjs.org/api/components-nuxt-link/)
322
+ */
323
+ to: {
324
+ type: [String, Object]
325
+ },
326
+ /**
327
+ * Anchor href
328
+ */
329
+ href: String,
330
+ /**
331
+ * Anchor target
332
+ */
333
+ target: String,
334
+ /**
335
+ * Anchor rel
336
+ */
337
+ rel: {
338
+ type: String,
339
+ default: "noopener noreferrer"
340
+ }
341
+ };
342
+ const ValidProps = {
343
+ /**
344
+ * Valid status
345
+ */
346
+ valid: { type: Boolean, default: false },
347
+ /**
348
+ * Valid label
349
+ */
350
+ validLabel: { type: [String, Array], default: void 0 }
351
+ };
352
+ const InvalidProps = {
353
+ /**
354
+ * Invalid status
355
+ */
356
+ invalid: {
357
+ type: Boolean,
358
+ default: false
359
+ },
360
+ /**
361
+ * Invalid label
362
+ */
363
+ invalidLabel: { type: [String, Array], default: void 0 }
364
+ };
365
+ const LoadingProps = {
366
+ /**
367
+ * Loading status
368
+ */
369
+ loading: {
370
+ type: Boolean,
371
+ default: false
372
+ },
373
+ /**
374
+ * Loading label
375
+ */
376
+ loadingLabel: {
377
+ type: String,
378
+ default: "Loading..."
379
+ }
380
+ };
381
+ const DisabledProps = {
382
+ /**
383
+ * Whether the form control is disabled
384
+ */
385
+ disabled: {
386
+ type: Boolean,
387
+ default: false
388
+ }
389
+ };
390
+ const RequiredProps = {
391
+ /**
392
+ * Whether the form control is required
393
+ */
394
+ required: {
395
+ type: Boolean,
396
+ default: false
397
+ }
398
+ };
399
+ const ActiveProps = {
400
+ /**
401
+ * Whether the item is active
402
+ */
403
+ active: {
404
+ type: Boolean,
405
+ default: false
406
+ }
407
+ };
408
+ const CurrentProps = {
409
+ /**
410
+ * Whether the item is current
411
+ */
412
+ current: {
413
+ type: Boolean,
414
+ default: false
415
+ }
416
+ };
417
+ const PressedProps = {
418
+ /**
419
+ * Whether the item is pressed
420
+ */
421
+ pressed: {
422
+ type: Boolean,
423
+ default: false
424
+ }
425
+ };
426
+ const LabelProps = {
427
+ /**
152
428
  * The item label
153
429
  */
154
430
  label: {
@@ -404,10 +680,7 @@ const InputTextareaProps = {
404
680
  * Available for all input types except color
405
681
  * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#required
406
682
  */
407
- required: {
408
- type: Boolean,
409
- default: false
410
- }
683
+ ...RequiredProps
411
684
  };
412
685
  ({
413
686
  ...DisabledProps,
@@ -489,273 +762,6 @@ const VvTextareaProps = {
489
762
  */
490
763
  resizable: Boolean
491
764
  };
492
- function isEmpty(value) {
493
- 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));
494
- }
495
- function isString(value) {
496
- return typeof value === "string" || value instanceof String;
497
- }
498
- function joinLines(items) {
499
- if (Array.isArray(items)) {
500
- return items.filter((item) => isString(item)).join(" ");
501
- }
502
- return items;
503
- }
504
- function HintSlotFactory(propsOrRef, slots) {
505
- const props = computed(() => {
506
- if (isRef(propsOrRef)) {
507
- return propsOrRef.value;
508
- }
509
- return propsOrRef;
510
- });
511
- const invalidLabel = computed(() => joinLines(props.value.invalidLabel));
512
- const validLabel = computed(() => joinLines(props.value.validLabel));
513
- const loadingLabel = computed(() => props.value.loadingLabel);
514
- const hintLabel = computed(() => props.value.hintLabel);
515
- const hasLoadingLabelOrSlot = computed(
516
- () => Boolean(props.value.loading && (slots.loading || loadingLabel.value))
517
- );
518
- const hasInvalidLabelOrSlot = computed(
519
- () => !hasLoadingLabelOrSlot.value && Boolean(
520
- props.value.invalid && (slots.invalid || invalidLabel.value)
521
- )
522
- );
523
- const hasValidLabelOrSlot = computed(
524
- () => !hasLoadingLabelOrSlot.value && !hasInvalidLabelOrSlot.value && Boolean(props.value.valid && (slots.valid || validLabel.value))
525
- );
526
- const hasHintLabelOrSlot = computed(
527
- () => !hasLoadingLabelOrSlot.value && !hasInvalidLabelOrSlot.value && !hasValidLabelOrSlot.value && Boolean(slots.hint || hintLabel.value)
528
- );
529
- const isVisible = computed(
530
- () => hasInvalidLabelOrSlot.value || hasValidLabelOrSlot.value || hasLoadingLabelOrSlot.value || hasHintLabelOrSlot.value
531
- );
532
- const hintSlotScope = computed(() => ({
533
- modelValue: props.value.modelValue,
534
- valid: props.value.valid,
535
- invalid: props.value.invalid,
536
- loading: props.value.loading
537
- }));
538
- const HintSlot = defineComponent({
539
- name: "HintSlot",
540
- props: {
541
- tag: {
542
- type: String,
543
- default: "small"
544
- }
545
- },
546
- setup() {
547
- return {
548
- isVisible,
549
- invalidLabel,
550
- validLabel,
551
- loadingLabel,
552
- hintLabel,
553
- hasInvalidLabelOrSlot,
554
- hasValidLabelOrSlot,
555
- hasLoadingLabelOrSlot,
556
- hasHintLabelOrSlot
557
- };
558
- },
559
- render() {
560
- var _a, _b, _c, _d, _e, _f, _g, _h;
561
- if (this.isVisible) {
562
- let role;
563
- if (this.hasInvalidLabelOrSlot) {
564
- role = "alert";
565
- }
566
- if (this.hasValidLabelOrSlot) {
567
- role = "status";
568
- }
569
- if (this.hasLoadingLabelOrSlot) {
570
- return h(
571
- this.tag,
572
- {
573
- role
574
- },
575
- ((_b = (_a = this.$slots).loading) == null ? void 0 : _b.call(_a)) ?? this.loadingLabel
576
- );
577
- }
578
- if (this.hasInvalidLabelOrSlot) {
579
- return h(
580
- this.tag,
581
- {
582
- role
583
- },
584
- ((_d = (_c = this.$slots).invalid) == null ? void 0 : _d.call(_c)) ?? this.$slots.invalid ?? this.invalidLabel
585
- );
586
- }
587
- if (this.hasValidLabelOrSlot) {
588
- return h(
589
- this.tag,
590
- {
591
- role
592
- },
593
- ((_f = (_e = this.$slots).valid) == null ? void 0 : _f.call(_e)) ?? this.validLabel
594
- );
595
- }
596
- return h(
597
- this.tag,
598
- {
599
- role
600
- },
601
- ((_h = (_g = this.$slots).hint) == null ? void 0 : _h.call(_g)) ?? this.$slots.hint ?? this.hintLabel
602
- );
603
- }
604
- return null;
605
- }
606
- });
607
- return {
608
- hasInvalidLabelOrSlot,
609
- hasHintLabelOrSlot,
610
- hasValidLabelOrSlot,
611
- hasLoadingLabelOrSlot,
612
- hintSlotScope,
613
- HintSlot
614
- };
615
- }
616
- const VvIconPropsDefaults = {
617
- prefix: "normal"
618
- /* normal */
619
- };
620
- function useVolver() {
621
- return inject(INJECTION_KEY_VOLVER);
622
- }
623
- function useModifiers(prefix, modifiers, others) {
624
- return computed(() => {
625
- const toReturn = {
626
- [prefix]: true
627
- };
628
- const modifiersArray = typeof (modifiers == null ? void 0 : modifiers.value) === "string" ? modifiers.value.split(" ") : modifiers == null ? void 0 : modifiers.value;
629
- if (modifiersArray) {
630
- if (Array.isArray(modifiersArray)) {
631
- modifiersArray.forEach((modifier) => {
632
- if (modifier) {
633
- toReturn[`${prefix}--${modifier}`] = true;
634
- }
635
- });
636
- }
637
- }
638
- if (others) {
639
- Object.keys(others.value).forEach((key) => {
640
- toReturn[`${prefix}--${key}`] = unref(others.value[key]);
641
- });
642
- }
643
- return toReturn;
644
- });
645
- }
646
- const __default__$1 = {
647
- name: "VvIcon"
648
- };
649
- const _sfc_main$1 = /* @__PURE__ */ defineComponent({
650
- ...__default__$1,
651
- props: /* @__PURE__ */ mergeDefaults({
652
- name: {},
653
- color: {},
654
- width: {},
655
- height: {},
656
- provider: {},
657
- prefix: {},
658
- src: {},
659
- horizontalFlip: { type: Boolean },
660
- verticalFlip: { type: Boolean },
661
- flip: {},
662
- mode: {},
663
- inline: { type: Boolean },
664
- rotate: {},
665
- onLoad: { type: Function },
666
- svg: {},
667
- modifiers: {}
668
- }, VvIconPropsDefaults),
669
- setup(__props) {
670
- const props = __props;
671
- const hasRotate = computed(() => {
672
- if (typeof props.rotate === "string") {
673
- return Number.parseFloat(props.rotate);
674
- }
675
- return props.rotate;
676
- });
677
- const show = ref(true);
678
- const volver = useVolver();
679
- const { modifiers } = toRefs(props);
680
- const bemCssClasses = useModifiers("vv-icon", modifiers);
681
- const provider = computed(() => {
682
- return props.provider || (volver == null ? void 0 : volver.iconsProvider);
683
- });
684
- const icon = computed(() => {
685
- const name = props.name ?? "";
686
- const iconName = `@${provider.value}:${props.prefix}:${name}`;
687
- if (iconExists(iconName)) {
688
- return iconName;
689
- }
690
- const iconsCollection = volver == null ? void 0 : volver.iconsCollections.find(
691
- (iconsCollection2) => {
692
- const icon2 = `@${provider.value}:${iconsCollection2.prefix}:${name}`;
693
- return iconExists(icon2);
694
- }
695
- );
696
- if (iconsCollection) {
697
- return `@${provider.value}:${iconsCollection.prefix}:${name}`;
698
- }
699
- return name;
700
- });
701
- function getSvgContent(svg) {
702
- let dom;
703
- if (typeof window === "undefined") {
704
- const { JSDOM } = require("jsdom");
705
- dom = new JSDOM().window;
706
- }
707
- const domParser = dom ? new dom.DOMParser() : new window.DOMParser();
708
- const svgDomString = domParser.parseFromString(svg, "text/html");
709
- const svgEl = svgDomString.querySelector("svg");
710
- return svgEl;
711
- }
712
- function addIconFromSvg(svg) {
713
- const svgContentEl = getSvgContent(svg);
714
- const svgContent = (svgContentEl == null ? void 0 : svgContentEl.innerHTML.trim()) || "";
715
- if (svgContentEl && svgContent) {
716
- addIcon(`@${provider.value}:${props.prefix}:${props.name}`, {
717
- body: svgContent,
718
- // Set height and width from svg content
719
- height: svgContentEl.viewBox.baseVal.height,
720
- width: svgContentEl.viewBox.baseVal.width
721
- });
722
- }
723
- }
724
- if (volver) {
725
- if (props.src && !iconExists(`@${provider.value}:${props.prefix}:${props.name}`)) {
726
- show.value = false;
727
- volver.fetchIcon(props.src).then((svg) => {
728
- if (svg) {
729
- addIconFromSvg(svg);
730
- show.value = true;
731
- }
732
- }).catch((e) => {
733
- throw new Error(`Error during fetch icon: ${e == null ? void 0 : e.message}`);
734
- });
735
- }
736
- }
737
- if (props.svg) {
738
- addIconFromSvg(props.svg);
739
- }
740
- return (_ctx, _cache) => {
741
- return unref(show) ? (openBlock(), createBlock(unref(Icon), mergeProps({
742
- key: 0,
743
- class: unref(bemCssClasses)
744
- }, {
745
- inline: _ctx.inline,
746
- width: _ctx.width,
747
- height: _ctx.height,
748
- horizontalFlip: _ctx.horizontalFlip,
749
- verticalFlip: _ctx.verticalFlip,
750
- flip: _ctx.flip,
751
- rotate: unref(hasRotate),
752
- color: _ctx.color,
753
- onLoad: _ctx.onLoad,
754
- icon: unref(icon)
755
- }), null, 16, ["class"])) : createCommentVNode("v-if", true);
756
- };
757
- }
758
- });
759
765
  function useDefaults(componentName, propsDefinition, props) {
760
766
  const volver = useVolver();
761
767
  const volverComponentDefaults = computed(() => {