@stackone/malachite 2.91.0 → 2.92.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/COMPONENTS.md +1 -1
- package/dist/components/Accordion.js +52 -49
- package/dist/components/Accordion.js.map +1 -1
- package/dist/components/FilterSearch.js +318 -282
- package/dist/components/FilterSearch.js.map +1 -1
- package/dist/components/Modal.js +58 -59
- package/dist/components/Modal.js.map +1 -1
- package/dist/components/SidePanel.js +47 -48
- package/dist/components/SidePanel.js.map +1 -1
- package/dist/components/afterNextPaint.js +11 -0
- package/dist/components/afterNextPaint.js.map +1 -0
- package/dist/components/filterSearchModel.js +32 -31
- package/dist/components/filterSearchModel.js.map +1 -1
- package/dist/components/frameStyles.js +6 -5
- package/dist/components/frameStyles.js.map +1 -1
- package/dist/index.d.ts +10 -3
- package/package.json +1 -1
|
@@ -1,39 +1,50 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { useId as
|
|
3
|
-
import { createPortal as
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import { CONTROL_TEXT_SIZE_CLASS as
|
|
10
|
-
import { controlWidthStyle as
|
|
11
|
-
import { getTriggerVisual as
|
|
12
|
-
import { pushEscapeLayer as
|
|
13
|
-
import { orderSelections as
|
|
14
|
-
import { ensureFilterSearchStyles as
|
|
15
|
-
import { measureMenuGeometry as
|
|
16
|
-
import { FOCUS_RING as
|
|
17
|
-
import { usePopupLayer as
|
|
18
|
-
import { useTopLayer as
|
|
19
|
-
import { useFollowTrigger as
|
|
20
|
-
import { useLatestRef as
|
|
21
|
-
const
|
|
22
|
-
small: `min-h-[var(--malachite-control-height-small,28px)] gap-1 px-2.5 py-[2px] ${
|
|
23
|
-
medium: `min-h-[var(--malachite-control-height-medium,32px)] gap-1 px-3 py-[3px] ${
|
|
24
|
-
large: `min-h-[var(--malachite-control-height-large,42px)] gap-1.5 px-4 py-[6px] ${
|
|
25
|
-
},
|
|
1
|
+
import { jsxs as h, Fragment as X, jsx as o } from "react/jsx-runtime";
|
|
2
|
+
import { useId as Qe, useState as j, useRef as w, useEffect as O, useMemo as U, useCallback as Q, useLayoutEffect as Ne, useInsertionEffect as et } from "react";
|
|
3
|
+
import { createPortal as tt } from "react-dom";
|
|
4
|
+
import rt from "./CustomIcons/CaretDownIcon.js";
|
|
5
|
+
import nt from "./CustomIcons/CheckmarkIcon.js";
|
|
6
|
+
import Ie from "./CustomIcons/DismissIcon.js";
|
|
7
|
+
import Me from "./CustomIcons/SearchIcon.js";
|
|
8
|
+
import it from "./Spinner.js";
|
|
9
|
+
import { CONTROL_TEXT_SIZE_CLASS as oe, CONTROL_TEXT_SIZE as ot } from "./controlTextSize.js";
|
|
10
|
+
import { controlWidthStyle as lt } from "./controlWidth.js";
|
|
11
|
+
import { getTriggerVisual as st, DROPDOWN_TRIGGER_ATTR as at } from "./dropdownTriggerStyle.js";
|
|
12
|
+
import { pushEscapeLayer as ct } from "./escapeLayers.js";
|
|
13
|
+
import { orderSelections as dt, resolveMode as pt, openFilterOf as ut, filterRows as Te, searchRows as mt, chipText as ft, removeFilter as ht, clearAll as gt, commitText as xt, selectAll as bt, deselectAll as vt, toggleValue as yt } from "./filterSearchModel.js";
|
|
14
|
+
import { ensureFilterSearchStyles as wt, FILTER_SEARCH_CLASS as $ } from "./filterSearchStyles.js";
|
|
15
|
+
import { measureMenuGeometry as kt, MENU_MAX_HEIGHT_PX as St, MENU_SPECS as V } from "./floatingMenuGeometry.js";
|
|
16
|
+
import { FOCUS_RING as le } from "./focusRing.js";
|
|
17
|
+
import { usePopupLayer as Et } from "./overlayLayers.js";
|
|
18
|
+
import { useTopLayer as Rt } from "./topLayer.js";
|
|
19
|
+
import { useFollowTrigger as Ct } from "./useFollowTrigger.js";
|
|
20
|
+
import { useLatestRef as $e } from "./useLatestRef.js";
|
|
21
|
+
const Nt = {
|
|
22
|
+
small: `min-h-[var(--malachite-control-height-small,28px)] gap-1 px-2.5 py-[2px] ${oe.small} rounded-[var(--malachite-radius-10,10px)]`,
|
|
23
|
+
medium: `min-h-[var(--malachite-control-height-medium,32px)] gap-1 px-3 py-[3px] ${oe.medium} rounded-xl`,
|
|
24
|
+
large: `min-h-[var(--malachite-control-height-large,42px)] gap-1.5 px-4 py-[6px] ${oe.large} rounded-[var(--malachite-radius-xxl,14px)]`
|
|
25
|
+
}, It = {
|
|
26
26
|
small: "gap-1",
|
|
27
27
|
medium: "gap-1",
|
|
28
28
|
large: "gap-1.5"
|
|
29
|
-
},
|
|
29
|
+
}, se = {
|
|
30
30
|
resting: "bg-[var(--malachite-tag-default-background,rgba(123,123,123,0.1))] text-[var(--malachite-text-primary,rgb(10,10,10))]",
|
|
31
31
|
active: "bg-[var(--malachite-accent-background,rgb(0,175,102))] text-[var(--malachite-card-background,rgb(255,255,255))]"
|
|
32
|
-
},
|
|
33
|
-
|
|
34
|
-
|
|
32
|
+
}, Tt = 5, ae = (i) => !!i && !(i.kind === "item" && i.row.item.disabled), $t = (i) => {
|
|
33
|
+
switch (i.kind) {
|
|
34
|
+
case "text":
|
|
35
|
+
return "text";
|
|
36
|
+
case "filter":
|
|
37
|
+
return `filter:${i.filter.value}`;
|
|
38
|
+
case "toggle":
|
|
39
|
+
return "toggle";
|
|
40
|
+
case "item":
|
|
41
|
+
return `item:${i.row.filter.value}:${i.row.item.value}`;
|
|
42
|
+
}
|
|
43
|
+
}, Dt = (i, x) => {
|
|
44
|
+
for (let l = Math.max(x, 0); l < i.length; l++)
|
|
45
|
+
if (ae(i[l])) return l;
|
|
35
46
|
return -1;
|
|
36
|
-
},
|
|
47
|
+
}, At = {
|
|
37
48
|
display: "flex",
|
|
38
49
|
alignItems: "center",
|
|
39
50
|
gap: 8,
|
|
@@ -46,33 +57,38 @@ const yt = {
|
|
|
46
57
|
font: "inherit",
|
|
47
58
|
cursor: "pointer",
|
|
48
59
|
minWidth: 0
|
|
49
|
-
},
|
|
60
|
+
}, De = {
|
|
50
61
|
borderRadius: 6,
|
|
51
62
|
padding: "2px 6px",
|
|
52
63
|
flexShrink: 0,
|
|
53
64
|
whiteSpace: "nowrap"
|
|
54
|
-
},
|
|
65
|
+
}, q = {
|
|
55
66
|
overflow: "hidden",
|
|
56
67
|
textOverflow: "ellipsis",
|
|
57
68
|
whiteSpace: "nowrap",
|
|
58
69
|
minWidth: 0
|
|
59
|
-
},
|
|
70
|
+
}, Ae = { ...q, marginLeft: "auto", flexShrink: 1 }, Le = (i) => i.preventDefault(), Lt = (i) => {
|
|
60
71
|
i.preventDefault(), i.stopPropagation();
|
|
61
|
-
},
|
|
72
|
+
}, Mt = ({ row: i, showFilter: x }) => {
|
|
73
|
+
if (i.kind === "text")
|
|
74
|
+
return /* @__PURE__ */ h(X, { children: [
|
|
75
|
+
/* @__PURE__ */ o(Me, { size: 13, style: { flexShrink: 0 } }),
|
|
76
|
+
/* @__PURE__ */ o("span", { style: q, children: `${i.label} "${i.text}"` })
|
|
77
|
+
] });
|
|
62
78
|
if (i.kind === "filter")
|
|
63
|
-
return /* @__PURE__ */
|
|
64
|
-
/* @__PURE__ */
|
|
65
|
-
i.filter.info && /* @__PURE__ */
|
|
66
|
-
i.filter.example && /* @__PURE__ */
|
|
79
|
+
return /* @__PURE__ */ h(X, { children: [
|
|
80
|
+
/* @__PURE__ */ o("span", { className: $.pill, style: De, children: i.filter.label }),
|
|
81
|
+
i.filter.info && /* @__PURE__ */ o("span", { style: q, children: i.filter.info }),
|
|
82
|
+
i.filter.example && /* @__PURE__ */ o("span", { className: $.hint, style: Ae, children: i.filter.example })
|
|
67
83
|
] });
|
|
68
84
|
if (i.kind === "toggle")
|
|
69
|
-
return /* @__PURE__ */
|
|
70
|
-
const { item:
|
|
71
|
-
return /* @__PURE__ */
|
|
72
|
-
|
|
73
|
-
/* @__PURE__ */
|
|
74
|
-
|
|
75
|
-
|
|
85
|
+
return /* @__PURE__ */ o("span", { style: { color: "var(--malachite-text-primary, rgb(10, 10, 10))" }, children: i.toggle === "select" ? "Select All" : "Deselect All" });
|
|
86
|
+
const { item: l, filter: D, selected: H } = i.row;
|
|
87
|
+
return /* @__PURE__ */ h(X, { children: [
|
|
88
|
+
x && /* @__PURE__ */ o("span", { className: $.pill, style: De, children: D.label }),
|
|
89
|
+
/* @__PURE__ */ o("span", { style: q, children: l.label }),
|
|
90
|
+
H ? /* @__PURE__ */ o(
|
|
91
|
+
nt,
|
|
76
92
|
{
|
|
77
93
|
size: 16,
|
|
78
94
|
style: {
|
|
@@ -81,96 +97,110 @@ const yt = {
|
|
|
81
97
|
color: "var(--malachite-accent-background, rgb(0, 175, 102))"
|
|
82
98
|
}
|
|
83
99
|
}
|
|
84
|
-
) :
|
|
100
|
+
) : x && D.info && /* @__PURE__ */ o("span", { className: $.hint, style: Ae, children: D.info })
|
|
85
101
|
] });
|
|
86
|
-
},
|
|
102
|
+
}, tr = ({
|
|
87
103
|
filters: i,
|
|
88
|
-
searchFilters:
|
|
89
|
-
value:
|
|
90
|
-
onChange:
|
|
91
|
-
onClear:
|
|
92
|
-
onActiveFilterChange:
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
104
|
+
searchFilters: x,
|
|
105
|
+
value: l,
|
|
106
|
+
onChange: D,
|
|
107
|
+
onClear: H,
|
|
108
|
+
onActiveFilterChange: _e,
|
|
109
|
+
onQueryChange: Oe,
|
|
110
|
+
textFilter: A,
|
|
111
|
+
placeholder: ee = "Search",
|
|
112
|
+
size: te = "medium",
|
|
113
|
+
width: He,
|
|
114
|
+
loading: u = !1,
|
|
115
|
+
disabled: m = !1,
|
|
116
|
+
clearable: Pe = !1,
|
|
117
|
+
maxVisibleChips: ze = 4,
|
|
118
|
+
className: We = "",
|
|
119
|
+
style: Fe,
|
|
120
|
+
id: Ge,
|
|
121
|
+
"aria-label": ce,
|
|
122
|
+
"aria-labelledby": de
|
|
105
123
|
}) => {
|
|
106
|
-
var
|
|
107
|
-
const
|
|
108
|
-
|
|
109
|
-
|
|
124
|
+
var Ce;
|
|
125
|
+
const pe = Qe(), ue = `${pe}-listbox`, me = (e) => `${pe}-option-${e}`, [a, re] = j(!1), [d, b] = j(""), k = $e(Oe), ne = w("");
|
|
126
|
+
O(() => {
|
|
127
|
+
var e;
|
|
128
|
+
ne.current !== d && (ne.current = d, (e = k.current) == null || e.call(k, d));
|
|
129
|
+
}, [d, k]), O(
|
|
130
|
+
() => () => {
|
|
131
|
+
var e;
|
|
132
|
+
ne.current !== "" && ((e = k.current) == null || e.call(k, ""));
|
|
133
|
+
},
|
|
134
|
+
[k]
|
|
135
|
+
);
|
|
136
|
+
const [c, je] = j(null), [fe, f] = j(0), [p, he] = j(null), C = w(null), P = w(null), S = w(null), B = w(null), ge = w([]);
|
|
137
|
+
Rt(S, a);
|
|
138
|
+
const Ue = Et("multiselect", a, S), xe = w(/* @__PURE__ */ new Map()), z = U(() => {
|
|
110
139
|
var t;
|
|
111
|
-
const e = new Map(
|
|
112
|
-
for (const
|
|
113
|
-
const
|
|
114
|
-
e.set(
|
|
115
|
-
label:
|
|
140
|
+
const e = new Map(xe.current);
|
|
141
|
+
for (const n of [...x ?? [], ...i]) {
|
|
142
|
+
const r = ((t = e.get(n.value)) == null ? void 0 : t.items) ?? /* @__PURE__ */ new Map();
|
|
143
|
+
e.set(n.value, {
|
|
144
|
+
label: n.label,
|
|
116
145
|
items: new Map([
|
|
117
|
-
...
|
|
118
|
-
...
|
|
146
|
+
...r,
|
|
147
|
+
...n.items.map((s) => [s.value, s.label])
|
|
119
148
|
])
|
|
120
149
|
});
|
|
121
150
|
}
|
|
122
151
|
return e;
|
|
123
|
-
}, [i,
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
}, [
|
|
127
|
-
const
|
|
128
|
-
() =>
|
|
129
|
-
[
|
|
152
|
+
}, [i, x]);
|
|
153
|
+
O(() => {
|
|
154
|
+
xe.current = z;
|
|
155
|
+
}, [z]);
|
|
156
|
+
const be = w([]), W = U(
|
|
157
|
+
() => dt(l, be.current, c),
|
|
158
|
+
[l, c]
|
|
130
159
|
);
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
}, [
|
|
134
|
-
const g =
|
|
135
|
-
() =>
|
|
136
|
-
[c, i,
|
|
137
|
-
),
|
|
160
|
+
O(() => {
|
|
161
|
+
be.current = W;
|
|
162
|
+
}, [W]);
|
|
163
|
+
const g = pt(c, d), ie = x ?? i, N = U(
|
|
164
|
+
() => ut(c, i, x, l),
|
|
165
|
+
[c, i, x, l]
|
|
166
|
+
), ve = w(c), K = $e(_e), E = Q(
|
|
138
167
|
(e) => {
|
|
139
168
|
var t;
|
|
140
|
-
|
|
169
|
+
ve.current !== e && (ve.current = e, je(e), (t = K.current) == null || t.call(K, e));
|
|
141
170
|
},
|
|
142
|
-
[
|
|
143
|
-
),
|
|
144
|
-
if (
|
|
171
|
+
[K]
|
|
172
|
+
), F = A == null ? void 0 : A.value, L = A == null ? void 0 : A.label, v = U(() => {
|
|
173
|
+
if (u) return [];
|
|
145
174
|
if (g === "filters") return i.map((r) => ({ kind: "filter", filter: r }));
|
|
146
|
-
const { toggle: e, items: t } = g === "items" ?
|
|
175
|
+
const { toggle: e, items: t } = g === "items" ? Te(N, l, d) : mt(ie, l, d);
|
|
147
176
|
return [
|
|
177
|
+
...g === "search" && L !== void 0 ? [{ kind: "text", label: L, text: d.trim() }] : [],
|
|
148
178
|
...e ? [{ kind: "toggle", toggle: e }] : [],
|
|
149
179
|
...t.map((r) => ({ kind: "item", row: r }))
|
|
150
180
|
];
|
|
151
|
-
}, [
|
|
152
|
-
const e = new Map(
|
|
153
|
-
const
|
|
154
|
-
if (!
|
|
155
|
-
return
|
|
156
|
-
if (!
|
|
157
|
-
const
|
|
158
|
-
return [{ filter:
|
|
159
|
-
},
|
|
160
|
-
return [...
|
|
161
|
-
}, [
|
|
181
|
+
}, [u, g, i, ie, N, l, d, L]), Z = U(() => {
|
|
182
|
+
const e = new Map(l.map((r) => [r.filter, r.items])), t = (r) => {
|
|
183
|
+
const s = r === F && L !== void 0 ? { label: L, items: /* @__PURE__ */ new Map() } : z.get(r), y = e.get(r);
|
|
184
|
+
if (!y)
|
|
185
|
+
return r === c ? [{ filter: r, text: (s == null ? void 0 : s.label) ?? r }] : [];
|
|
186
|
+
if (!s && u) return [];
|
|
187
|
+
const T = y.map((R) => (s == null ? void 0 : s.items.get(R)) ?? R);
|
|
188
|
+
return [{ filter: r, text: ft((s == null ? void 0 : s.label) ?? r, T) }];
|
|
189
|
+
}, n = c !== null && !W.includes(c);
|
|
190
|
+
return [...W, ...n ? [c] : []].flatMap(t);
|
|
191
|
+
}, [W, l, z, u, c, F, L]), ye = Z.slice(0, ze), we = Z.length - ye.length, G = Q(
|
|
162
192
|
({ next: e, changes: t }) => {
|
|
163
|
-
t.length > 0 &&
|
|
193
|
+
t.length > 0 && D(e, t);
|
|
164
194
|
},
|
|
165
|
-
[
|
|
166
|
-
),
|
|
167
|
-
|
|
168
|
-
}, [
|
|
169
|
-
|
|
170
|
-
},
|
|
195
|
+
[D]
|
|
196
|
+
), I = Q(() => {
|
|
197
|
+
re(!1), b(""), E(null), he(null);
|
|
198
|
+
}, [E]), Y = () => {
|
|
199
|
+
m || a || (f(0), re(!0));
|
|
200
|
+
}, M = Q(() => {
|
|
171
201
|
const e = C.current;
|
|
172
|
-
e &&
|
|
173
|
-
|
|
202
|
+
e && he(
|
|
203
|
+
kt(S.current, {
|
|
174
204
|
triggerRect: e.getBoundingClientRect(),
|
|
175
205
|
preset: "standard",
|
|
176
206
|
viewportWidth: window.innerWidth,
|
|
@@ -178,200 +208,206 @@ const yt = {
|
|
|
178
208
|
})
|
|
179
209
|
);
|
|
180
210
|
}, []);
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
}, [
|
|
184
|
-
if (!
|
|
185
|
-
const e = (
|
|
186
|
-
const
|
|
187
|
-
(!
|
|
211
|
+
Ct(a, C, M, I), O(() => {
|
|
212
|
+
m && a && I();
|
|
213
|
+
}, [m, a, I]), O(() => {
|
|
214
|
+
if (!a) return;
|
|
215
|
+
const e = (s) => {
|
|
216
|
+
const y = s.composedPath(), T = C.current, R = S.current;
|
|
217
|
+
(!T || !y.includes(T)) && (!R || !y.includes(R)) && I();
|
|
188
218
|
};
|
|
189
219
|
let t = null;
|
|
190
|
-
const
|
|
220
|
+
const n = () => {
|
|
191
221
|
t === null && (t = requestAnimationFrame(() => {
|
|
192
|
-
t = null,
|
|
222
|
+
t = null, M();
|
|
193
223
|
}));
|
|
194
|
-
},
|
|
195
|
-
return document.addEventListener("mousedown", e), window.addEventListener("resize",
|
|
196
|
-
document.removeEventListener("mousedown", e), window.removeEventListener("resize",
|
|
224
|
+
}, r = ct(I);
|
|
225
|
+
return document.addEventListener("mousedown", e), window.addEventListener("resize", n), () => {
|
|
226
|
+
document.removeEventListener("mousedown", e), window.removeEventListener("resize", n), t !== null && cancelAnimationFrame(t), r();
|
|
197
227
|
};
|
|
198
|
-
}, [
|
|
199
|
-
if (!
|
|
200
|
-
const e = new ResizeObserver(() =>
|
|
201
|
-
return
|
|
202
|
-
}, [
|
|
203
|
-
|
|
204
|
-
}, [g, c,
|
|
205
|
-
|
|
206
|
-
}, [
|
|
207
|
-
const
|
|
228
|
+
}, [a, I, M]), Ne(() => {
|
|
229
|
+
if (!a || (M(), typeof ResizeObserver > "u")) return;
|
|
230
|
+
const e = new ResizeObserver(() => M());
|
|
231
|
+
return S.current && e.observe(S.current), C.current && e.observe(C.current), () => e.disconnect();
|
|
232
|
+
}, [a, M]), Ne(() => {
|
|
233
|
+
B.current && (B.current.scrollTop = 0);
|
|
234
|
+
}, [g, c, d]), et(() => {
|
|
235
|
+
a && wt();
|
|
236
|
+
}, [a]);
|
|
237
|
+
const ke = (e) => {
|
|
208
238
|
requestAnimationFrame(() => {
|
|
209
|
-
const t =
|
|
210
|
-
if (!t || !
|
|
211
|
-
const
|
|
212
|
-
|
|
239
|
+
const t = ge.current[e], n = B.current;
|
|
240
|
+
if (!t || !n) return;
|
|
241
|
+
const r = t.offsetTop, s = r + t.offsetHeight;
|
|
242
|
+
s > n.scrollTop + n.clientHeight ? n.scrollTop = s - n.clientHeight : r < n.scrollTop && (n.scrollTop = r);
|
|
213
243
|
});
|
|
214
|
-
},
|
|
244
|
+
}, Se = (e) => {
|
|
245
|
+
if (e.kind === "text") {
|
|
246
|
+
F !== void 0 && G(xt(l, F, e.text)), b(""), f(0);
|
|
247
|
+
return;
|
|
248
|
+
}
|
|
215
249
|
if (e.kind === "filter") {
|
|
216
|
-
|
|
250
|
+
E(e.filter.value), b(""), f(0);
|
|
217
251
|
return;
|
|
218
252
|
}
|
|
219
253
|
if (e.kind === "toggle") {
|
|
220
|
-
const
|
|
221
|
-
|
|
222
|
-
e.toggle === "select" ?
|
|
223
|
-
),
|
|
254
|
+
const J = g === "items" && N ? [N] : ie;
|
|
255
|
+
G(
|
|
256
|
+
e.toggle === "select" ? bt(J, l, d) : vt(J, l, d)
|
|
257
|
+
), b(""), f(0);
|
|
224
258
|
return;
|
|
225
259
|
}
|
|
226
|
-
const { item: t, filter:
|
|
260
|
+
const { item: t, filter: n } = e.row;
|
|
227
261
|
if (t.disabled) return;
|
|
228
|
-
const
|
|
229
|
-
if (
|
|
230
|
-
|
|
262
|
+
const r = yt(l, n.value, t.value);
|
|
263
|
+
if (G(r), b(""), g !== "items") {
|
|
264
|
+
f(0);
|
|
231
265
|
return;
|
|
232
266
|
}
|
|
233
|
-
const { toggle:
|
|
234
|
-
|
|
235
|
-
},
|
|
236
|
-
if (
|
|
237
|
-
let t =
|
|
238
|
-
for (let
|
|
239
|
-
if (t = (t + e +
|
|
240
|
-
|
|
267
|
+
const { toggle: s, items: y } = Te(n, r.next, ""), T = y.findIndex((J) => J.item.value === t.value), R = T < 0 ? 0 : T + (s ? 1 : 0);
|
|
268
|
+
f(R), ke(R);
|
|
269
|
+
}, Ve = (e) => {
|
|
270
|
+
if (v.length === 0) return;
|
|
271
|
+
let t = _ < 0 ? fe : _;
|
|
272
|
+
for (let n = 0; n < v.length; n++)
|
|
273
|
+
if (t = (t + e + v.length) % v.length, ae(v[t])) {
|
|
274
|
+
f(t), ke(t);
|
|
241
275
|
return;
|
|
242
276
|
}
|
|
243
|
-
},
|
|
244
|
-
e === c &&
|
|
245
|
-
},
|
|
246
|
-
var
|
|
247
|
-
|
|
248
|
-
|
|
277
|
+
}, Ee = (e) => {
|
|
278
|
+
e === c && E(null), G(ht(l, e));
|
|
279
|
+
}, Xe = (e) => {
|
|
280
|
+
var n, r;
|
|
281
|
+
if (m || u) return;
|
|
282
|
+
const t = e === F ? (n = l.find((s) => s.filter === e)) == null ? void 0 : n.items[0] : void 0;
|
|
283
|
+
E(t === void 0 ? e : null), b(t ?? ""), f(0), re(!0), (r = P.current) == null || r.focus();
|
|
284
|
+
}, qe = (e) => {
|
|
249
285
|
if (!(e.nativeEvent.isComposing || e.nativeEvent.keyCode === 229))
|
|
250
286
|
switch (e.key) {
|
|
251
287
|
case "ArrowDown":
|
|
252
288
|
case "ArrowUp": {
|
|
253
|
-
if (e.preventDefault(), !
|
|
254
|
-
|
|
289
|
+
if (e.preventDefault(), !a) {
|
|
290
|
+
Y();
|
|
255
291
|
return;
|
|
256
292
|
}
|
|
257
|
-
|
|
293
|
+
Ve(e.key === "ArrowDown" ? 1 : -1);
|
|
258
294
|
return;
|
|
259
295
|
}
|
|
260
296
|
case "Enter": {
|
|
261
|
-
if (e.preventDefault(), !
|
|
262
|
-
|
|
297
|
+
if (e.preventDefault(), !a) {
|
|
298
|
+
Y();
|
|
263
299
|
return;
|
|
264
300
|
}
|
|
265
|
-
const t =
|
|
266
|
-
|
|
301
|
+
const t = v[_];
|
|
302
|
+
ae(t) && Se(t);
|
|
267
303
|
return;
|
|
268
304
|
}
|
|
269
305
|
case "Backspace": {
|
|
270
|
-
if (
|
|
271
|
-
if (c !== null && !
|
|
272
|
-
e.preventDefault(),
|
|
306
|
+
if (d !== "") return;
|
|
307
|
+
if (c !== null && !l.some((s) => s.filter === c)) {
|
|
308
|
+
e.preventDefault(), E(null), f(0);
|
|
273
309
|
return;
|
|
274
310
|
}
|
|
275
|
-
const
|
|
276
|
-
if (!
|
|
277
|
-
e.preventDefault(),
|
|
311
|
+
const n = Z.filter((s) => l.some((y) => y.filter === s.filter)), r = n[n.length - 1];
|
|
312
|
+
if (!r) return;
|
|
313
|
+
e.preventDefault(), Ee(r.filter);
|
|
278
314
|
return;
|
|
279
315
|
}
|
|
280
316
|
}
|
|
281
|
-
},
|
|
282
|
-
e.stopPropagation(),
|
|
283
|
-
},
|
|
284
|
-
|
|
285
|
-
},
|
|
317
|
+
}, Be = (e) => {
|
|
318
|
+
e.stopPropagation(), G(gt(l)), E(null), b(""), H == null || H();
|
|
319
|
+
}, Ke = () => {
|
|
320
|
+
E(null), b(""), f(0);
|
|
321
|
+
}, Re = Pe && l.length > 0 && !m && !u, _ = a ? Dt(v, fe) : -1, Ze = st({ disabled: m, open: a }), Ye = g === "filters" ? "No filters available" : "No matching values", Je = {
|
|
286
322
|
position: "fixed",
|
|
287
323
|
top: (p == null ? void 0 : p.top) ?? 0,
|
|
288
324
|
left: (p == null ? void 0 : p.left) ?? 0,
|
|
289
325
|
width: p == null ? void 0 : p.width,
|
|
290
|
-
background:
|
|
291
|
-
border:
|
|
292
|
-
borderRadius:
|
|
293
|
-
boxShadow:
|
|
294
|
-
padding:
|
|
326
|
+
background: V.standard.background,
|
|
327
|
+
border: V.standard.border,
|
|
328
|
+
borderRadius: V.standard.radius,
|
|
329
|
+
boxShadow: V.standard.shadow,
|
|
330
|
+
padding: V.standard.padding,
|
|
295
331
|
display: "flex",
|
|
296
332
|
flexDirection: "column",
|
|
297
333
|
gap: 4,
|
|
298
|
-
maxHeight: (p == null ? void 0 : p.maxHeight) ??
|
|
299
|
-
fontSize:
|
|
334
|
+
maxHeight: (p == null ? void 0 : p.maxHeight) ?? St,
|
|
335
|
+
fontSize: ot[te],
|
|
300
336
|
visibility: p ? "visible" : "hidden",
|
|
301
337
|
opacity: p ? 1 : 0
|
|
302
338
|
};
|
|
303
|
-
return /* @__PURE__ */
|
|
304
|
-
/* @__PURE__ */
|
|
339
|
+
return /* @__PURE__ */ h(X, { children: [
|
|
340
|
+
/* @__PURE__ */ h(
|
|
305
341
|
"div",
|
|
306
342
|
{
|
|
307
|
-
className: `relative min-w-0 ${
|
|
308
|
-
style: { ...
|
|
343
|
+
className: `relative min-w-0 ${We}`,
|
|
344
|
+
style: { ...lt(He), ...Fe },
|
|
309
345
|
children: [
|
|
310
|
-
/* @__PURE__ */
|
|
346
|
+
/* @__PURE__ */ h(
|
|
311
347
|
"div",
|
|
312
348
|
{
|
|
313
349
|
ref: C,
|
|
314
|
-
[
|
|
315
|
-
"data-open":
|
|
350
|
+
[at]: "",
|
|
351
|
+
"data-open": a || void 0,
|
|
316
352
|
onBlur: (e) => {
|
|
317
|
-
var
|
|
353
|
+
var n, r;
|
|
318
354
|
const t = e.relatedTarget;
|
|
319
|
-
t && ((
|
|
355
|
+
t && ((n = C.current) != null && n.contains(t) || (r = S.current) != null && r.contains(t)) || I();
|
|
320
356
|
},
|
|
321
357
|
onMouseDown: (e) => {
|
|
322
358
|
var t;
|
|
323
|
-
|
|
359
|
+
m || (e.target !== P.current && e.preventDefault(), (t = P.current) == null || t.focus(), Y());
|
|
324
360
|
},
|
|
325
361
|
style: {
|
|
326
362
|
transition: "border-color 0.15s ease, box-shadow 0.15s ease",
|
|
327
|
-
...
|
|
363
|
+
...Ze
|
|
328
364
|
},
|
|
329
|
-
className: `w-full min-w-0 flex items-center border border-solid font-normal ${
|
|
365
|
+
className: `w-full min-w-0 flex items-center border border-solid font-normal ${Nt[te]} ${m ? "cursor-not-allowed" : "cursor-text"}`,
|
|
330
366
|
children: [
|
|
331
|
-
/* @__PURE__ */
|
|
332
|
-
|
|
367
|
+
/* @__PURE__ */ o(
|
|
368
|
+
Me,
|
|
333
369
|
{
|
|
334
370
|
size: 13,
|
|
335
371
|
className: "shrink-0 mr-1",
|
|
336
372
|
style: { color: "var(--malachite-text-placeholder, rgb(187, 187, 187))" }
|
|
337
373
|
}
|
|
338
374
|
),
|
|
339
|
-
/* @__PURE__ */
|
|
375
|
+
/* @__PURE__ */ h(
|
|
340
376
|
"div",
|
|
341
377
|
{
|
|
342
|
-
className: `flex flex-1 min-w-0 flex-wrap items-center ${
|
|
378
|
+
className: `flex flex-1 min-w-0 flex-wrap items-center ${It[te]} ${Re ? "pr-[18px]" : ""}`,
|
|
343
379
|
children: [
|
|
344
|
-
|
|
345
|
-
const t =
|
|
346
|
-
return /* @__PURE__ */
|
|
380
|
+
ye.map((e) => {
|
|
381
|
+
const t = a && e.filter === c;
|
|
382
|
+
return /* @__PURE__ */ h(
|
|
347
383
|
"span",
|
|
348
384
|
{
|
|
349
|
-
onMouseDown:
|
|
350
|
-
className: `inline-flex items-center gap-1 max-w-[max(60px,calc(100%-64px))] min-w-0 h-[22px] pl-1.5 pr-1 rounded-md text-xs ${t ?
|
|
385
|
+
onMouseDown: Lt,
|
|
386
|
+
className: `inline-flex items-center gap-1 max-w-[max(60px,calc(100%-64px))] min-w-0 h-[22px] pl-1.5 pr-1 rounded-md text-xs ${t ? se.active : se.resting}`,
|
|
351
387
|
children: [
|
|
352
|
-
/* @__PURE__ */
|
|
388
|
+
/* @__PURE__ */ o(
|
|
353
389
|
"button",
|
|
354
390
|
{
|
|
355
391
|
type: "button",
|
|
356
|
-
disabled:
|
|
392
|
+
disabled: m,
|
|
357
393
|
title: e.text,
|
|
358
394
|
"aria-label": `Edit filter ${e.text}`,
|
|
359
|
-
onClick: () =>
|
|
360
|
-
className: `truncate min-w-0 bg-transparent border-none p-0 text-[length:inherit] text-current ${
|
|
395
|
+
onClick: () => Xe(e.filter),
|
|
396
|
+
className: `truncate min-w-0 bg-transparent border-none p-0 text-[length:inherit] text-current ${m || u ? "cursor-default" : "cursor-pointer"} ${le}`,
|
|
361
397
|
children: e.text
|
|
362
398
|
}
|
|
363
399
|
),
|
|
364
|
-
!
|
|
400
|
+
!m && /* @__PURE__ */ o(
|
|
365
401
|
"button",
|
|
366
402
|
{
|
|
367
403
|
type: "button",
|
|
368
404
|
"aria-label": `Remove filter ${e.text}`,
|
|
369
|
-
onClick: (
|
|
370
|
-
var
|
|
371
|
-
|
|
405
|
+
onClick: (n) => {
|
|
406
|
+
var r;
|
|
407
|
+
n.stopPropagation(), Ee(e.filter), (r = P.current) == null || r.focus();
|
|
372
408
|
},
|
|
373
|
-
className: `flex items-center justify-center shrink-0 bg-transparent border-none p-0 text-current opacity-70 hover:opacity-100 cursor-pointer ${
|
|
374
|
-
children: /* @__PURE__ */
|
|
409
|
+
className: `flex items-center justify-center shrink-0 bg-transparent border-none p-0 text-current opacity-70 hover:opacity-100 cursor-pointer ${le}`,
|
|
410
|
+
children: /* @__PURE__ */ o(Ie, { size: 10 })
|
|
375
411
|
}
|
|
376
412
|
)
|
|
377
413
|
]
|
|
@@ -379,84 +415,84 @@ const yt = {
|
|
|
379
415
|
e.filter
|
|
380
416
|
);
|
|
381
417
|
}),
|
|
382
|
-
|
|
418
|
+
we > 0 && /* @__PURE__ */ h(
|
|
383
419
|
"span",
|
|
384
420
|
{
|
|
385
|
-
className: `inline-flex items-center h-[22px] px-1.5 rounded-md text-xs ${
|
|
421
|
+
className: `inline-flex items-center h-[22px] px-1.5 rounded-md text-xs ${se.resting}`,
|
|
386
422
|
children: [
|
|
387
423
|
"+",
|
|
388
|
-
|
|
424
|
+
we
|
|
389
425
|
]
|
|
390
426
|
}
|
|
391
427
|
),
|
|
392
|
-
/* @__PURE__ */
|
|
428
|
+
/* @__PURE__ */ o(
|
|
393
429
|
"input",
|
|
394
430
|
{
|
|
395
|
-
ref:
|
|
396
|
-
id:
|
|
431
|
+
ref: P,
|
|
432
|
+
id: Ge,
|
|
397
433
|
type: "text",
|
|
398
434
|
role: "combobox",
|
|
399
|
-
value:
|
|
400
|
-
disabled:
|
|
401
|
-
placeholder:
|
|
435
|
+
value: d,
|
|
436
|
+
disabled: m,
|
|
437
|
+
placeholder: Z.length === 0 ? ee : "",
|
|
402
438
|
autoComplete: "off",
|
|
403
439
|
spellCheck: !1,
|
|
404
|
-
"aria-label":
|
|
405
|
-
"aria-labelledby":
|
|
440
|
+
"aria-label": de ? void 0 : ce ?? ee,
|
|
441
|
+
"aria-labelledby": de,
|
|
406
442
|
"aria-haspopup": "listbox",
|
|
407
443
|
"aria-autocomplete": "list",
|
|
408
|
-
"aria-expanded":
|
|
409
|
-
"aria-controls":
|
|
410
|
-
"aria-activedescendant":
|
|
411
|
-
"aria-busy":
|
|
444
|
+
"aria-expanded": a,
|
|
445
|
+
"aria-controls": a ? ue : void 0,
|
|
446
|
+
"aria-activedescendant": _ >= 0 ? me(_) : void 0,
|
|
447
|
+
"aria-busy": u || void 0,
|
|
412
448
|
onChange: (e) => {
|
|
413
|
-
|
|
449
|
+
b(e.target.value), f(0), Y();
|
|
414
450
|
},
|
|
415
|
-
onKeyDown:
|
|
451
|
+
onKeyDown: qe,
|
|
416
452
|
className: "flex-1 min-w-[60px] border-none outline-none bg-transparent p-0 text-[length:inherit] text-[var(--malachite-text-primary,rgb(10,10,10))] placeholder:text-[var(--malachite-text-placeholder,rgb(187,187,187))] disabled:cursor-not-allowed"
|
|
417
453
|
}
|
|
418
454
|
)
|
|
419
455
|
]
|
|
420
456
|
}
|
|
421
457
|
),
|
|
422
|
-
/* @__PURE__ */
|
|
423
|
-
|
|
458
|
+
/* @__PURE__ */ o("span", { className: "flex items-center justify-center shrink-0 size-[14px] ml-1", children: u ? /* @__PURE__ */ o(it, { size: "xxxsmall" }) : /* @__PURE__ */ o(
|
|
459
|
+
rt,
|
|
424
460
|
{
|
|
425
461
|
size: 13,
|
|
426
462
|
style: {
|
|
427
|
-
color:
|
|
463
|
+
color: a ? "var(--malachite-text-primary, rgb(10, 10, 10))" : "var(--malachite-text-placeholder, rgb(187, 187, 187))",
|
|
428
464
|
transition: "transform 0.2s ease, color 0.2s ease",
|
|
429
|
-
transform:
|
|
465
|
+
transform: a ? "rotate(180deg)" : "rotate(0deg)"
|
|
430
466
|
}
|
|
431
467
|
}
|
|
432
468
|
) })
|
|
433
469
|
]
|
|
434
470
|
}
|
|
435
471
|
),
|
|
436
|
-
|
|
472
|
+
Re && /* @__PURE__ */ o(
|
|
437
473
|
"button",
|
|
438
474
|
{
|
|
439
475
|
type: "button",
|
|
440
476
|
"aria-label": "Clear filters",
|
|
441
|
-
onMouseDown:
|
|
442
|
-
onClick:
|
|
443
|
-
className: `absolute top-0 bottom-0 right-[30px] flex items-center justify-center px-[2px] bg-transparent border-none text-[var(--malachite-text-placeholder)] hover:text-[var(--malachite-text-primary)] cursor-pointer ${
|
|
444
|
-
children: /* @__PURE__ */
|
|
477
|
+
onMouseDown: Le,
|
|
478
|
+
onClick: Be,
|
|
479
|
+
className: `absolute top-0 bottom-0 right-[30px] flex items-center justify-center px-[2px] bg-transparent border-none text-[var(--malachite-text-placeholder)] hover:text-[var(--malachite-text-primary)] cursor-pointer ${le}`,
|
|
480
|
+
children: /* @__PURE__ */ o(Ie, { size: 10 })
|
|
445
481
|
}
|
|
446
482
|
)
|
|
447
483
|
]
|
|
448
484
|
}
|
|
449
485
|
),
|
|
450
|
-
|
|
451
|
-
/* @__PURE__ */
|
|
486
|
+
a && tt(
|
|
487
|
+
/* @__PURE__ */ h(
|
|
452
488
|
"div",
|
|
453
489
|
{
|
|
454
|
-
ref:
|
|
455
|
-
...
|
|
456
|
-
style:
|
|
457
|
-
onMouseDown:
|
|
490
|
+
ref: S,
|
|
491
|
+
...Ue,
|
|
492
|
+
style: Je,
|
|
493
|
+
onMouseDown: Le,
|
|
458
494
|
children: [
|
|
459
|
-
/* @__PURE__ */
|
|
495
|
+
/* @__PURE__ */ o(
|
|
460
496
|
"div",
|
|
461
497
|
{
|
|
462
498
|
style: {
|
|
@@ -466,14 +502,14 @@ const yt = {
|
|
|
466
502
|
gap: 4,
|
|
467
503
|
minWidth: 0
|
|
468
504
|
},
|
|
469
|
-
children: g === "items" ? /* @__PURE__ */
|
|
470
|
-
/* @__PURE__ */
|
|
505
|
+
children: g === "items" ? /* @__PURE__ */ h(X, { children: [
|
|
506
|
+
/* @__PURE__ */ o(
|
|
471
507
|
"button",
|
|
472
508
|
{
|
|
473
509
|
type: "button",
|
|
474
510
|
tabIndex: -1,
|
|
475
|
-
onClick:
|
|
476
|
-
className:
|
|
511
|
+
onClick: Ke,
|
|
512
|
+
className: $.crumb,
|
|
477
513
|
style: {
|
|
478
514
|
background: "none",
|
|
479
515
|
border: "none",
|
|
@@ -484,19 +520,19 @@ const yt = {
|
|
|
484
520
|
children: "Filters"
|
|
485
521
|
}
|
|
486
522
|
),
|
|
487
|
-
/* @__PURE__ */
|
|
523
|
+
/* @__PURE__ */ o("span", { style: q, children: `> ${(N == null ? void 0 : N.label) ?? ((Ce = z.get(c ?? "")) == null ? void 0 : Ce.label) ?? ""}` })
|
|
488
524
|
] }) : "Filters"
|
|
489
525
|
}
|
|
490
526
|
),
|
|
491
|
-
/* @__PURE__ */
|
|
527
|
+
/* @__PURE__ */ h(
|
|
492
528
|
"div",
|
|
493
529
|
{
|
|
494
|
-
ref:
|
|
495
|
-
id:
|
|
530
|
+
ref: B,
|
|
531
|
+
id: ue,
|
|
496
532
|
role: "listbox",
|
|
497
533
|
"aria-multiselectable": g !== "filters",
|
|
498
|
-
"aria-label":
|
|
499
|
-
"aria-busy":
|
|
534
|
+
"aria-label": ce ?? ee,
|
|
535
|
+
"aria-busy": u || void 0,
|
|
500
536
|
style: {
|
|
501
537
|
display: "flex",
|
|
502
538
|
flexDirection: "column",
|
|
@@ -508,11 +544,11 @@ const yt = {
|
|
|
508
544
|
scrollbarWidth: "thin"
|
|
509
545
|
},
|
|
510
546
|
children: [
|
|
511
|
-
|
|
547
|
+
u && Array.from({ length: Tt }, (e, t) => /* @__PURE__ */ o(
|
|
512
548
|
"div",
|
|
513
549
|
{
|
|
514
550
|
role: "presentation",
|
|
515
|
-
className:
|
|
551
|
+
className: $.loading,
|
|
516
552
|
style: {
|
|
517
553
|
height: 24,
|
|
518
554
|
margin: "4px 10px",
|
|
@@ -522,7 +558,7 @@ const yt = {
|
|
|
522
558
|
},
|
|
523
559
|
t
|
|
524
560
|
)),
|
|
525
|
-
!
|
|
561
|
+
!u && v.length === 0 && /* @__PURE__ */ o(
|
|
526
562
|
"div",
|
|
527
563
|
{
|
|
528
564
|
role: "presentation",
|
|
@@ -530,34 +566,34 @@ const yt = {
|
|
|
530
566
|
padding: "6px 10px",
|
|
531
567
|
color: "var(--malachite-text-secondary, rgb(123, 123, 123))"
|
|
532
568
|
},
|
|
533
|
-
children:
|
|
569
|
+
children: Ye
|
|
534
570
|
}
|
|
535
571
|
),
|
|
536
|
-
|
|
537
|
-
const
|
|
538
|
-
return /* @__PURE__ */
|
|
572
|
+
v.map((e, t) => {
|
|
573
|
+
const n = e.kind === "item" && !!e.row.item.disabled;
|
|
574
|
+
return /* @__PURE__ */ o(
|
|
539
575
|
"button",
|
|
540
576
|
{
|
|
541
|
-
id:
|
|
542
|
-
ref: (
|
|
543
|
-
|
|
577
|
+
id: me(t),
|
|
578
|
+
ref: (r) => {
|
|
579
|
+
ge.current[t] = r;
|
|
544
580
|
},
|
|
545
581
|
type: "button",
|
|
546
582
|
tabIndex: -1,
|
|
547
583
|
role: "option",
|
|
548
584
|
"aria-selected": e.kind === "item" ? e.row.selected : !1,
|
|
549
585
|
"aria-disabled": n || void 0,
|
|
550
|
-
"data-highlighted": t ===
|
|
586
|
+
"data-highlighted": t === _,
|
|
551
587
|
"data-disabled": n,
|
|
552
|
-
className:
|
|
588
|
+
className: $.row,
|
|
553
589
|
onMouseEnter: () => {
|
|
554
|
-
n ||
|
|
590
|
+
n || f(t);
|
|
555
591
|
},
|
|
556
|
-
onClick: () =>
|
|
557
|
-
style:
|
|
558
|
-
children: /* @__PURE__ */
|
|
592
|
+
onClick: () => Se(e),
|
|
593
|
+
style: At,
|
|
594
|
+
children: /* @__PURE__ */ o(Mt, { row: e, showFilter: g === "search" })
|
|
559
595
|
},
|
|
560
|
-
|
|
596
|
+
$t(e)
|
|
561
597
|
);
|
|
562
598
|
})
|
|
563
599
|
]
|
|
@@ -571,7 +607,7 @@ const yt = {
|
|
|
571
607
|
] });
|
|
572
608
|
};
|
|
573
609
|
export {
|
|
574
|
-
|
|
575
|
-
|
|
610
|
+
tr as FilterSearch,
|
|
611
|
+
tr as default
|
|
576
612
|
};
|
|
577
613
|
//# sourceMappingURL=FilterSearch.js.map
|