@stackone/malachite 2.90.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.
@@ -1,39 +1,50 @@
1
- import { jsxs as f, Fragment as V, jsx as l } from "react/jsx-runtime";
2
- import { useId as Xe, useState as O, useRef as R, useMemo as H, useEffect as q, useCallback as B, useLayoutEffect as ke, useInsertionEffect as qe } from "react";
3
- import { createPortal as Be } from "react-dom";
4
- import Ve from "./CustomIcons/CaretDownIcon.js";
5
- import Ze from "./CustomIcons/CheckmarkIcon.js";
6
- import Se from "./CustomIcons/DismissIcon.js";
7
- import Ke from "./CustomIcons/SearchIcon.js";
8
- import Qe from "./Spinner.js";
9
- import { CONTROL_TEXT_SIZE_CLASS as ee, CONTROL_TEXT_SIZE as Ye } from "./controlTextSize.js";
10
- import { controlWidthStyle as Je } from "./controlWidth.js";
11
- import { getTriggerVisual as et, DROPDOWN_TRIGGER_ATTR as tt } from "./dropdownTriggerStyle.js";
12
- import { pushEscapeLayer as rt } from "./escapeLayers.js";
13
- import { orderSelections as nt, resolveMode as it, openFilterOf as ot, filterRows as Re, searchRows as lt, chipText as at, removeFilter as st, clearAll as ct, selectAll as pt, deselectAll as dt, toggleValue as ut } from "./filterSearchModel.js";
14
- import { ensureFilterSearchStyles as mt, FILTER_SEARCH_CLASS as D } from "./filterSearchStyles.js";
15
- import { measureMenuGeometry as ft, MENU_MAX_HEIGHT_PX as ht, MENU_SPECS as P } from "./floatingMenuGeometry.js";
16
- import { FOCUS_RING as te } from "./focusRing.js";
17
- import { usePopupLayer as gt } from "./overlayLayers.js";
18
- import { useTopLayer as xt } from "./topLayer.js";
19
- import { useFollowTrigger as bt } from "./useFollowTrigger.js";
20
- import { useLatestRef as vt } from "./useLatestRef.js";
21
- const yt = {
22
- small: `min-h-[var(--malachite-control-height-small,28px)] gap-1 px-2.5 py-[2px] ${ee.small} rounded-[var(--malachite-radius-10,10px)]`,
23
- medium: `min-h-[var(--malachite-control-height-medium,32px)] gap-1 px-3 py-[3px] ${ee.medium} rounded-xl`,
24
- large: `min-h-[var(--malachite-control-height-large,42px)] gap-1.5 px-4 py-[6px] ${ee.large} rounded-[var(--malachite-radius-xxl,14px)]`
25
- }, wt = {
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
- }, re = {
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
- }, kt = 5, ne = (i) => !!i && !(i.kind === "item" && i.row.item.disabled), St = (i, h) => {
33
- for (let a = Math.max(h, 0); a < i.length; a++)
34
- if (ne(i[a])) return a;
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
- }, Rt = {
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
- }, Ce = {
60
+ }, De = {
50
61
  borderRadius: 6,
51
62
  padding: "2px 6px",
52
63
  flexShrink: 0,
53
64
  whiteSpace: "nowrap"
54
- }, Z = {
65
+ }, q = {
55
66
  overflow: "hidden",
56
67
  textOverflow: "ellipsis",
57
68
  whiteSpace: "nowrap",
58
69
  minWidth: 0
59
- }, Ee = { ...Z, marginLeft: "auto", flexShrink: 1 }, Ne = (i) => i.preventDefault(), Ct = (i) => {
70
+ }, Ae = { ...q, marginLeft: "auto", flexShrink: 1 }, Le = (i) => i.preventDefault(), Lt = (i) => {
60
71
  i.preventDefault(), i.stopPropagation();
61
- }, Et = ({ row: i, showFilter: h }) => {
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__ */ f(V, { children: [
64
- /* @__PURE__ */ l("span", { className: D.pill, style: Ce, children: i.filter.label }),
65
- i.filter.info && /* @__PURE__ */ l("span", { style: Z, children: i.filter.info }),
66
- i.filter.example && /* @__PURE__ */ l("span", { className: D.hint, style: Ee, children: i.filter.example })
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__ */ l("span", { style: { color: "var(--malachite-text-primary, rgb(10, 10, 10))" }, children: i.toggle === "select" ? "Select All" : "Deselect All" });
70
- const { item: a, filter: T, selected: L } = i.row;
71
- return /* @__PURE__ */ f(V, { children: [
72
- h && /* @__PURE__ */ l("span", { className: D.pill, style: Ce, children: T.label }),
73
- /* @__PURE__ */ l("span", { style: Z, children: a.label }),
74
- L ? /* @__PURE__ */ l(
75
- Ze,
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
- ) : h && T.info && /* @__PURE__ */ l("span", { className: D.hint, style: Ee, children: T.info })
100
+ ) : x && D.info && /* @__PURE__ */ o("span", { className: $.hint, style: Ae, children: D.info })
85
101
  ] });
86
- }, Bt = ({
102
+ }, tr = ({
87
103
  filters: i,
88
- searchFilters: h,
89
- value: a,
90
- onChange: T,
91
- onClear: L,
92
- onActiveFilterChange: Ie,
93
- placeholder: K = "Search",
94
- size: Q = "medium",
95
- width: De,
96
- loading: d = !1,
97
- disabled: u = !1,
98
- clearable: Te = !1,
99
- maxVisibleChips: Ae = 4,
100
- className: $e = "",
101
- style: Le,
102
- id: Me,
103
- "aria-label": ie,
104
- "aria-labelledby": oe
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 we;
107
- const le = Xe(), ae = `${le}-listbox`, se = (e) => `${le}-option-${e}`, [s, Y] = O(!1), [x, y] = O(""), [c, _e] = O(null), [ce, m] = O(0), [p, pe] = O(null), C = R(null), M = R(null), w = R(null), z = R(null), de = R([]);
108
- xt(w, s);
109
- const Fe = gt("multiselect", s, w), ue = R(/* @__PURE__ */ new Map()), _ = H(() => {
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(ue.current);
112
- for (const r of [...h ?? [], ...i]) {
113
- const n = ((t = e.get(r.value)) == null ? void 0 : t.items) ?? /* @__PURE__ */ new Map();
114
- e.set(r.value, {
115
- label: r.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
- ...n,
118
- ...r.items.map((o) => [o.value, o.label])
146
+ ...r,
147
+ ...n.items.map((s) => [s.value, s.label])
119
148
  ])
120
149
  });
121
150
  }
122
151
  return e;
123
- }, [i, h]);
124
- q(() => {
125
- ue.current = _;
126
- }, [_]);
127
- const me = R([]), F = H(
128
- () => nt(a, me.current, c),
129
- [a, c]
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
- q(() => {
132
- me.current = F;
133
- }, [F]);
134
- const g = it(c, x), J = h ?? i, E = H(
135
- () => ot(c, i, h, a),
136
- [c, i, h, a]
137
- ), fe = R(c), W = vt(Ie), k = B(
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
- fe.current !== e && (fe.current = e, _e(e), (t = W.current) == null || t.call(W, e));
169
+ ve.current !== e && (ve.current = e, je(e), (t = K.current) == null || t.call(K, e));
141
170
  },
142
- [W]
143
- ), b = H(() => {
144
- if (d) return [];
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" ? Re(E, a, x) : lt(J, a, x);
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
- }, [d, g, i, J, E, a, x]), G = H(() => {
152
- const e = new Map(a.map((n) => [n.filter, n.items])), t = (n) => {
153
- const o = _.get(n), v = e.get(n);
154
- if (!v)
155
- return n === c ? [{ filter: n, text: (o == null ? void 0 : o.label) ?? n }] : [];
156
- if (!o && d) return [];
157
- const I = v.map((S) => (o == null ? void 0 : o.items.get(S)) ?? S);
158
- return [{ filter: n, text: at((o == null ? void 0 : o.label) ?? n, I) }];
159
- }, r = c !== null && !F.includes(c);
160
- return [...F, ...r ? [c] : []].flatMap(t);
161
- }, [F, a, _, d, c]), he = G.slice(0, Ae), ge = G.length - he.length, j = B(
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 && T(e, t);
193
+ t.length > 0 && D(e, t);
164
194
  },
165
- [T]
166
- ), N = B(() => {
167
- Y(!1), y(""), k(null), pe(null);
168
- }, [k]), U = () => {
169
- u || s || (m(0), Y(!0));
170
- }, A = B(() => {
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 && pe(
173
- ft(w.current, {
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
- bt(s, C, A, N), q(() => {
182
- u && s && N();
183
- }, [u, s, N]), q(() => {
184
- if (!s) return;
185
- const e = (o) => {
186
- const v = o.composedPath(), I = C.current, S = w.current;
187
- (!I || !v.includes(I)) && (!S || !v.includes(S)) && N();
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 r = () => {
220
+ const n = () => {
191
221
  t === null && (t = requestAnimationFrame(() => {
192
- t = null, A();
222
+ t = null, M();
193
223
  }));
194
- }, n = rt(N);
195
- return document.addEventListener("mousedown", e), window.addEventListener("resize", r), () => {
196
- document.removeEventListener("mousedown", e), window.removeEventListener("resize", r), t !== null && cancelAnimationFrame(t), n();
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
- }, [s, N, A]), ke(() => {
199
- if (!s || (A(), typeof ResizeObserver > "u")) return;
200
- const e = new ResizeObserver(() => A());
201
- return w.current && e.observe(w.current), C.current && e.observe(C.current), () => e.disconnect();
202
- }, [s, A]), ke(() => {
203
- z.current && (z.current.scrollTop = 0);
204
- }, [g, c, x]), qe(() => {
205
- s && mt();
206
- }, [s]);
207
- const xe = (e) => {
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 = de.current[e], r = z.current;
210
- if (!t || !r) return;
211
- const n = t.offsetTop, o = n + t.offsetHeight;
212
- o > r.scrollTop + r.clientHeight ? r.scrollTop = o - r.clientHeight : n < r.scrollTop && (r.scrollTop = n);
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
- }, be = (e) => {
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
- k(e.filter.value), y(""), m(0);
250
+ E(e.filter.value), b(""), f(0);
217
251
  return;
218
252
  }
219
253
  if (e.kind === "toggle") {
220
- const X = g === "items" && E ? [E] : J;
221
- j(
222
- e.toggle === "select" ? pt(X, a, x) : dt(X, a, x)
223
- ), y(""), m(0);
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: r } = e.row;
260
+ const { item: t, filter: n } = e.row;
227
261
  if (t.disabled) return;
228
- const n = ut(a, r.value, t.value);
229
- if (j(n), y(""), g !== "items") {
230
- m(0);
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: o, items: v } = Re(r, n.next, ""), I = v.findIndex((X) => X.item.value === t.value), S = I < 0 ? 0 : I + (o ? 1 : 0);
234
- m(S), xe(S);
235
- }, Oe = (e) => {
236
- if (b.length === 0) return;
237
- let t = $ < 0 ? ce : $;
238
- for (let r = 0; r < b.length; r++)
239
- if (t = (t + e + b.length) % b.length, ne(b[t])) {
240
- m(t), xe(t);
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
- }, ve = (e) => {
244
- e === c && k(null), j(st(a, e));
245
- }, He = (e) => {
246
- var t;
247
- u || d || (k(e), y(""), m(0), Y(!0), (t = M.current) == null || t.focus());
248
- }, Pe = (e) => {
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(), !s) {
254
- U();
289
+ if (e.preventDefault(), !a) {
290
+ Y();
255
291
  return;
256
292
  }
257
- Oe(e.key === "ArrowDown" ? 1 : -1);
293
+ Ve(e.key === "ArrowDown" ? 1 : -1);
258
294
  return;
259
295
  }
260
296
  case "Enter": {
261
- if (e.preventDefault(), !s) {
262
- U();
297
+ if (e.preventDefault(), !a) {
298
+ Y();
263
299
  return;
264
300
  }
265
- const t = b[$];
266
- ne(t) && be(t);
301
+ const t = v[_];
302
+ ae(t) && Se(t);
267
303
  return;
268
304
  }
269
305
  case "Backspace": {
270
- if (x !== "") return;
271
- if (c !== null && !a.some((o) => o.filter === c)) {
272
- e.preventDefault(), k(null), m(0);
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 r = G.filter((o) => a.some((v) => v.filter === o.filter)), n = r[r.length - 1];
276
- if (!n) return;
277
- e.preventDefault(), ve(n.filter);
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
- }, ze = (e) => {
282
- e.stopPropagation(), j(ct(a)), k(null), y(""), L == null || L();
283
- }, We = () => {
284
- k(null), y(""), m(0);
285
- }, ye = Te && a.length > 0 && !u && !d, $ = s ? St(b, ce) : -1, Ge = et({ disabled: u, open: s }), je = g === "filters" ? "No filters available" : "No matching values", Ue = {
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: P.standard.background,
291
- border: P.standard.border,
292
- borderRadius: P.standard.radius,
293
- boxShadow: P.standard.shadow,
294
- padding: P.standard.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) ?? ht,
299
- fontSize: Ye[Q],
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__ */ f(V, { children: [
304
- /* @__PURE__ */ f(
339
+ return /* @__PURE__ */ h(X, { children: [
340
+ /* @__PURE__ */ h(
305
341
  "div",
306
342
  {
307
- className: `relative min-w-0 ${$e}`,
308
- style: { ...Je(De), ...Le },
343
+ className: `relative min-w-0 ${We}`,
344
+ style: { ...lt(He), ...Fe },
309
345
  children: [
310
- /* @__PURE__ */ f(
346
+ /* @__PURE__ */ h(
311
347
  "div",
312
348
  {
313
349
  ref: C,
314
- [tt]: "",
315
- "data-open": s || void 0,
350
+ [at]: "",
351
+ "data-open": a || void 0,
316
352
  onBlur: (e) => {
317
- var r, n;
353
+ var n, r;
318
354
  const t = e.relatedTarget;
319
- t && ((r = C.current) != null && r.contains(t) || (n = w.current) != null && n.contains(t)) || N();
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
- u || (e.target !== M.current && e.preventDefault(), (t = M.current) == null || t.focus(), U());
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
- ...Ge
363
+ ...Ze
328
364
  },
329
- className: `w-full min-w-0 flex items-center border border-solid font-normal ${yt[Q]} ${u ? "cursor-not-allowed" : "cursor-text"}`,
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__ */ l(
332
- Ke,
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__ */ f(
375
+ /* @__PURE__ */ h(
340
376
  "div",
341
377
  {
342
- className: `flex flex-1 min-w-0 flex-wrap items-center ${wt[Q]} ${ye ? "pr-[18px]" : ""}`,
378
+ className: `flex flex-1 min-w-0 flex-wrap items-center ${It[te]} ${Re ? "pr-[18px]" : ""}`,
343
379
  children: [
344
- he.map((e) => {
345
- const t = s && e.filter === c;
346
- return /* @__PURE__ */ f(
380
+ ye.map((e) => {
381
+ const t = a && e.filter === c;
382
+ return /* @__PURE__ */ h(
347
383
  "span",
348
384
  {
349
- onMouseDown: Ct,
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 ? re.active : re.resting}`,
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__ */ l(
388
+ /* @__PURE__ */ o(
353
389
  "button",
354
390
  {
355
391
  type: "button",
356
- disabled: u,
392
+ disabled: m,
357
393
  title: e.text,
358
394
  "aria-label": `Edit filter ${e.text}`,
359
- onClick: () => He(e.filter),
360
- className: `truncate min-w-0 bg-transparent border-none p-0 text-[length:inherit] text-current ${u || d ? "cursor-default" : "cursor-pointer"} ${te}`,
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
- !u && /* @__PURE__ */ l(
400
+ !m && /* @__PURE__ */ o(
365
401
  "button",
366
402
  {
367
403
  type: "button",
368
404
  "aria-label": `Remove filter ${e.text}`,
369
- onClick: (r) => {
370
- var n;
371
- r.stopPropagation(), ve(e.filter), (n = M.current) == null || n.focus();
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 ${te}`,
374
- children: /* @__PURE__ */ l(Se, { size: 10 })
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
- ge > 0 && /* @__PURE__ */ f(
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 ${re.resting}`,
421
+ className: `inline-flex items-center h-[22px] px-1.5 rounded-md text-xs ${se.resting}`,
386
422
  children: [
387
423
  "+",
388
- ge
424
+ we
389
425
  ]
390
426
  }
391
427
  ),
392
- /* @__PURE__ */ l(
428
+ /* @__PURE__ */ o(
393
429
  "input",
394
430
  {
395
- ref: M,
396
- id: Me,
431
+ ref: P,
432
+ id: Ge,
397
433
  type: "text",
398
434
  role: "combobox",
399
- value: x,
400
- disabled: u,
401
- placeholder: G.length === 0 ? K : "",
435
+ value: d,
436
+ disabled: m,
437
+ placeholder: Z.length === 0 ? ee : "",
402
438
  autoComplete: "off",
403
439
  spellCheck: !1,
404
- "aria-label": oe ? void 0 : ie ?? K,
405
- "aria-labelledby": oe,
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": s,
409
- "aria-controls": s ? ae : void 0,
410
- "aria-activedescendant": $ >= 0 ? se($) : void 0,
411
- "aria-busy": d || void 0,
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
- y(e.target.value), m(0), U();
449
+ b(e.target.value), f(0), Y();
414
450
  },
415
- onKeyDown: Pe,
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__ */ l("span", { className: "flex items-center justify-center shrink-0 size-[14px] ml-1", children: d ? /* @__PURE__ */ l(Qe, { size: "xxxsmall" }) : /* @__PURE__ */ l(
423
- Ve,
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: s ? "var(--malachite-text-primary, rgb(10, 10, 10))" : "var(--malachite-text-placeholder, rgb(187, 187, 187))",
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: s ? "rotate(180deg)" : "rotate(0deg)"
465
+ transform: a ? "rotate(180deg)" : "rotate(0deg)"
430
466
  }
431
467
  }
432
468
  ) })
433
469
  ]
434
470
  }
435
471
  ),
436
- ye && /* @__PURE__ */ l(
472
+ Re && /* @__PURE__ */ o(
437
473
  "button",
438
474
  {
439
475
  type: "button",
440
476
  "aria-label": "Clear filters",
441
- onMouseDown: Ne,
442
- onClick: ze,
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 ${te}`,
444
- children: /* @__PURE__ */ l(Se, { size: 10 })
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
- s && Be(
451
- /* @__PURE__ */ f(
486
+ a && tt(
487
+ /* @__PURE__ */ h(
452
488
  "div",
453
489
  {
454
- ref: w,
455
- ...Fe,
456
- style: Ue,
457
- onMouseDown: Ne,
490
+ ref: S,
491
+ ...Ue,
492
+ style: Je,
493
+ onMouseDown: Le,
458
494
  children: [
459
- /* @__PURE__ */ l(
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__ */ f(V, { children: [
470
- /* @__PURE__ */ l(
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: We,
476
- className: D.crumb,
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__ */ l("span", { style: Z, children: `> ${(E == null ? void 0 : E.label) ?? ((we = _.get(c ?? "")) == null ? void 0 : we.label) ?? ""}` })
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__ */ f(
527
+ /* @__PURE__ */ h(
492
528
  "div",
493
529
  {
494
- ref: z,
495
- id: ae,
530
+ ref: B,
531
+ id: ue,
496
532
  role: "listbox",
497
533
  "aria-multiselectable": g !== "filters",
498
- "aria-label": ie ?? K,
499
- "aria-busy": d || void 0,
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
- d && Array.from({ length: kt }, (e, t) => /* @__PURE__ */ l(
547
+ u && Array.from({ length: Tt }, (e, t) => /* @__PURE__ */ o(
512
548
  "div",
513
549
  {
514
550
  role: "presentation",
515
- className: D.loading,
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
- !d && b.length === 0 && /* @__PURE__ */ l(
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: je
569
+ children: Ye
534
570
  }
535
571
  ),
536
- b.map((e, t) => {
537
- const r = e.kind === "filter" ? `filter:${e.filter.value}` : e.kind === "toggle" ? "toggle" : `item:${e.row.filter.value}:${e.row.item.value}`, n = e.kind === "item" && !!e.row.item.disabled;
538
- return /* @__PURE__ */ l(
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: se(t),
542
- ref: (o) => {
543
- de.current[t] = o;
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: D.row,
588
+ className: $.row,
553
589
  onMouseEnter: () => {
554
- n || m(t);
590
+ n || f(t);
555
591
  },
556
- onClick: () => be(e),
557
- style: Rt,
558
- children: /* @__PURE__ */ l(Et, { row: e, showFilter: g === "search" })
592
+ onClick: () => Se(e),
593
+ style: At,
594
+ children: /* @__PURE__ */ o(Mt, { row: e, showFilter: g === "search" })
559
595
  },
560
- r
596
+ $t(e)
561
597
  );
562
598
  })
563
599
  ]
@@ -571,7 +607,7 @@ const yt = {
571
607
  ] });
572
608
  };
573
609
  export {
574
- Bt as FilterSearch,
575
- Bt as default
610
+ tr as FilterSearch,
611
+ tr as default
576
612
  };
577
613
  //# sourceMappingURL=FilterSearch.js.map