@solibo/solibo-ui 0.3.39 → 0.3.40
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/assets/index.css +1 -1
- package/dist/assets/index20.css +1 -1
- package/dist/assets/index22.css +1 -1
- package/dist/assets/index41.css +1 -1
- package/dist/components/_collapsible/index.cjs +1 -1
- package/dist/components/_collapsible/index.cjs.map +1 -1
- package/dist/components/_collapsible/index.js +19 -15
- package/dist/components/_collapsible/index.js.map +1 -1
- package/dist/components/_dropdown/index.cjs +1 -1
- package/dist/components/_dropdown/index.cjs.map +1 -1
- package/dist/components/_dropdown/index.js +149 -136
- package/dist/components/_dropdown/index.js.map +1 -1
- package/dist/components/checkbox/index.cjs +1 -1
- package/dist/components/checkbox/index.js +1 -1
- package/dist/components/icon/index.cjs +1 -1
- package/dist/components/icon/index.js +1 -1
- package/dist/components/input/index.cjs +1 -1
- package/dist/components/input/index.js +2 -2
- package/dist/components/nav/index.cjs +1 -1
- package/dist/components/nav/index.js +1 -1
- package/dist/components/select/index.cjs +1 -1
- package/dist/components/select/index.js +3 -2
- package/dist/components/select/index.js.map +1 -1
- package/dist/components/table/index.cjs +1 -1
- package/dist/components/table/index.cjs.map +1 -1
- package/dist/components/table/index.js +10 -10
- package/dist/components/table/index.js.map +1 -1
- package/dist/components/textarea/index.cjs +1 -1
- package/dist/components/textarea/index.js +1 -1
- package/dist/{icons-CMoejLkL.cjs → icons-C_cX1FYp.cjs} +2 -2
- package/dist/{icons-CMoejLkL.cjs.map → icons-C_cX1FYp.cjs.map} +1 -1
- package/dist/{icons-BqQRUUWn.js → icons-DfmpRbxE.js} +2 -2
- package/dist/{icons-BqQRUUWn.js.map → icons-DfmpRbxE.js.map} +1 -1
- package/dist/{index-xRmXVWAN.js → index-C_OgUYu-.js} +25 -18
- package/dist/index-C_OgUYu-.js.map +1 -0
- package/dist/index-CfK1ATlt.cjs +2 -0
- package/dist/index-CfK1ATlt.cjs.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.js +1 -1
- package/dist/utils-BFlnRYx7.js +34 -0
- package/dist/utils-BFlnRYx7.js.map +1 -0
- package/dist/utils-DqVa4K58.cjs +2 -0
- package/dist/utils-DqVa4K58.cjs.map +1 -0
- package/package.json +1 -1
- package/dist/index-HNd9cEc6.cjs +0 -2
- package/dist/index-HNd9cEc6.cjs.map +0 -1
- package/dist/index-xRmXVWAN.js.map +0 -1
- package/dist/utils-DXIJVVzz.js +0 -14
- package/dist/utils-DXIJVVzz.js.map +0 -1
- package/dist/utils-D_TJ8wDc.cjs +0 -2
- package/dist/utils-D_TJ8wDc.cjs.map +0 -1
|
@@ -1,175 +1,188 @@
|
|
|
1
|
-
import { jsxs as w, jsx as
|
|
2
|
-
import { t as
|
|
3
|
-
import
|
|
4
|
-
import { Button as
|
|
5
|
-
import { i as
|
|
6
|
-
import { Input as
|
|
7
|
-
import { i as
|
|
8
|
-
import { List as
|
|
9
|
-
import { s as
|
|
10
|
-
import
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
1
|
+
import { jsxs as w, jsx as i, Fragment as Z } from "react/jsx-runtime";
|
|
2
|
+
import { t as C } from "../../classix-DG18itHa.js";
|
|
3
|
+
import ee, { useRef as _, useState as V, useEffect as O, Children as te, isValidElement as g } from "react";
|
|
4
|
+
import { Button as A } from "../button/index.js";
|
|
5
|
+
import { i as re } from "../../icons-DfmpRbxE.js";
|
|
6
|
+
import { Input as ne } from "../input/index.js";
|
|
7
|
+
import { i as oe } from "../../styles.module-C_Z8FrR5.js";
|
|
8
|
+
import { List as le } from "../list/index.js";
|
|
9
|
+
import { s as se, S as ie } from "../../index-C_OgUYu-.js";
|
|
10
|
+
import { r as G } from "../../utils-BFlnRYx7.js";
|
|
11
|
+
import '../../assets/index22.css';const ae = "_dropdown_k2w7p_1", ce = "_empty_k2w7p_4", pe = "_group_k2w7p_5", ue = "_placeholder_k2w7p_6", de = "_filter_k2w7p_14", fe = "_native_k2w7p_25", me = "_option_k2w7p_35", he = "_options_k2w7p_57", ge = "_panel_k2w7p_64", _e = "_selected_k2w7p_85", we = "_text_k2w7p_89", ve = "_trigger_k2w7p_97", ye = "_minimal_k2w7p_113", s = {
|
|
12
|
+
dropdown: ae,
|
|
13
|
+
empty: ce,
|
|
14
|
+
group: pe,
|
|
15
|
+
placeholder: ue,
|
|
16
|
+
filter: de,
|
|
17
|
+
native: fe,
|
|
18
|
+
option: me,
|
|
19
|
+
options: he,
|
|
20
|
+
panel: ge,
|
|
21
|
+
selected: _e,
|
|
22
|
+
text: we,
|
|
23
|
+
trigger: ve,
|
|
24
|
+
minimal: ye
|
|
24
25
|
};
|
|
25
|
-
function
|
|
26
|
-
return
|
|
26
|
+
function K(e, n) {
|
|
27
|
+
return {
|
|
28
|
+
"--icon-svg": re(e).replace("currentColor", n)
|
|
29
|
+
};
|
|
27
30
|
}
|
|
28
|
-
function
|
|
29
|
-
return
|
|
31
|
+
function P(e) {
|
|
32
|
+
return typeof e == "string" || typeof e == "number" ? String(e) : Array.isArray(e) ? e.map(P).join(" ") : g(e) ? P(e.props.children) : "";
|
|
30
33
|
}
|
|
31
|
-
function
|
|
32
|
-
return
|
|
34
|
+
function be(e) {
|
|
35
|
+
return g(e) && e.type === "option";
|
|
33
36
|
}
|
|
34
|
-
function Se(
|
|
35
|
-
return
|
|
37
|
+
function Se(e) {
|
|
38
|
+
return g(e) && e.type === "optgroup";
|
|
36
39
|
}
|
|
37
|
-
function
|
|
38
|
-
return
|
|
40
|
+
function xe(e) {
|
|
41
|
+
return g(e) && e.type === ee.Fragment;
|
|
39
42
|
}
|
|
40
|
-
function
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
43
|
+
function ke(e) {
|
|
44
|
+
return g(e) && e.type === ie;
|
|
45
|
+
}
|
|
46
|
+
function $(e, n, o = !1) {
|
|
47
|
+
const l = [];
|
|
48
|
+
return te.forEach(e, (t) => {
|
|
49
|
+
if (xe(t)) {
|
|
50
|
+
l.push(...$(t.props.children, n, o));
|
|
45
51
|
return;
|
|
46
52
|
}
|
|
47
|
-
if (be(
|
|
48
|
-
const
|
|
49
|
-
|
|
50
|
-
disabled:
|
|
51
|
-
groupLabel:
|
|
52
|
-
hidden: !!
|
|
53
|
-
isPlaceholder: !!(
|
|
54
|
-
label:
|
|
55
|
-
selected: !!
|
|
56
|
-
text:
|
|
57
|
-
value:
|
|
53
|
+
if (be(t)) {
|
|
54
|
+
const p = P(t.props.children).trim(), u = t.props.value != null ? String(t.props.value) : p;
|
|
55
|
+
l.push({
|
|
56
|
+
disabled: o || !!t.props.disabled,
|
|
57
|
+
groupLabel: n,
|
|
58
|
+
hidden: !!t.props.hidden,
|
|
59
|
+
isPlaceholder: !!(t.props.hidden && u === ""),
|
|
60
|
+
label: t.props.children,
|
|
61
|
+
selected: !!t.props.selected,
|
|
62
|
+
text: p,
|
|
63
|
+
value: u
|
|
58
64
|
});
|
|
59
65
|
return;
|
|
60
66
|
}
|
|
61
|
-
|
|
62
|
-
}),
|
|
67
|
+
Se(t) && l.push(...$(t.props.children, t.props.label, o || !!t.props.disabled));
|
|
68
|
+
}), l;
|
|
63
69
|
}
|
|
64
|
-
function
|
|
65
|
-
const
|
|
66
|
-
if (!
|
|
70
|
+
function Ne(e) {
|
|
71
|
+
const n = e.trim();
|
|
72
|
+
if (!n)
|
|
67
73
|
return null;
|
|
68
|
-
const
|
|
69
|
-
return new RegExp(`^${
|
|
74
|
+
const l = [.../[*?]/.test(n) ? n : `*${n}*`].map((t) => t === "*" ? ".*" : t === "?" ? "." : t.replace(/[|\\{}()[\]^$+.,]/g, "\\$&")).join("");
|
|
75
|
+
return new RegExp(`^${l}$`, "i");
|
|
76
|
+
}
|
|
77
|
+
function Ee(e, n) {
|
|
78
|
+
const o = Ne(n), l = e.filter((t) => !t.hidden && !t.isPlaceholder);
|
|
79
|
+
return o ? l.filter((t) => o.test([t.groupLabel, t.text, t.value].filter(Boolean).join(" "))) : l;
|
|
70
80
|
}
|
|
71
|
-
function
|
|
72
|
-
|
|
73
|
-
if (l != null)
|
|
74
|
-
return String(l);
|
|
75
|
-
if (i != null)
|
|
76
|
-
return String(i);
|
|
77
|
-
const s = t.find((d) => d.selected);
|
|
78
|
-
return s ? s.value : ((n = t[0]) == null ? void 0 : n.value) ?? "";
|
|
81
|
+
function Ce(e, n) {
|
|
82
|
+
return e.find((o) => o.value === n) ?? e.find((o) => o.isPlaceholder) ?? e[0];
|
|
79
83
|
}
|
|
80
|
-
function
|
|
81
|
-
|
|
84
|
+
function Ve(e, n, o) {
|
|
85
|
+
var t;
|
|
86
|
+
if (n != null)
|
|
87
|
+
return String(n);
|
|
88
|
+
if (o != null)
|
|
89
|
+
return String(o);
|
|
90
|
+
const l = e.find((p) => p.selected);
|
|
91
|
+
return l ? l.value : ((t = e[0]) == null ? void 0 : t.value) ?? "";
|
|
92
|
+
}
|
|
93
|
+
function Oe(e) {
|
|
94
|
+
if (ke(e)) {
|
|
82
95
|
const {
|
|
83
|
-
children:
|
|
84
|
-
placeholder:
|
|
85
|
-
...
|
|
86
|
-
} =
|
|
96
|
+
children: n,
|
|
97
|
+
placeholder: o,
|
|
98
|
+
...l
|
|
99
|
+
} = e.props;
|
|
87
100
|
return {
|
|
88
|
-
children: /* @__PURE__ */ w(
|
|
89
|
-
|
|
90
|
-
|
|
101
|
+
children: /* @__PURE__ */ w(Z, { children: [
|
|
102
|
+
o && /* @__PURE__ */ i("option", { hidden: !0, value: "", children: o }),
|
|
103
|
+
n
|
|
91
104
|
] }),
|
|
92
|
-
props:
|
|
105
|
+
props: l
|
|
93
106
|
};
|
|
94
107
|
}
|
|
95
108
|
return {
|
|
96
|
-
children:
|
|
97
|
-
props:
|
|
109
|
+
children: e.props.children,
|
|
110
|
+
props: e.props
|
|
98
111
|
};
|
|
99
112
|
}
|
|
100
|
-
const
|
|
101
|
-
children:
|
|
102
|
-
className:
|
|
103
|
-
emptyLabel:
|
|
104
|
-
searchPlaceholder:
|
|
105
|
-
variant:
|
|
106
|
-
...
|
|
113
|
+
const Qe = ({
|
|
114
|
+
children: e,
|
|
115
|
+
className: n,
|
|
116
|
+
emptyLabel: o = "No matches found",
|
|
117
|
+
searchPlaceholder: l = "Filter",
|
|
118
|
+
variant: t = "default",
|
|
119
|
+
...p
|
|
107
120
|
}) => {
|
|
108
|
-
const
|
|
109
|
-
defaultValue:
|
|
110
|
-
onChange:
|
|
111
|
-
value:
|
|
112
|
-
...
|
|
113
|
-
} =
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
if (!u) {
|
|
124
|
-
k("");
|
|
121
|
+
const u = Oe(e), {
|
|
122
|
+
defaultValue: T,
|
|
123
|
+
onChange: v,
|
|
124
|
+
value: y,
|
|
125
|
+
...q
|
|
126
|
+
} = u.props, B = se(q), I = _(null), L = _(null), R = _(null), j = _(null), m = $(u.children), h = y != null, b = Ve(m, y, T), [S, x] = V(() => b), [c, k] = V(!1), [D, F] = V(""), N = h ? String(y) : S, W = {
|
|
127
|
+
default: G("--color-icon"),
|
|
128
|
+
white: G("--color-white", "white")
|
|
129
|
+
}, Q = t === "minimal" ? W.white : W.default, d = Ce(m, N), H = K("chevron", Q), J = K("search", Q), z = Ee(m, D);
|
|
130
|
+
O(() => {
|
|
131
|
+
!h && !m.some((r) => r.value === S) && x(b);
|
|
132
|
+
}, [b, S, h, m]), O(() => {
|
|
133
|
+
var r;
|
|
134
|
+
if (!c) {
|
|
135
|
+
F("");
|
|
125
136
|
return;
|
|
126
137
|
}
|
|
127
|
-
(
|
|
128
|
-
}, [
|
|
129
|
-
if (!
|
|
138
|
+
(r = j.current) == null || r.focus();
|
|
139
|
+
}, [c]), O(() => {
|
|
140
|
+
if (!c)
|
|
130
141
|
return;
|
|
131
|
-
const
|
|
132
|
-
var
|
|
133
|
-
(
|
|
142
|
+
const r = (a) => {
|
|
143
|
+
var f;
|
|
144
|
+
(f = L.current) != null && f.contains(a.target) || k(!1);
|
|
134
145
|
};
|
|
135
|
-
return document.addEventListener("mousedown",
|
|
136
|
-
document.removeEventListener("mousedown",
|
|
146
|
+
return document.addEventListener("mousedown", r), () => {
|
|
147
|
+
document.removeEventListener("mousedown", r);
|
|
137
148
|
};
|
|
138
|
-
}, [
|
|
139
|
-
const
|
|
140
|
-
h ||
|
|
141
|
-
},
|
|
142
|
-
var
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
149
|
+
}, [c]);
|
|
150
|
+
const U = (r) => {
|
|
151
|
+
h || x(r.target.value), v == null || v(r);
|
|
152
|
+
}, E = () => {
|
|
153
|
+
var r;
|
|
154
|
+
k(!1), (r = I.current) == null || r.focus();
|
|
155
|
+
}, X = (r) => {
|
|
156
|
+
var M;
|
|
157
|
+
h || x(r);
|
|
158
|
+
const a = R.current;
|
|
159
|
+
if (!a) {
|
|
160
|
+
E();
|
|
147
161
|
return;
|
|
148
162
|
}
|
|
149
|
-
const
|
|
150
|
-
|
|
163
|
+
const f = (M = Object.getOwnPropertyDescriptor(HTMLSelectElement.prototype, "value")) == null ? void 0 : M.set;
|
|
164
|
+
f == null || f.call(a, r), a.dispatchEvent(new Event("change", {
|
|
151
165
|
bubbles: !0
|
|
152
|
-
})),
|
|
153
|
-
},
|
|
154
|
-
|
|
155
|
-
e.key === "Escape" && (_(!1), (r = y.current) == null || r.focus());
|
|
166
|
+
})), E();
|
|
167
|
+
}, Y = (r) => {
|
|
168
|
+
r.key === "Escape" && E();
|
|
156
169
|
};
|
|
157
|
-
return /* @__PURE__ */ w("div", { className:
|
|
158
|
-
/* @__PURE__ */
|
|
159
|
-
/* @__PURE__ */
|
|
160
|
-
|
|
161
|
-
/* @__PURE__ */
|
|
162
|
-
/* @__PURE__ */
|
|
163
|
-
const
|
|
164
|
-
return /* @__PURE__ */
|
|
165
|
-
/* @__PURE__ */
|
|
166
|
-
|
|
167
|
-
] }) }, `${
|
|
168
|
-
}) : /* @__PURE__ */
|
|
170
|
+
return /* @__PURE__ */ w("div", { className: C(s.dropdown, t === "minimal" && s.minimal, n), onKeyDown: Y, ref: L, ...p, "data-component": "dropdown", children: [
|
|
171
|
+
/* @__PURE__ */ i("select", { ...B, "aria-hidden": "true", className: s.native, onChange: U, ref: R, tabIndex: -1, value: N, children: u.children }),
|
|
172
|
+
/* @__PURE__ */ i(A, { "aria-expanded": c, "aria-haspopup": "dialog", className: C(t === "default" && oe.input, s.trigger, (d == null ? void 0 : d.isPlaceholder) && s.placeholder), "data-open": c ? "true" : void 0, disabled: B.disabled, onClick: () => k((r) => !r), ref: I, style: H, variant: "minimal", children: /* @__PURE__ */ i("span", { className: s.text, children: (d == null ? void 0 : d.label) ?? "Select an option" }) }),
|
|
173
|
+
c && /* @__PURE__ */ w("div", { className: s.panel, children: [
|
|
174
|
+
/* @__PURE__ */ i(ne, { "aria-label": "Filter", className: s.filter, icon: "search", onChange: (r) => F(r.target.value), placeholder: l, ref: j, style: J, type: "search", value: D }),
|
|
175
|
+
/* @__PURE__ */ i(le, { "aria-label": "Dropdown", className: s.options, children: z.length > 0 ? z.map((r) => {
|
|
176
|
+
const a = r.value === N;
|
|
177
|
+
return /* @__PURE__ */ i("li", { "data-component": "dropdown", children: /* @__PURE__ */ w(A, { "aria-label": a ? `${r.text}, selected` : r.text, className: C(s.option, a && s.selected), disabled: r.disabled, onClick: () => X(r.value), variant: "minimal", children: [
|
|
178
|
+
/* @__PURE__ */ i("span", { className: s.text, children: r.label }),
|
|
179
|
+
r.groupLabel && /* @__PURE__ */ i("small", { className: s.group, children: r.groupLabel })
|
|
180
|
+
] }) }, `${r.groupLabel ?? "root"}-${r.value}`);
|
|
181
|
+
}) : /* @__PURE__ */ i("li", { className: s.empty, children: o }) })
|
|
169
182
|
] })
|
|
170
183
|
] });
|
|
171
184
|
};
|
|
172
185
|
export {
|
|
173
|
-
|
|
186
|
+
Qe as Dropdown
|
|
174
187
|
};
|
|
175
188
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../src/components/_dropdown/index.tsx"],"sourcesContent":["import cx from 'classix';\nimport React, { Children, isValidElement, useEffect, useMemo, useRef, useState } from 'react';\n\nimport { Button } from '@/components/button';\nimport { iconSVG } from '@/components/icon/icons';\nimport { Input } from '@/components/input';\nimport inputStyles from '@/components/input/styles.module.css';\nimport { List } from '@/components/list';\nimport { Select, type SelectProps } from '@/components/select';\nimport { sanitizeSelectProps } from '@/components/select/sanitizeSelectProps';\n\nimport styles from './styles.module.css';\n\ntype NativeSelectProps = Omit<React.ComponentPropsWithoutRef<'select'>, 'children' | 'multiple'> & {\n children: React.ReactNode;\n multiple?: false;\n};\n\ntype NativeSelectElement = React.ReactElement<NativeSelectProps, 'select'>;\ntype WrappedSelectElement = React.ReactElement<SelectProps, typeof Select>;\ntype DropdownSelectElement = NativeSelectElement | WrappedSelectElement;\n\ntype DropdownOption = {\n disabled: boolean;\n groupLabel?: string;\n hidden: boolean;\n isPlaceholder: boolean;\n label: React.ReactNode;\n selected: boolean;\n text: string;\n value: string;\n};\n\nexport type DropdownProps = Omit<React.ComponentPropsWithoutRef<'div'>, 'children'> & {\n children: DropdownSelectElement;\n emptyLabel?: string;\n searchPlaceholder?: string;\n variant?: 'default' | 'minimal';\n};\n\nfunction getNodeText(node: React.ReactNode): string {\n if (typeof node === 'string' || typeof node === 'number') {\n return String(node);\n }\n\n if (Array.isArray(node)) {\n return node.map(getNodeText).join(' ');\n }\n\n if (isValidElement<{ children?: React.ReactNode }>(node)) {\n return getNodeText(node.props.children);\n }\n\n return '';\n}\n\nfunction isOptionElement(\n node: React.ReactNode\n): node is React.ReactElement<React.ComponentPropsWithoutRef<'option'>, 'option'> {\n return isValidElement(node) && node.type === 'option';\n}\n\nfunction isOptGroupElement(\n node: React.ReactNode\n): node is React.ReactElement<React.ComponentPropsWithoutRef<'optgroup'>, 'optgroup'> {\n return isValidElement(node) && node.type === 'optgroup';\n}\n\nfunction isFragmentElement(\n node: React.ReactNode\n): node is React.ReactElement<{ children?: React.ReactNode }, typeof React.Fragment> {\n return isValidElement(node) && node.type === React.Fragment;\n}\n\nfunction isWrappedSelectElement(node: React.ReactNode): node is WrappedSelectElement {\n return isValidElement(node) && node.type === Select;\n}\n\nfunction extractOptions(\n children: React.ReactNode,\n groupLabel?: string,\n groupDisabled = false\n): DropdownOption[] {\n const options: DropdownOption[] = [];\n\n Children.forEach(children, (child) => {\n if (isFragmentElement(child)) {\n options.push(...extractOptions(child.props.children, groupLabel, groupDisabled));\n return;\n }\n\n if (isOptionElement(child)) {\n const text = getNodeText(child.props.children).trim();\n const value = child.props.value != null ? String(child.props.value) : text;\n\n options.push({\n disabled: groupDisabled || Boolean(child.props.disabled),\n groupLabel,\n hidden: Boolean(child.props.hidden),\n isPlaceholder: Boolean(child.props.hidden && value === ''),\n label: child.props.children,\n selected: Boolean(child.props.selected),\n text,\n value,\n });\n\n return;\n }\n\n if (isOptGroupElement(child)) {\n options.push(\n ...extractOptions(\n child.props.children,\n child.props.label,\n groupDisabled || Boolean(child.props.disabled)\n )\n );\n }\n });\n\n return options;\n}\n\nfunction buildWildcardMatcher(query: string) {\n const trimmedQuery = query.trim();\n\n if (!trimmedQuery) {\n return null;\n }\n\n const wildcardQuery = /[*?]/.test(trimmedQuery) ? trimmedQuery : `*${trimmedQuery}*`;\n const expression = [...wildcardQuery]\n .map((character) => {\n if (character === '*') {\n return '.*';\n }\n\n if (character === '?') {\n return '.';\n }\n\n return character.replace(/[|\\\\{}()[\\]^$+.,]/g, '\\\\$&');\n })\n .join('');\n\n return new RegExp(`^${expression}$`, 'i');\n}\n\nfunction getInitialValue(\n options: DropdownOption[],\n value?: NativeSelectProps['value'],\n defaultValue?: NativeSelectProps['defaultValue']\n) {\n if (value != null) {\n return String(value);\n }\n\n if (defaultValue != null) {\n return String(defaultValue);\n }\n\n const selectedOption = options.find((option) => option.selected);\n\n if (selectedOption) {\n return selectedOption.value;\n }\n\n return options[0]?.value ?? '';\n}\n\nfunction normalizeSelectElement(selectElement: DropdownSelectElement) {\n if (isWrappedSelectElement(selectElement)) {\n const { children, placeholder, ...props } = selectElement.props;\n\n return {\n children: (\n <>\n {placeholder && (\n <option\n hidden\n value=''\n >\n {placeholder}\n </option>\n )}\n {children}\n </>\n ),\n props,\n };\n }\n\n return {\n children: selectElement.props.children,\n props: selectElement.props,\n };\n}\n\nexport const Dropdown = ({\n children: selectElement,\n className,\n emptyLabel = 'No matches found',\n searchPlaceholder = 'Filter',\n variant = 'default',\n ...props\n}: DropdownProps) => {\n const normalizedSelect = normalizeSelectElement(selectElement);\n const { defaultValue, onChange, value, ...restSelectProps } = normalizedSelect.props;\n const selectProps = sanitizeSelectProps(restSelectProps);\n const buttonRef = useRef<HTMLButtonElement>(null);\n const containerRef = useRef<HTMLDivElement>(null);\n const nativeSelectRef = useRef<HTMLSelectElement>(null);\n const searchRef = useRef<HTMLInputElement>(null);\n const options = useMemo(\n () => extractOptions(normalizedSelect.children),\n [normalizedSelect.children]\n );\n const isControlled = value != null;\n const initialValue = useMemo(\n () => getInitialValue(options, value, defaultValue),\n [defaultValue, options, value]\n );\n const [internalValue, setInternalValue] = useState(() => initialValue);\n const [isOpen, setIsOpen] = useState(false);\n const [query, setQuery] = useState('');\n const selectedValue = isControlled ? String(value) : internalValue;\n\n const selectedOption = options.find((option) => option.value === selectedValue);\n const displayOption =\n selectedOption ?? options.find((option) => option.isPlaceholder) ?? options[0];\n const filterStyle = useMemo(\n () =>\n ({\n '--icon-svg': iconSVG('search').replace(\n 'currentColor',\n variant === 'minimal' ? 'rgb(255 255 255)' : 'rgb(0 0 0)'\n ),\n }) as React.CSSProperties,\n [variant]\n );\n const matcher = useMemo(() => buildWildcardMatcher(query), [query]);\n\n const filteredOptions = useMemo(() => {\n const selectableOptions = options.filter((option) => !option.hidden && !option.isPlaceholder);\n\n if (!matcher) {\n return selectableOptions;\n }\n\n return selectableOptions.filter((option) =>\n matcher.test([option.groupLabel, option.text, option.value].filter(Boolean).join(' '))\n );\n }, [matcher, options]);\n\n useEffect(() => {\n if (!isControlled && !options.some((option) => option.value === internalValue)) {\n setInternalValue(initialValue);\n }\n }, [initialValue, internalValue, isControlled, options]);\n\n useEffect(() => {\n if (!isOpen) {\n setQuery('');\n return;\n }\n\n searchRef.current?.focus();\n }, [isOpen]);\n\n useEffect(() => {\n if (!isOpen) {\n return;\n }\n\n const handlePointerDown = (event: MouseEvent) => {\n if (!containerRef.current?.contains(event.target as Node)) {\n setIsOpen(false);\n }\n };\n\n document.addEventListener('mousedown', handlePointerDown);\n\n return () => {\n document.removeEventListener('mousedown', handlePointerDown);\n };\n }, [isOpen]);\n\n const handleNativeChange = (event: React.ChangeEvent<HTMLSelectElement>) => {\n if (!isControlled) {\n setInternalValue(event.target.value);\n }\n\n onChange?.(event);\n };\n\n const commitValue = (nextValue: string) => {\n if (!isControlled) {\n setInternalValue(nextValue);\n }\n\n const nativeSelect = nativeSelectRef.current;\n\n if (!nativeSelect) {\n setIsOpen(false);\n buttonRef.current?.focus();\n return;\n }\n\n const valueSetter = Object.getOwnPropertyDescriptor(HTMLSelectElement.prototype, 'value')?.set;\n\n valueSetter?.call(nativeSelect, nextValue);\n nativeSelect.dispatchEvent(new Event('change', { bubbles: true }));\n setIsOpen(false);\n buttonRef.current?.focus();\n };\n\n const handleKeyDown = (event: React.KeyboardEvent<HTMLDivElement>) => {\n if (event.key === 'Escape') {\n setIsOpen(false);\n buttonRef.current?.focus();\n }\n };\n\n return (\n <div\n className={cx(styles.dropdown, variant === 'minimal' && styles.minimal, className)}\n onKeyDown={handleKeyDown}\n ref={containerRef}\n {...props}\n >\n <select\n {...selectProps}\n aria-hidden='true'\n className={styles.native}\n onChange={handleNativeChange}\n ref={nativeSelectRef}\n tabIndex={-1}\n value={selectedValue}\n >\n {normalizedSelect.children}\n </select>\n <Button\n aria-expanded={isOpen}\n aria-haspopup='dialog'\n className={cx(\n variant === 'default' && inputStyles.input,\n styles.trigger,\n displayOption?.isPlaceholder && styles.placeholder\n )}\n data-open={isOpen ? 'true' : undefined}\n disabled={selectProps.disabled}\n onClick={() => setIsOpen((currentValue) => !currentValue)}\n ref={buttonRef}\n variant='minimal'\n >\n <span className={styles.text}>{displayOption?.label ?? 'Select an option'}</span>\n </Button>\n {isOpen && (\n <div className={styles.panel}>\n <Input\n aria-label='Filter'\n className={styles.filter}\n icon='search'\n onChange={(event) => setQuery(event.target.value)}\n placeholder={searchPlaceholder}\n ref={searchRef}\n style={filterStyle}\n type='search'\n value={query}\n />\n <List\n aria-label='Dropdown'\n className={styles.options}\n >\n {filteredOptions.length > 0 ? (\n filteredOptions.map((option) => {\n const isSelected = option.value === selectedValue;\n\n return (\n <li key={`${option.groupLabel ?? 'root'}-${option.value}`}>\n <Button\n aria-label={isSelected ? `${option.text}, selected` : option.text}\n className={cx(styles.option, isSelected && styles.selected)}\n disabled={option.disabled}\n onClick={() => commitValue(option.value)}\n variant='minimal'\n >\n <span className={styles.text}>{option.label}</span>\n {option.groupLabel && (\n <small className={styles.group}>{option.groupLabel}</small>\n )}\n </Button>\n </li>\n );\n })\n ) : (\n <li className={styles.empty}>{emptyLabel}</li>\n )}\n </List>\n </div>\n )}\n </div>\n );\n};\n"],"names":["getNodeText","node","String","Array","isArray","map","join","isValidElement","props","children","isOptionElement","type","isOptGroupElement","isFragmentElement","React","Fragment","isWrappedSelectElement","Select","extractOptions","groupLabel","groupDisabled","options","Children","forEach","child","push","text","trim","value","disabled","Boolean","hidden","isPlaceholder","label","selected","buildWildcardMatcher","query","trimmedQuery","expression","test","character","replace","RegExp","getInitialValue","defaultValue","selectedOption","find","option","normalizeSelectElement","selectElement","placeholder","jsxs","Dropdown","className","emptyLabel","searchPlaceholder","variant","normalizedSelect","onChange","restSelectProps","selectProps","sanitizeSelectProps","buttonRef","useRef","containerRef","nativeSelectRef","searchRef","useMemo","isControlled","initialValue","internalValue","setInternalValue","useState","isOpen","setIsOpen","setQuery","selectedValue","displayOption","filterStyle","iconSVG","matcher","filteredOptions","selectableOptions","filter","useEffect","some","current","focus","handlePointerDown","event","contains","target","document","addEventListener","removeEventListener","handleNativeChange","commitValue","nextValue","nativeSelect","valueSetter","Object","getOwnPropertyDescriptor","HTMLSelectElement","prototype","set","call","dispatchEvent","Event","bubbles","handleKeyDown","key","cx","styles","dropdown","minimal","jsx","native","Button","inputStyles","input","trigger","undefined","currentValue","panel","Input","List","length","isSelected","group","empty"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAwCA,SAASA,EAAYC,GAA+B;AAClD,SAAI,OAAOA,KAAS,YAAY,OAAOA,KAAS,WACvCC,OAAOD,CAAI,IAGhBE,MAAMC,QAAQH,CAAI,IACbA,EAAKI,IAAIL,CAAW,EAAEM,KAAK,GAAG,IAGnCC,EAA+CN,CAAI,IAC9CD,EAAYC,EAAKO,MAAMC,QAAQ,IAGjC;AACT;AAEA,SAASC,GACPT,GACgF;AAChF,SAAOM,EAAeN,CAAI,KAAKA,EAAKU,SAAS;AAC/C;AAEA,SAASC,GACPX,GACoF;AACpF,SAAOM,EAAeN,CAAI,KAAKA,EAAKU,SAAS;AAC/C;AAEA,SAASE,GACPZ,GACmF;AACnF,SAAOM,EAAeN,CAAI,KAAKA,EAAKU,SAASG,EAAMC;AACrD;AAEA,SAASC,GAAuBf,GAAqD;AACnF,SAAOM,EAAeN,CAAI,KAAKA,EAAKU,SAASM;AAC/C;AAEA,SAASC,EACPT,GACAU,GACAC,IAAgB,IACE;AAClB,QAAMC,IAA4B,CAAA;AAElCC,SAAAA,EAASC,QAAQd,GAAWe,CAAAA,MAAU;AACpC,QAAIX,GAAkBW,CAAK,GAAG;AAC5BH,MAAAA,EAAQI,KAAK,GAAGP,EAAeM,EAAMhB,MAAMC,UAAUU,GAA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B,UAAUgD;AAEpC,eACE,gBAAAuC,EAAC,MAAA,EAAyD,kBAAA,YACxD,4BAACE,GAAA,EACC,cAAYU,IAAa,GAAGhF,EAAOrB,IAAI,eAAeqB,EAAOrB,MAC7D,WAAWqF,EAAGC,EAAOjE,QAAQgF,KAAcf,EAAO9E,QAAQ,GAC1D,UAAUa,EAAOlB,UACjB,SAAS,MAAMmE,EAAYjD,EAAOnB,KAAK,GACvC,SAAQ,WAER,UAAA;AAAA,UAAA,gBAAAuF,EAAC,QAAA,EAAK,WAAWH,EAAOtF,MAAOqB,YAAOd,OAAM;AAAA,UAC3Cc,EAAO5B,cACN,gBAAAgG,EAAC,SAAA,EAAM,WAAWH,EAAOgB,OAAQjF,YAAO5B,WAAAA,CAAW;AAAA,QAAA,GAEvD,EAAA,GAZO,GAAG4B,EAAO5B,cAAc,MAAM,IAAI4B,EAAOnB,KAAK,EAavD;AAAA,MAEJ,CAAC,IAED,gBAAAuF,EAAC,MAAA,EAAG,WAAWH,EAAOiB,OAAQ3E,aAAW,EAAA,CAE7C;AAAA,IAAA,EAAA,CACF;AAAA,EAAA,GAEJ;AAEJ;"}
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../src/components/_dropdown/index.tsx"],"sourcesContent":["import cx from 'classix';\nimport React, { Children, isValidElement, useEffect, useRef, useState } from 'react';\n\nimport { Button } from '@/components/button';\nimport { type IconName, iconSVG } from '@/components/icon/icons';\nimport { Input } from '@/components/input';\nimport inputStyles from '@/components/input/styles.module.css';\nimport { List } from '@/components/list';\nimport { Select, type SelectProps } from '@/components/select';\nimport { sanitizeSelectProps } from '@/components/select/sanitizeSelectProps';\nimport { resolveColor } from '@/utils';\n\nimport styles from './styles.module.css';\n\ntype NativeSelectProps = Omit<React.ComponentPropsWithoutRef<'select'>, 'children' | 'multiple'> & {\n children: React.ReactNode;\n multiple?: false;\n};\n\ntype NativeSelectElement = React.ReactElement<NativeSelectProps, 'select'>;\ntype WrappedSelectElement = React.ReactElement<SelectProps, typeof Select>;\ntype DropdownSelectElement = NativeSelectElement | WrappedSelectElement;\n\ntype DropdownOption = {\n disabled: boolean;\n groupLabel?: string;\n hidden: boolean;\n isPlaceholder: boolean;\n label: React.ReactNode;\n selected: boolean;\n text: string;\n value: string;\n};\n\nexport type DropdownProps = Omit<React.ComponentPropsWithoutRef<'div'>, 'children'> & {\n children: DropdownSelectElement;\n emptyLabel?: string;\n searchPlaceholder?: string;\n variant?: 'default' | 'minimal';\n};\n\ntype withVars = React.CSSProperties & {\n '--icon-svg'?: string;\n};\n\nfunction getIconWithVars(icon: IconName, color: string): withVars {\n return {\n '--icon-svg': iconSVG(icon).replace('currentColor', color),\n };\n}\n\nfunction getNodeText(node: React.ReactNode): string {\n if (typeof node === 'string' || typeof node === 'number') {\n return String(node);\n }\n\n if (Array.isArray(node)) {\n return node.map(getNodeText).join(' ');\n }\n\n if (isValidElement<{ children?: React.ReactNode }>(node)) {\n return getNodeText(node.props.children);\n }\n\n return '';\n}\n\nfunction isOptionElement(\n node: React.ReactNode\n): node is React.ReactElement<React.ComponentPropsWithoutRef<'option'>, 'option'> {\n return isValidElement(node) && node.type === 'option';\n}\n\nfunction isOptGroupElement(\n node: React.ReactNode\n): node is React.ReactElement<React.ComponentPropsWithoutRef<'optgroup'>, 'optgroup'> {\n return isValidElement(node) && node.type === 'optgroup';\n}\n\nfunction isFragmentElement(\n node: React.ReactNode\n): node is React.ReactElement<{ children?: React.ReactNode }, typeof React.Fragment> {\n return isValidElement(node) && node.type === React.Fragment;\n}\n\nfunction isWrappedSelectElement(node: React.ReactNode): node is WrappedSelectElement {\n return isValidElement(node) && node.type === Select;\n}\n\nfunction extractOptions(\n children: React.ReactNode,\n groupLabel?: string,\n groupDisabled = false\n): DropdownOption[] {\n const options: DropdownOption[] = [];\n\n Children.forEach(children, (child) => {\n if (isFragmentElement(child)) {\n options.push(...extractOptions(child.props.children, groupLabel, groupDisabled));\n return;\n }\n\n if (isOptionElement(child)) {\n const text = getNodeText(child.props.children).trim();\n const value = child.props.value != null ? String(child.props.value) : text;\n\n options.push({\n disabled: groupDisabled || Boolean(child.props.disabled),\n groupLabel,\n hidden: Boolean(child.props.hidden),\n isPlaceholder: Boolean(child.props.hidden && value === ''),\n label: child.props.children,\n selected: Boolean(child.props.selected),\n text,\n value,\n });\n\n return;\n }\n\n if (isOptGroupElement(child)) {\n options.push(\n ...extractOptions(\n child.props.children,\n child.props.label,\n groupDisabled || Boolean(child.props.disabled)\n )\n );\n }\n });\n\n return options;\n}\n\nfunction buildWildcardMatcher(query: string) {\n const trimmedQuery = query.trim();\n\n if (!trimmedQuery) {\n return null;\n }\n\n const wildcardQuery = /[*?]/.test(trimmedQuery) ? trimmedQuery : `*${trimmedQuery}*`;\n const expression = [...wildcardQuery]\n .map((character) => {\n if (character === '*') {\n return '.*';\n }\n\n if (character === '?') {\n return '.';\n }\n\n return character.replace(/[|\\\\{}()[\\]^$+.,]/g, '\\\\$&');\n })\n .join('');\n\n return new RegExp(`^${expression}$`, 'i');\n}\n\nfunction filterOptions(options: DropdownOption[], query: string) {\n const matcher = buildWildcardMatcher(query);\n const selectableOptions = options.filter((option) => !option.hidden && !option.isPlaceholder);\n\n if (!matcher) {\n return selectableOptions;\n }\n\n return selectableOptions.filter((option) =>\n matcher.test([option.groupLabel, option.text, option.value].filter(Boolean).join(' '))\n );\n}\n\nfunction getDisplayOption(options: DropdownOption[], selectedValue: string) {\n return (\n options.find((option) => option.value === selectedValue) ??\n options.find((option) => option.isPlaceholder) ??\n options[0]\n );\n}\n\nfunction getInitialValue(\n options: DropdownOption[],\n value?: NativeSelectProps['value'],\n defaultValue?: NativeSelectProps['defaultValue']\n) {\n if (value != null) {\n return String(value);\n }\n\n if (defaultValue != null) {\n return String(defaultValue);\n }\n\n const selectedOption = options.find((option) => option.selected);\n\n if (selectedOption) {\n return selectedOption.value;\n }\n\n return options[0]?.value ?? '';\n}\n\nfunction normalizeSelectElement(selectElement: DropdownSelectElement) {\n if (isWrappedSelectElement(selectElement)) {\n const { children, placeholder, ...props } = selectElement.props;\n\n return {\n children: (\n <>\n {placeholder && (\n <option\n hidden\n value=''\n >\n {placeholder}\n </option>\n )}\n {children}\n </>\n ),\n props,\n };\n }\n\n return {\n children: selectElement.props.children,\n props: selectElement.props,\n };\n}\n\nexport const Dropdown = ({\n children: selectElement,\n className,\n emptyLabel = 'No matches found',\n searchPlaceholder = 'Filter',\n variant = 'default',\n ...props\n}: DropdownProps) => {\n const normalizedSelect = normalizeSelectElement(selectElement);\n const { defaultValue, onChange, value, ...restSelectProps } = normalizedSelect.props;\n const selectProps = sanitizeSelectProps(restSelectProps);\n const buttonRef = useRef<HTMLButtonElement>(null);\n const containerRef = useRef<HTMLDivElement>(null);\n const nativeSelectRef = useRef<HTMLSelectElement>(null);\n const searchRef = useRef<HTMLInputElement>(null);\n const options = extractOptions(normalizedSelect.children);\n const isControlled = value != null;\n const initialValue = getInitialValue(options, value, defaultValue);\n const [internalValue, setInternalValue] = useState(() => initialValue);\n const [isOpen, setIsOpen] = useState(false);\n const [query, setQuery] = useState('');\n const selectedValue = isControlled ? String(value) : internalValue;\n const iconColors = {\n default: resolveColor('--color-icon'),\n white: resolveColor('--color-white', 'white'),\n };\n const dropdownIconColor = variant === 'minimal' ? iconColors.white : iconColors.default;\n const displayOption = getDisplayOption(options, selectedValue);\n const triggerWithVars = getIconWithVars('chevron', dropdownIconColor);\n const filterWithVars = getIconWithVars('search', dropdownIconColor);\n const filteredOptions = filterOptions(options, query);\n\n useEffect(() => {\n if (!isControlled && !options.some((option) => option.value === internalValue)) {\n setInternalValue(initialValue);\n }\n }, [initialValue, internalValue, isControlled, options]);\n\n useEffect(() => {\n if (!isOpen) {\n setQuery('');\n return;\n }\n\n searchRef.current?.focus();\n }, [isOpen]);\n\n useEffect(() => {\n if (!isOpen) {\n return;\n }\n\n const handlePointerDown = (event: MouseEvent) => {\n if (!containerRef.current?.contains(event.target as Node)) {\n setIsOpen(false);\n }\n };\n\n document.addEventListener('mousedown', handlePointerDown);\n\n return () => {\n document.removeEventListener('mousedown', handlePointerDown);\n };\n }, [isOpen]);\n\n const handleNativeChange = (event: React.ChangeEvent<HTMLSelectElement>) => {\n if (!isControlled) {\n setInternalValue(event.target.value);\n }\n\n onChange?.(event);\n };\n\n const closeMenu = () => {\n setIsOpen(false);\n buttonRef.current?.focus();\n };\n\n const commitValue = (nextValue: string) => {\n if (!isControlled) {\n setInternalValue(nextValue);\n }\n\n const nativeSelect = nativeSelectRef.current;\n\n if (!nativeSelect) {\n closeMenu();\n return;\n }\n\n const valueSetter = Object.getOwnPropertyDescriptor(HTMLSelectElement.prototype, 'value')?.set;\n\n valueSetter?.call(nativeSelect, nextValue);\n nativeSelect.dispatchEvent(new Event('change', { bubbles: true }));\n closeMenu();\n };\n\n const handleKeyDown = (event: React.KeyboardEvent<HTMLDivElement>) => {\n if (event.key === 'Escape') {\n closeMenu();\n }\n };\n\n return (\n <div\n className={cx(styles.dropdown, variant === 'minimal' && styles.minimal, className)}\n onKeyDown={handleKeyDown}\n ref={containerRef}\n {...props}\n >\n <select\n {...selectProps}\n aria-hidden='true'\n className={styles.native}\n onChange={handleNativeChange}\n ref={nativeSelectRef}\n tabIndex={-1}\n value={selectedValue}\n >\n {normalizedSelect.children}\n </select>\n <Button\n aria-expanded={isOpen}\n aria-haspopup='dialog'\n className={cx(\n variant === 'default' && inputStyles.input,\n styles.trigger,\n displayOption?.isPlaceholder && styles.placeholder\n )}\n data-open={isOpen ? 'true' : undefined}\n disabled={selectProps.disabled}\n onClick={() => setIsOpen((currentValue) => !currentValue)}\n ref={buttonRef}\n style={triggerWithVars}\n variant='minimal'\n >\n <span className={styles.text}>{displayOption?.label ?? 'Select an option'}</span>\n </Button>\n {isOpen && (\n <div className={styles.panel}>\n <Input\n aria-label='Filter'\n className={styles.filter}\n icon='search'\n onChange={(event) => setQuery(event.target.value)}\n placeholder={searchPlaceholder}\n ref={searchRef}\n style={filterWithVars}\n type='search'\n value={query}\n />\n <List\n aria-label='Dropdown'\n className={styles.options}\n >\n {filteredOptions.length > 0 ? (\n filteredOptions.map((option) => {\n const isSelected = option.value === selectedValue;\n\n return (\n <li key={`${option.groupLabel ?? 'root'}-${option.value}`}>\n <Button\n aria-label={isSelected ? `${option.text}, selected` : option.text}\n className={cx(styles.option, isSelected && styles.selected)}\n disabled={option.disabled}\n onClick={() => commitValue(option.value)}\n variant='minimal'\n >\n <span className={styles.text}>{option.label}</span>\n {option.groupLabel && (\n <small className={styles.group}>{option.groupLabel}</small>\n )}\n </Button>\n </li>\n );\n })\n ) : (\n <li className={styles.empty}>{emptyLabel}</li>\n )}\n </List>\n </div>\n )}\n </div>\n );\n};\n"],"names":["getIconWithVars","icon","color","iconSVG","replace","getNodeText","node","String","Array","isArray","map","join","isValidElement","props","children","isOptionElement","type","isOptGroupElement","isFragmentElement","React","Fragment","isWrappedSelectElement","Select","extractOptions","groupLabel","groupDisabled","options","Children","forEach","child","push","text","trim","value","disabled","Boolean","hidden","isPlaceholder","label","selected","buildWildcardMatcher","query","trimmedQuery","expression","test","character","RegExp","filterOptions","matcher","selectableOptions","filter","option","getDisplayOption","selectedValue","find","getInitialValue","defaultValue","selectedOption","normalizeSelectElement","selectElement","placeholder","jsxs","Dropdown","className","emptyLabel","searchPlaceholder","variant","normalizedSelect","onChange","restSelectProps","selectProps","sanitizeSelectProps","buttonRef","useRef","containerRef","nativeSelectRef","searchRef","isControlled","initialValue","internalValue","setInternalValue","useState","isOpen","setIsOpen","setQuery","iconColors","default","resolveColor","white","dropdownIconColor","displayOption","triggerWithVars","filterWithVars","filteredOptions","useEffect","some","current","focus","handlePointerDown","event","contains","target","document","addEventListener","removeEventListener","handleNativeChange","closeMenu","commitValue","nextValue","nativeSelect","valueSetter","Object","getOwnPropertyDescriptor","HTMLSelectElement","prototype","set","call","dispatchEvent","Event","bubbles","handleKeyDown","key","cx","styles","dropdown","minimal","jsx","native","Button","inputStyles","input","trigger","undefined","currentValue","panel","Input","List","length","isSelected","group","empty"],"mappings":";;;;;;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gBAAA6F,EAAC,QAAA,EAAK,WAAWH,EAAO5F,MAAOoB,YAAOb,OAAM;AAAA,UAC3Ca,EAAO3B,cACN,gBAAAsG,EAAC,SAAA,EAAM,WAAWH,EAAOgB,OAAQxF,YAAO3B,WAAAA,CAAW;AAAA,QAAA,GAEvD,EAAA,GAZO,GAAG2B,EAAO3B,cAAc,MAAM,IAAI2B,EAAOlB,KAAK,EAavD;AAAA,MAEJ,CAAC,IAED,gBAAA6F,EAAC,MAAA,EAAG,WAAWH,EAAOiB,OAAQ5E,aAAW,EAAA,CAE7C;AAAA,IAAA,EAAA,CACF;AAAA,EAAA,GAEJ;AAEJ;"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require('../../assets/index13.css');const e=require("react/jsx-runtime"),x=require("../../icons-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require('../../assets/index13.css');const e=require("react/jsx-runtime"),x=require("../../icons-C_cX1FYp.cjs"),b=require("../loading/index.cjs"),h="_checkbox_16skt_1",k={checkbox:h},u=({checked:s,disabled:t,isLoading:c,label:o,onChange:n,...i})=>{const r={"--icon-svg":x.iconSVG("check")};return e.jsxs("label",{className:k.checkbox,"data-component":"checkbox",children:[c&&e.jsx(b.Loading,{size:24,sticky:!0}),e.jsx("input",{checked:s,disabled:t||c,onChange:n,type:"checkbox",style:r,...i}),o&&o]})};exports.Checkbox=u;
|
|
2
2
|
//# sourceMappingURL=index.cjs.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsxs as h, jsx as e } from "react/jsx-runtime";
|
|
2
|
-
import { i as k } from "../../icons-
|
|
2
|
+
import { i as k } from "../../icons-DfmpRbxE.js";
|
|
3
3
|
import { Loading as x } from "../loading/index.js";
|
|
4
4
|
import '../../assets/index13.css';const b = "_checkbox_16skt_1", m = {
|
|
5
5
|
checkbox: b
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require('../../assets/index36.css');const r=require("react/jsx-runtime"),l=require("../../classix-5H4IWnMA.cjs"),i=require("../../icons-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require('../../assets/index36.css');const r=require("react/jsx-runtime"),l=require("../../classix-5H4IWnMA.cjs"),i=require("../../icons-C_cX1FYp.cjs"),_="_icon_wciqx_1",m="_small_wciqx_9",u="_medium_wciqx_14",d="_large_wciqx_19",g="_danger_wciqx_24",w="_primary_wciqx_32",q="_white_wciqx_36",e={icon:_,small:m,medium:u,large:d,danger:g,default:"_default_wciqx_28",primary:w,white:q,"gap-right":"_gap-right_wciqx_40","gap-left":"_gap-left_wciqx_44"},x={large:e.large,medium:e.medium,small:e.small},p={danger:e.danger,default:e.default,primary:e.primary,white:e.white},y=({fill:n,gap:t="none",name:c,size:a="medium",variant:s="default"})=>{const o={maskImage:i.iconSVG(c,n??!1)};return r.jsx("span",{className:l.t(t!=="none"&&e[`gap-${t}`],x[a],e.icon,p[s]),style:o,"data-component":"icon"})},f=()=>Object.keys(i.iconPaths);exports.Icon=y;exports.Icons=f;
|
|
2
2
|
//# sourceMappingURL=index.cjs.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as o } from "react/jsx-runtime";
|
|
2
2
|
import { t as r } from "../../classix-DG18itHa.js";
|
|
3
|
-
import { i as m, a as _ } from "../../icons-
|
|
3
|
+
import { i as m, a as _ } from "../../icons-DfmpRbxE.js";
|
|
4
4
|
import '../../assets/index36.css';const l = "_icon_wciqx_1", d = "_small_wciqx_9", g = "_medium_wciqx_14", p = "_large_wciqx_19", w = "_danger_wciqx_24", u = "_primary_wciqx_32", x = "_white_wciqx_36", a = {
|
|
5
5
|
icon: l,
|
|
6
6
|
small: d,
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("react/jsx-runtime"),c=require("../../classix-5H4IWnMA.cjs"),s=require("react"),I=require("../../icons-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("react/jsx-runtime"),c=require("../../classix-5H4IWnMA.cjs"),s=require("react"),I=require("../../icons-C_cX1FYp.cjs"),P=require("../../utils-DqVa4K58.cjs"),a=require("../../styles.module-CwroCNAt.cjs"),R=s.forwardRef(({className:y,defaultCountryCode:d="+47",disabled:i=!1,icon:o,label:h,placeholder:m,type:t="text",...e},v)=>{const[l,g]=s.useState(""),[r,x]=s.useState(""),{onChange:N,value:j,...C}=e,{touched:f,onBlur:S}=P.useTouched(j===""),q=o&&t!=="radio"&&t!=="datetime-local"?{"--icon-svg":I.iconSVG(o,!0)}:void 0;s.useEffect(()=>{if(typeof e.onChange=="function"&&t==="tel"){const u={name:e.name,value:r?(l||d).split(" ").join("")+r.split(" ").join(""):void 0};e.onChange({target:u,currentTarget:u})}},[l,r]),s.useEffect(()=>{t==="tel"&&!e.value&&(x(""),g(""))},[e.value,t]);const p=n.jsxs(n.Fragment,{children:[n.jsx("input",{disabled:i,hidden:!0,onChange:N,pattern:void 0,placeholder:m,ref:v,type:t,value:j}),n.jsx("input",{type:"text",className:a.inputStyles.input,disabled:i,maxLength:5,onChange:u=>g(u.target.value),placeholder:d,value:l}),n.jsx("input",{type:"tel",className:c.t(a.inputStyles.input,f&&"touched"),"data-icon":o?"true":void 0,disabled:i,maxLength:14,name:void 0,onChange:u=>x(u.target.value),onBlur:S,pattern:e.pattern,style:q,value:r,...C})]});return n.jsxs("label",{className:a.inputStyles.label,children:[h&&n.jsx("span",{className:c.t(e.required&&a.inputStyles.required),children:h}),t==="tel"?p:n.jsx("input",{ref:v,className:c.t(a.inputStyles.input,y,f&&"touched"),"data-icon":o?"true":void 0,disabled:i,onBlur:S,placeholder:m,style:q,type:t,...e})]})});exports.Input=R;
|
|
2
2
|
//# sourceMappingURL=index.cjs.map
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { jsxs as C, Fragment as P, jsx as a } from "react/jsx-runtime";
|
|
2
2
|
import { t as l } from "../../classix-DG18itHa.js";
|
|
3
3
|
import { forwardRef as T, useState as j, useEffect as S } from "react";
|
|
4
|
-
import { i as V } from "../../icons-
|
|
5
|
-
import { u as B } from "../../utils-
|
|
4
|
+
import { i as V } from "../../icons-DfmpRbxE.js";
|
|
5
|
+
import { u as B } from "../../utils-BFlnRYx7.js";
|
|
6
6
|
import { i as o } from "../../styles.module-C_Z8FrR5.js";
|
|
7
7
|
const y = T(({
|
|
8
8
|
className: q,
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require('../../assets/index40.css');const p=require("react/jsx-runtime"),_=require("../../classix-5H4IWnMA.cjs"),f=require("react"),v=require("../../icons-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require('../../assets/index40.css');const p=require("react/jsx-runtime"),_=require("../../classix-5H4IWnMA.cjs"),f=require("react"),v=require("../../icons-C_cX1FYp.cjs"),h="_nav_roa57_1",b="_horizontal_roa57_7",g="_tabs_roa57_17",m="_pills_roa57_38",t={nav:h,horizontal:b,tabs:g,pills:m},w={default:t.default,pills:t.pills,tabs:t.tabs},q=({animation:o,children:i,className:r,horizontal:e=!1,variant:a="default",...l})=>{const[c,s]=f.useState(!1),u={"--icon-svg":v.iconSVG("chevron")};return p.jsx("nav",{className:_.t(r,e&&t.horizontal,t.nav,w[a]),"data-animation":o,"data-open":c?"true":"false","data-orientation":e?"horizontal":"vertical",onBlurCapture:n=>{if(a!=="pills"||window.innerWidth>960)return;const d=n.relatedTarget;n.currentTarget.contains(d)||s(!1)},onClick:()=>{a!=="pills"||window.innerWidth>960||s(n=>!n)},style:u,...l,"data-component":"nav",children:i})};exports.Nav=q;
|
|
2
2
|
//# sourceMappingURL=index.cjs.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as d } from "react/jsx-runtime";
|
|
2
2
|
import { t as _ } from "../../classix-DG18itHa.js";
|
|
3
3
|
import { useState as m } from "react";
|
|
4
|
-
import { i as u } from "../../icons-
|
|
4
|
+
import { i as u } from "../../icons-DfmpRbxE.js";
|
|
5
5
|
import '../../assets/index40.css';const v = "_nav_roa57_1", h = "_horizontal_roa57_7", b = "_tabs_roa57_17", w = "_pills_roa57_38", t = {
|
|
6
6
|
nav: v,
|
|
7
7
|
horizontal: h,
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("react/jsx-runtime");require("../../classix-5H4IWnMA.cjs");require("../../utils-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("react/jsx-runtime");require("../../classix-5H4IWnMA.cjs");require("../../icons-C_cX1FYp.cjs");require("../../utils-DqVa4K58.cjs");const e=require("../../index-CfK1ATlt.cjs");exports.Select=e.Select;
|
|
2
2
|
//# sourceMappingURL=index.cjs.map
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import "react/jsx-runtime";
|
|
2
2
|
import "../../classix-DG18itHa.js";
|
|
3
|
-
import "../../
|
|
4
|
-
import
|
|
3
|
+
import "../../icons-DfmpRbxE.js";
|
|
4
|
+
import "../../utils-BFlnRYx7.js";
|
|
5
|
+
import { S as e } from "../../index-C_OgUYu-.js";
|
|
5
6
|
export {
|
|
6
7
|
e as Select
|
|
7
8
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require('../../assets/index3.css');const f=require("react/jsx-runtime"),i=require("react"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require('../../assets/index3.css');const f=require("react/jsx-runtime"),i=require("react"),k=require("../icon/index.cjs"),z="_table_18uji_1",D="_sortable_18uji_27",j={table:z,sortable:D},m=r=>i.isValidElement(r),A=r=>i.Children.toArray(r).reduce((e,t)=>m(t)?e+(t.type==="td"||t.type==="th"?1:A(t.props.children)):e,0),v=r=>{for(const e of i.Children.toArray(r)){if(!m(e))continue;if(e.type==="tr")return A(e.props.children);const t=v(e.props.children);if(t!==null)return t}return null},S=(r,e)=>i.Children.map(r,t=>{if(!m(t))return t;let s=t.props.children===void 0?t.props.children:S(t.props.children,e),n;return t.type==="td"&&t.props["data-span"]==="all"&&(n={colSpan:e}),t.type==="th"&&t.props["data-type"]&&(s=f.jsxs("span",{className:j.sortable,children:[s,f.jsx(k.Icon,{"aria-hidden":"true",name:"updown",variant:"primary"})]})),n||s!==t.props.children?i.cloneElement(t,n,s):t}),I=(r,e,t,s,n=1)=>{if(t==="text")return r.localeCompare(e,s,{sensitivity:"base"})*n;const l=t==="date"?Date.parse(r):Number.parseFloat(r),c=t==="date"?Date.parse(e):Number.parseFloat(e);return Number.isNaN(l)&&Number.isNaN(c)?0:Number.isNaN(l)?1:Number.isNaN(c)?-1:(l-c)*n},P=({children:r,locale:e,...t})=>{const s=i.useRef(null),n=v(r),l=n&&n>0?S(r,n):r,c=(d,u,o)=>{d.querySelectorAll("th[data-type]").forEach(a=>{a===u?(a.dataset.dir=o,a.setAttribute("aria-sort",o==="asc"?"ascending":"descending")):(delete a.dataset.dir,a.setAttribute("aria-sort","none"))})},q=i.useCallback(d=>{var x,g;const u=s.current;if(!u)return;const o=(x=d.target)==null?void 0:x.closest("th");if(!o)return;const p=u.tHead;if(!p||!p.contains(o))return;const a=o.cellIndex;if(a<0)return;const b=(g=u.tBodies)==null?void 0:g[0];if(!b)return;const y=o.getAttribute("data-type");if(!y)return;const N=o.dataset.dir==="asc"?"desc":"asc";c(p,o,N);const w=N==="asc"?1:-1,C=Array.from(b.rows);C.sort((E,R)=>{var _,h;const T=(((_=E.cells[a])==null?void 0:_.textContent)??"").trim(),F=(((h=R.cells[a])==null?void 0:h.textContent)??"").trim();return I(T,F,y,e,w)}),b.append(...C)},[e]);return f.jsx("table",{className:j.table,onClick:q,ref:s,...t,"data-component":"table",children:l})};exports.Table=P;
|
|
2
2
|
//# sourceMappingURL=index.cjs.map
|