@m4l/components 0.0.3 → 0.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (80) hide show
  1. package/dist/commonjs.js +5 -1
  2. package/dist/components/DataGrid/components/Actions/components/Density/index.d.ts +2 -0
  3. package/dist/components/DataGrid/components/Actions/components/Density/styles.d.ts +3 -0
  4. package/dist/components/DataGrid/components/Actions/components/Filter/index.d.ts +2 -0
  5. package/dist/components/DataGrid/components/Actions/components/Filter/styles.d.ts +2 -0
  6. package/dist/components/DataGrid/components/Actions/components/RowsCount/index.d.ts +2 -0
  7. package/dist/components/DataGrid/components/Actions/components/RowsCount/styles.d.ts +4 -0
  8. package/dist/components/DataGrid/components/Actions/components/Settings/ColumnsConfig/components/FormatterColumn/index.d.ts +4 -0
  9. package/dist/components/DataGrid/components/Actions/components/Settings/ColumnsConfig/index.d.ts +3 -0
  10. package/dist/components/DataGrid/components/Actions/components/Settings/ColumnsConfig/styles.d.ts +8 -0
  11. package/dist/components/DataGrid/components/Actions/components/Settings/ColumnsConfig/types.d.ts +25 -0
  12. package/dist/components/DataGrid/components/Actions/components/Settings/index.d.ts +2 -0
  13. package/dist/components/DataGrid/components/Actions/components/Settings/styles.d.ts +2 -0
  14. package/dist/components/DataGrid/components/Actions/components/Settings/types.d.ts +2 -0
  15. package/dist/components/DataGrid/components/Actions/index.d.ts +3 -0
  16. package/dist/components/DataGrid/components/Actions/styles.d.ts +2 -0
  17. package/dist/components/DataGrid/components/Actions/types.d.ts +11 -0
  18. package/dist/components/DataGrid/components/Table/components/ActionsColumn.d.ts +4 -0
  19. package/dist/components/DataGrid/components/Table/components/CheckboxFormatter.d.ts +3 -0
  20. package/dist/components/DataGrid/components/Table/components/CustomIcons.d.ts +15 -0
  21. package/dist/components/DataGrid/components/Table/components/DraggableHeaderRenderer.d.ts +6 -0
  22. package/dist/components/DataGrid/components/Table/components/SelectColumn.d.ts +4 -0
  23. package/dist/components/DataGrid/components/Table/components/SkeletonFormatter/index.d.ts +2 -0
  24. package/dist/components/DataGrid/components/Table/components/SkeletonFormatter/styles.d.ts +2 -0
  25. package/dist/components/DataGrid/components/Table/hooks/getDragHeaderRenderer.d.ts +3 -0
  26. package/dist/components/DataGrid/components/Table/hooks/useFocusRef.d.ts +5 -0
  27. package/dist/components/DataGrid/components/Table/hooks/useSortColumnsRows.d.ts +8 -0
  28. package/dist/components/DataGrid/components/Table/index.d.ts +3 -0
  29. package/dist/components/DataGrid/components/Table/styles.d.ts +3 -0
  30. package/dist/components/DataGrid/contexts/BaseContext/index.d.ts +5 -0
  31. package/dist/components/DataGrid/contexts/BaseContext/types.d.ts +51 -0
  32. package/dist/components/DataGrid/contexts/FilterContext/index.d.ts +9 -0
  33. package/dist/components/DataGrid/contexts/FilterContext/types.d.ts +11 -0
  34. package/dist/components/DataGrid/dictionary.d.ts +3 -0
  35. package/dist/components/DataGrid/formatters/DateFormatter/index.d.ts +3 -0
  36. package/dist/components/DataGrid/formatters/DateFormatter/types.d.ts +6 -0
  37. package/dist/components/DataGrid/hooks/useBase.d.ts +1 -0
  38. package/dist/components/DataGrid/hooks/useFilters.d.ts +1 -0
  39. package/dist/components/DataGrid/index.d.ts +3 -0
  40. package/dist/components/DataGrid/index.js +1656 -0
  41. package/dist/components/DataGrid/styles.d.ts +3 -0
  42. package/dist/components/DataGrid/types.d.ts +56 -0
  43. package/dist/components/FormActions/dictionary.d.ts +3 -0
  44. package/dist/components/FormActions/index.js +10 -1
  45. package/dist/components/ModalDialog/dictionary.d.ts +3 -0
  46. package/dist/components/ModalDialog/index.js +10 -3
  47. package/dist/components/ObjectLogs/components/DetailDialog/index.d.ts +3 -0
  48. package/dist/components/ObjectLogs/components/DetailDialog/styles.d.ts +3 -0
  49. package/dist/components/ObjectLogs/components/DetailDialog/types.d.ts +3 -0
  50. package/dist/components/ObjectLogs/components/DetailFormatter/index.d.ts +3 -0
  51. package/dist/components/ObjectLogs/components/DetailFormatter/types.d.ts +3 -0
  52. package/dist/components/ObjectLogs/dictionary.d.ts +3 -0
  53. package/dist/components/ObjectLogs/index.d.ts +3 -0
  54. package/dist/components/ObjectLogs/index.js +300 -0
  55. package/dist/components/ObjectLogs/styles.d.ts +4 -0
  56. package/dist/components/ObjectLogs/types.d.ts +18 -0
  57. package/dist/components/index.d.ts +7 -0
  58. package/dist/components/mui_extended/IconButton/index.d.ts +5 -0
  59. package/dist/components/mui_extended/IconButton/index.js +37 -0
  60. package/dist/components/mui_extended/IconButton/types.d.ts +5 -0
  61. package/dist/components/mui_extended/MenuActions/index.d.ts +2 -1
  62. package/dist/components/mui_extended/MenuActions/styles.d.ts +2 -2
  63. package/dist/components/mui_extended/Pager/components/PagerActions/index.d.ts +3 -0
  64. package/dist/components/mui_extended/Pager/components/PagerActions/styles.d.ts +2 -0
  65. package/dist/components/mui_extended/Pager/components/PagerActions/types.d.ts +7 -0
  66. package/dist/components/mui_extended/Pager/dicctionary.d.ts +3 -0
  67. package/dist/components/mui_extended/Pager/index.d.ts +4 -0
  68. package/dist/components/mui_extended/Pager/index.js +201 -0
  69. package/dist/components/mui_extended/Pager/styles.d.ts +6 -0
  70. package/dist/components/mui_extended/Pager/types.d.ts +13 -0
  71. package/dist/components/mui_extended/index.d.ts +5 -1
  72. package/dist/hooks/usePaginate.d.ts +15 -0
  73. package/dist/index.js +18 -6
  74. package/dist/react-data-grid.js +2652 -0
  75. package/dist/react-draggable.js +2 -2
  76. package/dist/react-json-view.js +2764 -0
  77. package/dist/vendor.js +78 -4
  78. package/package.json +15 -3
  79. package/dist/prop-types.js +0 -1
  80. package/dist/react.js +0 -2
@@ -0,0 +1,2652 @@
1
+ import { useContext, forwardRef, useRef, createContext, useState, useMemo, useCallback, useImperativeHandle, useEffect, useLayoutEffect as useLayoutEffect$1, memo } from "react";
2
+ import clsx from "clsx";
3
+ import { jsx, jsxs, Fragment } from "react/jsx-runtime";
4
+ function styleInject(css, ref) {
5
+ if (ref === void 0)
6
+ ref = {};
7
+ var insertAt = ref.insertAt;
8
+ if (!css || typeof document === "undefined") {
9
+ return;
10
+ }
11
+ var head = document.head || document.getElementsByTagName("head")[0];
12
+ var style = document.createElement("style");
13
+ style.type = "text/css";
14
+ if (insertAt === "top") {
15
+ if (head.firstChild) {
16
+ head.insertBefore(style, head.firstChild);
17
+ } else {
18
+ head.appendChild(style);
19
+ }
20
+ } else {
21
+ head.appendChild(style);
22
+ }
23
+ if (style.styleSheet) {
24
+ style.styleSheet.cssText = css;
25
+ } else {
26
+ style.appendChild(document.createTextNode(css));
27
+ }
28
+ }
29
+ var css_248z$f = ".c1wupbe700-beta13{background-color:inherit;border-block-end:1px solid var(--rdg-border-color);border-inline-end:1px solid var(--rdg-border-color);contain:size style;grid-row-start:var(--rdg-grid-row-start);outline:none;overflow:hidden;overflow:clip;padding-block:0;padding-inline:8px;position:relative;text-overflow:ellipsis;white-space:nowrap}.c1wupbe700-beta13[aria-selected=true]{outline:2px solid var(--rdg-selection-color);outline-offset:-2px}.cd0kgiy700-beta13 .c1wupbe700-beta13{contain:content}.c1730fa4700-beta13{position:sticky;z-index:1}.c9dpaye700-beta13{box-shadow:calc(2px*var(--rdg-sign)) 0 5px -2px hsla(0,0%,53%,.3)}";
30
+ styleInject(css_248z$f, { "insertAt": "top" });
31
+ const cell = "c1wupbe700-beta13";
32
+ const cellClassname = `rdg-cell ${cell}`;
33
+ const cellAutoResizeClassname = "cd0kgiy700-beta13";
34
+ const cellFrozen = "c1730fa4700-beta13";
35
+ const cellFrozenClassname = `rdg-cell-frozen ${cellFrozen}`;
36
+ const cellFrozenLast = "c9dpaye700-beta13";
37
+ const cellFrozenLastClassname = `rdg-cell-frozen-last ${cellFrozenLast}`;
38
+ var css_248z$e = '.r104f42s700-beta13{--rdg-color:#000;--rdg-border-color:#ddd;--rdg-summary-border-color:#aaa;--rdg-background-color:#fff;--rdg-header-background-color:#f9f9f9;--rdg-row-hover-background-color:#f5f5f5;--rdg-row-selected-background-color:#dbecfa;--row-selected-hover-background-color:#c9e3f8;--rdg-checkbox-color:#005194;--rdg-checkbox-focus-color:#61b8ff;--rdg-checkbox-disabled-border-color:#ccc;--rdg-checkbox-disabled-background-color:#ddd;--rdg-selection-color:#66afe9;--rdg-font-size:14px;content-visibility:auto;background-color:var(--rdg-background-color);block-size:350px;border:1px solid var(--rdg-border-color);box-sizing:border-box;color:var(--rdg-color);color-scheme:var(--rdg-color-scheme,light dark);contain:strict;contain:size layout style paint;display:grid;font-size:var(--rdg-font-size);overflow:auto;user-select:none}@supports not (contain:strict){.r104f42s700-beta13{position:relative;z-index:0}}.r104f42s700-beta13 *,.r104f42s700-beta13 :after,.r104f42s700-beta13 :before{box-sizing:inherit}.r104f42s700-beta13:before{content:"";grid-column:1/-1;grid-row:1/-1}.r104f42s700-beta13.rdg-dark{--rdg-color-scheme:dark;--rdg-color:#ddd;--rdg-border-color:#444;--rdg-summary-border-color:#555;--rdg-background-color:#212121;--rdg-header-background-color:#1b1b1b;--rdg-row-hover-background-color:#171717;--rdg-row-selected-background-color:#1a73bc;--row-selected-hover-background-color:#1768ab;--rdg-checkbox-color:#94cfff;--rdg-checkbox-focus-color:#c7e6ff;--rdg-checkbox-disabled-border-color:#000;--rdg-checkbox-disabled-background-color:#333}.r104f42s700-beta13.rdg-light{--rdg-color-scheme:light}@media (prefers-color-scheme:dark){.r104f42s700-beta13:not(.rdg-light){--rdg-color:#ddd;--rdg-border-color:#444;--rdg-summary-border-color:#555;--rdg-background-color:#212121;--rdg-header-background-color:#1b1b1b;--rdg-row-hover-background-color:#171717;--rdg-row-selected-background-color:#1a73bc;--row-selected-hover-background-color:#1768ab;--rdg-checkbox-color:#94cfff;--rdg-checkbox-focus-color:#c7e6ff;--rdg-checkbox-disabled-border-color:#000;--rdg-checkbox-disabled-background-color:#333}}.v7ly7s700-beta13.r1otpg64700-beta13{cursor:move}.fc4f4zb700-beta13{grid-column:1/-1;pointer-events:none;z-index:4}';
39
+ styleInject(css_248z$e, { "insertAt": "top" });
40
+ const root = "r104f42s700-beta13";
41
+ const rootClassname = `rdg ${root}`;
42
+ const viewportDragging = "v7ly7s700-beta13";
43
+ const viewportDraggingClassname = `rdg-viewport-dragging ${viewportDragging}`;
44
+ const focusSinkClassname = "fc4f4zb700-beta13";
45
+ var css_248z$d = '.r1otpg64700-beta13{background-color:var(--rdg-background-color);display:contents;line-height:var(--rdg-row-height)}.r1otpg64700-beta13:hover{background-color:var(--rdg-row-hover-background-color)}.r1otpg64700-beta13[aria-selected=true]{background-color:var(--rdg-row-selected-background-color)}.r1otpg64700-beta13[aria-selected=true]:hover{background-color:var(--row-selected-hover-background-color)}.rel5gk2700-beta13{outline:2px solid var(--rdg-selection-color);outline-offset:-2px}.r1qymf1z700-beta13:before{border-inline-start:2px solid var(--rdg-selection-color);content:"";display:inline-block;height:100%;inset-inline-start:0;position:sticky}';
46
+ styleInject(css_248z$d, { "insertAt": "top" });
47
+ const row = "r1otpg64700-beta13";
48
+ const rowClassname = `rdg-row ${row}`;
49
+ const rowSelected = "rel5gk2700-beta13";
50
+ const rowSelectedClassname = `rdg-row-selected`;
51
+ const rowSelectedWithFrozenCell = "r1qymf1z700-beta13";
52
+ var css_248z$c = '.cd9l4jz700-beta13{align-items:center;cursor:pointer;display:flex;inset:0;justify-content:center;margin-inline-end:1px;position:absolute}.c1noyk41700-beta13{all:unset}.cdwjxv8700-beta13{background-color:var(--rdg-background-color);block-size:20px;border:2px solid var(--rdg-border-color);content:"";inline-size:20px}.c1noyk41700-beta13:checked+.cdwjxv8700-beta13{background-color:var(--rdg-checkbox-color);outline:4px solid var(--rdg-background-color);outline-offset:-6px}.c1noyk41700-beta13:focus+.cdwjxv8700-beta13{border-color:var(--rdg-checkbox-focus-color)}.cca4mwn700-beta13{cursor:default}.cca4mwn700-beta13 .cdwjxv8700-beta13{background-color:var(--rdg-checkbox-disabled-background-color);border-color:var(--rdg-checkbox-disabled-border-color)}';
53
+ styleInject(css_248z$c, { "insertAt": "top" });
54
+ const checkboxLabel = "cd9l4jz700-beta13";
55
+ const checkboxLabelClassname = `rdg-checkbox-label ${checkboxLabel}`;
56
+ const checkboxInput = "c1noyk41700-beta13";
57
+ const checkboxInputClassname = `rdg-checkbox-input ${checkboxInput}`;
58
+ const checkbox = "cdwjxv8700-beta13";
59
+ const checkboxClassname = `rdg-checkbox ${checkbox}`;
60
+ const checkboxLabelDisabled = "cca4mwn700-beta13";
61
+ const checkboxLabelDisabledClassname = `rdg-checkbox-label-disabled ${checkboxLabelDisabled}`;
62
+ const CheckboxFormatter = /* @__PURE__ */ forwardRef(function CheckboxFormatter2({
63
+ onChange,
64
+ ...props
65
+ }, ref) {
66
+ function handleChange(e) {
67
+ onChange(e.target.checked, e.nativeEvent.shiftKey);
68
+ }
69
+ return /* @__PURE__ */ jsxs("label", {
70
+ className: clsx(checkboxLabelClassname, props.disabled && checkboxLabelDisabledClassname),
71
+ children: [/* @__PURE__ */ jsx("input", {
72
+ type: "checkbox",
73
+ ref,
74
+ ...props,
75
+ className: checkboxInputClassname,
76
+ onChange: handleChange
77
+ }), /* @__PURE__ */ jsx("div", {
78
+ className: checkboxClassname
79
+ })]
80
+ });
81
+ });
82
+ const useLayoutEffect = typeof window === "undefined" ? useEffect : useLayoutEffect$1;
83
+ function useFocusRef(isSelected) {
84
+ const ref = useRef(null);
85
+ useLayoutEffect(() => {
86
+ if (!isSelected)
87
+ return;
88
+ ref.current?.focus({
89
+ preventScroll: true
90
+ });
91
+ }, [isSelected]);
92
+ return {
93
+ ref,
94
+ tabIndex: isSelected ? 0 : -1
95
+ };
96
+ }
97
+ const DataGridDefaultComponentsContext = /* @__PURE__ */ createContext(void 0);
98
+ const DataGridDefaultComponentsProvider = DataGridDefaultComponentsContext.Provider;
99
+ function useDefaultComponents() {
100
+ return useContext(DataGridDefaultComponentsContext);
101
+ }
102
+ function SelectCellFormatter({
103
+ value,
104
+ isCellSelected,
105
+ disabled,
106
+ onChange,
107
+ "aria-label": ariaLabel,
108
+ "aria-labelledby": ariaLabelledBy
109
+ }) {
110
+ const {
111
+ ref,
112
+ tabIndex
113
+ } = useFocusRef(isCellSelected);
114
+ const Formatter = useDefaultComponents().checkboxFormatter;
115
+ return /* @__PURE__ */ jsx(Formatter, {
116
+ "aria-label": ariaLabel,
117
+ "aria-labelledby": ariaLabelledBy,
118
+ ref,
119
+ tabIndex,
120
+ disabled,
121
+ checked: value,
122
+ onChange
123
+ });
124
+ }
125
+ function ValueFormatter(props) {
126
+ try {
127
+ return /* @__PURE__ */ jsx(Fragment, {
128
+ children: props.row[props.column.key]
129
+ });
130
+ } catch {
131
+ return null;
132
+ }
133
+ }
134
+ var css_248z$b = ".gch972y700-beta13{outline:none}.cz2qf0d700-beta13{stroke:currentColor;stroke-width:1.5px;fill:transparent;margin-inline-start:4px;vertical-align:middle}.cz2qf0d700-beta13>path{transition:d .1s}";
135
+ styleInject(css_248z$b, { "insertAt": "top" });
136
+ const groupCellContent = "gch972y700-beta13";
137
+ const groupCellContentClassname = `rdg-group-cell-content ${groupCellContent}`;
138
+ const caret = "cz2qf0d700-beta13";
139
+ const caretClassname = `rdg-caret ${caret}`;
140
+ function ToggleGroupFormatter({
141
+ groupKey,
142
+ isExpanded,
143
+ isCellSelected,
144
+ toggleGroup
145
+ }) {
146
+ const {
147
+ ref,
148
+ tabIndex
149
+ } = useFocusRef(isCellSelected);
150
+ function handleKeyDown({
151
+ key
152
+ }) {
153
+ if (key === "Enter") {
154
+ toggleGroup();
155
+ }
156
+ }
157
+ const d = isExpanded ? "M1 1 L 7 7 L 13 1" : "M1 7 L 7 1 L 13 7";
158
+ return /* @__PURE__ */ jsxs("span", {
159
+ ref,
160
+ className: groupCellContentClassname,
161
+ tabIndex,
162
+ onKeyDown: handleKeyDown,
163
+ children: [groupKey, /* @__PURE__ */ jsx("svg", {
164
+ viewBox: "0 0 14 8",
165
+ width: "14",
166
+ height: "8",
167
+ className: caretClassname,
168
+ "aria-hidden": true,
169
+ children: /* @__PURE__ */ jsx("path", {
170
+ d
171
+ })
172
+ })]
173
+ });
174
+ }
175
+ const RowSelectionContext = /* @__PURE__ */ createContext(void 0);
176
+ const RowSelectionProvider = RowSelectionContext.Provider;
177
+ const RowSelectionChangeContext = /* @__PURE__ */ createContext(void 0);
178
+ const RowSelectionChangeProvider = RowSelectionChangeContext.Provider;
179
+ function useRowSelection() {
180
+ const rowSelectionContext = useContext(RowSelectionContext);
181
+ const rowSelectionChangeContext = useContext(RowSelectionChangeContext);
182
+ if (rowSelectionContext === void 0 || rowSelectionChangeContext === void 0) {
183
+ throw new Error("useRowSelection must be used within DataGrid cells");
184
+ }
185
+ return [rowSelectionContext, rowSelectionChangeContext];
186
+ }
187
+ const SELECT_COLUMN_KEY = "select-row";
188
+ function getColSpan(column, lastFrozenColumnIndex, args) {
189
+ const colSpan = typeof column.colSpan === "function" ? column.colSpan(args) : 1;
190
+ if (Number.isInteger(colSpan) && colSpan > 1 && (!column.frozen || column.idx + colSpan - 1 <= lastFrozenColumnIndex)) {
191
+ return colSpan;
192
+ }
193
+ return void 0;
194
+ }
195
+ function scrollIntoView(element) {
196
+ element?.scrollIntoView({
197
+ inline: "nearest",
198
+ block: "nearest"
199
+ });
200
+ }
201
+ const nonInputKeys = /* @__PURE__ */ new Set(["Unidentified", "Alt", "AltGraph", "CapsLock", "Control", "Fn", "FnLock", "Meta", "NumLock", "ScrollLock", "Shift", "Tab", "ArrowDown", "ArrowLeft", "ArrowRight", "ArrowUp", "End", "Home", "PageDown", "PageUp", "Insert", "ContextMenu", "Escape", "Pause", "Play", "PrintScreen", "F1", "F3", "F4", "F5", "F6", "F7", "F8", "F9", "F10", "F11", "F12"]);
202
+ function isCtrlKeyHeldDown(e) {
203
+ return (e.ctrlKey || e.metaKey) && e.key !== "Control";
204
+ }
205
+ function isDefaultCellInput(event) {
206
+ return !nonInputKeys.has(event.key);
207
+ }
208
+ function onEditorNavigation({
209
+ key,
210
+ target
211
+ }) {
212
+ if (key === "Tab" && (target instanceof HTMLInputElement || target instanceof HTMLTextAreaElement || target instanceof HTMLSelectElement)) {
213
+ return target.matches(".rdg-editor-container > :only-child, .rdg-editor-container > label:only-child > :only-child");
214
+ }
215
+ return false;
216
+ }
217
+ function isSelectedCellEditable({
218
+ selectedPosition,
219
+ columns,
220
+ rows,
221
+ isGroupRow
222
+ }) {
223
+ const column = columns[selectedPosition.idx];
224
+ const row2 = rows[selectedPosition.rowIdx];
225
+ return !isGroupRow(row2) && isCellEditable(column, row2);
226
+ }
227
+ function isCellEditable(column, row2) {
228
+ return column.editor != null && !column.rowGroup && (typeof column.editable === "function" ? column.editable(row2) : column.editable) !== false;
229
+ }
230
+ function getSelectedCellColSpan({
231
+ rows,
232
+ summaryRows,
233
+ rowIdx,
234
+ lastFrozenColumnIndex,
235
+ column,
236
+ isGroupRow
237
+ }) {
238
+ if (rowIdx === -1) {
239
+ return getColSpan(column, lastFrozenColumnIndex, {
240
+ type: "HEADER"
241
+ });
242
+ }
243
+ if (rowIdx >= 0 && rowIdx < rows.length) {
244
+ const row2 = rows[rowIdx];
245
+ if (!isGroupRow(row2)) {
246
+ return getColSpan(column, lastFrozenColumnIndex, {
247
+ type: "ROW",
248
+ row: row2
249
+ });
250
+ }
251
+ return void 0;
252
+ }
253
+ if (summaryRows) {
254
+ return getColSpan(column, lastFrozenColumnIndex, {
255
+ type: "SUMMARY",
256
+ row: summaryRows[rowIdx - rows.length]
257
+ });
258
+ }
259
+ return void 0;
260
+ }
261
+ function getNextSelectedCellPosition({
262
+ cellNavigationMode,
263
+ columns,
264
+ colSpanColumns,
265
+ rows,
266
+ summaryRows,
267
+ minRowIdx,
268
+ maxRowIdx,
269
+ currentPosition: {
270
+ idx: currentIdx
271
+ },
272
+ nextPosition,
273
+ lastFrozenColumnIndex,
274
+ isCellWithinBounds,
275
+ isGroupRow
276
+ }) {
277
+ let {
278
+ idx: nextIdx,
279
+ rowIdx: nextRowIdx
280
+ } = nextPosition;
281
+ const setColSpan = (moveRight) => {
282
+ if (nextRowIdx >= 0 && nextRowIdx < rows.length) {
283
+ const row2 = rows[nextRowIdx];
284
+ if (isGroupRow(row2))
285
+ return;
286
+ }
287
+ for (const column of colSpanColumns) {
288
+ const colIdx = column.idx;
289
+ if (colIdx > nextIdx)
290
+ break;
291
+ const colSpan = getSelectedCellColSpan({
292
+ rows,
293
+ summaryRows,
294
+ rowIdx: nextRowIdx,
295
+ lastFrozenColumnIndex,
296
+ column,
297
+ isGroupRow
298
+ });
299
+ if (colSpan && nextIdx > colIdx && nextIdx < colSpan + colIdx) {
300
+ nextIdx = colIdx + (moveRight ? colSpan : 0);
301
+ break;
302
+ }
303
+ }
304
+ };
305
+ if (isCellWithinBounds(nextPosition)) {
306
+ setColSpan(nextIdx - currentIdx > 0);
307
+ }
308
+ if (cellNavigationMode !== "NONE") {
309
+ const columnsCount = columns.length;
310
+ const isAfterLastColumn = nextIdx === columnsCount;
311
+ const isBeforeFirstColumn = nextIdx === -1;
312
+ if (isAfterLastColumn) {
313
+ if (cellNavigationMode === "CHANGE_ROW") {
314
+ const isLastRow = nextRowIdx === maxRowIdx;
315
+ if (!isLastRow) {
316
+ nextIdx = 0;
317
+ nextRowIdx += 1;
318
+ }
319
+ } else {
320
+ nextIdx = 0;
321
+ }
322
+ } else if (isBeforeFirstColumn) {
323
+ if (cellNavigationMode === "CHANGE_ROW") {
324
+ const isFirstRow = nextRowIdx === minRowIdx;
325
+ if (!isFirstRow) {
326
+ nextRowIdx -= 1;
327
+ nextIdx = columnsCount - 1;
328
+ }
329
+ } else {
330
+ nextIdx = columnsCount - 1;
331
+ }
332
+ setColSpan(false);
333
+ }
334
+ }
335
+ return {
336
+ idx: nextIdx,
337
+ rowIdx: nextRowIdx
338
+ };
339
+ }
340
+ function canExitGrid({
341
+ cellNavigationMode,
342
+ maxColIdx,
343
+ minRowIdx,
344
+ maxRowIdx,
345
+ selectedPosition: {
346
+ rowIdx,
347
+ idx
348
+ },
349
+ shiftKey
350
+ }) {
351
+ if (cellNavigationMode === "NONE" || cellNavigationMode === "CHANGE_ROW") {
352
+ const atLastCellInRow = idx === maxColIdx;
353
+ const atFirstCellInRow = idx === 0;
354
+ const atLastRow = rowIdx === maxRowIdx;
355
+ const atFirstRow = rowIdx === minRowIdx;
356
+ return shiftKey ? atFirstCellInRow && atFirstRow : atLastCellInRow && atLastRow;
357
+ }
358
+ return false;
359
+ }
360
+ function getRowStyle(rowIdx, height) {
361
+ if (height !== void 0) {
362
+ return {
363
+ "--rdg-grid-row-start": rowIdx,
364
+ "--rdg-row-height": `${height}px`
365
+ };
366
+ }
367
+ return {
368
+ "--rdg-grid-row-start": rowIdx
369
+ };
370
+ }
371
+ function getCellStyle(column, colSpan) {
372
+ return {
373
+ gridColumnStart: column.idx + 1,
374
+ gridColumnEnd: colSpan !== void 0 ? `span ${colSpan}` : void 0,
375
+ insetInlineStart: column.frozen ? `var(--rdg-frozen-left-${column.idx})` : void 0
376
+ };
377
+ }
378
+ function getCellClassname(column, ...extraClasses) {
379
+ return clsx(cellClassname, ...extraClasses, column.frozen && cellFrozenClassname, column.isLastFrozenColumn && cellFrozenLastClassname);
380
+ }
381
+ const {
382
+ min,
383
+ max,
384
+ round,
385
+ floor,
386
+ sign,
387
+ abs,
388
+ ceil
389
+ } = Math;
390
+ function assertIsValidKeyGetter(keyGetter) {
391
+ if (typeof keyGetter !== "function") {
392
+ throw new Error("Please specify the rowKeyGetter prop to use selection");
393
+ }
394
+ }
395
+ function clampColumnWidth(width, {
396
+ minWidth,
397
+ maxWidth
398
+ }) {
399
+ width = max(width, minWidth);
400
+ if (typeof maxWidth === "number" && maxWidth >= minWidth) {
401
+ return min(width, maxWidth);
402
+ }
403
+ return width;
404
+ }
405
+ function useCalculatedColumns({
406
+ rawColumns,
407
+ columnWidths,
408
+ viewportWidth,
409
+ scrollLeft,
410
+ defaultColumnOptions,
411
+ rawGroupBy,
412
+ enableVirtualization
413
+ }) {
414
+ const defaultWidth = defaultColumnOptions?.width;
415
+ const defaultMinWidth = defaultColumnOptions?.minWidth ?? 80;
416
+ const defaultMaxWidth = defaultColumnOptions?.maxWidth;
417
+ const defaultFormatter = defaultColumnOptions?.formatter ?? ValueFormatter;
418
+ const defaultSortable = defaultColumnOptions?.sortable ?? false;
419
+ const defaultResizable = defaultColumnOptions?.resizable ?? false;
420
+ const {
421
+ columns,
422
+ colSpanColumns,
423
+ lastFrozenColumnIndex,
424
+ groupBy
425
+ } = useMemo(() => {
426
+ const groupBy2 = [];
427
+ let lastFrozenColumnIndex2 = -1;
428
+ const columns2 = rawColumns.map((rawColumn) => {
429
+ const rowGroup = rawGroupBy?.includes(rawColumn.key) ?? false;
430
+ const frozen = rowGroup || rawColumn.frozen || false;
431
+ const column = {
432
+ ...rawColumn,
433
+ idx: 0,
434
+ frozen,
435
+ isLastFrozenColumn: false,
436
+ rowGroup,
437
+ width: rawColumn.width ?? defaultWidth,
438
+ minWidth: rawColumn.minWidth ?? defaultMinWidth,
439
+ maxWidth: rawColumn.maxWidth ?? defaultMaxWidth,
440
+ sortable: rawColumn.sortable ?? defaultSortable,
441
+ resizable: rawColumn.resizable ?? defaultResizable,
442
+ formatter: rawColumn.formatter ?? defaultFormatter
443
+ };
444
+ if (rowGroup) {
445
+ column.groupFormatter ?? (column.groupFormatter = ToggleGroupFormatter);
446
+ }
447
+ if (frozen) {
448
+ lastFrozenColumnIndex2++;
449
+ }
450
+ return column;
451
+ });
452
+ columns2.sort(({
453
+ key: aKey,
454
+ frozen: frozenA
455
+ }, {
456
+ key: bKey,
457
+ frozen: frozenB
458
+ }) => {
459
+ if (aKey === SELECT_COLUMN_KEY)
460
+ return -1;
461
+ if (bKey === SELECT_COLUMN_KEY)
462
+ return 1;
463
+ if (rawGroupBy?.includes(aKey)) {
464
+ if (rawGroupBy.includes(bKey)) {
465
+ return rawGroupBy.indexOf(aKey) - rawGroupBy.indexOf(bKey);
466
+ }
467
+ return -1;
468
+ }
469
+ if (rawGroupBy?.includes(bKey))
470
+ return 1;
471
+ if (frozenA) {
472
+ if (frozenB)
473
+ return 0;
474
+ return -1;
475
+ }
476
+ if (frozenB)
477
+ return 1;
478
+ return 0;
479
+ });
480
+ const colSpanColumns2 = [];
481
+ columns2.forEach((column, idx) => {
482
+ column.idx = idx;
483
+ if (column.rowGroup) {
484
+ groupBy2.push(column.key);
485
+ }
486
+ if (column.colSpan != null) {
487
+ colSpanColumns2.push(column);
488
+ }
489
+ });
490
+ if (lastFrozenColumnIndex2 !== -1) {
491
+ columns2[lastFrozenColumnIndex2].isLastFrozenColumn = true;
492
+ }
493
+ return {
494
+ columns: columns2,
495
+ colSpanColumns: colSpanColumns2,
496
+ lastFrozenColumnIndex: lastFrozenColumnIndex2,
497
+ groupBy: groupBy2
498
+ };
499
+ }, [rawColumns, defaultWidth, defaultMinWidth, defaultMaxWidth, defaultFormatter, defaultResizable, defaultSortable, rawGroupBy]);
500
+ const {
501
+ layoutCssVars,
502
+ totalFrozenColumnWidth,
503
+ columnMetrics
504
+ } = useMemo(() => {
505
+ const columnMetrics2 = /* @__PURE__ */ new Map();
506
+ let left = 0;
507
+ let totalFrozenColumnWidth2 = 0;
508
+ let templateColumns = "";
509
+ let allocatedWidth = 0;
510
+ let unassignedColumnsCount = 0;
511
+ for (const column of columns) {
512
+ let width = getSpecifiedWidth(column, columnWidths, viewportWidth);
513
+ if (width === void 0) {
514
+ unassignedColumnsCount++;
515
+ } else {
516
+ width = clampColumnWidth(width, column);
517
+ allocatedWidth += width;
518
+ columnMetrics2.set(column, {
519
+ width,
520
+ left: 0
521
+ });
522
+ }
523
+ }
524
+ for (const column of columns) {
525
+ let width;
526
+ if (columnMetrics2.has(column)) {
527
+ const columnMetric = columnMetrics2.get(column);
528
+ columnMetric.left = left;
529
+ ({
530
+ width
531
+ } = columnMetric);
532
+ } else {
533
+ const unallocatedWidth = viewportWidth - allocatedWidth;
534
+ const unallocatedColumnWidth = round(unallocatedWidth / unassignedColumnsCount);
535
+ width = clampColumnWidth(unallocatedColumnWidth, column);
536
+ allocatedWidth += width;
537
+ unassignedColumnsCount--;
538
+ columnMetrics2.set(column, {
539
+ width,
540
+ left
541
+ });
542
+ }
543
+ left += width;
544
+ templateColumns += `${width}px `;
545
+ }
546
+ if (lastFrozenColumnIndex !== -1) {
547
+ const columnMetric = columnMetrics2.get(columns[lastFrozenColumnIndex]);
548
+ totalFrozenColumnWidth2 = columnMetric.left + columnMetric.width;
549
+ }
550
+ const layoutCssVars2 = {
551
+ gridTemplateColumns: templateColumns
552
+ };
553
+ for (let i = 0; i <= lastFrozenColumnIndex; i++) {
554
+ const column = columns[i];
555
+ layoutCssVars2[`--rdg-frozen-left-${column.idx}`] = `${columnMetrics2.get(column).left}px`;
556
+ }
557
+ return {
558
+ layoutCssVars: layoutCssVars2,
559
+ totalFrozenColumnWidth: totalFrozenColumnWidth2,
560
+ columnMetrics: columnMetrics2
561
+ };
562
+ }, [columnWidths, columns, viewportWidth, lastFrozenColumnIndex]);
563
+ const [colOverscanStartIdx, colOverscanEndIdx] = useMemo(() => {
564
+ if (!enableVirtualization) {
565
+ return [0, columns.length - 1];
566
+ }
567
+ const viewportLeft = scrollLeft + totalFrozenColumnWidth;
568
+ const viewportRight = scrollLeft + viewportWidth;
569
+ const lastColIdx = columns.length - 1;
570
+ const firstUnfrozenColumnIdx = min(lastFrozenColumnIndex + 1, lastColIdx);
571
+ if (viewportLeft >= viewportRight) {
572
+ return [firstUnfrozenColumnIdx, firstUnfrozenColumnIdx];
573
+ }
574
+ let colVisibleStartIdx = firstUnfrozenColumnIdx;
575
+ while (colVisibleStartIdx < lastColIdx) {
576
+ const {
577
+ left,
578
+ width
579
+ } = columnMetrics.get(columns[colVisibleStartIdx]);
580
+ if (left + width > viewportLeft) {
581
+ break;
582
+ }
583
+ colVisibleStartIdx++;
584
+ }
585
+ let colVisibleEndIdx = colVisibleStartIdx;
586
+ while (colVisibleEndIdx < lastColIdx) {
587
+ const {
588
+ left,
589
+ width
590
+ } = columnMetrics.get(columns[colVisibleEndIdx]);
591
+ if (left + width >= viewportRight) {
592
+ break;
593
+ }
594
+ colVisibleEndIdx++;
595
+ }
596
+ const colOverscanStartIdx2 = max(firstUnfrozenColumnIdx, colVisibleStartIdx - 1);
597
+ const colOverscanEndIdx2 = min(lastColIdx, colVisibleEndIdx + 1);
598
+ return [colOverscanStartIdx2, colOverscanEndIdx2];
599
+ }, [columnMetrics, columns, lastFrozenColumnIndex, scrollLeft, totalFrozenColumnWidth, viewportWidth, enableVirtualization]);
600
+ return {
601
+ columns,
602
+ colSpanColumns,
603
+ colOverscanStartIdx,
604
+ colOverscanEndIdx,
605
+ layoutCssVars,
606
+ columnMetrics,
607
+ lastFrozenColumnIndex,
608
+ totalFrozenColumnWidth,
609
+ groupBy
610
+ };
611
+ }
612
+ function getSpecifiedWidth({
613
+ key,
614
+ width
615
+ }, columnWidths, viewportWidth) {
616
+ if (columnWidths.has(key)) {
617
+ return columnWidths.get(key);
618
+ }
619
+ if (typeof width === "number") {
620
+ return width;
621
+ }
622
+ if (typeof width === "string" && /^\d+%$/.test(width)) {
623
+ return floor(viewportWidth * parseInt(width, 10) / 100);
624
+ }
625
+ return void 0;
626
+ }
627
+ function useGridDimensions() {
628
+ const gridRef = useRef(null);
629
+ const [inlineSize, setInlineSize] = useState(1);
630
+ const [blockSize, setBlockSize] = useState(1);
631
+ useLayoutEffect(() => {
632
+ const {
633
+ ResizeObserver
634
+ } = window;
635
+ if (ResizeObserver == null)
636
+ return;
637
+ const {
638
+ clientWidth,
639
+ clientHeight,
640
+ offsetWidth,
641
+ offsetHeight
642
+ } = gridRef.current;
643
+ const {
644
+ width,
645
+ height
646
+ } = gridRef.current.getBoundingClientRect();
647
+ const initialWidth = width - offsetWidth + clientWidth;
648
+ const initialHeight = height - offsetHeight + clientHeight;
649
+ setInlineSize(handleDevicePixelRatio(initialWidth));
650
+ setBlockSize(initialHeight);
651
+ const resizeObserver = new ResizeObserver((entries) => {
652
+ const size = entries[0].contentBoxSize[0];
653
+ setInlineSize(handleDevicePixelRatio(size.inlineSize));
654
+ setBlockSize(size.blockSize);
655
+ });
656
+ resizeObserver.observe(gridRef.current);
657
+ return () => {
658
+ resizeObserver.disconnect();
659
+ };
660
+ }, []);
661
+ return [gridRef, inlineSize, blockSize];
662
+ }
663
+ function handleDevicePixelRatio(size) {
664
+ return size - (devicePixelRatio === 1 ? 0 : ceil(devicePixelRatio));
665
+ }
666
+ function useLatestFunc(fn) {
667
+ const ref = useRef(fn);
668
+ useEffect(() => {
669
+ ref.current = fn;
670
+ });
671
+ return useCallback((...args) => {
672
+ ref.current(...args);
673
+ }, []);
674
+ }
675
+ function useRovingCellRef(isSelected) {
676
+ const [isChildFocused, setIsChildFocused] = useState(false);
677
+ if (isChildFocused && !isSelected) {
678
+ setIsChildFocused(false);
679
+ }
680
+ const ref = useCallback((cell2) => {
681
+ if (cell2 === null)
682
+ return;
683
+ scrollIntoView(cell2);
684
+ if (cell2.contains(document.activeElement))
685
+ return;
686
+ cell2.focus({
687
+ preventScroll: true
688
+ });
689
+ }, []);
690
+ function onFocus(event) {
691
+ if (event.target !== event.currentTarget) {
692
+ setIsChildFocused(true);
693
+ }
694
+ }
695
+ const isFocused = isSelected && !isChildFocused;
696
+ return {
697
+ ref: isSelected ? ref : void 0,
698
+ tabIndex: isFocused ? 0 : -1,
699
+ onFocus: isSelected ? onFocus : void 0
700
+ };
701
+ }
702
+ function useViewportColumns({
703
+ columns,
704
+ colSpanColumns,
705
+ rows,
706
+ summaryRows,
707
+ colOverscanStartIdx,
708
+ colOverscanEndIdx,
709
+ lastFrozenColumnIndex,
710
+ rowOverscanStartIdx,
711
+ rowOverscanEndIdx,
712
+ isGroupRow
713
+ }) {
714
+ const startIdx = useMemo(() => {
715
+ if (colOverscanStartIdx === 0)
716
+ return 0;
717
+ let startIdx2 = colOverscanStartIdx;
718
+ const updateStartIdx = (colIdx, colSpan) => {
719
+ if (colSpan !== void 0 && colIdx + colSpan > colOverscanStartIdx) {
720
+ startIdx2 = colIdx;
721
+ return true;
722
+ }
723
+ return false;
724
+ };
725
+ for (const column of colSpanColumns) {
726
+ const colIdx = column.idx;
727
+ if (colIdx >= startIdx2)
728
+ break;
729
+ if (updateStartIdx(colIdx, getColSpan(column, lastFrozenColumnIndex, {
730
+ type: "HEADER"
731
+ }))) {
732
+ break;
733
+ }
734
+ for (let rowIdx = rowOverscanStartIdx; rowIdx <= rowOverscanEndIdx; rowIdx++) {
735
+ const row2 = rows[rowIdx];
736
+ if (isGroupRow(row2))
737
+ continue;
738
+ if (updateStartIdx(colIdx, getColSpan(column, lastFrozenColumnIndex, {
739
+ type: "ROW",
740
+ row: row2
741
+ }))) {
742
+ break;
743
+ }
744
+ }
745
+ if (summaryRows != null) {
746
+ for (const row2 of summaryRows) {
747
+ if (updateStartIdx(colIdx, getColSpan(column, lastFrozenColumnIndex, {
748
+ type: "SUMMARY",
749
+ row: row2
750
+ }))) {
751
+ break;
752
+ }
753
+ }
754
+ }
755
+ }
756
+ return startIdx2;
757
+ }, [rowOverscanStartIdx, rowOverscanEndIdx, rows, summaryRows, colOverscanStartIdx, lastFrozenColumnIndex, colSpanColumns, isGroupRow]);
758
+ return useMemo(() => {
759
+ const viewportColumns = [];
760
+ for (let colIdx = 0; colIdx <= colOverscanEndIdx; colIdx++) {
761
+ const column = columns[colIdx];
762
+ if (colIdx < startIdx && !column.frozen)
763
+ continue;
764
+ viewportColumns.push(column);
765
+ }
766
+ return viewportColumns;
767
+ }, [startIdx, colOverscanEndIdx, columns]);
768
+ }
769
+ function isReadonlyArray(arr) {
770
+ return Array.isArray(arr);
771
+ }
772
+ function useViewportRows({
773
+ rawRows,
774
+ rowHeight,
775
+ clientHeight,
776
+ scrollTop,
777
+ groupBy,
778
+ rowGrouper,
779
+ expandedGroupIds,
780
+ enableVirtualization
781
+ }) {
782
+ const [groupedRows, rowsCount] = useMemo(() => {
783
+ if (groupBy.length === 0 || rowGrouper == null)
784
+ return [void 0, rawRows.length];
785
+ const groupRows = (rows2, [groupByKey, ...remainingGroupByKeys], startRowIndex) => {
786
+ let groupRowsCount = 0;
787
+ const groups = {};
788
+ for (const [key, childRows] of Object.entries(rowGrouper(rows2, groupByKey))) {
789
+ const [childGroups, childRowsCount] = remainingGroupByKeys.length === 0 ? [childRows, childRows.length] : groupRows(childRows, remainingGroupByKeys, startRowIndex + groupRowsCount + 1);
790
+ groups[key] = {
791
+ childRows,
792
+ childGroups,
793
+ startRowIndex: startRowIndex + groupRowsCount
794
+ };
795
+ groupRowsCount += childRowsCount + 1;
796
+ }
797
+ return [groups, groupRowsCount];
798
+ };
799
+ return groupRows(rawRows, groupBy, 0);
800
+ }, [groupBy, rowGrouper, rawRows]);
801
+ const [rows, isGroupRow] = useMemo(() => {
802
+ const allGroupRows = /* @__PURE__ */ new Set();
803
+ if (!groupedRows)
804
+ return [rawRows, isGroupRow2];
805
+ const flattenedRows = [];
806
+ const expandGroup = (rows2, parentId, level) => {
807
+ if (isReadonlyArray(rows2)) {
808
+ flattenedRows.push(...rows2);
809
+ return;
810
+ }
811
+ Object.keys(rows2).forEach((groupKey, posInSet, keys) => {
812
+ const id = parentId !== void 0 ? `${parentId}__${groupKey}` : groupKey;
813
+ const isExpanded = expandedGroupIds?.has(id) ?? false;
814
+ const {
815
+ childRows,
816
+ childGroups,
817
+ startRowIndex
818
+ } = rows2[groupKey];
819
+ const groupRow2 = {
820
+ id,
821
+ parentId,
822
+ groupKey,
823
+ isExpanded,
824
+ childRows,
825
+ level,
826
+ posInSet,
827
+ startRowIndex,
828
+ setSize: keys.length
829
+ };
830
+ flattenedRows.push(groupRow2);
831
+ allGroupRows.add(groupRow2);
832
+ if (isExpanded) {
833
+ expandGroup(childGroups, id, level + 1);
834
+ }
835
+ });
836
+ };
837
+ expandGroup(groupedRows, void 0, 0);
838
+ return [flattenedRows, isGroupRow2];
839
+ function isGroupRow2(row2) {
840
+ return allGroupRows.has(row2);
841
+ }
842
+ }, [expandedGroupIds, groupedRows, rawRows]);
843
+ const {
844
+ totalRowHeight,
845
+ gridTemplateRows,
846
+ getRowTop,
847
+ getRowHeight,
848
+ findRowIdx
849
+ } = useMemo(() => {
850
+ if (typeof rowHeight === "number") {
851
+ return {
852
+ totalRowHeight: rowHeight * rows.length,
853
+ gridTemplateRows: ` repeat(${rows.length}, ${rowHeight}px)`,
854
+ getRowTop: (rowIdx) => rowIdx * rowHeight,
855
+ getRowHeight: () => rowHeight,
856
+ findRowIdx: (offset) => floor(offset / rowHeight)
857
+ };
858
+ }
859
+ let totalRowHeight2 = 0;
860
+ let gridTemplateRows2 = " ";
861
+ const rowPositions = rows.map((row2) => {
862
+ const currentRowHeight = isGroupRow(row2) ? rowHeight({
863
+ type: "GROUP",
864
+ row: row2
865
+ }) : rowHeight({
866
+ type: "ROW",
867
+ row: row2
868
+ });
869
+ const position = {
870
+ top: totalRowHeight2,
871
+ height: currentRowHeight
872
+ };
873
+ gridTemplateRows2 += `${currentRowHeight}px `;
874
+ totalRowHeight2 += currentRowHeight;
875
+ return position;
876
+ });
877
+ const validateRowIdx = (rowIdx) => {
878
+ return max(0, min(rows.length - 1, rowIdx));
879
+ };
880
+ return {
881
+ totalRowHeight: totalRowHeight2,
882
+ gridTemplateRows: gridTemplateRows2,
883
+ getRowTop: (rowIdx) => rowPositions[validateRowIdx(rowIdx)].top,
884
+ getRowHeight: (rowIdx) => rowPositions[validateRowIdx(rowIdx)].height,
885
+ findRowIdx(offset) {
886
+ let start = 0;
887
+ let end = rowPositions.length - 1;
888
+ while (start <= end) {
889
+ const middle = start + floor((end - start) / 2);
890
+ const currentOffset = rowPositions[middle].top;
891
+ if (currentOffset === offset)
892
+ return middle;
893
+ if (currentOffset < offset) {
894
+ start = middle + 1;
895
+ } else if (currentOffset > offset) {
896
+ end = middle - 1;
897
+ }
898
+ if (start > end)
899
+ return end;
900
+ }
901
+ return 0;
902
+ }
903
+ };
904
+ }, [isGroupRow, rowHeight, rows]);
905
+ let rowOverscanStartIdx = 0;
906
+ let rowOverscanEndIdx = rows.length - 1;
907
+ if (enableVirtualization) {
908
+ const overscanThreshold = 4;
909
+ const rowVisibleStartIdx = findRowIdx(scrollTop);
910
+ const rowVisibleEndIdx = findRowIdx(scrollTop + clientHeight);
911
+ rowOverscanStartIdx = max(0, rowVisibleStartIdx - overscanThreshold);
912
+ rowOverscanEndIdx = min(rows.length - 1, rowVisibleEndIdx + overscanThreshold);
913
+ }
914
+ return {
915
+ rowOverscanStartIdx,
916
+ rowOverscanEndIdx,
917
+ rows,
918
+ rowsCount,
919
+ totalRowHeight,
920
+ gridTemplateRows,
921
+ isGroupRow,
922
+ getRowTop,
923
+ getRowHeight,
924
+ findRowIdx
925
+ };
926
+ }
927
+ var css_248z$a = ".h1tr5c9i700-beta13{cursor:pointer;display:flex}.h1tr5c9i700-beta13:focus{outline:none}.h19r0msv700-beta13{flex-grow:1;overflow:hidden;overflow:clip;text-overflow:ellipsis}";
928
+ styleInject(css_248z$a, { "insertAt": "top" });
929
+ const headerSortCell = "h1tr5c9i700-beta13";
930
+ const headerSortCellClassname = `rdg-header-sort-cell ${headerSortCell}`;
931
+ const headerSortName = "h19r0msv700-beta13";
932
+ const headerSortNameClassname = `rdg-header-sort-name ${headerSortName}`;
933
+ function HeaderRenderer({
934
+ column,
935
+ sortDirection,
936
+ priority,
937
+ onSort,
938
+ isCellSelected
939
+ }) {
940
+ if (!column.sortable)
941
+ return /* @__PURE__ */ jsx(Fragment, {
942
+ children: column.name
943
+ });
944
+ return /* @__PURE__ */ jsx(SortableHeaderCell, {
945
+ onSort,
946
+ sortDirection,
947
+ priority,
948
+ isCellSelected,
949
+ children: column.name
950
+ });
951
+ }
952
+ function SortableHeaderCell({
953
+ onSort,
954
+ sortDirection,
955
+ priority,
956
+ children,
957
+ isCellSelected
958
+ }) {
959
+ const SortIcon2 = useDefaultComponents().sortIcon;
960
+ const {
961
+ ref,
962
+ tabIndex
963
+ } = useFocusRef(isCellSelected);
964
+ function handleKeyDown(event) {
965
+ if (event.key === " " || event.key === "Enter") {
966
+ event.preventDefault();
967
+ onSort(event.ctrlKey || event.metaKey);
968
+ }
969
+ }
970
+ function handleClick(event) {
971
+ onSort(event.ctrlKey || event.metaKey);
972
+ }
973
+ return /* @__PURE__ */ jsxs("span", {
974
+ ref,
975
+ tabIndex,
976
+ className: headerSortCellClassname,
977
+ onClick: handleClick,
978
+ onKeyDown: handleKeyDown,
979
+ children: [/* @__PURE__ */ jsx("span", {
980
+ className: headerSortNameClassname,
981
+ children
982
+ }), /* @__PURE__ */ jsxs("span", {
983
+ children: [/* @__PURE__ */ jsx(SortIcon2, {
984
+ sortDirection
985
+ }), priority]
986
+ })]
987
+ });
988
+ }
989
+ var css_248z$9 = '.celq7o9700-beta13{touch-action:none}.celq7o9700-beta13:after{content:"";cursor:col-resize;inline-size:10px;inset-block-end:0;inset-block-start:0;inset-inline-end:0;position:absolute}';
990
+ styleInject(css_248z$9, { "insertAt": "top" });
991
+ const cellResizable = "celq7o9700-beta13";
992
+ const cellResizableClassname = `rdg-cell-resizable ${cellResizable}`;
993
+ function HeaderCell({
994
+ column,
995
+ colSpan,
996
+ isCellSelected,
997
+ onColumnResize,
998
+ allRowsSelected,
999
+ onAllRowsSelectionChange,
1000
+ sortColumns,
1001
+ onSortColumnsChange,
1002
+ selectCell,
1003
+ shouldFocusGrid,
1004
+ direction
1005
+ }) {
1006
+ const isRtl = direction === "rtl";
1007
+ const {
1008
+ ref,
1009
+ tabIndex,
1010
+ onFocus
1011
+ } = useRovingCellRef(isCellSelected);
1012
+ const sortIndex = sortColumns?.findIndex((sort) => sort.columnKey === column.key);
1013
+ const sortColumn = sortIndex !== void 0 && sortIndex > -1 ? sortColumns[sortIndex] : void 0;
1014
+ const sortDirection = sortColumn?.direction;
1015
+ const priority = sortColumn !== void 0 && sortColumns.length > 1 ? sortIndex + 1 : void 0;
1016
+ const ariaSort = sortDirection && !priority ? sortDirection === "ASC" ? "ascending" : "descending" : void 0;
1017
+ const className = getCellClassname(column, column.headerCellClass, column.resizable && cellResizableClassname);
1018
+ const HeaderRenderer$1 = column.headerRenderer ?? HeaderRenderer;
1019
+ function onPointerDown(event) {
1020
+ if (event.pointerType === "mouse" && event.buttons !== 1) {
1021
+ return;
1022
+ }
1023
+ const {
1024
+ currentTarget,
1025
+ pointerId
1026
+ } = event;
1027
+ const {
1028
+ right,
1029
+ left
1030
+ } = currentTarget.getBoundingClientRect();
1031
+ const offset = isRtl ? event.clientX - left : right - event.clientX;
1032
+ if (offset > 11) {
1033
+ return;
1034
+ }
1035
+ function onPointerMove(event2) {
1036
+ const {
1037
+ right: right2,
1038
+ left: left2
1039
+ } = currentTarget.getBoundingClientRect();
1040
+ const width = isRtl ? right2 + offset - event2.clientX : event2.clientX + offset - left2;
1041
+ if (width > 0) {
1042
+ onColumnResize(column, clampColumnWidth(width, column));
1043
+ }
1044
+ }
1045
+ function onLostPointerCapture() {
1046
+ currentTarget.removeEventListener("pointermove", onPointerMove);
1047
+ currentTarget.removeEventListener("lostpointercapture", onLostPointerCapture);
1048
+ }
1049
+ currentTarget.setPointerCapture(pointerId);
1050
+ currentTarget.addEventListener("pointermove", onPointerMove);
1051
+ currentTarget.addEventListener("lostpointercapture", onLostPointerCapture);
1052
+ }
1053
+ function onSort(ctrlClick) {
1054
+ if (onSortColumnsChange == null)
1055
+ return;
1056
+ const {
1057
+ sortDescendingFirst
1058
+ } = column;
1059
+ if (sortColumn === void 0) {
1060
+ const nextSort = {
1061
+ columnKey: column.key,
1062
+ direction: sortDescendingFirst ? "DESC" : "ASC"
1063
+ };
1064
+ onSortColumnsChange(sortColumns && ctrlClick ? [...sortColumns, nextSort] : [nextSort]);
1065
+ } else {
1066
+ let nextSortColumn;
1067
+ if (sortDescendingFirst && sortDirection === "DESC" || !sortDescendingFirst && sortDirection === "ASC") {
1068
+ nextSortColumn = {
1069
+ columnKey: column.key,
1070
+ direction: sortDirection === "ASC" ? "DESC" : "ASC"
1071
+ };
1072
+ }
1073
+ if (ctrlClick) {
1074
+ const nextSortColumns = [...sortColumns];
1075
+ if (nextSortColumn) {
1076
+ nextSortColumns[sortIndex] = nextSortColumn;
1077
+ } else {
1078
+ nextSortColumns.splice(sortIndex, 1);
1079
+ }
1080
+ onSortColumnsChange(nextSortColumns);
1081
+ } else {
1082
+ onSortColumnsChange(nextSortColumn ? [nextSortColumn] : []);
1083
+ }
1084
+ }
1085
+ }
1086
+ function onClick() {
1087
+ selectCell(column.idx);
1088
+ }
1089
+ function onDoubleClick(event) {
1090
+ const {
1091
+ right,
1092
+ left
1093
+ } = event.currentTarget.getBoundingClientRect();
1094
+ const offset = isRtl ? event.clientX - left : right - event.clientX;
1095
+ if (offset > 11) {
1096
+ return;
1097
+ }
1098
+ onColumnResize(column, "auto");
1099
+ }
1100
+ function handleFocus(event) {
1101
+ onFocus?.(event);
1102
+ if (shouldFocusGrid) {
1103
+ selectCell(0);
1104
+ }
1105
+ }
1106
+ return /* @__PURE__ */ jsx("div", {
1107
+ role: "columnheader",
1108
+ "aria-colindex": column.idx + 1,
1109
+ "aria-selected": isCellSelected,
1110
+ "aria-sort": ariaSort,
1111
+ "aria-colspan": colSpan,
1112
+ ref,
1113
+ tabIndex: shouldFocusGrid ? 0 : tabIndex,
1114
+ className,
1115
+ style: {
1116
+ ...getCellStyle(column, colSpan),
1117
+ minWidth: column.minWidth,
1118
+ maxWidth: column.maxWidth ?? void 0
1119
+ },
1120
+ onFocus: handleFocus,
1121
+ onClick,
1122
+ onDoubleClick: column.resizable ? onDoubleClick : void 0,
1123
+ onPointerDown: column.resizable ? onPointerDown : void 0,
1124
+ children: /* @__PURE__ */ jsx(HeaderRenderer$1, {
1125
+ column,
1126
+ sortDirection,
1127
+ priority,
1128
+ onSort,
1129
+ allRowsSelected,
1130
+ onAllRowsSelectionChange,
1131
+ isCellSelected
1132
+ })
1133
+ });
1134
+ }
1135
+ var css_248z$8 = ".h197vzie700-beta13{background-color:var(--rdg-header-background-color);display:contents;font-weight:700;line-height:var(--rdg-header-row-height)}.h197vzie700-beta13>.c1wupbe700-beta13{inset-block-start:0;position:sticky;z-index:2}.h197vzie700-beta13>.c1730fa4700-beta13{z-index:3}";
1136
+ styleInject(css_248z$8, { "insertAt": "top" });
1137
+ const headerRow = "h197vzie700-beta13";
1138
+ const headerRowClassname = `rdg-header-row ${headerRow}`;
1139
+ function HeaderRow({
1140
+ columns,
1141
+ allRowsSelected,
1142
+ onAllRowsSelectionChange,
1143
+ onColumnResize,
1144
+ sortColumns,
1145
+ onSortColumnsChange,
1146
+ lastFrozenColumnIndex,
1147
+ selectedCellIdx,
1148
+ selectCell,
1149
+ shouldFocusGrid,
1150
+ direction
1151
+ }) {
1152
+ const cells = [];
1153
+ for (let index = 0; index < columns.length; index++) {
1154
+ const column = columns[index];
1155
+ const colSpan = getColSpan(column, lastFrozenColumnIndex, {
1156
+ type: "HEADER"
1157
+ });
1158
+ if (colSpan !== void 0) {
1159
+ index += colSpan - 1;
1160
+ }
1161
+ cells.push(/* @__PURE__ */ jsx(HeaderCell, {
1162
+ column,
1163
+ colSpan,
1164
+ isCellSelected: selectedCellIdx === column.idx,
1165
+ onColumnResize,
1166
+ allRowsSelected,
1167
+ onAllRowsSelectionChange,
1168
+ onSortColumnsChange,
1169
+ sortColumns,
1170
+ selectCell,
1171
+ shouldFocusGrid: shouldFocusGrid && index === 0,
1172
+ direction
1173
+ }, column.key));
1174
+ }
1175
+ return /* @__PURE__ */ jsx("div", {
1176
+ role: "row",
1177
+ "aria-rowindex": 1,
1178
+ className: clsx(headerRowClassname, selectedCellIdx === -1 && rowSelectedClassname),
1179
+ style: getRowStyle(1),
1180
+ children: cells
1181
+ });
1182
+ }
1183
+ const HeaderRow$1 = /* @__PURE__ */ memo(HeaderRow);
1184
+ var css_248z$7 = ".c1bmg16t700-beta13,.ccpfvsn700-beta13{background-color:#ccf}.c1bmg16t700-beta13.ccpfvsn700-beta13{background-color:#99f}";
1185
+ styleInject(css_248z$7, { "insertAt": "top" });
1186
+ const cellCopied = "ccpfvsn700-beta13";
1187
+ const cellCopiedClassname = `rdg-cell-copied ${cellCopied}`;
1188
+ const cellDraggedOver = "c1bmg16t700-beta13";
1189
+ const cellDraggedOverClassname = `rdg-cell-dragged-over ${cellDraggedOver}`;
1190
+ function Cell({
1191
+ column,
1192
+ colSpan,
1193
+ isCellSelected,
1194
+ isCopied,
1195
+ isDraggedOver,
1196
+ row: row2,
1197
+ dragHandle,
1198
+ onRowClick,
1199
+ onRowDoubleClick,
1200
+ onRowChange,
1201
+ selectCell,
1202
+ ...props
1203
+ }) {
1204
+ const {
1205
+ ref,
1206
+ tabIndex,
1207
+ onFocus
1208
+ } = useRovingCellRef(isCellSelected);
1209
+ const {
1210
+ cellClass
1211
+ } = column;
1212
+ const className = getCellClassname(column, typeof cellClass === "function" ? cellClass(row2) : cellClass, isCopied && cellCopiedClassname, isDraggedOver && cellDraggedOverClassname);
1213
+ function selectCellWrapper(openEditor) {
1214
+ selectCell(row2, column, openEditor);
1215
+ }
1216
+ function handleClick() {
1217
+ selectCellWrapper(column.editorOptions?.editOnClick);
1218
+ onRowClick?.(row2, column);
1219
+ }
1220
+ function handleContextMenu() {
1221
+ selectCellWrapper();
1222
+ }
1223
+ function handleDoubleClick() {
1224
+ selectCellWrapper(true);
1225
+ onRowDoubleClick?.(row2, column);
1226
+ }
1227
+ return /* @__PURE__ */ jsx("div", {
1228
+ role: "gridcell",
1229
+ "aria-colindex": column.idx + 1,
1230
+ "aria-selected": isCellSelected,
1231
+ "aria-colspan": colSpan,
1232
+ "aria-readonly": !isCellEditable(column, row2) || void 0,
1233
+ ref,
1234
+ tabIndex,
1235
+ className,
1236
+ style: getCellStyle(column, colSpan),
1237
+ onClick: handleClick,
1238
+ onDoubleClick: handleDoubleClick,
1239
+ onContextMenu: handleContextMenu,
1240
+ onFocus,
1241
+ ...props,
1242
+ children: !column.rowGroup && /* @__PURE__ */ jsxs(Fragment, {
1243
+ children: [/* @__PURE__ */ jsx(column.formatter, {
1244
+ column,
1245
+ row: row2,
1246
+ isCellSelected,
1247
+ onRowChange
1248
+ }), dragHandle]
1249
+ })
1250
+ });
1251
+ }
1252
+ const Cell$1 = /* @__PURE__ */ memo(Cell);
1253
+ function Row({
1254
+ className,
1255
+ rowIdx,
1256
+ gridRowStart,
1257
+ height,
1258
+ selectedCellIdx,
1259
+ isRowSelected,
1260
+ copiedCellIdx,
1261
+ draggedOverCellIdx,
1262
+ lastFrozenColumnIndex,
1263
+ row: row2,
1264
+ viewportColumns,
1265
+ selectedCellEditor,
1266
+ selectedCellDragHandle,
1267
+ onRowClick,
1268
+ onRowDoubleClick,
1269
+ rowClass,
1270
+ setDraggedOverRowIdx,
1271
+ onMouseEnter,
1272
+ onRowChange,
1273
+ selectCell,
1274
+ ...props
1275
+ }, ref) {
1276
+ const handleRowChange = useLatestFunc((newRow) => {
1277
+ onRowChange(rowIdx, newRow);
1278
+ });
1279
+ function handleDragEnter(event) {
1280
+ setDraggedOverRowIdx?.(rowIdx);
1281
+ onMouseEnter?.(event);
1282
+ }
1283
+ className = clsx(rowClassname, `rdg-row-${rowIdx % 2 === 0 ? "even" : "odd"}`, rowClass?.(row2), className, selectedCellIdx === -1 && rowSelectedClassname);
1284
+ const cells = [];
1285
+ for (let index = 0; index < viewportColumns.length; index++) {
1286
+ const column = viewportColumns[index];
1287
+ const {
1288
+ idx
1289
+ } = column;
1290
+ const colSpan = getColSpan(column, lastFrozenColumnIndex, {
1291
+ type: "ROW",
1292
+ row: row2
1293
+ });
1294
+ if (colSpan !== void 0) {
1295
+ index += colSpan - 1;
1296
+ }
1297
+ const isCellSelected = selectedCellIdx === idx;
1298
+ if (isCellSelected && selectedCellEditor) {
1299
+ cells.push(selectedCellEditor);
1300
+ } else {
1301
+ cells.push(/* @__PURE__ */ jsx(Cell$1, {
1302
+ column,
1303
+ colSpan,
1304
+ row: row2,
1305
+ isCopied: copiedCellIdx === idx,
1306
+ isDraggedOver: draggedOverCellIdx === idx,
1307
+ isCellSelected,
1308
+ dragHandle: isCellSelected ? selectedCellDragHandle : void 0,
1309
+ onRowClick,
1310
+ onRowDoubleClick,
1311
+ onRowChange: handleRowChange,
1312
+ selectCell
1313
+ }, column.key));
1314
+ }
1315
+ }
1316
+ return /* @__PURE__ */ jsx(RowSelectionProvider, {
1317
+ value: isRowSelected,
1318
+ children: /* @__PURE__ */ jsx("div", {
1319
+ role: "row",
1320
+ ref,
1321
+ className,
1322
+ onMouseEnter: handleDragEnter,
1323
+ style: getRowStyle(gridRowStart, height),
1324
+ ...props,
1325
+ children: cells
1326
+ })
1327
+ });
1328
+ }
1329
+ const Row$1 = /* @__PURE__ */ memo(/* @__PURE__ */ forwardRef(Row));
1330
+ function GroupCell({
1331
+ id,
1332
+ groupKey,
1333
+ childRows,
1334
+ isExpanded,
1335
+ isCellSelected,
1336
+ column,
1337
+ row: row2,
1338
+ groupColumnIndex,
1339
+ toggleGroup: toggleGroupWrapper
1340
+ }) {
1341
+ const {
1342
+ ref,
1343
+ tabIndex,
1344
+ onFocus
1345
+ } = useRovingCellRef(isCellSelected);
1346
+ function toggleGroup() {
1347
+ toggleGroupWrapper(id);
1348
+ }
1349
+ const isLevelMatching = column.rowGroup && groupColumnIndex === column.idx;
1350
+ return /* @__PURE__ */ jsx("div", {
1351
+ role: "gridcell",
1352
+ "aria-colindex": column.idx + 1,
1353
+ "aria-selected": isCellSelected,
1354
+ ref,
1355
+ tabIndex,
1356
+ className: getCellClassname(column),
1357
+ style: {
1358
+ ...getCellStyle(column),
1359
+ cursor: isLevelMatching ? "pointer" : "default"
1360
+ },
1361
+ onClick: isLevelMatching ? toggleGroup : void 0,
1362
+ onFocus,
1363
+ children: (!column.rowGroup || groupColumnIndex === column.idx) && column.groupFormatter && /* @__PURE__ */ jsx(column.groupFormatter, {
1364
+ groupKey,
1365
+ childRows,
1366
+ column,
1367
+ row: row2,
1368
+ isExpanded,
1369
+ isCellSelected,
1370
+ toggleGroup
1371
+ })
1372
+ }, column.key);
1373
+ }
1374
+ const GroupCell$1 = /* @__PURE__ */ memo(GroupCell);
1375
+ var css_248z$6 = ".gyxx7e9700-beta13:not([aria-selected=true]){background-color:var(--rdg-header-background-color)}.gyxx7e9700-beta13>.c1wupbe700-beta13:not(:last-child):not(.c9dpaye700-beta13){border-inline-end:none}";
1376
+ styleInject(css_248z$6, { "insertAt": "top" });
1377
+ const groupRow = "gyxx7e9700-beta13";
1378
+ const groupRowClassname = `rdg-group-row ${groupRow}`;
1379
+ function GroupedRow({
1380
+ id,
1381
+ groupKey,
1382
+ viewportColumns,
1383
+ childRows,
1384
+ rowIdx,
1385
+ row: row2,
1386
+ gridRowStart,
1387
+ height,
1388
+ level,
1389
+ isExpanded,
1390
+ selectedCellIdx,
1391
+ isRowSelected,
1392
+ selectGroup,
1393
+ toggleGroup,
1394
+ ...props
1395
+ }) {
1396
+ const idx = viewportColumns[0].key === SELECT_COLUMN_KEY ? level + 1 : level;
1397
+ function handleSelectGroup() {
1398
+ selectGroup(rowIdx);
1399
+ }
1400
+ return /* @__PURE__ */ jsx(RowSelectionProvider, {
1401
+ value: isRowSelected,
1402
+ children: /* @__PURE__ */ jsx("div", {
1403
+ role: "row",
1404
+ "aria-level": level,
1405
+ "aria-expanded": isExpanded,
1406
+ className: clsx(rowClassname, groupRowClassname, `rdg-row-${rowIdx % 2 === 0 ? "even" : "odd"}`, selectedCellIdx === -1 && rowSelectedClassname),
1407
+ onClick: handleSelectGroup,
1408
+ style: getRowStyle(gridRowStart, height),
1409
+ ...props,
1410
+ children: viewportColumns.map((column) => /* @__PURE__ */ jsx(GroupCell$1, {
1411
+ id,
1412
+ groupKey,
1413
+ childRows,
1414
+ isExpanded,
1415
+ isCellSelected: selectedCellIdx === column.idx,
1416
+ column,
1417
+ row: row2,
1418
+ groupColumnIndex: idx,
1419
+ toggleGroup
1420
+ }, column.key))
1421
+ })
1422
+ });
1423
+ }
1424
+ const GroupRowRenderer = /* @__PURE__ */ memo(GroupedRow);
1425
+ var css_248z$5 = ".s1n3hxke700-beta13{inset-block-end:var(--rdg-summary-row-bottom);inset-block-start:var(--rdg-summary-row-top)}";
1426
+ styleInject(css_248z$5, { "insertAt": "top" });
1427
+ const summaryCellClassname = "s1n3hxke700-beta13";
1428
+ function SummaryCell({
1429
+ column,
1430
+ colSpan,
1431
+ row: row2,
1432
+ isCellSelected,
1433
+ selectCell
1434
+ }) {
1435
+ const {
1436
+ ref,
1437
+ tabIndex,
1438
+ onFocus
1439
+ } = useRovingCellRef(isCellSelected);
1440
+ const {
1441
+ summaryFormatter: SummaryFormatter,
1442
+ summaryCellClass
1443
+ } = column;
1444
+ const className = getCellClassname(column, summaryCellClassname, typeof summaryCellClass === "function" ? summaryCellClass(row2) : summaryCellClass);
1445
+ function onClick() {
1446
+ selectCell(row2, column);
1447
+ }
1448
+ return /* @__PURE__ */ jsx("div", {
1449
+ role: "gridcell",
1450
+ "aria-colindex": column.idx + 1,
1451
+ "aria-colspan": colSpan,
1452
+ "aria-selected": isCellSelected,
1453
+ ref,
1454
+ tabIndex,
1455
+ className,
1456
+ style: getCellStyle(column, colSpan),
1457
+ onClick,
1458
+ onFocus,
1459
+ children: SummaryFormatter && /* @__PURE__ */ jsx(SummaryFormatter, {
1460
+ column,
1461
+ row: row2,
1462
+ isCellSelected
1463
+ })
1464
+ });
1465
+ }
1466
+ const SummaryCell$1 = /* @__PURE__ */ memo(SummaryCell);
1467
+ var css_248z$4 = ".snfqesz700-beta13.r1otpg64700-beta13{line-height:var(--rdg-summary-row-height)}.snfqesz700-beta13.r1otpg64700-beta13>.c1wupbe700-beta13{position:sticky}.s1jijrjz700-beta13>.c1wupbe700-beta13{border-block-start:2px solid var(--rdg-summary-border-color)}";
1468
+ styleInject(css_248z$4, { "insertAt": "top" });
1469
+ const summaryRow = "snfqesz700-beta13";
1470
+ const summaryRowBorderClassname = "s1jijrjz700-beta13";
1471
+ const summaryRowClassname = `rdg-summary-row ${summaryRow}`;
1472
+ function SummaryRow({
1473
+ rowIdx,
1474
+ gridRowStart,
1475
+ row: row2,
1476
+ viewportColumns,
1477
+ top,
1478
+ bottom,
1479
+ lastFrozenColumnIndex,
1480
+ selectedCellIdx,
1481
+ selectCell,
1482
+ "aria-rowindex": ariaRowIndex
1483
+ }) {
1484
+ const cells = [];
1485
+ for (let index = 0; index < viewportColumns.length; index++) {
1486
+ const column = viewportColumns[index];
1487
+ const colSpan = getColSpan(column, lastFrozenColumnIndex, {
1488
+ type: "SUMMARY",
1489
+ row: row2
1490
+ });
1491
+ if (colSpan !== void 0) {
1492
+ index += colSpan - 1;
1493
+ }
1494
+ const isCellSelected = selectedCellIdx === column.idx;
1495
+ cells.push(/* @__PURE__ */ jsx(SummaryCell$1, {
1496
+ column,
1497
+ colSpan,
1498
+ row: row2,
1499
+ isCellSelected,
1500
+ selectCell
1501
+ }, column.key));
1502
+ }
1503
+ return /* @__PURE__ */ jsx("div", {
1504
+ role: "row",
1505
+ "aria-rowindex": ariaRowIndex,
1506
+ className: clsx(rowClassname, `rdg-row-${rowIdx % 2 === 0 ? "even" : "odd"}`, summaryRowClassname, rowIdx === 0 && summaryRowBorderClassname, selectedCellIdx === -1 && rowSelectedClassname),
1507
+ style: {
1508
+ ...getRowStyle(gridRowStart),
1509
+ "--rdg-summary-row-top": top !== void 0 ? `${top}px` : void 0,
1510
+ "--rdg-summary-row-bottom": bottom !== void 0 ? `${bottom}px` : void 0
1511
+ },
1512
+ children: cells
1513
+ });
1514
+ }
1515
+ const SummaryRow$1 = /* @__PURE__ */ memo(SummaryRow);
1516
+ var css_248z$3 = ".c1tngyp1700-beta13.rdg-cell{padding:0}";
1517
+ styleInject(css_248z$3, { "insertAt": "top" });
1518
+ const cellEditing = "c1tngyp1700-beta13";
1519
+ function EditCell({
1520
+ column,
1521
+ colSpan,
1522
+ row: row2,
1523
+ onRowChange,
1524
+ closeEditor
1525
+ }) {
1526
+ const frameRequestRef = useRef();
1527
+ const commitOnOutsideClick = column.editorOptions?.commitOnOutsideClick !== false;
1528
+ const commitOnOutsideMouseDown = useLatestFunc(() => {
1529
+ onClose(true);
1530
+ });
1531
+ useEffect(() => {
1532
+ if (!commitOnOutsideClick)
1533
+ return;
1534
+ function onWindowCaptureMouseDown() {
1535
+ frameRequestRef.current = requestAnimationFrame(commitOnOutsideMouseDown);
1536
+ }
1537
+ addEventListener("mousedown", onWindowCaptureMouseDown, {
1538
+ capture: true
1539
+ });
1540
+ return () => {
1541
+ removeEventListener("mousedown", onWindowCaptureMouseDown, {
1542
+ capture: true
1543
+ });
1544
+ cancelFrameRequest();
1545
+ };
1546
+ }, [commitOnOutsideClick, commitOnOutsideMouseDown]);
1547
+ function cancelFrameRequest() {
1548
+ cancelAnimationFrame(frameRequestRef.current);
1549
+ }
1550
+ function onKeyDown(event) {
1551
+ if (event.key === "Escape") {
1552
+ event.stopPropagation();
1553
+ onClose();
1554
+ } else if (event.key === "Enter") {
1555
+ event.stopPropagation();
1556
+ onClose(true);
1557
+ } else {
1558
+ const onNavigation = column.editorOptions?.onNavigation ?? onEditorNavigation;
1559
+ if (!onNavigation(event)) {
1560
+ event.stopPropagation();
1561
+ }
1562
+ }
1563
+ }
1564
+ function onClose(commitChanges) {
1565
+ if (commitChanges) {
1566
+ onRowChange(row2, true);
1567
+ } else {
1568
+ closeEditor();
1569
+ }
1570
+ }
1571
+ const {
1572
+ cellClass
1573
+ } = column;
1574
+ const className = getCellClassname(column, "rdg-editor-container", typeof cellClass === "function" ? cellClass(row2) : cellClass, !column.editorOptions?.renderFormatter && cellEditing);
1575
+ return /* @__PURE__ */ jsx("div", {
1576
+ role: "gridcell",
1577
+ "aria-colindex": column.idx + 1,
1578
+ "aria-colspan": colSpan,
1579
+ "aria-selected": true,
1580
+ className,
1581
+ style: getCellStyle(column, colSpan),
1582
+ onKeyDown,
1583
+ onMouseDownCapture: commitOnOutsideClick ? cancelFrameRequest : void 0,
1584
+ children: column.editor != null && /* @__PURE__ */ jsxs(Fragment, {
1585
+ children: [/* @__PURE__ */ jsx(column.editor, {
1586
+ column,
1587
+ row: row2,
1588
+ onRowChange,
1589
+ onClose
1590
+ }), column.editorOptions?.renderFormatter && /* @__PURE__ */ jsx(column.formatter, {
1591
+ column,
1592
+ row: row2,
1593
+ isCellSelected: true,
1594
+ onRowChange
1595
+ })]
1596
+ })
1597
+ });
1598
+ }
1599
+ var css_248z$2 = ".cadd3bp700-beta13{background-color:var(--rdg-selection-color);block-size:8px;cursor:move;inline-size:8px;inset-block-end:0;inset-inline-end:0;position:absolute}.cadd3bp700-beta13:hover{background-color:var(--rdg-background-color);block-size:16px;border:2px solid var(--rdg-selection-color);inline-size:16px}";
1600
+ styleInject(css_248z$2, { "insertAt": "top" });
1601
+ const cellDragHandle = "cadd3bp700-beta13";
1602
+ const cellDragHandleClassname = `rdg-cell-drag-handle ${cellDragHandle}`;
1603
+ function DragHandle({
1604
+ rows,
1605
+ columns,
1606
+ selectedPosition,
1607
+ latestDraggedOverRowIdx,
1608
+ isCellEditable: isCellEditable2,
1609
+ onRowsChange,
1610
+ onFill,
1611
+ setDragging,
1612
+ setDraggedOverRowIdx
1613
+ }) {
1614
+ function handleMouseDown(event) {
1615
+ if (event.buttons !== 1)
1616
+ return;
1617
+ setDragging(true);
1618
+ window.addEventListener("mouseover", onMouseOver);
1619
+ window.addEventListener("mouseup", onMouseUp);
1620
+ function onMouseOver(event2) {
1621
+ if (event2.buttons !== 1)
1622
+ onMouseUp();
1623
+ }
1624
+ function onMouseUp() {
1625
+ window.removeEventListener("mouseover", onMouseOver);
1626
+ window.removeEventListener("mouseup", onMouseUp);
1627
+ setDragging(false);
1628
+ handleDragEnd();
1629
+ }
1630
+ }
1631
+ function handleDragEnd() {
1632
+ const overRowIdx = latestDraggedOverRowIdx.current;
1633
+ if (overRowIdx === void 0)
1634
+ return;
1635
+ const {
1636
+ rowIdx
1637
+ } = selectedPosition;
1638
+ const startRowIndex = rowIdx < overRowIdx ? rowIdx + 1 : overRowIdx;
1639
+ const endRowIndex = rowIdx < overRowIdx ? overRowIdx + 1 : rowIdx;
1640
+ updateRows(startRowIndex, endRowIndex);
1641
+ setDraggedOverRowIdx(void 0);
1642
+ }
1643
+ function handleDoubleClick(event) {
1644
+ event.stopPropagation();
1645
+ updateRows(selectedPosition.rowIdx + 1, rows.length);
1646
+ }
1647
+ function updateRows(startRowIdx, endRowIdx) {
1648
+ const {
1649
+ idx,
1650
+ rowIdx
1651
+ } = selectedPosition;
1652
+ const column = columns[idx];
1653
+ const sourceRow = rows[rowIdx];
1654
+ const updatedRows = [...rows];
1655
+ const indexes = [];
1656
+ for (let i = startRowIdx; i < endRowIdx; i++) {
1657
+ if (isCellEditable2({
1658
+ rowIdx: i,
1659
+ idx
1660
+ })) {
1661
+ const updatedRow = onFill({
1662
+ columnKey: column.key,
1663
+ sourceRow,
1664
+ targetRow: rows[i]
1665
+ });
1666
+ if (updatedRow !== rows[i]) {
1667
+ updatedRows[i] = updatedRow;
1668
+ indexes.push(i);
1669
+ }
1670
+ }
1671
+ }
1672
+ if (indexes.length > 0) {
1673
+ onRowsChange?.(updatedRows, {
1674
+ indexes,
1675
+ column
1676
+ });
1677
+ }
1678
+ }
1679
+ return /* @__PURE__ */ jsx("div", {
1680
+ className: cellDragHandleClassname,
1681
+ onMouseDown: handleMouseDown,
1682
+ onDoubleClick: handleDoubleClick
1683
+ });
1684
+ }
1685
+ var css_248z$1 = ".a888944700-beta13{fill:currentColor}.a888944700-beta13>path{transition:d .1s}";
1686
+ styleInject(css_248z$1, { "insertAt": "top" });
1687
+ const arrow = "a888944700-beta13";
1688
+ const arrowClassname = `rdg-sort-arrow ${arrow}`;
1689
+ function SortIcon({
1690
+ sortDirection
1691
+ }) {
1692
+ return sortDirection !== void 0 ? /* @__PURE__ */ jsx("svg", {
1693
+ viewBox: "0 0 12 8",
1694
+ width: "12",
1695
+ height: "8",
1696
+ className: arrowClassname,
1697
+ "aria-hidden": true,
1698
+ children: /* @__PURE__ */ jsx("path", {
1699
+ d: sortDirection === "ASC" ? "M0 8 6 0 12 8" : "M0 0 6 8 12 0"
1700
+ })
1701
+ }) : null;
1702
+ }
1703
+ const initialPosition = {
1704
+ idx: -1,
1705
+ rowIdx: -2,
1706
+ mode: "SELECT"
1707
+ };
1708
+ function DataGrid({
1709
+ columns: rawColumns,
1710
+ rows: rawRows,
1711
+ summaryRows,
1712
+ rowKeyGetter,
1713
+ onRowsChange,
1714
+ rowHeight,
1715
+ headerRowHeight: rawHeaderRowHeight,
1716
+ summaryRowHeight: rawSummaryRowHeight,
1717
+ selectedRows,
1718
+ onSelectedRowsChange,
1719
+ sortColumns,
1720
+ onSortColumnsChange,
1721
+ defaultColumnOptions,
1722
+ groupBy: rawGroupBy,
1723
+ rowGrouper,
1724
+ expandedGroupIds,
1725
+ onExpandedGroupIdsChange,
1726
+ onRowClick,
1727
+ onRowDoubleClick,
1728
+ onScroll,
1729
+ onColumnResize,
1730
+ onFill,
1731
+ onCopy,
1732
+ onPaste,
1733
+ cellNavigationMode: rawCellNavigationMode,
1734
+ enableVirtualization,
1735
+ components,
1736
+ className,
1737
+ style,
1738
+ rowClass,
1739
+ direction,
1740
+ "aria-label": ariaLabel,
1741
+ "aria-labelledby": ariaLabelledBy,
1742
+ "aria-describedby": ariaDescribedBy,
1743
+ "data-testid": testId
1744
+ }, ref) {
1745
+ const defaultComponents = useDefaultComponents();
1746
+ rowHeight ?? (rowHeight = 35);
1747
+ const headerRowHeight = rawHeaderRowHeight ?? (typeof rowHeight === "number" ? rowHeight : 35);
1748
+ const summaryRowHeight = rawSummaryRowHeight ?? (typeof rowHeight === "number" ? rowHeight : 35);
1749
+ const RowRenderer = components?.rowRenderer ?? defaultComponents?.rowRenderer ?? Row$1;
1750
+ const sortIcon = components?.sortIcon ?? defaultComponents?.sortIcon ?? SortIcon;
1751
+ const checkboxFormatter = components?.checkboxFormatter ?? defaultComponents?.checkboxFormatter ?? CheckboxFormatter;
1752
+ const noRowsFallback = components?.noRowsFallback ?? defaultComponents?.noRowsFallback;
1753
+ const cellNavigationMode = rawCellNavigationMode ?? "NONE";
1754
+ enableVirtualization ?? (enableVirtualization = true);
1755
+ direction ?? (direction = "ltr");
1756
+ const [scrollTop, setScrollTop] = useState(0);
1757
+ const [scrollLeft, setScrollLeft] = useState(0);
1758
+ const [columnWidths, setColumnWidths] = useState(() => /* @__PURE__ */ new Map());
1759
+ const [selectedPosition, setSelectedPosition] = useState(initialPosition);
1760
+ const [copiedCell, setCopiedCell] = useState(null);
1761
+ const [isDragging, setDragging] = useState(false);
1762
+ const [draggedOverRowIdx, setOverRowIdx] = useState(void 0);
1763
+ const [autoResizeColumn, setAutoResizeColumn] = useState(null);
1764
+ const prevSelectedPosition = useRef(selectedPosition);
1765
+ const latestDraggedOverRowIdx = useRef(draggedOverRowIdx);
1766
+ const lastSelectedRowIdx = useRef(-1);
1767
+ const rowRef = useRef(null);
1768
+ const [gridRef, gridWidth, gridHeight] = useGridDimensions();
1769
+ const headerRowsCount = 1;
1770
+ const summaryRowsCount = summaryRows?.length ?? 0;
1771
+ const clientHeight = gridHeight - headerRowHeight - summaryRowsCount * summaryRowHeight;
1772
+ const isSelectable = selectedRows != null && onSelectedRowsChange != null;
1773
+ const isHeaderRowSelected = selectedPosition.rowIdx === -1;
1774
+ const isRtl = direction === "rtl";
1775
+ const leftKey = isRtl ? "ArrowRight" : "ArrowLeft";
1776
+ const rightKey = isRtl ? "ArrowLeft" : "ArrowRight";
1777
+ const defaultGridComponents = useMemo(() => ({
1778
+ sortIcon,
1779
+ checkboxFormatter
1780
+ }), [sortIcon, checkboxFormatter]);
1781
+ const allRowsSelected = useMemo(() => {
1782
+ const {
1783
+ length
1784
+ } = rawRows;
1785
+ return length !== 0 && selectedRows != null && rowKeyGetter != null && selectedRows.size >= length && rawRows.every((row2) => selectedRows.has(rowKeyGetter(row2)));
1786
+ }, [rawRows, selectedRows, rowKeyGetter]);
1787
+ const {
1788
+ columns,
1789
+ colSpanColumns,
1790
+ colOverscanStartIdx,
1791
+ colOverscanEndIdx,
1792
+ layoutCssVars,
1793
+ columnMetrics,
1794
+ lastFrozenColumnIndex,
1795
+ totalFrozenColumnWidth,
1796
+ groupBy
1797
+ } = useCalculatedColumns({
1798
+ rawColumns,
1799
+ columnWidths,
1800
+ scrollLeft,
1801
+ viewportWidth: gridWidth,
1802
+ defaultColumnOptions,
1803
+ rawGroupBy: rowGrouper ? rawGroupBy : void 0,
1804
+ enableVirtualization
1805
+ });
1806
+ const {
1807
+ rowOverscanStartIdx,
1808
+ rowOverscanEndIdx,
1809
+ rows,
1810
+ rowsCount,
1811
+ totalRowHeight,
1812
+ gridTemplateRows,
1813
+ isGroupRow,
1814
+ getRowTop,
1815
+ getRowHeight,
1816
+ findRowIdx
1817
+ } = useViewportRows({
1818
+ rawRows,
1819
+ groupBy,
1820
+ rowGrouper,
1821
+ rowHeight,
1822
+ clientHeight,
1823
+ scrollTop,
1824
+ expandedGroupIds,
1825
+ enableVirtualization
1826
+ });
1827
+ const viewportColumns = useViewportColumns({
1828
+ columns,
1829
+ colSpanColumns,
1830
+ colOverscanStartIdx,
1831
+ colOverscanEndIdx,
1832
+ lastFrozenColumnIndex,
1833
+ rowOverscanStartIdx,
1834
+ rowOverscanEndIdx,
1835
+ rows,
1836
+ summaryRows,
1837
+ isGroupRow
1838
+ });
1839
+ const hasGroups = groupBy.length > 0 && typeof rowGrouper === "function";
1840
+ const minColIdx = hasGroups ? -1 : 0;
1841
+ const maxColIdx = columns.length - 1;
1842
+ const minRowIdx = -1;
1843
+ const maxRowIdx = headerRowsCount + rows.length + summaryRowsCount - 2;
1844
+ const selectedCellIsWithinSelectionBounds = isCellWithinSelectionBounds(selectedPosition);
1845
+ const selectedCellIsWithinViewportBounds = isCellWithinViewportBounds(selectedPosition);
1846
+ const selectRowLatest = useLatestFunc(selectRow);
1847
+ const selectAllRowsLatest = useLatestFunc(selectAllRows);
1848
+ const handleFormatterRowChangeLatest = useLatestFunc(updateRow);
1849
+ const selectViewportCellLatest = useLatestFunc((row2, column, enableEditor) => {
1850
+ const rowIdx = rows.indexOf(row2);
1851
+ selectCell({
1852
+ rowIdx,
1853
+ idx: column.idx
1854
+ }, enableEditor);
1855
+ });
1856
+ const selectGroupLatest = useLatestFunc((rowIdx) => {
1857
+ selectCell({
1858
+ rowIdx,
1859
+ idx: -1
1860
+ });
1861
+ });
1862
+ const selectHeaderCellLatest = useLatestFunc((idx) => {
1863
+ selectCell({
1864
+ rowIdx: -1,
1865
+ idx
1866
+ });
1867
+ });
1868
+ const selectSummaryCellLatest = useLatestFunc((summaryRow2, column) => {
1869
+ const rowIdx = summaryRows.indexOf(summaryRow2) + headerRowsCount + rows.length - 1;
1870
+ selectCell({
1871
+ rowIdx,
1872
+ idx: column.idx
1873
+ });
1874
+ });
1875
+ const toggleGroupLatest = useLatestFunc(toggleGroup);
1876
+ useLayoutEffect(() => {
1877
+ if (!selectedCellIsWithinSelectionBounds || isSamePosition(selectedPosition, prevSelectedPosition.current)) {
1878
+ prevSelectedPosition.current = selectedPosition;
1879
+ return;
1880
+ }
1881
+ prevSelectedPosition.current = selectedPosition;
1882
+ if (selectedPosition.idx === -1) {
1883
+ rowRef.current.focus({
1884
+ preventScroll: true
1885
+ });
1886
+ scrollIntoView(rowRef.current);
1887
+ }
1888
+ });
1889
+ useLayoutEffect(() => {
1890
+ if (autoResizeColumn === null)
1891
+ return;
1892
+ const columnElement = gridRef.current.querySelector(`[aria-colindex="${autoResizeColumn.idx + 1}"]`);
1893
+ const {
1894
+ width
1895
+ } = columnElement.getBoundingClientRect();
1896
+ setColumnWidths((columnWidths2) => {
1897
+ const newColumnWidths = new Map(columnWidths2);
1898
+ newColumnWidths.set(autoResizeColumn.key, width);
1899
+ return newColumnWidths;
1900
+ });
1901
+ setAutoResizeColumn(null);
1902
+ onColumnResize?.(autoResizeColumn.idx, width);
1903
+ }, [autoResizeColumn, gridRef, onColumnResize]);
1904
+ useImperativeHandle(ref, () => ({
1905
+ element: gridRef.current,
1906
+ scrollToColumn,
1907
+ scrollToRow(rowIdx) {
1908
+ const {
1909
+ current
1910
+ } = gridRef;
1911
+ if (!current)
1912
+ return;
1913
+ current.scrollTo({
1914
+ top: getRowTop(rowIdx),
1915
+ behavior: "smooth"
1916
+ });
1917
+ },
1918
+ selectCell
1919
+ }));
1920
+ const handleColumnResize = useCallback((column, width) => {
1921
+ if (width === "auto") {
1922
+ setAutoResizeColumn(column);
1923
+ return;
1924
+ }
1925
+ setColumnWidths((columnWidths2) => {
1926
+ const newColumnWidths = new Map(columnWidths2);
1927
+ newColumnWidths.set(column.key, width);
1928
+ return newColumnWidths;
1929
+ });
1930
+ onColumnResize?.(column.idx, width);
1931
+ }, [onColumnResize]);
1932
+ const setDraggedOverRowIdx = useCallback((rowIdx) => {
1933
+ setOverRowIdx(rowIdx);
1934
+ latestDraggedOverRowIdx.current = rowIdx;
1935
+ }, []);
1936
+ function selectRow({
1937
+ row: row2,
1938
+ checked,
1939
+ isShiftClick
1940
+ }) {
1941
+ if (!onSelectedRowsChange)
1942
+ return;
1943
+ assertIsValidKeyGetter(rowKeyGetter);
1944
+ const newSelectedRows = new Set(selectedRows);
1945
+ if (isGroupRow(row2)) {
1946
+ for (const childRow of row2.childRows) {
1947
+ const rowKey2 = rowKeyGetter(childRow);
1948
+ if (checked) {
1949
+ newSelectedRows.add(rowKey2);
1950
+ } else {
1951
+ newSelectedRows.delete(rowKey2);
1952
+ }
1953
+ }
1954
+ onSelectedRowsChange(newSelectedRows);
1955
+ return;
1956
+ }
1957
+ const rowKey = rowKeyGetter(row2);
1958
+ if (checked) {
1959
+ newSelectedRows.add(rowKey);
1960
+ const previousRowIdx = lastSelectedRowIdx.current;
1961
+ const rowIdx = rows.indexOf(row2);
1962
+ lastSelectedRowIdx.current = rowIdx;
1963
+ if (isShiftClick && previousRowIdx !== -1 && previousRowIdx !== rowIdx) {
1964
+ const step = sign(rowIdx - previousRowIdx);
1965
+ for (let i = previousRowIdx + step; i !== rowIdx; i += step) {
1966
+ const row3 = rows[i];
1967
+ if (isGroupRow(row3))
1968
+ continue;
1969
+ newSelectedRows.add(rowKeyGetter(row3));
1970
+ }
1971
+ }
1972
+ } else {
1973
+ newSelectedRows.delete(rowKey);
1974
+ lastSelectedRowIdx.current = -1;
1975
+ }
1976
+ onSelectedRowsChange(newSelectedRows);
1977
+ }
1978
+ function selectAllRows(checked) {
1979
+ if (!onSelectedRowsChange)
1980
+ return;
1981
+ assertIsValidKeyGetter(rowKeyGetter);
1982
+ const newSelectedRows = new Set(selectedRows);
1983
+ for (const row2 of rawRows) {
1984
+ const rowKey = rowKeyGetter(row2);
1985
+ if (checked) {
1986
+ newSelectedRows.add(rowKey);
1987
+ } else {
1988
+ newSelectedRows.delete(rowKey);
1989
+ }
1990
+ }
1991
+ onSelectedRowsChange(newSelectedRows);
1992
+ }
1993
+ function toggleGroup(expandedGroupId) {
1994
+ if (!onExpandedGroupIdsChange)
1995
+ return;
1996
+ const newExpandedGroupIds = new Set(expandedGroupIds);
1997
+ if (newExpandedGroupIds.has(expandedGroupId)) {
1998
+ newExpandedGroupIds.delete(expandedGroupId);
1999
+ } else {
2000
+ newExpandedGroupIds.add(expandedGroupId);
2001
+ }
2002
+ onExpandedGroupIdsChange(newExpandedGroupIds);
2003
+ }
2004
+ function handleKeyDown(event) {
2005
+ if (!(event.target instanceof Element))
2006
+ return;
2007
+ const isCellEvent = event.target.closest(".rdg-cell") !== null;
2008
+ const isRowEvent = hasGroups && event.target === rowRef.current;
2009
+ if (!isCellEvent && !isRowEvent)
2010
+ return;
2011
+ const {
2012
+ key,
2013
+ keyCode
2014
+ } = event;
2015
+ const {
2016
+ rowIdx
2017
+ } = selectedPosition;
2018
+ if (selectedCellIsWithinViewportBounds && (onPaste != null || onCopy != null) && isCtrlKeyHeldDown(event) && !isGroupRow(rows[rowIdx]) && selectedPosition.mode === "SELECT") {
2019
+ const cKey = 67;
2020
+ const vKey = 86;
2021
+ if (keyCode === cKey) {
2022
+ handleCopy();
2023
+ return;
2024
+ }
2025
+ if (keyCode === vKey) {
2026
+ handlePaste();
2027
+ return;
2028
+ }
2029
+ }
2030
+ if (isRowIdxWithinViewportBounds(rowIdx)) {
2031
+ const row2 = rows[rowIdx];
2032
+ if (isGroupRow(row2) && selectedPosition.idx === -1 && (key === leftKey && row2.isExpanded || key === rightKey && !row2.isExpanded)) {
2033
+ event.preventDefault();
2034
+ toggleGroup(row2.id);
2035
+ return;
2036
+ }
2037
+ }
2038
+ switch (event.key) {
2039
+ case "Escape":
2040
+ setCopiedCell(null);
2041
+ return;
2042
+ case "ArrowUp":
2043
+ case "ArrowDown":
2044
+ case "ArrowLeft":
2045
+ case "ArrowRight":
2046
+ case "Tab":
2047
+ case "Home":
2048
+ case "End":
2049
+ case "PageUp":
2050
+ case "PageDown":
2051
+ navigate(event);
2052
+ break;
2053
+ default:
2054
+ handleCellInput(event);
2055
+ break;
2056
+ }
2057
+ }
2058
+ function handleScroll(event) {
2059
+ const {
2060
+ scrollTop: scrollTop2,
2061
+ scrollLeft: scrollLeft2
2062
+ } = event.currentTarget;
2063
+ setScrollTop(scrollTop2);
2064
+ setScrollLeft(abs(scrollLeft2));
2065
+ onScroll?.(event);
2066
+ }
2067
+ function getRawRowIdx(rowIdx) {
2068
+ return hasGroups ? rawRows.indexOf(rows[rowIdx]) : rowIdx;
2069
+ }
2070
+ function updateRow(rowIdx, row2) {
2071
+ if (typeof onRowsChange !== "function")
2072
+ return;
2073
+ const rawRowIdx = getRawRowIdx(rowIdx);
2074
+ if (row2 === rawRows[rawRowIdx])
2075
+ return;
2076
+ const updatedRows = [...rawRows];
2077
+ updatedRows[rawRowIdx] = row2;
2078
+ onRowsChange(updatedRows, {
2079
+ indexes: [rawRowIdx],
2080
+ column: columns[selectedPosition.idx]
2081
+ });
2082
+ }
2083
+ function commitEditorChanges() {
2084
+ if (selectedPosition.mode !== "EDIT")
2085
+ return;
2086
+ updateRow(selectedPosition.rowIdx, selectedPosition.row);
2087
+ }
2088
+ function handleCopy() {
2089
+ const {
2090
+ idx,
2091
+ rowIdx
2092
+ } = selectedPosition;
2093
+ const sourceRow = rawRows[getRawRowIdx(rowIdx)];
2094
+ const sourceColumnKey = columns[idx].key;
2095
+ setCopiedCell({
2096
+ row: sourceRow,
2097
+ columnKey: sourceColumnKey
2098
+ });
2099
+ onCopy?.({
2100
+ sourceRow,
2101
+ sourceColumnKey
2102
+ });
2103
+ }
2104
+ function handlePaste() {
2105
+ if (!onPaste || !onRowsChange || copiedCell === null || !isCellEditable2(selectedPosition)) {
2106
+ return;
2107
+ }
2108
+ const {
2109
+ idx,
2110
+ rowIdx
2111
+ } = selectedPosition;
2112
+ const targetRow = rawRows[getRawRowIdx(rowIdx)];
2113
+ const updatedTargetRow = onPaste({
2114
+ sourceRow: copiedCell.row,
2115
+ sourceColumnKey: copiedCell.columnKey,
2116
+ targetRow,
2117
+ targetColumnKey: columns[idx].key
2118
+ });
2119
+ updateRow(rowIdx, updatedTargetRow);
2120
+ }
2121
+ function handleCellInput(event) {
2122
+ if (!selectedCellIsWithinViewportBounds)
2123
+ return;
2124
+ const row2 = rows[selectedPosition.rowIdx];
2125
+ if (isGroupRow(row2))
2126
+ return;
2127
+ const {
2128
+ key,
2129
+ shiftKey
2130
+ } = event;
2131
+ if (isSelectable && shiftKey && key === " ") {
2132
+ assertIsValidKeyGetter(rowKeyGetter);
2133
+ const rowKey = rowKeyGetter(row2);
2134
+ selectRow({
2135
+ row: row2,
2136
+ checked: !selectedRows.has(rowKey),
2137
+ isShiftClick: false
2138
+ });
2139
+ event.preventDefault();
2140
+ return;
2141
+ }
2142
+ const column = columns[selectedPosition.idx];
2143
+ column.editorOptions?.onCellKeyDown?.(event);
2144
+ if (event.isDefaultPrevented())
2145
+ return;
2146
+ if (isCellEditable2(selectedPosition) && isDefaultCellInput(event)) {
2147
+ setSelectedPosition(({
2148
+ idx,
2149
+ rowIdx
2150
+ }) => ({
2151
+ idx,
2152
+ rowIdx,
2153
+ mode: "EDIT",
2154
+ row: row2,
2155
+ originalRow: row2
2156
+ }));
2157
+ }
2158
+ }
2159
+ function isColIdxWithinSelectionBounds(idx) {
2160
+ return idx >= minColIdx && idx <= maxColIdx;
2161
+ }
2162
+ function isRowIdxWithinViewportBounds(rowIdx) {
2163
+ return rowIdx >= 0 && rowIdx < rows.length;
2164
+ }
2165
+ function isCellWithinSelectionBounds({
2166
+ idx,
2167
+ rowIdx
2168
+ }) {
2169
+ return rowIdx >= minRowIdx && rowIdx <= maxRowIdx && isColIdxWithinSelectionBounds(idx);
2170
+ }
2171
+ function isCellWithinViewportBounds({
2172
+ idx,
2173
+ rowIdx
2174
+ }) {
2175
+ return isRowIdxWithinViewportBounds(rowIdx) && isColIdxWithinSelectionBounds(idx);
2176
+ }
2177
+ function isCellEditable2(position) {
2178
+ return isCellWithinViewportBounds(position) && isSelectedCellEditable({
2179
+ columns,
2180
+ rows,
2181
+ selectedPosition: position,
2182
+ isGroupRow
2183
+ });
2184
+ }
2185
+ function selectCell(position, enableEditor) {
2186
+ if (!isCellWithinSelectionBounds(position))
2187
+ return;
2188
+ commitEditorChanges();
2189
+ if (enableEditor && isCellEditable2(position)) {
2190
+ const row2 = rows[position.rowIdx];
2191
+ setSelectedPosition({
2192
+ ...position,
2193
+ mode: "EDIT",
2194
+ row: row2,
2195
+ originalRow: row2
2196
+ });
2197
+ } else if (isSamePosition(selectedPosition, position)) {
2198
+ scrollIntoView(gridRef.current?.querySelector('[tabindex="0"]'));
2199
+ } else {
2200
+ setSelectedPosition({
2201
+ ...position,
2202
+ mode: "SELECT"
2203
+ });
2204
+ }
2205
+ }
2206
+ function scrollToColumn(idx) {
2207
+ const {
2208
+ current
2209
+ } = gridRef;
2210
+ if (!current)
2211
+ return;
2212
+ if (idx > lastFrozenColumnIndex) {
2213
+ const {
2214
+ rowIdx
2215
+ } = selectedPosition;
2216
+ if (!isCellWithinSelectionBounds({
2217
+ rowIdx,
2218
+ idx
2219
+ }))
2220
+ return;
2221
+ const {
2222
+ clientWidth
2223
+ } = current;
2224
+ const column = columns[idx];
2225
+ const {
2226
+ left,
2227
+ width
2228
+ } = columnMetrics.get(column);
2229
+ let right = left + width;
2230
+ const colSpan = getSelectedCellColSpan({
2231
+ rows,
2232
+ summaryRows,
2233
+ rowIdx,
2234
+ lastFrozenColumnIndex,
2235
+ column,
2236
+ isGroupRow
2237
+ });
2238
+ if (colSpan !== void 0) {
2239
+ const {
2240
+ left: left2,
2241
+ width: width2
2242
+ } = columnMetrics.get(columns[column.idx + colSpan - 1]);
2243
+ right = left2 + width2;
2244
+ }
2245
+ const isCellAtLeftBoundary = left < scrollLeft + totalFrozenColumnWidth;
2246
+ const isCellAtRightBoundary = right > clientWidth + scrollLeft;
2247
+ const sign2 = isRtl ? -1 : 1;
2248
+ if (isCellAtLeftBoundary) {
2249
+ current.scrollLeft = (left - totalFrozenColumnWidth) * sign2;
2250
+ } else if (isCellAtRightBoundary) {
2251
+ current.scrollLeft = (right - clientWidth) * sign2;
2252
+ }
2253
+ }
2254
+ }
2255
+ function getNextPosition(key, ctrlKey, shiftKey) {
2256
+ const {
2257
+ idx,
2258
+ rowIdx
2259
+ } = selectedPosition;
2260
+ const row2 = rows[rowIdx];
2261
+ const isRowSelected = selectedCellIsWithinSelectionBounds && idx === -1;
2262
+ if (key === leftKey && isRowSelected && isGroupRow(row2) && !row2.isExpanded && row2.level !== 0) {
2263
+ let parentRowIdx = -1;
2264
+ for (let i = selectedPosition.rowIdx - 1; i >= 0; i--) {
2265
+ const parentRow = rows[i];
2266
+ if (isGroupRow(parentRow) && parentRow.id === row2.parentId) {
2267
+ parentRowIdx = i;
2268
+ break;
2269
+ }
2270
+ }
2271
+ if (parentRowIdx !== -1) {
2272
+ return {
2273
+ idx,
2274
+ rowIdx: parentRowIdx
2275
+ };
2276
+ }
2277
+ }
2278
+ switch (key) {
2279
+ case "ArrowUp":
2280
+ return {
2281
+ idx,
2282
+ rowIdx: rowIdx - 1
2283
+ };
2284
+ case "ArrowDown":
2285
+ return {
2286
+ idx,
2287
+ rowIdx: rowIdx + 1
2288
+ };
2289
+ case leftKey:
2290
+ return {
2291
+ idx: idx - 1,
2292
+ rowIdx
2293
+ };
2294
+ case rightKey:
2295
+ return {
2296
+ idx: idx + 1,
2297
+ rowIdx
2298
+ };
2299
+ case "Tab":
2300
+ return {
2301
+ idx: idx + (shiftKey ? -1 : 1),
2302
+ rowIdx
2303
+ };
2304
+ case "Home":
2305
+ if (isRowSelected)
2306
+ return {
2307
+ idx,
2308
+ rowIdx: 0
2309
+ };
2310
+ return {
2311
+ idx: 0,
2312
+ rowIdx: ctrlKey ? minRowIdx : rowIdx
2313
+ };
2314
+ case "End":
2315
+ if (isRowSelected)
2316
+ return {
2317
+ idx,
2318
+ rowIdx: rows.length - 1
2319
+ };
2320
+ return {
2321
+ idx: maxColIdx,
2322
+ rowIdx: ctrlKey ? maxRowIdx : rowIdx
2323
+ };
2324
+ case "PageUp": {
2325
+ if (selectedPosition.rowIdx === minRowIdx)
2326
+ return selectedPosition;
2327
+ const nextRowY = getRowTop(rowIdx) + getRowHeight(rowIdx) - clientHeight;
2328
+ return {
2329
+ idx,
2330
+ rowIdx: nextRowY > 0 ? findRowIdx(nextRowY) : 0
2331
+ };
2332
+ }
2333
+ case "PageDown": {
2334
+ if (selectedPosition.rowIdx >= rows.length)
2335
+ return selectedPosition;
2336
+ const nextRowY = getRowTop(rowIdx) + clientHeight;
2337
+ return {
2338
+ idx,
2339
+ rowIdx: nextRowY < totalRowHeight ? findRowIdx(nextRowY) : rows.length - 1
2340
+ };
2341
+ }
2342
+ default:
2343
+ return selectedPosition;
2344
+ }
2345
+ }
2346
+ function navigate(event) {
2347
+ const {
2348
+ key,
2349
+ shiftKey
2350
+ } = event;
2351
+ let mode = cellNavigationMode;
2352
+ if (key === "Tab") {
2353
+ if (canExitGrid({
2354
+ shiftKey,
2355
+ cellNavigationMode,
2356
+ maxColIdx,
2357
+ minRowIdx,
2358
+ maxRowIdx,
2359
+ selectedPosition
2360
+ })) {
2361
+ commitEditorChanges();
2362
+ return;
2363
+ }
2364
+ mode = cellNavigationMode === "NONE" ? "CHANGE_ROW" : cellNavigationMode;
2365
+ }
2366
+ event.preventDefault();
2367
+ const ctrlKey = isCtrlKeyHeldDown(event);
2368
+ const nextPosition = getNextPosition(key, ctrlKey, shiftKey);
2369
+ if (isSamePosition(selectedPosition, nextPosition))
2370
+ return;
2371
+ const nextSelectedCellPosition = getNextSelectedCellPosition({
2372
+ columns,
2373
+ colSpanColumns,
2374
+ rows,
2375
+ summaryRows,
2376
+ minRowIdx,
2377
+ maxRowIdx,
2378
+ lastFrozenColumnIndex,
2379
+ cellNavigationMode: mode,
2380
+ currentPosition: selectedPosition,
2381
+ nextPosition,
2382
+ isCellWithinBounds: isCellWithinSelectionBounds,
2383
+ isGroupRow
2384
+ });
2385
+ selectCell(nextSelectedCellPosition);
2386
+ }
2387
+ function getDraggedOverCellIdx(currentRowIdx) {
2388
+ if (draggedOverRowIdx === void 0)
2389
+ return;
2390
+ const {
2391
+ rowIdx
2392
+ } = selectedPosition;
2393
+ const isDraggedOver = rowIdx < draggedOverRowIdx ? rowIdx < currentRowIdx && currentRowIdx <= draggedOverRowIdx : rowIdx > currentRowIdx && currentRowIdx >= draggedOverRowIdx;
2394
+ return isDraggedOver ? selectedPosition.idx : void 0;
2395
+ }
2396
+ function getLayoutCssVars() {
2397
+ if (autoResizeColumn === null)
2398
+ return layoutCssVars;
2399
+ const {
2400
+ gridTemplateColumns
2401
+ } = layoutCssVars;
2402
+ const newSizes = gridTemplateColumns.split(" ");
2403
+ newSizes[autoResizeColumn.idx] = "max-content";
2404
+ return {
2405
+ ...layoutCssVars,
2406
+ gridTemplateColumns: newSizes.join(" ")
2407
+ };
2408
+ }
2409
+ function getDragHandle(rowIdx) {
2410
+ if (selectedPosition.rowIdx !== rowIdx || selectedPosition.mode === "EDIT" || hasGroups || onFill == null) {
2411
+ return;
2412
+ }
2413
+ return /* @__PURE__ */ jsx(DragHandle, {
2414
+ rows: rawRows,
2415
+ columns,
2416
+ selectedPosition,
2417
+ isCellEditable: isCellEditable2,
2418
+ latestDraggedOverRowIdx,
2419
+ onRowsChange,
2420
+ onFill,
2421
+ setDragging,
2422
+ setDraggedOverRowIdx
2423
+ });
2424
+ }
2425
+ function getCellEditor(rowIdx) {
2426
+ if (selectedPosition.rowIdx !== rowIdx || selectedPosition.mode === "SELECT")
2427
+ return;
2428
+ const {
2429
+ idx,
2430
+ row: row2
2431
+ } = selectedPosition;
2432
+ const column = columns[idx];
2433
+ const colSpan = getColSpan(column, lastFrozenColumnIndex, {
2434
+ type: "ROW",
2435
+ row: row2
2436
+ });
2437
+ const closeEditor = () => {
2438
+ setSelectedPosition(({
2439
+ idx: idx2,
2440
+ rowIdx: rowIdx2
2441
+ }) => ({
2442
+ idx: idx2,
2443
+ rowIdx: rowIdx2,
2444
+ mode: "SELECT"
2445
+ }));
2446
+ };
2447
+ const onRowChange = (row3, commitChanges) => {
2448
+ if (commitChanges) {
2449
+ updateRow(selectedPosition.rowIdx, row3);
2450
+ closeEditor();
2451
+ } else {
2452
+ setSelectedPosition((position) => ({
2453
+ ...position,
2454
+ row: row3
2455
+ }));
2456
+ }
2457
+ };
2458
+ if (rows[selectedPosition.rowIdx] !== selectedPosition.originalRow) {
2459
+ closeEditor();
2460
+ }
2461
+ return /* @__PURE__ */ jsx(EditCell, {
2462
+ column,
2463
+ colSpan,
2464
+ row: row2,
2465
+ onRowChange,
2466
+ closeEditor
2467
+ }, column.key);
2468
+ }
2469
+ function getRowViewportColumns(rowIdx) {
2470
+ const selectedColumn = columns[selectedPosition.idx];
2471
+ if (selectedColumn !== void 0 && selectedPosition.rowIdx === rowIdx && !viewportColumns.includes(selectedColumn)) {
2472
+ return selectedPosition.idx > colOverscanEndIdx ? [...viewportColumns, selectedColumn] : [...viewportColumns.slice(0, lastFrozenColumnIndex + 1), selectedColumn, ...viewportColumns.slice(lastFrozenColumnIndex + 1)];
2473
+ }
2474
+ return viewportColumns;
2475
+ }
2476
+ function getViewportRows() {
2477
+ const rowElements = [];
2478
+ let startRowIndex = 0;
2479
+ const {
2480
+ idx: selectedIdx,
2481
+ rowIdx: selectedRowIdx
2482
+ } = selectedPosition;
2483
+ const startRowIdx = selectedCellIsWithinViewportBounds && selectedRowIdx < rowOverscanStartIdx ? rowOverscanStartIdx - 1 : rowOverscanStartIdx;
2484
+ const endRowIdx = selectedCellIsWithinViewportBounds && selectedRowIdx > rowOverscanEndIdx ? rowOverscanEndIdx + 1 : rowOverscanEndIdx;
2485
+ for (let viewportRowIdx = startRowIdx; viewportRowIdx <= endRowIdx; viewportRowIdx++) {
2486
+ const isRowOutsideViewport = viewportRowIdx === rowOverscanStartIdx - 1 || viewportRowIdx === rowOverscanEndIdx + 1;
2487
+ const rowIdx = isRowOutsideViewport ? selectedRowIdx : viewportRowIdx;
2488
+ let rowColumns = viewportColumns;
2489
+ const selectedColumn = columns[selectedIdx];
2490
+ if (selectedColumn !== void 0) {
2491
+ if (isRowOutsideViewport) {
2492
+ rowColumns = [selectedColumn];
2493
+ } else {
2494
+ rowColumns = getRowViewportColumns(rowIdx);
2495
+ }
2496
+ }
2497
+ const row2 = rows[rowIdx];
2498
+ const gridRowStart = headerRowsCount + rowIdx + 1;
2499
+ if (isGroupRow(row2)) {
2500
+ ({
2501
+ startRowIndex
2502
+ } = row2);
2503
+ const isGroupRowSelected = isSelectable && row2.childRows.every((cr) => selectedRows.has(rowKeyGetter(cr)));
2504
+ rowElements.push(/* @__PURE__ */ jsx(GroupRowRenderer, {
2505
+ "aria-level": row2.level + 1,
2506
+ "aria-setsize": row2.setSize,
2507
+ "aria-posinset": row2.posInSet + 1,
2508
+ "aria-rowindex": headerRowsCount + startRowIndex + 1,
2509
+ "aria-selected": isSelectable ? isGroupRowSelected : void 0,
2510
+ id: row2.id,
2511
+ groupKey: row2.groupKey,
2512
+ viewportColumns: rowColumns,
2513
+ childRows: row2.childRows,
2514
+ rowIdx,
2515
+ row: row2,
2516
+ gridRowStart,
2517
+ height: getRowHeight(rowIdx),
2518
+ level: row2.level,
2519
+ isExpanded: row2.isExpanded,
2520
+ selectedCellIdx: selectedRowIdx === rowIdx ? selectedIdx : void 0,
2521
+ isRowSelected: isGroupRowSelected,
2522
+ selectGroup: selectGroupLatest,
2523
+ toggleGroup: toggleGroupLatest
2524
+ }, row2.id));
2525
+ continue;
2526
+ }
2527
+ startRowIndex++;
2528
+ let key;
2529
+ let isRowSelected = false;
2530
+ if (typeof rowKeyGetter === "function") {
2531
+ key = rowKeyGetter(row2);
2532
+ isRowSelected = selectedRows?.has(key) ?? false;
2533
+ } else {
2534
+ key = hasGroups ? startRowIndex : rowIdx;
2535
+ }
2536
+ rowElements.push(/* @__PURE__ */ jsx(RowRenderer, {
2537
+ "aria-rowindex": headerRowsCount + (hasGroups ? startRowIndex : rowIdx) + 1,
2538
+ "aria-selected": isSelectable ? isRowSelected : void 0,
2539
+ rowIdx,
2540
+ row: row2,
2541
+ viewportColumns: rowColumns,
2542
+ isRowSelected,
2543
+ onRowClick,
2544
+ onRowDoubleClick,
2545
+ rowClass,
2546
+ gridRowStart,
2547
+ height: getRowHeight(rowIdx),
2548
+ copiedCellIdx: copiedCell !== null && copiedCell.row === row2 ? columns.findIndex((c) => c.key === copiedCell.columnKey) : void 0,
2549
+ selectedCellIdx: selectedRowIdx === rowIdx ? selectedIdx : void 0,
2550
+ draggedOverCellIdx: getDraggedOverCellIdx(rowIdx),
2551
+ setDraggedOverRowIdx: isDragging ? setDraggedOverRowIdx : void 0,
2552
+ lastFrozenColumnIndex,
2553
+ onRowChange: handleFormatterRowChangeLatest,
2554
+ selectCell: selectViewportCellLatest,
2555
+ selectedCellDragHandle: getDragHandle(rowIdx),
2556
+ selectedCellEditor: getCellEditor(rowIdx)
2557
+ }, key));
2558
+ }
2559
+ return rowElements;
2560
+ }
2561
+ if (selectedPosition.idx > maxColIdx || selectedPosition.rowIdx > maxRowIdx) {
2562
+ setSelectedPosition(initialPosition);
2563
+ setDraggedOverRowIdx(void 0);
2564
+ }
2565
+ let templateRows = `${headerRowHeight}px`;
2566
+ if (rows.length > 0) {
2567
+ templateRows += gridTemplateRows;
2568
+ }
2569
+ if (summaryRowsCount > 0) {
2570
+ templateRows += ` repeat(${summaryRowsCount}, ${summaryRowHeight}px)`;
2571
+ }
2572
+ const isGroupRowFocused = selectedPosition.idx === -1 && selectedPosition.rowIdx !== -2;
2573
+ return /* @__PURE__ */ jsxs("div", {
2574
+ role: hasGroups ? "treegrid" : "grid",
2575
+ "aria-label": ariaLabel,
2576
+ "aria-labelledby": ariaLabelledBy,
2577
+ "aria-describedby": ariaDescribedBy,
2578
+ "aria-multiselectable": isSelectable ? true : void 0,
2579
+ "aria-colcount": columns.length,
2580
+ "aria-rowcount": headerRowsCount + rowsCount + summaryRowsCount,
2581
+ className: clsx(rootClassname, className, isDragging && viewportDraggingClassname, autoResizeColumn !== null && cellAutoResizeClassname),
2582
+ style: {
2583
+ ...style,
2584
+ scrollPaddingInlineStart: selectedPosition.idx > lastFrozenColumnIndex ? `${totalFrozenColumnWidth}px` : void 0,
2585
+ scrollPaddingBlock: selectedPosition.rowIdx >= 0 && selectedPosition.rowIdx < rows.length ? `${headerRowHeight}px ${summaryRowsCount * summaryRowHeight}px` : void 0,
2586
+ gridTemplateRows: templateRows,
2587
+ "--rdg-header-row-height": `${headerRowHeight}px`,
2588
+ "--rdg-summary-row-height": `${summaryRowHeight}px`,
2589
+ "--rdg-sign": isRtl ? -1 : 1,
2590
+ ...getLayoutCssVars()
2591
+ },
2592
+ dir: direction,
2593
+ ref: gridRef,
2594
+ onScroll: handleScroll,
2595
+ onKeyDown: handleKeyDown,
2596
+ "data-testid": testId,
2597
+ children: [hasGroups && /* @__PURE__ */ jsx("div", {
2598
+ ref: rowRef,
2599
+ tabIndex: isGroupRowFocused ? 0 : -1,
2600
+ className: clsx(focusSinkClassname, isGroupRowFocused && [rowSelected, lastFrozenColumnIndex !== -1 && rowSelectedWithFrozenCell]),
2601
+ style: {
2602
+ gridRowStart: selectedPosition.rowIdx + 2
2603
+ },
2604
+ onKeyDown: handleKeyDown
2605
+ }), /* @__PURE__ */ jsxs(DataGridDefaultComponentsProvider, {
2606
+ value: defaultGridComponents,
2607
+ children: [/* @__PURE__ */ jsx(HeaderRow$1, {
2608
+ columns: getRowViewportColumns(-1),
2609
+ onColumnResize: handleColumnResize,
2610
+ allRowsSelected,
2611
+ onAllRowsSelectionChange: selectAllRowsLatest,
2612
+ sortColumns,
2613
+ onSortColumnsChange,
2614
+ lastFrozenColumnIndex,
2615
+ selectedCellIdx: isHeaderRowSelected ? selectedPosition.idx : void 0,
2616
+ selectCell: selectHeaderCellLatest,
2617
+ shouldFocusGrid: !selectedCellIsWithinSelectionBounds,
2618
+ direction
2619
+ }), rows.length === 0 && noRowsFallback ? noRowsFallback : /* @__PURE__ */ jsxs(Fragment, {
2620
+ children: [/* @__PURE__ */ jsx(RowSelectionChangeProvider, {
2621
+ value: selectRowLatest,
2622
+ children: getViewportRows()
2623
+ }), summaryRows?.map((row2, rowIdx) => {
2624
+ const gridRowStart = headerRowsCount + rows.length + rowIdx + 1;
2625
+ const summaryRowIdx = headerRowsCount + rows.length + rowIdx - 1;
2626
+ const isSummaryRowSelected = selectedPosition.rowIdx === summaryRowIdx;
2627
+ const top = clientHeight > totalRowHeight ? gridHeight - summaryRowHeight * (summaryRows.length - rowIdx) : void 0;
2628
+ const bottom = top === void 0 ? summaryRowHeight * (summaryRows.length - 1 - rowIdx) : void 0;
2629
+ return /* @__PURE__ */ jsx(SummaryRow$1, {
2630
+ "aria-rowindex": headerRowsCount + rowsCount + rowIdx + 1,
2631
+ rowIdx,
2632
+ gridRowStart,
2633
+ row: row2,
2634
+ top,
2635
+ bottom,
2636
+ viewportColumns: getRowViewportColumns(summaryRowIdx),
2637
+ lastFrozenColumnIndex,
2638
+ selectedCellIdx: isSummaryRowSelected ? selectedPosition.idx : void 0,
2639
+ selectCell: selectSummaryCellLatest
2640
+ }, rowIdx);
2641
+ })]
2642
+ })]
2643
+ })]
2644
+ });
2645
+ }
2646
+ function isSamePosition(p1, p2) {
2647
+ return p1.idx === p2.idx && p1.rowIdx === p2.rowIdx;
2648
+ }
2649
+ const DataGrid$1 = /* @__PURE__ */ forwardRef(DataGrid);
2650
+ var css_248z = ".t16y9g8l700-beta13{appearance:none;background-color:var(--rdg-background-color);block-size:100%;border:2px solid #ccc;box-sizing:border-box;color:var(--rdg-color);font-family:inherit;font-size:var(--rdg-font-size);inline-size:100%;padding-block:0;padding-inline:6px;vertical-align:top}.t16y9g8l700-beta13:focus{border-color:var(--rdg-selection-color);outline:none}.t16y9g8l700-beta13::placeholder{color:#999;opacity:1}";
2651
+ styleInject(css_248z, { "insertAt": "top" });
2652
+ export { DataGrid$1 as D, HeaderRenderer as H, SELECT_COLUMN_KEY as S, SelectCellFormatter as a, useRowSelection as u };