@volverjs/ui-vue 0.0.6-beta.5 → 0.0.6-beta.7
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/auto-imports.d.ts +9 -0
- package/dist/Volver.d.ts +1 -1
- package/dist/components/VvAccordion/index.d.ts +1 -1
- package/dist/components/VvButton/VvButton.es.js +25 -19
- package/dist/components/VvButton/VvButton.umd.js +1 -1
- package/dist/components/VvCheckbox/VvCheckbox.es.js +151 -98
- package/dist/components/VvCheckbox/VvCheckbox.umd.js +1 -1
- package/dist/components/VvCheckbox/VvCheckbox.vue.d.ts +37 -1
- package/dist/components/VvCheckbox/index.d.ts +6 -1
- package/dist/components/VvCheckboxGroup/VvCheckboxGroup.es.js +187 -101
- package/dist/components/VvCheckboxGroup/VvCheckboxGroup.umd.js +1 -1
- package/dist/components/VvCheckboxGroup/VvCheckboxGroup.vue.d.ts +36 -0
- package/dist/components/VvCheckboxGroup/index.d.ts +5 -0
- package/dist/components/VvCombobox/VvCombobox.es.js +236 -140
- package/dist/components/VvCombobox/VvCombobox.umd.js +1 -1
- package/dist/components/VvCombobox/VvCombobox.vue.d.ts +25 -1
- package/dist/components/VvDialog/VvDialog.es.js +25 -19
- package/dist/components/VvDialog/VvDialog.umd.js +1 -1
- package/dist/components/VvDropdown/VvDropdown.es.js +19 -4
- package/dist/components/VvDropdown/VvDropdown.umd.js +1 -1
- package/dist/components/VvDropdown/VvDropdown.vue.d.ts +8 -4
- package/dist/components/VvDropdown/index.d.ts +1 -1
- package/dist/components/VvIcon/VvIcon.es.js +25 -19
- package/dist/components/VvIcon/VvIcon.umd.js +1 -1
- package/dist/components/VvIcon/VvIcon.vue.d.ts +2 -2
- package/dist/components/VvIcon/index.d.ts +2 -2
- package/dist/components/VvInputText/VvInputText.es.js +160 -136
- package/dist/components/VvInputText/VvInputText.umd.js +1 -1
- package/dist/components/VvInputText/VvInputText.vue.d.ts +24 -0
- package/dist/components/VvRadio/VvRadio.es.js +151 -98
- package/dist/components/VvRadio/VvRadio.umd.js +1 -1
- package/dist/components/VvRadio/VvRadio.vue.d.ts +37 -1
- package/dist/components/VvRadio/index.d.ts +6 -1
- package/dist/components/VvRadioGroup/VvRadioGroup.es.js +187 -101
- package/dist/components/VvRadioGroup/VvRadioGroup.umd.js +1 -1
- package/dist/components/VvRadioGroup/VvRadioGroup.vue.d.ts +36 -0
- package/dist/components/VvRadioGroup/index.d.ts +5 -0
- package/dist/components/VvSelect/VvSelect.es.js +163 -137
- package/dist/components/VvSelect/VvSelect.umd.js +1 -1
- package/dist/components/VvSelect/VvSelect.vue.d.ts +24 -0
- package/dist/components/VvTextarea/VvTextarea.es.js +160 -136
- package/dist/components/VvTextarea/VvTextarea.umd.js +1 -1
- package/dist/components/VvTextarea/VvTextarea.vue.d.ts +24 -0
- package/dist/components/common/HintSlot.d.ts +38 -12
- package/dist/components/index.es.js +466 -168
- package/dist/components/index.umd.js +1 -1
- package/dist/composables/group/useInjectedGroupState.d.ts +1 -1
- package/dist/composables/useOptions.d.ts +2 -2
- package/dist/directives/index.d.ts +2 -2
- package/dist/icons.es.js +3 -3
- package/dist/icons.umd.js +1 -1
- package/dist/props/index.d.ts +22 -0
- package/package.json +33 -33
- 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 +23 -2
- package/src/components/VvCheckboxGroup/VvCheckboxGroup.vue +15 -2
- package/src/components/VvCombobox/VvCombobox.vue +40 -16
- package/src/components/VvDropdown/VvDropdown.vue +20 -2
- package/src/components/VvIcon/VvIcon.vue +37 -34
- package/src/components/VvIcon/index.ts +2 -2
- package/src/components/VvInputText/VvInputText.vue +26 -9
- package/src/components/VvRadio/VvRadio.vue +23 -2
- package/src/components/VvRadioGroup/VvRadioGroup.vue +15 -2
- package/src/components/VvSelect/VvSelect.vue +26 -9
- package/src/components/VvTextarea/VvTextarea.vue +26 -9
- package/src/components/common/HintSlot.ts +129 -170
- package/src/composables/useOptions.ts +9 -7
- package/src/props/index.ts +2 -0
|
@@ -1,137 +1,121 @@
|
|
|
1
|
-
import { unref,
|
|
2
|
-
import { toReactive, useFocus, useElementVisibility } from "@vueuse/core";
|
|
1
|
+
import { unref, computed, defineComponent, h, inject, ref, toRefs, openBlock, createBlock, mergeProps, createCommentVNode, watch, useSlots, createElementBlock, normalizeClass, toDisplayString, createElementVNode, renderSlot, normalizeProps, guardReactiveProps, withDirectives, isRef, vModelText, createTextVNode, createVNode, createSlots, withCtx } from "vue";
|
|
3
2
|
import { iconExists, Icon, addIcon } from "@iconify/vue";
|
|
4
3
|
import { nanoid } from "nanoid";
|
|
5
|
-
|
|
6
|
-
if (data && Object.keys(data).length && field) {
|
|
7
|
-
if (field.indexOf(".") === -1) {
|
|
8
|
-
return data[field];
|
|
9
|
-
} else {
|
|
10
|
-
const fields = field.split(".");
|
|
11
|
-
let value = data;
|
|
12
|
-
for (let i = 0, len = fields.length; i < len; ++i) {
|
|
13
|
-
if (data == null) {
|
|
14
|
-
return null;
|
|
15
|
-
}
|
|
16
|
-
value = value[fields[i]];
|
|
17
|
-
}
|
|
18
|
-
return value;
|
|
19
|
-
}
|
|
20
|
-
} else {
|
|
21
|
-
return null;
|
|
22
|
-
}
|
|
23
|
-
}
|
|
4
|
+
import { useFocus, useElementVisibility } from "@vueuse/core";
|
|
24
5
|
function isEmpty(value) {
|
|
25
6
|
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));
|
|
26
7
|
}
|
|
27
8
|
function isString(value) {
|
|
28
9
|
return typeof value === "string" || value instanceof String;
|
|
29
10
|
}
|
|
30
|
-
function joinLines(
|
|
31
|
-
if (Array.isArray(
|
|
32
|
-
return
|
|
11
|
+
function joinLines(items) {
|
|
12
|
+
if (Array.isArray(items)) {
|
|
13
|
+
return items.filter((item) => isString(item)).join(" ");
|
|
33
14
|
}
|
|
34
|
-
return
|
|
15
|
+
return items;
|
|
35
16
|
}
|
|
36
|
-
function HintSlotFactory(
|
|
37
|
-
const
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
const {
|
|
44
|
-
hintLabel,
|
|
45
|
-
modelValue,
|
|
46
|
-
valid,
|
|
47
|
-
validLabel,
|
|
48
|
-
invalid,
|
|
49
|
-
invalidLabel,
|
|
50
|
-
...otherProps
|
|
51
|
-
} = toRefs(parentProps);
|
|
52
|
-
const loading = resolveFieldData(otherProps, "loading");
|
|
53
|
-
const loadingLabel = resolveFieldData(otherProps, "loadingLabel");
|
|
54
|
-
const hasInvalid = computed(() => {
|
|
55
|
-
if (!invalid.value) {
|
|
56
|
-
return false;
|
|
57
|
-
}
|
|
58
|
-
if (invalid.value && invalidSlot) {
|
|
59
|
-
return true;
|
|
60
|
-
}
|
|
61
|
-
if ((invalidLabel == null ? void 0 : invalidLabel.value) && Array.isArray(invalidLabel.value) && invalidLabel.value.length > 0) {
|
|
62
|
-
return true;
|
|
63
|
-
}
|
|
64
|
-
if ((invalidLabel == null ? void 0 : invalidLabel.value) && !isEmpty(invalidLabel)) {
|
|
65
|
-
return true;
|
|
66
|
-
}
|
|
67
|
-
return false;
|
|
68
|
-
});
|
|
69
|
-
const hasHint = computed(
|
|
70
|
-
() => !!(hintLabel && hintLabel.value || hintSlot)
|
|
17
|
+
function HintSlotFactory(props, slots) {
|
|
18
|
+
const invalidLabel = computed(() => joinLines(props.invalidLabel));
|
|
19
|
+
const validLabel = computed(() => joinLines(props.validLabel));
|
|
20
|
+
const loadingLabel = computed(() => props.loadingLabel);
|
|
21
|
+
const hintLabel = computed(() => props.hintLabel);
|
|
22
|
+
const hasLoadingLabelOrSlot = computed(
|
|
23
|
+
() => Boolean(props.loading && (slots.loading || loadingLabel.value))
|
|
71
24
|
);
|
|
72
|
-
const
|
|
73
|
-
() =>
|
|
25
|
+
const hasInvalidLabelOrSlot = computed(
|
|
26
|
+
() => !hasLoadingLabelOrSlot.value && Boolean(props.invalid && (slots.invalid || invalidLabel.value))
|
|
74
27
|
);
|
|
75
|
-
const
|
|
76
|
-
() =>
|
|
28
|
+
const hasValidLabelOrSlot = computed(
|
|
29
|
+
() => !hasLoadingLabelOrSlot.value && !hasInvalidLabelOrSlot.value && Boolean(props.valid && (slots.valid || validLabel.value))
|
|
30
|
+
);
|
|
31
|
+
const hasHintLabelOrSlot = computed(
|
|
32
|
+
() => !hasLoadingLabelOrSlot.value && !hasInvalidLabelOrSlot.value && !hasValidLabelOrSlot.value && Boolean(slots.hint || hintLabel.value)
|
|
77
33
|
);
|
|
78
34
|
const isVisible = computed(
|
|
79
|
-
() =>
|
|
35
|
+
() => hasInvalidLabelOrSlot.value || hasValidLabelOrSlot.value || hasLoadingLabelOrSlot.value || hasHintLabelOrSlot.value
|
|
80
36
|
);
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
37
|
+
const hintSlotScope = computed(() => ({
|
|
38
|
+
modelValue: props.modelValue,
|
|
39
|
+
valid: props.valid,
|
|
40
|
+
invalid: props.invalid,
|
|
41
|
+
loading: props.loading
|
|
42
|
+
}));
|
|
43
|
+
const HintSlot = defineComponent({
|
|
44
|
+
name: "HintSlot",
|
|
45
|
+
props: {
|
|
46
|
+
tag: {
|
|
47
|
+
type: String,
|
|
48
|
+
default: "small"
|
|
49
|
+
}
|
|
50
|
+
},
|
|
51
|
+
setup() {
|
|
52
|
+
return {
|
|
53
|
+
isVisible,
|
|
54
|
+
invalidLabel,
|
|
55
|
+
validLabel,
|
|
56
|
+
loadingLabel,
|
|
57
|
+
hintLabel,
|
|
58
|
+
hasInvalidLabelOrSlot,
|
|
59
|
+
hasValidLabelOrSlot,
|
|
60
|
+
hasLoadingLabelOrSlot,
|
|
61
|
+
hasHintLabelOrSlot
|
|
62
|
+
};
|
|
63
|
+
},
|
|
64
|
+
render() {
|
|
65
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
66
|
+
if (this.isVisible) {
|
|
67
|
+
let role;
|
|
68
|
+
if (this.hasInvalidLabelOrSlot) {
|
|
69
|
+
role = "alert";
|
|
92
70
|
}
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
hintLabel,
|
|
98
|
-
modelValue,
|
|
99
|
-
valid,
|
|
100
|
-
validLabel,
|
|
101
|
-
invalid,
|
|
102
|
-
invalidLabel,
|
|
103
|
-
loading,
|
|
104
|
-
loadingLabel,
|
|
105
|
-
...props.params
|
|
106
|
-
});
|
|
107
|
-
if (invalid == null ? void 0 : invalid.value) {
|
|
108
|
-
return (invalidSlot == null ? void 0 : invalidSlot(slotProps)) || joinLines(invalidLabel == null ? void 0 : invalidLabel.value) || (hintLabel == null ? void 0 : hintLabel.value);
|
|
109
|
-
}
|
|
110
|
-
if (valid == null ? void 0 : valid.value)
|
|
111
|
-
return (validSlot == null ? void 0 : validSlot(slotProps)) || joinLines(validLabel == null ? void 0 : validLabel.value) || (hintLabel == null ? void 0 : hintLabel.value);
|
|
112
|
-
if (loading == null ? void 0 : loading.value)
|
|
113
|
-
return (loadingSlot == null ? void 0 : loadingSlot(slotProps)) || joinLines(loadingLabel == null ? void 0 : loadingLabel.value) || (hintLabel == null ? void 0 : hintLabel.value);
|
|
114
|
-
return (hintSlot == null ? void 0 : hintSlot(slotProps)) || joinLines(hintLabel == null ? void 0 : hintLabel.value) || (hintLabel == null ? void 0 : hintLabel.value);
|
|
115
|
-
});
|
|
116
|
-
return {
|
|
117
|
-
isVisible,
|
|
118
|
-
hasInvalid,
|
|
119
|
-
hasValid,
|
|
120
|
-
hintContent
|
|
121
|
-
};
|
|
122
|
-
},
|
|
123
|
-
render() {
|
|
124
|
-
if (this.isVisible) {
|
|
71
|
+
if (this.hasValidLabelOrSlot) {
|
|
72
|
+
role = "status";
|
|
73
|
+
}
|
|
74
|
+
if (this.hasLoadingLabelOrSlot) {
|
|
125
75
|
return h(
|
|
126
|
-
|
|
76
|
+
this.tag,
|
|
127
77
|
{
|
|
128
|
-
role
|
|
78
|
+
role
|
|
129
79
|
},
|
|
130
|
-
this.
|
|
80
|
+
((_b = (_a = this.$slots).loading) == null ? void 0 : _b.call(_a)) ?? this.loadingLabel
|
|
131
81
|
);
|
|
132
82
|
}
|
|
83
|
+
if (this.hasInvalidLabelOrSlot) {
|
|
84
|
+
return h(
|
|
85
|
+
this.tag,
|
|
86
|
+
{
|
|
87
|
+
role
|
|
88
|
+
},
|
|
89
|
+
((_d = (_c = this.$slots).invalid) == null ? void 0 : _d.call(_c)) ?? this.$slots.invalid ?? this.invalidLabel
|
|
90
|
+
);
|
|
91
|
+
}
|
|
92
|
+
if (this.hasValidLabelOrSlot) {
|
|
93
|
+
return h(
|
|
94
|
+
this.tag,
|
|
95
|
+
{
|
|
96
|
+
role
|
|
97
|
+
},
|
|
98
|
+
((_f = (_e = this.$slots).valid) == null ? void 0 : _f.call(_e)) ?? this.validLabel
|
|
99
|
+
);
|
|
100
|
+
}
|
|
101
|
+
return h(
|
|
102
|
+
this.tag,
|
|
103
|
+
{
|
|
104
|
+
role
|
|
105
|
+
},
|
|
106
|
+
((_h = (_g = this.$slots).hint) == null ? void 0 : _h.call(_g)) ?? this.$slots.hint ?? this.hintLabel
|
|
107
|
+
);
|
|
133
108
|
}
|
|
109
|
+
return null;
|
|
134
110
|
}
|
|
111
|
+
});
|
|
112
|
+
return {
|
|
113
|
+
hasInvalidLabelOrSlot,
|
|
114
|
+
hasHintLabelOrSlot,
|
|
115
|
+
hasValidLabelOrSlot,
|
|
116
|
+
hasLoadingLabelOrSlot,
|
|
117
|
+
hintSlotScope,
|
|
118
|
+
HintSlot
|
|
135
119
|
};
|
|
136
120
|
}
|
|
137
121
|
const VvIconProps = {
|
|
@@ -299,6 +283,12 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
299
283
|
props: VvIconProps,
|
|
300
284
|
setup(__props) {
|
|
301
285
|
const props = __props;
|
|
286
|
+
const hasRotate = computed(() => {
|
|
287
|
+
if (typeof props.rotate === "string") {
|
|
288
|
+
return parseFloat(props.rotate);
|
|
289
|
+
}
|
|
290
|
+
return props.rotate;
|
|
291
|
+
});
|
|
302
292
|
const show = ref(true);
|
|
303
293
|
const volver = useVolver();
|
|
304
294
|
const { modifiers } = toRefs(props);
|
|
@@ -307,25 +297,24 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
307
297
|
return props.provider || (volver == null ? void 0 : volver.iconsProvider);
|
|
308
298
|
});
|
|
309
299
|
const icon = computed(() => {
|
|
310
|
-
const
|
|
311
|
-
const iconName = `@${provider.value}:${props.prefix}:${
|
|
312
|
-
if (iconExists(
|
|
313
|
-
return _name;
|
|
314
|
-
} else if (iconExists(iconName)) {
|
|
300
|
+
const name = props.name ?? "";
|
|
301
|
+
const iconName = `@${provider.value}:${props.prefix}:${name}`;
|
|
302
|
+
if (iconExists(iconName)) {
|
|
315
303
|
return iconName;
|
|
316
|
-
} else {
|
|
317
|
-
return (volver == null ? void 0 : volver.iconsCollections.find(
|
|
318
|
-
(iconsCollection) => {
|
|
319
|
-
const icon2 = `@${provider.value}:${iconsCollection.prefix}:${_name}`;
|
|
320
|
-
if (iconExists(icon2)) {
|
|
321
|
-
return icon2;
|
|
322
|
-
}
|
|
323
|
-
}
|
|
324
|
-
)) || _name;
|
|
325
304
|
}
|
|
305
|
+
const iconsCollection = volver == null ? void 0 : volver.iconsCollections.find(
|
|
306
|
+
(iconsCollection2) => {
|
|
307
|
+
const icon2 = `@${provider.value}:${iconsCollection2.prefix}:${name}`;
|
|
308
|
+
return iconExists(icon2);
|
|
309
|
+
}
|
|
310
|
+
);
|
|
311
|
+
if (iconsCollection) {
|
|
312
|
+
return `@${provider.value}:${iconsCollection.prefix}:${name}`;
|
|
313
|
+
}
|
|
314
|
+
return name;
|
|
326
315
|
});
|
|
327
316
|
function getSvgContent(svg) {
|
|
328
|
-
let dom
|
|
317
|
+
let dom;
|
|
329
318
|
if (typeof window === "undefined") {
|
|
330
319
|
const { JSDOM } = require("jsdom");
|
|
331
320
|
dom = new JSDOM().window;
|
|
@@ -356,12 +345,13 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
356
345
|
show.value = true;
|
|
357
346
|
}
|
|
358
347
|
}).catch((e) => {
|
|
359
|
-
throw new Error(`
|
|
348
|
+
throw new Error(`Error during fetch icon: ${e == null ? void 0 : e.message}`);
|
|
360
349
|
});
|
|
361
|
-
} else if (props.svg) {
|
|
362
|
-
addIconFromSvg(props.svg);
|
|
363
350
|
}
|
|
364
351
|
}
|
|
352
|
+
if (props.svg) {
|
|
353
|
+
addIconFromSvg(props.svg);
|
|
354
|
+
}
|
|
365
355
|
return (_ctx, _cache) => {
|
|
366
356
|
return unref(show) ? (openBlock(), createBlock(unref(Icon), mergeProps({
|
|
367
357
|
key: 0,
|
|
@@ -373,7 +363,7 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
373
363
|
horizontalFlip: _ctx.horizontalFlip,
|
|
374
364
|
verticalFlip: _ctx.verticalFlip,
|
|
375
365
|
flip: _ctx.flip,
|
|
376
|
-
rotate:
|
|
366
|
+
rotate: unref(hasRotate),
|
|
377
367
|
color: _ctx.color,
|
|
378
368
|
onLoad: _ctx.onLoad,
|
|
379
369
|
icon: unref(icon)
|
|
@@ -892,7 +882,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
892
882
|
modifiers
|
|
893
883
|
} = toRefs(props);
|
|
894
884
|
const hasId = useUniqueId(id);
|
|
895
|
-
const
|
|
885
|
+
const hasHintId = computed(() => `${hasId.value}-hint`);
|
|
896
886
|
const hasPlaceholder = computed(
|
|
897
887
|
() => props.floating && isEmpty(props.placeholder) ? " " : props.placeholder
|
|
898
888
|
);
|
|
@@ -927,7 +917,12 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
927
917
|
}
|
|
928
918
|
return void 0;
|
|
929
919
|
});
|
|
930
|
-
const {
|
|
920
|
+
const {
|
|
921
|
+
HintSlot,
|
|
922
|
+
hasHintLabelOrSlot,
|
|
923
|
+
hasInvalidLabelOrSlot,
|
|
924
|
+
hintSlotScope
|
|
925
|
+
} = HintSlotFactory(props, slots);
|
|
931
926
|
const bemCssClasses = useModifiers(
|
|
932
927
|
"vv-textarea",
|
|
933
928
|
modifiers,
|
|
@@ -961,8 +956,8 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
961
956
|
wrap: props.wrap,
|
|
962
957
|
spellcheck: props.spellcheck,
|
|
963
958
|
"aria-invalid": isInvalid.value,
|
|
964
|
-
"aria-describedby":
|
|
965
|
-
"aria-errormessage":
|
|
959
|
+
"aria-describedby": hasHintLabelOrSlot.value ? hasHintId.value : void 0,
|
|
960
|
+
"aria-errormessage": hasInvalidLabelOrSlot.value ? hasHintId.value : void 0
|
|
966
961
|
})
|
|
967
962
|
);
|
|
968
963
|
const slotProps = computed(() => ({
|
|
@@ -1020,9 +1015,38 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
1020
1015
|
])) : createCommentVNode("", true)
|
|
1021
1016
|
]),
|
|
1022
1017
|
createVNode(unref(HintSlot), {
|
|
1023
|
-
id: unref(
|
|
1018
|
+
id: unref(hasHintId),
|
|
1024
1019
|
class: "vv-textarea__hint"
|
|
1025
|
-
},
|
|
1020
|
+
}, createSlots({ _: 2 }, [
|
|
1021
|
+
_ctx.$slots.hint ? {
|
|
1022
|
+
name: "hint",
|
|
1023
|
+
fn: withCtx(() => [
|
|
1024
|
+
renderSlot(_ctx.$slots, "hint", normalizeProps(guardReactiveProps(unref(hintSlotScope))))
|
|
1025
|
+
]),
|
|
1026
|
+
key: "0"
|
|
1027
|
+
} : void 0,
|
|
1028
|
+
_ctx.$slots.loading ? {
|
|
1029
|
+
name: "loading",
|
|
1030
|
+
fn: withCtx(() => [
|
|
1031
|
+
renderSlot(_ctx.$slots, "loading", normalizeProps(guardReactiveProps(unref(hintSlotScope))))
|
|
1032
|
+
]),
|
|
1033
|
+
key: "1"
|
|
1034
|
+
} : void 0,
|
|
1035
|
+
_ctx.$slots.valid ? {
|
|
1036
|
+
name: "valid",
|
|
1037
|
+
fn: withCtx(() => [
|
|
1038
|
+
renderSlot(_ctx.$slots, "valid", normalizeProps(guardReactiveProps(unref(hintSlotScope))))
|
|
1039
|
+
]),
|
|
1040
|
+
key: "2"
|
|
1041
|
+
} : void 0,
|
|
1042
|
+
_ctx.$slots.invalid ? {
|
|
1043
|
+
name: "invalid",
|
|
1044
|
+
fn: withCtx(() => [
|
|
1045
|
+
renderSlot(_ctx.$slots, "invalid", normalizeProps(guardReactiveProps(unref(hintSlotScope))))
|
|
1046
|
+
]),
|
|
1047
|
+
key: "3"
|
|
1048
|
+
} : void 0
|
|
1049
|
+
]), 1032, ["id"])
|
|
1026
1050
|
], 2);
|
|
1027
1051
|
};
|
|
1028
1052
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(e,l){"object"==typeof exports&&"undefined"!=typeof module?module.exports=l(require("vue"),require("@vueuse/core"),require("@iconify/vue"),require("nanoid")):"function"==typeof define&&define.amd?define(["vue","@vueuse/core","@iconify/vue","nanoid"],l):(e="undefined"!=typeof globalThis?globalThis:e||self).VvTextarea=l(e.vue,e.core,e.vue$1,e.nanoid)}(this,(function(e,l,o,t){"use strict";function n(e,l){if(e&&Object.keys(e).length&&l){if(-1===l.indexOf("."))return e[l];{const o=l.split(".");let t=e;for(let l=0,n=o.length;l<n;++l){if(null==e)return null;t=t[o[l]]}return t}}return null}function a(l){return null==(o=e.unref(l))||""===o||Array.isArray(o)&&0===o.length||!(o instanceof Date)&&"object"==typeof o&&0===Object.keys(o).length;var o}function i(e){return Array.isArray(e)?e.filter((e=>{return"string"==typeof(l=e)||l instanceof String;var l})).join(" "):e}const r={color:String,width:{type:[String,Number]},height:{type:[String,Number]},name:{type:String,required:!0},provider:{type:String},prefix:{type:String,default:"normal"},src:String,horizontalFlip:Boolean,verticalFlip:Boolean,flip:String,mode:String,inline:Boolean,rotate:[Number,String],onLoad:Function,svg:String,modifiers:{type:[String,Array]}};var u=(e=>(e.left="left",e.right="right",e.top="top",e.bottom="bottom",e))(u||{}),d=(e=>(e.before="before",e.after="after",e))(d||{}),v=(e=>(e.button="button",e.submit="submit",e.reset="reset",e))(v||{});const c=Symbol.for("volver");function s(l,o,t){return e.computed((()=>{const n={[l]:!0},a="string"==typeof(null==o?void 0:o.value)?o.value.split(" "):null==o?void 0:o.value;return a&&Array.isArray(a)&&a.forEach((e=>{e&&(n[`${l}--${e}`]=!0)})),t&&Object.keys(t.value).forEach((o=>{n[`${l}--${o}`]=e.unref(t.value[o])})),n}))}const m=e.defineComponent({name:"VvIcon",props:r,setup(l){const t=l,n=e.ref(!0),a=e.inject(c),{modifiers:i}=e.toRefs(t),r=s("vv-icon",i),u=e.computed((()=>t.provider||(null==a?void 0:a.iconsProvider))),d=e.computed((()=>{const e=t.name??"",l=`@${u.value}:${t.prefix}:${t.name}`;return o.iconExists(e)?e:o.iconExists(l)?l:(null==a?void 0:a.iconsCollections.find((l=>{const t=`@${u.value}:${l.prefix}:${e}`;if(o.iconExists(t))return t})))||e}));function v(e){const l=function(e){let l=null;if("undefined"==typeof window){const{JSDOM:e}=require("jsdom");l=(new e).window}return(l?new l.DOMParser:new window.DOMParser).parseFromString(e,"text/html").querySelector("svg")}(e),n=(null==l?void 0:l.innerHTML.trim())||"";l&&n&&o.addIcon(`@${u.value}:${t.prefix}:${t.name}`,{body:n,height:l.viewBox.baseVal.height,width:l.viewBox.baseVal.width})}return a&&(t.src&&!o.iconExists(`@${u.value}:${t.prefix}:${t.name}`)?(n.value=!1,a.fetchIcon(t.src).then((e=>{e&&(v(e),n.value=!0)})).catch((e=>{throw new Error(`During fetch icon: ${null==e?void 0:e.message}`)}))):t.svg&&v(t.svg)),(l,t)=>e.unref(n)?(e.openBlock(),e.createBlock(e.unref(o.Icon),e.mergeProps({key:0,class:e.unref(r)},{inline:l.inline,width:l.width,height:l.height,horizontalFlip:l.horizontalFlip,verticalFlip:l.verticalFlip,flip:l.flip,rotate:l.rotate,color:l.color,onLoad:l.onLoad,icon:e.unref(d)}),null,16,["class"])):e.createCommentVNode("",!0)}}),f={valid:Boolean,validLabel:[String,Array]},p={invalid:Boolean,invalidLabel:[String,Array]},g={loading:Boolean,loadingLabel:{type:String,default:"Loading..."}},h={disabled:Boolean},b=(Boolean,Boolean,{label:[String,Number]}),y={readonly:Boolean},B={modifiers:[String,Array]},S={hintLabel:{type:String,default:""}},x={count:{type:[Boolean,String],default:!1,validator:e=>[!0,!1,"limit","countdown"].includes(e)}},w={debounce:[Number,String]},L={icon:{type:[String,Object]},iconPosition:{type:String,default:d.before,validation:e=>Object.values(d).includes(e)}},k={tabindex:{type:[String,Number],default:0}},V={floating:Boolean},$={id:[String,Number]};u.bottom,Boolean,Boolean,Boolean,Boolean,Boolean,Boolean,Boolean,Boolean;const N={...{...$,name:{type:String,required:!0}},...{autofocus:Boolean},...{autocomplete:{type:String,default:"off"}},...k,...h,...y,...f,...p,...S,...g,...B,...x,...w,...L,...V,...b,minlength:[String,Number],maxlength:[String,Number],placeholder:String,required:Boolean};v.button;const _={...N,modelValue:String,cols:{type:[String,Number],default:20},rows:{type:[String,Number],default:2},wrap:{type:String,default:"soft"},spellcheck:{type:[Boolean,String],default:"default"},resizable:Boolean};const I=["for"],E={class:"vv-textarea__wrapper"},P={key:0,class:"vv-textarea__input-before"},A={class:"vv-textarea__inner"},C=["id"],j={key:1,class:"vv-textarea__input-after"},q={key:2,class:"vv-textarea__limit"};return e.defineComponent({name:"VvTextarea",props:_,emits:["update:modelValue","focus","blur","keyup"],setup(o,{emit:r}){const v=o,c=e.useSlots(),f=e.ref(),{id:p,icon:g,iconPosition:h,label:b,modelValue:y,count:B,valid:S,invalid:x,loading:w,modifiers:L}=e.toRefs(v),k=(l=>e.computed((()=>String((null==l?void 0:l.value)||t.nanoid()))))(p),V=e.computed((()=>`${k.value}-hint`)),$=e.computed((()=>v.floating&&a(v.placeholder)?" ":v.placeholder)),N=function(l,o,t=0,{getter:n=(e=>e),setter:a=(e=>e)}={}){let i;return"string"==typeof t&&(t=parseInt(t)),e.computed({get:()=>n(null==l?void 0:l.value),set:e=>{i&&clearTimeout(i),i=setTimeout((()=>{o("update:modelValue",a(e))}),t)}})}(y,r,v.debounce),{hasIcon:_,hasIconBefore:z,hasIconAfter:O}=function(l,o){const t=e.computed((()=>Boolean((null==l?void 0:l.value)&&o.value===d.before))),n=e.computed((()=>Boolean((null==l?void 0:l.value)&&o.value===d.after))),a=e.computed((()=>Boolean((null==l?void 0:l.value)&&o.value===u.left))),i=e.computed((()=>Boolean((null==l?void 0:l.value)&&o.value===u.right))),r=e.computed((()=>Boolean((null==l?void 0:l.value)&&o.value===u.top))),v=e.computed((()=>Boolean((null==l?void 0:l.value)&&o.value===u.bottom)));return{hasIcon:e.computed((()=>"string"==typeof(null==l?void 0:l.value)?{name:null==l?void 0:l.value}:null==l?void 0:l.value)),hasIconLeft:a,hasIconRight:i,hasIconTop:r,hasIconBottom:v,hasIconBefore:t,hasIconAfter:n}}(g,h),{focused:T}=function(o,t){const{focused:n}=l.useFocus(o);return e.watch(n,(l=>{t(l?"focus":"blur",e.unref(o))})),{focused:n}}(f,r),F=l.useElementVisibility(f);e.watch(F,(e=>{e&&v.autofocus&&(T.value=!0)}));const{formatted:R}=function(l,o){const t=e.computed((()=>(e.unref(l)??"").length)),n=e.computed((()=>void 0!==(null==o?void 0:o.lowerLimit)&&t.value<(null==o?void 0:o.lowerLimit)?t.value-o.lowerLimit:void 0!==(null==o?void 0:o.upperLimit)&&t.value<(null==o?void 0:o.upperLimit)?o.upperLimit-t.value:0)),a=e.computed((()=>{if(!1===(null==o?void 0:o.mode))return"";if("limit"===(null==o?void 0:o.mode)&&(null==o?void 0:o.upperLimit))return`${t.value} / ${o.lowerLimit?`${o.lowerLimit}-`:""}${o.upperLimit}`;if("countdown"===(null==o?void 0:o.mode)){if(0===n.value)return;return n}return t.value}));return{length:t,gap:n,formatted:a}}(N,{mode:v.count,upperLimit:Number(v.maxlength),lowerLimit:Number(v.minlength)}),D=e.computed((()=>!v.disabled&&!v.readonly)),H=e.computed((()=>D.value?v.tabindex:-1)),M=e.computed((()=>!a(y))),J=e.computed((()=>!0===v.invalid||!0!==v.valid&&void 0)),{HintSlot:K,hasHint:U,hasInvalid:G}=function(o,t){const{invalid:r,valid:u,hint:d,loading:v}=t,{hintLabel:c,modelValue:s,valid:m,validLabel:f,invalid:p,invalidLabel:g,...h}=e.toRefs(o),b=n(h,"loading"),y=n(h,"loadingLabel"),B=e.computed((()=>!(!p.value||(!p.value||!r)&&!((null==g?void 0:g.value)&&Array.isArray(g.value)&&g.value.length>0)&&(!(null==g?void 0:g.value)||a(g))))),S=e.computed((()=>!!(c&&c.value||d))),x=e.computed((()=>!!(f&&f.value||u))),w=e.computed((()=>!!((null==b?void 0:b.value)&&v||(null==b?void 0:b.value)&&(null==y?void 0:y.value)))),L=e.computed((()=>S.value||x.value||B.value||w.value));return{hasInvalid:B,hasHint:S,hasValid:x,hasLoading:w,HintSlot:{name:"HintSlot",props:{params:{type:Object,default:()=>({})}},setup(o){const t=e.computed((()=>{const e=l.toReactive({hintLabel:c,modelValue:s,valid:m,validLabel:f,invalid:p,invalidLabel:g,loading:b,loadingLabel:y,...o.params});return(null==p?void 0:p.value)?(null==r?void 0:r(e))||i(null==g?void 0:g.value)||(null==c?void 0:c.value):(null==m?void 0:m.value)?(null==u?void 0:u(e))||i(null==f?void 0:f.value)||(null==c?void 0:c.value):(null==b?void 0:b.value)?(null==v?void 0:v(e))||i(null==y?void 0:y.value)||(null==c?void 0:c.value):(null==d?void 0:d(e))||i(null==c?void 0:c.value)||(null==c?void 0:c.value)}));return{isVisible:L,hasInvalid:B,hasValid:x,hintContent:t}},render(){if(this.isVisible)return e.h("small",{role:this.hasInvalid?"alert":this.hasValid?"status":void 0},this.hintContent)}}}}(v,c),Q=s("vv-textarea",L,e.computed((()=>({valid:S.value,invalid:x.value,loading:w.value,disabled:v.disabled,readonly:v.readonly,"icon-before":z.value,"icon-after":O.value,floating:v.floating&&!a(v.label),dirty:M.value,focused:T.value,resizable:v.resizable})))),W=e.computed((()=>({name:v.name,placeholder:$.value,tabindex:H.value,disabled:v.disabled,readonly:v.readonly,required:v.required,autocomplete:v.autocomplete,minlength:v.minlength,maxlength:v.maxlength,cols:v.cols,rows:v.rows,wrap:v.wrap,spellcheck:v.spellcheck,"aria-invalid":J.value,"aria-describedby":!G.value&&U.value?V.value:void 0,"aria-errormessage":G.value?V.value:void 0}))),X=e.computed((()=>({valid:v.valid,invalid:v.invalid,modelValue:v.modelValue,hintLabel:v.hintLabel,maxlength:v.maxlength,minlength:v.minlength,clear:Y}))),Y=()=>{N.value=void 0};return(l,o)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(e.unref(Q))},[e.unref(b)?(e.openBlock(),e.createElementBlock("label",{key:0,for:e.unref(k),class:"vv-textarea__label"},e.toDisplayString(e.unref(b)),9,I)):e.createCommentVNode("",!0),e.createElementVNode("div",E,[l.$slots.before?(e.openBlock(),e.createElementBlock("div",P,[e.renderSlot(l.$slots,"before",e.normalizeProps(e.guardReactiveProps(e.unref(X))))])):e.createCommentVNode("",!0),e.createElementVNode("div",A,[e.unref(z)?(e.openBlock(),e.createBlock(m,e.mergeProps({key:0,class:"vv-textarea__icon"},e.unref(_)),null,16)):e.createCommentVNode("",!0),e.withDirectives(e.createElementVNode("textarea",e.mergeProps({id:e.unref(k),ref_key:"textarea",ref:f,"onUpdate:modelValue":o[0]||(o[0]=l=>e.isRef(N)?N.value=l:null)},e.unref(W),{onKeyup:o[1]||(o[1]=e=>r("keyup",e))}),null,16,C),[[e.vModelText,e.unref(N)]]),e.unref(O)?(e.openBlock(),e.createBlock(m,e.mergeProps({key:1,class:"vv-textarea__icon vv-textarea__icon-after"},e.unref(_)),null,16)):e.createCommentVNode("",!0)]),l.$slots.after?(e.openBlock(),e.createElementBlock("div",j,[e.renderSlot(l.$slots,"after",e.normalizeProps(e.guardReactiveProps(e.unref(X))))])):e.createCommentVNode("",!0),e.unref(B)?(e.openBlock(),e.createElementBlock("span",q,[e.renderSlot(l.$slots,"count",e.normalizeProps(e.guardReactiveProps(e.unref(X))),(()=>[e.createTextVNode(e.toDisplayString(e.unref(R)),1)]))])):e.createCommentVNode("",!0)]),e.createVNode(e.unref(K),{id:e.unref(V),class:"vv-textarea__hint"},null,8,["id"])],2))}})}));
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t(require("vue"),require("@iconify/vue"),require("nanoid"),require("@vueuse/core")):"function"==typeof define&&define.amd?define(["vue","@iconify/vue","nanoid","@vueuse/core"],t):(e="undefined"!=typeof globalThis?globalThis:e||self).VvTextarea=t(e.vue,e.vue$1,e.nanoid,e.core)}(this,(function(e,t,o,l){"use strict";function a(t){return null==(o=e.unref(t))||""===o||Array.isArray(o)&&0===o.length||!(o instanceof Date)&&"object"==typeof o&&0===Object.keys(o).length;var o}function n(e){return Array.isArray(e)?e.filter((e=>{return"string"==typeof(t=e)||t instanceof String;var t})).join(" "):e}const i={color:String,width:{type:[String,Number]},height:{type:[String,Number]},name:{type:String,required:!0},provider:{type:String},prefix:{type:String,default:"normal"},src:String,horizontalFlip:Boolean,verticalFlip:Boolean,flip:String,mode:String,inline:Boolean,rotate:[Number,String],onLoad:Function,svg:String,modifiers:{type:[String,Array]}};var r=(e=>(e.left="left",e.right="right",e.top="top",e.bottom="bottom",e))(r||{}),u=(e=>(e.before="before",e.after="after",e))(u||{}),d=(e=>(e.button="button",e.submit="submit",e.reset="reset",e))(d||{});const s=Symbol.for("volver");function c(t,o,l){return e.computed((()=>{const a={[t]:!0},n="string"==typeof(null==o?void 0:o.value)?o.value.split(" "):null==o?void 0:o.value;return n&&Array.isArray(n)&&n.forEach((e=>{e&&(a[`${t}--${e}`]=!0)})),l&&Object.keys(l.value).forEach((o=>{a[`${t}--${o}`]=e.unref(l.value[o])})),a}))}const v=e.defineComponent({name:"VvIcon",props:i,setup(o){const l=o,a=e.computed((()=>"string"==typeof l.rotate?parseFloat(l.rotate):l.rotate)),n=e.ref(!0),i=e.inject(s),{modifiers:r}=e.toRefs(l),u=c("vv-icon",r),d=e.computed((()=>l.provider||(null==i?void 0:i.iconsProvider))),v=e.computed((()=>{const e=l.name??"",o=`@${d.value}:${l.prefix}:${e}`;if(t.iconExists(o))return o;const a=null==i?void 0:i.iconsCollections.find((o=>{const l=`@${d.value}:${o.prefix}:${e}`;return t.iconExists(l)}));return a?`@${d.value}:${a.prefix}:${e}`:e}));function m(e){const o=function(e){let t;if("undefined"==typeof window){const{JSDOM:e}=require("jsdom");t=(new e).window}return(t?new t.DOMParser:new window.DOMParser).parseFromString(e,"text/html").querySelector("svg")}(e),a=(null==o?void 0:o.innerHTML.trim())||"";o&&a&&t.addIcon(`@${d.value}:${l.prefix}:${l.name}`,{body:a,height:o.viewBox.baseVal.height,width:o.viewBox.baseVal.width})}return i&&l.src&&!t.iconExists(`@${d.value}:${l.prefix}:${l.name}`)&&(n.value=!1,i.fetchIcon(l.src).then((e=>{e&&(m(e),n.value=!0)})).catch((e=>{throw new Error(`Error during fetch icon: ${null==e?void 0:e.message}`)}))),l.svg&&m(l.svg),(o,l)=>e.unref(n)?(e.openBlock(),e.createBlock(e.unref(t.Icon),e.mergeProps({key:0,class:e.unref(u)},{inline:o.inline,width:o.width,height:o.height,horizontalFlip:o.horizontalFlip,verticalFlip:o.verticalFlip,flip:o.flip,rotate:e.unref(a),color:o.color,onLoad:o.onLoad,icon:e.unref(v)}),null,16,["class"])):e.createCommentVNode("",!0)}}),m={valid:Boolean,validLabel:[String,Array]},p={invalid:Boolean,invalidLabel:[String,Array]},f={loading:Boolean,loadingLabel:{type:String,default:"Loading..."}},h={disabled:Boolean},g=(Boolean,Boolean,{label:[String,Number]}),b={readonly:Boolean},S={modifiers:[String,Array]},y={hintLabel:{type:String,default:""}},B={count:{type:[Boolean,String],default:!1,validator:e=>[!0,!1,"limit","countdown"].includes(e)}},L={debounce:[Number,String]},$={icon:{type:[String,Object]},iconPosition:{type:String,default:u.before,validation:e=>Object.values(u).includes(e)}},x={tabindex:{type:[String,Number],default:0}},w={floating:Boolean},k={id:[String,Number]};r.bottom,Boolean,Boolean,Boolean,Boolean,Boolean,Boolean,Boolean,Boolean;const V={...{...k,name:{type:String,required:!0}},...{autofocus:Boolean},...{autocomplete:{type:String,default:"off"}},...x,...h,...b,...m,...p,...y,...f,...S,...B,...L,...$,...w,...g,minlength:[String,Number],maxlength:[String,Number],placeholder:String,required:Boolean};d.button;const N={...V,modelValue:String,cols:{type:[String,Number],default:20},rows:{type:[String,Number],default:2},wrap:{type:String,default:"soft"},spellcheck:{type:[Boolean,String],default:"default"},resizable:Boolean};const P=["for"],O={class:"vv-textarea__wrapper"},_={key:0,class:"vv-textarea__input-before"},I={class:"vv-textarea__inner"},C=["id"],E={key:1,class:"vv-textarea__input-after"},z={key:2,class:"vv-textarea__limit"};return e.defineComponent({name:"VvTextarea",props:N,emits:["update:modelValue","focus","blur","keyup"],setup(t,{emit:i}){const d=t,s=e.useSlots(),m=e.ref(),{id:p,icon:f,iconPosition:h,label:g,modelValue:b,count:S,valid:y,invalid:B,loading:L,modifiers:$}=e.toRefs(d),x=(t=>e.computed((()=>String((null==t?void 0:t.value)||o.nanoid()))))(p),w=e.computed((()=>`${x.value}-hint`)),k=e.computed((()=>d.floating&&a(d.placeholder)?" ":d.placeholder)),V=function(t,o,l=0,{getter:a=(e=>e),setter:n=(e=>e)}={}){let i;return"string"==typeof l&&(l=parseInt(l)),e.computed({get:()=>a(null==t?void 0:t.value),set:e=>{i&&clearTimeout(i),i=setTimeout((()=>{o("update:modelValue",n(e))}),l)}})}(b,i,d.debounce),{hasIcon:N,hasIconBefore:A,hasIconAfter:q}=function(t,o){const l=e.computed((()=>Boolean((null==t?void 0:t.value)&&o.value===u.before))),a=e.computed((()=>Boolean((null==t?void 0:t.value)&&o.value===u.after))),n=e.computed((()=>Boolean((null==t?void 0:t.value)&&o.value===r.left))),i=e.computed((()=>Boolean((null==t?void 0:t.value)&&o.value===r.right))),d=e.computed((()=>Boolean((null==t?void 0:t.value)&&o.value===r.top))),s=e.computed((()=>Boolean((null==t?void 0:t.value)&&o.value===r.bottom)));return{hasIcon:e.computed((()=>"string"==typeof(null==t?void 0:t.value)?{name:null==t?void 0:t.value}:null==t?void 0:t.value)),hasIconLeft:n,hasIconRight:i,hasIconTop:d,hasIconBottom:s,hasIconBefore:l,hasIconAfter:a}}(f,h),{focused:R}=function(t,o){const{focused:a}=l.useFocus(t);return e.watch(a,(l=>{o(l?"focus":"blur",e.unref(t))})),{focused:a}}(m,i),F=l.useElementVisibility(m);e.watch(F,(e=>{e&&d.autofocus&&(R.value=!0)}));const{formatted:T}=function(t,o){const l=e.computed((()=>(e.unref(t)??"").length)),a=e.computed((()=>void 0!==(null==o?void 0:o.lowerLimit)&&l.value<(null==o?void 0:o.lowerLimit)?l.value-o.lowerLimit:void 0!==(null==o?void 0:o.upperLimit)&&l.value<(null==o?void 0:o.upperLimit)?o.upperLimit-l.value:0)),n=e.computed((()=>{if(!1===(null==o?void 0:o.mode))return"";if("limit"===(null==o?void 0:o.mode)&&(null==o?void 0:o.upperLimit))return`${l.value} / ${o.lowerLimit?`${o.lowerLimit}-`:""}${o.upperLimit}`;if("countdown"===(null==o?void 0:o.mode)){if(0===a.value)return;return a}return l.value}));return{length:l,gap:a,formatted:n}}(V,{mode:d.count,upperLimit:Number(d.maxlength),lowerLimit:Number(d.minlength)}),j=e.computed((()=>!d.disabled&&!d.readonly)),D=e.computed((()=>j.value?d.tabindex:-1)),H=e.computed((()=>!a(b))),M=e.computed((()=>!0===d.invalid||!0!==d.valid&&void 0)),{HintSlot:J,hasHintLabelOrSlot:K,hasInvalidLabelOrSlot:U,hintSlotScope:G}=function(t,o){const l=e.computed((()=>n(t.invalidLabel))),a=e.computed((()=>n(t.validLabel))),i=e.computed((()=>t.loadingLabel)),r=e.computed((()=>t.hintLabel)),u=e.computed((()=>Boolean(t.loading&&(o.loading||i.value)))),d=e.computed((()=>!u.value&&Boolean(t.invalid&&(o.invalid||l.value)))),s=e.computed((()=>!u.value&&!d.value&&Boolean(t.valid&&(o.valid||a.value)))),c=e.computed((()=>!u.value&&!d.value&&!s.value&&Boolean(o.hint||r.value))),v=e.computed((()=>d.value||s.value||u.value||c.value)),m=e.computed((()=>({modelValue:t.modelValue,valid:t.valid,invalid:t.invalid,loading:t.loading}))),p=e.defineComponent({name:"HintSlot",props:{tag:{type:String,default:"small"}},setup:()=>({isVisible:v,invalidLabel:l,validLabel:a,loadingLabel:i,hintLabel:r,hasInvalidLabelOrSlot:d,hasValidLabelOrSlot:s,hasLoadingLabelOrSlot:u,hasHintLabelOrSlot:c}),render(){var t,o,l,a,n,i,r,u;if(this.isVisible){let d;return this.hasInvalidLabelOrSlot&&(d="alert"),this.hasValidLabelOrSlot&&(d="status"),this.hasLoadingLabelOrSlot?e.h(this.tag,{role:d},(null==(o=(t=this.$slots).loading)?void 0:o.call(t))??this.loadingLabel):this.hasInvalidLabelOrSlot?e.h(this.tag,{role:d},(null==(a=(l=this.$slots).invalid)?void 0:a.call(l))??this.$slots.invalid??this.invalidLabel):this.hasValidLabelOrSlot?e.h(this.tag,{role:d},(null==(i=(n=this.$slots).valid)?void 0:i.call(n))??this.validLabel):e.h(this.tag,{role:d},(null==(u=(r=this.$slots).hint)?void 0:u.call(r))??this.$slots.hint??this.hintLabel)}return null}});return{hasInvalidLabelOrSlot:d,hasHintLabelOrSlot:c,hasValidLabelOrSlot:s,hasLoadingLabelOrSlot:u,hintSlotScope:m,HintSlot:p}}(d,s),Q=c("vv-textarea",$,e.computed((()=>({valid:y.value,invalid:B.value,loading:L.value,disabled:d.disabled,readonly:d.readonly,"icon-before":A.value,"icon-after":q.value,floating:d.floating&&!a(d.label),dirty:H.value,focused:R.value,resizable:d.resizable})))),W=e.computed((()=>({name:d.name,placeholder:k.value,tabindex:D.value,disabled:d.disabled,readonly:d.readonly,required:d.required,autocomplete:d.autocomplete,minlength:d.minlength,maxlength:d.maxlength,cols:d.cols,rows:d.rows,wrap:d.wrap,spellcheck:d.spellcheck,"aria-invalid":M.value,"aria-describedby":K.value?w.value:void 0,"aria-errormessage":U.value?w.value:void 0}))),X=e.computed((()=>({valid:d.valid,invalid:d.invalid,modelValue:d.modelValue,hintLabel:d.hintLabel,maxlength:d.maxlength,minlength:d.minlength,clear:Y}))),Y=()=>{V.value=void 0};return(t,o)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(e.unref(Q))},[e.unref(g)?(e.openBlock(),e.createElementBlock("label",{key:0,for:e.unref(x),class:"vv-textarea__label"},e.toDisplayString(e.unref(g)),9,P)):e.createCommentVNode("",!0),e.createElementVNode("div",O,[t.$slots.before?(e.openBlock(),e.createElementBlock("div",_,[e.renderSlot(t.$slots,"before",e.normalizeProps(e.guardReactiveProps(e.unref(X))))])):e.createCommentVNode("",!0),e.createElementVNode("div",I,[e.unref(A)?(e.openBlock(),e.createBlock(v,e.mergeProps({key:0,class:"vv-textarea__icon"},e.unref(N)),null,16)):e.createCommentVNode("",!0),e.withDirectives(e.createElementVNode("textarea",e.mergeProps({id:e.unref(x),ref_key:"textarea",ref:m,"onUpdate:modelValue":o[0]||(o[0]=t=>e.isRef(V)?V.value=t:null)},e.unref(W),{onKeyup:o[1]||(o[1]=e=>i("keyup",e))}),null,16,C),[[e.vModelText,e.unref(V)]]),e.unref(q)?(e.openBlock(),e.createBlock(v,e.mergeProps({key:1,class:"vv-textarea__icon vv-textarea__icon-after"},e.unref(N)),null,16)):e.createCommentVNode("",!0)]),t.$slots.after?(e.openBlock(),e.createElementBlock("div",E,[e.renderSlot(t.$slots,"after",e.normalizeProps(e.guardReactiveProps(e.unref(X))))])):e.createCommentVNode("",!0),e.unref(S)?(e.openBlock(),e.createElementBlock("span",z,[e.renderSlot(t.$slots,"count",e.normalizeProps(e.guardReactiveProps(e.unref(X))),(()=>[e.createTextVNode(e.toDisplayString(e.unref(T)),1)]))])):e.createCommentVNode("",!0)]),e.createVNode(e.unref(J),{id:e.unref(w),class:"vv-textarea__hint"},e.createSlots({_:2},[t.$slots.hint?{name:"hint",fn:e.withCtx((()=>[e.renderSlot(t.$slots,"hint",e.normalizeProps(e.guardReactiveProps(e.unref(G))))])),key:"0"}:void 0,t.$slots.loading?{name:"loading",fn:e.withCtx((()=>[e.renderSlot(t.$slots,"loading",e.normalizeProps(e.guardReactiveProps(e.unref(G))))])),key:"1"}:void 0,t.$slots.valid?{name:"valid",fn:e.withCtx((()=>[e.renderSlot(t.$slots,"valid",e.normalizeProps(e.guardReactiveProps(e.unref(G))))])),key:"2"}:void 0,t.$slots.invalid?{name:"invalid",fn:e.withCtx((()=>[e.renderSlot(t.$slots,"invalid",e.normalizeProps(e.guardReactiveProps(e.unref(G))))])),key:"3"}:void 0]),1032,["id"])],2))}})}));
|
|
@@ -186,6 +186,30 @@ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<{
|
|
|
186
186
|
minlength: string | number | undefined;
|
|
187
187
|
clear: () => void;
|
|
188
188
|
}) => any;
|
|
189
|
+
hint: (_: {
|
|
190
|
+
modelValue: any;
|
|
191
|
+
valid: boolean;
|
|
192
|
+
invalid: boolean;
|
|
193
|
+
loading: boolean;
|
|
194
|
+
}) => any;
|
|
195
|
+
loading: (_: {
|
|
196
|
+
modelValue: any;
|
|
197
|
+
valid: boolean;
|
|
198
|
+
invalid: boolean;
|
|
199
|
+
loading: boolean;
|
|
200
|
+
}) => any;
|
|
201
|
+
valid: (_: {
|
|
202
|
+
modelValue: any;
|
|
203
|
+
valid: boolean;
|
|
204
|
+
invalid: boolean;
|
|
205
|
+
loading: boolean;
|
|
206
|
+
}) => any;
|
|
207
|
+
invalid: (_: {
|
|
208
|
+
modelValue: any;
|
|
209
|
+
valid: boolean;
|
|
210
|
+
invalid: boolean;
|
|
211
|
+
loading: boolean;
|
|
212
|
+
}) => any;
|
|
189
213
|
}>;
|
|
190
214
|
export default _default;
|
|
191
215
|
type __VLS_WithTemplateSlots<T, S> = T & {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
|
|
1
|
+
import type { ExtractPropTypes, Slots } from 'vue';
|
|
2
|
+
export type HintSlotProps = Readonly<ExtractPropTypes<{
|
|
3
3
|
hintLabel: {
|
|
4
4
|
type: StringConstructor;
|
|
5
5
|
default: '';
|
|
@@ -10,22 +10,48 @@ interface HintSlotProps {
|
|
|
10
10
|
validLabel: (StringConstructor | ArrayConstructor)[];
|
|
11
11
|
invalid: BooleanConstructor;
|
|
12
12
|
invalidLabel: (StringConstructor | ArrayConstructor)[];
|
|
13
|
-
}
|
|
14
|
-
interface HintSlotPropsWithLoading extends HintSlotProps {
|
|
15
13
|
loading: BooleanConstructor;
|
|
16
14
|
loadingLabel: StringConstructor;
|
|
17
|
-
}
|
|
15
|
+
}>>;
|
|
18
16
|
/**
|
|
19
17
|
* Return a vue component (HintSlot) to render and manage hint, errors, valid, loading state and messages
|
|
20
|
-
* @param {
|
|
18
|
+
* @param {HintSlotProps} parentProps vue props
|
|
21
19
|
* @param {Slots} parentSlots vue slots
|
|
22
20
|
* @returns {Component} vue component
|
|
23
21
|
*/
|
|
24
|
-
export declare function HintSlotFactory(
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
22
|
+
export declare function HintSlotFactory(props: HintSlotProps, slots: Slots): {
|
|
23
|
+
hasInvalidLabelOrSlot: globalThis.ComputedRef<boolean>;
|
|
24
|
+
hasHintLabelOrSlot: globalThis.ComputedRef<boolean>;
|
|
25
|
+
hasValidLabelOrSlot: globalThis.ComputedRef<boolean>;
|
|
26
|
+
hasLoadingLabelOrSlot: globalThis.ComputedRef<boolean>;
|
|
27
|
+
hintSlotScope: globalThis.ComputedRef<{
|
|
28
|
+
modelValue: any;
|
|
29
|
+
valid: boolean;
|
|
30
|
+
invalid: boolean;
|
|
31
|
+
loading: boolean;
|
|
32
|
+
}>;
|
|
33
|
+
HintSlot: import("vue").DefineComponent<{
|
|
34
|
+
tag: {
|
|
35
|
+
type: StringConstructor;
|
|
36
|
+
default: string;
|
|
37
|
+
};
|
|
38
|
+
}, {
|
|
39
|
+
isVisible: globalThis.ComputedRef<boolean>;
|
|
40
|
+
invalidLabel: globalThis.ComputedRef<string | undefined>;
|
|
41
|
+
validLabel: globalThis.ComputedRef<string | undefined>;
|
|
42
|
+
loadingLabel: globalThis.ComputedRef<string | undefined>;
|
|
43
|
+
hintLabel: globalThis.ComputedRef<string>;
|
|
44
|
+
hasInvalidLabelOrSlot: globalThis.ComputedRef<boolean>;
|
|
45
|
+
hasValidLabelOrSlot: globalThis.ComputedRef<boolean>;
|
|
46
|
+
hasLoadingLabelOrSlot: globalThis.ComputedRef<boolean>;
|
|
47
|
+
hasHintLabelOrSlot: globalThis.ComputedRef<boolean>;
|
|
48
|
+
}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<ExtractPropTypes<{
|
|
49
|
+
tag: {
|
|
50
|
+
type: StringConstructor;
|
|
51
|
+
default: string;
|
|
52
|
+
};
|
|
53
|
+
}>>, {
|
|
54
|
+
tag: string;
|
|
55
|
+
}>;
|
|
30
56
|
};
|
|
31
57
|
export default HintSlotFactory;
|