@progress/kendo-react-grid 9.4.0-develop.9 → 9.4.1-develop.1

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 (41) hide show
  1. package/GridClientWrapper.js +1 -1
  2. package/GridClientWrapper.mjs +463 -374
  3. package/GridComponent.js +1 -1
  4. package/GridComponent.mjs +337 -307
  5. package/GridSearchBox.js +8 -0
  6. package/GridSearchBox.mjs +35 -0
  7. package/GridState.js +1 -1
  8. package/GridState.mjs +79 -67
  9. package/NOTICE.txt +40 -51
  10. package/cells/GridCell.js +1 -1
  11. package/cells/GridCell.mjs +24 -20
  12. package/cells/client/GridRowReorderContainer.js +1 -1
  13. package/cells/client/GridRowReorderContainer.mjs +15 -9
  14. package/columnMenu/GridColumnMenuCheckboxFilter.js +1 -1
  15. package/columnMenu/GridColumnMenuCheckboxFilter.mjs +56 -55
  16. package/columnMenu/GridColumnMenuColumnsChooser.js +9 -0
  17. package/columnMenu/GridColumnMenuColumnsChooser.mjs +82 -0
  18. package/columnMenu/GridColumnMenuFilter.js +1 -1
  19. package/columnMenu/GridColumnMenuFilter.mjs +19 -19
  20. package/columnMenu/GridColumnMenuSort.js +1 -1
  21. package/columnMenu/GridColumnMenuSort.mjs +1 -1
  22. package/components/noRecords/GridNoRecords.js +1 -1
  23. package/components/noRecords/GridNoRecords.mjs +8 -7
  24. package/dist/cdn/js/kendo-react-grid.js +1 -1
  25. package/header/client/GridHeaderCellContainer.js +1 -1
  26. package/header/client/GridHeaderCellContainer.mjs +20 -18
  27. package/index.d.mts +289 -48
  28. package/index.d.ts +289 -48
  29. package/index.js +1 -1
  30. package/index.mjs +76 -72
  31. package/messages/index.js +1 -1
  32. package/messages/index.mjs +38 -36
  33. package/package-metadata.js +1 -1
  34. package/package-metadata.mjs +2 -2
  35. package/package.json +14 -14
  36. package/rows/GridRow.js +1 -1
  37. package/rows/GridRow.mjs +45 -45
  38. package/utils/index.js +1 -1
  39. package/utils/index.mjs +156 -146
  40. /package/{interfaces/GridSortSettings.js → sortCommon.js} +0 -0
  41. /package/{interfaces/GridSortSettings.mjs → sortCommon.mjs} +0 -0
@@ -7,22 +7,22 @@
7
7
  */
8
8
  "use client";
9
9
  import * as i from "react";
10
- import { useDir as yt, setScrollbarWidth as ke, canUseDOM as q, getter as X, getActiveElement as St, getScrollbarWidth as kt, RowHeightService as De } from "@progress/kendo-react-common";
11
- import { getSelectionOptions as $, getEditableOptions as Dt, tableKeyboardNavigation as M, ClipboardService as Kt, TableKeyboardNavigationContext as Mt, getSelectedStateFromKeyDown as Tt, closestTagName as Ke, getColumnIndex as At, getRowIndex as Ht, editReducer as Ft, EDIT_ACTION as Gt, getDetailExpandableOptions as zt, detailExpandReducer as Me, getGroupExpandableOptions as Lt, groupExpandReducer as Nt, DETAIL_EXPAND_ACTION as Ot, getSelectedState as Te, updateLeft as Bt, updateRight as Ut } from "@progress/kendo-react-data-tools";
12
- import { ColumnResize as Vt } from "./drag/ColumnResize.mjs";
13
- import { CommonDragLogic as Wt } from "./drag/CommonDragLogic.mjs";
14
- import { SAFARI_REGEX as _t } from "./constants/index.mjs";
15
- import { getDefaultHeadContextMenuItems as jt, getDefaultBodyContextMenuItems as qt, sanitizeColumns as Xt, firefox as Ae, firefoxMaxHeight as He } from "./utils/index.mjs";
16
- import { VirtualScrollFixed as Fe } from "./VirtualScrollFixed.mjs";
17
- import { VirtualScroll as $t } from "./VirtualScroll.mjs";
18
- import { GridContextMenu as Jt } from "./contextMenu/GridContextMenu.mjs";
19
- import { GridContextMenuAnchorPart as Ge } from "./contextMenu/enums.mjs";
20
- import { normalize as Yt, firstLevelSortSeqMap as Qt } from "./interfaces/GridSortSettings.mjs";
21
- const Zt = i.createContext(void 0), sr = (t) => {
22
- var ye, Se;
23
- const E = t.gridProps.isClient, [h, fe] = i.useState({}), ze = (e) => {
24
- e.event.preventDefault(), fe({
25
- ...h,
10
+ import { canUseDOM as $, getActiveElement as zt, useDir as Nt, setScrollbarWidth as Fe, getter as J, getScrollbarWidth as Ot, RowHeightService as Le } from "@progress/kendo-react-common";
11
+ import { getSelectionOptions as Y, populateClipboardData as Bt, ClipboardActionType as me, getEditableOptions as Ut, tableKeyboardNavigation as T, ClipboardService as Vt, TableKeyboardNavigationContext as Wt, getSelectedStateFromKeyDown as _t, closestTagName as Ge, getColumnIndex as jt, getRowIndex as qt, editReducer as Xt, EDIT_ACTION as $t, getDetailExpandableOptions as Jt, detailExpandReducer as ze, getGroupExpandableOptions as Yt, groupExpandReducer as Qt, DETAIL_EXPAND_ACTION as Zt, getSelectedState as Ne, updateLeft as pt, updateRight as er } from "@progress/kendo-react-data-tools";
12
+ import { ColumnResize as tr } from "./drag/ColumnResize.mjs";
13
+ import { CommonDragLogic as rr } from "./drag/CommonDragLogic.mjs";
14
+ import { SAFARI_REGEX as nr } from "./constants/index.mjs";
15
+ import { getDefaultHeadContextMenuItems as or, getDefaultBodyContextMenuItems as ar, isRowReorderEnabled as ir, sanitizeColumns as dr, getDataAsArray as cr, firefox as Oe, firefoxMaxHeight as Be } from "./utils/index.mjs";
16
+ import { VirtualScrollFixed as Ue } from "./VirtualScrollFixed.mjs";
17
+ import { VirtualScroll as lr } from "./VirtualScroll.mjs";
18
+ import { GridContextMenu as sr } from "./contextMenu/GridContextMenu.mjs";
19
+ import { GridContextMenuAnchorPart as Ve } from "./contextMenu/enums.mjs";
20
+ import { normalize as ur, firstLevelSortSeqMap as gr } from "./sortCommon.mjs";
21
+ const fr = i.createContext(void 0), Sr = (t) => {
22
+ var ke, Ke;
23
+ const E = t.gridProps.isClient, [b, Pe] = i.useState({}), We = (e) => {
24
+ e.event.preventDefault(), Pe({
25
+ ...b,
26
26
  show: !0,
27
27
  offset: {
28
28
  left: e.event.pageX,
@@ -31,30 +31,31 @@ const Zt = i.createContext(void 0), sr = (t) => {
31
31
  dataItem: e.dataItem,
32
32
  field: e.field
33
33
  });
34
- }, me = () => {
35
- fe({});
36
- }, m = i.useMemo(() => t.columnsRef.current.find((e) => e.field === h.field), [t.columnsRef, h]), Pe = i.useMemo(() => {
37
- const e = t.gridProps.sortable && (m == null ? void 0 : m.sortable);
38
- return jt({
34
+ }, he = () => {
35
+ Pe({});
36
+ }, P = i.useMemo(() => t.columnsRef.current.find((e) => e.field === b.field), [t.columnsRef, b]), be = i.useMemo(() => {
37
+ const e = t.gridProps.sortable && (P == null ? void 0 : P.sortable);
38
+ return or({
39
39
  sortable: !!e,
40
- selectable: $(t.gridProps.selectable).enabled,
40
+ selectable: Y(t.gridProps.selectable).enabled,
41
41
  clipboard: !!t.gridProps.clipboard
42
42
  });
43
- }, [m, t.gridProps.sortable, t.gridProps.selectable, t.gridProps.clipboard]), he = i.useMemo(() => {
44
- const e = t.gridProps.sortable && (m == null ? void 0 : m.sortable);
45
- return qt({
43
+ }, [P, t.gridProps.sortable, t.gridProps.selectable, t.gridProps.clipboard]), Ie = i.useMemo(() => {
44
+ const e = t.gridProps.sortable && (P == null ? void 0 : P.sortable);
45
+ return ar({
46
46
  sortable: !!e,
47
- selectable: $(t.gridProps.selectable).enabled,
48
- clipboard: !!t.gridProps.clipboard
47
+ selectable: Y(t.gridProps.selectable).enabled,
48
+ clipboard: !!t.gridProps.clipboard,
49
+ rowReorderable: ir(t.gridProps.rowReorderable)
49
50
  });
50
- }, [m, t.gridProps.sortable, t.gridProps.selectable, t.gridProps.clipboard]), Le = i.useMemo(() => {
51
- const e = (m == null ? void 0 : m.contextMenu) || t.gridProps.contextMenu, r = typeof e == "function" ? e(h) : e;
52
- if (r && h.offset) {
53
- const n = h.dataItem ? Ge.body : Ge.head, o = r[n];
54
- return o === !1 ? void 0 : o === !0 || o === void 0 ? h.dataItem ? he : Pe : o;
51
+ }, [P, t.gridProps.sortable, t.gridProps.selectable, t.gridProps.clipboard]), _e = i.useMemo(() => {
52
+ const e = (P == null ? void 0 : P.contextMenu) || t.gridProps.contextMenu, r = typeof e == "function" ? e(b) : e;
53
+ if (r && b.offset) {
54
+ const n = b.dataItem ? Ve.body : Ve.head, o = r[n], a = b.dataItem ? Ie : be;
55
+ return o === !1 ? void 0 : o === !0 || o === void 0 ? a : o;
55
56
  }
56
- }, [t.gridProps.contextMenu, h, he, Pe, m]), Ne = (e) => {
57
- var c;
57
+ }, [t.gridProps.contextMenu, b, Ie, be, P]), je = (e) => {
58
+ var l, f, m, s, C, Te, Me, Ae, He;
58
59
  const r = e.event.item, n = {
59
60
  target: R.current,
60
61
  syntheticEvent: e.event.syntheticEvent,
@@ -62,8 +63,8 @@ const Zt = i.createContext(void 0), sr = (t) => {
62
63
  menuItem: r,
63
64
  ...e
64
65
  };
65
- t.gridProps.onContextMenuItemClick && s(t.gridProps.onContextMenuItemClick, n);
66
- const o = Z(), a = {
66
+ t.gridProps.onContextMenuItemClick && u(t.gridProps.onContextMenuItemClick, n);
67
+ const o = V(), a = {
67
68
  selectedField: t.gridProps.selectedField || "",
68
69
  componentId: t.id,
69
70
  dataItems: o,
@@ -77,31 +78,56 @@ const Zt = i.createContext(void 0), sr = (t) => {
77
78
  metaKey: !1,
78
79
  shiftKey: !1,
79
80
  isDrag: !1,
80
- ...$(t.gridProps.selectable),
81
+ ...Y(t.gridProps.selectable),
81
82
  ...n
82
- };
83
- switch ((c = r.data) == null ? void 0 : c.action) {
83
+ }, d = o.findIndex((fe) => fe === e.dataItem);
84
+ switch ((l = r.data) == null ? void 0 : l.action) {
84
85
  case "SortCommand":
85
- if (m) {
86
- const l = r.name ? r.name.toLowerCase().includes("asc") ? "asc" : r.name.toLowerCase().includes("desc") ? "desc" : void 0 : void 0;
87
- be(e.event.syntheticEvent, m, l);
86
+ if (P) {
87
+ const fe = (f = r.name) == null ? void 0 : f.toLowerCase().includes("asc"), Ft = ((m = r.name) == null ? void 0 : m.toLowerCase().includes("desc")) ? "desc" : void 0, Lt = fe ? "asc" : Ft, Gt = r.name ? Lt : void 0;
88
+ Re(e.event.syntheticEvent, P, Gt);
88
89
  }
89
90
  break;
90
91
  case "SelectRowCommand":
91
- et(a);
92
+ dt(a);
92
93
  break;
93
94
  case "SelectAllRowsCommand":
94
- pe(a);
95
+ it(a);
95
96
  break;
96
97
  case "ClearSelectionCommand":
97
- tt(a);
98
+ ct(a);
99
+ break;
100
+ case "ReorderRowCommand":
101
+ G.current = e.dataItem, (s = r.name) != null && s.toLowerCase().includes("rowup") && d > 0 && A(e.event.syntheticEvent, d - 1, "before"), (C = r.name) != null && C.toLowerCase().includes("rowdown") && d < o.length - 1 && A(e.event.syntheticEvent, d + 1, "after"), (Te = r.name) != null && Te.toLowerCase().includes("rowtop") && A(e.event.syntheticEvent, 0, "before"), (Me = r.name) != null && Me.toLowerCase().includes("rowbottom") && A(e.event.syntheticEvent, o.length - 1, "after");
102
+ break;
103
+ case "CopySelectionCommand":
104
+ B(
105
+ me.copy,
106
+ e.event.nativeEvent,
107
+ {
108
+ copyHeaders: !((Ae = r.name) != null && Ae.toLowerCase().includes("noheaders"))
109
+ },
110
+ e.dataItem,
111
+ e.field
112
+ );
113
+ break;
114
+ case "PasteCommand":
115
+ B(
116
+ me.paste,
117
+ e.event.nativeEvent,
118
+ {
119
+ copyHeaders: !((He = r.name) != null && He.toLowerCase().includes("noheaders"))
120
+ },
121
+ e.dataItem,
122
+ e.field
123
+ );
98
124
  break;
99
125
  }
100
- me();
101
- }, G = () => {
102
- const e = u.current.filter((r) => r.declarationIndex >= 0 && r.parentIndex === -1);
103
- return Xt(e);
104
- }, Oe = (e, r, n) => {
126
+ he();
127
+ }, z = () => {
128
+ const e = g.current.filter((r) => r.declarationIndex >= 0 && r.parentIndex === -1);
129
+ return dr(e);
130
+ }, qe = (e, r, n) => {
105
131
  if (t.gridProps.onContextMenu && E) {
106
132
  const o = {
107
133
  target: R.current,
@@ -110,65 +136,65 @@ const Zt = i.createContext(void 0), sr = (t) => {
110
136
  dataItem: r,
111
137
  field: n
112
138
  };
113
- s(t.gridProps.onContextMenu, o);
139
+ u(t.gridProps.onContextMenu, o);
114
140
  }
115
- t.gridProps.contextMenu && ze({
141
+ t.gridProps.contextMenu && We({
116
142
  event: e,
117
143
  dataItem: r,
118
144
  field: n
119
145
  });
120
- }, Be = (e) => {
146
+ }, Xe = (e) => {
121
147
  if (e.target !== e.currentTarget)
122
148
  return;
123
- clearTimeout(le.current), d.current && (d.current.table = x.current);
149
+ clearTimeout(se.current), c.current && (c.current.table = x.current);
124
150
  const r = e.currentTarget.scrollLeft, n = e.currentTarget.scrollTop, o = t.gridProps.scrollable === "virtual";
125
- t.gridProps.columnVirtualization && (!o || n === ce.current) && (le.current = window.setTimeout(() => {
126
- te();
127
- }, 0)), t.gridProps.scrollLeftRef && (t.gridProps.scrollLeftRef.current = r), H.current && H.current.setScrollLeft(r), A.current && A.current.setScrollLeft(r), d.current && n !== ce.current && d.current.scrollHandler(e), t.gridProps.onScroll && E && s(t.gridProps.onScroll, {
128
- ...P(e)
129
- }), ce.current = n;
130
- }, Ue = (e) => {
131
- var n, o, a, c;
132
- M.onKeyDown(e, {
151
+ t.gridProps.columnVirtualization && (!o || n === le.current) && (se.current = window.setTimeout(() => {
152
+ re();
153
+ }, 0)), t.gridProps.scrollLeftRef && (t.gridProps.scrollLeftRef.current = r), L.current && L.current.setScrollLeft(r), F.current && F.current.setScrollLeft(r), c.current && n !== le.current && c.current.scrollHandler(e), t.gridProps.onScroll && E && u(t.gridProps.onScroll, {
154
+ ...h(e)
155
+ }), le.current = n;
156
+ }, $e = (e) => {
157
+ var n, o;
158
+ T.onKeyDown(e, {
133
159
  navigatable: t.gridProps.navigatable || !1,
134
- contextStateRef: w,
135
- navigationStateRef: k,
136
- onNavigationAction: We,
137
- columns: G()
138
- }), M.onGetSnapshotBeforeUpdate({
139
- document: C(),
140
- contextStateRef: w,
141
- navigationStateRef: k
160
+ contextStateRef: y,
161
+ navigationStateRef: D,
162
+ onNavigationAction: Ye,
163
+ columns: z()
164
+ }), T.onGetSnapshotBeforeUpdate({
165
+ document: v(),
166
+ contextStateRef: y,
167
+ navigationStateRef: D
142
168
  });
143
169
  const r = {
144
- dataItems: O(),
145
- mode: b.mode,
146
- cell: b.cell,
170
+ dataItems: U(),
171
+ mode: I.mode,
172
+ cell: I.cell,
147
173
  componentId: t.id,
148
174
  selectedField: t.gridProps.selectedField,
149
- ...P(e)
175
+ ...h(e)
150
176
  };
151
- if (t.gridProps.onKeyDown && E && s(t.gridProps.onKeyDown, r), !t.gridProps.selectedField && b.enabled && t.gridProps.dataItemKey) {
152
- const l = Tt({
177
+ if (t.gridProps.onKeyDown && E && u(t.gridProps.onKeyDown, r), !t.gridProps.selectedField && I.enabled && t.gridProps.dataItemKey) {
178
+ const a = _t({
153
179
  event: r,
154
180
  selectedState: (n = t.gridProps.select) != null ? n : {},
155
181
  dataItemKey: t.gridProps.dataItemKey
156
182
  });
157
- if (l === t.gridProps.select)
183
+ if (a === t.gridProps.select)
158
184
  return;
159
- const f = e.target, I = Ke(f, "TD"), g = Ke(f, "TR"), y = At(I), F = Ht(g);
160
- if (y !== void 0 && F !== void 0) {
161
- const ge = Array.isArray(t.gridProps.data) ? (o = t.gridProps.data) == null ? void 0 : o[F] : (c = (a = t.gridProps.data) == null ? void 0 : a.data) == null ? void 0 : c[F];
162
- t.gridProps.onSelectionChange && s(t.gridProps.onSelectionChange, {
185
+ const d = e.target, l = Ge(d, "TD"), f = Ge(d, "TR"), m = jt(l), s = qt(f);
186
+ if (m !== void 0 && s !== void 0) {
187
+ const C = (o = cr(t.gridProps.data)) == null ? void 0 : o[s];
188
+ t.gridProps.onSelectionChange && u(t.gridProps.onSelectionChange, {
163
189
  ...r,
164
- select: l,
165
- dataItem: ge,
166
- startRowIndex: F,
167
- startColIndex: y,
168
- startDataItem: ge,
169
- endDataItem: ge,
170
- endRowIndex: F,
171
- endColIndex: y,
190
+ select: a,
191
+ dataItem: C,
192
+ startRowIndex: s,
193
+ startColIndex: m,
194
+ startDataItem: C,
195
+ endDataItem: C,
196
+ endRowIndex: s,
197
+ endColIndex: m,
172
198
  ctrlKey: e.ctrlKey,
173
199
  altKey: e.altKey,
174
200
  metaKey: e.metaKey,
@@ -177,83 +203,83 @@ const Zt = i.createContext(void 0), sr = (t) => {
177
203
  });
178
204
  }
179
205
  }
180
- }, Ve = (e) => {
181
- M.onFocus(e, {
206
+ }, Je = (e) => {
207
+ T.onFocus(e, {
182
208
  navigatable: !!t.gridProps.navigatable,
183
- contextStateRef: w
209
+ contextStateRef: y
184
210
  });
185
- }, We = (e) => {
186
- if (e.action === "moveToNextPage" && nt(e.event), e.action === "moveToPrevPage" && ot(e.event), e.focusElement && e.action === "reorderToRight") {
211
+ }, Ye = (e) => {
212
+ if (e.action === "moveToNextPage" && st(e.event), e.action === "moveToPrevPage" && ut(e.event), e.focusElement && e.action === "reorderToRight") {
187
213
  const r = parseInt(e.focusElement.ariaColIndex, 10) - 1;
188
- r < u.current.length - 1 && Y(r, r + 1, e.event);
214
+ r < g.current.length - 1 && Z(r, r + 1, e.event);
189
215
  }
190
216
  if (e.focusElement && e.action === "reorderToLeft") {
191
217
  const r = parseInt(e.focusElement.ariaColIndex, 10) - 1;
192
- r > 0 && Y(r, r - 1, e.event);
218
+ r > 0 && Z(r, r - 1, e.event);
193
219
  }
194
220
  if (t.gridProps.onNavigationAction && E) {
195
221
  const r = {
196
222
  focusElement: e.focusElement,
197
- ...P(e.event)
223
+ ...h(e.event)
198
224
  };
199
- s(t.gridProps.onNavigationAction, r);
225
+ u(t.gridProps.onNavigationAction, r);
200
226
  }
201
- }, _e = (e, r) => {
202
- t.gridProps.onRowClick && e.target.nodeName === "TD" && s(t.gridProps.onRowClick, {
227
+ }, Qe = (e, r) => {
228
+ t.gridProps.onRowClick && e.target.nodeName === "TD" && u(t.gridProps.onRowClick, {
203
229
  dataItem: r,
204
- ...P(e)
230
+ ...h(e)
205
231
  });
206
- }, je = (e, r) => {
207
- t.gridProps.onRowDoubleClick && e.target.nodeName === "TD" && s(t.gridProps.onRowDoubleClick, {
232
+ }, Ze = (e, r) => {
233
+ t.gridProps.onRowDoubleClick && e.target.nodeName === "TD" && u(t.gridProps.onRowDoubleClick, {
208
234
  dataItem: r,
209
- ...P(e)
235
+ ...h(e)
210
236
  });
211
- }, qe = (e, r, n) => {
212
- if (we.enabled && we.mode === "incell" && t.gridProps.dataItemKey) {
213
- const o = Ft(t.gridProps.edit, {
214
- type: Gt.ENTER_FIELD_EDIT,
237
+ }, pe = (e, r, n) => {
238
+ if (Se.enabled && Se.mode === "incell" && t.gridProps.dataItemKey) {
239
+ const o = Xt(t.gridProps.edit, {
240
+ type: $t.ENTER_FIELD_EDIT,
215
241
  payload: { id: r[t.gridProps.dataItemKey], field: n }
216
242
  });
217
- t.gridProps.onEditChange && s(t.gridProps.onEditChange, {
243
+ t.gridProps.onEditChange && u(t.gridProps.onEditChange, {
218
244
  edit: o,
219
- ...P(e)
245
+ ...h(e)
220
246
  });
221
247
  }
222
- }, Xe = (e, r) => {
248
+ }, et = (e, r) => {
223
249
  var o;
224
- if (zt(t.detailExpandable).enabled) {
225
- const a = Me((o = t.gridProps.detailExpand) != null ? o : {}, e);
226
- t.gridProps.onDetailExpandChange && s(t.gridProps.onDetailExpandChange, {
227
- ...P(r),
250
+ if (Jt(t.detailExpandable).enabled) {
251
+ const a = ze((o = t.gridProps.detailExpand) != null ? o : {}, e);
252
+ t.gridProps.onDetailExpandChange && u(t.gridProps.onDetailExpandChange, {
253
+ ...h(r),
228
254
  detailExpand: a
229
255
  });
230
256
  }
231
- }, $e = (e, r) => {
257
+ }, tt = (e, r) => {
232
258
  var o;
233
- const n = Lt(
259
+ const n = Yt(
234
260
  typeof t.gridProps.groupable == "object" ? t.gridProps.groupable.expandable !== !1 : t.gridProps.groupable
235
261
  );
236
262
  if (n.enabled) {
237
- const a = Nt((o = t.gridProps.groupExpand) != null ? o : [], e, n);
238
- t.gridProps.onGroupExpandChange && s(t.gridProps.onGroupExpandChange, {
239
- ...P(r),
263
+ const a = Qt((o = t.gridProps.groupExpand) != null ? o : [], e, n);
264
+ t.gridProps.onGroupExpandChange && u(t.gridProps.onGroupExpandChange, {
265
+ ...h(r),
240
266
  groupExpand: a
241
267
  });
242
268
  }
243
- }, be = (e, r, n) => {
244
- const { allowUnsort: o, mode: a } = Yt(t.gridProps.sortable || !1, r.sortable || !1), c = (t.gridProps.sort || []).filter((I) => I.field === r.field)[0], l = n || Qt[o][c && c.dir || ""], f = a === "single" ? [] : (t.gridProps.sort || []).filter((I) => I.field !== r.field);
245
- l !== "" && r.field && f.push({ field: r.field, dir: l }), Ie(f, e);
246
- }, Je = (e) => {
269
+ }, Re = (e, r, n) => {
270
+ const { allowUnsort: o, mode: a } = ur(t.gridProps.sortable || !1, r.sortable || !1), d = (t.gridProps.sort || []).filter((m) => m.field === r.field)[0], l = n || gr[o][d && d.dir || ""], f = a === "single" ? [] : (t.gridProps.sort || []).filter((m) => m.field !== r.field);
271
+ l !== "" && r.field && f.push({ field: r.field, dir: l }), Ce(f, e);
272
+ }, rt = (e) => {
247
273
  var r;
248
274
  if (e.field === t.gridProps.expandField || e._expand || t.gridProps.group && e.field === void 0) {
249
275
  if (t.gridProps.onExpandChange) {
250
- const n = t.gridProps.dataItemKey ? Me((r = t.gridProps.detailExpand) != null ? r : {}, {
251
- type: Ot.SET,
276
+ const n = t.gridProps.dataItemKey ? ze((r = t.gridProps.detailExpand) != null ? r : {}, {
277
+ type: Zt.SET,
252
278
  id: e.dataItem[t.gridProps.dataItemKey],
253
279
  payload: e.value
254
280
  }) : t.gridProps.detailExpand;
255
- s(t.gridProps.onExpandChange, {
256
- ...P(e.syntheticEvent),
281
+ u(t.gridProps.onExpandChange, {
282
+ ...h(e.syntheticEvent),
257
283
  expand: n,
258
284
  dataItem: e.dataItem,
259
285
  dataIndex: e.dataIndex,
@@ -262,49 +288,49 @@ const Zt = i.createContext(void 0), sr = (t) => {
262
288
  }
263
289
  return;
264
290
  }
265
- t.gridProps.onItemChange && s(t.gridProps.onItemChange, {
266
- ...P(e.syntheticEvent),
291
+ t.gridProps.onItemChange && u(t.gridProps.onItemChange, {
292
+ ...h(e.syntheticEvent),
267
293
  dataItem: e.dataItem,
268
294
  dataIndex: e.dataIndex,
269
295
  field: e.field,
270
296
  value: e.value
271
297
  });
272
- }, Ye = (e) => {
298
+ }, nt = (e) => {
273
299
  var r;
274
- if (t.gridProps.onSelectionChange && b.enabled) {
275
- const { event: n, dataItem: o, dataIndex: a, columnIndex: c } = e, l = {
276
- ...P(n.syntheticEvent),
300
+ if (t.gridProps.onSelectionChange && I.enabled) {
301
+ const { event: n, dataItem: o, dataIndex: a, columnIndex: d } = e, l = {
302
+ ...h(n.syntheticEvent),
277
303
  dataItem: o,
278
- startColIndex: c,
279
- endColIndex: c,
304
+ startColIndex: d,
305
+ endColIndex: d,
280
306
  startRowIndex: a,
281
307
  endRowIndex: a,
282
- dataItems: O(),
308
+ dataItems: U(),
283
309
  altKey: !1,
284
310
  ctrlKey: !1,
285
311
  shiftKey: !1,
286
312
  metaKey: !1,
287
- mode: b.mode,
288
- cell: b.cell,
313
+ mode: I.mode,
314
+ cell: I.cell,
289
315
  isDrag: !1,
290
316
  componentId: t.id,
291
317
  selectedField: t.gridProps.selectedField || ""
292
318
  };
293
- s(t.gridProps.onSelectionChange, {
319
+ u(t.gridProps.onSelectionChange, {
294
320
  ...l,
295
- select: t.gridProps.dataItemKey ? Te({
321
+ select: t.gridProps.dataItemKey ? Ne({
296
322
  event: l,
297
323
  selectedState: (r = t.gridProps.select) != null ? r : {},
298
324
  dataItemKey: t.gridProps.dataItemKey
299
325
  }) : {}
300
326
  });
301
327
  }
302
- }, Qe = (e) => {
328
+ }, ot = (e) => {
303
329
  var r;
304
- if (t.gridProps.onHeaderSelectionChange && b.enabled) {
305
- const n = O();
306
- s(t.gridProps.onHeaderSelectionChange, {
307
- select: e.syntheticEvent.target.checked ? n.reduce((o, a) => (t.gridProps.dataItemKey && X(t.gridProps.dataItemKey)(a) !== void 0 && (o[X(t.gridProps.dataItemKey)(a)] = !0), o), {}) : {},
330
+ if (t.gridProps.onHeaderSelectionChange && I.enabled) {
331
+ const n = U();
332
+ u(t.gridProps.onHeaderSelectionChange, {
333
+ select: e.syntheticEvent.target.checked ? n.reduce((o, a) => (t.gridProps.dataItemKey && J(t.gridProps.dataItemKey)(a) !== void 0 && (o[J(t.gridProps.dataItemKey)(a)] = !0), o), {}) : {},
308
334
  field: e.field,
309
335
  nativeEvent: e.syntheticEvent && e.syntheticEvent.nativeEvent,
310
336
  syntheticEvent: e.syntheticEvent,
@@ -313,35 +339,35 @@ const Zt = i.createContext(void 0), sr = (t) => {
313
339
  selectedField: (r = t.gridProps.selectedField) != null ? r : ""
314
340
  });
315
341
  }
316
- }, z = (e, r) => {
317
- t.gridProps.onSelectionChange && E && b.enabled && s(t.gridProps.onSelectionChange, {
342
+ }, N = (e, r) => {
343
+ t.gridProps.onSelectionChange && I.enabled && u(t.gridProps.onSelectionChange, {
318
344
  ...e,
319
345
  select: r
320
346
  });
321
- }, Ze = (e) => {
347
+ }, at = (e) => {
322
348
  var r;
323
- if (t.gridProps.onSelectionChange && b.enabled) {
324
- const n = Z()[e.startRowIndex], o = Z()[e.endRowIndex], a = {
349
+ if (t.gridProps.onSelectionChange && I.enabled) {
350
+ const n = V()[e.startRowIndex], o = V()[e.endRowIndex], a = {
325
351
  syntheticEvent: void 0,
326
352
  target: R.current,
327
353
  selectedField: t.gridProps.selectedField || "",
328
354
  componentId: t.id,
329
- dataItems: O(),
355
+ dataItems: U(),
330
356
  dataItem: null,
331
357
  startDataItem: n,
332
358
  endDataItem: o,
333
359
  ...e
334
- }, c = Te({
360
+ }, d = Ne({
335
361
  event: a,
336
362
  selectedState: (r = t.gridProps.select) != null ? r : {},
337
363
  // Thats kinda strange, even through the `dataItemKey` is required by the `getSelectedState`
338
364
  // it does work correctly even without it
339
365
  dataItemKey: t.gridProps.dataItemKey
340
366
  });
341
- z(a, c);
367
+ N(a, d);
342
368
  }
343
- }, pe = (e) => {
344
- if (t.gridProps.onSelectionChange && b.enabled) {
369
+ }, it = (e) => {
370
+ if (t.gridProps.onSelectionChange && I.enabled) {
345
371
  const r = e.dataItems[0], n = e.dataItems[e.dataItems.length - 1], o = {}, a = {
346
372
  ...e,
347
373
  startDataItem: r,
@@ -349,176 +375,225 @@ const Zt = i.createContext(void 0), sr = (t) => {
349
375
  startRowIndex: 0,
350
376
  endRowIndex: e.dataItems.length - 1,
351
377
  startColIndex: 0,
352
- endColIndex: u.current.length - 1
378
+ endColIndex: g.current.length - 1
353
379
  };
354
- e.dataItems.forEach((c) => {
355
- const f = X(t.gridProps.dataItemKey)(c);
356
- o[f] = e.cell ? [...Array(u.current.length).keys()] : !0;
357
- }), z(a, o);
380
+ e.dataItems.forEach((d) => {
381
+ const f = J(t.gridProps.dataItemKey)(d);
382
+ o[f] = e.cell ? [...Array(g.current.length).keys()] : !0;
383
+ }), N(a, o);
358
384
  }
359
- }, et = (e) => {
360
- if (t.gridProps.onSelectionChange && b.enabled) {
361
- const n = X(t.gridProps.dataItemKey)(e.dataItem), o = 0, a = u.current.length - 1, c = e.dataItems.findIndex(
362
- (y) => y[t.gridProps.dataItemKey] === e.dataItem[t.gridProps.dataItemKey]
363
- ), I = {
385
+ }, dt = (e) => {
386
+ if (t.gridProps.onSelectionChange && I.enabled) {
387
+ const n = J(t.gridProps.dataItemKey)(e.dataItem), o = 0, a = g.current.length - 1, d = e.dataItems.findIndex(
388
+ (C) => C[t.gridProps.dataItemKey] === e.dataItem[t.gridProps.dataItemKey]
389
+ ), m = {
364
390
  ...e,
365
- startDataItem: c,
366
- endDataItem: c,
367
- startRowIndex: c,
368
- endRowIndex: c,
391
+ startDataItem: d,
392
+ endDataItem: d,
393
+ startRowIndex: d,
394
+ endRowIndex: d,
369
395
  startColIndex: o,
370
396
  endColIndex: a
371
- }, g = e.mode === "multiple" ? t.gridProps.select || {} : {};
372
- g[n] === !0 || Array.isArray(g[n]) && g[n].length === u.current.length ? delete g[n] : g[n] = e.cell ? [...Array(u.current.length).keys()] : !0, z(I, g);
397
+ }, s = e.mode === "multiple" ? t.gridProps.select || {} : {};
398
+ s[n] === !0 || Array.isArray(s[n]) && s[n].length === g.current.length ? delete s[n] : s[n] = e.cell ? [...Array(g.current.length).keys()] : !0, N(m, s);
373
399
  }
374
- }, tt = (e) => {
375
- t.gridProps.onSelectionChange && b.enabled && z(e, {});
376
- }, L = (e, r, n, o, a) => {
377
- const c = t.gridProps.onDataStateChange;
400
+ }, ct = (e) => {
401
+ t.gridProps.onSelectionChange && I.enabled && N(e, {});
402
+ }, M = (e, r, n, o, a) => {
403
+ const d = t.gridProps.onDataStateChange;
378
404
  if (e) {
379
- const l = { ...P(o), ...r, targetEvent: a };
380
- s(e, l);
405
+ const l = { ...h(o), ...r, targetEvent: a };
406
+ u(e, l);
381
407
  } else
382
- c && s(c, {
383
- ...P(o),
408
+ d && u(d, {
409
+ ...h(o),
384
410
  targetEvent: a || {},
385
411
  dataState: {
386
- ...ft(),
412
+ ...Ct(),
387
413
  ...n
388
414
  }
389
415
  });
390
- }, N = (e, r, n) => {
391
- L(
416
+ }, O = (e, r, n) => {
417
+ M(
392
418
  t.gridProps.onPageChange,
393
419
  { page: e },
394
420
  { skip: e.skip, take: e.take },
395
421
  r,
396
422
  n
397
423
  );
398
- }, rt = () => {
424
+ }, lt = () => {
399
425
  let e = t.gridProps.total || 0;
400
426
  return Array.isArray(t.gridProps.data) ? e = e || t.gridProps.data.length : t.gridProps.data && (e = e || t.gridProps.data.total), e;
401
- }, nt = (e) => {
402
- var a, c;
403
- const r = (c = (a = t.gridProps.take) != null ? a : t.gridProps.pageSize) != null ? c : 0, n = (t.gridProps.skip || 0) + r, o = rt();
404
- n < o && N({ skip: n, take: r }, e);
405
- }, ot = (e) => {
427
+ }, st = (e) => {
428
+ var a, d;
429
+ const r = (d = (a = t.gridProps.take) != null ? a : t.gridProps.pageSize) != null ? d : 0, n = (t.gridProps.skip || 0) + r, o = lt();
430
+ n < o && O({ skip: n, take: r }, e);
431
+ }, ut = (e) => {
406
432
  var o, a;
407
433
  const r = (a = (o = t.gridProps.take) != null ? o : t.gridProps.pageSize) != null ? a : 0, n = (t.gridProps.skip || 0) - r;
408
- n >= 0 && N({ skip: n, take: r }, e);
409
- }, at = (e) => {
410
- N({ skip: e.skip, take: e.take }, e.syntheticEvent, e.targetEvent);
411
- }, Ie = (e, r) => {
412
- L(
434
+ n >= 0 && O({ skip: n, take: r }, e);
435
+ }, gt = (e) => {
436
+ O({ skip: e.skip, take: e.take }, e.syntheticEvent, e.targetEvent);
437
+ }, Ce = (e, r) => {
438
+ M(
413
439
  t.gridProps.onSortChange,
414
440
  { sort: e },
415
441
  { sort: e, ...t.gridProps.scrollable === "virtual" ? { skip: 0 } : {} },
416
442
  r
417
443
  );
418
- }, it = (e, r) => {
419
- L(
444
+ }, ft = (e, r) => {
445
+ M(
420
446
  t.gridProps.onFilterChange,
421
447
  { filter: e },
422
448
  { filter: e || void 0, skip: 0 },
423
449
  r
424
450
  );
425
- }, J = (e, r) => {
451
+ }, mt = (e) => {
452
+ const r = t.gridProps.searchFields || g.current.map((a) => a.field) || [], n = e.nativeEvent.target.value, o = {
453
+ logic: "or",
454
+ filters: r.filter((a) => a !== void 0).map((a) => {
455
+ var d;
456
+ return typeof a == "string" ? { field: a, value: n, operator: "contains" } : {
457
+ value: n,
458
+ operator: (d = a.operator) != null ? d : "contains",
459
+ field: a.field,
460
+ ignoreCase: a.ignoreCase
461
+ };
462
+ })
463
+ };
464
+ M(
465
+ t.gridProps.onSearchChange,
466
+ {
467
+ search: o
468
+ },
469
+ {},
470
+ e.syntheticEvent
471
+ );
472
+ }, Q = (e, r) => {
426
473
  const n = r.nativeEvent ? r : { nativeEvent: r.nativeEvent || r.originalEvent };
427
- e.length === 0 && t.gridProps.navigatable && (ae.current = !0), L(
474
+ e.length === 0 && t.gridProps.navigatable && (ie.current = !0), M(
428
475
  t.gridProps.onGroupChange,
429
476
  { group: e },
430
477
  { group: e, skip: 0 },
431
478
  n
432
479
  );
433
- }, Y = (e, r, n) => {
434
- const o = u.current[e], a = o.depth, c = (g) => {
480
+ }, Pt = (e) => {
481
+ if (t.gridProps.onColumnsStateChange) {
482
+ const r = {
483
+ target: R.current,
484
+ columnsState: e
485
+ };
486
+ u(t.gridProps.onColumnsStateChange, r);
487
+ }
488
+ }, Z = (e, r, n) => {
489
+ const o = g.current[e], a = o.depth, d = (s) => {
435
490
  do
436
- g++;
437
- while (g < u.current.length && u.current[g].depth > a);
438
- return g;
439
- }, l = u.current.splice(e, c(e) - e);
440
- u.current.splice(e < r ? c(r - l.length) : r, 0, ...l), u.current.filter((g) => g.declarationIndex >= 0).forEach((g, y) => g.orderIndex = y);
441
- const f = u.current[e].locked && u.current[r].locked;
442
- Bt(t.columnsMapRef, u.current, f || _.current), Ut(t.columnsMapRef, u.current, f || _.current), oe.current && (_.current = !1, oe.current = !1);
443
- const I = G();
444
- if (te(), t.gridProps.onColumnReorder) {
445
- const g = {
491
+ s++;
492
+ while (s < g.current.length && g.current[s].depth > a);
493
+ return s;
494
+ }, l = g.current.splice(e, d(e) - e);
495
+ g.current.splice(e < r ? d(r - l.length) : r, 0, ...l), g.current.filter((s) => s.declarationIndex >= 0).forEach((s, C) => s.orderIndex = C);
496
+ const f = g.current[e].locked && g.current[r].locked;
497
+ pt(t.columnsMapRef, g.current, f || X.current), er(t.columnsMapRef, g.current, f || X.current), ae.current && (X.current = !1, ae.current = !1);
498
+ const m = z();
499
+ if (re(), t.gridProps.onColumnReorder) {
500
+ const s = {
446
501
  target: R.current,
447
- columns: I,
502
+ columns: m,
448
503
  columnId: o.id,
449
504
  nativeEvent: n
450
505
  };
451
- s(t.gridProps.onColumnReorder, g);
506
+ u(t.gridProps.onColumnReorder, s);
452
507
  }
453
- }, dt = (e, r, n) => {
508
+ }, A = (e, r, n) => {
454
509
  const o = typeof t.gridProps.rowReorderable == "object" ? t.gridProps.rowReorderable.enabled : t.gridProps.rowReorderable;
455
- if (n === "forbidden" || !o || !j.current)
510
+ if (n === "forbidden" || !o || !G.current)
456
511
  return;
457
- const { slicedData: a, dataRef: c } = t, l = (a || c)[r];
458
- t.gridProps.onRowReorder && s(t.gridProps.onRowReorder, {
459
- draggedDataItems: [j.current],
512
+ const { slicedData: a, dataRef: d } = t, l = (a || d)[r];
513
+ t.gridProps.onRowReorder && u(t.gridProps.onRowReorder, {
514
+ draggedDataItems: [G.current],
460
515
  droppedDataItem: l == null ? void 0 : l.dataItem,
461
516
  dropPosition: n,
462
517
  nativeEvent: e.originalEvent,
463
518
  dragEvent: e,
464
519
  target: R.current
465
- }), j.current = null;
466
- }, ct = (e, r, n) => {
520
+ }), G.current = null;
521
+ }, ht = (e, r, n) => {
467
522
  if (t.gridProps.group === void 0)
468
523
  return;
469
524
  const o = t.gridProps.group.slice();
470
- o.splice(r, 0, ...o.splice(e, 1)), J(o, n);
471
- }, Re = (e, r, n) => {
472
- const o = u.current[e].field;
525
+ o.splice(r, 0, ...o.splice(e, 1)), Q(o, n);
526
+ }, ve = (e, r, n) => {
527
+ const o = g.current[e].field;
473
528
  if (!o)
474
529
  return;
475
530
  const a = (t.gridProps.group || []).slice();
476
- a.splice(r, 0, { field: o }), J(a, n);
477
- }, lt = (e, r) => {
531
+ a.splice(r, 0, { field: o }), Q(a, n);
532
+ }, bt = (e, r) => {
478
533
  const n = S.current.getCurrentGroupsLength;
479
- Re(e, n, r);
480
- }, Q = () => {
534
+ ve(e, n, r);
535
+ }, p = () => {
481
536
  let e = 0;
482
- if (!v.current.colGroupMain)
537
+ if (!w.current.colGroupMain)
483
538
  return;
484
- const r = v.current.colGroupMain.children;
539
+ const r = w.current.colGroupMain.children;
485
540
  for (let n = 0; n < r.length; n++) {
486
541
  const o = r[n].width;
487
542
  if (!o)
488
543
  return;
489
544
  e += parseFloat(o.toString());
490
545
  }
491
- e = Math.round(e), H.current && H.current.setWidth(e), A.current && A.current.setWidth(e), x.current && (x.current.style.width = e + "px");
492
- }, st = (e, r) => {
493
- if (t.gridProps.onClipboard && E) {
494
- if (!ut() || !e)
546
+ e = Math.round(e), L.current && L.current.setWidth(e), F.current && F.current.setWidth(e), x.current && (x.current.style.width = e + "px");
547
+ }, B = i.useCallback(
548
+ (e, r, n, o, a) => {
549
+ var m;
550
+ if (!It() && !n || !e)
495
551
  return;
496
- s(t.gridProps.onClipboard, {
552
+ const d = {
497
553
  type: e,
498
554
  nativeEvent: r,
499
- columns: u.current,
555
+ columns: g.current,
500
556
  dataItemKey: t.gridProps.dataItemKey || "",
501
- ...typeof t.gridProps.clipboard != "boolean" ? t.gridProps.clipboard : {}
557
+ dataItem: o,
558
+ field: a,
559
+ ...typeof t.gridProps.clipboard != "boolean" ? t.gridProps.clipboard : {},
560
+ ...n
561
+ }, l = V(), f = Bt({
562
+ event: d,
563
+ data: l,
564
+ selectedState: (m = t.gridProps.select) != null ? m : {},
565
+ previousCopiedItems: ye.current
502
566
  });
503
- }
504
- }, ut = () => {
505
- var a, c, l;
506
- if (!q)
567
+ e !== me.paste && (ye.current = f.copiedItems), t.gridProps.onClipboard && E && u(t.gridProps.onClipboard, {
568
+ ...d,
569
+ ...f
570
+ });
571
+ },
572
+ [
573
+ t.gridProps.select,
574
+ t.gridProps.dataItemKey,
575
+ t.gridProps.data,
576
+ t.gridProps.clipboard,
577
+ t.gridProps.onClipboard
578
+ ]
579
+ ), It = () => {
580
+ var a, d, l;
581
+ if (!$)
507
582
  return !1;
508
- const e = St(C()), r = e ? e.matches(".k-table-td") ? e : (a = C()) == null ? void 0 : a.body : (c = C()) == null ? void 0 : c.body, n = r.closest(".k-grid-container"), o = r && ((l = K.current) == null ? void 0 : l.contains(r));
583
+ const e = zt(v()), r = e ? e.matches(".k-table-td") ? e : (a = v()) == null ? void 0 : a.body : (d = v()) == null ? void 0 : d.body, n = r.closest(".k-grid-container"), o = r && ((l = K.current) == null ? void 0 : l.contains(r));
509
584
  return !!(r && o && n);
510
- }, gt = (e, r, n, o, a, c) => {
511
- Q(), _.current = !0, oe.current = !0, t.gridProps.onColumnResize && E && s(t.gridProps.onColumnResize, {
512
- columns: G(),
585
+ }, Rt = (e, r, n, o, a, d) => {
586
+ p(), X.current = !0, ae.current = !0, t.gridProps.onColumnResize && E && u(t.gridProps.onColumnResize, {
587
+ columns: z(),
513
588
  nativeEvent: o,
514
- targetColumnId: c,
589
+ targetColumnId: d,
515
590
  index: e,
516
591
  newWidth: r,
517
592
  oldWidth: n,
518
593
  end: a,
519
594
  target: R.current
520
595
  });
521
- }, ft = () => {
596
+ }, Ct = () => {
522
597
  var e;
523
598
  return {
524
599
  filter: t.gridProps.filter,
@@ -527,103 +602,112 @@ const Zt = i.createContext(void 0), sr = (t) => {
527
602
  take: (e = t.gridProps.take) != null ? e : t.gridProps.pageSize,
528
603
  group: t.gridProps.group
529
604
  };
530
- }, P = (e) => ({
605
+ }, h = (e) => ({
531
606
  nativeEvent: e && e.nativeEvent,
532
607
  syntheticEvent: e,
533
608
  target: R.current
534
- }), mt = (e) => ({
609
+ }), vt = (e) => ({
535
610
  ...e,
536
611
  nativeEvent: void 0,
537
612
  syntheticEvent: void 0,
538
613
  target: void 0,
539
614
  targetEvent: void 0,
540
615
  focusElement: void 0
541
- }), s = (e, r) => {
542
- if (e.name === "proxy") {
543
- e.call(void 0, mt(r));
616
+ }), u = (e, r) => {
617
+ if (t.gridProps.isClient) {
618
+ e(r);
544
619
  return;
545
620
  }
546
- e.call(void 0, r);
547
- }, Pt = () => {
621
+ e(vt(r));
622
+ }, Et = () => {
548
623
  var e, r, n;
549
- if (T.current && ((e = T.current) == null ? void 0 : e.getElementsByClassName("k-grid-edit-row").length) > 0) {
550
- de.current = !1, (r = document.activeElement) != null && r.closest(".k-grid-edit-row") ? ie.current = document.activeElement : ie.current = void 0;
551
- const o = Array.from((n = T.current) == null ? void 0 : n.getElementsByClassName("k-grid-edit-row"));
552
- o.length > ue.current.length ? W.current = o.filter(
553
- (a) => !ue.current.includes(a)
554
- )[0] : o.length === 1 && (W.current = o[0], de.current = !0), ue.current = o;
624
+ if (H.current && ((e = H.current) == null ? void 0 : e.getElementsByClassName("k-grid-edit-row").length) > 0) {
625
+ ce.current = !1, (r = document.activeElement) != null && r.closest(".k-grid-edit-row") ? de.current = document.activeElement : de.current = void 0;
626
+ const o = Array.from((n = H.current) == null ? void 0 : n.getElementsByClassName("k-grid-edit-row"));
627
+ o.length > ge.current.length ? q.current = o.filter(
628
+ (a) => !ge.current.includes(a)
629
+ )[0] : o.length === 1 && (q.current = o[0], ce.current = !0), ge.current = o;
555
630
  }
556
- }, O = () => t.dataRef.filter((e) => e.rowType === "data").map((e) => e.dataItem), Z = () => (t.slicedData || t.dataRef).filter((e) => e.rowType === "data").map((e) => e.dataItem), p = () => (ne.current || (ne.current = kt() || void 0), ne.current), C = () => {
631
+ }, U = () => t.dataRef.filter((e) => e.rowType === "data").map((e) => e.dataItem), V = () => (t.slicedData || t.dataRef).filter((e) => e.rowType === "data").map((e) => e.dataItem), ee = () => (oe.current || (oe.current = Ot() || void 0), oe.current), v = () => {
557
632
  var e;
558
- if (q)
559
- return ((e = B()) == null ? void 0 : e.ownerDocument) || document;
560
- }, B = () => K.current, ee = i.useCallback(
633
+ if ($)
634
+ return ((e = W()) == null ? void 0 : e.ownerDocument) || document;
635
+ }, W = () => K.current, te = i.useCallback(
561
636
  (e) => {
562
637
  var o;
563
- if (!d.current || !((o = d.current) != null && o.container) || t.gridProps.scrollable === "none")
638
+ if (!c.current || !((o = c.current) != null && o.container) || t.gridProps.scrollable === "none")
564
639
  return;
565
- D.current && D.current.disconnect();
566
- const { rowIndex: r } = e, n = B();
640
+ k.current && k.current.disconnect();
641
+ const { rowIndex: r } = e, n = W();
567
642
  if (t.gridProps.scrollable === "virtual")
568
- d.current.askedSkip = r, d.current.container.scroll(
643
+ c.current.askedSkip = r, c.current.container.scroll(
569
644
  0,
570
- Math.round(d.current.askedSkip / d.current.total * d.current.container.scrollHeight)
645
+ Math.round(c.current.askedSkip / c.current.total * c.current.container.scrollHeight)
571
646
  );
572
647
  else if (n) {
573
648
  const a = r < 1 ? n.querySelector("tbody > tr:nth-child(1)") : n.querySelector(`tbody > tr:nth-child(${r + 1})`);
574
- a && V.current && (V.current.scrollTop = a.offsetTop);
649
+ a && j.current && (j.current.scrollTop = a.offsetTop);
575
650
  }
576
651
  },
577
652
  [t.gridProps.scrollable]
578
- ), Ee = (e) => JSON.stringify(e.map((r) => ({ id: r.id, field: r.field, title: r.title, children: r.children }))), ht = () => Ee(xt) === Ee(u.current), bt = () => {
579
- ht() || te();
580
- }, It = () => {
653
+ ), Ee = (e) => JSON.stringify(e.map((r) => ({ id: r.id, field: r.field, title: r.title, children: r.children }))), wt = () => Ee(At) === Ee(g.current), yt = () => {
654
+ wt() || re();
655
+ }, xt = () => {
581
656
  const { data: e, total: r } = t.gridProps;
582
657
  return Array.isArray(e) ? e.length === r : e ? r === e.total : !1;
583
- }, Rt = (e, r) => {
658
+ }, St = (e, r) => {
584
659
  var n, o;
585
- if (d.current) {
586
- if (d.current.fixedScroll = t.gridProps.fixedScroll || !1, d.current.PageChange = N, d.current.realSkip = t.gridProps.skip || 0, d.current.pageSize = (o = (n = t.gridProps.take) != null ? n : t.gridProps.pageSize) != null ? o : 0, d.current.scrollableVirtual = t.gridProps.scrollable === "virtual", d.current.total = e, d.current.propsSkip = (t.gridProps.skip || 0) + (t.gridProps.scrollable === "virtual" ? d.current.topCacheCount + (d.current.attendedSkip - (t.gridProps.skip || 0)) : 0), t.gridProps.rowHeight !== void 0 && t.gridProps.rowHeight > 0 && !r) {
660
+ if (c.current) {
661
+ if (c.current.fixedScroll = t.gridProps.fixedScroll || !1, c.current.PageChange = O, c.current.realSkip = t.gridProps.skip || 0, c.current.pageSize = (o = (n = t.gridProps.take) != null ? n : t.gridProps.pageSize) != null ? o : 0, c.current.scrollableVirtual = t.gridProps.scrollable === "virtual", c.current.total = e, c.current.propsSkip = (t.gridProps.skip || 0) + (t.gridProps.scrollable === "virtual" ? c.current.topCacheCount + (c.current.attendedSkip - (t.gridProps.skip || 0)) : 0), t.gridProps.rowHeight !== void 0 && t.gridProps.rowHeight > 0 && !r) {
587
662
  const a = t.gridProps.rowHeight * e;
588
- d.current.containerHeight = Ae ? Math.min(He, a) : a;
663
+ c.current.containerHeight = Oe ? Math.min(Be, a) : a;
589
664
  } else
590
- d.current.containerHeight = 1533915;
591
- if (d.current.containerRef = V, d.current.tableBodyRef = T, d.current.table = x.current, d.current instanceof Fe) {
592
- const { rowHeight: a = 0, detail: c, expandField: l } = t.gridProps;
665
+ c.current.containerHeight = 1533915;
666
+ if (c.current.containerRef = j, c.current.tableBodyRef = H, c.current.table = x.current, c.current instanceof Ue) {
667
+ const { rowHeight: a = 0, detail: d, expandField: l } = t.gridProps;
593
668
  let { detailRowHeight: f = 0 } = t.gridProps;
594
- f = c && l ? f : a, It() ? (d.current.total = t.dataRef.length, d.current.rowHeightService = new De(
669
+ f = d && l ? f : a, xt() ? (c.current.total = t.dataRef.length, c.current.rowHeightService = new Le(
595
670
  t.dataRef.length,
596
671
  a,
597
672
  f,
598
673
  t.dataRef
599
- )) : d.current.rowHeightService = new De(e, a, f);
600
- const I = d.current.rowHeightService.totalHeight();
601
- d.current.containerHeight = Ae ? Math.min(He, I) : I;
674
+ )) : c.current.rowHeightService = new Le(e, a, f);
675
+ const m = c.current.rowHeightService.totalHeight();
676
+ c.current.containerHeight = Oe ? Math.min(Be, m) : m;
602
677
  }
603
678
  }
604
- }, Ce = i.useCallback(
679
+ }, Dt = () => {
680
+ const e = (n) => n.map((o) => ({
681
+ id: o.id,
682
+ field: o.field,
683
+ title: o.title,
684
+ hidden: !1,
685
+ children: o.children ? e(o.children) : null
686
+ })), r = t.columnsRef.current.filter((n) => n.depth === 0);
687
+ return e(r);
688
+ }, we = i.useCallback(
605
689
  (e) => {
606
- const r = { rowIndex: se.current };
690
+ const r = { rowIndex: ue.current };
607
691
  e.forEach((n) => {
608
- n.isIntersecting || ee(r);
692
+ n.isIntersecting || te(r);
609
693
  });
610
694
  },
611
- [ee]
612
- ), te = () => {
695
+ [te]
696
+ ), re = () => {
613
697
  t.gridProps.forceUpdate && t.gridProps.forceUpdate();
614
- }, Et = (e) => e.left !== void 0 ? ve !== "rtl" ? { left: e.left, right: e.right } : { left: e.right, right: e.left } : {}, R = i.useRef(null), u = t.columnsRef, d = i.useRef(), v = i.useRef(), S = i.useRef(), w = i.useRef(), k = i.useRef(), U = i.useRef(), D = i.useRef(null), T = i.useRef(null), Ct = i.useRef(null), V = i.useRef(null), x = i.useRef(null), re = i.useRef(null), K = i.useRef(null), A = i.useRef(null), H = i.useRef(null), ne = i.useRef(), oe = i.useRef(!1), ae = i.useRef(!1), W = i.useRef(), ie = i.useRef(), de = i.useRef(!1), _ = i.useRef(!0), ce = i.useRef(0), le = i.useRef(), se = i.useRef(), ue = i.useRef([]), j = i.useRef(null), vt = i.useRef(null), wt = i.useRef(null), ve = yt(K), xt = i.useMemo(() => i.Children.toArray(t.gridProps.children), [t.gridProps.children]), b = $((ye = t.gridProps.selectable) != null ? ye : !!t.gridProps.selectedField), we = Dt((Se = t.gridProps.editable) != null ? Se : !!t.gridProps.editField);
698
+ }, kt = (e) => e.left !== void 0 ? xe !== "rtl" ? { left: e.left, right: e.right } : { left: e.right, right: e.left } : {}, R = i.useRef(null), g = t.columnsRef, c = i.useRef(), w = i.useRef(), S = i.useRef(), y = i.useRef(), D = i.useRef(), _ = i.useRef(), k = i.useRef(null), H = i.useRef(null), Kt = i.useRef(null), j = i.useRef(null), x = i.useRef(null), ne = i.useRef(null), K = i.useRef(null), F = i.useRef(null), L = i.useRef(null), oe = i.useRef(), ae = i.useRef(!1), ie = i.useRef(!1), q = i.useRef(), de = i.useRef(), ce = i.useRef(!1), X = i.useRef(!0), le = i.useRef(0), se = i.useRef(), ue = i.useRef(), ge = i.useRef([]), ye = i.useRef([]), G = i.useRef(null), Tt = i.useRef(null), Mt = i.useRef(null), xe = Nt(K), At = i.useMemo(() => i.Children.toArray(t.gridProps.children), [t.gridProps.children]), I = Y((ke = t.gridProps.selectable) != null ? ke : !!t.gridProps.selectedField), Se = Ut((Ke = t.gridProps.editable) != null ? Ke : !!t.gridProps.editField);
615
699
  i.useMemo(() => {
616
- M.onConstructor({
700
+ T.onConstructor({
617
701
  navigatable: !!t.gridProps.navigatable,
618
- contextStateRef: w,
619
- navigationStateRef: k,
702
+ contextStateRef: y,
703
+ navigationStateRef: D,
620
704
  idPrefix: t.id
621
705
  });
622
706
  }, []), i.useMemo(() => {
623
707
  var n;
624
- (n = d.current) == null || n.reset();
625
- const e = t.gridProps.groupable === !0 || typeof t.gridProps.groupable == "object" && t.gridProps.groupable.enabled !== !1, r = t.isFixedVirtualScroll ? Fe : $t;
626
- d.current = new r(e || t.gridProps.rowHeight === void 0 || t.gridProps.rowHeight === 0);
708
+ (n = c.current) == null || n.reset();
709
+ const e = t.gridProps.groupable === !0 || typeof t.gridProps.groupable == "object" && t.gridProps.groupable.enabled !== !1, r = t.isFixedVirtualScroll ? Ue : lr;
710
+ c.current = new r(e || t.gridProps.rowHeight === void 0 || t.gridProps.rowHeight === 0);
627
711
  }, [
628
712
  t.gridProps.scrollable,
629
713
  t.gridProps.total,
@@ -632,140 +716,145 @@ const Zt = i.createContext(void 0), sr = (t) => {
632
716
  t.gridProps.groupable,
633
717
  t.gridProps.sort,
634
718
  t.gridProps.rowHeight
635
- ]), i.useEffect(() => (t.gridProps.clipboard && (U.current = new Kt(st), U.current.addEventListeners(C())), () => {
636
- U.current && U.current.removeEventListeners(C());
637
- }), [t.gridProps.onClipboard, t.gridProps.clipboard]), i.useEffect(() => (t.gridProps.columnVirtualization && !window.navigator.userAgent.match(_t) && (re.current && (re.current.style.display = "block"), x.current && (x.current.style.display = "block")), Q(), ke(p()), M.onComponentDidMount({
719
+ ]), i.useEffect(() => (t.gridProps.clipboard && (_.current = new Vt(B), _.current.addEventListeners(v())), () => {
720
+ _.current && _.current.removeEventListeners(v());
721
+ }), [t.gridProps.onClipboard, t.gridProps.clipboard, B, v]), i.useEffect(() => (t.gridProps.columnVirtualization && !window.navigator.userAgent.match(nr) && (ne.current && (ne.current.style.display = "block"), x.current && (x.current.style.display = "block")), p(), Fe(ee()), T.onComponentDidMount({
638
722
  scope: K.current || void 0,
639
- contextStateRef: w,
640
- navigationStateRef: k
723
+ contextStateRef: y,
724
+ navigationStateRef: D
641
725
  }), () => {
642
- clearTimeout(le.current);
726
+ clearTimeout(se.current);
643
727
  }), []), i.useEffect(() => {
644
728
  var e;
645
- Q(), ke(p()), (e = d.current) != null && e.tableTransform && d.current.table && (d.current.table.style.transform = d.current.tableTransform, d.current.tableTransform = ""), Pt(), M.onComponentDidUpdate({
729
+ p(), Fe(ee()), (e = c.current) != null && e.tableTransform && c.current.table && (c.current.table.style.transform = c.current.tableTransform, c.current.tableTransform = ""), Et(), T.onComponentDidUpdate({
646
730
  scope: K.current || void 0,
647
- contextStateRef: w,
648
- navigationStateRef: k,
649
- focusFirst: ae.current,
650
- newEditableRow: W.current,
651
- singleEditRow: de.current,
652
- lastActiveElement: ie.current,
731
+ contextStateRef: y,
732
+ navigationStateRef: D,
733
+ focusFirst: ie.current,
734
+ newEditableRow: q.current,
735
+ singleEditRow: ce.current,
736
+ lastActiveElement: de.current,
653
737
  navigatable: t.gridProps.navigatable
654
- }), ae.current = !1, W.current = void 0;
738
+ }), ie.current = !1, q.current = void 0;
655
739
  }), i.useEffect(() => {
656
- if (q) {
740
+ if ($) {
657
741
  const e = {
658
742
  rootMargin: "0px",
659
743
  threshold: 0.9
660
744
  };
661
- D.current = window.IntersectionObserver && new window.IntersectionObserver(Ce, e) || null;
745
+ k.current = window.IntersectionObserver && new window.IntersectionObserver(we, e) || null;
662
746
  }
663
- }, [Ce]), i.useEffect(() => {
747
+ }, [we]), i.useEffect(() => {
664
748
  var r;
665
749
  let e;
666
- return q && window.ResizeObserver && (e = new window.ResizeObserver(bt), e.observe((r = C()) == null ? void 0 : r.body)), () => {
750
+ return $ && window.ResizeObserver && (e = new window.ResizeObserver(yt), e.observe((r = v()) == null ? void 0 : r.body)), () => {
667
751
  e == null || e.disconnect();
668
752
  };
669
753
  }, []), i.useImperativeHandle(
670
754
  R,
671
755
  () => ({
672
756
  get element() {
673
- return B();
757
+ return W();
674
758
  },
675
759
  props: t.gridProps,
676
760
  get columns() {
677
- return G();
761
+ return z();
678
762
  },
679
763
  scrollIntoView: (e) => {
680
764
  var o;
681
- if (!((o = d.current) != null && o.container) || t.gridProps.scrollable === "none")
765
+ if (!((o = c.current) != null && o.container) || t.gridProps.scrollable === "none")
682
766
  return;
683
767
  const { rowIndex: r } = e;
684
- se.current = r;
685
- const n = B();
686
- if (D.current && n) {
687
- D.current.disconnect();
688
- const a = n.querySelector(`[absolute-row-index="${se.current}"]`);
689
- a ? D.current.observe(a) : ee(e);
768
+ ue.current = r;
769
+ const n = W();
770
+ if (k.current && n) {
771
+ k.current.disconnect();
772
+ const a = n.querySelector(`[absolute-row-index="${ue.current}"]`);
773
+ a ? k.current.observe(a) : te(e);
690
774
  }
691
775
  },
692
776
  fitColumns: (e) => {
693
- v.current.dblClickHandler(null, e);
777
+ w.current.dblClickHandler(null, e);
694
778
  }
695
779
  })
696
780
  ), i.useImperativeHandle(t.gridRef, () => R.current), i.useMemo(() => {
697
- v.current = new Vt(gt);
781
+ w.current = new tr(Rt);
698
782
  }, [t.gridProps.onColumnResize]), i.useMemo(() => {
699
- S.current = new Wt(Y, ct, Re);
783
+ S.current = new rr(Z, ht, ve);
700
784
  }, [
701
785
  t.gridProps.onColumnReorder,
702
786
  t.gridProps.onGroupChange,
703
787
  t.gridProps.group,
704
788
  t.gridProps.groupable
705
- ]), v.current.resizable = t.gridProps.resizable || !1, v.current.columns = u.current;
706
- const xe = t.gridProps.groupable === !0 || typeof t.gridProps.groupable == "object" && t.gridProps.groupable.enabled !== !1;
707
- return S.current.reorderable = t.gridProps.reorderable || !1, S.current.groupable = xe, S.current.columns = u.current, Rt(t.total, xe), /* @__PURE__ */ i.createElement(
708
- Zt.Provider,
789
+ ]), w.current.resizable = t.gridProps.resizable || !1, w.current.columns = g.current;
790
+ const De = t.gridProps.groupable === !0 || typeof t.gridProps.groupable == "object" && t.gridProps.groupable.enabled !== !1;
791
+ S.current.reorderable = t.gridProps.reorderable || !1, S.current.groupable = De, S.current.columns = g.current, St(t.total, De);
792
+ const Ht = t.gridProps.columnsState || Dt();
793
+ return /* @__PURE__ */ i.createElement(
794
+ fr.Provider,
709
795
  {
710
796
  value: {
711
797
  isClient: E,
712
- rowReorder: dt,
713
- activeDragRowDataItemRef: j,
714
- reorderRowDragTargetRef: vt,
715
- reorderRowDropTargetRef: wt,
716
- dir: ve,
717
- getCellPositionStyle: Et,
798
+ rowReorder: A,
799
+ activeDragRowDataItemRef: G,
800
+ reorderRowDragTargetRef: Tt,
801
+ reorderRowDropTargetRef: Mt,
802
+ dir: xe,
803
+ getCellPositionStyle: kt,
718
804
  dataItemKey: t.gridProps.dataItemKey,
719
- groupChange: J,
720
- selectionRelease: Ze,
721
- pagerPageChange: at,
722
- onContextMenu: Oe,
723
- rowClick: _e,
724
- rowDblClick: je,
725
- cellClick: qe,
726
- headerCellClick: be,
727
- itemChange: Je,
728
- sortChange: Ie,
729
- filterChange: it,
730
- onHeaderSelectionChange: Qe,
731
- columnGroupChange: lt,
732
- onKeyDown: Ue,
733
- onFocus: Ve,
734
- scrollHandler: Be,
735
- selectionChange: Ye,
736
- dispatchDetailExpand: Xe,
737
- dispatchGroupExpand: $e,
738
- columnResizeRef: v,
805
+ columnsState: Ht,
806
+ onColumnsStateChange: Pt,
807
+ groupChange: Q,
808
+ selectionRelease: at,
809
+ pagerPageChange: gt,
810
+ onContextMenu: qe,
811
+ rowClick: Qe,
812
+ rowDblClick: Ze,
813
+ cellClick: pe,
814
+ headerCellClick: Re,
815
+ itemChange: rt,
816
+ sortChange: Ce,
817
+ filterChange: ft,
818
+ searchChange: mt,
819
+ onHeaderSelectionChange: ot,
820
+ columnGroupChange: bt,
821
+ onKeyDown: $e,
822
+ onFocus: Je,
823
+ scrollHandler: Xe,
824
+ selectionChange: nt,
825
+ dispatchDetailExpand: et,
826
+ dispatchGroupExpand: tt,
827
+ columnResizeRef: w,
739
828
  dragLogicRef: S,
740
- navigationStateRef: k,
829
+ navigationStateRef: D,
741
830
  tableElementRef: x,
742
- tableBodyElementRef: T,
743
- headerElementRef: Ct,
744
- containerElementRef: V,
745
- headTableElementRef: re,
831
+ tableBodyElementRef: H,
832
+ headerElementRef: Kt,
833
+ containerElementRef: j,
834
+ headTableElementRef: ne,
746
835
  elementRef: K,
747
- footerRef: A,
748
- headerRef: H,
749
- getCachedScrollbarWidth: p,
750
- vsRef: d
836
+ footerRef: F,
837
+ headerRef: L,
838
+ getCachedScrollbarWidth: ee,
839
+ vsRef: c
751
840
  }
752
841
  },
753
- /* @__PURE__ */ i.createElement(Mt.Provider, { value: w.current }, t.children),
842
+ /* @__PURE__ */ i.createElement(Wt.Provider, { value: y.current }, t.children),
754
843
  /* @__PURE__ */ i.createElement(
755
- Jt,
844
+ sr,
756
845
  {
757
- show: h.show,
758
- dataItem: h.dataItem,
759
- field: h.field,
760
- items: Le,
761
- offset: h.offset,
762
- onClose: me,
763
- onSelect: Ne
846
+ show: b.show,
847
+ dataItem: b.dataItem,
848
+ field: b.field,
849
+ items: _e,
850
+ offset: b.offset,
851
+ onClose: he,
852
+ onSelect: je
764
853
  }
765
854
  )
766
855
  );
767
856
  };
768
857
  export {
769
- sr as GridClientWrapper,
770
- Zt as GridContext
858
+ Sr as GridClientWrapper,
859
+ fr as GridContext
771
860
  };