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