@volverjs/ui-vue 0.0.1 → 0.0.2
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/README.md +17 -0
- package/dist/components/VvButton/VvButton.es.js +159 -147
- package/dist/components/VvButton/VvButton.umd.js +1 -1
- package/dist/components/VvButton/VvButton.vue.d.ts +0 -8
- package/dist/components/VvButton/index.d.ts +4 -4
- package/dist/components/VvButtonGroup/VvButtonGroup.es.js +36 -37
- package/dist/components/VvButtonGroup/VvButtonGroup.umd.js +1 -1
- package/dist/components/VvButtonGroup/VvButtonGroup.vue.d.ts +10 -10
- package/dist/components/VvButtonGroup/index.d.ts +5 -5
- package/dist/components/VvCombobox/VvCombobox.es.js +526 -345
- package/dist/components/VvCombobox/VvCombobox.umd.js +1 -1
- package/dist/components/VvCombobox/VvCombobox.vue.d.ts +22 -0
- package/dist/components/VvCombobox/index.d.ts +13 -1
- package/dist/components/VvDropdown/VvDropdown.es.js +118 -109
- package/dist/components/VvDropdown/VvDropdown.umd.js +1 -1
- package/dist/components/VvDropdown/VvDropdown.vue.d.ts +19 -0
- package/dist/components/VvDropdown/index.d.ts +12 -0
- package/dist/components/VvInputText/VvInputText.es.js +221 -213
- package/dist/components/VvInputText/VvInputText.umd.js +1 -1
- package/dist/components/VvInputText/VvInputText.vue.d.ts +13 -13
- package/dist/components/VvInputText/index.d.ts +5 -5
- package/dist/components/VvSelect/VvSelect.es.js +186 -167
- package/dist/components/VvSelect/VvSelect.umd.js +1 -1
- package/dist/components/VvSelect/VvSelect.vue.d.ts +23 -11
- package/dist/components/VvSelect/index.d.ts +10 -17
- package/dist/components/VvTextarea/VvTextarea.es.js +112 -104
- package/dist/components/VvTextarea/VvTextarea.umd.js +1 -1
- package/dist/components/VvTextarea/VvTextarea.vue.d.ts +12 -12
- package/dist/components/VvTextarea/index.d.ts +5 -5
- package/dist/components/index.es.js +1045 -975
- package/dist/components/index.umd.js +1 -1
- package/dist/composables/group/types/IButtonGroupState.d.ts +1 -1
- package/dist/composables/group/types/IGroupState.d.ts +1 -1
- package/dist/composables/group/useInjectedGroupState.d.ts +1 -1
- package/dist/icons.es.js +3 -3
- package/dist/icons.umd.js +1 -1
- package/dist/index.es.js +1065 -995
- package/dist/index.umd.js +1 -1
- package/dist/props/index.d.ts +35 -4
- package/dist/resolvers/unplugin.es.js +26 -24
- package/dist/resolvers/unplugin.umd.js +1 -1
- package/dist/stories/Button/Button.settings.d.ts +9 -11
- package/dist/stories/ButtonGroup/ButtonGroup.settings.d.ts +9 -0
- package/dist/stories/Combobox/Combobox.settings.d.ts +19 -0
- package/dist/stories/Dropdown/Dropdown.settings.d.ts +10 -0
- package/dist/stories/InputText/InputText.settings.d.ts +23 -23
- package/dist/stories/Select/Select.settings.d.ts +42 -23
- package/dist/stories/Textarea/Textarea.settings.d.ts +23 -23
- package/dist/stories/argTypes.d.ts +50 -1
- package/package.json +5 -4
- 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/VvButton/index.ts +28 -10
- package/src/components/VvButtonGroup/VvButtonGroup.vue +1 -1
- package/src/components/VvButtonGroup/index.ts +3 -6
- package/src/components/VvCombobox/VvCombobox.vue +45 -11
- package/src/components/VvCombobox/index.ts +6 -0
- package/src/components/VvDropdown/VvDropdown.vue +9 -6
- package/src/components/VvDropdown/index.ts +11 -1
- package/src/components/VvInputText/VvInputText.vue +10 -8
- package/src/components/VvSelect/VvSelect.vue +23 -1
- package/src/components/VvSelect/index.ts +8 -11
- package/src/components/VvTextarea/VvTextarea.vue +10 -8
- package/src/composables/group/types/IButtonGroupState.ts +1 -1
- package/src/composables/group/types/IGroupState.ts +1 -1
- package/src/composables/group/useInjectedGroupState.ts +3 -3
- package/src/composables/useTextCount.ts +1 -1
- package/src/props/index.ts +33 -15
- package/src/resolvers/unplugin.ts +22 -13
- package/src/stories/Button/Button.settings.ts +2 -7
- package/src/stories/ButtonGroup/ButtonGroup.settings.ts +6 -1
- package/src/stories/ButtonGroup/ButtonGroupSlots.stories.mdx +37 -0
- package/src/stories/ButtonGroup/ButtonGroupToggle.stories.mdx +12 -1
- package/src/stories/Combobox/Combobox.settings.ts +5 -0
- package/src/stories/Combobox/Combobox.stories.mdx +51 -0
- package/src/stories/Combobox/Combobox.test.ts +7 -0
- package/src/stories/Dropdown/Dropdown.settings.ts +10 -1
- package/src/stories/Dropdown/Dropdown.stories.mdx +17 -0
- package/src/stories/Select/Select.settings.ts +9 -23
- package/src/stories/Select/Select.stories.mdx +60 -0
- package/src/stories/argTypes.ts +46 -22
|
@@ -1,10 +1,5 @@
|
|
|
1
1
|
import type { Option } from '@/types/generic';
|
|
2
2
|
declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<{
|
|
3
|
-
autocomplete: {
|
|
4
|
-
type: StringConstructor;
|
|
5
|
-
default: string;
|
|
6
|
-
};
|
|
7
|
-
autofocus: BooleanConstructor;
|
|
8
3
|
multiple: BooleanConstructor;
|
|
9
4
|
required: BooleanConstructor;
|
|
10
5
|
size: (StringConstructor | NumberConstructor)[];
|
|
@@ -14,6 +9,11 @@ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<{
|
|
|
14
9
|
};
|
|
15
10
|
label: StringConstructor;
|
|
16
11
|
placeholder: StringConstructor;
|
|
12
|
+
unselectable: {
|
|
13
|
+
type: BooleanConstructor;
|
|
14
|
+
default: boolean;
|
|
15
|
+
};
|
|
16
|
+
floating: BooleanConstructor;
|
|
17
17
|
icon: {
|
|
18
18
|
type: (ObjectConstructor | StringConstructor)[];
|
|
19
19
|
};
|
|
@@ -51,17 +51,17 @@ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<{
|
|
|
51
51
|
type: (StringConstructor | NumberConstructor)[];
|
|
52
52
|
default: number;
|
|
53
53
|
};
|
|
54
|
+
autocomplete: {
|
|
55
|
+
type: StringConstructor;
|
|
56
|
+
default: string;
|
|
57
|
+
};
|
|
58
|
+
autofocus: BooleanConstructor;
|
|
54
59
|
id: (StringConstructor | NumberConstructor)[];
|
|
55
60
|
name: {
|
|
56
61
|
type: StringConstructor;
|
|
57
62
|
required: boolean;
|
|
58
63
|
};
|
|
59
64
|
}, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, string[], string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
|
|
60
|
-
autocomplete: {
|
|
61
|
-
type: StringConstructor;
|
|
62
|
-
default: string;
|
|
63
|
-
};
|
|
64
|
-
autofocus: BooleanConstructor;
|
|
65
65
|
multiple: BooleanConstructor;
|
|
66
66
|
required: BooleanConstructor;
|
|
67
67
|
size: (StringConstructor | NumberConstructor)[];
|
|
@@ -71,6 +71,11 @@ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<{
|
|
|
71
71
|
};
|
|
72
72
|
label: StringConstructor;
|
|
73
73
|
placeholder: StringConstructor;
|
|
74
|
+
unselectable: {
|
|
75
|
+
type: BooleanConstructor;
|
|
76
|
+
default: boolean;
|
|
77
|
+
};
|
|
78
|
+
floating: BooleanConstructor;
|
|
74
79
|
icon: {
|
|
75
80
|
type: (ObjectConstructor | StringConstructor)[];
|
|
76
81
|
};
|
|
@@ -108,6 +113,11 @@ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<{
|
|
|
108
113
|
type: (StringConstructor | NumberConstructor)[];
|
|
109
114
|
default: number;
|
|
110
115
|
};
|
|
116
|
+
autocomplete: {
|
|
117
|
+
type: StringConstructor;
|
|
118
|
+
default: string;
|
|
119
|
+
};
|
|
120
|
+
autofocus: BooleanConstructor;
|
|
111
121
|
id: (StringConstructor | NumberConstructor)[];
|
|
112
122
|
name: {
|
|
113
123
|
type: StringConstructor;
|
|
@@ -120,6 +130,7 @@ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<{
|
|
|
120
130
|
disabled: boolean;
|
|
121
131
|
required: boolean;
|
|
122
132
|
multiple: boolean;
|
|
133
|
+
unselectable: boolean;
|
|
123
134
|
iconPosition: import("../../props/index.js").IconPosition;
|
|
124
135
|
loading: boolean;
|
|
125
136
|
readonly: boolean;
|
|
@@ -130,8 +141,9 @@ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<{
|
|
|
130
141
|
options: (string | Option)[];
|
|
131
142
|
labelKey: string | Function;
|
|
132
143
|
valueKey: string | Function;
|
|
133
|
-
|
|
144
|
+
floating: boolean;
|
|
134
145
|
autocomplete: string;
|
|
146
|
+
autofocus: boolean;
|
|
135
147
|
}>, {
|
|
136
148
|
before: (_: {}) => any;
|
|
137
149
|
after: (_: {}) => any;
|
|
@@ -1,18 +1,4 @@
|
|
|
1
1
|
export declare const VvSelectProps: {
|
|
2
|
-
/**
|
|
3
|
-
* Global attribute autocomplete
|
|
4
|
-
* @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/select#attr-autocomplete
|
|
5
|
-
* @see https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/autocomplete
|
|
6
|
-
*/
|
|
7
|
-
autocomplete: {
|
|
8
|
-
type: StringConstructor;
|
|
9
|
-
default: string;
|
|
10
|
-
};
|
|
11
|
-
/**
|
|
12
|
-
* Global attribute autofocus
|
|
13
|
-
* @see https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/autofocus
|
|
14
|
-
*/
|
|
15
|
-
autofocus: BooleanConstructor;
|
|
16
2
|
/**
|
|
17
3
|
* This Boolean attribute indicates that multiple options can be selected in the list.
|
|
18
4
|
* If it is not specified, then only one option can be selected at a time.
|
|
@@ -47,14 +33,16 @@ export declare const VvSelectProps: {
|
|
|
47
33
|
* Select placeholder
|
|
48
34
|
*/
|
|
49
35
|
placeholder: StringConstructor;
|
|
36
|
+
unselectable: {
|
|
37
|
+
type: BooleanConstructor;
|
|
38
|
+
default: boolean;
|
|
39
|
+
};
|
|
40
|
+
floating: BooleanConstructor;
|
|
50
41
|
icon: {
|
|
51
42
|
type: (ObjectConstructor | StringConstructor)[];
|
|
52
43
|
};
|
|
53
44
|
iconPosition: {
|
|
54
45
|
type: import("vue").PropType<import("@/props").IconPosition>;
|
|
55
|
-
/**
|
|
56
|
-
* modelValue can be a string, number, boolean, object or array of string, number, boolean, object
|
|
57
|
-
*/
|
|
58
46
|
validation: (value: import("@/props").IconPosition) => boolean;
|
|
59
47
|
default: "right";
|
|
60
48
|
};
|
|
@@ -87,6 +75,11 @@ export declare const VvSelectProps: {
|
|
|
87
75
|
type: (StringConstructor | NumberConstructor)[];
|
|
88
76
|
default: number;
|
|
89
77
|
};
|
|
78
|
+
autocomplete: {
|
|
79
|
+
type: StringConstructor;
|
|
80
|
+
default: string;
|
|
81
|
+
};
|
|
82
|
+
autofocus: BooleanConstructor;
|
|
90
83
|
id: (StringConstructor | NumberConstructor)[];
|
|
91
84
|
name: {
|
|
92
85
|
type: StringConstructor;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { unref as s, toRefs as j, computed as i, h as
|
|
1
|
+
import { unref as s, toRefs as j, computed as i, h as ie, watch as J, defineComponent as U, ref as W, inject as ue, openBlock as w, createBlock as R, mergeProps as k, createCommentVNode as C, useSlots as se, createElementBlock as D, normalizeClass as ce, toDisplayString as z, createElementVNode as M, renderSlot as O, normalizeProps as _, guardReactiveProps as E, withDirectives as de, isRef as fe, vModelText as ve, createTextVNode as me, createVNode as ge } from "vue";
|
|
2
2
|
import { nanoid as he } from "nanoid";
|
|
3
|
-
import { toReactive as pe, useFocus as ye } from "@vueuse/core";
|
|
4
|
-
import { iconExists as B, Icon as
|
|
3
|
+
import { toReactive as pe, useFocus as ye, useElementVisibility as be } from "@vueuse/core";
|
|
4
|
+
import { iconExists as B, Icon as Se, addIcon as we } from "@iconify/vue";
|
|
5
5
|
function q(r, t) {
|
|
6
6
|
if (r && Object.keys(r).length && t) {
|
|
7
7
|
if (t.indexOf(".") === -1)
|
|
@@ -19,10 +19,10 @@ function q(r, t) {
|
|
|
19
19
|
} else
|
|
20
20
|
return null;
|
|
21
21
|
}
|
|
22
|
-
function
|
|
22
|
+
function N(r) {
|
|
23
23
|
return ((t) => t == null || t === "" || Array.isArray(t) && t.length === 0 || !(t instanceof Date) && typeof t == "object" && Object.keys(t).length === 0)(s(r));
|
|
24
24
|
}
|
|
25
|
-
function
|
|
25
|
+
function Ie(r) {
|
|
26
26
|
return typeof r == "string" || r instanceof String;
|
|
27
27
|
}
|
|
28
28
|
function Z(r) {
|
|
@@ -32,10 +32,10 @@ function Z(r) {
|
|
|
32
32
|
/[A-Z]{2,}(?=[A-Z][a-z]+[0-9]*|\b)|[A-Z]?[a-z]+[0-9]*|[A-Z]|[0-9]+/g
|
|
33
33
|
)) == null ? void 0 : t.join("-")) == null ? void 0 : e.toLowerCase();
|
|
34
34
|
}
|
|
35
|
-
function
|
|
36
|
-
return Array.isArray(r) ? r.filter((t) =>
|
|
35
|
+
function A(r) {
|
|
36
|
+
return Array.isArray(r) ? r.filter((t) => Ie(t)).join(" ") : r;
|
|
37
37
|
}
|
|
38
|
-
function
|
|
38
|
+
function Pe(r, t) {
|
|
39
39
|
const {
|
|
40
40
|
invalid: e,
|
|
41
41
|
valid: u,
|
|
@@ -49,13 +49,13 @@ function Ie(r, t) {
|
|
|
49
49
|
invalid: n,
|
|
50
50
|
invalidLabel: o,
|
|
51
51
|
...g
|
|
52
|
-
} = j(r), c = q(g, "loading"), v = q(g, "loadingLabel"), y = i(() => n.value ? !!(n.value && e || o != null && o.value && Array.isArray(o.value) && o.value.length > 0 || o != null && o.value && !
|
|
52
|
+
} = j(r), c = q(g, "loading"), v = q(g, "loadingLabel"), y = i(() => n.value ? !!(n.value && e || o != null && o.value && Array.isArray(o.value) && o.value.length > 0 || o != null && o.value && !N(o)) : !1), p = i(
|
|
53
53
|
() => !!(a && a.value || l)
|
|
54
54
|
), b = i(
|
|
55
55
|
() => !!(f && f.value || u)
|
|
56
56
|
), I = i(
|
|
57
57
|
() => !!(c != null && c.value && d || c != null && c.value && (v != null && v.value))
|
|
58
|
-
),
|
|
58
|
+
), $ = i(
|
|
59
59
|
() => p.value || b.value || y.value || I.value
|
|
60
60
|
);
|
|
61
61
|
return {
|
|
@@ -71,8 +71,8 @@ function Ie(r, t) {
|
|
|
71
71
|
default: () => ({})
|
|
72
72
|
}
|
|
73
73
|
},
|
|
74
|
-
setup(
|
|
75
|
-
const
|
|
74
|
+
setup(x) {
|
|
75
|
+
const F = i(() => {
|
|
76
76
|
const S = pe({
|
|
77
77
|
hintLabel: a,
|
|
78
78
|
modelValue: h,
|
|
@@ -82,20 +82,20 @@ function Ie(r, t) {
|
|
|
82
82
|
invalidLabel: o,
|
|
83
83
|
loading: c,
|
|
84
84
|
loadingLabel: v,
|
|
85
|
-
|
|
85
|
+
...x.params
|
|
86
86
|
});
|
|
87
|
-
return n != null && n.value ? (e == null ? void 0 : e(S)) ||
|
|
87
|
+
return n != null && n.value ? (e == null ? void 0 : e(S)) || A(o == null ? void 0 : o.value) || (a == null ? void 0 : a.value) : m != null && m.value ? (u == null ? void 0 : u(S)) || A(f == null ? void 0 : f.value) || (a == null ? void 0 : a.value) : c != null && c.value ? (d == null ? void 0 : d(S)) || A(v == null ? void 0 : v.value) || (a == null ? void 0 : a.value) : (l == null ? void 0 : l(S)) || A(a == null ? void 0 : a.value) || (a == null ? void 0 : a.value);
|
|
88
88
|
});
|
|
89
89
|
return {
|
|
90
|
-
isVisible:
|
|
90
|
+
isVisible: $,
|
|
91
91
|
hasInvalid: y,
|
|
92
92
|
hasValid: b,
|
|
93
|
-
hintContent:
|
|
93
|
+
hintContent: F
|
|
94
94
|
};
|
|
95
95
|
},
|
|
96
96
|
render() {
|
|
97
97
|
if (this.isVisible)
|
|
98
|
-
return
|
|
98
|
+
return ie(
|
|
99
99
|
"small",
|
|
100
100
|
{
|
|
101
101
|
role: this.hasInvalid || this.hasValid ? "alert" : void 0
|
|
@@ -106,7 +106,7 @@ function Ie(r, t) {
|
|
|
106
106
|
}
|
|
107
107
|
};
|
|
108
108
|
}
|
|
109
|
-
function
|
|
109
|
+
function Ce(r, t, e) {
|
|
110
110
|
const u = i(
|
|
111
111
|
() => !!(r != null && r.value && t.value === "left" || e != null && e.iconLeft)
|
|
112
112
|
), l = i(
|
|
@@ -124,15 +124,15 @@ function Pe(r, t, e) {
|
|
|
124
124
|
hasIconBottom: a
|
|
125
125
|
};
|
|
126
126
|
}
|
|
127
|
-
function
|
|
127
|
+
function $e(r, t) {
|
|
128
128
|
const { focused: e } = ye(r);
|
|
129
|
-
return
|
|
129
|
+
return J(e, (u) => {
|
|
130
130
|
t(u ? "focus" : "blur", s(r));
|
|
131
131
|
}), {
|
|
132
132
|
focused: e
|
|
133
133
|
};
|
|
134
134
|
}
|
|
135
|
-
function
|
|
135
|
+
function xe(r, t, e = 0) {
|
|
136
136
|
let u;
|
|
137
137
|
return typeof e == "string" && (e = parseInt(e)), i({
|
|
138
138
|
get: () => r == null ? void 0 : r.value,
|
|
@@ -143,15 +143,15 @@ function $e(r, t, e = 0) {
|
|
|
143
143
|
}
|
|
144
144
|
});
|
|
145
145
|
}
|
|
146
|
-
function
|
|
147
|
-
const e = i(() => (s(r) ?? "").length), u = i(() => (t == null ? void 0 : t.lowerLimit) !== void 0 && e.value < (t == null ? void 0 : t.lowerLimit) ? e.value - t.lowerLimit : (t == null ? void 0 : t.upperLimit) !== void 0 && e.value < (t == null ? void 0 : t.upperLimit) ? t.upperLimit - e.value : 0), l = i(() => (t == null ? void 0 : t.mode) === !1 ? "" : (t == null ? void 0 : t.mode) === "limit" ? `${e.value} / ${t.lowerLimit ? `${t.lowerLimit}-` : ""}${t.upperLimit}` : (t == null ? void 0 : t.mode) === "countdown" ? u.value === 0 ? void 0 : u : e.value);
|
|
146
|
+
function Ve(r, t) {
|
|
147
|
+
const e = i(() => (s(r) ?? "").length), u = i(() => (t == null ? void 0 : t.lowerLimit) !== void 0 && e.value < (t == null ? void 0 : t.lowerLimit) ? e.value - t.lowerLimit : (t == null ? void 0 : t.upperLimit) !== void 0 && e.value < (t == null ? void 0 : t.upperLimit) ? t.upperLimit - e.value : 0), l = i(() => (t == null ? void 0 : t.mode) === !1 ? "" : (t == null ? void 0 : t.mode) === "limit" && (t != null && t.upperLimit) ? `${e.value} / ${t.lowerLimit ? `${t.lowerLimit}-` : ""}${t.upperLimit}` : (t == null ? void 0 : t.mode) === "countdown" ? u.value === 0 ? void 0 : u : e.value);
|
|
148
148
|
return {
|
|
149
149
|
length: e,
|
|
150
150
|
gap: u,
|
|
151
151
|
formatted: l
|
|
152
152
|
};
|
|
153
153
|
}
|
|
154
|
-
function
|
|
154
|
+
function X(r, t) {
|
|
155
155
|
const e = { [`${r}`]: !0 };
|
|
156
156
|
return {
|
|
157
157
|
bemCssClasses: i(() => Object.keys(t).reduce((l, d) => {
|
|
@@ -209,13 +209,13 @@ const _e = "ds", Be = {
|
|
|
209
209
|
modifiers: {
|
|
210
210
|
type: [String, Array]
|
|
211
211
|
}
|
|
212
|
-
},
|
|
212
|
+
}, Ae = {
|
|
213
213
|
name: "VvIcon"
|
|
214
|
-
}, G = /* @__PURE__ */
|
|
215
|
-
...
|
|
214
|
+
}, G = /* @__PURE__ */ U({
|
|
215
|
+
...Ae,
|
|
216
216
|
props: Be,
|
|
217
217
|
setup(r) {
|
|
218
|
-
const t = r, e =
|
|
218
|
+
const t = r, e = W(!0), { modifiers: u } = j(t), l = ue(_e), { bemCssClasses: d } = X("vv-icon", {
|
|
219
219
|
modifiers: u
|
|
220
220
|
}), a = i(() => t.provider || (l == null ? void 0 : l.provider)), h = i(() => {
|
|
221
221
|
const n = t.name ?? "", o = `@${a.value}:${t.prefix}:${t.name}`;
|
|
@@ -235,7 +235,7 @@ const _e = "ds", Be = {
|
|
|
235
235
|
}
|
|
236
236
|
function f(n) {
|
|
237
237
|
const o = m(n), g = (o == null ? void 0 : o.innerHTML.trim()) || "";
|
|
238
|
-
o && g &&
|
|
238
|
+
o && g && we(`@${a.value}:${t.prefix}:${t.name}`, {
|
|
239
239
|
body: g,
|
|
240
240
|
height: o.viewBox.baseVal.height,
|
|
241
241
|
width: o.viewBox.baseVal.width
|
|
@@ -245,7 +245,7 @@ const _e = "ds", Be = {
|
|
|
245
245
|
n && (f(n), e.value = !0);
|
|
246
246
|
}).catch((n) => {
|
|
247
247
|
throw new Error(`During fetch icon: ${n == null ? void 0 : n.message}`);
|
|
248
|
-
})) : t.svg && f(t.svg)), (n, o) => e.value ? (w(),
|
|
248
|
+
})) : t.svg && f(t.svg)), (n, o) => e.value ? (w(), R(s(Se), k({
|
|
249
249
|
key: 0,
|
|
250
250
|
class: s(d)
|
|
251
251
|
}, {
|
|
@@ -259,26 +259,26 @@ const _e = "ds", Be = {
|
|
|
259
259
|
color: n.color,
|
|
260
260
|
onLoad: n.onLoad,
|
|
261
261
|
icon: s(h)
|
|
262
|
-
}), null, 16, ["class"])) :
|
|
262
|
+
}), null, 16, ["class"])) : C("", !0);
|
|
263
263
|
}
|
|
264
264
|
}), ke = {
|
|
265
265
|
valid: Boolean,
|
|
266
266
|
validLabel: [String, Array]
|
|
267
|
-
},
|
|
267
|
+
}, Ne = {
|
|
268
268
|
invalid: Boolean,
|
|
269
269
|
invalidLabel: [String, Array]
|
|
270
|
-
},
|
|
270
|
+
}, Fe = {
|
|
271
271
|
loading: Boolean,
|
|
272
272
|
loadingLabel: String
|
|
273
|
-
},
|
|
273
|
+
}, Le = {
|
|
274
274
|
disabled: Boolean
|
|
275
|
-
},
|
|
275
|
+
}, Te = {
|
|
276
276
|
readonly: Boolean
|
|
277
|
-
}, Le = {
|
|
278
|
-
modifiers: [String, Array]
|
|
279
277
|
}, De = {
|
|
280
|
-
|
|
278
|
+
modifiers: [String, Array]
|
|
281
279
|
}, Oe = {
|
|
280
|
+
hintLabel: { type: String, default: "" }
|
|
281
|
+
}, Ee = {
|
|
282
282
|
count: {
|
|
283
283
|
type: [Boolean, String],
|
|
284
284
|
default: !1,
|
|
@@ -289,65 +289,71 @@ const _e = "ds", Be = {
|
|
|
289
289
|
}, K = {
|
|
290
290
|
LEFT: "left",
|
|
291
291
|
RIGHT: "right"
|
|
292
|
-
},
|
|
292
|
+
}, je = {
|
|
293
293
|
icon: { type: [String, Object] },
|
|
294
294
|
iconPosition: {
|
|
295
295
|
type: String,
|
|
296
296
|
validation: (r) => Object.values(K).includes(r),
|
|
297
297
|
default: K.RIGHT
|
|
298
298
|
}
|
|
299
|
-
}, je = {
|
|
300
|
-
tabindex: { type: [String, Number], default: 0 }
|
|
301
299
|
}, He = {
|
|
300
|
+
tabindex: { type: [String, Number], default: 0 }
|
|
301
|
+
}, ze = {
|
|
302
|
+
floating: Boolean
|
|
303
|
+
}, Me = {
|
|
302
304
|
id: [String, Number],
|
|
303
305
|
name: { type: String, required: !0 }
|
|
304
|
-
},
|
|
306
|
+
}, qe = {
|
|
307
|
+
autofocus: Boolean
|
|
308
|
+
}, Ze = {
|
|
309
|
+
autocomplete: { type: String, default: "off" }
|
|
310
|
+
}, Ge = {
|
|
311
|
+
...Me,
|
|
312
|
+
...qe,
|
|
313
|
+
...Ze,
|
|
305
314
|
...He,
|
|
306
|
-
...
|
|
315
|
+
...Le,
|
|
307
316
|
...Te,
|
|
308
|
-
...Fe,
|
|
309
317
|
...ke,
|
|
310
|
-
...Ae,
|
|
311
|
-
...De,
|
|
312
318
|
...Ne,
|
|
313
|
-
...Le,
|
|
314
319
|
...Oe,
|
|
315
|
-
...
|
|
320
|
+
...Fe,
|
|
321
|
+
...De,
|
|
316
322
|
...Ee,
|
|
317
|
-
|
|
318
|
-
|
|
323
|
+
...Re,
|
|
324
|
+
...je,
|
|
325
|
+
...ze,
|
|
319
326
|
minlength: Number,
|
|
320
327
|
maxlength: Number,
|
|
321
328
|
placeholder: String,
|
|
322
329
|
required: Boolean,
|
|
323
|
-
label: String
|
|
324
|
-
|
|
325
|
-
}, Me = {
|
|
330
|
+
label: String
|
|
331
|
+
}, Ke = {
|
|
326
332
|
hard: "hard",
|
|
327
333
|
soft: "soft"
|
|
328
|
-
},
|
|
334
|
+
}, Je = {
|
|
329
335
|
true: !0,
|
|
330
336
|
false: !1,
|
|
331
337
|
default: "default"
|
|
332
|
-
},
|
|
333
|
-
...
|
|
338
|
+
}, Ue = ["update:modelValue", "focus", "blur", "keyup"], We = {
|
|
339
|
+
...Ge,
|
|
334
340
|
modelValue: String,
|
|
335
341
|
cols: { type: [String, Number], default: 20 },
|
|
336
342
|
rows: { type: [String, Number], default: 2 },
|
|
337
|
-
wrap: { type: String, default:
|
|
338
|
-
spellcheck: { type: [Boolean, String], default:
|
|
343
|
+
wrap: { type: String, default: Ke.soft },
|
|
344
|
+
spellcheck: { type: [Boolean, String], default: Je.default },
|
|
339
345
|
resizable: Boolean
|
|
340
|
-
},
|
|
346
|
+
}, Xe = ["for"], Qe = { class: "vv-textarea__wrapper" }, Ye = ["id"], et = {
|
|
341
347
|
key: 0,
|
|
342
348
|
class: "vv-textarea__limit"
|
|
343
|
-
},
|
|
349
|
+
}, tt = {
|
|
344
350
|
name: "VvTextarea"
|
|
345
|
-
},
|
|
346
|
-
...
|
|
347
|
-
props:
|
|
348
|
-
emits:
|
|
351
|
+
}, ot = /* @__PURE__ */ U({
|
|
352
|
+
...tt,
|
|
353
|
+
props: We,
|
|
354
|
+
emits: Ue,
|
|
349
355
|
setup(r, { emit: t }) {
|
|
350
|
-
const e = r, u =
|
|
356
|
+
const e = r, u = se(), l = W(), {
|
|
351
357
|
icon: d,
|
|
352
358
|
iconPosition: a,
|
|
353
359
|
label: h,
|
|
@@ -357,22 +363,26 @@ const _e = "ds", Be = {
|
|
|
357
363
|
invalid: o,
|
|
358
364
|
loading: g
|
|
359
365
|
} = j(e), c = i(() => String(e.id || he())), v = i(() => `${c.value}-hint`), y = i(
|
|
360
|
-
() => e.floating &&
|
|
361
|
-
), p =
|
|
366
|
+
() => e.floating && N(e.placeholder) ? " " : e.placeholder
|
|
367
|
+
), p = xe(m, t, e.debounce), { hasIcon: b, hasIconLeft: I, hasIconRight: $ } = Ce(
|
|
362
368
|
d,
|
|
363
369
|
a
|
|
364
|
-
), { focused:
|
|
370
|
+
), { focused: x } = $e(l, t), F = be(l);
|
|
371
|
+
J(F, (P) => {
|
|
372
|
+
P && e.autofocus && (x.value = !0);
|
|
373
|
+
});
|
|
374
|
+
const { formatted: S } = Ve(p, {
|
|
365
375
|
mode: e.count,
|
|
366
376
|
upperLimit: e.maxlength,
|
|
367
377
|
lowerLimit: e.minlength
|
|
368
|
-
}),
|
|
369
|
-
() =>
|
|
370
|
-
),
|
|
378
|
+
}), Q = i(() => !e.disabled && !e.readonly), Y = i(
|
|
379
|
+
() => Q.value ? e.tabindex : -1
|
|
380
|
+
), ee = i(() => !N(m)), te = i(() => {
|
|
371
381
|
if (e.invalid === !0)
|
|
372
382
|
return !0;
|
|
373
383
|
if (e.valid === !0)
|
|
374
384
|
return !1;
|
|
375
|
-
}), { HintSlot:
|
|
385
|
+
}), { HintSlot: re, hasHint: ne, hasInvalid: H } = Pe(e, u), { bemCssClasses: ae } = X("vv-textarea", {
|
|
376
386
|
modifiers: e.modifiers,
|
|
377
387
|
valid: n,
|
|
378
388
|
invalid: o,
|
|
@@ -380,16 +390,16 @@ const _e = "ds", Be = {
|
|
|
380
390
|
disabled: e.disabled,
|
|
381
391
|
readonly: e.readonly,
|
|
382
392
|
iconLeft: I,
|
|
383
|
-
iconRight:
|
|
384
|
-
floating: e.floating && !
|
|
385
|
-
dirty:
|
|
386
|
-
focused:
|
|
393
|
+
iconRight: $,
|
|
394
|
+
floating: e.floating && !N(e.label),
|
|
395
|
+
dirty: ee,
|
|
396
|
+
focused: x,
|
|
387
397
|
resizable: e.resizable
|
|
388
|
-
}),
|
|
398
|
+
}), le = i(
|
|
389
399
|
() => ({
|
|
390
400
|
name: e.name,
|
|
391
401
|
placeholder: y.value,
|
|
392
|
-
tabindex:
|
|
402
|
+
tabindex: Y.value,
|
|
393
403
|
disabled: e.disabled,
|
|
394
404
|
readonly: e.readonly,
|
|
395
405
|
required: e.required,
|
|
@@ -400,58 +410,56 @@ const _e = "ds", Be = {
|
|
|
400
410
|
rows: e.rows,
|
|
401
411
|
wrap: e.wrap,
|
|
402
412
|
spellcheck: e.spellcheck,
|
|
403
|
-
"aria-invalid":
|
|
404
|
-
"aria-describedby": !H.value &&
|
|
413
|
+
"aria-invalid": te.value,
|
|
414
|
+
"aria-describedby": !H.value && ne.value ? v.value : void 0,
|
|
405
415
|
"aria-errormessage": H.value ? v.value : void 0
|
|
406
416
|
})
|
|
407
|
-
),
|
|
417
|
+
), L = i(() => ({
|
|
408
418
|
valid: e.valid,
|
|
409
419
|
invalid: e.invalid,
|
|
410
420
|
modelValue: e.modelValue,
|
|
411
421
|
hintLabel: e.hintLabel,
|
|
412
422
|
maxlength: e.maxlength,
|
|
413
423
|
minlength: e.minlength,
|
|
414
|
-
clear:
|
|
415
|
-
})),
|
|
424
|
+
clear: oe
|
|
425
|
+
})), oe = () => {
|
|
416
426
|
p.value = void 0;
|
|
417
427
|
};
|
|
418
|
-
return
|
|
419
|
-
|
|
420
|
-
}), (F, x) => (w(), D("div", {
|
|
421
|
-
class: ce(s(re))
|
|
428
|
+
return (P, V) => (w(), D("div", {
|
|
429
|
+
class: ce(s(ae))
|
|
422
430
|
}, [
|
|
423
431
|
s(h) ? (w(), D("label", {
|
|
424
432
|
key: 0,
|
|
425
433
|
for: s(c),
|
|
426
434
|
class: "vv-textarea__label"
|
|
427
|
-
}, z(s(h)), 9,
|
|
428
|
-
M("div",
|
|
429
|
-
O(
|
|
430
|
-
s(I) ? (w(),
|
|
435
|
+
}, z(s(h)), 9, Xe)) : C("", !0),
|
|
436
|
+
M("div", Qe, [
|
|
437
|
+
O(P.$slots, "before", _(E(s(L))), () => [
|
|
438
|
+
s(I) ? (w(), R(G, k({
|
|
431
439
|
key: 0,
|
|
432
440
|
class: "vv-textarea__icon-left"
|
|
433
|
-
}, s(b)), null, 16)) :
|
|
441
|
+
}, s(b)), null, 16)) : C("", !0)
|
|
434
442
|
]),
|
|
435
443
|
de(M("textarea", k({
|
|
436
444
|
id: s(c),
|
|
437
445
|
ref_key: "textarea",
|
|
438
446
|
ref: l,
|
|
439
|
-
"onUpdate:modelValue":
|
|
440
|
-
}, s(
|
|
441
|
-
onKeyup:
|
|
442
|
-
}), null, 16,
|
|
447
|
+
"onUpdate:modelValue": V[0] || (V[0] = (T) => fe(p) ? p.value = T : null)
|
|
448
|
+
}, s(le), {
|
|
449
|
+
onKeyup: V[1] || (V[1] = (T) => t("keyup", T))
|
|
450
|
+
}), null, 16, Ye), [
|
|
443
451
|
[ve, s(p)]
|
|
444
452
|
]),
|
|
445
|
-
O(
|
|
446
|
-
s(
|
|
453
|
+
O(P.$slots, "after", _(E(s(L))), () => [
|
|
454
|
+
s($) ? (w(), R(G, _(k({ key: 0 }, s(b))), null, 16)) : C("", !0)
|
|
447
455
|
]),
|
|
448
|
-
s(f) ? (w(), D("span",
|
|
449
|
-
O(
|
|
450
|
-
me(z(s(
|
|
456
|
+
s(f) ? (w(), D("span", et, [
|
|
457
|
+
O(P.$slots, "count", _(E(s(L))), () => [
|
|
458
|
+
me(z(s(S)), 1)
|
|
451
459
|
])
|
|
452
|
-
])) :
|
|
460
|
+
])) : C("", !0)
|
|
453
461
|
]),
|
|
454
|
-
ge(s(
|
|
462
|
+
ge(s(re), {
|
|
455
463
|
id: s(v),
|
|
456
464
|
class: "vv-textarea__hint"
|
|
457
465
|
}, null, 8, ["id"])
|
|
@@ -459,5 +467,5 @@ const _e = "ds", Be = {
|
|
|
459
467
|
}
|
|
460
468
|
});
|
|
461
469
|
export {
|
|
462
|
-
|
|
470
|
+
ot as default
|
|
463
471
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(e,w){typeof exports=="object"&&typeof module<"u"?module.exports=w(require("vue"),require("nanoid"),require("@vueuse/core"),require("@iconify/vue")):typeof define=="function"&&define.amd?define(["vue","nanoid","@vueuse/core","@iconify/vue"],w):(e=typeof globalThis<"u"?globalThis:e||self,e.VvTextarea=w(e.vue,e.nanoid,e.core,e.vue$1))})(this,function(e,w,T,S){"use strict";function A(n,r){if(n&&Object.keys(n).length&&r){if(r.indexOf(".")===-1)return n[r];{const t=r.split(".");let s=n;for(let i=0,u=t.length;i<u;++i){if(n==null)return null;s=s[t[i]]}return s}}else return null}function C(n){return(r=>r==null||r===""||Array.isArray(r)&&r.length===0||!(r instanceof Date)&&typeof r=="object"&&Object.keys(r).length===0)(e.unref(n))}function O(n){return typeof n=="string"||n instanceof String}function E(n){var r,t;if(n)return(t=(r=n.match(/[A-Z]{2,}(?=[A-Z][a-z]+[0-9]*|\b)|[A-Z]?[a-z]+[0-9]*|[A-Z]|[0-9]+/g))==null?void 0:r.join("-"))==null?void 0:t.toLowerCase()}function x(n){return Array.isArray(n)?n.filter(r=>O(r)).join(" "):n}function j(n,r){const{invalid:t,valid:s,hint:i,loading:u}=r,{hintLabel:a,modelValue:g,valid:m,validLabel:d,invalid:o,invalidLabel:l,...p}=e.toRefs(n),c=A(p,"loading"),f=A(p,"loadingLabel"),y=e.computed(()=>o.value?!!(o.value&&t||l!=null&&l.value&&Array.isArray(l.value)&&l.value.length>0||l!=null&&l.value&&!C(l)):!1),h=e.computed(()=>!!(a&&a.value||i)),b=e.computed(()=>!!(d&&d.value||s)),I=e.computed(()=>!!(c!=null&&c.value&&u||c!=null&&c.value&&(f!=null&&f.value))),B=e.computed(()=>h.value||b.value||y.value||I.value);return{hasInvalid:y,hasHint:h,hasValid:b,hasLoading:I,HintSlot:{name:"HintSlot",props:{params:{type:Object,default:()=>({})}},setup(V){const v=e.computed(()=>{const P=T.toReactive({hintLabel:a,modelValue:g,valid:m,validLabel:d,invalid:o,invalidLabel:l,loading:c,loadingLabel:f,...V.params});return o!=null&&o.value?(t==null?void 0:t(P))||x(l==null?void 0:l.value)||(a==null?void 0:a.value):m!=null&&m.value?(s==null?void 0:s(P))||x(d==null?void 0:d.value)||(a==null?void 0:a.value):c!=null&&c.value?(u==null?void 0:u(P))||x(f==null?void 0:f.value)||(a==null?void 0:a.value):(i==null?void 0:i(P))||x(a==null?void 0:a.value)||(a==null?void 0:a.value)});return{isVisible:B,hasInvalid:y,hasValid:b,hintContent:v}},render(){if(this.isVisible)return e.h("small",{role:this.hasInvalid||this.hasValid?"alert":void 0},this.hintContent)}}}}function z(n,r,t){const s=e.computed(()=>!!(n!=null&&n.value&&r.value==="left"||t!=null&&t.iconLeft)),i=e.computed(()=>!!(n!=null&&n.value&&r.value==="right"||t!=null&&t.iconRight)),u=e.computed(()=>!!(n!=null&&n.value&&r.value==="top"||t!=null&&t.iconTop)),a=e.computed(()=>!!(n!=null&&n.value&&r.value==="bottom"||t!=null&&t.iconBottom));return{hasIcon:e.computed(()=>typeof(n==null?void 0:n.value)=="string"?{name:n==null?void 0:n.value}:n==null?void 0:n.value),hasIconLeft:s,hasIconRight:i,hasIconTop:u,hasIconBottom:a}}function q(n,r){const{focused:t}=T.useFocus(n);return e.watch(t,s=>{r(s?"focus":"blur",e.unref(n))}),{focused:t}}function H(n,r,t=0){let s;return typeof t=="string"&&(t=parseInt(t)),e.computed({get:()=>n==null?void 0:n.value,set:i=>{s&&clearTimeout(s),s=setTimeout(()=>{r("update:modelValue",i)},t)}})}function M(n,r){const t=e.computed(()=>(e.unref(n)??"").length),s=e.computed(()=>(r==null?void 0:r.lowerLimit)!==void 0&&t.value<(r==null?void 0:r.lowerLimit)?t.value-r.lowerLimit:(r==null?void 0:r.upperLimit)!==void 0&&t.value<(r==null?void 0:r.upperLimit)?r.upperLimit-t.value:0),i=e.computed(()=>(r==null?void 0:r.mode)===!1?"":(r==null?void 0:r.mode)==="limit"?`${t.value} / ${r.lowerLimit?`${r.lowerLimit}-`:""}${r.upperLimit}`:(r==null?void 0:r.mode)==="countdown"?s.value===0?void 0:s:t.value);return{length:t,gap:s,formatted:i}}function R(n,r){const t={[`${n}`]:!0};return{bemCssClasses:e.computed(()=>Object.keys(r).reduce((i,u)=>{const a=e.unref(r[u])||!1;if(!a)return i;if(u==="modifiers"){const g=Array.isArray(a)?a:a.split(" ");return{...i,...g.reduce((m,d)=>({...m,[`${n}--${E(d)}`]:!0}),{})}}else return{...i,[`${n}--${E(u)}`]:a}},t)||{})}}const Z="ds",G={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]}},K={name:"VvIcon"},D=e.defineComponent({...K,props:G,setup(n){const r=n,t=e.ref(!0),{modifiers:s}=e.toRefs(r),i=e.inject(Z),{bemCssClasses:u}=R("vv-icon",{modifiers:s}),a=e.computed(()=>r.provider||(i==null?void 0:i.provider)),g=e.computed(()=>{const o=r.name??"",l=`@${a.value}:${r.prefix}:${r.name}`;return S.iconExists(o)?o:S.iconExists(l)?l:(i==null?void 0:i.iconsCollections.find(p=>{const c=`@${a.value}:${p.prefix}:${o}`;if(S.iconExists(c))return c}))||o});function m(o){let l=null;if(typeof window>"u"){const{JSDOM:y}=require("jsdom");l=new y().window}return(l?new l.DOMParser:new window.DOMParser).parseFromString(o,"text/html").querySelector("svg")}function d(o){const l=m(o),p=(l==null?void 0:l.innerHTML.trim())||"";l&&p&&S.addIcon(`@${a.value}:${r.prefix}:${r.name}`,{body:p,height:l.viewBox.baseVal.height,width:l.viewBox.baseVal.width})}return i&&(r.src&&!S.iconExists(`@${a.value}:${r.prefix}:${r.name}`)?(t.value=!1,i.fetchIcon(r.src).then(o=>{o&&(d(o),t.value=!0)}).catch(o=>{throw new Error(`During fetch icon: ${o==null?void 0:o.message}`)})):r.svg&&d(r.svg)),(o,l)=>t.value?(e.openBlock(),e.createBlock(e.unref(S.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:o.rotate,color:o.color,onLoad:o.onLoad,icon:e.unref(g)}),null,16,["class"])):e.createCommentVNode("",!0)}}),J={valid:Boolean,validLabel:[String,Array]},U={invalid:Boolean,invalidLabel:[String,Array]},W={loading:Boolean,loadingLabel:String},X={disabled:Boolean},Q={readonly:Boolean},Y={modifiers:[String,Array]},ee={hintLabel:{type:String,default:""}},te={count:{type:[Boolean,String],default:!1,validator:n=>[!0,!1,"limit","countdown"].includes(n)}},re={debounce:[Number,String]},F={LEFT:"left",RIGHT:"right"},ne={icon:{type:[String,Object]},iconPosition:{type:String,validation:n=>Object.values(F).includes(n),default:F.RIGHT}},oe={...{id:[String,Number],name:{type:String,required:!0}},...{tabindex:{type:[String,Number],default:0}},...X,...Q,...J,...U,...ee,...W,...Y,...te,...re,...ne,autofocus:Boolean,autocomplete:{type:String,default:"off"},minlength:Number,maxlength:Number,placeholder:String,required:Boolean,label:String,floating:Boolean},ae={hard:"hard",soft:"soft"},ie={true:!0,false:!1,default:"default"},le=["update:modelValue","focus","blur","keyup"],se={...oe,modelValue:String,cols:{type:[String,Number],default:20},rows:{type:[String,Number],default:2},wrap:{type:String,default:ae.soft},spellcheck:{type:[Boolean,String],default:ie.default},resizable:Boolean},ce=["for"],ue={class:"vv-textarea__wrapper"},de=["id"],fe={key:0,class:"vv-textarea__limit"},me={name:"VvTextarea"};return e.defineComponent({...me,props:se,emits:le,setup(n,{emit:r}){const t=n,s=e.useSlots(),i=e.ref(),{icon:u,iconPosition:a,label:g,modelValue:m,count:d,valid:o,invalid:l,loading:p}=e.toRefs(t),c=e.computed(()=>String(t.id||w.nanoid())),f=e.computed(()=>`${c.value}-hint`),y=e.computed(()=>t.floating&&C(t.placeholder)?" ":t.placeholder),h=H(m,r,t.debounce),{hasIcon:b,hasIconLeft:I,hasIconRight:B}=z(u,a),{focused:V}=q(i,r),{formatted:v}=M(h,{mode:t.count,upperLimit:t.maxlength,lowerLimit:t.minlength}),P=e.computed(()=>!t.disabled&&!t.readonly),pe=e.computed(()=>P.value?t.tabindex:-1),ge=e.computed(()=>!C(m)),he=e.computed(()=>{if(t.invalid===!0)return!0;if(t.valid===!0)return!1}),{HintSlot:ye,hasHint:Se,hasInvalid:L}=j(t,s),{bemCssClasses:be}=R("vv-textarea",{modifiers:t.modifiers,valid:o,invalid:l,loading:p,disabled:t.disabled,readonly:t.readonly,iconLeft:I,iconRight:B,floating:t.floating&&!C(t.label),dirty:ge,focused:V,resizable:t.resizable}),Pe=e.computed(()=>({name:t.name,placeholder:y.value,tabindex:pe.value,disabled:t.disabled,readonly:t.readonly,required:t.required,autocomplete:t.autocomplete,minlength:t.minlength,maxlength:t.maxlength,cols:t.cols,rows:t.rows,wrap:t.wrap,spellcheck:t.spellcheck,"aria-invalid":he.value,"aria-describedby":!L.value&&Se.value?f.value:void 0,"aria-errormessage":L.value?f.value:void 0})),_=e.computed(()=>({valid:t.valid,invalid:t.invalid,modelValue:t.modelValue,hintLabel:t.hintLabel,maxlength:t.maxlength,minlength:t.minlength,clear:we})),we=()=>{h.value=void 0};return e.onMounted(()=>{t.autofocus&&(V.value=!0)}),(N,k)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(e.unref(be))},[e.unref(g)?(e.openBlock(),e.createElementBlock("label",{key:0,for:e.unref(c),class:"vv-textarea__label"},e.toDisplayString(e.unref(g)),9,ce)):e.createCommentVNode("",!0),e.createElementVNode("div",ue,[e.renderSlot(N.$slots,"before",e.normalizeProps(e.guardReactiveProps(e.unref(_))),()=>[e.unref(I)?(e.openBlock(),e.createBlock(D,e.mergeProps({key:0,class:"vv-textarea__icon-left"},e.unref(b)),null,16)):e.createCommentVNode("",!0)]),e.withDirectives(e.createElementVNode("textarea",e.mergeProps({id:e.unref(c),ref_key:"textarea",ref:i,"onUpdate:modelValue":k[0]||(k[0]=$=>e.isRef(h)?h.value=$:null)},e.unref(Pe),{onKeyup:k[1]||(k[1]=$=>r("keyup",$))}),null,16,de),[[e.vModelText,e.unref(h)]]),e.renderSlot(N.$slots,"after",e.normalizeProps(e.guardReactiveProps(e.unref(_))),()=>[e.unref(B)?(e.openBlock(),e.createBlock(D,e.normalizeProps(e.mergeProps({key:0},e.unref(b))),null,16)):e.createCommentVNode("",!0)]),e.unref(d)?(e.openBlock(),e.createElementBlock("span",fe,[e.renderSlot(N.$slots,"count",e.normalizeProps(e.guardReactiveProps(e.unref(_))),()=>[e.createTextVNode(e.toDisplayString(e.unref(v)),1)])])):e.createCommentVNode("",!0)]),e.createVNode(e.unref(ye),{id:e.unref(f),class:"vv-textarea__hint"},null,8,["id"])],2))}})});
|
|
1
|
+
(function(e,w){typeof exports=="object"&&typeof module<"u"?module.exports=w(require("vue"),require("nanoid"),require("@vueuse/core"),require("@iconify/vue")):typeof define=="function"&&define.amd?define(["vue","nanoid","@vueuse/core","@iconify/vue"],w):(e=typeof globalThis<"u"?globalThis:e||self,e.VvTextarea=w(e.vue,e.nanoid,e.core,e.vue$1))})(this,function(e,w,_,b){"use strict";function T(n,r){if(n&&Object.keys(n).length&&r){if(r.indexOf(".")===-1)return n[r];{const t=r.split(".");let s=n;for(let l=0,u=t.length;l<u;++l){if(n==null)return null;s=s[t[l]]}return s}}else return null}function x(n){return(r=>r==null||r===""||Array.isArray(r)&&r.length===0||!(r instanceof Date)&&typeof r=="object"&&Object.keys(r).length===0)(e.unref(n))}function O(n){return typeof n=="string"||n instanceof String}function E(n){var r,t;if(n)return(t=(r=n.match(/[A-Z]{2,}(?=[A-Z][a-z]+[0-9]*|\b)|[A-Z]?[a-z]+[0-9]*|[A-Z]|[0-9]+/g))==null?void 0:r.join("-"))==null?void 0:t.toLowerCase()}function B(n){return Array.isArray(n)?n.filter(r=>O(r)).join(" "):n}function j(n,r){const{invalid:t,valid:s,hint:l,loading:u}=r,{hintLabel:a,modelValue:g,valid:m,validLabel:d,invalid:o,invalidLabel:i,...p}=e.toRefs(n),c=T(p,"loading"),f=T(p,"loadingLabel"),y=e.computed(()=>o.value?!!(o.value&&t||i!=null&&i.value&&Array.isArray(i.value)&&i.value.length>0||i!=null&&i.value&&!x(i)):!1),h=e.computed(()=>!!(a&&a.value||l)),S=e.computed(()=>!!(d&&d.value||s)),I=e.computed(()=>!!(c!=null&&c.value&&u||c!=null&&c.value&&(f!=null&&f.value))),V=e.computed(()=>h.value||S.value||y.value||I.value);return{hasInvalid:y,hasHint:h,hasValid:S,hasLoading:I,HintSlot:{name:"HintSlot",props:{params:{type:Object,default:()=>({})}},setup(k){const N=e.computed(()=>{const P=_.toReactive({hintLabel:a,modelValue:g,valid:m,validLabel:d,invalid:o,invalidLabel:i,loading:c,loadingLabel:f,...k.params});return o!=null&&o.value?(t==null?void 0:t(P))||B(i==null?void 0:i.value)||(a==null?void 0:a.value):m!=null&&m.value?(s==null?void 0:s(P))||B(d==null?void 0:d.value)||(a==null?void 0:a.value):c!=null&&c.value?(u==null?void 0:u(P))||B(f==null?void 0:f.value)||(a==null?void 0:a.value):(l==null?void 0:l(P))||B(a==null?void 0:a.value)||(a==null?void 0:a.value)});return{isVisible:V,hasInvalid:y,hasValid:S,hintContent:N}},render(){if(this.isVisible)return e.h("small",{role:this.hasInvalid||this.hasValid?"alert":void 0},this.hintContent)}}}}function z(n,r,t){const s=e.computed(()=>!!(n!=null&&n.value&&r.value==="left"||t!=null&&t.iconLeft)),l=e.computed(()=>!!(n!=null&&n.value&&r.value==="right"||t!=null&&t.iconRight)),u=e.computed(()=>!!(n!=null&&n.value&&r.value==="top"||t!=null&&t.iconTop)),a=e.computed(()=>!!(n!=null&&n.value&&r.value==="bottom"||t!=null&&t.iconBottom));return{hasIcon:e.computed(()=>typeof(n==null?void 0:n.value)=="string"?{name:n==null?void 0:n.value}:n==null?void 0:n.value),hasIconLeft:s,hasIconRight:l,hasIconTop:u,hasIconBottom:a}}function q(n,r){const{focused:t}=_.useFocus(n);return e.watch(t,s=>{r(s?"focus":"blur",e.unref(n))}),{focused:t}}function H(n,r,t=0){let s;return typeof t=="string"&&(t=parseInt(t)),e.computed({get:()=>n==null?void 0:n.value,set:l=>{s&&clearTimeout(s),s=setTimeout(()=>{r("update:modelValue",l)},t)}})}function M(n,r){const t=e.computed(()=>(e.unref(n)??"").length),s=e.computed(()=>(r==null?void 0:r.lowerLimit)!==void 0&&t.value<(r==null?void 0:r.lowerLimit)?t.value-r.lowerLimit:(r==null?void 0:r.upperLimit)!==void 0&&t.value<(r==null?void 0:r.upperLimit)?r.upperLimit-t.value:0),l=e.computed(()=>(r==null?void 0:r.mode)===!1?"":(r==null?void 0:r.mode)==="limit"&&(r!=null&&r.upperLimit)?`${t.value} / ${r.lowerLimit?`${r.lowerLimit}-`:""}${r.upperLimit}`:(r==null?void 0:r.mode)==="countdown"?s.value===0?void 0:s:t.value);return{length:t,gap:s,formatted:l}}function F(n,r){const t={[`${n}`]:!0};return{bemCssClasses:e.computed(()=>Object.keys(r).reduce((l,u)=>{const a=e.unref(r[u])||!1;if(!a)return l;if(u==="modifiers"){const g=Array.isArray(a)?a:a.split(" ");return{...l,...g.reduce((m,d)=>({...m,[`${n}--${E(d)}`]:!0}),{})}}else return{...l,[`${n}--${E(u)}`]:a}},t)||{})}}const Z="ds",G={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]}},K={name:"VvIcon"},L=e.defineComponent({...K,props:G,setup(n){const r=n,t=e.ref(!0),{modifiers:s}=e.toRefs(r),l=e.inject(Z),{bemCssClasses:u}=F("vv-icon",{modifiers:s}),a=e.computed(()=>r.provider||(l==null?void 0:l.provider)),g=e.computed(()=>{const o=r.name??"",i=`@${a.value}:${r.prefix}:${r.name}`;return b.iconExists(o)?o:b.iconExists(i)?i:(l==null?void 0:l.iconsCollections.find(p=>{const c=`@${a.value}:${p.prefix}:${o}`;if(b.iconExists(c))return c}))||o});function m(o){let i=null;if(typeof window>"u"){const{JSDOM:y}=require("jsdom");i=new y().window}return(i?new i.DOMParser:new window.DOMParser).parseFromString(o,"text/html").querySelector("svg")}function d(o){const i=m(o),p=(i==null?void 0:i.innerHTML.trim())||"";i&&p&&b.addIcon(`@${a.value}:${r.prefix}:${r.name}`,{body:p,height:i.viewBox.baseVal.height,width:i.viewBox.baseVal.width})}return l&&(r.src&&!b.iconExists(`@${a.value}:${r.prefix}:${r.name}`)?(t.value=!1,l.fetchIcon(r.src).then(o=>{o&&(d(o),t.value=!0)}).catch(o=>{throw new Error(`During fetch icon: ${o==null?void 0:o.message}`)})):r.svg&&d(r.svg)),(o,i)=>t.value?(e.openBlock(),e.createBlock(e.unref(b.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:o.rotate,color:o.color,onLoad:o.onLoad,icon:e.unref(g)}),null,16,["class"])):e.createCommentVNode("",!0)}}),J={valid:Boolean,validLabel:[String,Array]},U={invalid:Boolean,invalidLabel:[String,Array]},W={loading:Boolean,loadingLabel:String},X={disabled:Boolean},Q={readonly:Boolean},Y={modifiers:[String,Array]},ee={hintLabel:{type:String,default:""}},te={count:{type:[Boolean,String],default:!1,validator:n=>[!0,!1,"limit","countdown"].includes(n)}},re={debounce:[Number,String]},R={LEFT:"left",RIGHT:"right"},ne={icon:{type:[String,Object]},iconPosition:{type:String,validation:n=>Object.values(R).includes(n),default:R.RIGHT}},oe={...{id:[String,Number],name:{type:String,required:!0}},...{autofocus:Boolean},...{autocomplete:{type:String,default:"off"}},...{tabindex:{type:[String,Number],default:0}},...X,...Q,...J,...U,...ee,...W,...Y,...te,...re,...ne,...{floating:Boolean},minlength:Number,maxlength:Number,placeholder:String,required:Boolean,label:String},ae={hard:"hard",soft:"soft"},le={true:!0,false:!1,default:"default"},ie=["update:modelValue","focus","blur","keyup"],se={...oe,modelValue:String,cols:{type:[String,Number],default:20},rows:{type:[String,Number],default:2},wrap:{type:String,default:ae.soft},spellcheck:{type:[Boolean,String],default:le.default},resizable:Boolean},ce=["for"],ue={class:"vv-textarea__wrapper"},de=["id"],fe={key:0,class:"vv-textarea__limit"},me={name:"VvTextarea"};return e.defineComponent({...me,props:se,emits:ie,setup(n,{emit:r}){const t=n,s=e.useSlots(),l=e.ref(),{icon:u,iconPosition:a,label:g,modelValue:m,count:d,valid:o,invalid:i,loading:p}=e.toRefs(t),c=e.computed(()=>String(t.id||w.nanoid())),f=e.computed(()=>`${c.value}-hint`),y=e.computed(()=>t.floating&&x(t.placeholder)?" ":t.placeholder),h=H(m,r,t.debounce),{hasIcon:S,hasIconLeft:I,hasIconRight:V}=z(u,a),{focused:k}=q(l,r),N=_.useElementVisibility(l);e.watch(N,C=>{C&&t.autofocus&&(k.value=!0)});const{formatted:P}=M(h,{mode:t.count,upperLimit:t.maxlength,lowerLimit:t.minlength}),pe=e.computed(()=>!t.disabled&&!t.readonly),ge=e.computed(()=>pe.value?t.tabindex:-1),he=e.computed(()=>!x(m)),ye=e.computed(()=>{if(t.invalid===!0)return!0;if(t.valid===!0)return!1}),{HintSlot:be,hasHint:Se,hasInvalid:D}=j(t,s),{bemCssClasses:Pe}=F("vv-textarea",{modifiers:t.modifiers,valid:o,invalid:i,loading:p,disabled:t.disabled,readonly:t.readonly,iconLeft:I,iconRight:V,floating:t.floating&&!x(t.label),dirty:he,focused:k,resizable:t.resizable}),we=e.computed(()=>({name:t.name,placeholder:y.value,tabindex:ge.value,disabled:t.disabled,readonly:t.readonly,required:t.required,autocomplete:t.autocomplete,minlength:t.minlength,maxlength:t.maxlength,cols:t.cols,rows:t.rows,wrap:t.wrap,spellcheck:t.spellcheck,"aria-invalid":ye.value,"aria-describedby":!D.value&&Se.value?f.value:void 0,"aria-errormessage":D.value?f.value:void 0})),$=e.computed(()=>({valid:t.valid,invalid:t.invalid,modelValue:t.modelValue,hintLabel:t.hintLabel,maxlength:t.maxlength,minlength:t.minlength,clear:Ie})),Ie=()=>{h.value=void 0};return(C,v)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(e.unref(Pe))},[e.unref(g)?(e.openBlock(),e.createElementBlock("label",{key:0,for:e.unref(c),class:"vv-textarea__label"},e.toDisplayString(e.unref(g)),9,ce)):e.createCommentVNode("",!0),e.createElementVNode("div",ue,[e.renderSlot(C.$slots,"before",e.normalizeProps(e.guardReactiveProps(e.unref($))),()=>[e.unref(I)?(e.openBlock(),e.createBlock(L,e.mergeProps({key:0,class:"vv-textarea__icon-left"},e.unref(S)),null,16)):e.createCommentVNode("",!0)]),e.withDirectives(e.createElementVNode("textarea",e.mergeProps({id:e.unref(c),ref_key:"textarea",ref:l,"onUpdate:modelValue":v[0]||(v[0]=A=>e.isRef(h)?h.value=A:null)},e.unref(we),{onKeyup:v[1]||(v[1]=A=>r("keyup",A))}),null,16,de),[[e.vModelText,e.unref(h)]]),e.renderSlot(C.$slots,"after",e.normalizeProps(e.guardReactiveProps(e.unref($))),()=>[e.unref(V)?(e.openBlock(),e.createBlock(L,e.normalizeProps(e.mergeProps({key:0},e.unref(S))),null,16)):e.createCommentVNode("",!0)]),e.unref(d)?(e.openBlock(),e.createElementBlock("span",fe,[e.renderSlot(C.$slots,"count",e.normalizeProps(e.guardReactiveProps(e.unref($))),()=>[e.createTextVNode(e.toDisplayString(e.unref(P)),1)])])):e.createCommentVNode("",!0)]),e.createVNode(e.unref(be),{id:e.unref(f),class:"vv-textarea__hint"},null,8,["id"])],2))}})});
|