@sia.soul/sia-react-ui 0.1.164 → 0.1.166
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-WR5YBY2A.js → chunk-T2F6X3LA.js} +31 -21
- package/dist/{core-r-smfiNN.d.cts → core-Cnt8r6pj.d.cts} +5 -3
- package/dist/{core-XtqUDbbD.d.ts → core-Dy8NWJ1b.d.ts} +5 -3
- package/dist/core.cjs +210 -200
- package/dist/core.css +3 -0
- package/dist/core.d.cts +1 -1
- package/dist/core.d.ts +1 -1
- package/dist/core.js +1 -1
- package/dist/index.cjs +552 -554
- package/dist/index.css +3 -0
- package/dist/index.d.cts +7 -7
- package/dist/index.d.ts +7 -7
- package/dist/index.js +15 -27
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -14729,7 +14729,15 @@ function openSelectModal(config) {
|
|
|
14729
14729
|
}
|
|
14730
14730
|
|
|
14731
14731
|
// src/components/Tag.tsx
|
|
14732
|
+
var import_react58 = require("react");
|
|
14732
14733
|
var import_jsx_runtime56 = require("react/jsx-runtime");
|
|
14734
|
+
function hasTagContent(content) {
|
|
14735
|
+
return import_react58.Children.toArray(content).some((node) => {
|
|
14736
|
+
if (typeof node === "string") return node.trim().length > 0;
|
|
14737
|
+
if ((0, import_react58.isValidElement)(node) && node.type === import_react58.Fragment) return hasTagContent(node.props.children);
|
|
14738
|
+
return true;
|
|
14739
|
+
});
|
|
14740
|
+
}
|
|
14733
14741
|
function Tag({
|
|
14734
14742
|
size: sizeProp,
|
|
14735
14743
|
color,
|
|
@@ -14747,6 +14755,8 @@ function Tag({
|
|
|
14747
14755
|
...props
|
|
14748
14756
|
}) {
|
|
14749
14757
|
const size = useControlSize(sizeProp ?? (compact ? "small" : void 0));
|
|
14758
|
+
const hasIcon = hasTagContent(icon);
|
|
14759
|
+
if (!hasTagContent(children) && !hasIcon) return null;
|
|
14750
14760
|
const customColor = color?.trim() ? variant === "outlined" ? { borderColor: color, color, backgroundColor: "transparent" } : variant === "filled" ? { backgroundColor: color, color: "#fff", borderColor: "transparent" } : { color, backgroundColor: `color-mix(in srgb, ${color} 10%, transparent)`, borderColor: `color-mix(in srgb, ${color} 35%, transparent)` } : void 0;
|
|
14751
14761
|
return /* @__PURE__ */ (0, import_jsx_runtime56.jsxs)(
|
|
14752
14762
|
"span",
|
|
@@ -14756,7 +14766,7 @@ function Tag({
|
|
|
14756
14766
|
style: customColor ? { ...customColor, ...style } : style,
|
|
14757
14767
|
...withTitleTooltip(props),
|
|
14758
14768
|
children: [
|
|
14759
|
-
|
|
14769
|
+
hasIcon ? /* @__PURE__ */ (0, import_jsx_runtime56.jsx)("span", { className: "sia-tag__icon", children: icon }) : null,
|
|
14760
14770
|
/* @__PURE__ */ (0, import_jsx_runtime56.jsx)("span", { children }),
|
|
14761
14771
|
closable ? /* @__PURE__ */ (0, import_jsx_runtime56.jsx)(
|
|
14762
14772
|
"button",
|
|
@@ -14778,9 +14788,9 @@ function Tag({
|
|
|
14778
14788
|
}
|
|
14779
14789
|
|
|
14780
14790
|
// src/components/Tabs.tsx
|
|
14781
|
-
var import_react58 = require("react");
|
|
14782
|
-
var import_jsx_runtime57 = require("react/jsx-runtime");
|
|
14783
14791
|
var import_react59 = require("react");
|
|
14792
|
+
var import_jsx_runtime57 = require("react/jsx-runtime");
|
|
14793
|
+
var import_react60 = require("react");
|
|
14784
14794
|
function Tabs({
|
|
14785
14795
|
items,
|
|
14786
14796
|
activeKey,
|
|
@@ -14807,25 +14817,25 @@ function Tabs({
|
|
|
14807
14817
|
...props
|
|
14808
14818
|
}) {
|
|
14809
14819
|
const firstEnabledKey = items.find((item) => !item.disabled)?.key ?? "";
|
|
14810
|
-
const [internalActiveKey, setInternalActiveKey] = (0,
|
|
14820
|
+
const [internalActiveKey, setInternalActiveKey] = (0, import_react59.useState)(defaultActiveKey ?? firstEnabledKey);
|
|
14811
14821
|
const currentKey = activeKey ?? internalActiveKey;
|
|
14812
14822
|
const selectedKey = items.some((item) => item.key === currentKey && !item.disabled) ? currentKey : firstEnabledKey;
|
|
14813
|
-
const baseId = (0,
|
|
14814
|
-
const enabledItems = (0,
|
|
14823
|
+
const baseId = (0, import_react59.useId)().replace(/:/g, "");
|
|
14824
|
+
const enabledItems = (0, import_react59.useMemo)(() => items.filter((item) => !item.disabled), [items]);
|
|
14815
14825
|
const resolvedPosition = tabPosition ?? (orientation === "vertical" ? "left" : "top");
|
|
14816
14826
|
const resolvedOrientation = resolvedPosition === "left" || resolvedPosition === "right" ? "vertical" : "horizontal";
|
|
14817
14827
|
const defaultIndicatorPosition = { top: "bottom", bottom: "top", left: "right", right: "left" }[resolvedPosition];
|
|
14818
14828
|
const resolvedIndicatorPosition = indicatorPosition && (resolvedOrientation === "vertical" ? ["left", "right"] : ["top", "bottom"]).includes(indicatorPosition) ? indicatorPosition : defaultIndicatorPosition;
|
|
14819
14829
|
const sliding = ["capsule", "line", "underline", "rounded", "tech", "tech-line"].includes(type);
|
|
14820
|
-
const listRef = (0,
|
|
14821
|
-
const indicatorRef = (0,
|
|
14822
|
-
const indicatorTargetRef = (0,
|
|
14823
|
-
const moreRef = (0,
|
|
14824
|
-
const [overflow, setOverflow] = (0,
|
|
14825
|
-
const [moreOpen, setMoreOpen] = (0,
|
|
14830
|
+
const listRef = (0, import_react59.useRef)(null);
|
|
14831
|
+
const indicatorRef = (0, import_react59.useRef)(null);
|
|
14832
|
+
const indicatorTargetRef = (0, import_react59.useRef)();
|
|
14833
|
+
const moreRef = (0, import_react59.useRef)(null);
|
|
14834
|
+
const [overflow, setOverflow] = (0, import_react59.useState)({ count: items.length, width: 0 });
|
|
14835
|
+
const [moreOpen, setMoreOpen] = (0, import_react59.useState)(false);
|
|
14826
14836
|
const visibleCount = resolvedOrientation === "horizontal" ? overflow.count : items.length;
|
|
14827
14837
|
const hiddenItems = items.slice(visibleCount);
|
|
14828
|
-
(0,
|
|
14838
|
+
(0, import_react59.useLayoutEffect)(() => {
|
|
14829
14839
|
const list = listRef.current;
|
|
14830
14840
|
if (!list || resolvedOrientation !== "horizontal") return;
|
|
14831
14841
|
const entries = Array.from(list.children).filter((node) => node instanceof HTMLElement && node.hasAttribute("data-tab-entry"));
|
|
@@ -14856,14 +14866,14 @@ function Tabs({
|
|
|
14856
14866
|
entries.forEach((entry) => observer.observe(entry));
|
|
14857
14867
|
return () => observer.disconnect();
|
|
14858
14868
|
}, [items, type, size, closable, resolvedOrientation, tabBarTitle, tabBarExtraContent]);
|
|
14859
|
-
const [settledContentKey, setSettledContentKey] = (0,
|
|
14860
|
-
const [visitedKeys, setVisitedKeys] = (0,
|
|
14861
|
-
const settledKeyRef = (0,
|
|
14862
|
-
const afterChangeRef = (0,
|
|
14863
|
-
(0,
|
|
14869
|
+
const [settledContentKey, setSettledContentKey] = (0, import_react59.useState)(selectedKey);
|
|
14870
|
+
const [visitedKeys, setVisitedKeys] = (0, import_react59.useState)(() => /* @__PURE__ */ new Set([selectedKey]));
|
|
14871
|
+
const settledKeyRef = (0, import_react59.useRef)(selectedKey);
|
|
14872
|
+
const afterChangeRef = (0, import_react59.useRef)(onAfterChange);
|
|
14873
|
+
(0, import_react59.useLayoutEffect)(() => {
|
|
14864
14874
|
afterChangeRef.current = onAfterChange;
|
|
14865
14875
|
}, [onAfterChange]);
|
|
14866
|
-
(0,
|
|
14876
|
+
(0, import_react59.useLayoutEffect)(() => {
|
|
14867
14877
|
if (!sliding) return;
|
|
14868
14878
|
const list = listRef.current;
|
|
14869
14879
|
const indicator = indicatorRef.current;
|
|
@@ -14925,7 +14935,7 @@ function Tabs({
|
|
|
14925
14935
|
motionPreference.removeEventListener("change", stopMotion);
|
|
14926
14936
|
};
|
|
14927
14937
|
}, [sliding, type, selectedKey, items, size, resolvedPosition, centered, closable, visibleCount, indicatorMotion]);
|
|
14928
|
-
(0,
|
|
14938
|
+
(0, import_react59.useEffect)(() => {
|
|
14929
14939
|
let cancelled = false;
|
|
14930
14940
|
let frame = 0;
|
|
14931
14941
|
frame = requestAnimationFrame(() => {
|
|
@@ -14951,7 +14961,7 @@ function Tabs({
|
|
|
14951
14961
|
};
|
|
14952
14962
|
}, [selectedKey, type, deferContent, indicatorMotion]);
|
|
14953
14963
|
const contentKey = deferContent && items.some((item) => item.key === settledContentKey) ? settledContentKey : selectedKey;
|
|
14954
|
-
(0,
|
|
14964
|
+
(0, import_react59.useLayoutEffect)(() => {
|
|
14955
14965
|
if (deferContent && contentKey !== settledContentKey) setSettledContentKey(contentKey);
|
|
14956
14966
|
setVisitedKeys((previous) => {
|
|
14957
14967
|
const next = new Set(items.filter((item) => item.key === contentKey || !destroyInactiveTabPane && previous.has(item.key)).map((item) => item.key));
|
|
@@ -14999,7 +15009,7 @@ function Tabs({
|
|
|
14999
15009
|
const canClose = item.closable ?? closable;
|
|
15000
15010
|
const contextMenuItems = typeof tabContextMenu === "function" ? tabContextMenu(item) : tabContextMenu;
|
|
15001
15011
|
const entryProps = { "data-tab-entry": "", "data-tab-hidden": index >= visibleCount, "aria-hidden": index >= visibleCount || void 0 };
|
|
15002
|
-
const tabNode = /* @__PURE__ */ (0,
|
|
15012
|
+
const tabNode = /* @__PURE__ */ (0, import_react60.createElement)("span", { ...!contextMenuItems?.length ? entryProps : {}, className: `sia-tabs__tab-wrap${canClose ? " is-closable" : ""}`, key: item.key }, /* @__PURE__ */ (0, import_jsx_runtime57.jsxs)(
|
|
15003
15013
|
"button",
|
|
15004
15014
|
{
|
|
15005
15015
|
id: `${baseId}-tab-${item.key}`,
|
|
@@ -15030,7 +15040,7 @@ function Tabs({
|
|
|
15030
15040
|
}
|
|
15031
15041
|
) : null);
|
|
15032
15042
|
if (!contextMenuItems?.length) return tabNode;
|
|
15033
|
-
return /* @__PURE__ */ (0,
|
|
15043
|
+
return /* @__PURE__ */ (0, import_react60.createElement)(
|
|
15034
15044
|
Dropdown,
|
|
15035
15045
|
{
|
|
15036
15046
|
...entryProps,
|
|
@@ -15093,9 +15103,9 @@ function Tabs({
|
|
|
15093
15103
|
}
|
|
15094
15104
|
|
|
15095
15105
|
// src/components/Treemap.tsx
|
|
15096
|
-
var import_react60 = require("react");
|
|
15097
|
-
var import_jsx_runtime58 = require("react/jsx-runtime");
|
|
15098
15106
|
var import_react61 = require("react");
|
|
15107
|
+
var import_jsx_runtime58 = require("react/jsx-runtime");
|
|
15108
|
+
var import_react62 = require("react");
|
|
15099
15109
|
function positiveValue(value) {
|
|
15100
15110
|
return Number.isFinite(value) && value > 0 ? value : 1;
|
|
15101
15111
|
}
|
|
@@ -15466,19 +15476,19 @@ function Treemap({
|
|
|
15466
15476
|
style,
|
|
15467
15477
|
...props
|
|
15468
15478
|
}) {
|
|
15469
|
-
const containerRef = (0,
|
|
15470
|
-
const [size, setSize] = (0,
|
|
15471
|
-
const [internalExpandedKeys, setInternalExpandedKeys] = (0,
|
|
15472
|
-
const [internalFocusedKey, setInternalFocusedKey] = (0,
|
|
15479
|
+
const containerRef = (0, import_react61.useRef)(null);
|
|
15480
|
+
const [size, setSize] = (0, import_react61.useState)({ width: 0, height: 0 });
|
|
15481
|
+
const [internalExpandedKeys, setInternalExpandedKeys] = (0, import_react61.useState)(() => [...defaultExpandedKeys]);
|
|
15482
|
+
const [internalFocusedKey, setInternalFocusedKey] = (0, import_react61.useState)(defaultFocusedKey);
|
|
15473
15483
|
const currentExpandedKeys = expandedKeys ?? internalExpandedKeys;
|
|
15474
15484
|
const currentFocusedKey = focusedKey === void 0 ? internalFocusedKey : focusedKey;
|
|
15475
|
-
const expandedSet = (0,
|
|
15476
|
-
const focusedNode = (0,
|
|
15485
|
+
const expandedSet = (0, import_react61.useMemo)(() => new Set(currentExpandedKeys), [currentExpandedKeys]);
|
|
15486
|
+
const focusedNode = (0, import_react61.useMemo)(
|
|
15477
15487
|
() => currentFocusedKey ? findNode(data, currentFocusedKey) : null,
|
|
15478
15488
|
[currentFocusedKey, data]
|
|
15479
15489
|
);
|
|
15480
15490
|
const effectiveFocusedNode = focusedNode && expandedSet.has(focusedNode.key) && Boolean(focusedNode.children?.length) ? focusedNode : null;
|
|
15481
|
-
const positions = (0,
|
|
15491
|
+
const positions = (0, import_react61.useMemo)(
|
|
15482
15492
|
() => collectPositions(
|
|
15483
15493
|
effectiveFocusedNode ? [effectiveFocusedNode] : data,
|
|
15484
15494
|
{ x: 0, y: 0, ...size },
|
|
@@ -15494,7 +15504,7 @@ function Treemap({
|
|
|
15494
15504
|
),
|
|
15495
15505
|
[activeKey, aggregateOverflow, data, effectiveFocusedNode, expandedSet, gap, headerHeight, maxVisibleNodes, minTileHeight, minTileWidth, overflowLabel, size]
|
|
15496
15506
|
);
|
|
15497
|
-
(0,
|
|
15507
|
+
(0, import_react61.useEffect)(() => {
|
|
15498
15508
|
const element = containerRef.current;
|
|
15499
15509
|
if (!element) return void 0;
|
|
15500
15510
|
const updateSize = () => {
|
|
@@ -15506,7 +15516,7 @@ function Treemap({
|
|
|
15506
15516
|
observer.observe(element);
|
|
15507
15517
|
return () => observer.disconnect();
|
|
15508
15518
|
}, []);
|
|
15509
|
-
(0,
|
|
15519
|
+
(0, import_react61.useEffect)(() => {
|
|
15510
15520
|
if (!currentFocusedKey || effectiveFocusedNode) return;
|
|
15511
15521
|
if (focusedKey === void 0) setInternalFocusedKey(null);
|
|
15512
15522
|
onFocusedChange?.(null);
|
|
@@ -15554,7 +15564,7 @@ function Treemap({
|
|
|
15554
15564
|
const hasChildren = Boolean(node.hasChildren || node.children?.length);
|
|
15555
15565
|
const title = `${node.label} \xB7 ${String(valueFormatter(node.value, node))}`;
|
|
15556
15566
|
if (expanded) {
|
|
15557
|
-
return /* @__PURE__ */ (0,
|
|
15567
|
+
return /* @__PURE__ */ (0, import_react62.createElement)(
|
|
15558
15568
|
"div",
|
|
15559
15569
|
{
|
|
15560
15570
|
className: `sia-treemap__tile sia-treemap__tile--directory is-expanded${effectiveFocusedNode?.key === node.key ? " is-focused" : ""}${active ? " is-active" : ""}`,
|
|
@@ -15593,7 +15603,7 @@ function Treemap({
|
|
|
15593
15603
|
] })
|
|
15594
15604
|
);
|
|
15595
15605
|
}
|
|
15596
|
-
return /* @__PURE__ */ (0,
|
|
15606
|
+
return /* @__PURE__ */ (0, import_react62.createElement)(
|
|
15597
15607
|
"button",
|
|
15598
15608
|
{
|
|
15599
15609
|
type: "button",
|
|
@@ -15619,7 +15629,7 @@ function Treemap({
|
|
|
15619
15629
|
}
|
|
15620
15630
|
|
|
15621
15631
|
// src/components/Table/TableCellContent.tsx
|
|
15622
|
-
var
|
|
15632
|
+
var import_react63 = require("react");
|
|
15623
15633
|
var import_jsx_runtime59 = require("react/jsx-runtime");
|
|
15624
15634
|
var pendingLayouts = /* @__PURE__ */ new Map();
|
|
15625
15635
|
var layoutFrame;
|
|
@@ -15638,10 +15648,10 @@ function scheduleLayout(element, task) {
|
|
|
15638
15648
|
});
|
|
15639
15649
|
}
|
|
15640
15650
|
function TableCellContent({ children, ellipsis, title }) {
|
|
15641
|
-
const ref = (0,
|
|
15642
|
-
const [overflowing, setOverflowing] = (0,
|
|
15651
|
+
const ref = (0, import_react63.useRef)(null);
|
|
15652
|
+
const [overflowing, setOverflowing] = (0, import_react63.useState)(false);
|
|
15643
15653
|
const customContent = typeof children !== "string" && typeof children !== "number" && children != null;
|
|
15644
|
-
(0,
|
|
15654
|
+
(0, import_react63.useLayoutEffect)(() => {
|
|
15645
15655
|
const element = ref.current;
|
|
15646
15656
|
if (!element || !ellipsis || !customContent) return;
|
|
15647
15657
|
const normalizeLayouts = (parent, layouts) => {
|
|
@@ -15677,14 +15687,14 @@ function TableCellContent({ children, ellipsis, title }) {
|
|
|
15677
15687
|
}
|
|
15678
15688
|
|
|
15679
15689
|
// src/components/Table/useRemainingHeight.ts
|
|
15680
|
-
var
|
|
15690
|
+
var import_react64 = require("react");
|
|
15681
15691
|
function useRemainingHeight(rootRef, options) {
|
|
15682
|
-
const [height, setHeight] = (0,
|
|
15692
|
+
const [height, setHeight] = (0, import_react64.useState)();
|
|
15683
15693
|
const enabled = !!options;
|
|
15684
15694
|
const container = typeof options === "object" ? options.container : void 0;
|
|
15685
15695
|
const bottomOffset = typeof options === "object" ? options.bottomOffset ?? 0 : 0;
|
|
15686
15696
|
const minHeight = typeof options === "object" ? options.minHeight ?? 0 : 0;
|
|
15687
|
-
(0,
|
|
15697
|
+
(0, import_react64.useLayoutEffect)(() => {
|
|
15688
15698
|
const root = rootRef.current;
|
|
15689
15699
|
if (!enabled || !root) return;
|
|
15690
15700
|
const win = root.ownerDocument.defaultView;
|
|
@@ -15755,7 +15765,7 @@ function useRemainingHeight(rootRef, options) {
|
|
|
15755
15765
|
}
|
|
15756
15766
|
|
|
15757
15767
|
// src/components/Table/TableCanvasLayer.tsx
|
|
15758
|
-
var
|
|
15768
|
+
var import_react65 = require("react");
|
|
15759
15769
|
|
|
15760
15770
|
// src/components/Table/utils.ts
|
|
15761
15771
|
var AUTO_WIDTH_COLUMN_KEYS = /* @__PURE__ */ new Set(["action", "actions", "operation", "operations"]);
|
|
@@ -15810,8 +15820,8 @@ function toTablePageParams(current, pageSize) {
|
|
|
15810
15820
|
// src/components/Table/TableCanvasLayer.tsx
|
|
15811
15821
|
var import_jsx_runtime60 = require("react/jsx-runtime");
|
|
15812
15822
|
function TableCanvasLayer({ viewport, rows, columns, widths, rowHeight, headerHeight }) {
|
|
15813
|
-
const canvasRef = (0,
|
|
15814
|
-
(0,
|
|
15823
|
+
const canvasRef = (0, import_react65.useRef)(null);
|
|
15824
|
+
(0, import_react65.useLayoutEffect)(() => {
|
|
15815
15825
|
const canvas = canvasRef.current;
|
|
15816
15826
|
const scroller = viewport.current;
|
|
15817
15827
|
if (!canvas || !scroller) return;
|
|
@@ -15991,13 +16001,13 @@ function createRowHeightLayout(rows, baseHeight, heights, minimumHeight = 1) {
|
|
|
15991
16001
|
}
|
|
15992
16002
|
|
|
15993
16003
|
// src/components/Table/RowResizeHandle.tsx
|
|
15994
|
-
var
|
|
16004
|
+
var import_react66 = require("react");
|
|
15995
16005
|
var import_jsx_runtime61 = require("react/jsx-runtime");
|
|
15996
16006
|
function RowResizeHandle({ height, min, max, onPreview, onCommit }) {
|
|
15997
|
-
const drag = (0,
|
|
15998
|
-
const previewCallback = (0,
|
|
16007
|
+
const drag = (0, import_react66.useRef)(null);
|
|
16008
|
+
const previewCallback = (0, import_react66.useRef)(onPreview);
|
|
15999
16009
|
previewCallback.current = onPreview;
|
|
16000
|
-
(0,
|
|
16010
|
+
(0, import_react66.useEffect)(() => {
|
|
16001
16011
|
const cancel = () => {
|
|
16002
16012
|
if (!drag.current) return;
|
|
16003
16013
|
drag.current = null;
|
|
@@ -16107,11 +16117,11 @@ function playCellFocusGlow(cell, isVisible, onFinish, options) {
|
|
|
16107
16117
|
}
|
|
16108
16118
|
|
|
16109
16119
|
// src/components/Table/Table.tsx
|
|
16110
|
-
var
|
|
16120
|
+
var import_react68 = require("react");
|
|
16111
16121
|
var import_react_dom7 = require("react-dom");
|
|
16112
16122
|
|
|
16113
16123
|
// src/components/Table/plugins.tsx
|
|
16114
|
-
var
|
|
16124
|
+
var import_react67 = require("react");
|
|
16115
16125
|
|
|
16116
16126
|
// src/components/Table/columnSettings.ts
|
|
16117
16127
|
function reconcileColumnSettings(columns, defaults, saved) {
|
|
@@ -16824,7 +16834,7 @@ function TableSelectedItemsPanel({
|
|
|
16824
16834
|
onRemove,
|
|
16825
16835
|
onClear
|
|
16826
16836
|
}) {
|
|
16827
|
-
const [showAll, setShowAll] = (0,
|
|
16837
|
+
const [showAll, setShowAll] = (0, import_react67.useState)(false);
|
|
16828
16838
|
const visibleEntries = showAll ? entries : entries.slice(0, maxCount2);
|
|
16829
16839
|
const hiddenCount = Math.max(0, entries.length - visibleEntries.length);
|
|
16830
16840
|
const baseColumnMap = new Map(
|
|
@@ -17230,10 +17240,10 @@ function TableFilterControl({
|
|
|
17230
17240
|
placeholder,
|
|
17231
17241
|
onApply
|
|
17232
17242
|
}) {
|
|
17233
|
-
const [open, setOpen] = (0,
|
|
17234
|
-
const [draft, setDraft] = (0,
|
|
17243
|
+
const [open, setOpen] = (0, import_react67.useState)(false);
|
|
17244
|
+
const [draft, setDraft] = (0, import_react67.useState)(value);
|
|
17235
17245
|
const label = getColumnLabel(column);
|
|
17236
|
-
(0,
|
|
17246
|
+
(0, import_react67.useEffect)(() => {
|
|
17237
17247
|
if (open) setDraft(value);
|
|
17238
17248
|
}, [open, value]);
|
|
17239
17249
|
const apply = (nextValue) => {
|
|
@@ -17670,18 +17680,18 @@ function EditableTableCell({
|
|
|
17670
17680
|
showEditIcon
|
|
17671
17681
|
}) {
|
|
17672
17682
|
const config = typeof editable === "object" ? editable : { type: "input" };
|
|
17673
|
-
const [editValue, setEditValue] = (0,
|
|
17674
|
-
const [saving, setSaving] = (0,
|
|
17675
|
-
const inputRef = (0,
|
|
17676
|
-
const editorRef = (0,
|
|
17677
|
-
const ownedEvents = (0,
|
|
17678
|
-
const editValueRef = (0,
|
|
17679
|
-
const savingRef = (0,
|
|
17680
|
-
const saveRef = (0,
|
|
17683
|
+
const [editValue, setEditValue] = (0, import_react67.useState)(value);
|
|
17684
|
+
const [saving, setSaving] = (0, import_react67.useState)(false);
|
|
17685
|
+
const inputRef = (0, import_react67.useRef)(null);
|
|
17686
|
+
const editorRef = (0, import_react67.useRef)(null);
|
|
17687
|
+
const ownedEvents = (0, import_react67.useRef)(/* @__PURE__ */ new WeakSet());
|
|
17688
|
+
const editValueRef = (0, import_react67.useRef)(value);
|
|
17689
|
+
const savingRef = (0, import_react67.useRef)(false);
|
|
17690
|
+
const saveRef = (0, import_react67.useRef)(
|
|
17681
17691
|
async () => {
|
|
17682
17692
|
}
|
|
17683
17693
|
);
|
|
17684
|
-
(0,
|
|
17694
|
+
(0, import_react67.useEffect)(() => {
|
|
17685
17695
|
if (!active) return;
|
|
17686
17696
|
editValueRef.current = value;
|
|
17687
17697
|
setEditValue(value);
|
|
@@ -17712,7 +17722,7 @@ function EditableTableCell({
|
|
|
17712
17722
|
}
|
|
17713
17723
|
}
|
|
17714
17724
|
saveRef.current = save;
|
|
17715
|
-
(0,
|
|
17725
|
+
(0, import_react67.useEffect)(() => {
|
|
17716
17726
|
if (!active) return;
|
|
17717
17727
|
const handleOutsidePointerDown = (event) => {
|
|
17718
17728
|
const target = event.target;
|
|
@@ -18029,12 +18039,12 @@ function ColumnSettingPanel({
|
|
|
18029
18039
|
onClose,
|
|
18030
18040
|
onApply
|
|
18031
18041
|
}) {
|
|
18032
|
-
const [draft, setDraft] = (0,
|
|
18033
|
-
const listRef = (0,
|
|
18034
|
-
const cancelDrag = (0,
|
|
18035
|
-
const [preview, setPreview] = (0,
|
|
18036
|
-
const syncedDraft = (0,
|
|
18037
|
-
(0,
|
|
18042
|
+
const [draft, setDraft] = (0, import_react67.useState)(items);
|
|
18043
|
+
const listRef = (0, import_react67.useRef)(null);
|
|
18044
|
+
const cancelDrag = (0, import_react67.useRef)(null);
|
|
18045
|
+
const [preview, setPreview] = (0, import_react67.useState)(null);
|
|
18046
|
+
const syncedDraft = (0, import_react67.useRef)({ open: false, signature: "" });
|
|
18047
|
+
(0, import_react67.useEffect)(() => {
|
|
18038
18048
|
const signature = JSON.stringify(items);
|
|
18039
18049
|
const changed = signature !== syncedDraft.current.signature;
|
|
18040
18050
|
if (open !== syncedDraft.current.open || changed) cancelDrag.current?.();
|
|
@@ -18043,7 +18053,7 @@ function ColumnSettingPanel({
|
|
|
18043
18053
|
}
|
|
18044
18054
|
syncedDraft.current = { open, signature };
|
|
18045
18055
|
}, [items, open]);
|
|
18046
|
-
(0,
|
|
18056
|
+
(0, import_react67.useEffect)(() => () => cancelDrag.current?.(), []);
|
|
18047
18057
|
const labels = new Map(
|
|
18048
18058
|
flattenTableColumns(columns).map((column) => [
|
|
18049
18059
|
column.key,
|
|
@@ -18570,7 +18580,7 @@ function tableExportText(node) {
|
|
|
18570
18580
|
if (typeof node === "string" || typeof node === "number" || typeof node === "bigint")
|
|
18571
18581
|
return String(node);
|
|
18572
18582
|
if (Array.isArray(node)) return node.map(tableExportText).join("");
|
|
18573
|
-
if ((0,
|
|
18583
|
+
if ((0, import_react67.isValidElement)(node))
|
|
18574
18584
|
return tableExportText(node.props.children);
|
|
18575
18585
|
return "";
|
|
18576
18586
|
}
|
|
@@ -18669,7 +18679,7 @@ var SIZE_ROW_HEIGHT = { small: 28, medium: 36, large: 46 };
|
|
|
18669
18679
|
function getHeaderTitleText(content) {
|
|
18670
18680
|
if (typeof content === "string" || typeof content === "number") return String(content);
|
|
18671
18681
|
if (Array.isArray(content)) return content.map(getHeaderTitleText).join("");
|
|
18672
|
-
if ((0,
|
|
18682
|
+
if ((0, import_react68.isValidElement)(content)) return getHeaderTitleText(content.props.children);
|
|
18673
18683
|
return "";
|
|
18674
18684
|
}
|
|
18675
18685
|
function getColumnDepth(columns) {
|
|
@@ -18749,7 +18759,7 @@ function getTableHorizontalMetrics(viewport, table) {
|
|
|
18749
18759
|
const contentWidth = Math.max(viewport.clientWidth, table?.getBoundingClientRect().width ?? viewport.clientWidth);
|
|
18750
18760
|
return { contentWidth, maxLeft: Math.max(0, contentWidth - viewport.clientWidth) };
|
|
18751
18761
|
}
|
|
18752
|
-
var TableBodyRow = (0,
|
|
18762
|
+
var TableBodyRow = (0, import_react68.memo)(function TableBodyRow2({
|
|
18753
18763
|
canvas,
|
|
18754
18764
|
visibleColumns,
|
|
18755
18765
|
row,
|
|
@@ -18777,7 +18787,7 @@ var TableBodyRow = (0, import_react67.memo)(function TableBodyRow2({
|
|
|
18777
18787
|
onCellPointerDown,
|
|
18778
18788
|
onCellPointerMove
|
|
18779
18789
|
}) {
|
|
18780
|
-
const [textColumn, setTextColumn] = (0,
|
|
18790
|
+
const [textColumn, setTextColumn] = (0, import_react68.useState)();
|
|
18781
18791
|
const resizeColumnKey = resize ? columns.find((column) => !getCellProps(column).hidden)?.key : void 0;
|
|
18782
18792
|
return /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(
|
|
18783
18793
|
"tr",
|
|
@@ -18890,42 +18900,42 @@ function TableInner(props, ref) {
|
|
|
18890
18900
|
style,
|
|
18891
18901
|
...htmlProps
|
|
18892
18902
|
} = props;
|
|
18893
|
-
const [localRowHeights, setLocalRowHeights] = (0,
|
|
18894
|
-
const [rowHeightPreview, setRowHeightPreview] = (0,
|
|
18903
|
+
const [localRowHeights, setLocalRowHeights] = (0, import_react68.useState)({});
|
|
18904
|
+
const [rowHeightPreview, setRowHeightPreview] = (0, import_react68.useState)(null);
|
|
18895
18905
|
const configuredRowHeights = rowHeights ?? localRowHeights;
|
|
18896
|
-
const effectiveRowHeights = (0,
|
|
18906
|
+
const effectiveRowHeights = (0, import_react68.useMemo)(() => rowHeightPreview ? { ...configuredRowHeights, [rowHeightPreview.key]: rowHeightPreview.height } : configuredRowHeights, [configuredRowHeights, rowHeightPreview]);
|
|
18897
18907
|
const resizeMin = Math.max(SIZE_ROW_HEIGHT[size], Number.isFinite(minRowHeight) ? minRowHeight : SIZE_ROW_HEIGHT[size]);
|
|
18898
18908
|
const resizeMax = Math.max(resizeMin, Number.isFinite(maxRowHeight) ? maxRowHeight : 480);
|
|
18899
18909
|
const managedRowHeights = rowHeights !== void 0 || rowResizable || Object.keys(localRowHeights).length > 0;
|
|
18900
|
-
const commitRowHeight = (0,
|
|
18910
|
+
const commitRowHeight = (0, import_react68.useCallback)((row, height2) => {
|
|
18901
18911
|
if (rowHeights === void 0) setLocalRowHeights((previous) => ({ ...previous, [String(row.key)]: height2 }));
|
|
18902
18912
|
onRowHeightChange?.(row.record, height2, row.sourceIndex);
|
|
18903
18913
|
}, [rowHeights, onRowHeightChange]);
|
|
18904
|
-
const rootRef = (0,
|
|
18914
|
+
const rootRef = (0, import_react68.useRef)(null);
|
|
18905
18915
|
const remainingHeight = useRemainingHeight(rootRef, height == null && tableHeight == null ? fillRemaining : false);
|
|
18906
|
-
const scrollRef = (0,
|
|
18907
|
-
const cellFocusRequest = (0,
|
|
18908
|
-
const cellGlow = (0,
|
|
18909
|
-
(0,
|
|
18916
|
+
const scrollRef = (0, import_react68.useRef)(null);
|
|
18917
|
+
const cellFocusRequest = (0, import_react68.useRef)(0);
|
|
18918
|
+
const cellGlow = (0, import_react68.useRef)(null);
|
|
18919
|
+
(0, import_react68.useEffect)(() => () => {
|
|
18910
18920
|
cellFocusRequest.current++;
|
|
18911
18921
|
cellGlow.current?.();
|
|
18912
18922
|
}, []);
|
|
18913
|
-
const tableRef = (0,
|
|
18923
|
+
const tableRef = (0, import_react68.useRef)(null);
|
|
18914
18924
|
useScrollbarProximity();
|
|
18915
|
-
const scrollbarDragRef = (0,
|
|
18916
|
-
const [internalLoading, setInternalLoading] = (0,
|
|
18917
|
-
const [scrollTop, setScrollTop] = (0,
|
|
18918
|
-
const [scrollLeft, setScrollLeft] = (0,
|
|
18919
|
-
const [viewportHeight, setViewportHeight] = (0,
|
|
18920
|
-
const [viewportWidth, setViewportWidth] = (0,
|
|
18921
|
-
const [autoColumnWidths, setAutoColumnWidths] = (0,
|
|
18922
|
-
const [resolveRowIdentity] = (0,
|
|
18923
|
-
const getRowKey = (0,
|
|
18924
|
-
const builtInResizePlugin = (0,
|
|
18925
|
-
const builtInHighlightPlugin = (0,
|
|
18926
|
-
const builtInCellSelectionPlugin = (0,
|
|
18927
|
-
const builtInIndexPlugin = (0,
|
|
18928
|
-
const activePlugins = (0,
|
|
18925
|
+
const scrollbarDragRef = (0, import_react68.useRef)(null);
|
|
18926
|
+
const [internalLoading, setInternalLoading] = (0, import_react68.useState)(false);
|
|
18927
|
+
const [scrollTop, setScrollTop] = (0, import_react68.useState)(0);
|
|
18928
|
+
const [scrollLeft, setScrollLeft] = (0, import_react68.useState)(0);
|
|
18929
|
+
const [viewportHeight, setViewportHeight] = (0, import_react68.useState)(420);
|
|
18930
|
+
const [viewportWidth, setViewportWidth] = (0, import_react68.useState)(0);
|
|
18931
|
+
const [autoColumnWidths, setAutoColumnWidths] = (0, import_react68.useState)({});
|
|
18932
|
+
const [resolveRowIdentity] = (0, import_react68.useState)(createRowIdentity);
|
|
18933
|
+
const getRowKey = (0, import_react68.useCallback)((record, index) => resolveRowIdentity(record, index, typeof rowKey === "function" ? rowKey : rowKey == null ? void 0 : String(rowKey)), [rowKey, resolveRowIdentity]);
|
|
18934
|
+
const builtInResizePlugin = (0, import_react68.useMemo)(() => createResizePlugin(), []);
|
|
18935
|
+
const builtInHighlightPlugin = (0, import_react68.useMemo)(() => createHighlightPlugin(), []);
|
|
18936
|
+
const builtInCellSelectionPlugin = (0, import_react68.useMemo)(() => createCellSelectionPlugin(), []);
|
|
18937
|
+
const builtInIndexPlugin = (0, import_react68.useMemo)(() => createIndexPlugin(), []);
|
|
18938
|
+
const activePlugins = (0, import_react68.useMemo)(() => {
|
|
18929
18939
|
const plugins = providedPlugins.filter((plugin) => (resizable || plugin.id !== "resize") && (cellSelection || plugin.id !== "cellSelection") && (showIndex || plugin.id !== "index"));
|
|
18930
18940
|
if (!plugins.some((plugin) => plugin.id === "highlight")) plugins.push(builtInHighlightPlugin);
|
|
18931
18941
|
if (resizable && !plugins.some((plugin) => plugin.id === "resize")) plugins.push(builtInResizePlugin);
|
|
@@ -18933,19 +18943,19 @@ function TableInner(props, ref) {
|
|
|
18933
18943
|
if (showIndex && !plugins.some((plugin) => plugin.id === "index")) plugins.push(builtInIndexPlugin);
|
|
18934
18944
|
return plugins;
|
|
18935
18945
|
}, [builtInHighlightPlugin, builtInResizePlugin, builtInCellSelectionPlugin, builtInIndexPlugin, providedPlugins, resizable, cellSelection, showIndex]);
|
|
18936
|
-
const sortedPlugins = (0,
|
|
18937
|
-
const pluginsByIdRef = (0,
|
|
18946
|
+
const sortedPlugins = (0, import_react68.useMemo)(() => [...activePlugins].sort((a, b) => (a.order ?? 100) - (b.order ?? 100)), [activePlugins]);
|
|
18947
|
+
const pluginsByIdRef = (0, import_react68.useRef)(/* @__PURE__ */ new Map());
|
|
18938
18948
|
pluginsByIdRef.current = new Map(sortedPlugins.map((plugin) => [plugin.id, plugin]));
|
|
18939
|
-
const [pluginStates, setPluginStates] = (0,
|
|
18949
|
+
const [pluginStates, setPluginStates] = (0, import_react68.useState)(() => Object.fromEntries(
|
|
18940
18950
|
sortedPlugins.map((plugin) => [plugin.id, resolveInitialState(plugin)])
|
|
18941
18951
|
));
|
|
18942
|
-
const pluginApisRef = (0,
|
|
18943
|
-
const contextsRef = (0,
|
|
18944
|
-
const mountedPluginsRef = (0,
|
|
18952
|
+
const pluginApisRef = (0, import_react68.useRef)({});
|
|
18953
|
+
const contextsRef = (0, import_react68.useRef)(/* @__PURE__ */ new Map());
|
|
18954
|
+
const mountedPluginsRef = (0, import_react68.useRef)(/* @__PURE__ */ new Map());
|
|
18945
18955
|
const pipeline = { columns: baseColumns, rows: createTableRows(dataSource, getRowKey) };
|
|
18946
18956
|
const nextApis = {};
|
|
18947
18957
|
const contexts = /* @__PURE__ */ new Map();
|
|
18948
|
-
const setPluginState = (0,
|
|
18958
|
+
const setPluginState = (0, import_react68.useCallback)((pluginId, next) => {
|
|
18949
18959
|
setPluginStates((previous) => {
|
|
18950
18960
|
const plugin = pluginsByIdRef.current.get(pluginId);
|
|
18951
18961
|
const previousValue = previous[pluginId] !== void 0 ? previous[pluginId] : plugin ? resolveInitialState(plugin) : void 0;
|
|
@@ -18998,7 +19008,7 @@ function TableInner(props, ref) {
|
|
|
18998
19008
|
});
|
|
18999
19009
|
pluginApisRef.current = nextApis;
|
|
19000
19010
|
contextsRef.current = contexts;
|
|
19001
|
-
(0,
|
|
19011
|
+
(0, import_react68.useEffect)(() => {
|
|
19002
19012
|
const activePlugins2 = new Map(sortedPlugins.map((plugin) => [plugin.id, plugin]));
|
|
19003
19013
|
for (const [pluginId, mounted] of mountedPluginsRef.current) {
|
|
19004
19014
|
if (activePlugins2.get(pluginId) === mounted.plugin) continue;
|
|
@@ -19010,11 +19020,11 @@ function TableInner(props, ref) {
|
|
|
19010
19020
|
mountedPluginsRef.current.set(plugin.id, { plugin, cleanup: plugin.onMount(contextsRef.current.get(plugin.id)) });
|
|
19011
19021
|
}
|
|
19012
19022
|
}, [sortedPlugins]);
|
|
19013
|
-
(0,
|
|
19023
|
+
(0, import_react68.useEffect)(() => () => {
|
|
19014
19024
|
for (const mounted of mountedPluginsRef.current.values()) mounted.cleanup?.();
|
|
19015
19025
|
mountedPluginsRef.current.clear();
|
|
19016
19026
|
}, []);
|
|
19017
|
-
const updateScrollMetrics = (0,
|
|
19027
|
+
const updateScrollMetrics = (0, import_react68.useCallback)(() => {
|
|
19018
19028
|
const root = rootRef.current;
|
|
19019
19029
|
const element = scrollRef.current;
|
|
19020
19030
|
if (!root || !element) return;
|
|
@@ -19054,7 +19064,7 @@ function TableInner(props, ref) {
|
|
|
19054
19064
|
verticalTrackElement?.style.setProperty("--sia-table-scrollbar-y-size", `${verticalThumb}px`);
|
|
19055
19065
|
verticalTrackElement?.style.setProperty("--sia-table-scrollbar-y-position", `${verticalPosition}px`);
|
|
19056
19066
|
}, []);
|
|
19057
|
-
(0,
|
|
19067
|
+
(0, import_react68.useEffect)(() => {
|
|
19058
19068
|
const element = scrollRef.current;
|
|
19059
19069
|
if (!element || typeof ResizeObserver === "undefined") return;
|
|
19060
19070
|
const observer = new ResizeObserver(() => {
|
|
@@ -19067,19 +19077,19 @@ function TableInner(props, ref) {
|
|
|
19067
19077
|
updateScrollMetrics();
|
|
19068
19078
|
return () => observer.disconnect();
|
|
19069
19079
|
}, [updateScrollMetrics]);
|
|
19070
|
-
(0,
|
|
19080
|
+
(0, import_react68.useEffect)(() => {
|
|
19071
19081
|
updateScrollMetrics();
|
|
19072
19082
|
});
|
|
19073
|
-
const orderedColumns = (0,
|
|
19074
|
-
const leafColumns = (0,
|
|
19075
|
-
const headerRows = (0,
|
|
19076
|
-
const measuredCells = (0,
|
|
19083
|
+
const orderedColumns = (0, import_react68.useMemo)(() => sortTableColumnsByFixed(pipeline.columns), [pipeline.columns]);
|
|
19084
|
+
const leafColumns = (0, import_react68.useMemo)(() => flattenTableColumns(orderedColumns), [orderedColumns]);
|
|
19085
|
+
const headerRows = (0, import_react68.useMemo)(() => buildHeaderRows(orderedColumns), [orderedColumns]);
|
|
19086
|
+
const measuredCells = (0, import_react68.useRef)(/* @__PURE__ */ new WeakSet());
|
|
19077
19087
|
const autoWidthSignature = leafColumns.map((column) => `${column.key}:${column.autoWidth}:${resizedWidths[column.key] ?? ""}`).join("|");
|
|
19078
|
-
(0,
|
|
19088
|
+
(0, import_react68.useEffect)(() => {
|
|
19079
19089
|
measuredCells.current = /* @__PURE__ */ new WeakSet();
|
|
19080
19090
|
setAutoColumnWidths({});
|
|
19081
19091
|
}, [dataSource, baseColumns, size, autoWidthSignature]);
|
|
19082
|
-
(0,
|
|
19092
|
+
(0, import_react68.useEffect)(() => {
|
|
19083
19093
|
const autoWidthColumns = leafColumns.filter((column) => column.autoWidth && resizedWidths[column.key] === void 0);
|
|
19084
19094
|
const root = rootRef.current;
|
|
19085
19095
|
if (!root || autoWidthColumns.length === 0) return;
|
|
@@ -19165,7 +19175,7 @@ function TableInner(props, ref) {
|
|
|
19165
19175
|
}
|
|
19166
19176
|
const topSpacer = shouldVirtualize ? rowLayout.offsets[startIndex] : 0;
|
|
19167
19177
|
const bottomSpacer = shouldVirtualize ? rowLayout.total - rowLayout.offsets[endIndex] : 0;
|
|
19168
|
-
const rowElements = (0,
|
|
19178
|
+
const rowElements = (0, import_react68.useMemo)(() => /* @__PURE__ */ new Map(), [
|
|
19169
19179
|
dataSource,
|
|
19170
19180
|
baseColumns,
|
|
19171
19181
|
sortedPlugins,
|
|
@@ -19191,20 +19201,20 @@ function TableInner(props, ref) {
|
|
|
19191
19201
|
]);
|
|
19192
19202
|
const toolbarStart = sortedPlugins.map((plugin) => {
|
|
19193
19203
|
const content = plugin.renderToolbarStart?.(getContext(plugin));
|
|
19194
|
-
return content ? /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(
|
|
19204
|
+
return content ? /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(import_react68.Fragment, { children: content }, `toolbar-start-${plugin.id}`) : null;
|
|
19195
19205
|
}).filter(Boolean);
|
|
19196
19206
|
const toolbarEnd = sortedPlugins.map((plugin) => {
|
|
19197
19207
|
const content = plugin.renderToolbarEnd?.(getContext(plugin));
|
|
19198
|
-
return content ? /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(
|
|
19208
|
+
return content ? /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(import_react68.Fragment, { children: content }, `toolbar-end-${plugin.id}`) : null;
|
|
19199
19209
|
}).filter(Boolean);
|
|
19200
19210
|
const summaries = sortedPlugins.flatMap((plugin) => plugin.renderSummary?.(getContext(plugin)) ?? []);
|
|
19201
19211
|
const footers = sortedPlugins.map((plugin) => {
|
|
19202
19212
|
const content = plugin.renderFooter?.(getContext(plugin));
|
|
19203
|
-
return content ? /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(
|
|
19213
|
+
return content ? /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(import_react68.Fragment, { children: content }, `footer-${plugin.id}`) : null;
|
|
19204
19214
|
}).filter(Boolean);
|
|
19205
19215
|
const overlays = sortedPlugins.map((plugin) => {
|
|
19206
19216
|
const content = plugin.renderOverlay?.(getContext(plugin));
|
|
19207
|
-
return content ? /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(
|
|
19217
|
+
return content ? /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(import_react68.Fragment, { children: content }, `overlay-${plugin.id}`) : null;
|
|
19208
19218
|
}).filter(Boolean);
|
|
19209
19219
|
const hasToolbar = toolbarStart.length > 0 || toolbarEnd.length > 0;
|
|
19210
19220
|
const effectiveHeight = height ?? tableHeight ?? remainingHeight ?? (shouldVirtualize && maxBodyHeight == null ? 420 : void 0);
|
|
@@ -19218,13 +19228,13 @@ function TableInner(props, ref) {
|
|
|
19218
19228
|
// 空态占位只覆盖内容区,必须给仍有业务意义的合计行留出空间。
|
|
19219
19229
|
"--sia-table-summary-height": `${summaries.length * rowHeight}px`
|
|
19220
19230
|
};
|
|
19221
|
-
const handleScroll = (0,
|
|
19231
|
+
const handleScroll = (0, import_react68.useCallback)((event) => {
|
|
19222
19232
|
const element = event.currentTarget;
|
|
19223
19233
|
if (shouldVirtualize) setScrollTop((previous) => managedRowHeights || Math.floor(previous / rowHeight) !== Math.floor(element.scrollTop / rowHeight) ? element.scrollTop : previous);
|
|
19224
19234
|
if (canvas) setScrollLeft(element.scrollLeft);
|
|
19225
19235
|
updateScrollMetrics();
|
|
19226
19236
|
}, [canvas, shouldVirtualize, rowHeight, managedRowHeights, updateScrollMetrics]);
|
|
19227
|
-
const handleScrollbarPointerDown = (0,
|
|
19237
|
+
const handleScrollbarPointerDown = (0, import_react68.useCallback)((axis, event, track = event.currentTarget) => {
|
|
19228
19238
|
const element = scrollRef.current;
|
|
19229
19239
|
const thumb = track.firstElementChild;
|
|
19230
19240
|
if (!element || !thumb || event.button !== 0) return;
|
|
@@ -19253,7 +19263,7 @@ function TableInner(props, ref) {
|
|
|
19253
19263
|
};
|
|
19254
19264
|
if (rootRef.current) rootRef.current.dataset.scrollbarDragging = "true";
|
|
19255
19265
|
}, []);
|
|
19256
|
-
const handleScrollbarPointerMove = (0,
|
|
19266
|
+
const handleScrollbarPointerMove = (0, import_react68.useCallback)((event) => {
|
|
19257
19267
|
const drag = scrollbarDragRef.current;
|
|
19258
19268
|
const element = scrollRef.current;
|
|
19259
19269
|
if (!drag || !element || drag.pointerId !== event.pointerId) return;
|
|
@@ -19262,12 +19272,12 @@ function TableInner(props, ref) {
|
|
|
19262
19272
|
if (drag.axis === "x") element.scrollLeft = nextScroll;
|
|
19263
19273
|
else element.scrollTop = nextScroll;
|
|
19264
19274
|
}, []);
|
|
19265
|
-
const handleScrollbarPointerEnd = (0,
|
|
19275
|
+
const handleScrollbarPointerEnd = (0, import_react68.useCallback)((event) => {
|
|
19266
19276
|
if (scrollbarDragRef.current?.pointerId !== event.pointerId) return;
|
|
19267
19277
|
scrollbarDragRef.current = null;
|
|
19268
19278
|
if (rootRef.current) rootRef.current.dataset.scrollbarDragging = "false";
|
|
19269
19279
|
}, []);
|
|
19270
|
-
(0,
|
|
19280
|
+
(0, import_react68.useImperativeHandle)(ref, () => {
|
|
19271
19281
|
const api = {
|
|
19272
19282
|
getRows: () => pipeline.rows.map((row) => row.record),
|
|
19273
19283
|
getColumns: () => pipeline.columns,
|
|
@@ -19636,7 +19646,7 @@ function TableInner(props, ref) {
|
|
|
19636
19646
|
}
|
|
19637
19647
|
);
|
|
19638
19648
|
}
|
|
19639
|
-
var Table2 = (0,
|
|
19649
|
+
var Table2 = (0, import_react68.forwardRef)(TableInner);
|
|
19640
19650
|
|
|
19641
19651
|
// src/components/Table/worksheetModel.ts
|
|
19642
19652
|
function parseWorksheetText(text) {
|
|
@@ -20315,7 +20325,7 @@ function Breadcrumb({ items, separator = "/", itemRender, className = "", ...pro
|
|
|
20315
20325
|
}
|
|
20316
20326
|
|
|
20317
20327
|
// src/components/Typography.tsx
|
|
20318
|
-
var
|
|
20328
|
+
var import_react69 = require("react");
|
|
20319
20329
|
var import_jsx_runtime66 = require("react/jsx-runtime");
|
|
20320
20330
|
function TypographyContent({
|
|
20321
20331
|
as: Tag2 = "span",
|
|
@@ -20335,26 +20345,26 @@ function TypographyContent({
|
|
|
20335
20345
|
className = "",
|
|
20336
20346
|
...props
|
|
20337
20347
|
}) {
|
|
20338
|
-
const contentRef = (0,
|
|
20339
|
-
const editRef = (0,
|
|
20340
|
-
const timer = (0,
|
|
20341
|
-
const [localText, setLocalText] = (0,
|
|
20342
|
-
const [draft, setDraft] = (0,
|
|
20343
|
-
const [editing, setEditing] = (0,
|
|
20344
|
-
const [copied, setCopied] = (0,
|
|
20345
|
-
const [copyError, setCopyError] = (0,
|
|
20346
|
-
const [expanded, setExpanded] = (0,
|
|
20347
|
-
const [overflow, setOverflow] = (0,
|
|
20348
|
+
const contentRef = (0, import_react69.useRef)(null);
|
|
20349
|
+
const editRef = (0, import_react69.useRef)(null);
|
|
20350
|
+
const timer = (0, import_react69.useRef)();
|
|
20351
|
+
const [localText, setLocalText] = (0, import_react69.useState)();
|
|
20352
|
+
const [draft, setDraft] = (0, import_react69.useState)("");
|
|
20353
|
+
const [editing, setEditing] = (0, import_react69.useState)(false);
|
|
20354
|
+
const [copied, setCopied] = (0, import_react69.useState)(false);
|
|
20355
|
+
const [copyError, setCopyError] = (0, import_react69.useState)(false);
|
|
20356
|
+
const [expanded, setExpanded] = (0, import_react69.useState)(false);
|
|
20357
|
+
const [overflow, setOverflow] = (0, import_react69.useState)(false);
|
|
20348
20358
|
const editConfig = typeof editable === "object" ? editable : void 0;
|
|
20349
20359
|
const content = editConfig?.text ?? localText ?? children;
|
|
20350
20360
|
const requestedRows = typeof ellipsis === "object" ? ellipsis.rows ?? 1 : 1;
|
|
20351
20361
|
const rows = Number.isFinite(requestedRows) ? Math.max(1, Math.floor(requestedRows)) : 1;
|
|
20352
20362
|
const expandable = typeof ellipsis === "object" && ellipsis.expandable;
|
|
20353
|
-
(0,
|
|
20363
|
+
(0, import_react69.useEffect)(() => {
|
|
20354
20364
|
setLocalText(void 0);
|
|
20355
20365
|
}, [children]);
|
|
20356
|
-
(0,
|
|
20357
|
-
(0,
|
|
20366
|
+
(0, import_react69.useEffect)(() => () => clearTimeout(timer.current), []);
|
|
20367
|
+
(0, import_react69.useLayoutEffect)(() => {
|
|
20358
20368
|
const element = contentRef.current;
|
|
20359
20369
|
if (!element || !ellipsis || !expandable || editing || expanded) return;
|
|
20360
20370
|
const measure = () => setOverflow(element.scrollHeight > element.clientHeight + 1 || element.scrollWidth > element.clientWidth + 1);
|
|
@@ -20472,17 +20482,17 @@ var Typography = Object.assign(TypographyRoot, {
|
|
|
20472
20482
|
});
|
|
20473
20483
|
|
|
20474
20484
|
// src/components/Video.tsx
|
|
20475
|
-
var
|
|
20485
|
+
var import_react70 = require("react");
|
|
20476
20486
|
var import_jsx_runtime67 = require("react/jsx-runtime");
|
|
20477
|
-
var Video = (0,
|
|
20487
|
+
var Video = (0, import_react70.forwardRef)(function Video2({ controls = true, muted = false, playsInline = true, className = "", ...props }, ref) {
|
|
20478
20488
|
return /* @__PURE__ */ (0, import_jsx_runtime67.jsx)("video", { ...props, ref, controls, muted, playsInline, className: `sia-video ${className}`.trim() });
|
|
20479
20489
|
});
|
|
20480
20490
|
|
|
20481
20491
|
// src/components/FloatButton.tsx
|
|
20482
|
-
var
|
|
20492
|
+
var import_react71 = require("react");
|
|
20483
20493
|
var import_jsx_runtime68 = require("react/jsx-runtime");
|
|
20484
|
-
var GroupShape = (0,
|
|
20485
|
-
var FloatButtonRoot = (0,
|
|
20494
|
+
var GroupShape = (0, import_react71.createContext)(void 0);
|
|
20495
|
+
var FloatButtonRoot = (0, import_react71.forwardRef)(function FloatButton({
|
|
20486
20496
|
icon,
|
|
20487
20497
|
description,
|
|
20488
20498
|
tooltip,
|
|
@@ -20495,7 +20505,7 @@ var FloatButtonRoot = (0, import_react70.forwardRef)(function FloatButton({
|
|
|
20495
20505
|
children,
|
|
20496
20506
|
...props
|
|
20497
20507
|
}, ref) {
|
|
20498
|
-
const groupShape = (0,
|
|
20508
|
+
const groupShape = (0, import_react71.useContext)(GroupShape);
|
|
20499
20509
|
const label = props["aria-label"] ?? (typeof tooltip === "string" ? tooltip : typeof description === "string" ? description : "\u60AC\u6D6E\u64CD\u4F5C");
|
|
20500
20510
|
const button = /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(
|
|
20501
20511
|
"button",
|
|
@@ -20533,12 +20543,12 @@ function FloatButtonGroup({
|
|
|
20533
20543
|
...props
|
|
20534
20544
|
}) {
|
|
20535
20545
|
const [visible, setVisible] = useControllableState({ value: open, defaultValue: defaultOpen, onChange: onOpenChange });
|
|
20536
|
-
const rootRef = (0,
|
|
20537
|
-
const triggerRef = (0,
|
|
20538
|
-
const listRef = (0,
|
|
20546
|
+
const rootRef = (0, import_react71.useRef)(null);
|
|
20547
|
+
const triggerRef = (0, import_react71.useRef)(null);
|
|
20548
|
+
const listRef = (0, import_react71.useRef)(null);
|
|
20539
20549
|
const motion = useOverlayMotion(!trigger || visible, listRef, "popup", placement, true, void 0, !!trigger);
|
|
20540
|
-
const id = (0,
|
|
20541
|
-
(0,
|
|
20550
|
+
const id = (0, import_react71.useId)();
|
|
20551
|
+
(0, import_react71.useEffect)(() => {
|
|
20542
20552
|
if (!trigger || !visible) return;
|
|
20543
20553
|
const close = (event) => {
|
|
20544
20554
|
if (!rootRef.current?.contains(event.target)) setVisible(false);
|
|
@@ -20592,10 +20602,10 @@ function FloatButtonGroup({
|
|
|
20592
20602
|
) });
|
|
20593
20603
|
}
|
|
20594
20604
|
function FloatButtonBackTop({ target, visibilityHeight = 400, behavior = "smooth", onClick, icon, tooltip = "\u8FD4\u56DE\u9876\u90E8", ...props }) {
|
|
20595
|
-
const [visible, setVisible] = (0,
|
|
20596
|
-
const buttonRef = (0,
|
|
20605
|
+
const [visible, setVisible] = (0, import_react71.useState)(false);
|
|
20606
|
+
const buttonRef = (0, import_react71.useRef)(null);
|
|
20597
20607
|
const motion = useOverlayMotion(visible, buttonRef, "fade");
|
|
20598
|
-
(0,
|
|
20608
|
+
(0, import_react71.useEffect)(() => {
|
|
20599
20609
|
const element = target ? target() : window;
|
|
20600
20610
|
if (!element) return;
|
|
20601
20611
|
const update = () => setVisible((element === window ? window.scrollY : element.scrollTop) >= visibilityHeight);
|
|
@@ -20619,11 +20629,11 @@ var FloatButton2 = Object.assign(FloatButtonRoot, {
|
|
|
20619
20629
|
});
|
|
20620
20630
|
|
|
20621
20631
|
// src/components/ChartWhirlingLoading.tsx
|
|
20622
|
-
var
|
|
20632
|
+
var import_react72 = require("react");
|
|
20623
20633
|
var import_jsx_runtime69 = require("react/jsx-runtime");
|
|
20624
20634
|
function ChartWhirlingLoading({ width = 720, height = 360, text = "\u6570\u636E\u83B7\u53D6\u4E2D", textWidth, frame }) {
|
|
20625
|
-
const [tick, setTick] = (0,
|
|
20626
|
-
(0,
|
|
20635
|
+
const [tick, setTick] = (0, import_react72.useState)(0);
|
|
20636
|
+
(0, import_react72.useEffect)(() => {
|
|
20627
20637
|
if (frame != null) return;
|
|
20628
20638
|
const media = window.matchMedia("(prefers-reduced-motion: reduce)");
|
|
20629
20639
|
let timer;
|
|
@@ -20654,20 +20664,20 @@ function ChartWhirlingLoading({ width = 720, height = 360, text = "\u6570\u636E\
|
|
|
20654
20664
|
}
|
|
20655
20665
|
|
|
20656
20666
|
// src/components/SvgMapPlot.tsx
|
|
20657
|
-
var
|
|
20667
|
+
var import_react84 = require("react");
|
|
20658
20668
|
|
|
20659
20669
|
// src/components/ChartBrush.tsx
|
|
20660
|
-
var
|
|
20670
|
+
var import_react73 = require("react");
|
|
20661
20671
|
var import_jsx_runtime70 = require("react/jsx-runtime");
|
|
20662
20672
|
function ChartBrush({ bounds, onSelect, onCancel, selectionShape = "band", selectionStyle, minSelectionSize }) {
|
|
20663
|
-
const [vertical, setVertical] = (0,
|
|
20664
|
-
const startY = (0,
|
|
20673
|
+
const [vertical, setVertical] = (0, import_react73.useState)(null);
|
|
20674
|
+
const startY = (0, import_react73.useRef)(0);
|
|
20665
20675
|
const y = (event) => {
|
|
20666
20676
|
const matrix = event.currentTarget.ownerSVGElement?.getScreenCTM();
|
|
20667
20677
|
return matrix ? Math.max(bounds.y, Math.min(bounds.y + bounds.height, new DOMPoint(event.clientX, event.clientY).matrixTransform(matrix.inverse()).y)) : bounds.y;
|
|
20668
20678
|
};
|
|
20669
|
-
const drag = (0,
|
|
20670
|
-
const [selection, setSelection] = (0,
|
|
20679
|
+
const drag = (0, import_react73.useRef)(null);
|
|
20680
|
+
const [selection, setSelection] = (0, import_react73.useState)(null);
|
|
20671
20681
|
const x = (event) => {
|
|
20672
20682
|
const matrix = event.currentTarget.ownerSVGElement?.getScreenCTM();
|
|
20673
20683
|
if (!matrix) return null;
|
|
@@ -20790,7 +20800,7 @@ function appendChartExportHeadings(original, clone, host) {
|
|
|
20790
20800
|
}
|
|
20791
20801
|
|
|
20792
20802
|
// src/components/ChartNodeTimeline.tsx
|
|
20793
|
-
var
|
|
20803
|
+
var import_react75 = require("react");
|
|
20794
20804
|
|
|
20795
20805
|
// src/components/timelinePositions.ts
|
|
20796
20806
|
function timelineRatios(count, dates) {
|
|
@@ -20816,7 +20826,7 @@ function nearestTimelineIndex(ratios, ratio) {
|
|
|
20816
20826
|
}
|
|
20817
20827
|
|
|
20818
20828
|
// src/components/ChartPointMotion.tsx
|
|
20819
|
-
var
|
|
20829
|
+
var import_react74 = require("react");
|
|
20820
20830
|
|
|
20821
20831
|
// src/components/chartMotion.ts
|
|
20822
20832
|
function chartMotionBaseline(points, horizontal = false) {
|
|
@@ -20837,11 +20847,11 @@ function interpolateChartPoints(from, to, progress) {
|
|
|
20837
20847
|
var import_jsx_runtime71 = require("react/jsx-runtime");
|
|
20838
20848
|
function ChartPointMotion({ points, enabled, duration, updateDuration = 500, animateInitial = true, easing = "linear", progress, horizontal = false, origin, children }) {
|
|
20839
20849
|
const baseline = (target) => origin ? target.map(() => origin) : chartMotionBaseline(target, horizontal);
|
|
20840
|
-
const [frame, setFrame] = (0,
|
|
20841
|
-
const displayed = (0,
|
|
20842
|
-
const initialized = (0,
|
|
20850
|
+
const [frame, setFrame] = (0, import_react74.useState)(() => enabled && animateInitial ? baseline(points) : points);
|
|
20851
|
+
const displayed = (0, import_react74.useRef)(frame);
|
|
20852
|
+
const initialized = (0, import_react74.useRef)(!animateInitial);
|
|
20843
20853
|
const signature = JSON.stringify(points);
|
|
20844
|
-
(0,
|
|
20854
|
+
(0, import_react74.useEffect)(() => {
|
|
20845
20855
|
const target = points;
|
|
20846
20856
|
const reduced = window.matchMedia("(prefers-reduced-motion: reduce)");
|
|
20847
20857
|
if (!enabled || progress != null || reduced.matches) {
|
|
@@ -20880,8 +20890,8 @@ function ChartPointMotion({ points, enabled, duration, updateDuration = 500, ani
|
|
|
20880
20890
|
// src/components/ChartNodeTimeline.tsx
|
|
20881
20891
|
var import_jsx_runtime72 = require("react/jsx-runtime");
|
|
20882
20892
|
function ChartNodeTimeline({ labels, dates, value, onChange, autoPlay = false, playInterval = 2e3, loop = true, x = 80, y = 520, width = 840 }) {
|
|
20883
|
-
const [playing, setPlaying] = (0,
|
|
20884
|
-
const [draft, setDraft] = (0,
|
|
20893
|
+
const [playing, setPlaying] = (0, import_react75.useState)(autoPlay), dragging = (0, import_react75.useRef)();
|
|
20894
|
+
const [draft, setDraft] = (0, import_react75.useState)(), pending = (0, import_react75.useRef)(), draftRef = (0, import_react75.useRef)();
|
|
20885
20895
|
const shown = draft ?? value;
|
|
20886
20896
|
const cancelPending = () => {
|
|
20887
20897
|
clearTimeout(pending.current);
|
|
@@ -20889,8 +20899,8 @@ function ChartNodeTimeline({ labels, dates, value, onChange, autoPlay = false, p
|
|
|
20889
20899
|
draftRef.current = void 0;
|
|
20890
20900
|
setDraft(void 0);
|
|
20891
20901
|
};
|
|
20892
|
-
(0,
|
|
20893
|
-
(0,
|
|
20902
|
+
(0, import_react75.useEffect)(() => () => clearTimeout(pending.current), []);
|
|
20903
|
+
(0, import_react75.useEffect)(() => {
|
|
20894
20904
|
cancelPending();
|
|
20895
20905
|
}, [value]);
|
|
20896
20906
|
const preview = (index) => {
|
|
@@ -20905,8 +20915,8 @@ function ChartNodeTimeline({ labels, dates, value, onChange, autoPlay = false, p
|
|
|
20905
20915
|
draftRef.current = void 0;
|
|
20906
20916
|
}, 200);
|
|
20907
20917
|
};
|
|
20908
|
-
(0,
|
|
20909
|
-
(0,
|
|
20918
|
+
(0, import_react75.useEffect)(() => setPlaying(autoPlay), [autoPlay]);
|
|
20919
|
+
(0, import_react75.useEffect)(() => {
|
|
20910
20920
|
if (!playing || labels.length < 2) return;
|
|
20911
20921
|
const timer = window.setTimeout(() => {
|
|
20912
20922
|
if (value + 1 < labels.length) onChange(value + 1);
|
|
@@ -21015,7 +21025,7 @@ function ChartNodeTimeline({ labels, dates, value, onChange, autoPlay = false, p
|
|
|
21015
21025
|
}
|
|
21016
21026
|
|
|
21017
21027
|
// src/components/ChartVerticalRange.tsx
|
|
21018
|
-
var
|
|
21028
|
+
var import_react76 = require("react");
|
|
21019
21029
|
|
|
21020
21030
|
// src/components/chartColorRamp.ts
|
|
21021
21031
|
function chartColorRamp(colors, ratio) {
|
|
@@ -21035,16 +21045,16 @@ function chartColorRamp(colors, ratio) {
|
|
|
21035
21045
|
// src/components/ChartVerticalRange.tsx
|
|
21036
21046
|
var import_jsx_runtime73 = require("react/jsx-runtime");
|
|
21037
21047
|
function ChartVerticalRange({ min, max, x, y, length, thickness, colors, range, endLabels, onChange, indicatorValue, onHoverRange, realtime = true, readOnly = false }) {
|
|
21038
|
-
const id = (0,
|
|
21039
|
-
const drag = (0,
|
|
21040
|
-
const [draft, setDraft] = (0,
|
|
21041
|
-
const pending = (0,
|
|
21048
|
+
const id = (0, import_react76.useId)().replaceAll(":", "");
|
|
21049
|
+
const drag = (0, import_react76.useRef)();
|
|
21050
|
+
const [draft, setDraft] = (0, import_react76.useState)();
|
|
21051
|
+
const pending = (0, import_react76.useRef)();
|
|
21042
21052
|
const cancel = () => {
|
|
21043
21053
|
drag.current = void 0;
|
|
21044
21054
|
pending.current = void 0;
|
|
21045
21055
|
setDraft(void 0);
|
|
21046
21056
|
};
|
|
21047
|
-
(0,
|
|
21057
|
+
(0, import_react76.useEffect)(() => {
|
|
21048
21058
|
if (!realtime) cancel();
|
|
21049
21059
|
}, [range[0], range[1], min, max, realtime]);
|
|
21050
21060
|
const shown = draft ?? range;
|
|
@@ -21125,18 +21135,18 @@ function ChartVerticalRange({ min, max, x, y, length, thickness, colors, range,
|
|
|
21125
21135
|
}
|
|
21126
21136
|
|
|
21127
21137
|
// src/components/ChartHorizontalRange.tsx
|
|
21128
|
-
var
|
|
21138
|
+
var import_react77 = require("react");
|
|
21129
21139
|
var import_jsx_runtime74 = require("react/jsx-runtime");
|
|
21130
21140
|
function ChartHorizontalRange({ min, max, x, y, length, thickness, colors, range, endLabels, onChange, indicatorValue, onHoverRange, realtime = true }) {
|
|
21131
|
-
const id = (0,
|
|
21132
|
-
const drag = (0,
|
|
21133
|
-
const [draft, setDraft] = (0,
|
|
21141
|
+
const id = (0, import_react77.useId)().replaceAll(":", ""), span = max - min;
|
|
21142
|
+
const drag = (0, import_react77.useRef)();
|
|
21143
|
+
const [draft, setDraft] = (0, import_react77.useState)(), pending = (0, import_react77.useRef)();
|
|
21134
21144
|
const cancel = () => {
|
|
21135
21145
|
drag.current = void 0;
|
|
21136
21146
|
pending.current = void 0;
|
|
21137
21147
|
setDraft(void 0);
|
|
21138
21148
|
};
|
|
21139
|
-
(0,
|
|
21149
|
+
(0, import_react77.useEffect)(() => {
|
|
21140
21150
|
if (!realtime) cancel();
|
|
21141
21151
|
}, [range[0], range[1], min, max, realtime]);
|
|
21142
21152
|
const shown = draft ?? range, low = Math.max(min, Math.min(max, shown[0])), high = Math.max(low, Math.min(max, shown[1]));
|
|
@@ -21214,7 +21224,7 @@ function ChartHorizontalRange({ min, max, x, y, length, thickness, colors, range
|
|
|
21214
21224
|
}
|
|
21215
21225
|
|
|
21216
21226
|
// src/components/Chart.tsx
|
|
21217
|
-
var
|
|
21227
|
+
var import_react78 = require("react");
|
|
21218
21228
|
|
|
21219
21229
|
// src/components/chartCompositeExport.ts
|
|
21220
21230
|
function serializeChartComposite(host) {
|
|
@@ -21338,20 +21348,20 @@ var DEFAULT_CHART_PALETTE = [
|
|
|
21338
21348
|
"#2f54eb",
|
|
21339
21349
|
"#a0d911"
|
|
21340
21350
|
];
|
|
21341
|
-
var ChartContext = (0,
|
|
21351
|
+
var ChartContext = (0, import_react78.createContext)(null);
|
|
21342
21352
|
function toCssSize(value, fallback) {
|
|
21343
21353
|
if (typeof value === "number") return `${value}px`;
|
|
21344
21354
|
return value ?? fallback;
|
|
21345
21355
|
}
|
|
21346
|
-
var ChartComposite = (0,
|
|
21347
|
-
const host = (0,
|
|
21348
|
-
(0,
|
|
21356
|
+
var ChartComposite = (0, import_react78.forwardRef)(function ChartComposite2({ layers, width = "100%", height = 320, ariaLabel = "\u7EC4\u5408\u56FE\u8868", className = "", style, ...props }, ref) {
|
|
21357
|
+
const host = (0, import_react78.useRef)(null);
|
|
21358
|
+
(0, import_react78.useImperativeHandle)(ref, () => ({ toSvgString: () => host.current ? serializeChartComposite(host.current) : null, saveAsImage: (filename) => saveCompositeImage(host.current ? serializeChartComposite(host.current) : null, filename) }), []);
|
|
21349
21359
|
return /* @__PURE__ */ (0, import_jsx_runtime75.jsx)("div", { ...withTitleTooltip(props), ref: host, className: `sia-chart-composite${className ? ` ${className}` : ""}`, style: { ...style, width: toCssSize(width, "100%"), height: toCssSize(height, "320px") }, role: "group", "aria-label": ariaLabel, children: layers.map((layer, index) => /* @__PURE__ */ (0, import_jsx_runtime75.jsx)("div", { className: "sia-chart-composite__layer", style: { left: layer.left ?? 0, top: layer.top ?? 0, width: layer.width ?? "100%", height: layer.height ?? "100%", zIndex: layer.zIndex ?? index, pointerEvents: layer.pointerEvents }, children: layer.content }, layer.key ?? index)) });
|
|
21350
21360
|
});
|
|
21351
|
-
var useTooltipLayoutEffect = typeof window === "undefined" ?
|
|
21361
|
+
var useTooltipLayoutEffect = typeof window === "undefined" ? import_react78.useEffect : import_react78.useLayoutEffect;
|
|
21352
21362
|
function ChartTooltip({ open, left, top, children, enterable = false, inheritTextStyle = false, placement = "above", className = "", style, ...props }) {
|
|
21353
|
-
const elementRef = (0,
|
|
21354
|
-
const [position, setPosition] = (0,
|
|
21363
|
+
const elementRef = (0, import_react78.useRef)(null);
|
|
21364
|
+
const [position, setPosition] = (0, import_react78.useState)([left, top]);
|
|
21355
21365
|
useTooltipLayoutEffect(() => {
|
|
21356
21366
|
const element = elementRef.current, host = element?.parentElement;
|
|
21357
21367
|
if (!open || placement !== "axis" || !element || !host) return;
|
|
@@ -21475,7 +21485,7 @@ function ChartToolbox({
|
|
|
21475
21485
|
))
|
|
21476
21486
|
] });
|
|
21477
21487
|
}
|
|
21478
|
-
var SiaChart = (0,
|
|
21488
|
+
var SiaChart = (0, import_react78.forwardRef)(function SiaChart2({
|
|
21479
21489
|
children,
|
|
21480
21490
|
width = "100%",
|
|
21481
21491
|
height = 320,
|
|
@@ -21502,19 +21512,19 @@ var SiaChart = (0, import_react77.forwardRef)(function SiaChart2({
|
|
|
21502
21512
|
style,
|
|
21503
21513
|
...rest
|
|
21504
21514
|
}, ref) {
|
|
21505
|
-
const hostRef = (0,
|
|
21506
|
-
const svgRef = (0,
|
|
21507
|
-
const titleId = (0,
|
|
21508
|
-
const descriptionId = (0,
|
|
21509
|
-
const [tooltip, setTooltip] = (0,
|
|
21510
|
-
const tooltipHideTimer = (0,
|
|
21511
|
-
const tooltipHeld = (0,
|
|
21515
|
+
const hostRef = (0, import_react78.useRef)(null);
|
|
21516
|
+
const svgRef = (0, import_react78.useRef)(null);
|
|
21517
|
+
const titleId = (0, import_react78.useId)();
|
|
21518
|
+
const descriptionId = (0, import_react78.useId)();
|
|
21519
|
+
const [tooltip, setTooltip] = (0, import_react78.useState)(null);
|
|
21520
|
+
const tooltipHideTimer = (0, import_react78.useRef)();
|
|
21521
|
+
const tooltipHeld = (0, import_react78.useRef)(false);
|
|
21512
21522
|
const cancelTooltipHide = () => {
|
|
21513
21523
|
clearTimeout(tooltipHideTimer.current);
|
|
21514
21524
|
};
|
|
21515
|
-
(0,
|
|
21516
|
-
const [linkedPosition, setLinkedPosition] = (0,
|
|
21517
|
-
(0,
|
|
21525
|
+
(0, import_react78.useEffect)(() => () => clearTimeout(tooltipHideTimer.current), []);
|
|
21526
|
+
const [linkedPosition, setLinkedPosition] = (0, import_react78.useState)({ left: 0, top: 0 });
|
|
21527
|
+
(0, import_react78.useEffect)(() => {
|
|
21518
21528
|
const host = hostRef.current, svg = svgRef.current;
|
|
21519
21529
|
if (!controlledTooltip || !host || !svg) return;
|
|
21520
21530
|
const position = () => {
|
|
@@ -21529,12 +21539,12 @@ var SiaChart = (0, import_react77.forwardRef)(function SiaChart2({
|
|
|
21529
21539
|
observer.observe(host);
|
|
21530
21540
|
return () => observer.disconnect();
|
|
21531
21541
|
}, [controlledTooltip]);
|
|
21532
|
-
const [dataViewOpen, setDataViewOpen] = (0,
|
|
21533
|
-
const [markMode, setMarkMode] = (0,
|
|
21534
|
-
const [markStart, setMarkStart] = (0,
|
|
21535
|
-
const [userMarks, setUserMarks] = (0,
|
|
21542
|
+
const [dataViewOpen, setDataViewOpen] = (0, import_react78.useState)(false);
|
|
21543
|
+
const [markMode, setMarkMode] = (0, import_react78.useState)(false);
|
|
21544
|
+
const [markStart, setMarkStart] = (0, import_react78.useState)(null);
|
|
21545
|
+
const [userMarks, setUserMarks] = (0, import_react78.useState)([]);
|
|
21536
21546
|
const toolboxOptions = toolbox === true ? {} : toolbox || void 0;
|
|
21537
|
-
const rootStyle = (0,
|
|
21547
|
+
const rootStyle = (0, import_react78.useMemo)(() => ({
|
|
21538
21548
|
...style,
|
|
21539
21549
|
width: toCssSize(width, "100%"),
|
|
21540
21550
|
height: toCssSize(height, "320px"),
|
|
@@ -21592,13 +21602,13 @@ var SiaChart = (0, import_react77.forwardRef)(function SiaChart2({
|
|
|
21592
21602
|
anchor.href = canvas.toDataURL("image/png");
|
|
21593
21603
|
anchor.click();
|
|
21594
21604
|
}
|
|
21595
|
-
(0,
|
|
21605
|
+
(0, import_react78.useImperativeHandle)(ref, () => ({
|
|
21596
21606
|
getElement: () => svgRef.current,
|
|
21597
21607
|
focus: () => svgRef.current?.focus(),
|
|
21598
21608
|
toSvgString: serializeSvg,
|
|
21599
21609
|
toDataUrl: svgDataUrl
|
|
21600
21610
|
}), []);
|
|
21601
|
-
const context = (0,
|
|
21611
|
+
const context = (0, import_react78.useMemo)(() => ({
|
|
21602
21612
|
palette,
|
|
21603
21613
|
showTooltip: (event, content, point) => {
|
|
21604
21614
|
cancelTooltipHide();
|
|
@@ -21785,7 +21795,7 @@ var SiaChart = (0, import_react77.forwardRef)(function SiaChart2({
|
|
|
21785
21795
|
) });
|
|
21786
21796
|
});
|
|
21787
21797
|
function ChartMark({ tooltip, tooltipPoint, label, onPointerMove, onPointerLeave, onFocus, onBlur, ...props }) {
|
|
21788
|
-
const context = (0,
|
|
21798
|
+
const context = (0, import_react78.useContext)(ChartContext);
|
|
21789
21799
|
return /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(
|
|
21790
21800
|
"g",
|
|
21791
21801
|
{
|
|
@@ -21814,7 +21824,7 @@ function ChartMark({ tooltip, tooltipPoint, label, onPointerMove, onPointerLeave
|
|
|
21814
21824
|
);
|
|
21815
21825
|
}
|
|
21816
21826
|
function ChartLegend({ items, symbol = "rect", x = CHART_VIEWBOX_WIDTH / 2, y = 20, align = "center", itemGap = 18, orientation = "horizontal", selected, onItemClick, maxWidth, rowGap = 24, iconWidth, iconHeight = 14, textGap = 5, textStyle, inactiveColor, background }) {
|
|
21817
|
-
const paintId = (0,
|
|
21827
|
+
const paintId = (0, import_react78.useId)().replaceAll(":", "");
|
|
21818
21828
|
const widths = items.map((item) => (iconWidth == null ? 18 : iconWidth + textGap) + (item.textWidth ?? Math.max(30, Array.from(item.name).reduce((width, character) => width + (character.charCodeAt(0) > 255 ? 13 : 7), 0))));
|
|
21819
21829
|
const totalWidth = orientation === "horizontal" ? widths.reduce((sum, value) => sum + value, 0) + Math.max(0, items.length - 1) * itemGap : Math.max(0, ...widths);
|
|
21820
21830
|
const startX = align === "start" ? x : align === "end" ? x - totalWidth : x - totalWidth / 2;
|
|
@@ -21943,7 +21953,7 @@ function ChartAxis({ layer = "all", orientation, x, y, length, labels, positions
|
|
|
21943
21953
|
] });
|
|
21944
21954
|
}
|
|
21945
21955
|
function ChartVisualMap({ min, max, colors = ["#e6f4ff", "#1677ff"], x = 16, y = 284, width = 110, height = 9, label, endLabels, indicatorValue, onHoverRange, realtime = true, svgHandles = false, orientation = "horizontal", calculable = false, value = max, onChange, range, onRangeChange, pieces, selectedPieces, onPieceToggle }) {
|
|
21946
|
-
const id = (0,
|
|
21956
|
+
const id = (0, import_react78.useId)().replaceAll(":", "");
|
|
21947
21957
|
const vertical = orientation === "vertical";
|
|
21948
21958
|
if (svgHandles && vertical && !calculable && !pieces?.length) return /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(ChartVerticalRange, { readOnly: true, min, max, x, y, length: width, thickness: height, colors, range: [min, max], endLabels, indicatorValue, onHoverRange });
|
|
21949
21959
|
if (svgHandles && vertical && calculable && range && !pieces?.length) return /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(ChartVerticalRange, { min, max, x, y, length: width, thickness: height, colors, range, onChange: onRangeChange, endLabels, indicatorValue, onHoverRange, realtime });
|
|
@@ -21971,8 +21981,8 @@ function ChartVisualMap({ min, max, colors = ["#e6f4ff", "#1677ff"], x = 16, y =
|
|
|
21971
21981
|
] });
|
|
21972
21982
|
}
|
|
21973
21983
|
function ChartDataZoom({ value, min = 0, max = 100, ariaLabel = "\u56FE\u8868\u53EF\u89C1\u8303\u56F4", orientation = "horizontal", dataShadow = [], showDetail = false, minSpan = 1, formatter, onChange, panEnabled = false, shadowBounds, handleLabels }) {
|
|
21974
|
-
const [activeHandle, setActiveHandle] = (0,
|
|
21975
|
-
const pan = (0,
|
|
21984
|
+
const [activeHandle, setActiveHandle] = (0, import_react78.useState)(null);
|
|
21985
|
+
const pan = (0, import_react78.useRef)();
|
|
21976
21986
|
const start = Math.min(value[0], value[1]);
|
|
21977
21987
|
const end = Math.max(value[0], value[1]);
|
|
21978
21988
|
const startPercent = (start - min) / Math.max(1, max - min) * 100;
|
|
@@ -22046,9 +22056,9 @@ function ChartDataZoom({ value, min = 0, max = 100, ariaLabel = "\u56FE\u8868\u5
|
|
|
22046
22056
|
] });
|
|
22047
22057
|
}
|
|
22048
22058
|
function ChartTimeline({ labels, value, onChange, autoPlay = false, playInterval = 2e3, loop = true, className = "", ...props }) {
|
|
22049
|
-
const [playing, setPlaying] = (0,
|
|
22050
|
-
(0,
|
|
22051
|
-
(0,
|
|
22059
|
+
const [playing, setPlaying] = (0, import_react78.useState)(autoPlay);
|
|
22060
|
+
(0, import_react78.useEffect)(() => setPlaying(autoPlay), [autoPlay]);
|
|
22061
|
+
(0, import_react78.useEffect)(() => {
|
|
22052
22062
|
if (!playing || labels.length <= 1) return void 0;
|
|
22053
22063
|
const timer = window.setInterval(() => {
|
|
22054
22064
|
const next = value + 1;
|
|
@@ -22158,7 +22168,7 @@ function parseSvgMapPaths(source) {
|
|
|
22158
22168
|
}
|
|
22159
22169
|
|
|
22160
22170
|
// src/components/useMapRoam.ts
|
|
22161
|
-
var
|
|
22171
|
+
var import_react79 = require("react");
|
|
22162
22172
|
|
|
22163
22173
|
// src/components/chartRoam.ts
|
|
22164
22174
|
function zoomChartViewport(view, factor, point, limit = { min: 0.05, max: 20 }) {
|
|
@@ -22175,14 +22185,14 @@ var initial = { x: 0, y: 0, scale: 1 };
|
|
|
22175
22185
|
function useMapRoam(mode, scaleLimit = { min: 0.65, max: 5 }, wheelFactors = [1.12, 0.9]) {
|
|
22176
22186
|
const [zoomIn, zoomOut] = wheelFactors;
|
|
22177
22187
|
const min = scaleLimit?.min, max = scaleLimit?.max, unlimited = scaleLimit === null;
|
|
22178
|
-
const host = (0,
|
|
22179
|
-
const [view, setView] = (0,
|
|
22180
|
-
const drag = (0,
|
|
22188
|
+
const host = (0, import_react79.useRef)(null);
|
|
22189
|
+
const [view, setView] = (0, import_react79.useState)(initial);
|
|
22190
|
+
const drag = (0, import_react79.useRef)();
|
|
22181
22191
|
const local = (x, y) => {
|
|
22182
22192
|
const matrix = host.current?.ownerSVGElement?.getScreenCTM();
|
|
22183
22193
|
return matrix ? new DOMPoint(x, y).matrixTransform(matrix.inverse()) : new DOMPoint(x, y);
|
|
22184
22194
|
};
|
|
22185
|
-
(0,
|
|
22195
|
+
(0, import_react79.useEffect)(() => {
|
|
22186
22196
|
const node = host.current;
|
|
22187
22197
|
if (!node || !mode || mode === "move") return;
|
|
22188
22198
|
const wheel = (event) => {
|
|
@@ -22244,7 +22254,7 @@ function useMapRoam(mode, scaleLimit = { min: 0.65, max: 5 }, wheelFactors = [1.
|
|
|
22244
22254
|
}
|
|
22245
22255
|
|
|
22246
22256
|
// src/components/ChartMapLineReveal.tsx
|
|
22247
|
-
var
|
|
22257
|
+
var import_react80 = require("react");
|
|
22248
22258
|
|
|
22249
22259
|
// src/components/mapLineGeometry.ts
|
|
22250
22260
|
function mapLineControl(source, target, curveness) {
|
|
@@ -22261,9 +22271,9 @@ function mapLineDuration(source, target, period) {
|
|
|
22261
22271
|
// src/components/ChartMapLineReveal.tsx
|
|
22262
22272
|
var import_jsx_runtime76 = require("react/jsx-runtime");
|
|
22263
22273
|
function ChartMapLineReveal({ source, control, target, enabled, initialDuration = 2e3, updateDuration = 500, children }) {
|
|
22264
|
-
const signature = JSON.stringify([source, control, target]), initialized = (0,
|
|
22265
|
-
const [frame, setFrame] = (0,
|
|
22266
|
-
(0,
|
|
22274
|
+
const signature = JSON.stringify([source, control, target]), initialized = (0, import_react80.useRef)(false);
|
|
22275
|
+
const [frame, setFrame] = (0, import_react80.useState)({ signature, progress: enabled ? 0 : 1 });
|
|
22276
|
+
(0, import_react80.useEffect)(() => {
|
|
22267
22277
|
const reduced = window.matchMedia("(prefers-reduced-motion: reduce)");
|
|
22268
22278
|
const duration = Math.max(1, initialized.current ? updateDuration : initialDuration);
|
|
22269
22279
|
if (!enabled || reduced.matches) {
|
|
@@ -22296,15 +22306,15 @@ function ChartMapLineReveal({ source, control, target, enabled, initialDuration
|
|
|
22296
22306
|
}
|
|
22297
22307
|
|
|
22298
22308
|
// src/components/ChartMapLineEffect.tsx
|
|
22299
|
-
var
|
|
22309
|
+
var import_react81 = require("react");
|
|
22300
22310
|
var import_jsx_runtime77 = require("react/jsx-runtime");
|
|
22301
22311
|
function ChartMapLineEffect({ source, control, target, period = 30, color = "#fff", radius = 1, shadowBlur = 10, shadowColor = color, trailAlpha }) {
|
|
22302
|
-
const ref = (0,
|
|
22303
|
-
const trails = (0,
|
|
22312
|
+
const ref = (0, import_react81.useRef)(null);
|
|
22313
|
+
const trails = (0, import_react81.useRef)([]);
|
|
22304
22314
|
const alpha = trailAlpha === void 0 ? 0 : Math.max(0, Math.min(0.999, trailAlpha));
|
|
22305
22315
|
const count = alpha > 0 ? Math.min(240, Math.ceil(Math.log(5e-3) / Math.log(alpha))) : 0;
|
|
22306
22316
|
const duration = mapLineDuration(source, target, period);
|
|
22307
|
-
(0,
|
|
22317
|
+
(0, import_react81.useEffect)(() => {
|
|
22308
22318
|
const started = performance.now();
|
|
22309
22319
|
let frame = 0;
|
|
22310
22320
|
const history = [];
|
|
@@ -22337,7 +22347,7 @@ function ChartMapLineEffect({ source, control, target, period = 30, color = "#ff
|
|
|
22337
22347
|
}
|
|
22338
22348
|
|
|
22339
22349
|
// src/components/ChartMapPointPulse.tsx
|
|
22340
|
-
var
|
|
22350
|
+
var import_react82 = require("react");
|
|
22341
22351
|
|
|
22342
22352
|
// src/components/mapPointPulse.ts
|
|
22343
22353
|
function mapPointPulseDuration(period, random = Math.random) {
|
|
@@ -22347,7 +22357,7 @@ function mapPointPulseDuration(period, random = Math.random) {
|
|
|
22347
22357
|
// src/components/ChartMapPointPulse.tsx
|
|
22348
22358
|
var import_jsx_runtime78 = require("react/jsx-runtime");
|
|
22349
22359
|
function ChartMapPointPulse({ x, y, size, color, period = 15, scaleSize = 2 }) {
|
|
22350
|
-
const [duration] = (0,
|
|
22360
|
+
const [duration] = (0, import_react82.useState)(() => mapPointPulseDuration(period));
|
|
22351
22361
|
return /* @__PURE__ */ (0, import_jsx_runtime78.jsxs)("circle", { "data-svg-map-pulse": duration, cx: x, cy: y, r: size * scaleSize * 0.1, fill: "none", stroke: color, strokeWidth: 0.1, pointerEvents: "none", style: { filter: `drop-shadow(0 0 2px ${color})` }, children: [
|
|
22352
22362
|
/* @__PURE__ */ (0, import_jsx_runtime78.jsx)("animate", { attributeName: "r", values: `${size * scaleSize * 0.1};${size * scaleSize}`, dur: `${duration}ms`, repeatCount: "indefinite", calcMode: "linear" }),
|
|
22353
22363
|
/* @__PURE__ */ (0, import_jsx_runtime78.jsx)("animate", { attributeName: "stroke-width", values: ".1;1", dur: `${duration}ms`, repeatCount: "indefinite", calcMode: "linear" })
|
|
@@ -22355,11 +22365,11 @@ function ChartMapPointPulse({ x, y, size, color, period = 15, scaleSize = 2 }) {
|
|
|
22355
22365
|
}
|
|
22356
22366
|
|
|
22357
22367
|
// src/components/ChartMapPointEntrance.tsx
|
|
22358
|
-
var
|
|
22368
|
+
var import_react83 = require("react");
|
|
22359
22369
|
var import_jsx_runtime79 = require("react/jsx-runtime");
|
|
22360
22370
|
function ChartMapPointEntrance({ enabled, x, y, children }) {
|
|
22361
|
-
const [progress, setProgress] = (0,
|
|
22362
|
-
(0,
|
|
22371
|
+
const [progress, setProgress] = (0, import_react83.useState)(enabled ? 0.01 : 1);
|
|
22372
|
+
(0, import_react83.useEffect)(() => {
|
|
22363
22373
|
const reduced = window.matchMedia("(prefers-reduced-motion: reduce)");
|
|
22364
22374
|
if (!enabled || reduced.matches) {
|
|
22365
22375
|
setProgress(1);
|
|
@@ -22402,8 +22412,8 @@ function mapLineEndLabel(source, target) {
|
|
|
22402
22412
|
// src/components/SvgMapPlot.tsx
|
|
22403
22413
|
var import_jsx_runtime80 = require("react/jsx-runtime");
|
|
22404
22414
|
function SvgMapRegion({ d, name, value, series, color, scale, offset, emphasized, onHover, stroke, strokeWidth, opacity, hoverable = true, showLabel = true, tooltipNameOnly = false }) {
|
|
22405
|
-
const path = (0,
|
|
22406
|
-
(0,
|
|
22415
|
+
const path = (0, import_react84.useRef)(null), [center, setCenter] = (0, import_react84.useState)([0, 0]);
|
|
22416
|
+
(0, import_react84.useLayoutEffect)(() => {
|
|
22407
22417
|
const box = path.current?.getBBox();
|
|
22408
22418
|
if (box) setCenter([box.x + box.width / 2, box.y + box.height / 2]);
|
|
22409
22419
|
}, [d]);
|
|
@@ -22421,9 +22431,9 @@ function SvgMapRegion({ d, name, value, series, color, scale, offset, emphasized
|
|
|
22421
22431
|
] }), onPointerMove: () => onHover(true), onPointerLeave: () => onHover(false), onFocus: () => onHover(true), onBlur: () => onHover(false), children: content });
|
|
22422
22432
|
}
|
|
22423
22433
|
function SvgMapPlot({ source, name, data, x, y, width, height, domain, range = domain, colors, labelOffsets, hoverRange, onHoverValue, roam = true, resetKey = 0, children, markPoints = [], markLines = [], lineAnimation = false, tooltipNameOnly = false, showLabels = true, pointAnimation = false, pointEntrance = false, pointAnimationEasing = "linear" }) {
|
|
22424
|
-
const map = (0,
|
|
22425
|
-
const [hoveredLine, setHoveredLine] = (0,
|
|
22426
|
-
(0,
|
|
22434
|
+
const map = (0, import_react84.useMemo)(() => parseSvgMapPaths(source), [source]), control = useMapRoam(roam, null, [1.2, 1 / 1.2]), [hovered, setHovered] = (0, import_react84.useState)();
|
|
22435
|
+
const [hoveredLine, setHoveredLine] = (0, import_react84.useState)();
|
|
22436
|
+
(0, import_react84.useEffect)(() => {
|
|
22427
22437
|
control.reset();
|
|
22428
22438
|
setHovered(void 0);
|
|
22429
22439
|
}, [resetKey]);
|
|
@@ -22486,16 +22496,16 @@ function SvgMapPlot({ source, name, data, x, y, width, height, domain, range = d
|
|
|
22486
22496
|
}
|
|
22487
22497
|
|
|
22488
22498
|
// src/components/ChartRoamController.tsx
|
|
22489
|
-
var
|
|
22499
|
+
var import_react85 = require("react");
|
|
22490
22500
|
var import_jsx_runtime81 = require("react/jsx-runtime");
|
|
22491
22501
|
function ChartRoamController({ x = 800, y = 5, onPan, onZoom }) {
|
|
22492
|
-
const [hovered, setHovered] = (0,
|
|
22493
|
-
const timer = (0,
|
|
22502
|
+
const [hovered, setHovered] = (0, import_react85.useState)(), [focused, setFocused] = (0, import_react85.useState)();
|
|
22503
|
+
const timer = (0, import_react85.useRef)();
|
|
22494
22504
|
const stop = () => {
|
|
22495
22505
|
if (timer.current !== void 0) clearInterval(timer.current);
|
|
22496
22506
|
timer.current = void 0;
|
|
22497
22507
|
};
|
|
22498
|
-
(0,
|
|
22508
|
+
(0, import_react85.useEffect)(() => {
|
|
22499
22509
|
window.addEventListener("blur", stop);
|
|
22500
22510
|
return () => {
|
|
22501
22511
|
stop();
|
|
@@ -22534,13 +22544,13 @@ function ChartRoamController({ x = 800, y = 5, onPan, onZoom }) {
|
|
|
22534
22544
|
}
|
|
22535
22545
|
|
|
22536
22546
|
// src/components/LineShareChart.tsx
|
|
22537
|
-
var
|
|
22547
|
+
var import_react105 = require("react");
|
|
22538
22548
|
|
|
22539
22549
|
// src/components/Charts.tsx
|
|
22540
|
-
var
|
|
22550
|
+
var import_react103 = require("react");
|
|
22541
22551
|
|
|
22542
22552
|
// src/components/ChartScatterMotion.tsx
|
|
22543
|
-
var
|
|
22553
|
+
var import_react86 = require("react");
|
|
22544
22554
|
|
|
22545
22555
|
// src/components/scatterMotion.ts
|
|
22546
22556
|
function scatterMotionEase(progress) {
|
|
@@ -22552,9 +22562,9 @@ function scatterMotionEase(progress) {
|
|
|
22552
22562
|
var import_jsx_runtime82 = require("react/jsx-runtime");
|
|
22553
22563
|
function ChartScatterMotion({ x, y, radius, enabled, duration = 2e3, updateDuration = 500, progress, children }) {
|
|
22554
22564
|
const target = { x, y, radius };
|
|
22555
|
-
const [frame, setFrame] = (0,
|
|
22556
|
-
const displayed = (0,
|
|
22557
|
-
(0,
|
|
22565
|
+
const [frame, setFrame] = (0, import_react86.useState)(() => ({ ...target, radius: enabled ? radius * 0.01 : radius }));
|
|
22566
|
+
const displayed = (0, import_react86.useRef)(frame), started = (0, import_react86.useRef)(false);
|
|
22567
|
+
(0, import_react86.useEffect)(() => {
|
|
22558
22568
|
const reduced = window.matchMedia("(prefers-reduced-motion: reduce)");
|
|
22559
22569
|
let request = 0;
|
|
22560
22570
|
const publish = (next) => {
|
|
@@ -22665,12 +22675,12 @@ function layoutEventRiver(series, tailLength, area) {
|
|
|
22665
22675
|
}
|
|
22666
22676
|
|
|
22667
22677
|
// src/components/EventRiverBubble.tsx
|
|
22668
|
-
var
|
|
22678
|
+
var import_react87 = require("react");
|
|
22669
22679
|
var import_jsx_runtime83 = require("react/jsx-runtime");
|
|
22670
22680
|
function EventRiverBubble({ resetKey, draggable = true, tooltipPoint, onPointerUp, ...props }) {
|
|
22671
|
-
const [offset, setOffset] = (0,
|
|
22672
|
-
const drag = (0,
|
|
22673
|
-
(0,
|
|
22681
|
+
const [offset, setOffset] = (0, import_react87.useState)(0);
|
|
22682
|
+
const drag = (0, import_react87.useRef)();
|
|
22683
|
+
(0, import_react87.useEffect)(() => {
|
|
22674
22684
|
setOffset(0);
|
|
22675
22685
|
drag.current = void 0;
|
|
22676
22686
|
}, [resetKey]);
|
|
@@ -22721,13 +22731,13 @@ function EventRiverBubble({ resetKey, draggable = true, tooltipPoint, onPointerU
|
|
|
22721
22731
|
}
|
|
22722
22732
|
|
|
22723
22733
|
// src/components/EventRiverMotion.tsx
|
|
22724
|
-
var
|
|
22734
|
+
var import_react88 = require("react");
|
|
22725
22735
|
var import_jsx_runtime84 = require("react/jsx-runtime");
|
|
22726
22736
|
function EventRiverMotion({ geometry, enabled = true, duration = 2e3, updateDuration = 500, progress, children }) {
|
|
22727
|
-
const [frame, setFrame] = (0,
|
|
22728
|
-
const displayed = (0,
|
|
22737
|
+
const [frame, setFrame] = (0, import_react88.useState)(() => ({ ...geometry, scale: enabled ? 0.1 : 1 }));
|
|
22738
|
+
const displayed = (0, import_react88.useRef)(frame), started = (0, import_react88.useRef)(false);
|
|
22729
22739
|
const signature = JSON.stringify(geometry);
|
|
22730
|
-
(0,
|
|
22740
|
+
(0, import_react88.useEffect)(() => {
|
|
22731
22741
|
const preference = window.matchMedia("(prefers-reduced-motion: reduce)"), target = { ...geometry, scale: 1 };
|
|
22732
22742
|
const from = started.current ? displayed.current : { ...geometry, scale: 0.1 };
|
|
22733
22743
|
let request = 0;
|
|
@@ -22845,7 +22855,7 @@ function transferPieValue(series, source, target, connector = " & ") {
|
|
|
22845
22855
|
}
|
|
22846
22856
|
|
|
22847
22857
|
// src/components/ChartValueIsland.tsx
|
|
22848
|
-
var
|
|
22858
|
+
var import_react89 = require("react");
|
|
22849
22859
|
|
|
22850
22860
|
// src/components/cartesianTransfer.ts
|
|
22851
22861
|
function addValues(a, b) {
|
|
@@ -22911,13 +22921,13 @@ function findCompositeValueTarget(element, x, y) {
|
|
|
22911
22921
|
// src/components/ChartValueIsland.tsx
|
|
22912
22922
|
var import_jsx_runtime85 = require("react/jsx-runtime");
|
|
22913
22923
|
function ChartValueIsland({ name, value, x, y, color = "#2ec7c9", onDrop, resolveTarget = findCompositeValueTarget }) {
|
|
22914
|
-
const drag = (0,
|
|
22915
|
-
const [offset, setOffset] = (0,
|
|
22924
|
+
const drag = (0, import_react89.useRef)(null);
|
|
22925
|
+
const [offset, setOffset] = (0, import_react89.useState)([0, 0]);
|
|
22916
22926
|
const cancel = () => {
|
|
22917
22927
|
drag.current = null;
|
|
22918
22928
|
setOffset([0, 0]);
|
|
22919
22929
|
};
|
|
22920
|
-
(0,
|
|
22930
|
+
(0, import_react89.useEffect)(cancel, [x, y]);
|
|
22921
22931
|
return /* @__PURE__ */ (0, import_jsx_runtime85.jsxs)(
|
|
22922
22932
|
ChartMark,
|
|
22923
22933
|
{
|
|
@@ -22970,12 +22980,12 @@ function ChartValueIsland({ name, value, x, y, color = "#2ec7c9", onDrop, resolv
|
|
|
22970
22980
|
}
|
|
22971
22981
|
|
|
22972
22982
|
// src/components/ChartPulseRing.tsx
|
|
22973
|
-
var
|
|
22983
|
+
var import_react90 = require("react");
|
|
22974
22984
|
var import_jsx_runtime86 = require("react/jsx-runtime");
|
|
22975
22985
|
function ChartPulseRing({ center, radius, scaleSize = 2, color = "gold", shadowBlur = 10, period = 15, progress, enabled = true }) {
|
|
22976
|
-
const id = (0,
|
|
22977
|
-
const [reduced, setReduced] = (0,
|
|
22978
|
-
(0,
|
|
22986
|
+
const id = (0, import_react90.useId)().replace(/:/g, ""), [phase, setPhase] = (0, import_react90.useState)(0);
|
|
22987
|
+
const [reduced, setReduced] = (0, import_react90.useState)(false);
|
|
22988
|
+
(0, import_react90.useEffect)(() => {
|
|
22979
22989
|
const preference = window.matchMedia("(prefers-reduced-motion: reduce)");
|
|
22980
22990
|
setReduced(preference.matches);
|
|
22981
22991
|
let frame = 0;
|
|
@@ -23119,7 +23129,7 @@ function chartMarkerPath(kind, x, y, size) {
|
|
|
23119
23129
|
}
|
|
23120
23130
|
|
|
23121
23131
|
// src/components/ChartLargeMapPointCanvas.tsx
|
|
23122
|
-
var
|
|
23132
|
+
var import_react91 = require("react");
|
|
23123
23133
|
|
|
23124
23134
|
// src/components/largeMapPointPulse.ts
|
|
23125
23135
|
function largeMapPointPulse(elapsed, period, initial3, delay) {
|
|
@@ -23135,8 +23145,8 @@ function largeMapPointSize(size, pulse) {
|
|
|
23135
23145
|
// src/components/ChartLargeMapPointCanvas.tsx
|
|
23136
23146
|
var import_jsx_runtime87 = require("react/jsx-runtime");
|
|
23137
23147
|
function ChartLargeMapPointCanvas({ groups, width, height }) {
|
|
23138
|
-
const canvas = (0,
|
|
23139
|
-
(0,
|
|
23148
|
+
const canvas = (0, import_react91.useRef)(null), key = JSON.stringify(groups);
|
|
23149
|
+
(0, import_react91.useEffect)(() => {
|
|
23140
23150
|
const element = canvas.current, context = element?.getContext("2d");
|
|
23141
23151
|
if (!element || !context) return;
|
|
23142
23152
|
const ratio = window.devicePixelRatio || 1;
|
|
@@ -23195,12 +23205,12 @@ function ChartLargeMapPointCanvas({ groups, width, height }) {
|
|
|
23195
23205
|
}
|
|
23196
23206
|
|
|
23197
23207
|
// src/components/ChartCrosshair.tsx
|
|
23198
|
-
var
|
|
23208
|
+
var import_react92 = require("react");
|
|
23199
23209
|
var import_jsx_runtime88 = require("react/jsx-runtime");
|
|
23200
23210
|
function ChartCrosshair({ bounds, xDomain, yDomain, formatX = decimal, formatY = decimal }) {
|
|
23201
|
-
const ref = (0,
|
|
23202
|
-
const [point, setPoint] = (0,
|
|
23203
|
-
(0,
|
|
23211
|
+
const ref = (0, import_react92.useRef)(null);
|
|
23212
|
+
const [point, setPoint] = (0, import_react92.useState)(null);
|
|
23213
|
+
(0, import_react92.useEffect)(() => {
|
|
23204
23214
|
const svg = ref.current?.ownerSVGElement;
|
|
23205
23215
|
if (!svg) return;
|
|
23206
23216
|
const clear = () => setPoint(null);
|
|
@@ -23220,7 +23230,7 @@ function ChartCrosshair({ bounds, xDomain, yDomain, formatX = decimal, formatY =
|
|
|
23220
23230
|
svg.removeEventListener("pointercancel", clear);
|
|
23221
23231
|
};
|
|
23222
23232
|
}, [bounds.x, bounds.y, bounds.width, bounds.height]);
|
|
23223
|
-
(0,
|
|
23233
|
+
(0, import_react92.useEffect)(() => setPoint(null), [xDomain[0], xDomain[1], yDomain[0], yDomain[1]]);
|
|
23224
23234
|
const x = point ? xDomain[0] + (point.x - bounds.x) / bounds.width * (xDomain[1] - xDomain[0]) : 0;
|
|
23225
23235
|
const y = point ? yDomain[1] - (point.y - bounds.y) / bounds.height * (yDomain[1] - yDomain[0]) : 0;
|
|
23226
23236
|
return /* @__PURE__ */ (0, import_jsx_runtime88.jsxs)("g", { ref, className: "sia-chart__crosshair", "aria-hidden": "true", children: [
|
|
@@ -23237,7 +23247,7 @@ function decimal(value) {
|
|
|
23237
23247
|
}
|
|
23238
23248
|
|
|
23239
23249
|
// src/components/HeatmapRasterLayer.tsx
|
|
23240
|
-
var
|
|
23250
|
+
var import_react93 = require("react");
|
|
23241
23251
|
|
|
23242
23252
|
// src/components/heatmapRaster.ts
|
|
23243
23253
|
var defaultGradient = [{ offset: 0.2, color: [0, 0, 255] }, { offset: 0.4, color: [0, 255, 255] }, { offset: 0.6, color: [0, 255, 0] }, { offset: 0.8, color: [255, 255, 0] }, { offset: 1, color: [255, 0, 0] }];
|
|
@@ -23284,9 +23294,9 @@ function rasterizeHeatmap(width, height, points, options = {}) {
|
|
|
23284
23294
|
// src/components/HeatmapRasterLayer.tsx
|
|
23285
23295
|
var import_jsx_runtime89 = require("react/jsx-runtime");
|
|
23286
23296
|
function HeatmapRaster({ width, height, points, options }) {
|
|
23287
|
-
const [url, setUrl] = (0,
|
|
23297
|
+
const [url, setUrl] = (0, import_react93.useState)();
|
|
23288
23298
|
const optionsKey = JSON.stringify(options);
|
|
23289
|
-
(0,
|
|
23299
|
+
(0, import_react93.useEffect)(() => {
|
|
23290
23300
|
const canvas = document.createElement("canvas");
|
|
23291
23301
|
canvas.width = width;
|
|
23292
23302
|
canvas.height = height;
|
|
@@ -23386,10 +23396,10 @@ function chordMatrixLayout(matrix, options = {}) {
|
|
|
23386
23396
|
}
|
|
23387
23397
|
|
|
23388
23398
|
// src/components/MatrixChordPlot.tsx
|
|
23389
|
-
var
|
|
23399
|
+
var import_react94 = require("react");
|
|
23390
23400
|
var import_jsx_runtime90 = require("react/jsx-runtime");
|
|
23391
23401
|
function MatrixChordPlot({ names, matrix, series, appearance, showNodeLabels = false, rotateNodeLabels = false, linkLabel, sort, sortSub, padAngle, clockwise, palette, geometry, legacySubSort = false, showScale = false }) {
|
|
23392
|
-
const [hoveredLink, setHoveredLink] = (0,
|
|
23402
|
+
const [hoveredLink, setHoveredLink] = (0, import_react94.useState)(null);
|
|
23393
23403
|
const layout = series ? chordMultiMatrixLayout(series.map((s) => s.matrix), { padAngle, clockwise, startAngle: geometry?.startAngle }) : chordMatrixLayout(matrix, { sort, sortSub, padAngle, clockwise, legacySubSort, startAngle: geometry?.startAngle }), cx = geometry?.center[0] ?? 360, cy = geometry?.center[1] ?? 182, r = geometry?.innerRadius ?? 108, outer = geometry?.outerRadius ?? 128;
|
|
23394
23404
|
const point = (angle) => [cx + Math.cos(angle) * r, cy + Math.sin(angle) * r];
|
|
23395
23405
|
return /* @__PURE__ */ (0, import_jsx_runtime90.jsxs)("g", { className: "sia-chart__matrix-chord", children: [
|
|
@@ -23736,13 +23746,13 @@ function transferRadarSeries(panels, source, target, connector = " & ") {
|
|
|
23736
23746
|
}
|
|
23737
23747
|
|
|
23738
23748
|
// src/components/ChartRoamGroup.tsx
|
|
23739
|
-
var
|
|
23749
|
+
var import_react95 = require("react");
|
|
23740
23750
|
var import_jsx_runtime92 = require("react/jsx-runtime");
|
|
23741
23751
|
var initial2 = { x: 0, y: 0, scale: 1 };
|
|
23742
23752
|
function ChartRoamGroup({ children, enabled, width, height, zoomEnabled = true, ariaLabel, resetSignal = 0 }) {
|
|
23743
|
-
const group = (0,
|
|
23744
|
-
const [view, setView] = (0,
|
|
23745
|
-
(0,
|
|
23753
|
+
const group = (0, import_react95.useRef)(null), drag = (0, import_react95.useRef)();
|
|
23754
|
+
const [view, setView] = (0, import_react95.useState)(initial2);
|
|
23755
|
+
(0, import_react95.useEffect)(() => {
|
|
23746
23756
|
setView(initial2);
|
|
23747
23757
|
drag.current = void 0;
|
|
23748
23758
|
}, [resetSignal]);
|
|
@@ -23752,7 +23762,7 @@ function ChartRoamGroup({ children, enabled, width, height, zoomEnabled = true,
|
|
|
23752
23762
|
const local = new DOMPoint(clientX, clientY).matrixTransform(matrix.inverse());
|
|
23753
23763
|
return [local.x, local.y];
|
|
23754
23764
|
};
|
|
23755
|
-
(0,
|
|
23765
|
+
(0, import_react95.useEffect)(() => {
|
|
23756
23766
|
const target = group.current;
|
|
23757
23767
|
if (!target || !enabled || !zoomEnabled) return;
|
|
23758
23768
|
const wheel = (event) => {
|
|
@@ -23813,11 +23823,11 @@ function ChartRoamGroup({ children, enabled, width, height, zoomEnabled = true,
|
|
|
23813
23823
|
}
|
|
23814
23824
|
|
|
23815
23825
|
// src/components/TreeNodeGlyph.tsx
|
|
23816
|
-
var
|
|
23826
|
+
var import_react96 = require("react");
|
|
23817
23827
|
var import_jsx_runtime93 = require("react/jsx-runtime");
|
|
23818
23828
|
function TreeNodeGlyph({ symbol = "circle", x, y, width, height, color, itemStyle }) {
|
|
23819
|
-
const [failed, setFailed] = (0,
|
|
23820
|
-
(0,
|
|
23829
|
+
const [failed, setFailed] = (0, import_react96.useState)(false);
|
|
23830
|
+
(0, import_react96.useEffect)(() => setFailed(false), [symbol]);
|
|
23821
23831
|
const style = { fill: itemStyle.brushType === "stroke" ? "none" : color, stroke: itemStyle.borderColor, strokeWidth: itemStyle.borderWidth };
|
|
23822
23832
|
if (symbol.startsWith("image://")) return failed ? /* @__PURE__ */ (0, import_jsx_runtime93.jsxs)("g", { role: "img", "aria-label": "\u539F\u59CB\u8282\u70B9\u56FE\u7247\u52A0\u8F7D\u5931\u8D25", children: [
|
|
23823
23833
|
/* @__PURE__ */ (0, import_jsx_runtime93.jsx)("rect", { x: x - width / 2, y: y - height / 2, width, height, fill: "none", stroke: "#999", strokeDasharray: "3 3" }),
|
|
@@ -24106,7 +24116,7 @@ function resolveMapRegionAppearance(base, datum, emphasized) {
|
|
|
24106
24116
|
}
|
|
24107
24117
|
|
|
24108
24118
|
// src/components/ChartBundledMapCanvas.tsx
|
|
24109
|
-
var
|
|
24119
|
+
var import_react97 = require("react");
|
|
24110
24120
|
|
|
24111
24121
|
// src/components/edgeBundling.ts
|
|
24112
24122
|
var distance = (a, b) => Math.hypot(a[0] - b[0], a[1] - b[1]);
|
|
@@ -24250,9 +24260,9 @@ function sampleBundledPath(curves, progress) {
|
|
|
24250
24260
|
var import_jsx_runtime94 = require("react/jsx-runtime");
|
|
24251
24261
|
function ChartBundledMapCanvas({ edges, points = [], smoothness = 0.1, color = "rgba(2,166,253,0.05)", opacity = 0.2, lineWidth = 0.5, pointColor = "rgba(255,0,0,0.5)", pointRadius = 1.5, effect, width, height }) {
|
|
24252
24262
|
const signature = JSON.stringify(edges), pointKey = JSON.stringify(points), effectKey = JSON.stringify(effect);
|
|
24253
|
-
const paths = (0,
|
|
24254
|
-
const base = (0,
|
|
24255
|
-
(0,
|
|
24263
|
+
const paths = (0, import_react97.useMemo)(() => bundleEdges(JSON.parse(signature)).map((row) => ({ index: row.index, curves: smoothBundledPath(row.points, smoothness) })), [signature, smoothness]);
|
|
24264
|
+
const base = (0, import_react97.useRef)(null), moving = (0, import_react97.useRef)(null);
|
|
24265
|
+
(0, import_react97.useEffect)(() => {
|
|
24256
24266
|
const node = base.current, ctx = node?.getContext("2d");
|
|
24257
24267
|
if (!node || !ctx) return;
|
|
24258
24268
|
const ratio = window.devicePixelRatio || 1;
|
|
@@ -24278,7 +24288,7 @@ function ChartBundledMapCanvas({ edges, points = [], smoothness = 0.1, color = "
|
|
|
24278
24288
|
ctx.fill();
|
|
24279
24289
|
}
|
|
24280
24290
|
}, [paths, pointKey, width, height, color, opacity, lineWidth, pointColor, pointRadius]);
|
|
24281
|
-
(0,
|
|
24291
|
+
(0, import_react97.useEffect)(() => {
|
|
24282
24292
|
const node = moving.current, ctx = node?.getContext("2d");
|
|
24283
24293
|
if (!node || !ctx) return;
|
|
24284
24294
|
const ratio = window.devicePixelRatio || 1;
|
|
@@ -24340,11 +24350,11 @@ function ChartBundledMapCanvas({ edges, points = [], smoothness = 0.1, color = "
|
|
|
24340
24350
|
}
|
|
24341
24351
|
|
|
24342
24352
|
// src/components/ChartMapEffectCanvas.tsx
|
|
24343
|
-
var
|
|
24353
|
+
var import_react98 = require("react");
|
|
24344
24354
|
var import_jsx_runtime95 = require("react/jsx-runtime");
|
|
24345
24355
|
function ChartMapEffectCanvas({ effects, width, height, alpha = 0.95 }) {
|
|
24346
|
-
const canvas = (0,
|
|
24347
|
-
(0,
|
|
24356
|
+
const canvas = (0, import_react98.useRef)(null), key = JSON.stringify(effects);
|
|
24357
|
+
(0, import_react98.useEffect)(() => {
|
|
24348
24358
|
const element = canvas.current;
|
|
24349
24359
|
if (!element) return;
|
|
24350
24360
|
const context = element.getContext("2d");
|
|
@@ -24490,12 +24500,12 @@ function layoutTreeNodes(root, options = {}) {
|
|
|
24490
24500
|
}
|
|
24491
24501
|
|
|
24492
24502
|
// src/components/ChartDataEditor.tsx
|
|
24493
|
-
var
|
|
24503
|
+
var import_react99 = require("react");
|
|
24494
24504
|
var import_jsx_runtime96 = require("react/jsx-runtime");
|
|
24495
24505
|
function ChartDataEditor({ series, onApply, readOnly = false, allowNull = false }) {
|
|
24496
|
-
const [draft, setDraft] = (0,
|
|
24497
|
-
const [error, setError] = (0,
|
|
24498
|
-
const [applied, setApplied] = (0,
|
|
24506
|
+
const [draft, setDraft] = (0, import_react99.useState)(() => JSON.stringify(series.map((item) => item.data), null, 2));
|
|
24507
|
+
const [error, setError] = (0, import_react99.useState)("");
|
|
24508
|
+
const [applied, setApplied] = (0, import_react99.useState)(false);
|
|
24499
24509
|
function apply() {
|
|
24500
24510
|
try {
|
|
24501
24511
|
const values = JSON.parse(draft);
|
|
@@ -24526,11 +24536,11 @@ function ChartDataEditor({ series, onApply, readOnly = false, allowNull = false
|
|
|
24526
24536
|
}
|
|
24527
24537
|
|
|
24528
24538
|
// src/components/ChartBarStatistics.tsx
|
|
24529
|
-
var
|
|
24539
|
+
var import_react100 = require("react");
|
|
24530
24540
|
var import_jsx_runtime97 = require("react/jsx-runtime");
|
|
24531
24541
|
function ChartBarStatistics({ values, kinds, project, plot, horizontal, color, gradient, seriesName }) {
|
|
24532
|
-
const id = (0,
|
|
24533
|
-
const [active, setActive] = (0,
|
|
24542
|
+
const id = (0, import_react100.useId)().replaceAll(":", "");
|
|
24543
|
+
const [active, setActive] = (0, import_react100.useState)();
|
|
24534
24544
|
const paint = gradient ? `url(#${id})` : color;
|
|
24535
24545
|
return /* @__PURE__ */ (0, import_jsx_runtime97.jsxs)("g", { children: [
|
|
24536
24546
|
gradient ? /* @__PURE__ */ (0, import_jsx_runtime97.jsx)("defs", { children: /* @__PURE__ */ (0, import_jsx_runtime97.jsx)("linearGradient", { id, gradientUnits: "userSpaceOnUse", x1: gradient.start[0], y1: gradient.start[1], x2: gradient.end[0], y2: gradient.end[1], children: gradient.stops.map((stop, i) => /* @__PURE__ */ (0, import_jsx_runtime97.jsx)("stop", { offset: stop.offset, stopColor: stop.color }, i)) }) }) : null,
|
|
@@ -24585,7 +24595,7 @@ function lineSegments(points) {
|
|
|
24585
24595
|
}
|
|
24586
24596
|
|
|
24587
24597
|
// src/components/useBarMagicState.ts
|
|
24588
|
-
var
|
|
24598
|
+
var import_react101 = require("react");
|
|
24589
24599
|
|
|
24590
24600
|
// src/components/cartesianMagicState.ts
|
|
24591
24601
|
function changeCartesianMagic(state, action) {
|
|
@@ -24600,8 +24610,8 @@ function changeCartesianMagic(state, action) {
|
|
|
24600
24610
|
function useBarMagicState(toolbox, shape = "bar") {
|
|
24601
24611
|
const initial3 = { shape, layout: "original" };
|
|
24602
24612
|
const options = toolbox === true ? {} : typeof toolbox === "object" ? toolbox : void 0;
|
|
24603
|
-
const [state, setState] = (0,
|
|
24604
|
-
(0,
|
|
24613
|
+
const [state, setState] = (0, import_react101.useState)(() => changeCartesianMagic(initial3, options?.activeMagicType ?? shape));
|
|
24614
|
+
(0, import_react101.useEffect)(() => {
|
|
24605
24615
|
if (options?.activeMagicType) setState((s) => changeCartesianMagic(s, options.activeMagicType));
|
|
24606
24616
|
}, [options?.activeMagicType]);
|
|
24607
24617
|
const resolved = options ? { ...options, activeMagicType: state.shape, activeMagicTypes: options.activeMagicTypes ?? (state.layout === "original" ? [state.shape] : [state.shape, state.layout]), onMagicTypeChange: (action) => {
|
|
@@ -24615,7 +24625,7 @@ function useBarMagicState(toolbox, shape = "bar") {
|
|
|
24615
24625
|
}
|
|
24616
24626
|
|
|
24617
24627
|
// src/components/useBarValueTransfer.ts
|
|
24618
|
-
var
|
|
24628
|
+
var import_react102 = require("react");
|
|
24619
24629
|
|
|
24620
24630
|
// src/components/barTransfer.ts
|
|
24621
24631
|
function transferBarValue(series, source, target, categories) {
|
|
@@ -24632,10 +24642,10 @@ function transferBarValue(series, source, target, categories) {
|
|
|
24632
24642
|
|
|
24633
24643
|
// src/components/useBarValueTransfer.ts
|
|
24634
24644
|
function useBarValueTransfer(series, initial3, categories, enabled, publish, onError) {
|
|
24635
|
-
const [islands, setIslands] = (0,
|
|
24636
|
-
const drag = (0,
|
|
24637
|
-
const [offset, setOffset] = (0,
|
|
24638
|
-
(0,
|
|
24645
|
+
const [islands, setIslands] = (0, import_react102.useState)([]);
|
|
24646
|
+
const drag = (0, import_react102.useRef)();
|
|
24647
|
+
const [offset, setOffset] = (0, import_react102.useState)();
|
|
24648
|
+
(0, import_react102.useEffect)(() => {
|
|
24639
24649
|
setIslands([]);
|
|
24640
24650
|
drag.current = void 0;
|
|
24641
24651
|
setOffset(void 0);
|
|
@@ -24736,12 +24746,12 @@ function logarithmicValueAt(progress, domain) {
|
|
|
24736
24746
|
|
|
24737
24747
|
// src/components/Charts.tsx
|
|
24738
24748
|
var import_jsx_runtime98 = require("react/jsx-runtime");
|
|
24739
|
-
var
|
|
24749
|
+
var import_react104 = require("react");
|
|
24740
24750
|
var PLOT = { x: 62, y: 48, width: 628, height: 250 };
|
|
24741
24751
|
var PLOT_BOTTOM = PLOT.y + PLOT.height;
|
|
24742
24752
|
function useLegendSelection(names, controlled, onChange) {
|
|
24743
|
-
const [internal, setInternal] = (0,
|
|
24744
|
-
(0,
|
|
24753
|
+
const [internal, setInternal] = (0, import_react103.useState)(() => Object.fromEntries(names.map((name) => [name, true])));
|
|
24754
|
+
(0, import_react103.useEffect)(() => {
|
|
24745
24755
|
setInternal((current) => {
|
|
24746
24756
|
const next = { ...current };
|
|
24747
24757
|
names.forEach((name) => {
|
|
@@ -24841,7 +24851,7 @@ function lineSymbol(type, x, y, size, color, image, strokeWidth = 2) {
|
|
|
24841
24851
|
return /* @__PURE__ */ (0, import_jsx_runtime98.jsx)("circle", { cx: x, cy: y, r: size / 2, fill: color, stroke: "var(--sia-color-surface)", strokeWidth: 2 });
|
|
24842
24852
|
}
|
|
24843
24853
|
function useZoom(value, defaultValue, onChange) {
|
|
24844
|
-
const [internal, setInternal] = (0,
|
|
24854
|
+
const [internal, setInternal] = (0, import_react103.useState)([...defaultValue ?? [0, 100]]);
|
|
24845
24855
|
const current = value ?? internal;
|
|
24846
24856
|
const update = (next) => {
|
|
24847
24857
|
if (!value) setInternal(next);
|
|
@@ -24851,8 +24861,8 @@ function useZoom(value, defaultValue, onChange) {
|
|
|
24851
24861
|
}
|
|
24852
24862
|
function useToolboxMagicType(toolbox, fallback) {
|
|
24853
24863
|
const options = toolbox === true ? {} : typeof toolbox === "object" ? toolbox : void 0;
|
|
24854
|
-
const [internal, setInternal] = (0,
|
|
24855
|
-
(0,
|
|
24864
|
+
const [internal, setInternal] = (0, import_react103.useState)(options?.activeMagicType ?? fallback);
|
|
24865
|
+
(0, import_react103.useEffect)(() => {
|
|
24856
24866
|
if (options?.activeMagicType) setInternal(options.activeMagicType);
|
|
24857
24867
|
}, [options?.activeMagicType]);
|
|
24858
24868
|
const active = options?.activeMagicType ?? internal;
|
|
@@ -24870,15 +24880,15 @@ function useToolboxMagicType(toolbox, fallback) {
|
|
|
24870
24880
|
} : toolbox;
|
|
24871
24881
|
return [active, resolved];
|
|
24872
24882
|
}
|
|
24873
|
-
var LineChart = (0,
|
|
24874
|
-
const [hoverIndex, setHoverIndex] = (0,
|
|
24875
|
-
const [editableSeries, setEditableSeries] = (0,
|
|
24876
|
-
const [dragPoint, setDragPoint] = (0,
|
|
24877
|
-
const linePaintId = (0,
|
|
24878
|
-
const [hoveredLinePoint, setHoveredLinePoint] = (0,
|
|
24879
|
-
(0,
|
|
24883
|
+
var LineChart = (0, import_react103.forwardRef)(function LineChart2({ calculableMode = "resize", onTransferError, grid, valueTransfer: externalValueTransfer, categories, series: sourceSeries, appearance = "sia", categoryLabelInterval = 0, boundaryGap = false, showCategorySplitLine = true, categoryAxisName, valueAxisName, legendLayout, logBase = 10, logExponentStep = 1, animationProgress, animationDurationUpdate = 500, valueDomain, axisLabelFormatter, stacked = false, orientation = "vertical", xAxisType = "category", valueAxisType = "value", valueAxisInverse = false, tooltipTrigger = "item", showLegend = true, legendInteractive = true, legendSelected, onLegendSelectionChange, valueFormatter, onDataClick, dataZoom = false, zoomIndexMode = "points", zoomPosition = "bottom", zoomControlBounds, zoomPan = false, zoomSelectionShape = "band", zoomSelectionStyle, zoomMinSelectionSize, calculable = false, zoom, defaultZoom, onZoomChange, onDataChange, palette, toolbox, ...props }, ref) {
|
|
24884
|
+
const [hoverIndex, setHoverIndex] = (0, import_react103.useState)(null);
|
|
24885
|
+
const [editableSeries, setEditableSeries] = (0, import_react103.useState)(sourceSeries);
|
|
24886
|
+
const [dragPoint, setDragPoint] = (0, import_react103.useState)(null);
|
|
24887
|
+
const linePaintId = (0, import_react103.useId)().replaceAll(":", "");
|
|
24888
|
+
const [hoveredLinePoint, setHoveredLinePoint] = (0, import_react103.useState)();
|
|
24889
|
+
(0, import_react103.useEffect)(() => setEditableSeries(sourceSeries), [sourceSeries]);
|
|
24880
24890
|
const series = externalValueTransfer ? sourceSeries : editableSeries;
|
|
24881
|
-
const initialTransferSeries = (0,
|
|
24891
|
+
const initialTransferSeries = (0, import_react103.useMemo)(() => sourceSeries.map((item) => ({ ...item, data: item.data.map(lineValue) })), [sourceSeries]);
|
|
24882
24892
|
const localTransfer = useBarValueTransfer(series.map((item) => ({ ...item, data: item.data.map(lineValue) })), initialTransferSeries, categories, calculable && calculableMode === "transfer" && !externalValueTransfer, (nextBars) => {
|
|
24883
24893
|
const next = series.map((item, row) => ({ ...item, data: item.data.map((datum, index) => {
|
|
24884
24894
|
const value = barDatum(nextBars[row].data[index]).value;
|
|
@@ -24895,8 +24905,8 @@ var LineChart = (0, import_react102.forwardRef)(function LineChart2({ calculable
|
|
|
24895
24905
|
const legend = useLegendSelection(series.map((item) => item.name), legendSelected, onLegendSelectionChange);
|
|
24896
24906
|
const [zoomValue, setZoomValue] = useZoom(zoom, defaultZoom, onZoomChange);
|
|
24897
24907
|
const inlineZoom = dataZoom && zoomControlBounds ? /* @__PURE__ */ (0, import_jsx_runtime98.jsx)("foreignObject", { className: "sia-chart__inline-zoom sia-chart__inline-zoom--compact", ...withTitleTooltip(zoomControlBounds), children: /* @__PURE__ */ (0, import_jsx_runtime98.jsx)(ChartDataZoom, { handleLabels: [categories[Math.min(categories.length - 1, Math.floor(Math.min(...zoomValue) / 100 * categories.length))] ?? "", categories[Math.max(0, Math.ceil(Math.max(...zoomValue) / 100 * categories.length) - 1)] ?? ""], shadowBounds: zoomControlBounds, panEnabled: zoomPan, value: zoomValue, dataShadow: series[0]?.data.map(lineValue), onChange: setZoomValue }) }) : null;
|
|
24898
|
-
const [zoomBrushActive, setZoomBrushActive] = (0,
|
|
24899
|
-
const [zoomHistory, setZoomHistory] = (0,
|
|
24908
|
+
const [zoomBrushActive, setZoomBrushActive] = (0, import_react103.useState)(false);
|
|
24909
|
+
const [zoomHistory, setZoomHistory] = (0, import_react103.useState)(() => dataZoom ? [defaultZoom ?? zoom ?? [0, 100]] : []);
|
|
24900
24910
|
const zoomBrush = dataZoom && zoomBrushActive ? { minSelectionSize: zoomMinSelectionSize, selectionStyle: zoomSelectionStyle, selectionShape: zoomSelectionShape, bounds: PLOT2, onCancel: () => setZoomBrushActive(false), onSelect: (range) => {
|
|
24901
24911
|
const start = Math.min(...zoomValue), span = Math.max(...zoomValue) - start;
|
|
24902
24912
|
const next = [start + range[0] * span, start + range[1] * span];
|
|
@@ -25283,17 +25293,17 @@ function ChartPin({ point, color, label }) {
|
|
|
25283
25293
|
function barDatum(datum) {
|
|
25284
25294
|
return typeof datum === "number" ? { value: datum } : datum;
|
|
25285
25295
|
}
|
|
25286
|
-
var BarChart = (0,
|
|
25287
|
-
const [editableSeries, setEditableSeries] = (0,
|
|
25288
|
-
const [dragBar, setDragBar] = (0,
|
|
25289
|
-
const [hoveredBar, setHoveredBar] = (0,
|
|
25290
|
-
const barPaintId = (0,
|
|
25296
|
+
var BarChart = (0, import_react103.forwardRef)(function BarChart2({ valueTransfer: externalValueTransfer, calculableMode = "resize", onTransferError, categories, series: sourceSeries, appearance = "sia", animationProgress, animationDurationUpdate = 500, valueDomain, axisLabelFormatter, grid, valueAxisPosition = "bottom", showValueAxis = true, showCategoryAxis = true, showCategorySplitLine = false, tooltipTrigger = "item", tooltipFormatter, stacked = false, orientation = "vertical", minBarSize = 1, calculable = false, onDataChange, showLegend = true, legendOrder, legendLayout, barCategoryGap = 0.2, valuePadding = 0, legendInteractive = true, legendSelected, onLegendSelectionChange, valueFormatter, onDataClick, palette, toolbox, ...props }, ref) {
|
|
25297
|
+
const [editableSeries, setEditableSeries] = (0, import_react103.useState)(sourceSeries);
|
|
25298
|
+
const [dragBar, setDragBar] = (0, import_react103.useState)(null);
|
|
25299
|
+
const [hoveredBar, setHoveredBar] = (0, import_react103.useState)();
|
|
25300
|
+
const barPaintId = (0, import_react103.useId)().replaceAll(":", "");
|
|
25291
25301
|
const localTransfer = useBarValueTransfer(editableSeries, sourceSeries, categories, calculable && calculableMode === "transfer" && !externalValueTransfer, (next) => {
|
|
25292
25302
|
setEditableSeries(next);
|
|
25293
25303
|
onDataChange?.(next);
|
|
25294
25304
|
}, onTransferError);
|
|
25295
25305
|
const transfer = externalValueTransfer ?? localTransfer;
|
|
25296
|
-
(0,
|
|
25306
|
+
(0, import_react103.useEffect)(() => setEditableSeries(sourceSeries), [sourceSeries]);
|
|
25297
25307
|
const series = externalValueTransfer ? sourceSeries : editableSeries;
|
|
25298
25308
|
const legacy = appearance === "macarons";
|
|
25299
25309
|
const PLOT2 = legacy ? { x: grid?.left ?? 80, y: grid?.top ?? 60, width: (props.viewBoxSize?.[0] ?? 720) - (grid?.left ?? 80) - (grid?.right ?? 80), height: (props.viewBoxSize?.[1] ?? 360) - (grid?.top ?? 60) - (grid?.bottom ?? 70) } : { x: 62, y: 48, width: 628, height: 250 };
|
|
@@ -25540,17 +25550,17 @@ var BarChart = (0, import_react102.forwardRef)(function BarChart2({ valueTransfe
|
|
|
25540
25550
|
] }, `bar-island-${index}`)) : null
|
|
25541
25551
|
] });
|
|
25542
25552
|
});
|
|
25543
|
-
var ScatterChart = (0,
|
|
25544
|
-
const [data, setData] = (0,
|
|
25545
|
-
const [emphasizedPoint, setEmphasizedPoint] = (0,
|
|
25546
|
-
const [emphasizedAnnotation, setEmphasizedAnnotation] = (0,
|
|
25547
|
-
(0,
|
|
25553
|
+
var ScatterChart = (0, import_react103.forwardRef)(function ScatterChart2({ symbolAnimation = false, animationProgress, animationDurationUpdate = 500, statisticPoints = [], statisticLines = [], annotations = [], data: initialData, toolbox, showXAxis = true, showXSplitLine = true, showYSplitLine = true, tooltipFormatter, plotBounds, xDomain: fixedXDomain, yDomain: fixedYDomain, showPointLabels = false, yAxisPosition = "left", xCategories, xFormatter, crosshair = false, markColor, xSplitNumber = 5, ySplitNumber = 5, symbolSize, markAppearance = "label", markByCategory = false, xUnit = "", yUnit = "", minSymbolRadius = 5, xLabel, yLabel, xAxisType = "value", showLegend = true, legendInteractive = true, legendSelected, onLegendSelectionChange, dataZoom = false, zoom, defaultZoom, onZoomChange, visualMap, markAverage, markExtremes = false, largeThreshold = 1200, onDataClick, palette, ...props }, ref) {
|
|
25554
|
+
const [data, setData] = (0, import_react103.useState)(initialData);
|
|
25555
|
+
const [emphasizedPoint, setEmphasizedPoint] = (0, import_react103.useState)(null);
|
|
25556
|
+
const [emphasizedAnnotation, setEmphasizedAnnotation] = (0, import_react103.useState)();
|
|
25557
|
+
(0, import_react103.useEffect)(() => setData(initialData), [initialData]);
|
|
25548
25558
|
const plot = plotBounds ?? PLOT, bottom = plot.y + plot.height;
|
|
25549
25559
|
const [zoomValue, setZoomValue] = useZoom(zoom, defaultZoom, onZoomChange);
|
|
25550
25560
|
const allCategories = [...new Set(data.map((item) => item.category).filter((value) => Boolean(value)))];
|
|
25551
25561
|
const legend = useLegendSelection(allCategories, legendSelected, onLegendSelectionChange);
|
|
25552
25562
|
const activeData = data.filter((item) => !item.category || legend.isSelected(item.category));
|
|
25553
|
-
const sorted = (0,
|
|
25563
|
+
const sorted = (0, import_react103.useMemo)(() => [...activeData].sort((left, right) => left.x - right.x), [activeData]);
|
|
25554
25564
|
const startIndex = dataZoom ? Math.floor(Math.min(...zoomValue) / 100 * Math.max(0, sorted.length - 1)) : 0;
|
|
25555
25565
|
const endIndex = dataZoom ? Math.max(startIndex + 1, Math.ceil(Math.max(...zoomValue) / 100 * sorted.length)) : sorted.length;
|
|
25556
25566
|
const categoryWindow = xCategories ? scatterCategoryWindow(xCategories, dataZoom ? zoomValue : [0, 100]) : void 0;
|
|
@@ -25565,10 +25575,10 @@ var ScatterChart = (0, import_react102.forwardRef)(function ScatterChart2({ symb
|
|
|
25565
25575
|
const visualMinimum = visualMap?.min ?? (visualValues.length ? Math.min(...visualValues) : 0);
|
|
25566
25576
|
const visualMaximum = visualMap?.max ?? (visualValues.length ? Math.max(...visualValues) : 1);
|
|
25567
25577
|
const visualColors = visualMap?.colors ?? ["#e6f4ff", "#1677ff"];
|
|
25568
|
-
const [selectedPieces, setSelectedPieces] = (0,
|
|
25569
|
-
const [visualRange, setVisualRange] = (0,
|
|
25578
|
+
const [selectedPieces, setSelectedPieces] = (0, import_react103.useState)([]);
|
|
25579
|
+
const [visualRange, setVisualRange] = (0, import_react103.useState)();
|
|
25570
25580
|
const piecesKey = JSON.stringify(visualMap?.pieces ?? []);
|
|
25571
|
-
(0,
|
|
25581
|
+
(0, import_react103.useEffect)(() => setSelectedPieces([]), [piecesKey]);
|
|
25572
25582
|
const statistics = scatterStatistics(visibleData, markByCategory);
|
|
25573
25583
|
const plotted = visibleData.map((item, index) => {
|
|
25574
25584
|
const x = linearScale(categoryWindow ? categoryWindow.indexOf(item.x) : item.x, [xDomain[0], xDomain[1]], [plot.x, plot.x + plot.width]);
|
|
@@ -25726,8 +25736,8 @@ var ScatterChart = (0, import_react102.forwardRef)(function ScatterChart2({ symb
|
|
|
25726
25736
|
/* @__PURE__ */ (0, import_jsx_runtime98.jsx)(ChartDataZoom, { value: zoomValue, onChange: setZoomValue })
|
|
25727
25737
|
] }) : content;
|
|
25728
25738
|
});
|
|
25729
|
-
var CandlestickChart = (0,
|
|
25730
|
-
const [data, setData] = (0,
|
|
25739
|
+
var CandlestickChart = (0, import_react103.forwardRef)(function CandlestickChart2({ showAxes = true, data: initialData, valueDomain, axisLabelFormatter, activeIndex, onActiveIndexChange, seriesVisible: controlledVisible, onSeriesVisibilityChange, showLegend = true, showCategoryLabels = true, plotBounds, markPoints, seriesName, risingBorderColor, fallingBorderColor, borderWidth = 2, risingEmphasisColor, fallingEmphasisColor, maxBarWidth = 34, appearance = "sia", risingColor = "#f5222d", fallingColor = "#52c41a", hollowRising = false, dataZoom = false, zoom, defaultZoom, onZoomChange, markExtremes = false, onDataClick, toolbox, ...props }, ref) {
|
|
25740
|
+
const [data, setData] = (0, import_react103.useState)(initialData), [internalActive, setInternalActive] = (0, import_react103.useState)(null), [internalVisible, setInternalVisible] = (0, import_react103.useState)(true);
|
|
25731
25741
|
const active = activeIndex === void 0 ? internalActive : activeIndex;
|
|
25732
25742
|
const seriesVisible = controlledVisible ?? internalVisible;
|
|
25733
25743
|
const setActive = (index) => {
|
|
@@ -25738,7 +25748,7 @@ var CandlestickChart = (0, import_react102.forwardRef)(function CandlestickChart
|
|
|
25738
25748
|
if (controlledVisible === void 0) setInternalVisible(visible);
|
|
25739
25749
|
onSeriesVisibilityChange?.(visible);
|
|
25740
25750
|
};
|
|
25741
|
-
(0,
|
|
25751
|
+
(0, import_react103.useEffect)(() => {
|
|
25742
25752
|
setData(initialData);
|
|
25743
25753
|
}, [initialData]);
|
|
25744
25754
|
const legacy = appearance === "macarons";
|
|
@@ -25829,20 +25839,20 @@ var CandlestickChart = (0, import_react102.forwardRef)(function CandlestickChart
|
|
|
25829
25839
|
] }) : content;
|
|
25830
25840
|
});
|
|
25831
25841
|
var EMPTY_PIE_DATA = [];
|
|
25832
|
-
var PieChart = (0,
|
|
25833
|
-
const pieGradientId = (0,
|
|
25834
|
-
const [pieIslands, setPieIslands] = (0,
|
|
25835
|
-
const sourceRings = (0,
|
|
25836
|
-
const [editableRings, setEditableRings] = (0,
|
|
25837
|
-
const valueDrag = (0,
|
|
25838
|
-
const [valueOffset, setValueOffset] = (0,
|
|
25839
|
-
(0,
|
|
25842
|
+
var PieChart = (0, import_react103.forwardRef)(function PieChart2({ pulseRing, calculable = false, markPoints = [], data = EMPTY_PIE_DATA, series, innerRadius = 62, outerRadius = 124, rose = false, center = [360, 173], startAngle = -90, clockwise = true, padAngle = 0, showLegend = true, legendInteractive = true, legendSelected, onLegendSelectionChange, showLabels = true, showLabelLines = true, centerLabel, selectedMode = false, selected, defaultSelected, selectedOffset = 9, onSelectionChange, onDataClick, palette, toolbox, appearance = "sia", animationProgress, animationDurationUpdate = 500, legendLayout, showGuideRings = false, onDataChange, transferId, onValueTransfer, onTransferError, onValueDragOut, outsideLabelLayout, ...props }, ref) {
|
|
25843
|
+
const pieGradientId = (0, import_react103.useId)().replace(/:/g, "");
|
|
25844
|
+
const [pieIslands, setPieIslands] = (0, import_react103.useState)([]);
|
|
25845
|
+
const sourceRings = (0, import_react103.useMemo)(() => series?.length ? series : [{ data, innerRadius, outerRadius, rose, showLabels }], [series, data, innerRadius, outerRadius, rose, showLabels]);
|
|
25846
|
+
const [editableRings, setEditableRings] = (0, import_react103.useState)(sourceRings);
|
|
25847
|
+
const valueDrag = (0, import_react103.useRef)(null);
|
|
25848
|
+
const [valueOffset, setValueOffset] = (0, import_react103.useState)();
|
|
25849
|
+
(0, import_react103.useEffect)(() => setEditableRings(sourceRings), [sourceRings]);
|
|
25840
25850
|
const allData = editableRings.flatMap((ring) => ring.data).filter((item) => !item.missing);
|
|
25841
25851
|
const names = [...new Set(allData.map((item) => item.name))];
|
|
25842
25852
|
const legend = useLegendSelection(names, legendSelected, onLegendSelectionChange);
|
|
25843
25853
|
const [magicType, resolvedToolbox] = useToolboxMagicType(toolbox, "\u997C\u56FE");
|
|
25844
|
-
const [hovered, setHovered] = (0,
|
|
25845
|
-
const [internalSelected, setInternalSelected] = (0,
|
|
25854
|
+
const [hovered, setHovered] = (0, import_react103.useState)();
|
|
25855
|
+
const [internalSelected, setInternalSelected] = (0, import_react103.useState)(() => [...defaultSelected ?? allData.filter((item) => item.selected).map((item) => item.name)]);
|
|
25846
25856
|
const selectedNames = selected ?? internalSelected;
|
|
25847
25857
|
const legacy = appearance === "macarons";
|
|
25848
25858
|
const colorNames = [...new Set(allData.filter((item) => item.showInLegend !== false).map((item) => item.name))];
|
|
@@ -26062,15 +26072,15 @@ var PieChart = (0, import_react102.forwardRef)(function PieChart2({ pulseRing, c
|
|
|
26062
26072
|
});
|
|
26063
26073
|
var EMPTY_RADAR_INDICATORS = [];
|
|
26064
26074
|
var EMPTY_RADAR_SERIES = [];
|
|
26065
|
-
var RadarChart = (0,
|
|
26075
|
+
var RadarChart = (0, import_react103.forwardRef)(function RadarChart2({ indicators = EMPTY_RADAR_INDICATORS, series = EMPTY_RADAR_SERIES, radars, calculable = false, onTransferError, markers, levels = 5, showLegend = true, legendInteractive = true, legendSelected, onLegendSelectionChange, onDataClick, palette, toolbox, appearance = "sia", animationProgress, legendOrder, legendLayout, onDataChange, ...props }, ref) {
|
|
26066
26076
|
const legacy = appearance === "macarons";
|
|
26067
|
-
const initialPanels = (0,
|
|
26068
|
-
const [sourcePanels, setSourcePanels] = (0,
|
|
26069
|
-
const [hoveredRadar, setHoveredRadar] = (0,
|
|
26070
|
-
const radarPaintId = `sia-radar-${(0,
|
|
26071
|
-
const radarDrag = (0,
|
|
26072
|
-
const [radarOffset, setRadarOffset] = (0,
|
|
26073
|
-
(0,
|
|
26077
|
+
const initialPanels = (0, import_react103.useMemo)(() => radars?.length ? radars : [{ indicators, series, levels }], [radars, indicators, series, levels]);
|
|
26078
|
+
const [sourcePanels, setSourcePanels] = (0, import_react103.useState)(initialPanels);
|
|
26079
|
+
const [hoveredRadar, setHoveredRadar] = (0, import_react103.useState)(null);
|
|
26080
|
+
const radarPaintId = `sia-radar-${(0, import_react103.useId)().replaceAll(":", "")}`;
|
|
26081
|
+
const radarDrag = (0, import_react103.useRef)(null);
|
|
26082
|
+
const [radarOffset, setRadarOffset] = (0, import_react103.useState)(null);
|
|
26083
|
+
(0, import_react103.useEffect)(() => {
|
|
26074
26084
|
setSourcePanels(initialPanels);
|
|
26075
26085
|
radarDrag.current = null;
|
|
26076
26086
|
setRadarOffset(null);
|
|
@@ -26224,7 +26234,7 @@ var RadarChart = (0, import_react102.forwardRef)(function RadarChart2({ indicato
|
|
|
26224
26234
|
})
|
|
26225
26235
|
] });
|
|
26226
26236
|
});
|
|
26227
|
-
var ChordChart = (0,
|
|
26237
|
+
var ChordChart = (0, import_react103.forwardRef)(function ChordChart2({ nodes, links, nodeGeometry, matrixAppearance, matrix, matrixSeries, showNodeLabels = false, rotateNodeLabels = false, matrixLinkLabel, matrixGeometry, legacySubSort = false, showScale = false, sortSub = "none", padAngle = 0.035, ribbon = true, clockwise = true, sort = "none", onNodeClick, onLinkClick, palette, toolbox, ...props }, ref) {
|
|
26228
26238
|
const [magicType, resolvedToolbox] = useToolboxMagicType(toolbox, "\u548C\u5F26");
|
|
26229
26239
|
if (/force|力导向|关系/i.test(magicType)) return /* @__PURE__ */ (0, import_jsx_runtime98.jsx)(
|
|
26230
26240
|
GraphChart,
|
|
@@ -26297,11 +26307,11 @@ var ChordChart = (0, import_react102.forwardRef)(function ChordChart2({ nodes, l
|
|
|
26297
26307
|
})
|
|
26298
26308
|
] });
|
|
26299
26309
|
});
|
|
26300
|
-
var GraphChart = (0,
|
|
26310
|
+
var GraphChart = (0, import_react103.forwardRef)(function GraphChart2({ nodes, links, roam = false, chordOptions, forceOptions, progressiveForce = false, layout = "circular", showLabels = true, draggable = true, legendInteractive = true, legendSelected, onLegendSelectionChange, onNodeClick, palette, toolbox, ...props }, ref) {
|
|
26301
26311
|
const categories = [...new Set(nodes.map((node) => node.category).filter((value) => Boolean(value)))];
|
|
26302
26312
|
const legend = useLegendSelection(categories, legendSelected, onLegendSelectionChange);
|
|
26303
26313
|
const [magicType, resolvedToolbox] = useToolboxMagicType(toolbox, layout === "force" ? "\u529B\u5BFC\u5411" : "\u5173\u7CFB");
|
|
26304
|
-
const [roamReset, setRoamReset] = (0,
|
|
26314
|
+
const [roamReset, setRoamReset] = (0, import_react103.useState)(0);
|
|
26305
26315
|
const chartToolbox = typeof resolvedToolbox === "object" ? {
|
|
26306
26316
|
...resolvedToolbox,
|
|
26307
26317
|
onRestore: () => {
|
|
@@ -26310,23 +26320,23 @@ var GraphChart = (0, import_react102.forwardRef)(function GraphChart2({ nodes, l
|
|
|
26310
26320
|
resolvedToolbox.onRestore?.();
|
|
26311
26321
|
}
|
|
26312
26322
|
} : resolvedToolbox;
|
|
26313
|
-
const activeNodes = (0,
|
|
26314
|
-
const activeLinks = (0,
|
|
26323
|
+
const activeNodes = (0, import_react103.useMemo)(() => nodes.filter((node) => !node.category || legend.selected[node.category] !== false), [legend.selected, nodes]);
|
|
26324
|
+
const activeLinks = (0, import_react103.useMemo)(() => {
|
|
26315
26325
|
const activeIds = new Set(activeNodes.map((node) => node.id));
|
|
26316
26326
|
return links.filter((link) => activeIds.has(link.source) && activeIds.has(link.target));
|
|
26317
26327
|
}, [activeNodes, links]);
|
|
26318
26328
|
const progressive = progressiveForce && layout === "force" && props.animation !== false && !/chord|和弦/i.test(magicType);
|
|
26319
|
-
const calculatedPositions = (0,
|
|
26320
|
-
const [positions, setPositions] = (0,
|
|
26321
|
-
const [dragging, setDragging] = (0,
|
|
26322
|
-
const heldNode = (0,
|
|
26323
|
-
const [forceRestart, setForceRestart] = (0,
|
|
26324
|
-
(0,
|
|
26329
|
+
const calculatedPositions = (0, import_react103.useMemo)(() => graphLayout(activeNodes, activeLinks, layout === "force" && !progressive, forceOptions), [activeLinks, activeNodes, layout, forceOptions, progressive]);
|
|
26330
|
+
const [positions, setPositions] = (0, import_react103.useState)(calculatedPositions);
|
|
26331
|
+
const [dragging, setDragging] = (0, import_react103.useState)(null);
|
|
26332
|
+
const heldNode = (0, import_react103.useRef)(null);
|
|
26333
|
+
const [forceRestart, setForceRestart] = (0, import_react103.useState)(0);
|
|
26334
|
+
(0, import_react103.useEffect)(() => {
|
|
26325
26335
|
setPositions(calculatedPositions);
|
|
26326
26336
|
setDragging(null);
|
|
26327
26337
|
heldNode.current = null;
|
|
26328
26338
|
}, [calculatedPositions, roamReset]);
|
|
26329
|
-
(0,
|
|
26339
|
+
(0, import_react103.useEffect)(() => {
|
|
26330
26340
|
if (!progressive || activeNodes.length > (forceOptions?.maxNodes ?? 80)) return;
|
|
26331
26341
|
let frame = 0, remaining = Math.max(0, forceOptions?.iterations ?? 140), previous, carry = 0;
|
|
26332
26342
|
const tick = (time) => {
|
|
@@ -26444,7 +26454,7 @@ var GraphChart = (0, import_react102.forwardRef)(function GraphChart2({ nodes, l
|
|
|
26444
26454
|
] })
|
|
26445
26455
|
] });
|
|
26446
26456
|
});
|
|
26447
|
-
var ForceGraphChart = (0,
|
|
26457
|
+
var ForceGraphChart = (0, import_react103.forwardRef)(function ForceGraphChart2(props, ref) {
|
|
26448
26458
|
return /* @__PURE__ */ (0, import_jsx_runtime98.jsx)(GraphChart, { ...props, layout: "force", ref });
|
|
26449
26459
|
});
|
|
26450
26460
|
var ForceChart = ForceGraphChart;
|
|
@@ -26473,12 +26483,12 @@ function colorBetween(start, end, ratio) {
|
|
|
26473
26483
|
const to = read(end);
|
|
26474
26484
|
return `rgb(${from.map((value, index) => Math.round(value + ((to[index] ?? value) - value) * Math.max(0, Math.min(1, ratio)))).join(" ")})`;
|
|
26475
26485
|
}
|
|
26476
|
-
var MapChart = (0,
|
|
26477
|
-
const [internalSelected, setInternalSelected] = (0,
|
|
26486
|
+
var MapChart = (0, import_react103.forwardRef)(function MapChart2({ overlayProjection, bundledLines, largeMarkPoints, markLineEffectRenderer = "svg", insetStyle, insetLabelStyle, regionHoverable = true, markPointTooltipFormatter, emphasisValueRange, onRegionHover, coordinateTransform, specialAreas, labelCoordinates, labelOffsets, nameMap, wheelZoomFactors, clampVisualValues = false, showMap = true, visualMapLayout, labelStyle, emphasisLabelStyle, regionStyle, emphasisRegionStyle, outOfRangeColor, scaleLimit, roamController = false, map, geoJson, data, colors = ["#e6f4ff", "#1677ff"], nameProperty = "name", showLabels = true, showEmphasisLabels = false, tooltipFormatter, roam = false, selectedMode = false, selected, defaultSelected, onSelectionChange, calculableVisualMap = false, visualRange, defaultVisualRange, onVisualRangeChange, markPoints = [], markLines = [], onRegionClick, toolbox, plotBounds: sourcePlotBounds, longitudeRatio, geographicInsets = [], valueDomain, showVisualMap = true, seriesName, ...props }, ref) {
|
|
26487
|
+
const [internalSelected, setInternalSelected] = (0, import_react103.useState)(() => [...defaultSelected ?? data.filter((item) => item.selected).map((item) => item.name)]);
|
|
26478
26488
|
const selectedNames = selected ?? internalSelected;
|
|
26479
|
-
const [hoveredRegion, setHoveredRegion] = (0,
|
|
26480
|
-
const [hoveredMarkPoint, setHoveredMarkPoint] = (0,
|
|
26481
|
-
const [internalHoveredValueRange, setHoveredValueRange] = (0,
|
|
26489
|
+
const [hoveredRegion, setHoveredRegion] = (0, import_react103.useState)();
|
|
26490
|
+
const [hoveredMarkPoint, setHoveredMarkPoint] = (0, import_react103.useState)();
|
|
26491
|
+
const [internalHoveredValueRange, setHoveredValueRange] = (0, import_react103.useState)();
|
|
26482
26492
|
const hoveredValueRange = emphasisValueRange ?? internalHoveredValueRange;
|
|
26483
26493
|
const roamControl = useMapRoam(roam, scaleLimit, wheelZoomFactors);
|
|
26484
26494
|
const { view } = roamControl;
|
|
@@ -26493,8 +26503,8 @@ var MapChart = (0, import_react102.forwardRef)(function MapChart2({ overlayProje
|
|
|
26493
26503
|
const values = data.map((item) => item.value);
|
|
26494
26504
|
const minimum = valueDomain?.[0] ?? (values.length ? Math.min(...values) : 0);
|
|
26495
26505
|
const maximum = valueDomain?.[1] ?? (values.length ? Math.max(...values) : 1);
|
|
26496
|
-
const [internalVisualRange, setInternalVisualRange] = (0,
|
|
26497
|
-
(0,
|
|
26506
|
+
const [internalVisualRange, setInternalVisualRange] = (0, import_react103.useState)(() => [...defaultVisualRange ?? [minimum, maximum]]);
|
|
26507
|
+
(0, import_react103.useEffect)(() => {
|
|
26498
26508
|
if (!visualRange && !defaultVisualRange) setInternalVisualRange([minimum, maximum]);
|
|
26499
26509
|
}, [defaultVisualRange, maximum, minimum, visualRange]);
|
|
26500
26510
|
const currentVisualRange = visualRange ?? internalVisualRange;
|
|
@@ -26670,7 +26680,7 @@ var MapChart = (0, import_react102.forwardRef)(function MapChart2({ overlayProje
|
|
|
26670
26680
|
roamController ? /* @__PURE__ */ (0, import_jsx_runtime98.jsx)(ChartRoamController, { x: (props.viewBoxSize?.[0] ?? 720) - 90, y: 5, onPan: roamControl.pan, onZoom: (factor) => roamControl.zoom(factor, [(props.viewBoxSize?.[0] ?? 720) / 2, (props.viewBoxSize?.[1] ?? 360) / 2]) }) : null
|
|
26671
26681
|
] });
|
|
26672
26682
|
});
|
|
26673
|
-
var GaugeChart = (0,
|
|
26683
|
+
var GaugeChart = (0, import_react103.forwardRef)(function GaugeChart2({ tooltipFormatter, data, min = 0, max = 100, startAngle = 210, endAngle = -30, segments, splitNumber = 10, showAxisLabels = true, showProgress = true, detailOffset = 84, valueFormatter, onDataClick, palette, appearance = "sia", animationProgress, ...props }, ref) {
|
|
26674
26684
|
const count = Math.max(1, data.length);
|
|
26675
26685
|
const legacy = appearance === "macarons";
|
|
26676
26686
|
return /* @__PURE__ */ (0, import_jsx_runtime98.jsx)(SiaChart, { ...props, className: `${props.className ?? ""}${legacy ? " sia-chart--macarons" : ""}`, ref, palette, empty: !data.length, ariaLabel: props.ariaLabel ?? "\u4EEA\u8868\u76D8", children: [...data].sort((a, b) => (a.zIndex ?? 0) - (b.zIndex ?? 0)).map((item, index) => {
|
|
@@ -26753,12 +26763,12 @@ var GaugeChart = (0, import_react102.forwardRef)(function GaugeChart2({ tooltipF
|
|
|
26753
26763
|
] }, `${item.name}-${index}`);
|
|
26754
26764
|
}) });
|
|
26755
26765
|
});
|
|
26756
|
-
var FunnelChart = (0,
|
|
26766
|
+
var FunnelChart = (0, import_react103.forwardRef)(function FunnelChart2({ data = EMPTY_PIE_DATA, series, sort = "descending", gap = 4, align = "center", orientation = "vertical", showLegend = true, legendInteractive = true, legendSelected, onLegendSelectionChange, onDataClick, palette, toolbox, appearance = "sia", animationProgress, legendOrder, legendLayout, onDataChange, ...props }, ref) {
|
|
26757
26767
|
const legacy = appearance === "macarons";
|
|
26758
|
-
const [activeFunnel, setActiveFunnel] = (0,
|
|
26759
|
-
const initialFunnels = (0,
|
|
26760
|
-
const [sourceFunnels, setSourceFunnels] = (0,
|
|
26761
|
-
(0,
|
|
26768
|
+
const [activeFunnel, setActiveFunnel] = (0, import_react103.useState)(null);
|
|
26769
|
+
const initialFunnels = (0, import_react103.useMemo)(() => series?.length ? series : [{ data, sort, gap, align, orientation }], [series, data, sort, gap, align, orientation]);
|
|
26770
|
+
const [sourceFunnels, setSourceFunnels] = (0, import_react103.useState)(initialFunnels);
|
|
26771
|
+
(0, import_react103.useEffect)(() => setSourceFunnels(initialFunnels), [initialFunnels]);
|
|
26762
26772
|
const allData = sourceFunnels.flatMap((funnel) => funnel.data);
|
|
26763
26773
|
const legendData = [...new Map(allData.map((item) => [item.name, item])).values()];
|
|
26764
26774
|
const legend = useLegendSelection(legendData.map((item) => item.name), legendSelected, onLegendSelectionChange);
|
|
@@ -26849,7 +26859,7 @@ var FunnelChart = (0, import_react102.forwardRef)(function FunnelChart2({ data =
|
|
|
26849
26859
|
})
|
|
26850
26860
|
] });
|
|
26851
26861
|
});
|
|
26852
|
-
var HeatmapChart = (0,
|
|
26862
|
+
var HeatmapChart = (0, import_react103.forwardRef)(function HeatmapChart2({ raster, xLabels = [], yLabels = [], data = [], points = [], colors = ["#e6f4ff", "#1677ff"], showValues = false, pointRadius = 30, blur = 16, minAlpha = 0.12, maxAlpha = 0.82, valueFormatter, onDataClick, ...props }, ref) {
|
|
26853
26863
|
const pointMode = points.length > 0;
|
|
26854
26864
|
const values = pointMode ? points.map((point) => point.value) : data.flatMap((row) => [...row]);
|
|
26855
26865
|
const minimum = values.length ? Math.min(...values) : 0;
|
|
@@ -26858,7 +26868,7 @@ var HeatmapChart = (0, import_react102.forwardRef)(function HeatmapChart2({ rast
|
|
|
26858
26868
|
const cellHeight = PLOT.height / Math.max(1, yLabels.length);
|
|
26859
26869
|
const pointXDomain = niceChartDomain(points.map((point) => point.x), false);
|
|
26860
26870
|
const pointYDomain = niceChartDomain(points.map((point) => point.y), false);
|
|
26861
|
-
const filterId = `sia-heat-${(0,
|
|
26871
|
+
const filterId = `sia-heat-${(0, import_react103.useId)().replaceAll(":", "")}`;
|
|
26862
26872
|
if (raster) return /* @__PURE__ */ (0, import_jsx_runtime98.jsxs)(SiaChart, { ...props, ref, empty: !points.length, ariaLabel: props.ariaLabel ?? "\u50CF\u7D20\u70ED\u529B\u56FE", children: [
|
|
26863
26873
|
raster.backgroundImage ? /* @__PURE__ */ (0, import_jsx_runtime98.jsx)("image", { href: raster.backgroundImage, x: 0, y: 0, width: raster.width, height: raster.height, preserveAspectRatio: "none", pointerEvents: "none" }) : null,
|
|
26864
26874
|
/* @__PURE__ */ (0, import_jsx_runtime98.jsx)(HeatmapRaster, { width: raster.width, height: raster.height, points, options: raster })
|
|
@@ -26894,7 +26904,7 @@ var HeatmapChart = (0, import_react102.forwardRef)(function HeatmapChart2({ rast
|
|
|
26894
26904
|
] })
|
|
26895
26905
|
] });
|
|
26896
26906
|
});
|
|
26897
|
-
var ThemeRiverChart = (0,
|
|
26907
|
+
var ThemeRiverChart = (0, import_react103.forwardRef)(function ThemeRiverChart2({ categories, series, legendInteractive = true, legendSelected, onLegendSelectionChange, onDataClick, palette, ...props }, ref) {
|
|
26898
26908
|
const legend = useLegendSelection(series.map((item) => item.name), legendSelected, onLegendSelectionChange);
|
|
26899
26909
|
const activeSeries = series.filter((item) => legend.isSelected(item.name));
|
|
26900
26910
|
const totals = categories.map((_, index) => activeSeries.reduce((sum, item) => sum + Math.max(0, item.data[index] ?? 0), 0));
|
|
@@ -26932,8 +26942,8 @@ function eventTime(value) {
|
|
|
26932
26942
|
if (typeof value === "number") return value;
|
|
26933
26943
|
return Date.parse(/^\d{4}-\d{2}-\d{2}$/.test(value) ? value.replace(/-/g, "/") : value);
|
|
26934
26944
|
}
|
|
26935
|
-
var EventRiverChart = (0,
|
|
26936
|
-
const [restoreVersion, setRestoreVersion] = (0,
|
|
26945
|
+
var EventRiverChart = (0, import_react103.forwardRef)(function EventRiverChart2({ series, showLabels = true, draggable = true, appearance = "sia", plot = PLOT, animationProgress, boundaryGap = [0.05, 0.1], legendInteractive = true, legendSelected, onLegendSelectionChange, onDataClick, palette, ...props }, ref) {
|
|
26946
|
+
const [restoreVersion, setRestoreVersion] = (0, import_react103.useState)(0);
|
|
26937
26947
|
const area = plot;
|
|
26938
26948
|
palette = palette ?? (appearance === "macarons" ? ["#2ec7c9", "#b6a2de"] : void 0);
|
|
26939
26949
|
const legend = useLegendSelection(series.map((item) => item.name), legendSelected, onLegendSelectionChange);
|
|
@@ -27006,9 +27016,9 @@ function vennDistance(radiusA, radiusB, overlap) {
|
|
|
27006
27016
|
}
|
|
27007
27017
|
return (low + high) / 2;
|
|
27008
27018
|
}
|
|
27009
|
-
var VennChart = (0,
|
|
27010
|
-
const [sets, setSets] = (0,
|
|
27011
|
-
(0,
|
|
27019
|
+
var VennChart = (0, import_react103.forwardRef)(function VennChart2({ sets: initialSets, intersection: initialIntersection, appearance = "sia", emphasisColor, emphasisBorderColor, emphasisBorderWidth, onDataClick, palette, toolbox, ...props }, ref) {
|
|
27020
|
+
const [sets, setSets] = (0, import_react103.useState)(initialSets), [intersection, setIntersection] = (0, import_react103.useState)(initialIntersection), [active, setActive] = (0, import_react103.useState)();
|
|
27021
|
+
(0, import_react103.useEffect)(() => {
|
|
27012
27022
|
setSets(initialSets);
|
|
27013
27023
|
setIntersection(initialIntersection);
|
|
27014
27024
|
}, [initialSets, initialIntersection]);
|
|
@@ -27071,17 +27081,17 @@ function layoutTreemap(nodes, x, y, width, height, gap, maxDepth, depth = 0, see
|
|
|
27071
27081
|
});
|
|
27072
27082
|
return result;
|
|
27073
27083
|
}
|
|
27074
|
-
var TreemapChart = (0,
|
|
27075
|
-
const [path, setPath] = (0,
|
|
27076
|
-
const [sourceData, setSourceData] = (0,
|
|
27077
|
-
const [active, setActive] = (0,
|
|
27078
|
-
(0,
|
|
27084
|
+
var TreemapChart = (0, import_react103.forwardRef)(function TreemapChart2({ data, gap = 4, maxDepth = 2, drilldown = false, showBreadcrumb = true, bounds, itemStyle, emphasis, cornerRadius = 5, showChildBoundaries = false, breadcrumbPosition = "top", breadcrumbRootName = "\u5168\u90E8", valueFormatter, onDataClick, palette, toolbox, ...props }, ref) {
|
|
27085
|
+
const [path, setPath] = (0, import_react103.useState)([]);
|
|
27086
|
+
const [sourceData, setSourceData] = (0, import_react103.useState)(data);
|
|
27087
|
+
const [active, setActive] = (0, import_react103.useState)();
|
|
27088
|
+
(0, import_react103.useEffect)(() => {
|
|
27079
27089
|
setSourceData(data);
|
|
27080
27090
|
setPath([]);
|
|
27081
27091
|
}, [data]);
|
|
27082
27092
|
const currentData = path.reduce((nodes, name) => nodes.find((node) => node.name === name)?.children ?? nodes, sourceData);
|
|
27083
27093
|
const top = drilldown && showBreadcrumb ? 52 : 28;
|
|
27084
|
-
const rectangles = (0,
|
|
27094
|
+
const rectangles = (0, import_react103.useMemo)(() => layoutTreemap(currentData, bounds?.x ?? 24, bounds?.y ?? top, bounds?.width ?? 672, bounds?.height ?? 336 - top, gap, maxDepth), [currentData, gap, maxDepth, top, bounds]);
|
|
27085
27095
|
const chartToolbox = typeof toolbox === "object" ? { ...toolbox, dataView: toolbox.dataView ?? /* @__PURE__ */ (0, import_jsx_runtime98.jsx)(ChartDataEditor, { readOnly: toolbox.dataViewReadOnly, series: currentData.map((node) => ({ name: node.name, data: [treemapValue(node)] })), onApply: (values) => {
|
|
27086
27096
|
const update = (nodes, depth) => nodes.map((node, i) => depth === path.length ? { ...node, value: values[i][0] } : node.name === path[depth] ? { ...node, children: update(node.children ?? [], depth + 1) } : node);
|
|
27087
27097
|
setSourceData(update(sourceData, 0));
|
|
@@ -27149,15 +27159,15 @@ function flattenTree2(root, collapsed) {
|
|
|
27149
27159
|
visit(root, 0);
|
|
27150
27160
|
return { nodes, leafCount: Math.max(1, leafOrder), maxDepth: Math.max(0, ...nodes.map((item) => item.depth)) };
|
|
27151
27161
|
}
|
|
27152
|
-
var TreeChart = (0,
|
|
27153
|
-
const [sourceData, setSourceData] = (0,
|
|
27154
|
-
const [roamReset, setRoamReset] = (0,
|
|
27155
|
-
const [active, setActive] = (0,
|
|
27156
|
-
(0,
|
|
27162
|
+
var TreeChart = (0, import_react103.forwardRef)(function TreeChart2({ data, itemStyle, emphasis, orientation = "horizontal", radial = false, nodeSize = 8, rootPosition, nodePadding, layerPadding, showLabels = true, emphasisShowLabels = true, nodeColor, edgeColor, edgeWidth, edgeShadow, roam = false, hoverable = true, labelFontSize, labelColor, linkStyle = "curve", collapsible = false, onToggle, onDataClick, palette, toolbox, ...props }, ref) {
|
|
27163
|
+
const [sourceData, setSourceData] = (0, import_react103.useState)(data);
|
|
27164
|
+
const [roamReset, setRoamReset] = (0, import_react103.useState)(0);
|
|
27165
|
+
const [active, setActive] = (0, import_react103.useState)();
|
|
27166
|
+
(0, import_react103.useEffect)(() => {
|
|
27157
27167
|
setSourceData(data);
|
|
27158
27168
|
setActive(void 0);
|
|
27159
27169
|
}, [data]);
|
|
27160
|
-
const [collapsed, setCollapsed] = (0,
|
|
27170
|
+
const [collapsed, setCollapsed] = (0, import_react103.useState)(() => {
|
|
27161
27171
|
const result = /* @__PURE__ */ new Set();
|
|
27162
27172
|
const visit = (node) => {
|
|
27163
27173
|
if (node.collapsed) result.add(node.name);
|
|
@@ -27166,8 +27176,8 @@ var TreeChart = (0, import_react102.forwardRef)(function TreeChart2({ data, item
|
|
|
27166
27176
|
visit(data);
|
|
27167
27177
|
return result;
|
|
27168
27178
|
});
|
|
27169
|
-
const layout = (0,
|
|
27170
|
-
const fixedLayout = (0,
|
|
27179
|
+
const layout = (0, import_react103.useMemo)(() => flattenTree2(sourceData, collapsed), [collapsed, sourceData]);
|
|
27180
|
+
const fixedLayout = (0, import_react103.useMemo)(() => {
|
|
27171
27181
|
const visible = (node) => ({ ...node, children: collapsed.has(node.name) ? [] : node.children?.map(visible) });
|
|
27172
27182
|
return rootPosition ? layoutTreeNodes(visible(sourceData), { nodeSize, nodePadding, layerPadding, rootPosition, orientation }) : void 0;
|
|
27173
27183
|
}, [sourceData, collapsed, rootPosition, nodeSize, nodePadding, layerPadding, orientation]);
|
|
@@ -27237,15 +27247,15 @@ var TreeChart = (0, import_react102.forwardRef)(function TreeChart2({ data, item
|
|
|
27237
27247
|
})
|
|
27238
27248
|
] }) });
|
|
27239
27249
|
});
|
|
27240
|
-
var WordCloudChart = (0,
|
|
27241
|
-
const placements = (0,
|
|
27250
|
+
var WordCloudChart = (0, import_react103.forwardRef)(function WordCloudChart2({ data, bounds, areaSizing = false, autoFit = false, onLayout, minFontSize = 14, maxFontSize = 52, rotations = [0, 0, -28, 28, 0], spiralStep = 9, shape = "ellipse", padding = 4, fontFamily, fontWeight = 650, onDataClick, palette, ...props }, ref) {
|
|
27251
|
+
const placements = (0, import_react103.useMemo)(() => {
|
|
27242
27252
|
const context = typeof document === "undefined" ? null : document.createElement("canvas").getContext("2d");
|
|
27243
27253
|
return layoutCloudWords(data, { bounds: bounds ?? { x: 18, y: 18, width: 684, height: 324 }, minFontSize, maxFontSize, rotations, spiralStep, shape, padding, autoFit, areaSizing, measure: context ? (word, size) => {
|
|
27244
27254
|
context.font = `${word.fontWeight ?? fontWeight} ${size}px ${word.fontFamily ?? fontFamily ?? "Arial"}`;
|
|
27245
27255
|
return context.measureText(word.name).width;
|
|
27246
27256
|
} : void 0 });
|
|
27247
27257
|
}, [data, bounds, autoFit, areaSizing, maxFontSize, minFontSize, padding, rotations, shape, spiralStep, fontFamily, fontWeight]);
|
|
27248
|
-
(0,
|
|
27258
|
+
(0, import_react103.useEffect)(() => {
|
|
27249
27259
|
const present = new Set(placements.map((p) => p.index));
|
|
27250
27260
|
onLayout?.({ placed: placements.length, unplaced: data.filter((_, i) => !present.has(i)).map((item) => item.name) });
|
|
27251
27261
|
}, [placements, data, onLayout]);
|
|
@@ -27254,30 +27264,30 @@ var WordCloudChart = (0, import_react102.forwardRef)(function WordCloudChart2({
|
|
|
27254
27264
|
return /* @__PURE__ */ (0, import_jsx_runtime98.jsx)(ChartMark, { label: `${placement.item.name}\uFF0C${placement.item.value}`, tooltip: /* @__PURE__ */ (0, import_jsx_runtime98.jsx)(TooltipValue, { name: placement.item.name, value: placement.item.value }), tooltipPoint: [placement.x, placement.y], transform: `rotate(${placement.rotation} ${placement.x} ${placement.y})`, onPointerUp: (event) => onDataClick?.({ name: placement.item.name, value: placement.item.value, data: placement.item, nativeEvent: event }), children: /* @__PURE__ */ (0, import_jsx_runtime98.jsx)("text", { x: placement.x, y: placement.y + placement.fontSize * 0.34, textAnchor: "middle", fill: color, style: { fontSize: placement.fontSize, fontFamily: placement.item.fontFamily ?? fontFamily, fontWeight: placement.item.fontWeight ?? fontWeight }, className: "sia-chart__word", children: placement.item.name }) }, `${placement.item.name}-${placement.index}`);
|
|
27255
27265
|
}) });
|
|
27256
27266
|
});
|
|
27257
|
-
var MixedChart = (0,
|
|
27258
|
-
const plotClipId = `sia-mixed-plot-${(0,
|
|
27259
|
-
const [editableSeries, setEditableSeries] = (0,
|
|
27260
|
-
const [geometry, setGeometry] = (0,
|
|
27261
|
-
const [pointerIndex, setPointerIndex] = (0,
|
|
27262
|
-
const [pointerAxisIndex, setPointerAxisIndex] = (0,
|
|
27263
|
-
const [motionRevision, setMotionRevision] = (0,
|
|
27264
|
-
const [stackMode, setStackMode] = (0,
|
|
27265
|
-
const lastPublished = (0,
|
|
27267
|
+
var MixedChart = (0, import_react103.forwardRef)(function MixedChart2({ axisPointer, categoryAxisLabels, axisLayering = "inline", barSpacing, renderAxes, coordinateAnimation = false, animationProgress, animationDurationUpdate = 500, boundaryGap = true, categories, activeIndex, onActiveIndexChange, showCategoryLabels = true, categoryLabelInterval = 0, clipPlot = false, series: sourceSeries, valueAxes, stacked: sourceStacked = false, plotBounds, tooltipTrigger = "item", calculable = false, onTransferError, onDataChange, transferId, onValueTransfer, toolbox, legendNames, axisTooltipFormatter, legendLayout, showLegend = true, legendInteractive = true, legendSelected, onLegendSelectionChange, valueFormatter, onDataClick, palette, ...props }, ref) {
|
|
27268
|
+
const plotClipId = `sia-mixed-plot-${(0, import_react103.useId)().replaceAll(":", "")}`;
|
|
27269
|
+
const [editableSeries, setEditableSeries] = (0, import_react103.useState)(sourceSeries);
|
|
27270
|
+
const [geometry, setGeometry] = (0, import_react103.useState)();
|
|
27271
|
+
const [pointerIndex, setPointerIndex] = (0, import_react103.useState)(null);
|
|
27272
|
+
const [pointerAxisIndex, setPointerAxisIndex] = (0, import_react103.useState)(0);
|
|
27273
|
+
const [motionRevision, setMotionRevision] = (0, import_react103.useState)(0);
|
|
27274
|
+
const [stackMode, setStackMode] = (0, import_react103.useState)();
|
|
27275
|
+
const lastPublished = (0, import_react103.useRef)(null);
|
|
27266
27276
|
const publishData = (next) => {
|
|
27267
27277
|
lastPublished.current = next;
|
|
27268
27278
|
onDataChange?.(next);
|
|
27269
27279
|
};
|
|
27270
|
-
const [islands, setIslands] = (0,
|
|
27271
|
-
const drag = (0,
|
|
27272
|
-
const [dragOffset, setDragOffset] = (0,
|
|
27273
|
-
(0,
|
|
27280
|
+
const [islands, setIslands] = (0, import_react103.useState)([]);
|
|
27281
|
+
const drag = (0, import_react103.useRef)(null);
|
|
27282
|
+
const [dragOffset, setDragOffset] = (0, import_react103.useState)();
|
|
27283
|
+
(0, import_react103.useEffect)(() => {
|
|
27274
27284
|
if (sourceSeries === lastPublished.current) return;
|
|
27275
27285
|
setEditableSeries(sourceSeries);
|
|
27276
27286
|
setIslands([]);
|
|
27277
27287
|
drag.current = null;
|
|
27278
27288
|
setDragOffset(void 0);
|
|
27279
27289
|
}, [sourceSeries]);
|
|
27280
|
-
const series = (0,
|
|
27290
|
+
const series = (0, import_react103.useMemo)(() => editableSeries.map((item) => geometry ? { ...item, type: geometry } : item), [editableSeries, geometry]);
|
|
27281
27291
|
const stacked = stackMode ?? sourceStacked;
|
|
27282
27292
|
const PLOT2 = plotBounds ?? { x: 62, y: 48, width: 628, height: 250 }, PLOT_BOTTOM2 = PLOT2.y + PLOT2.height;
|
|
27283
27293
|
const legend = useLegendSelection(series.map((item) => item.name), legendSelected, onLegendSelectionChange);
|
|
@@ -27441,7 +27451,7 @@ var MixedChart = (0, import_react102.forwardRef)(function MixedChart2({ axisPoin
|
|
|
27441
27451
|
})
|
|
27442
27452
|
] }) : /* @__PURE__ */ (0, import_jsx_runtime98.jsx)(CartesianAxes, { categories, domain, band: categoryGap }),
|
|
27443
27453
|
activeIndex != null && activeIndex >= 0 && activeIndex < categories.length ? /* @__PURE__ */ (0, import_jsx_runtime98.jsx)("rect", { "data-mixed-active-index": activeIndex, x: Math.max(PLOT2.x, categoryAt(activeIndex) - band / 2), y: PLOT2.y, width: Math.min(PLOT2.x + PLOT2.width, categoryAt(activeIndex) + band / 2) - Math.max(PLOT2.x, categoryAt(activeIndex) - band / 2), height: PLOT2.height, fill: "currentColor", opacity: 0.06, pointerEvents: "none" }) : null,
|
|
27444
|
-
tooltipTrigger === "axis" ? categories.map((name, index) => /* @__PURE__ */ (0,
|
|
27454
|
+
tooltipTrigger === "axis" ? categories.map((name, index) => /* @__PURE__ */ (0, import_react104.createElement)(ChartMark, { ...activeProps(index), key: `axis-${index}`, "data-mixed-axis-tooltip": index, label: `${name.trim()} \u5404\u6307\u6807`, tooltip: axisTooltip(index), tooltipPoint: [categoryAt(index), PLOT2.y + PLOT2.height / 2] }, /* @__PURE__ */ (0, import_jsx_runtime98.jsx)("rect", { x: Math.max(PLOT2.x, categoryAt(index) - band / 2), y: PLOT2.y, width: Math.min(PLOT2.x + PLOT2.width, categoryAt(index) + band / 2) - Math.max(PLOT2.x, categoryAt(index) - band / 2), height: PLOT2.height, fill: "transparent" }))) : null,
|
|
27445
27455
|
calculable ? activeSeries.flatMap((item) => item.data.map((value, index) => value === null ? /* @__PURE__ */ (0, import_jsx_runtime98.jsx)(ChartMark, { ...dragProps(series.indexOf(item), index), label: `${item.name}\uFF0C${categories[index]}\uFF0C\u7A7A\u69FD`, tooltip: "\u62D6\u5165\u6570\u636E\u4EE5\u586B\u5145", children: /* @__PURE__ */ (0, import_jsx_runtime98.jsx)("rect", { x: PLOT2.x + index * band + band * activeSeries.indexOf(item) / Math.max(1, activeSeries.length), y: PLOT_BOTTOM2 - 14, width: Math.max(4, band / Math.max(1, activeSeries.length) - 2), height: 14, fill: "transparent", stroke: getColor(series.indexOf(item), item.color, palette), strokeDasharray: "3 2" }) }, `empty-${item.name}-${index}`) : null)) : null,
|
|
27446
27456
|
/* @__PURE__ */ (0, import_jsx_runtime98.jsx)("defs", { children: /* @__PURE__ */ (0, import_jsx_runtime98.jsx)("clipPath", { id: plotClipId, children: /* @__PURE__ */ (0, import_jsx_runtime98.jsx)("rect", { x: PLOT2.x, y: PLOT2.y, width: PLOT2.width, height: PLOT2.height }) }) }),
|
|
27447
27457
|
/* @__PURE__ */ (0, import_jsx_runtime98.jsx)("g", { "data-mixed-plot": "", clipPath: clipPlot ? `url(#${plotClipId})` : void 0, children: renderSeries.map((item) => {
|
|
@@ -27480,7 +27490,7 @@ var MixedChart = (0, import_react102.forwardRef)(function MixedChart2({ axisPoin
|
|
|
27480
27490
|
const zero = linearScale(placement.start, [valueDomain[0], valueDomain[1]], [PLOT_BOTTOM2, PLOT2.y]);
|
|
27481
27491
|
const rectY = barSpacing?.pixelAlign ? Math.floor(Math.min(y, zero)) : Math.min(y, zero);
|
|
27482
27492
|
const rectHeight = barSpacing?.pixelAlign ? Math.ceil(Math.abs(zero - y)) : Math.abs(zero - y);
|
|
27483
|
-
return /* @__PURE__ */ (0, import_jsx_runtime98.jsx)(ChartPointMotion, { points: [[x, value >= 0 ? rectY + rectHeight : rectY], [x, rectY], [x + width, rectY + rectHeight]], enabled: coordinateAnimation && props.animation !== false, duration: props.animationDuration ?? 2e3, updateDuration: animationDurationUpdate, progress: coordinateAnimation ? animationProgress : void 0, children: (frame) => /* @__PURE__ */ (0,
|
|
27493
|
+
return /* @__PURE__ */ (0, import_jsx_runtime98.jsx)(ChartPointMotion, { points: [[x, value >= 0 ? rectY + rectHeight : rectY], [x, rectY], [x + width, rectY + rectHeight]], enabled: coordinateAnimation && props.animation !== false, duration: props.animationDuration ?? 2e3, updateDuration: animationDurationUpdate, progress: coordinateAnimation ? animationProgress : void 0, children: (frame) => /* @__PURE__ */ (0, import_react104.createElement)(ChartMark, { ...dragProps(seriesIndex, index), key: `${name}-${index}`, label: `${item.name}\uFF0C${name}\uFF0C${value}`, tooltip: (item.tooltipTrigger ?? tooltipTrigger) === "axis" ? axisTooltip(index, item.categoryAxisIndex) : /* @__PURE__ */ (0, import_jsx_runtime98.jsx)(TooltipValue, { name, series: item.name, value, formatter: valueFormatter }), tooltipPoint: [props.tooltipProps?.placement === "axis" ? Math.round(categoryAt(index)) : x + width / 2, y], onPointerUp: (event) => {
|
|
27484
27494
|
if (!finishDrag(event)) onDataClick?.({ name, value, seriesName: item.name, data: value, nativeEvent: event });
|
|
27485
27495
|
} }, /* @__PURE__ */ (0, import_jsx_runtime98.jsx)("rect", { style: { animation: coordinateAnimation ? "none" : void 0 }, x: frame[1][0], y: Math.min(frame[1][1], frame[2][1]), width: Math.max(0, frame[2][0] - frame[1][0]), height: Math.abs(frame[2][1] - frame[1][1]), rx: item.barRadius ?? 4, fill: item.pointColors?.[index] ?? color, className: "sia-chart__bar" })) }, `${item.name}-${index}-${motionRevision}`);
|
|
27486
27496
|
})
|
|
@@ -27509,7 +27519,7 @@ var MixedChart = (0, import_react102.forwardRef)(function MixedChart2({ axisPoin
|
|
|
27509
27519
|
if (!placements[index]) return null;
|
|
27510
27520
|
const name = categoryName(index, item.categoryAxisIndex);
|
|
27511
27521
|
const value = item.data[index] ?? 0;
|
|
27512
|
-
return /* @__PURE__ */ (0,
|
|
27522
|
+
return /* @__PURE__ */ (0, import_react104.createElement)(ChartMark, { ...dragProps(seriesIndex, index), key: `${name}-${index}`, label: `${item.name}\uFF0C${name}\uFF0C${value}`, tooltip: (item.tooltipTrigger ?? tooltipTrigger) === "axis" ? axisTooltip(index, item.categoryAxisIndex) : /* @__PURE__ */ (0, import_jsx_runtime98.jsx)(TooltipValue, { name, series: item.name, value, formatter: valueFormatter }), tooltipPoint: props.tooltipProps?.placement === "axis" ? [Math.round(point[0]), point[1]] : point, onPointerUp: (event) => {
|
|
27513
27523
|
if (!finishDrag(event)) onDataClick?.({ name, value, seriesName: item.name, data: value, nativeEvent: event });
|
|
27514
27524
|
} }, /* @__PURE__ */ (0, import_jsx_runtime98.jsx)("circle", { className: item.hollowSymbol ? "sia-chart__mixed-hollow-symbol" : void 0, cx: point[0], cy: point[1], r: Math.max(0, item.symbolSize ?? 9) / 2, fill: item.hollowSymbol ? "#fff" : color, stroke: item.hollowSymbol ? color : "var(--sia-color-surface)", strokeWidth: 2 }));
|
|
27515
27525
|
})
|
|
@@ -27550,9 +27560,9 @@ var KLineChart = CandlestickChart;
|
|
|
27550
27560
|
|
|
27551
27561
|
// src/components/LineShareChart.tsx
|
|
27552
27562
|
var import_jsx_runtime99 = require("react/jsx-runtime");
|
|
27553
|
-
var LineShareChart = (0,
|
|
27554
|
-
const [selected, setSelected] = (0,
|
|
27555
|
-
const [maskHovered, setMaskHovered] = (0,
|
|
27563
|
+
var LineShareChart = (0, import_react105.forwardRef)(function LineShareChart2({ data, lineColor = "#2ec7c9", shareColor = "#b6a2de", ...props }, ref) {
|
|
27564
|
+
const [selected, setSelected] = (0, import_react105.useState)(null);
|
|
27565
|
+
const [maskHovered, setMaskHovered] = (0, import_react105.useState)(false);
|
|
27556
27566
|
const width = props.viewBoxSize?.[0] ?? 900, height = props.viewBoxSize?.[1] ?? 450;
|
|
27557
27567
|
const total = data.reduce((sum, item2) => sum + item2.value, 0), gap = data.length ? Math.round(Math.max(...data.map((item2) => item2.value)) - Math.min(...data.map((item2) => item2.value))) : 0;
|
|
27558
27568
|
const maximum = data.reduce((best, item2, i) => item2.value >= data[best].value ? i : best, 0);
|
|
@@ -27630,16 +27640,16 @@ function paddedValueExtent(values, padding = 0.05) {
|
|
|
27630
27640
|
}
|
|
27631
27641
|
|
|
27632
27642
|
// src/components/XYChart.tsx
|
|
27633
|
-
var
|
|
27643
|
+
var import_react106 = require("react");
|
|
27634
27644
|
var import_jsx_runtime100 = require("react/jsx-runtime");
|
|
27635
|
-
var XYChart = (0,
|
|
27636
|
-
const [series, setSeries] = (0,
|
|
27637
|
-
const [hidden, setHidden] = (0,
|
|
27638
|
-
const [crosshair, setCrosshair] = (0,
|
|
27639
|
-
const [drag, setDrag] = (0,
|
|
27640
|
-
const [geometry, setGeometry] = (0,
|
|
27641
|
-
const [zoom, setZoom] = (0,
|
|
27642
|
-
(0,
|
|
27645
|
+
var XYChart = (0, import_react106.forwardRef)(function XYChart2({ series: source, xDomain, yDomain, animationProgress, calculable = false, onDataChange, xAxisType = "value", xFormatter, tooltipFormatter, dataZoom = false, defaultZoom = [0, 100], onZoomChange, toolbox, ...props }, ref) {
|
|
27646
|
+
const [series, setSeries] = (0, import_react106.useState)(source);
|
|
27647
|
+
const [hidden, setHidden] = (0, import_react106.useState)([]);
|
|
27648
|
+
const [crosshair, setCrosshair] = (0, import_react106.useState)();
|
|
27649
|
+
const [drag, setDrag] = (0, import_react106.useState)();
|
|
27650
|
+
const [geometry, setGeometry] = (0, import_react106.useState)();
|
|
27651
|
+
const [zoom, setZoom] = (0, import_react106.useState)(defaultZoom);
|
|
27652
|
+
(0, import_react106.useEffect)(() => setSeries(source), [source]);
|
|
27643
27653
|
const window2 = dataZoom || xAxisType === "time" ? scatterValueWindow(series.flatMap((item) => item.data.map((point) => point[0])), dataZoom ? zoom : [0, 100]) : void 0;
|
|
27644
27654
|
const active = series.filter((item) => !hidden.includes(item.name)).map((item) => ({ ...item, data: window2 ? item.data.filter((point) => point[0] >= window2[0] && point[0] <= window2[1]) : item.data }));
|
|
27645
27655
|
const width = props.viewBoxSize?.[0] ?? 663, height = props.viewBoxSize?.[1] ?? 379;
|
|
@@ -27768,7 +27778,7 @@ var XYChart = (0, import_react105.forwardRef)(function XYChart2({ series: source
|
|
|
27768
27778
|
});
|
|
27769
27779
|
|
|
27770
27780
|
// src/components/ChartMapOverlay.tsx
|
|
27771
|
-
var
|
|
27781
|
+
var import_react107 = require("react");
|
|
27772
27782
|
|
|
27773
27783
|
// src/components/mapOverlayHost.ts
|
|
27774
27784
|
function observeMapOverlayHost(host, onChange) {
|
|
@@ -27807,11 +27817,11 @@ function observeMapOverlayHost(host, onChange) {
|
|
|
27807
27817
|
// src/components/ChartMapOverlay.tsx
|
|
27808
27818
|
var import_jsx_runtime101 = require("react/jsx-runtime");
|
|
27809
27819
|
function ChartMapOverlay({ createHost, children, className, style, ariaLabel = "\u5730\u56FE\u53E0\u52A0\u56FE\u8868", onError }) {
|
|
27810
|
-
const container = (0,
|
|
27811
|
-
const errorHandler = (0,
|
|
27820
|
+
const container = (0, import_react107.useRef)(null);
|
|
27821
|
+
const errorHandler = (0, import_react107.useRef)(onError);
|
|
27812
27822
|
errorHandler.current = onError;
|
|
27813
|
-
const [snapshot, setSnapshot] = (0,
|
|
27814
|
-
(0,
|
|
27823
|
+
const [snapshot, setSnapshot] = (0, import_react107.useState)();
|
|
27824
|
+
(0, import_react107.useEffect)(() => {
|
|
27815
27825
|
setSnapshot(void 0);
|
|
27816
27826
|
if (!container.current) return;
|
|
27817
27827
|
try {
|
|
@@ -27891,9 +27901,9 @@ function createBaiduMapHost(element, sdk, options) {
|
|
|
27891
27901
|
initializeDefaultScrollbars();
|
|
27892
27902
|
|
|
27893
27903
|
// src/components/InputSelect.tsx
|
|
27894
|
-
var
|
|
27904
|
+
var import_react108 = require("react");
|
|
27895
27905
|
var import_jsx_runtime102 = require("react/jsx-runtime");
|
|
27896
|
-
var InputSelect = (0,
|
|
27906
|
+
var InputSelect = (0, import_react108.forwardRef)(function InputSelect2({
|
|
27897
27907
|
options,
|
|
27898
27908
|
value,
|
|
27899
27909
|
defaultValue,
|
|
@@ -27919,22 +27929,22 @@ var InputSelect = (0, import_react107.forwardRef)(function InputSelect2({
|
|
|
27919
27929
|
...inputProps
|
|
27920
27930
|
}, forwardedRef) {
|
|
27921
27931
|
const size = useControlSize(sizeProp);
|
|
27922
|
-
const [internal, setInternal] = (0,
|
|
27932
|
+
const [internal, setInternal] = (0, import_react108.useState)(defaultValue);
|
|
27923
27933
|
const current = value !== void 0 ? value : internal;
|
|
27924
27934
|
const values = normalizeSelectionValues(current == null ? [] : Array.isArray(current) ? current : [current], options);
|
|
27925
27935
|
const text = values.map((item) => displayField === "label" ? String(options.find((option) => option.optionType !== "divider" && option.value === item)?.label ?? item) : String(item)).join(",");
|
|
27926
|
-
const [draft, setDraft] = (0,
|
|
27927
|
-
(0,
|
|
27936
|
+
const [draft, setDraft] = (0, import_react108.useState)(text);
|
|
27937
|
+
(0, import_react108.useEffect)(() => {
|
|
27928
27938
|
setDraft(text);
|
|
27929
27939
|
}, [text, current]);
|
|
27930
|
-
const [open, setOpen] = (0,
|
|
27931
|
-
const [search, setSearch] = (0,
|
|
27932
|
-
const [modalOpen, setModalOpen] = (0,
|
|
27933
|
-
const [modalValues, setModalValues] = (0,
|
|
27934
|
-
const [selectedOnly, setSelectedOnly] = (0,
|
|
27935
|
-
const rootRef = (0,
|
|
27936
|
-
const popupRef = (0,
|
|
27937
|
-
const inputRef = (0,
|
|
27940
|
+
const [open, setOpen] = (0, import_react108.useState)(false);
|
|
27941
|
+
const [search, setSearch] = (0, import_react108.useState)("");
|
|
27942
|
+
const [modalOpen, setModalOpen] = (0, import_react108.useState)(false);
|
|
27943
|
+
const [modalValues, setModalValues] = (0, import_react108.useState)([]);
|
|
27944
|
+
const [selectedOnly, setSelectedOnly] = (0, import_react108.useState)(false);
|
|
27945
|
+
const rootRef = (0, import_react108.useRef)(null);
|
|
27946
|
+
const popupRef = (0, import_react108.useRef)(null);
|
|
27947
|
+
const inputRef = (0, import_react108.useRef)(null);
|
|
27938
27948
|
const config = typeof enableModal === "object" ? enableModal : {};
|
|
27939
27949
|
function changeOpen(next) {
|
|
27940
27950
|
if (next && (disabled || loading)) return;
|
|
@@ -27954,7 +27964,7 @@ var InputSelect = (0, import_react107.forwardRef)(function InputSelect2({
|
|
|
27954
27964
|
inputRef.current?.focus();
|
|
27955
27965
|
}
|
|
27956
27966
|
}
|
|
27957
|
-
(0,
|
|
27967
|
+
(0, import_react108.useEffect)(() => {
|
|
27958
27968
|
if (!open) return;
|
|
27959
27969
|
const outside = (event) => {
|
|
27960
27970
|
if (!rootRef.current?.contains(event.target) && !popupRef.current?.contains(event.target)) changeOpen(false);
|
|
@@ -27962,7 +27972,7 @@ var InputSelect = (0, import_react107.forwardRef)(function InputSelect2({
|
|
|
27962
27972
|
document.addEventListener("pointerdown", outside);
|
|
27963
27973
|
return () => document.removeEventListener("pointerdown", outside);
|
|
27964
27974
|
}, [open, onOpenChange]);
|
|
27965
|
-
(0,
|
|
27975
|
+
(0, import_react108.useEffect)(() => {
|
|
27966
27976
|
if (disabled || loading) {
|
|
27967
27977
|
changeOpen(false);
|
|
27968
27978
|
setModalOpen(false);
|
|
@@ -28095,10 +28105,10 @@ var InputSelect = (0, import_react107.forwardRef)(function InputSelect2({
|
|
|
28095
28105
|
});
|
|
28096
28106
|
|
|
28097
28107
|
// src/components/QueryForm.tsx
|
|
28098
|
-
var
|
|
28108
|
+
var import_react112 = require("react");
|
|
28099
28109
|
|
|
28100
28110
|
// src/components/useQueryFormMotion.ts
|
|
28101
|
-
var
|
|
28111
|
+
var import_react109 = require("react");
|
|
28102
28112
|
function readLayout(row) {
|
|
28103
28113
|
const root = row.getBoundingClientRect();
|
|
28104
28114
|
const scaleX = root.width / row.offsetWidth || 1, scaleY = root.height / row.offsetHeight || 1;
|
|
@@ -28111,10 +28121,10 @@ function readLayout(row) {
|
|
|
28111
28121
|
return { height: row.offsetHeight, boxes };
|
|
28112
28122
|
}
|
|
28113
28123
|
function useQueryFormMotion(ref, layoutKey) {
|
|
28114
|
-
const previous = (0,
|
|
28115
|
-
const stop = (0,
|
|
28116
|
-
const snapshot = (0,
|
|
28117
|
-
(0,
|
|
28124
|
+
const previous = (0, import_react109.useRef)();
|
|
28125
|
+
const stop = (0, import_react109.useRef)();
|
|
28126
|
+
const snapshot = (0, import_react109.useRef)();
|
|
28127
|
+
(0, import_react109.useLayoutEffect)(() => {
|
|
28118
28128
|
const row = ref.current;
|
|
28119
28129
|
if (!row) return;
|
|
28120
28130
|
if (!previous.current) {
|
|
@@ -28207,7 +28217,7 @@ function useQueryFormMotion(ref, layoutKey) {
|
|
|
28207
28217
|
cancelled = true;
|
|
28208
28218
|
};
|
|
28209
28219
|
}, [ref, layoutKey]);
|
|
28210
|
-
(0,
|
|
28220
|
+
(0, import_react109.useLayoutEffect)(() => {
|
|
28211
28221
|
const row = ref.current;
|
|
28212
28222
|
if (!row) return;
|
|
28213
28223
|
const observer = new ResizeObserver(() => {
|
|
@@ -28222,10 +28232,10 @@ function useQueryFormMotion(ref, layoutKey) {
|
|
|
28222
28232
|
}
|
|
28223
28233
|
|
|
28224
28234
|
// src/components/QueryFormSettings.tsx
|
|
28225
|
-
var
|
|
28235
|
+
var import_react111 = require("react");
|
|
28226
28236
|
|
|
28227
28237
|
// src/components/useQueryFieldSort.ts
|
|
28228
|
-
var
|
|
28238
|
+
var import_react110 = require("react");
|
|
28229
28239
|
function getQuerySortPreview(keys, rects, from, dy, gap) {
|
|
28230
28240
|
const center = rects[from].top + rects[from].height / 2 + dy;
|
|
28231
28241
|
const rest = keys.map((_, index) => index).filter((index) => index !== from);
|
|
@@ -28244,13 +28254,13 @@ function getQuerySortPreview(keys, rects, from, dy, gap) {
|
|
|
28244
28254
|
return { ordered, offsets };
|
|
28245
28255
|
}
|
|
28246
28256
|
function useQueryFieldSort(keys, enabled, onCommit) {
|
|
28247
|
-
const listRef = (0,
|
|
28248
|
-
const cancelRef = (0,
|
|
28249
|
-
const commitRef = (0,
|
|
28257
|
+
const listRef = (0, import_react110.useRef)(null);
|
|
28258
|
+
const cancelRef = (0, import_react110.useRef)();
|
|
28259
|
+
const commitRef = (0, import_react110.useRef)(onCommit);
|
|
28250
28260
|
commitRef.current = onCommit;
|
|
28251
|
-
const [preview, setPreview] = (0,
|
|
28261
|
+
const [preview, setPreview] = (0, import_react110.useState)();
|
|
28252
28262
|
const signature = JSON.stringify(keys);
|
|
28253
|
-
(0,
|
|
28263
|
+
(0, import_react110.useEffect)(() => {
|
|
28254
28264
|
cancelRef.current?.();
|
|
28255
28265
|
return () => cancelRef.current?.();
|
|
28256
28266
|
}, [enabled, signature]);
|
|
@@ -28375,23 +28385,27 @@ function countQueryFieldRows(centers) {
|
|
|
28375
28385
|
// src/components/QueryFormSettings.tsx
|
|
28376
28386
|
var import_jsx_runtime103 = require("react/jsx-runtime");
|
|
28377
28387
|
function useQueryFormSettings(config, fields, defaultCollapsed, applyCollapsed, disabled) {
|
|
28378
|
-
const [snapshot, setSnapshot] = (0,
|
|
28379
|
-
const [draft, setDraft] = (0,
|
|
28380
|
-
const [open, setOpen] = (0,
|
|
28381
|
-
const [loading, setLoading] = (0,
|
|
28382
|
-
const [saving, setSaving] = (0,
|
|
28383
|
-
const [error, setError] = (0,
|
|
28384
|
-
const [loadFailed, setLoadFailed] = (0,
|
|
28385
|
-
const token = (0,
|
|
28386
|
-
const saveLock = (0,
|
|
28387
|
-
const latest = (0,
|
|
28388
|
+
const [snapshot, setSnapshot] = (0, import_react111.useState)();
|
|
28389
|
+
const [draft, setDraft] = (0, import_react111.useState)({ fields: [], defaultCollapsed: defaultCollapsed ?? false });
|
|
28390
|
+
const [open, setOpen] = (0, import_react111.useState)(false);
|
|
28391
|
+
const [loading, setLoading] = (0, import_react111.useState)(false);
|
|
28392
|
+
const [saving, setSaving] = (0, import_react111.useState)(false);
|
|
28393
|
+
const [error, setError] = (0, import_react111.useState)("");
|
|
28394
|
+
const [loadFailed, setLoadFailed] = (0, import_react111.useState)(false);
|
|
28395
|
+
const token = (0, import_react111.useRef)(0);
|
|
28396
|
+
const saveLock = (0, import_react111.useRef)(false);
|
|
28397
|
+
const latest = (0, import_react111.useRef)({ config, fields, defaultCollapsed, applyCollapsed });
|
|
28388
28398
|
latest.current = { config, fields, defaultCollapsed, applyCollapsed };
|
|
28389
28399
|
const moduleName = config?.scope.moduleName;
|
|
28390
28400
|
const businessKey = config?.scope.businessKey;
|
|
28391
28401
|
const adapter = config?.adapter;
|
|
28392
28402
|
async function load(edit) {
|
|
28393
28403
|
const current = latest.current;
|
|
28394
|
-
if (!current.config)
|
|
28404
|
+
if (!current.config) {
|
|
28405
|
+
const next = snapshot ?? { fields: [], defaultCollapsed: current.defaultCollapsed ?? false };
|
|
28406
|
+
setDraft({ ...next, fields: reconcileQueryFields(current.fields.map((field) => field.key), next.fields, current.fields.filter((field) => field.hideDisabled).map((field) => field.key)) });
|
|
28407
|
+
return;
|
|
28408
|
+
}
|
|
28395
28409
|
const request = ++token.current;
|
|
28396
28410
|
setLoading(true);
|
|
28397
28411
|
setError("");
|
|
@@ -28413,7 +28427,7 @@ function useQueryFormSettings(config, fields, defaultCollapsed, applyCollapsed,
|
|
|
28413
28427
|
if (request === token.current) setLoading(false);
|
|
28414
28428
|
}
|
|
28415
28429
|
}
|
|
28416
|
-
(0,
|
|
28430
|
+
(0, import_react111.useEffect)(() => {
|
|
28417
28431
|
setSnapshot(void 0);
|
|
28418
28432
|
setOpen(false);
|
|
28419
28433
|
setError("");
|
|
@@ -28429,7 +28443,7 @@ function useQueryFormSettings(config, fields, defaultCollapsed, applyCollapsed,
|
|
|
28429
28443
|
}, [adapter, moduleName, businessKey]);
|
|
28430
28444
|
async function save() {
|
|
28431
28445
|
const current = latest.current;
|
|
28432
|
-
if (
|
|
28446
|
+
if (loading || loadFailed || disabled || saveLock.current) return false;
|
|
28433
28447
|
saveLock.current = true;
|
|
28434
28448
|
setSaving(true);
|
|
28435
28449
|
setError("");
|
|
@@ -28437,7 +28451,7 @@ function useQueryFormSettings(config, fields, defaultCollapsed, applyCollapsed,
|
|
|
28437
28451
|
const active = reconcileQueryFields(current.fields.map((field) => field.key), draft.fields, current.fields.filter((field) => field.hideDisabled).map((field) => field.key));
|
|
28438
28452
|
const next = { ...draft, fields: mergeQueryFields(snapshot?.fields ?? [], active) };
|
|
28439
28453
|
try {
|
|
28440
|
-
await saveSettingsPatch(current.config.adapter, current.config.scope, { queryForm: next });
|
|
28454
|
+
if (current.config) await saveSettingsPatch(current.config.adapter, current.config.scope, { queryForm: next });
|
|
28441
28455
|
if (request !== token.current) return false;
|
|
28442
28456
|
setSnapshot(next);
|
|
28443
28457
|
current.applyCollapsed(next.defaultCollapsed);
|
|
@@ -28446,7 +28460,7 @@ function useQueryFormSettings(config, fields, defaultCollapsed, applyCollapsed,
|
|
|
28446
28460
|
} catch (reason) {
|
|
28447
28461
|
if (request !== token.current) return false;
|
|
28448
28462
|
setError(reason instanceof Error ? reason.message : "\u4FDD\u5B58\u67E5\u8BE2\u8BBE\u7F6E\u5931\u8D25");
|
|
28449
|
-
current.config
|
|
28463
|
+
current.config?.onError?.(reason, "save");
|
|
28450
28464
|
return false;
|
|
28451
28465
|
} finally {
|
|
28452
28466
|
if (request === token.current) {
|
|
@@ -28469,7 +28483,7 @@ function useQueryFormSettings(config, fields, defaultCollapsed, applyCollapsed,
|
|
|
28469
28483
|
const items = new Map(visibleDraft.map((item) => [item.key, item]));
|
|
28470
28484
|
setDraft((current) => ({ ...current, fields: keys.map((key, order) => ({ ...items.get(key), order })) }));
|
|
28471
28485
|
});
|
|
28472
|
-
const control =
|
|
28486
|
+
const control = /* @__PURE__ */ (0, import_jsx_runtime103.jsx)(
|
|
28473
28487
|
Button,
|
|
28474
28488
|
{
|
|
28475
28489
|
type: "button",
|
|
@@ -28484,8 +28498,8 @@ function useQueryFormSettings(config, fields, defaultCollapsed, applyCollapsed,
|
|
|
28484
28498
|
void load(true);
|
|
28485
28499
|
}
|
|
28486
28500
|
}
|
|
28487
|
-
)
|
|
28488
|
-
const panel =
|
|
28501
|
+
);
|
|
28502
|
+
const panel = /* @__PURE__ */ (0, import_jsx_runtime103.jsx)(import_jsx_runtime103.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime103.jsx)(
|
|
28489
28503
|
Modal2,
|
|
28490
28504
|
{
|
|
28491
28505
|
title: "\u67E5\u8BE2\u8BBE\u7F6E",
|
|
@@ -28528,7 +28542,7 @@ function useQueryFormSettings(config, fields, defaultCollapsed, applyCollapsed,
|
|
|
28528
28542
|
/* @__PURE__ */ (0, import_jsx_runtime103.jsx)(Button, { type: "button", disabled: locked, onClick: () => setDraft({ fields: reconcileQueryFields(fields.map((field) => field.key)), defaultCollapsed: defaultCollapsed ?? false }), children: "\u6062\u590D\u9ED8\u8BA4" })
|
|
28529
28543
|
] })
|
|
28530
28544
|
}
|
|
28531
|
-
) })
|
|
28545
|
+
) });
|
|
28532
28546
|
return { snapshot, control, panel };
|
|
28533
28547
|
}
|
|
28534
28548
|
|
|
@@ -28537,7 +28551,7 @@ var import_jsx_runtime104 = require("react/jsx-runtime");
|
|
|
28537
28551
|
function QueryForm({
|
|
28538
28552
|
fields,
|
|
28539
28553
|
settings,
|
|
28540
|
-
showSettings,
|
|
28554
|
+
showSettings = true,
|
|
28541
28555
|
children,
|
|
28542
28556
|
form: providedForm,
|
|
28543
28557
|
onSearch,
|
|
@@ -28568,26 +28582,26 @@ function QueryForm({
|
|
|
28568
28582
|
...formProps
|
|
28569
28583
|
}) {
|
|
28570
28584
|
const [form] = useForm(providedForm);
|
|
28571
|
-
const [internalCollapsed, setInternalCollapsed] = (0,
|
|
28572
|
-
const [expandedRows, setExpandedRows] = (0,
|
|
28573
|
-
const [needsCollapse, setNeedsCollapse] = (0,
|
|
28585
|
+
const [internalCollapsed, setInternalCollapsed] = (0, import_react112.useState)(defaultCollapsed);
|
|
28586
|
+
const [expandedRows, setExpandedRows] = (0, import_react112.useState)(0);
|
|
28587
|
+
const [needsCollapse, setNeedsCollapse] = (0, import_react112.useState)(false);
|
|
28574
28588
|
const collapsed = collapsible && needsCollapse && (controlledCollapsed ?? internalCollapsed ?? expandedRows >= 3);
|
|
28575
|
-
const [searching, setSearching] = (0,
|
|
28576
|
-
const [saving, setSaving] = (0,
|
|
28577
|
-
const [removing, setRemoving] = (0,
|
|
28578
|
-
const [saveOpen, setSaveOpen] = (0,
|
|
28579
|
-
const [saveName, setSaveName] = (0,
|
|
28580
|
-
const [saveError, setSaveError] = (0,
|
|
28581
|
-
const [activeShortcut, setActiveShortcut] = (0,
|
|
28582
|
-
const source = (0,
|
|
28583
|
-
const searchLock = (0,
|
|
28584
|
-
const saveLock = (0,
|
|
28585
|
-
const removeLock = (0,
|
|
28586
|
-
const snapshot = (0,
|
|
28589
|
+
const [searching, setSearching] = (0, import_react112.useState)(false);
|
|
28590
|
+
const [saving, setSaving] = (0, import_react112.useState)(false);
|
|
28591
|
+
const [removing, setRemoving] = (0, import_react112.useState)(false);
|
|
28592
|
+
const [saveOpen, setSaveOpen] = (0, import_react112.useState)(false);
|
|
28593
|
+
const [saveName, setSaveName] = (0, import_react112.useState)("");
|
|
28594
|
+
const [saveError, setSaveError] = (0, import_react112.useState)("");
|
|
28595
|
+
const [activeShortcut, setActiveShortcut] = (0, import_react112.useState)("");
|
|
28596
|
+
const source = (0, import_react112.useRef)({ source: "submit" });
|
|
28597
|
+
const searchLock = (0, import_react112.useRef)(false);
|
|
28598
|
+
const saveLock = (0, import_react112.useRef)(false);
|
|
28599
|
+
const removeLock = (0, import_react112.useRef)(false);
|
|
28600
|
+
const snapshot = (0, import_react112.useRef)();
|
|
28587
28601
|
const busy = disabled || loading || searching;
|
|
28588
28602
|
const shortcutBusy = busy || shortcutsLoading || saving || removing;
|
|
28589
28603
|
const fieldLabel = (content) => {
|
|
28590
|
-
if (!(0,
|
|
28604
|
+
if (!(0, import_react112.isValidElement)(content)) return void 0;
|
|
28591
28605
|
return content.props.label ?? content.props.placeholder ?? fieldLabel(content.props.children);
|
|
28592
28606
|
};
|
|
28593
28607
|
const sourceEntries = fields ? fields.map(({ key, width, settingsLabel, settingsHideDisabled, ...item }) => ({
|
|
@@ -28596,8 +28610,8 @@ function QueryForm({
|
|
|
28596
28610
|
hideDisabled: settingsHideDisabled,
|
|
28597
28611
|
label: settingsLabel ?? item.label ?? (typeof item.children === "function" ? void 0 : fieldLabel(item.children)) ?? key,
|
|
28598
28612
|
content: /* @__PURE__ */ (0, import_jsx_runtime104.jsx)(Form.Item, { noStyle: true, ...item })
|
|
28599
|
-
})) :
|
|
28600
|
-
key: (0,
|
|
28613
|
+
})) : import_react112.Children.toArray(children).map((content, index) => ({
|
|
28614
|
+
key: (0, import_react112.isValidElement)(content) && content.key != null ? String(content.key) : String(index),
|
|
28601
28615
|
width: void 0,
|
|
28602
28616
|
hideDisabled: false,
|
|
28603
28617
|
label: fieldLabel(content) ?? `\u6761\u4EF6 ${index + 1}`,
|
|
@@ -28610,33 +28624,17 @@ function QueryForm({
|
|
|
28610
28624
|
const entries = configured.map((item) => ({ ...entriesByKey.get(item.key), visible: item.visible, visibleIndex: item.visible ? visibleIndex++ : -1 }));
|
|
28611
28625
|
const layoutKey = JSON.stringify(configured);
|
|
28612
28626
|
const limit = Math.max(1, Math.floor(collapsedCount));
|
|
28613
|
-
const rowRef = (0,
|
|
28614
|
-
const actionsRef = (0,
|
|
28615
|
-
const toggleRef = (0,
|
|
28616
|
-
const [fittingCount, setFittingCount] = (0,
|
|
28617
|
-
|
|
28618
|
-
(0, import_react111.useLayoutEffect)(() => {
|
|
28627
|
+
const rowRef = (0, import_react112.useRef)(null);
|
|
28628
|
+
const actionsRef = (0, import_react112.useRef)(null);
|
|
28629
|
+
const toggleRef = (0, import_react112.useRef)(null);
|
|
28630
|
+
const [fittingCount, setFittingCount] = (0, import_react112.useState)(limit);
|
|
28631
|
+
(0, import_react112.useLayoutEffect)(() => {
|
|
28619
28632
|
const row = rowRef.current;
|
|
28620
28633
|
const actions = actionsRef.current;
|
|
28621
28634
|
if (!row || !actions) return;
|
|
28622
28635
|
function measure() {
|
|
28623
28636
|
if (!row || !actions || row.dataset.queryMotion === "true") return;
|
|
28624
28637
|
const gap = parseFloat(getComputedStyle(row).columnGap) || 0;
|
|
28625
|
-
const sourceFields = Array.from(row.querySelectorAll(":scope > .sia-query-form__field"));
|
|
28626
|
-
const sourceHidden = sourceFields.map((field) => field.hidden);
|
|
28627
|
-
const sourceCollapsed = row.classList.contains("is-collapsed");
|
|
28628
|
-
row.classList.remove("is-collapsed");
|
|
28629
|
-
sourceFields.forEach((field) => {
|
|
28630
|
-
field.hidden = false;
|
|
28631
|
-
});
|
|
28632
|
-
if (row.clientWidth > 0) setSettingsRows(countQueryFieldRows(sourceFields.map((field) => {
|
|
28633
|
-
const rect = field.getBoundingClientRect();
|
|
28634
|
-
return rect.top + rect.height / 2;
|
|
28635
|
-
})));
|
|
28636
|
-
sourceFields.forEach((field, index) => {
|
|
28637
|
-
field.hidden = sourceHidden[index];
|
|
28638
|
-
});
|
|
28639
|
-
row.classList.toggle("is-collapsed", sourceCollapsed);
|
|
28640
28638
|
const allFields = Array.from(
|
|
28641
28639
|
row.querySelectorAll(":scope > .sia-query-form__field:not([data-settings-hidden])")
|
|
28642
28640
|
);
|
|
@@ -28865,7 +28863,7 @@ function QueryForm({
|
|
|
28865
28863
|
children: saveText
|
|
28866
28864
|
}
|
|
28867
28865
|
) : null,
|
|
28868
|
-
showSettings
|
|
28866
|
+
showSettings ? cloudSettings.control : null
|
|
28869
28867
|
] }),
|
|
28870
28868
|
collapsible && entries.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime104.jsx)("span", { ref: toggleRef, hidden: !needsCollapse, children: /* @__PURE__ */ (0, import_jsx_runtime104.jsx)(
|
|
28871
28869
|
Button,
|
|
@@ -28956,9 +28954,9 @@ function QueryForm({
|
|
|
28956
28954
|
}
|
|
28957
28955
|
|
|
28958
28956
|
// src/components/NumberRange.tsx
|
|
28959
|
-
var
|
|
28957
|
+
var import_react113 = require("react");
|
|
28960
28958
|
var import_jsx_runtime105 = require("react/jsx-runtime");
|
|
28961
|
-
var NumberRange = (0,
|
|
28959
|
+
var NumberRange = (0, import_react113.forwardRef)(function NumberRange2({
|
|
28962
28960
|
value,
|
|
28963
28961
|
defaultValue = [null, null],
|
|
28964
28962
|
onChange,
|
|
@@ -29047,7 +29045,7 @@ function Result({ status = "info", title, subTitle, icon, extra, children, class
|
|
|
29047
29045
|
}
|
|
29048
29046
|
|
|
29049
29047
|
// src/components/VirtualGrid.tsx
|
|
29050
|
-
var
|
|
29048
|
+
var import_react114 = require("react");
|
|
29051
29049
|
var import_jsx_runtime107 = require("react/jsx-runtime");
|
|
29052
29050
|
function VirtualGrid({
|
|
29053
29051
|
items,
|
|
@@ -29067,11 +29065,11 @@ function VirtualGrid({
|
|
|
29067
29065
|
tabIndex = 0,
|
|
29068
29066
|
...props
|
|
29069
29067
|
}) {
|
|
29070
|
-
const viewport = (0,
|
|
29071
|
-
const [size, setSize] = (0,
|
|
29072
|
-
const [scrollTop, setScrollTop] = (0,
|
|
29073
|
-
const frame = (0,
|
|
29074
|
-
const requestedLength = (0,
|
|
29068
|
+
const viewport = (0, import_react114.useRef)(null);
|
|
29069
|
+
const [size, setSize] = (0, import_react114.useState)({ width: 0, height: 0 });
|
|
29070
|
+
const [scrollTop, setScrollTop] = (0, import_react114.useState)(0);
|
|
29071
|
+
const frame = (0, import_react114.useRef)();
|
|
29072
|
+
const requestedLength = (0, import_react114.useRef)();
|
|
29075
29073
|
const height = Math.max(1, rowHeight);
|
|
29076
29074
|
const spacing = Math.max(0, gap);
|
|
29077
29075
|
const columns = Math.max(1, Math.floor((size.width + spacing) / (Math.max(1, minColumnWidth) + spacing)));
|
|
@@ -29081,7 +29079,7 @@ function VirtualGrid({
|
|
|
29081
29079
|
const paddingRows = Math.max(0, Math.floor(overscan));
|
|
29082
29080
|
const startRow = Math.max(0, Math.min(rowCount - 1, Math.floor(scrollTop / stride)) - paddingRows);
|
|
29083
29081
|
const endRow = Math.min(rowCount, Math.ceil((scrollTop + size.height) / stride) + paddingRows);
|
|
29084
|
-
(0,
|
|
29082
|
+
(0, import_react114.useLayoutEffect)(() => {
|
|
29085
29083
|
const el = viewport.current;
|
|
29086
29084
|
if (!el) return;
|
|
29087
29085
|
const measure = () => setSize((previous) => previous.width === el.clientWidth && previous.height === el.clientHeight ? previous : { width: el.clientWidth, height: el.clientHeight });
|
|
@@ -29093,14 +29091,14 @@ function VirtualGrid({
|
|
|
29093
29091
|
if (frame.current !== void 0) cancelAnimationFrame(frame.current);
|
|
29094
29092
|
};
|
|
29095
29093
|
}, []);
|
|
29096
|
-
(0,
|
|
29094
|
+
(0, import_react114.useLayoutEffect)(() => {
|
|
29097
29095
|
const el = viewport.current;
|
|
29098
29096
|
if (!el) return;
|
|
29099
29097
|
const next = Math.min(el.scrollTop, Math.max(0, totalHeight - size.height));
|
|
29100
29098
|
if (el.scrollTop !== next) el.scrollTop = next;
|
|
29101
29099
|
setScrollTop(next);
|
|
29102
29100
|
}, [totalHeight, size.height]);
|
|
29103
|
-
(0,
|
|
29101
|
+
(0, import_react114.useEffect)(() => {
|
|
29104
29102
|
if (!onLoadMore || !hasMore || loading || size.height <= 0) return;
|
|
29105
29103
|
if (totalHeight - scrollTop - size.height > Math.max(0, loadMoreThreshold)) return;
|
|
29106
29104
|
if (requestedLength.current === items.length) return;
|