@lensui/lens-table 0.1.93 → 0.1.95
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/dist/index.cjs +79 -22
- package/dist/index.js +140 -79
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -953,8 +953,22 @@ function TextEditor({ value, type, min, max, integer = false, style, labels, onC
|
|
|
953
953
|
var import_react6 = require("react");
|
|
954
954
|
var import_react_dom = require("react-dom");
|
|
955
955
|
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
956
|
-
function TextAreaEditor({
|
|
956
|
+
function TextAreaEditor({
|
|
957
|
+
value,
|
|
958
|
+
title,
|
|
959
|
+
maxLength,
|
|
960
|
+
inline = false,
|
|
961
|
+
keepRightBorderVisible = false,
|
|
962
|
+
style,
|
|
963
|
+
labels,
|
|
964
|
+
onChange,
|
|
965
|
+
onCommit,
|
|
966
|
+
onCancel
|
|
967
|
+
}) {
|
|
957
968
|
const [open, setOpen] = (0, import_react6.useState)(false);
|
|
969
|
+
const inputRef = (0, import_react6.useRef)(null);
|
|
970
|
+
const textareaRef = (0, import_react6.useRef)(null);
|
|
971
|
+
const selectionRef = (0, import_react6.useRef)(null);
|
|
958
972
|
const inlineHeaderHeight = typeof style.height === "number" ? style.height : 34;
|
|
959
973
|
const editorStyle = inline && open ? {
|
|
960
974
|
...style,
|
|
@@ -966,6 +980,28 @@ function TextAreaEditor({ value, title, maxLength, inline = false, keepRightBord
|
|
|
966
980
|
if (event.key === "Enter") onCommit(value);
|
|
967
981
|
if (event.key === "Escape") onCancel();
|
|
968
982
|
};
|
|
983
|
+
const rememberSelection = (control) => {
|
|
984
|
+
if (!control || control.selectionStart === null || control.selectionEnd === null)
|
|
985
|
+
return;
|
|
986
|
+
selectionRef.current = {
|
|
987
|
+
start: control.selectionStart,
|
|
988
|
+
end: control.selectionEnd,
|
|
989
|
+
direction: control.selectionDirection ?? "none"
|
|
990
|
+
};
|
|
991
|
+
};
|
|
992
|
+
(0, import_react6.useLayoutEffect)(() => {
|
|
993
|
+
if (!inline || !selectionRef.current) return;
|
|
994
|
+
const control = open ? textareaRef.current : inputRef.current;
|
|
995
|
+
if (!control) return;
|
|
996
|
+
const selection = selectionRef.current;
|
|
997
|
+
const length = control.value.length;
|
|
998
|
+
control.focus();
|
|
999
|
+
control.setSelectionRange(
|
|
1000
|
+
Math.min(selection.start, length),
|
|
1001
|
+
Math.min(selection.end, length),
|
|
1002
|
+
selection.direction
|
|
1003
|
+
);
|
|
1004
|
+
}, [inline, open]);
|
|
969
1005
|
return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
|
|
970
1006
|
"div",
|
|
971
1007
|
{
|
|
@@ -975,6 +1011,7 @@ function TextAreaEditor({ value, title, maxLength, inline = false, keepRightBord
|
|
|
975
1011
|
!(inline && open) && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
976
1012
|
"input",
|
|
977
1013
|
{
|
|
1014
|
+
ref: inputRef,
|
|
978
1015
|
value,
|
|
979
1016
|
autoFocus: true,
|
|
980
1017
|
maxLength,
|
|
@@ -998,7 +1035,12 @@ function TextAreaEditor({ value, title, maxLength, inline = false, keepRightBord
|
|
|
998
1035
|
setOpen(true);
|
|
999
1036
|
return;
|
|
1000
1037
|
}
|
|
1001
|
-
|
|
1038
|
+
if (open) {
|
|
1039
|
+
textareaRef.current?.focus();
|
|
1040
|
+
return;
|
|
1041
|
+
}
|
|
1042
|
+
rememberSelection(inputRef.current);
|
|
1043
|
+
setOpen(true);
|
|
1002
1044
|
},
|
|
1003
1045
|
children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(MultilineEditorIcon, {})
|
|
1004
1046
|
}
|
|
@@ -1006,6 +1048,7 @@ function TextAreaEditor({ value, title, maxLength, inline = false, keepRightBord
|
|
|
1006
1048
|
open && inline && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
1007
1049
|
"textarea",
|
|
1008
1050
|
{
|
|
1051
|
+
ref: textareaRef,
|
|
1009
1052
|
className: "rvg-textarea-inline",
|
|
1010
1053
|
"aria-label": title,
|
|
1011
1054
|
"data-rvg-preserve-edit": true,
|
|
@@ -1016,30 +1059,44 @@ function TextAreaEditor({ value, title, maxLength, inline = false, keepRightBord
|
|
|
1016
1059
|
onChange: (event) => onChange(event.target.value),
|
|
1017
1060
|
onKeyDown: (event) => {
|
|
1018
1061
|
event.stopPropagation();
|
|
1019
|
-
if ((event.metaKey || event.ctrlKey) && event.key === "Enter")
|
|
1020
|
-
|
|
1062
|
+
if ((event.metaKey || event.ctrlKey) && event.key === "Enter")
|
|
1063
|
+
onCommit(value);
|
|
1064
|
+
if (event.key === "Escape") {
|
|
1065
|
+
rememberSelection(event.currentTarget);
|
|
1066
|
+
setOpen(false);
|
|
1067
|
+
}
|
|
1021
1068
|
}
|
|
1022
1069
|
}
|
|
1023
1070
|
),
|
|
1024
1071
|
open && !inline && (0, import_react_dom.createPortal)(
|
|
1025
|
-
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "rvg-textarea-backdrop", role: "presentation", children: /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
"textarea",
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1072
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "rvg-textarea-backdrop", role: "presentation", children: /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
|
|
1073
|
+
"section",
|
|
1074
|
+
{
|
|
1075
|
+
className: "rvg-textarea-dialog",
|
|
1076
|
+
role: "dialog",
|
|
1077
|
+
"aria-modal": "true",
|
|
1078
|
+
"aria-label": title,
|
|
1079
|
+
children: [
|
|
1080
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("header", { children: title }),
|
|
1081
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
1082
|
+
"textarea",
|
|
1083
|
+
{
|
|
1084
|
+
value,
|
|
1085
|
+
autoFocus: true,
|
|
1086
|
+
maxLength,
|
|
1087
|
+
onChange: (event) => onChange(event.target.value),
|
|
1088
|
+
onKeyDown: (event) => {
|
|
1089
|
+
event.stopPropagation();
|
|
1090
|
+
if ((event.metaKey || event.ctrlKey) && event.key === "Enter")
|
|
1091
|
+
onCommit(value);
|
|
1092
|
+
if (event.key === "Escape") setOpen(false);
|
|
1093
|
+
}
|
|
1094
|
+
}
|
|
1095
|
+
),
|
|
1096
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("footer", { children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("button", { type: "button", onClick: () => onCommit(value), children: labels.confirm }) })
|
|
1097
|
+
]
|
|
1098
|
+
}
|
|
1099
|
+
) }),
|
|
1043
1100
|
document.body
|
|
1044
1101
|
)
|
|
1045
1102
|
]
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// src/Table.tsx
|
|
2
|
-
import { forwardRef, useImperativeHandle, Fragment as Fragment2, useCallback as useCallback3, useEffect as useEffect3, useLayoutEffect as
|
|
2
|
+
import { forwardRef, useImperativeHandle, Fragment as Fragment2, useCallback as useCallback3, useEffect as useEffect3, useLayoutEffect as useLayoutEffect4, useMemo as useMemo2, useRef as useRef5, useState as useState6 } from "react";
|
|
3
3
|
import { flushSync } from "react-dom";
|
|
4
4
|
|
|
5
5
|
// src/components/EmptyState.tsx
|
|
@@ -920,11 +920,29 @@ function TextEditor({ value, type, min, max, integer = false, style, labels, onC
|
|
|
920
920
|
}
|
|
921
921
|
|
|
922
922
|
// src/components/editors/TextAreaEditor.tsx
|
|
923
|
-
import {
|
|
923
|
+
import {
|
|
924
|
+
useLayoutEffect as useLayoutEffect3,
|
|
925
|
+
useRef as useRef4,
|
|
926
|
+
useState as useState4
|
|
927
|
+
} from "react";
|
|
924
928
|
import { createPortal } from "react-dom";
|
|
925
929
|
import { jsx as jsx7, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
926
|
-
function TextAreaEditor({
|
|
930
|
+
function TextAreaEditor({
|
|
931
|
+
value,
|
|
932
|
+
title,
|
|
933
|
+
maxLength,
|
|
934
|
+
inline = false,
|
|
935
|
+
keepRightBorderVisible = false,
|
|
936
|
+
style,
|
|
937
|
+
labels,
|
|
938
|
+
onChange,
|
|
939
|
+
onCommit,
|
|
940
|
+
onCancel
|
|
941
|
+
}) {
|
|
927
942
|
const [open, setOpen] = useState4(false);
|
|
943
|
+
const inputRef = useRef4(null);
|
|
944
|
+
const textareaRef = useRef4(null);
|
|
945
|
+
const selectionRef = useRef4(null);
|
|
928
946
|
const inlineHeaderHeight = typeof style.height === "number" ? style.height : 34;
|
|
929
947
|
const editorStyle = inline && open ? {
|
|
930
948
|
...style,
|
|
@@ -936,6 +954,28 @@ function TextAreaEditor({ value, title, maxLength, inline = false, keepRightBord
|
|
|
936
954
|
if (event.key === "Enter") onCommit(value);
|
|
937
955
|
if (event.key === "Escape") onCancel();
|
|
938
956
|
};
|
|
957
|
+
const rememberSelection = (control) => {
|
|
958
|
+
if (!control || control.selectionStart === null || control.selectionEnd === null)
|
|
959
|
+
return;
|
|
960
|
+
selectionRef.current = {
|
|
961
|
+
start: control.selectionStart,
|
|
962
|
+
end: control.selectionEnd,
|
|
963
|
+
direction: control.selectionDirection ?? "none"
|
|
964
|
+
};
|
|
965
|
+
};
|
|
966
|
+
useLayoutEffect3(() => {
|
|
967
|
+
if (!inline || !selectionRef.current) return;
|
|
968
|
+
const control = open ? textareaRef.current : inputRef.current;
|
|
969
|
+
if (!control) return;
|
|
970
|
+
const selection = selectionRef.current;
|
|
971
|
+
const length = control.value.length;
|
|
972
|
+
control.focus();
|
|
973
|
+
control.setSelectionRange(
|
|
974
|
+
Math.min(selection.start, length),
|
|
975
|
+
Math.min(selection.end, length),
|
|
976
|
+
selection.direction
|
|
977
|
+
);
|
|
978
|
+
}, [inline, open]);
|
|
939
979
|
return /* @__PURE__ */ jsxs7(
|
|
940
980
|
"div",
|
|
941
981
|
{
|
|
@@ -945,6 +985,7 @@ function TextAreaEditor({ value, title, maxLength, inline = false, keepRightBord
|
|
|
945
985
|
!(inline && open) && /* @__PURE__ */ jsx7(
|
|
946
986
|
"input",
|
|
947
987
|
{
|
|
988
|
+
ref: inputRef,
|
|
948
989
|
value,
|
|
949
990
|
autoFocus: true,
|
|
950
991
|
maxLength,
|
|
@@ -968,7 +1009,12 @@ function TextAreaEditor({ value, title, maxLength, inline = false, keepRightBord
|
|
|
968
1009
|
setOpen(true);
|
|
969
1010
|
return;
|
|
970
1011
|
}
|
|
971
|
-
|
|
1012
|
+
if (open) {
|
|
1013
|
+
textareaRef.current?.focus();
|
|
1014
|
+
return;
|
|
1015
|
+
}
|
|
1016
|
+
rememberSelection(inputRef.current);
|
|
1017
|
+
setOpen(true);
|
|
972
1018
|
},
|
|
973
1019
|
children: /* @__PURE__ */ jsx7(MultilineEditorIcon, {})
|
|
974
1020
|
}
|
|
@@ -976,6 +1022,7 @@ function TextAreaEditor({ value, title, maxLength, inline = false, keepRightBord
|
|
|
976
1022
|
open && inline && /* @__PURE__ */ jsx7(
|
|
977
1023
|
"textarea",
|
|
978
1024
|
{
|
|
1025
|
+
ref: textareaRef,
|
|
979
1026
|
className: "rvg-textarea-inline",
|
|
980
1027
|
"aria-label": title,
|
|
981
1028
|
"data-rvg-preserve-edit": true,
|
|
@@ -986,30 +1033,44 @@ function TextAreaEditor({ value, title, maxLength, inline = false, keepRightBord
|
|
|
986
1033
|
onChange: (event) => onChange(event.target.value),
|
|
987
1034
|
onKeyDown: (event) => {
|
|
988
1035
|
event.stopPropagation();
|
|
989
|
-
if ((event.metaKey || event.ctrlKey) && event.key === "Enter")
|
|
990
|
-
|
|
1036
|
+
if ((event.metaKey || event.ctrlKey) && event.key === "Enter")
|
|
1037
|
+
onCommit(value);
|
|
1038
|
+
if (event.key === "Escape") {
|
|
1039
|
+
rememberSelection(event.currentTarget);
|
|
1040
|
+
setOpen(false);
|
|
1041
|
+
}
|
|
991
1042
|
}
|
|
992
1043
|
}
|
|
993
1044
|
),
|
|
994
1045
|
open && !inline && createPortal(
|
|
995
|
-
/* @__PURE__ */ jsx7("div", { className: "rvg-textarea-backdrop", role: "presentation", children: /* @__PURE__ */ jsxs7(
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
"textarea",
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1046
|
+
/* @__PURE__ */ jsx7("div", { className: "rvg-textarea-backdrop", role: "presentation", children: /* @__PURE__ */ jsxs7(
|
|
1047
|
+
"section",
|
|
1048
|
+
{
|
|
1049
|
+
className: "rvg-textarea-dialog",
|
|
1050
|
+
role: "dialog",
|
|
1051
|
+
"aria-modal": "true",
|
|
1052
|
+
"aria-label": title,
|
|
1053
|
+
children: [
|
|
1054
|
+
/* @__PURE__ */ jsx7("header", { children: title }),
|
|
1055
|
+
/* @__PURE__ */ jsx7(
|
|
1056
|
+
"textarea",
|
|
1057
|
+
{
|
|
1058
|
+
value,
|
|
1059
|
+
autoFocus: true,
|
|
1060
|
+
maxLength,
|
|
1061
|
+
onChange: (event) => onChange(event.target.value),
|
|
1062
|
+
onKeyDown: (event) => {
|
|
1063
|
+
event.stopPropagation();
|
|
1064
|
+
if ((event.metaKey || event.ctrlKey) && event.key === "Enter")
|
|
1065
|
+
onCommit(value);
|
|
1066
|
+
if (event.key === "Escape") setOpen(false);
|
|
1067
|
+
}
|
|
1068
|
+
}
|
|
1069
|
+
),
|
|
1070
|
+
/* @__PURE__ */ jsx7("footer", { children: /* @__PURE__ */ jsx7("button", { type: "button", onClick: () => onCommit(value), children: labels.confirm }) })
|
|
1071
|
+
]
|
|
1072
|
+
}
|
|
1073
|
+
) }),
|
|
1013
1074
|
document.body
|
|
1014
1075
|
)
|
|
1015
1076
|
]
|
|
@@ -2074,8 +2135,8 @@ function TableInner({
|
|
|
2074
2135
|
const baseHeaderHeight = layout?.headerHeight ?? headerHeightProp ?? 40;
|
|
2075
2136
|
const headerDepth = useMemo2(() => Math.max(1, ...sourceColumns.map(getColumnDepth)), [sourceColumns]);
|
|
2076
2137
|
const { language, labels } = useMemo2(() => resolveGridLocale(locale), [locale]);
|
|
2077
|
-
const customHeaderContentRefs =
|
|
2078
|
-
const customHeaderMeasurementsRef =
|
|
2138
|
+
const customHeaderContentRefs = useRef5(/* @__PURE__ */ new Map());
|
|
2139
|
+
const customHeaderMeasurementsRef = useRef5(/* @__PURE__ */ new Map());
|
|
2079
2140
|
const [measuredHeaderRowHeights, setMeasuredHeaderRowHeights] = useState6([]);
|
|
2080
2141
|
const headerRowHeights = useMemo2(() => Array.from({ length: headerDepth }, (_, level) => Math.max(baseHeaderHeight, measuredHeaderRowHeights[level] ?? 0)), [baseHeaderHeight, headerDepth, measuredHeaderRowHeights]);
|
|
2081
2142
|
const headerRowOffsets = useMemo2(() => {
|
|
@@ -2111,7 +2172,7 @@ function TableInner({
|
|
|
2111
2172
|
const customContextMenuConfig = typeof contextMenuConfig === "object" ? contextMenuConfig : void 0;
|
|
2112
2173
|
const [resizedColumnWidths, setResizedColumnWidths] = useState6({});
|
|
2113
2174
|
const leafSourceColumns = useMemo2(() => flattenDataColumns(sourceColumns), [sourceColumns]);
|
|
2114
|
-
const sourceColumnWidthsRef =
|
|
2175
|
+
const sourceColumnWidthsRef = useRef5(new Map(leafSourceColumns.map((column) => [column.key, column.width])));
|
|
2115
2176
|
const showRowCheckbox = Boolean(rowSelection) && (typeof rowSelection !== "object" || rowSelection.showCheckbox !== false);
|
|
2116
2177
|
const rowSelectionIndicator = typeof rowSelection === "object" ? rowSelection.indicator ?? "checkbox" : "checkbox";
|
|
2117
2178
|
const rowSelectionColumnWidth = typeof rowSelection === "object" ? Math.max(24, rowSelection.columnWidth ?? 44) : 44;
|
|
@@ -2164,54 +2225,54 @@ function TableInner({
|
|
|
2164
2225
|
});
|
|
2165
2226
|
return levels;
|
|
2166
2227
|
}, [columns, headerCells, headerDepth]);
|
|
2167
|
-
const canvasRef =
|
|
2168
|
-
const scrollerRef =
|
|
2169
|
-
const rootRef =
|
|
2170
|
-
const frameRef =
|
|
2171
|
-
const textFrameRef =
|
|
2172
|
-
const textLayoutScrollTopRef =
|
|
2173
|
-
const toastTimerRef =
|
|
2174
|
-
const headerTooltipTimerRef =
|
|
2175
|
-
const cellTooltipTimerRef =
|
|
2176
|
-
const pendingHeaderTooltipKeyRef =
|
|
2177
|
-
const pendingCellTooltipKeyRef =
|
|
2178
|
-
const clickedCellRef =
|
|
2179
|
-
const rowAnchorRef =
|
|
2180
|
-
const columnAnchorRef =
|
|
2181
|
-
const columnDragRef =
|
|
2182
|
-
const columnOrderDragRef =
|
|
2183
|
-
const columnOrderLongPressTimerRef =
|
|
2184
|
-
const rowOrderDragRef =
|
|
2185
|
-
const dragGuideRef =
|
|
2186
|
-
const rowDragGuideRef =
|
|
2187
|
-
const selectionFocusRef =
|
|
2188
|
-
const selectionEdgeTargetRef =
|
|
2189
|
-
const verticalScrollbarRef =
|
|
2190
|
-
const verticalScrollbarThumbRef =
|
|
2191
|
-
const verticalScrollbarDragRef =
|
|
2192
|
-
const horizontalScrollbarRef =
|
|
2193
|
-
const horizontalScrollbarThumbRef =
|
|
2194
|
-
const horizontalScrollbarDragRef =
|
|
2195
|
-
const verticalScrollbarVisibilityTimerRef =
|
|
2196
|
-
const horizontalScrollbarVisibilityTimerRef =
|
|
2197
|
-
const rowByKeyRef =
|
|
2198
|
-
const rowIndexByKeyRef =
|
|
2199
|
-
const headerIconsRef =
|
|
2200
|
-
const scrollingHeaderIconsRef =
|
|
2201
|
-
const scrollingTextRef =
|
|
2202
|
-
const filterRef =
|
|
2203
|
-
const contextMenuRef =
|
|
2204
|
-
const suppressClickRef =
|
|
2205
|
-
const hasCompletedLoadRef =
|
|
2206
|
-
const validColumnDropRef =
|
|
2207
|
-
const hoveredHeaderActionRef =
|
|
2208
|
-
const hoveredRowIndexRef =
|
|
2228
|
+
const canvasRef = useRef5(null);
|
|
2229
|
+
const scrollerRef = useRef5(null);
|
|
2230
|
+
const rootRef = useRef5(null);
|
|
2231
|
+
const frameRef = useRef5(null);
|
|
2232
|
+
const textFrameRef = useRef5(null);
|
|
2233
|
+
const textLayoutScrollTopRef = useRef5(0);
|
|
2234
|
+
const toastTimerRef = useRef5(null);
|
|
2235
|
+
const headerTooltipTimerRef = useRef5(null);
|
|
2236
|
+
const cellTooltipTimerRef = useRef5(null);
|
|
2237
|
+
const pendingHeaderTooltipKeyRef = useRef5("");
|
|
2238
|
+
const pendingCellTooltipKeyRef = useRef5("");
|
|
2239
|
+
const clickedCellRef = useRef5(null);
|
|
2240
|
+
const rowAnchorRef = useRef5(null);
|
|
2241
|
+
const columnAnchorRef = useRef5(null);
|
|
2242
|
+
const columnDragRef = useRef5(null);
|
|
2243
|
+
const columnOrderDragRef = useRef5(null);
|
|
2244
|
+
const columnOrderLongPressTimerRef = useRef5(null);
|
|
2245
|
+
const rowOrderDragRef = useRef5(null);
|
|
2246
|
+
const dragGuideRef = useRef5(null);
|
|
2247
|
+
const rowDragGuideRef = useRef5(null);
|
|
2248
|
+
const selectionFocusRef = useRef5(null);
|
|
2249
|
+
const selectionEdgeTargetRef = useRef5(null);
|
|
2250
|
+
const verticalScrollbarRef = useRef5(null);
|
|
2251
|
+
const verticalScrollbarThumbRef = useRef5(null);
|
|
2252
|
+
const verticalScrollbarDragRef = useRef5(null);
|
|
2253
|
+
const horizontalScrollbarRef = useRef5(null);
|
|
2254
|
+
const horizontalScrollbarThumbRef = useRef5(null);
|
|
2255
|
+
const horizontalScrollbarDragRef = useRef5(null);
|
|
2256
|
+
const verticalScrollbarVisibilityTimerRef = useRef5(null);
|
|
2257
|
+
const horizontalScrollbarVisibilityTimerRef = useRef5(null);
|
|
2258
|
+
const rowByKeyRef = useRef5(/* @__PURE__ */ new Map());
|
|
2259
|
+
const rowIndexByKeyRef = useRef5(/* @__PURE__ */ new Map());
|
|
2260
|
+
const headerIconsRef = useRef5(null);
|
|
2261
|
+
const scrollingHeaderIconsRef = useRef5(null);
|
|
2262
|
+
const scrollingTextRef = useRef5(null);
|
|
2263
|
+
const filterRef = useRef5(null);
|
|
2264
|
+
const contextMenuRef = useRef5(null);
|
|
2265
|
+
const suppressClickRef = useRef5(false);
|
|
2266
|
+
const hasCompletedLoadRef = useRef5(!loading);
|
|
2267
|
+
const validColumnDropRef = useRef5(null);
|
|
2268
|
+
const hoveredHeaderActionRef = useRef5(null);
|
|
2269
|
+
const hoveredRowIndexRef = useRef5(null);
|
|
2209
2270
|
const [viewport, setViewport] = useState6({ width: 0, height: typeof height === "number" ? height : FALLBACK_HEIGHT });
|
|
2210
2271
|
const [horizontalScrollbarHeight, setHorizontalScrollbarHeight] = useState6(0);
|
|
2211
2272
|
const [availableHeight, setAvailableHeight] = useState6(FALLBACK_HEIGHT);
|
|
2212
2273
|
const resolvedHeight = typeof height === "number" ? height : availableHeight;
|
|
2213
2274
|
const [scrollPosition, setScrollPosition] = useState6({ left: 0, top: 0 });
|
|
2214
|
-
const scrollRef =
|
|
2275
|
+
const scrollRef = useRef5({ left: 0, top: 0 });
|
|
2215
2276
|
const [rowKeys, setRowKeys] = useControllableKeys(selectedRowKeys, defaultSelectedRowKeys, (keys) => {
|
|
2216
2277
|
if (!onSelectedRowChange) return;
|
|
2217
2278
|
const missing = new Set(keys.filter((key) => !rowByKeyRef.current.has(key)));
|
|
@@ -2311,7 +2372,7 @@ function TableInner({
|
|
|
2311
2372
|
return changed ? nextHeights : current;
|
|
2312
2373
|
});
|
|
2313
2374
|
}, [activeCustomHeaderLevels, baseHeaderHeight, headerDepth]);
|
|
2314
|
-
|
|
2375
|
+
useLayoutEffect4(() => {
|
|
2315
2376
|
customHeaderContentRefs.current.forEach((_, key) => {
|
|
2316
2377
|
if (!activeCustomHeaderLevels.has(key)) customHeaderContentRefs.current.delete(key);
|
|
2317
2378
|
});
|
|
@@ -2365,12 +2426,12 @@ function TableInner({
|
|
|
2365
2426
|
const [annotationContent, setAnnotationContent] = useState6("");
|
|
2366
2427
|
const [annotationOpen, setAnnotationOpen] = useState6(false);
|
|
2367
2428
|
const [annotationPlacement, setAnnotationPlacement] = useState6("right-down");
|
|
2368
|
-
const originalCellValuesRef =
|
|
2429
|
+
const originalCellValuesRef = useRef5(/* @__PURE__ */ new Map());
|
|
2369
2430
|
const [pendingDeletedRowKeys, setPendingDeletedRowKeys] = useState6(() => /* @__PURE__ */ new Set());
|
|
2370
2431
|
const [pendingInserts, setPendingInserts] = useState6(() => []);
|
|
2371
2432
|
const [insertedRowKeys, setInsertedRowKeys] = useState6(() => /* @__PURE__ */ new Set());
|
|
2372
2433
|
const [rowOrderKeys, setRowOrderKeys] = useState6(null);
|
|
2373
|
-
const settledPendingInsertIdsRef =
|
|
2434
|
+
const settledPendingInsertIdsRef = useRef5(/* @__PURE__ */ new Set());
|
|
2374
2435
|
const getDataRowKey = useCallback3((row, index) => {
|
|
2375
2436
|
return typeof rowKey === "function" ? rowKey(row, index) : rowKey ? row[rowKey] : getDefaultRowKey(row, index);
|
|
2376
2437
|
}, [rowKey]);
|
|
@@ -2473,7 +2534,7 @@ function TableInner({
|
|
|
2473
2534
|
}, [columns, onSelectedCellChange, rows]);
|
|
2474
2535
|
const [selection, setSelection] = useControllableValue(resolvedSelectedCell, resolvedDefaultSelectedCell, handleSelectedCellChange);
|
|
2475
2536
|
const [selectionRange, setSelectionRange] = useState6(null);
|
|
2476
|
-
const rangeDragRef =
|
|
2537
|
+
const rangeDragRef = useRef5(null);
|
|
2477
2538
|
useEffect3(() => {
|
|
2478
2539
|
if (!selection) return void 0;
|
|
2479
2540
|
const handleOutsidePointerDown = (event) => {
|
|
@@ -2528,7 +2589,7 @@ function TableInner({
|
|
|
2528
2589
|
return changed ? next : current;
|
|
2529
2590
|
});
|
|
2530
2591
|
}, [getDataRowKey, pendingDeletedRowKeys.size, sourceRows]);
|
|
2531
|
-
|
|
2592
|
+
useLayoutEffect4(() => {
|
|
2532
2593
|
if (!editing) return;
|
|
2533
2594
|
if (selection?.rowKey === editing.rowKey && selection.columnKey === editing.columnKey) return;
|
|
2534
2595
|
setEditing(null);
|
|
@@ -2934,7 +2995,7 @@ function TableInner({
|
|
|
2934
2995
|
target.classList.remove("is-shape-syncing");
|
|
2935
2996
|
}
|
|
2936
2997
|
}, [getSelectionEdgeIndicator]);
|
|
2937
|
-
|
|
2998
|
+
useLayoutEffect4(() => {
|
|
2938
2999
|
const element = scrollerRef.current;
|
|
2939
3000
|
if (!element) return;
|
|
2940
3001
|
const root = element.parentElement;
|
|
@@ -3107,7 +3168,7 @@ function TableInner({
|
|
|
3107
3168
|
horizontalThumb.style.width = `${Math.min(trackWidth, thumbWidth)}px`;
|
|
3108
3169
|
horizontalThumb.style.transform = `translateX(${thumbLeft}px)`;
|
|
3109
3170
|
}, [autoHeight, bodyTop, bottomSummaryHeight, effectiveHeight, fixedHeader, fixedWidth, realContentHeight, renderHeight, rightFixedWidth, viewport.width]);
|
|
3110
|
-
|
|
3171
|
+
useLayoutEffect4(() => {
|
|
3111
3172
|
updateCustomScrollbars();
|
|
3112
3173
|
}, [contentHeight, contentWidth, updateCustomScrollbars, viewport.height, viewport.width]);
|
|
3113
3174
|
const handleVerticalScrollbarPointerDown = useCallback3((event) => {
|
|
@@ -3230,7 +3291,7 @@ function TableInner({
|
|
|
3230
3291
|
horizontalScrollbarDragRef.current = null;
|
|
3231
3292
|
showCustomScrollbar("horizontal");
|
|
3232
3293
|
}, [showCustomScrollbar]);
|
|
3233
|
-
|
|
3294
|
+
useLayoutEffect4(() => {
|
|
3234
3295
|
textLayoutScrollTopRef.current = scrollPosition.top;
|
|
3235
3296
|
const clips = rootRef.current?.querySelectorAll(".rvg-body-text-clip");
|
|
3236
3297
|
clips?.forEach((clip) => {
|
|
@@ -4861,7 +4922,7 @@ function TableInner({
|
|
|
4861
4922
|
"--rvg-corner-hover-height-extension": "4px"
|
|
4862
4923
|
} : null
|
|
4863
4924
|
} : void 0;
|
|
4864
|
-
|
|
4925
|
+
useLayoutEffect4(() => {
|
|
4865
4926
|
syncSelectionEdgeTarget(scrollPosition.left, scrollPosition.top);
|
|
4866
4927
|
}, [scrollPosition.left, scrollPosition.top, syncSelectionEdgeTarget]);
|
|
4867
4928
|
const handleContextMenu = (event) => {
|