@progress/kendo-react-treelist 15.2.0-develop.1 → 15.2.0-develop.3

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 (38) hide show
  1. package/TreeList.d.ts +10 -121
  2. package/TreeList.js +1 -1
  3. package/TreeList.mjs +840 -526
  4. package/TreeListNoRecords.d.ts +8 -6
  5. package/TreeListNoRecords.js +1 -1
  6. package/TreeListNoRecords.mjs +15 -12
  7. package/cells/EditCells/TreeListBooleanEditor.js +1 -1
  8. package/cells/EditCells/TreeListBooleanEditor.mjs +5 -5
  9. package/cells/EditCells/TreeListDateEditor.js +1 -1
  10. package/cells/EditCells/TreeListDateEditor.mjs +9 -9
  11. package/cells/EditCells/TreeListNumericEditor.js +1 -1
  12. package/cells/EditCells/TreeListNumericEditor.mjs +9 -9
  13. package/cells/EditCells/TreeListTextEditor.js +1 -1
  14. package/cells/EditCells/TreeListTextEditor.mjs +4 -4
  15. package/cells/TreeListCell.js +1 -1
  16. package/cells/TreeListCell.mjs +10 -10
  17. package/cells/TreeListSelectionCell.js +1 -1
  18. package/cells/TreeListSelectionCell.mjs +1 -1
  19. package/dist/cdn/js/kendo-react-treelist.js +1 -1
  20. package/header/TreeListHeaderSelectionCell.d.ts +10 -6
  21. package/header/TreeListHeaderSelectionCell.js +1 -1
  22. package/header/TreeListHeaderSelectionCell.mjs +16 -14
  23. package/index.d.mts +5 -7
  24. package/index.d.ts +5 -7
  25. package/index.js +1 -1
  26. package/index.mjs +49 -50
  27. package/interfaces/events.d.ts +6 -6
  28. package/package-metadata.js +1 -1
  29. package/package-metadata.mjs +2 -2
  30. package/package.json +9 -9
  31. package/rows/TreeListDraggableRow.d.ts +7 -26
  32. package/rows/TreeListDraggableRow.js +1 -1
  33. package/rows/TreeListDraggableRow.mjs +88 -77
  34. package/rows/TreeListRow.js +1 -1
  35. package/rows/TreeListRow.mjs +1 -1
  36. package/TreeListMcpWrapper.d.ts +0 -17
  37. package/TreeListMcpWrapper.js +0 -8
  38. package/TreeListMcpWrapper.mjs +0 -18
package/TreeList.mjs CHANGED
@@ -5,582 +5,896 @@
5
5
  * Licensed under commercial license. See LICENSE.md in the package root for more information
6
6
  *-------------------------------------------------------------------------------------------
7
7
  */
8
- import * as r from "react";
9
- import n from "prop-types";
10
- import { memoizeOne as A, getNestedValue as y, validatePackage as Z, getLicenseMessage as ee, noop as K, canUseDOM as te, getAbsoluteVirtualRowIndex as oe, getter as se, classNames as ne, WatermarkOverlay as ae } from "@progress/kendo-react-common";
11
- import { readColumns as ie, mapColumns as le, tableKeyboardNavigation as S, getSelectionOptions as O, CommonDragLogic as re, ColumnResize as he, TableKeyboardNavigationContext as P, tableKeyboardNavigationTools as V, Header as de, FilterRow as ce, HeaderRow as pe, tableColumnsVirtualization as ge, tableKeyboardNavigationScopeAttributes as ue, TableSelection as me, tableKeyboardNavigationBodyAttributes as fe, DropClue as Ce, DragClue as ve, flatData as be } from "@progress/kendo-react-data-tools";
12
- import { setHeaderRowsTop as Se, tableRowsVirtualization as we } from "./utils/index.mjs";
13
- import { TreeListCell as Re } from "./cells/TreeListCell.mjs";
14
- import { TreeListNoRecords as xe } from "./TreeListNoRecords.mjs";
15
- import { TreeListRow as ye } from "./rows/TreeListRow.mjs";
16
- import { packageMetadata as B } from "./package-metadata.mjs";
17
- const M = class M extends r.Component {
18
- constructor(h) {
19
- super(h), this.element = null, this.wrapperScrollLeft = 0, this.wrapperScrollTop = 0, this.updateOnScroll = !1, this.tbodyOffsetTop = 0, this.prevData = [], this.flattedData = [], this.extendedColumn = [], this.columnsMap = [], this.contextStateRef = { current: void 0 }, this.navigationStateRef = { current: void 0 }, this.showLicenseWatermark = !1, this.licenseMessage = void 0, this.scrollIntoView = (e) => {
20
- if (!this.element)
21
- return;
22
- const { rowIndex: t = 0 } = e, { scrollable: o, rowHeight: s = 0 } = this.props;
23
- if (o === "virtual" || s)
24
- this.element.scroll(0, (t - 1) * s);
25
- else {
26
- const l = this.element.querySelector(`tbody > tr:nth-child(${t})`);
27
- if (l) {
28
- const i = l.offsetTop - this.tbodyOffsetTop;
29
- this.element.scroll(0, i);
8
+ import * as t from "react";
9
+ import c from "prop-types";
10
+ import { validatePackage as tn, getLicenseMessage as nn, getNestedValue as D, memoizeOne as nt, useWebMcpRegister as rn, noop as rt, getter as an, classNames as ke, WatermarkOverlay as at, canUseDOM as on } from "@progress/kendo-react-common";
11
+ import { readColumns as ln, mapColumns as cn, ColumnResize as sn, CommonDragLogic as un, tableKeyboardNavigation as K, getSelectionOptions as ot, tableKeyboardNavigationTools as Se, tableColumnsVirtualization as dn, Header as fn, FilterRow as gn, HeaderRow as hn, TableKeyboardNavigationContext as lt, tableKeyboardNavigationScopeAttributes as ct, TableSelection as st, tableKeyboardNavigationBodyAttributes as it, DropClue as ut, DragClue as dt, flatData as mn } from "@progress/kendo-react-data-tools";
12
+ import { setHeaderRowsTop as pn, tableRowsVirtualization as bn } from "./utils/index.mjs";
13
+ import { TreeListCell as vn } from "./cells/TreeListCell.mjs";
14
+ import { TreeListNoRecords as Cn } from "./TreeListNoRecords.mjs";
15
+ import { TreeListRow as Rn } from "./rows/TreeListRow.mjs";
16
+ import { packageMetadata as ft } from "./package-metadata.mjs";
17
+ const gt = t.forwardRef((H, ht) => {
18
+ var Ye;
19
+ const {
20
+ columns: B = [],
21
+ filterRow: xe,
22
+ scrollable: O = "scrollable",
23
+ resizable: Ie = !1,
24
+ reorderable: V = !1,
25
+ skip: G,
26
+ take: J,
27
+ data: ae = [],
28
+ rowHeight: Fe,
29
+ columnVirtualization: mt,
30
+ selectable: A,
31
+ selectedField: oe,
32
+ editField: pt,
33
+ expandField: le,
34
+ subItemsField: U,
35
+ dataItemKey: De,
36
+ id: Q,
37
+ style: ce,
38
+ className: He,
39
+ toolbar: Me,
40
+ noRecords: bt,
41
+ tableProps: vt,
42
+ pager: X,
43
+ sort: $,
44
+ sortable: Ct,
45
+ filter: Rt,
46
+ columnMenu: Et,
47
+ columnMenuFilter: wt,
48
+ row: yt,
49
+ editRow: Ne,
50
+ rowRender: kt,
51
+ cellRender: St,
52
+ headerCellRender: xt
53
+ } = H, C = t.useRef(null), se = t.useRef(null), E = t.useRef(null), Y = t.useRef(null), M = t.useRef(null), j = t.useRef(null), Te = t.useRef(!1), ie = t.useRef(!1), ue = t.useRef(!1), de = t.useRef(0), fe = t.useRef(0), Z = t.useRef(!1), ee = t.useRef(0), ge = t.useRef([]), _ = t.useRef([]), w = t.useRef([]), q = t.useRef([]), s = t.useRef(H);
54
+ s.current = H;
55
+ const y = t.useRef({ current: void 0 }), x = t.useRef({ current: void 0 }), Le = t.useMemo(() => !tn(ft, { component: "TreeList" }), []), Pe = t.useMemo(() => nn(ft), []), b = t.useRef(null), R = t.useRef(null), [, It] = t.useReducer((e) => !e, !0), T = Q ? Q + "-treelist" : void 0, ze = () => {
56
+ var e;
57
+ if (on)
58
+ return ((e = C.current) == null ? void 0 : e.ownerDocument) || document;
59
+ }, We = t.useCallback(
60
+ (e) => !!D(le, e),
61
+ [le]
62
+ ), Ke = t.useCallback(
63
+ (e) => !!D(U, e),
64
+ [U]
65
+ ), Ft = t.useCallback(
66
+ (e) => {
67
+ const n = [];
68
+ return We(e) && Ke(e) && n.push(...D(U, e)), n;
69
+ },
70
+ [We, Ke, U]
71
+ ), he = t.useMemo(
72
+ () => nt((e, n) => ln(e, {
73
+ prevId: 0,
74
+ idPrefix: n
75
+ })),
76
+ []
77
+ ), me = t.useMemo(
78
+ () => nt(
79
+ (e, n) => cn(e, n)
80
+ ),
81
+ []
82
+ ), g = t.useRef(null), Dt = t.useCallback((e) => {
83
+ if (!C.current)
84
+ return;
85
+ const { rowIndex: n = 0 } = e, r = s.current, a = r.rowHeight || 0, l = E.current || C.current;
86
+ if (r.scrollable === "virtual" || a)
87
+ l.scroll(0, (n - 1) * a);
88
+ else {
89
+ const u = (E.current || C.current).querySelector(
90
+ `tbody > tr:nth-child(${n})`
91
+ );
92
+ if (u) {
93
+ const o = u.offsetTop - ee.current;
94
+ l.scroll(0, o);
95
+ }
96
+ }
97
+ }, []);
98
+ if (t.useImperativeHandle(
99
+ g,
100
+ () => ({
101
+ get element() {
102
+ return C.current;
103
+ },
104
+ props: H,
105
+ scrollIntoView: Dt
106
+ })
107
+ ), t.useImperativeHandle(ht, () => g.current), rn("treelist", g, H, H.webMcp), !b.current) {
108
+ const e = (a, l, u, o, d) => {
109
+ var p, i, f;
110
+ const h = (p = b.current) == null ? void 0 : p.colGroupMain;
111
+ if (h) {
112
+ let v = 0;
113
+ const m = h.children;
114
+ for (let F = 0; F < m.length; F++) {
115
+ const W = m[F].style.width;
116
+ if (!W) {
117
+ v = 0;
118
+ break;
119
+ }
120
+ v += parseFloat(W);
30
121
  }
122
+ v = Math.round(v);
123
+ const N = v ? v + "px" : "";
124
+ M.current && (M.current.style.width = N), j.current && (j.current.style.width = N);
31
125
  }
32
- }, this.getExtendedColumn = A((e, t) => ie(e, {
33
- prevId: 0,
34
- idPrefix: t
35
- })), this.getColumnsMap = A((e, t) => le(e, t)), this.onKeyDown = (e) => {
36
- if (S.onKeyDown(e, {
37
- navigatable: !1,
38
- contextStateRef: this.contextStateRef,
39
- navigationStateRef: this.navigationStateRef
40
- }), this.props.onKeyDown) {
41
- const { mode: t, cell: o } = O(this.props.selectable), s = {
42
- dataItems: this.getLeafDataItems(),
43
- mode: t,
44
- cell: o,
45
- componentId: this._treeListId,
46
- selectedField: this.props.selectedField || "",
47
- ...this.getArguments(e)
126
+ if (s.current.onColumnResize) {
127
+ let v = 0;
128
+ const m = (f = (i = b.current) == null ? void 0 : i.colGroupMain) == null ? void 0 : f.children;
129
+ if (m)
130
+ for (let S = 0; S < m.length; S++)
131
+ v += parseFloat(m[S].style.width || "0");
132
+ const F = w.current.filter(
133
+ (S) => S.declarationIndex >= 0 && S.parentIndex === -1
134
+ ), W = (S) => (S.sort((re, Ee) => re.declarationIndex - Ee.declarationIndex), S.map((re) => {
135
+ const {
136
+ declarationIndex: Ee,
137
+ parentIndex: Zt,
138
+ depth: en,
139
+ colSpan: we,
140
+ rowSpan: ye,
141
+ index: wn,
142
+ kFirst: yn,
143
+ groupable: kn,
144
+ children: et,
145
+ ...tt
146
+ } = re;
147
+ return et.length ? { children: W(et), ...tt } : tt;
148
+ })), Ze = {
149
+ columns: W(F),
150
+ totalWidth: v,
151
+ index: a,
152
+ nativeEvent: o,
153
+ newWidth: l,
154
+ oldWidth: u,
155
+ end: d,
156
+ target: g.current
48
157
  };
49
- this.props.onKeyDown.call(void 0, s);
158
+ s.current.onColumnResize(Ze);
50
159
  }
51
- }, this.onFocus = (e) => {
52
- S.onFocus(e, {
53
- contextStateRef: this.contextStateRef
54
- });
55
- }, this.onRowDrag = (e) => {
56
- this.props.onRowDrag && this.props.onRowDrag.call(void 0, { ...e, target: this });
57
- }, this.onRowDrop = (e) => {
58
- this.props.onRowDrop && this.props.onRowDrop.call(void 0, { ...e, target: this });
59
- }, this.columnReorder = (e, t, o) => {
60
- const s = this.extendedColumn[e].depth, l = (d) => {
160
+ };
161
+ b.current = new sn(e);
162
+ const n = (a, l, u) => {
163
+ const o = w.current, d = o[a].depth, h = (i) => {
61
164
  do
62
- d++;
63
- while (d < this.extendedColumn.length && this.extendedColumn[d].depth > s);
64
- return d;
65
- }, i = this.extendedColumn.splice(e, l(e) - e);
66
- if (this.extendedColumn.splice(e < t ? l(t - i.length) : t, 0, ...i), this.extendedColumn.filter((d) => d.declarationIndex >= 0).forEach((d, g) => d.orderIndex = g), this.props.onColumnReorder) {
67
- const d = {
68
- target: this,
69
- columns: this.columns,
70
- nativeEvent: o
165
+ i++;
166
+ while (i < o.length && o[i].depth > d);
167
+ return i;
168
+ }, p = o.splice(a, h(a) - a);
169
+ if (o.splice(a < l ? h(l - p.length) : l, 0, ...p), o.filter((i) => i.declarationIndex >= 0).forEach((i, f) => i.orderIndex = f), s.current.onColumnReorder) {
170
+ const i = o.filter(
171
+ (m) => m.declarationIndex >= 0 && m.parentIndex === -1
172
+ ), f = (m) => (m.sort((N, F) => N.declarationIndex - F.declarationIndex), m.map((N) => {
173
+ const {
174
+ declarationIndex: F,
175
+ parentIndex: W,
176
+ depth: Ze,
177
+ colSpan: S,
178
+ rowSpan: re,
179
+ index: Ee,
180
+ kFirst: Zt,
181
+ groupable: en,
182
+ children: we,
183
+ ...ye
184
+ } = N;
185
+ return we.length ? { children: f(we), ...ye } : ye;
186
+ })), v = {
187
+ target: g.current,
188
+ columns: f(i),
189
+ nativeEvent: u
71
190
  };
72
- this.props.onColumnReorder.call(void 0, d);
191
+ s.current.onColumnReorder(v);
192
+ }
193
+ };
194
+ R.current = new un(n, rt, rt);
195
+ const r = b.current.dragHandler.bind(b.current);
196
+ b.current.dragHandler = (a, l, u, o) => {
197
+ Ht(), r(a, l, u, o);
198
+ }, K.onConstructor({
199
+ navigatable: !!s.current.navigatable,
200
+ contextStateRef: y.current,
201
+ navigationStateRef: x.current
202
+ });
203
+ }
204
+ const pe = t.useCallback((e) => {
205
+ var u;
206
+ if (!e || s.current.scrollable === "none")
207
+ return;
208
+ if (E.current) {
209
+ const o = E.current.querySelector("table");
210
+ o != null && o.tBodies[0] && (ee.current = o.tBodies[0].offsetTop);
211
+ const d = (u = Y.current) == null ? void 0 : u.parentElement;
212
+ if (d) {
213
+ const h = E.current.offsetWidth - E.current.clientWidth;
214
+ d.style.paddingInlineEnd = h + "px";
215
+ }
216
+ return;
217
+ }
218
+ const n = Array.from(e.childNodes), r = n.find((o) => o.nodeName === "TABLE"), a = s.current.toolbar && n.find(
219
+ (o) => o.nodeType === 1 && o.classList.contains("k-grid-toolbar")
220
+ );
221
+ let l = 0;
222
+ if (a) {
223
+ const o = a.style.boxSizing;
224
+ a.style.boxSizing = "border-box", l = parseFloat(String(window.getComputedStyle(a).height)) || a.offsetHeight, a.style.boxSizing = o, a.getAttribute("style") || a.removeAttribute("style");
225
+ }
226
+ ee.current = r.tBodies[0].offsetTop, pn(r, l);
227
+ }, []), Ht = () => {
228
+ var p, i;
229
+ const e = (p = b.current) == null ? void 0 : p.colGroupMain;
230
+ if (!e || !M.current)
231
+ return;
232
+ const n = e.children, r = w.current.filter((f) => f.children.length === 0), a = (i = b.current) == null ? void 0 : i.colGroupHeader, l = M.current.offsetWidth;
233
+ let u = 0, o = !0;
234
+ for (let f = 0; f < r.length; f++)
235
+ if (r[f].width !== void 0)
236
+ u += parseFloat(String(r[f].width));
237
+ else {
238
+ o = !1;
239
+ break;
73
240
  }
74
- }, this.onResize = (e, t, o, s, l) => {
75
- if (this.props.onColumnResize) {
76
- const i = this.extendedColumn.filter((g) => g.children.length === 0).reduce((g, u) => g += parseFloat(String(u.width)), 0), d = {
77
- columns: this.columns,
78
- totalWidth: i,
79
- index: e,
80
- nativeEvent: s,
81
- newWidth: t,
82
- oldWidth: o,
83
- end: l,
84
- target: this
241
+ if (!o || !l || !u || Math.abs(l - u) <= 1)
242
+ return;
243
+ Te.current = !0;
244
+ const d = l / u;
245
+ let h = 0;
246
+ for (let f = 0; f < r.length; f++) {
247
+ const v = parseFloat(String(r[f].width));
248
+ let m;
249
+ f === r.length - 1 ? m = l - h : m = Math.round(v * d), h += m, r[f].width = m, n[f] && (n[f].style.width = m + "px"), a != null && a.children[f] && (a.children[f].style.width = m + "px");
250
+ }
251
+ M.current && (M.current.style.width = l + "px"), j.current && (j.current.style.width = l + "px");
252
+ }, te = () => _.current.map((e) => e.dataItem), L = t.useCallback(
253
+ (e, n, r) => {
254
+ const a = s.current;
255
+ if (e)
256
+ e({
257
+ nativeEvent: r == null ? void 0 : r.nativeEvent,
258
+ syntheticEvent: r,
259
+ target: g.current,
260
+ ...n
261
+ });
262
+ else if (a.onDataStateChange) {
263
+ const l = {
264
+ nativeEvent: r == null ? void 0 : r.nativeEvent,
265
+ syntheticEvent: r,
266
+ target: g.current,
267
+ dataState: {
268
+ filter: a.filter,
269
+ sort: a.sort,
270
+ ...n
271
+ }
85
272
  };
86
- this.props.onColumnResize.call(void 0, d);
273
+ a.onDataStateChange(l);
87
274
  }
88
- }, this.handleOnScroll = (e) => {
89
- const t = e.currentTarget.scrollLeft, o = e.currentTarget.scrollTop, { columnVirtualization: s, scrollable: l, rowHeight: i = 0 } = this.props, d = i, g = 0;
90
- let u = !1;
91
- s && Math.abs(this.wrapperScrollLeft - t) > g && (this.wrapperScrollLeft = t, u = !0), l === "virtual" && Math.abs(this.wrapperScrollTop - o) > d && (this.wrapperScrollTop = o, u = !0), u && (this.updateOnScroll = !0, this.forceUpdate());
92
- }, this.calculateSizes = (e) => {
93
- if (!e || this.props.scrollable === "none")
94
- return;
95
- const t = Array.from(e.childNodes), o = t.find((i) => i.nodeName === "TABLE"), s = this.props.toolbar && t.find(
96
- (i) => i.nodeType === 1 && i.classList.contains("k-grid-toolbar")
275
+ },
276
+ []
277
+ ), Mt = t.useCallback(
278
+ (e, n, r) => {
279
+ L(s.current.onSortChange, { sort: n, field: r }, e);
280
+ },
281
+ [L]
282
+ ), Nt = t.useCallback(
283
+ (e, n, r) => {
284
+ L(s.current.onFilterChange, { filter: n, field: r }, e);
285
+ },
286
+ [L]
287
+ ), Tt = t.useCallback(
288
+ (e) => {
289
+ L(
290
+ s.current.onFilterChange,
291
+ { filter: e.filter, field: e.field },
292
+ e.syntheticEvent
97
293
  );
98
- let l = 0;
99
- if (s) {
100
- const i = s.style.boxSizing;
101
- s.style.boxSizing = "border-box", l = parseFloat(String(window.getComputedStyle(s).height)) || s.offsetHeight, s.style.boxSizing = i, s.getAttribute("style") || s.removeAttribute("style");
102
- }
103
- this.tbodyOffsetTop = o.tBodies[0].offsetTop, Se(o, l);
104
- }, this.itemChange = (e) => {
105
- const t = this.props.onItemChange;
106
- if (e.field === this.props.expandField) {
107
- const o = this.props.onExpandChange;
108
- if (o) {
109
- const s = {
110
- ...this.getArguments(e.syntheticEvent),
111
- dataItem: e.dataItem,
112
- level: e.level,
113
- value: e.value
114
- };
115
- o.call(void 0, s);
116
- }
294
+ },
295
+ [L]
296
+ ), Lt = t.useCallback(
297
+ (e, n, r) => {
298
+ const a = s.current;
299
+ if (!a.onColumnMenuFilterChange)
117
300
  return;
301
+ const l = {
302
+ syntheticEvent: e,
303
+ filter: n,
304
+ field: r,
305
+ target: g.current,
306
+ nativeEvent: e.nativeEvent
307
+ };
308
+ a.onColumnMenuFilterChange(l);
309
+ },
310
+ []
311
+ ), Pt = t.useCallback(
312
+ (e, n, r) => {
313
+ const a = s.current;
314
+ if (a.expandField && a.onExpandChange) {
315
+ const l = {
316
+ nativeEvent: e == null ? void 0 : e.nativeEvent,
317
+ syntheticEvent: e,
318
+ target: g.current,
319
+ dataItem: n,
320
+ level: r,
321
+ value: !!D(a.expandField, n)
322
+ };
323
+ a.onExpandChange(l);
118
324
  }
119
- if (t) {
120
- const o = {
121
- ...this.getArguments(e.syntheticEvent),
325
+ },
326
+ []
327
+ ), Be = t.useCallback((e) => {
328
+ var r, a;
329
+ const n = s.current;
330
+ if (e.field === n.expandField) {
331
+ if (n.onExpandChange) {
332
+ const l = {
333
+ nativeEvent: (r = e.syntheticEvent) == null ? void 0 : r.nativeEvent,
334
+ syntheticEvent: e.syntheticEvent,
335
+ target: g.current,
122
336
  dataItem: e.dataItem,
123
337
  level: e.level,
124
- field: e.field,
125
338
  value: e.value
126
339
  };
127
- t.call(void 0, o);
340
+ n.onExpandChange(l);
128
341
  }
129
- }, this.onHeaderSelectionChange = (e) => {
130
- if (this.props.onHeaderSelectionChange) {
131
- const t = {
132
- field: e.field,
133
- nativeEvent: e.syntheticEvent && e.syntheticEvent.nativeEvent,
134
- syntheticEvent: e.syntheticEvent,
135
- target: this,
136
- dataItems: this.getLeafDataItems()
342
+ return;
343
+ }
344
+ if (n.onItemChange) {
345
+ const l = {
346
+ nativeEvent: (a = e.syntheticEvent) == null ? void 0 : a.nativeEvent,
347
+ syntheticEvent: e.syntheticEvent,
348
+ target: g.current,
349
+ dataItem: e.dataItem,
350
+ level: e.level,
351
+ field: e.field,
352
+ value: e.value
353
+ };
354
+ n.onItemChange(l);
355
+ }
356
+ }, []), zt = t.useCallback(
357
+ (e) => {
358
+ var r;
359
+ const n = s.current;
360
+ if (n.onSelectionChange) {
361
+ const { event: a, item: l, dataIndex: u, columnIndex: o } = e, { mode: d, cell: h } = ot(n.selectable), p = {
362
+ nativeEvent: (r = a.syntheticEvent) == null ? void 0 : r.nativeEvent,
363
+ syntheticEvent: a.syntheticEvent,
364
+ target: g.current,
365
+ dataItem: l.dataItem,
366
+ level: l.level,
367
+ startColIndex: o,
368
+ endColIndex: o,
369
+ startRowIndex: u,
370
+ endRowIndex: u,
371
+ dataItems: te(),
372
+ altKey: !1,
373
+ ctrlKey: !1,
374
+ shiftKey: !1,
375
+ metaKey: !1,
376
+ mode: d,
377
+ cell: h,
378
+ isDrag: !1,
379
+ componentId: T,
380
+ selectedField: n.selectedField || ""
137
381
  };
138
- this.props.onHeaderSelectionChange.call(void 0, t);
382
+ n.onSelectionChange(p);
139
383
  }
140
- }, this.selectionRelease = (e) => {
141
- if (this.props.onSelectionChange) {
142
- const t = {
384
+ },
385
+ [T]
386
+ ), Wt = t.useCallback((e) => {
387
+ var r;
388
+ const n = s.current;
389
+ if (n.onHeaderSelectionChange) {
390
+ const a = {
391
+ field: e.field,
392
+ nativeEvent: (r = e.syntheticEvent) == null ? void 0 : r.nativeEvent,
393
+ syntheticEvent: e.syntheticEvent,
394
+ target: g.current,
395
+ dataItems: te()
396
+ };
397
+ n.onHeaderSelectionChange(a);
398
+ }
399
+ }, []), Oe = t.useCallback(
400
+ (e) => {
401
+ const n = s.current;
402
+ if (n.onSelectionChange) {
403
+ const r = {
143
404
  syntheticEvent: void 0,
144
- target: this,
145
- selectedField: this.props.selectedField || "",
146
- componentId: this._treeListId,
147
- dataItems: this.getLeafDataItems(),
405
+ target: g.current,
406
+ selectedField: n.selectedField || "",
407
+ componentId: T,
408
+ dataItems: te(),
148
409
  dataItem: null,
149
410
  level: [],
150
411
  ...e
151
412
  };
152
- this.props.onSelectionChange.call(void 0, t);
413
+ n.onSelectionChange(r);
153
414
  }
154
- }, this.sortChange = (e, t, o) => {
155
- this.raiseDataEvent(this.props.onSortChange, { sort: t, field: o }, e);
156
- }, this.headerFilterChange = (e, t, o) => {
157
- this.raiseDataEvent(this.props.onFilterChange, { filter: t, field: o }, e);
158
- }, this.filterChange = (e) => {
159
- const { filter: t, field: o } = e;
160
- this.raiseDataEvent(this.props.onFilterChange, { filter: t, field: o }, e.syntheticEvent);
161
- }, this.columnMenuFilterChange = (e, t, o) => {
162
- const { onColumnMenuFilterChange: s } = this.props;
163
- if (!s || !o)
164
- return;
165
- const l = {
415
+ },
416
+ [T]
417
+ ), Kt = t.useCallback((e, n) => {
418
+ if (s.current.onRowClick && e.target.nodeName === "TD") {
419
+ const r = {
420
+ dataItem: n.dataItem,
421
+ level: n.level,
422
+ nativeEvent: e == null ? void 0 : e.nativeEvent,
166
423
  syntheticEvent: e,
167
- filter: t,
168
- field: o,
169
- target: this,
170
- nativeEvent: e.nativeEvent
424
+ target: g.current
171
425
  };
172
- s.call(void 0, l);
173
- }, this.expandChange = (e, t, o) => {
174
- const { expandField: s, onExpandChange: l } = this.props;
175
- if (s && l) {
176
- const i = {
177
- ...this.getArguments(e),
178
- dataItem: t,
179
- level: o,
180
- value: this.expanded(t)
181
- };
182
- l.call(void 0, i);
183
- }
184
- }, this.rowClick = (e, t) => {
185
- if (this.props.onRowClick && e.target.nodeName === "TD") {
186
- const o = {
187
- dataItem: t.dataItem,
188
- level: t.level,
189
- ...this.getArguments(e)
190
- };
191
- this.props.onRowClick.call(void 0, o);
192
- }
193
- }, this.rowDoubleClick = (e, t) => {
194
- if (this.props.onRowDoubleClick && e.target.nodeName === "TD") {
195
- const o = {
196
- dataItem: t.dataItem,
197
- level: t.level,
198
- ...this.getArguments(e)
199
- };
200
- this.props.onRowDoubleClick.call(void 0, o);
201
- }
202
- }, this.rowContextMenu = (e, t) => {
203
- if (this.props.onRowContextMenu && e.target.nodeName === "TD") {
204
- const o = {
205
- dataItem: t.dataItem,
206
- level: t.level,
207
- ...this.getArguments(e)
208
- };
209
- this.props.onRowContextMenu.call(void 0, o);
210
- }
211
- }, this.onPageChange = (e) => {
212
- if (this.props.onPageChange) {
213
- const t = {
214
- ...this.getArguments(e.syntheticEvent),
426
+ s.current.onRowClick(r);
427
+ }
428
+ }, []), Bt = t.useCallback((e, n) => {
429
+ if (s.current.onRowDoubleClick && e.target.nodeName === "TD") {
430
+ const r = {
431
+ dataItem: n.dataItem,
432
+ level: n.level,
433
+ nativeEvent: e == null ? void 0 : e.nativeEvent,
434
+ syntheticEvent: e,
435
+ target: g.current
436
+ };
437
+ s.current.onRowDoubleClick(r);
438
+ }
439
+ }, []), Ot = t.useCallback((e, n) => {
440
+ if (s.current.onRowContextMenu && e.target.nodeName === "TD") {
441
+ const r = {
442
+ dataItem: n.dataItem,
443
+ level: n.level,
444
+ nativeEvent: e == null ? void 0 : e.nativeEvent,
445
+ syntheticEvent: e,
446
+ target: g.current
447
+ };
448
+ s.current.onRowContextMenu(r);
449
+ }
450
+ }, []), Ve = t.useCallback(
451
+ (e) => {
452
+ var n;
453
+ if (s.current.onPageChange) {
454
+ const r = {
455
+ nativeEvent: (n = e.syntheticEvent) == null ? void 0 : n.nativeEvent,
456
+ syntheticEvent: e.syntheticEvent,
457
+ target: g.current,
215
458
  skip: e.skip,
216
459
  take: e.take
217
460
  };
218
- this.props.onPageChange.call(void 0, t);
461
+ s.current.onPageChange(r);
219
462
  }
220
- }, this.expandedSubItems = (e) => {
221
- const t = [];
222
- return this.expanded(e) && this.hasChildren(e) && t.push(...y(this.props.subItemsField, e)), t;
223
- }, this.getLeafDataItems = () => this.flatData.map((e) => e.dataItem), this.expanded = (e) => !!y(this.props.expandField, e), this.hasChildren = (e) => !!y(this.props.subItemsField, e), this.showLicenseWatermark = !Z(B, { component: "TreeList" }), this.licenseMessage = ee(B), this.dragLogic = new re(this.columnReorder, K, K), this.columnResize = new he(this.onResize.bind(this)), S.onConstructor({
224
- navigatable: !!h.navigatable,
225
- contextStateRef: this.contextStateRef,
226
- navigationStateRef: this.navigationStateRef
227
- });
228
- }
229
- get _treeListId() {
230
- return this.props.id + "-treelist";
231
- }
232
- get document() {
233
- if (te)
234
- return this.element && this.element.ownerDocument || document;
235
- }
236
- /**
237
- * @hidden
238
- */
239
- componentDidMount() {
240
- this.calculateSizes(this.element), S.onComponentDidMount({
241
- scope: this.element || void 0,
242
- contextStateRef: this.contextStateRef,
243
- navigationStateRef: this.navigationStateRef
244
- });
245
- }
246
- /**
247
- * @hidden
248
- */
249
- getSnapshotBeforeUpdate() {
250
- return S.onGetSnapshotBeforeUpdate({
251
- document: this.document,
252
- contextStateRef: this.contextStateRef,
253
- navigationStateRef: this.navigationStateRef
254
- }), null;
255
- }
256
- /**
257
- * @hidden
258
- */
259
- componentDidUpdate(h) {
260
- h.columns !== this.props.columns && this.calculateSizes(this.element), S.onComponentDidUpdate({
261
- scope: this.element || void 0,
262
- contextStateRef: this.contextStateRef,
263
- navigationStateRef: this.navigationStateRef
463
+ },
464
+ []
465
+ ), Vt = t.useCallback(
466
+ (e) => {
467
+ s.current.onRowDrag && s.current.onRowDrag({ ...e, target: g.current });
468
+ },
469
+ []
470
+ ), Gt = t.useCallback(
471
+ (e) => {
472
+ s.current.onRowDrop && s.current.onRowDrop({ ...e, target: g.current });
473
+ },
474
+ []
475
+ ), Ge = t.useCallback(
476
+ (e) => {
477
+ if (K.onKeyDown(e, {
478
+ navigatable: !!s.current.navigatable,
479
+ contextStateRef: y.current,
480
+ navigationStateRef: x.current
481
+ }), s.current.onKeyDown) {
482
+ const { mode: n, cell: r } = ot(s.current.selectable), a = {
483
+ dataItems: te(),
484
+ mode: n,
485
+ cell: r,
486
+ componentId: T,
487
+ selectedField: s.current.selectedField,
488
+ nativeEvent: e == null ? void 0 : e.nativeEvent,
489
+ syntheticEvent: e,
490
+ target: g.current
491
+ };
492
+ s.current.onKeyDown(a);
493
+ }
494
+ },
495
+ [T]
496
+ ), Ae = t.useCallback((e) => {
497
+ K.onFocus(e, {
498
+ contextStateRef: y.current
264
499
  });
265
- }
266
- /**
267
- * @hidden
268
- */
269
- componentWillUnmount() {
270
- this.columnsMap = [], this.prevData = [], this.flattedData = [], this.updateOnScroll = !1, this.getExtendedColumn.clear(), this.getColumnsMap.clear();
271
- }
272
- /**
273
- * @hidden
274
- */
275
- render() {
276
- const {
277
- columns: h = [],
278
- filterRow: e,
279
- scrollable: t = "scrollable",
280
- resizable: o = !1,
281
- reorderable: s = !1,
282
- skip: l,
283
- take: i
284
- } = this.props, d = h.some((a) => !!a.filter || !!a.filterCell) || e !== void 0, g = e || ce, u = V.getIdPrefix(this.navigationStateRef), L = this.getExtendedColumn(h, u), T = L.length !== this.extendedColumn.length;
285
- this.extendedColumn = L, this.columnsMap = this.getColumnsMap(this.extendedColumn, T);
286
- const m = this.extendedColumn.filter((a) => a.children.length === 0);
287
- this.columnResize.columns = this.extendedColumn, this.columnResize.resizable = o, this.dragLogic.columns = this.extendedColumn, this.dragLogic.reorderable = s, this.dragLogic.groupable = !1;
288
- const I = /* @__PURE__ */ r.createElement(
289
- de,
290
- {
291
- headerRow: /* @__PURE__ */ r.createElement(
292
- pe,
293
- {
294
- sort: this.props.sort,
295
- sortable: this.props.sortable,
296
- sortChange: this.sortChange,
297
- selectionChange: this.onHeaderSelectionChange,
298
- columns: this.extendedColumn,
299
- columnsMap: this.columnsMap,
300
- cellRender: this.props.headerCellRender,
301
- columnResize: this.columnResize,
302
- columnMenu: this.props.columnMenu,
303
- columnMenuFilter: this.props.columnMenuFilter,
304
- columnMenuFilterChange: this.columnMenuFilterChange,
305
- pressHandler: this.dragLogic.pressHandler,
306
- dragHandler: this.dragLogic.dragHandler,
307
- releaseHandler: this.dragLogic.releaseHandler,
308
- filterChange: this.headerFilterChange
309
- }
310
- ),
311
- reorderable: this.props.reorderable,
312
- filterRow: d && /* @__PURE__ */ r.createElement(
313
- g,
314
- {
315
- columns: m,
316
- filter: this.props.filter,
317
- filterChange: this.filterChange,
318
- sort: this.props.sort,
319
- ariaRowIndex: this.columnsMap.length + 1
320
- }
321
- ) || void 0,
322
- columnResize: this.columnResize
500
+ }, []), At = t.useCallback((e) => {
501
+ var h;
502
+ const n = e.currentTarget.scrollLeft, r = e.currentTarget.scrollTop, a = s.current, u = a.rowHeight || 0, o = 0;
503
+ let d = !1;
504
+ if (a.columnVirtualization && Math.abs(de.current - n) > o && (de.current = n, d = !0), a.scrollable === "virtual" && Math.abs(fe.current - r) > u && (fe.current = r, d = !0), d) {
505
+ if (y.current.current && x.current.current) {
506
+ const p = (h = ze()) == null ? void 0 : h.activeElement, i = p && Se.getNavigatableId(p);
507
+ i && i === y.current.current.activeId && (x.current.current.activeElementIsFocused = !0);
323
508
  }
324
- ), z = this.props.style || {}, { colSpans: W, hiddenColumns: $ } = ge({
325
- enabled: this.props.columnVirtualization,
326
- columns: m,
327
- scrollLeft: this.wrapperScrollLeft,
328
- tableViewPortWidth: parseFloat((z.width || "").toString())
329
- }), j = (a, v, b, D, E, w) => m.map((c, p) => {
330
- if ($[p])
331
- return null;
332
- const C = c.id ? c.id : p, k = `${c.className ? c.className + " " : ""}${c.locked ? "k-grid-content-sticky" : ""}`, R = {
333
- id: V.generateNavigatableId(`${b}-${String(p)}`, u),
334
- colSpan: W[p],
335
- dataItem: a.dataItem,
336
- field: c.field,
337
- format: c.format,
338
- className: k || void 0,
339
- render: this.props.cellRender,
340
- onChange: this.itemChange,
341
- selectionChange: this.props.onSelectionChange ? (F) => {
342
- this.selectionChange({ event: F, item: a, columnIndex: p, dataIndex: E });
343
- } : void 0,
344
- level: a.level,
345
- expandable: c.expandable,
346
- expanded: D,
347
- hasChildren: this.hasChildren(a.dataItem),
348
- onExpandChange: this.expandChange,
349
- colIndex: p,
350
- ariaColumnIndex: c.ariaColumnIndex,
351
- style: c.left !== void 0 && {
352
- left: c.left,
353
- right: c.right,
354
- borderRightWidth: c.rightBorder ? "1px" : ""
355
- } || {},
356
- isSelected: Array.isArray(w) && w.indexOf(p) > -1
357
- };
358
- return v && c.editCell ? /* @__PURE__ */ r.createElement(c.editCell, { key: C, ...R, onChange: this.itemChange }) : c.cell ? /* @__PURE__ */ r.createElement(c.cell, { key: C, ...R }) : /* @__PURE__ */ r.createElement(Re, { key: C, ...R });
509
+ Z.current = !0, It();
510
+ }
511
+ Y.current && !ue.current && (ie.current = !0, Y.current.scrollLeft = n), ue.current = !1;
512
+ }, []), Ut = t.useCallback((e) => {
513
+ if (ie.current) {
514
+ ie.current = !1;
515
+ return;
516
+ }
517
+ const n = e.currentTarget.scrollLeft;
518
+ E.current && E.current.scrollLeft !== n && (ue.current = !0, E.current.scrollLeft = n);
519
+ }, []), be = t.useRef(!1);
520
+ t.useLayoutEffect(() => (pe(C.current), K.onComponentDidMount({
521
+ scope: se.current || C.current || void 0,
522
+ contextStateRef: y.current,
523
+ navigationStateRef: x.current
524
+ }), () => {
525
+ be.current = !1, q.current = [], ge.current = [], _.current = [], Z.current = !1, he.clear(), me.clear();
526
+ }), [pe, he, me]), t.useLayoutEffect(() => {
527
+ K.onGetSnapshotBeforeUpdate({
528
+ document: ze(),
529
+ contextStateRef: y.current,
530
+ navigationStateRef: x.current
359
531
  });
360
- let f = this.flatData;
361
- const N = f.length;
362
- l !== void 0 && i !== void 0 && (f = f.slice(l, l + i)), t === "virtual" && (f = we({
363
- rows: f,
364
- tableViewPortHeight: parseFloat((z.height || z.maxHeight || "").toString()),
365
- scrollTop: this.wrapperScrollTop
366
- }), this.updateOnScroll = !1);
367
- const G = f.map((a) => a.level), _ = this.columnsMap.length + (d ? 1 : 0) + 1, q = f.length > 0 && f.map((a, v) => {
368
- const b = oe(t, a, v), D = y(this.props.editField, a.dataItem), E = this.props.dataItemKey && se(this.props.dataItemKey)(a.dataItem), w = String(E || a.level.join(".")), c = this.expanded(a.dataItem), p = this.props.selectedField ? y(this.props.selectedField, a.dataItem) : void 0, C = {
369
- key: w,
370
- level: a.level,
371
- levels: G,
372
- dataItem: a.dataItem,
373
- selectedField: this.props.selectedField,
374
- rowHeight: t === "virtual" ? a.height : this.props.rowHeight,
375
- render: this.props.rowRender,
376
- onDrop: this.onRowDrop,
377
- onDrag: this.onRowDrag,
378
- onClick: (x) => this.rowClick(x, a),
379
- onDoubleClick: (x) => this.rowDoubleClick(x, a),
380
- onContextMenu: (x) => this.rowContextMenu(x, a),
381
- isAltRow: b % 2 !== 0,
382
- expanded: c,
383
- rowIndex: b,
384
- ariaRowIndex: _ + b,
385
- ariaSetSize: a.levelCount,
386
- ariaPosInSet: a.level[a.level.length - 1] + 1,
387
- isSelected: typeof p == "boolean" && p
388
- }, k = this.props.editRow, R = this.props.row || ye, F = j(a, D, w, c, b, p);
389
- return D && k ? /* @__PURE__ */ r.createElement(k, { ...C, key: C.key }, F) : /* @__PURE__ */ r.createElement(R, { ...C, key: C.key }, F);
390
- }) || /* @__PURE__ */ r.createElement("tr", { className: "k-table-row k-grid-norecords" }, /* @__PURE__ */ r.createElement("td", { colSpan: m.length }, this.props.noRecords || /* @__PURE__ */ r.createElement(xe, null))), J = (a) => this.props.sort && this.props.sort.some((v) => v.field === a), Q = /* @__PURE__ */ r.createElement(
391
- "colgroup",
392
- {
393
- ref: (a) => {
394
- this.columnResize.colGroupMain = a;
532
+ });
533
+ const Ue = t.useRef(B);
534
+ t.useLayoutEffect(() => {
535
+ if (!be.current) {
536
+ be.current = !0;
537
+ return;
538
+ }
539
+ Ue.current !== B && pe(C.current), Ue.current = B, K.onComponentDidUpdate({
540
+ scope: se.current || C.current || void 0,
541
+ contextStateRef: y.current,
542
+ navigationStateRef: x.current
543
+ });
544
+ });
545
+ const $e = B.some((e) => !!e.filter || !!e.filterCell) || xe !== void 0, $t = xe || gn, je = Se.getIdPrefix(x.current), _e = he(B, je), jt = _e.length !== w.current.length;
546
+ w.current = _e, q.current = me(w.current, jt);
547
+ const k = w.current.filter((e) => e.children.length === 0);
548
+ b.current.columns = w.current, b.current.resizable = Ie, R.current.columns = w.current, R.current.reorderable = V, R.current.groupable = !1;
549
+ let I = (() => {
550
+ let e = 0;
551
+ const n = (a) => {
552
+ const l = { height: Fe || 0, offsetTop: e };
553
+ return e += l.height, l;
554
+ }, r = Z.current && ge.current === ae && ee.current > 0 && _.current.length ? _.current : mn(ae, Ft, n);
555
+ return ge.current = ae, _.current = r, r;
556
+ })();
557
+ const ne = I.length;
558
+ G !== void 0 && J !== void 0 && (I = I.slice(G, G + J));
559
+ const ve = ce || {};
560
+ O === "virtual" && (I = bn({
561
+ rows: I,
562
+ tableViewPortHeight: parseFloat((ve.height || ve.maxHeight || "").toString()),
563
+ scrollTop: fe.current
564
+ }), Z.current = !1);
565
+ const { colSpans: _t, hiddenColumns: qt } = dn({
566
+ enabled: mt,
567
+ columns: k,
568
+ scrollLeft: de.current,
569
+ tableViewPortWidth: parseFloat((ve.width || "").toString())
570
+ }), Jt = I.map((e) => e.level), Qt = q.current.length + ($e ? 1 : 0) + 1, qe = /* @__PURE__ */ t.createElement(
571
+ fn,
572
+ {
573
+ headerRow: /* @__PURE__ */ t.createElement(
574
+ hn,
575
+ {
576
+ sort: $,
577
+ sortable: Ct,
578
+ sortChange: Mt,
579
+ selectionChange: Wt,
580
+ columns: w.current,
581
+ columnsMap: q.current,
582
+ cellRender: xt,
583
+ columnResize: b.current,
584
+ columnMenu: Et,
585
+ columnMenuFilter: wt,
586
+ columnMenuFilterChange: Lt,
587
+ pressHandler: R.current.pressHandler,
588
+ dragHandler: R.current.dragHandler,
589
+ releaseHandler: R.current.releaseHandler,
590
+ filterChange: Nt
395
591
  }
396
- },
397
- m.map((a, v) => /* @__PURE__ */ r.createElement(
398
- "col",
592
+ ),
593
+ reorderable: V,
594
+ className: O !== "none" ? "k-table-thead" : void 0,
595
+ role: O !== "none" ? "rowgroup" : void 0,
596
+ filterRow: $e && /* @__PURE__ */ t.createElement(
597
+ $t,
399
598
  {
400
- key: v.toString(),
401
- className: J(a.field) ? "k-sorted" : void 0,
402
- style: a.width !== void 0 ? { width: a.width } : void 0
599
+ columns: k,
600
+ filter: Rt,
601
+ filterChange: Tt,
602
+ sort: $,
603
+ ariaRowIndex: q.current.length + 1
403
604
  }
404
- ))
405
- ), X = this.props.columnVirtualization || this.props.scrollable === "virtual", Y = this.props.selectable && this.props.selectable.drag ? "none" : void 0, H = this.props.tableProps || {};
406
- return /* @__PURE__ */ r.createElement(P.Provider, { value: this.contextStateRef.current }, /* @__PURE__ */ r.createElement(
605
+ ) || void 0,
606
+ columnResize: b.current
607
+ }
608
+ ), Xt = (e, n, r, a, l, u) => k.map((o, d) => {
609
+ if (qt[d])
610
+ return null;
611
+ const h = o.id ? o.id : d, p = `${o.className ? o.className + " " : ""}${o.locked ? "k-grid-content-sticky" : ""}`, i = {
612
+ id: Se.generateNavigatableId(`${r}-${String(d)}`, je),
613
+ colSpan: _t[d],
614
+ dataItem: e.dataItem,
615
+ field: o.field,
616
+ format: o.format,
617
+ className: p || void 0,
618
+ render: St,
619
+ onChange: Be,
620
+ selectionChange: H.onSelectionChange ? (f) => {
621
+ zt({ event: f, item: e, columnIndex: d, dataIndex: l });
622
+ } : void 0,
623
+ level: e.level,
624
+ expandable: o.expandable,
625
+ expanded: a,
626
+ hasChildren: !!D(U, e.dataItem),
627
+ onExpandChange: Pt,
628
+ colIndex: d,
629
+ ariaColumnIndex: o.ariaColumnIndex,
630
+ style: o.left !== void 0 && {
631
+ left: o.left,
632
+ right: o.right,
633
+ borderRightWidth: o.rightBorder ? "1px" : ""
634
+ } || {},
635
+ isSelected: Array.isArray(u) && u.indexOf(d) > -1
636
+ };
637
+ return n && o.editCell ? /* @__PURE__ */ t.createElement(o.editCell, { key: h, ...i, onChange: Be }) : o.cell ? /* @__PURE__ */ t.createElement(o.cell, { key: h, ...i }) : /* @__PURE__ */ t.createElement(vn, { key: h, ...i });
638
+ }), Je = I.length > 0 && I.map((e, n) => {
639
+ const r = D(pt, e.dataItem), a = De && an(De)(e.dataItem), l = String(a || e.level.join(".")), u = !!D(le, e.dataItem), o = oe ? D(oe, e.dataItem) : void 0, d = {
640
+ key: l,
641
+ level: e.level,
642
+ levels: Jt,
643
+ dataItem: e.dataItem,
644
+ selectedField: oe,
645
+ rowHeight: O === "virtual" ? e.height : Fe,
646
+ render: kt,
647
+ onDrop: Gt,
648
+ onDrag: Vt,
649
+ onClick: (i) => Kt(i, e),
650
+ onDoubleClick: (i) => Bt(i, e),
651
+ onContextMenu: (i) => Ot(i, e),
652
+ isAltRow: n % 2 !== 0,
653
+ expanded: u,
654
+ rowIndex: n,
655
+ ariaRowIndex: Qt + n,
656
+ ariaSetSize: e.levelCount,
657
+ ariaPosInSet: e.level[e.level.length - 1] + 1,
658
+ isSelected: typeof o == "boolean" && o
659
+ }, h = yt || Rn, p = Xt(e, r, l, u, n, o);
660
+ return r && Ne ? /* @__PURE__ */ t.createElement(Ne, { ...d, key: d.key }, p) : /* @__PURE__ */ t.createElement(h, { ...d, key: d.key }, p);
661
+ }) || /* @__PURE__ */ t.createElement("tr", { className: "k-table-row k-grid-norecords" }, /* @__PURE__ */ t.createElement("td", { colSpan: k.length }, bt || /* @__PURE__ */ t.createElement(Cn, null))), Yt = (e) => $ == null ? void 0 : $.some((n) => n.field === e), Ce = k.map((e) => /* @__PURE__ */ t.createElement(
662
+ "col",
663
+ {
664
+ key: e.declarationIndex,
665
+ className: Yt(e.field) ? "k-sorted" : void 0,
666
+ style: e.width !== void 0 ? { width: e.width } : void 0
667
+ }
668
+ )), Qe = A != null && A.drag ? "none" : void 0, P = vt || {}, Xe = O !== "none";
669
+ let z = 0;
670
+ if (Xe && Ie && Te.current) {
671
+ let e = !0;
672
+ for (let n = 0; n < k.length; n++)
673
+ if (k[n].width !== void 0)
674
+ z += parseFloat(String(k[n].width));
675
+ else {
676
+ e = !1;
677
+ break;
678
+ }
679
+ e || (z = 0);
680
+ }
681
+ let Re;
682
+ return z ? Re = { width: z } : (Ye = P.style) != null && Ye.width && (Re = { width: P.style.width }), Xe ? /* @__PURE__ */ t.createElement(lt.Provider, { value: y.current.current }, /* @__PURE__ */ t.createElement(
683
+ "div",
684
+ {
685
+ id: Q,
686
+ style: ce,
687
+ className: ke("k-grid", "k-treelist", "k-treelist-scrollable", He),
688
+ ref: (e) => {
689
+ C.current = e;
690
+ },
691
+ onKeyDown: Ge,
692
+ onFocus: Ae
693
+ },
694
+ Me,
695
+ /* @__PURE__ */ t.createElement(
407
696
  "div",
408
697
  {
409
- id: this.props.id,
410
- style: this.props.style,
411
- className: ne("k-grid", "k-treelist", this.props.className, {
412
- "k-treelist-scrollable": t !== "none"
413
- }),
414
- ref: (a) => {
415
- this.element = a;
416
- },
417
- onScroll: X ? this.handleOnScroll : void 0,
418
- onKeyDown: this.onKeyDown,
419
- onFocus: this.onFocus,
420
- "aria-rowcount": N,
421
- "aria-colcount": m.length,
698
+ className: "k-grid-aria-root k-treelist",
422
699
  role: "treegrid",
423
- ...ue
700
+ "aria-rowcount": ne,
701
+ "aria-colcount": k.length,
702
+ ref: (e) => {
703
+ se.current = e;
704
+ },
705
+ ...ct
424
706
  },
425
- this.props.toolbar,
426
- /* @__PURE__ */ r.createElement(me, { selectable: this.props.selectable, onRelease: this.selectionRelease }, /* @__PURE__ */ r.createElement(
427
- "table",
707
+ /* @__PURE__ */ t.createElement("div", { className: ke("k-grid-header", { "k-grid-draggable-header": V }) }, /* @__PURE__ */ t.createElement(
708
+ "div",
428
709
  {
429
- className: "k-table k-grid-table",
430
- ...H,
431
- style: { ...H.style || {}, userSelect: Y },
432
- role: "presentation"
710
+ className: "k-grid-header-wrap",
711
+ ref: (e) => {
712
+ Y.current = e;
713
+ },
714
+ onScroll: Ut
433
715
  },
434
- Q,
435
- I,
436
- /* @__PURE__ */ r.createElement(
437
- "tbody",
716
+ /* @__PURE__ */ t.createElement(
717
+ "table",
438
718
  {
439
- className: "k-table-tbody",
440
- ...fe,
441
- role: "presentation"
719
+ className: "k-table k-grid-header-table",
720
+ role: "presentation",
721
+ style: Re,
722
+ ref: (e) => {
723
+ M.current = e;
724
+ }
442
725
  },
443
- q
726
+ /* @__PURE__ */ t.createElement(
727
+ "colgroup",
728
+ {
729
+ ref: (e) => {
730
+ b.current.colGroupHeader = e;
731
+ }
732
+ },
733
+ Ce
734
+ ),
735
+ qe
444
736
  )
445
737
  )),
446
- this.props.pager && /* @__PURE__ */ r.createElement(
447
- this.props.pager,
738
+ /* @__PURE__ */ t.createElement("div", { className: "k-grid-container" }, /* @__PURE__ */ t.createElement(
739
+ "div",
448
740
  {
449
- className: "k-grid-pager",
450
- total: N,
451
- skip: l,
452
- take: i,
453
- onPageChange: this.onPageChange
454
- }
741
+ className: "k-grid-content",
742
+ ref: (e) => {
743
+ E.current = e;
744
+ },
745
+ onScroll: At
746
+ },
747
+ /* @__PURE__ */ t.createElement(st, { selectable: A, onRelease: Oe }, /* @__PURE__ */ t.createElement(
748
+ "table",
749
+ {
750
+ className: "k-table k-grid-table",
751
+ ...P,
752
+ style: {
753
+ ...P.style || {},
754
+ userSelect: Qe,
755
+ ...z ? { width: z } : {}
756
+ },
757
+ role: "presentation",
758
+ ref: (e) => {
759
+ j.current = e;
760
+ }
761
+ },
762
+ /* @__PURE__ */ t.createElement(
763
+ "colgroup",
764
+ {
765
+ ref: (e) => {
766
+ b.current.colGroupMain = e;
767
+ }
768
+ },
769
+ Ce
770
+ ),
771
+ /* @__PURE__ */ t.createElement(
772
+ "tbody",
773
+ {
774
+ className: "k-table-tbody",
775
+ ...it,
776
+ role: "rowgroup"
777
+ },
778
+ Je
779
+ )
780
+ ))
781
+ ))
782
+ ),
783
+ X && /* @__PURE__ */ t.createElement(
784
+ X,
785
+ {
786
+ className: "k-grid-pager",
787
+ total: ne,
788
+ skip: G,
789
+ take: J,
790
+ onPageChange: Ve
791
+ }
792
+ ),
793
+ V && /* @__PURE__ */ t.createElement(t.Fragment, null, /* @__PURE__ */ t.createElement(ut, { ref: R.current.refDropElementClue }), /* @__PURE__ */ t.createElement(dt, { ref: R.current.refDragElementClue })),
794
+ Le && /* @__PURE__ */ t.createElement(at, { message: Pe })
795
+ )) : /* @__PURE__ */ t.createElement(lt.Provider, { value: y.current.current }, /* @__PURE__ */ t.createElement(
796
+ "div",
797
+ {
798
+ id: Q,
799
+ style: ce,
800
+ className: ke("k-grid", "k-treelist", He),
801
+ ref: (e) => {
802
+ C.current = e;
803
+ },
804
+ onKeyDown: Ge,
805
+ onFocus: Ae,
806
+ "aria-rowcount": ne,
807
+ "aria-colcount": k.length,
808
+ role: "treegrid",
809
+ ...ct
810
+ },
811
+ Me,
812
+ /* @__PURE__ */ t.createElement(st, { selectable: A, onRelease: Oe }, /* @__PURE__ */ t.createElement(
813
+ "table",
814
+ {
815
+ className: "k-table k-grid-table",
816
+ ...P,
817
+ style: { ...P.style || {}, userSelect: Qe },
818
+ role: "presentation"
819
+ },
820
+ /* @__PURE__ */ t.createElement(
821
+ "colgroup",
822
+ {
823
+ ref: (e) => {
824
+ b.current.colGroupMain = e;
825
+ }
826
+ },
827
+ Ce
455
828
  ),
456
- s && /* @__PURE__ */ r.createElement(r.Fragment, null, /* @__PURE__ */ r.createElement(Ce, { ref: this.dragLogic.refDropElementClue }), /* @__PURE__ */ r.createElement(ve, { ref: this.dragLogic.refDragElementClue })),
457
- this.showLicenseWatermark && /* @__PURE__ */ r.createElement(ae, { message: this.licenseMessage })
458
- ));
459
- }
460
- get columns() {
461
- const h = this.extendedColumn.filter((t) => t.declarationIndex >= 0 && t.parentIndex === -1), e = (t) => (t.sort((o, s) => o.declarationIndex - s.declarationIndex), t.map((o) => {
462
- const {
463
- declarationIndex: s,
464
- parentIndex: l,
465
- depth: i,
466
- colSpan: d,
467
- rowSpan: g,
468
- index: u,
469
- kFirst: L,
470
- groupable: T,
471
- children: m,
472
- ...I
473
- } = o;
474
- return m.length ? {
475
- children: e(m),
476
- ...I
477
- } : I;
478
- }));
479
- return e(h);
480
- }
481
- get flatData() {
482
- const { data: h = [], rowHeight: e = 0 } = this.props;
483
- let t = 0;
484
- const o = (l) => {
485
- const i = { height: e, offsetTop: t };
486
- return t += i.height, i;
487
- }, s = this.updateOnScroll && this.prevData === h && this.tbodyOffsetTop > 0 && this.flattedData.length ? this.flattedData : be(h, this.expandedSubItems, o);
488
- return this.prevData = h, this.flattedData = s, s;
489
- }
490
- selectionChange(h) {
491
- if (this.props.onSelectionChange) {
492
- const { event: e, item: t, dataIndex: o, columnIndex: s } = h, { mode: l, cell: i } = O(this.props.selectable), d = {
493
- ...this.getArguments(e.syntheticEvent),
494
- dataItem: t.dataItem,
495
- level: t.level,
496
- startColIndex: s,
497
- endColIndex: s,
498
- startRowIndex: o,
499
- endRowIndex: o,
500
- dataItems: this.getLeafDataItems(),
501
- altKey: !1,
502
- ctrlKey: !1,
503
- shiftKey: !1,
504
- metaKey: !1,
505
- mode: l,
506
- cell: i,
507
- isDrag: !1,
508
- componentId: this._treeListId,
509
- selectedField: this.props.selectedField || ""
510
- };
511
- this.props.onSelectionChange.call(void 0, d);
512
- }
513
- }
514
- raiseDataEvent(h, e, t) {
515
- const o = this.props.onDataStateChange;
516
- if (h)
517
- h.call(void 0, { ...this.getArguments(t), ...e });
518
- else if (o) {
519
- const s = {
520
- ...this.getArguments(t),
521
- dataState: { ...this.getDataState(), ...e }
522
- };
523
- o.call(void 0, s);
524
- }
525
- }
526
- getDataState() {
527
- return {
528
- filter: this.props.filter,
529
- sort: this.props.sort
530
- };
531
- }
532
- getArguments(h) {
533
- return {
534
- nativeEvent: h && h.nativeEvent,
535
- syntheticEvent: h,
536
- target: this
537
- };
538
- }
539
- };
540
- M.propTypes = {
541
- data: n.array,
542
- resizable: n.bool,
543
- reorderable: n.bool,
544
- sortable: n.oneOfType([
545
- n.bool,
546
- n.shape({
547
- mode: n.oneOf(["single", "multiple"]),
548
- allowUnsort: n.bool
829
+ qe,
830
+ /* @__PURE__ */ t.createElement(
831
+ "tbody",
832
+ {
833
+ className: "k-table-tbody",
834
+ ...it,
835
+ role: "presentation"
836
+ },
837
+ Je
838
+ )
839
+ )),
840
+ X && /* @__PURE__ */ t.createElement(
841
+ X,
842
+ {
843
+ className: "k-grid-pager",
844
+ total: ne,
845
+ skip: G,
846
+ take: J,
847
+ onPageChange: Ve
848
+ }
849
+ ),
850
+ V && /* @__PURE__ */ t.createElement(t.Fragment, null, /* @__PURE__ */ t.createElement(ut, { ref: R.current.refDropElementClue }), /* @__PURE__ */ t.createElement(dt, { ref: R.current.refDragElementClue })),
851
+ Le && /* @__PURE__ */ t.createElement(at, { message: Pe })
852
+ ));
853
+ });
854
+ gt.propTypes = {
855
+ data: c.array,
856
+ resizable: c.bool,
857
+ reorderable: c.bool,
858
+ sortable: c.oneOfType([
859
+ c.bool,
860
+ c.shape({
861
+ mode: c.oneOf(["single", "multiple"]),
862
+ allowUnsort: c.bool
549
863
  })
550
864
  ]),
551
- onSortChange: n.func,
552
- sort: n.array,
553
- columns: n.arrayOf(n.object),
554
- columnVirtualization: n.bool,
555
- filter: n.array,
556
- onFilterChange: n.func,
557
- filterRow: n.any,
558
- toolbar: n.any,
559
- noRecords: n.any,
560
- onExpandChange: n.func,
561
- expandField: n.string,
562
- subItemsField: n.string,
563
- selectedField: n.string,
564
- onSelectionChange: n.func,
565
- onHeaderSelectionChange: n.func,
566
- onRowClick: n.func,
567
- onItemChange: n.func,
568
- editField: n.string,
569
- scrollable: n.oneOf(["none", "scrollable", "virtual"]),
570
- rowHeight: n.number,
571
- style: n.object,
572
- tableProps: n.object,
573
- pager: n.any,
574
- skip: n.number,
575
- take: n.number,
576
- onPageChange: n.func,
577
- onDataStateChange: n.func,
578
- onColumnResize: n.func,
579
- onColumnReorder: n.func,
580
- dataItemKey: n.string,
581
- navigatable: n.bool
582
- }, M.contextType = P;
583
- let U = M;
865
+ onSortChange: c.func,
866
+ sort: c.array,
867
+ columns: c.arrayOf(c.object),
868
+ columnVirtualization: c.bool,
869
+ filter: c.array,
870
+ onFilterChange: c.func,
871
+ filterRow: c.any,
872
+ toolbar: c.any,
873
+ noRecords: c.any,
874
+ onExpandChange: c.func,
875
+ expandField: c.string,
876
+ subItemsField: c.string,
877
+ selectedField: c.string,
878
+ onSelectionChange: c.func,
879
+ onHeaderSelectionChange: c.func,
880
+ onRowClick: c.func,
881
+ onItemChange: c.func,
882
+ editField: c.string,
883
+ scrollable: c.oneOf(["none", "scrollable", "virtual"]),
884
+ rowHeight: c.number,
885
+ style: c.object,
886
+ tableProps: c.object,
887
+ pager: c.any,
888
+ skip: c.number,
889
+ take: c.number,
890
+ onPageChange: c.func,
891
+ onDataStateChange: c.func,
892
+ onColumnResize: c.func,
893
+ onColumnReorder: c.func,
894
+ dataItemKey: c.string,
895
+ navigatable: c.bool
896
+ };
897
+ gt.displayName = "KendoReactTreeList";
584
898
  export {
585
- U as TreeList
899
+ gt as TreeList
586
900
  };