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