@nice2dev/ui 1.4.4 → 1.4.6

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.
Files changed (33) hide show
  1. package/CHANGELOG.md +59 -0
  2. package/dist/{NiceDataGrid-mrnaLHQk.cjs → NiceDataGrid-D3qRQSjy.cjs} +1 -1
  3. package/dist/NiceForm-BWb4LTQJ.cjs +1 -0
  4. package/dist/{NiceHtmlEditor-C1OVtLQ6.cjs → NiceHtmlEditor-BzECmDO3.cjs} +1 -1
  5. package/dist/{NiceMention-tgJKS8PH.cjs → NiceMention-CYRqPKGU.cjs} +19 -19
  6. package/dist/NiceModuleLifecyclePanel-CiYbPcHV.cjs +1 -0
  7. package/dist/{NicePagination-D7XxeNFz.cjs → NicePagination-BAxwqeEd.cjs} +1 -1
  8. package/dist/{NicePivotGrid-Cnkr9WkC.cjs → NicePivotGrid-Cxu5PECg.cjs} +1 -1
  9. package/dist/NiceSavedQueryPanel-BSZhE-_l.cjs +587 -0
  10. package/dist/{NiceScheduler-Boo-D1S-.cjs → NiceScheduler-BqYiHPvz.cjs} +1 -1
  11. package/dist/{core-lazy-C_qnVGxE.cjs → core-lazy-BQexApr7.cjs} +1 -1
  12. package/dist/data/NiceTreeGrid.mjs +519 -458
  13. package/dist/data.cjs +1 -1
  14. package/dist/data.d.ts +20 -1
  15. package/dist/editors.cjs +1 -1
  16. package/dist/index.cjs +98 -98
  17. package/dist/index.d.ts +197 -1
  18. package/dist/index.mjs +303 -293
  19. package/dist/lazy.cjs +1 -1
  20. package/dist/navigation.cjs +1 -1
  21. package/dist/no-code/NiceNoCodeScriptEditor.mjs +584 -0
  22. package/dist/no-code/noCodeScript.mjs +326 -0
  23. package/dist/no-code-B1jzfUF5.cjs +331 -0
  24. package/dist/no-code.cjs +1 -1
  25. package/dist/no-code.d.ts +177 -0
  26. package/dist/no-code.mjs +26 -16
  27. package/dist/style.css +2 -2
  28. package/package.json +4 -4
  29. package/dist/NiceForm-O3sv-DNX.cjs +0 -1
  30. package/dist/NiceModuleLifecyclePanel-DKlqKPy2.cjs +0 -1
  31. package/dist/NiceSavedQueryPanel-BPGpKWN2.cjs +0 -587
  32. package/dist/NiceSelect-BNPXs6FQ.cjs +0 -1
  33. package/dist/no-code-B3BHeyG-.cjs +0 -331
@@ -1,152 +1,153 @@
1
- import { jsx as a, jsxs as g, Fragment as me } from "react/jsx-runtime";
2
- import { useNiceTranslation as qn, useNiceAccessMode as Fn, useControllableState as Ue, useVirtualScroll as Hn, useTreeFocus as Wn, NiceIcon as ye } from "@nice2dev/ui-core";
3
- import Jn, { useCallback as d, useMemo as o, useState as z, useRef as T, useEffect as pe, memo as Qn } from "react";
4
- import { NiceHighlight as Xn } from "../typography/NiceHighlight.mjs";
5
- import { buildTreeFromNested as Zn, buildTreeFromFlat as er, attachLoadedChildren as tr, collectParentKeys as mt, filterTreeBySearch as nr, filterTreeChecked as rr, collectExpandableKeys as ar, sortTree as cr, flattenVisible as lr, collectKeys as sr } from "./NiceTreeGrid.helpers.mjs";
6
- import { buildTreeCheckIndex as ir, normalizeCheckedKeys as or, computeTreeCheck as rn, emitCheckedKeys as yt, toggleTreeCheck as dr, setTreeChecked as an } from "./treeCheck.mjs";
7
- const ur = [], hr = [], _t = [], fr = /* @__PURE__ */ new Set(), gr = /* @__PURE__ */ new Map(), pr = [], mr = /* @__PURE__ */ new Map(), yr = /* @__PURE__ */ new Map(), cn = [
1
+ import { jsx as a, jsxs as h, Fragment as _e } from "react/jsx-runtime";
2
+ import { useNiceTranslation as Zn, useNiceAccessMode as er, useControllableState as qe, useVirtualScroll as tr, useTreeFocus as nr, NiceThemeContext as rr, useOverlayFocus as ar, useRovingFocus as cr, NiceIcon as Q } from "@nice2dev/ui-core";
3
+ import lr, { useCallback as o, useMemo as d, useState as L, useRef as E, useEffect as ye, useContext as ir, memo as sr } from "react";
4
+ import { createPortal as or } from "react-dom";
5
+ import { NiceHighlight as dr } from "../typography/NiceHighlight.mjs";
6
+ import { buildTreeFromNested as ur, buildTreeFromFlat as hr, attachLoadedChildren as fr, collectParentKeys as bt, filterTreeBySearch as gr, filterTreeChecked as pr, collectExpandableKeys as mr, sortTree as yr, flattenVisible as _r, collectKeys as kr } from "./NiceTreeGrid.helpers.mjs";
7
+ import { buildTreeCheckIndex as br, normalizeCheckedKeys as vr, computeTreeCheck as dn, emitCheckedKeys as vt, toggleTreeCheck as wr, setTreeChecked as un } from "./treeCheck.mjs";
8
+ const Cr = [], Sr = [], wt = [], xr = /* @__PURE__ */ new Set(), Nr = /* @__PURE__ */ new Map(), Er = [], Tr = /* @__PURE__ */ new Map(), Ar = /* @__PURE__ */ new Map(), hn = [
8
9
  "expandAll",
9
10
  "collapseAll",
10
11
  "onlyChecked",
11
12
  "clearChecked"
12
- ], ln = 10;
13
- function _r({
13
+ ], fn = 10;
14
+ function Mr({
14
15
  node: v,
15
- level: Q,
16
- posInSet: X,
17
- setSize: _e,
18
- rowIndex: ke,
19
- ariaRowIndex: be,
20
- columns: L,
21
- highlight: ve,
22
- query: Z,
16
+ level: Z,
17
+ posInSet: ee,
18
+ setSize: ke,
19
+ rowIndex: be,
20
+ ariaRowIndex: ve,
21
+ columns: D,
22
+ highlight: we,
23
+ query: te,
23
24
  expandable: w,
24
25
  expanded: N,
25
- busy: ee,
26
- expandLabel: we,
27
- collapseLabel: te,
28
- subtreeAction: ne,
26
+ busy: ne,
27
+ expandLabel: Ce,
28
+ collapseLabel: re,
29
+ subtreeAction: ae,
29
30
  subtreeLabel: Se,
30
31
  checkMode: I,
31
- hasCheckbox: S,
32
- checkState: re,
33
- checkLabel: qe,
34
- locked: h,
35
- countChecked: Ce,
36
- countTotal: ae,
37
- countTitle: xe,
38
- selectColumn: Ne,
39
- selected: D,
40
- selectLabel: ce,
41
- readOnly: Ee,
42
- className: Te,
43
- clickable: Ae,
32
+ hasCheckbox: C,
33
+ checkState: ce,
34
+ checkLabel: He,
35
+ locked: f,
36
+ countChecked: xe,
37
+ countTotal: le,
38
+ countTitle: Ne,
39
+ selectColumn: Ee,
40
+ selected: O,
41
+ selectLabel: ie,
42
+ readOnly: Te,
43
+ className: Ae,
44
+ clickable: Me,
44
45
  height: A,
45
- handlers: O
46
+ handlers: $
46
47
  }) {
47
- const Me = S ? /* @__PURE__ */ a(
48
+ const Re = C ? /* @__PURE__ */ a(
48
49
  "input",
49
50
  {
50
51
  type: "checkbox",
51
52
  className: "nice-treegrid__check-input",
52
- checked: re === "checked",
53
+ checked: ce === "checked",
53
54
  ref: (p) => {
54
- p && (p.indeterminate = re === "indeterminate");
55
+ p && (p.indeterminate = ce === "indeterminate");
55
56
  },
56
- disabled: h || Ee,
57
+ disabled: f || Te,
57
58
  tabIndex: -1,
58
- "aria-label": qe,
59
+ "aria-label": He,
59
60
  onClick: (p) => p.stopPropagation(),
60
61
  onChange: (p) => {
61
- O.toggleCheck(v.key), p.currentTarget.closest("tr")?.focus({ preventScroll: !0 });
62
+ $.toggleCheck(v.key), p.currentTarget.closest("tr")?.focus({ preventScroll: !0 });
62
63
  }
63
64
  }
64
- ) : null, Fe = [
65
+ ) : null, We = [
65
66
  "nice-treegrid__row",
66
- I !== "none" && !S ? "nice-treegrid__row--info" : "",
67
- h ? "nice-treegrid__row--disabled" : "",
68
- S && re === "checked" ? "nice-treegrid__row--checked" : "",
69
- D ? "nice-datagrid__row--selected" : "",
70
- Te ?? ""
67
+ I !== "none" && !C ? "nice-treegrid__row--info" : "",
68
+ f ? "nice-treegrid__row--disabled" : "",
69
+ C && ce === "checked" ? "nice-treegrid__row--checked" : "",
70
+ O ? "nice-datagrid__row--selected" : "",
71
+ Ae ?? ""
71
72
  ].filter(Boolean).join(" ");
72
- return /* @__PURE__ */ g(
73
+ return /* @__PURE__ */ h(
73
74
  "tr",
74
75
  {
75
- className: Fe,
76
+ className: We,
76
77
  "data-key": v.key,
77
78
  tabIndex: -1,
78
- "aria-level": Q,
79
- "aria-posinset": X,
80
- "aria-setsize": _e,
81
- "aria-rowindex": be,
79
+ "aria-level": Z,
80
+ "aria-posinset": ee,
81
+ "aria-setsize": ke,
82
+ "aria-rowindex": ve,
82
83
  "aria-expanded": w ? N : void 0,
83
- "aria-selected": D,
84
- "aria-disabled": h || void 0,
85
- "aria-busy": ee || void 0,
86
- onClick: () => O.rowClick(v),
87
- style: Ae || A !== void 0 ? { cursor: Ae ? "pointer" : void 0, height: A } : void 0,
84
+ "aria-selected": O,
85
+ "aria-disabled": f || void 0,
86
+ "aria-busy": ne || void 0,
87
+ onClick: () => $.rowClick(v),
88
+ style: Me || A !== void 0 ? { cursor: Me ? "pointer" : void 0, height: A } : void 0,
88
89
  children: [
89
- I === "column" && /* @__PURE__ */ a("td", { className: "nice-datagrid__checkbox nice-treegrid__check-cell", children: Me }),
90
- Ne && /* @__PURE__ */ a("td", { className: "nice-datagrid__checkbox", children: /* @__PURE__ */ a(
90
+ I === "column" && /* @__PURE__ */ a("td", { className: "nice-datagrid__checkbox nice-treegrid__check-cell", children: Re }),
91
+ Ee && /* @__PURE__ */ a("td", { className: "nice-datagrid__checkbox", children: /* @__PURE__ */ a(
91
92
  "input",
92
93
  {
93
94
  type: "checkbox",
94
- checked: !!D,
95
- onChange: () => O.toggleSelected(v.key),
95
+ checked: !!O,
96
+ onChange: () => $.toggleSelected(v.key),
96
97
  onClick: (p) => p.stopPropagation(),
97
- disabled: Ee,
98
+ disabled: Te,
98
99
  tabIndex: -1,
99
- "aria-label": ce
100
+ "aria-label": ie
100
101
  }
101
102
  ) }),
102
- L.map((p, M) => {
103
+ D.map((p, M) => {
103
104
  const V = v.data[p.field];
104
- return /* @__PURE__ */ g("td", { style: { textAlign: p.align }, children: [
105
- M === 0 && /* @__PURE__ */ g(me, { children: [
106
- /* @__PURE__ */ a("span", { className: "nice-treegrid__indent", style: { width: (Q - 1) * 20 } }),
105
+ return /* @__PURE__ */ h("td", { style: { textAlign: p.align }, children: [
106
+ M === 0 && /* @__PURE__ */ h(_e, { children: [
107
+ /* @__PURE__ */ a("span", { className: "nice-treegrid__indent", style: { width: (Z - 1) * 20 } }),
107
108
  /* @__PURE__ */ a(
108
109
  "button",
109
110
  {
110
111
  type: "button",
111
112
  className: `nice-treegrid__toggle ${w ? "" : "nice-treegrid__toggle--leaf"}`,
112
- onClick: (P) => {
113
- P.stopPropagation(), w && O.toggleExpand(v.key, P.altKey || P.shiftKey);
113
+ onClick: (R) => {
114
+ R.stopPropagation(), w && $.toggleExpand(v.key, R.altKey || R.shiftKey);
114
115
  },
115
116
  tabIndex: -1,
116
117
  "aria-hidden": w ? void 0 : !0,
117
- "aria-label": w ? N ? te : we : void 0,
118
- children: w ? /* @__PURE__ */ a(ye, { name: N ? "chevron-down" : "chevron-right", size: 12 }) : ""
118
+ "aria-label": w ? N ? re : Ce : void 0,
119
+ children: w ? /* @__PURE__ */ a(Q, { name: N ? "chevron-down" : "chevron-right", size: 12 }) : ""
119
120
  }
120
121
  ),
121
122
  I === "tree" && /* @__PURE__ */ a(
122
123
  "span",
123
124
  {
124
- className: `nice-treegrid__check${S ? "" : " nice-treegrid__check--none"}`,
125
- children: Me
125
+ className: `nice-treegrid__check${C ? "" : " nice-treegrid__check--none"}`,
126
+ children: Re
126
127
  }
127
128
  )
128
129
  ] }),
129
- p.render ? p.render(V, v.data, ke) : ve[M] && Z ? /* @__PURE__ */ a(
130
- Xn,
130
+ p.render ? p.render(V, v.data, be) : we[M] && te ? /* @__PURE__ */ a(
131
+ dr,
131
132
  {
132
133
  text: String(V ?? ""),
133
- query: Z,
134
+ query: te,
134
135
  highlightClassName: "nice-treegrid__match"
135
136
  }
136
137
  ) : String(V ?? ""),
137
- M === 0 && ae > 0 && /* @__PURE__ */ g(
138
+ M === 0 && le > 0 && /* @__PURE__ */ h(
138
139
  "span",
139
140
  {
140
- className: `nice-treegrid__count${Ce === ae ? " nice-treegrid__count--full" : ""}`,
141
- title: xe,
141
+ className: `nice-treegrid__count${xe === le ? " nice-treegrid__count--full" : ""}`,
142
+ title: Ne,
142
143
  children: [
143
- Ce,
144
+ xe,
144
145
  "/",
145
- ae
146
+ le
146
147
  ]
147
148
  }
148
149
  ),
149
- M === 0 && ne && /* @__PURE__ */ a(
150
+ M === 0 && ae && /* @__PURE__ */ a(
150
151
  "button",
151
152
  {
152
153
  type: "button",
@@ -154,10 +155,10 @@ function _r({
154
155
  tabIndex: -1,
155
156
  "aria-label": Se,
156
157
  title: Se,
157
- onClick: (P) => {
158
- P.stopPropagation(), O.setSubtreeExpanded(v.key, ne === "expand");
158
+ onClick: (R) => {
159
+ R.stopPropagation(), $.setSubtreeExpanded(v.key, ae === "expand");
159
160
  },
160
- children: /* @__PURE__ */ a(ye, { name: ne === "expand" ? "expand" : "collapse", size: 12 })
161
+ children: /* @__PURE__ */ a(Q, { name: ae === "expand" ? "expand" : "collapse", size: 12 })
161
162
  }
162
163
  )
163
164
  ] }, p.field);
@@ -166,421 +167,432 @@ function _r({
166
167
  }
167
168
  );
168
169
  }
169
- const kr = /* @__PURE__ */ Qn(_r);
170
- function Er({
171
- columns: v = ur,
172
- data: Q = hr,
173
- keyField: X = "id",
174
- parentKeyField: _e = "parentId",
175
- nested: ke = !1,
176
- childrenField: be = "children",
177
- expandedKeys: L,
178
- defaultExpandedKeys: ve,
179
- onExpandedChange: Z,
170
+ const Rr = /* @__PURE__ */ sr(Mr);
171
+ function zr({
172
+ columns: v = Cr,
173
+ data: Z = Sr,
174
+ keyField: ee = "id",
175
+ parentKeyField: ke = "parentId",
176
+ nested: be = !1,
177
+ childrenField: ve = "children",
178
+ expandedKeys: D,
179
+ defaultExpandedKeys: we,
180
+ onExpandedChange: te,
180
181
  hasChildren: w,
181
182
  loadChildren: N,
182
- rowActions: ee,
183
- defaultExpandAll: we = !1,
184
- sortable: te = !0,
185
- sortField: ne,
183
+ rowActions: ne,
184
+ defaultExpandAll: Ce = !1,
185
+ sortable: re = !0,
186
+ sortField: ae,
186
187
  sortDirection: Se,
187
188
  onSort: I,
188
- selectable: S,
189
- selectedKeys: re,
190
- onSelectionChange: qe,
191
- checkable: h,
192
- checkedKeys: Ce,
193
- defaultCheckedKeys: ae,
194
- onCheckedChange: xe,
195
- checkStrategy: Ne = "all",
196
- isRowCheckable: D,
197
- isRowDisabled: ce,
198
- checkboxPlacement: Ee = "tree",
199
- checkOnRowClick: Te,
200
- showCheckedCount: Ae,
189
+ selectable: C,
190
+ selectedKeys: ce,
191
+ onSelectionChange: He,
192
+ checkable: f,
193
+ checkedKeys: xe,
194
+ defaultCheckedKeys: le,
195
+ onCheckedChange: Ne,
196
+ checkStrategy: Ee = "all",
197
+ isRowCheckable: O,
198
+ isRowDisabled: ie,
199
+ checkboxPlacement: Te = "tree",
200
+ checkOnRowClick: Ae,
201
+ showCheckedCount: Me,
201
202
  checkedSummary: A,
202
- showSelectAll: O = !0,
203
- showOnlyChecked: Me,
204
- defaultShowOnlyChecked: Fe,
203
+ showSelectAll: $ = !0,
204
+ showOnlyChecked: Re,
205
+ defaultShowOnlyChecked: We,
205
206
  onShowOnlyCheckedChange: p,
206
207
  toolbarActions: M,
207
208
  searchable: V,
208
- searchPlaceholder: P,
209
- searchText: sn,
210
- defaultSearchText: on,
211
- onSearchChange: dn,
212
- searchFields: kt,
213
- searchFilter: le,
214
- searchKeepDescendants: bt = !1,
215
- searchAutoExpand: vt = !0,
216
- highlightMatches: wt = !0,
217
- rowClassName: He,
218
- getRowLabel: St,
219
- virtualScroll: un,
220
- rowHeight: se = 36,
221
- height: We,
222
- striped: hn,
223
- compact: fn,
224
- size: gn = "md",
225
- loading: Ct,
226
- disabled: pn,
227
- readOnly: mn,
209
+ searchPlaceholder: R,
210
+ searchText: gn,
211
+ defaultSearchText: pn,
212
+ onSearchChange: mn,
213
+ searchFields: Ct,
214
+ searchFilter: se,
215
+ searchKeepDescendants: St = !1,
216
+ searchAutoExpand: xt = !0,
217
+ highlightMatches: Nt = !0,
218
+ rowClassName: Xe,
219
+ getRowLabel: Et,
220
+ virtualScroll: yn,
221
+ rowHeight: oe = 36,
222
+ height: Je,
223
+ striped: _n,
224
+ compact: kn,
225
+ size: bn = "md",
226
+ loading: Tt,
227
+ disabled: vn,
228
+ readOnly: wn,
228
229
  error: Pe,
229
- emptyText: yn,
230
- toolbar: xt,
231
- onRowClick: Nt,
232
- className: _n,
233
- style: kn,
234
- id: Et,
235
- testId: bn,
236
- "data-testid": vn,
237
- accessMode: wn,
238
- "aria-label": Sn,
239
- "aria-labelledby": Cn
230
+ emptyText: Cn,
231
+ toolbar: At,
232
+ onRowClick: Mt,
233
+ contextMenuItems: Ge,
234
+ className: Sn,
235
+ style: xn,
236
+ id: Rt,
237
+ testId: Nn,
238
+ "data-testid": En,
239
+ accessMode: Tn,
240
+ "aria-label": An,
241
+ "aria-labelledby": Mn
240
242
  }) {
241
- const { t: s } = qn(), Je = Fn(wn, Et), Y = !!pn || Je === "disabled", $ = !!mn || Je === "readOnly", Re = d(
242
- (e, t) => ke ? Zn(e, be, X, t) : er(e, X, _e, t),
243
- [X, _e, ke, be]
244
- ), Qe = o(() => Re(Q, 0), [Re, Q]), [ie, xn] = z(mr), [Xe, Ze] = z(yr), k = o(
245
- () => ie.size > 0 ? tr(Qe, ie, Re) : Qe,
246
- [Qe, ie, Re]
247
- ), b = o(() => {
243
+ const { t: s } = Zn(), Qe = er(Tn, Rt), Y = !!vn || Qe === "disabled", z = !!wn || Qe === "readOnly", Ke = o(
244
+ (e, t) => be ? ur(e, ve, ee, t) : hr(e, ee, ke, t),
245
+ [ee, ke, be, ve]
246
+ ), Ze = d(() => Ke(Z, 0), [Ke, Z]), [de, Rn] = L(Tr), [et, tt] = L(Ar), b = d(
247
+ () => de.size > 0 ? fr(Ze, de, Ke) : Ze,
248
+ [Ze, de, Ke]
249
+ ), _ = d(() => {
248
250
  const e = /* @__PURE__ */ new Map(), t = (n) => n.forEach((r) => {
249
251
  e.set(r.key, r), t(r.children);
250
252
  });
251
- return t(k), e;
252
- }, [k]), Ge = !!w || !!N, C = d(
253
+ return t(b), e;
254
+ }, [b]), Le = !!w || !!N, S = o(
253
255
  (e) => {
254
- if (!Ge)
256
+ if (!Le)
255
257
  return !1;
256
- const t = b.get(e);
257
- return !!t && t.children.length === 0 && !ie.has(e) && (w ? w(t.data) : !0);
258
+ const t = _.get(e);
259
+ return !!t && t.children.length === 0 && !de.has(e) && (w ? w(t.data) : !0);
258
260
  },
259
- [Ge, b, ie, w]
260
- ), et = T(/* @__PURE__ */ new Set()), tt = T(!0);
261
- pe(() => (tt.current = !0, () => {
262
- tt.current = !1;
261
+ [Le, _, de, w]
262
+ ), nt = E(/* @__PURE__ */ new Set()), rt = E(!0);
263
+ ye(() => (rt.current = !0, () => {
264
+ rt.current = !1;
263
265
  }), []);
264
- const Tt = d(
266
+ const Pt = o(
265
267
  (e) => {
266
- const t = b.get(e);
267
- if (!N || !t || et.current.has(e))
268
+ const t = _.get(e);
269
+ if (!N || !t || nt.current.has(e))
268
270
  return;
269
- et.current.add(e);
271
+ nt.current.add(e);
270
272
  const n = (r) => {
271
- et.current.delete(e), tt.current && (r && xn((i) => new Map(i).set(e, r)), Ze((i) => {
273
+ nt.current.delete(e), rt.current && (r && Rn((i) => new Map(i).set(e, r)), tt((i) => {
272
274
  const u = new Map(i);
273
275
  return r ? u.delete(e) : u.set(e, "error"), u;
274
276
  }));
275
277
  };
276
- Ze((r) => new Map(r).set(e, "loading")), N(t.data).then(
278
+ tt((r) => new Map(r).set(e, "loading")), N(t.data).then(
277
279
  (r) => n(Array.isArray(r) ? r : []),
278
280
  () => n(null)
279
281
  );
280
282
  },
281
- [N, b]
282
- ), Nn = d((e) => {
283
- Ze((t) => {
283
+ [N, _]
284
+ ), Pn = o((e) => {
285
+ tt((t) => {
284
286
  const n = new Map(t);
285
287
  return n.delete(e), n;
286
288
  });
287
- }, []), R = o(() => v.filter((e) => !e.hidden), [v]), Ke = o(() => mt(k), [k]), [nt, En] = z(null), oe = o(() => {
288
- if (L)
289
- return new Set(L);
290
- if (nt)
291
- return nt;
292
- const e = new Set(ve ?? _t);
293
- return we && Ke.forEach((t) => e.add(t)), e;
294
- }, [L, nt, ve, we, Ke]), rt = T(oe);
295
- rt.current = oe;
296
- const Le = d(
289
+ }, []), P = d(() => v.filter((e) => !e.hidden), [v]), De = d(() => bt(b), [b]), [at, Gn] = L(null), ue = d(() => {
290
+ if (D)
291
+ return new Set(D);
292
+ if (at)
293
+ return at;
294
+ const e = new Set(we ?? wt);
295
+ return Ce && De.forEach((t) => e.add(t)), e;
296
+ }, [D, at, we, Ce, De]), ct = E(ue);
297
+ ct.current = ue;
298
+ const Ie = o(
297
299
  (e) => {
298
- rt.current = e, L || En(e), Z?.([...e]);
300
+ ct.current = e, D || Gn(e), te?.([...e]);
299
301
  },
300
- [L, Z]
301
- ), [At, Tn] = z({
302
+ [D, te]
303
+ ), [Gt, Kn] = L({
302
304
  field: "",
303
305
  dir: null
304
- }), B = ne ?? At.field, G = Se ?? At.dir, An = d(
306
+ }), B = ae ?? Gt.field, G = Se ?? Gt.dir, Ln = o(
305
307
  (e) => {
306
308
  const t = B === e ? G === "asc" ? "desc" : G === "desc" ? null : "asc" : "asc";
307
- I ? I(e, t) : Tn({ field: e, dir: t });
309
+ I ? I(e, t) : Kn({ field: e, dir: t });
308
310
  },
309
311
  [B, G, I]
310
- ), [Mn, Mt] = Ue({
311
- value: re,
312
- fallbackValue: fr,
313
- onChange: qe,
312
+ ), [Dn, Kt] = qe({
313
+ value: ce,
314
+ fallbackValue: xr,
315
+ onChange: He,
314
316
  componentName: "NiceTreeGrid"
315
- }), Ie = d(
317
+ }), Oe = o(
316
318
  (e) => {
317
- Mt((t) => {
319
+ Kt((t) => {
318
320
  const n = new Set(t);
319
321
  return n.has(e) ? n.delete(e) : n.add(e), n;
320
322
  });
321
323
  },
322
- [Mt]
323
- ), c = o(
324
- () => h ? ir(k, {
324
+ [Kt]
325
+ ), c = d(
326
+ () => f ? br(b, {
325
327
  getKey: (e) => e.key,
326
328
  getChildren: (e) => e.children,
327
- isCheckable: D ? (e) => D(e.data) : void 0,
328
- isDisabled: ce ? (e) => ce(e.data) : void 0
329
+ isCheckable: O ? (e) => O(e.data) : void 0,
330
+ isDisabled: ie ? (e) => ie(e.data) : void 0
329
331
  }) : null,
330
- [h, k, D, ce]
331
- ), [Pt, Rt] = Ue({
332
- value: Ce,
333
- defaultValue: ae,
334
- fallbackValue: _t,
332
+ [f, b, O, ie]
333
+ ), [Lt, Dt] = qe({
334
+ value: xe,
335
+ defaultValue: le,
336
+ fallbackValue: wt,
335
337
  componentName: "NiceTreeGrid"
336
- }), l = o(
337
- () => c ? or(c, Pt) : null,
338
- [c, Pt]
339
- ), f = o(
340
- () => c && l ? rn(c, l.leaves) : null,
338
+ }), l = d(
339
+ () => c ? vr(c, Lt) : null,
340
+ [c, Lt]
341
+ ), g = d(
342
+ () => c && l ? dn(c, l.leaves) : null,
341
343
  [c, l]
342
- ), Gt = o(() => {
343
- if (typeof A != "function" || !c || !l || !f)
344
+ ), It = d(() => {
345
+ if (typeof A != "function" || !c || !l || !g)
344
346
  return null;
345
- const e = yt(c, l.leaves, "leaves"), t = [];
347
+ const e = vt(c, l.leaves, "leaves"), t = [];
346
348
  return e.forEach((n) => {
347
- const r = b.get(n);
349
+ const r = _.get(n);
348
350
  r && t.push(r.data);
349
- }), { checked: f.total.checked, total: f.total.total, leafKeys: e, rows: t };
350
- }, [A, c, l, f, b]), j = d(
351
+ }), { checked: g.total.checked, total: g.total.total, leafKeys: e, rows: t };
352
+ }, [A, c, l, g, _]), F = o(
351
353
  (e, t) => {
352
354
  if (!c || !l || e === l.leaves)
353
355
  return;
354
- const n = yt(c, e, Ne, l.unknown);
355
- Rt(n), xe?.(n, {
356
+ const n = vt(c, e, Ee, l.unknown);
357
+ Dt(n), Ne?.(n, {
356
358
  ...t,
357
- leafKeys: yt(c, e, "leaves"),
358
- halfCheckedKeys: [...rn(c, e).halfChecked]
359
+ leafKeys: vt(c, e, "leaves"),
360
+ halfCheckedKeys: [...dn(c, e).halfChecked]
359
361
  });
360
362
  },
361
- [c, l, Ne, Rt, xe]
362
- ), De = d(
363
+ [c, l, Ee, Dt, Ne]
364
+ ), $e = o(
363
365
  (e) => {
364
366
  if (!c || !l)
365
367
  return;
366
- const t = dr(c, l.leaves, e);
367
- j(t, {
368
+ const t = wr(c, l.leaves, e);
369
+ F(t, {
368
370
  source: "row",
369
371
  checked: t.size > l.leaves.size,
370
372
  key: e,
371
- row: b.get(e)?.data
373
+ row: _.get(e)?.data
372
374
  });
373
375
  },
374
- [c, l, j, b]
375
- ), [Oe, at] = Ue({
376
- value: sn,
377
- defaultValue: on,
376
+ [c, l, F, _]
377
+ ), [ze, lt] = qe({
378
+ value: gn,
379
+ defaultValue: pn,
378
380
  fallbackValue: "",
379
- onChange: dn,
381
+ onChange: mn,
380
382
  componentName: "NiceTreeGrid"
381
- }), x = Oe.trim(), $e = o(
382
- () => kt ?? R.map((e) => e.field),
383
- [kt, R]
384
- ), U = o(() => {
383
+ }), x = ze.trim(), Ve = d(
384
+ () => Ct ?? P.map((e) => e.field),
385
+ [Ct, P]
386
+ ), j = d(() => {
385
387
  if (!x)
386
388
  return null;
387
389
  const e = x.toLowerCase();
388
- return nr(k, le ? (n) => le(n.data, x) : (n) => $e.some(
390
+ return gr(b, se ? (n) => se(n.data, x) : (n) => Ve.some(
389
391
  (r) => String(n.data[r] ?? "").toLowerCase().includes(e)
390
- ), bt);
391
- }, [k, x, le, $e, bt]), de = U?.tree ?? k, [Kt, Pn] = Ue({
392
- value: Me,
393
- defaultValue: Fe,
392
+ ), St);
393
+ }, [b, x, se, Ve, St]), he = j?.tree ?? b, [Ot, In] = qe({
394
+ value: Re,
395
+ defaultValue: We,
394
396
  fallbackValue: !1,
395
397
  onChange: p,
396
398
  componentName: "NiceTreeGrid"
397
- }), K = !!h && Kt && f !== null, q = o(
398
- () => K && f && c ? rr(de, {
399
- state: f.state,
399
+ }), K = !!f && Ot && g !== null, U = d(
400
+ () => K && g && c ? pr(he, {
401
+ state: g.state,
400
402
  isCheckable: c.isCheckable,
401
403
  isLeaf: c.isLeaf
402
- }) : de,
403
- [K, f, c, de]
404
- ), F = x !== "" || K, H = `${x}
405
- ${K ? 1 : 0}`, [Lt, It] = z(
404
+ }) : he,
405
+ [K, g, c, he]
406
+ ), q = x !== "" || K, H = `${x}
407
+ ${K ? 1 : 0}`, [$t, zt] = L(
406
408
  () => ({ key: "", map: /* @__PURE__ */ new Map() })
407
- ), Dt = Lt.key === H ? Lt.map : gr, Ot = o(() => {
409
+ ), Vt = $t.key === H ? $t.map : Nr, Yt = d(() => {
408
410
  const e = /* @__PURE__ */ new Set();
409
- return U && vt && U.expand.forEach((t) => e.add(t)), K && c && mt(q).forEach((t) => {
411
+ return j && xt && j.expand.forEach((t) => e.add(t)), K && c && bt(U).forEach((t) => {
410
412
  c.isLeaf(t) || e.add(t);
411
413
  }), e;
412
- }, [U, vt, K, c, q]), E = d(
413
- (e) => F ? Dt.get(e) ?? (oe.has(e) || Ot.has(e)) : oe.has(e),
414
- [F, Dt, oe, Ot]
415
- ), ze = d(
414
+ }, [j, xt, K, c, U]), T = o(
415
+ (e) => q ? Vt.get(e) ?? (ue.has(e) || Yt.has(e)) : ue.has(e),
416
+ [q, Vt, ue, Yt]
417
+ ), Ye = o(
416
418
  (e, t) => {
417
- const n = rt.current;
419
+ const n = ct.current;
418
420
  if (e.some((r) => n.has(r) !== t)) {
419
421
  const r = new Set(n);
420
- e.forEach((i) => t ? r.add(i) : r.delete(i)), Le(r);
422
+ e.forEach((i) => t ? r.add(i) : r.delete(i)), Ie(r);
421
423
  }
422
- F && It((r) => {
424
+ q && zt((r) => {
423
425
  const i = new Map(r.key === H ? r.map : void 0);
424
426
  return e.forEach((u) => i.set(u, t)), { key: H, map: i };
425
427
  });
426
428
  },
427
- [Le, F, H]
428
- ), $t = d(
429
- (e) => e.children.length > 0 || C(e.key),
430
- [C]
431
- ), ue = T(/* @__PURE__ */ new Set()), Ve = d(
429
+ [Ie, q, H]
430
+ ), Bt = o(
431
+ (e) => e.children.length > 0 || S(e.key),
432
+ [S]
433
+ ), fe = E(/* @__PURE__ */ new Set()), Be = o(
432
434
  (e, t) => {
433
- const n = e.flatMap((r) => ar(r, $t));
435
+ const n = e.flatMap((r) => mr(r, Bt));
434
436
  n.forEach((r) => {
435
- t ? C(r) && ue.current.add(r) : ue.current.delete(r);
436
- }), ze(n, t);
437
+ t ? S(r) && fe.current.add(r) : fe.current.delete(r);
438
+ }), Ye(n, t);
437
439
  },
438
- [$t, C, ze]
439
- ), he = d(
440
+ [Bt, S, Ye]
441
+ ), ge = o(
440
442
  (e, t) => {
441
- const n = b.get(e);
442
- n && Ve([n], t);
443
+ const n = _.get(e);
444
+ n && Be([n], t);
443
445
  },
444
- [b, Ve]
445
- ), zt = d(
446
+ [_, Be]
447
+ ), Ft = o(
446
448
  (e, t) => {
447
- const n = !E(e);
448
- t ? he(e, n) : ze([e], n);
449
+ const n = !T(e);
450
+ t ? ge(e, n) : Ye([e], n);
449
451
  },
450
- [E, he, ze]
451
- ), Vt = T({ nodeByKey: b, isPending: C, setSubtreesExpanded: Ve });
452
- Vt.current = { nodeByKey: b, isPending: C, setSubtreesExpanded: Ve }, pe(() => {
453
- const { nodeByKey: e, isPending: t, setSubtreesExpanded: n } = Vt.current, r = [];
454
- for (const i of [...ue.current]) {
452
+ [T, ge, Ye]
453
+ ), jt = E({ nodeByKey: _, isPending: S, setSubtreesExpanded: Be });
454
+ jt.current = { nodeByKey: _, isPending: S, setSubtreesExpanded: Be }, ye(() => {
455
+ const { nodeByKey: e, isPending: t, setSubtreesExpanded: n } = jt.current, r = [];
456
+ for (const i of [...fe.current]) {
455
457
  const u = e.get(i);
456
- (!u || u.children.length > 0 || !t(i)) && (ue.current.delete(i), r.push(...u?.children ?? []));
458
+ (!u || u.children.length > 0 || !t(i)) && (fe.current.delete(i), r.push(...u?.children ?? []));
457
459
  }
458
460
  r.length > 0 && n(r, !0);
459
- }, [k]);
460
- const Rn = d(
461
+ }, [b]);
462
+ const On = o(
461
463
  (e) => {
462
- e || ue.current.clear(), Le(e ? new Set(Ke) : /* @__PURE__ */ new Set()), F && It({
464
+ e || fe.current.clear(), Ie(e ? new Set(De) : /* @__PURE__ */ new Set()), q && zt({
463
465
  key: H,
464
- map: new Map(mt(q).map((t) => [t, e]))
466
+ map: new Map(bt(U).map((t) => [t, e]))
465
467
  });
466
468
  },
467
- [Le, Ke, F, H, q]
468
- ), Yt = o(
469
- () => cr(q, B, G),
470
- [q, B, G]
471
- ), Bt = d(
472
- (e) => C(e.key) ? Xe.get(e.key) === "error" ? "error" : "loading" : null,
473
- [C, Xe]
474
- ), _ = o(
475
- () => lr(Yt, E, Ge ? Bt : void 0),
476
- [Yt, E, Ge, Bt]
477
- ), ct = ee === !0 || Array.isArray(ee) && ee.includes("expandSubtree"), Gn = o(() => {
469
+ [Ie, De, q, H, U]
470
+ ), Ut = d(
471
+ () => yr(U, B, G),
472
+ [U, B, G]
473
+ ), qt = o(
474
+ (e) => S(e.key) ? et.get(e.key) === "error" ? "error" : "loading" : null,
475
+ [S, et]
476
+ ), k = d(
477
+ () => _r(Ut, T, Le ? qt : void 0),
478
+ [Ut, T, Le, qt]
479
+ ), it = ne === !0 || Array.isArray(ne) && ne.includes("expandSubtree"), $n = d(() => {
478
480
  const e = /* @__PURE__ */ new Set();
479
- if (!ct)
481
+ if (!it)
480
482
  return e;
481
483
  const t = (n) => {
482
484
  if (n.children.length === 0)
483
- return !C(n.key);
484
- let r = E(n.key);
485
+ return !S(n.key);
486
+ let r = T(n.key);
485
487
  return n.children.forEach((i) => {
486
488
  t(i) || (r = !1);
487
489
  }), r && e.add(n.key), r;
488
490
  };
489
- return k.forEach(t), e;
490
- }, [ct, k, C, E]);
491
- pe(() => {
492
- N && _.forEach((e) => {
493
- e.placeholder === "loading" && Tt(e.node.key);
491
+ return b.forEach(t), e;
492
+ }, [it, b, S, T]);
493
+ ye(() => {
494
+ N && k.forEach((e) => {
495
+ e.placeholder === "loading" && Pt(e.node.key);
494
496
  });
495
- }, [_, N, Tt]);
496
- const W = o(() => c ? x ? sr(de).filter((e) => c.isLeaf(e)) : c.leaves : _t, [c, x, de]), jt = o(() => {
497
+ }, [k, N, Pt]);
498
+ const W = d(() => c ? x ? kr(he).filter((e) => c.isLeaf(e)) : c.leaves : wt, [c, x, he]), Ht = d(() => {
497
499
  if (!l || W.length === 0)
498
500
  return "unchecked";
499
501
  let e = 0;
500
502
  for (const t of W)
501
503
  l.leaves.has(t) && e++;
502
504
  return e === 0 ? "unchecked" : e === W.length ? "checked" : "indeterminate";
503
- }, [l, W]), Kn = d(() => {
505
+ }, [l, W]), zn = o(() => {
504
506
  if (!c || !l)
505
507
  return;
506
508
  const e = W.filter((n) => !c.isLocked(n)), t = !e.every((n) => l.leaves.has(n));
507
- j(an(c, l.leaves, e, t), {
509
+ F(un(c, l.leaves, e, t), {
508
510
  source: "selectAll",
509
511
  checked: t
510
512
  });
511
- }, [c, l, W, j]), Ln = d(() => {
512
- c && l && j(an(c, l.leaves, c.leaves, !1), {
513
+ }, [c, l, W, F]), Vn = o(() => {
514
+ c && l && F(un(c, l.leaves, c.leaves, !1), {
513
515
  source: "clear",
514
516
  checked: !1
515
517
  });
516
- }, [c, l, j]), Ut = (e) => {
517
- $ || Y || (h && Te && c?.isCheckable(e.key) ? De(e.key) : h && S && Ie(e.key), Nt?.(e.data));
518
- }, J = T({
519
- toggleExpand: zt,
520
- setSubtreeExpanded: he,
521
- toggleCheck: De,
522
- toggleSelected: Ie,
523
- rowClick: Ut
518
+ }, [c, l, F]), Wt = (e) => {
519
+ z || Y || (f && Ae && c?.isCheckable(e.key) ? $e(e.key) : f && C && Oe(e.key), Mt?.(e.data));
520
+ }, X = E({
521
+ toggleExpand: Ft,
522
+ setSubtreeExpanded: ge,
523
+ toggleCheck: $e,
524
+ toggleSelected: Oe,
525
+ rowClick: Wt
524
526
  });
525
- J.current = {
526
- toggleExpand: zt,
527
- setSubtreeExpanded: he,
528
- toggleCheck: De,
529
- toggleSelected: Ie,
530
- rowClick: Ut
527
+ X.current = {
528
+ toggleExpand: Ft,
529
+ setSubtreeExpanded: ge,
530
+ toggleCheck: $e,
531
+ toggleSelected: Oe,
532
+ rowClick: Wt
531
533
  };
532
- const qt = o(
534
+ const Xt = d(
533
535
  () => ({
534
- toggleExpand: (e, t) => J.current.toggleExpand(e, t),
535
- setSubtreeExpanded: (e, t) => J.current.setSubtreeExpanded(e, t),
536
- toggleCheck: (e) => J.current.toggleCheck(e),
537
- toggleSelected: (e) => J.current.toggleSelected(e),
538
- rowClick: (e) => J.current.rowClick(e)
536
+ toggleExpand: (e, t) => X.current.toggleExpand(e, t),
537
+ setSubtreeExpanded: (e, t) => X.current.setSubtreeExpanded(e, t),
538
+ toggleCheck: (e) => X.current.toggleCheck(e),
539
+ toggleSelected: (e) => X.current.toggleSelected(e),
540
+ rowClick: (e) => X.current.rowClick(e)
539
541
  }),
540
542
  []
541
- ), m = !!un, Ye = T(null), [Ft, In] = z(typeof We == "number" ? We : 480);
542
- pe(() => {
543
- const e = Ye.current;
543
+ ), m = !!yn, Fe = E(null), [Jt, Yn] = L(typeof Je == "number" ? Je : 480);
544
+ ye(() => {
545
+ const e = Fe.current;
544
546
  if (!m || !e || typeof ResizeObserver > "u")
545
547
  return;
546
548
  const t = new ResizeObserver(() => {
547
- e.clientHeight > 0 && In(e.clientHeight);
549
+ e.clientHeight > 0 && Yn(e.clientHeight);
548
550
  });
549
551
  return t.observe(e), () => t.disconnect();
550
552
  }, [m]);
551
- const lt = Hn({
552
- itemCount: m ? _.length : 0,
553
- itemHeight: se,
554
- containerHeight: Ft,
553
+ const st = tr({
554
+ itemCount: m ? k.length : 0,
555
+ itemHeight: oe,
556
+ containerHeight: Jt,
555
557
  overscan: 8
556
- }), st = m ? lt.startIndex : 0, it = m ? lt.endIndex : _.length, ot = T(null), Ht = T(E);
557
- Ht.current = E, Wn(ot, {
558
+ }), ot = m ? st.startIndex : 0, dt = m ? st.endIndex : k.length, ut = E(null), Qt = E(T);
559
+ Qt.current = T, nr(ut, {
558
560
  itemSelector: "tr.nice-treegrid__row",
559
561
  enabled: !Y,
560
562
  onToggle: (e, t) => {
561
563
  const n = e.dataset.key;
562
- n !== void 0 && e.hasAttribute("aria-expanded") && Ht.current(n) !== t && qt.toggleExpand(n);
564
+ n !== void 0 && e.hasAttribute("aria-expanded") && Qt.current(n) !== t && Xt.toggleExpand(n);
563
565
  }
564
566
  });
565
- const dt = d(
566
- (e) => [...ot.current?.querySelectorAll("tr.nice-treegrid__row") ?? []].find(
567
+ const Bn = ir(rr), ht = E(null), [J, Zt] = L(null), ft = o(() => Zt(null), []);
568
+ ar(ht, {
569
+ open: !!J,
570
+ modal: !1,
571
+ initialFocus: '[role="menuitem"]:not([disabled])',
572
+ onClose: ft
573
+ }), cr(ht, { orientation: "vertical", itemSelector: '[role="menuitem"]' });
574
+ const en = (e, t, n) => {
575
+ const r = Ge ? _.get(e) : void 0, i = r ? Ge?.(r.data) : void 0;
576
+ return i?.some((u) => !u.divider) ? (Zt({ key: e, x: t, y: n, items: i }), !0) : !1;
577
+ }, gt = o(
578
+ (e) => [...ut.current?.querySelectorAll("tr.nice-treegrid__row") ?? []].find(
567
579
  (t) => t.dataset.key === e
568
580
  ),
569
581
  []
570
- ), [ut, Wt] = z(null);
571
- pe(() => {
572
- if (ut === null)
582
+ ), [pt, tn] = L(null);
583
+ ye(() => {
584
+ if (pt === null)
573
585
  return;
574
- const e = dt(ut);
575
- e && (e.focus(), Wt(null));
576
- }, [ut, st, it, dt]);
577
- const Dn = (e) => {
578
- const t = _[e]?.placeholder ? e - 1 : e, n = _[t]?.node.key;
586
+ const e = gt(pt);
587
+ e && (e.focus(), tn(null));
588
+ }, [pt, ot, dt, gt]);
589
+ const Fn = (e) => {
590
+ const t = k[e]?.placeholder ? e - 1 : e, n = k[t]?.node.key;
579
591
  if (n === void 0)
580
592
  return;
581
- const r = dt(n);
582
- r ? r.focus() : m && Ye.current && (Ye.current.scrollTop = Math.max(0, t * se - Ft / 2), Wt(n));
583
- }, On = (e) => {
593
+ const r = gt(n);
594
+ r ? r.focus() : m && Fe.current && (Fe.current.scrollTop = Math.max(0, t * oe - Jt / 2), tn(n));
595
+ }, jn = (e) => {
584
596
  const t = e.target;
585
597
  if (e.altKey || e.ctrlKey || e.metaKey || !t.matches?.("tr.nice-treegrid__row"))
586
598
  return;
@@ -589,85 +601,85 @@ ${K ? 1 : 0}`, [Lt, It] = z(
589
601
  if (t.hasAttribute("aria-expanded")) {
590
602
  e.preventDefault();
591
603
  const u = getComputedStyle(t).direction === "rtl";
592
- he(n, e.key === "ArrowRight" !== u);
604
+ ge(n, e.key === "ArrowRight" !== u);
593
605
  }
594
606
  return;
595
607
  }
596
608
  if (e.key === " ") {
597
- if ($)
609
+ if (z)
598
610
  return;
599
- h && c?.isCheckable(n) ? (e.preventDefault(), De(n)) : S && (e.preventDefault(), Ie(n));
611
+ f && c?.isCheckable(n) ? (e.preventDefault(), $e(n)) : C && (e.preventDefault(), Oe(n));
600
612
  return;
601
613
  }
602
614
  if (!(e.key === "PageDown" || e.key === "PageUp") && !(m && (e.key === "Home" || e.key === "End")))
603
615
  return;
604
- const i = _.findIndex((u) => u.node.key === n);
605
- i < 0 || (e.preventDefault(), Dn(
606
- e.key === "PageDown" ? Math.min(_.length - 1, i + ln) : e.key === "PageUp" ? Math.max(0, i - ln) : e.key === "Home" ? 0 : _.length - 1
616
+ const i = k.findIndex((u) => u.node.key === n);
617
+ i < 0 || (e.preventDefault(), Fn(
618
+ e.key === "PageDown" ? Math.min(k.length - 1, i + fn) : e.key === "PageUp" ? Math.max(0, i - fn) : e.key === "Home" ? 0 : k.length - 1
607
619
  ));
608
- }, $n = s("controls.expand", "Expand"), zn = s("controls.collapse", "Collapse"), Jt = R[0]?.field, Vn = (e) => St ? St(e.data) : String((Jt != null ? e.data[Jt] : void 0) ?? e.key), Qt = (e, t) => s("treeGrid.checkedSummary", "{checked} of {total} selected").replace("{checked}", String(e)).replace("{total}", String(t)), Yn = o(() => {
609
- const e = new Set($e);
610
- return R.map((t) => wt && !le && e.has(t.field));
611
- }, [R, $e, wt, le]), ht = M === !0 ? h ? cn : cn.slice(0, 2) : Array.isArray(M) ? M.filter((e) => h || e === "expandAll" || e === "collapseAll") : pr, Be = h ? Ee === "column" ? "column" : "tree" : "none", je = !!S && !h, fe = R.length + (Be === "column" || je ? 1 : 0), Xt = [
612
- ["checked", !f || A === !1 ? null : Gt && typeof A == "function" ? A(Gt) : Qt(f.total.checked, f.total.total)],
620
+ }, Un = s("controls.expand", "Expand"), qn = s("controls.collapse", "Collapse"), nn = P[0]?.field, Hn = (e) => Et ? Et(e.data) : String((nn != null ? e.data[nn] : void 0) ?? e.key), rn = (e, t) => s("treeGrid.checkedSummary", "{checked} of {total} selected").replace("{checked}", String(e)).replace("{total}", String(t)), Wn = d(() => {
621
+ const e = new Set(Ve);
622
+ return P.map((t) => Nt && !se && e.has(t.field));
623
+ }, [P, Ve, Nt, se]), mt = M === !0 ? f ? hn : hn.slice(0, 2) : Array.isArray(M) ? M.filter((e) => f || e === "expandAll" || e === "collapseAll") : Er, je = f ? Te === "column" ? "column" : "tree" : "none", Ue = !!C && !f, pe = P.length + (je === "column" || Ue ? 1 : 0), an = [
624
+ ["checked", !g || A === !1 ? null : It && typeof A == "function" ? A(It) : rn(g.total.checked, g.total.total)],
613
625
  [
614
626
  "matches",
615
- U ? s("treeGrid.matchCount", "{count} matching rows").replace(
627
+ j ? s("treeGrid.matchCount", "{count} matching rows").replace(
616
628
  "{count}",
617
- String(U.matched.size)
629
+ String(j.matched.size)
618
630
  ) : null
619
631
  ]
620
632
  ].filter(([, e]) => e != null && e !== !1 && e !== "");
621
- if (Je === "hidden")
633
+ if (Qe === "hidden")
622
634
  return null;
623
- const ft = h && O && c && c.leaves.length > 0 ? /* @__PURE__ */ a(
635
+ const yt = f && $ && c && c.leaves.length > 0 ? /* @__PURE__ */ a(
624
636
  "input",
625
637
  {
626
638
  type: "checkbox",
627
639
  className: "nice-treegrid__check-input nice-treegrid__select-all",
628
- checked: jt === "checked",
640
+ checked: Ht === "checked",
629
641
  ref: (e) => {
630
- e && (e.indeterminate = jt === "indeterminate");
642
+ e && (e.indeterminate = Ht === "indeterminate");
631
643
  },
632
- disabled: $ || Y,
644
+ disabled: z || Y,
633
645
  "aria-label": x ? s("treeGrid.selectAllResults", "Select all results") : s("controls.selectAll", "Select all"),
634
646
  onClick: (e) => e.stopPropagation(),
635
- onChange: Kn
647
+ onChange: zn
636
648
  }
637
- ) : null, Bn = (e) => {
649
+ ) : null, Xn = (e) => {
638
650
  const t = {
639
651
  expandAll: { icon: "expand", label: s("treeGrid.expandAll", "Expand all") },
640
652
  collapseAll: { icon: "collapse", label: s("treeGrid.collapseAll", "Collapse all") },
641
653
  onlyChecked: { icon: "filter", label: s("treeGrid.showOnlyChecked", "Show selected only") },
642
654
  clearChecked: { icon: "eraser", label: s("treeGrid.clearChecked", "Clear selection") }
643
655
  }[e];
644
- return /* @__PURE__ */ g(
656
+ return /* @__PURE__ */ h(
645
657
  "button",
646
658
  {
647
659
  type: "button",
648
660
  className: `nice-btn nice-btn--sm nice-btn--ghost nice-treegrid__action${e === "onlyChecked" && K ? " nice-treegrid__action--active" : ""}`,
649
661
  "aria-pressed": e === "onlyChecked" ? K : void 0,
650
- disabled: Y || e === "clearChecked" && ($ || !f || f.total.checked === 0),
662
+ disabled: Y || e === "clearChecked" && (z || !g || g.total.checked === 0),
651
663
  onClick: () => {
652
- e === "expandAll" || e === "collapseAll" ? Rn(e === "expandAll") : e === "onlyChecked" ? Pn(!Kt) : Ln();
664
+ e === "expandAll" || e === "collapseAll" ? On(e === "expandAll") : e === "onlyChecked" ? In(!Ot) : Vn();
653
665
  },
654
666
  children: [
655
- /* @__PURE__ */ a(ye, { name: t.icon, size: 14 }),
667
+ /* @__PURE__ */ a(Q, { name: t.icon, size: 14 }),
656
668
  /* @__PURE__ */ a("span", { children: t.label })
657
669
  ]
658
670
  },
659
671
  e
660
672
  );
661
- }, jn = (e) => {
662
- const { node: t, level: n, posInSet: r, setSize: i, placeholder: u } = _[e], y = t.key;
673
+ }, Jn = (e) => {
674
+ const { node: t, level: n, posInSet: r, setSize: i, placeholder: u } = k[e], y = t.key;
663
675
  if (u)
664
676
  return /* @__PURE__ */ a(
665
677
  "tr",
666
678
  {
667
679
  className: `nice-treegrid__placeholder nice-treegrid__placeholder--${u}`,
668
680
  "aria-level": n,
669
- style: m ? { height: se } : void 0,
670
- children: /* @__PURE__ */ g("td", { colSpan: fe, children: [
681
+ style: m ? { height: oe } : void 0,
682
+ children: /* @__PURE__ */ h("td", { colSpan: pe, children: [
671
683
  /* @__PURE__ */ a("span", { className: "nice-treegrid__indent", style: { width: (n - 1) * 20 } }),
672
684
  /* @__PURE__ */ a(
673
685
  "span",
@@ -676,17 +688,17 @@ ${K ? 1 : 0}`, [Lt, It] = z(
676
688
  "aria-hidden": "true"
677
689
  }
678
690
  ),
679
- u === "loading" ? /* @__PURE__ */ g(me, { children: [
691
+ u === "loading" ? /* @__PURE__ */ h(_e, { children: [
680
692
  /* @__PURE__ */ a("span", { className: "nice-spinner nice-spinner--sm", "aria-hidden": "true" }),
681
693
  /* @__PURE__ */ a("span", { role: "status", children: s("treeGrid.loading", "Loading…") })
682
- ] }) : /* @__PURE__ */ g(me, { children: [
694
+ ] }) : /* @__PURE__ */ h(_e, { children: [
683
695
  /* @__PURE__ */ a("span", { role: "alert", children: s("treeGrid.loadError", "Could not load the rows.") }),
684
696
  /* @__PURE__ */ a(
685
697
  "button",
686
698
  {
687
699
  type: "button",
688
700
  className: "nice-btn nice-btn--sm nice-btn--ghost",
689
- onClick: () => Nn(y),
701
+ onClick: () => Pn(y),
690
702
  children: s("treeGrid.retry", "Retry")
691
703
  }
692
704
  )
@@ -695,9 +707,9 @@ ${K ? 1 : 0}`, [Lt, It] = z(
695
707
  },
696
708
  `${y}\0${u}`
697
709
  );
698
- const gt = t.children.length > 0 || C(y), tn = gt && E(y), pt = ct && gt ? Gn.has(y) ? "collapse" : "expand" : null, nn = !!c?.isCheckable(y), ge = Ae && f && c && !c.isLeaf(y) ? f.count(y) : null, Un = Vn(t);
710
+ const _t = t.children.length > 0 || S(y), sn = _t && T(y), kt = it && _t ? $n.has(y) ? "collapse" : "expand" : null, on = !!c?.isCheckable(y), me = Me && g && c && !c.isLeaf(y) ? g.count(y) : null, Qn = Hn(t);
699
711
  return /* @__PURE__ */ a(
700
- kr,
712
+ Rr,
701
713
  {
702
714
  node: t,
703
715
  level: n,
@@ -705,79 +717,79 @@ ${K ? 1 : 0}`, [Lt, It] = z(
705
717
  setSize: i,
706
718
  rowIndex: e,
707
719
  ariaRowIndex: m ? e + 2 : void 0,
708
- columns: R,
709
- highlight: Yn,
720
+ columns: P,
721
+ highlight: Wn,
710
722
  query: x,
711
- expandable: gt,
712
- expanded: tn,
713
- busy: tn && Xe.get(y) === "loading",
714
- expandLabel: $n,
715
- collapseLabel: zn,
716
- subtreeAction: pt,
717
- subtreeLabel: pt === "expand" ? s("treeGrid.expandSubtree", "Expand all below") : pt === "collapse" ? s("treeGrid.collapseSubtree", "Collapse all below") : "",
718
- checkMode: Be,
719
- hasCheckbox: nn,
720
- checkState: f ? f.state(y) : "unchecked",
721
- checkLabel: nn ? s("treeGrid.checkRow", "Select {label}").replace("{label}", Un) : "",
723
+ expandable: _t,
724
+ expanded: sn,
725
+ busy: sn && et.get(y) === "loading",
726
+ expandLabel: Un,
727
+ collapseLabel: qn,
728
+ subtreeAction: kt,
729
+ subtreeLabel: kt === "expand" ? s("treeGrid.expandSubtree", "Expand all below") : kt === "collapse" ? s("treeGrid.collapseSubtree", "Collapse all below") : "",
730
+ checkMode: je,
731
+ hasCheckbox: on,
732
+ checkState: g ? g.state(y) : "unchecked",
733
+ checkLabel: on ? s("treeGrid.checkRow", "Select {label}").replace("{label}", Qn) : "",
722
734
  locked: !!c?.isLocked(y),
723
- countChecked: ge?.checked ?? 0,
724
- countTotal: ge?.total ?? 0,
725
- countTitle: ge ? Qt(ge.checked, ge.total) : "",
726
- selectColumn: je,
727
- selected: S ? Mn.has(y) : void 0,
728
- selectLabel: je ? s("controls.selectRow", "Select row {key}").replace("{key}", y) : "",
729
- readOnly: $,
730
- className: typeof He == "function" ? He(t.data, e) : He,
731
- clickable: !$ && (!!Nt || !!Te || !!h && !!S),
732
- height: m ? se : void 0,
733
- handlers: qt
735
+ countChecked: me?.checked ?? 0,
736
+ countTotal: me?.total ?? 0,
737
+ countTitle: me ? rn(me.checked, me.total) : "",
738
+ selectColumn: Ue,
739
+ selected: C ? Dn.has(y) : void 0,
740
+ selectLabel: Ue ? s("controls.selectRow", "Select row {key}").replace("{key}", y) : "",
741
+ readOnly: z,
742
+ className: typeof Xe == "function" ? Xe(t.data, e) : Xe,
743
+ clickable: !z && (!!Mt || !!Ae || !!f && !!C),
744
+ height: m ? oe : void 0,
745
+ handlers: Xt
734
746
  },
735
747
  y
736
748
  );
737
- }, Zt = [];
738
- for (let e = st; e < it; e++)
739
- Zt.push(jn(e));
740
- const en = (e, t) => e > 0 ? /* @__PURE__ */ a("tr", { className: "nice-treegrid__spacer", "aria-hidden": "true", children: /* @__PURE__ */ a("td", { colSpan: fe, style: { height: e * se } }) }, t) : null;
741
- return /* @__PURE__ */ g(
749
+ }, cn = [];
750
+ for (let e = ot; e < dt; e++)
751
+ cn.push(Jn(e));
752
+ const ln = (e, t) => e > 0 ? /* @__PURE__ */ a("tr", { className: "nice-treegrid__spacer", "aria-hidden": "true", children: /* @__PURE__ */ a("td", { colSpan: pe, style: { height: e * oe } }) }, t) : null;
753
+ return /* @__PURE__ */ h(
742
754
  "div",
743
755
  {
744
- id: Et,
745
- "data-testid": vn ?? bn,
746
- className: `nice-treegrid nice-datagrid ${Y ? "nice-treegrid--disabled" : ""} ${$ ? "nice-treegrid--readonly" : ""} ${Pe ? "nice-treegrid--error" : ""} ${m ? "nice-treegrid--virtual" : ""} ${_n || ""}`,
747
- style: kn,
756
+ id: Rt,
757
+ "data-testid": En ?? Nn,
758
+ className: `nice-treegrid nice-datagrid ${Y ? "nice-treegrid--disabled" : ""} ${z ? "nice-treegrid--readonly" : ""} ${Pe ? "nice-treegrid--error" : ""} ${m ? "nice-treegrid--virtual" : ""} ${Sn || ""}`,
759
+ style: xn,
748
760
  "aria-disabled": Y || void 0,
749
- "aria-busy": Ct || void 0,
761
+ "aria-busy": Tt || void 0,
750
762
  "aria-invalid": !!Pe || void 0,
751
763
  children: [
752
- (V || xt || ht.length > 0) && /* @__PURE__ */ g("div", { className: "nice-datagrid__toolbar nice-treegrid__toolbar", children: [
753
- V && /* @__PURE__ */ g("div", { className: "nice-datagrid__search nice-treegrid__search", children: [
764
+ (V || At || mt.length > 0) && /* @__PURE__ */ h("div", { className: "nice-datagrid__toolbar nice-treegrid__toolbar", children: [
765
+ V && /* @__PURE__ */ h("div", { className: "nice-datagrid__search nice-treegrid__search", children: [
754
766
  /* @__PURE__ */ a(
755
767
  "input",
756
768
  {
757
769
  type: "search",
758
- value: Oe,
759
- onChange: (e) => at(e.target.value),
770
+ value: ze,
771
+ onChange: (e) => lt(e.target.value),
760
772
  onKeyDown: (e) => {
761
- e.key === "Escape" && Oe && (e.preventDefault(), at(""));
773
+ e.key === "Escape" && ze && (e.preventDefault(), lt(""));
762
774
  },
763
- placeholder: P || s("controls.search", "Search..."),
764
- "aria-label": P || s("controls.search", "Search...")
775
+ placeholder: R || s("controls.search", "Search..."),
776
+ "aria-label": R || s("controls.search", "Search...")
765
777
  }
766
778
  ),
767
- Oe && /* @__PURE__ */ a(
779
+ ze && /* @__PURE__ */ a(
768
780
  "button",
769
781
  {
770
782
  type: "button",
771
783
  className: "nice-treegrid__search-clear",
772
- onClick: () => at(""),
784
+ onClick: () => lt(""),
773
785
  "aria-label": s("treeGrid.clearSearch", "Clear search"),
774
- children: /* @__PURE__ */ a(ye, { name: "close", size: 12 })
786
+ children: /* @__PURE__ */ a(Q, { name: "close", size: 12 })
775
787
  }
776
788
  )
777
789
  ] }),
778
- ht.length > 0 && /* @__PURE__ */ a("div", { className: "nice-treegrid__actions", children: ht.map(Bn) }),
779
- xt,
780
- Xt.length > 0 && /* @__PURE__ */ a("span", { className: "nice-treegrid__summary", role: "status", children: Xt.map(([e, t], n) => /* @__PURE__ */ g(Jn.Fragment, { children: [
790
+ mt.length > 0 && /* @__PURE__ */ a("div", { className: "nice-treegrid__actions", children: mt.map(Xn) }),
791
+ At,
792
+ an.length > 0 && /* @__PURE__ */ a("span", { className: "nice-treegrid__summary", role: "status", children: an.map(([e, t], n) => /* @__PURE__ */ h(lr.Fragment, { children: [
781
793
  n > 0 && " · ",
782
794
  t
783
795
  ] }, e)) })
@@ -785,33 +797,48 @@ ${K ? 1 : 0}`, [Lt, It] = z(
785
797
  /* @__PURE__ */ a(
786
798
  "div",
787
799
  {
788
- ref: Ye,
800
+ ref: Fe,
789
801
  className: "nice-datagrid__table-wrap",
790
- style: m ? { height: We ?? 480, overflow: "auto" } : void 0,
791
- onScroll: m ? lt.onScroll : void 0,
792
- children: /* @__PURE__ */ g(
802
+ style: m ? { height: Je ?? 480, overflow: "auto" } : void 0,
803
+ onScroll: m ? st.onScroll : void 0,
804
+ children: /* @__PURE__ */ h(
793
805
  "table",
794
806
  {
795
- ref: ot,
807
+ ref: ut,
796
808
  role: "treegrid",
797
- "aria-label": Sn,
798
- "aria-labelledby": Cn,
799
- "aria-multiselectable": S || h || void 0,
800
- "aria-rowcount": m ? _.length + 1 : void 0,
801
- className: `nice-table nice-table--${gn} ${hn ? "nice-table--striped" : ""} ${fn ? "nice-table--compact" : ""}`,
802
- onKeyDownCapture: On,
809
+ "aria-label": An,
810
+ "aria-labelledby": Mn,
811
+ "aria-multiselectable": C || f || void 0,
812
+ "aria-rowcount": m ? k.length + 1 : void 0,
813
+ className: `nice-table nice-table--${bn} ${_n ? "nice-table--striped" : ""} ${kn ? "nice-table--compact" : ""}`,
814
+ onKeyDownCapture: (e) => {
815
+ if (Ge && (e.key === "ContextMenu" || e.key === "F10" && e.shiftKey)) {
816
+ const t = e.target.closest("tr.nice-treegrid__row"), n = t?.getBoundingClientRect();
817
+ if (t?.dataset.key !== void 0 && n && en(t.dataset.key, n.left + 24, n.bottom)) {
818
+ e.preventDefault(), e.stopPropagation();
819
+ return;
820
+ }
821
+ }
822
+ jn(e);
823
+ },
824
+ onContextMenu: Ge ? (e) => {
825
+ const t = e.target.closest(
826
+ "tr.nice-treegrid__row"
827
+ );
828
+ t?.dataset.key !== void 0 && en(t.dataset.key, e.clientX, e.clientY) && e.preventDefault();
829
+ } : void 0,
803
830
  children: [
804
- /* @__PURE__ */ a("thead", { children: /* @__PURE__ */ g("tr", { children: [
805
- Be === "column" && /* @__PURE__ */ a("th", { className: "nice-datagrid__checkbox nice-treegrid__th-check", children: ft }),
806
- je && /* @__PURE__ */ a("th", { className: "nice-datagrid__checkbox", style: { width: 36 } }),
807
- R.map((e, t) => /* @__PURE__ */ g(
831
+ /* @__PURE__ */ a("thead", { children: /* @__PURE__ */ h("tr", { children: [
832
+ je === "column" && /* @__PURE__ */ a("th", { className: "nice-datagrid__checkbox nice-treegrid__th-check", children: yt }),
833
+ Ue && /* @__PURE__ */ a("th", { className: "nice-datagrid__checkbox", style: { width: 36 } }),
834
+ P.map((e, t) => /* @__PURE__ */ h(
808
835
  "th",
809
836
  {
810
837
  style: { width: e.width, minWidth: e.minWidth, textAlign: e.align },
811
- className: te && e.sortable !== !1 ? "nice-datagrid__th--sortable" : void 0,
812
- onClick: () => te && e.sortable !== !1 && An(e.field),
838
+ className: re && e.sortable !== !1 ? "nice-datagrid__th--sortable" : void 0,
839
+ onClick: () => re && e.sortable !== !1 && Ln(e.field),
813
840
  children: [
814
- t === 0 && Be === "tree" && ft && /* @__PURE__ */ g(me, { children: [
841
+ t === 0 && je === "tree" && yt && /* @__PURE__ */ h(_e, { children: [
815
842
  /* @__PURE__ */ a(
816
843
  "span",
817
844
  {
@@ -819,16 +846,16 @@ ${K ? 1 : 0}`, [Lt, It] = z(
819
846
  "aria-hidden": "true"
820
847
  }
821
848
  ),
822
- /* @__PURE__ */ a("span", { className: "nice-treegrid__check", children: ft })
849
+ /* @__PURE__ */ a("span", { className: "nice-treegrid__check", children: yt })
823
850
  ] }),
824
851
  e.header,
825
- te && e.sortable !== !1 && /* @__PURE__ */ a(
852
+ re && e.sortable !== !1 && /* @__PURE__ */ a(
826
853
  "span",
827
854
  {
828
855
  className: "nice-table__sort-icon",
829
856
  style: { opacity: B === e.field && G ? void 0 : 0.3 },
830
857
  children: /* @__PURE__ */ a(
831
- ye,
858
+ Q,
832
859
  {
833
860
  name: B === e.field && G ? G === "asc" ? "sort-asc" : "sort-desc" : "sort",
834
861
  size: 12
@@ -841,28 +868,62 @@ ${K ? 1 : 0}`, [Lt, It] = z(
841
868
  e.field
842
869
  ))
843
870
  ] }) }),
844
- /* @__PURE__ */ a("tbody", { children: Ct ? /* @__PURE__ */ a("tr", { children: /* @__PURE__ */ a("td", { colSpan: fe, className: "nice-datagrid__empty", children: /* @__PURE__ */ a("div", { className: "nice-spinner nice-spinner--md", style: { margin: "0 auto" } }) }) }) : Pe ? /* @__PURE__ */ a("tr", { children: /* @__PURE__ */ a(
871
+ /* @__PURE__ */ a("tbody", { children: Tt ? /* @__PURE__ */ a("tr", { children: /* @__PURE__ */ a("td", { colSpan: pe, className: "nice-datagrid__empty", children: /* @__PURE__ */ a("div", { className: "nice-spinner nice-spinner--md", style: { margin: "0 auto" } }) }) }) : Pe ? /* @__PURE__ */ a("tr", { children: /* @__PURE__ */ a(
845
872
  "td",
846
873
  {
847
- colSpan: fe,
874
+ colSpan: pe,
848
875
  className: "nice-datagrid__empty nice-treegrid__error",
849
876
  role: "alert",
850
877
  children: Pe
851
878
  }
852
- ) }) : _.length === 0 ? /* @__PURE__ */ a("tr", { children: /* @__PURE__ */ a("td", { colSpan: fe, className: "nice-datagrid__empty", children: x ? s("controls.noResults", "No results") : yn || s("controls.noData", "No data available") }) }) : /* @__PURE__ */ g(me, { children: [
853
- en(st, "top"),
854
- Zt,
855
- en(_.length - it, "bottom")
879
+ ) }) : k.length === 0 ? /* @__PURE__ */ a("tr", { children: /* @__PURE__ */ a("td", { colSpan: pe, className: "nice-datagrid__empty", children: x ? s("controls.noResults", "No results") : Cn || s("controls.noData", "No data available") }) }) : /* @__PURE__ */ h(_e, { children: [
880
+ ln(ot, "top"),
881
+ cn,
882
+ ln(k.length - dt, "bottom")
856
883
  ] }) })
857
884
  ]
858
885
  }
859
886
  )
860
887
  }
861
- )
888
+ ),
889
+ J && typeof document < "u" && or(
890
+ /* @__PURE__ */ a(
891
+ "div",
892
+ {
893
+ ref: ht,
894
+ className: "nice-treegrid__menu",
895
+ role: "menu",
896
+ "aria-label": s("treeGrid.rowMenu", "Row actions"),
897
+ style: { position: "fixed", left: J.x, top: J.y },
898
+ children: J.items.map(
899
+ (e) => e.divider ? /* @__PURE__ */ a("div", { className: "nice-treegrid__menu-divider", role: "separator" }, e.id) : /* @__PURE__ */ h(
900
+ "button",
901
+ {
902
+ type: "button",
903
+ role: "menuitem",
904
+ className: `nice-treegrid__menu-item${e.danger ? " nice-treegrid__menu-item--danger" : ""}`,
905
+ disabled: e.disabled,
906
+ onClick: () => {
907
+ ft(), e.onSelect?.();
908
+ },
909
+ children: [
910
+ e.icon && /* @__PURE__ */ a(Q, { name: e.icon, size: 14 }),
911
+ e.label
912
+ ]
913
+ },
914
+ e.id
915
+ )
916
+ )
917
+ }
918
+ ),
919
+ Bn?.portalTarget ?? document.body
920
+ ),
921
+ J && // a click outside the menu closes it
922
+ /* @__PURE__ */ a("div", { className: "nice-treegrid__menu-backdrop", "aria-hidden": "true", onMouseDown: ft })
862
923
  ]
863
924
  }
864
925
  );
865
926
  }
866
927
  export {
867
- Er as NiceTreeGrid
928
+ zr as NiceTreeGrid
868
929
  };