@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,99 +1,99 @@
|
|
|
1
|
-
import { unref as
|
|
2
|
-
import { nanoid as
|
|
3
|
-
import { useFocus as
|
|
4
|
-
import { iconExists as F, Icon as
|
|
5
|
-
function
|
|
1
|
+
import { unref as c, computed as i, toRefs as j, watch as J, defineComponent as X, ref as Q, inject as ae, openBlock as y, createBlock as R, mergeProps as D, createCommentVNode as O, h as ue, useSlots as ce, createElementBlock as B, normalizeClass as de, toDisplayString as E, createElementVNode as T, renderSlot as q, normalizeProps as L, withDirectives as fe, isRef as ve, Fragment as pe, renderList as me, vModelSelect as ge, createVNode as he } from "vue";
|
|
2
|
+
import { nanoid as ye } from "nanoid";
|
|
3
|
+
import { useFocus as be, toReactive as Se, useElementVisibility as Ie } from "@vueuse/core";
|
|
4
|
+
import { iconExists as F, Icon as Ve, addIcon as Pe } from "@iconify/vue";
|
|
5
|
+
function K(e, r) {
|
|
6
6
|
if (e && Object.keys(e).length && r) {
|
|
7
7
|
if (r.indexOf(".") === -1)
|
|
8
8
|
return e[r];
|
|
9
9
|
{
|
|
10
10
|
const t = r.split(".");
|
|
11
|
-
let
|
|
12
|
-
for (let
|
|
11
|
+
let a = e;
|
|
12
|
+
for (let l = 0, d = t.length; l < d; ++l) {
|
|
13
13
|
if (e == null)
|
|
14
14
|
return null;
|
|
15
|
-
|
|
15
|
+
a = a[t[l]];
|
|
16
16
|
}
|
|
17
|
-
return
|
|
17
|
+
return a;
|
|
18
18
|
}
|
|
19
19
|
} else
|
|
20
20
|
return null;
|
|
21
21
|
}
|
|
22
|
-
function
|
|
23
|
-
return ((r) => r == null || r === "" || Array.isArray(r) && r.length === 0 || !(r instanceof Date) && typeof r == "object" && Object.keys(r).length === 0)(
|
|
22
|
+
function W(e) {
|
|
23
|
+
return ((r) => r == null || r === "" || Array.isArray(r) && r.length === 0 || !(r instanceof Date) && typeof r == "object" && Object.keys(r).length === 0)(c(e));
|
|
24
24
|
}
|
|
25
|
-
function
|
|
25
|
+
function Ae(e) {
|
|
26
26
|
return typeof e == "string" || e instanceof String;
|
|
27
27
|
}
|
|
28
|
-
function
|
|
28
|
+
function Z(e) {
|
|
29
29
|
var r, t;
|
|
30
30
|
if (e)
|
|
31
31
|
return (t = (r = e.match(
|
|
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 : r.join("-")) == null ? void 0 : t.toLowerCase();
|
|
34
34
|
}
|
|
35
|
-
function
|
|
35
|
+
function Y(e, r) {
|
|
36
36
|
const t = { [`${e}`]: !0 };
|
|
37
37
|
return {
|
|
38
|
-
bemCssClasses: i(() => Object.keys(r).reduce((
|
|
39
|
-
const n =
|
|
38
|
+
bemCssClasses: i(() => Object.keys(r).reduce((l, d) => {
|
|
39
|
+
const n = c(r[d]) || !1;
|
|
40
40
|
if (!n)
|
|
41
|
-
return
|
|
42
|
-
if (
|
|
41
|
+
return l;
|
|
42
|
+
if (d === "modifiers") {
|
|
43
43
|
const h = Array.isArray(n) ? n : n.split(" ");
|
|
44
44
|
return {
|
|
45
|
-
...
|
|
45
|
+
...l,
|
|
46
46
|
...h.reduce(
|
|
47
|
-
(p,
|
|
47
|
+
(p, v) => ({
|
|
48
48
|
...p,
|
|
49
|
-
[`${e}--${
|
|
49
|
+
[`${e}--${Z(v)}`]: !0
|
|
50
50
|
}),
|
|
51
51
|
{}
|
|
52
52
|
)
|
|
53
53
|
};
|
|
54
54
|
} else
|
|
55
55
|
return {
|
|
56
|
-
...
|
|
57
|
-
[`${e}--${
|
|
56
|
+
...l,
|
|
57
|
+
[`${e}--${Z(d)}`]: n
|
|
58
58
|
};
|
|
59
59
|
}, t) || {})
|
|
60
60
|
};
|
|
61
61
|
}
|
|
62
|
-
function
|
|
63
|
-
const
|
|
62
|
+
function Be(e, r, t) {
|
|
63
|
+
const a = i(
|
|
64
64
|
() => !!(e != null && e.value && r.value === "left" || t != null && t.iconLeft)
|
|
65
|
-
),
|
|
65
|
+
), l = i(
|
|
66
66
|
() => !!(e != null && e.value && r.value === "right" || t != null && t.iconRight)
|
|
67
|
-
),
|
|
67
|
+
), d = i(
|
|
68
68
|
() => !!(e != null && e.value && r.value === "top" || t != null && t.iconTop)
|
|
69
69
|
), n = i(
|
|
70
70
|
() => !!(e != null && e.value && r.value === "bottom" || t != null && t.iconBottom)
|
|
71
71
|
);
|
|
72
72
|
return {
|
|
73
73
|
hasIcon: i(() => typeof (e == null ? void 0 : e.value) == "string" ? { name: e == null ? void 0 : e.value } : e == null ? void 0 : e.value),
|
|
74
|
-
hasIconLeft:
|
|
75
|
-
hasIconRight:
|
|
76
|
-
hasIconTop:
|
|
74
|
+
hasIconLeft: a,
|
|
75
|
+
hasIconRight: l,
|
|
76
|
+
hasIconTop: d,
|
|
77
77
|
hasIconBottom: n
|
|
78
78
|
};
|
|
79
79
|
}
|
|
80
|
-
function
|
|
81
|
-
const { options: r, labelKey: t, valueKey:
|
|
80
|
+
function Oe(e) {
|
|
81
|
+
const { options: r, labelKey: t, valueKey: a } = j(e);
|
|
82
82
|
return {
|
|
83
83
|
options: r,
|
|
84
84
|
getOptionLabel: (n) => typeof n != "object" && n !== null ? n : typeof t.value == "function" ? t.value(n) : n[t.value],
|
|
85
|
-
getOptionValue: (n) => typeof n != "object" && n !== null ? n : typeof
|
|
85
|
+
getOptionValue: (n) => typeof n != "object" && n !== null ? n : typeof a.value == "function" ? a.value(n) : n[a.value]
|
|
86
86
|
};
|
|
87
87
|
}
|
|
88
|
-
function
|
|
89
|
-
const { focused: t } =
|
|
90
|
-
return
|
|
91
|
-
r(
|
|
88
|
+
function $e(e, r) {
|
|
89
|
+
const { focused: t } = be(e);
|
|
90
|
+
return J(t, (a) => {
|
|
91
|
+
r(a ? "focus" : "blur", c(e));
|
|
92
92
|
}), {
|
|
93
93
|
focused: t
|
|
94
94
|
};
|
|
95
95
|
}
|
|
96
|
-
const
|
|
96
|
+
const Ce = "ds", we = {
|
|
97
97
|
color: String,
|
|
98
98
|
width: {
|
|
99
99
|
type: [String, Number]
|
|
@@ -124,20 +124,20 @@ const Oe = "ds", $e = {
|
|
|
124
124
|
modifiers: {
|
|
125
125
|
type: [String, Array]
|
|
126
126
|
}
|
|
127
|
-
},
|
|
127
|
+
}, Fe = {
|
|
128
128
|
name: "VvIcon"
|
|
129
|
-
},
|
|
130
|
-
...
|
|
131
|
-
props:
|
|
129
|
+
}, G = /* @__PURE__ */ X({
|
|
130
|
+
...Fe,
|
|
131
|
+
props: we,
|
|
132
132
|
setup(e) {
|
|
133
|
-
const r = e, t =
|
|
134
|
-
modifiers:
|
|
135
|
-
}), n = i(() => r.provider || (
|
|
133
|
+
const r = e, t = Q(!0), { modifiers: a } = j(r), l = ae(Ce), { bemCssClasses: d } = Y("vv-icon", {
|
|
134
|
+
modifiers: a
|
|
135
|
+
}), n = i(() => r.provider || (l == null ? void 0 : l.provider)), h = i(() => {
|
|
136
136
|
const o = r.name ?? "", s = `@${n.value}:${r.prefix}:${r.name}`;
|
|
137
|
-
return F(o) ? o : F(s) ? s : (
|
|
138
|
-
const
|
|
139
|
-
if (F(
|
|
140
|
-
return
|
|
137
|
+
return F(o) ? o : F(s) ? s : (l == null ? void 0 : l.iconsCollections.find((m) => {
|
|
138
|
+
const f = `@${n.value}:${m.prefix}:${o}`;
|
|
139
|
+
if (F(f))
|
|
140
|
+
return f;
|
|
141
141
|
})) || o;
|
|
142
142
|
});
|
|
143
143
|
function p(o) {
|
|
@@ -148,21 +148,21 @@ const Oe = "ds", $e = {
|
|
|
148
148
|
}
|
|
149
149
|
return (s ? new s.DOMParser() : new window.DOMParser()).parseFromString(o, "text/html").querySelector("svg");
|
|
150
150
|
}
|
|
151
|
-
function
|
|
151
|
+
function v(o) {
|
|
152
152
|
const s = p(o), m = (s == null ? void 0 : s.innerHTML.trim()) || "";
|
|
153
|
-
s && m &&
|
|
153
|
+
s && m && Pe(`@${n.value}:${r.prefix}:${r.name}`, {
|
|
154
154
|
body: m,
|
|
155
155
|
height: s.viewBox.baseVal.height,
|
|
156
156
|
width: s.viewBox.baseVal.width
|
|
157
157
|
});
|
|
158
158
|
}
|
|
159
|
-
return
|
|
160
|
-
o && (
|
|
159
|
+
return l && (r.src && !F(`@${n.value}:${r.prefix}:${r.name}`) ? (t.value = !1, l.fetchIcon(r.src).then((o) => {
|
|
160
|
+
o && (v(o), t.value = !0);
|
|
161
161
|
}).catch((o) => {
|
|
162
162
|
throw new Error(`During fetch icon: ${o == null ? void 0 : o.message}`);
|
|
163
|
-
})) : r.svg &&
|
|
163
|
+
})) : r.svg && v(r.svg)), (o, s) => t.value ? (y(), R(c(Ve), D({
|
|
164
164
|
key: 0,
|
|
165
|
-
class:
|
|
165
|
+
class: c(d)
|
|
166
166
|
}, {
|
|
167
167
|
inline: o.inline,
|
|
168
168
|
width: o.width,
|
|
@@ -173,41 +173,41 @@ const Oe = "ds", $e = {
|
|
|
173
173
|
rotate: o.rotate,
|
|
174
174
|
color: o.color,
|
|
175
175
|
onLoad: o.onLoad,
|
|
176
|
-
icon:
|
|
177
|
-
}), null, 16, ["class"])) :
|
|
176
|
+
icon: c(h)
|
|
177
|
+
}), null, 16, ["class"])) : O("", !0);
|
|
178
178
|
}
|
|
179
179
|
});
|
|
180
180
|
function _(e) {
|
|
181
|
-
return Array.isArray(e) ? e.filter((r) =>
|
|
181
|
+
return Array.isArray(e) ? e.filter((r) => Ae(r)).join(" ") : e;
|
|
182
182
|
}
|
|
183
|
-
function
|
|
183
|
+
function _e(e, r) {
|
|
184
184
|
const {
|
|
185
185
|
invalid: t,
|
|
186
|
-
valid:
|
|
187
|
-
hint:
|
|
188
|
-
loading:
|
|
186
|
+
valid: a,
|
|
187
|
+
hint: l,
|
|
188
|
+
loading: d
|
|
189
189
|
} = r, {
|
|
190
190
|
hintLabel: n,
|
|
191
191
|
modelValue: h,
|
|
192
192
|
valid: p,
|
|
193
|
-
validLabel:
|
|
193
|
+
validLabel: v,
|
|
194
194
|
invalid: o,
|
|
195
195
|
invalidLabel: s,
|
|
196
196
|
...m
|
|
197
|
-
} = j(e),
|
|
198
|
-
() => !!(n && n.value ||
|
|
199
|
-
),
|
|
200
|
-
() => !!(
|
|
201
|
-
),
|
|
202
|
-
() => !!(
|
|
197
|
+
} = j(e), f = K(m, "loading"), g = K(m, "loadingLabel"), b = i(() => o.value ? !!(o.value && t || s != null && s.value && Array.isArray(s.value) && s.value.length > 0 || s != null && s.value && !W(s)) : !1), $ = i(
|
|
198
|
+
() => !!(n && n.value || l)
|
|
199
|
+
), V = i(
|
|
200
|
+
() => !!(v && v.value || a)
|
|
201
|
+
), I = i(
|
|
202
|
+
() => !!(f != null && f.value && d || f != null && f.value && (g != null && g.value))
|
|
203
203
|
), P = i(
|
|
204
|
-
() =>
|
|
204
|
+
() => $.value || V.value || b.value || I.value
|
|
205
205
|
);
|
|
206
206
|
return {
|
|
207
207
|
hasInvalid: b,
|
|
208
|
-
hasHint:
|
|
209
|
-
hasValid:
|
|
210
|
-
hasLoading:
|
|
208
|
+
hasHint: $,
|
|
209
|
+
hasValid: V,
|
|
210
|
+
hasLoading: I,
|
|
211
211
|
HintSlot: {
|
|
212
212
|
name: "HintSlot",
|
|
213
213
|
props: {
|
|
@@ -216,31 +216,31 @@ function Pe(e, r) {
|
|
|
216
216
|
default: () => ({})
|
|
217
217
|
}
|
|
218
218
|
},
|
|
219
|
-
setup(
|
|
220
|
-
const
|
|
221
|
-
const
|
|
219
|
+
setup(C) {
|
|
220
|
+
const k = i(() => {
|
|
221
|
+
const S = Se({
|
|
222
222
|
hintLabel: n,
|
|
223
223
|
modelValue: h,
|
|
224
224
|
valid: p,
|
|
225
|
-
validLabel:
|
|
225
|
+
validLabel: v,
|
|
226
226
|
invalid: o,
|
|
227
227
|
invalidLabel: s,
|
|
228
|
-
loading:
|
|
228
|
+
loading: f,
|
|
229
229
|
loadingLabel: g,
|
|
230
|
-
...
|
|
230
|
+
...C.params
|
|
231
231
|
});
|
|
232
|
-
return o != null && o.value ? (t == null ? void 0 : t(
|
|
232
|
+
return o != null && o.value ? (t == null ? void 0 : t(S)) || _(s == null ? void 0 : s.value) || (n == null ? void 0 : n.value) : p != null && p.value ? (a == null ? void 0 : a(S)) || _(v == null ? void 0 : v.value) || (n == null ? void 0 : n.value) : f != null && f.value ? (d == null ? void 0 : d(S)) || _(g == null ? void 0 : g.value) || (n == null ? void 0 : n.value) : (l == null ? void 0 : l(S)) || _(n == null ? void 0 : n.value) || (n == null ? void 0 : n.value);
|
|
233
233
|
});
|
|
234
234
|
return {
|
|
235
235
|
isVisible: P,
|
|
236
236
|
hasInvalid: b,
|
|
237
|
-
hasValid:
|
|
238
|
-
hintContent:
|
|
237
|
+
hasValid: V,
|
|
238
|
+
hintContent: k
|
|
239
239
|
};
|
|
240
240
|
},
|
|
241
241
|
render() {
|
|
242
242
|
if (this.isVisible)
|
|
243
|
-
return
|
|
243
|
+
return ue(
|
|
244
244
|
"small",
|
|
245
245
|
{
|
|
246
246
|
role: this.hasInvalid || this.hasValid ? "alert" : void 0
|
|
@@ -251,59 +251,69 @@ function Pe(e, r) {
|
|
|
251
251
|
}
|
|
252
252
|
};
|
|
253
253
|
}
|
|
254
|
-
const
|
|
254
|
+
const De = {
|
|
255
255
|
valid: Boolean,
|
|
256
256
|
validLabel: [String, Array]
|
|
257
|
-
},
|
|
257
|
+
}, je = {
|
|
258
258
|
invalid: Boolean,
|
|
259
259
|
invalidLabel: [String, Array]
|
|
260
|
-
},
|
|
260
|
+
}, ke = {
|
|
261
261
|
loading: Boolean,
|
|
262
262
|
loadingLabel: String
|
|
263
|
-
},
|
|
263
|
+
}, Ne = {
|
|
264
264
|
disabled: Boolean
|
|
265
|
-
},
|
|
265
|
+
}, Ee = {
|
|
266
266
|
readonly: Boolean
|
|
267
|
-
},
|
|
267
|
+
}, Re = {
|
|
268
268
|
modifiers: [String, Array]
|
|
269
|
-
},
|
|
269
|
+
}, ze = {
|
|
270
270
|
hintLabel: { type: String, default: "" }
|
|
271
|
-
},
|
|
271
|
+
}, He = {
|
|
272
272
|
options: {
|
|
273
273
|
type: Array,
|
|
274
274
|
default: () => []
|
|
275
275
|
},
|
|
276
276
|
labelKey: { type: [String, Function], default: "label" },
|
|
277
277
|
valueKey: { type: [String, Function], default: "value" }
|
|
278
|
-
},
|
|
278
|
+
}, U = {
|
|
279
279
|
LEFT: "left",
|
|
280
280
|
RIGHT: "right"
|
|
281
|
-
},
|
|
281
|
+
}, Me = {
|
|
282
282
|
icon: { type: [String, Object] },
|
|
283
283
|
iconPosition: {
|
|
284
284
|
type: String,
|
|
285
|
-
validation: (e) => Object.values(
|
|
286
|
-
default:
|
|
285
|
+
validation: (e) => Object.values(U).includes(e),
|
|
286
|
+
default: U.RIGHT
|
|
287
287
|
}
|
|
288
|
-
},
|
|
288
|
+
}, Te = {
|
|
289
289
|
tabindex: { type: [String, Number], default: 0 }
|
|
290
|
-
},
|
|
290
|
+
}, qe = {
|
|
291
|
+
floating: Boolean
|
|
292
|
+
}, Le = {
|
|
293
|
+
unselectable: { type: Boolean, default: !0 }
|
|
294
|
+
}, Ke = {
|
|
291
295
|
id: [String, Number],
|
|
292
296
|
name: { type: String, required: !0 }
|
|
293
|
-
},
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
...
|
|
299
|
-
...
|
|
300
|
-
...
|
|
297
|
+
}, Ze = {
|
|
298
|
+
autofocus: Boolean
|
|
299
|
+
}, Ge = {
|
|
300
|
+
autocomplete: { type: String, default: "off" }
|
|
301
|
+
}, Ue = {
|
|
302
|
+
...Ke,
|
|
303
|
+
...Ze,
|
|
304
|
+
...Ge,
|
|
305
|
+
...Te,
|
|
301
306
|
...De,
|
|
302
307
|
...je,
|
|
308
|
+
...ze,
|
|
309
|
+
...ke,
|
|
303
310
|
...Ne,
|
|
311
|
+
...Ee,
|
|
304
312
|
...Re,
|
|
305
|
-
|
|
306
|
-
|
|
313
|
+
...He,
|
|
314
|
+
...Me,
|
|
315
|
+
...qe,
|
|
316
|
+
...Le,
|
|
307
317
|
multiple: Boolean,
|
|
308
318
|
required: Boolean,
|
|
309
319
|
size: [String, Number],
|
|
@@ -313,103 +323,112 @@ const Be = {
|
|
|
313
323
|
},
|
|
314
324
|
label: String,
|
|
315
325
|
placeholder: String
|
|
316
|
-
},
|
|
317
|
-
key: 0,
|
|
318
|
-
value: void 0,
|
|
319
|
-
disabled: ""
|
|
320
|
-
}, Ze = ["disabled", "value"], Ge = {
|
|
326
|
+
}, Je = ["update:modelValue", "focus", "blur"], Xe = ["for"], Qe = { class: "vv-select__wrapper" }, We = ["id"], Ye = ["disabled", "hidden"], xe = ["disabled", "value"], et = {
|
|
321
327
|
name: "VvSelect"
|
|
322
|
-
},
|
|
323
|
-
...
|
|
324
|
-
props:
|
|
325
|
-
emits:
|
|
328
|
+
}, st = /* @__PURE__ */ X({
|
|
329
|
+
...et,
|
|
330
|
+
props: Ue,
|
|
331
|
+
emits: Je,
|
|
326
332
|
setup(e, { emit: r }) {
|
|
327
|
-
const t = e,
|
|
333
|
+
const t = e, a = ce(), l = Q(), { HintSlot: d, hasHint: n, hasInvalid: h } = _e(t, a), {
|
|
328
334
|
modifiers: p,
|
|
329
|
-
disabled:
|
|
335
|
+
disabled: v,
|
|
330
336
|
readonly: o,
|
|
331
337
|
loading: s,
|
|
332
338
|
icon: m,
|
|
333
|
-
iconPosition:
|
|
339
|
+
iconPosition: f,
|
|
334
340
|
invalid: g,
|
|
335
|
-
valid: b
|
|
336
|
-
|
|
341
|
+
valid: b,
|
|
342
|
+
floating: $,
|
|
343
|
+
multiple: V
|
|
344
|
+
} = j(t), I = i(() => String(t.id || ye())), P = i(() => `${I.value}-hint`), { focused: C } = $e(l, r), k = Ie(l);
|
|
345
|
+
J(k, (u) => {
|
|
346
|
+
u && t.autofocus && (C.value = !0);
|
|
347
|
+
});
|
|
348
|
+
const { hasIcon: S, hasIconLeft: z, hasIconRight: H } = Be(
|
|
337
349
|
m,
|
|
338
|
-
|
|
339
|
-
),
|
|
350
|
+
f
|
|
351
|
+
), x = i(() => !W(t.modelValue)), M = i(() => t.disabled || t.readonly), ee = i(() => M.value ? -1 : t.tabindex), te = i(() => {
|
|
340
352
|
if (t.invalid === !0)
|
|
341
353
|
return !0;
|
|
342
354
|
if (t.valid === !0)
|
|
343
355
|
return !1;
|
|
344
|
-
}), { bemCssClasses:
|
|
356
|
+
}), { bemCssClasses: re } = Y("vv-select", {
|
|
345
357
|
modifiers: p,
|
|
346
358
|
valid: b,
|
|
347
359
|
invalid: g,
|
|
348
360
|
loading: s,
|
|
349
|
-
disabled:
|
|
361
|
+
disabled: v,
|
|
350
362
|
readonly: o,
|
|
351
|
-
iconLeft:
|
|
352
|
-
iconRight:
|
|
353
|
-
dirty:
|
|
354
|
-
focus: C
|
|
355
|
-
|
|
363
|
+
iconLeft: z,
|
|
364
|
+
iconRight: H,
|
|
365
|
+
dirty: x,
|
|
366
|
+
focus: C,
|
|
367
|
+
floating: $,
|
|
368
|
+
multiple: V
|
|
369
|
+
}), ne = i(() => ({
|
|
356
370
|
name: t.name,
|
|
357
|
-
tabindex:
|
|
358
|
-
disabled:
|
|
371
|
+
tabindex: ee.value,
|
|
372
|
+
disabled: M.value,
|
|
359
373
|
required: t.required,
|
|
360
374
|
size: t.size,
|
|
361
375
|
autocomplete: t.autocomplete,
|
|
362
376
|
multiple: t.multiple,
|
|
363
|
-
"aria-invalid":
|
|
364
|
-
"aria-describedby": !h.value && n.value ?
|
|
365
|
-
"aria-errormessage": h.value ?
|
|
366
|
-
})), { getOptionLabel:
|
|
367
|
-
function
|
|
368
|
-
return typeof
|
|
377
|
+
"aria-invalid": te.value,
|
|
378
|
+
"aria-describedby": !h.value && n.value ? P.value : void 0,
|
|
379
|
+
"aria-errormessage": h.value ? P.value : void 0
|
|
380
|
+
})), { getOptionLabel: oe, getOptionValue: se } = Oe(t);
|
|
381
|
+
function le(u) {
|
|
382
|
+
return typeof u == "string" || u.disabled === void 0 ? v.value : u.disabled;
|
|
369
383
|
}
|
|
370
|
-
const
|
|
384
|
+
const N = i({
|
|
371
385
|
get: () => t.modelValue,
|
|
372
|
-
set: (
|
|
373
|
-
r("update:modelValue",
|
|
386
|
+
set: (u) => {
|
|
387
|
+
Array.isArray(u) && (u = u.filter((w) => w !== void 0)), r("update:modelValue", u);
|
|
374
388
|
}
|
|
375
389
|
});
|
|
376
|
-
return (
|
|
377
|
-
class:
|
|
390
|
+
return (u, w) => (y(), B("div", {
|
|
391
|
+
class: de(c(re))
|
|
378
392
|
}, [
|
|
379
|
-
|
|
393
|
+
u.label ? (y(), B("label", {
|
|
380
394
|
key: 0,
|
|
381
|
-
for:
|
|
382
|
-
},
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
395
|
+
for: c(I)
|
|
396
|
+
}, E(u.label), 9, Xe)) : O("", !0),
|
|
397
|
+
T("div", Qe, [
|
|
398
|
+
q(u.$slots, "before", {}, () => [
|
|
399
|
+
c(z) ? (y(), R(G, L(D({ key: 0 }, c(S))), null, 16)) : O("", !0)
|
|
386
400
|
]),
|
|
387
|
-
|
|
388
|
-
id:
|
|
401
|
+
fe(T("select", D({
|
|
402
|
+
id: c(I),
|
|
389
403
|
ref_key: "select",
|
|
390
|
-
ref:
|
|
391
|
-
"onUpdate:modelValue":
|
|
392
|
-
},
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
disabled:
|
|
397
|
-
|
|
398
|
-
},
|
|
399
|
-
|
|
400
|
-
|
|
404
|
+
ref: l,
|
|
405
|
+
"onUpdate:modelValue": w[0] || (w[0] = (A) => ve(N) ? N.value = A : null)
|
|
406
|
+
}, c(ne)), [
|
|
407
|
+
u.placeholder ? (y(), B("option", {
|
|
408
|
+
key: 0,
|
|
409
|
+
value: void 0,
|
|
410
|
+
disabled: !u.unselectable,
|
|
411
|
+
hidden: !u.unselectable
|
|
412
|
+
}, E(u.placeholder), 9, Ye)) : O("", !0),
|
|
413
|
+
(y(!0), B(pe, null, me(u.options, (A, ie) => (y(), B("option", {
|
|
414
|
+
key: ie,
|
|
415
|
+
disabled: le(A),
|
|
416
|
+
value: c(se)(A)
|
|
417
|
+
}, E(c(oe)(A)), 9, xe))), 128))
|
|
418
|
+
], 16, We), [
|
|
419
|
+
[ge, c(N)]
|
|
401
420
|
]),
|
|
402
|
-
|
|
403
|
-
|
|
421
|
+
q(u.$slots, "after", {}, () => [
|
|
422
|
+
c(H) ? (y(), R(G, L(D({ key: 0 }, c(S))), null, 16)) : O("", !0)
|
|
404
423
|
])
|
|
405
424
|
]),
|
|
406
|
-
|
|
407
|
-
id:
|
|
425
|
+
he(c(d), {
|
|
426
|
+
id: c(P),
|
|
408
427
|
class: "vv-select__hint"
|
|
409
428
|
}, null, 8, ["id"])
|
|
410
429
|
], 2));
|
|
411
430
|
}
|
|
412
431
|
});
|
|
413
432
|
export {
|
|
414
|
-
|
|
433
|
+
st as default
|
|
415
434
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(e,
|
|
1
|
+
(function(e,P){typeof exports=="object"&&typeof module<"u"?module.exports=P(require("vue"),require("nanoid"),require("@vueuse/core"),require("@iconify/vue")):typeof define=="function"&&define.amd?define(["vue","nanoid","@vueuse/core","@iconify/vue"],P):(e=typeof globalThis<"u"?globalThis:e||self,e.VvSelect=P(e.vue,e.nanoid,e.core,e.vue$1))})(this,function(e,P,w,S){"use strict";function E(t,r){if(t&&Object.keys(t).length&&r){if(r.indexOf(".")===-1)return t[r];{const n=r.split(".");let a=t;for(let l=0,u=n.length;l<u;++l){if(t==null)return null;a=a[n[l]]}return a}}else return null}function $(t){return(r=>r==null||r===""||Array.isArray(r)&&r.length===0||!(r instanceof Date)&&typeof r=="object"&&Object.keys(r).length===0)(e.unref(t))}function H(t){return typeof t=="string"||t instanceof String}function _(t){var r,n;if(t)return(n=(r=t.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:n.toLowerCase()}function D(t,r){const n={[`${t}`]:!0};return{bemCssClasses:e.computed(()=>Object.keys(r).reduce((l,u)=>{const o=e.unref(r[u])||!1;if(!o)return l;if(u==="modifiers"){const y=Array.isArray(o)?o:o.split(" ");return{...l,...y.reduce((p,f)=>({...p,[`${t}--${_(f)}`]:!0}),{})}}else return{...l,[`${t}--${_(u)}`]:o}},n)||{})}}function M(t,r,n){const a=e.computed(()=>!!(t!=null&&t.value&&r.value==="left"||n!=null&&n.iconLeft)),l=e.computed(()=>!!(t!=null&&t.value&&r.value==="right"||n!=null&&n.iconRight)),u=e.computed(()=>!!(t!=null&&t.value&&r.value==="top"||n!=null&&n.iconTop)),o=e.computed(()=>!!(t!=null&&t.value&&r.value==="bottom"||n!=null&&n.iconBottom));return{hasIcon:e.computed(()=>typeof(t==null?void 0:t.value)=="string"?{name:t==null?void 0:t.value}:t==null?void 0:t.value),hasIconLeft:a,hasIconRight:l,hasIconTop:u,hasIconBottom:o}}function L(t){const{options:r,labelKey:n,valueKey:a}=e.toRefs(t);return{options:r,getOptionLabel:o=>typeof o!="object"&&o!==null?o:typeof n.value=="function"?n.value(o):o[n.value],getOptionValue:o=>typeof o!="object"&&o!==null?o:typeof a.value=="function"?a.value(o):o[a.value]}}function K(t,r){const{focused:n}=w.useFocus(t);return e.watch(n,a=>{r(a?"focus":"blur",e.unref(t))}),{focused:n}}const Z="ds",x={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]}},U={name:"VvIcon"},j=e.defineComponent({...U,props:x,setup(t){const r=t,n=e.ref(!0),{modifiers:a}=e.toRefs(r),l=e.inject(Z),{bemCssClasses:u}=D("vv-icon",{modifiers:a}),o=e.computed(()=>r.provider||(l==null?void 0:l.provider)),y=e.computed(()=>{const s=r.name??"",i=`@${o.value}:${r.prefix}:${r.name}`;return S.iconExists(s)?s:S.iconExists(i)?i:(l==null?void 0:l.iconsCollections.find(m=>{const d=`@${o.value}:${m.prefix}:${s}`;if(S.iconExists(d))return d}))||s});function p(s){let i=null;if(typeof window>"u"){const{JSDOM:h}=require("jsdom");i=new h().window}return(i?new i.DOMParser:new window.DOMParser).parseFromString(s,"text/html").querySelector("svg")}function f(s){const i=p(s),m=(i==null?void 0:i.innerHTML.trim())||"";i&&m&&S.addIcon(`@${o.value}:${r.prefix}:${r.name}`,{body:m,height:i.viewBox.baseVal.height,width:i.viewBox.baseVal.width})}return l&&(r.src&&!S.iconExists(`@${o.value}:${r.prefix}:${r.name}`)?(n.value=!1,l.fetchIcon(r.src).then(s=>{s&&(f(s),n.value=!0)}).catch(s=>{throw new Error(`During fetch icon: ${s==null?void 0:s.message}`)})):r.svg&&f(r.svg)),(s,i)=>n.value?(e.openBlock(),e.createBlock(e.unref(S.Icon),e.mergeProps({key:0,class:e.unref(u)},{inline:s.inline,width:s.width,height:s.height,horizontalFlip:s.horizontalFlip,verticalFlip:s.verticalFlip,flip:s.flip,rotate:s.rotate,color:s.color,onLoad:s.onLoad,icon:e.unref(y)}),null,16,["class"])):e.createCommentVNode("",!0)}});function C(t){return Array.isArray(t)?t.filter(r=>H(r)).join(" "):t}function G(t,r){const{invalid:n,valid:a,hint:l,loading:u}=r,{hintLabel:o,modelValue:y,valid:p,validLabel:f,invalid:s,invalidLabel:i,...m}=e.toRefs(t),d=E(m,"loading"),g=E(m,"loadingLabel"),h=e.computed(()=>s.value?!!(s.value&&n||i!=null&&i.value&&Array.isArray(i.value)&&i.value.length>0||i!=null&&i.value&&!$(i)):!1),v=e.computed(()=>!!(o&&o.value||l)),V=e.computed(()=>!!(f&&f.value||a)),B=e.computed(()=>!!(d!=null&&d.value&&u||d!=null&&d.value&&(g!=null&&g.value))),I=e.computed(()=>v.value||V.value||h.value||B.value);return{hasInvalid:h,hasHint:v,hasValid:V,hasLoading:B,HintSlot:{name:"HintSlot",props:{params:{type:Object,default:()=>({})}},setup(A){const F=e.computed(()=>{const b=w.toReactive({hintLabel:o,modelValue:y,valid:p,validLabel:f,invalid:s,invalidLabel:i,loading:d,loadingLabel:g,...A.params});return s!=null&&s.value?(n==null?void 0:n(b))||C(i==null?void 0:i.value)||(o==null?void 0:o.value):p!=null&&p.value?(a==null?void 0:a(b))||C(f==null?void 0:f.value)||(o==null?void 0:o.value):d!=null&&d.value?(u==null?void 0:u(b))||C(g==null?void 0:g.value)||(o==null?void 0:o.value):(l==null?void 0:l(b))||C(o==null?void 0:o.value)||(o==null?void 0:o.value)});return{isVisible:I,hasInvalid:h,hasValid:V,hintContent:F}},render(){if(this.isVisible)return e.h("small",{role:this.hasInvalid||this.hasValid?"alert":void 0},this.hintContent)}}}}const J={valid:Boolean,validLabel:[String,Array]},X={invalid:Boolean,invalidLabel:[String,Array]},Q={loading:Boolean,loadingLabel:String},W={disabled:Boolean},Y={readonly:Boolean},ee={modifiers:[String,Array]},te={hintLabel:{type:String,default:""}},ne={options:{type:Array,default:()=>[]},labelKey:{type:[String,Function],default:"label"},valueKey:{type:[String,Function],default:"value"}},R={LEFT:"left",RIGHT:"right"},re={icon:{type:[String,Object]},iconPosition:{type:String,validation:t=>Object.values(R).includes(t),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}},...J,...X,...te,...Q,...W,...Y,...ee,...ne,...re,...{floating:Boolean},...{unselectable:{type:Boolean,default:!0}},multiple:Boolean,required:Boolean,size:[String,Number],modelValue:{type:[String,Number,Boolean,Object,Array],default:void 0},label:String,placeholder:String},se=["update:modelValue","focus","blur"],ie=["for"],le={class:"vv-select__wrapper"},ae=["id"],ce=["disabled","hidden"],ue=["disabled","value"],de={name:"VvSelect"};return e.defineComponent({...de,props:oe,emits:se,setup(t,{emit:r}){const n=t,a=e.useSlots(),l=e.ref(),{HintSlot:u,hasHint:o,hasInvalid:y}=G(n,a),{modifiers:p,disabled:f,readonly:s,loading:i,icon:m,iconPosition:d,invalid:g,valid:h,floating:v,multiple:V}=e.toRefs(n),B=e.computed(()=>String(n.id||P.nanoid())),I=e.computed(()=>`${B.value}-hint`),{focused:A}=K(l,r),F=w.useElementVisibility(l);e.watch(F,c=>{c&&n.autofocus&&(A.value=!0)});const{hasIcon:b,hasIconLeft:q,hasIconRight:z}=M(m,d),fe=e.computed(()=>!$(n.modelValue)),T=e.computed(()=>n.disabled||n.readonly),pe=e.computed(()=>T.value?-1:n.tabindex),me=e.computed(()=>{if(n.invalid===!0)return!0;if(n.valid===!0)return!1}),{bemCssClasses:ge}=D("vv-select",{modifiers:p,valid:h,invalid:g,loading:i,disabled:f,readonly:s,iconLeft:q,iconRight:z,dirty:fe,focus:A,floating:v,multiple:V}),ye=e.computed(()=>({name:n.name,tabindex:pe.value,disabled:T.value,required:n.required,size:n.size,autocomplete:n.autocomplete,multiple:n.multiple,"aria-invalid":me.value,"aria-describedby":!y.value&&o.value?I.value:void 0,"aria-errormessage":y.value?I.value:void 0})),{getOptionLabel:he,getOptionValue:be}=L(n);function Se(c){return typeof c=="string"||c.disabled===void 0?f.value:c.disabled}const N=e.computed({get:()=>n.modelValue,set:c=>{Array.isArray(c)&&(c=c.filter(O=>O!==void 0)),r("update:modelValue",c)}});return(c,O)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(e.unref(ge))},[c.label?(e.openBlock(),e.createElementBlock("label",{key:0,for:e.unref(B)},e.toDisplayString(c.label),9,ie)):e.createCommentVNode("",!0),e.createElementVNode("div",le,[e.renderSlot(c.$slots,"before",{},()=>[e.unref(q)?(e.openBlock(),e.createBlock(j,e.normalizeProps(e.mergeProps({key:0},e.unref(b))),null,16)):e.createCommentVNode("",!0)]),e.withDirectives(e.createElementVNode("select",e.mergeProps({id:e.unref(B),ref_key:"select",ref:l,"onUpdate:modelValue":O[0]||(O[0]=k=>e.isRef(N)?N.value=k:null)},e.unref(ye)),[c.placeholder?(e.openBlock(),e.createElementBlock("option",{key:0,value:void 0,disabled:!c.unselectable,hidden:!c.unselectable},e.toDisplayString(c.placeholder),9,ce)):e.createCommentVNode("",!0),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(c.options,(k,Be)=>(e.openBlock(),e.createElementBlock("option",{key:Be,disabled:Se(k),value:e.unref(be)(k)},e.toDisplayString(e.unref(he)(k)),9,ue))),128))],16,ae),[[e.vModelSelect,e.unref(N)]]),e.renderSlot(c.$slots,"after",{},()=>[e.unref(z)?(e.openBlock(),e.createBlock(j,e.normalizeProps(e.mergeProps({key:0},e.unref(b))),null,16)):e.createCommentVNode("",!0)])]),e.createVNode(e.unref(u),{id:e.unref(I),class:"vv-select__hint"},null,8,["id"])],2))}})});
|