@weni/unnnic-system 3.36.0 → 3.36.1-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/MultiSelect/MultiSelectOption.css +1 -1
- package/dist/components/MultiSelect/MultiSelectOption.vue.mjs +2 -2
- package/dist/components/MultiSelect/MultiSelectOption.vue2.mjs +41 -15
- package/dist/components/MultiSelect/MultiSelectTreeOptions.css +1 -0
- package/dist/components/MultiSelect/MultiSelectTreeOptions.vue.mjs +7 -0
- package/dist/components/MultiSelect/MultiSelectTreeOptions.vue2.mjs +50 -0
- package/dist/components/MultiSelect/index.css +1 -1
- package/dist/components/MultiSelect/index.vue.mjs +2 -2
- package/dist/components/MultiSelect/index.vue2.mjs +126 -114
- package/dist/composables/useMultiSelectRows.mjs +74 -0
- package/dist/composables/useMultiSelectSelection.mjs +44 -0
- package/dist/composables/useSelectBase.mjs +44 -39
- package/dist/composables/useSelectKeyboard.mjs +70 -35
- package/dist/composables/useTreeExpansion.mjs +24 -0
- package/dist/lib/tree-selection.mjs +66 -0
- package/dist/locales/en.json.mjs +9 -5
- package/dist/style.css +4 -2
- package/dist/unnnic.umd.js +19 -19
- package/package.json +2 -2
- package/src/components/MultiSelect/MultiSelectOption.vue +66 -3
- package/src/components/MultiSelect/MultiSelectTreeOptions.vue +73 -0
- package/src/components/MultiSelect/__tests__/MultiSelect.spec.js +556 -0
- package/src/components/MultiSelect/__tests__/MultiSelectOption.spec.js +55 -1
- package/src/components/MultiSelect/__tests__/__snapshots__/MultiSelectOption.spec.js.snap +5 -0
- package/src/components/MultiSelect/index.vue +57 -50
- package/src/components/Select/_select-shared.scss +8 -0
- package/src/components/Select/types.ts +1 -0
- package/src/composables/useMultiSelectRows.ts +121 -0
- package/src/composables/useMultiSelectSelection.ts +97 -0
- package/src/composables/useSelectBase.ts +40 -16
- package/src/composables/useSelectKeyboard.ts +92 -18
- package/src/composables/useTreeExpansion.ts +44 -0
- package/src/lib/__tests__/tree-selection.spec.ts +141 -0
- package/src/lib/tree-selection.ts +156 -0
- package/src/locales/en.json +3 -1
- package/src/stories/MultiSelect.stories.js +62 -1
|
@@ -1,53 +1,88 @@
|
|
|
1
|
-
import { ref as
|
|
2
|
-
const
|
|
3
|
-
function
|
|
4
|
-
const
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
import { ref as E, watch as w, nextTick as y, onBeforeUnmount as K, toValue as T } from "vue";
|
|
2
|
+
const I = "data-option-index";
|
|
3
|
+
function v(u) {
|
|
4
|
+
const i = u.target;
|
|
5
|
+
return i instanceof HTMLElement ? i.closest('input, textarea, button, [contenteditable="true"]') ? !0 : i.isContentEditable : !1;
|
|
6
|
+
}
|
|
7
|
+
function O(u, i, m) {
|
|
8
|
+
const {
|
|
9
|
+
closeOnSelect: D = !0,
|
|
10
|
+
closePopover: b,
|
|
11
|
+
openPopoverRef: a,
|
|
12
|
+
onArrowRight: k,
|
|
13
|
+
onArrowLeft: A,
|
|
14
|
+
toggleOnSpace: g = !1
|
|
15
|
+
} = m, n = E(-1);
|
|
16
|
+
function l(e, t = "smooth", f = "center") {
|
|
17
|
+
y(() => {
|
|
18
|
+
var r;
|
|
8
19
|
const o = document.querySelector(
|
|
9
|
-
`[${
|
|
20
|
+
`[${I}="${e}"]`
|
|
10
21
|
);
|
|
11
|
-
(
|
|
22
|
+
(r = o == null ? void 0 : o.scrollIntoView) == null || r.call(o, { behavior: t, block: f });
|
|
12
23
|
});
|
|
13
24
|
}
|
|
14
|
-
function
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
25
|
+
function c() {
|
|
26
|
+
const t = u()[n.value];
|
|
27
|
+
n.value < 0 || !t || t.disabled || (i(t), D && b());
|
|
28
|
+
}
|
|
29
|
+
function s(e) {
|
|
30
|
+
const t = u();
|
|
18
31
|
if (e.key === "ArrowUp") {
|
|
19
|
-
if (n.value <= 0) return;
|
|
20
|
-
n.value--,
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
32
|
+
if (e.preventDefault(), n.value <= 0) return;
|
|
33
|
+
n.value--, l(n.value);
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
if (e.key === "ArrowDown") {
|
|
37
|
+
if (e.preventDefault(), n.value >= t.length - 1) return;
|
|
38
|
+
n.value++, l(n.value);
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
if (e.key === "Enter") {
|
|
42
|
+
e.preventDefault(), c();
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
const f = e.key === "ArrowRight" ? k : e.key === "ArrowLeft" ? A : void 0;
|
|
46
|
+
if (f) {
|
|
47
|
+
if (v(e)) return;
|
|
48
|
+
e.preventDefault();
|
|
25
49
|
const o = t[n.value];
|
|
26
|
-
if (o
|
|
27
|
-
|
|
50
|
+
if (!o) return;
|
|
51
|
+
const r = f(n.value, o);
|
|
52
|
+
typeof r == "number" && r >= 0 && (n.value = r, l(r));
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
if (e.key === " " && T(g)) {
|
|
56
|
+
if (v(e)) return;
|
|
57
|
+
e.preventDefault(), c();
|
|
28
58
|
}
|
|
29
59
|
}
|
|
30
|
-
function
|
|
31
|
-
|
|
60
|
+
function d(e) {
|
|
61
|
+
a.value && s(e);
|
|
32
62
|
}
|
|
33
|
-
function
|
|
34
|
-
document.addEventListener("keydown",
|
|
63
|
+
function h() {
|
|
64
|
+
document.addEventListener("keydown", d);
|
|
35
65
|
}
|
|
36
|
-
function
|
|
37
|
-
document.removeEventListener("keydown",
|
|
66
|
+
function p() {
|
|
67
|
+
document.removeEventListener("keydown", d);
|
|
38
68
|
}
|
|
39
|
-
function
|
|
40
|
-
|
|
41
|
-
e ?
|
|
42
|
-
}),
|
|
69
|
+
function x() {
|
|
70
|
+
w(a, (e) => {
|
|
71
|
+
e ? y(h) : p();
|
|
72
|
+
}), w(
|
|
73
|
+
() => u().length,
|
|
74
|
+
(e) => {
|
|
75
|
+
n.value >= e && (n.value = e - 1);
|
|
76
|
+
}
|
|
77
|
+
), K(p);
|
|
43
78
|
}
|
|
44
79
|
return {
|
|
45
80
|
focusedOptionIndex: n,
|
|
46
|
-
scrollToOption:
|
|
47
|
-
handleKeyDown:
|
|
48
|
-
setupKeydownBinding:
|
|
81
|
+
scrollToOption: l,
|
|
82
|
+
handleKeyDown: s,
|
|
83
|
+
setupKeydownBinding: x
|
|
49
84
|
};
|
|
50
85
|
}
|
|
51
86
|
export {
|
|
52
|
-
|
|
87
|
+
O as useSelectKeyboard
|
|
53
88
|
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { ref as d, watch as i, toValue as a } from "vue";
|
|
2
|
+
function h(t) {
|
|
3
|
+
const s = d(/* @__PURE__ */ new Set()), n = d(/* @__PURE__ */ new Set());
|
|
4
|
+
i(
|
|
5
|
+
() => a(t),
|
|
6
|
+
() => {
|
|
7
|
+
n.value = /* @__PURE__ */ new Set();
|
|
8
|
+
}
|
|
9
|
+
);
|
|
10
|
+
function u(e) {
|
|
11
|
+
return a(t) ? !n.value.has(e) : s.value.has(e);
|
|
12
|
+
}
|
|
13
|
+
function f(e, l = !u(e)) {
|
|
14
|
+
const r = a(t), c = r ? n : s, p = r ? !l : l, o = new Set(c.value);
|
|
15
|
+
p ? o.add(e) : o.delete(e), c.value = o;
|
|
16
|
+
}
|
|
17
|
+
function w() {
|
|
18
|
+
s.value = /* @__PURE__ */ new Set(), n.value = /* @__PURE__ */ new Set();
|
|
19
|
+
}
|
|
20
|
+
return { isExpanded: u, setExpanded: f, reset: w };
|
|
21
|
+
}
|
|
22
|
+
export {
|
|
23
|
+
h as useTreeExpansion
|
|
24
|
+
};
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
function l(e) {
|
|
2
|
+
return Array.isArray(e.children) ? e.children : [];
|
|
3
|
+
}
|
|
4
|
+
function a(e) {
|
|
5
|
+
return l(e).length > 0;
|
|
6
|
+
}
|
|
7
|
+
function y(e) {
|
|
8
|
+
return e.some(a);
|
|
9
|
+
}
|
|
10
|
+
function C(e) {
|
|
11
|
+
return e.flatMap((t) => [t, ...l(t)]);
|
|
12
|
+
}
|
|
13
|
+
function o(e) {
|
|
14
|
+
const t = l(e), n = t.filter((i) => !i.disabled);
|
|
15
|
+
return n.length ? n : t;
|
|
16
|
+
}
|
|
17
|
+
function b(e, t) {
|
|
18
|
+
return e.filter(
|
|
19
|
+
(n) => t(n) || l(n).some(t)
|
|
20
|
+
);
|
|
21
|
+
}
|
|
22
|
+
function S(e, t) {
|
|
23
|
+
const n = l(e);
|
|
24
|
+
return t(e) ? n : n.filter(t);
|
|
25
|
+
}
|
|
26
|
+
function p(e, t, n) {
|
|
27
|
+
const i = new Set(t), r = e.filter((s) => i.has(n(s))).flatMap(l).filter((s) => !s.disabled && !i.has(n(s))).map(n);
|
|
28
|
+
return [...t, ...r];
|
|
29
|
+
}
|
|
30
|
+
function g(e, t, n) {
|
|
31
|
+
const i = (s) => t.has(n(s)), r = l(e);
|
|
32
|
+
return r.length ? o(e).every(i) ? !0 : r.some(i) ? "less" : !1 : i(e);
|
|
33
|
+
}
|
|
34
|
+
function O(e, t, n) {
|
|
35
|
+
const i = n(t);
|
|
36
|
+
return e.find(
|
|
37
|
+
(r) => l(r).some((s) => n(s) === i)
|
|
38
|
+
);
|
|
39
|
+
}
|
|
40
|
+
function m(e, t, n) {
|
|
41
|
+
const i = n(e), r = new Set(t), s = t.filter((c) => c !== i);
|
|
42
|
+
return o(e).every(
|
|
43
|
+
(c) => r.has(n(c))
|
|
44
|
+
) ? [...s, i] : s;
|
|
45
|
+
}
|
|
46
|
+
function w(e, t, n, i, r) {
|
|
47
|
+
const s = a(n), f = s ? n : O(e, n, r), h = (s ? l(n).filter((d) => !d.disabled) : [n]).map(r), u = t.filter((d) => !h.includes(d));
|
|
48
|
+
return i && u.push(...h), f ? m(f, u, r) : u;
|
|
49
|
+
}
|
|
50
|
+
function x(e, t, n) {
|
|
51
|
+
const i = (r) => t.has(n(r));
|
|
52
|
+
return e.flatMap((r) => a(r) ? g(r, t, n) === !0 ? [r] : l(r).filter(i) : i(r) ? [r] : []);
|
|
53
|
+
}
|
|
54
|
+
export {
|
|
55
|
+
b as filterTreeOptions,
|
|
56
|
+
C as flattenTreeOptions,
|
|
57
|
+
g as getCheckState,
|
|
58
|
+
x as getDisplayOptions,
|
|
59
|
+
o as getDrivingChildren,
|
|
60
|
+
l as getOptionChildren,
|
|
61
|
+
S as getVisibleChildren,
|
|
62
|
+
a as hasOptionChildren,
|
|
63
|
+
y as isTreeOptions,
|
|
64
|
+
w as toggleOptionValue,
|
|
65
|
+
p as withImpliedChildren
|
|
66
|
+
};
|
package/dist/locales/en.json.mjs
CHANGED
|
@@ -40,7 +40,7 @@ const e = {
|
|
|
40
40
|
flags: "Flags",
|
|
41
41
|
custom: "Custom"
|
|
42
42
|
}
|
|
43
|
-
}, i = "
|
|
43
|
+
}, i = "Collapse", l = "Expand", d = "Search", n = "No results found", u = {
|
|
44
44
|
upload_area: e,
|
|
45
45
|
import_card: t,
|
|
46
46
|
audio_recorder: o,
|
|
@@ -48,18 +48,22 @@ const e = {
|
|
|
48
48
|
chats_contact: a,
|
|
49
49
|
data_table: r,
|
|
50
50
|
emoji_picker: c,
|
|
51
|
-
|
|
52
|
-
|
|
51
|
+
collapse: i,
|
|
52
|
+
expand: l,
|
|
53
|
+
search: d,
|
|
54
|
+
without_results: n
|
|
53
55
|
};
|
|
54
56
|
export {
|
|
55
57
|
o as audio_recorder,
|
|
56
58
|
s as chat_message,
|
|
57
59
|
a as chats_contact,
|
|
60
|
+
i as collapse,
|
|
58
61
|
r as data_table,
|
|
59
62
|
u as default,
|
|
60
63
|
c as emoji_picker,
|
|
64
|
+
l as expand,
|
|
61
65
|
t as import_card,
|
|
62
|
-
|
|
66
|
+
d as search,
|
|
63
67
|
e as upload_area,
|
|
64
|
-
|
|
68
|
+
n as without_results
|
|
65
69
|
};
|