@sia.soul/sia-react-ui 0.1.43 → 0.1.44
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/{chunk-ORLXJLLW.js → chunk-KXPNW4E6.js} +3 -3
- package/dist/{chunk-3Q3S6CDZ.js → chunk-NYJSSPIX.js} +16 -3
- package/dist/{chunk-LWVZEUGJ.js → chunk-QIXU7N4X.js} +1 -1
- package/dist/core.cjs +18 -5
- package/dist/core.js +2 -2
- package/dist/index.cjs +105 -39
- package/dist/index.js +90 -37
- package/dist/select-date-range.cjs +16 -3
- package/dist/select-date-range.js +2 -2
- package/package.json +1 -1
|
@@ -5,7 +5,7 @@ import {
|
|
|
5
5
|
Popover,
|
|
6
6
|
Tooltip,
|
|
7
7
|
useOverlayLifecycle
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-NYJSSPIX.js";
|
|
9
9
|
import {
|
|
10
10
|
Dropdown,
|
|
11
11
|
Icon
|
|
@@ -1815,13 +1815,13 @@ function TypographyContent({
|
|
|
1815
1815
|
useEffect5(() => () => clearTimeout(timer.current), []);
|
|
1816
1816
|
useLayoutEffect3(() => {
|
|
1817
1817
|
const element = contentRef.current;
|
|
1818
|
-
if (!element || !ellipsis || editing || expanded) return;
|
|
1818
|
+
if (!element || !ellipsis || !expandable || editing || expanded) return;
|
|
1819
1819
|
const measure = () => setOverflow(element.scrollHeight > element.clientHeight + 1 || element.scrollWidth > element.clientWidth + 1);
|
|
1820
1820
|
measure();
|
|
1821
1821
|
const observer = new ResizeObserver(measure);
|
|
1822
1822
|
observer.observe(element);
|
|
1823
1823
|
return () => observer.disconnect();
|
|
1824
|
-
}, [content, ellipsis, rows, editing, expanded]);
|
|
1824
|
+
}, [content, ellipsis, rows, expandable, editing, expanded]);
|
|
1825
1825
|
async function copy() {
|
|
1826
1826
|
try {
|
|
1827
1827
|
const text = typeof copyable === "object" ? copyable.text ?? contentRef.current?.textContent ?? "" : contentRef.current?.textContent ?? "";
|
|
@@ -1294,7 +1294,17 @@ function FloatingScrollbarProvider({ disabled = false, targetRef }) {
|
|
|
1294
1294
|
};
|
|
1295
1295
|
const scanTargets = () => {
|
|
1296
1296
|
scanFrame = 0;
|
|
1297
|
-
const
|
|
1297
|
+
const managedSelector = ".sia-table__viewport, [data-sia-native-scrollbar], .sia-scrollbar-track, .sia-floating-scrollbar-layer";
|
|
1298
|
+
const discovered = [];
|
|
1299
|
+
if (!targetRef) {
|
|
1300
|
+
const walker = document.createTreeWalker(document.body, NodeFilter.SHOW_ELEMENT, {
|
|
1301
|
+
acceptNode: (node) => node.matches(managedSelector) ? NodeFilter.FILTER_REJECT : NodeFilter.FILTER_ACCEPT
|
|
1302
|
+
});
|
|
1303
|
+
for (let node = walker.nextNode(); node; node = walker.nextNode()) {
|
|
1304
|
+
if (node instanceof HTMLElement) discovered.push(node);
|
|
1305
|
+
}
|
|
1306
|
+
}
|
|
1307
|
+
const candidates = (targetRef ? [targetRef.current] : [document.scrollingElement, ...discovered]).filter((target) => target instanceof HTMLElement);
|
|
1298
1308
|
const nextTargets = /* @__PURE__ */ new Set();
|
|
1299
1309
|
candidates.forEach((target) => {
|
|
1300
1310
|
if (canScroll(target, "horizontal") || canScroll(target, "vertical")) {
|
|
@@ -1312,9 +1322,12 @@ function FloatingScrollbarProvider({ disabled = false, targetRef }) {
|
|
|
1312
1322
|
scanFrame = window.requestAnimationFrame(scanTargets);
|
|
1313
1323
|
};
|
|
1314
1324
|
const mutationObserver = new MutationObserver((mutations) => {
|
|
1315
|
-
if (mutations.some((mutation) =>
|
|
1325
|
+
if (mutations.some((mutation) => {
|
|
1326
|
+
const target = mutation.target instanceof Element ? mutation.target : mutation.target.parentElement;
|
|
1327
|
+
return target && !layer.contains(target) && !target.closest(".sia-table__viewport, [data-sia-native-scrollbar], .sia-scrollbar-track");
|
|
1328
|
+
})) scheduleScan();
|
|
1316
1329
|
});
|
|
1317
|
-
mutationObserver.observe(document.documentElement, { subtree: true, childList: true, attributes: true });
|
|
1330
|
+
mutationObserver.observe(document.documentElement, { subtree: true, childList: true, attributes: true, attributeFilter: ["class", "style", "hidden"] });
|
|
1318
1331
|
window.addEventListener("resize", scheduleScan);
|
|
1319
1332
|
window.addEventListener("scroll", scheduleUpdateAll, true);
|
|
1320
1333
|
scheduleScan();
|
package/dist/core.cjs
CHANGED
|
@@ -3457,7 +3457,17 @@ function FloatingScrollbarProvider({ disabled = false, targetRef }) {
|
|
|
3457
3457
|
};
|
|
3458
3458
|
const scanTargets = () => {
|
|
3459
3459
|
scanFrame = 0;
|
|
3460
|
-
const
|
|
3460
|
+
const managedSelector = ".sia-table__viewport, [data-sia-native-scrollbar], .sia-scrollbar-track, .sia-floating-scrollbar-layer";
|
|
3461
|
+
const discovered = [];
|
|
3462
|
+
if (!targetRef) {
|
|
3463
|
+
const walker = document.createTreeWalker(document.body, NodeFilter.SHOW_ELEMENT, {
|
|
3464
|
+
acceptNode: (node) => node.matches(managedSelector) ? NodeFilter.FILTER_REJECT : NodeFilter.FILTER_ACCEPT
|
|
3465
|
+
});
|
|
3466
|
+
for (let node = walker.nextNode(); node; node = walker.nextNode()) {
|
|
3467
|
+
if (node instanceof HTMLElement) discovered.push(node);
|
|
3468
|
+
}
|
|
3469
|
+
}
|
|
3470
|
+
const candidates = (targetRef ? [targetRef.current] : [document.scrollingElement, ...discovered]).filter((target) => target instanceof HTMLElement);
|
|
3461
3471
|
const nextTargets = /* @__PURE__ */ new Set();
|
|
3462
3472
|
candidates.forEach((target) => {
|
|
3463
3473
|
if (canScroll(target, "horizontal") || canScroll(target, "vertical")) {
|
|
@@ -3475,9 +3485,12 @@ function FloatingScrollbarProvider({ disabled = false, targetRef }) {
|
|
|
3475
3485
|
scanFrame = window.requestAnimationFrame(scanTargets);
|
|
3476
3486
|
};
|
|
3477
3487
|
const mutationObserver = new MutationObserver((mutations) => {
|
|
3478
|
-
if (mutations.some((mutation) =>
|
|
3488
|
+
if (mutations.some((mutation) => {
|
|
3489
|
+
const target = mutation.target instanceof Element ? mutation.target : mutation.target.parentElement;
|
|
3490
|
+
return target && !layer.contains(target) && !target.closest(".sia-table__viewport, [data-sia-native-scrollbar], .sia-scrollbar-track");
|
|
3491
|
+
})) scheduleScan();
|
|
3479
3492
|
});
|
|
3480
|
-
mutationObserver.observe(document.documentElement, { subtree: true, childList: true, attributes: true });
|
|
3493
|
+
mutationObserver.observe(document.documentElement, { subtree: true, childList: true, attributes: true, attributeFilter: ["class", "style", "hidden"] });
|
|
3481
3494
|
window.addEventListener("resize", scheduleScan);
|
|
3482
3495
|
window.addEventListener("scroll", scheduleUpdateAll, true);
|
|
3483
3496
|
scheduleScan();
|
|
@@ -4947,13 +4960,13 @@ function TypographyContent({
|
|
|
4947
4960
|
(0, import_react26.useEffect)(() => () => clearTimeout(timer.current), []);
|
|
4948
4961
|
(0, import_react26.useLayoutEffect)(() => {
|
|
4949
4962
|
const element = contentRef.current;
|
|
4950
|
-
if (!element || !ellipsis || editing || expanded) return;
|
|
4963
|
+
if (!element || !ellipsis || !expandable || editing || expanded) return;
|
|
4951
4964
|
const measure = () => setOverflow(element.scrollHeight > element.clientHeight + 1 || element.scrollWidth > element.clientWidth + 1);
|
|
4952
4965
|
measure();
|
|
4953
4966
|
const observer = new ResizeObserver(measure);
|
|
4954
4967
|
observer.observe(element);
|
|
4955
4968
|
return () => observer.disconnect();
|
|
4956
|
-
}, [content, ellipsis, rows, editing, expanded]);
|
|
4969
|
+
}, [content, ellipsis, rows, expandable, editing, expanded]);
|
|
4957
4970
|
async function copy() {
|
|
4958
4971
|
try {
|
|
4959
4972
|
const text = typeof copyable === "object" ? copyable.text ?? contentRef.current?.textContent ?? "" : contentRef.current?.textContent ?? "";
|
package/dist/core.js
CHANGED
|
@@ -10,12 +10,12 @@ import {
|
|
|
10
10
|
Typography,
|
|
11
11
|
Upload,
|
|
12
12
|
message
|
|
13
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-KXPNW4E6.js";
|
|
14
14
|
import "./chunk-SMCYEPBL.js";
|
|
15
15
|
import {
|
|
16
16
|
Modal,
|
|
17
17
|
Select
|
|
18
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-NYJSSPIX.js";
|
|
19
19
|
import {
|
|
20
20
|
Icon,
|
|
21
21
|
Input,
|
package/dist/index.cjs
CHANGED
|
@@ -3348,7 +3348,17 @@ function FloatingScrollbarProvider({ disabled = false, targetRef }) {
|
|
|
3348
3348
|
};
|
|
3349
3349
|
const scanTargets = () => {
|
|
3350
3350
|
scanFrame = 0;
|
|
3351
|
-
const
|
|
3351
|
+
const managedSelector = ".sia-table__viewport, [data-sia-native-scrollbar], .sia-scrollbar-track, .sia-floating-scrollbar-layer";
|
|
3352
|
+
const discovered = [];
|
|
3353
|
+
if (!targetRef) {
|
|
3354
|
+
const walker = document.createTreeWalker(document.body, NodeFilter.SHOW_ELEMENT, {
|
|
3355
|
+
acceptNode: (node) => node.matches(managedSelector) ? NodeFilter.FILTER_REJECT : NodeFilter.FILTER_ACCEPT
|
|
3356
|
+
});
|
|
3357
|
+
for (let node = walker.nextNode(); node; node = walker.nextNode()) {
|
|
3358
|
+
if (node instanceof HTMLElement) discovered.push(node);
|
|
3359
|
+
}
|
|
3360
|
+
}
|
|
3361
|
+
const candidates = (targetRef ? [targetRef.current] : [document.scrollingElement, ...discovered]).filter((target) => target instanceof HTMLElement);
|
|
3352
3362
|
const nextTargets = /* @__PURE__ */ new Set();
|
|
3353
3363
|
candidates.forEach((target) => {
|
|
3354
3364
|
if (canScroll(target, "horizontal") || canScroll(target, "vertical")) {
|
|
@@ -3366,9 +3376,12 @@ function FloatingScrollbarProvider({ disabled = false, targetRef }) {
|
|
|
3366
3376
|
scanFrame = window.requestAnimationFrame(scanTargets);
|
|
3367
3377
|
};
|
|
3368
3378
|
const mutationObserver = new MutationObserver((mutations) => {
|
|
3369
|
-
if (mutations.some((mutation) =>
|
|
3379
|
+
if (mutations.some((mutation) => {
|
|
3380
|
+
const target = mutation.target instanceof Element ? mutation.target : mutation.target.parentElement;
|
|
3381
|
+
return target && !layer.contains(target) && !target.closest(".sia-table__viewport, [data-sia-native-scrollbar], .sia-scrollbar-track");
|
|
3382
|
+
})) scheduleScan();
|
|
3370
3383
|
});
|
|
3371
|
-
mutationObserver.observe(document.documentElement, { subtree: true, childList: true, attributes: true });
|
|
3384
|
+
mutationObserver.observe(document.documentElement, { subtree: true, childList: true, attributes: true, attributeFilter: ["class", "style", "hidden"] });
|
|
3372
3385
|
window.addEventListener("resize", scheduleScan);
|
|
3373
3386
|
window.addEventListener("scroll", scheduleUpdateAll, true);
|
|
3374
3387
|
scheduleScan();
|
|
@@ -11848,6 +11861,22 @@ function Treemap({
|
|
|
11848
11861
|
// src/components/Table/TableCellContent.tsx
|
|
11849
11862
|
var import_react49 = require("react");
|
|
11850
11863
|
var import_jsx_runtime49 = require("react/jsx-runtime");
|
|
11864
|
+
var pendingLayouts = /* @__PURE__ */ new Map();
|
|
11865
|
+
var layoutFrame;
|
|
11866
|
+
function scheduleLayout(element, task) {
|
|
11867
|
+
pendingLayouts.set(element, task);
|
|
11868
|
+
if (layoutFrame !== void 0) return;
|
|
11869
|
+
layoutFrame = requestAnimationFrame(() => {
|
|
11870
|
+
layoutFrame = void 0;
|
|
11871
|
+
const tasks = [...pendingLayouts.values()];
|
|
11872
|
+
pendingLayouts.clear();
|
|
11873
|
+
const layouts = tasks.flatMap((task2) => task2.layouts());
|
|
11874
|
+
layouts.forEach((layout) => {
|
|
11875
|
+
if (!layout.hasAttribute("data-table-inline-layout")) layout.setAttribute("data-table-inline-layout", "");
|
|
11876
|
+
});
|
|
11877
|
+
tasks.forEach((task2) => task2.measure());
|
|
11878
|
+
});
|
|
11879
|
+
}
|
|
11851
11880
|
function TableCellContent({ children, ellipsis, title }) {
|
|
11852
11881
|
const ref = (0, import_react49.useRef)(null);
|
|
11853
11882
|
const [overflowing, setOverflowing] = (0, import_react49.useState)(false);
|
|
@@ -11855,29 +11884,33 @@ function TableCellContent({ children, ellipsis, title }) {
|
|
|
11855
11884
|
(0, import_react49.useLayoutEffect)(() => {
|
|
11856
11885
|
const element = ref.current;
|
|
11857
11886
|
if (!element || !ellipsis || !customContent) return;
|
|
11858
|
-
const
|
|
11859
|
-
const normalizeLayouts = (parent) => {
|
|
11887
|
+
const normalizeLayouts = (parent, layouts) => {
|
|
11860
11888
|
for (const child of parent.children) {
|
|
11861
11889
|
if (!(child instanceof HTMLElement)) continue;
|
|
11862
11890
|
const component = [...child.classList].some((name) => name.startsWith("sia-") && !name.startsWith("sia-space") && name !== "sia-flex");
|
|
11863
11891
|
if (component || child.matches("button, input, textarea, select, [contenteditable]")) continue;
|
|
11864
11892
|
const display = getComputedStyle(child).display;
|
|
11865
11893
|
if (["flex", "inline-flex", "grid", "inline-grid"].includes(display)) {
|
|
11866
|
-
child.setAttribute("data-table-inline-layout", "");
|
|
11867
11894
|
layouts.push(child);
|
|
11868
11895
|
}
|
|
11869
|
-
normalizeLayouts(child);
|
|
11896
|
+
normalizeLayouts(child, layouts);
|
|
11870
11897
|
}
|
|
11871
11898
|
};
|
|
11872
|
-
normalizeLayouts(element);
|
|
11873
11899
|
const update = () => setOverflowing(element.scrollWidth > element.clientWidth + 1 || element.scrollHeight > element.clientHeight + 1);
|
|
11874
|
-
|
|
11900
|
+
scheduleLayout(element, {
|
|
11901
|
+
layouts: () => {
|
|
11902
|
+
const layouts = [];
|
|
11903
|
+
normalizeLayouts(element, layouts);
|
|
11904
|
+
return layouts;
|
|
11905
|
+
},
|
|
11906
|
+
measure: update
|
|
11907
|
+
});
|
|
11875
11908
|
const observer = new ResizeObserver(update);
|
|
11876
11909
|
observer.observe(element);
|
|
11877
11910
|
for (const child of element.children) observer.observe(child);
|
|
11878
11911
|
return () => {
|
|
11879
11912
|
observer.disconnect();
|
|
11880
|
-
|
|
11913
|
+
pendingLayouts.delete(element);
|
|
11881
11914
|
};
|
|
11882
11915
|
}, [children, ellipsis, customContent]);
|
|
11883
11916
|
return /* @__PURE__ */ (0, import_jsx_runtime49.jsx)("div", { ref, className: "sia-table__cell-content", "data-custom-content": customContent || void 0, "data-content-overflow": ellipsis && customContent && overflowing || void 0, children: title ? /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(Tooltip, { title, className: "sia-table__cell-tooltip", children: /* @__PURE__ */ (0, import_jsx_runtime49.jsx)("span", { children }) }) : children });
|
|
@@ -14420,10 +14453,9 @@ function buildHeaderRows(columns) {
|
|
|
14420
14453
|
function resolveInitialState(plugin) {
|
|
14421
14454
|
return typeof plugin.initialState === "function" ? plugin.initialState() : plugin.initialState;
|
|
14422
14455
|
}
|
|
14423
|
-
function
|
|
14456
|
+
function prepareTableCellMeasurement(cell) {
|
|
14424
14457
|
const content = cell.querySelector(":scope > .sia-table__cell-content");
|
|
14425
14458
|
const target = cell.classList.contains("sia-table__header-cell") ? cell.querySelector(".sia-table__resizable-header > span:first-child, .sia-table__header-label-content") : content;
|
|
14426
|
-
let contentWidth = cell.scrollWidth;
|
|
14427
14459
|
if (target) {
|
|
14428
14460
|
const measurement = target.cloneNode(true);
|
|
14429
14461
|
Object.assign(measurement.style, {
|
|
@@ -14441,11 +14473,8 @@ function measureTableCellContentWidth(cell) {
|
|
|
14441
14473
|
});
|
|
14442
14474
|
measurement.setAttribute("aria-hidden", "true");
|
|
14443
14475
|
cell.appendChild(measurement);
|
|
14444
|
-
|
|
14445
|
-
measurement.remove();
|
|
14476
|
+
return measurement;
|
|
14446
14477
|
}
|
|
14447
|
-
const style = window.getComputedStyle(cell);
|
|
14448
|
-
return contentWidth + (Number.parseFloat(style.paddingLeft) || 0) + (Number.parseFloat(style.paddingRight) || 0) + (Number.parseFloat(style.borderLeftWidth) || 0) + (Number.parseFloat(style.borderRightWidth) || 0);
|
|
14449
14478
|
}
|
|
14450
14479
|
function getTableHorizontalMetrics(viewport, table) {
|
|
14451
14480
|
const contentWidth = Math.max(viewport.clientWidth, table?.getBoundingClientRect().width ?? viewport.clientWidth);
|
|
@@ -14666,18 +14695,22 @@ function TableInner(props, ref) {
|
|
|
14666
14695
|
if (element.scrollLeft > maxLeft) element.scrollLeft = maxLeft > 1 ? maxLeft : 0;
|
|
14667
14696
|
const logicalScrollLeft = Math.min(element.scrollLeft, maxLeft);
|
|
14668
14697
|
const maxTop = Math.max(0, element.scrollHeight - element.clientHeight);
|
|
14669
|
-
|
|
14670
|
-
|
|
14671
|
-
|
|
14672
|
-
|
|
14698
|
+
const setFlag = (key, value) => {
|
|
14699
|
+
const next = String(value);
|
|
14700
|
+
if (root.dataset[key] !== next) root.dataset[key] = next;
|
|
14701
|
+
};
|
|
14702
|
+
setFlag("overflowX", maxLeft > 1);
|
|
14703
|
+
setFlag("overflowY", maxTop > 1);
|
|
14704
|
+
const horizontalTrackElement = root.querySelector(".sia-table__scrollbar--horizontal");
|
|
14705
|
+
const verticalTrackElement = root.querySelector(".sia-table__scrollbar--vertical");
|
|
14706
|
+
const horizontalTrack = horizontalTrackElement?.clientWidth ?? 0;
|
|
14707
|
+
const verticalTrack = verticalTrackElement?.clientHeight ?? 0;
|
|
14673
14708
|
const horizontalThumb = maxLeft > 1 ? Math.min(horizontalTrack, Math.max(36, horizontalTrack * element.clientWidth / horizontalContentWidth)) : 0;
|
|
14674
14709
|
const verticalThumb = maxTop > 1 ? Math.min(verticalTrack, Math.max(36, verticalTrack * element.clientHeight / element.scrollHeight)) : 0;
|
|
14675
14710
|
const horizontalPosition = maxLeft > 0 ? logicalScrollLeft / maxLeft * Math.max(0, horizontalTrack - horizontalThumb) : 0;
|
|
14676
14711
|
const verticalPosition = maxTop > 0 ? element.scrollTop / maxTop * Math.max(0, verticalTrack - verticalThumb) : 0;
|
|
14677
|
-
|
|
14678
|
-
|
|
14679
|
-
root.dataset.overflowX = String(maxLeft > 1);
|
|
14680
|
-
root.dataset.overflowY = String(maxTop > 1);
|
|
14712
|
+
setFlag("scrolledLeft", logicalScrollLeft > 1);
|
|
14713
|
+
setFlag("scrolledRight", maxLeft > 1 && logicalScrollLeft < maxLeft - 1);
|
|
14681
14714
|
const viewportRect = element.getBoundingClientRect();
|
|
14682
14715
|
const leftEdge = root.querySelector(".sia-table__header-cell.sia-table__cell--fixed-left-edge");
|
|
14683
14716
|
const rightEdge = root.querySelector(".sia-table__header-cell.sia-table__cell--fixed-right-edge");
|
|
@@ -14689,10 +14722,10 @@ function TableInner(props, ref) {
|
|
|
14689
14722
|
const rightEdgeRect = rightEdge.getBoundingClientRect();
|
|
14690
14723
|
root.style.setProperty("--sia-table-fixed-right-width", `${Math.max(0, viewportRect.right - rightEdgeRect.left)}px`);
|
|
14691
14724
|
}
|
|
14692
|
-
|
|
14693
|
-
|
|
14694
|
-
|
|
14695
|
-
|
|
14725
|
+
horizontalTrackElement?.style.setProperty("--sia-table-scrollbar-x-size", `${horizontalThumb}px`);
|
|
14726
|
+
horizontalTrackElement?.style.setProperty("--sia-table-scrollbar-x-position", `${horizontalPosition}px`);
|
|
14727
|
+
verticalTrackElement?.style.setProperty("--sia-table-scrollbar-y-size", `${verticalThumb}px`);
|
|
14728
|
+
verticalTrackElement?.style.setProperty("--sia-table-scrollbar-y-position", `${verticalPosition}px`);
|
|
14696
14729
|
}, []);
|
|
14697
14730
|
(0, import_react51.useEffect)(() => {
|
|
14698
14731
|
const element = scrollRef.current;
|
|
@@ -14713,19 +14746,33 @@ function TableInner(props, ref) {
|
|
|
14713
14746
|
const orderedColumns = (0, import_react51.useMemo)(() => sortTableColumnsByFixed(pipeline.columns), [pipeline.columns]);
|
|
14714
14747
|
const leafColumns = (0, import_react51.useMemo)(() => flattenTableColumns(orderedColumns), [orderedColumns]);
|
|
14715
14748
|
const headerRows = (0, import_react51.useMemo)(() => buildHeaderRows(orderedColumns), [orderedColumns]);
|
|
14749
|
+
const measuredCells = (0, import_react51.useRef)(/* @__PURE__ */ new WeakSet());
|
|
14750
|
+
const autoWidthSignature = leafColumns.map((column) => `${column.key}:${column.autoWidth}:${resizedWidths[column.key] ?? ""}`).join("|");
|
|
14751
|
+
(0, import_react51.useEffect)(() => {
|
|
14752
|
+
measuredCells.current = /* @__PURE__ */ new WeakSet();
|
|
14753
|
+
setAutoColumnWidths({});
|
|
14754
|
+
}, [dataSource, baseColumns, size, autoWidthSignature]);
|
|
14716
14755
|
(0, import_react51.useEffect)(() => {
|
|
14717
14756
|
const autoWidthColumns = leafColumns.filter((column) => column.autoWidth && resizedWidths[column.key] === void 0);
|
|
14718
14757
|
const root = rootRef.current;
|
|
14719
14758
|
if (!root || autoWidthColumns.length === 0) return;
|
|
14720
14759
|
const frame = window.requestAnimationFrame(() => {
|
|
14721
14760
|
const measurements = {};
|
|
14722
|
-
const
|
|
14761
|
+
const columnsByKey = new Map(autoWidthColumns.map((column) => [column.key, column]));
|
|
14762
|
+
const cells = [...root.querySelectorAll("th[data-column-key], td[data-column-key]")].filter((cell) => columnsByKey.has(cell.dataset.columnKey) && !measuredCells.current.has(cell));
|
|
14763
|
+
if (cells.length === 0) return;
|
|
14764
|
+
const prepared = cells.map((cell) => ({ cell, node: prepareTableCellMeasurement(cell) }));
|
|
14765
|
+
for (const { cell, node } of prepared) {
|
|
14766
|
+
const key = cell.dataset.columnKey;
|
|
14767
|
+
const style2 = window.getComputedStyle(cell);
|
|
14768
|
+
const padding = (Number.parseFloat(style2.paddingLeft) || 0) + (Number.parseFloat(style2.paddingRight) || 0) + (Number.parseFloat(style2.borderLeftWidth) || 0) + (Number.parseFloat(style2.borderRightWidth) || 0);
|
|
14769
|
+
measurements[key] = Math.max(measurements[key] ?? 0, node ? Math.max(node.scrollWidth, node.getBoundingClientRect().width) + padding : cell.scrollWidth);
|
|
14770
|
+
measuredCells.current.add(cell);
|
|
14771
|
+
}
|
|
14772
|
+
prepared.forEach(({ node }) => node?.remove());
|
|
14723
14773
|
for (const column of autoWidthColumns) {
|
|
14724
|
-
|
|
14725
|
-
|
|
14726
|
-
if (cell.dataset.columnKey !== column.key) continue;
|
|
14727
|
-
width = Math.max(width, measureTableCellContentWidth(cell));
|
|
14728
|
-
}
|
|
14774
|
+
if (measurements[column.key] === void 0) continue;
|
|
14775
|
+
const width = Math.max(column.minWidth ?? 56, autoColumnWidths[column.key] ?? 0, measurements[column.key]);
|
|
14729
14776
|
measurements[column.key] = Math.ceil(Math.min(column.maxWidth ?? Number.POSITIVE_INFINITY, width));
|
|
14730
14777
|
}
|
|
14731
14778
|
setAutoColumnWidths((previous) => {
|
|
@@ -14781,6 +14828,21 @@ function TableInner(props, ref) {
|
|
|
14781
14828
|
const renderedRows = pipeline.rows.slice(startIndex, endIndex);
|
|
14782
14829
|
const topSpacer = shouldVirtualize ? startIndex * rowHeight : 0;
|
|
14783
14830
|
const bottomSpacer = shouldVirtualize ? Math.max(0, (pipeline.rows.length - endIndex) * rowHeight) : 0;
|
|
14831
|
+
const rowElements = (0, import_react51.useMemo)(() => /* @__PURE__ */ new Map(), [
|
|
14832
|
+
dataSource,
|
|
14833
|
+
baseColumns,
|
|
14834
|
+
sortedPlugins,
|
|
14835
|
+
pluginStates,
|
|
14836
|
+
autoColumnWidths,
|
|
14837
|
+
viewportWidth,
|
|
14838
|
+
rowHeight,
|
|
14839
|
+
striped,
|
|
14840
|
+
rowClassName,
|
|
14841
|
+
getRowKey,
|
|
14842
|
+
onRowClick,
|
|
14843
|
+
onRowDoubleClick,
|
|
14844
|
+
onCellContextMenu
|
|
14845
|
+
]);
|
|
14784
14846
|
const toolbarStart = sortedPlugins.map((plugin) => {
|
|
14785
14847
|
const content = plugin.renderToolbarStart?.(getContext(plugin));
|
|
14786
14848
|
return content ? /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(import_react51.Fragment, { children: content }, `toolbar-start-${plugin.id}`) : null;
|
|
@@ -14807,9 +14869,9 @@ function TableInner(props, ref) {
|
|
|
14807
14869
|
};
|
|
14808
14870
|
const handleScroll = (0, import_react51.useCallback)((event) => {
|
|
14809
14871
|
const element = event.currentTarget;
|
|
14810
|
-
if (shouldVirtualize) setScrollTop(element.scrollTop);
|
|
14872
|
+
if (shouldVirtualize) setScrollTop((previous) => Math.floor(previous / rowHeight) === Math.floor(element.scrollTop / rowHeight) ? previous : element.scrollTop);
|
|
14811
14873
|
updateScrollMetrics();
|
|
14812
|
-
}, [shouldVirtualize, updateScrollMetrics]);
|
|
14874
|
+
}, [shouldVirtualize, rowHeight, updateScrollMetrics]);
|
|
14813
14875
|
const handleScrollbarPointerDown = (0, import_react51.useCallback)((axis, event, track = event.currentTarget) => {
|
|
14814
14876
|
const element = scrollRef.current;
|
|
14815
14877
|
const thumb = track.firstElementChild;
|
|
@@ -15030,10 +15092,12 @@ function TableInner(props, ref) {
|
|
|
15030
15092
|
/* @__PURE__ */ (0, import_jsx_runtime51.jsxs)("tbody", { children: [
|
|
15031
15093
|
topSpacer > 0 ? /* @__PURE__ */ (0, import_jsx_runtime51.jsx)("tr", { "aria-hidden": "true", children: /* @__PURE__ */ (0, import_jsx_runtime51.jsx)("td", { colSpan: leafColumns.length, style: { height: topSpacer, padding: 0, border: 0 } }) }) : null,
|
|
15032
15094
|
renderedRows.map((row, offset) => {
|
|
15095
|
+
const cached = rowElements.get(row.key);
|
|
15096
|
+
if (cached) return cached;
|
|
15033
15097
|
const rowIndex = startIndex + offset;
|
|
15034
15098
|
const pluginClasses = sortedPlugins.map((plugin) => plugin.getRowClassName?.(row, getContext(plugin))).filter(Boolean).join(" ");
|
|
15035
15099
|
const customClass = typeof rowClassName === "function" ? rowClassName(row.record, row.sourceIndex) : rowClassName ?? "";
|
|
15036
|
-
|
|
15100
|
+
const element = /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(
|
|
15037
15101
|
TableBodyRow,
|
|
15038
15102
|
{
|
|
15039
15103
|
row,
|
|
@@ -15079,6 +15143,8 @@ function TableInner(props, ref) {
|
|
|
15079
15143
|
},
|
|
15080
15144
|
row.key
|
|
15081
15145
|
);
|
|
15146
|
+
rowElements.set(row.key, element);
|
|
15147
|
+
return element;
|
|
15082
15148
|
}),
|
|
15083
15149
|
bottomSpacer > 0 ? /* @__PURE__ */ (0, import_jsx_runtime51.jsx)("tr", { "aria-hidden": "true", children: /* @__PURE__ */ (0, import_jsx_runtime51.jsx)("td", { colSpan: leafColumns.length, style: { height: bottomSpacer, padding: 0, border: 0 } }) }) : null
|
|
15084
15150
|
] }),
|
|
@@ -15264,13 +15330,13 @@ function TypographyContent({
|
|
|
15264
15330
|
(0, import_react53.useEffect)(() => () => clearTimeout(timer.current), []);
|
|
15265
15331
|
(0, import_react53.useLayoutEffect)(() => {
|
|
15266
15332
|
const element = contentRef.current;
|
|
15267
|
-
if (!element || !ellipsis || editing || expanded) return;
|
|
15333
|
+
if (!element || !ellipsis || !expandable || editing || expanded) return;
|
|
15268
15334
|
const measure = () => setOverflow(element.scrollHeight > element.clientHeight + 1 || element.scrollWidth > element.clientWidth + 1);
|
|
15269
15335
|
measure();
|
|
15270
15336
|
const observer = new ResizeObserver(measure);
|
|
15271
15337
|
observer.observe(element);
|
|
15272
15338
|
return () => observer.disconnect();
|
|
15273
|
-
}, [content, ellipsis, rows, editing, expanded]);
|
|
15339
|
+
}, [content, ellipsis, rows, expandable, editing, expanded]);
|
|
15274
15340
|
async function copy() {
|
|
15275
15341
|
try {
|
|
15276
15342
|
const text = typeof copyable === "object" ? copyable.text ?? contentRef.current?.textContent ?? "" : contentRef.current?.textContent ?? "";
|
package/dist/index.js
CHANGED
|
@@ -80,7 +80,7 @@ import {
|
|
|
80
80
|
Watermark,
|
|
81
81
|
message,
|
|
82
82
|
notification
|
|
83
|
-
} from "./chunk-
|
|
83
|
+
} from "./chunk-KXPNW4E6.js";
|
|
84
84
|
import {
|
|
85
85
|
TextArea
|
|
86
86
|
} from "./chunk-SMCYEPBL.js";
|
|
@@ -95,7 +95,7 @@ import {
|
|
|
95
95
|
DatePicker,
|
|
96
96
|
SelectDateRange,
|
|
97
97
|
TimePanel
|
|
98
|
-
} from "./chunk-
|
|
98
|
+
} from "./chunk-QIXU7N4X.js";
|
|
99
99
|
import {
|
|
100
100
|
Checkbox,
|
|
101
101
|
FloatingScrollbarProvider,
|
|
@@ -110,7 +110,7 @@ import {
|
|
|
110
110
|
Tree,
|
|
111
111
|
useOverlayLifecycle,
|
|
112
112
|
useScrollbarProximity
|
|
113
|
-
} from "./chunk-
|
|
113
|
+
} from "./chunk-NYJSSPIX.js";
|
|
114
114
|
import {
|
|
115
115
|
Dropdown,
|
|
116
116
|
FILLED_ICON_NAMES,
|
|
@@ -4652,6 +4652,22 @@ function Treemap({
|
|
|
4652
4652
|
// src/components/Table/TableCellContent.tsx
|
|
4653
4653
|
import { useLayoutEffect as useLayoutEffect2, useRef as useRef13, useState as useState16 } from "react";
|
|
4654
4654
|
import { jsx as jsx20 } from "react/jsx-runtime";
|
|
4655
|
+
var pendingLayouts = /* @__PURE__ */ new Map();
|
|
4656
|
+
var layoutFrame;
|
|
4657
|
+
function scheduleLayout(element, task) {
|
|
4658
|
+
pendingLayouts.set(element, task);
|
|
4659
|
+
if (layoutFrame !== void 0) return;
|
|
4660
|
+
layoutFrame = requestAnimationFrame(() => {
|
|
4661
|
+
layoutFrame = void 0;
|
|
4662
|
+
const tasks = [...pendingLayouts.values()];
|
|
4663
|
+
pendingLayouts.clear();
|
|
4664
|
+
const layouts = tasks.flatMap((task2) => task2.layouts());
|
|
4665
|
+
layouts.forEach((layout) => {
|
|
4666
|
+
if (!layout.hasAttribute("data-table-inline-layout")) layout.setAttribute("data-table-inline-layout", "");
|
|
4667
|
+
});
|
|
4668
|
+
tasks.forEach((task2) => task2.measure());
|
|
4669
|
+
});
|
|
4670
|
+
}
|
|
4655
4671
|
function TableCellContent({ children, ellipsis, title }) {
|
|
4656
4672
|
const ref = useRef13(null);
|
|
4657
4673
|
const [overflowing, setOverflowing] = useState16(false);
|
|
@@ -4659,29 +4675,33 @@ function TableCellContent({ children, ellipsis, title }) {
|
|
|
4659
4675
|
useLayoutEffect2(() => {
|
|
4660
4676
|
const element = ref.current;
|
|
4661
4677
|
if (!element || !ellipsis || !customContent) return;
|
|
4662
|
-
const
|
|
4663
|
-
const normalizeLayouts = (parent) => {
|
|
4678
|
+
const normalizeLayouts = (parent, layouts) => {
|
|
4664
4679
|
for (const child of parent.children) {
|
|
4665
4680
|
if (!(child instanceof HTMLElement)) continue;
|
|
4666
4681
|
const component = [...child.classList].some((name) => name.startsWith("sia-") && !name.startsWith("sia-space") && name !== "sia-flex");
|
|
4667
4682
|
if (component || child.matches("button, input, textarea, select, [contenteditable]")) continue;
|
|
4668
4683
|
const display = getComputedStyle(child).display;
|
|
4669
4684
|
if (["flex", "inline-flex", "grid", "inline-grid"].includes(display)) {
|
|
4670
|
-
child.setAttribute("data-table-inline-layout", "");
|
|
4671
4685
|
layouts.push(child);
|
|
4672
4686
|
}
|
|
4673
|
-
normalizeLayouts(child);
|
|
4687
|
+
normalizeLayouts(child, layouts);
|
|
4674
4688
|
}
|
|
4675
4689
|
};
|
|
4676
|
-
normalizeLayouts(element);
|
|
4677
4690
|
const update = () => setOverflowing(element.scrollWidth > element.clientWidth + 1 || element.scrollHeight > element.clientHeight + 1);
|
|
4678
|
-
|
|
4691
|
+
scheduleLayout(element, {
|
|
4692
|
+
layouts: () => {
|
|
4693
|
+
const layouts = [];
|
|
4694
|
+
normalizeLayouts(element, layouts);
|
|
4695
|
+
return layouts;
|
|
4696
|
+
},
|
|
4697
|
+
measure: update
|
|
4698
|
+
});
|
|
4679
4699
|
const observer = new ResizeObserver(update);
|
|
4680
4700
|
observer.observe(element);
|
|
4681
4701
|
for (const child of element.children) observer.observe(child);
|
|
4682
4702
|
return () => {
|
|
4683
4703
|
observer.disconnect();
|
|
4684
|
-
|
|
4704
|
+
pendingLayouts.delete(element);
|
|
4685
4705
|
};
|
|
4686
4706
|
}, [children, ellipsis, customContent]);
|
|
4687
4707
|
return /* @__PURE__ */ jsx20("div", { ref, className: "sia-table__cell-content", "data-custom-content": customContent || void 0, "data-content-overflow": ellipsis && customContent && overflowing || void 0, children: title ? /* @__PURE__ */ jsx20(Tooltip, { title, className: "sia-table__cell-tooltip", children: /* @__PURE__ */ jsx20("span", { children }) }) : children });
|
|
@@ -7224,10 +7244,9 @@ function buildHeaderRows(columns) {
|
|
|
7224
7244
|
function resolveInitialState(plugin) {
|
|
7225
7245
|
return typeof plugin.initialState === "function" ? plugin.initialState() : plugin.initialState;
|
|
7226
7246
|
}
|
|
7227
|
-
function
|
|
7247
|
+
function prepareTableCellMeasurement(cell) {
|
|
7228
7248
|
const content = cell.querySelector(":scope > .sia-table__cell-content");
|
|
7229
7249
|
const target = cell.classList.contains("sia-table__header-cell") ? cell.querySelector(".sia-table__resizable-header > span:first-child, .sia-table__header-label-content") : content;
|
|
7230
|
-
let contentWidth = cell.scrollWidth;
|
|
7231
7250
|
if (target) {
|
|
7232
7251
|
const measurement = target.cloneNode(true);
|
|
7233
7252
|
Object.assign(measurement.style, {
|
|
@@ -7245,11 +7264,8 @@ function measureTableCellContentWidth(cell) {
|
|
|
7245
7264
|
});
|
|
7246
7265
|
measurement.setAttribute("aria-hidden", "true");
|
|
7247
7266
|
cell.appendChild(measurement);
|
|
7248
|
-
|
|
7249
|
-
measurement.remove();
|
|
7267
|
+
return measurement;
|
|
7250
7268
|
}
|
|
7251
|
-
const style = window.getComputedStyle(cell);
|
|
7252
|
-
return contentWidth + (Number.parseFloat(style.paddingLeft) || 0) + (Number.parseFloat(style.paddingRight) || 0) + (Number.parseFloat(style.borderLeftWidth) || 0) + (Number.parseFloat(style.borderRightWidth) || 0);
|
|
7253
7269
|
}
|
|
7254
7270
|
function getTableHorizontalMetrics(viewport, table) {
|
|
7255
7271
|
const contentWidth = Math.max(viewport.clientWidth, table?.getBoundingClientRect().width ?? viewport.clientWidth);
|
|
@@ -7470,18 +7486,22 @@ function TableInner(props, ref) {
|
|
|
7470
7486
|
if (element.scrollLeft > maxLeft) element.scrollLeft = maxLeft > 1 ? maxLeft : 0;
|
|
7471
7487
|
const logicalScrollLeft = Math.min(element.scrollLeft, maxLeft);
|
|
7472
7488
|
const maxTop = Math.max(0, element.scrollHeight - element.clientHeight);
|
|
7473
|
-
|
|
7474
|
-
|
|
7475
|
-
|
|
7476
|
-
|
|
7489
|
+
const setFlag = (key, value) => {
|
|
7490
|
+
const next = String(value);
|
|
7491
|
+
if (root.dataset[key] !== next) root.dataset[key] = next;
|
|
7492
|
+
};
|
|
7493
|
+
setFlag("overflowX", maxLeft > 1);
|
|
7494
|
+
setFlag("overflowY", maxTop > 1);
|
|
7495
|
+
const horizontalTrackElement = root.querySelector(".sia-table__scrollbar--horizontal");
|
|
7496
|
+
const verticalTrackElement = root.querySelector(".sia-table__scrollbar--vertical");
|
|
7497
|
+
const horizontalTrack = horizontalTrackElement?.clientWidth ?? 0;
|
|
7498
|
+
const verticalTrack = verticalTrackElement?.clientHeight ?? 0;
|
|
7477
7499
|
const horizontalThumb = maxLeft > 1 ? Math.min(horizontalTrack, Math.max(36, horizontalTrack * element.clientWidth / horizontalContentWidth)) : 0;
|
|
7478
7500
|
const verticalThumb = maxTop > 1 ? Math.min(verticalTrack, Math.max(36, verticalTrack * element.clientHeight / element.scrollHeight)) : 0;
|
|
7479
7501
|
const horizontalPosition = maxLeft > 0 ? logicalScrollLeft / maxLeft * Math.max(0, horizontalTrack - horizontalThumb) : 0;
|
|
7480
7502
|
const verticalPosition = maxTop > 0 ? element.scrollTop / maxTop * Math.max(0, verticalTrack - verticalThumb) : 0;
|
|
7481
|
-
|
|
7482
|
-
|
|
7483
|
-
root.dataset.overflowX = String(maxLeft > 1);
|
|
7484
|
-
root.dataset.overflowY = String(maxTop > 1);
|
|
7503
|
+
setFlag("scrolledLeft", logicalScrollLeft > 1);
|
|
7504
|
+
setFlag("scrolledRight", maxLeft > 1 && logicalScrollLeft < maxLeft - 1);
|
|
7485
7505
|
const viewportRect = element.getBoundingClientRect();
|
|
7486
7506
|
const leftEdge = root.querySelector(".sia-table__header-cell.sia-table__cell--fixed-left-edge");
|
|
7487
7507
|
const rightEdge = root.querySelector(".sia-table__header-cell.sia-table__cell--fixed-right-edge");
|
|
@@ -7493,10 +7513,10 @@ function TableInner(props, ref) {
|
|
|
7493
7513
|
const rightEdgeRect = rightEdge.getBoundingClientRect();
|
|
7494
7514
|
root.style.setProperty("--sia-table-fixed-right-width", `${Math.max(0, viewportRect.right - rightEdgeRect.left)}px`);
|
|
7495
7515
|
}
|
|
7496
|
-
|
|
7497
|
-
|
|
7498
|
-
|
|
7499
|
-
|
|
7516
|
+
horizontalTrackElement?.style.setProperty("--sia-table-scrollbar-x-size", `${horizontalThumb}px`);
|
|
7517
|
+
horizontalTrackElement?.style.setProperty("--sia-table-scrollbar-x-position", `${horizontalPosition}px`);
|
|
7518
|
+
verticalTrackElement?.style.setProperty("--sia-table-scrollbar-y-size", `${verticalThumb}px`);
|
|
7519
|
+
verticalTrackElement?.style.setProperty("--sia-table-scrollbar-y-position", `${verticalPosition}px`);
|
|
7500
7520
|
}, []);
|
|
7501
7521
|
useEffect12(() => {
|
|
7502
7522
|
const element = scrollRef.current;
|
|
@@ -7517,19 +7537,33 @@ function TableInner(props, ref) {
|
|
|
7517
7537
|
const orderedColumns = useMemo9(() => sortTableColumnsByFixed(pipeline.columns), [pipeline.columns]);
|
|
7518
7538
|
const leafColumns = useMemo9(() => flattenTableColumns(orderedColumns), [orderedColumns]);
|
|
7519
7539
|
const headerRows = useMemo9(() => buildHeaderRows(orderedColumns), [orderedColumns]);
|
|
7540
|
+
const measuredCells = useRef15(/* @__PURE__ */ new WeakSet());
|
|
7541
|
+
const autoWidthSignature = leafColumns.map((column) => `${column.key}:${column.autoWidth}:${resizedWidths[column.key] ?? ""}`).join("|");
|
|
7542
|
+
useEffect12(() => {
|
|
7543
|
+
measuredCells.current = /* @__PURE__ */ new WeakSet();
|
|
7544
|
+
setAutoColumnWidths({});
|
|
7545
|
+
}, [dataSource, baseColumns, size, autoWidthSignature]);
|
|
7520
7546
|
useEffect12(() => {
|
|
7521
7547
|
const autoWidthColumns = leafColumns.filter((column) => column.autoWidth && resizedWidths[column.key] === void 0);
|
|
7522
7548
|
const root = rootRef.current;
|
|
7523
7549
|
if (!root || autoWidthColumns.length === 0) return;
|
|
7524
7550
|
const frame = window.requestAnimationFrame(() => {
|
|
7525
7551
|
const measurements = {};
|
|
7526
|
-
const
|
|
7552
|
+
const columnsByKey = new Map(autoWidthColumns.map((column) => [column.key, column]));
|
|
7553
|
+
const cells = [...root.querySelectorAll("th[data-column-key], td[data-column-key]")].filter((cell) => columnsByKey.has(cell.dataset.columnKey) && !measuredCells.current.has(cell));
|
|
7554
|
+
if (cells.length === 0) return;
|
|
7555
|
+
const prepared = cells.map((cell) => ({ cell, node: prepareTableCellMeasurement(cell) }));
|
|
7556
|
+
for (const { cell, node } of prepared) {
|
|
7557
|
+
const key = cell.dataset.columnKey;
|
|
7558
|
+
const style2 = window.getComputedStyle(cell);
|
|
7559
|
+
const padding = (Number.parseFloat(style2.paddingLeft) || 0) + (Number.parseFloat(style2.paddingRight) || 0) + (Number.parseFloat(style2.borderLeftWidth) || 0) + (Number.parseFloat(style2.borderRightWidth) || 0);
|
|
7560
|
+
measurements[key] = Math.max(measurements[key] ?? 0, node ? Math.max(node.scrollWidth, node.getBoundingClientRect().width) + padding : cell.scrollWidth);
|
|
7561
|
+
measuredCells.current.add(cell);
|
|
7562
|
+
}
|
|
7563
|
+
prepared.forEach(({ node }) => node?.remove());
|
|
7527
7564
|
for (const column of autoWidthColumns) {
|
|
7528
|
-
|
|
7529
|
-
|
|
7530
|
-
if (cell.dataset.columnKey !== column.key) continue;
|
|
7531
|
-
width = Math.max(width, measureTableCellContentWidth(cell));
|
|
7532
|
-
}
|
|
7565
|
+
if (measurements[column.key] === void 0) continue;
|
|
7566
|
+
const width = Math.max(column.minWidth ?? 56, autoColumnWidths[column.key] ?? 0, measurements[column.key]);
|
|
7533
7567
|
measurements[column.key] = Math.ceil(Math.min(column.maxWidth ?? Number.POSITIVE_INFINITY, width));
|
|
7534
7568
|
}
|
|
7535
7569
|
setAutoColumnWidths((previous) => {
|
|
@@ -7585,6 +7619,21 @@ function TableInner(props, ref) {
|
|
|
7585
7619
|
const renderedRows = pipeline.rows.slice(startIndex, endIndex);
|
|
7586
7620
|
const topSpacer = shouldVirtualize ? startIndex * rowHeight : 0;
|
|
7587
7621
|
const bottomSpacer = shouldVirtualize ? Math.max(0, (pipeline.rows.length - endIndex) * rowHeight) : 0;
|
|
7622
|
+
const rowElements = useMemo9(() => /* @__PURE__ */ new Map(), [
|
|
7623
|
+
dataSource,
|
|
7624
|
+
baseColumns,
|
|
7625
|
+
sortedPlugins,
|
|
7626
|
+
pluginStates,
|
|
7627
|
+
autoColumnWidths,
|
|
7628
|
+
viewportWidth,
|
|
7629
|
+
rowHeight,
|
|
7630
|
+
striped,
|
|
7631
|
+
rowClassName,
|
|
7632
|
+
getRowKey,
|
|
7633
|
+
onRowClick,
|
|
7634
|
+
onRowDoubleClick,
|
|
7635
|
+
onCellContextMenu
|
|
7636
|
+
]);
|
|
7588
7637
|
const toolbarStart = sortedPlugins.map((plugin) => {
|
|
7589
7638
|
const content = plugin.renderToolbarStart?.(getContext(plugin));
|
|
7590
7639
|
return content ? /* @__PURE__ */ jsx22(Fragment8, { children: content }, `toolbar-start-${plugin.id}`) : null;
|
|
@@ -7611,9 +7660,9 @@ function TableInner(props, ref) {
|
|
|
7611
7660
|
};
|
|
7612
7661
|
const handleScroll = useCallback2((event) => {
|
|
7613
7662
|
const element = event.currentTarget;
|
|
7614
|
-
if (shouldVirtualize) setScrollTop(element.scrollTop);
|
|
7663
|
+
if (shouldVirtualize) setScrollTop((previous) => Math.floor(previous / rowHeight) === Math.floor(element.scrollTop / rowHeight) ? previous : element.scrollTop);
|
|
7615
7664
|
updateScrollMetrics();
|
|
7616
|
-
}, [shouldVirtualize, updateScrollMetrics]);
|
|
7665
|
+
}, [shouldVirtualize, rowHeight, updateScrollMetrics]);
|
|
7617
7666
|
const handleScrollbarPointerDown = useCallback2((axis, event, track = event.currentTarget) => {
|
|
7618
7667
|
const element = scrollRef.current;
|
|
7619
7668
|
const thumb = track.firstElementChild;
|
|
@@ -7834,10 +7883,12 @@ function TableInner(props, ref) {
|
|
|
7834
7883
|
/* @__PURE__ */ jsxs21("tbody", { children: [
|
|
7835
7884
|
topSpacer > 0 ? /* @__PURE__ */ jsx22("tr", { "aria-hidden": "true", children: /* @__PURE__ */ jsx22("td", { colSpan: leafColumns.length, style: { height: topSpacer, padding: 0, border: 0 } }) }) : null,
|
|
7836
7885
|
renderedRows.map((row, offset) => {
|
|
7886
|
+
const cached = rowElements.get(row.key);
|
|
7887
|
+
if (cached) return cached;
|
|
7837
7888
|
const rowIndex = startIndex + offset;
|
|
7838
7889
|
const pluginClasses = sortedPlugins.map((plugin) => plugin.getRowClassName?.(row, getContext(plugin))).filter(Boolean).join(" ");
|
|
7839
7890
|
const customClass = typeof rowClassName === "function" ? rowClassName(row.record, row.sourceIndex) : rowClassName ?? "";
|
|
7840
|
-
|
|
7891
|
+
const element = /* @__PURE__ */ jsx22(
|
|
7841
7892
|
TableBodyRow,
|
|
7842
7893
|
{
|
|
7843
7894
|
row,
|
|
@@ -7883,6 +7934,8 @@ function TableInner(props, ref) {
|
|
|
7883
7934
|
},
|
|
7884
7935
|
row.key
|
|
7885
7936
|
);
|
|
7937
|
+
rowElements.set(row.key, element);
|
|
7938
|
+
return element;
|
|
7886
7939
|
}),
|
|
7887
7940
|
bottomSpacer > 0 ? /* @__PURE__ */ jsx22("tr", { "aria-hidden": "true", children: /* @__PURE__ */ jsx22("td", { colSpan: leafColumns.length, style: { height: bottomSpacer, padding: 0, border: 0 } }) }) : null
|
|
7888
7941
|
] }),
|
|
@@ -1474,7 +1474,17 @@ function FloatingScrollbarProvider({ disabled = false, targetRef }) {
|
|
|
1474
1474
|
};
|
|
1475
1475
|
const scanTargets = () => {
|
|
1476
1476
|
scanFrame = 0;
|
|
1477
|
-
const
|
|
1477
|
+
const managedSelector = ".sia-table__viewport, [data-sia-native-scrollbar], .sia-scrollbar-track, .sia-floating-scrollbar-layer";
|
|
1478
|
+
const discovered = [];
|
|
1479
|
+
if (!targetRef) {
|
|
1480
|
+
const walker = document.createTreeWalker(document.body, NodeFilter.SHOW_ELEMENT, {
|
|
1481
|
+
acceptNode: (node) => node.matches(managedSelector) ? NodeFilter.FILTER_REJECT : NodeFilter.FILTER_ACCEPT
|
|
1482
|
+
});
|
|
1483
|
+
for (let node = walker.nextNode(); node; node = walker.nextNode()) {
|
|
1484
|
+
if (node instanceof HTMLElement) discovered.push(node);
|
|
1485
|
+
}
|
|
1486
|
+
}
|
|
1487
|
+
const candidates = (targetRef ? [targetRef.current] : [document.scrollingElement, ...discovered]).filter((target) => target instanceof HTMLElement);
|
|
1478
1488
|
const nextTargets = /* @__PURE__ */ new Set();
|
|
1479
1489
|
candidates.forEach((target) => {
|
|
1480
1490
|
if (canScroll(target, "horizontal") || canScroll(target, "vertical")) {
|
|
@@ -1492,9 +1502,12 @@ function FloatingScrollbarProvider({ disabled = false, targetRef }) {
|
|
|
1492
1502
|
scanFrame = window.requestAnimationFrame(scanTargets);
|
|
1493
1503
|
};
|
|
1494
1504
|
const mutationObserver = new MutationObserver((mutations) => {
|
|
1495
|
-
if (mutations.some((mutation) =>
|
|
1505
|
+
if (mutations.some((mutation) => {
|
|
1506
|
+
const target = mutation.target instanceof Element ? mutation.target : mutation.target.parentElement;
|
|
1507
|
+
return target && !layer.contains(target) && !target.closest(".sia-table__viewport, [data-sia-native-scrollbar], .sia-scrollbar-track");
|
|
1508
|
+
})) scheduleScan();
|
|
1496
1509
|
});
|
|
1497
|
-
mutationObserver.observe(document.documentElement, { subtree: true, childList: true, attributes: true });
|
|
1510
|
+
mutationObserver.observe(document.documentElement, { subtree: true, childList: true, attributes: true, attributeFilter: ["class", "style", "hidden"] });
|
|
1498
1511
|
window.addEventListener("resize", scheduleScan);
|
|
1499
1512
|
window.addEventListener("scroll", scheduleUpdateAll, true);
|
|
1500
1513
|
scheduleScan();
|