@m4l/components 0.1.26 → 0.1.28
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/assets/Logo/index.228dcb5a.js +42 -35
- package/commonjs.565e6834.js +5 -5
- package/components/CommonActions/components/ActionCancel/index.e498eeb2.js +17 -0
- package/components/CommonActions/components/ActionFormCancel/index.4ff0ad73.js +64 -0
- package/components/CommonActions/components/ActionFormIntro/index.ca4d2674.js +28 -22
- package/components/CommonActions/components/ActionIntro/index.60ef7bd7.js +18 -0
- package/components/CommonActions/components/Actions/index.0645e30f.js +867 -0
- package/components/DataGrid/index.76d8fd25.js +1075 -0
- package/components/DynamicFilter/index.342ba5fe.js +1577 -0
- package/components/ErrorLabel/index.c8615f16.js +13 -12
- package/components/Icon/index.619c31c4.js +96 -0
- package/components/Icon/types.d.ts +2 -1
- package/components/Image/index.93d5f37f.js +190 -0
- package/components/Loadable/index.f5518558.js +8 -8
- package/components/ModalDialog/index.9ea10764.js +184 -0
- package/components/NoItemSelected/{index.9609a7f7.js → index.46d2f632.js} +52 -41
- package/components/ObjectLogs/index.f941fb79.js +288 -0
- package/components/Page/index.4237c241.js +22 -20
- package/components/PaperForm/index.ec9cb8c9.js +112 -0
- package/components/Period/index.2941fbda.js +249 -0
- package/components/PropertyValue/index.dfcfe1ba.js +147 -0
- package/components/PropertyValue/styles.d.ts +2 -1
- package/components/PropertyValue/types.d.ts +3 -3
- package/components/Resizeable/index.45995d2b.js +19 -19
- package/components/ScrollBar/index.39eeb2de.js +26 -21
- package/components/ScrollToTop/index.e06f98f6.js +8 -7
- package/components/SplitLayout/index.4032673d.js +35 -33
- package/components/animate/LoadingScreen/index.1d0c4307.js +33 -33
- package/components/animate/MotionContainer/index.8d9f9d80.js +25 -22
- package/components/animate/MotionLazyContainer/index.572dd012.js +10 -10
- package/components/animate/features.0fbf41e1.js +3 -3
- package/components/animate/variants/bounce.784aaaaa.js +16 -13
- package/components/animate/variants/container.11f82b76.js +8 -6
- package/components/animate/variants/fade.b561c0fc.js +32 -28
- package/components/animate/variants/transition.bd46b9ce.js +17 -12
- package/components/formatters/BooleanFormatter/index.8da35c9c.js +55 -0
- package/components/formatters/DateFormatter/index.1b9baacc.js +69 -0
- package/components/formatters/index.689a8086.js +119 -0
- package/components/hook-form/RHFAutocomplete/index.59a68f9f.js +224 -0
- package/components/hook-form/RHFAutocompleteAsync/index.c3083062.js +87 -0
- package/components/hook-form/RHFCheckbox/index.6dcec9e2.js +49 -39
- package/components/hook-form/RHFDateTime/index.9231a7c7.js +69 -56
- package/components/hook-form/RHFMultiCheckbox/index.2680b3b6.js +23 -23
- package/components/hook-form/RHFPeriod/index.64a228d5.js +55 -0
- package/components/hook-form/RHFRadioGroup/index.b3335e13.js +29 -29
- package/components/hook-form/RHFSelect/index.b6ca8bb2.js +24 -24
- package/components/hook-form/RHFTextField/index.f9aaaa90.js +146 -0
- package/components/hook-form/RHFUpload/RHFUploadImage/{components → subcomponents}/UploadImage/index.d.ts +0 -0
- package/components/hook-form/RHFUpload/RHFUploadImage/{components → subcomponents}/UploadImage/styles.d.ts +4 -3
- package/components/hook-form/RHFUpload/RHFUploadImage/{components → subcomponents}/UploadImage/subcomponents/Skeleton/index.d.ts +0 -0
- package/components/hook-form/RHFUpload/RHFUploadImage/{components → subcomponents}/UploadImage/subcomponents/Skeleton/styles.d.ts +0 -0
- package/components/hook-form/RHFUpload/RHFUploadImage/{components → subcomponents}/UploadImage/types.d.ts +0 -0
- package/components/hook-form/RHFUpload/index.d5cc7c13.js +285 -0
- package/components/mui_extended/Accordion/index.a02ac6ae.js +107 -0
- package/components/mui_extended/Avatar/index.fe06afd7.js +51 -0
- package/components/mui_extended/BoxIcon/index.e638ecc8.js +10 -10
- package/components/mui_extended/Breadcrumbs/index.5e37d903.js +49 -44
- package/components/mui_extended/Button/index.53b56958.js +178 -0
- package/components/mui_extended/CircularProgress/index.ad569afd.js +8 -6
- package/components/mui_extended/IconButton/index.a321e5cb.js +120 -0
- package/components/mui_extended/IconButton/index.d.ts +1 -1
- package/components/mui_extended/LinkWithRoute/index.16436ab8.js +25 -21
- package/components/mui_extended/Pager/index.c0865b70.js +141 -0
- package/components/mui_extended/Popover/index.705275a4.js +278 -0
- package/components/mui_extended/Tab/index.e0653a0a.js +25 -21
- package/components/mui_extended/Typography/index.e5494696.js +25 -21
- package/contexts/ModalContext/index.b92fa565.js +153 -0
- package/contexts/ModalContext/{components → subcomponents}/ContentConfirm/index.d.ts +0 -0
- package/contexts/ModalContext/{components → subcomponents}/ContentConfirm/styles.d.ts +0 -0
- package/contexts/ModalContext/{components → subcomponents}/ContentConfirm/types.d.ts +0 -0
- package/contexts/RHFormContext/index.b142190a.js +63 -0
- package/hooks/useFormAddEdit/index.d4845f1a.js +40 -22
- package/hooks/useModal/index.5fee01a3.js +11 -0
- package/index.js +153 -153
- package/package.json +2 -1
- package/react-data-grid.d46d625e.js +2206 -1663
- package/react-draggable.20e95c61.js +800 -553
- package/react-json-view.f56a7f8e.js +2344 -2340
- package/react-resizable.5277deaf.js +470 -298
- package/react-splitter-layout.7810ac1b.js +130 -128
- package/utils/index.214d9542.js +500 -354
- package/components/CommonActions/components/ActionCancel/index.6736b782.js +0 -17
- package/components/CommonActions/components/ActionFormCancel/index.281ee166.js +0 -49
- package/components/CommonActions/components/ActionIntro/index.4665a611.js +0 -18
- package/components/CommonActions/components/Actions/index.cd7b2671.js +0 -742
- package/components/DataGrid/index.2caf6231.js +0 -894
- package/components/DynamicFilter/index.f2377369.js +0 -1157
- package/components/Icon/index.f569765b.js +0 -82
- package/components/Image/index.c9da2d5a.js +0 -152
- package/components/ModalDialog/index.bee344a5.js +0 -168
- package/components/ObjectLogs/index.6b6f95e6.js +0 -266
- package/components/PaperForm/index.3f8c7ef2.js +0 -105
- package/components/Period/index.a112ce37.js +0 -175
- package/components/PropertyValue/index.ab3dd7e9.js +0 -116
- package/components/contexts/RHFormContext/index.33dba822.js +0 -56
- package/components/formatters/BooleanFormatter/index.3ec56305.js +0 -42
- package/components/formatters/DateFormatter/index.08d8823b.js +0 -57
- package/components/formatters/index.6959c2de.js +0 -106
- package/components/hook-form/RHFAutocomplete/index.5eee9d7c.js +0 -174
- package/components/hook-form/RHFAutocompleteAsync/index.757b5080.js +0 -65
- package/components/hook-form/RHFPeriod/index.979d0898.js +0 -51
- package/components/hook-form/RHFTextField/index.ba2a8f67.js +0 -129
- package/components/hook-form/RHFUpload/index.6347159a.js +0 -258
- package/components/mui_extended/Accordion/index.49f5df8e.js +0 -103
- package/components/mui_extended/Avatar/index.dadb0528.js +0 -37
- package/components/mui_extended/Button/index.52d18aea.js +0 -144
- package/components/mui_extended/IconButton/index.4b5ce8b5.js +0 -103
- package/components/mui_extended/Pager/index.951b6975.js +0 -126
- package/components/mui_extended/Popover/index.4da8587a.js +0 -252
- package/contexts/ModalContext/index.5388dfd5.js +0 -136
- package/hooks/useModal/index.3b1ff084.js +0 -11
- package/node_modules.168cb897.js +0 -55
|
@@ -1,1590 +1,2043 @@
|
|
|
1
|
-
import { forwardRef
|
|
2
|
-
import
|
|
3
|
-
import { jsx
|
|
4
|
-
function
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
import { forwardRef, useRef, createContext, useContext, useState, useMemo, useImperativeHandle, useCallback, 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));
|
|
10
27
|
}
|
|
11
28
|
}
|
|
12
|
-
var
|
|
13
|
-
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
const
|
|
21
|
-
var
|
|
22
|
-
|
|
23
|
-
const
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
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", {
|
|
33
72
|
type: "checkbox",
|
|
34
|
-
ref
|
|
35
|
-
...
|
|
36
|
-
className:
|
|
37
|
-
onChange:
|
|
38
|
-
}), /* @__PURE__ */
|
|
39
|
-
className:
|
|
73
|
+
ref,
|
|
74
|
+
...props,
|
|
75
|
+
className: checkboxInputClassname,
|
|
76
|
+
onChange: handleChange
|
|
77
|
+
}), /* @__PURE__ */ jsx("div", {
|
|
78
|
+
className: checkboxClassname
|
|
40
79
|
})]
|
|
41
80
|
});
|
|
42
|
-
})
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
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
|
|
48
90
|
});
|
|
49
|
-
}, [
|
|
50
|
-
|
|
51
|
-
|
|
91
|
+
}, [isSelected]);
|
|
92
|
+
return {
|
|
93
|
+
ref,
|
|
94
|
+
tabIndex: isSelected ? 0 : -1
|
|
52
95
|
};
|
|
53
96
|
}
|
|
54
|
-
const
|
|
55
|
-
|
|
56
|
-
|
|
97
|
+
const DataGridDefaultComponentsContext = /* @__PURE__ */ createContext(void 0);
|
|
98
|
+
const DataGridDefaultComponentsProvider = DataGridDefaultComponentsContext.Provider;
|
|
99
|
+
function useDefaultComponents() {
|
|
100
|
+
return useContext(DataGridDefaultComponentsContext);
|
|
57
101
|
}
|
|
58
|
-
function
|
|
59
|
-
value
|
|
60
|
-
isCellSelected
|
|
61
|
-
disabled
|
|
62
|
-
onChange
|
|
63
|
-
"aria-label":
|
|
64
|
-
"aria-labelledby":
|
|
102
|
+
function SelectCellFormatter({
|
|
103
|
+
value,
|
|
104
|
+
isCellSelected,
|
|
105
|
+
disabled,
|
|
106
|
+
onChange,
|
|
107
|
+
"aria-label": ariaLabel,
|
|
108
|
+
"aria-labelledby": ariaLabelledBy
|
|
65
109
|
}) {
|
|
66
110
|
const {
|
|
67
|
-
ref
|
|
68
|
-
tabIndex
|
|
69
|
-
} =
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
"aria-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
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
|
|
78
123
|
});
|
|
79
124
|
}
|
|
80
|
-
function
|
|
125
|
+
function ValueFormatter(props) {
|
|
81
126
|
try {
|
|
82
|
-
return /* @__PURE__ */
|
|
83
|
-
children:
|
|
127
|
+
return /* @__PURE__ */ jsx(Fragment, {
|
|
128
|
+
children: props.row[props.column.key]
|
|
84
129
|
});
|
|
85
130
|
} catch {
|
|
86
131
|
return null;
|
|
87
132
|
}
|
|
88
133
|
}
|
|
89
|
-
var
|
|
90
|
-
|
|
91
|
-
const
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
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
|
|
97
145
|
}) {
|
|
98
146
|
const {
|
|
99
|
-
ref
|
|
100
|
-
tabIndex
|
|
101
|
-
} =
|
|
102
|
-
function
|
|
103
|
-
key
|
|
147
|
+
ref,
|
|
148
|
+
tabIndex
|
|
149
|
+
} = useFocusRef(isCellSelected);
|
|
150
|
+
function handleKeyDown({
|
|
151
|
+
key
|
|
104
152
|
}) {
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
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", {
|
|
113
164
|
viewBox: "0 0 14 8",
|
|
114
165
|
width: "14",
|
|
115
166
|
height: "8",
|
|
116
|
-
className:
|
|
117
|
-
"aria-hidden":
|
|
118
|
-
children: /* @__PURE__ */
|
|
119
|
-
d
|
|
167
|
+
className: caretClassname,
|
|
168
|
+
"aria-hidden": true,
|
|
169
|
+
children: /* @__PURE__ */ jsx("path", {
|
|
170
|
+
d
|
|
120
171
|
})
|
|
121
172
|
})]
|
|
122
173
|
});
|
|
123
174
|
}
|
|
124
|
-
const
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
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) {
|
|
128
183
|
throw new Error("useRowSelection must be used within DataGrid cells");
|
|
129
|
-
|
|
184
|
+
}
|
|
185
|
+
return [rowSelectionContext, rowSelectionChangeContext];
|
|
130
186
|
}
|
|
131
|
-
const
|
|
132
|
-
function
|
|
133
|
-
const
|
|
134
|
-
if (Number.isInteger(
|
|
135
|
-
return
|
|
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;
|
|
136
194
|
}
|
|
137
|
-
function
|
|
138
|
-
|
|
195
|
+
function scrollIntoView(element) {
|
|
196
|
+
element?.scrollIntoView({
|
|
139
197
|
inline: "nearest",
|
|
140
198
|
block: "nearest"
|
|
141
199
|
});
|
|
142
200
|
}
|
|
143
|
-
const
|
|
144
|
-
function
|
|
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) {
|
|
145
203
|
return (e.ctrlKey || e.metaKey) && e.key !== "Control";
|
|
146
204
|
}
|
|
147
|
-
function
|
|
148
|
-
return !
|
|
205
|
+
function isDefaultCellInput(event) {
|
|
206
|
+
return !nonInputKeys.has(event.key);
|
|
149
207
|
}
|
|
150
|
-
function
|
|
151
|
-
key
|
|
152
|
-
target
|
|
208
|
+
function onEditorNavigation({
|
|
209
|
+
key,
|
|
210
|
+
target
|
|
153
211
|
}) {
|
|
154
|
-
|
|
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;
|
|
155
216
|
}
|
|
156
|
-
function
|
|
157
|
-
selectedPosition
|
|
158
|
-
columns
|
|
159
|
-
rows
|
|
160
|
-
isGroupRow
|
|
217
|
+
function isSelectedCellEditable({
|
|
218
|
+
selectedPosition,
|
|
219
|
+
columns,
|
|
220
|
+
rows,
|
|
221
|
+
isGroupRow
|
|
161
222
|
}) {
|
|
162
|
-
const
|
|
163
|
-
|
|
223
|
+
const column = columns[selectedPosition.idx];
|
|
224
|
+
const row2 = rows[selectedPosition.rowIdx];
|
|
225
|
+
return !isGroupRow(row2) && isCellEditable(column, row2);
|
|
164
226
|
}
|
|
165
|
-
function
|
|
166
|
-
return
|
|
227
|
+
function isCellEditable(column, row2) {
|
|
228
|
+
return column.editor != null && !column.rowGroup && (typeof column.editable === "function" ? column.editable(row2) : column.editable) !== false;
|
|
167
229
|
}
|
|
168
|
-
function
|
|
169
|
-
rows
|
|
170
|
-
summaryRows
|
|
171
|
-
rowIdx
|
|
172
|
-
lastFrozenColumnIndex
|
|
173
|
-
column
|
|
174
|
-
isGroupRow
|
|
230
|
+
function getSelectedCellColSpan({
|
|
231
|
+
rows,
|
|
232
|
+
summaryRows,
|
|
233
|
+
rowIdx,
|
|
234
|
+
lastFrozenColumnIndex,
|
|
235
|
+
column,
|
|
236
|
+
isGroupRow
|
|
175
237
|
}) {
|
|
176
|
-
if (
|
|
177
|
-
return
|
|
238
|
+
if (rowIdx === -1) {
|
|
239
|
+
return getColSpan(column, lastFrozenColumnIndex, {
|
|
178
240
|
type: "HEADER"
|
|
179
241
|
});
|
|
180
|
-
if (n >= 0 && n < e.length) {
|
|
181
|
-
const d = e[n];
|
|
182
|
-
return c(d) ? void 0 : Z(l, i, {
|
|
183
|
-
type: "ROW",
|
|
184
|
-
row: d
|
|
185
|
-
});
|
|
186
242
|
}
|
|
187
|
-
if (
|
|
188
|
-
|
|
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, {
|
|
189
255
|
type: "SUMMARY",
|
|
190
|
-
row:
|
|
256
|
+
row: summaryRows[rowIdx - rows.length]
|
|
191
257
|
});
|
|
258
|
+
}
|
|
259
|
+
return void 0;
|
|
192
260
|
}
|
|
193
|
-
function
|
|
194
|
-
cellNavigationMode
|
|
195
|
-
columns
|
|
196
|
-
colSpanColumns
|
|
197
|
-
rows
|
|
198
|
-
summaryRows
|
|
199
|
-
minRowIdx
|
|
200
|
-
maxRowIdx
|
|
261
|
+
function getNextSelectedCellPosition({
|
|
262
|
+
cellNavigationMode,
|
|
263
|
+
columns,
|
|
264
|
+
colSpanColumns,
|
|
265
|
+
rows,
|
|
266
|
+
summaryRows,
|
|
267
|
+
minRowIdx,
|
|
268
|
+
maxRowIdx,
|
|
201
269
|
currentPosition: {
|
|
202
|
-
idx:
|
|
270
|
+
idx: currentIdx
|
|
203
271
|
},
|
|
204
|
-
nextPosition
|
|
205
|
-
lastFrozenColumnIndex
|
|
206
|
-
isCellWithinBounds
|
|
207
|
-
isGroupRow
|
|
272
|
+
nextPosition,
|
|
273
|
+
lastFrozenColumnIndex,
|
|
274
|
+
isCellWithinBounds,
|
|
275
|
+
isGroupRow
|
|
208
276
|
}) {
|
|
209
277
|
let {
|
|
210
|
-
idx:
|
|
211
|
-
rowIdx:
|
|
212
|
-
} =
|
|
213
|
-
const
|
|
214
|
-
if (
|
|
215
|
-
const
|
|
216
|
-
if (
|
|
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))
|
|
217
285
|
return;
|
|
218
286
|
}
|
|
219
|
-
for (const
|
|
220
|
-
const
|
|
221
|
-
if (
|
|
287
|
+
for (const column of colSpanColumns) {
|
|
288
|
+
const colIdx = column.idx;
|
|
289
|
+
if (colIdx > nextIdx)
|
|
222
290
|
break;
|
|
223
|
-
const
|
|
224
|
-
rows
|
|
225
|
-
summaryRows
|
|
226
|
-
rowIdx:
|
|
227
|
-
lastFrozenColumnIndex
|
|
228
|
-
column
|
|
229
|
-
isGroupRow
|
|
291
|
+
const colSpan = getSelectedCellColSpan({
|
|
292
|
+
rows,
|
|
293
|
+
summaryRows,
|
|
294
|
+
rowIdx: nextRowIdx,
|
|
295
|
+
lastFrozenColumnIndex,
|
|
296
|
+
column,
|
|
297
|
+
isGroupRow
|
|
230
298
|
});
|
|
231
|
-
if (
|
|
232
|
-
|
|
299
|
+
if (colSpan && nextIdx > colIdx && nextIdx < colSpan + colIdx) {
|
|
300
|
+
nextIdx = colIdx + (moveRight ? colSpan : 0);
|
|
233
301
|
break;
|
|
234
302
|
}
|
|
235
303
|
}
|
|
236
304
|
};
|
|
237
|
-
if (
|
|
238
|
-
|
|
239
|
-
|
|
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
|
+
}
|
|
240
334
|
}
|
|
241
335
|
return {
|
|
242
|
-
idx:
|
|
243
|
-
rowIdx:
|
|
336
|
+
idx: nextIdx,
|
|
337
|
+
rowIdx: nextRowIdx
|
|
244
338
|
};
|
|
245
339
|
}
|
|
246
|
-
function
|
|
247
|
-
cellNavigationMode
|
|
248
|
-
maxColIdx
|
|
249
|
-
minRowIdx
|
|
250
|
-
maxRowIdx
|
|
340
|
+
function canExitGrid({
|
|
341
|
+
cellNavigationMode,
|
|
342
|
+
maxColIdx,
|
|
343
|
+
minRowIdx,
|
|
344
|
+
maxRowIdx,
|
|
251
345
|
selectedPosition: {
|
|
252
|
-
rowIdx
|
|
253
|
-
idx
|
|
346
|
+
rowIdx,
|
|
347
|
+
idx
|
|
254
348
|
},
|
|
255
|
-
shiftKey
|
|
349
|
+
shiftKey
|
|
256
350
|
}) {
|
|
257
|
-
|
|
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;
|
|
258
359
|
}
|
|
259
|
-
function
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
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
|
|
265
369
|
};
|
|
266
370
|
}
|
|
267
|
-
function
|
|
371
|
+
function getCellStyle(column, colSpan) {
|
|
268
372
|
return {
|
|
269
|
-
gridColumnStart:
|
|
270
|
-
gridColumnEnd:
|
|
271
|
-
insetInlineStart:
|
|
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
|
|
272
376
|
};
|
|
273
377
|
}
|
|
274
|
-
function
|
|
275
|
-
return
|
|
378
|
+
function getCellClassname(column, ...extraClasses) {
|
|
379
|
+
return clsx(cellClassname, ...extraClasses, column.frozen && cellFrozenClassname, column.isLastFrozenColumn && cellFrozenLastClassname);
|
|
276
380
|
}
|
|
277
381
|
const {
|
|
278
|
-
min
|
|
279
|
-
max
|
|
280
|
-
round
|
|
281
|
-
floor
|
|
282
|
-
sign
|
|
283
|
-
abs
|
|
284
|
-
ceil
|
|
382
|
+
min,
|
|
383
|
+
max,
|
|
384
|
+
round,
|
|
385
|
+
floor,
|
|
386
|
+
sign,
|
|
387
|
+
abs,
|
|
388
|
+
ceil
|
|
285
389
|
} = Math;
|
|
286
|
-
function
|
|
287
|
-
if (typeof
|
|
390
|
+
function assertIsValidKeyGetter(keyGetter) {
|
|
391
|
+
if (typeof keyGetter !== "function") {
|
|
288
392
|
throw new Error("Please specify the rowKeyGetter prop to use selection");
|
|
393
|
+
}
|
|
289
394
|
}
|
|
290
|
-
function
|
|
291
|
-
minWidth
|
|
292
|
-
maxWidth
|
|
395
|
+
function clampColumnWidth(width, {
|
|
396
|
+
minWidth,
|
|
397
|
+
maxWidth
|
|
293
398
|
}) {
|
|
294
|
-
|
|
399
|
+
width = max(width, minWidth);
|
|
400
|
+
if (typeof maxWidth === "number" && maxWidth >= minWidth) {
|
|
401
|
+
return min(width, maxWidth);
|
|
402
|
+
}
|
|
403
|
+
return width;
|
|
295
404
|
}
|
|
296
|
-
function
|
|
297
|
-
rawColumns
|
|
298
|
-
columnWidths
|
|
299
|
-
viewportWidth
|
|
300
|
-
scrollLeft
|
|
301
|
-
defaultColumnOptions
|
|
302
|
-
rawGroupBy
|
|
303
|
-
enableVirtualization
|
|
405
|
+
function useCalculatedColumns({
|
|
406
|
+
rawColumns,
|
|
407
|
+
columnWidths,
|
|
408
|
+
viewportWidth,
|
|
409
|
+
scrollLeft,
|
|
410
|
+
defaultColumnOptions,
|
|
411
|
+
rawGroupBy,
|
|
412
|
+
enableVirtualization
|
|
304
413
|
}) {
|
|
305
|
-
const
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
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,
|
|
316
433
|
idx: 0,
|
|
317
|
-
frozen
|
|
318
|
-
isLastFrozenColumn:
|
|
319
|
-
rowGroup
|
|
320
|
-
width:
|
|
321
|
-
minWidth:
|
|
322
|
-
maxWidth:
|
|
323
|
-
sortable:
|
|
324
|
-
resizable:
|
|
325
|
-
formatter:
|
|
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
|
|
326
443
|
};
|
|
327
|
-
|
|
444
|
+
if (rowGroup) {
|
|
445
|
+
column.groupFormatter ?? (column.groupFormatter = ToggleGroupFormatter);
|
|
446
|
+
}
|
|
447
|
+
if (frozen) {
|
|
448
|
+
lastFrozenColumnIndex2++;
|
|
449
|
+
}
|
|
450
|
+
return column;
|
|
328
451
|
});
|
|
329
|
-
|
|
330
|
-
key:
|
|
331
|
-
frozen:
|
|
452
|
+
columns2.sort(({
|
|
453
|
+
key: aKey,
|
|
454
|
+
frozen: frozenA
|
|
332
455
|
}, {
|
|
333
|
-
key:
|
|
334
|
-
frozen:
|
|
335
|
-
}) =>
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
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
|
|
344
498
|
};
|
|
345
|
-
}, [
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
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
|
+
}
|
|
358
523
|
}
|
|
359
|
-
for (const
|
|
360
|
-
let
|
|
361
|
-
if (
|
|
362
|
-
const
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
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);
|
|
366
532
|
} else {
|
|
367
|
-
const
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
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
|
|
371
541
|
});
|
|
372
542
|
}
|
|
373
|
-
|
|
543
|
+
left += width;
|
|
544
|
+
templateColumns += `${width}px `;
|
|
374
545
|
}
|
|
375
|
-
if (
|
|
376
|
-
const
|
|
377
|
-
|
|
546
|
+
if (lastFrozenColumnIndex !== -1) {
|
|
547
|
+
const columnMetric = columnMetrics2.get(columns[lastFrozenColumnIndex]);
|
|
548
|
+
totalFrozenColumnWidth2 = columnMetric.left + columnMetric.width;
|
|
378
549
|
}
|
|
379
|
-
const
|
|
380
|
-
gridTemplateColumns:
|
|
550
|
+
const layoutCssVars2 = {
|
|
551
|
+
gridTemplateColumns: templateColumns
|
|
381
552
|
};
|
|
382
|
-
for (let
|
|
383
|
-
const
|
|
384
|
-
|
|
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`;
|
|
385
556
|
}
|
|
386
557
|
return {
|
|
387
|
-
layoutCssVars:
|
|
388
|
-
totalFrozenColumnWidth:
|
|
389
|
-
columnMetrics:
|
|
558
|
+
layoutCssVars: layoutCssVars2,
|
|
559
|
+
totalFrozenColumnWidth: totalFrozenColumnWidth2,
|
|
560
|
+
columnMetrics: columnMetrics2
|
|
390
561
|
};
|
|
391
|
-
}, [
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
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) {
|
|
399
576
|
const {
|
|
400
|
-
left
|
|
401
|
-
width
|
|
402
|
-
} =
|
|
403
|
-
if (
|
|
577
|
+
left,
|
|
578
|
+
width
|
|
579
|
+
} = columnMetrics.get(columns[colVisibleStartIdx]);
|
|
580
|
+
if (left + width > viewportLeft) {
|
|
404
581
|
break;
|
|
405
|
-
|
|
582
|
+
}
|
|
583
|
+
colVisibleStartIdx++;
|
|
406
584
|
}
|
|
407
|
-
let
|
|
408
|
-
|
|
585
|
+
let colVisibleEndIdx = colVisibleStartIdx;
|
|
586
|
+
while (colVisibleEndIdx < lastColIdx) {
|
|
409
587
|
const {
|
|
410
|
-
left
|
|
411
|
-
width
|
|
412
|
-
} =
|
|
413
|
-
if (
|
|
588
|
+
left,
|
|
589
|
+
width
|
|
590
|
+
} = columnMetrics.get(columns[colVisibleEndIdx]);
|
|
591
|
+
if (left + width >= viewportRight) {
|
|
414
592
|
break;
|
|
415
|
-
|
|
593
|
+
}
|
|
594
|
+
colVisibleEndIdx++;
|
|
416
595
|
}
|
|
417
|
-
const
|
|
418
|
-
|
|
419
|
-
|
|
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]);
|
|
420
600
|
return {
|
|
421
|
-
columns
|
|
422
|
-
colSpanColumns
|
|
423
|
-
colOverscanStartIdx
|
|
424
|
-
colOverscanEndIdx
|
|
425
|
-
layoutCssVars
|
|
426
|
-
columnMetrics
|
|
427
|
-
lastFrozenColumnIndex
|
|
428
|
-
totalFrozenColumnWidth
|
|
429
|
-
groupBy
|
|
601
|
+
columns,
|
|
602
|
+
colSpanColumns,
|
|
603
|
+
colOverscanStartIdx,
|
|
604
|
+
colOverscanEndIdx,
|
|
605
|
+
layoutCssVars,
|
|
606
|
+
columnMetrics,
|
|
607
|
+
lastFrozenColumnIndex,
|
|
608
|
+
totalFrozenColumnWidth,
|
|
609
|
+
groupBy
|
|
430
610
|
};
|
|
431
611
|
}
|
|
432
|
-
function
|
|
433
|
-
key
|
|
434
|
-
width
|
|
435
|
-
},
|
|
436
|
-
if (
|
|
437
|
-
return
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
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;
|
|
442
626
|
}
|
|
443
|
-
function
|
|
444
|
-
const
|
|
445
|
-
|
|
627
|
+
function useGridDimensions() {
|
|
628
|
+
const gridRef = useRef(null);
|
|
629
|
+
const [inlineSize, setInlineSize] = useState(1);
|
|
630
|
+
const [blockSize, setBlockSize] = useState(1);
|
|
631
|
+
useLayoutEffect(() => {
|
|
446
632
|
const {
|
|
447
|
-
ResizeObserver
|
|
633
|
+
ResizeObserver
|
|
448
634
|
} = window;
|
|
449
|
-
if (
|
|
635
|
+
if (ResizeObserver == null)
|
|
450
636
|
return;
|
|
451
637
|
const {
|
|
452
|
-
clientWidth
|
|
453
|
-
clientHeight
|
|
454
|
-
offsetWidth
|
|
455
|
-
offsetHeight
|
|
456
|
-
} =
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
const
|
|
462
|
-
|
|
463
|
-
|
|
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);
|
|
464
655
|
});
|
|
465
|
-
|
|
466
|
-
|
|
656
|
+
resizeObserver.observe(gridRef.current);
|
|
657
|
+
return () => {
|
|
658
|
+
resizeObserver.disconnect();
|
|
467
659
|
};
|
|
468
|
-
}, [])
|
|
660
|
+
}, []);
|
|
661
|
+
return [gridRef, inlineSize, blockSize];
|
|
469
662
|
}
|
|
470
|
-
function
|
|
471
|
-
return
|
|
663
|
+
function handleDevicePixelRatio(size) {
|
|
664
|
+
return size - (devicePixelRatio === 1 ? 0 : ceil(devicePixelRatio));
|
|
472
665
|
}
|
|
473
|
-
function
|
|
474
|
-
const
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
})
|
|
478
|
-
|
|
666
|
+
function useLatestFunc(fn) {
|
|
667
|
+
const ref = useRef(fn);
|
|
668
|
+
useEffect(() => {
|
|
669
|
+
ref.current = fn;
|
|
670
|
+
});
|
|
671
|
+
return useCallback((...args) => {
|
|
672
|
+
ref.current(...args);
|
|
479
673
|
}, []);
|
|
480
674
|
}
|
|
481
|
-
function
|
|
482
|
-
const [
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
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
|
+
});
|
|
488
689
|
}, []);
|
|
489
|
-
function
|
|
490
|
-
|
|
690
|
+
function onFocus(event) {
|
|
691
|
+
if (event.target !== event.currentTarget) {
|
|
692
|
+
setIsChildFocused(true);
|
|
693
|
+
}
|
|
491
694
|
}
|
|
695
|
+
const isFocused = isSelected && !isChildFocused;
|
|
492
696
|
return {
|
|
493
|
-
ref:
|
|
494
|
-
tabIndex:
|
|
495
|
-
onFocus:
|
|
697
|
+
ref: isSelected ? ref : void 0,
|
|
698
|
+
tabIndex: isFocused ? 0 : -1,
|
|
699
|
+
onFocus: isSelected ? onFocus : void 0
|
|
496
700
|
};
|
|
497
701
|
}
|
|
498
|
-
function
|
|
499
|
-
columns
|
|
500
|
-
colSpanColumns
|
|
501
|
-
rows
|
|
502
|
-
summaryRows
|
|
503
|
-
colOverscanStartIdx
|
|
504
|
-
colOverscanEndIdx
|
|
505
|
-
lastFrozenColumnIndex
|
|
506
|
-
rowOverscanStartIdx
|
|
507
|
-
rowOverscanEndIdx
|
|
508
|
-
isGroupRow
|
|
702
|
+
function useViewportColumns({
|
|
703
|
+
columns,
|
|
704
|
+
colSpanColumns,
|
|
705
|
+
rows,
|
|
706
|
+
summaryRows,
|
|
707
|
+
colOverscanStartIdx,
|
|
708
|
+
colOverscanEndIdx,
|
|
709
|
+
lastFrozenColumnIndex,
|
|
710
|
+
rowOverscanStartIdx,
|
|
711
|
+
rowOverscanEndIdx,
|
|
712
|
+
isGroupRow
|
|
509
713
|
}) {
|
|
510
|
-
const
|
|
511
|
-
if (
|
|
714
|
+
const startIdx = useMemo(() => {
|
|
715
|
+
if (colOverscanStartIdx === 0)
|
|
512
716
|
return 0;
|
|
513
|
-
let
|
|
514
|
-
const
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
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, {
|
|
518
730
|
type: "HEADER"
|
|
519
|
-
})))
|
|
731
|
+
}))) {
|
|
520
732
|
break;
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
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, {
|
|
524
739
|
type: "ROW",
|
|
525
|
-
row:
|
|
526
|
-
})))
|
|
740
|
+
row: row2
|
|
741
|
+
}))) {
|
|
527
742
|
break;
|
|
743
|
+
}
|
|
528
744
|
}
|
|
529
|
-
if (
|
|
530
|
-
for (const
|
|
531
|
-
if (
|
|
745
|
+
if (summaryRows != null) {
|
|
746
|
+
for (const row2 of summaryRows) {
|
|
747
|
+
if (updateStartIdx(colIdx, getColSpan(column, lastFrozenColumnIndex, {
|
|
532
748
|
type: "SUMMARY",
|
|
533
|
-
row:
|
|
534
|
-
})))
|
|
749
|
+
row: row2
|
|
750
|
+
}))) {
|
|
535
751
|
break;
|
|
752
|
+
}
|
|
753
|
+
}
|
|
536
754
|
}
|
|
537
755
|
}
|
|
538
|
-
return
|
|
539
|
-
}, [
|
|
540
|
-
return
|
|
541
|
-
const
|
|
542
|
-
for (let
|
|
543
|
-
const
|
|
544
|
-
|
|
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);
|
|
545
765
|
}
|
|
546
|
-
return
|
|
547
|
-
}, [
|
|
766
|
+
return viewportColumns;
|
|
767
|
+
}, [startIdx, colOverscanEndIdx, columns]);
|
|
548
768
|
}
|
|
549
|
-
function
|
|
550
|
-
return Array.isArray(
|
|
769
|
+
function isReadonlyArray(arr) {
|
|
770
|
+
return Array.isArray(arr);
|
|
551
771
|
}
|
|
552
|
-
function
|
|
553
|
-
rawRows
|
|
554
|
-
rowHeight
|
|
555
|
-
clientHeight
|
|
556
|
-
scrollTop
|
|
557
|
-
groupBy
|
|
558
|
-
rowGrouper
|
|
559
|
-
expandedGroupIds
|
|
560
|
-
enableVirtualization
|
|
772
|
+
function useViewportRows({
|
|
773
|
+
rawRows,
|
|
774
|
+
rowHeight,
|
|
775
|
+
clientHeight,
|
|
776
|
+
scrollTop,
|
|
777
|
+
groupBy,
|
|
778
|
+
rowGrouper,
|
|
779
|
+
expandedGroupIds,
|
|
780
|
+
enableVirtualization
|
|
561
781
|
}) {
|
|
562
|
-
const [
|
|
563
|
-
if (
|
|
564
|
-
return [void 0,
|
|
565
|
-
const
|
|
566
|
-
let
|
|
567
|
-
const
|
|
568
|
-
for (const [
|
|
569
|
-
const [
|
|
570
|
-
|
|
571
|
-
childRows
|
|
572
|
-
childGroups
|
|
573
|
-
startRowIndex:
|
|
574
|
-
}
|
|
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;
|
|
575
796
|
}
|
|
576
|
-
return [
|
|
797
|
+
return [groups, groupRowsCount];
|
|
577
798
|
};
|
|
578
|
-
return
|
|
579
|
-
}, [
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
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);
|
|
586
809
|
return;
|
|
587
810
|
}
|
|
588
|
-
Object.keys(
|
|
589
|
-
const
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
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
|
|
603
829
|
};
|
|
604
|
-
|
|
830
|
+
flattenedRows.push(groupRow2);
|
|
831
|
+
allGroupRows.add(groupRow2);
|
|
832
|
+
if (isExpanded) {
|
|
833
|
+
expandGroup(childGroups, id, level + 1);
|
|
834
|
+
}
|
|
605
835
|
});
|
|
606
836
|
};
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
837
|
+
expandGroup(groupedRows, void 0, 0);
|
|
838
|
+
return [flattenedRows, isGroupRow2];
|
|
839
|
+
function isGroupRow2(row2) {
|
|
840
|
+
return allGroupRows.has(row2);
|
|
610
841
|
}
|
|
611
|
-
}, [
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
842
|
+
}, [expandedGroupIds, groupedRows, rawRows]);
|
|
843
|
+
const {
|
|
844
|
+
totalRowHeight,
|
|
845
|
+
gridTemplateRows,
|
|
846
|
+
getRowTop,
|
|
847
|
+
getRowHeight,
|
|
848
|
+
findRowIdx
|
|
849
|
+
} = useMemo(() => {
|
|
850
|
+
if (typeof rowHeight === "number") {
|
|
619
851
|
return {
|
|
620
|
-
totalRowHeight:
|
|
621
|
-
gridTemplateRows: ` repeat(${
|
|
622
|
-
getRowTop: (
|
|
623
|
-
getRowHeight: () =>
|
|
624
|
-
findRowIdx: (
|
|
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)
|
|
625
857
|
};
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
858
|
+
}
|
|
859
|
+
let totalRowHeight2 = 0;
|
|
860
|
+
let gridTemplateRows2 = " ";
|
|
861
|
+
const rowPositions = rows.map((row2) => {
|
|
862
|
+
const currentRowHeight = isGroupRow(row2) ? rowHeight({
|
|
629
863
|
type: "GROUP",
|
|
630
|
-
row:
|
|
631
|
-
}) :
|
|
864
|
+
row: row2
|
|
865
|
+
}) : rowHeight({
|
|
632
866
|
type: "ROW",
|
|
633
|
-
row:
|
|
634
|
-
})
|
|
635
|
-
|
|
636
|
-
|
|
867
|
+
row: row2
|
|
868
|
+
});
|
|
869
|
+
const position = {
|
|
870
|
+
top: totalRowHeight2,
|
|
871
|
+
height: currentRowHeight
|
|
637
872
|
};
|
|
638
|
-
|
|
639
|
-
|
|
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
|
+
};
|
|
640
880
|
return {
|
|
641
|
-
totalRowHeight:
|
|
642
|
-
gridTemplateRows:
|
|
643
|
-
getRowTop: (
|
|
644
|
-
getRowHeight: (
|
|
645
|
-
findRowIdx(
|
|
646
|
-
let
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
if (
|
|
652
|
-
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;
|
|
653
900
|
}
|
|
654
901
|
return 0;
|
|
655
902
|
}
|
|
656
903
|
};
|
|
657
|
-
}, [
|
|
658
|
-
let
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
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);
|
|
662
913
|
}
|
|
663
914
|
return {
|
|
664
|
-
rowOverscanStartIdx
|
|
665
|
-
rowOverscanEndIdx
|
|
666
|
-
rows
|
|
667
|
-
rowsCount
|
|
668
|
-
totalRowHeight
|
|
669
|
-
gridTemplateRows
|
|
670
|
-
isGroupRow
|
|
671
|
-
getRowTop
|
|
672
|
-
getRowHeight
|
|
673
|
-
findRowIdx
|
|
915
|
+
rowOverscanStartIdx,
|
|
916
|
+
rowOverscanEndIdx,
|
|
917
|
+
rows,
|
|
918
|
+
rowsCount,
|
|
919
|
+
totalRowHeight,
|
|
920
|
+
gridTemplateRows,
|
|
921
|
+
isGroupRow,
|
|
922
|
+
getRowTop,
|
|
923
|
+
getRowHeight,
|
|
924
|
+
findRowIdx
|
|
674
925
|
};
|
|
675
926
|
}
|
|
676
|
-
var
|
|
677
|
-
|
|
678
|
-
const
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
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
|
|
685
939
|
}) {
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
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
|
|
694
950
|
});
|
|
695
951
|
}
|
|
696
|
-
function
|
|
697
|
-
onSort
|
|
698
|
-
sortDirection
|
|
699
|
-
priority
|
|
700
|
-
children
|
|
701
|
-
isCellSelected
|
|
952
|
+
function SortableHeaderCell({
|
|
953
|
+
onSort,
|
|
954
|
+
sortDirection,
|
|
955
|
+
priority,
|
|
956
|
+
children,
|
|
957
|
+
isCellSelected
|
|
702
958
|
}) {
|
|
703
|
-
const
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
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]
|
|
726
986
|
})]
|
|
727
987
|
});
|
|
728
988
|
}
|
|
729
|
-
var
|
|
730
|
-
|
|
731
|
-
const
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
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
|
|
744
1005
|
}) {
|
|
745
|
-
const
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
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) {
|
|
752
1021
|
return;
|
|
1022
|
+
}
|
|
1023
|
+
const {
|
|
1024
|
+
currentTarget,
|
|
1025
|
+
pointerId
|
|
1026
|
+
} = event;
|
|
753
1027
|
const {
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
} =
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
} = D.getBoundingClientRect(), ee = w ? x.clientX - V : F - x.clientX;
|
|
760
|
-
if (ee > 11)
|
|
1028
|
+
right,
|
|
1029
|
+
left
|
|
1030
|
+
} = currentTarget.getBoundingClientRect();
|
|
1031
|
+
const offset = isRtl ? event.clientX - left : right - event.clientX;
|
|
1032
|
+
if (offset > 11) {
|
|
761
1033
|
return;
|
|
762
|
-
|
|
1034
|
+
}
|
|
1035
|
+
function onPointerMove(event2) {
|
|
763
1036
|
const {
|
|
764
|
-
right:
|
|
765
|
-
left:
|
|
766
|
-
} =
|
|
767
|
-
|
|
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
|
+
}
|
|
768
1044
|
}
|
|
769
|
-
function
|
|
770
|
-
|
|
1045
|
+
function onLostPointerCapture() {
|
|
1046
|
+
currentTarget.removeEventListener("pointermove", onPointerMove);
|
|
1047
|
+
currentTarget.removeEventListener("lostpointercapture", onLostPointerCapture);
|
|
771
1048
|
}
|
|
772
|
-
|
|
1049
|
+
currentTarget.setPointerCapture(pointerId);
|
|
1050
|
+
currentTarget.addEventListener("pointermove", onPointerMove);
|
|
1051
|
+
currentTarget.addEventListener("lostpointercapture", onLostPointerCapture);
|
|
773
1052
|
}
|
|
774
|
-
function
|
|
775
|
-
if (
|
|
1053
|
+
function onSort(ctrlClick) {
|
|
1054
|
+
if (onSortColumnsChange == null)
|
|
776
1055
|
return;
|
|
777
1056
|
const {
|
|
778
|
-
sortDescendingFirst
|
|
779
|
-
} =
|
|
780
|
-
if (
|
|
781
|
-
const
|
|
782
|
-
columnKey:
|
|
783
|
-
direction:
|
|
1057
|
+
sortDescendingFirst
|
|
1058
|
+
} = column;
|
|
1059
|
+
if (sortColumn === void 0) {
|
|
1060
|
+
const nextSort = {
|
|
1061
|
+
columnKey: column.key,
|
|
1062
|
+
direction: sortDescendingFirst ? "DESC" : "ASC"
|
|
784
1063
|
};
|
|
785
|
-
|
|
1064
|
+
onSortColumnsChange(sortColumns && ctrlClick ? [...sortColumns, nextSort] : [nextSort]);
|
|
786
1065
|
} else {
|
|
787
|
-
let
|
|
788
|
-
if (
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
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
|
+
}
|
|
796
1084
|
}
|
|
797
1085
|
}
|
|
798
|
-
function
|
|
799
|
-
|
|
1086
|
+
function onClick() {
|
|
1087
|
+
selectCell(column.idx);
|
|
800
1088
|
}
|
|
801
|
-
function
|
|
1089
|
+
function onDoubleClick(event) {
|
|
802
1090
|
const {
|
|
803
|
-
right
|
|
804
|
-
left
|
|
805
|
-
} =
|
|
806
|
-
|
|
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");
|
|
807
1099
|
}
|
|
808
|
-
function
|
|
809
|
-
|
|
1100
|
+
function handleFocus(event) {
|
|
1101
|
+
onFocus?.(event);
|
|
1102
|
+
if (shouldFocusGrid) {
|
|
1103
|
+
selectCell(0);
|
|
1104
|
+
}
|
|
810
1105
|
}
|
|
811
|
-
return /* @__PURE__ */
|
|
1106
|
+
return /* @__PURE__ */ jsx("div", {
|
|
812
1107
|
role: "columnheader",
|
|
813
|
-
"aria-colindex":
|
|
814
|
-
"aria-selected":
|
|
815
|
-
"aria-sort":
|
|
816
|
-
"aria-colspan":
|
|
817
|
-
ref
|
|
818
|
-
tabIndex:
|
|
819
|
-
className
|
|
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,
|
|
820
1115
|
style: {
|
|
821
|
-
...
|
|
822
|
-
minWidth:
|
|
823
|
-
maxWidth:
|
|
1116
|
+
...getCellStyle(column, colSpan),
|
|
1117
|
+
minWidth: column.minWidth,
|
|
1118
|
+
maxWidth: column.maxWidth ?? void 0
|
|
824
1119
|
},
|
|
825
|
-
onFocus:
|
|
826
|
-
onClick
|
|
827
|
-
onDoubleClick:
|
|
828
|
-
onPointerDown:
|
|
829
|
-
children: /* @__PURE__ */
|
|
830
|
-
column
|
|
831
|
-
sortDirection
|
|
832
|
-
priority
|
|
833
|
-
onSort
|
|
834
|
-
allRowsSelected
|
|
835
|
-
onAllRowsSelectionChange
|
|
836
|
-
isCellSelected
|
|
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
|
|
837
1132
|
})
|
|
838
1133
|
});
|
|
839
1134
|
}
|
|
840
|
-
var
|
|
841
|
-
|
|
842
|
-
const
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
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
|
|
855
1151
|
}) {
|
|
856
|
-
const
|
|
857
|
-
for (let
|
|
858
|
-
const
|
|
1152
|
+
const cells = [];
|
|
1153
|
+
for (let index = 0; index < columns.length; index++) {
|
|
1154
|
+
const column = columns[index];
|
|
1155
|
+
const colSpan = getColSpan(column, lastFrozenColumnIndex, {
|
|
859
1156
|
type: "HEADER"
|
|
860
1157
|
});
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
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", {
|
|
876
1176
|
role: "row",
|
|
877
1177
|
"aria-rowindex": 1,
|
|
878
|
-
className:
|
|
879
|
-
style:
|
|
880
|
-
children:
|
|
1178
|
+
className: clsx(headerRowClassname, selectedCellIdx === -1 && rowSelectedClassname),
|
|
1179
|
+
style: getRowStyle(1),
|
|
1180
|
+
children: cells
|
|
881
1181
|
});
|
|
882
1182
|
}
|
|
883
|
-
const
|
|
884
|
-
var
|
|
885
|
-
|
|
886
|
-
const
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
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
|
|
900
1203
|
}) {
|
|
901
1204
|
const {
|
|
902
|
-
ref
|
|
903
|
-
tabIndex
|
|
904
|
-
onFocus
|
|
905
|
-
} =
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
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);
|
|
910
1215
|
}
|
|
911
|
-
function
|
|
912
|
-
|
|
1216
|
+
function handleClick() {
|
|
1217
|
+
selectCellWrapper(column.editorOptions?.editOnClick);
|
|
1218
|
+
onRowClick?.(row2, column);
|
|
913
1219
|
}
|
|
914
|
-
function
|
|
915
|
-
|
|
1220
|
+
function handleContextMenu() {
|
|
1221
|
+
selectCellWrapper();
|
|
916
1222
|
}
|
|
917
|
-
function
|
|
918
|
-
|
|
1223
|
+
function handleDoubleClick() {
|
|
1224
|
+
selectCellWrapper(true);
|
|
1225
|
+
onRowDoubleClick?.(row2, column);
|
|
919
1226
|
}
|
|
920
|
-
return /* @__PURE__ */
|
|
1227
|
+
return /* @__PURE__ */ jsx("div", {
|
|
921
1228
|
role: "gridcell",
|
|
922
|
-
"aria-colindex":
|
|
923
|
-
"aria-selected":
|
|
924
|
-
"aria-colspan":
|
|
925
|
-
"aria-readonly": !
|
|
926
|
-
ref
|
|
927
|
-
tabIndex
|
|
928
|
-
className
|
|
929
|
-
style:
|
|
930
|
-
onClick:
|
|
931
|
-
onDoubleClick:
|
|
932
|
-
onContextMenu:
|
|
933
|
-
onFocus
|
|
934
|
-
...
|
|
935
|
-
children: !
|
|
936
|
-
children: [/* @__PURE__ */
|
|
937
|
-
column
|
|
938
|
-
row:
|
|
939
|
-
isCellSelected
|
|
940
|
-
onRowChange
|
|
941
|
-
}),
|
|
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]
|
|
942
1249
|
})
|
|
943
1250
|
});
|
|
944
1251
|
}
|
|
945
|
-
const
|
|
946
|
-
function
|
|
947
|
-
className
|
|
948
|
-
rowIdx
|
|
949
|
-
gridRowStart
|
|
950
|
-
height
|
|
951
|
-
selectedCellIdx
|
|
952
|
-
isRowSelected
|
|
953
|
-
copiedCellIdx
|
|
954
|
-
draggedOverCellIdx
|
|
955
|
-
lastFrozenColumnIndex
|
|
956
|
-
row:
|
|
957
|
-
viewportColumns
|
|
958
|
-
selectedCellEditor
|
|
959
|
-
selectedCellDragHandle
|
|
960
|
-
onRowClick
|
|
961
|
-
onRowDoubleClick
|
|
962
|
-
rowClass
|
|
963
|
-
setDraggedOverRowIdx
|
|
964
|
-
onMouseEnter
|
|
965
|
-
onRowChange
|
|
966
|
-
selectCell
|
|
967
|
-
...
|
|
968
|
-
},
|
|
969
|
-
const
|
|
970
|
-
|
|
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);
|
|
971
1278
|
});
|
|
972
|
-
function
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
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, {
|
|
981
1291
|
type: "ROW",
|
|
982
|
-
row:
|
|
1292
|
+
row: row2
|
|
983
1293
|
});
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
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", {
|
|
1003
1319
|
role: "row",
|
|
1004
|
-
ref
|
|
1005
|
-
className
|
|
1006
|
-
onMouseEnter:
|
|
1007
|
-
style:
|
|
1008
|
-
...
|
|
1009
|
-
children:
|
|
1320
|
+
ref,
|
|
1321
|
+
className,
|
|
1322
|
+
onMouseEnter: handleDragEnter,
|
|
1323
|
+
style: getRowStyle(gridRowStart, height),
|
|
1324
|
+
...props,
|
|
1325
|
+
children: cells
|
|
1010
1326
|
})
|
|
1011
1327
|
});
|
|
1012
1328
|
}
|
|
1013
|
-
const
|
|
1014
|
-
function
|
|
1015
|
-
id
|
|
1016
|
-
groupKey
|
|
1017
|
-
childRows
|
|
1018
|
-
isExpanded
|
|
1019
|
-
isCellSelected
|
|
1020
|
-
column
|
|
1021
|
-
row:
|
|
1022
|
-
groupColumnIndex
|
|
1023
|
-
toggleGroup:
|
|
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
|
|
1024
1340
|
}) {
|
|
1025
1341
|
const {
|
|
1026
|
-
ref
|
|
1027
|
-
tabIndex
|
|
1028
|
-
onFocus
|
|
1029
|
-
} =
|
|
1030
|
-
function
|
|
1031
|
-
|
|
1032
|
-
}
|
|
1033
|
-
const
|
|
1034
|
-
return /* @__PURE__ */
|
|
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", {
|
|
1035
1351
|
role: "gridcell",
|
|
1036
|
-
"aria-colindex":
|
|
1037
|
-
"aria-selected":
|
|
1038
|
-
ref
|
|
1039
|
-
tabIndex
|
|
1040
|
-
className:
|
|
1352
|
+
"aria-colindex": column.idx + 1,
|
|
1353
|
+
"aria-selected": isCellSelected,
|
|
1354
|
+
ref,
|
|
1355
|
+
tabIndex,
|
|
1356
|
+
className: getCellClassname(column),
|
|
1041
1357
|
style: {
|
|
1042
|
-
...
|
|
1043
|
-
cursor:
|
|
1358
|
+
...getCellStyle(column),
|
|
1359
|
+
cursor: isLevelMatching ? "pointer" : "default"
|
|
1044
1360
|
},
|
|
1045
|
-
onClick:
|
|
1046
|
-
onFocus
|
|
1047
|
-
children: (!
|
|
1048
|
-
groupKey
|
|
1049
|
-
childRows
|
|
1050
|
-
column
|
|
1051
|
-
row:
|
|
1052
|
-
isExpanded
|
|
1053
|
-
isCellSelected
|
|
1054
|
-
toggleGroup
|
|
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
|
|
1055
1371
|
})
|
|
1056
|
-
},
|
|
1372
|
+
}, column.key);
|
|
1057
1373
|
}
|
|
1058
|
-
const
|
|
1059
|
-
var
|
|
1060
|
-
|
|
1061
|
-
const
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
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
|
|
1078
1395
|
}) {
|
|
1079
|
-
const
|
|
1080
|
-
function
|
|
1081
|
-
|
|
1396
|
+
const idx = viewportColumns[0].key === SELECT_COLUMN_KEY ? level + 1 : level;
|
|
1397
|
+
function handleSelectGroup() {
|
|
1398
|
+
selectGroup(rowIdx);
|
|
1082
1399
|
}
|
|
1083
|
-
return /* @__PURE__ */
|
|
1084
|
-
value:
|
|
1085
|
-
children: /* @__PURE__ */
|
|
1400
|
+
return /* @__PURE__ */ jsx(RowSelectionProvider, {
|
|
1401
|
+
value: isRowSelected,
|
|
1402
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
1086
1403
|
role: "row",
|
|
1087
|
-
"aria-level":
|
|
1088
|
-
"aria-expanded":
|
|
1089
|
-
className:
|
|
1090
|
-
onClick:
|
|
1091
|
-
style:
|
|
1092
|
-
...
|
|
1093
|
-
children:
|
|
1094
|
-
id
|
|
1095
|
-
groupKey
|
|
1096
|
-
childRows
|
|
1097
|
-
isExpanded
|
|
1098
|
-
isCellSelected:
|
|
1099
|
-
column
|
|
1100
|
-
row:
|
|
1101
|
-
groupColumnIndex:
|
|
1102
|
-
toggleGroup
|
|
1103
|
-
},
|
|
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))
|
|
1104
1421
|
})
|
|
1105
1422
|
});
|
|
1106
1423
|
}
|
|
1107
|
-
const
|
|
1108
|
-
var
|
|
1109
|
-
|
|
1110
|
-
const
|
|
1111
|
-
function
|
|
1112
|
-
column
|
|
1113
|
-
colSpan
|
|
1114
|
-
row:
|
|
1115
|
-
isCellSelected
|
|
1116
|
-
selectCell
|
|
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
|
|
1117
1434
|
}) {
|
|
1118
1435
|
const {
|
|
1119
|
-
ref
|
|
1120
|
-
tabIndex
|
|
1121
|
-
onFocus
|
|
1122
|
-
} =
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
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", {
|
|
1130
1449
|
role: "gridcell",
|
|
1131
|
-
"aria-colindex":
|
|
1132
|
-
"aria-colspan":
|
|
1133
|
-
"aria-selected":
|
|
1134
|
-
ref
|
|
1135
|
-
tabIndex
|
|
1136
|
-
className
|
|
1137
|
-
style:
|
|
1138
|
-
onClick
|
|
1139
|
-
onFocus
|
|
1140
|
-
children:
|
|
1141
|
-
column
|
|
1142
|
-
row:
|
|
1143
|
-
isCellSelected
|
|
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
|
|
1144
1463
|
})
|
|
1145
1464
|
});
|
|
1146
1465
|
}
|
|
1147
|
-
const
|
|
1148
|
-
var
|
|
1149
|
-
|
|
1150
|
-
const
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
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
|
|
1162
1483
|
}) {
|
|
1163
|
-
const
|
|
1164
|
-
for (let
|
|
1165
|
-
const
|
|
1484
|
+
const cells = [];
|
|
1485
|
+
for (let index = 0; index < viewportColumns.length; index++) {
|
|
1486
|
+
const column = viewportColumns[index];
|
|
1487
|
+
const colSpan = getColSpan(column, lastFrozenColumnIndex, {
|
|
1166
1488
|
type: "SUMMARY",
|
|
1167
|
-
row:
|
|
1489
|
+
row: row2
|
|
1168
1490
|
});
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
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", {
|
|
1180
1504
|
role: "row",
|
|
1181
|
-
"aria-rowindex":
|
|
1182
|
-
className:
|
|
1505
|
+
"aria-rowindex": ariaRowIndex,
|
|
1506
|
+
className: clsx(rowClassname, `rdg-row-${rowIdx % 2 === 0 ? "even" : "odd"}`, summaryRowClassname, rowIdx === 0 && summaryRowBorderClassname, selectedCellIdx === -1 && rowSelectedClassname),
|
|
1183
1507
|
style: {
|
|
1184
|
-
...
|
|
1185
|
-
"--rdg-summary-row-top":
|
|
1186
|
-
"--rdg-summary-row-bottom":
|
|
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
|
|
1187
1511
|
},
|
|
1188
|
-
children:
|
|
1512
|
+
children: cells
|
|
1189
1513
|
});
|
|
1190
1514
|
}
|
|
1191
|
-
const
|
|
1192
|
-
var
|
|
1193
|
-
|
|
1194
|
-
const
|
|
1195
|
-
function
|
|
1196
|
-
column
|
|
1197
|
-
colSpan
|
|
1198
|
-
row:
|
|
1199
|
-
onRowChange
|
|
1200
|
-
closeEditor
|
|
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
|
|
1201
1525
|
}) {
|
|
1202
|
-
const
|
|
1203
|
-
|
|
1526
|
+
const frameRequestRef = useRef();
|
|
1527
|
+
const commitOnOutsideClick = column.editorOptions?.commitOnOutsideClick !== false;
|
|
1528
|
+
const commitOnOutsideMouseDown = useLatestFunc(() => {
|
|
1529
|
+
onClose(true);
|
|
1204
1530
|
});
|
|
1205
|
-
|
|
1206
|
-
if (!
|
|
1531
|
+
useEffect(() => {
|
|
1532
|
+
if (!commitOnOutsideClick)
|
|
1207
1533
|
return;
|
|
1208
|
-
function
|
|
1209
|
-
|
|
1534
|
+
function onWindowCaptureMouseDown() {
|
|
1535
|
+
frameRequestRef.current = requestAnimationFrame(commitOnOutsideMouseDown);
|
|
1210
1536
|
}
|
|
1211
|
-
|
|
1212
|
-
capture:
|
|
1213
|
-
})
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1537
|
+
addEventListener("mousedown", onWindowCaptureMouseDown, {
|
|
1538
|
+
capture: true
|
|
1539
|
+
});
|
|
1540
|
+
return () => {
|
|
1541
|
+
removeEventListener("mousedown", onWindowCaptureMouseDown, {
|
|
1542
|
+
capture: true
|
|
1543
|
+
});
|
|
1544
|
+
cancelFrameRequest();
|
|
1217
1545
|
};
|
|
1218
|
-
}, [
|
|
1219
|
-
function
|
|
1220
|
-
cancelAnimationFrame(
|
|
1546
|
+
}, [commitOnOutsideClick, commitOnOutsideMouseDown]);
|
|
1547
|
+
function cancelFrameRequest() {
|
|
1548
|
+
cancelAnimationFrame(frameRequestRef.current);
|
|
1221
1549
|
}
|
|
1222
|
-
function
|
|
1223
|
-
|
|
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
|
+
}
|
|
1224
1563
|
}
|
|
1225
|
-
function
|
|
1226
|
-
|
|
1564
|
+
function onClose(commitChanges) {
|
|
1565
|
+
if (commitChanges) {
|
|
1566
|
+
onRowChange(row2, true);
|
|
1567
|
+
} else {
|
|
1568
|
+
closeEditor();
|
|
1569
|
+
}
|
|
1227
1570
|
}
|
|
1228
1571
|
const {
|
|
1229
|
-
cellClass
|
|
1230
|
-
} =
|
|
1231
|
-
|
|
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", {
|
|
1232
1576
|
role: "gridcell",
|
|
1233
|
-
"aria-colindex":
|
|
1234
|
-
"aria-colspan":
|
|
1235
|
-
"aria-selected":
|
|
1236
|
-
className
|
|
1237
|
-
style:
|
|
1238
|
-
onKeyDown
|
|
1239
|
-
onMouseDownCapture:
|
|
1240
|
-
children:
|
|
1241
|
-
children: [/* @__PURE__ */
|
|
1242
|
-
column
|
|
1243
|
-
row:
|
|
1244
|
-
onRowChange
|
|
1245
|
-
onClose
|
|
1246
|
-
}),
|
|
1247
|
-
column
|
|
1248
|
-
row:
|
|
1249
|
-
isCellSelected:
|
|
1250
|
-
onRowChange
|
|
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
|
|
1251
1595
|
})]
|
|
1252
1596
|
})
|
|
1253
1597
|
});
|
|
1254
1598
|
}
|
|
1255
|
-
var
|
|
1256
|
-
|
|
1257
|
-
const
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
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
|
|
1268
1613
|
}) {
|
|
1269
|
-
function
|
|
1270
|
-
if (
|
|
1614
|
+
function handleMouseDown(event) {
|
|
1615
|
+
if (event.buttons !== 1)
|
|
1271
1616
|
return;
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1617
|
+
setDragging(true);
|
|
1618
|
+
window.addEventListener("mouseover", onMouseOver);
|
|
1619
|
+
window.addEventListener("mouseup", onMouseUp);
|
|
1620
|
+
function onMouseOver(event2) {
|
|
1621
|
+
if (event2.buttons !== 1)
|
|
1622
|
+
onMouseUp();
|
|
1275
1623
|
}
|
|
1276
|
-
function
|
|
1277
|
-
window.removeEventListener("mouseover",
|
|
1624
|
+
function onMouseUp() {
|
|
1625
|
+
window.removeEventListener("mouseover", onMouseOver);
|
|
1626
|
+
window.removeEventListener("mouseup", onMouseUp);
|
|
1627
|
+
setDragging(false);
|
|
1628
|
+
handleDragEnd();
|
|
1278
1629
|
}
|
|
1279
1630
|
}
|
|
1280
|
-
function
|
|
1281
|
-
const
|
|
1282
|
-
if (
|
|
1631
|
+
function handleDragEnd() {
|
|
1632
|
+
const overRowIdx = latestDraggedOverRowIdx.current;
|
|
1633
|
+
if (overRowIdx === void 0)
|
|
1283
1634
|
return;
|
|
1284
1635
|
const {
|
|
1285
|
-
rowIdx
|
|
1286
|
-
} =
|
|
1287
|
-
|
|
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);
|
|
1288
1642
|
}
|
|
1289
|
-
function
|
|
1290
|
-
|
|
1643
|
+
function handleDoubleClick(event) {
|
|
1644
|
+
event.stopPropagation();
|
|
1645
|
+
updateRows(selectedPosition.rowIdx + 1, rows.length);
|
|
1291
1646
|
}
|
|
1292
|
-
function
|
|
1647
|
+
function updateRows(startRowIdx, endRowIdx) {
|
|
1293
1648
|
const {
|
|
1294
|
-
idx
|
|
1295
|
-
rowIdx
|
|
1296
|
-
} =
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
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
|
|
1301
1660
|
})) {
|
|
1302
|
-
const
|
|
1303
|
-
columnKey:
|
|
1304
|
-
sourceRow
|
|
1305
|
-
targetRow:
|
|
1661
|
+
const updatedRow = onFill({
|
|
1662
|
+
columnKey: column.key,
|
|
1663
|
+
sourceRow,
|
|
1664
|
+
targetRow: rows[i]
|
|
1306
1665
|
});
|
|
1307
|
-
|
|
1666
|
+
if (updatedRow !== rows[i]) {
|
|
1667
|
+
updatedRows[i] = updatedRow;
|
|
1668
|
+
indexes.push(i);
|
|
1669
|
+
}
|
|
1308
1670
|
}
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1671
|
+
}
|
|
1672
|
+
if (indexes.length > 0) {
|
|
1673
|
+
onRowsChange?.(updatedRows, {
|
|
1674
|
+
indexes,
|
|
1675
|
+
column
|
|
1676
|
+
});
|
|
1677
|
+
}
|
|
1313
1678
|
}
|
|
1314
|
-
return /* @__PURE__ */
|
|
1315
|
-
className:
|
|
1316
|
-
onMouseDown:
|
|
1317
|
-
onDoubleClick:
|
|
1679
|
+
return /* @__PURE__ */ jsx("div", {
|
|
1680
|
+
className: cellDragHandleClassname,
|
|
1681
|
+
onMouseDown: handleMouseDown,
|
|
1682
|
+
onDoubleClick: handleDoubleClick
|
|
1318
1683
|
});
|
|
1319
1684
|
}
|
|
1320
|
-
var
|
|
1321
|
-
|
|
1322
|
-
const
|
|
1323
|
-
|
|
1324
|
-
|
|
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
|
|
1325
1691
|
}) {
|
|
1326
|
-
return
|
|
1692
|
+
return sortDirection !== void 0 ? /* @__PURE__ */ jsx("svg", {
|
|
1327
1693
|
viewBox: "0 0 12 8",
|
|
1328
1694
|
width: "12",
|
|
1329
1695
|
height: "8",
|
|
1330
|
-
className:
|
|
1331
|
-
"aria-hidden":
|
|
1332
|
-
children: /* @__PURE__ */
|
|
1333
|
-
d:
|
|
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"
|
|
1334
1700
|
})
|
|
1335
1701
|
}) : null;
|
|
1336
1702
|
}
|
|
1337
|
-
const
|
|
1703
|
+
const initialPosition = {
|
|
1338
1704
|
idx: -1,
|
|
1339
1705
|
rowIdx: -2,
|
|
1340
1706
|
mode: "SELECT"
|
|
1341
1707
|
};
|
|
1342
|
-
function
|
|
1343
|
-
columns:
|
|
1344
|
-
rows:
|
|
1345
|
-
summaryRows
|
|
1346
|
-
rowKeyGetter
|
|
1347
|
-
onRowsChange
|
|
1348
|
-
rowHeight
|
|
1349
|
-
headerRowHeight:
|
|
1350
|
-
summaryRowHeight:
|
|
1351
|
-
selectedRows
|
|
1352
|
-
onSelectedRowsChange
|
|
1353
|
-
sortColumns
|
|
1354
|
-
onSortColumnsChange
|
|
1355
|
-
defaultColumnOptions
|
|
1356
|
-
groupBy:
|
|
1357
|
-
rowGrouper
|
|
1358
|
-
expandedGroupIds
|
|
1359
|
-
onExpandedGroupIdsChange
|
|
1360
|
-
onRowClick
|
|
1361
|
-
onRowDoubleClick
|
|
1362
|
-
onScroll
|
|
1363
|
-
onColumnResize
|
|
1364
|
-
onFill
|
|
1365
|
-
onCopy
|
|
1366
|
-
onPaste
|
|
1367
|
-
cellNavigationMode:
|
|
1368
|
-
enableVirtualization
|
|
1369
|
-
components
|
|
1370
|
-
className
|
|
1371
|
-
style
|
|
1372
|
-
rowClass
|
|
1373
|
-
direction
|
|
1374
|
-
"aria-label":
|
|
1375
|
-
"aria-labelledby":
|
|
1376
|
-
"aria-describedby":
|
|
1377
|
-
"data-testid":
|
|
1378
|
-
},
|
|
1379
|
-
const
|
|
1380
|
-
|
|
1381
|
-
const
|
|
1382
|
-
|
|
1383
|
-
const
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
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(() => {
|
|
1387
1782
|
const {
|
|
1388
|
-
length
|
|
1389
|
-
} =
|
|
1390
|
-
return
|
|
1391
|
-
}, [
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
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,
|
|
1449
1859
|
idx: -1
|
|
1450
1860
|
});
|
|
1451
|
-
})
|
|
1452
|
-
|
|
1861
|
+
});
|
|
1862
|
+
const selectHeaderCellLatest = useLatestFunc((idx) => {
|
|
1863
|
+
selectCell({
|
|
1453
1864
|
rowIdx: -1,
|
|
1454
|
-
idx
|
|
1865
|
+
idx
|
|
1455
1866
|
});
|
|
1456
|
-
})
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
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
|
|
1461
1873
|
});
|
|
1462
|
-
})
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1874
|
+
});
|
|
1875
|
+
const toggleGroupLatest = useLatestFunc(toggleGroup);
|
|
1876
|
+
useLayoutEffect(() => {
|
|
1877
|
+
if (!selectedCellIsWithinSelectionBounds || isSamePosition(selectedPosition, prevSelectedPosition.current)) {
|
|
1878
|
+
prevSelectedPosition.current = selectedPosition;
|
|
1466
1879
|
return;
|
|
1467
1880
|
}
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
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)
|
|
1473
1891
|
return;
|
|
1474
|
-
const
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
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) {
|
|
1485
1908
|
const {
|
|
1486
|
-
current
|
|
1487
|
-
} =
|
|
1488
|
-
|
|
1489
|
-
|
|
1909
|
+
current
|
|
1910
|
+
} = gridRef;
|
|
1911
|
+
if (!current)
|
|
1912
|
+
return;
|
|
1913
|
+
current.scrollTo({
|
|
1914
|
+
top: getRowTop(rowIdx),
|
|
1490
1915
|
behavior: "smooth"
|
|
1491
1916
|
});
|
|
1492
1917
|
},
|
|
1493
|
-
selectCell
|
|
1918
|
+
selectCell
|
|
1494
1919
|
}));
|
|
1495
|
-
const
|
|
1496
|
-
if (
|
|
1497
|
-
|
|
1920
|
+
const handleColumnResize = useCallback((column, width) => {
|
|
1921
|
+
if (width === "auto") {
|
|
1922
|
+
setAutoResizeColumn(column);
|
|
1498
1923
|
return;
|
|
1499
1924
|
}
|
|
1500
|
-
|
|
1501
|
-
const
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
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;
|
|
1506
1935
|
}, []);
|
|
1507
|
-
function
|
|
1508
|
-
row:
|
|
1509
|
-
checked
|
|
1510
|
-
isShiftClick
|
|
1936
|
+
function selectRow({
|
|
1937
|
+
row: row2,
|
|
1938
|
+
checked,
|
|
1939
|
+
isShiftClick
|
|
1511
1940
|
}) {
|
|
1512
|
-
if (!
|
|
1941
|
+
if (!onSelectedRowsChange)
|
|
1513
1942
|
return;
|
|
1514
|
-
|
|
1515
|
-
const
|
|
1516
|
-
if (
|
|
1517
|
-
for (const
|
|
1518
|
-
const
|
|
1519
|
-
|
|
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
|
+
}
|
|
1520
1953
|
}
|
|
1521
|
-
|
|
1954
|
+
onSelectedRowsChange(newSelectedRows);
|
|
1522
1955
|
return;
|
|
1523
1956
|
}
|
|
1524
|
-
const
|
|
1525
|
-
if (
|
|
1526
|
-
|
|
1527
|
-
const
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
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));
|
|
1533
1970
|
}
|
|
1534
1971
|
}
|
|
1535
|
-
} else
|
|
1536
|
-
|
|
1537
|
-
|
|
1972
|
+
} else {
|
|
1973
|
+
newSelectedRows.delete(rowKey);
|
|
1974
|
+
lastSelectedRowIdx.current = -1;
|
|
1975
|
+
}
|
|
1976
|
+
onSelectedRowsChange(newSelectedRows);
|
|
1538
1977
|
}
|
|
1539
|
-
function
|
|
1540
|
-
if (!
|
|
1978
|
+
function selectAllRows(checked) {
|
|
1979
|
+
if (!onSelectedRowsChange)
|
|
1541
1980
|
return;
|
|
1542
|
-
|
|
1543
|
-
const
|
|
1544
|
-
for (const
|
|
1545
|
-
const
|
|
1546
|
-
|
|
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
|
+
}
|
|
1547
1990
|
}
|
|
1548
|
-
|
|
1991
|
+
onSelectedRowsChange(newSelectedRows);
|
|
1549
1992
|
}
|
|
1550
|
-
function
|
|
1551
|
-
if (!
|
|
1993
|
+
function toggleGroup(expandedGroupId) {
|
|
1994
|
+
if (!onExpandedGroupIdsChange)
|
|
1552
1995
|
return;
|
|
1553
|
-
const
|
|
1554
|
-
|
|
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);
|
|
1555
2003
|
}
|
|
1556
|
-
function
|
|
1557
|
-
if (!(
|
|
2004
|
+
function handleKeyDown(event) {
|
|
2005
|
+
if (!(event.target instanceof Element))
|
|
1558
2006
|
return;
|
|
1559
|
-
const
|
|
1560
|
-
|
|
2007
|
+
const isCellEvent = event.target.closest(".rdg-cell") !== null;
|
|
2008
|
+
const isRowEvent = hasGroups && event.target === rowRef.current;
|
|
2009
|
+
if (!isCellEvent && !isRowEvent)
|
|
1561
2010
|
return;
|
|
1562
2011
|
const {
|
|
1563
|
-
key
|
|
1564
|
-
keyCode
|
|
1565
|
-
} =
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
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();
|
|
1571
2023
|
return;
|
|
1572
2024
|
}
|
|
1573
|
-
if (
|
|
1574
|
-
|
|
2025
|
+
if (keyCode === vKey) {
|
|
2026
|
+
handlePaste();
|
|
1575
2027
|
return;
|
|
1576
2028
|
}
|
|
1577
2029
|
}
|
|
1578
|
-
if (
|
|
1579
|
-
const
|
|
1580
|
-
if (
|
|
1581
|
-
|
|
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);
|
|
1582
2035
|
return;
|
|
1583
2036
|
}
|
|
1584
2037
|
}
|
|
1585
|
-
switch (
|
|
2038
|
+
switch (event.key) {
|
|
1586
2039
|
case "Escape":
|
|
1587
|
-
|
|
2040
|
+
setCopiedCell(null);
|
|
1588
2041
|
return;
|
|
1589
2042
|
case "ArrowUp":
|
|
1590
2043
|
case "ArrowDown":
|
|
@@ -1595,521 +2048,611 @@ function Kr({
|
|
|
1595
2048
|
case "End":
|
|
1596
2049
|
case "PageUp":
|
|
1597
2050
|
case "PageDown":
|
|
1598
|
-
|
|
2051
|
+
navigate(event);
|
|
1599
2052
|
break;
|
|
1600
2053
|
default:
|
|
1601
|
-
|
|
2054
|
+
handleCellInput(event);
|
|
1602
2055
|
break;
|
|
1603
2056
|
}
|
|
1604
2057
|
}
|
|
1605
|
-
function
|
|
2058
|
+
function handleScroll(event) {
|
|
1606
2059
|
const {
|
|
1607
|
-
scrollTop:
|
|
1608
|
-
scrollLeft:
|
|
1609
|
-
} =
|
|
1610
|
-
|
|
2060
|
+
scrollTop: scrollTop2,
|
|
2061
|
+
scrollLeft: scrollLeft2
|
|
2062
|
+
} = event.currentTarget;
|
|
2063
|
+
setScrollTop(scrollTop2);
|
|
2064
|
+
setScrollLeft(abs(scrollLeft2));
|
|
2065
|
+
onScroll?.(event);
|
|
1611
2066
|
}
|
|
1612
|
-
function
|
|
1613
|
-
return
|
|
2067
|
+
function getRawRowIdx(rowIdx) {
|
|
2068
|
+
return hasGroups ? rawRows.indexOf(rows[rowIdx]) : rowIdx;
|
|
1614
2069
|
}
|
|
1615
|
-
function
|
|
1616
|
-
if (typeof
|
|
2070
|
+
function updateRow(rowIdx, row2) {
|
|
2071
|
+
if (typeof onRowsChange !== "function")
|
|
1617
2072
|
return;
|
|
1618
|
-
const
|
|
1619
|
-
if (
|
|
2073
|
+
const rawRowIdx = getRawRowIdx(rowIdx);
|
|
2074
|
+
if (row2 === rawRows[rawRowIdx])
|
|
1620
2075
|
return;
|
|
1621
|
-
const
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
|
|
2076
|
+
const updatedRows = [...rawRows];
|
|
2077
|
+
updatedRows[rawRowIdx] = row2;
|
|
2078
|
+
onRowsChange(updatedRows, {
|
|
2079
|
+
indexes: [rawRowIdx],
|
|
2080
|
+
column: columns[selectedPosition.idx]
|
|
1625
2081
|
});
|
|
1626
2082
|
}
|
|
1627
|
-
function
|
|
1628
|
-
|
|
2083
|
+
function commitEditorChanges() {
|
|
2084
|
+
if (selectedPosition.mode !== "EDIT")
|
|
2085
|
+
return;
|
|
2086
|
+
updateRow(selectedPosition.rowIdx, selectedPosition.row);
|
|
1629
2087
|
}
|
|
1630
|
-
function
|
|
2088
|
+
function handleCopy() {
|
|
1631
2089
|
const {
|
|
1632
|
-
idx
|
|
1633
|
-
rowIdx
|
|
1634
|
-
} =
|
|
1635
|
-
|
|
1636
|
-
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
|
|
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
|
|
1641
2102
|
});
|
|
1642
2103
|
}
|
|
1643
|
-
function
|
|
1644
|
-
if (!
|
|
2104
|
+
function handlePaste() {
|
|
2105
|
+
if (!onPaste || !onRowsChange || copiedCell === null || !isCellEditable2(selectedPosition)) {
|
|
1645
2106
|
return;
|
|
2107
|
+
}
|
|
1646
2108
|
const {
|
|
1647
|
-
idx
|
|
1648
|
-
rowIdx
|
|
1649
|
-
} =
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
|
|
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
|
|
1654
2118
|
});
|
|
1655
|
-
|
|
2119
|
+
updateRow(rowIdx, updatedTargetRow);
|
|
1656
2120
|
}
|
|
1657
|
-
function
|
|
1658
|
-
if (!
|
|
2121
|
+
function handleCellInput(event) {
|
|
2122
|
+
if (!selectedCellIsWithinViewportBounds)
|
|
1659
2123
|
return;
|
|
1660
|
-
const
|
|
1661
|
-
if (
|
|
2124
|
+
const row2 = rows[selectedPosition.rowIdx];
|
|
2125
|
+
if (isGroupRow(row2))
|
|
1662
2126
|
return;
|
|
1663
2127
|
const {
|
|
1664
|
-
key
|
|
1665
|
-
shiftKey
|
|
1666
|
-
} =
|
|
1667
|
-
if (
|
|
1668
|
-
|
|
1669
|
-
const
|
|
1670
|
-
|
|
1671
|
-
row:
|
|
1672
|
-
checked: !
|
|
1673
|
-
isShiftClick:
|
|
1674
|
-
})
|
|
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();
|
|
1675
2140
|
return;
|
|
1676
2141
|
}
|
|
1677
|
-
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
}
|
|
1694
|
-
function
|
|
1695
|
-
idx
|
|
1696
|
-
|
|
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
|
|
1697
2168
|
}) {
|
|
1698
|
-
return
|
|
2169
|
+
return rowIdx >= minRowIdx && rowIdx <= maxRowIdx && isColIdxWithinSelectionBounds(idx);
|
|
1699
2170
|
}
|
|
1700
|
-
function
|
|
1701
|
-
idx
|
|
1702
|
-
rowIdx
|
|
2171
|
+
function isCellWithinViewportBounds({
|
|
2172
|
+
idx,
|
|
2173
|
+
rowIdx
|
|
1703
2174
|
}) {
|
|
1704
|
-
return
|
|
1705
|
-
}
|
|
1706
|
-
function
|
|
1707
|
-
return
|
|
1708
|
-
columns
|
|
1709
|
-
rows
|
|
1710
|
-
selectedPosition:
|
|
1711
|
-
isGroupRow
|
|
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
|
|
1712
2183
|
});
|
|
1713
2184
|
}
|
|
1714
|
-
function
|
|
1715
|
-
if (
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
|
|
1728
|
-
|
|
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
|
+
}
|
|
1729
2205
|
}
|
|
1730
|
-
function
|
|
2206
|
+
function scrollToColumn(idx) {
|
|
1731
2207
|
const {
|
|
1732
|
-
current
|
|
1733
|
-
} =
|
|
1734
|
-
if (
|
|
2208
|
+
current
|
|
2209
|
+
} = gridRef;
|
|
2210
|
+
if (!current)
|
|
2211
|
+
return;
|
|
2212
|
+
if (idx > lastFrozenColumnIndex) {
|
|
1735
2213
|
const {
|
|
1736
|
-
rowIdx
|
|
1737
|
-
} =
|
|
1738
|
-
if (!
|
|
1739
|
-
rowIdx
|
|
1740
|
-
idx
|
|
2214
|
+
rowIdx
|
|
2215
|
+
} = selectedPosition;
|
|
2216
|
+
if (!isCellWithinSelectionBounds({
|
|
2217
|
+
rowIdx,
|
|
2218
|
+
idx
|
|
1741
2219
|
}))
|
|
1742
2220
|
return;
|
|
1743
2221
|
const {
|
|
1744
|
-
clientWidth
|
|
1745
|
-
} =
|
|
1746
|
-
|
|
1747
|
-
|
|
1748
|
-
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
|
|
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
|
|
1757
2237
|
});
|
|
1758
|
-
if (
|
|
2238
|
+
if (colSpan !== void 0) {
|
|
1759
2239
|
const {
|
|
1760
|
-
left:
|
|
1761
|
-
width:
|
|
1762
|
-
} =
|
|
1763
|
-
|
|
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;
|
|
1764
2252
|
}
|
|
1765
|
-
const q = $ < Xe + et, He = K > a + Xe, j = Oe ? -1 : 1;
|
|
1766
|
-
q ? r.scrollLeft = ($ - et) * j : He && (r.scrollLeft = (K - a) * j);
|
|
1767
2253
|
}
|
|
1768
2254
|
}
|
|
1769
|
-
function
|
|
2255
|
+
function getNextPosition(key, ctrlKey, shiftKey) {
|
|
1770
2256
|
const {
|
|
1771
|
-
idx
|
|
1772
|
-
rowIdx
|
|
1773
|
-
} =
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
|
|
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;
|
|
1780
2268
|
break;
|
|
1781
2269
|
}
|
|
1782
2270
|
}
|
|
1783
|
-
if (
|
|
2271
|
+
if (parentRowIdx !== -1) {
|
|
1784
2272
|
return {
|
|
1785
|
-
idx
|
|
1786
|
-
rowIdx:
|
|
2273
|
+
idx,
|
|
2274
|
+
rowIdx: parentRowIdx
|
|
1787
2275
|
};
|
|
2276
|
+
}
|
|
1788
2277
|
}
|
|
1789
|
-
switch (
|
|
2278
|
+
switch (key) {
|
|
1790
2279
|
case "ArrowUp":
|
|
1791
2280
|
return {
|
|
1792
|
-
idx
|
|
1793
|
-
rowIdx:
|
|
2281
|
+
idx,
|
|
2282
|
+
rowIdx: rowIdx - 1
|
|
1794
2283
|
};
|
|
1795
2284
|
case "ArrowDown":
|
|
1796
2285
|
return {
|
|
1797
|
-
idx
|
|
1798
|
-
rowIdx:
|
|
2286
|
+
idx,
|
|
2287
|
+
rowIdx: rowIdx + 1
|
|
1799
2288
|
};
|
|
1800
|
-
case
|
|
2289
|
+
case leftKey:
|
|
1801
2290
|
return {
|
|
1802
|
-
idx:
|
|
1803
|
-
rowIdx
|
|
2291
|
+
idx: idx - 1,
|
|
2292
|
+
rowIdx
|
|
1804
2293
|
};
|
|
1805
|
-
case
|
|
2294
|
+
case rightKey:
|
|
1806
2295
|
return {
|
|
1807
|
-
idx:
|
|
1808
|
-
rowIdx
|
|
2296
|
+
idx: idx + 1,
|
|
2297
|
+
rowIdx
|
|
1809
2298
|
};
|
|
1810
2299
|
case "Tab":
|
|
1811
2300
|
return {
|
|
1812
|
-
idx:
|
|
1813
|
-
rowIdx
|
|
2301
|
+
idx: idx + (shiftKey ? -1 : 1),
|
|
2302
|
+
rowIdx
|
|
1814
2303
|
};
|
|
1815
2304
|
case "Home":
|
|
1816
|
-
|
|
1817
|
-
|
|
1818
|
-
|
|
1819
|
-
|
|
2305
|
+
if (isRowSelected)
|
|
2306
|
+
return {
|
|
2307
|
+
idx,
|
|
2308
|
+
rowIdx: 0
|
|
2309
|
+
};
|
|
2310
|
+
return {
|
|
1820
2311
|
idx: 0,
|
|
1821
|
-
rowIdx:
|
|
2312
|
+
rowIdx: ctrlKey ? minRowIdx : rowIdx
|
|
1822
2313
|
};
|
|
1823
2314
|
case "End":
|
|
1824
|
-
|
|
1825
|
-
|
|
1826
|
-
|
|
1827
|
-
|
|
1828
|
-
|
|
1829
|
-
|
|
2315
|
+
if (isRowSelected)
|
|
2316
|
+
return {
|
|
2317
|
+
idx,
|
|
2318
|
+
rowIdx: rows.length - 1
|
|
2319
|
+
};
|
|
2320
|
+
return {
|
|
2321
|
+
idx: maxColIdx,
|
|
2322
|
+
rowIdx: ctrlKey ? maxRowIdx : rowIdx
|
|
1830
2323
|
};
|
|
1831
2324
|
case "PageUp": {
|
|
1832
|
-
if (
|
|
1833
|
-
return
|
|
1834
|
-
const
|
|
2325
|
+
if (selectedPosition.rowIdx === minRowIdx)
|
|
2326
|
+
return selectedPosition;
|
|
2327
|
+
const nextRowY = getRowTop(rowIdx) + getRowHeight(rowIdx) - clientHeight;
|
|
1835
2328
|
return {
|
|
1836
|
-
idx
|
|
1837
|
-
rowIdx:
|
|
2329
|
+
idx,
|
|
2330
|
+
rowIdx: nextRowY > 0 ? findRowIdx(nextRowY) : 0
|
|
1838
2331
|
};
|
|
1839
2332
|
}
|
|
1840
2333
|
case "PageDown": {
|
|
1841
|
-
if (
|
|
1842
|
-
return
|
|
1843
|
-
const
|
|
2334
|
+
if (selectedPosition.rowIdx >= rows.length)
|
|
2335
|
+
return selectedPosition;
|
|
2336
|
+
const nextRowY = getRowTop(rowIdx) + clientHeight;
|
|
1844
2337
|
return {
|
|
1845
|
-
idx
|
|
1846
|
-
rowIdx:
|
|
2338
|
+
idx,
|
|
2339
|
+
rowIdx: nextRowY < totalRowHeight ? findRowIdx(nextRowY) : rows.length - 1
|
|
1847
2340
|
};
|
|
1848
2341
|
}
|
|
1849
2342
|
default:
|
|
1850
|
-
return
|
|
2343
|
+
return selectedPosition;
|
|
1851
2344
|
}
|
|
1852
2345
|
}
|
|
1853
|
-
function
|
|
2346
|
+
function navigate(event) {
|
|
1854
2347
|
const {
|
|
1855
|
-
key
|
|
1856
|
-
shiftKey
|
|
1857
|
-
} =
|
|
1858
|
-
let
|
|
1859
|
-
if (
|
|
1860
|
-
if (
|
|
1861
|
-
shiftKey
|
|
1862
|
-
cellNavigationMode
|
|
1863
|
-
maxColIdx
|
|
1864
|
-
minRowIdx
|
|
1865
|
-
maxRowIdx
|
|
1866
|
-
selectedPosition
|
|
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
|
|
1867
2360
|
})) {
|
|
1868
|
-
|
|
2361
|
+
commitEditorChanges();
|
|
1869
2362
|
return;
|
|
1870
2363
|
}
|
|
1871
|
-
|
|
2364
|
+
mode = cellNavigationMode === "NONE" ? "CHANGE_ROW" : cellNavigationMode;
|
|
1872
2365
|
}
|
|
1873
|
-
|
|
1874
|
-
const
|
|
1875
|
-
|
|
2366
|
+
event.preventDefault();
|
|
2367
|
+
const ctrlKey = isCtrlKeyHeldDown(event);
|
|
2368
|
+
const nextPosition = getNextPosition(key, ctrlKey, shiftKey);
|
|
2369
|
+
if (isSamePosition(selectedPosition, nextPosition))
|
|
1876
2370
|
return;
|
|
1877
|
-
const
|
|
1878
|
-
columns
|
|
1879
|
-
colSpanColumns
|
|
1880
|
-
rows
|
|
1881
|
-
summaryRows
|
|
1882
|
-
minRowIdx
|
|
1883
|
-
maxRowIdx
|
|
1884
|
-
lastFrozenColumnIndex
|
|
1885
|
-
cellNavigationMode:
|
|
1886
|
-
currentPosition:
|
|
1887
|
-
nextPosition
|
|
1888
|
-
isCellWithinBounds:
|
|
1889
|
-
isGroupRow
|
|
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
|
|
1890
2384
|
});
|
|
1891
|
-
|
|
2385
|
+
selectCell(nextSelectedCellPosition);
|
|
1892
2386
|
}
|
|
1893
|
-
function
|
|
1894
|
-
if (
|
|
2387
|
+
function getDraggedOverCellIdx(currentRowIdx) {
|
|
2388
|
+
if (draggedOverRowIdx === void 0)
|
|
1895
2389
|
return;
|
|
1896
2390
|
const {
|
|
1897
|
-
rowIdx
|
|
1898
|
-
} =
|
|
1899
|
-
|
|
2391
|
+
rowIdx
|
|
2392
|
+
} = selectedPosition;
|
|
2393
|
+
const isDraggedOver = rowIdx < draggedOverRowIdx ? rowIdx < currentRowIdx && currentRowIdx <= draggedOverRowIdx : rowIdx > currentRowIdx && currentRowIdx >= draggedOverRowIdx;
|
|
2394
|
+
return isDraggedOver ? selectedPosition.idx : void 0;
|
|
1900
2395
|
}
|
|
1901
|
-
function
|
|
1902
|
-
if (
|
|
1903
|
-
return
|
|
2396
|
+
function getLayoutCssVars() {
|
|
2397
|
+
if (autoResizeColumn === null)
|
|
2398
|
+
return layoutCssVars;
|
|
1904
2399
|
const {
|
|
1905
|
-
gridTemplateColumns
|
|
1906
|
-
} =
|
|
1907
|
-
|
|
1908
|
-
|
|
1909
|
-
|
|
2400
|
+
gridTemplateColumns
|
|
2401
|
+
} = layoutCssVars;
|
|
2402
|
+
const newSizes = gridTemplateColumns.split(" ");
|
|
2403
|
+
newSizes[autoResizeColumn.idx] = "max-content";
|
|
2404
|
+
return {
|
|
2405
|
+
...layoutCssVars,
|
|
2406
|
+
gridTemplateColumns: newSizes.join(" ")
|
|
1910
2407
|
};
|
|
1911
2408
|
}
|
|
1912
|
-
function
|
|
1913
|
-
if (
|
|
1914
|
-
return
|
|
1915
|
-
|
|
1916
|
-
|
|
1917
|
-
|
|
1918
|
-
|
|
1919
|
-
|
|
1920
|
-
|
|
1921
|
-
|
|
1922
|
-
|
|
1923
|
-
|
|
1924
|
-
|
|
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
|
+
});
|
|
1925
2424
|
}
|
|
1926
|
-
function
|
|
1927
|
-
if (
|
|
2425
|
+
function getCellEditor(rowIdx) {
|
|
2426
|
+
if (selectedPosition.rowIdx !== rowIdx || selectedPosition.mode === "SELECT")
|
|
1928
2427
|
return;
|
|
1929
2428
|
const {
|
|
1930
|
-
idx
|
|
1931
|
-
row:
|
|
1932
|
-
} =
|
|
2429
|
+
idx,
|
|
2430
|
+
row: row2
|
|
2431
|
+
} = selectedPosition;
|
|
2432
|
+
const column = columns[idx];
|
|
2433
|
+
const colSpan = getColSpan(column, lastFrozenColumnIndex, {
|
|
1933
2434
|
type: "ROW",
|
|
1934
|
-
row:
|
|
1935
|
-
})
|
|
1936
|
-
|
|
1937
|
-
|
|
1938
|
-
|
|
2435
|
+
row: row2
|
|
2436
|
+
});
|
|
2437
|
+
const closeEditor = () => {
|
|
2438
|
+
setSelectedPosition(({
|
|
2439
|
+
idx: idx2,
|
|
2440
|
+
rowIdx: rowIdx2
|
|
1939
2441
|
}) => ({
|
|
1940
|
-
idx:
|
|
1941
|
-
rowIdx:
|
|
2442
|
+
idx: idx2,
|
|
2443
|
+
rowIdx: rowIdx2,
|
|
1942
2444
|
mode: "SELECT"
|
|
1943
2445
|
}));
|
|
1944
|
-
}, L = (K, P) => {
|
|
1945
|
-
P ? (Pe(u.rowIdx, K), $()) : be((q) => ({
|
|
1946
|
-
...q,
|
|
1947
|
-
row: K
|
|
1948
|
-
}));
|
|
1949
2446
|
};
|
|
1950
|
-
|
|
1951
|
-
|
|
1952
|
-
|
|
1953
|
-
|
|
1954
|
-
|
|
1955
|
-
|
|
1956
|
-
|
|
1957
|
-
|
|
1958
|
-
|
|
1959
|
-
|
|
1960
|
-
|
|
1961
|
-
|
|
1962
|
-
|
|
1963
|
-
|
|
1964
|
-
|
|
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;
|
|
1965
2479
|
const {
|
|
1966
|
-
idx:
|
|
1967
|
-
rowIdx:
|
|
1968
|
-
} =
|
|
1969
|
-
|
|
1970
|
-
|
|
1971
|
-
|
|
1972
|
-
const
|
|
1973
|
-
|
|
1974
|
-
|
|
1975
|
-
|
|
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)) {
|
|
1976
2500
|
({
|
|
1977
|
-
startRowIndex
|
|
1978
|
-
} =
|
|
1979
|
-
const
|
|
1980
|
-
|
|
1981
|
-
"aria-level":
|
|
1982
|
-
"aria-setsize":
|
|
1983
|
-
"aria-posinset":
|
|
1984
|
-
"aria-rowindex":
|
|
1985
|
-
"aria-selected":
|
|
1986
|
-
id:
|
|
1987
|
-
groupKey:
|
|
1988
|
-
viewportColumns:
|
|
1989
|
-
childRows:
|
|
1990
|
-
rowIdx
|
|
1991
|
-
row:
|
|
1992
|
-
gridRowStart
|
|
1993
|
-
height:
|
|
1994
|
-
level:
|
|
1995
|
-
isExpanded:
|
|
1996
|
-
selectedCellIdx:
|
|
1997
|
-
isRowSelected:
|
|
1998
|
-
selectGroup:
|
|
1999
|
-
toggleGroup:
|
|
2000
|
-
},
|
|
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));
|
|
2001
2525
|
continue;
|
|
2002
2526
|
}
|
|
2003
|
-
|
|
2004
|
-
let
|
|
2005
|
-
|
|
2006
|
-
|
|
2007
|
-
|
|
2008
|
-
|
|
2009
|
-
|
|
2010
|
-
|
|
2011
|
-
|
|
2012
|
-
|
|
2013
|
-
|
|
2014
|
-
|
|
2015
|
-
|
|
2016
|
-
|
|
2017
|
-
|
|
2018
|
-
|
|
2019
|
-
|
|
2020
|
-
|
|
2021
|
-
|
|
2022
|
-
|
|
2023
|
-
|
|
2024
|
-
|
|
2025
|
-
|
|
2026
|
-
|
|
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));
|
|
2027
2558
|
}
|
|
2028
|
-
return
|
|
2029
|
-
}
|
|
2030
|
-
(
|
|
2031
|
-
|
|
2032
|
-
|
|
2033
|
-
|
|
2034
|
-
|
|
2035
|
-
|
|
2036
|
-
|
|
2037
|
-
|
|
2038
|
-
|
|
2039
|
-
|
|
2040
|
-
|
|
2041
|
-
|
|
2042
|
-
|
|
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),
|
|
2043
2582
|
style: {
|
|
2044
|
-
...
|
|
2045
|
-
scrollPaddingInlineStart:
|
|
2046
|
-
scrollPaddingBlock:
|
|
2047
|
-
gridTemplateRows:
|
|
2048
|
-
"--rdg-header-row-height": `${
|
|
2049
|
-
"--rdg-summary-row-height": `${
|
|
2050
|
-
"--rdg-sign":
|
|
2051
|
-
...
|
|
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()
|
|
2052
2591
|
},
|
|
2053
|
-
dir:
|
|
2054
|
-
ref:
|
|
2055
|
-
onScroll:
|
|
2056
|
-
onKeyDown:
|
|
2057
|
-
"data-testid":
|
|
2058
|
-
children: [
|
|
2059
|
-
ref:
|
|
2060
|
-
tabIndex:
|
|
2061
|
-
className:
|
|
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]),
|
|
2062
2601
|
style: {
|
|
2063
|
-
gridRowStart:
|
|
2602
|
+
gridRowStart: selectedPosition.rowIdx + 2
|
|
2064
2603
|
},
|
|
2065
|
-
onKeyDown:
|
|
2066
|
-
}), /* @__PURE__ */
|
|
2067
|
-
value:
|
|
2068
|
-
children: [/* @__PURE__ */
|
|
2069
|
-
columns:
|
|
2070
|
-
onColumnResize:
|
|
2071
|
-
allRowsSelected
|
|
2072
|
-
onAllRowsSelectionChange:
|
|
2073
|
-
sortColumns
|
|
2074
|
-
onSortColumnsChange
|
|
2075
|
-
lastFrozenColumnIndex
|
|
2076
|
-
selectedCellIdx:
|
|
2077
|
-
selectCell:
|
|
2078
|
-
shouldFocusGrid: !
|
|
2079
|
-
direction
|
|
2080
|
-
}),
|
|
2081
|
-
children: [/* @__PURE__ */
|
|
2082
|
-
value:
|
|
2083
|
-
children:
|
|
2084
|
-
}),
|
|
2085
|
-
const
|
|
2086
|
-
|
|
2087
|
-
|
|
2088
|
-
|
|
2089
|
-
|
|
2090
|
-
|
|
2091
|
-
|
|
2092
|
-
|
|
2093
|
-
|
|
2094
|
-
|
|
2095
|
-
|
|
2096
|
-
|
|
2097
|
-
|
|
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);
|
|
2098
2641
|
})]
|
|
2099
2642
|
})]
|
|
2100
2643
|
})]
|
|
2101
2644
|
});
|
|
2102
2645
|
}
|
|
2103
|
-
function
|
|
2104
|
-
return
|
|
2646
|
+
function isSamePosition(p1, p2) {
|
|
2647
|
+
return p1.idx === p2.idx && p1.rowIdx === p2.rowIdx;
|
|
2105
2648
|
}
|
|
2106
|
-
const
|
|
2107
|
-
var
|
|
2108
|
-
|
|
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" });
|
|
2109
2652
|
export {
|
|
2110
|
-
|
|
2111
|
-
|
|
2112
|
-
|
|
2113
|
-
|
|
2114
|
-
|
|
2653
|
+
DataGrid$1 as D,
|
|
2654
|
+
HeaderRenderer as H,
|
|
2655
|
+
SELECT_COLUMN_KEY as S,
|
|
2656
|
+
SelectCellFormatter as a,
|
|
2657
|
+
useRowSelection as u
|
|
2115
2658
|
};
|