@progress/kendo-react-grid 10.0.0-develop.2 → 10.0.0-develop.4

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