@volverjs/ui-vue 0.0.10-beta.52 → 0.0.10-beta.54
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.
- package/dist/components/VvCheckboxGroup/VvCheckboxGroup.es.js +13 -1
- package/dist/components/VvCheckboxGroup/VvCheckboxGroup.umd.js +1 -1
- package/dist/components/VvCheckboxGroup/VvCheckboxGroup.vue.d.ts +9 -0
- package/dist/components/VvCheckboxGroup/index.d.ts +4 -0
- package/dist/components/VvInputFile/VvInputFile.es.js +17 -3
- package/dist/components/VvInputFile/VvInputFile.umd.js +1 -1
- package/dist/components/VvInputFile/VvInputFile.vue.d.ts +9 -0
- package/dist/components/VvInputFile/index.d.ts +4 -0
- package/dist/components/VvInputText/VvInputText.es.js +1 -1
- package/dist/components/VvInputText/VvInputText.umd.js +1 -1
- package/dist/components/VvRadioGroup/VvRadioGroup.es.js +13 -1
- package/dist/components/VvRadioGroup/VvRadioGroup.umd.js +1 -1
- package/dist/components/VvRadioGroup/VvRadioGroup.vue.d.ts +9 -0
- package/dist/components/VvRadioGroup/index.d.ts +4 -0
- package/dist/components/VvTextarea/VvTextarea.es.js +346 -345
- package/dist/components/VvTextarea/VvTextarea.umd.js +1 -1
- package/dist/components/index.es.js +17 -6
- package/dist/components/index.umd.js +1 -1
- package/dist/icons.es.js +3 -3
- package/dist/icons.umd.js +1 -1
- package/dist/props/index.d.ts +8 -1
- package/dist/stories/InputText/InputText.stories.d.ts +2 -0
- package/dist/stories/InputText/InputText.test.d.ts +2 -0
- package/package.json +3 -3
- package/src/assets/icons/detailed.json +1 -1
- package/src/assets/icons/normal.json +1 -1
- package/src/assets/icons/simple.json +1 -1
- package/src/components/VvCheckbox/VvCheckbox.vue +2 -2
- package/src/components/VvCheckboxGroup/VvCheckboxGroup.vue +2 -0
- package/src/components/VvInputFile/VvInputFile.vue +12 -8
- package/src/components/VvInputFile/index.ts +2 -0
- package/src/components/VvInputText/VvInputText.vue +2 -2
- package/src/components/VvRadio/VvRadio.vue +2 -2
- package/src/components/VvRadioGroup/VvRadioGroup.vue +2 -0
- package/src/components/VvTextarea/VvTextarea.vue +2 -1
- package/src/props/index.ts +2 -1
- package/src/stories/InputText/InputText.stories.ts +37 -1
- package/src/stories/InputText/InputText.test.ts +18 -0
- package/src/stories/Textarea/Textarea.stories.ts +1 -1
|
@@ -1,134 +1,6 @@
|
|
|
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
|
-
};
|
|
132
4
|
var StorageType = /* @__PURE__ */ ((StorageType2) => {
|
|
133
5
|
StorageType2["local"] = "local";
|
|
134
6
|
StorageType2["session"] = "session";
|
|
@@ -176,145 +48,6 @@ var ActionTag = /* @__PURE__ */ ((ActionTag2) => {
|
|
|
176
48
|
return ActionTag2;
|
|
177
49
|
})(ActionTag || {});
|
|
178
50
|
const INJECTION_KEY_VOLVER = Symbol.for("volver");
|
|
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"
|
|
207
|
-
};
|
|
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
51
|
const LinkProps = {
|
|
319
52
|
/**
|
|
320
53
|
* The router-link/nuxt-link property, if it is defined the button is rendered as a ruouter-link or nuxt-link.
|
|
@@ -682,86 +415,353 @@ const InputTextareaProps = {
|
|
|
682
415
|
*/
|
|
683
416
|
...RequiredProps
|
|
684
417
|
};
|
|
685
|
-
({
|
|
686
|
-
...DisabledProps,
|
|
687
|
-
...LabelProps,
|
|
688
|
-
...PressedProps,
|
|
689
|
-
...ActiveProps,
|
|
690
|
-
...CurrentProps,
|
|
691
|
-
...LinkProps,
|
|
692
|
-
/**
|
|
693
|
-
* Button type
|
|
694
|
-
*/
|
|
695
|
-
type: {
|
|
696
|
-
type: String,
|
|
697
|
-
default: ButtonType.button,
|
|
698
|
-
validator: (value) => Object.values(ButtonType).includes(value)
|
|
699
|
-
},
|
|
700
|
-
/**
|
|
701
|
-
* Button aria-label
|
|
702
|
-
*/
|
|
703
|
-
ariaLabel: {
|
|
704
|
-
type: String,
|
|
705
|
-
default: void 0
|
|
706
|
-
},
|
|
707
|
-
/**
|
|
708
|
-
* Default tag for the action
|
|
709
|
-
*/
|
|
710
|
-
defaultTag: {
|
|
711
|
-
type: String,
|
|
712
|
-
default: ActionTag.button
|
|
418
|
+
({
|
|
419
|
+
...DisabledProps,
|
|
420
|
+
...LabelProps,
|
|
421
|
+
...PressedProps,
|
|
422
|
+
...ActiveProps,
|
|
423
|
+
...CurrentProps,
|
|
424
|
+
...LinkProps,
|
|
425
|
+
/**
|
|
426
|
+
* Button type
|
|
427
|
+
*/
|
|
428
|
+
type: {
|
|
429
|
+
type: String,
|
|
430
|
+
default: ButtonType.button,
|
|
431
|
+
validator: (value) => Object.values(ButtonType).includes(value)
|
|
432
|
+
},
|
|
433
|
+
/**
|
|
434
|
+
* Button aria-label
|
|
435
|
+
*/
|
|
436
|
+
ariaLabel: {
|
|
437
|
+
type: String,
|
|
438
|
+
default: void 0
|
|
439
|
+
},
|
|
440
|
+
/**
|
|
441
|
+
* Default tag for the action
|
|
442
|
+
*/
|
|
443
|
+
defaultTag: {
|
|
444
|
+
type: String,
|
|
445
|
+
default: ActionTag.button
|
|
446
|
+
}
|
|
447
|
+
});
|
|
448
|
+
({
|
|
449
|
+
storageType: {
|
|
450
|
+
type: String,
|
|
451
|
+
default: StorageType.local,
|
|
452
|
+
validator: (value) => Object.values(StorageType).includes(value)
|
|
453
|
+
},
|
|
454
|
+
storageKey: String
|
|
455
|
+
});
|
|
456
|
+
const WRAP = {
|
|
457
|
+
hard: "hard",
|
|
458
|
+
soft: "soft"
|
|
459
|
+
};
|
|
460
|
+
const SPELLCHECK = {
|
|
461
|
+
true: true,
|
|
462
|
+
false: false,
|
|
463
|
+
default: "default"
|
|
464
|
+
};
|
|
465
|
+
const VvTextareaEvents = ["update:modelValue", "focus", "blur", "keyup"];
|
|
466
|
+
const VvTextareaProps = {
|
|
467
|
+
...InputTextareaProps,
|
|
468
|
+
/**
|
|
469
|
+
* Textarea value
|
|
470
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/textarea#value
|
|
471
|
+
*/
|
|
472
|
+
modelValue: String,
|
|
473
|
+
/**
|
|
474
|
+
* The visible width of the text control, in average character widths. If it is specified, it must be a positive integer. If it is not specified, the default value is 20.
|
|
475
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/textarea#cols
|
|
476
|
+
*/
|
|
477
|
+
cols: { type: [String, Number], default: 20 },
|
|
478
|
+
/**
|
|
479
|
+
* The number of visible text lines for the control. If it is specified, it must be a positive integer. If it is not specified, the default value is 2.
|
|
480
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/textarea#rows
|
|
481
|
+
*/
|
|
482
|
+
rows: { type: [String, Number], default: 2 },
|
|
483
|
+
/**
|
|
484
|
+
* Indicates how the control should wrap the value for form submission.
|
|
485
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/textarea#wrap
|
|
486
|
+
*/
|
|
487
|
+
wrap: { type: String, default: WRAP.soft },
|
|
488
|
+
/**
|
|
489
|
+
* Specifies whether the <textarea> is subject to spell checking by the underlying browser/OS.
|
|
490
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/textarea#wrap
|
|
491
|
+
*/
|
|
492
|
+
spellcheck: { type: [Boolean, String], default: SPELLCHECK.default },
|
|
493
|
+
/**
|
|
494
|
+
* If true, the textarea will be resizable
|
|
495
|
+
*/
|
|
496
|
+
resizable: Boolean
|
|
497
|
+
};
|
|
498
|
+
function isEmpty(value) {
|
|
499
|
+
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));
|
|
500
|
+
}
|
|
501
|
+
function isString(value) {
|
|
502
|
+
return typeof value === "string" || value instanceof String;
|
|
503
|
+
}
|
|
504
|
+
function joinLines(items) {
|
|
505
|
+
if (Array.isArray(items)) {
|
|
506
|
+
return items.filter((item) => isString(item)).join(" ");
|
|
507
|
+
}
|
|
508
|
+
return items;
|
|
509
|
+
}
|
|
510
|
+
function HintSlotFactory(propsOrRef, slots) {
|
|
511
|
+
const props = computed(() => {
|
|
512
|
+
if (isRef(propsOrRef)) {
|
|
513
|
+
return propsOrRef.value;
|
|
514
|
+
}
|
|
515
|
+
return propsOrRef;
|
|
516
|
+
});
|
|
517
|
+
const invalidLabel = computed(() => joinLines(props.value.invalidLabel));
|
|
518
|
+
const validLabel = computed(() => joinLines(props.value.validLabel));
|
|
519
|
+
const loadingLabel = computed(() => props.value.loadingLabel);
|
|
520
|
+
const hintLabel = computed(() => props.value.hintLabel);
|
|
521
|
+
const hasLoadingLabelOrSlot = computed(
|
|
522
|
+
() => Boolean(props.value.loading && (slots.loading || loadingLabel.value))
|
|
523
|
+
);
|
|
524
|
+
const hasInvalidLabelOrSlot = computed(
|
|
525
|
+
() => !hasLoadingLabelOrSlot.value && Boolean(
|
|
526
|
+
props.value.invalid && (slots.invalid || invalidLabel.value)
|
|
527
|
+
)
|
|
528
|
+
);
|
|
529
|
+
const hasValidLabelOrSlot = computed(
|
|
530
|
+
() => !hasLoadingLabelOrSlot.value && !hasInvalidLabelOrSlot.value && Boolean(props.value.valid && (slots.valid || validLabel.value))
|
|
531
|
+
);
|
|
532
|
+
const hasHintLabelOrSlot = computed(
|
|
533
|
+
() => !hasLoadingLabelOrSlot.value && !hasInvalidLabelOrSlot.value && !hasValidLabelOrSlot.value && Boolean(slots.hint || hintLabel.value)
|
|
534
|
+
);
|
|
535
|
+
const isVisible = computed(
|
|
536
|
+
() => hasInvalidLabelOrSlot.value || hasValidLabelOrSlot.value || hasLoadingLabelOrSlot.value || hasHintLabelOrSlot.value
|
|
537
|
+
);
|
|
538
|
+
const hintSlotScope = computed(() => ({
|
|
539
|
+
modelValue: props.value.modelValue,
|
|
540
|
+
valid: props.value.valid,
|
|
541
|
+
invalid: props.value.invalid,
|
|
542
|
+
loading: props.value.loading
|
|
543
|
+
}));
|
|
544
|
+
const HintSlot = defineComponent({
|
|
545
|
+
name: "HintSlot",
|
|
546
|
+
props: {
|
|
547
|
+
tag: {
|
|
548
|
+
type: String,
|
|
549
|
+
default: "small"
|
|
550
|
+
}
|
|
551
|
+
},
|
|
552
|
+
setup() {
|
|
553
|
+
return {
|
|
554
|
+
isVisible,
|
|
555
|
+
invalidLabel,
|
|
556
|
+
validLabel,
|
|
557
|
+
loadingLabel,
|
|
558
|
+
hintLabel,
|
|
559
|
+
hasInvalidLabelOrSlot,
|
|
560
|
+
hasValidLabelOrSlot,
|
|
561
|
+
hasLoadingLabelOrSlot,
|
|
562
|
+
hasHintLabelOrSlot
|
|
563
|
+
};
|
|
564
|
+
},
|
|
565
|
+
render() {
|
|
566
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
567
|
+
if (this.isVisible) {
|
|
568
|
+
let role;
|
|
569
|
+
if (this.hasInvalidLabelOrSlot) {
|
|
570
|
+
role = "alert";
|
|
571
|
+
}
|
|
572
|
+
if (this.hasValidLabelOrSlot) {
|
|
573
|
+
role = "status";
|
|
574
|
+
}
|
|
575
|
+
if (this.hasLoadingLabelOrSlot) {
|
|
576
|
+
return h(
|
|
577
|
+
this.tag,
|
|
578
|
+
{
|
|
579
|
+
role
|
|
580
|
+
},
|
|
581
|
+
((_b = (_a = this.$slots).loading) == null ? void 0 : _b.call(_a)) ?? this.loadingLabel
|
|
582
|
+
);
|
|
583
|
+
}
|
|
584
|
+
if (this.hasInvalidLabelOrSlot) {
|
|
585
|
+
return h(
|
|
586
|
+
this.tag,
|
|
587
|
+
{
|
|
588
|
+
role
|
|
589
|
+
},
|
|
590
|
+
((_d = (_c = this.$slots).invalid) == null ? void 0 : _d.call(_c)) ?? this.$slots.invalid ?? this.invalidLabel
|
|
591
|
+
);
|
|
592
|
+
}
|
|
593
|
+
if (this.hasValidLabelOrSlot) {
|
|
594
|
+
return h(
|
|
595
|
+
this.tag,
|
|
596
|
+
{
|
|
597
|
+
role
|
|
598
|
+
},
|
|
599
|
+
((_f = (_e = this.$slots).valid) == null ? void 0 : _f.call(_e)) ?? this.validLabel
|
|
600
|
+
);
|
|
601
|
+
}
|
|
602
|
+
return h(
|
|
603
|
+
this.tag,
|
|
604
|
+
{
|
|
605
|
+
role
|
|
606
|
+
},
|
|
607
|
+
((_h = (_g = this.$slots).hint) == null ? void 0 : _h.call(_g)) ?? this.$slots.hint ?? this.hintLabel
|
|
608
|
+
);
|
|
609
|
+
}
|
|
610
|
+
return null;
|
|
611
|
+
}
|
|
612
|
+
});
|
|
613
|
+
return {
|
|
614
|
+
hasInvalidLabelOrSlot,
|
|
615
|
+
hasHintLabelOrSlot,
|
|
616
|
+
hasValidLabelOrSlot,
|
|
617
|
+
hasLoadingLabelOrSlot,
|
|
618
|
+
hintSlotScope,
|
|
619
|
+
HintSlot
|
|
620
|
+
};
|
|
621
|
+
}
|
|
622
|
+
const VvIconPropsDefaults = {
|
|
623
|
+
prefix: "normal"
|
|
624
|
+
/* normal */
|
|
625
|
+
};
|
|
626
|
+
function useVolver() {
|
|
627
|
+
return inject(INJECTION_KEY_VOLVER);
|
|
628
|
+
}
|
|
629
|
+
function useModifiers(prefix, modifiers, others) {
|
|
630
|
+
return computed(() => {
|
|
631
|
+
const toReturn = {
|
|
632
|
+
[prefix]: true
|
|
633
|
+
};
|
|
634
|
+
const modifiersArray = typeof (modifiers == null ? void 0 : modifiers.value) === "string" ? modifiers.value.split(" ") : modifiers == null ? void 0 : modifiers.value;
|
|
635
|
+
if (modifiersArray) {
|
|
636
|
+
if (Array.isArray(modifiersArray)) {
|
|
637
|
+
modifiersArray.forEach((modifier) => {
|
|
638
|
+
if (modifier) {
|
|
639
|
+
toReturn[`${prefix}--${modifier}`] = true;
|
|
640
|
+
}
|
|
641
|
+
});
|
|
642
|
+
}
|
|
643
|
+
}
|
|
644
|
+
if (others) {
|
|
645
|
+
Object.keys(others.value).forEach((key) => {
|
|
646
|
+
toReturn[`${prefix}--${key}`] = unref(others.value[key]);
|
|
647
|
+
});
|
|
648
|
+
}
|
|
649
|
+
return toReturn;
|
|
650
|
+
});
|
|
651
|
+
}
|
|
652
|
+
const __default__$1 = {
|
|
653
|
+
name: "VvIcon"
|
|
654
|
+
};
|
|
655
|
+
const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
656
|
+
...__default__$1,
|
|
657
|
+
props: /* @__PURE__ */ mergeDefaults({
|
|
658
|
+
name: {},
|
|
659
|
+
color: {},
|
|
660
|
+
width: {},
|
|
661
|
+
height: {},
|
|
662
|
+
provider: {},
|
|
663
|
+
prefix: {},
|
|
664
|
+
src: {},
|
|
665
|
+
horizontalFlip: { type: Boolean },
|
|
666
|
+
verticalFlip: { type: Boolean },
|
|
667
|
+
flip: {},
|
|
668
|
+
mode: {},
|
|
669
|
+
inline: { type: Boolean },
|
|
670
|
+
rotate: {},
|
|
671
|
+
onLoad: { type: Function },
|
|
672
|
+
svg: {},
|
|
673
|
+
modifiers: {}
|
|
674
|
+
}, VvIconPropsDefaults),
|
|
675
|
+
setup(__props) {
|
|
676
|
+
const props = __props;
|
|
677
|
+
const hasRotate = computed(() => {
|
|
678
|
+
if (typeof props.rotate === "string") {
|
|
679
|
+
return Number.parseFloat(props.rotate);
|
|
680
|
+
}
|
|
681
|
+
return props.rotate;
|
|
682
|
+
});
|
|
683
|
+
const show = ref(true);
|
|
684
|
+
const volver = useVolver();
|
|
685
|
+
const { modifiers } = toRefs(props);
|
|
686
|
+
const bemCssClasses = useModifiers("vv-icon", modifiers);
|
|
687
|
+
const provider = computed(() => {
|
|
688
|
+
return props.provider || (volver == null ? void 0 : volver.iconsProvider);
|
|
689
|
+
});
|
|
690
|
+
const icon = computed(() => {
|
|
691
|
+
const name = props.name ?? "";
|
|
692
|
+
const iconName = `@${provider.value}:${props.prefix}:${name}`;
|
|
693
|
+
if (iconExists(iconName)) {
|
|
694
|
+
return iconName;
|
|
695
|
+
}
|
|
696
|
+
const iconsCollection = volver == null ? void 0 : volver.iconsCollections.find(
|
|
697
|
+
(iconsCollection2) => {
|
|
698
|
+
const icon2 = `@${provider.value}:${iconsCollection2.prefix}:${name}`;
|
|
699
|
+
return iconExists(icon2);
|
|
700
|
+
}
|
|
701
|
+
);
|
|
702
|
+
if (iconsCollection) {
|
|
703
|
+
return `@${provider.value}:${iconsCollection.prefix}:${name}`;
|
|
704
|
+
}
|
|
705
|
+
return name;
|
|
706
|
+
});
|
|
707
|
+
function getSvgContent(svg) {
|
|
708
|
+
let dom;
|
|
709
|
+
if (typeof window === "undefined") {
|
|
710
|
+
const { JSDOM } = require("jsdom");
|
|
711
|
+
dom = new JSDOM().window;
|
|
712
|
+
}
|
|
713
|
+
const domParser = dom ? new dom.DOMParser() : new window.DOMParser();
|
|
714
|
+
const svgDomString = domParser.parseFromString(svg, "text/html");
|
|
715
|
+
const svgEl = svgDomString.querySelector("svg");
|
|
716
|
+
return svgEl;
|
|
717
|
+
}
|
|
718
|
+
function addIconFromSvg(svg) {
|
|
719
|
+
const svgContentEl = getSvgContent(svg);
|
|
720
|
+
const svgContent = (svgContentEl == null ? void 0 : svgContentEl.innerHTML.trim()) || "";
|
|
721
|
+
if (svgContentEl && svgContent) {
|
|
722
|
+
addIcon(`@${provider.value}:${props.prefix}:${props.name}`, {
|
|
723
|
+
body: svgContent,
|
|
724
|
+
// Set height and width from svg content
|
|
725
|
+
height: svgContentEl.viewBox.baseVal.height,
|
|
726
|
+
width: svgContentEl.viewBox.baseVal.width
|
|
727
|
+
});
|
|
728
|
+
}
|
|
729
|
+
}
|
|
730
|
+
if (volver) {
|
|
731
|
+
if (props.src && !iconExists(`@${provider.value}:${props.prefix}:${props.name}`)) {
|
|
732
|
+
show.value = false;
|
|
733
|
+
volver.fetchIcon(props.src).then((svg) => {
|
|
734
|
+
if (svg) {
|
|
735
|
+
addIconFromSvg(svg);
|
|
736
|
+
show.value = true;
|
|
737
|
+
}
|
|
738
|
+
}).catch((e) => {
|
|
739
|
+
throw new Error(`Error during fetch icon: ${e == null ? void 0 : e.message}`);
|
|
740
|
+
});
|
|
741
|
+
}
|
|
742
|
+
}
|
|
743
|
+
if (props.svg) {
|
|
744
|
+
addIconFromSvg(props.svg);
|
|
745
|
+
}
|
|
746
|
+
return (_ctx, _cache) => {
|
|
747
|
+
return unref(show) ? (openBlock(), createBlock(unref(Icon), mergeProps({
|
|
748
|
+
key: 0,
|
|
749
|
+
class: unref(bemCssClasses)
|
|
750
|
+
}, {
|
|
751
|
+
inline: _ctx.inline,
|
|
752
|
+
width: _ctx.width,
|
|
753
|
+
height: _ctx.height,
|
|
754
|
+
horizontalFlip: _ctx.horizontalFlip,
|
|
755
|
+
verticalFlip: _ctx.verticalFlip,
|
|
756
|
+
flip: _ctx.flip,
|
|
757
|
+
rotate: unref(hasRotate),
|
|
758
|
+
color: _ctx.color,
|
|
759
|
+
onLoad: _ctx.onLoad,
|
|
760
|
+
icon: unref(icon)
|
|
761
|
+
}), null, 16, ["class"])) : createCommentVNode("v-if", true);
|
|
762
|
+
};
|
|
713
763
|
}
|
|
714
764
|
});
|
|
715
|
-
({
|
|
716
|
-
storageType: {
|
|
717
|
-
type: String,
|
|
718
|
-
default: StorageType.local,
|
|
719
|
-
validator: (value) => Object.values(StorageType).includes(value)
|
|
720
|
-
},
|
|
721
|
-
storageKey: String
|
|
722
|
-
});
|
|
723
|
-
const WRAP = {
|
|
724
|
-
hard: "hard",
|
|
725
|
-
soft: "soft"
|
|
726
|
-
};
|
|
727
|
-
const SPELLCHECK = {
|
|
728
|
-
true: true,
|
|
729
|
-
false: false,
|
|
730
|
-
default: "default"
|
|
731
|
-
};
|
|
732
|
-
const VvTextareaEvents = ["update:modelValue", "focus", "blur", "keyup"];
|
|
733
|
-
const VvTextareaProps = {
|
|
734
|
-
...InputTextareaProps,
|
|
735
|
-
/**
|
|
736
|
-
* Textarea value
|
|
737
|
-
* @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/textarea#value
|
|
738
|
-
*/
|
|
739
|
-
modelValue: String,
|
|
740
|
-
/**
|
|
741
|
-
* The visible width of the text control, in average character widths. If it is specified, it must be a positive integer. If it is not specified, the default value is 20.
|
|
742
|
-
* @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/textarea#cols
|
|
743
|
-
*/
|
|
744
|
-
cols: { type: [String, Number], default: 20 },
|
|
745
|
-
/**
|
|
746
|
-
* The number of visible text lines for the control. If it is specified, it must be a positive integer. If it is not specified, the default value is 2.
|
|
747
|
-
* @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/textarea#rows
|
|
748
|
-
*/
|
|
749
|
-
rows: { type: [String, Number], default: 2 },
|
|
750
|
-
/**
|
|
751
|
-
* Indicates how the control should wrap the value for form submission.
|
|
752
|
-
* @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/textarea#wrap
|
|
753
|
-
*/
|
|
754
|
-
wrap: { type: String, default: WRAP.soft },
|
|
755
|
-
/**
|
|
756
|
-
* Specifies whether the <textarea> is subject to spell checking by the underlying browser/OS.
|
|
757
|
-
* @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/textarea#wrap
|
|
758
|
-
*/
|
|
759
|
-
spellcheck: { type: [Boolean, String], default: SPELLCHECK.default },
|
|
760
|
-
/**
|
|
761
|
-
* If true, the textarea will be resizable
|
|
762
|
-
*/
|
|
763
|
-
resizable: Boolean
|
|
764
|
-
};
|
|
765
765
|
function useDefaults(componentName, propsDefinition, props) {
|
|
766
766
|
const volver = useVolver();
|
|
767
767
|
const volverComponentDefaults = computed(() => {
|
|
@@ -1012,6 +1012,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
1012
1012
|
"loading": loading.value,
|
|
1013
1013
|
"disabled": props.disabled,
|
|
1014
1014
|
"readonly": props.readonly,
|
|
1015
|
+
"required": props.required,
|
|
1015
1016
|
"icon-before": hasIconBefore.value !== void 0,
|
|
1016
1017
|
"icon-after": hasIconAfter.value !== void 0,
|
|
1017
1018
|
"floating": props.floating && !isEmpty(props.label),
|