@lensui/lens-table 0.1.64 → 0.1.66
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 +633 -410
- package/dist/index.css +151 -0
- package/dist/index.d.cts +24 -3
- package/dist/index.d.ts +24 -3
- package/dist/index.js +554 -331
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -29,8 +29,8 @@ __export(index_exports, {
|
|
|
29
29
|
module.exports = __toCommonJS(index_exports);
|
|
30
30
|
|
|
31
31
|
// src/Table.tsx
|
|
32
|
-
var
|
|
33
|
-
var
|
|
32
|
+
var import_react8 = require("react");
|
|
33
|
+
var import_react_dom2 = require("react-dom");
|
|
34
34
|
|
|
35
35
|
// src/components/EmptyState.tsx
|
|
36
36
|
var import_react = require("react");
|
|
@@ -229,6 +229,7 @@ function DefaultEmptyState({ label = ZH_CN_GRID_LABELS.empty }) {
|
|
|
229
229
|
// src/components/editors/ChoiceEditor.tsx
|
|
230
230
|
var import_portal = require("@ark-ui/react/portal");
|
|
231
231
|
var import_select = require("@ark-ui/react/select");
|
|
232
|
+
var import_react2 = require("react");
|
|
232
233
|
|
|
233
234
|
// src/icons/gridIcons.tsx
|
|
234
235
|
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
@@ -261,6 +262,13 @@ function ChoiceChevronIcon() {
|
|
|
261
262
|
function ChoiceCheckIcon() {
|
|
262
263
|
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("svg", { className: "rvg-choice-check", viewBox: "0 0 16 16", "aria-hidden": "true", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("path", { d: "m3.5 8 2.6 2.6L12.5 4" }) });
|
|
263
264
|
}
|
|
265
|
+
function MultilineEditorIcon() {
|
|
266
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("svg", { className: "rvg-multiline-icon", viewBox: "0 0 16 16", "aria-hidden": "true", children: [
|
|
267
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("circle", { cx: "3.5", cy: "8", r: "1" }),
|
|
268
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("circle", { cx: "8", cy: "8", r: "1" }),
|
|
269
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("circle", { cx: "12.5", cy: "8", r: "1" })
|
|
270
|
+
] });
|
|
271
|
+
}
|
|
264
272
|
function HeaderDragIcon({ className, style }) {
|
|
265
273
|
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("svg", { className, style, viewBox: "0 0 14 14", "aria-hidden": "true", children: [
|
|
266
274
|
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("circle", { cx: "7", cy: "2.5", r: "1.25" }),
|
|
@@ -324,12 +332,126 @@ function LoadingSpinnerIcon() {
|
|
|
324
332
|
|
|
325
333
|
// src/components/editors/ChoiceEditor.tsx
|
|
326
334
|
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
327
|
-
function
|
|
328
|
-
const
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
335
|
+
function SearchableChoiceEditor({ value, options, allowCustomValue, maxDropdownHeight, style, labels, onChange, onCommit, onCancel }) {
|
|
336
|
+
const editorRef = (0, import_react2.useRef)(null);
|
|
337
|
+
const popupRef = (0, import_react2.useRef)(null);
|
|
338
|
+
const originalValueRef = (0, import_react2.useRef)(value);
|
|
339
|
+
const listboxId = (0, import_react2.useId)();
|
|
340
|
+
const originalValue = originalValueRef.current;
|
|
341
|
+
const [inputValue, setInputValue] = (0, import_react2.useState)(value);
|
|
342
|
+
const [activeIndex, setActiveIndex] = (0, import_react2.useState)(0);
|
|
343
|
+
const [popupStyle, setPopupStyle] = (0, import_react2.useState)({});
|
|
344
|
+
const filteredOptions = (0, import_react2.useMemo)(() => {
|
|
345
|
+
const query = inputValue.trim().toLocaleLowerCase();
|
|
346
|
+
if (!query || query === originalValue.toLocaleLowerCase()) return options;
|
|
347
|
+
return options.filter((option) => option.label.toLocaleLowerCase().includes(query) || option.value.toLocaleLowerCase().includes(query));
|
|
348
|
+
}, [inputValue, options, originalValue]);
|
|
349
|
+
(0, import_react2.useLayoutEffect)(() => {
|
|
350
|
+
const positionPopup = () => {
|
|
351
|
+
const rect = editorRef.current?.getBoundingClientRect();
|
|
352
|
+
if (!rect) return;
|
|
353
|
+
const availableBelow = window.innerHeight - rect.bottom - 8;
|
|
354
|
+
const availableAbove = rect.top - 8;
|
|
355
|
+
if (availableBelow < 120 && availableAbove > availableBelow) {
|
|
356
|
+
setPopupStyle({
|
|
357
|
+
position: "fixed",
|
|
358
|
+
bottom: window.innerHeight - rect.top + 4,
|
|
359
|
+
left: rect.left,
|
|
360
|
+
width: rect.width,
|
|
361
|
+
maxHeight: Math.min(maxDropdownHeight, availableAbove)
|
|
362
|
+
});
|
|
363
|
+
return;
|
|
364
|
+
}
|
|
365
|
+
setPopupStyle({
|
|
366
|
+
position: "fixed",
|
|
367
|
+
top: rect.bottom + 4,
|
|
368
|
+
left: rect.left,
|
|
369
|
+
width: rect.width,
|
|
370
|
+
maxHeight: Math.min(maxDropdownHeight, Math.max(80, availableBelow))
|
|
371
|
+
});
|
|
372
|
+
};
|
|
373
|
+
positionPopup();
|
|
374
|
+
window.addEventListener("resize", positionPopup);
|
|
375
|
+
window.addEventListener("scroll", positionPopup, true);
|
|
376
|
+
return () => {
|
|
377
|
+
window.removeEventListener("resize", positionPopup);
|
|
378
|
+
window.removeEventListener("scroll", positionPopup, true);
|
|
379
|
+
};
|
|
380
|
+
}, [maxDropdownHeight]);
|
|
381
|
+
(0, import_react2.useEffect)(() => {
|
|
382
|
+
const handleOutsidePointer = (event) => {
|
|
383
|
+
const target = event.target;
|
|
384
|
+
if (!(target instanceof Node)) return;
|
|
385
|
+
if (editorRef.current?.contains(target) || popupRef.current?.contains(target)) return;
|
|
386
|
+
onCommit(allowCustomValue ? inputValue || originalValue : originalValue);
|
|
387
|
+
};
|
|
388
|
+
document.addEventListener("pointerdown", handleOutsidePointer, true);
|
|
389
|
+
return () => document.removeEventListener("pointerdown", handleOutsidePointer, true);
|
|
390
|
+
}, [allowCustomValue, inputValue, onCommit, originalValue]);
|
|
391
|
+
const selectOption = (option) => {
|
|
392
|
+
onChange(option.value);
|
|
393
|
+
onCommit(option.value);
|
|
394
|
+
};
|
|
395
|
+
const handleKeyDown = (event) => {
|
|
396
|
+
event.stopPropagation();
|
|
397
|
+
if (event.key === "Escape") onCancel();
|
|
398
|
+
if (event.key === "ArrowDown") {
|
|
399
|
+
event.preventDefault();
|
|
400
|
+
setActiveIndex((index) => Math.min(filteredOptions.length - 1, index + 1));
|
|
401
|
+
}
|
|
402
|
+
if (event.key === "ArrowUp") {
|
|
403
|
+
event.preventDefault();
|
|
404
|
+
setActiveIndex((index) => Math.max(0, index - 1));
|
|
405
|
+
}
|
|
406
|
+
if (event.key === "Enter") {
|
|
407
|
+
event.preventDefault();
|
|
408
|
+
const option = filteredOptions[activeIndex];
|
|
409
|
+
if (option) selectOption(option);
|
|
410
|
+
else if (allowCustomValue) onCommit(inputValue || originalValue);
|
|
411
|
+
}
|
|
412
|
+
};
|
|
413
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { ref: editorRef, className: "rvg-choice-editor rvg-searchable-choice-editor", style, children: [
|
|
414
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
415
|
+
"input",
|
|
416
|
+
{
|
|
417
|
+
className: inputValue === originalValue ? "is-pristine" : void 0,
|
|
418
|
+
value: inputValue,
|
|
419
|
+
autoFocus: true,
|
|
420
|
+
"aria-label": labels.search,
|
|
421
|
+
"aria-controls": listboxId,
|
|
422
|
+
onFocus: (event) => event.currentTarget.select(),
|
|
423
|
+
onChange: (event) => {
|
|
424
|
+
setInputValue(event.target.value);
|
|
425
|
+
onChange(event.target.value);
|
|
426
|
+
setActiveIndex(0);
|
|
427
|
+
},
|
|
428
|
+
onKeyDown: handleKeyDown
|
|
429
|
+
}
|
|
430
|
+
),
|
|
431
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "rvg-searchable-choice-indicator", children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(ChoiceChevronIcon, {}) }),
|
|
432
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_portal.Portal, { children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { ref: popupRef, id: listboxId, role: "listbox", className: "rvg-choice-content rvg-searchable-choice-content", style: popupStyle, children: filteredOptions.map((option, index) => /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
|
|
433
|
+
"button",
|
|
434
|
+
{
|
|
435
|
+
type: "button",
|
|
436
|
+
role: "option",
|
|
437
|
+
"aria-selected": option.value === originalValue,
|
|
438
|
+
className: `rvg-choice-item${index === activeIndex ? " is-active" : ""}${option.value === originalValue ? " is-selected" : ""}`,
|
|
439
|
+
onPointerDown: (event) => event.preventDefault(),
|
|
440
|
+
onMouseEnter: () => setActiveIndex(index),
|
|
441
|
+
onClick: () => selectOption(option),
|
|
442
|
+
children: [
|
|
443
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { children: option.label }),
|
|
444
|
+
option.value === originalValue && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(ChoiceCheckIcon, {})
|
|
445
|
+
]
|
|
446
|
+
},
|
|
447
|
+
option.value
|
|
448
|
+
)) }) })
|
|
449
|
+
] });
|
|
450
|
+
}
|
|
451
|
+
function ChoiceEditor(props) {
|
|
452
|
+
const { value, options, searchable = false, maxDropdownHeight = 240, style, labels, onChange, onCommit, onCancel } = props;
|
|
453
|
+
if (searchable) return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(SearchableChoiceEditor, { ...props, maxDropdownHeight });
|
|
454
|
+
const collection = (0, import_select.createListCollection)({ items: options, itemToValue: (item) => item.value, itemToString: (item) => item.label });
|
|
333
455
|
return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
|
|
334
456
|
import_select.Select.Root,
|
|
335
457
|
{
|
|
@@ -360,7 +482,7 @@ function ChoiceEditor({ value, options, style, labels, onChange, onCommit, onCan
|
|
|
360
482
|
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_select.Select.ValueText, { placeholder: labels.choose }),
|
|
361
483
|
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_select.Select.Indicator, { children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(ChoiceChevronIcon, {}) })
|
|
362
484
|
] }) }),
|
|
363
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_portal.Portal, { children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_select.Select.Positioner, { children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_select.Select.Content, { className: "rvg-choice-content", children: options.map((option) => /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_select.Select.Item, { className: "rvg-choice-item", item: option, children: [
|
|
485
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_portal.Portal, { children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_select.Select.Positioner, { children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_select.Select.Content, { className: "rvg-choice-content", style: { maxHeight: maxDropdownHeight, overflowY: "auto" }, children: options.map((option) => /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_select.Select.Item, { className: "rvg-choice-item", item: option, children: [
|
|
364
486
|
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_select.Select.ItemText, { children: option.label }),
|
|
365
487
|
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_select.Select.ItemIndicator, { children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(ChoiceCheckIcon, {}) })
|
|
366
488
|
] }, option.value)) }) }) }),
|
|
@@ -371,7 +493,7 @@ function ChoiceEditor({ value, options, style, labels, onChange, onCommit, onCan
|
|
|
371
493
|
}
|
|
372
494
|
|
|
373
495
|
// src/components/editors/DateEditor.tsx
|
|
374
|
-
var
|
|
496
|
+
var import_react4 = require("react");
|
|
375
497
|
var import_date_picker = require("@ark-ui/react/date-picker");
|
|
376
498
|
var import_portal2 = require("@ark-ui/react/portal");
|
|
377
499
|
var import_date2 = require("@internationalized/date");
|
|
@@ -418,22 +540,22 @@ function timeFormatHasSeconds(format, value) {
|
|
|
418
540
|
}
|
|
419
541
|
|
|
420
542
|
// src/components/editors/TimeEditors.tsx
|
|
421
|
-
var
|
|
543
|
+
var import_react3 = require("react");
|
|
422
544
|
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
423
545
|
function CompactTimeEditor({ value, range, showSeconds, style, labels, onChange, onCommit, onCancel }) {
|
|
424
546
|
const values = range ? value.split(" ~ ") : [value];
|
|
425
|
-
const [dropdownOpen, setDropdownOpen] = (0,
|
|
426
|
-
const optionRefs = (0,
|
|
427
|
-
const editorRef = (0,
|
|
428
|
-
const hasPositionedTimeRef = (0,
|
|
429
|
-
(0,
|
|
547
|
+
const [dropdownOpen, setDropdownOpen] = (0, import_react3.useState)(true);
|
|
548
|
+
const optionRefs = (0, import_react3.useRef)([[], []]);
|
|
549
|
+
const editorRef = (0, import_react3.useRef)(null);
|
|
550
|
+
const hasPositionedTimeRef = (0, import_react3.useRef)(false);
|
|
551
|
+
(0, import_react3.useEffect)(() => {
|
|
430
552
|
const closeOnOutsidePointer = (event) => {
|
|
431
553
|
if (!editorRef.current?.contains(event.target)) setDropdownOpen(false);
|
|
432
554
|
};
|
|
433
555
|
document.addEventListener("pointerdown", closeOnOutsidePointer, true);
|
|
434
556
|
return () => document.removeEventListener("pointerdown", closeOnOutsidePointer, true);
|
|
435
557
|
}, []);
|
|
436
|
-
(0,
|
|
558
|
+
(0, import_react3.useLayoutEffect)(() => {
|
|
437
559
|
if (!dropdownOpen) return;
|
|
438
560
|
const behavior = hasPositionedTimeRef.current ? "smooth" : "auto";
|
|
439
561
|
values.forEach((time, index) => {
|
|
@@ -508,14 +630,14 @@ function CompactTimeEditor({ value, range, showSeconds, style, labels, onChange,
|
|
|
508
630
|
] });
|
|
509
631
|
}
|
|
510
632
|
function DateTimePanel({ values, labels, showSeconds, onChange }) {
|
|
511
|
-
const [activeIndex, setActiveIndex] = (0,
|
|
633
|
+
const [activeIndex, setActiveIndex] = (0, import_react3.useState)(0);
|
|
512
634
|
const activeValue = values[activeIndex] ?? "";
|
|
513
635
|
const [, hour = "00", minute = "00", second = "00"] = activeValue.match(/[T ](\d{2}):(\d{2})(?::(\d{2}))?/) ?? [];
|
|
514
|
-
const hoursRef = (0,
|
|
515
|
-
const minutesRef = (0,
|
|
516
|
-
const secondsRef = (0,
|
|
517
|
-
const positionedRef = (0,
|
|
518
|
-
(0,
|
|
636
|
+
const hoursRef = (0, import_react3.useRef)(null);
|
|
637
|
+
const minutesRef = (0, import_react3.useRef)(null);
|
|
638
|
+
const secondsRef = (0, import_react3.useRef)(null);
|
|
639
|
+
const positionedRef = (0, import_react3.useRef)(false);
|
|
640
|
+
(0, import_react3.useLayoutEffect)(() => {
|
|
519
641
|
const behavior = positionedRef.current ? "smooth" : "auto";
|
|
520
642
|
hoursRef.current?.scrollTo({ top: Number(hour) * 28, behavior });
|
|
521
643
|
minutesRef.current?.scrollTo({ top: Number(minute) * 28, behavior });
|
|
@@ -550,7 +672,7 @@ function DateTimePanel({ values, labels, showSeconds, onChange }) {
|
|
|
550
672
|
// src/components/editors/DateEditor.tsx
|
|
551
673
|
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
552
674
|
function DateEditor({ editor, value: draft, style, locale, labels, onChange, onCommit, onCancel }) {
|
|
553
|
-
const [rangeHoverValue, setRangeHoverValue] = (0,
|
|
675
|
+
const [rangeHoverValue, setRangeHoverValue] = (0, import_react4.useState)();
|
|
554
676
|
const editorType = editor.type;
|
|
555
677
|
const isRange = editorType === "date-range" || editorType === "date-time-range";
|
|
556
678
|
const isYear = editorType === "year";
|
|
@@ -693,11 +815,21 @@ function DateEditor({ editor, value: draft, style, locale, labels, onChange, onC
|
|
|
693
815
|
}
|
|
694
816
|
|
|
695
817
|
// src/components/editors/TextEditor.tsx
|
|
818
|
+
var import_react5 = require("react");
|
|
696
819
|
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
697
|
-
function TextEditor({ value, type, style, labels, onChange, onCommit, onCancel }) {
|
|
820
|
+
function TextEditor({ value, type, min, max, integer = false, style, labels, onChange, onCommit, onCancel }) {
|
|
821
|
+
const originalValueRef = (0, import_react5.useRef)(value);
|
|
822
|
+
const normalizeNumber = (draft) => {
|
|
823
|
+
if (draft.trim() === "") return "";
|
|
824
|
+
const parsed = Number(draft);
|
|
825
|
+
if (!Number.isFinite(parsed)) return originalValueRef.current;
|
|
826
|
+
const integral = integer ? Math.trunc(parsed) : parsed;
|
|
827
|
+
return String(Math.min(max ?? Infinity, Math.max(min ?? -Infinity, integral)));
|
|
828
|
+
};
|
|
829
|
+
const commitValue = () => onCommit(type === "number" ? normalizeNumber(value) : value);
|
|
698
830
|
const handleKeyDown = (event) => {
|
|
699
831
|
event.stopPropagation();
|
|
700
|
-
if (event.key === "Enter")
|
|
832
|
+
if (event.key === "Enter") commitValue();
|
|
701
833
|
if (event.key === "Escape") onCancel();
|
|
702
834
|
};
|
|
703
835
|
return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "rvg-native-editor has-clear", style, children: [
|
|
@@ -705,11 +837,19 @@ function TextEditor({ value, type, style, labels, onChange, onCommit, onCancel }
|
|
|
705
837
|
"input",
|
|
706
838
|
{
|
|
707
839
|
type,
|
|
840
|
+
min: type === "number" ? min : void 0,
|
|
841
|
+
max: type === "number" ? max : void 0,
|
|
842
|
+
step: type === "number" && integer ? 1 : void 0,
|
|
843
|
+
inputMode: type === "number" ? "numeric" : void 0,
|
|
708
844
|
style: { font: "var(--rvg-font-size-body) Inter, ui-sans-serif, system-ui, sans-serif", textAlign: style.textAlign },
|
|
709
845
|
value,
|
|
710
846
|
autoFocus: true,
|
|
711
|
-
onChange: (event) =>
|
|
712
|
-
|
|
847
|
+
onChange: (event) => {
|
|
848
|
+
const next = event.target.value;
|
|
849
|
+
if (type === "number" && integer && next !== "" && !/^-?\d+$/.test(next)) return;
|
|
850
|
+
onChange(next);
|
|
851
|
+
},
|
|
852
|
+
onBlur: commitValue,
|
|
713
853
|
onKeyDown: handleKeyDown
|
|
714
854
|
}
|
|
715
855
|
),
|
|
@@ -733,6 +873,66 @@ function TextEditor({ value, type, style, labels, onChange, onCommit, onCancel }
|
|
|
733
873
|
] });
|
|
734
874
|
}
|
|
735
875
|
|
|
876
|
+
// src/components/editors/TextAreaEditor.tsx
|
|
877
|
+
var import_react6 = require("react");
|
|
878
|
+
var import_react_dom = require("react-dom");
|
|
879
|
+
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
880
|
+
function TextAreaEditor({ value, title, maxLength, style, labels, onChange, onCommit, onCancel }) {
|
|
881
|
+
const [open, setOpen] = (0, import_react6.useState)(false);
|
|
882
|
+
const handleKeyDown = (event) => {
|
|
883
|
+
event.stopPropagation();
|
|
884
|
+
if (event.key === "Enter") onCommit(value);
|
|
885
|
+
if (event.key === "Escape") onCancel();
|
|
886
|
+
};
|
|
887
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "rvg-native-editor rvg-textarea-editor", style, children: [
|
|
888
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
889
|
+
"input",
|
|
890
|
+
{
|
|
891
|
+
value,
|
|
892
|
+
autoFocus: true,
|
|
893
|
+
maxLength,
|
|
894
|
+
onChange: (event) => onChange(event.target.value),
|
|
895
|
+
onKeyDown: handleKeyDown
|
|
896
|
+
}
|
|
897
|
+
),
|
|
898
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
899
|
+
"button",
|
|
900
|
+
{
|
|
901
|
+
type: "button",
|
|
902
|
+
className: "rvg-textarea-trigger",
|
|
903
|
+
"aria-label": title,
|
|
904
|
+
onPointerDown: (event) => {
|
|
905
|
+
event.preventDefault();
|
|
906
|
+
event.stopPropagation();
|
|
907
|
+
},
|
|
908
|
+
onClick: () => setOpen(true),
|
|
909
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(MultilineEditorIcon, {})
|
|
910
|
+
}
|
|
911
|
+
),
|
|
912
|
+
open && (0, import_react_dom.createPortal)(
|
|
913
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "rvg-textarea-backdrop", role: "presentation", children: /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("section", { className: "rvg-textarea-dialog", role: "dialog", "aria-modal": "true", "aria-label": title, children: [
|
|
914
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("header", { children: title }),
|
|
915
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
916
|
+
"textarea",
|
|
917
|
+
{
|
|
918
|
+
value,
|
|
919
|
+
autoFocus: true,
|
|
920
|
+
maxLength,
|
|
921
|
+
onChange: (event) => onChange(event.target.value),
|
|
922
|
+
onKeyDown: (event) => {
|
|
923
|
+
event.stopPropagation();
|
|
924
|
+
if ((event.metaKey || event.ctrlKey) && event.key === "Enter") onCommit(value);
|
|
925
|
+
if (event.key === "Escape") setOpen(false);
|
|
926
|
+
}
|
|
927
|
+
}
|
|
928
|
+
),
|
|
929
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("footer", { children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("button", { type: "button", onClick: () => onCommit(value), children: labels.confirm }) })
|
|
930
|
+
] }) }),
|
|
931
|
+
document.body
|
|
932
|
+
)
|
|
933
|
+
] });
|
|
934
|
+
}
|
|
935
|
+
|
|
736
936
|
// src/icons/domIcons.ts
|
|
737
937
|
function createRowDragHandleSvg() {
|
|
738
938
|
const svg = document.createElementNS("http://www.w3.org/2000/svg", "svg");
|
|
@@ -1028,7 +1228,7 @@ function paintGrid(options) {
|
|
|
1028
1228
|
ctx.fillStyle = colors.insertedFill;
|
|
1029
1229
|
ctx.fillRect(x, y, cellWidth, cellHeight);
|
|
1030
1230
|
}
|
|
1031
|
-
const isSelectedCell = !column.rowDragHandle && !column.rowSelection && !column.rowNumber && selection?.rowIndex === rowIndex && selection.columnIndex === columnIndex && selection.rowKey === rowKey && selection.columnKey === column.key;
|
|
1231
|
+
const isSelectedCell = !column.rowDragHandle && !column.rowSelection && !column.rowNumber && column.suppressSelectionStyle !== true && selection?.rowIndex === rowIndex && selection.columnIndex === columnIndex && selection.rowKey === rowKey && selection.columnKey === column.key;
|
|
1032
1232
|
const annotation = cellAnnotations.get(`${typeof rowKey}:${String(rowKey)}\0${column.key}`);
|
|
1033
1233
|
const rawValue = column.dataIndex === void 0 ? void 0 : row[column.dataIndex];
|
|
1034
1234
|
const cellStyle = column.cellStyle?.(rawValue, row, rowIndex);
|
|
@@ -1360,7 +1560,7 @@ function paintGrid(options) {
|
|
|
1360
1560
|
}
|
|
1361
1561
|
const selectedRow = selection ? rows[selection.rowIndex] : void 0;
|
|
1362
1562
|
const hasValidSelection = Boolean(selection && selectedRow && getRowKey(selectedRow, selection.rowIndex) === selection.rowKey);
|
|
1363
|
-
if (selection && hasValidSelection && !selectionRange && !rowDragPreview) {
|
|
1563
|
+
if (selection && hasValidSelection && !selectionRange && !rowDragPreview && columns[selection.columnIndex]?.suppressSelectionStyle !== true) {
|
|
1364
1564
|
const metric = metrics[selection.columnIndex];
|
|
1365
1565
|
if (metric) {
|
|
1366
1566
|
const fixedSide = columns[selection.columnIndex].fixed;
|
|
@@ -1432,20 +1632,20 @@ function paintGrid(options) {
|
|
|
1432
1632
|
}
|
|
1433
1633
|
|
|
1434
1634
|
// src/hooks/useControllable.ts
|
|
1435
|
-
var
|
|
1635
|
+
var import_react7 = require("react");
|
|
1436
1636
|
function useControllableKeys(value, defaultValue, onChange) {
|
|
1437
|
-
const [internal, setInternal] = (0,
|
|
1637
|
+
const [internal, setInternal] = (0, import_react7.useState)(defaultValue ?? []);
|
|
1438
1638
|
const keys = value === void 0 ? internal : value;
|
|
1439
|
-
const setKeys = (0,
|
|
1639
|
+
const setKeys = (0, import_react7.useCallback)((next) => {
|
|
1440
1640
|
if (value === void 0) setInternal(next);
|
|
1441
1641
|
onChange?.(next);
|
|
1442
1642
|
}, [onChange, value]);
|
|
1443
1643
|
return [keys, setKeys];
|
|
1444
1644
|
}
|
|
1445
1645
|
function useControllableValue(value, defaultValue, onChange) {
|
|
1446
|
-
const [internal, setInternal] = (0,
|
|
1646
|
+
const [internal, setInternal] = (0, import_react7.useState)(defaultValue ?? null);
|
|
1447
1647
|
const selected = value === void 0 ? internal : value;
|
|
1448
|
-
const setSelected = (0,
|
|
1648
|
+
const setSelected = (0, import_react7.useCallback)((next) => {
|
|
1449
1649
|
if (value === void 0) setInternal(next);
|
|
1450
1650
|
onChange?.(next);
|
|
1451
1651
|
}, [onChange, value]);
|
|
@@ -1453,7 +1653,7 @@ function useControllableValue(value, defaultValue, onChange) {
|
|
|
1453
1653
|
}
|
|
1454
1654
|
|
|
1455
1655
|
// src/Table.tsx
|
|
1456
|
-
var
|
|
1656
|
+
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
1457
1657
|
function resolveColumnDropIndex(sourceIndex, targetIndex, edge, columnCount) {
|
|
1458
1658
|
const insertionIndex = targetIndex + (edge === "right" ? 1 : 0) - (sourceIndex < targetIndex ? 1 : 0);
|
|
1459
1659
|
return Math.max(0, Math.min(columnCount - 1, insertionIndex));
|
|
@@ -1674,6 +1874,7 @@ function TableInner({
|
|
|
1674
1874
|
onColumnsReorder,
|
|
1675
1875
|
onColumnResize,
|
|
1676
1876
|
rowDraggable = false,
|
|
1877
|
+
utilityColumnOrder = ["drag", "selection", "rowNumber"],
|
|
1677
1878
|
onRowsReorder,
|
|
1678
1879
|
onInsertRows,
|
|
1679
1880
|
onDeleteRows,
|
|
@@ -1690,21 +1891,21 @@ function TableInner({
|
|
|
1690
1891
|
style,
|
|
1691
1892
|
ariaLabel = "Data grid"
|
|
1692
1893
|
}, ref) {
|
|
1693
|
-
const [sourceColumns, setSourceColumns] = (0,
|
|
1694
|
-
(0,
|
|
1894
|
+
const [sourceColumns, setSourceColumns] = (0, import_react8.useState)(columnProps);
|
|
1895
|
+
(0, import_react8.useEffect)(() => {
|
|
1695
1896
|
setSourceColumns((current) => reconcileColumns(current, columnProps));
|
|
1696
1897
|
}, [columnProps]);
|
|
1697
1898
|
const rowHeight = layout?.rowHeight ?? rowHeightProp ?? 36;
|
|
1698
1899
|
const headerActionSize = Math.max(8, layout?.headerActionSize ?? 14);
|
|
1699
1900
|
const headerActionSlotWidth = headerActionSize + 2;
|
|
1700
1901
|
const baseHeaderHeight = layout?.headerHeight ?? headerHeightProp ?? 40;
|
|
1701
|
-
const headerDepth = (0,
|
|
1702
|
-
const { language, labels } = (0,
|
|
1703
|
-
const customHeaderContentRefs = (0,
|
|
1704
|
-
const customHeaderMeasurementsRef = (0,
|
|
1705
|
-
const [measuredHeaderRowHeights, setMeasuredHeaderRowHeights] = (0,
|
|
1706
|
-
const headerRowHeights = (0,
|
|
1707
|
-
const headerRowOffsets = (0,
|
|
1902
|
+
const headerDepth = (0, import_react8.useMemo)(() => Math.max(1, ...sourceColumns.map(getColumnDepth)), [sourceColumns]);
|
|
1903
|
+
const { language, labels } = (0, import_react8.useMemo)(() => resolveGridLocale(locale), [locale]);
|
|
1904
|
+
const customHeaderContentRefs = (0, import_react8.useRef)(/* @__PURE__ */ new Map());
|
|
1905
|
+
const customHeaderMeasurementsRef = (0, import_react8.useRef)(/* @__PURE__ */ new Map());
|
|
1906
|
+
const [measuredHeaderRowHeights, setMeasuredHeaderRowHeights] = (0, import_react8.useState)([]);
|
|
1907
|
+
const headerRowHeights = (0, import_react8.useMemo)(() => Array.from({ length: headerDepth }, (_, level) => Math.max(baseHeaderHeight, measuredHeaderRowHeights[level] ?? 0)), [baseHeaderHeight, headerDepth, measuredHeaderRowHeights]);
|
|
1908
|
+
const headerRowOffsets = (0, import_react8.useMemo)(() => {
|
|
1708
1909
|
const offsets = [];
|
|
1709
1910
|
let top = 0;
|
|
1710
1911
|
headerRowHeights.forEach((height2) => {
|
|
@@ -1735,37 +1936,37 @@ function TableInner({
|
|
|
1735
1936
|
const summaryEmptyValue = typeof summary === "object" ? summary.emptyValue ?? "" : "";
|
|
1736
1937
|
const contextMenuEnabled = contextMenuConfig !== false;
|
|
1737
1938
|
const customContextMenuConfig = typeof contextMenuConfig === "object" ? contextMenuConfig : void 0;
|
|
1738
|
-
const [resizedColumnWidths, setResizedColumnWidths] = (0,
|
|
1739
|
-
const leafSourceColumns = (0,
|
|
1740
|
-
const sourceColumnWidthsRef = (0,
|
|
1939
|
+
const [resizedColumnWidths, setResizedColumnWidths] = (0, import_react8.useState)({});
|
|
1940
|
+
const leafSourceColumns = (0, import_react8.useMemo)(() => flattenDataColumns(sourceColumns), [sourceColumns]);
|
|
1941
|
+
const sourceColumnWidthsRef = (0, import_react8.useRef)(new Map(leafSourceColumns.map((column) => [column.key, column.width])));
|
|
1741
1942
|
const showRowCheckbox = Boolean(rowSelection) && (typeof rowSelection !== "object" || rowSelection.showCheckbox !== false);
|
|
1742
1943
|
const rowSelectionIndicator = typeof rowSelection === "object" ? rowSelection.indicator ?? "checkbox" : "checkbox";
|
|
1743
1944
|
const rowSelectionColumnWidth = typeof rowSelection === "object" ? Math.max(24, rowSelection.columnWidth ?? 44) : 44;
|
|
1744
|
-
(0,
|
|
1945
|
+
(0, import_react8.useEffect)(() => {
|
|
1745
1946
|
if (!isProductionRuntime() && hasNestedFixedColumns(sourceColumns)) {
|
|
1746
1947
|
console.warn("[Table] Multi-level headers only support fixed columns on top-level columns. Nested fixed values are ignored.");
|
|
1747
1948
|
}
|
|
1748
1949
|
}, [sourceColumns]);
|
|
1749
|
-
const columns = (0,
|
|
1950
|
+
const columns = (0, import_react8.useMemo)(() => {
|
|
1750
1951
|
const utilityColumns = [];
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
}
|
|
1952
|
+
utilityColumnOrder.forEach((utilityColumn) => {
|
|
1953
|
+
if (utilityColumn === "drag" && rowDraggable) {
|
|
1954
|
+
utilityColumns.push({ key: "__rvg_row_drag__", title: "", width: 36, align: "center", fixed: "left", rowDragHandle: true });
|
|
1955
|
+
} else if (utilityColumn === "selection" && showRowCheckbox) {
|
|
1956
|
+
utilityColumns.push({ key: "__rvg_row_selection__", title: "", width: rowSelectionColumnWidth, align: "center", fixed: "left", rowSelection: true, rowSelectionIndicator });
|
|
1957
|
+
} else if (utilityColumn === "rowNumber" && rowNumber) {
|
|
1958
|
+
utilityColumns.push({ key: "__rvg_row_number__", title: "#", width: getRowNumberColumnWidth(sourceRows.length), align: "center", fixed: typeof rowNumber === "object" && rowNumber.fixed === false ? void 0 : "left", rowNumber: true });
|
|
1959
|
+
}
|
|
1960
|
+
});
|
|
1760
1961
|
const dataColumns = leafSourceColumns.map((column) => {
|
|
1761
1962
|
const resizedWidth = resizedColumnWidths[column.key];
|
|
1762
1963
|
return resizedWidth === void 0 ? column : { ...column, width: resizedWidth };
|
|
1763
1964
|
});
|
|
1764
1965
|
return [...utilityColumns, ...dataColumns];
|
|
1765
|
-
}, [leafSourceColumns, resizedColumnWidths, rowDraggable, rowNumber, rowSelectionColumnWidth, rowSelectionIndicator, showRowCheckbox, sourceRows.length]);
|
|
1966
|
+
}, [leafSourceColumns, resizedColumnWidths, rowDraggable, rowNumber, rowSelectionColumnWidth, rowSelectionIndicator, showRowCheckbox, sourceRows.length, utilityColumnOrder]);
|
|
1766
1967
|
const utilityColumnCount = (rowDraggable ? 1 : 0) + (showRowCheckbox ? 1 : 0) + (rowNumber ? 1 : 0);
|
|
1767
|
-
const headerCells = (0,
|
|
1768
|
-
const activeCustomHeaderLevels = (0,
|
|
1968
|
+
const headerCells = (0, import_react8.useMemo)(() => buildHeaderCells(sourceColumns, utilityColumnCount, headerDepth), [headerDepth, sourceColumns, utilityColumnCount]);
|
|
1969
|
+
const activeCustomHeaderLevels = (0, import_react8.useMemo)(() => {
|
|
1769
1970
|
const levels = /* @__PURE__ */ new Map();
|
|
1770
1971
|
columns.forEach((column) => {
|
|
1771
1972
|
if (column.renderHeader) levels.set(column.key, headerDepth - 1);
|
|
@@ -1775,52 +1976,52 @@ function TableInner({
|
|
|
1775
1976
|
});
|
|
1776
1977
|
return levels;
|
|
1777
1978
|
}, [columns, headerCells, headerDepth]);
|
|
1778
|
-
const canvasRef = (0,
|
|
1779
|
-
const scrollerRef = (0,
|
|
1780
|
-
const rootRef = (0,
|
|
1781
|
-
const frameRef = (0,
|
|
1782
|
-
const textFrameRef = (0,
|
|
1783
|
-
const toastTimerRef = (0,
|
|
1784
|
-
const headerTooltipTimerRef = (0,
|
|
1785
|
-
const cellTooltipTimerRef = (0,
|
|
1786
|
-
const pendingHeaderTooltipKeyRef = (0,
|
|
1787
|
-
const pendingCellTooltipKeyRef = (0,
|
|
1788
|
-
const clickedCellRef = (0,
|
|
1789
|
-
const rowAnchorRef = (0,
|
|
1790
|
-
const columnAnchorRef = (0,
|
|
1791
|
-
const columnDragRef = (0,
|
|
1792
|
-
const columnOrderDragRef = (0,
|
|
1793
|
-
const columnOrderLongPressTimerRef = (0,
|
|
1794
|
-
const dragGuideRef = (0,
|
|
1795
|
-
const rowDragGuideRef = (0,
|
|
1796
|
-
const selectionFocusRef = (0,
|
|
1797
|
-
const selectionEdgeTargetRef = (0,
|
|
1798
|
-
const verticalScrollbarRef = (0,
|
|
1799
|
-
const verticalScrollbarThumbRef = (0,
|
|
1800
|
-
const verticalScrollbarDragRef = (0,
|
|
1801
|
-
const horizontalScrollbarRef = (0,
|
|
1802
|
-
const horizontalScrollbarThumbRef = (0,
|
|
1803
|
-
const horizontalScrollbarDragRef = (0,
|
|
1804
|
-
const verticalScrollbarVisibilityTimerRef = (0,
|
|
1805
|
-
const horizontalScrollbarVisibilityTimerRef = (0,
|
|
1806
|
-
const rowByKeyRef = (0,
|
|
1807
|
-
const rowIndexByKeyRef = (0,
|
|
1808
|
-
const headerIconsRef = (0,
|
|
1809
|
-
const scrollingHeaderIconsRef = (0,
|
|
1810
|
-
const scrollingTextRef = (0,
|
|
1811
|
-
const filterRef = (0,
|
|
1812
|
-
const contextMenuRef = (0,
|
|
1813
|
-
const suppressClickRef = (0,
|
|
1814
|
-
const hasCompletedLoadRef = (0,
|
|
1815
|
-
const validColumnDropRef = (0,
|
|
1816
|
-
const hoveredHeaderActionRef = (0,
|
|
1817
|
-
const hoveredRowIndexRef = (0,
|
|
1818
|
-
const [viewport, setViewport] = (0,
|
|
1819
|
-
const [horizontalScrollbarHeight, setHorizontalScrollbarHeight] = (0,
|
|
1820
|
-
const [availableHeight, setAvailableHeight] = (0,
|
|
1979
|
+
const canvasRef = (0, import_react8.useRef)(null);
|
|
1980
|
+
const scrollerRef = (0, import_react8.useRef)(null);
|
|
1981
|
+
const rootRef = (0, import_react8.useRef)(null);
|
|
1982
|
+
const frameRef = (0, import_react8.useRef)(null);
|
|
1983
|
+
const textFrameRef = (0, import_react8.useRef)(null);
|
|
1984
|
+
const toastTimerRef = (0, import_react8.useRef)(null);
|
|
1985
|
+
const headerTooltipTimerRef = (0, import_react8.useRef)(null);
|
|
1986
|
+
const cellTooltipTimerRef = (0, import_react8.useRef)(null);
|
|
1987
|
+
const pendingHeaderTooltipKeyRef = (0, import_react8.useRef)("");
|
|
1988
|
+
const pendingCellTooltipKeyRef = (0, import_react8.useRef)("");
|
|
1989
|
+
const clickedCellRef = (0, import_react8.useRef)(null);
|
|
1990
|
+
const rowAnchorRef = (0, import_react8.useRef)(null);
|
|
1991
|
+
const columnAnchorRef = (0, import_react8.useRef)(null);
|
|
1992
|
+
const columnDragRef = (0, import_react8.useRef)(null);
|
|
1993
|
+
const columnOrderDragRef = (0, import_react8.useRef)(null);
|
|
1994
|
+
const columnOrderLongPressTimerRef = (0, import_react8.useRef)(null);
|
|
1995
|
+
const dragGuideRef = (0, import_react8.useRef)(null);
|
|
1996
|
+
const rowDragGuideRef = (0, import_react8.useRef)(null);
|
|
1997
|
+
const selectionFocusRef = (0, import_react8.useRef)(null);
|
|
1998
|
+
const selectionEdgeTargetRef = (0, import_react8.useRef)(null);
|
|
1999
|
+
const verticalScrollbarRef = (0, import_react8.useRef)(null);
|
|
2000
|
+
const verticalScrollbarThumbRef = (0, import_react8.useRef)(null);
|
|
2001
|
+
const verticalScrollbarDragRef = (0, import_react8.useRef)(null);
|
|
2002
|
+
const horizontalScrollbarRef = (0, import_react8.useRef)(null);
|
|
2003
|
+
const horizontalScrollbarThumbRef = (0, import_react8.useRef)(null);
|
|
2004
|
+
const horizontalScrollbarDragRef = (0, import_react8.useRef)(null);
|
|
2005
|
+
const verticalScrollbarVisibilityTimerRef = (0, import_react8.useRef)(null);
|
|
2006
|
+
const horizontalScrollbarVisibilityTimerRef = (0, import_react8.useRef)(null);
|
|
2007
|
+
const rowByKeyRef = (0, import_react8.useRef)(/* @__PURE__ */ new Map());
|
|
2008
|
+
const rowIndexByKeyRef = (0, import_react8.useRef)(/* @__PURE__ */ new Map());
|
|
2009
|
+
const headerIconsRef = (0, import_react8.useRef)(null);
|
|
2010
|
+
const scrollingHeaderIconsRef = (0, import_react8.useRef)(null);
|
|
2011
|
+
const scrollingTextRef = (0, import_react8.useRef)(null);
|
|
2012
|
+
const filterRef = (0, import_react8.useRef)(null);
|
|
2013
|
+
const contextMenuRef = (0, import_react8.useRef)(null);
|
|
2014
|
+
const suppressClickRef = (0, import_react8.useRef)(false);
|
|
2015
|
+
const hasCompletedLoadRef = (0, import_react8.useRef)(!loading);
|
|
2016
|
+
const validColumnDropRef = (0, import_react8.useRef)(null);
|
|
2017
|
+
const hoveredHeaderActionRef = (0, import_react8.useRef)(null);
|
|
2018
|
+
const hoveredRowIndexRef = (0, import_react8.useRef)(null);
|
|
2019
|
+
const [viewport, setViewport] = (0, import_react8.useState)({ width: 0, height: typeof height === "number" ? height : FALLBACK_HEIGHT });
|
|
2020
|
+
const [horizontalScrollbarHeight, setHorizontalScrollbarHeight] = (0, import_react8.useState)(0);
|
|
2021
|
+
const [availableHeight, setAvailableHeight] = (0, import_react8.useState)(FALLBACK_HEIGHT);
|
|
1821
2022
|
const resolvedHeight = typeof height === "number" ? height : availableHeight;
|
|
1822
|
-
const [scrollPosition, setScrollPosition] = (0,
|
|
1823
|
-
const scrollRef = (0,
|
|
2023
|
+
const [scrollPosition, setScrollPosition] = (0, import_react8.useState)({ left: 0, top: 0 });
|
|
2024
|
+
const scrollRef = (0, import_react8.useRef)({ left: 0, top: 0 });
|
|
1824
2025
|
const [rowKeys, setRowKeys] = useControllableKeys(selectedRowKeys, defaultSelectedRowKeys, (keys) => {
|
|
1825
2026
|
if (!onSelectedRowChange) return;
|
|
1826
2027
|
const missing = new Set(keys.filter((key) => !rowByKeyRef.current.has(key)));
|
|
@@ -1842,20 +2043,20 @@ function TableInner({
|
|
|
1842
2043
|
onSelectedRowChange(keys, entries.map(({ row }) => row), entries.map(({ index }) => index));
|
|
1843
2044
|
});
|
|
1844
2045
|
const [columnKeys, setColumnKeys] = useControllableKeys(selectedColumnKeys, defaultSelectedColumnKeys, onSelectedColumnChange);
|
|
1845
|
-
const [editing, setEditing] = (0,
|
|
1846
|
-
const [draft, setDraft] = (0,
|
|
1847
|
-
const [rowDragPreview, setRowDragPreview] = (0,
|
|
1848
|
-
const [columnDragPreview, setColumnDragPreview] = (0,
|
|
1849
|
-
const [columnDropTarget, setColumnDropTarget] = (0,
|
|
1850
|
-
(0,
|
|
2046
|
+
const [editing, setEditing] = (0, import_react8.useState)(null);
|
|
2047
|
+
const [draft, setDraft] = (0, import_react8.useState)("");
|
|
2048
|
+
const [rowDragPreview, setRowDragPreview] = (0, import_react8.useState)(null);
|
|
2049
|
+
const [columnDragPreview, setColumnDragPreview] = (0, import_react8.useState)(null);
|
|
2050
|
+
const [columnDropTarget, setColumnDropTarget] = (0, import_react8.useState)(null);
|
|
2051
|
+
(0, import_react8.useEffect)(() => {
|
|
1851
2052
|
if (!loading) hasCompletedLoadRef.current = true;
|
|
1852
2053
|
}, [loading]);
|
|
1853
|
-
(0,
|
|
2054
|
+
(0, import_react8.useEffect)(() => {
|
|
1854
2055
|
if (rangeSelection) return;
|
|
1855
2056
|
rangeDragRef.current = null;
|
|
1856
2057
|
setSelectionRange(null);
|
|
1857
2058
|
}, [rangeSelection]);
|
|
1858
|
-
(0,
|
|
2059
|
+
(0, import_react8.useEffect)(() => {
|
|
1859
2060
|
const previousSourceWidths = sourceColumnWidthsRef.current;
|
|
1860
2061
|
const nextSourceWidths = new Map(leafSourceColumns.map((column) => [column.key, column.width]));
|
|
1861
2062
|
sourceColumnWidthsRef.current = nextSourceWidths;
|
|
@@ -1879,11 +2080,11 @@ function TableInner({
|
|
|
1879
2080
|
return changed ? next : current;
|
|
1880
2081
|
});
|
|
1881
2082
|
}, [leafSourceColumns]);
|
|
1882
|
-
(0,
|
|
2083
|
+
(0, import_react8.useEffect)(() => () => {
|
|
1883
2084
|
if (headerTooltipTimerRef.current !== null) clearTimeout(headerTooltipTimerRef.current);
|
|
1884
2085
|
if (cellTooltipTimerRef.current !== null) clearTimeout(cellTooltipTimerRef.current);
|
|
1885
2086
|
}, []);
|
|
1886
|
-
const measureCustomHeaderHeight = (0,
|
|
2087
|
+
const measureCustomHeaderHeight = (0, import_react8.useCallback)(() => {
|
|
1887
2088
|
const nextHeights = Array.from({ length: headerDepth }, () => baseHeaderHeight);
|
|
1888
2089
|
customHeaderContentRefs.current.forEach((node) => {
|
|
1889
2090
|
const headerCell = node.closest(".rvg-header-title");
|
|
@@ -1901,7 +2102,7 @@ function TableInner({
|
|
|
1901
2102
|
return changed ? nextHeights : current;
|
|
1902
2103
|
});
|
|
1903
2104
|
}, [activeCustomHeaderLevels, baseHeaderHeight, headerDepth]);
|
|
1904
|
-
(0,
|
|
2105
|
+
(0, import_react8.useLayoutEffect)(() => {
|
|
1905
2106
|
customHeaderContentRefs.current.forEach((_, key) => {
|
|
1906
2107
|
if (!activeCustomHeaderLevels.has(key)) customHeaderContentRefs.current.delete(key);
|
|
1907
2108
|
});
|
|
@@ -1909,7 +2110,7 @@ function TableInner({
|
|
|
1909
2110
|
if (!activeCustomHeaderLevels.has(key)) customHeaderMeasurementsRef.current.delete(key);
|
|
1910
2111
|
});
|
|
1911
2112
|
if (activeCustomHeaderLevels.size === 0) {
|
|
1912
|
-
setMeasuredHeaderRowHeights([]);
|
|
2113
|
+
setMeasuredHeaderRowHeights((current) => current.length === 0 ? current : []);
|
|
1913
2114
|
return;
|
|
1914
2115
|
}
|
|
1915
2116
|
measureCustomHeaderHeight();
|
|
@@ -1918,23 +2119,23 @@ function TableInner({
|
|
|
1918
2119
|
customHeaderContentRefs.current.forEach((node) => observer.observe(node));
|
|
1919
2120
|
return () => observer.disconnect();
|
|
1920
2121
|
}, [activeCustomHeaderLevels, measureCustomHeaderHeight, viewport.width]);
|
|
1921
|
-
const [filterEditor, setFilterEditor] = (0,
|
|
1922
|
-
const [filterValues, setFilterValues] = (0,
|
|
1923
|
-
const [sortState, setSortState] = (0,
|
|
1924
|
-
const [contextMenu, setContextMenu] = (0,
|
|
1925
|
-
const [insertCounts, setInsertCounts] = (0,
|
|
1926
|
-
const [confirmAction, setConfirmAction] = (0,
|
|
1927
|
-
const [confirmLoading, setConfirmLoading] = (0,
|
|
1928
|
-
const [insertBusy, setInsertBusy] = (0,
|
|
1929
|
-
const [deleteBusy, setDeleteBusy] = (0,
|
|
1930
|
-
const [toast, setToast] = (0,
|
|
1931
|
-
const [resizeGuideX, setResizeGuideX] = (0,
|
|
1932
|
-
const [resizeGuideTop, setResizeGuideTop] = (0,
|
|
1933
|
-
const [hoveredHeaderColumnIndex, setHoveredHeaderColumnIndex] = (0,
|
|
1934
|
-
const [hoveredHeaderAction, setHoveredHeaderAction] = (0,
|
|
1935
|
-
const [visibleHeaderTooltip, setVisibleHeaderTooltip] = (0,
|
|
1936
|
-
const [hoveredCellTooltip, setHoveredCellTooltip] = (0,
|
|
1937
|
-
const hideDragTooltips = (0,
|
|
2122
|
+
const [filterEditor, setFilterEditor] = (0, import_react8.useState)(null);
|
|
2123
|
+
const [filterValues, setFilterValues] = (0, import_react8.useState)({});
|
|
2124
|
+
const [sortState, setSortState] = (0, import_react8.useState)(null);
|
|
2125
|
+
const [contextMenu, setContextMenu] = (0, import_react8.useState)(null);
|
|
2126
|
+
const [insertCounts, setInsertCounts] = (0, import_react8.useState)({ before: 1, after: 1 });
|
|
2127
|
+
const [confirmAction, setConfirmAction] = (0, import_react8.useState)(null);
|
|
2128
|
+
const [confirmLoading, setConfirmLoading] = (0, import_react8.useState)(false);
|
|
2129
|
+
const [insertBusy, setInsertBusy] = (0, import_react8.useState)(false);
|
|
2130
|
+
const [deleteBusy, setDeleteBusy] = (0, import_react8.useState)(false);
|
|
2131
|
+
const [toast, setToast] = (0, import_react8.useState)(null);
|
|
2132
|
+
const [resizeGuideX, setResizeGuideX] = (0, import_react8.useState)(null);
|
|
2133
|
+
const [resizeGuideTop, setResizeGuideTop] = (0, import_react8.useState)(0);
|
|
2134
|
+
const [hoveredHeaderColumnIndex, setHoveredHeaderColumnIndex] = (0, import_react8.useState)(null);
|
|
2135
|
+
const [hoveredHeaderAction, setHoveredHeaderAction] = (0, import_react8.useState)(null);
|
|
2136
|
+
const [visibleHeaderTooltip, setVisibleHeaderTooltip] = (0, import_react8.useState)(null);
|
|
2137
|
+
const [hoveredCellTooltip, setHoveredCellTooltip] = (0, import_react8.useState)(null);
|
|
2138
|
+
const hideDragTooltips = (0, import_react8.useCallback)(() => {
|
|
1938
2139
|
if (headerTooltipTimerRef.current !== null) {
|
|
1939
2140
|
clearTimeout(headerTooltipTimerRef.current);
|
|
1940
2141
|
headerTooltipTimerRef.current = null;
|
|
@@ -1948,23 +2149,23 @@ function TableInner({
|
|
|
1948
2149
|
setVisibleHeaderTooltip(null);
|
|
1949
2150
|
setHoveredCellTooltip(null);
|
|
1950
2151
|
}, []);
|
|
1951
|
-
const [editedCellKeys, setEditedCellKeys] = (0,
|
|
1952
|
-
const [cellAnnotations, setCellAnnotations] = (0,
|
|
1953
|
-
const [annotationType, setAnnotationType] = (0,
|
|
1954
|
-
const [annotationColor, setAnnotationColor] = (0,
|
|
1955
|
-
const [annotationContent, setAnnotationContent] = (0,
|
|
1956
|
-
const [annotationOpen, setAnnotationOpen] = (0,
|
|
1957
|
-
const [annotationPlacement, setAnnotationPlacement] = (0,
|
|
1958
|
-
const originalCellValuesRef = (0,
|
|
1959
|
-
const [pendingDeletedRowKeys, setPendingDeletedRowKeys] = (0,
|
|
1960
|
-
const [pendingInserts, setPendingInserts] = (0,
|
|
1961
|
-
const [insertedRowKeys, setInsertedRowKeys] = (0,
|
|
1962
|
-
const [rowOrderKeys, setRowOrderKeys] = (0,
|
|
1963
|
-
const settledPendingInsertIdsRef = (0,
|
|
1964
|
-
const getDataRowKey = (0,
|
|
2152
|
+
const [editedCellKeys, setEditedCellKeys] = (0, import_react8.useState)(() => /* @__PURE__ */ new Set());
|
|
2153
|
+
const [cellAnnotations, setCellAnnotations] = (0, import_react8.useState)(() => /* @__PURE__ */ new Map());
|
|
2154
|
+
const [annotationType, setAnnotationType] = (0, import_react8.useState)("corner");
|
|
2155
|
+
const [annotationColor, setAnnotationColor] = (0, import_react8.useState)(ANNOTATION_COLORS[0]);
|
|
2156
|
+
const [annotationContent, setAnnotationContent] = (0, import_react8.useState)("");
|
|
2157
|
+
const [annotationOpen, setAnnotationOpen] = (0, import_react8.useState)(false);
|
|
2158
|
+
const [annotationPlacement, setAnnotationPlacement] = (0, import_react8.useState)("right-down");
|
|
2159
|
+
const originalCellValuesRef = (0, import_react8.useRef)(/* @__PURE__ */ new Map());
|
|
2160
|
+
const [pendingDeletedRowKeys, setPendingDeletedRowKeys] = (0, import_react8.useState)(() => /* @__PURE__ */ new Set());
|
|
2161
|
+
const [pendingInserts, setPendingInserts] = (0, import_react8.useState)(() => []);
|
|
2162
|
+
const [insertedRowKeys, setInsertedRowKeys] = (0, import_react8.useState)(() => /* @__PURE__ */ new Set());
|
|
2163
|
+
const [rowOrderKeys, setRowOrderKeys] = (0, import_react8.useState)(null);
|
|
2164
|
+
const settledPendingInsertIdsRef = (0, import_react8.useRef)(/* @__PURE__ */ new Set());
|
|
2165
|
+
const getDataRowKey = (0, import_react8.useCallback)((row, index) => {
|
|
1965
2166
|
return typeof rowKey === "function" ? rowKey(row, index) : rowKey ? row[rowKey] : getDefaultRowKey(row, index);
|
|
1966
2167
|
}, [rowKey]);
|
|
1967
|
-
const getSourceRowIndexByKey = (0,
|
|
2168
|
+
const getSourceRowIndexByKey = (0, import_react8.useCallback)((key, preferredIndex) => {
|
|
1968
2169
|
const preferredRow = sourceRows[preferredIndex];
|
|
1969
2170
|
if (preferredRow && getDataRowKey(preferredRow, preferredIndex) === key) return preferredIndex;
|
|
1970
2171
|
const start = Math.max(0, preferredIndex - 8);
|
|
@@ -1974,7 +2175,7 @@ function TableInner({
|
|
|
1974
2175
|
}
|
|
1975
2176
|
return sourceRows.findIndex((sourceRow, index) => getDataRowKey(sourceRow, index) === key);
|
|
1976
2177
|
}, [getDataRowKey, sourceRows]);
|
|
1977
|
-
const orderedRows = (0,
|
|
2178
|
+
const orderedRows = (0, import_react8.useMemo)(() => {
|
|
1978
2179
|
let next = sourceRows;
|
|
1979
2180
|
if (pendingInserts.length > 0) {
|
|
1980
2181
|
const activeInserts = pendingInserts.filter((insert) => {
|
|
@@ -2010,10 +2211,10 @@ function TableInner({
|
|
|
2010
2211
|
});
|
|
2011
2212
|
return ordered;
|
|
2012
2213
|
}, [getDataRowKey, pendingDeletedRowKeys, pendingInserts, rowOrderKeys, sourceRows]);
|
|
2013
|
-
const activeFilterValues = (0,
|
|
2214
|
+
const activeFilterValues = (0, import_react8.useMemo)(() => Object.fromEntries(
|
|
2014
2215
|
Object.entries(filterValues).filter(([, value]) => value.trim() !== "")
|
|
2015
2216
|
), [filterValues]);
|
|
2016
|
-
const filteredRows = (0,
|
|
2217
|
+
const filteredRows = (0, import_react8.useMemo)(() => {
|
|
2017
2218
|
if (Object.keys(activeFilterValues).length === 0) return orderedRows;
|
|
2018
2219
|
if (onFilterChange) return onFilterChange(orderedRows, activeFilterValues);
|
|
2019
2220
|
return orderedRows.filter((row, rowIndex) => Object.entries(activeFilterValues).every(([columnKey, query]) => {
|
|
@@ -2022,7 +2223,7 @@ function TableInner({
|
|
|
2022
2223
|
return getDisplayLabel(column, row, rowIndex).toLocaleLowerCase().includes(query.trim().toLocaleLowerCase());
|
|
2023
2224
|
}));
|
|
2024
2225
|
}, [activeFilterValues, columns, onFilterChange, orderedRows]);
|
|
2025
|
-
const rows = (0,
|
|
2226
|
+
const rows = (0, import_react8.useMemo)(() => {
|
|
2026
2227
|
if (!sortState) return filteredRows;
|
|
2027
2228
|
if (onSortChange) return onSortChange(filteredRows, sortState);
|
|
2028
2229
|
const column = columns.find((candidate) => candidate.key === sortState.columnKey);
|
|
@@ -2035,7 +2236,7 @@ function TableInner({
|
|
|
2035
2236
|
return result * direction;
|
|
2036
2237
|
});
|
|
2037
2238
|
}, [columns, filteredRows, language, onSortChange, sortState]);
|
|
2038
|
-
const resolveSelectionTarget = (0,
|
|
2239
|
+
const resolveSelectionTarget = (0, import_react8.useCallback)((target) => {
|
|
2039
2240
|
if (target == null) return target;
|
|
2040
2241
|
const columnIndex = columns.findIndex((column) => column.key === target.columnKey);
|
|
2041
2242
|
const rowIndex = target.rowKey !== void 0 ? rows.findIndex((row2, index) => getDataRowKey(row2, index) === target.rowKey) : target.rowIndex ?? -1;
|
|
@@ -2048,9 +2249,9 @@ function TableInner({
|
|
|
2048
2249
|
columnKey: target.columnKey
|
|
2049
2250
|
};
|
|
2050
2251
|
}, [columns, getDataRowKey, rows]);
|
|
2051
|
-
const resolvedSelectedCell = (0,
|
|
2052
|
-
const resolvedDefaultSelectedCell = (0,
|
|
2053
|
-
const handleSelectedCellChange = (0,
|
|
2252
|
+
const resolvedSelectedCell = (0, import_react8.useMemo)(() => resolveSelectionTarget(selectedCell), [resolveSelectionTarget, selectedCell]);
|
|
2253
|
+
const resolvedDefaultSelectedCell = (0, import_react8.useMemo)(() => resolveSelectionTarget(defaultSelectedCell), [defaultSelectedCell, resolveSelectionTarget]);
|
|
2254
|
+
const handleSelectedCellChange = (0, import_react8.useCallback)((next) => {
|
|
2054
2255
|
if (!onSelectedCellChange) return;
|
|
2055
2256
|
if (!next) {
|
|
2056
2257
|
onSelectedCellChange(null);
|
|
@@ -2062,15 +2263,16 @@ function TableInner({
|
|
|
2062
2263
|
onSelectedCellChange({ ...next, value });
|
|
2063
2264
|
}, [columns, onSelectedCellChange, rows]);
|
|
2064
2265
|
const [selection, setSelection] = useControllableValue(resolvedSelectedCell, resolvedDefaultSelectedCell, handleSelectedCellChange);
|
|
2065
|
-
const [selectionRange, setSelectionRange] = (0,
|
|
2066
|
-
const rangeDragRef = (0,
|
|
2067
|
-
(0,
|
|
2266
|
+
const [selectionRange, setSelectionRange] = (0, import_react8.useState)(null);
|
|
2267
|
+
const rangeDragRef = (0, import_react8.useRef)(null);
|
|
2268
|
+
(0, import_react8.useEffect)(() => {
|
|
2068
2269
|
if (!selection) return void 0;
|
|
2069
2270
|
const handleOutsidePointerDown = (event) => {
|
|
2070
2271
|
const target = event.target;
|
|
2071
2272
|
if (!(target instanceof Node)) return;
|
|
2072
2273
|
if (rootRef.current?.contains(target)) return;
|
|
2073
2274
|
if (target instanceof Element && target.closest(".rvg-choice-content, .rvg-date-content, .rvg-time-dropdown")) return;
|
|
2275
|
+
if (target instanceof Element && target.closest(".rvg-textarea-dialog")) return;
|
|
2074
2276
|
clickedCellRef.current = null;
|
|
2075
2277
|
setSelectionRange(null);
|
|
2076
2278
|
setSelection(null);
|
|
@@ -2078,7 +2280,7 @@ function TableInner({
|
|
|
2078
2280
|
document.addEventListener("pointerdown", handleOutsidePointerDown);
|
|
2079
2281
|
return () => document.removeEventListener("pointerdown", handleOutsidePointerDown);
|
|
2080
2282
|
}, [selection, setSelection]);
|
|
2081
|
-
const applyRowOrder = (0,
|
|
2283
|
+
const applyRowOrder = (0, import_react8.useCallback)((sourceIndex, targetIndex) => {
|
|
2082
2284
|
if (sourceIndex === targetIndex || sourceIndex < 0 || targetIndex < 0 || sourceIndex >= rows.length || targetIndex >= rows.length) return;
|
|
2083
2285
|
const nextEntries = rows.map((row, index) => ({ row, key: getDataRowKey(row, index) }));
|
|
2084
2286
|
const [entry] = nextEntries.splice(sourceIndex, 1);
|
|
@@ -2087,12 +2289,12 @@ function TableInner({
|
|
|
2087
2289
|
setRowOrderKeys(nextEntries.map(({ key }) => key));
|
|
2088
2290
|
onRowsReorder?.(nextRows, { sourceIndex, targetIndex });
|
|
2089
2291
|
}, [getDataRowKey, onRowsReorder, rows]);
|
|
2090
|
-
const applyColumnOrder = (0,
|
|
2292
|
+
const applyColumnOrder = (0, import_react8.useCallback)((sourceIndex, targetIndex, detail) => {
|
|
2091
2293
|
const nextColumns = reorderColumns(sourceColumns, detail);
|
|
2092
2294
|
setSourceColumns(nextColumns);
|
|
2093
2295
|
onColumnsReorder?.(nextColumns, { sourceIndex, targetIndex, ...detail });
|
|
2094
2296
|
}, [onColumnsReorder, sourceColumns]);
|
|
2095
|
-
(0,
|
|
2297
|
+
(0, import_react8.useEffect)(() => {
|
|
2096
2298
|
if (insertBusy || settledPendingInsertIdsRef.current.size === 0) return;
|
|
2097
2299
|
setPendingInserts((current) => {
|
|
2098
2300
|
const next = current.filter((insert) => !settledPendingInsertIdsRef.current.has(insert.id));
|
|
@@ -2103,7 +2305,7 @@ function TableInner({
|
|
|
2103
2305
|
return next;
|
|
2104
2306
|
});
|
|
2105
2307
|
}, [insertBusy, pendingInserts]);
|
|
2106
|
-
(0,
|
|
2308
|
+
(0, import_react8.useEffect)(() => {
|
|
2107
2309
|
if (pendingDeletedRowKeys.size === 0) return;
|
|
2108
2310
|
setPendingDeletedRowKeys((current) => {
|
|
2109
2311
|
if (current.size === 0) return current;
|
|
@@ -2117,20 +2319,20 @@ function TableInner({
|
|
|
2117
2319
|
return changed ? next : current;
|
|
2118
2320
|
});
|
|
2119
2321
|
}, [getDataRowKey, pendingDeletedRowKeys.size, sourceRows]);
|
|
2120
|
-
(0,
|
|
2322
|
+
(0, import_react8.useLayoutEffect)(() => {
|
|
2121
2323
|
if (!editing) return;
|
|
2122
2324
|
if (selection?.rowKey === editing.rowKey && selection.columnKey === editing.columnKey) return;
|
|
2123
2325
|
setEditing(null);
|
|
2124
2326
|
}, [editing, selection]);
|
|
2125
2327
|
const hasManualColumnWidths = Object.keys(resizedColumnWidths).length > 0;
|
|
2126
|
-
const metrics = (0,
|
|
2328
|
+
const metrics = (0, import_react8.useMemo)(() => buildColumnMetrics(columns, {
|
|
2127
2329
|
columnDraggable,
|
|
2128
2330
|
viewportWidth: !stretchColumns || hasManualColumnWidths ? 0 : viewport.width
|
|
2129
2331
|
}), [columnDraggable, columns, hasManualColumnWidths, stretchColumns, viewport.width]);
|
|
2130
2332
|
const contentWidth = metrics.length > 0 ? metrics[metrics.length - 1].right : 0;
|
|
2131
2333
|
const contentHeight = rows.length * rowHeight;
|
|
2132
|
-
const fixedWidth = (0,
|
|
2133
|
-
const leftFixedOffsets = (0,
|
|
2334
|
+
const fixedWidth = (0, import_react8.useMemo)(() => columns.reduce((width2, column, index) => column.fixed === "left" ? width2 + metrics[index].width : width2, 0), [columns, metrics]);
|
|
2335
|
+
const leftFixedOffsets = (0, import_react8.useMemo)(() => {
|
|
2134
2336
|
const offsets = /* @__PURE__ */ new Map();
|
|
2135
2337
|
let offset = 0;
|
|
2136
2338
|
for (let index = 0; index < columns.length; index += 1) {
|
|
@@ -2140,8 +2342,8 @@ function TableInner({
|
|
|
2140
2342
|
}
|
|
2141
2343
|
return offsets;
|
|
2142
2344
|
}, [columns, metrics]);
|
|
2143
|
-
const rightFixedWidth = (0,
|
|
2144
|
-
const rightFixedOffsets = (0,
|
|
2345
|
+
const rightFixedWidth = (0, import_react8.useMemo)(() => columns.reduce((width2, column, index) => column.fixed === "right" ? width2 + metrics[index].width : width2, 0), [columns, metrics]);
|
|
2346
|
+
const rightFixedOffsets = (0, import_react8.useMemo)(() => {
|
|
2145
2347
|
const offsets = /* @__PURE__ */ new Map();
|
|
2146
2348
|
let offset = 0;
|
|
2147
2349
|
for (let index = columns.length - 1; index >= 0; index -= 1) {
|
|
@@ -2151,7 +2353,7 @@ function TableInner({
|
|
|
2151
2353
|
}
|
|
2152
2354
|
return offsets;
|
|
2153
2355
|
}, [columns, metrics]);
|
|
2154
|
-
const scrollableColumnLefts = (0,
|
|
2356
|
+
const scrollableColumnLefts = (0, import_react8.useMemo)(() => {
|
|
2155
2357
|
const lefts = [];
|
|
2156
2358
|
let width2 = fixedWidth;
|
|
2157
2359
|
for (let index = 0; index < columns.length; index += 1) {
|
|
@@ -2160,10 +2362,10 @@ function TableInner({
|
|
|
2160
2362
|
}
|
|
2161
2363
|
return lefts;
|
|
2162
2364
|
}, [columns, fixedWidth, metrics]);
|
|
2163
|
-
const getScrollableColumnLeft = (0,
|
|
2164
|
-
const hasRowSelectionColumn = (0,
|
|
2365
|
+
const getScrollableColumnLeft = (0, import_react8.useCallback)((columnIndex) => scrollableColumnLefts[columnIndex] ?? fixedWidth, [fixedWidth, scrollableColumnLefts]);
|
|
2366
|
+
const hasRowSelectionColumn = (0, import_react8.useMemo)(() => columns.some((column) => column.rowSelection), [columns]);
|
|
2165
2367
|
const rowSelectionMode = typeof rowSelection === "object" ? rowSelection.mode ?? "multiple" : "multiple";
|
|
2166
|
-
const summarySignature = (0,
|
|
2368
|
+
const summarySignature = (0, import_react8.useMemo)(() => getSummarySignature(columns), [columns]);
|
|
2167
2369
|
const hasSummaryRow = rows.length > 0 && summaryEnabled && summarySignature.length > 0;
|
|
2168
2370
|
const topSummaryHeight = hasSummaryRow && summaryPosition === "top" ? rowHeight : 0;
|
|
2169
2371
|
const bottomSummaryHeight = hasSummaryRow && summaryPosition === "bottom" ? rowHeight : 0;
|
|
@@ -2173,10 +2375,10 @@ function TableInner({
|
|
|
2173
2375
|
const effectiveHeight = autoHeight ? Math.max(bodyTop + bottomSummaryHeight, Math.min(resolvedHeight, realContentHeight)) : resolvedHeight;
|
|
2174
2376
|
const renderHeight = Math.max(0, effectiveHeight - bottomSummaryHeight);
|
|
2175
2377
|
const bodyViewportHeight = Math.max(0, renderHeight - (fixedHeader ? headerHeight + topSummaryHeight : 0));
|
|
2176
|
-
const [summaryState, setSummaryState] = (0,
|
|
2378
|
+
const [summaryState, setSummaryState] = (0, import_react8.useState)(() => ({ signature: "", rows: null, values: /* @__PURE__ */ new Map(), pending: false }));
|
|
2177
2379
|
const summaryPending = hasSummaryRow && (loading || summaryState.pending || summaryState.signature !== summarySignature || summaryState.rows !== rows);
|
|
2178
2380
|
const summaryValues = hasSummaryRow && summaryState.signature === summarySignature && summaryState.rows === rows ? summaryState.values : /* @__PURE__ */ new Map();
|
|
2179
|
-
(0,
|
|
2381
|
+
(0, import_react8.useEffect)(() => {
|
|
2180
2382
|
let cancelled = false;
|
|
2181
2383
|
if (!hasSummaryRow) {
|
|
2182
2384
|
setSummaryState((current) => current.signature === "" && current.rows === null && current.values.size === 0 && !current.pending ? current : { signature: "", rows: null, values: /* @__PURE__ */ new Map(), pending: false });
|
|
@@ -2207,19 +2409,19 @@ function TableInner({
|
|
|
2207
2409
|
cancelled = true;
|
|
2208
2410
|
};
|
|
2209
2411
|
}, [hasSummaryRow, loading, rows, summarySignature]);
|
|
2210
|
-
const domRange = (0,
|
|
2412
|
+
const domRange = (0, import_react8.useMemo)(() => {
|
|
2211
2413
|
if (!isVirtualized) return { rowStart: 0, rowEnd: rows.length, columnStart: 0, columnEnd: columns.length };
|
|
2212
2414
|
const currentScroll2 = scrollRef.current;
|
|
2213
2415
|
const rowScrollTop = fixedHeader ? currentScroll2.top : Math.max(0, currentScroll2.top - bodyTop);
|
|
2214
2416
|
return getViewportRange(currentScroll2.left, rowScrollTop, viewport.width, bodyViewportHeight, rows.length, rowHeight, metrics, virtualOverscan);
|
|
2215
2417
|
}, [bodyTop, bodyViewportHeight, columns.length, fixedHeader, isVirtualized, metrics, rowHeight, rows.length, scrollPosition, viewport.width, virtualOverscan]);
|
|
2216
|
-
const getRowKey = (0,
|
|
2418
|
+
const getRowKey = (0, import_react8.useCallback)((row, index) => {
|
|
2217
2419
|
const key = getDataRowKey(row, index);
|
|
2218
2420
|
rowByKeyRef.current.set(key, row);
|
|
2219
2421
|
rowIndexByKeyRef.current.set(key, index);
|
|
2220
2422
|
return key;
|
|
2221
2423
|
}, [getDataRowKey]);
|
|
2222
|
-
const resolvedCellSpans = (0,
|
|
2424
|
+
const resolvedCellSpans = (0, import_react8.useMemo)(() => {
|
|
2223
2425
|
if (Array.isArray(cellSpans)) return cellSpans;
|
|
2224
2426
|
const spans = [];
|
|
2225
2427
|
rows.forEach((row, rowIndex) => {
|
|
@@ -2235,7 +2437,7 @@ function TableInner({
|
|
|
2235
2437
|
});
|
|
2236
2438
|
return spans;
|
|
2237
2439
|
}, [cellSpans, columns, rows]);
|
|
2238
|
-
const cellSpanLookup = (0,
|
|
2440
|
+
const cellSpanLookup = (0, import_react8.useMemo)(() => {
|
|
2239
2441
|
if (resolvedCellSpans.length === 0) return createEmptyCellSpanLookup();
|
|
2240
2442
|
const rowIndexByKey = /* @__PURE__ */ new Map();
|
|
2241
2443
|
rows.forEach((row, index) => rowIndexByKey.set(getRowKey(row, index), index));
|
|
@@ -2279,10 +2481,10 @@ function TableInner({
|
|
|
2279
2481
|
}
|
|
2280
2482
|
return lookup;
|
|
2281
2483
|
}, [columns, getRowKey, resolvedCellSpans, rows]);
|
|
2282
|
-
const selectedRowKeySet = (0,
|
|
2283
|
-
const selectedColumnKeySet = (0,
|
|
2284
|
-
const insertedRowKeySet = (0,
|
|
2285
|
-
const measureHeaderTitleWidth = (0,
|
|
2484
|
+
const selectedRowKeySet = (0, import_react8.useMemo)(() => new Set(rowKeys), [rowKeys]);
|
|
2485
|
+
const selectedColumnKeySet = (0, import_react8.useMemo)(() => new Set(columnKeys), [columnKeys]);
|
|
2486
|
+
const insertedRowKeySet = (0, import_react8.useMemo)(() => insertedRowKeys, [insertedRowKeys]);
|
|
2487
|
+
const measureHeaderTitleWidth = (0, import_react8.useCallback)((columnIndex) => {
|
|
2286
2488
|
const title = columns[columnIndex]?.title ?? "";
|
|
2287
2489
|
const context = canvasRef.current?.getContext("2d");
|
|
2288
2490
|
if (!context) return Array.from(title).reduce((width3, character) => width3 + (/^[\x00-\x7F]$/.test(character) ? 7 : 13), 0);
|
|
@@ -2292,7 +2494,7 @@ function TableInner({
|
|
|
2292
2494
|
context.restore();
|
|
2293
2495
|
return width2;
|
|
2294
2496
|
}, [columns]);
|
|
2295
|
-
const getCellLabel = (0,
|
|
2497
|
+
const getCellLabel = (0, import_react8.useCallback)((rowIndex, columnIndex) => {
|
|
2296
2498
|
const row = rows[rowIndex];
|
|
2297
2499
|
const column = columns[columnIndex];
|
|
2298
2500
|
if (!row || !column || column.rowSelection || column.rowDragHandle) return "";
|
|
@@ -2303,15 +2505,15 @@ function TableInner({
|
|
|
2303
2505
|
return "Render error";
|
|
2304
2506
|
}
|
|
2305
2507
|
}, [columns, rows]);
|
|
2306
|
-
const getCellSpan = (0,
|
|
2307
|
-
const getCellDisplayWidth = (0,
|
|
2508
|
+
const getCellSpan = (0, import_react8.useCallback)((rowIndex, columnIndex) => cellSpanLookup.covered.get(getCellCoordKey2(rowIndex, columnIndex)), [cellSpanLookup]);
|
|
2509
|
+
const getCellDisplayWidth = (0, import_react8.useCallback)((columnIndex, colSpan = 1) => {
|
|
2308
2510
|
let width2 = 0;
|
|
2309
2511
|
for (let index = columnIndex; index < Math.min(columns.length, columnIndex + colSpan); index += 1) {
|
|
2310
2512
|
width2 += metrics[index]?.width ?? 0;
|
|
2311
2513
|
}
|
|
2312
2514
|
return width2;
|
|
2313
2515
|
}, [columns.length, metrics]);
|
|
2314
|
-
(0,
|
|
2516
|
+
(0, import_react8.useEffect)(() => {
|
|
2315
2517
|
if (!selection) return;
|
|
2316
2518
|
const nextRowIndex = rows.findIndex((row, index) => getRowKey(row, index) === selection.rowKey);
|
|
2317
2519
|
const nextColumnIndex = columns.findIndex((column) => column.key === selection.columnKey);
|
|
@@ -2319,7 +2521,7 @@ function TableInner({
|
|
|
2319
2521
|
if (nextRowIndex === selection.rowIndex && nextColumnIndex === selection.columnIndex) return;
|
|
2320
2522
|
setSelection({ ...selection, rowIndex: nextRowIndex, columnIndex: nextColumnIndex });
|
|
2321
2523
|
}, [columns, getRowKey, rows, selection, setSelection]);
|
|
2322
|
-
const draw = (0,
|
|
2524
|
+
const draw = (0, import_react8.useCallback)(() => {
|
|
2323
2525
|
frameRef.current = null;
|
|
2324
2526
|
const canvas = canvasRef.current;
|
|
2325
2527
|
if (!canvas || viewport.width <= 0) return;
|
|
@@ -2365,15 +2567,15 @@ function TableInner({
|
|
|
2365
2567
|
const range = isVirtualized ? getViewportRange(scroll.left, rowScrollTop, viewport.width, bodyViewportHeight, rows.length, rowHeight, metrics, virtualOverscan) : { rowStart: 0, rowEnd: rows.length, columnStart: 0, columnEnd: columns.length };
|
|
2366
2568
|
paintGrid({ context, width: viewport.width, height: renderHeight, pixelRatio: ratio, scrollLeft: scroll.left, scrollTop: scroll.top, rowHeight, bodyFontSize, headerActionSlotWidth, headerHeight, headerLeafTop, headerLeafHeight, bodyTop, suppressLastRowBottomBorder: bottomSummaryHeight > 0, suppressFrameBottomBorder: bottomSummaryHeight > 0, fixedHeader, verticalBorderless: !hasVerticalBorders, horizontalBorderless, frameBorderless, extendVerticalGridLines: !autoHeight, striped: hasStripedRows, columnDraggable, sortState, filterValues, hoveredHeaderAction: hoveredHeaderActionRef.current, rows, rowStyle, columns, metrics, range, selection, editing, hoveredRowIndex: hoveredRowIndexRef.current, selectionRange, selectedRowKeys: selectedRowKeySet, rowSelectionMode, selectedColumnKeys: selectedColumnKeySet, cellSpans: cellSpanLookup.covered, maxRowSpan: cellSpanLookup.maxRowSpan, highlightEditedCells: highlightsEditedCells, highlightInsertedRows: highlightsInsertedRows, insertedRowKeys: insertedRowKeySet, editedCellKeys, cellAnnotations, getRowKey, rowDragPreview, columnDropTarget, colors: themeColors });
|
|
2367
2569
|
}, [autoHeight, bodyTop, bodyViewportHeight, bottomSummaryHeight, cellAnnotations, cellSpanLookup, columnDragPreview, columnDraggable, columnDropTarget, columns, editedCellHighlightColor, editedCellKeys, editing, renderHeight, filterValues, fixedHeader, frameBorderless, getRowKey, hasStripedRows, hasVerticalBorders, headerActionSlotWidth, headerDepth, headerHeight, headerLeafHeight, headerLeafTop, horizontalBorderless, highlightsEditedCells, highlightsInsertedRows, insertedRowHighlightColor, insertedRowKeySet, isVirtualized, metrics, rowDragPreview, rowHeight, rowSelectionMode, rowStyle, rows, selectedColumnKeySet, selectedRowKeySet, selection, selectionRange, sortState, stripedColor, viewport.width, virtualOverscan]);
|
|
2368
|
-
const scheduleDraw = (0,
|
|
2570
|
+
const scheduleDraw = (0, import_react8.useCallback)(() => {
|
|
2369
2571
|
if (frameRef.current === null) frameRef.current = requestAnimationFrame(draw);
|
|
2370
2572
|
}, [draw]);
|
|
2371
|
-
const drawImmediately = (0,
|
|
2573
|
+
const drawImmediately = (0, import_react8.useCallback)(() => {
|
|
2372
2574
|
if (frameRef.current !== null) cancelAnimationFrame(frameRef.current);
|
|
2373
2575
|
frameRef.current = null;
|
|
2374
2576
|
draw();
|
|
2375
2577
|
}, [draw]);
|
|
2376
|
-
const getSelectionHorizontalVisibility = (0,
|
|
2578
|
+
const getSelectionHorizontalVisibility = (0, import_react8.useCallback)((scrollLeft) => {
|
|
2377
2579
|
if (!selection || selectionRange) return "visible";
|
|
2378
2580
|
const column = columns[selection.columnIndex];
|
|
2379
2581
|
if (!column || column.fixed !== void 0) return "visible";
|
|
@@ -2384,7 +2586,7 @@ function TableInner({
|
|
|
2384
2586
|
if (left >= viewport.width - rightFixedWidth) return "hidden-right";
|
|
2385
2587
|
return "visible";
|
|
2386
2588
|
}, [columns, fixedWidth, getCellDisplayWidth, getCellSpan, getScrollableColumnLeft, rightFixedWidth, selection, selectionRange, viewport.width]);
|
|
2387
|
-
const getSelectionEdgeIndicator = (0,
|
|
2589
|
+
const getSelectionEdgeIndicator = (0, import_react8.useCallback)((scrollLeft, scrollTop) => {
|
|
2388
2590
|
if (!selection || selectionRange) return null;
|
|
2389
2591
|
const row = rows[selection.rowIndex];
|
|
2390
2592
|
const metric = metrics[selection.columnIndex];
|
|
@@ -2489,7 +2691,7 @@ function TableInner({
|
|
|
2489
2691
|
}
|
|
2490
2692
|
};
|
|
2491
2693
|
}, [bodyTop, columns, fixedHeader, fixedWidth, getCellDisplayWidth, getCellSpan, getRowKey, getScrollableColumnLeft, hasVerticalBorders, leftFixedOffsets, metrics, renderHeight, rightFixedOffsets, rightFixedWidth, rowHeight, rows, selection, selectionRange, viewport.width]);
|
|
2492
|
-
const syncSelectionEdgeTarget = (0,
|
|
2694
|
+
const syncSelectionEdgeTarget = (0, import_react8.useCallback)((scrollLeft, scrollTop) => {
|
|
2493
2695
|
const target = selectionEdgeTargetRef.current;
|
|
2494
2696
|
if (!target) return;
|
|
2495
2697
|
const indicator = getSelectionEdgeIndicator(scrollLeft, scrollTop);
|
|
@@ -2520,7 +2722,7 @@ function TableInner({
|
|
|
2520
2722
|
target.classList.remove("is-shape-syncing");
|
|
2521
2723
|
}
|
|
2522
2724
|
}, [getSelectionEdgeIndicator]);
|
|
2523
|
-
(0,
|
|
2725
|
+
(0, import_react8.useLayoutEffect)(() => {
|
|
2524
2726
|
const element = scrollerRef.current;
|
|
2525
2727
|
if (!element) return;
|
|
2526
2728
|
const root = element.parentElement;
|
|
@@ -2546,7 +2748,7 @@ function TableInner({
|
|
|
2546
2748
|
if (root?.parentElement) observer.observe(root.parentElement);
|
|
2547
2749
|
return () => observer.disconnect();
|
|
2548
2750
|
}, [height]);
|
|
2549
|
-
(0,
|
|
2751
|
+
(0, import_react8.useEffect)(() => {
|
|
2550
2752
|
scheduleDraw();
|
|
2551
2753
|
return () => {
|
|
2552
2754
|
if (frameRef.current !== null) {
|
|
@@ -2555,13 +2757,13 @@ function TableInner({
|
|
|
2555
2757
|
}
|
|
2556
2758
|
};
|
|
2557
2759
|
}, [scheduleDraw]);
|
|
2558
|
-
(0,
|
|
2760
|
+
(0, import_react8.useEffect)(() => () => {
|
|
2559
2761
|
if (textFrameRef.current !== null) cancelAnimationFrame(textFrameRef.current);
|
|
2560
2762
|
if (toastTimerRef.current !== null) clearTimeout(toastTimerRef.current);
|
|
2561
2763
|
if (verticalScrollbarVisibilityTimerRef.current !== null) clearTimeout(verticalScrollbarVisibilityTimerRef.current);
|
|
2562
2764
|
if (horizontalScrollbarVisibilityTimerRef.current !== null) clearTimeout(horizontalScrollbarVisibilityTimerRef.current);
|
|
2563
2765
|
}, []);
|
|
2564
|
-
(0,
|
|
2766
|
+
(0, import_react8.useEffect)(() => {
|
|
2565
2767
|
const scroller = scrollerRef.current;
|
|
2566
2768
|
if (!scroller) return;
|
|
2567
2769
|
const containHorizontalOverscroll = (event) => {
|
|
@@ -2573,7 +2775,7 @@ function TableInner({
|
|
|
2573
2775
|
scroller.addEventListener("wheel", containHorizontalOverscroll, { passive: false });
|
|
2574
2776
|
return () => scroller.removeEventListener("wheel", containHorizontalOverscroll);
|
|
2575
2777
|
}, []);
|
|
2576
|
-
(0,
|
|
2778
|
+
(0, import_react8.useEffect)(() => {
|
|
2577
2779
|
if (!filterEditor) return;
|
|
2578
2780
|
const closeOnOutsidePointer = (event) => {
|
|
2579
2781
|
if (!filterRef.current?.contains(event.target)) setFilterEditor(null);
|
|
@@ -2581,7 +2783,7 @@ function TableInner({
|
|
|
2581
2783
|
document.addEventListener("pointerdown", closeOnOutsidePointer);
|
|
2582
2784
|
return () => document.removeEventListener("pointerdown", closeOnOutsidePointer);
|
|
2583
2785
|
}, [filterEditor]);
|
|
2584
|
-
(0,
|
|
2786
|
+
(0, import_react8.useEffect)(() => {
|
|
2585
2787
|
if (!contextMenu) return;
|
|
2586
2788
|
const close = (event) => {
|
|
2587
2789
|
if (!contextMenuRef.current?.contains(event.target)) setContextMenu(null);
|
|
@@ -2596,10 +2798,10 @@ function TableInner({
|
|
|
2596
2798
|
document.removeEventListener("keydown", closeOnEscape);
|
|
2597
2799
|
};
|
|
2598
2800
|
}, [contextMenu]);
|
|
2599
|
-
(0,
|
|
2801
|
+
(0, import_react8.useEffect)(() => {
|
|
2600
2802
|
if (!confirmAction) setConfirmLoading(false);
|
|
2601
2803
|
}, [confirmAction]);
|
|
2602
|
-
(0,
|
|
2804
|
+
(0, import_react8.useEffect)(() => {
|
|
2603
2805
|
const scroller = scrollerRef.current;
|
|
2604
2806
|
if (!scroller || !insertBusy) return;
|
|
2605
2807
|
const left = scroller.scrollLeft;
|
|
@@ -2611,7 +2813,7 @@ function TableInner({
|
|
|
2611
2813
|
scroller.addEventListener("scroll", lockScroll);
|
|
2612
2814
|
return () => scroller.removeEventListener("scroll", lockScroll);
|
|
2613
2815
|
}, [insertBusy]);
|
|
2614
|
-
const showCustomScrollbar = (0,
|
|
2816
|
+
const showCustomScrollbar = (0, import_react8.useCallback)((axis, persist = false) => {
|
|
2615
2817
|
const showVertical = axis === "vertical" || axis === "both";
|
|
2616
2818
|
const showHorizontal = axis === "horizontal" || axis === "both";
|
|
2617
2819
|
if (showVertical) {
|
|
@@ -2635,15 +2837,15 @@ function TableInner({
|
|
|
2635
2837
|
}
|
|
2636
2838
|
}
|
|
2637
2839
|
}, []);
|
|
2638
|
-
const keepCustomScrollbarVisible = (0,
|
|
2840
|
+
const keepCustomScrollbarVisible = (0, import_react8.useCallback)((axis) => {
|
|
2639
2841
|
showCustomScrollbar(axis, true);
|
|
2640
2842
|
}, [showCustomScrollbar]);
|
|
2641
|
-
const releaseCustomScrollbarVisible = (0,
|
|
2843
|
+
const releaseCustomScrollbarVisible = (0, import_react8.useCallback)((axis) => {
|
|
2642
2844
|
if (axis === "vertical" && verticalScrollbarDragRef.current) return;
|
|
2643
2845
|
if (axis === "horizontal" && horizontalScrollbarDragRef.current) return;
|
|
2644
2846
|
showCustomScrollbar(axis);
|
|
2645
2847
|
}, [showCustomScrollbar]);
|
|
2646
|
-
const updateCustomScrollbars = (0,
|
|
2848
|
+
const updateCustomScrollbars = (0, import_react8.useCallback)(() => {
|
|
2647
2849
|
const scroller = scrollerRef.current;
|
|
2648
2850
|
const verticalTrack = verticalScrollbarRef.current;
|
|
2649
2851
|
const verticalThumb = verticalScrollbarThumbRef.current;
|
|
@@ -2693,10 +2895,10 @@ function TableInner({
|
|
|
2693
2895
|
horizontalThumb.style.width = `${Math.min(trackWidth, thumbWidth)}px`;
|
|
2694
2896
|
horizontalThumb.style.transform = `translateX(${thumbLeft}px)`;
|
|
2695
2897
|
}, [autoHeight, bodyTop, bottomSummaryHeight, effectiveHeight, fixedHeader, fixedWidth, realContentHeight, renderHeight, rightFixedWidth, viewport.width]);
|
|
2696
|
-
(0,
|
|
2898
|
+
(0, import_react8.useLayoutEffect)(() => {
|
|
2697
2899
|
updateCustomScrollbars();
|
|
2698
2900
|
}, [contentHeight, contentWidth, updateCustomScrollbars, viewport.height, viewport.width]);
|
|
2699
|
-
const handleVerticalScrollbarPointerDown = (0,
|
|
2901
|
+
const handleVerticalScrollbarPointerDown = (0, import_react8.useCallback)((event) => {
|
|
2700
2902
|
const scroller = scrollerRef.current;
|
|
2701
2903
|
const track = verticalScrollbarRef.current;
|
|
2702
2904
|
const thumb = verticalScrollbarThumbRef.current;
|
|
@@ -2733,7 +2935,7 @@ function TableInner({
|
|
|
2733
2935
|
maxScrollTop
|
|
2734
2936
|
};
|
|
2735
2937
|
}, [showCustomScrollbar, updateCustomScrollbars]);
|
|
2736
|
-
const handleVerticalScrollbarPointerMove = (0,
|
|
2938
|
+
const handleVerticalScrollbarPointerMove = (0, import_react8.useCallback)((event) => {
|
|
2737
2939
|
const drag = verticalScrollbarDragRef.current;
|
|
2738
2940
|
const scroller = scrollerRef.current;
|
|
2739
2941
|
if (!drag || !scroller || drag.pointerId !== event.pointerId) return;
|
|
@@ -2743,14 +2945,14 @@ function TableInner({
|
|
|
2743
2945
|
scroller.scrollTop = nextThumbTop / maxThumbTop * drag.maxScrollTop;
|
|
2744
2946
|
updateCustomScrollbars();
|
|
2745
2947
|
}, [updateCustomScrollbars]);
|
|
2746
|
-
const handleVerticalScrollbarPointerUp = (0,
|
|
2948
|
+
const handleVerticalScrollbarPointerUp = (0, import_react8.useCallback)((event) => {
|
|
2747
2949
|
const drag = verticalScrollbarDragRef.current;
|
|
2748
2950
|
if (!drag || drag.pointerId !== event.pointerId) return;
|
|
2749
2951
|
if (event.currentTarget.hasPointerCapture(event.pointerId)) event.currentTarget.releasePointerCapture(event.pointerId);
|
|
2750
2952
|
verticalScrollbarDragRef.current = null;
|
|
2751
2953
|
showCustomScrollbar("vertical");
|
|
2752
2954
|
}, [showCustomScrollbar]);
|
|
2753
|
-
const handleHorizontalScrollbarPointerDown = (0,
|
|
2955
|
+
const handleHorizontalScrollbarPointerDown = (0, import_react8.useCallback)((event) => {
|
|
2754
2956
|
const scroller = scrollerRef.current;
|
|
2755
2957
|
const track = horizontalScrollbarRef.current;
|
|
2756
2958
|
const thumb = horizontalScrollbarThumbRef.current;
|
|
@@ -2793,7 +2995,7 @@ function TableInner({
|
|
|
2793
2995
|
maxScrollLeft
|
|
2794
2996
|
};
|
|
2795
2997
|
}, [drawImmediately, getSelectionHorizontalVisibility, showCustomScrollbar, syncSelectionEdgeTarget, updateCustomScrollbars]);
|
|
2796
|
-
const handleHorizontalScrollbarPointerMove = (0,
|
|
2998
|
+
const handleHorizontalScrollbarPointerMove = (0, import_react8.useCallback)((event) => {
|
|
2797
2999
|
const drag = horizontalScrollbarDragRef.current;
|
|
2798
3000
|
const scroller = scrollerRef.current;
|
|
2799
3001
|
if (!drag || !scroller || drag.pointerId !== event.pointerId) return;
|
|
@@ -2809,14 +3011,14 @@ function TableInner({
|
|
|
2809
3011
|
if (visibilityChanged) drawImmediately();
|
|
2810
3012
|
updateCustomScrollbars();
|
|
2811
3013
|
}, [drawImmediately, getSelectionHorizontalVisibility, syncSelectionEdgeTarget, updateCustomScrollbars]);
|
|
2812
|
-
const handleHorizontalScrollbarPointerUp = (0,
|
|
3014
|
+
const handleHorizontalScrollbarPointerUp = (0, import_react8.useCallback)((event) => {
|
|
2813
3015
|
const drag = horizontalScrollbarDragRef.current;
|
|
2814
3016
|
if (!drag || drag.pointerId !== event.pointerId) return;
|
|
2815
3017
|
if (event.currentTarget.hasPointerCapture(event.pointerId)) event.currentTarget.releasePointerCapture(event.pointerId);
|
|
2816
3018
|
horizontalScrollbarDragRef.current = null;
|
|
2817
3019
|
showCustomScrollbar("horizontal");
|
|
2818
3020
|
}, [showCustomScrollbar]);
|
|
2819
|
-
const handleScroll = (0,
|
|
3021
|
+
const handleScroll = (0, import_react8.useCallback)(() => {
|
|
2820
3022
|
const element = scrollerRef.current;
|
|
2821
3023
|
if (!element) return;
|
|
2822
3024
|
const previousScroll = scrollRef.current;
|
|
@@ -2878,7 +3080,7 @@ function TableInner({
|
|
|
2878
3080
|
scheduleDraw();
|
|
2879
3081
|
setEditing(null);
|
|
2880
3082
|
}, [bodyTop, columns, renderHeight, fixedHeader, fixedWidth, getCellDisplayWidth, getCellSpan, getRowKey, getScrollableColumnLeft, metrics, rightFixedOffsets, rightFixedWidth, rowHeight, rows, scheduleDraw, selection, selectionRange, showCustomScrollbar, syncSelectionEdgeTarget, updateCustomScrollbars, viewport.width]);
|
|
2881
|
-
const locateColumn = (0,
|
|
3083
|
+
const locateColumn = (0, import_react8.useCallback)((clientX) => {
|
|
2882
3084
|
const canvas = canvasRef.current;
|
|
2883
3085
|
if (!canvas) return -1;
|
|
2884
3086
|
const rect = canvas.getBoundingClientRect();
|
|
@@ -2906,17 +3108,17 @@ function TableInner({
|
|
|
2906
3108
|
}
|
|
2907
3109
|
return columnIndex;
|
|
2908
3110
|
}, [columns, fixedWidth, getScrollableColumnLeft, leftFixedOffsets, metrics, rightFixedOffsets, rightFixedWidth, viewport.width]);
|
|
2909
|
-
const getDisplayedColumnLeft = (0,
|
|
3111
|
+
const getDisplayedColumnLeft = (0, import_react8.useCallback)((columnIndex) => {
|
|
2910
3112
|
const metric = metrics[columnIndex];
|
|
2911
3113
|
if (columns[columnIndex].fixed === "left") return leftFixedOffsets.get(columnIndex) ?? 0;
|
|
2912
3114
|
if (columns[columnIndex].fixed === "right") return viewport.width - (rightFixedOffsets.get(columnIndex) ?? 0) - metric.width;
|
|
2913
3115
|
return getScrollableColumnLeft(columnIndex) - scrollRef.current.left;
|
|
2914
3116
|
}, [columns, getScrollableColumnLeft, leftFixedOffsets, metrics, rightFixedOffsets, viewport.width]);
|
|
2915
|
-
const trailingColumnBorderLeft = (0,
|
|
3117
|
+
const trailingColumnBorderLeft = (0, import_react8.useMemo)(() => {
|
|
2916
3118
|
const displayedContentRight = columns.reduce((right, _column, columnIndex) => Math.max(right, getDisplayedColumnLeft(columnIndex) + metrics[columnIndex].width), 0);
|
|
2917
3119
|
return displayedContentRight > 0 && displayedContentRight < viewport.width ? Math.round(displayedContentRight) - 1 : null;
|
|
2918
3120
|
}, [columns, getDisplayedColumnLeft, metrics, scrollPosition.left, viewport.width]);
|
|
2919
|
-
const getHeaderLevelAtY = (0,
|
|
3121
|
+
const getHeaderLevelAtY = (0, import_react8.useCallback)((localY, headerY) => {
|
|
2920
3122
|
const y = localY - headerY;
|
|
2921
3123
|
for (let level = 0; level < headerRowHeights.length; level += 1) {
|
|
2922
3124
|
const top = headerRowOffsets[level] ?? 0;
|
|
@@ -2924,11 +3126,11 @@ function TableInner({
|
|
|
2924
3126
|
}
|
|
2925
3127
|
return headerDepth - 1;
|
|
2926
3128
|
}, [headerDepth, headerRowHeights, headerRowOffsets]);
|
|
2927
|
-
const resizeColumn = (0,
|
|
3129
|
+
const resizeColumn = (0, import_react8.useCallback)((columnKey, width2) => {
|
|
2928
3130
|
setResizedColumnWidths((current) => current[columnKey] === width2 ? current : { ...current, [columnKey]: width2 });
|
|
2929
3131
|
onColumnResize?.(columnKey, width2);
|
|
2930
3132
|
}, [onColumnResize]);
|
|
2931
|
-
const locateHeaderAction = (0,
|
|
3133
|
+
const locateHeaderAction = (0, import_react8.useCallback)((clientX, clientY, columnIndex) => {
|
|
2932
3134
|
if (columnIndex < 0 || !canvasRef.current) return null;
|
|
2933
3135
|
const column = columns[columnIndex];
|
|
2934
3136
|
if (column.rowSelection || column.rowDragHandle || column.rowNumber) return null;
|
|
@@ -2948,7 +3150,7 @@ function TableInner({
|
|
|
2948
3150
|
if (visibleActions.filter && localX >= right - headerActionSlotWidth && localX < right) return "filter";
|
|
2949
3151
|
return null;
|
|
2950
3152
|
}, [columnDraggable, columns, fixedHeader, getDisplayedColumnLeft, headerActionSize, headerActionSlotWidth, headerLeafHeight, headerLeafTop, measureHeaderTitleWidth, metrics]);
|
|
2951
|
-
const isHeaderTitleTruncated = (0,
|
|
3153
|
+
const isHeaderTitleTruncated = (0, import_react8.useCallback)((columnIndex) => {
|
|
2952
3154
|
const canvas = canvasRef.current;
|
|
2953
3155
|
if (columnIndex < 0 || !canvas) return false;
|
|
2954
3156
|
const column = columns[columnIndex];
|
|
@@ -2958,7 +3160,7 @@ function TableInner({
|
|
|
2958
3160
|
const actionWidth = (Number(visibleActions.drag) + Number(visibleActions.filter) + Number(visibleActions.sort)) * headerActionSlotWidth;
|
|
2959
3161
|
return getHeaderTitleRequiredWidth(column, titleWidth) > Math.max(0, metric.width - actionWidth);
|
|
2960
3162
|
}, [columnDraggable, columns, headerActionSlotWidth, measureHeaderTitleWidth, metrics]);
|
|
2961
|
-
const locateHeaderDragHandle = (0,
|
|
3163
|
+
const locateHeaderDragHandle = (0, import_react8.useCallback)((clientX, clientY, columnIndex) => {
|
|
2962
3164
|
if (!columnDraggable || columnIndex < 0 || !canvasRef.current) return false;
|
|
2963
3165
|
const column = columns[columnIndex];
|
|
2964
3166
|
if (column.rowSelection || column.rowDragHandle || column.rowNumber) return false;
|
|
@@ -2972,14 +3174,14 @@ function TableInner({
|
|
|
2972
3174
|
const columnRight = getDisplayedColumnLeft(columnIndex) + metrics[columnIndex].width;
|
|
2973
3175
|
return localX >= columnRight - headerActionSlotWidth && localX < columnRight - 2;
|
|
2974
3176
|
}, [columnDraggable, columns, fixedHeader, getDisplayedColumnLeft, headerActionSize, headerActionSlotWidth, headerLeafHeight, headerLeafTop, measureHeaderTitleWidth, metrics]);
|
|
2975
|
-
const getHeaderCellLeft = (0,
|
|
3177
|
+
const getHeaderCellLeft = (0, import_react8.useCallback)((cell) => {
|
|
2976
3178
|
const startMetric = metrics[cell.startIndex];
|
|
2977
3179
|
const fixedSide = columns[cell.startIndex]?.fixed;
|
|
2978
3180
|
if (!startMetric) return 0;
|
|
2979
3181
|
return fixedSide === "left" ? leftFixedOffsets.get(cell.startIndex) ?? 0 : fixedSide === "right" ? viewport.width - (rightFixedOffsets.get(cell.startIndex) ?? 0) - startMetric.width : getScrollableColumnLeft(cell.startIndex) - scrollRef.current.left;
|
|
2980
3182
|
}, [columns, getScrollableColumnLeft, leftFixedOffsets, metrics, rightFixedOffsets, viewport.width]);
|
|
2981
|
-
const getHeaderCellWidth = (0,
|
|
2982
|
-
const getHeaderCellEdgeFromMetrics = (0,
|
|
3183
|
+
const getHeaderCellWidth = (0, import_react8.useCallback)((cell) => cell.leaf ? metrics[cell.startIndex]?.width ?? 0 : getCellDisplayWidth(cell.startIndex, cell.endIndex - cell.startIndex + 1), [getCellDisplayWidth, metrics]);
|
|
3184
|
+
const getHeaderCellEdgeFromMetrics = (0, import_react8.useCallback)((startIndex, endIndex, edge, nextMetrics) => {
|
|
2983
3185
|
const fixedSide = columns[startIndex]?.fixed;
|
|
2984
3186
|
const width2 = nextMetrics.slice(startIndex, endIndex + 1).reduce((total, metric) => total + metric.width, 0);
|
|
2985
3187
|
let left;
|
|
@@ -3003,7 +3205,7 @@ function TableInner({
|
|
|
3003
3205
|
}
|
|
3004
3206
|
return left + (edge === "right" ? width2 : 0);
|
|
3005
3207
|
}, [columns, fixedWidth, viewport.width]);
|
|
3006
|
-
const locateHeaderResizeHit = (0,
|
|
3208
|
+
const locateHeaderResizeHit = (0, import_react8.useCallback)((clientX, clientY) => {
|
|
3007
3209
|
if (!columnResizable || !canvasRef.current) return null;
|
|
3008
3210
|
const rect = canvasRef.current.getBoundingClientRect();
|
|
3009
3211
|
const localX = clientX - rect.left;
|
|
@@ -3030,15 +3232,15 @@ function TableInner({
|
|
|
3030
3232
|
}
|
|
3031
3233
|
return closest;
|
|
3032
3234
|
}, [columnResizable, columns, fixedHeader, getHeaderCellLeft, getHeaderCellWidth, getHeaderLevelAtY, headerCells, headerHeight]);
|
|
3033
|
-
const locateHeaderResizeCell = (0,
|
|
3034
|
-
const locateHeaderCellDragHandle = (0,
|
|
3235
|
+
const locateHeaderResizeCell = (0, import_react8.useCallback)((clientX, clientY) => locateHeaderResizeHit(clientX, clientY)?.cell ?? null, [locateHeaderResizeHit]);
|
|
3236
|
+
const locateHeaderCellDragHandle = (0, import_react8.useCallback)((clientX, clientY, cell) => {
|
|
3035
3237
|
if (!columnDraggable || !canvasRef.current) return false;
|
|
3036
3238
|
if (cell.leaf) return locateHeaderDragHandle(clientX, clientY, cell.startIndex);
|
|
3037
3239
|
const localX = clientX - canvasRef.current.getBoundingClientRect().left;
|
|
3038
3240
|
const right = getHeaderCellLeft(cell) + getHeaderCellWidth(cell);
|
|
3039
3241
|
return localX >= right - headerActionSlotWidth && localX < right - 2;
|
|
3040
3242
|
}, [columnDraggable, getHeaderCellLeft, getHeaderCellWidth, headerActionSlotWidth, locateHeaderDragHandle]);
|
|
3041
|
-
const locateHeaderCell = (0,
|
|
3243
|
+
const locateHeaderCell = (0, import_react8.useCallback)((clientX, clientY) => {
|
|
3042
3244
|
const canvas = canvasRef.current;
|
|
3043
3245
|
if (!canvas) return null;
|
|
3044
3246
|
const rect = canvas.getBoundingClientRect();
|
|
@@ -3055,7 +3257,7 @@ function TableInner({
|
|
|
3055
3257
|
}
|
|
3056
3258
|
return null;
|
|
3057
3259
|
}, [fixedHeader, getHeaderCellLeft, getHeaderCellWidth, getHeaderLevelAtY, headerCells, headerHeight]);
|
|
3058
|
-
const setDragGuide = (0,
|
|
3260
|
+
const setDragGuide = (0, import_react8.useCallback)((x, top = 0) => {
|
|
3059
3261
|
const guide = dragGuideRef.current;
|
|
3060
3262
|
if (!guide) return;
|
|
3061
3263
|
guide.style.display = x === null ? "none" : "block";
|
|
@@ -3064,20 +3266,20 @@ function TableInner({
|
|
|
3064
3266
|
guide.style.transform = `translateX(${Math.round(x)}px)`;
|
|
3065
3267
|
}
|
|
3066
3268
|
}, []);
|
|
3067
|
-
const setRowDragGuide = (0,
|
|
3269
|
+
const setRowDragGuide = (0, import_react8.useCallback)((y) => {
|
|
3068
3270
|
const guide = rowDragGuideRef.current;
|
|
3069
3271
|
if (!guide) return;
|
|
3070
3272
|
guide.style.display = y === null ? "none" : "block";
|
|
3071
3273
|
if (y !== null) guide.style.transform = `translateY(${Math.round(y)}px)`;
|
|
3072
3274
|
}, []);
|
|
3073
|
-
const locateRow = (0,
|
|
3275
|
+
const locateRow = (0, import_react8.useCallback)((clientY) => {
|
|
3074
3276
|
const canvas = canvasRef.current;
|
|
3075
3277
|
if (!canvas) return -1;
|
|
3076
3278
|
const localY = clientY - canvas.getBoundingClientRect().top;
|
|
3077
3279
|
const rowIndex = Math.floor((localY - bodyTop + scrollRef.current.top) / rowHeight);
|
|
3078
3280
|
return rowIndex >= 0 && rowIndex < rows.length ? rowIndex : -1;
|
|
3079
3281
|
}, [bodyTop, rowHeight, rows.length]);
|
|
3080
|
-
(0,
|
|
3282
|
+
(0, import_react8.useEffect)(() => {
|
|
3081
3283
|
const canvas = canvasRef.current;
|
|
3082
3284
|
if (!canvas || !rowDraggable) return;
|
|
3083
3285
|
const cleanupDrag = (0, import_adapter.draggable)({
|
|
@@ -3200,7 +3402,7 @@ function TableInner({
|
|
|
3200
3402
|
cleanupDrop();
|
|
3201
3403
|
};
|
|
3202
3404
|
}, [applyRowOrder, bodyTop, columns, getCellLabel, getDisplayedColumnLeft, getRowKey, hideDragTooltips, locateColumn, locateRow, metrics, rowDraggable, rowHeight, rows, selectedRowKeySet, selection, setRowDragGuide]);
|
|
3203
|
-
const locateCell = (0,
|
|
3405
|
+
const locateCell = (0, import_react8.useCallback)((clientX, clientY) => {
|
|
3204
3406
|
const canvas = canvasRef.current;
|
|
3205
3407
|
if (!canvas) return null;
|
|
3206
3408
|
const rect = canvas.getBoundingClientRect();
|
|
@@ -3220,7 +3422,7 @@ function TableInner({
|
|
|
3220
3422
|
columnKey: columns[targetColumnIndex].key
|
|
3221
3423
|
};
|
|
3222
3424
|
}, [bodyTop, columns, fixedHeader, getCellSpan, getRowKey, locateColumn, rowHeight, rows]);
|
|
3223
|
-
const beginRangeDrag = (0,
|
|
3425
|
+
const beginRangeDrag = (0, import_react8.useCallback)((event) => {
|
|
3224
3426
|
if (!rangeSelection) return;
|
|
3225
3427
|
if (event.button !== 0 || editing || event.target !== event.currentTarget) return;
|
|
3226
3428
|
const cell = locateCell(event.clientX, event.clientY);
|
|
@@ -3229,7 +3431,7 @@ function TableInner({
|
|
|
3229
3431
|
setSelectionRange(null);
|
|
3230
3432
|
event.currentTarget.setPointerCapture(event.pointerId);
|
|
3231
3433
|
}, [columns, editing, locateCell, rangeSelection]);
|
|
3232
|
-
const updateRangeDrag = (0,
|
|
3434
|
+
const updateRangeDrag = (0, import_react8.useCallback)((event) => {
|
|
3233
3435
|
const drag = rangeDragRef.current;
|
|
3234
3436
|
if (!drag) return;
|
|
3235
3437
|
const focus = locateCell(event.clientX, event.clientY);
|
|
@@ -3239,7 +3441,7 @@ function TableInner({
|
|
|
3239
3441
|
event.preventDefault();
|
|
3240
3442
|
setSelectionRange((current) => current?.focus.rowIndex === focus.rowIndex && current.focus.columnIndex === focus.columnIndex ? current : { anchor: drag.anchor, focus });
|
|
3241
3443
|
}, [columns, locateCell]);
|
|
3242
|
-
const endRangeDrag = (0,
|
|
3444
|
+
const endRangeDrag = (0, import_react8.useCallback)((event) => {
|
|
3243
3445
|
const drag = rangeDragRef.current;
|
|
3244
3446
|
if (!drag) return;
|
|
3245
3447
|
rangeDragRef.current = null;
|
|
@@ -3249,7 +3451,7 @@ function TableInner({
|
|
|
3249
3451
|
setSelection(drag.anchor);
|
|
3250
3452
|
scrollerRef.current?.focus({ preventScroll: true });
|
|
3251
3453
|
}, [setSelection]);
|
|
3252
|
-
const selectRow = (0,
|
|
3454
|
+
const selectRow = (0, import_react8.useCallback)((rowIndex, event, forceToggle = false) => {
|
|
3253
3455
|
if (!rowSelection) return;
|
|
3254
3456
|
clickedCellRef.current = null;
|
|
3255
3457
|
setSelectionRange(null);
|
|
@@ -3269,7 +3471,7 @@ function TableInner({
|
|
|
3269
3471
|
rowAnchorRef.current = rowIndex;
|
|
3270
3472
|
setRowKeys(next);
|
|
3271
3473
|
}, [getRowKey, rowKeys, rowSelection, rows, selectedRowKeySet, setRowKeys, setSelection]);
|
|
3272
|
-
const selectColumn = (0,
|
|
3474
|
+
const selectColumn = (0, import_react8.useCallback)((columnIndex, event) => {
|
|
3273
3475
|
if (!columnSelection || columnIndex < 0) return;
|
|
3274
3476
|
clickedCellRef.current = null;
|
|
3275
3477
|
setSelectionRange(null);
|
|
@@ -3289,7 +3491,7 @@ function TableInner({
|
|
|
3289
3491
|
columnAnchorRef.current = columnIndex;
|
|
3290
3492
|
setColumnKeys(next);
|
|
3291
3493
|
}, [columnKeys, columnSelection, columns, selectedColumnKeySet, setColumnKeys, setSelection]);
|
|
3292
|
-
const toggleColumnFromMenu = (0,
|
|
3494
|
+
const toggleColumnFromMenu = (0, import_react8.useCallback)((columnIndex) => {
|
|
3293
3495
|
if (!columnSelection || columnIndex < 0) return;
|
|
3294
3496
|
clickedCellRef.current = null;
|
|
3295
3497
|
setSelectionRange(null);
|
|
@@ -3301,7 +3503,7 @@ function TableInner({
|
|
|
3301
3503
|
columnAnchorRef.current = columnIndex;
|
|
3302
3504
|
setColumnKeys(next);
|
|
3303
3505
|
}, [columnKeys, columnSelection, columns, selectedColumnKeySet, setColumnKeys, setSelection]);
|
|
3304
|
-
const revealCell = (0,
|
|
3506
|
+
const revealCell = (0, import_react8.useCallback)((cell) => {
|
|
3305
3507
|
const scroller = scrollerRef.current;
|
|
3306
3508
|
const metric = metrics[cell.columnIndex];
|
|
3307
3509
|
const column = columns[cell.columnIndex];
|
|
@@ -3331,13 +3533,13 @@ function TableInner({
|
|
|
3331
3533
|
scrollRef.current = { left: scroller.scrollLeft, top: scroller.scrollTop };
|
|
3332
3534
|
scheduleDraw();
|
|
3333
3535
|
}, [bodyTop, columns, fixedHeader, fixedWidth, getCellDisplayWidth, getCellSpan, getScrollableColumnLeft, metrics, rightFixedWidth, rowHeight, scheduleDraw, viewport.width]);
|
|
3334
|
-
const isCellEditable = (0,
|
|
3536
|
+
const isCellEditable = (0, import_react8.useCallback)((cell) => {
|
|
3335
3537
|
const column = columns[cell.columnIndex];
|
|
3336
3538
|
const row = rows[cell.rowIndex];
|
|
3337
3539
|
if (!column || !row || column.dataIndex === void 0 || column.rowNumber || column.rowSelection || column.rowDragHandle) return false;
|
|
3338
3540
|
return typeof column.editable === "function" ? column.editable(row[column.dataIndex], row, cell.rowIndex) : column.editable === true;
|
|
3339
3541
|
}, [columns, rows]);
|
|
3340
|
-
const beginEdit = (0,
|
|
3542
|
+
const beginEdit = (0, import_react8.useCallback)((cell) => {
|
|
3341
3543
|
const column = columns[cell.columnIndex];
|
|
3342
3544
|
if (!isCellEditable(cell) || column.dataIndex === void 0) return;
|
|
3343
3545
|
const value = rows[cell.rowIndex]?.[column.dataIndex];
|
|
@@ -3407,7 +3609,7 @@ function TableInner({
|
|
|
3407
3609
|
return next;
|
|
3408
3610
|
});
|
|
3409
3611
|
};
|
|
3410
|
-
const commitEdit = (0,
|
|
3612
|
+
const commitEdit = (0, import_react8.useCallback)((nextDraft, close = true) => {
|
|
3411
3613
|
if (!editing) return;
|
|
3412
3614
|
if (!isCellEditable(editing)) {
|
|
3413
3615
|
setEditing(null);
|
|
@@ -3432,11 +3634,29 @@ function TableInner({
|
|
|
3432
3634
|
if (!editing || !editorStyle) return null;
|
|
3433
3635
|
const column = columns[editing.columnIndex];
|
|
3434
3636
|
if (column.editor?.type === "select") {
|
|
3435
|
-
return /* @__PURE__ */ (0,
|
|
3637
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
3436
3638
|
ChoiceEditor,
|
|
3437
3639
|
{
|
|
3438
3640
|
value: draft,
|
|
3439
3641
|
options: column.editor.options,
|
|
3642
|
+
searchable: column.editor.searchable,
|
|
3643
|
+
allowCustomValue: column.editor.allowCustomValue,
|
|
3644
|
+
maxDropdownHeight: column.editor.maxDropdownHeight,
|
|
3645
|
+
style: editorStyle,
|
|
3646
|
+
labels,
|
|
3647
|
+
onChange: setDraft,
|
|
3648
|
+
onCommit: (next) => commitEdit(next),
|
|
3649
|
+
onCancel: () => setEditing(null)
|
|
3650
|
+
}
|
|
3651
|
+
);
|
|
3652
|
+
}
|
|
3653
|
+
if (column.editor?.type === "textarea") {
|
|
3654
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
3655
|
+
TextAreaEditor,
|
|
3656
|
+
{
|
|
3657
|
+
value: draft,
|
|
3658
|
+
title: column.editor.title ?? column.title,
|
|
3659
|
+
maxLength: column.editor.maxLength,
|
|
3440
3660
|
style: editorStyle,
|
|
3441
3661
|
labels,
|
|
3442
3662
|
onChange: setDraft,
|
|
@@ -3446,7 +3666,7 @@ function TableInner({
|
|
|
3446
3666
|
);
|
|
3447
3667
|
}
|
|
3448
3668
|
if (column.editor?.type === "time" || column.editor?.type === "time-range") {
|
|
3449
|
-
return /* @__PURE__ */ (0,
|
|
3669
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
3450
3670
|
CompactTimeEditor,
|
|
3451
3671
|
{
|
|
3452
3672
|
value: draft,
|
|
@@ -3461,7 +3681,7 @@ function TableInner({
|
|
|
3461
3681
|
);
|
|
3462
3682
|
}
|
|
3463
3683
|
if (column.editor && ["date", "date-range", "date-time", "date-time-range", "year", "month"].includes(column.editor.type)) {
|
|
3464
|
-
return /* @__PURE__ */ (0,
|
|
3684
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
3465
3685
|
DateEditor,
|
|
3466
3686
|
{
|
|
3467
3687
|
editor: column.editor,
|
|
@@ -3477,11 +3697,14 @@ function TableInner({
|
|
|
3477
3697
|
}
|
|
3478
3698
|
const row = rows[editing.rowIndex];
|
|
3479
3699
|
const cellValue = column.dataIndex === void 0 ? void 0 : row?.[column.dataIndex];
|
|
3480
|
-
return /* @__PURE__ */ (0,
|
|
3700
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
3481
3701
|
TextEditor,
|
|
3482
3702
|
{
|
|
3483
3703
|
value: draft,
|
|
3484
|
-
type: typeof cellValue === "number" ? "number" : "text",
|
|
3704
|
+
type: column.editor?.type === "number" || typeof cellValue === "number" ? "number" : "text",
|
|
3705
|
+
min: column.editor?.type === "number" ? column.editor.min : void 0,
|
|
3706
|
+
max: column.editor?.type === "number" ? column.editor.max : void 0,
|
|
3707
|
+
integer: column.editor?.type === "number" ? column.editor.integer : void 0,
|
|
3485
3708
|
style: editorStyle,
|
|
3486
3709
|
labels,
|
|
3487
3710
|
onChange: setDraft,
|
|
@@ -3490,7 +3713,7 @@ function TableInner({
|
|
|
3490
3713
|
}
|
|
3491
3714
|
);
|
|
3492
3715
|
};
|
|
3493
|
-
const handleKeyDown = (0,
|
|
3716
|
+
const handleKeyDown = (0, import_react8.useCallback)((event) => {
|
|
3494
3717
|
if (editing || !selection) return;
|
|
3495
3718
|
if (event.key === "Enter") {
|
|
3496
3719
|
event.preventDefault();
|
|
@@ -3523,7 +3746,7 @@ function TableInner({
|
|
|
3523
3746
|
}
|
|
3524
3747
|
}
|
|
3525
3748
|
}, [beginEdit, bodyTop, columns, editing, renderHeight, fixedHeader, fixedWidth, getCellDisplayWidth, getCellSpan, getRowKey, getScrollableColumnLeft, metrics, rightFixedWidth, rowHeight, rows, selection, setSelection, viewport.width]);
|
|
3526
|
-
const editorStyle = (0,
|
|
3749
|
+
const editorStyle = (0, import_react8.useMemo)(() => {
|
|
3527
3750
|
if (!editing) return void 0;
|
|
3528
3751
|
const metric = metrics[editing.columnIndex];
|
|
3529
3752
|
const column = columns[editing.columnIndex];
|
|
@@ -3558,7 +3781,7 @@ function TableInner({
|
|
|
3558
3781
|
clipPath: `inset(${Math.max(0, visibleTop - cellTop)}px ${Math.max(0, cellLeft + cellWidth - visibleRight)}px ${Math.max(0, cellTop + cellHeight - visibleBottom)}px ${Math.max(0, visibleLeft - cellLeft)}px)`
|
|
3559
3782
|
};
|
|
3560
3783
|
}, [bodyTop, columns, editing, fixedHeader, fixedWidth, getCellDisplayWidth, getCellSpan, getScrollableColumnLeft, leftFixedOffsets, metrics, renderHeight, rightFixedOffsets, rightFixedWidth, rowHeight, viewport.width]);
|
|
3561
|
-
const handleColumnPointerDown = (0,
|
|
3784
|
+
const handleColumnPointerDown = (0, import_react8.useCallback)((event) => {
|
|
3562
3785
|
const rect = event.currentTarget.getBoundingClientRect();
|
|
3563
3786
|
const localY = event.clientY - rect.top;
|
|
3564
3787
|
const headerY = fixedHeader ? 0 : -scrollRef.current.top;
|
|
@@ -3602,7 +3825,7 @@ function TableInner({
|
|
|
3602
3825
|
return;
|
|
3603
3826
|
}
|
|
3604
3827
|
}, [fixedHeader, getHeaderCellLeft, getHeaderCellWidth, headerHeight, headerRowOffsets, locateHeaderResizeHit, metrics]);
|
|
3605
|
-
const handleColumnPointerMove = (0,
|
|
3828
|
+
const handleColumnPointerMove = (0, import_react8.useCallback)((event) => {
|
|
3606
3829
|
const drag = columnDragRef.current;
|
|
3607
3830
|
if (!drag) return;
|
|
3608
3831
|
const column = columns[drag.columnIndex];
|
|
@@ -3638,7 +3861,7 @@ function TableInner({
|
|
|
3638
3861
|
resizeColumn(column.key, width2);
|
|
3639
3862
|
setGuideFromWidths([width2]);
|
|
3640
3863
|
}, [columnDraggable, columns, getHeaderCellEdgeFromMetrics, resizeColumn, viewport.width]);
|
|
3641
|
-
const handleColumnPointerUp = (0,
|
|
3864
|
+
const handleColumnPointerUp = (0, import_react8.useCallback)((event) => {
|
|
3642
3865
|
const drag = columnDragRef.current;
|
|
3643
3866
|
if (!drag) return;
|
|
3644
3867
|
if (event.currentTarget.hasPointerCapture(event.pointerId)) event.currentTarget.releasePointerCapture(event.pointerId);
|
|
@@ -3648,7 +3871,7 @@ function TableInner({
|
|
|
3648
3871
|
document.documentElement.classList.remove("rvg-is-dragging");
|
|
3649
3872
|
event.currentTarget.style.cursor = "default";
|
|
3650
3873
|
}, []);
|
|
3651
|
-
const clearColumnOrderPointerDrag = (0,
|
|
3874
|
+
const clearColumnOrderPointerDrag = (0, import_react8.useCallback)((canvas) => {
|
|
3652
3875
|
if (columnOrderLongPressTimerRef.current) {
|
|
3653
3876
|
clearTimeout(columnOrderLongPressTimerRef.current);
|
|
3654
3877
|
columnOrderLongPressTimerRef.current = null;
|
|
@@ -3661,7 +3884,7 @@ function TableInner({
|
|
|
3661
3884
|
document.documentElement.classList.remove("rvg-is-dragging");
|
|
3662
3885
|
canvas.style.cursor = "default";
|
|
3663
3886
|
}, [setDragGuide]);
|
|
3664
|
-
const updateColumnDragPreview = (0,
|
|
3887
|
+
const updateColumnDragPreview = (0, import_react8.useCallback)((sourceCell, clientX, canvas) => {
|
|
3665
3888
|
const rootRect = rootRef.current?.getBoundingClientRect() ?? canvas.getBoundingClientRect();
|
|
3666
3889
|
const sourceWidth = metrics[sourceCell.startIndex]?.width ?? 100;
|
|
3667
3890
|
const previewWidth = sourceWidth;
|
|
@@ -3673,7 +3896,7 @@ function TableInner({
|
|
|
3673
3896
|
sourceLeft: getDisplayedColumnLeft(sourceCell.startIndex)
|
|
3674
3897
|
});
|
|
3675
3898
|
}, [getDisplayedColumnLeft, metrics, viewport.width]);
|
|
3676
|
-
const activateColumnOrderPointerDrag = (0,
|
|
3899
|
+
const activateColumnOrderPointerDrag = (0, import_react8.useCallback)((canvas, clientX) => {
|
|
3677
3900
|
const drag = columnOrderDragRef.current;
|
|
3678
3901
|
if (!drag || drag.active) return;
|
|
3679
3902
|
if (columnOrderLongPressTimerRef.current) {
|
|
@@ -3687,7 +3910,7 @@ function TableInner({
|
|
|
3687
3910
|
canvas.style.cursor = "move";
|
|
3688
3911
|
updateColumnDragPreview(drag.sourceCell, clientX, canvas);
|
|
3689
3912
|
}, [hideDragTooltips, updateColumnDragPreview]);
|
|
3690
|
-
const handleColumnOrderPointerDown = (0,
|
|
3913
|
+
const handleColumnOrderPointerDown = (0, import_react8.useCallback)((event) => {
|
|
3691
3914
|
if (!columnDraggable || event.button !== 0 || columnDragRef.current) return;
|
|
3692
3915
|
const sourceCell = locateHeaderCell(event.clientX, event.clientY);
|
|
3693
3916
|
if (!sourceCell || locateHeaderResizeCell(event.clientX, event.clientY)) return;
|
|
@@ -3711,7 +3934,7 @@ function TableInner({
|
|
|
3711
3934
|
activateColumnOrderPointerDrag(canvas, drag.startX);
|
|
3712
3935
|
}, 320);
|
|
3713
3936
|
}, [activateColumnOrderPointerDrag, columnDraggable, columns, locateHeaderAction, locateHeaderCell, locateHeaderResizeCell]);
|
|
3714
|
-
const handleColumnOrderPointerMove = (0,
|
|
3937
|
+
const handleColumnOrderPointerMove = (0, import_react8.useCallback)((event) => {
|
|
3715
3938
|
const drag = columnOrderDragRef.current;
|
|
3716
3939
|
if (!drag || drag.pointerId !== event.pointerId || columnDragRef.current) return;
|
|
3717
3940
|
if (!drag.active) {
|
|
@@ -3782,7 +4005,7 @@ function TableInner({
|
|
|
3782
4005
|
columnEdge
|
|
3783
4006
|
};
|
|
3784
4007
|
}, [activateColumnOrderPointerDrag, columns, getHeaderCellLeft, getHeaderCellWidth, headerCells, headerRowOffsets, locateColumn, locateHeaderCell, setDragGuide, updateColumnDragPreview]);
|
|
3785
|
-
const finishColumnOrderPointerDrag = (0,
|
|
4008
|
+
const finishColumnOrderPointerDrag = (0, import_react8.useCallback)((event, apply) => {
|
|
3786
4009
|
const drag = columnOrderDragRef.current;
|
|
3787
4010
|
if (!drag || drag.pointerId !== event.pointerId) return;
|
|
3788
4011
|
if (event.currentTarget.hasPointerCapture(event.pointerId)) event.currentTarget.releasePointerCapture(event.pointerId);
|
|
@@ -3806,7 +4029,7 @@ function TableInner({
|
|
|
3806
4029
|
suppressClickRef.current = false;
|
|
3807
4030
|
}, 0);
|
|
3808
4031
|
}, [applyColumnOrder, clearColumnOrderPointerDrag, utilityColumnCount]);
|
|
3809
|
-
const queueSortStateChange = (0,
|
|
4032
|
+
const queueSortStateChange = (0, import_react8.useCallback)((next) => {
|
|
3810
4033
|
setSortState(next);
|
|
3811
4034
|
}, []);
|
|
3812
4035
|
const renderHeaderIcons = (columnIndex, left) => {
|
|
@@ -3822,26 +4045,26 @@ function TableInner({
|
|
|
3822
4045
|
if (visibleActions.drag) {
|
|
3823
4046
|
const hovered = hoveredHeaderAction?.columnIndex === columnIndex && hoveredHeaderAction.action === "drag";
|
|
3824
4047
|
icons.push(
|
|
3825
|
-
/* @__PURE__ */ (0,
|
|
4048
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(HeaderDragIcon, { className: `rvg-header-icon rvg-header-drag-icon${selectedClassName}${hoveredColumnClassName}${hovered ? " is-hovered" : ""}`, style: { left: left + metrics[columnIndex].width - headerActionSlotWidth, top } }, "drag")
|
|
3826
4049
|
);
|
|
3827
4050
|
}
|
|
3828
4051
|
if (visibleActions.sort) {
|
|
3829
4052
|
const hovered = hoveredHeaderAction?.columnIndex === columnIndex && hoveredHeaderAction.action === "sort";
|
|
3830
4053
|
const direction = sortState?.columnKey === column.key ? sortState.direction : null;
|
|
3831
4054
|
icons.push(
|
|
3832
|
-
/* @__PURE__ */ (0,
|
|
4055
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(HeaderSortIcon, { className: `rvg-header-icon${selectedClassName}${hoveredColumnClassName}${direction ? " is-active" : ""}${hovered ? " is-hovered" : ""}`, style: { left: right - headerActionSlotWidth, top }, direction }, "sort")
|
|
3833
4056
|
);
|
|
3834
4057
|
right -= headerActionSlotWidth;
|
|
3835
4058
|
}
|
|
3836
4059
|
if (visibleActions.filter) {
|
|
3837
4060
|
const hovered = hoveredHeaderAction?.columnIndex === columnIndex && hoveredHeaderAction.action === "filter";
|
|
3838
4061
|
icons.push(
|
|
3839
|
-
/* @__PURE__ */ (0,
|
|
4062
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(HeaderSearchIcon, { className: `rvg-header-icon rvg-header-search-icon${selectedClassName}${hoveredColumnClassName}${hovered ? " is-hovered" : ""}${filterValues[column.key] ? " is-active" : ""}`, style: { left: right - headerActionSlotWidth, top: top + 1 } }, "filter")
|
|
3840
4063
|
);
|
|
3841
4064
|
}
|
|
3842
4065
|
return icons;
|
|
3843
4066
|
};
|
|
3844
|
-
const createHeaderTooltip = (0,
|
|
4067
|
+
const createHeaderTooltip = (0, import_react8.useCallback)((action, columnIndex, cell) => {
|
|
3845
4068
|
const column = cell?.column ?? columns[columnIndex];
|
|
3846
4069
|
if (!column) return null;
|
|
3847
4070
|
const cellLeft = cell ? getHeaderCellLeft(cell) : getDisplayedColumnLeft(columnIndex);
|
|
@@ -3910,7 +4133,7 @@ function TableInner({
|
|
|
3910
4133
|
placement
|
|
3911
4134
|
};
|
|
3912
4135
|
}, [baseHeaderHeight, columnDraggable, columns, filterValues, fixedHeader, getDisplayedColumnLeft, getHeaderCellLeft, getHeaderCellWidth, headerActionSize, headerActionSlotWidth, headerDepth, headerLeafHeight, headerLeafTop, headerRowHeights, headerRowOffsets, labels, measureHeaderTitleWidth, metrics, scrollPosition.top, sortState, viewport.width]);
|
|
3913
|
-
const isPointerOnHeaderTitle = (0,
|
|
4136
|
+
const isPointerOnHeaderTitle = (0, import_react8.useCallback)((clientX, clientY, cell) => {
|
|
3914
4137
|
const canvas = canvasRef.current;
|
|
3915
4138
|
if (!canvas) return false;
|
|
3916
4139
|
const rect = canvas.getBoundingClientRect();
|
|
@@ -3931,7 +4154,7 @@ function TableInner({
|
|
|
3931
4154
|
const textTop = rowTop + 8;
|
|
3932
4155
|
return localX >= textLeft - 4 && localX <= textLeft + textWidth + 4 && localY >= textTop - 2 && localY <= textTop + 18;
|
|
3933
4156
|
}, [columnDraggable, fixedHeader, getHeaderCellLeft, getHeaderCellWidth, headerActionSlotWidth, headerRowOffsets]);
|
|
3934
|
-
const locateCustomHeaderTooltip = (0,
|
|
4157
|
+
const locateCustomHeaderTooltip = (0, import_react8.useCallback)((clientX, clientY, columnIndex) => {
|
|
3935
4158
|
const root = rootRef.current;
|
|
3936
4159
|
const canvas = canvasRef.current;
|
|
3937
4160
|
if (!root || !canvas || columnIndex < 0) return null;
|
|
@@ -4125,20 +4348,20 @@ function TableInner({
|
|
|
4125
4348
|
setAnnotationOpen(false);
|
|
4126
4349
|
setContextMenu(null);
|
|
4127
4350
|
};
|
|
4128
|
-
return /* @__PURE__ */ (0,
|
|
4129
|
-
/* @__PURE__ */ (0,
|
|
4130
|
-
/* @__PURE__ */ (0,
|
|
4131
|
-
/* @__PURE__ */ (0,
|
|
4132
|
-
/* @__PURE__ */ (0,
|
|
4133
|
-
/* @__PURE__ */ (0,
|
|
4351
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_jsx_runtime8.Fragment, { children: [
|
|
4352
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: `rvg-annotation-submenu is-${annotationPlacement}`, onMouseEnter: openAnnotation, onMouseLeave: () => setAnnotationOpen(false), children: [
|
|
4353
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("button", { type: "button", role: "menuitem", className: "rvg-context-annotation-trigger", "aria-expanded": annotationOpen, children: [
|
|
4354
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { className: "rvg-context-menu-icon", children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(ContextMenuIcon, { type: "annotation" }) }),
|
|
4355
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { className: "rvg-context-menu-label", children: labels.annotation }),
|
|
4356
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(SubmenuArrowIcon, {})
|
|
4134
4357
|
] }),
|
|
4135
|
-
annotationOpen && /* @__PURE__ */ (0,
|
|
4136
|
-
/* @__PURE__ */ (0,
|
|
4137
|
-
/* @__PURE__ */ (0,
|
|
4138
|
-
/* @__PURE__ */ (0,
|
|
4358
|
+
annotationOpen && /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: `rvg-annotation-panel is-${annotationPlacement}`, role: "menu", children: [
|
|
4359
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: `rvg-annotation-types${annotationType === "corner" ? " is-corner" : ""}`, role: "group", "aria-label": labels.annotationMode, children: [
|
|
4360
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("button", { type: "button", className: annotationType === "background" ? "is-active" : "", onClick: () => setAnnotationType("background"), children: labels.annotationBackground }),
|
|
4361
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("button", { type: "button", className: annotationType === "corner" ? "is-active" : "", onClick: () => setAnnotationType("corner"), children: labels.annotationCorner })
|
|
4139
4362
|
] }),
|
|
4140
|
-
/* @__PURE__ */ (0,
|
|
4141
|
-
/* @__PURE__ */ (0,
|
|
4363
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "rvg-annotation-colors", children: ANNOTATION_COLORS.map((color, index) => /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("button", { type: "button", className: annotationColor === color ? "is-active" : "", "aria-label": labels.annotationColor(index + 1), title: labels.annotationColor(index + 1), style: { backgroundColor: color, "--annotation-color": color }, onClick: () => setAnnotationColor(color) }, color)) }),
|
|
4364
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
4142
4365
|
"textarea",
|
|
4143
4366
|
{
|
|
4144
4367
|
className: "rvg-annotation-content",
|
|
@@ -4150,16 +4373,16 @@ function TableInner({
|
|
|
4150
4373
|
onChange: (event) => setAnnotationContent(event.target.value)
|
|
4151
4374
|
}
|
|
4152
4375
|
),
|
|
4153
|
-
/* @__PURE__ */ (0,
|
|
4154
|
-
/* @__PURE__ */ (0,
|
|
4376
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "rvg-annotation-actions", children: [
|
|
4377
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("span", { children: [
|
|
4155
4378
|
annotationContent.length,
|
|
4156
4379
|
"/100"
|
|
4157
4380
|
] }),
|
|
4158
|
-
/* @__PURE__ */ (0,
|
|
4381
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("button", { type: "button", onClick: saveAnnotation, children: labels.confirm })
|
|
4159
4382
|
] })
|
|
4160
4383
|
] })
|
|
4161
4384
|
] }),
|
|
4162
|
-
hasAnnotation && /* @__PURE__ */ (0,
|
|
4385
|
+
hasAnnotation && /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("button", { type: "button", role: "menuitem", onClick: () => {
|
|
4163
4386
|
setCellAnnotations((current) => {
|
|
4164
4387
|
const next = new Map(current);
|
|
4165
4388
|
targetCells.forEach((cell) => next.delete(getKey(cell)));
|
|
@@ -4167,8 +4390,8 @@ function TableInner({
|
|
|
4167
4390
|
});
|
|
4168
4391
|
setContextMenu(null);
|
|
4169
4392
|
}, children: [
|
|
4170
|
-
/* @__PURE__ */ (0,
|
|
4171
|
-
/* @__PURE__ */ (0,
|
|
4393
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { className: "rvg-context-menu-icon", children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(ContextMenuIcon, { type: "remove-annotation" }) }),
|
|
4394
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { className: "rvg-context-menu-label", children: labels.removeAnnotation })
|
|
4172
4395
|
] })
|
|
4173
4396
|
] });
|
|
4174
4397
|
};
|
|
@@ -4240,7 +4463,7 @@ function TableInner({
|
|
|
4240
4463
|
if (column.renderCell && !(editing?.rowIndex === rowIndex && editing.columnIndex === columnIndex)) {
|
|
4241
4464
|
const row = rows[rowIndex];
|
|
4242
4465
|
const value = column.dataIndex === void 0 ? void 0 : row[column.dataIndex];
|
|
4243
|
-
return /* @__PURE__ */ (0,
|
|
4466
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
4244
4467
|
"div",
|
|
4245
4468
|
{
|
|
4246
4469
|
className: `rvg-cell-render${selectedRowKeySet.has(getRowKey(row, rowIndex)) || selectedColumnKeySet.has(column.key) ? " is-axis-selected" : ""}`,
|
|
@@ -4268,12 +4491,12 @@ function TableInner({
|
|
|
4268
4491
|
const headerTop = fixedHeader ? 0 : -currentScrollTop;
|
|
4269
4492
|
const leafTop = headerTop + headerLeafTop;
|
|
4270
4493
|
if (column.rowNumber) {
|
|
4271
|
-
return /* @__PURE__ */ (0,
|
|
4494
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
4272
4495
|
"div",
|
|
4273
4496
|
{
|
|
4274
4497
|
className: `rvg-header-title${isDropTarget ? " is-drop-target" : ""}`,
|
|
4275
4498
|
style: { left, top: headerTop, width: metrics[columnIndex].width, height: headerHeight, justifyContent: "center", padding: 0, textAlign: "center" },
|
|
4276
|
-
children: /* @__PURE__ */ (0,
|
|
4499
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { children: column.title })
|
|
4277
4500
|
},
|
|
4278
4501
|
column.key
|
|
4279
4502
|
);
|
|
@@ -4282,12 +4505,12 @@ function TableInner({
|
|
|
4282
4505
|
if (rowSelectionMode === "single" || column.rowSelectionIndicator === "arrow" || column.rowSelectionIndicator === "none") return null;
|
|
4283
4506
|
const allSelected = rows.length > 0 && selectedRowKeySet.size === rows.length;
|
|
4284
4507
|
const indeterminate = selectedRowKeySet.size > 0 && !allSelected;
|
|
4285
|
-
return /* @__PURE__ */ (0,
|
|
4508
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
4286
4509
|
"div",
|
|
4287
4510
|
{
|
|
4288
4511
|
className: "rvg-header-selection-icon",
|
|
4289
4512
|
style: { left, top: headerTop, width: metrics[columnIndex].width, height: headerHeight },
|
|
4290
|
-
children: /* @__PURE__ */ (0,
|
|
4513
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(SelectionIcon, { checked: allSelected, indeterminate })
|
|
4291
4514
|
},
|
|
4292
4515
|
column.key
|
|
4293
4516
|
);
|
|
@@ -4296,7 +4519,7 @@ function TableInner({
|
|
|
4296
4519
|
const visibleActions = getVisibleHeaderActions(column, metrics[columnIndex].width, columnDraggable, measureHeaderTitleWidth(columnIndex), headerActionSlotWidth);
|
|
4297
4520
|
const actionWidth = (Number(visibleActions.drag) + Number(visibleActions.filter) + Number(visibleActions.sort)) * headerActionSlotWidth;
|
|
4298
4521
|
const isHeaderHovered = hoveredHeaderColumnIndex === columnIndex;
|
|
4299
|
-
return /* @__PURE__ */ (0,
|
|
4522
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
4300
4523
|
"div",
|
|
4301
4524
|
{
|
|
4302
4525
|
className: `rvg-header-title is-custom${isHeaderHovered ? " is-header-hovered" : ""}${isAxisSelected ? " is-axis-selected" : ""}${isDropTarget ? " is-drop-target" : ""}`,
|
|
@@ -4311,7 +4534,7 @@ function TableInner({
|
|
|
4311
4534
|
justifyContent: column.align === "right" ? "flex-end" : column.align === "center" ? "center" : "flex-start",
|
|
4312
4535
|
textAlign: column.align === "right" ? "right" : column.align === "center" ? "center" : "left"
|
|
4313
4536
|
},
|
|
4314
|
-
children: /* @__PURE__ */ (0,
|
|
4537
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
4315
4538
|
"span",
|
|
4316
4539
|
{
|
|
4317
4540
|
style: { width: "100%" },
|
|
@@ -4345,7 +4568,7 @@ function TableInner({
|
|
|
4345
4568
|
const actionWidth = visibleActions ? (Number(visibleActions.drag) + Number(visibleActions.filter) + Number(visibleActions.sort)) * headerActionSlotWidth : columnDraggable && !cell.leaf ? headerActionSlotWidth : 0;
|
|
4346
4569
|
const isDropTarget = Boolean(columnDropTarget && cell.endIndex >= columnDropTarget.startIndex && cell.startIndex <= columnDropTarget.endIndex);
|
|
4347
4570
|
const isAxisSelected = cell.leaf && selectedColumnKeySet.has(column.key);
|
|
4348
|
-
return /* @__PURE__ */ (0,
|
|
4571
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
|
|
4349
4572
|
"div",
|
|
4350
4573
|
{
|
|
4351
4574
|
className: `rvg-header-title rvg-header-group${column.renderHeader ? " is-custom" : ""}${cell.leaf ? " is-leaf" : ""}${isAxisSelected ? " is-axis-selected" : ""}${cell.endIndex === columns.length - 1 ? " is-frame-right" : ""}${isDropTarget ? " is-drop-target" : ""}`,
|
|
@@ -4364,7 +4587,7 @@ function TableInner({
|
|
|
4364
4587
|
textAlign: column.align === "right" ? "right" : column.align === "center" ? "center" : "left"
|
|
4365
4588
|
},
|
|
4366
4589
|
children: [
|
|
4367
|
-
/* @__PURE__ */ (0,
|
|
4590
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
4368
4591
|
"span",
|
|
4369
4592
|
{
|
|
4370
4593
|
ref: (node) => {
|
|
@@ -4378,7 +4601,7 @@ function TableInner({
|
|
|
4378
4601
|
children: column.renderHeader ? column.renderHeader(column) : column.title
|
|
4379
4602
|
}
|
|
4380
4603
|
),
|
|
4381
|
-
!cell.leaf && columnDraggable && /* @__PURE__ */ (0,
|
|
4604
|
+
!cell.leaf && columnDraggable && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
4382
4605
|
HeaderDragIcon,
|
|
4383
4606
|
{
|
|
4384
4607
|
className: `rvg-header-icon rvg-header-drag-icon${hoveredHeaderAction?.columnIndex === cell.startIndex && hoveredHeaderAction.action === "drag" ? " is-hovered" : ""}`,
|
|
@@ -4445,7 +4668,7 @@ function TableInner({
|
|
|
4445
4668
|
"--rvg-corner-hover-height-extension": "4px"
|
|
4446
4669
|
} : null
|
|
4447
4670
|
} : void 0;
|
|
4448
|
-
(0,
|
|
4671
|
+
(0, import_react8.useLayoutEffect)(() => {
|
|
4449
4672
|
syncSelectionEdgeTarget(scrollPosition.left, scrollPosition.top);
|
|
4450
4673
|
}, [scrollPosition.left, scrollPosition.top, syncSelectionEdgeTarget]);
|
|
4451
4674
|
const handleContextMenu = (event) => {
|
|
@@ -4480,7 +4703,7 @@ function TableInner({
|
|
|
4480
4703
|
if (override?.render !== void 0 || override?.childrens !== void 0) {
|
|
4481
4704
|
return renderContextMenuSubmenu(key, context, override?.label ?? label, override, icon, disabled, danger);
|
|
4482
4705
|
}
|
|
4483
|
-
return /* @__PURE__ */ (0,
|
|
4706
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
|
|
4484
4707
|
"button",
|
|
4485
4708
|
{
|
|
4486
4709
|
type: "button",
|
|
@@ -4494,9 +4717,9 @@ function TableInner({
|
|
|
4494
4717
|
setContextMenu(null);
|
|
4495
4718
|
},
|
|
4496
4719
|
children: [
|
|
4497
|
-
icon && /* @__PURE__ */ (0,
|
|
4498
|
-
/* @__PURE__ */ (0,
|
|
4499
|
-
override?.shortcut && /* @__PURE__ */ (0,
|
|
4720
|
+
icon && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { className: "rvg-context-menu-icon", children: icon }),
|
|
4721
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { className: "rvg-context-menu-label", children: override?.label ?? label }),
|
|
4722
|
+
override?.shortcut && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { className: "rvg-context-menu-shortcut", children: override.shortcut })
|
|
4500
4723
|
]
|
|
4501
4724
|
},
|
|
4502
4725
|
key
|
|
@@ -4515,20 +4738,20 @@ function TableInner({
|
|
|
4515
4738
|
}
|
|
4516
4739
|
const node = renderCustomContextMenuItem(child, context);
|
|
4517
4740
|
if (!node) return null;
|
|
4518
|
-
const wrapped = /* @__PURE__ */ (0,
|
|
4519
|
-
separatorPending && /* @__PURE__ */ (0,
|
|
4741
|
+
const wrapped = /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_react8.Fragment, { children: [
|
|
4742
|
+
separatorPending && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "rvg-context-separator" }),
|
|
4520
4743
|
node
|
|
4521
4744
|
] }, child.key);
|
|
4522
4745
|
separatorPending = false;
|
|
4523
4746
|
return wrapped;
|
|
4524
4747
|
});
|
|
4525
|
-
return /* @__PURE__ */ (0,
|
|
4526
|
-
/* @__PURE__ */ (0,
|
|
4527
|
-
icon && /* @__PURE__ */ (0,
|
|
4528
|
-
/* @__PURE__ */ (0,
|
|
4529
|
-
/* @__PURE__ */ (0,
|
|
4748
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "rvg-context-submenu", children: [
|
|
4749
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("button", { type: "button", role: "menuitem", className: danger ? "rvg-context-danger" : void 0, disabled, "aria-haspopup": "menu", children: [
|
|
4750
|
+
icon && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { className: "rvg-context-menu-icon", children: icon }),
|
|
4751
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { className: "rvg-context-menu-label", children: label }),
|
|
4752
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(SubmenuArrowIcon, {})
|
|
4530
4753
|
] }),
|
|
4531
|
-
/* @__PURE__ */ (0,
|
|
4754
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "rvg-context-submenu-panel", role: "menu", children: content })
|
|
4532
4755
|
] }, key);
|
|
4533
4756
|
};
|
|
4534
4757
|
const renderConfiguredContextMenu = (items, context, renderBuiltin) => {
|
|
@@ -4545,10 +4768,10 @@ function TableInner({
|
|
|
4545
4768
|
const node = renderBuiltin(key, override) ?? (override ? renderCustomContextMenuItem(override, context) : null);
|
|
4546
4769
|
if (!node) return;
|
|
4547
4770
|
if (separatorPending) {
|
|
4548
|
-
nodes.push(/* @__PURE__ */ (0,
|
|
4771
|
+
nodes.push(/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "rvg-context-separator" }, `separator:${index}`));
|
|
4549
4772
|
separatorPending = false;
|
|
4550
4773
|
}
|
|
4551
|
-
nodes.push(/* @__PURE__ */ (0,
|
|
4774
|
+
nodes.push(/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_react8.Fragment, { children: node }, typeof item === "string" ? `${item}:${index}` : item.key));
|
|
4552
4775
|
});
|
|
4553
4776
|
return nodes;
|
|
4554
4777
|
};
|
|
@@ -4558,8 +4781,8 @@ function TableInner({
|
|
|
4558
4781
|
const hasSummaryValue = summaryValues.has(column.key);
|
|
4559
4782
|
const summaryContent = hasSummaryValue ? summaryValues.get(column.key) : summaryEmptyValue;
|
|
4560
4783
|
const showSummarySkeleton = Boolean(column.summary) && summaryPending;
|
|
4561
|
-
const content = columnIndex === 0 ? language === "zh-CN" ? "\u5408\u8BA1" : "Total" : showSummarySkeleton ? /* @__PURE__ */ (0,
|
|
4562
|
-
return /* @__PURE__ */ (0,
|
|
4784
|
+
const content = columnIndex === 0 ? language === "zh-CN" ? "\u5408\u8BA1" : "Total" : showSummarySkeleton ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { className: "rvg-summary-skeleton" }) : summaryContent;
|
|
4785
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
4563
4786
|
"div",
|
|
4564
4787
|
{
|
|
4565
4788
|
className: `rvg-summary-cell${isUtility ? " is-utility" : ""}${column.summary ? " is-summary" : ""}${summaryVerticalBordered ? "" : " is-borderless"}`,
|
|
@@ -4573,7 +4796,7 @@ function TableInner({
|
|
|
4573
4796
|
`summary:${column.key}`
|
|
4574
4797
|
);
|
|
4575
4798
|
};
|
|
4576
|
-
(0,
|
|
4799
|
+
(0, import_react8.useImperativeHandle)(ref, () => {
|
|
4577
4800
|
const resolveDataCell = (target) => {
|
|
4578
4801
|
const cell = resolveSelectionTarget(target);
|
|
4579
4802
|
if (!cell) return null;
|
|
@@ -4661,9 +4884,9 @@ function TableInner({
|
|
|
4661
4884
|
const draggingSelectedColumn = Boolean(
|
|
4662
4885
|
columnDragPreview && selectedColumnKeySet.has(columns[columnDragPreview.sourceIndex]?.key)
|
|
4663
4886
|
);
|
|
4664
|
-
return /* @__PURE__ */ (0,
|
|
4665
|
-
/* @__PURE__ */ (0,
|
|
4666
|
-
/* @__PURE__ */ (0,
|
|
4887
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { ref: rootRef, className: `rvg-root${!hasVerticalBorders ? " is-vertical-borderless" : ""}${horizontalBorderless ? " is-horizontal-borderless" : ""}${frameBorderless ? " is-frame-borderless" : ""}${hasStripedRows ? " is-striped" : ""}${insertBusy ? " is-inserting" : ""}${deleteBusy ? " is-deleting" : ""}${draggingSelectedColumn ? " is-dragging-selected-column" : ""} ${loading && !hasCompletedLoadRef.current && !hasCustomLoading ? "is-initial-loading" : ""} ${className}`, style: rootStyle, children: [
|
|
4888
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { ref: scrollerRef, className: `rvg-scroller${contextMenu ? " is-context-menu-open" : ""}`, style: { bottom: scrollerBottom }, onScroll: handleScroll, onCopy: handleCopy, onContextMenu: handleContextMenu, tabIndex: 0, role: "grid", "aria-label": ariaLabel, "aria-rowcount": rows.length, "aria-colcount": columns.length, onKeyDown: handleKeyDown, children: [
|
|
4889
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
4667
4890
|
"canvas",
|
|
4668
4891
|
{
|
|
4669
4892
|
ref: canvasRef,
|
|
@@ -4901,48 +5124,48 @@ function TableInner({
|
|
|
4901
5124
|
onContextMenu: handleContextMenu
|
|
4902
5125
|
}
|
|
4903
5126
|
),
|
|
4904
|
-
/* @__PURE__ */ (0,
|
|
4905
|
-
/* @__PURE__ */ (0,
|
|
5127
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "rvg-text-layer", style: { width: viewport.width, height: renderHeight, marginTop: -renderHeight }, onContextMenu: handleContextMenu, children: [
|
|
5128
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "rvg-text-scroll-clip", style: { left: fixedWidth, right: rightFixedWidth }, children: /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
|
|
4906
5129
|
"div",
|
|
4907
5130
|
{
|
|
4908
5131
|
ref: scrollingTextRef,
|
|
4909
5132
|
className: "rvg-text-scroll-content",
|
|
4910
5133
|
style: { left: -fixedWidth, width: contentWidth, transform: `translateX(${-currentScroll.left}px)` },
|
|
4911
5134
|
children: [
|
|
4912
|
-
columns.map((column, columnIndex) => column.fixed || columnIndex >= utilityColumnCount && headerDepth > 1 ? null : columnIndex >= domRange.columnStart && columnIndex < domRange.columnEnd ? /* @__PURE__ */ (0,
|
|
5135
|
+
columns.map((column, columnIndex) => column.fixed || columnIndex >= utilityColumnCount && headerDepth > 1 ? null : columnIndex >= domRange.columnStart && columnIndex < domRange.columnEnd ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { children: renderHeaderTitle(columnIndex, getScrollableColumnLeft(columnIndex)) }, column.key) : null),
|
|
4913
5136
|
headerCells.map((cell) => {
|
|
4914
5137
|
if (columns[cell.startIndex]?.fixed) return null;
|
|
4915
5138
|
if (cell.endIndex < domRange.columnStart || cell.startIndex >= domRange.columnEnd) return null;
|
|
4916
5139
|
return renderGroupedHeaderCell(cell);
|
|
4917
5140
|
}),
|
|
4918
|
-
/* @__PURE__ */ (0,
|
|
5141
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "rvg-body-text-clip", style: { top: fixedHeader ? bodyTop : 0, bottom: 0 }, children: Array.from({ length: domRange.rowEnd - domRange.rowStart }, (_, offset) => domRange.rowStart + offset).flatMap((rowIndex) => columns.map((column, columnIndex) => {
|
|
4919
5142
|
if (column.fixed || columnIndex < domRange.columnStart || columnIndex >= domRange.columnEnd) return null;
|
|
4920
5143
|
return renderCellText(rowIndex, columnIndex, getScrollableColumnLeft(columnIndex));
|
|
4921
5144
|
})) })
|
|
4922
5145
|
]
|
|
4923
5146
|
}
|
|
4924
5147
|
) }),
|
|
4925
|
-
/* @__PURE__ */ (0,
|
|
5148
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "rvg-body-text-clip", style: { top: fixedHeader ? bodyTop : 0, bottom: 0 }, children: Array.from({ length: domRange.rowEnd - domRange.rowStart }, (_, offset) => domRange.rowStart + offset).flatMap((rowIndex) => columns.map((column, columnIndex) => {
|
|
4926
5149
|
if (!column.fixed) return null;
|
|
4927
5150
|
const left = column.fixed === "left" ? leftFixedOffsets.get(columnIndex) ?? 0 : viewport.width - (rightFixedOffsets.get(columnIndex) ?? 0) - metrics[columnIndex].width;
|
|
4928
5151
|
return renderCellText(rowIndex, columnIndex, left);
|
|
4929
5152
|
})) }),
|
|
4930
5153
|
columns.map((column, columnIndex) => column.fixed && (columnIndex < utilityColumnCount || headerDepth === 1) ? renderHeaderTitle(columnIndex, column.fixed === "right" ? viewport.width - (rightFixedOffsets.get(columnIndex) ?? 0) - metrics[columnIndex].width : column.fixed === "left" ? leftFixedOffsets.get(columnIndex) ?? 0 : getScrollableColumnLeft(columnIndex)) : null),
|
|
4931
5154
|
headerCells.map((cell) => columns[cell.startIndex]?.fixed ? renderGroupedHeaderCell(cell) : null),
|
|
4932
|
-
fixedWidth > 0 && currentScroll.left > 0 && /* @__PURE__ */ (0,
|
|
4933
|
-
rightFixedWidth > 0 && currentScroll.left < contentWidth - viewport.width && /* @__PURE__ */ (0,
|
|
4934
|
-
hasVerticalBorders && fixedWidth > 0 && /* @__PURE__ */ (0,
|
|
4935
|
-
hasVerticalBorders && rightFixedWidth > 0 && /* @__PURE__ */ (0,
|
|
5155
|
+
fixedWidth > 0 && currentScroll.left > 0 && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "rvg-text-fixed-shadow is-left", style: { left: fixedWidth } }),
|
|
5156
|
+
rightFixedWidth > 0 && currentScroll.left < contentWidth - viewport.width && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "rvg-text-fixed-shadow is-right", style: { right: rightFixedWidth } }),
|
|
5157
|
+
hasVerticalBorders && fixedWidth > 0 && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "rvg-text-fixed-border is-left", style: { left: fixedWidth - 1 } }),
|
|
5158
|
+
hasVerticalBorders && rightFixedWidth > 0 && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "rvg-text-fixed-border is-right", style: { right: rightFixedWidth } })
|
|
4936
5159
|
] }),
|
|
4937
|
-
/* @__PURE__ */ (0,
|
|
5160
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "rvg-spacer", style: { width: contentWidth, height: contentHeight + bodyTop, marginTop: -renderHeight } })
|
|
4938
5161
|
] }),
|
|
4939
|
-
hasSummaryRow && /* @__PURE__ */ (0,
|
|
5162
|
+
hasSummaryRow && /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
|
|
4940
5163
|
"div",
|
|
4941
5164
|
{
|
|
4942
5165
|
className: `rvg-summary-row is-${summaryPosition}${hasVerticalBorders ? "" : " is-vertical-borderless"}`,
|
|
4943
5166
|
style: { height: rowHeight, top: summaryPosition === "top" ? fixedHeader ? headerHeight : headerHeight - currentScroll.top : void 0 },
|
|
4944
5167
|
children: [
|
|
4945
|
-
/* @__PURE__ */ (0,
|
|
5168
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "rvg-summary-scroll-clip", style: { left: fixedWidth, right: rightFixedWidth }, children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
4946
5169
|
"div",
|
|
4947
5170
|
{
|
|
4948
5171
|
className: "rvg-summary-scroll-content",
|
|
@@ -4950,41 +5173,41 @@ function TableInner({
|
|
|
4950
5173
|
children: columns.map((column, columnIndex) => column.fixed ? null : renderSummaryCell(columnIndex, getScrollableColumnLeft(columnIndex)))
|
|
4951
5174
|
}
|
|
4952
5175
|
) }),
|
|
4953
|
-
/* @__PURE__ */ (0,
|
|
5176
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "rvg-summary-fixed-layer", children: [
|
|
4954
5177
|
columns.map((column, columnIndex) => column.fixed === "left" ? renderSummaryCell(columnIndex, leftFixedOffsets.get(columnIndex) ?? 0) : null),
|
|
4955
5178
|
columns.map((column, columnIndex) => column.fixed === "right" ? renderSummaryCell(columnIndex, viewport.width - (rightFixedOffsets.get(columnIndex) ?? 0) - metrics[columnIndex].width) : null)
|
|
4956
5179
|
] }),
|
|
4957
|
-
fixedWidth > 0 && currentScroll.left > 0 && /* @__PURE__ */ (0,
|
|
4958
|
-
rightFixedWidth > 0 && currentScroll.left < contentWidth - viewport.width && /* @__PURE__ */ (0,
|
|
4959
|
-
summaryVerticalBordered && fixedWidth > 0 && /* @__PURE__ */ (0,
|
|
4960
|
-
summaryVerticalBordered && rightFixedWidth > 0 && /* @__PURE__ */ (0,
|
|
5180
|
+
fixedWidth > 0 && currentScroll.left > 0 && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "rvg-summary-fixed-shadow is-left", style: { left: fixedWidth } }),
|
|
5181
|
+
rightFixedWidth > 0 && currentScroll.left < contentWidth - viewport.width && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "rvg-summary-fixed-shadow is-right", style: { right: rightFixedWidth } }),
|
|
5182
|
+
summaryVerticalBordered && fixedWidth > 0 && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "rvg-summary-fixed-border is-left", style: { left: fixedWidth - 1 } }),
|
|
5183
|
+
summaryVerticalBordered && rightFixedWidth > 0 && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "rvg-summary-fixed-border is-right", style: { right: rightFixedWidth } })
|
|
4961
5184
|
]
|
|
4962
5185
|
}
|
|
4963
5186
|
),
|
|
4964
|
-
/* @__PURE__ */ (0,
|
|
4965
|
-
/* @__PURE__ */ (0,
|
|
5187
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { ref: headerIconsRef, className: "rvg-header-icons", style: { height: headerHeight, transform: `translateY(${fixedHeader ? 0 : -scrollRef.current.top}px)` }, children: [
|
|
5188
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "rvg-header-scroll-clip", style: { left: fixedWidth, right: rightFixedWidth }, children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
4966
5189
|
"div",
|
|
4967
5190
|
{
|
|
4968
5191
|
ref: scrollingHeaderIconsRef,
|
|
4969
5192
|
className: "rvg-header-icon-layer rvg-header-icon-layer-scroll",
|
|
4970
5193
|
style: { left: -fixedWidth, width: contentWidth, transform: `translateX(${-scrollRef.current.left}px)` },
|
|
4971
|
-
children: columns.map((column, index) => column.fixed ? null : /* @__PURE__ */ (0,
|
|
5194
|
+
children: columns.map((column, index) => column.fixed ? null : /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { children: renderHeaderIcons(index, getScrollableColumnLeft(index)) }, column.key))
|
|
4972
5195
|
}
|
|
4973
5196
|
) }),
|
|
4974
|
-
/* @__PURE__ */ (0,
|
|
4975
|
-
columns.map((column, index) => column.fixed === "left" ? /* @__PURE__ */ (0,
|
|
4976
|
-
columns.map((column, index) => column.fixed === "right" ? /* @__PURE__ */ (0,
|
|
5197
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "rvg-header-icon-layer", children: [
|
|
5198
|
+
columns.map((column, index) => column.fixed === "left" ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { children: renderHeaderIcons(index, leftFixedOffsets.get(index) ?? 0) }, column.key) : null),
|
|
5199
|
+
columns.map((column, index) => column.fixed === "right" ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { children: renderHeaderIcons(index, viewport.width - (rightFixedOffsets.get(index) ?? 0) - metrics[index].width) }, column.key) : null)
|
|
4977
5200
|
] })
|
|
4978
5201
|
] }),
|
|
4979
|
-
hasVerticalBorders && trailingColumnBorderLeft !== null && /* @__PURE__ */ (0,
|
|
5202
|
+
hasVerticalBorders && trailingColumnBorderLeft !== null && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
4980
5203
|
"div",
|
|
4981
5204
|
{
|
|
4982
5205
|
className: "rvg-trailing-column-border",
|
|
4983
5206
|
style: { left: trailingColumnBorderLeft, height: renderHeight }
|
|
4984
5207
|
}
|
|
4985
5208
|
),
|
|
4986
|
-
headerTooltip && /* @__PURE__ */ (0,
|
|
4987
|
-
hoveredCellTooltip && /* @__PURE__ */ (0,
|
|
5209
|
+
headerTooltip && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: `rvg-header-tooltip is-${headerTooltip.placement}`, role: "tooltip", style: { left: headerTooltip.left, top: headerTooltip.top }, children: headerTooltip.label }),
|
|
5210
|
+
hoveredCellTooltip && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
4988
5211
|
"div",
|
|
4989
5212
|
{
|
|
4990
5213
|
className: `rvg-cell-tooltip${hoveredCellTooltip.annotation ? " is-annotation" : ` is-${hoveredCellTooltip.placement ?? "right"}`}`,
|
|
@@ -5006,7 +5229,7 @@ function TableInner({
|
|
|
5006
5229
|
children: hoveredCellTooltip.label
|
|
5007
5230
|
}
|
|
5008
5231
|
),
|
|
5009
|
-
rangeHandlePosition && /* @__PURE__ */ (0,
|
|
5232
|
+
rangeHandlePosition && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
5010
5233
|
"div",
|
|
5011
5234
|
{
|
|
5012
5235
|
className: "rvg-range-handle",
|
|
@@ -5030,8 +5253,8 @@ function TableInner({
|
|
|
5030
5253
|
}
|
|
5031
5254
|
}
|
|
5032
5255
|
),
|
|
5033
|
-
selectionOutlineStyle && /* @__PURE__ */ (0,
|
|
5034
|
-
selectionEdgeIndicator && selection && /* @__PURE__ */ (0,
|
|
5256
|
+
selectionOutlineStyle && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { ref: selectionFocusRef, className: "rvg-selection-focus", style: selectionOutlineStyle, "aria-hidden": "true" }),
|
|
5257
|
+
selectionEdgeIndicator && selection && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
5035
5258
|
"button",
|
|
5036
5259
|
{
|
|
5037
5260
|
ref: selectionEdgeTargetRef,
|
|
@@ -5049,10 +5272,10 @@ function TableInner({
|
|
|
5049
5272
|
scrollerRef.current?.focus({ preventScroll: true });
|
|
5050
5273
|
revealCell(selection);
|
|
5051
5274
|
},
|
|
5052
|
-
children: /* @__PURE__ */ (0,
|
|
5275
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { className: "rvg-selection-edge-halo", "aria-hidden": "true", children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("svg", { viewBox: "0 0 100 100", preserveAspectRatio: "none", children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("path", { d: "M 0 100 L 0 0 L 100 0" }) }) })
|
|
5053
5276
|
}
|
|
5054
5277
|
),
|
|
5055
|
-
contextMenu && /* @__PURE__ */ (0,
|
|
5278
|
+
contextMenu && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { ref: contextMenuRef, className: "rvg-context-menu", role: "menu", style: { left: contextMenu.left, top: contextMenu.top }, children: contextMenu.type === "header" ? (() => {
|
|
5056
5279
|
const column = columns[contextMenu.columnIndex];
|
|
5057
5280
|
const headerContext = { column, columnIndex: contextMenu.columnIndex };
|
|
5058
5281
|
return renderConfiguredContextMenu(resolveContextMenuSection(customContextMenuConfig?.header, DEFAULT_HEADER_CONTEXT_MENU), headerContext, (item, override) => {
|
|
@@ -5063,12 +5286,12 @@ function TableInner({
|
|
|
5063
5286
|
} catch {
|
|
5064
5287
|
showToast("error", labels.copyError);
|
|
5065
5288
|
}
|
|
5066
|
-
}, override, { icon: /* @__PURE__ */ (0,
|
|
5289
|
+
}, override, { icon: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(ContextMenuIcon, { type: "copy" }) });
|
|
5067
5290
|
if (item === "select-column") {
|
|
5068
5291
|
if (!columnSelection) return null;
|
|
5069
5292
|
return renderContextMenuButton("header-select-column", headerContext, selectedColumnKeySet.has(column.key) ? labels.deselectColumn : labels.selectColumn, () => {
|
|
5070
5293
|
toggleColumnFromMenu(contextMenu.columnIndex);
|
|
5071
|
-
}, override, { icon: /* @__PURE__ */ (0,
|
|
5294
|
+
}, override, { icon: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(ContextMenuIcon, { type: "select-column" }) });
|
|
5072
5295
|
}
|
|
5073
5296
|
return null;
|
|
5074
5297
|
});
|
|
@@ -5089,7 +5312,7 @@ function TableInner({
|
|
|
5089
5312
|
} catch {
|
|
5090
5313
|
showToast("error", labels.copyError);
|
|
5091
5314
|
}
|
|
5092
|
-
}, override, { icon: /* @__PURE__ */ (0,
|
|
5315
|
+
}, override, { icon: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(ContextMenuIcon, { type: "copy" }) });
|
|
5093
5316
|
if (item === "annotation") return renderAnnotationControls(rangeCells);
|
|
5094
5317
|
if (item === "undo") {
|
|
5095
5318
|
const changedCells = rangeCells.flatMap((cell) => {
|
|
@@ -5116,7 +5339,7 @@ function TableInner({
|
|
|
5116
5339
|
});
|
|
5117
5340
|
onCellChange?.({ ...cell, row, previousValue, value });
|
|
5118
5341
|
});
|
|
5119
|
-
}, override, { disabled: !onCellChange, icon: /* @__PURE__ */ (0,
|
|
5342
|
+
}, override, { disabled: !onCellChange, icon: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(ContextMenuIcon, { type: "undo" }) });
|
|
5120
5343
|
}
|
|
5121
5344
|
if (item === "clear") {
|
|
5122
5345
|
const hasClearableCell = rangeCells.some((cell) => {
|
|
@@ -5133,7 +5356,7 @@ function TableInner({
|
|
|
5133
5356
|
markCellEdited(cell, row[column.dataIndex], "");
|
|
5134
5357
|
onCellChange?.({ ...cell, row, previousValue: row[column.dataIndex], value: "" });
|
|
5135
5358
|
});
|
|
5136
|
-
}, override, { disabled: !onCellChange, icon: /* @__PURE__ */ (0,
|
|
5359
|
+
}, override, { disabled: !onCellChange, icon: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(ContextMenuIcon, { type: "clear" }) });
|
|
5137
5360
|
}
|
|
5138
5361
|
return null;
|
|
5139
5362
|
});
|
|
@@ -5151,7 +5374,7 @@ function TableInner({
|
|
|
5151
5374
|
const affectedRows = selectedIndices.includes(cell.rowIndex) ? selectedIndices : [cell.rowIndex];
|
|
5152
5375
|
const cellContext = { ...cell, row, column, value: dataIndex === void 0 ? void 0 : row[dataIndex] };
|
|
5153
5376
|
return renderConfiguredContextMenu(resolveContextMenuSection(customContextMenuConfig?.cell, DEFAULT_CELL_CONTEXT_MENU), cellContext, (item, override) => {
|
|
5154
|
-
if (item === "edit") return renderContextMenuButton("cell-edit", cellContext, labels.edit, () => beginEdit(cell), override, { disabled: !isCellEditable(cell), icon: /* @__PURE__ */ (0,
|
|
5377
|
+
if (item === "edit") return renderContextMenuButton("cell-edit", cellContext, labels.edit, () => beginEdit(cell), override, { disabled: !isCellEditable(cell), icon: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(ContextMenuIcon, { type: "edit" }) });
|
|
5155
5378
|
if (item === "copy") return renderContextMenuButton("cell-copy", cellContext, labels.copyContent, async () => {
|
|
5156
5379
|
try {
|
|
5157
5380
|
await navigator.clipboard.writeText(getCellLabel(cell.rowIndex, cell.columnIndex));
|
|
@@ -5159,20 +5382,20 @@ function TableInner({
|
|
|
5159
5382
|
} catch {
|
|
5160
5383
|
showToast("error", labels.copyError);
|
|
5161
5384
|
}
|
|
5162
|
-
}, override, { icon: /* @__PURE__ */ (0,
|
|
5385
|
+
}, override, { icon: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(ContextMenuIcon, { type: "copy" }) });
|
|
5163
5386
|
if (item === "undo") return renderContextMenuButton("cell-undo", cellContext, labels.undoChange, () => {
|
|
5164
5387
|
if (dataIndex === void 0 || originalValue === void 0) return;
|
|
5165
5388
|
const previousValue = row[dataIndex];
|
|
5166
5389
|
const value = typeof previousValue === "number" && originalValue !== "" ? Number(originalValue) : originalValue;
|
|
5167
5390
|
setConfirmAction({ type: "undo", cell, row, dataIndex, previousValue, value });
|
|
5168
|
-
}, override, { disabled: !onCellChange || dataIndex === void 0 || originalValue === void 0, icon: /* @__PURE__ */ (0,
|
|
5391
|
+
}, override, { disabled: !onCellChange || dataIndex === void 0 || originalValue === void 0, icon: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(ContextMenuIcon, { type: "undo" }) });
|
|
5169
5392
|
if (item === "clear") {
|
|
5170
5393
|
if (dataIndex === void 0 || isEmptyCellValue(row[dataIndex])) return null;
|
|
5171
5394
|
return renderContextMenuButton("cell-clear", cellContext, labels.clearContent, () => {
|
|
5172
5395
|
if (dataIndex === void 0) return;
|
|
5173
5396
|
const previousValue = row[dataIndex];
|
|
5174
5397
|
setConfirmAction({ type: "clear", cell, row, dataIndex, previousValue });
|
|
5175
|
-
}, override, { disabled: !onCellChange || dataIndex === void 0, danger: true, icon: /* @__PURE__ */ (0,
|
|
5398
|
+
}, override, { disabled: !onCellChange || dataIndex === void 0, danger: true, icon: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(ContextMenuIcon, { type: "clear" }) });
|
|
5176
5399
|
}
|
|
5177
5400
|
if (item === "annotation") return renderAnnotationControls([cell]);
|
|
5178
5401
|
if (item === "select-row") {
|
|
@@ -5182,56 +5405,56 @@ function TableInner({
|
|
|
5182
5405
|
setSelection(null);
|
|
5183
5406
|
if (selectedRowKeySet.has(cell.rowKey)) setRowKeys(rowKeys.filter((key) => key !== cell.rowKey));
|
|
5184
5407
|
else setRowKeys(rowSelectionMode === "single" ? [cell.rowKey] : [...rowKeys, cell.rowKey]);
|
|
5185
|
-
}, override, { icon: /* @__PURE__ */ (0,
|
|
5408
|
+
}, override, { icon: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(ContextMenuIcon, { type: "select-row" }) });
|
|
5186
5409
|
}
|
|
5187
5410
|
if (item === "select-column") {
|
|
5188
5411
|
if (!columnSelection) return null;
|
|
5189
5412
|
return renderContextMenuButton("cell-select-column", cellContext, selectedColumnKeySet.has(cell.columnKey) ? labels.deselectColumn : labels.selectColumn, () => {
|
|
5190
5413
|
toggleColumnFromMenu(cell.columnIndex);
|
|
5191
|
-
}, override, { icon: /* @__PURE__ */ (0,
|
|
5414
|
+
}, override, { icon: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(ContextMenuIcon, { type: "select-column" }) });
|
|
5192
5415
|
}
|
|
5193
|
-
if (item === "insert-above") return /* @__PURE__ */ (0,
|
|
5194
|
-
/* @__PURE__ */ (0,
|
|
5416
|
+
if (item === "insert-above") return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "rvg-context-insert", children: [
|
|
5417
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("button", { type: "button", role: "menuitem", disabled: !onInsertRows, onClick: () => {
|
|
5195
5418
|
void insertRowsOptimistically(cell, "before", insertCounts.before);
|
|
5196
5419
|
}, children: [
|
|
5197
|
-
/* @__PURE__ */ (0,
|
|
5198
|
-
/* @__PURE__ */ (0,
|
|
5420
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { className: "rvg-context-menu-icon", children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(ContextMenuIcon, { type: "insert-above" }) }),
|
|
5421
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { className: "rvg-context-menu-label", children: labels.insertAbove })
|
|
5199
5422
|
] }),
|
|
5200
|
-
/* @__PURE__ */ (0,
|
|
5201
|
-
/* @__PURE__ */ (0,
|
|
5423
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("input", { "aria-label": labels.insertAboveCount, type: "number", min: 1, max: 5, step: 1, value: insertCounts.before, onChange: (event) => setInsertCounts((current) => ({ ...current, before: Math.max(1, Math.min(5, Math.floor(Number(event.target.value) || 1))) })) }),
|
|
5424
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { children: labels.rowUnit })
|
|
5202
5425
|
] });
|
|
5203
|
-
if (item === "insert-below") return /* @__PURE__ */ (0,
|
|
5204
|
-
/* @__PURE__ */ (0,
|
|
5426
|
+
if (item === "insert-below") return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "rvg-context-insert", children: [
|
|
5427
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("button", { type: "button", role: "menuitem", disabled: !onInsertRows, onClick: () => {
|
|
5205
5428
|
void insertRowsOptimistically(cell, "after", insertCounts.after);
|
|
5206
5429
|
}, children: [
|
|
5207
|
-
/* @__PURE__ */ (0,
|
|
5208
|
-
/* @__PURE__ */ (0,
|
|
5430
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { className: "rvg-context-menu-icon", children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(ContextMenuIcon, { type: "insert-below" }) }),
|
|
5431
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { className: "rvg-context-menu-label", children: labels.insertBelow })
|
|
5209
5432
|
] }),
|
|
5210
|
-
/* @__PURE__ */ (0,
|
|
5211
|
-
/* @__PURE__ */ (0,
|
|
5433
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("input", { "aria-label": labels.insertBelowCount, type: "number", min: 1, max: 5, step: 1, value: insertCounts.after, onChange: (event) => setInsertCounts((current) => ({ ...current, after: Math.max(1, Math.min(5, Math.floor(Number(event.target.value) || 1))) })) }),
|
|
5434
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { children: labels.rowUnit })
|
|
5212
5435
|
] });
|
|
5213
5436
|
if (item === "move-up") {
|
|
5214
5437
|
if (!rowDraggable) return null;
|
|
5215
|
-
return renderContextMenuButton("cell-move-up", cellContext, labels.moveUp, () => applyRowOrder(cell.rowIndex, cell.rowIndex - 1), override, { disabled: cell.rowIndex === 0, icon: /* @__PURE__ */ (0,
|
|
5438
|
+
return renderContextMenuButton("cell-move-up", cellContext, labels.moveUp, () => applyRowOrder(cell.rowIndex, cell.rowIndex - 1), override, { disabled: cell.rowIndex === 0, icon: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(ContextMenuIcon, { type: "move-up" }) });
|
|
5216
5439
|
}
|
|
5217
5440
|
if (item === "move-down") {
|
|
5218
5441
|
if (!rowDraggable) return null;
|
|
5219
|
-
return renderContextMenuButton("cell-move-down", cellContext, labels.moveDown, () => applyRowOrder(cell.rowIndex, cell.rowIndex + 1), override, { disabled: cell.rowIndex === rows.length - 1, icon: /* @__PURE__ */ (0,
|
|
5442
|
+
return renderContextMenuButton("cell-move-down", cellContext, labels.moveDown, () => applyRowOrder(cell.rowIndex, cell.rowIndex + 1), override, { disabled: cell.rowIndex === rows.length - 1, icon: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(ContextMenuIcon, { type: "move-down" }) });
|
|
5220
5443
|
}
|
|
5221
|
-
if (item === "delete-row") return renderContextMenuButton("cell-delete-row", cellContext, labels.deleteRow, () => setConfirmAction({ type: "delete-row", rows: affectedRows.map((rowIndex) => ({ rowIndex, row: rows[rowIndex] })) }), override, { disabled: !onDeleteRows, danger: true, icon: /* @__PURE__ */ (0,
|
|
5444
|
+
if (item === "delete-row") return renderContextMenuButton("cell-delete-row", cellContext, labels.deleteRow, () => setConfirmAction({ type: "delete-row", rows: affectedRows.map((rowIndex) => ({ rowIndex, row: rows[rowIndex] })) }), override, { disabled: !onDeleteRows, danger: true, icon: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(ContextMenuIcon, { type: "delete" }) });
|
|
5222
5445
|
return null;
|
|
5223
5446
|
});
|
|
5224
5447
|
})() }),
|
|
5225
|
-
confirmAction && /* @__PURE__ */ (0,
|
|
5448
|
+
confirmAction && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "rvg-confirm-backdrop", role: "presentation", onMouseDown: (event) => {
|
|
5226
5449
|
if (!confirmLoading && event.target === event.currentTarget) setConfirmAction(null);
|
|
5227
|
-
}, children: /* @__PURE__ */ (0,
|
|
5228
|
-
/* @__PURE__ */ (0,
|
|
5229
|
-
/* @__PURE__ */ (0,
|
|
5230
|
-
/* @__PURE__ */ (0,
|
|
5231
|
-
/* @__PURE__ */ (0,
|
|
5232
|
-
/* @__PURE__ */ (0,
|
|
5450
|
+
}, children: /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "rvg-confirm", role: "alertdialog", "aria-modal": "true", "aria-labelledby": "rvg-delete-title", children: [
|
|
5451
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("strong", { id: "rvg-delete-title", children: confirmAction.type === "undo" ? labels.undoConfirmTitle : confirmAction.type === "clear" ? labels.clearConfirmTitle : labels.deleteConfirmTitle }),
|
|
5452
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("p", { children: confirmAction.type === "undo" ? labels.undoConfirmDescription : confirmAction.type === "clear" ? labels.clearConfirmDescription : labels.deleteConfirmDescription(confirmAction.rows.length) }),
|
|
5453
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "rvg-confirm-actions", children: [
|
|
5454
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("button", { type: "button", disabled: confirmLoading, onClick: () => setConfirmAction(null), children: labels.cancel }),
|
|
5455
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("button", { type: "button", className: "rvg-confirm-danger", disabled: confirmLoading, autoFocus: true, onClick: () => {
|
|
5233
5456
|
if (confirmLoading) return;
|
|
5234
|
-
(0,
|
|
5457
|
+
(0, import_react_dom2.flushSync)(() => setConfirmLoading(true));
|
|
5235
5458
|
window.requestAnimationFrame(async () => {
|
|
5236
5459
|
try {
|
|
5237
5460
|
if (confirmAction.type === "undo") {
|
|
@@ -5282,13 +5505,13 @@ function TableInner({
|
|
|
5282
5505
|
}
|
|
5283
5506
|
});
|
|
5284
5507
|
}, children: [
|
|
5285
|
-
confirmLoading && /* @__PURE__ */ (0,
|
|
5508
|
+
confirmLoading && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(LoadingSpinnerIcon, {}),
|
|
5286
5509
|
confirmAction.type === "undo" ? labels.undoChange : confirmAction.type === "clear" ? labels.clear : labels.delete
|
|
5287
5510
|
] })
|
|
5288
5511
|
] })
|
|
5289
5512
|
] }) }),
|
|
5290
|
-
toast && /* @__PURE__ */ (0,
|
|
5291
|
-
/* @__PURE__ */ (0,
|
|
5513
|
+
toast && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: `rvg-toast is-${toast.type}`, role: "status", children: toast.message }),
|
|
5514
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
5292
5515
|
"div",
|
|
5293
5516
|
{
|
|
5294
5517
|
ref: verticalScrollbarRef,
|
|
@@ -5299,10 +5522,10 @@ function TableInner({
|
|
|
5299
5522
|
onPointerMove: handleVerticalScrollbarPointerMove,
|
|
5300
5523
|
onPointerUp: handleVerticalScrollbarPointerUp,
|
|
5301
5524
|
onPointerCancel: handleVerticalScrollbarPointerUp,
|
|
5302
|
-
children: /* @__PURE__ */ (0,
|
|
5525
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { ref: verticalScrollbarThumbRef, className: "rvg-vertical-scrollbar-thumb" })
|
|
5303
5526
|
}
|
|
5304
5527
|
),
|
|
5305
|
-
/* @__PURE__ */ (0,
|
|
5528
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
5306
5529
|
"div",
|
|
5307
5530
|
{
|
|
5308
5531
|
ref: horizontalScrollbarRef,
|
|
@@ -5313,11 +5536,11 @@ function TableInner({
|
|
|
5313
5536
|
onPointerMove: handleHorizontalScrollbarPointerMove,
|
|
5314
5537
|
onPointerUp: handleHorizontalScrollbarPointerUp,
|
|
5315
5538
|
onPointerCancel: handleHorizontalScrollbarPointerUp,
|
|
5316
|
-
children: /* @__PURE__ */ (0,
|
|
5539
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { ref: horizontalScrollbarThumbRef, className: "rvg-horizontal-scrollbar-thumb" })
|
|
5317
5540
|
}
|
|
5318
5541
|
),
|
|
5319
|
-
/* @__PURE__ */ (0,
|
|
5320
|
-
columnDragPreview && /* @__PURE__ */ (0,
|
|
5542
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { ref: dragGuideRef, className: "rvg-column-guide" }),
|
|
5543
|
+
columnDragPreview && /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
|
|
5321
5544
|
"div",
|
|
5322
5545
|
{
|
|
5323
5546
|
"aria-hidden": "true",
|
|
@@ -5333,7 +5556,7 @@ function TableInner({
|
|
|
5333
5556
|
backgroundSize: `${viewport.width}px ${renderHeight}px`
|
|
5334
5557
|
},
|
|
5335
5558
|
children: [
|
|
5336
|
-
/* @__PURE__ */ (0,
|
|
5559
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
|
|
5337
5560
|
"div",
|
|
5338
5561
|
{
|
|
5339
5562
|
className: `rvg-column-drag-preview-header${selectedColumnKeySet.has(columns[columnDragPreview.sourceIndex]?.key) ? " is-axis-selected" : ""}`,
|
|
@@ -5346,7 +5569,7 @@ function TableInner({
|
|
|
5346
5569
|
),
|
|
5347
5570
|
rows.slice(domRange.rowStart, domRange.rowEnd).map((_row, visibleRowOffset) => {
|
|
5348
5571
|
const rowIndex = domRange.rowStart + visibleRowOffset;
|
|
5349
|
-
return /* @__PURE__ */ (0,
|
|
5572
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
5350
5573
|
"div",
|
|
5351
5574
|
{
|
|
5352
5575
|
className: `rvg-column-drag-preview-cell${selectedColumnKeySet.has(columns[columnDragPreview.sourceIndex]?.key) ? " is-axis-selected" : ""}${hasStripedRows && rowIndex % 2 === 1 ? " is-striped" : ""}`,
|
|
@@ -5359,16 +5582,16 @@ function TableInner({
|
|
|
5359
5582
|
]
|
|
5360
5583
|
}
|
|
5361
5584
|
),
|
|
5362
|
-
resizeGuideX !== null && /* @__PURE__ */ (0,
|
|
5585
|
+
resizeGuideX !== null && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
5363
5586
|
"div",
|
|
5364
5587
|
{
|
|
5365
5588
|
className: "rvg-column-guide is-resizing",
|
|
5366
5589
|
style: { display: "block", top: resizeGuideTop, transform: `translateX(${Math.round(resizeGuideX)}px)` }
|
|
5367
5590
|
}
|
|
5368
5591
|
),
|
|
5369
|
-
/* @__PURE__ */ (0,
|
|
5370
|
-
filterEditor && /* @__PURE__ */ (0,
|
|
5371
|
-
/* @__PURE__ */ (0,
|
|
5592
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { ref: rowDragGuideRef, className: "rvg-row-guide" }),
|
|
5593
|
+
filterEditor && /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { ref: filterRef, className: "rvg-filter", style: { left: filterEditor.left, top: filterEditor.top }, children: [
|
|
5594
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
5372
5595
|
"input",
|
|
5373
5596
|
{
|
|
5374
5597
|
autoFocus: true,
|
|
@@ -5392,15 +5615,15 @@ function TableInner({
|
|
|
5392
5615
|
}
|
|
5393
5616
|
}
|
|
5394
5617
|
),
|
|
5395
|
-
/* @__PURE__ */ (0,
|
|
5396
|
-
/* @__PURE__ */ (0,
|
|
5618
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "rvg-filter-actions", children: [
|
|
5619
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("button", { type: "button", onClick: () => {
|
|
5397
5620
|
const key = columns[filterEditor.columnIndex].key;
|
|
5398
5621
|
const next = { ...filterValues };
|
|
5399
5622
|
delete next[key];
|
|
5400
5623
|
setFilterValues(next);
|
|
5401
5624
|
setFilterEditor(null);
|
|
5402
5625
|
}, children: labels.reset }),
|
|
5403
|
-
/* @__PURE__ */ (0,
|
|
5626
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("button", { type: "button", className: "rvg-filter-confirm", onClick: () => {
|
|
5404
5627
|
const key = columns[filterEditor.columnIndex].key;
|
|
5405
5628
|
const next = { ...filterValues };
|
|
5406
5629
|
if (filterEditor.draft) next[key] = filterEditor.draft;
|
|
@@ -5411,31 +5634,31 @@ function TableInner({
|
|
|
5411
5634
|
] })
|
|
5412
5635
|
] }),
|
|
5413
5636
|
renderEditor(),
|
|
5414
|
-
rows.length === 0 && !loading && /* @__PURE__ */ (0,
|
|
5415
|
-
loading && hasCustomLoading && /* @__PURE__ */ (0,
|
|
5416
|
-
loading && !hasCustomLoading && !hasCompletedLoadRef.current && /* @__PURE__ */ (0,
|
|
5417
|
-
Array.from({ length: Math.ceil((renderHeight - headerHeight) / rowHeight) }, (_, rowIndex) => /* @__PURE__ */ (0,
|
|
5637
|
+
rows.length === 0 && !loading && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "rvg-empty", style: { top: bodyTop }, children: emptyContent ?? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(DefaultEmptyState, { label: labels.empty }) }),
|
|
5638
|
+
loading && hasCustomLoading && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "rvg-custom-loading", "aria-label": labels.refreshing, children: loadingContent }),
|
|
5639
|
+
loading && !hasCustomLoading && !hasCompletedLoadRef.current && /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "rvg-initial-loading", style: { top: headerHeight }, "aria-label": labels.initialLoading, children: [
|
|
5640
|
+
Array.from({ length: Math.ceil((renderHeight - headerHeight) / rowHeight) }, (_, rowIndex) => /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "rvg-loading-row", style: { height: rowHeight }, children: columns.map((column, columnIndex) => {
|
|
5418
5641
|
const left = getDisplayedColumnLeft(columnIndex);
|
|
5419
5642
|
const columnWidth = metrics[columnIndex].width;
|
|
5420
5643
|
if (left + columnWidth <= 0 || left >= viewport.width) return null;
|
|
5421
5644
|
const isUtility = column.rowSelection || column.rowDragHandle || column.rowNumber;
|
|
5422
|
-
return /* @__PURE__ */ (0,
|
|
5645
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
5423
5646
|
"span",
|
|
5424
5647
|
{
|
|
5425
5648
|
className: column.rowDragHandle ? "is-utility is-drag" : column.rowSelection ? "is-utility is-selection" : void 0,
|
|
5426
5649
|
style: { left, width: columnWidth, zIndex: column.fixed ? 1 : 0, background: column.fixed ? "#fff" : void 0, justifyContent: column.align === "right" ? "flex-end" : column.align === "center" || isUtility ? "center" : "flex-start" },
|
|
5427
|
-
children: /* @__PURE__ */ (0,
|
|
5650
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("i", { style: { width: isUtility ? 14 : `${38 + (rowIndex * 17 + columnIndex * 13) % 43}%`, animationDelay: `${(rowIndex * columns.length + columnIndex) * 24}ms` } })
|
|
5428
5651
|
},
|
|
5429
5652
|
column.key
|
|
5430
5653
|
);
|
|
5431
5654
|
}) }, rowIndex)),
|
|
5432
|
-
fixedWidth > 0 && currentScroll.left > 0 && /* @__PURE__ */ (0,
|
|
5433
|
-
rightFixedWidth > 0 && currentScroll.left < contentWidth - viewport.width && /* @__PURE__ */ (0,
|
|
5655
|
+
fixedWidth > 0 && currentScroll.left > 0 && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "rvg-loading-fixed-shadow is-left", style: { left: fixedWidth } }),
|
|
5656
|
+
rightFixedWidth > 0 && currentScroll.left < contentWidth - viewport.width && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "rvg-loading-fixed-shadow is-right", style: { right: rightFixedWidth } })
|
|
5434
5657
|
] }),
|
|
5435
|
-
loading && !hasCustomLoading && hasCompletedLoadRef.current && /* @__PURE__ */ (0,
|
|
5658
|
+
loading && !hasCustomLoading && hasCompletedLoadRef.current && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "rvg-refresh-loading", "aria-label": labels.refreshing, children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(LoadingSpinnerIcon, {}) })
|
|
5436
5659
|
] });
|
|
5437
5660
|
}
|
|
5438
|
-
var Table = (0,
|
|
5661
|
+
var Table = (0, import_react8.forwardRef)(TableInner);
|
|
5439
5662
|
// Annotate the CommonJS export names for ESM import in node:
|
|
5440
5663
|
0 && (module.exports = {
|
|
5441
5664
|
Table,
|