@progress/kendo-react-grid 10.0.0-develop.3 → 10.0.0-develop.5

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 Lt, useDir as Gt, setScrollbarWidth as Ae, getter as J, RowHeightService as He } from "@progress/kendo-react-common";
11
- import { getSelectionOptions as Y, populateClipboardData as zt, ClipboardActionType as ge, getEditableOptions as Nt, tableKeyboardNavigation as T, ClipboardService as Ot, TableKeyboardNavigationContext as Bt, editReducer as Ut, EDIT_ACTION as Vt, getDetailExpandableOptions as _t, detailExpandReducer as Fe, getGroupExpandableOptions as Wt, groupExpandReducer as jt, DETAIL_EXPAND_ACTION as qt, getSelectedState as Le, getSelectedStateFromKeyDown as Xt, closestTagName as Ge, getColumnIndex as $t, getRowIndex as Jt, updateLeft as Yt, updateRight as Qt } from "@progress/kendo-react-data-tools";
12
- import { ColumnResize as Zt } from "./drag/ColumnResize.mjs";
13
- import { CommonDragLogic as pt } from "./drag/CommonDragLogic.mjs";
14
- import { SAFARI_REGEX as er } from "./constants/index.mjs";
15
- import { getDefaultHeadContextMenuItems as tr, getDefaultBodyContextMenuItems as rr, isRowReorderEnabled as nr, sanitizeColumns as or, getDataAsArray as ar, 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 ir } from "./VirtualScroll.mjs";
18
- import { GridContextMenu as dr } 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 cr, firstLevelSortSeqMap as lr } from "./sortCommon.mjs";
21
- const sr = i.createContext(void 0), wr = (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 sr = i.createContext(void 0), wr = (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 tr({
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 rr({
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: nr(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 sr = i.createContext(void 0), wr = (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"), At = ((m = r.name) == null ? void 0 : m.toLowerCase().includes("desc")) ? "desc" : void 0, Ht = ue ? "asc" : At, Ft = r.name ? Ht : void 0;
88
- be(e.event.syntheticEvent, P, Ft);
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 or(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,80 +181,80 @@ const sr = i.createContext(void 0), wr = (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 = Ut(t.gridProps.edit, {
211
- type: Vt.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 (_t(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 = Wt(
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 = jt((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 } = cr(
240
+ }, ve = (e, n, r) => {
241
+ const { allowUnsort: a, mode: o } = cn(
242
242
  t.gridProps.sortable || !1,
243
- r.sortable || !1
244
- ), d = (t.gridProps.sort || []).filter((m) => m.field === r.field)[0], l = n || lr[o][d && d.dir || ""], s = a === "single" ? [] : (t.gridProps.sort || []).filter((m) => m.field !== r.field);
245
- l !== "" && r.field && s.push({ field: r.field, dir: l }), Ie(s, e);
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);
246
246
  }, et = (e) => {
247
- var r;
247
+ var n;
248
248
  if (e.field === t.gridProps.expandField || e._expand || t.gridProps.group && e.field === void 0) {
249
249
  if (t.gridProps.onExpandChange) {
250
- const n = t.gridProps.dataItemKey ? Fe((r = t.gridProps.detailExpand) != null ? r : {}, {
251
- type: qt.SET,
250
+ const r = t.gridProps.dataItemKey ? Fe((n = t.gridProps.detailExpand) != null ? n : {}, {
251
+ type: Wt.SET,
252
252
  id: e.dataItem[t.gridProps.dataItemKey],
253
253
  payload: e.value
254
254
  }) : t.gridProps.detailExpand;
255
- u(t.gridProps.onExpandChange, {
256
- ...h(e.syntheticEvent),
257
- expand: n,
255
+ s(t.gridProps.onExpandChange, {
256
+ ...P(e.syntheticEvent),
257
+ expand: r,
258
258
  dataItem: e.dataItem,
259
259
  dataIndex: e.dataIndex,
260
260
  value: e.value
@@ -262,73 +262,73 @@ const sr = i.createContext(void 0), wr = (t) => {
262
262
  }
263
263
  return;
264
264
  }
265
- t.gridProps.onItemChange && u(t.gridProps.onItemChange, {
266
- ...h(e.syntheticEvent),
265
+ t.gridProps.onItemChange && s(t.gridProps.onItemChange, {
266
+ ...P(e.syntheticEvent),
267
267
  dataItem: e.dataItem,
268
268
  dataIndex: e.dataIndex,
269
269
  field: e.field,
270
270
  value: e.value
271
271
  });
272
272
  }, tt = (e) => {
273
- var r;
274
- if (t.gridProps.onSelectionChange && b.enabled) {
275
- const { event: n, dataItem: o, dataIndex: a, columnIndex: d } = e, l = {
276
- ...h(n.syntheticEvent),
277
- 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,
278
278
  startColIndex: d,
279
279
  endColIndex: d,
280
- startRowIndex: a,
281
- endRowIndex: a,
280
+ startRowIndex: o,
281
+ endRowIndex: o,
282
282
  dataItems: H(),
283
283
  altKey: !1,
284
284
  ctrlKey: !1,
285
285
  shiftKey: !1,
286
286
  metaKey: !1,
287
- mode: b.mode,
288
- cell: b.cell,
287
+ mode: h.mode,
288
+ cell: h.cell,
289
289
  isDrag: !1,
290
290
  componentId: t.id,
291
291
  selectedField: t.gridProps.selectedField || ""
292
292
  };
293
- u(t.gridProps.onSelectionChange, {
293
+ s(t.gridProps.onSelectionChange, {
294
294
  ...l,
295
295
  select: t.gridProps.dataItemKey ? Le({
296
296
  event: l,
297
- selectedState: (r = t.gridProps.select) != null ? r : {},
297
+ selectedState: (n = t.gridProps.select) != null ? n : {},
298
298
  dataItemKey: t.gridProps.dataItemKey
299
299
  }) : {}
300
300
  });
301
301
  }
302
- }, rt = (e) => {
303
- var m, f;
304
- 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)
305
305
  return;
306
- const r = {
306
+ const n = {
307
307
  dataItems: H(),
308
- mode: b.mode,
309
- cell: b.cell,
308
+ mode: h.mode,
309
+ cell: h.cell,
310
310
  componentId: t.id,
311
311
  selectedField: t.gridProps.selectedField,
312
- ...h(e)
313
- }, n = Xt({
314
- event: r,
315
- selectedState: (m = t.gridProps.select) != null ? m : {},
312
+ ...P(e)
313
+ }, r = jt({
314
+ event: n,
315
+ selectedState: (g = t.gridProps.select) != null ? g : {},
316
316
  dataItemKey: t.gridProps.dataItemKey
317
317
  });
318
- if (n === t.gridProps.select)
318
+ if (r === t.gridProps.select)
319
319
  return;
320
- const o = e.target, a = Ge(o, "TD"), d = Ge(o, "TR"), l = $t(a), s = Jt(d);
321
- if (l !== void 0 && s !== void 0) {
322
- const R = (f = ar(t.gridProps.data)) == null ? void 0 : f[s];
323
- t.gridProps.onSelectionChange && u(t.gridProps.onSelectionChange, {
324
- ...r,
325
- select: n,
326
- dataItem: R,
327
- 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,
328
328
  startColIndex: l,
329
- startDataItem: R,
330
- endDataItem: R,
331
- endRowIndex: s,
329
+ startDataItem: C,
330
+ endDataItem: C,
331
+ endRowIndex: u,
332
332
  endColIndex: l,
333
333
  ctrlKey: e.ctrlKey,
334
334
  altKey: e.altKey,
@@ -337,248 +337,253 @@ const sr = i.createContext(void 0), wr = (t) => {
337
337
  isDrag: !1
338
338
  });
339
339
  }
340
- }, nt = (e) => {
341
- var r;
342
- if (t.gridProps.onHeaderSelectionChange && b.enabled) {
343
- const n = H();
344
- u(t.gridProps.onHeaderSelectionChange, {
345
- 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), {}) : {},
346
346
  field: e.field,
347
347
  nativeEvent: e.syntheticEvent && e.syntheticEvent.nativeEvent,
348
348
  syntheticEvent: e.syntheticEvent,
349
- target: C.current,
350
- dataItems: n,
351
- selectedField: (r = t.gridProps.selectedField) != null ? r : ""
349
+ target: R.current,
350
+ dataItems: r,
351
+ selectedField: (n = t.gridProps.selectedField) != null ? n : ""
352
352
  });
353
353
  }
354
- }, O = (e, r) => {
355
- t.gridProps.onSelectionChange && b.enabled && u(t.gridProps.onSelectionChange, {
354
+ }, V = (e, n) => {
355
+ t.gridProps.onSelectionChange && h.enabled && s(t.gridProps.onSelectionChange, {
356
356
  ...e,
357
- select: r
357
+ select: n
358
358
  });
359
- }, ot = (e) => {
360
- var r;
361
- if (t.gridProps.onSelectionChange && b.enabled) {
362
- 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 = {
363
363
  syntheticEvent: void 0,
364
- target: C.current,
364
+ target: R.current,
365
365
  selectedField: t.gridProps.selectedField || "",
366
366
  componentId: t.id,
367
367
  dataItems: H(),
368
368
  dataItem: null,
369
- startDataItem: n,
370
- endDataItem: o,
369
+ startDataItem: r,
370
+ endDataItem: a,
371
371
  ...e
372
372
  }, d = Le({
373
- event: a,
374
- selectedState: (r = t.gridProps.select) != null ? r : {},
373
+ event: o,
374
+ selectedState: (n = t.gridProps.select) != null ? n : {},
375
375
  // Thats kinda strange, even through the `dataItemKey` is required by the `getSelectedState`
376
376
  // it does work correctly even without it
377
377
  dataItemKey: t.gridProps.dataItemKey
378
378
  });
379
- O(a, d);
379
+ V(o, d);
380
380
  }
381
- }, at = (e) => {
382
- if (t.gridProps.onSelectionChange && b.enabled) {
383
- 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 = {
384
384
  ...e,
385
- startDataItem: r,
386
- endDataItem: n,
385
+ startDataItem: n,
386
+ endDataItem: r,
387
387
  startRowIndex: 0,
388
388
  endRowIndex: e.dataItems.length - 1,
389
389
  startColIndex: 0,
390
- endColIndex: g.current.length - 1
390
+ endColIndex: t.columnsRef.length - 1
391
391
  };
392
392
  e.dataItems.forEach((d) => {
393
- const s = J(t.gridProps.dataItemKey)(d);
394
- o[s] = e.cell ? [...Array(g.current.length).keys()] : !0;
395
- }), 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);
396
396
  }
397
397
  }, it = (e) => {
398
- if (t.gridProps.onSelectionChange && b.enabled) {
399
- const n = J(t.gridProps.dataItemKey)(e.dataItem), o = 0, a = g.current.length - 1, d = e.dataItems.findIndex(
400
- (R) => R[t.gridProps.dataItemKey] === e.dataItem[t.gridProps.dataItemKey]
401
- ), 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 = {
402
402
  ...e,
403
403
  startDataItem: d,
404
404
  endDataItem: d,
405
405
  startRowIndex: d,
406
406
  endRowIndex: d,
407
- startColIndex: o,
408
- endColIndex: a
407
+ startColIndex: a,
408
+ endColIndex: o
409
409
  }, f = e.mode === "multiple" ? t.gridProps.select || {} : {};
410
- 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);
411
411
  }
412
412
  }, dt = (e) => {
413
- t.gridProps.onSelectionChange && b.enabled && O(e, {});
414
- }, M = (e, r, n, o, a) => {
413
+ t.gridProps.onSelectionChange && h.enabled && V(e, {});
414
+ }, M = (e, n, r, a, o) => {
415
415
  const d = t.gridProps.onDataStateChange;
416
416
  if (e) {
417
- const l = { ...h(o), ...r, targetEvent: a };
418
- u(e, l);
417
+ const l = { ...P(a), ...n, targetEvent: o };
418
+ s(e, l);
419
419
  } else
420
- d && u(d, {
421
- ...h(o),
422
- targetEvent: a || {},
420
+ d && s(d, {
421
+ ...P(a),
422
+ targetEvent: o || {},
423
423
  dataState: {
424
- ...Ct(),
425
- ...n
424
+ ...It(),
425
+ ...r
426
426
  }
427
427
  });
428
- }, B = (e, r, n) => {
428
+ }, _ = (e, n, r) => {
429
429
  M(
430
430
  t.gridProps.onPageChange,
431
431
  { page: e },
432
432
  { skip: e.skip, take: e.take },
433
- r,
434
- n
433
+ n,
434
+ r
435
435
  );
436
436
  }, ct = () => {
437
437
  let e = t.gridProps.total || 0;
438
438
  return Array.isArray(t.gridProps.data) ? e = e || t.gridProps.data.length : t.gridProps.data && (e = e || t.gridProps.data.total), e;
439
439
  }, lt = (e) => {
440
- var a, d;
441
- const r = (d = (a = t.gridProps.take) != null ? a : t.gridProps.pageSize) != null ? d : 0, n = (t.gridProps.skip || 0) + r, o = ct();
442
- 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);
443
443
  }, st = (e) => {
444
- var o, a;
445
- const r = (a = (o = t.gridProps.take) != null ? o : t.gridProps.pageSize) != null ? a : 0, n = (t.gridProps.skip || 0) - r;
446
- 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);
447
447
  }, ut = (e) => {
448
- B({ skip: e.skip, take: e.take }, e.syntheticEvent, e.targetEvent);
449
- }, Ie = (e, r) => {
448
+ _({ skip: e.skip, take: e.take }, e.syntheticEvent, e.targetEvent);
449
+ }, Ee = (e, n) => {
450
450
  M(
451
451
  t.gridProps.onSortChange,
452
452
  { sort: e },
453
453
  { sort: e, ...t.gridProps.scrollable === "virtual" ? { skip: 0 } : {} },
454
- r
454
+ n
455
455
  );
456
- }, gt = (e, r) => {
456
+ }, gt = (e, n) => {
457
457
  M(
458
458
  t.gridProps.onFilterChange,
459
459
  { filter: e },
460
460
  { filter: e || void 0, skip: 0 },
461
- r
461
+ n
462
462
  );
463
463
  }, ft = (e) => {
464
- 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 = {
465
465
  logic: "or",
466
- filters: r.filter((a) => a !== void 0).map((a) => {
466
+ filters: n.filter((o) => o !== void 0).map((o) => {
467
467
  var d;
468
- return typeof a == "string" ? { field: a, value: n, operator: "contains" } : {
469
- value: n,
470
- operator: (d = a.operator) != null ? d : "contains",
471
- field: a.field,
472
- 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
473
473
  };
474
474
  })
475
475
  };
476
476
  M(
477
477
  t.gridProps.onSearchChange,
478
478
  {
479
- search: o
479
+ search: a
480
480
  },
481
481
  {},
482
482
  e.syntheticEvent
483
483
  );
484
- }, Q = (e, r) => {
485
- const n = r.nativeEvent ? r : { nativeEvent: r.nativeEvent || r.originalEvent };
486
- 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(
487
487
  t.gridProps.onGroupChange,
488
488
  { group: e },
489
489
  { group: e, skip: 0 },
490
- n
490
+ r
491
491
  );
492
- }, mt = (e) => {
492
+ }, ne = (e) => {
493
493
  if (t.gridProps.onColumnsStateChange) {
494
- const r = {
495
- target: C.current,
494
+ const n = {
495
+ target: R.current,
496
496
  columnsState: e
497
497
  };
498
- u(t.gridProps.onColumnsStateChange, r);
498
+ s(t.gridProps.onColumnsStateChange, n);
499
499
  }
500
- }, Z = (e, r, n) => {
501
- 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) => {
502
502
  do
503
- f++;
504
- while (f < g.current.length && g.current[f].depth > a);
505
- return f;
506
- }, l = g.current.splice(e, d(e) - e);
507
- 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);
508
- const s = g.current[e].locked && g.current[r].locked;
509
- Yt(t.columnsMapRef, g.current, s || X.current), Qt(t.columnsMapRef, g.current, s || X.current), ne.current && (X.current = !1, ne.current = !1);
510
- const m = N();
511
- if (te(), t.gridProps.onColumnReorder) {
512
- const f = {
513
- target: C.current,
514
- columns: m,
515
- columnId: o.id,
516
- 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
517
521
  };
518
- u(t.gridProps.onColumnReorder, f);
522
+ s(t.gridProps.onColumnReorder, b);
519
523
  }
520
- }, A = (e, r, n) => {
521
- const o = typeof t.gridProps.rowReorderable == "object" ? t.gridProps.rowReorderable.enabled : t.gridProps.rowReorderable;
522
- 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)
523
528
  return;
524
- const { slicedData: a, dataRef: d } = t, l = (a || d)[r];
525
- 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, {
526
531
  draggedDataItems: [z.current],
527
532
  droppedDataItem: l == null ? void 0 : l.dataItem,
528
- dropPosition: n,
533
+ dropPosition: r,
529
534
  nativeEvent: e.originalEvent,
530
535
  dragEvent: e,
531
- target: C.current
536
+ target: R.current
532
537
  }), z.current = null;
533
- }, Pt = (e, r, n) => {
538
+ }, mt = (e, n, r) => {
534
539
  if (t.gridProps.group === void 0)
535
540
  return;
536
- const o = t.gridProps.group.slice();
537
- o.splice(r, 0, ...o.splice(e, 1)), Q(o, n);
538
- }, Ce = (e, r, n) => {
539
- const o = g.current[e].field;
540
- 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)
541
546
  return;
542
- const a = (t.gridProps.group || []).slice();
543
- a.splice(r, 0, { field: o }), Q(a, n);
544
- }, ht = (e, r) => {
545
- const n = S.current.getCurrentGroupsLength;
546
- Ce(e, n, r);
547
- }, 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 = () => {
548
553
  let e = 0;
549
- if (!w.current.colGroupMain)
554
+ if (!E.current.colGroupMain)
550
555
  return;
551
- const r = w.current.colGroupMain.children;
552
- for (let n = 0; n < r.length; n++) {
553
- const o = r[n].width;
554
- 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)
555
560
  return;
556
- e += parseFloat(o.toString());
561
+ e += parseFloat(a.toString());
557
562
  }
558
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");
559
- }, U = i.useCallback(
560
- (e, r, n, o, a) => {
561
- var m;
562
- if (!bt() && !n || !e)
564
+ }, W = i.useCallback(
565
+ (e, n, r, a, o) => {
566
+ var g;
567
+ if (!ht() && !r || !e)
563
568
  return;
564
569
  const d = {
565
570
  type: e,
566
- nativeEvent: r,
567
- columns: g.current,
571
+ nativeEvent: n,
572
+ columns: t.columnsRef,
568
573
  dataItemKey: t.gridProps.dataItemKey || "",
569
- dataItem: o,
570
- field: a,
574
+ dataItem: a,
575
+ field: o,
571
576
  ...typeof t.gridProps.clipboard != "boolean" ? t.gridProps.clipboard : {},
572
- ...n
573
- }, l = V(), s = zt({
577
+ ...r
578
+ }, l = j(), u = Lt({
574
579
  event: d,
575
580
  data: l,
576
- selectedState: (m = t.gridProps.select) != null ? m : {},
577
- previousCopiedItems: Ee.current
581
+ selectedState: (g = t.gridProps.select) != null ? g : {},
582
+ previousCopiedItems: Se.current
578
583
  });
579
- 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, {
580
585
  ...d,
581
- ...s
586
+ ...u
582
587
  });
583
588
  },
584
589
  [
@@ -588,24 +593,24 @@ const sr = i.createContext(void 0), wr = (t) => {
588
593
  t.gridProps.clipboard,
589
594
  t.gridProps.onClipboard
590
595
  ]
591
- ), bt = () => {
592
- var a, d, l;
593
- if (!$)
596
+ ), ht = () => {
597
+ var o, d, l;
598
+ if (!Z)
594
599
  return !1;
595
- const e = Lt(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));
596
- return !!(r && o && n);
597
- }, It = (e, r, n, o, a, d) => {
598
- p(), X.current = !0, ne.current = !0, t.gridProps.onColumnResize && E && u(t.gridProps.onColumnResize, {
599
- columns: N(),
600
- nativeEvent: o,
601
- 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,
602
607
  index: e,
603
- newWidth: r,
604
- oldWidth: n,
605
- end: a,
606
- target: C.current
607
- });
608
- }, Ct = () => {
608
+ newWidth: n,
609
+ oldWidth: r,
610
+ end: o,
611
+ target: R.current
612
+ }), o && ne(d);
613
+ }, It = () => {
609
614
  var e;
610
615
  return {
611
616
  filter: t.gridProps.filter,
@@ -614,10 +619,10 @@ const sr = i.createContext(void 0), wr = (t) => {
614
619
  take: (e = t.gridProps.take) != null ? e : t.gridProps.pageSize,
615
620
  group: t.gridProps.group
616
621
  };
617
- }, h = (e) => ({
622
+ }, P = (e) => ({
618
623
  nativeEvent: e && e.nativeEvent,
619
624
  syntheticEvent: e,
620
- target: C.current
625
+ target: R.current
621
626
  }), Rt = (e) => ({
622
627
  ...e,
623
628
  nativeEvent: void 0,
@@ -625,86 +630,77 @@ const sr = i.createContext(void 0), wr = (t) => {
625
630
  target: void 0,
626
631
  targetEvent: void 0,
627
632
  focusElement: void 0
628
- }), u = (e, r) => {
633
+ }), s = (e, n) => {
629
634
  if (t.gridProps.isClient) {
630
- e(r);
635
+ e(n);
631
636
  return;
632
637
  }
633
- e(Rt(r));
634
- }, vt = () => {
635
- var e, r, n;
638
+ e(Rt(n));
639
+ }, Ct = () => {
640
+ var e, n, r;
636
641
  if (F.current && ((e = F.current) == null ? void 0 : e.getElementsByClassName("k-grid-edit-row").length) > 0) {
637
- ie.current = !1, (r = document.activeElement) != null && r.closest(".k-grid-edit-row") ? ae.current = document.activeElement : ae.current = void 0;
638
- const o = Array.from((n = F.current) == null ? void 0 : n.getElementsByClassName("k-grid-edit-row"));
639
- o.length > se.current.length ? q.current = o.filter(
640
- (a) => !se.current.includes(a)
641
- )[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;
642
647
  }
643
- }, 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 = () => {
644
649
  var e;
645
- if ($)
646
- return ((e = _()) == null ? void 0 : e.ownerDocument) || document;
647
- }, _ = () => 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(
648
653
  (e) => {
649
- var o;
650
- 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")
651
656
  return;
652
657
  k.current && k.current.disconnect();
653
- const { rowIndex: r } = e, n = _();
658
+ const { rowIndex: n } = e, r = q();
654
659
  if (t.gridProps.scrollable === "virtual")
655
- c.current.askedSkip = r, c.current.container.scroll(
660
+ c.current.askedSkip = n, c.current.container.scroll(
656
661
  0,
657
662
  Math.round(c.current.askedSkip / c.current.total * c.current.container.scrollHeight)
658
663
  );
659
- else if (n) {
660
- const a = r < 1 ? n.querySelector("tbody > tr:nth-child(1)") : n.querySelector(`tbody > tr:nth-child(${r + 1})`);
661
- 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);
662
667
  }
663
668
  },
664
669
  [t.gridProps.scrollable]
665
- ), Re = (e) => JSON.stringify(e.map((r) => ({ id: r.id, field: r.field, title: r.title, children: r.children }))), Et = () => Re(Tt) === Re(g.current), wt = () => {
666
- Et() || te();
667
- }, yt = (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, t.isAllData ? (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
- }, xt = () => {
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
- }, St = (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), Dt = 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), Kt = i.useRef(null), we = Gt(K), Tt = i.useMemo(() => i.Children.toArray(t.gridProps.children), [t.gridProps.children]), b = Y((Se = t.gridProps.selectable) != null ? Se : !!t.gridProps.selectedField), ye = Nt((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 sr = i.createContext(void 0), wr = (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 : ir;
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 sr = i.createContext(void 0), wr = (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 Ot(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(er) && (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 Zt(It);
791
- }, [t.gridProps.onColumnResize]), i.useMemo(() => {
792
- S.current = new pt(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, yt(t.total, xe);
801
- const Mt = t.gridProps.columnsState || xt();
802
- return /* @__PURE__ */ i.createElement(
803
- sr.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: Kt,
811
- dir: we,
812
- getCellPositionStyle: St,
804
+ reorderRowDragTargetRef: St,
805
+ reorderRowDropTargetRef: Dt,
806
+ dir: De,
807
+ getCellPositionStyle: yt,
813
808
  dataItemKey: t.gridProps.dataItemKey,
814
- columnsState: Mt,
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: Dt,
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(Bt.Provider, { value: y.current }, t.children),
845
+ /* @__PURE__ */ i.createElement(Nt.Provider, { value: y.current }, t.children),
851
846
  /* @__PURE__ */ i.createElement(
852
- dr,
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
- wr as GridClientWrapper,
867
- sr as GridContext
861
+ wn as GridClientWrapper,
862
+ sn as GridContext
868
863
  };