@sia.soul/sia-react-ui 0.1.14 → 0.1.17
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-25BU7YTB.js → chunk-G47MREYI.js} +1 -1
- package/dist/{chunk-K3XRTEIO.js → chunk-KJYKC5IV.js} +3 -2
- package/dist/{chunk-R3TYVU53.js → chunk-VXSG4EAO.js} +384 -6
- package/dist/{core-BK8AXc12.d.cts → core-AeKYVPDZ.d.cts} +4 -2
- package/dist/{core-CJK3_KTQ.d.ts → core-DcSXqSRs.d.ts} +4 -2
- package/dist/core.cjs +434 -57
- package/dist/core.css +143 -1
- package/dist/core.d.cts +1 -1
- package/dist/core.d.ts +1 -1
- package/dist/core.js +2 -2
- package/dist/index.cjs +10900 -9802
- package/dist/index.css +143 -1
- package/dist/index.d.cts +59 -5
- package/dist/index.d.ts +59 -5
- package/dist/index.js +1456 -734
- package/dist/select-date-range.cjs +400 -24
- package/dist/select-date-range.js +2 -2
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -79,7 +79,7 @@ import {
|
|
|
79
79
|
Watermark,
|
|
80
80
|
message,
|
|
81
81
|
notification
|
|
82
|
-
} from "./chunk-
|
|
82
|
+
} from "./chunk-KJYKC5IV.js";
|
|
83
83
|
import {
|
|
84
84
|
TextArea
|
|
85
85
|
} from "./chunk-YT6E3X2K.js";
|
|
@@ -94,9 +94,10 @@ import {
|
|
|
94
94
|
DatePicker,
|
|
95
95
|
SelectDateRange,
|
|
96
96
|
TimePanel
|
|
97
|
-
} from "./chunk-
|
|
97
|
+
} from "./chunk-G47MREYI.js";
|
|
98
98
|
import {
|
|
99
99
|
Checkbox,
|
|
100
|
+
FloatingScrollbarProvider,
|
|
100
101
|
Modal,
|
|
101
102
|
OverflowTags,
|
|
102
103
|
OverlayPortal,
|
|
@@ -106,8 +107,9 @@ import {
|
|
|
106
107
|
Timeline,
|
|
107
108
|
Tooltip,
|
|
108
109
|
Tree,
|
|
109
|
-
useOverlayLifecycle
|
|
110
|
-
|
|
110
|
+
useOverlayLifecycle,
|
|
111
|
+
useScrollbarProximity
|
|
112
|
+
} from "./chunk-VXSG4EAO.js";
|
|
111
113
|
import {
|
|
112
114
|
Dropdown,
|
|
113
115
|
FILLED_ICON_NAMES,
|
|
@@ -1337,7 +1339,7 @@ function openDrawer(config) {
|
|
|
1337
1339
|
let currentOpen = true;
|
|
1338
1340
|
let destroyed = false;
|
|
1339
1341
|
let cleanupTimer;
|
|
1340
|
-
function
|
|
1342
|
+
function cleanup() {
|
|
1341
1343
|
if (destroyed) return;
|
|
1342
1344
|
destroyed = true;
|
|
1343
1345
|
if (cleanupTimer !== void 0) window.clearTimeout(cleanupTimer);
|
|
@@ -1349,7 +1351,7 @@ function openDrawer(config) {
|
|
|
1349
1351
|
if (destroyed || !currentOpen) return;
|
|
1350
1352
|
currentOpen = false;
|
|
1351
1353
|
render();
|
|
1352
|
-
cleanupTimer = window.setTimeout(
|
|
1354
|
+
cleanupTimer = window.setTimeout(cleanup, DRAWER_MOTION_DURATION + 100);
|
|
1353
1355
|
}
|
|
1354
1356
|
function render() {
|
|
1355
1357
|
root.render(/* @__PURE__ */ jsx8(
|
|
@@ -1364,7 +1366,7 @@ function openDrawer(config) {
|
|
|
1364
1366
|
afterOpen: () => currentConfig.afterOpen?.(),
|
|
1365
1367
|
afterClose: () => {
|
|
1366
1368
|
currentConfig.afterClose?.();
|
|
1367
|
-
|
|
1369
|
+
cleanup();
|
|
1368
1370
|
}
|
|
1369
1371
|
}
|
|
1370
1372
|
));
|
|
@@ -3896,7 +3898,7 @@ function Markdown({ content, emptyText = "\u6682\u65E0 Markdown \u5185\u5BB9", r
|
|
|
3896
3898
|
});
|
|
3897
3899
|
return () => {
|
|
3898
3900
|
cancelled = true;
|
|
3899
|
-
cleanups.forEach((
|
|
3901
|
+
cleanups.forEach((cleanup) => cleanup());
|
|
3900
3902
|
};
|
|
3901
3903
|
}, [html, imagePreview, resolveImageSrc]);
|
|
3902
3904
|
function openImagePreview(target) {
|
|
@@ -4489,68 +4491,6 @@ function Treemap({
|
|
|
4489
4491
|
);
|
|
4490
4492
|
}
|
|
4491
4493
|
|
|
4492
|
-
// src/components/useScrollbarProximity.ts
|
|
4493
|
-
import { useEffect as useEffect11 } from "react";
|
|
4494
|
-
var users = 0;
|
|
4495
|
-
var cleanup;
|
|
4496
|
-
function useScrollbarProximity() {
|
|
4497
|
-
useEffect11(() => {
|
|
4498
|
-
if (users++ === 0) {
|
|
4499
|
-
let frame = 0;
|
|
4500
|
-
let x = -Infinity;
|
|
4501
|
-
let y = -Infinity;
|
|
4502
|
-
const nearby = /* @__PURE__ */ new Set();
|
|
4503
|
-
const clear = () => {
|
|
4504
|
-
nearby.forEach((track) => track.removeAttribute("data-scrollbar-near"));
|
|
4505
|
-
nearby.clear();
|
|
4506
|
-
};
|
|
4507
|
-
const update = () => {
|
|
4508
|
-
frame = 0;
|
|
4509
|
-
const next = /* @__PURE__ */ new Set();
|
|
4510
|
-
document.querySelectorAll(".sia-scrollbar-track").forEach((track) => {
|
|
4511
|
-
const rect = track.getBoundingClientRect();
|
|
4512
|
-
const proximity = Number.parseFloat(getComputedStyle(track).getPropertyValue("--sia-scrollbar-proximity")) || 16;
|
|
4513
|
-
if (rect.width && rect.height && x >= rect.left - proximity && x <= rect.right + proximity && y >= rect.top - proximity && y <= rect.bottom + proximity) {
|
|
4514
|
-
next.add(track);
|
|
4515
|
-
if (!nearby.has(track)) track.setAttribute("data-scrollbar-near", "true");
|
|
4516
|
-
}
|
|
4517
|
-
});
|
|
4518
|
-
nearby.forEach((track) => {
|
|
4519
|
-
if (!next.has(track)) track.removeAttribute("data-scrollbar-near");
|
|
4520
|
-
});
|
|
4521
|
-
nearby.clear();
|
|
4522
|
-
next.forEach((track) => nearby.add(track));
|
|
4523
|
-
};
|
|
4524
|
-
const move = (event) => {
|
|
4525
|
-
if (event.pointerType === "touch") return;
|
|
4526
|
-
x = event.clientX;
|
|
4527
|
-
y = event.clientY;
|
|
4528
|
-
if (!frame) frame = requestAnimationFrame(update);
|
|
4529
|
-
};
|
|
4530
|
-
const leave = () => {
|
|
4531
|
-
x = y = -Infinity;
|
|
4532
|
-
clear();
|
|
4533
|
-
};
|
|
4534
|
-
document.addEventListener("pointermove", move, { passive: true });
|
|
4535
|
-
document.documentElement.addEventListener("pointerleave", leave);
|
|
4536
|
-
window.addEventListener("blur", leave);
|
|
4537
|
-
cleanup = () => {
|
|
4538
|
-
if (frame) cancelAnimationFrame(frame);
|
|
4539
|
-
document.removeEventListener("pointermove", move);
|
|
4540
|
-
document.documentElement.removeEventListener("pointerleave", leave);
|
|
4541
|
-
window.removeEventListener("blur", leave);
|
|
4542
|
-
clear();
|
|
4543
|
-
};
|
|
4544
|
-
}
|
|
4545
|
-
return () => {
|
|
4546
|
-
if (--users === 0) {
|
|
4547
|
-
cleanup?.();
|
|
4548
|
-
cleanup = void 0;
|
|
4549
|
-
}
|
|
4550
|
-
};
|
|
4551
|
-
}, []);
|
|
4552
|
-
}
|
|
4553
|
-
|
|
4554
4494
|
// src/components/Table/TableCellContent.tsx
|
|
4555
4495
|
import { useLayoutEffect as useLayoutEffect2, useRef as useRef13, useState as useState15 } from "react";
|
|
4556
4496
|
import { jsx as jsx19 } from "react/jsx-runtime";
|
|
@@ -4590,10 +4530,10 @@ function TableCellContent({ children, ellipsis, title }) {
|
|
|
4590
4530
|
}
|
|
4591
4531
|
|
|
4592
4532
|
// src/components/Table/Table.tsx
|
|
4593
|
-
import { Fragment as Fragment7, forwardRef as forwardRef5, memo, useCallback as useCallback2, useEffect as
|
|
4533
|
+
import { Fragment as Fragment7, forwardRef as forwardRef5, memo, useCallback as useCallback2, useEffect as useEffect12, useImperativeHandle, useMemo as useMemo9, useRef as useRef15, useState as useState17 } from "react";
|
|
4594
4534
|
|
|
4595
4535
|
// src/components/Table/plugins.tsx
|
|
4596
|
-
import { isValidElement as isValidElement3, useEffect as
|
|
4536
|
+
import { isValidElement as isValidElement3, useEffect as useEffect11, useRef as useRef14, useState as useState16 } from "react";
|
|
4597
4537
|
|
|
4598
4538
|
// src/components/Table/utils.ts
|
|
4599
4539
|
var AUTO_WIDTH_COLUMN_KEYS = /* @__PURE__ */ new Set(["action", "actions", "operation", "operations"]);
|
|
@@ -4647,8 +4587,25 @@ function toTablePageParams(current, pageSize) {
|
|
|
4647
4587
|
|
|
4648
4588
|
// src/components/Table/plugins.tsx
|
|
4649
4589
|
import { Fragment as Fragment6, jsx as jsx20, jsxs as jsxs19 } from "react/jsx-runtime";
|
|
4650
|
-
function TableCheckbox({
|
|
4651
|
-
|
|
4590
|
+
function TableCheckbox({
|
|
4591
|
+
checked,
|
|
4592
|
+
indeterminate,
|
|
4593
|
+
disabled,
|
|
4594
|
+
label,
|
|
4595
|
+
onChange
|
|
4596
|
+
}) {
|
|
4597
|
+
return /* @__PURE__ */ jsx20(
|
|
4598
|
+
Checkbox,
|
|
4599
|
+
{
|
|
4600
|
+
className: "sia-table__checkbox",
|
|
4601
|
+
"aria-label": label,
|
|
4602
|
+
checked,
|
|
4603
|
+
indeterminate,
|
|
4604
|
+
disabled,
|
|
4605
|
+
onClick: (event) => event.stopPropagation(),
|
|
4606
|
+
onChange
|
|
4607
|
+
}
|
|
4608
|
+
);
|
|
4652
4609
|
}
|
|
4653
4610
|
function flattenRecords(data, childrenColumnName) {
|
|
4654
4611
|
const result = [];
|
|
@@ -4667,7 +4624,11 @@ function createColumnTransformPlugin(options) {
|
|
|
4667
4624
|
id: "columnTransform",
|
|
4668
4625
|
order: 2,
|
|
4669
4626
|
transformColumns(columns) {
|
|
4670
|
-
const composed = [
|
|
4627
|
+
const composed = [
|
|
4628
|
+
...options.prepend ?? [],
|
|
4629
|
+
...columns,
|
|
4630
|
+
...options.append ?? []
|
|
4631
|
+
];
|
|
4671
4632
|
return options.transform?.(composed) ?? composed;
|
|
4672
4633
|
}
|
|
4673
4634
|
};
|
|
@@ -4705,7 +4666,8 @@ function createHighlightPlugin(options = { row: true }) {
|
|
|
4705
4666
|
},
|
|
4706
4667
|
onCellMouseEnter(row, column, context) {
|
|
4707
4668
|
if (!rowEnabled && !columnEnabled && !cellEnabled) return;
|
|
4708
|
-
if (context.state.rowKey === row.key && context.state.columnKey === column.key)
|
|
4669
|
+
if (context.state.rowKey === row.key && context.state.columnKey === column.key)
|
|
4670
|
+
return;
|
|
4709
4671
|
context.setState({ rowKey: row.key, columnKey: column.key });
|
|
4710
4672
|
},
|
|
4711
4673
|
onRowMouseLeave(row, context) {
|
|
@@ -4717,7 +4679,11 @@ function sameCellAddress(left, right) {
|
|
|
4717
4679
|
return Object.is(left.rowKey, right.rowKey) && left.columnKey === right.columnKey;
|
|
4718
4680
|
}
|
|
4719
4681
|
function isInteractiveTableTarget(target) {
|
|
4720
|
-
return target instanceof Element && Boolean(
|
|
4682
|
+
return target instanceof Element && Boolean(
|
|
4683
|
+
target.closest(
|
|
4684
|
+
"button, input, textarea, select, a, [contenteditable='true'], [role='button'], [role='separator']"
|
|
4685
|
+
)
|
|
4686
|
+
);
|
|
4721
4687
|
}
|
|
4722
4688
|
function createCellSelectionPlugin(options = {}) {
|
|
4723
4689
|
let dragMode = null;
|
|
@@ -4774,9 +4740,14 @@ function createCellSelectionPlugin(options = {}) {
|
|
|
4774
4740
|
const rows = context.rows;
|
|
4775
4741
|
const columns = selectableColumns(context);
|
|
4776
4742
|
const range = context.state.range;
|
|
4777
|
-
if (snapshotCache?.rows === rows && snapshotCache.columns.length === columns.length && snapshotCache.columns.every(
|
|
4743
|
+
if (snapshotCache?.rows === rows && snapshotCache.columns.length === columns.length && snapshotCache.columns.every(
|
|
4744
|
+
(column, index) => column === columns[index]
|
|
4745
|
+
) && snapshotCache.range === range)
|
|
4746
|
+
return snapshotCache;
|
|
4778
4747
|
const rowIndexes = new Map(rows.map((row, index) => [row.key, index]));
|
|
4779
|
-
const columnIndexes = new Map(
|
|
4748
|
+
const columnIndexes = new Map(
|
|
4749
|
+
columns.map((column, index) => [column.key, index])
|
|
4750
|
+
);
|
|
4780
4751
|
const anchorRow = range ? rowIndexes.get(range.anchor.rowKey) : void 0;
|
|
4781
4752
|
const focusRow = range ? rowIndexes.get(range.focus.rowKey) : void 0;
|
|
4782
4753
|
const anchorColumn = range ? columnIndexes.get(range.anchor.columnKey) : void 0;
|
|
@@ -4797,19 +4768,30 @@ function createCellSelectionPlugin(options = {}) {
|
|
|
4797
4768
|
}
|
|
4798
4769
|
function selectedCells(context) {
|
|
4799
4770
|
const snapshot = getSnapshot(context);
|
|
4800
|
-
if (!snapshot.range || snapshot.top < 0)
|
|
4771
|
+
if (!snapshot.range || snapshot.top < 0)
|
|
4772
|
+
return [];
|
|
4801
4773
|
const cells = [];
|
|
4802
4774
|
for (let rowIndex = snapshot.top; rowIndex <= snapshot.bottom; rowIndex += 1) {
|
|
4803
4775
|
const row = snapshot.rows[rowIndex];
|
|
4804
4776
|
for (let columnIndex = snapshot.left; columnIndex <= snapshot.right; columnIndex += 1) {
|
|
4805
4777
|
const column = snapshot.columns[columnIndex];
|
|
4806
|
-
if (!(options.isCellSelectable?.(
|
|
4778
|
+
if (!(options.isCellSelectable?.(
|
|
4779
|
+
row.record,
|
|
4780
|
+
column,
|
|
4781
|
+
rowIndex,
|
|
4782
|
+
columnIndex
|
|
4783
|
+
) ?? true))
|
|
4784
|
+
continue;
|
|
4807
4785
|
cells.push({
|
|
4808
4786
|
rowKey: row.key,
|
|
4809
4787
|
columnKey: column.key,
|
|
4810
4788
|
record: row.record,
|
|
4811
4789
|
column,
|
|
4812
|
-
value: getTableValue(
|
|
4790
|
+
value: getTableValue(
|
|
4791
|
+
row.record,
|
|
4792
|
+
column.dataIndex,
|
|
4793
|
+
column.code ?? column.key
|
|
4794
|
+
),
|
|
4813
4795
|
rowIndex,
|
|
4814
4796
|
columnIndex
|
|
4815
4797
|
});
|
|
@@ -4823,9 +4805,18 @@ function createCellSelectionPlugin(options = {}) {
|
|
|
4823
4805
|
return snapshot.columns.slice(snapshot.left, snapshot.right + 1);
|
|
4824
4806
|
}
|
|
4825
4807
|
function clipboardCellText(row, column, rowIndex) {
|
|
4826
|
-
const value = getTableValue(
|
|
4808
|
+
const value = getTableValue(
|
|
4809
|
+
row.record,
|
|
4810
|
+
column.dataIndex,
|
|
4811
|
+
column.code ?? column.key
|
|
4812
|
+
);
|
|
4827
4813
|
const info = { row, rowIndex, column };
|
|
4828
|
-
const exported = column.exportRender?.(
|
|
4814
|
+
const exported = column.exportRender?.(
|
|
4815
|
+
value,
|
|
4816
|
+
row.record,
|
|
4817
|
+
row.sourceIndex,
|
|
4818
|
+
info
|
|
4819
|
+
);
|
|
4829
4820
|
if (exported !== void 0) return tableExportText(exported);
|
|
4830
4821
|
if (column.editable) return tableExportCell(value, true);
|
|
4831
4822
|
const rendered = column.render?.(value, row.record, row.sourceIndex, info);
|
|
@@ -4837,46 +4828,81 @@ function createCellSelectionPlugin(options = {}) {
|
|
|
4837
4828
|
const columns = selectedColumns(context);
|
|
4838
4829
|
const lines = [];
|
|
4839
4830
|
if (context.state.includeHeaders && columns.length > 0) {
|
|
4840
|
-
const paths = columns.map(
|
|
4841
|
-
|
|
4831
|
+
const paths = columns.map(
|
|
4832
|
+
(column) => findColumnPath(
|
|
4833
|
+
sortTableColumnsByFixed(context.columns),
|
|
4834
|
+
column.key
|
|
4835
|
+
) ?? [column]
|
|
4836
|
+
);
|
|
4837
|
+
const maximumDepth = paths.reduce(
|
|
4838
|
+
(maximum, path) => Math.max(maximum, path.length),
|
|
4839
|
+
1
|
|
4840
|
+
);
|
|
4842
4841
|
for (let depth = 0; depth < maximumDepth; depth += 1) {
|
|
4843
|
-
lines.push(
|
|
4844
|
-
|
|
4845
|
-
|
|
4846
|
-
|
|
4842
|
+
lines.push(
|
|
4843
|
+
paths.map((path) => {
|
|
4844
|
+
const offset = maximumDepth - path.length;
|
|
4845
|
+
return depth < offset ? "" : tableExportEscape(getColumnLabel(path[depth - offset]), " ");
|
|
4846
|
+
}).join(" ")
|
|
4847
|
+
);
|
|
4847
4848
|
}
|
|
4848
4849
|
}
|
|
4849
4850
|
for (let rowIndex = snapshot.top; rowIndex <= snapshot.bottom; rowIndex += 1) {
|
|
4850
4851
|
const row = snapshot.rows[rowIndex];
|
|
4851
|
-
lines.push(
|
|
4852
|
-
|
|
4853
|
-
|
|
4854
|
-
|
|
4855
|
-
|
|
4852
|
+
lines.push(
|
|
4853
|
+
columns.map((column, columnOffset) => {
|
|
4854
|
+
const columnIndex = snapshot.left + columnOffset;
|
|
4855
|
+
if (!(options.isCellSelectable?.(
|
|
4856
|
+
row.record,
|
|
4857
|
+
column,
|
|
4858
|
+
rowIndex,
|
|
4859
|
+
columnIndex
|
|
4860
|
+
) ?? true))
|
|
4861
|
+
return "";
|
|
4862
|
+
return tableExportEscape(
|
|
4863
|
+
clipboardCellText(row, column, rowIndex),
|
|
4864
|
+
" "
|
|
4865
|
+
);
|
|
4866
|
+
}).join(" ")
|
|
4867
|
+
);
|
|
4856
4868
|
}
|
|
4857
4869
|
return lines.join("\r\n");
|
|
4858
4870
|
}
|
|
4859
4871
|
function setSelection(context, range, includeHeaders = false, selectedHeaderKey = null) {
|
|
4860
4872
|
rememberContext(context);
|
|
4861
4873
|
snapshotCache = null;
|
|
4862
|
-
const nextState = {
|
|
4874
|
+
const nextState = {
|
|
4875
|
+
range,
|
|
4876
|
+
includeHeaders: Boolean(range) && includeHeaders,
|
|
4877
|
+
selectedHeaderKey: range ? selectedHeaderKey : null
|
|
4878
|
+
};
|
|
4863
4879
|
context.setState((previous) => {
|
|
4864
|
-
if (previous.range === range && previous.includeHeaders === nextState.includeHeaders && previous.selectedHeaderKey === nextState.selectedHeaderKey)
|
|
4865
|
-
|
|
4880
|
+
if (previous.range === range && previous.includeHeaders === nextState.includeHeaders && previous.selectedHeaderKey === nextState.selectedHeaderKey)
|
|
4881
|
+
return previous;
|
|
4882
|
+
if (previous.range && range && sameCellAddress(previous.range.anchor, range.anchor) && sameCellAddress(previous.range.focus, range.focus) && previous.includeHeaders === nextState.includeHeaders && previous.selectedHeaderKey === nextState.selectedHeaderKey)
|
|
4883
|
+
return previous;
|
|
4866
4884
|
return nextState;
|
|
4867
4885
|
});
|
|
4868
|
-
options.onChange?.(
|
|
4886
|
+
options.onChange?.(
|
|
4887
|
+
range,
|
|
4888
|
+
range ? selectedCells({ ...context, state: nextState }) : []
|
|
4889
|
+
);
|
|
4869
4890
|
}
|
|
4870
4891
|
function selectRows(context, anchorRowKey, focusRowKey) {
|
|
4871
4892
|
const columns = selectableColumns(context);
|
|
4872
4893
|
if (columns.length === 0) return;
|
|
4873
4894
|
setSelection(context, {
|
|
4874
4895
|
anchor: { rowKey: anchorRowKey, columnKey: columns[0].key },
|
|
4875
|
-
focus: {
|
|
4896
|
+
focus: {
|
|
4897
|
+
rowKey: focusRowKey,
|
|
4898
|
+
columnKey: columns[columns.length - 1].key
|
|
4899
|
+
}
|
|
4876
4900
|
});
|
|
4877
4901
|
}
|
|
4878
4902
|
function headerColumns(column, snapshot) {
|
|
4879
|
-
return flattenTableColumns([column]).filter(
|
|
4903
|
+
return flattenTableColumns([column]).filter(
|
|
4904
|
+
(item) => snapshot.columnIndexes.has(item.key)
|
|
4905
|
+
);
|
|
4880
4906
|
}
|
|
4881
4907
|
function selectHeaders(anchor, focus, context) {
|
|
4882
4908
|
const snapshot = getSnapshot(context);
|
|
@@ -4888,22 +4914,38 @@ function createCellSelectionPlugin(options = {}) {
|
|
|
4888
4914
|
if (indexes.length === 0) return;
|
|
4889
4915
|
const left = Math.min(...indexes);
|
|
4890
4916
|
const right = Math.max(...indexes);
|
|
4891
|
-
setSelection(
|
|
4892
|
-
|
|
4893
|
-
|
|
4894
|
-
|
|
4917
|
+
setSelection(
|
|
4918
|
+
context,
|
|
4919
|
+
{
|
|
4920
|
+
anchor: {
|
|
4921
|
+
rowKey: snapshot.rows[0].key,
|
|
4922
|
+
columnKey: snapshot.columns[left].key
|
|
4923
|
+
},
|
|
4924
|
+
focus: {
|
|
4925
|
+
rowKey: snapshot.rows[snapshot.rows.length - 1].key,
|
|
4926
|
+
columnKey: snapshot.columns[right].key
|
|
4927
|
+
}
|
|
4928
|
+
},
|
|
4929
|
+
true,
|
|
4930
|
+
anchor.key
|
|
4931
|
+
);
|
|
4895
4932
|
}
|
|
4896
4933
|
return {
|
|
4897
4934
|
id: "cellSelection",
|
|
4898
4935
|
order: 18,
|
|
4899
|
-
initialState: {
|
|
4936
|
+
initialState: {
|
|
4937
|
+
range: options.defaultRange ?? null,
|
|
4938
|
+
includeHeaders: false,
|
|
4939
|
+
selectedHeaderKey: null
|
|
4940
|
+
},
|
|
4900
4941
|
getCellProps(row, column, context) {
|
|
4901
4942
|
rememberContext(context);
|
|
4902
4943
|
if (!isSelectable(row, column, context)) return void 0;
|
|
4903
4944
|
const snapshot = getSnapshot(context);
|
|
4904
4945
|
const rowIndex = snapshot.rowIndexes.get(row.key);
|
|
4905
4946
|
const columnIndex = snapshot.columnIndexes.get(column.key);
|
|
4906
|
-
if (rowIndex === void 0 || columnIndex === void 0 || rowIndex < snapshot.top || rowIndex > snapshot.bottom || columnIndex < snapshot.left || columnIndex > snapshot.right)
|
|
4947
|
+
if (rowIndex === void 0 || columnIndex === void 0 || rowIndex < snapshot.top || rowIndex > snapshot.bottom || columnIndex < snapshot.left || columnIndex > snapshot.right)
|
|
4948
|
+
return void 0;
|
|
4907
4949
|
const multiple = snapshot.top !== snapshot.bottom || snapshot.left !== snapshot.right;
|
|
4908
4950
|
return {
|
|
4909
4951
|
className: [
|
|
@@ -4923,7 +4965,8 @@ function createCellSelectionPlugin(options = {}) {
|
|
|
4923
4965
|
const columns = headerColumns(column, snapshot);
|
|
4924
4966
|
if (columns.length === 0) return void 0;
|
|
4925
4967
|
const indexes = columns.map((item) => snapshot.columnIndexes.get(item.key)).filter((index) => index !== void 0);
|
|
4926
|
-
if (indexes.length === 0 || indexes.some((index) => index < snapshot.left || index > snapshot.right))
|
|
4968
|
+
if (indexes.length === 0 || indexes.some((index) => index < snapshot.left || index > snapshot.right))
|
|
4969
|
+
return void 0;
|
|
4927
4970
|
return {
|
|
4928
4971
|
className: [
|
|
4929
4972
|
"sia-table__header-cell--range-selected",
|
|
@@ -4937,7 +4980,10 @@ function createCellSelectionPlugin(options = {}) {
|
|
|
4937
4980
|
event.preventDefault();
|
|
4938
4981
|
window.getSelection()?.removeAllRanges();
|
|
4939
4982
|
focusTable(event.currentTarget);
|
|
4940
|
-
dragAnchor = {
|
|
4983
|
+
dragAnchor = {
|
|
4984
|
+
rowKey: row.key,
|
|
4985
|
+
columnKey: selectableColumns(context)[0]?.key ?? column.key
|
|
4986
|
+
};
|
|
4941
4987
|
dragMode = "rows";
|
|
4942
4988
|
selectRows(context, row.key, row.key);
|
|
4943
4989
|
return;
|
|
@@ -4967,10 +5013,14 @@ function createCellSelectionPlugin(options = {}) {
|
|
|
4967
5013
|
if (!isSelectable(row, column, context)) return;
|
|
4968
5014
|
event.preventDefault();
|
|
4969
5015
|
window.getSelection()?.removeAllRanges();
|
|
4970
|
-
setSelection(context, {
|
|
5016
|
+
setSelection(context, {
|
|
5017
|
+
anchor: dragAnchor,
|
|
5018
|
+
focus: { rowKey: row.key, columnKey: column.key }
|
|
5019
|
+
});
|
|
4971
5020
|
},
|
|
4972
5021
|
onHeaderPointerDown(column, event, context) {
|
|
4973
|
-
if (event.button !== 0 || isInteractiveTableTarget(event.target) || column.meta?.plugin === "selection")
|
|
5022
|
+
if (event.button !== 0 || isInteractiveTableTarget(event.target) || column.meta?.plugin === "selection")
|
|
5023
|
+
return;
|
|
4974
5024
|
event.preventDefault();
|
|
4975
5025
|
window.getSelection()?.removeAllRanges();
|
|
4976
5026
|
focusTable(event.currentTarget);
|
|
@@ -5000,7 +5050,8 @@ function createCellSelectionPlugin(options = {}) {
|
|
|
5000
5050
|
};
|
|
5001
5051
|
const handleCopy = (event) => {
|
|
5002
5052
|
const context = latestContext;
|
|
5003
|
-
if (options.copyable === false || !context || !activeRoot || !activeRoot.contains(document.activeElement) || isInteractiveTableTarget(document.activeElement))
|
|
5053
|
+
if (options.copyable === false || !context || !activeRoot || !activeRoot.contains(document.activeElement) || isInteractiveTableTarget(document.activeElement))
|
|
5054
|
+
return;
|
|
5004
5055
|
const text = copyText(context);
|
|
5005
5056
|
if (!text) return;
|
|
5006
5057
|
event.preventDefault();
|
|
@@ -5050,10 +5101,20 @@ function createRowSpanPlugin(options = {}) {
|
|
|
5050
5101
|
for (const column of configured) {
|
|
5051
5102
|
let start = 0;
|
|
5052
5103
|
while (start < rows.length) {
|
|
5053
|
-
const value = getRowSpanGroupValue(
|
|
5104
|
+
const value = getRowSpanGroupValue(
|
|
5105
|
+
column,
|
|
5106
|
+
rows[start].record,
|
|
5107
|
+
start,
|
|
5108
|
+
records
|
|
5109
|
+
);
|
|
5054
5110
|
let end = start + 1;
|
|
5055
5111
|
while (end < rows.length) {
|
|
5056
|
-
const nextValue = getRowSpanGroupValue(
|
|
5112
|
+
const nextValue = getRowSpanGroupValue(
|
|
5113
|
+
column,
|
|
5114
|
+
rows[end].record,
|
|
5115
|
+
end,
|
|
5116
|
+
records
|
|
5117
|
+
);
|
|
5057
5118
|
const equal = options.equals?.(value, nextValue, column) ?? Object.is(value, nextValue);
|
|
5058
5119
|
if (!equal) break;
|
|
5059
5120
|
end += 1;
|
|
@@ -5080,7 +5141,11 @@ function createRowSpanPlugin(options = {}) {
|
|
|
5080
5141
|
const records = context.rows.map((item) => item.record);
|
|
5081
5142
|
return {
|
|
5082
5143
|
...cell,
|
|
5083
|
-
className: [
|
|
5144
|
+
className: [
|
|
5145
|
+
"sia-table__cell--row-span",
|
|
5146
|
+
"sia-table__cell--merge-sticky",
|
|
5147
|
+
config.className
|
|
5148
|
+
].filter(Boolean).join(" "),
|
|
5084
5149
|
style: {
|
|
5085
5150
|
...config.style,
|
|
5086
5151
|
textAlign: config.align,
|
|
@@ -5103,7 +5168,9 @@ function TableSelectedItemsPanel({
|
|
|
5103
5168
|
const [showAll, setShowAll] = useState16(false);
|
|
5104
5169
|
const visibleEntries = showAll ? entries : entries.slice(0, maxCount);
|
|
5105
5170
|
const hiddenCount = Math.max(0, entries.length - visibleEntries.length);
|
|
5106
|
-
const baseColumnMap = new Map(
|
|
5171
|
+
const baseColumnMap = new Map(
|
|
5172
|
+
flattenTableColumns(baseColumns).map((column) => [column.key, column])
|
|
5173
|
+
);
|
|
5107
5174
|
return /* @__PURE__ */ jsxs19("div", { className: "sia-table-selection-panel", children: [
|
|
5108
5175
|
/* @__PURE__ */ jsxs19("div", { className: "sia-table-selection-panel__header", children: [
|
|
5109
5176
|
/* @__PURE__ */ jsxs19("strong", { children: [
|
|
@@ -5111,7 +5178,16 @@ function TableSelectedItemsPanel({
|
|
|
5111
5178
|
/* @__PURE__ */ jsx20("span", { children: entries.length }),
|
|
5112
5179
|
" \u9879"
|
|
5113
5180
|
] }),
|
|
5114
|
-
/* @__PURE__ */ jsx20(
|
|
5181
|
+
/* @__PURE__ */ jsx20(
|
|
5182
|
+
Button,
|
|
5183
|
+
{
|
|
5184
|
+
size: "small",
|
|
5185
|
+
variant: "link",
|
|
5186
|
+
disabled: entries.length === 0,
|
|
5187
|
+
onClick: onClear,
|
|
5188
|
+
children: "\u6E05\u7A7A"
|
|
5189
|
+
}
|
|
5190
|
+
)
|
|
5115
5191
|
] }),
|
|
5116
5192
|
/* @__PURE__ */ jsx20("div", { className: "sia-table-selection-panel__body", children: /* @__PURE__ */ jsxs19("table", { children: [
|
|
5117
5193
|
/* @__PURE__ */ jsx20("thead", { children: /* @__PURE__ */ jsxs19("tr", { children: [
|
|
@@ -5120,14 +5196,38 @@ function TableSelectedItemsPanel({
|
|
|
5120
5196
|
] }) }),
|
|
5121
5197
|
/* @__PURE__ */ jsx20("tbody", { children: visibleEntries.map((entry, selectedIndex) => /* @__PURE__ */ jsxs19("tr", { children: [
|
|
5122
5198
|
columns.map((column) => {
|
|
5123
|
-
if (column.meta?.plugin === "index")
|
|
5199
|
+
if (column.meta?.plugin === "index")
|
|
5200
|
+
return /* @__PURE__ */ jsx20("td", { children: entry.sourceIndex + 1 }, column.key);
|
|
5124
5201
|
const baseColumn = baseColumnMap.get(column.key) ?? column;
|
|
5125
|
-
const value = getTableValue(
|
|
5126
|
-
|
|
5127
|
-
|
|
5202
|
+
const value = getTableValue(
|
|
5203
|
+
entry.record,
|
|
5204
|
+
baseColumn.dataIndex,
|
|
5205
|
+
baseColumn.code ?? baseColumn.key
|
|
5206
|
+
);
|
|
5207
|
+
const row = {
|
|
5208
|
+
key: entry.key,
|
|
5209
|
+
record: entry.record,
|
|
5210
|
+
sourceIndex: entry.sourceIndex,
|
|
5211
|
+
depth: 0,
|
|
5212
|
+
meta: {}
|
|
5213
|
+
};
|
|
5214
|
+
const content = baseColumn.render?.(
|
|
5215
|
+
value,
|
|
5216
|
+
entry.record,
|
|
5217
|
+
entry.sourceIndex,
|
|
5218
|
+
{ row, rowIndex: entry.sourceIndex, column: baseColumn }
|
|
5219
|
+
) ?? value;
|
|
5128
5220
|
return /* @__PURE__ */ jsx20("td", { children: content }, column.key);
|
|
5129
5221
|
}),
|
|
5130
|
-
/* @__PURE__ */ jsx20("td", { children: /* @__PURE__ */ jsx20(
|
|
5222
|
+
/* @__PURE__ */ jsx20("td", { children: /* @__PURE__ */ jsx20(
|
|
5223
|
+
Button,
|
|
5224
|
+
{
|
|
5225
|
+
size: "small",
|
|
5226
|
+
variant: "link",
|
|
5227
|
+
onClick: () => onRemove(entry.key),
|
|
5228
|
+
children: "\u53D6\u6D88"
|
|
5229
|
+
}
|
|
5230
|
+
) })
|
|
5131
5231
|
] }, entry.key)) })
|
|
5132
5232
|
] }) }),
|
|
5133
5233
|
hiddenCount > 0 ? /* @__PURE__ */ jsxs19("div", { className: "sia-table-selection-panel__more", children: [
|
|
@@ -5152,14 +5252,32 @@ function createSelectionPlugin(options = {}) {
|
|
|
5152
5252
|
}
|
|
5153
5253
|
function entriesForKeys(keys, context) {
|
|
5154
5254
|
const records = allRecords(context);
|
|
5155
|
-
const currentRows = new Map(
|
|
5255
|
+
const currentRows = new Map(
|
|
5256
|
+
records.map(
|
|
5257
|
+
(record, index) => [
|
|
5258
|
+
context.getRowKey(record, index),
|
|
5259
|
+
{
|
|
5260
|
+
key: context.getRowKey(record, index),
|
|
5261
|
+
record,
|
|
5262
|
+
sourceIndex: index
|
|
5263
|
+
}
|
|
5264
|
+
]
|
|
5265
|
+
)
|
|
5266
|
+
);
|
|
5156
5267
|
if (preserving(context)) {
|
|
5157
5268
|
for (const key of keys) {
|
|
5158
5269
|
const entry = currentRows.get(key);
|
|
5159
5270
|
if (entry) preservedRows.set(key, entry.record);
|
|
5160
5271
|
}
|
|
5161
|
-
for (const key of preservedRows.keys())
|
|
5162
|
-
|
|
5272
|
+
for (const key of preservedRows.keys())
|
|
5273
|
+
if (!keys.includes(key)) preservedRows.delete(key);
|
|
5274
|
+
return keys.map(
|
|
5275
|
+
(key, selectedIndex) => currentRows.get(key) ?? (preservedRows.has(key) ? {
|
|
5276
|
+
key,
|
|
5277
|
+
record: preservedRows.get(key),
|
|
5278
|
+
sourceIndex: selectedIndex
|
|
5279
|
+
} : void 0)
|
|
5280
|
+
).filter((entry) => entry !== void 0);
|
|
5163
5281
|
}
|
|
5164
5282
|
return keys.map((key) => currentRows.get(key)).filter((entry) => entry !== void 0);
|
|
5165
5283
|
}
|
|
@@ -5168,31 +5286,48 @@ function createSelectionPlugin(options = {}) {
|
|
|
5168
5286
|
}
|
|
5169
5287
|
function setKeys(keys, context) {
|
|
5170
5288
|
if (keys.length === 0) preservedRows.clear();
|
|
5171
|
-
context.setState((state) => ({
|
|
5289
|
+
context.setState((state) => ({
|
|
5290
|
+
...state,
|
|
5291
|
+
selectedKeys: keys,
|
|
5292
|
+
panelOpen: keys.length > 0 && state.panelOpen
|
|
5293
|
+
}));
|
|
5172
5294
|
options.onChange?.(keys, rowsForKeys(keys, context));
|
|
5173
5295
|
}
|
|
5174
5296
|
function setPreserving(preserve, context) {
|
|
5175
5297
|
if (preserve === preserving(context)) return;
|
|
5176
5298
|
if (!preserve) {
|
|
5177
5299
|
const pageKeys = new Set(context.rows.map((row) => row.key));
|
|
5178
|
-
const currentPageKeys = selected(context).filter(
|
|
5300
|
+
const currentPageKeys = selected(context).filter(
|
|
5301
|
+
(key) => pageKeys.has(key)
|
|
5302
|
+
);
|
|
5179
5303
|
setKeys(currentPageKeys, context);
|
|
5180
5304
|
preservedRows.clear();
|
|
5181
5305
|
}
|
|
5182
|
-
context.setState((state) => ({
|
|
5306
|
+
context.setState((state) => ({
|
|
5307
|
+
...state,
|
|
5308
|
+
preserveSelectedRowKeys: preserve
|
|
5309
|
+
}));
|
|
5183
5310
|
options.onPreserveSelectedRowKeysChange?.(preserve);
|
|
5184
5311
|
}
|
|
5185
5312
|
function toggle(key, record, context, checked) {
|
|
5186
5313
|
if (options.getCheckboxDisabled?.(record)) return;
|
|
5187
5314
|
const keys = selected(context);
|
|
5188
|
-
if (mode === "single" || mode === "row")
|
|
5315
|
+
if (mode === "single" || mode === "row")
|
|
5316
|
+
return setKeys(keys.includes(key) ? [] : [key], context);
|
|
5189
5317
|
const nextChecked = checked ?? !keys.includes(key);
|
|
5190
|
-
setKeys(
|
|
5318
|
+
setKeys(
|
|
5319
|
+
nextChecked ? [.../* @__PURE__ */ new Set([...keys, key])] : keys.filter((item) => item !== key),
|
|
5320
|
+
context
|
|
5321
|
+
);
|
|
5191
5322
|
}
|
|
5192
5323
|
return {
|
|
5193
5324
|
id: "selection",
|
|
5194
5325
|
order: 20,
|
|
5195
|
-
initialState: {
|
|
5326
|
+
initialState: {
|
|
5327
|
+
selectedKeys: options.defaultSelectedKeys ?? [],
|
|
5328
|
+
preserveSelectedRowKeys: options.preserveSelectedRowKeys ?? false,
|
|
5329
|
+
panelOpen: false
|
|
5330
|
+
},
|
|
5196
5331
|
transformColumns(columns, context) {
|
|
5197
5332
|
if (mode === "row") return columns;
|
|
5198
5333
|
const selectionColumn = {
|
|
@@ -5208,16 +5343,48 @@ function createSelectionPlugin(options = {}) {
|
|
|
5208
5343
|
meta: { plugin: "selection" },
|
|
5209
5344
|
renderHeader: () => {
|
|
5210
5345
|
if (mode !== "multiple") return null;
|
|
5211
|
-
const enabledRows = context.rows.filter(
|
|
5346
|
+
const enabledRows = context.rows.filter(
|
|
5347
|
+
(row) => !options.getCheckboxDisabled?.(row.record)
|
|
5348
|
+
);
|
|
5212
5349
|
const keys = selected(context);
|
|
5213
5350
|
const allChecked = enabledRows.length > 0 && enabledRows.every((row) => keys.includes(row.key));
|
|
5214
5351
|
const someChecked = enabledRows.some((row) => keys.includes(row.key));
|
|
5215
|
-
return /* @__PURE__ */ jsx20(
|
|
5216
|
-
|
|
5217
|
-
|
|
5218
|
-
|
|
5352
|
+
return /* @__PURE__ */ jsx20(
|
|
5353
|
+
TableCheckbox,
|
|
5354
|
+
{
|
|
5355
|
+
label: "\u9009\u62E9\u5F53\u524D\u9875\u5168\u90E8\u884C",
|
|
5356
|
+
checked: allChecked,
|
|
5357
|
+
indeterminate: !allChecked && someChecked,
|
|
5358
|
+
onChange: (checked) => {
|
|
5359
|
+
const pageKeys = enabledRows.map((row) => row.key);
|
|
5360
|
+
setKeys(
|
|
5361
|
+
checked ? [.../* @__PURE__ */ new Set([...keys, ...pageKeys])] : keys.filter((key) => !pageKeys.includes(key)),
|
|
5362
|
+
context
|
|
5363
|
+
);
|
|
5364
|
+
}
|
|
5365
|
+
}
|
|
5366
|
+
);
|
|
5219
5367
|
},
|
|
5220
|
-
render: (_value, record, _index, info) => mode === "single" ? /* @__PURE__ */ jsx20(
|
|
5368
|
+
render: (_value, record, _index, info) => mode === "single" ? /* @__PURE__ */ jsx20(
|
|
5369
|
+
Radio2,
|
|
5370
|
+
{
|
|
5371
|
+
className: "sia-table__checkbox",
|
|
5372
|
+
value: String(info.row.key),
|
|
5373
|
+
"aria-label": `\u9009\u62E9\u7B2C ${info.rowIndex + 1} \u884C`,
|
|
5374
|
+
checked: selected(context).includes(info.row.key),
|
|
5375
|
+
disabled: options.getCheckboxDisabled?.(record),
|
|
5376
|
+
onClick: (event) => event.stopPropagation(),
|
|
5377
|
+
onChange: () => toggle(info.row.key, record, context)
|
|
5378
|
+
}
|
|
5379
|
+
) : /* @__PURE__ */ jsx20(
|
|
5380
|
+
TableCheckbox,
|
|
5381
|
+
{
|
|
5382
|
+
label: `\u9009\u62E9\u7B2C ${info.rowIndex + 1} \u884C`,
|
|
5383
|
+
checked: selected(context).includes(info.row.key),
|
|
5384
|
+
disabled: options.getCheckboxDisabled?.(record),
|
|
5385
|
+
onChange: (checked) => toggle(info.row.key, record, context, checked)
|
|
5386
|
+
}
|
|
5387
|
+
)
|
|
5221
5388
|
};
|
|
5222
5389
|
return [selectionColumn, ...columns];
|
|
5223
5390
|
},
|
|
@@ -5226,7 +5393,8 @@ function createSelectionPlugin(options = {}) {
|
|
|
5226
5393
|
},
|
|
5227
5394
|
onCellClick(row, column, event, context) {
|
|
5228
5395
|
if (column.meta?.plugin !== "selection" || event.button !== 0) return;
|
|
5229
|
-
if (event.target instanceof Element && event.target.closest(".sia-checkbox, .sia-radio, input"))
|
|
5396
|
+
if (event.target instanceof Element && event.target.closest(".sia-checkbox, .sia-radio, input"))
|
|
5397
|
+
return;
|
|
5230
5398
|
event.stopPropagation();
|
|
5231
5399
|
toggle(row.key, row.record, context);
|
|
5232
5400
|
},
|
|
@@ -5237,13 +5405,16 @@ function createSelectionPlugin(options = {}) {
|
|
|
5237
5405
|
return selected(context).includes(row.key) ? "sia-table__row--selected" : "";
|
|
5238
5406
|
},
|
|
5239
5407
|
onEvent(event, context) {
|
|
5240
|
-
if ((event.type === "pageChange" || event.type === "pageSizeChange") && !preserving(context) && selected(context).length > 0)
|
|
5408
|
+
if ((event.type === "pageChange" || event.type === "pageSizeChange") && !preserving(context) && selected(context).length > 0)
|
|
5409
|
+
setKeys([], context);
|
|
5241
5410
|
},
|
|
5242
5411
|
renderFooter(context) {
|
|
5243
5412
|
if (!options.showSelectedCount) return null;
|
|
5244
5413
|
const keys = selected(context);
|
|
5245
5414
|
const entries = entriesForKeys(keys, context);
|
|
5246
|
-
const columns = flattenTableColumns(context.columns).filter(
|
|
5415
|
+
const columns = flattenTableColumns(context.columns).filter(
|
|
5416
|
+
(column) => !column.hidden && column.meta?.plugin !== "selection"
|
|
5417
|
+
).slice(0, Math.max(1, options.selectionPanelColumnCount ?? 4));
|
|
5247
5418
|
return /* @__PURE__ */ jsxs19("span", { className: "sia-table__selection-footer", children: [
|
|
5248
5419
|
/* @__PURE__ */ jsx20(
|
|
5249
5420
|
Popover,
|
|
@@ -5253,17 +5424,46 @@ function createSelectionPlugin(options = {}) {
|
|
|
5253
5424
|
open: context.state.panelOpen && entries.length > 0,
|
|
5254
5425
|
onOpenChange: (panelOpen) => context.setState((state) => ({ ...state, panelOpen })),
|
|
5255
5426
|
overlayClassName: "sia-table-selection-popover",
|
|
5256
|
-
content: /* @__PURE__ */ jsx20(
|
|
5257
|
-
|
|
5258
|
-
|
|
5259
|
-
|
|
5260
|
-
|
|
5261
|
-
|
|
5262
|
-
|
|
5263
|
-
|
|
5427
|
+
content: /* @__PURE__ */ jsx20(
|
|
5428
|
+
TableSelectedItemsPanel,
|
|
5429
|
+
{
|
|
5430
|
+
entries,
|
|
5431
|
+
columns,
|
|
5432
|
+
baseColumns: context.baseColumns,
|
|
5433
|
+
maxCount: Math.max(1, options.selectionPanelMaxCount ?? 100),
|
|
5434
|
+
onRemove: (key) => {
|
|
5435
|
+
setKeys(
|
|
5436
|
+
keys.filter((item) => item !== key),
|
|
5437
|
+
context
|
|
5438
|
+
);
|
|
5439
|
+
},
|
|
5440
|
+
onClear: () => setKeys([], context)
|
|
5441
|
+
}
|
|
5442
|
+
),
|
|
5443
|
+
children: /* @__PURE__ */ jsxs19(
|
|
5444
|
+
Button,
|
|
5445
|
+
{
|
|
5446
|
+
className: "sia-table__selected-trigger",
|
|
5447
|
+
size: "small",
|
|
5448
|
+
variant: "link",
|
|
5449
|
+
disabled: entries.length === 0,
|
|
5450
|
+
children: [
|
|
5451
|
+
"\u5DF2\u9009 ",
|
|
5452
|
+
entries.length,
|
|
5453
|
+
" \u6761"
|
|
5454
|
+
]
|
|
5455
|
+
}
|
|
5456
|
+
)
|
|
5264
5457
|
}
|
|
5265
5458
|
),
|
|
5266
|
-
mode === "multiple" && options.showPreserveSelectedRowKeys !== false ? /* @__PURE__ */ jsx20(
|
|
5459
|
+
mode === "multiple" && options.showPreserveSelectedRowKeys !== false ? /* @__PURE__ */ jsx20(
|
|
5460
|
+
Checkbox,
|
|
5461
|
+
{
|
|
5462
|
+
checked: preserving(context),
|
|
5463
|
+
onChange: (checked) => setPreserving(checked, context),
|
|
5464
|
+
children: "\u8DE8\u9875\u4FDD\u7559\u52FE\u9009"
|
|
5465
|
+
}
|
|
5466
|
+
) : null
|
|
5267
5467
|
] });
|
|
5268
5468
|
},
|
|
5269
5469
|
getApi(context) {
|
|
@@ -5273,7 +5473,9 @@ function createSelectionPlugin(options = {}) {
|
|
|
5273
5473
|
clear: () => setKeys([], context),
|
|
5274
5474
|
toggle: (key, checked) => {
|
|
5275
5475
|
const records = allRecords(context);
|
|
5276
|
-
const record = records.find(
|
|
5476
|
+
const record = records.find(
|
|
5477
|
+
(item, index) => Object.is(context.getRowKey(item, index), key)
|
|
5478
|
+
) ?? preservedRows.get(key);
|
|
5277
5479
|
if (record) toggle(key, record, context, checked);
|
|
5278
5480
|
},
|
|
5279
5481
|
getSelectedRows: () => rowsForKeys(selected(context), context),
|
|
@@ -5305,19 +5507,45 @@ function createSortPlugin(options = {}) {
|
|
|
5305
5507
|
if (!column.sortable) return column;
|
|
5306
5508
|
const field = Array.isArray(column.dataIndex) ? column.dataIndex.join(".") : String(column.dataIndex ?? column.code ?? column.key);
|
|
5307
5509
|
const previousHeader = column.renderHeader;
|
|
5308
|
-
return {
|
|
5309
|
-
|
|
5310
|
-
|
|
5311
|
-
|
|
5312
|
-
/* @__PURE__ */ jsxs19("
|
|
5313
|
-
|
|
5314
|
-
|
|
5315
|
-
|
|
5316
|
-
|
|
5317
|
-
|
|
5318
|
-
|
|
5319
|
-
|
|
5320
|
-
|
|
5510
|
+
return {
|
|
5511
|
+
...column,
|
|
5512
|
+
renderHeader: (currentColumn, coreContext) => {
|
|
5513
|
+
const info = current(context);
|
|
5514
|
+
return /* @__PURE__ */ jsxs19("span", { className: "sia-table__sortable-header", children: [
|
|
5515
|
+
/* @__PURE__ */ jsx20("span", { children: previousHeader ? previousHeader(currentColumn, coreContext) : currentColumn.title ?? currentColumn.name ?? currentColumn.key }),
|
|
5516
|
+
/* @__PURE__ */ jsxs19(
|
|
5517
|
+
"button",
|
|
5518
|
+
{
|
|
5519
|
+
type: "button",
|
|
5520
|
+
className: "sia-table__sort-button",
|
|
5521
|
+
"aria-label": `\u5207\u6362${getColumnLabel(currentColumn)}\u6392\u5E8F`,
|
|
5522
|
+
onClick: (event) => {
|
|
5523
|
+
event.stopPropagation();
|
|
5524
|
+
cycle(field, context);
|
|
5525
|
+
},
|
|
5526
|
+
children: [
|
|
5527
|
+
/* @__PURE__ */ jsx20(
|
|
5528
|
+
Icon,
|
|
5529
|
+
{
|
|
5530
|
+
name: "chevron-up",
|
|
5531
|
+
size: 11,
|
|
5532
|
+
className: info?.field === field && info.order === "ascend" ? "is-active" : ""
|
|
5533
|
+
}
|
|
5534
|
+
),
|
|
5535
|
+
/* @__PURE__ */ jsx20(
|
|
5536
|
+
Icon,
|
|
5537
|
+
{
|
|
5538
|
+
name: "chevron-down",
|
|
5539
|
+
size: 11,
|
|
5540
|
+
className: info?.field === field && info.order === "descend" ? "is-active" : ""
|
|
5541
|
+
}
|
|
5542
|
+
)
|
|
5543
|
+
]
|
|
5544
|
+
}
|
|
5545
|
+
)
|
|
5546
|
+
] });
|
|
5547
|
+
}
|
|
5548
|
+
};
|
|
5321
5549
|
});
|
|
5322
5550
|
},
|
|
5323
5551
|
transformRows(rows, context) {
|
|
@@ -5327,11 +5555,17 @@ function createSortPlugin(options = {}) {
|
|
|
5327
5555
|
return rows.map((row, index) => ({ row, index })).sort((a, b) => {
|
|
5328
5556
|
const aValue = getTableValue(a.row.record, info.field, info.field);
|
|
5329
5557
|
const bValue = getTableValue(b.row.record, info.field, info.field);
|
|
5330
|
-
const result = options.compare ? options.compare(aValue, bValue, info.field) : aValue == null && bValue == null ? 0 : aValue == null ? -1 : bValue == null ? 1 : typeof aValue === "number" && typeof bValue === "number" ? aValue - bValue : String(aValue).localeCompare(String(bValue), "zh-CN", {
|
|
5558
|
+
const result = options.compare ? options.compare(aValue, bValue, info.field) : aValue == null && bValue == null ? 0 : aValue == null ? -1 : bValue == null ? 1 : typeof aValue === "number" && typeof bValue === "number" ? aValue - bValue : String(aValue).localeCompare(String(bValue), "zh-CN", {
|
|
5559
|
+
numeric: true
|
|
5560
|
+
});
|
|
5331
5561
|
return result === 0 ? a.index - b.index : result * direction;
|
|
5332
5562
|
}).map((item) => item.row);
|
|
5333
5563
|
},
|
|
5334
|
-
getApi: (context) => ({
|
|
5564
|
+
getApi: (context) => ({
|
|
5565
|
+
getSortInfo: () => current(context),
|
|
5566
|
+
setSortInfo: (sort) => update(sort, context),
|
|
5567
|
+
clear: () => update(null, context)
|
|
5568
|
+
})
|
|
5335
5569
|
};
|
|
5336
5570
|
}
|
|
5337
5571
|
function TableFilterControl({
|
|
@@ -5343,7 +5577,7 @@ function TableFilterControl({
|
|
|
5343
5577
|
const [open, setOpen] = useState16(false);
|
|
5344
5578
|
const [draft, setDraft] = useState16(value);
|
|
5345
5579
|
const label = getColumnLabel(column);
|
|
5346
|
-
|
|
5580
|
+
useEffect11(() => {
|
|
5347
5581
|
if (open) setDraft(value);
|
|
5348
5582
|
}, [open, value]);
|
|
5349
5583
|
const apply = (nextValue) => {
|
|
@@ -5375,11 +5609,27 @@ function TableFilterControl({
|
|
|
5375
5609
|
}
|
|
5376
5610
|
),
|
|
5377
5611
|
/* @__PURE__ */ jsxs19("div", { className: "sia-table-filter-panel__actions", children: [
|
|
5378
|
-
/* @__PURE__ */ jsx20(
|
|
5379
|
-
|
|
5380
|
-
|
|
5381
|
-
|
|
5382
|
-
|
|
5612
|
+
/* @__PURE__ */ jsx20(
|
|
5613
|
+
Button,
|
|
5614
|
+
{
|
|
5615
|
+
size: "small",
|
|
5616
|
+
disabled: !value && !draft,
|
|
5617
|
+
onClick: () => {
|
|
5618
|
+
setDraft("");
|
|
5619
|
+
apply("");
|
|
5620
|
+
},
|
|
5621
|
+
children: "\u6E05\u9664"
|
|
5622
|
+
}
|
|
5623
|
+
),
|
|
5624
|
+
/* @__PURE__ */ jsx20(
|
|
5625
|
+
Button,
|
|
5626
|
+
{
|
|
5627
|
+
size: "small",
|
|
5628
|
+
variant: "primary",
|
|
5629
|
+
onClick: () => apply(draft),
|
|
5630
|
+
children: "\u5E94\u7528"
|
|
5631
|
+
}
|
|
5632
|
+
)
|
|
5383
5633
|
] })
|
|
5384
5634
|
] }),
|
|
5385
5635
|
children: /* @__PURE__ */ jsx20(
|
|
@@ -5403,21 +5653,37 @@ function createFilterPlugin(options = {}) {
|
|
|
5403
5653
|
const filters = current(context);
|
|
5404
5654
|
return Object.entries(filters).every(([columnKey, filterValue]) => {
|
|
5405
5655
|
if (!filterValue) return true;
|
|
5406
|
-
const column = flattenTableColumns(context.columns).find(
|
|
5656
|
+
const column = flattenTableColumns(context.columns).find(
|
|
5657
|
+
(item) => item.key === columnKey
|
|
5658
|
+
) ?? flattenTableColumns(context.baseColumns).find(
|
|
5659
|
+
(item) => item.key === columnKey
|
|
5660
|
+
);
|
|
5407
5661
|
if (!column) return true;
|
|
5408
|
-
const value = getTableValue(
|
|
5409
|
-
|
|
5662
|
+
const value = getTableValue(
|
|
5663
|
+
record,
|
|
5664
|
+
column.dataIndex,
|
|
5665
|
+
column.code ?? column.key
|
|
5666
|
+
);
|
|
5667
|
+
if (options.predicate)
|
|
5668
|
+
return options.predicate(value, filterValue, record, column);
|
|
5410
5669
|
const normalizedFilter = filterValue.toLocaleLowerCase();
|
|
5411
|
-
if (value === null || value === void 0)
|
|
5670
|
+
if (value === null || value === void 0)
|
|
5671
|
+
return normalizedFilter === "null" || normalizedFilter === "\u7A7A";
|
|
5412
5672
|
const text = typeof value === "object" ? JSON.stringify(value) : String(value);
|
|
5413
5673
|
return text.toLocaleLowerCase().includes(normalizedFilter);
|
|
5414
5674
|
});
|
|
5415
5675
|
};
|
|
5416
5676
|
const update = (filters, context) => {
|
|
5417
|
-
const normalized = Object.fromEntries(
|
|
5677
|
+
const normalized = Object.fromEntries(
|
|
5678
|
+
Object.entries(filters).filter(([, value]) => value.trim()).map(([key, value]) => [key, value.trim()])
|
|
5679
|
+
);
|
|
5418
5680
|
context.setState({ filters: normalized });
|
|
5419
5681
|
const pagination = context.getState("pagination");
|
|
5420
|
-
if (pagination)
|
|
5682
|
+
if (pagination)
|
|
5683
|
+
context.setPluginState("pagination", {
|
|
5684
|
+
...pagination,
|
|
5685
|
+
current: 1
|
|
5686
|
+
});
|
|
5421
5687
|
options.onChange?.(normalized);
|
|
5422
5688
|
};
|
|
5423
5689
|
return {
|
|
@@ -5428,11 +5694,25 @@ function createFilterPlugin(options = {}) {
|
|
|
5428
5694
|
return mapTableLeafColumns(columns, (column) => {
|
|
5429
5695
|
if (!column.filterable) return column;
|
|
5430
5696
|
const previousHeader = column.renderHeader;
|
|
5431
|
-
return {
|
|
5432
|
-
|
|
5433
|
-
|
|
5434
|
-
|
|
5435
|
-
|
|
5697
|
+
return {
|
|
5698
|
+
...column,
|
|
5699
|
+
renderHeader: (currentColumn, coreContext) => {
|
|
5700
|
+
const renderedColumn = {
|
|
5701
|
+
...currentColumn,
|
|
5702
|
+
title: previousHeader ? previousHeader(currentColumn, coreContext) : currentColumn.title
|
|
5703
|
+
};
|
|
5704
|
+
const placeholder = typeof options.placeholder === "function" ? options.placeholder(currentColumn) : options.placeholder ?? `\u8F93\u5165${getColumnLabel(currentColumn)}\u7B5B\u9009`;
|
|
5705
|
+
return /* @__PURE__ */ jsx20(
|
|
5706
|
+
TableFilterControl,
|
|
5707
|
+
{
|
|
5708
|
+
column: renderedColumn,
|
|
5709
|
+
value: current(context)[column.key] ?? "",
|
|
5710
|
+
placeholder,
|
|
5711
|
+
onApply: (value) => update({ ...current(context), [column.key]: value }, context)
|
|
5712
|
+
}
|
|
5713
|
+
);
|
|
5714
|
+
}
|
|
5715
|
+
};
|
|
5436
5716
|
});
|
|
5437
5717
|
},
|
|
5438
5718
|
transformRows(rows, context) {
|
|
@@ -5442,20 +5722,35 @@ function createFilterPlugin(options = {}) {
|
|
|
5442
5722
|
return {
|
|
5443
5723
|
getFilters: () => current(context),
|
|
5444
5724
|
setFilter: (columnKey, value) => update({ ...current(context), [columnKey]: value }, context),
|
|
5445
|
-
clear: (columnKey) => update(
|
|
5725
|
+
clear: (columnKey) => update(
|
|
5726
|
+
columnKey ? { ...current(context), [columnKey]: "" } : {},
|
|
5727
|
+
context
|
|
5728
|
+
),
|
|
5446
5729
|
getFilteredRows: () => context.sourceData.filter((record) => matches(record, context))
|
|
5447
5730
|
};
|
|
5448
5731
|
}
|
|
5449
5732
|
};
|
|
5450
5733
|
}
|
|
5451
5734
|
function createPaginationPlugin(options = {}) {
|
|
5452
|
-
const currentPage = (context) => ({
|
|
5735
|
+
const currentPage = (context) => ({
|
|
5736
|
+
current: options.current ?? context.state.current,
|
|
5737
|
+
pageSize: options.pageSize ?? context.state.pageSize
|
|
5738
|
+
});
|
|
5453
5739
|
const setPage = (next, context, notify = true) => {
|
|
5454
5740
|
const previous = currentPage(context);
|
|
5455
|
-
const page = {
|
|
5741
|
+
const page = {
|
|
5742
|
+
current: Math.max(1, next.current ?? previous.current),
|
|
5743
|
+
pageSize: Math.max(1, next.pageSize ?? previous.pageSize)
|
|
5744
|
+
};
|
|
5456
5745
|
context.setState((state) => ({ ...state, ...page }));
|
|
5457
|
-
if (page.pageSize !== previous.pageSize)
|
|
5458
|
-
|
|
5746
|
+
if (page.pageSize !== previous.pageSize)
|
|
5747
|
+
context.emit({
|
|
5748
|
+
type: "pageSizeChange",
|
|
5749
|
+
source: "pagination",
|
|
5750
|
+
payload: page.pageSize
|
|
5751
|
+
});
|
|
5752
|
+
if (page.current !== previous.current)
|
|
5753
|
+
context.emit({ type: "pageChange", source: "pagination", payload: page });
|
|
5459
5754
|
if (notify) options.onChange?.(page.current, page.pageSize);
|
|
5460
5755
|
};
|
|
5461
5756
|
const requestCount = async (model, context) => {
|
|
@@ -5470,15 +5765,27 @@ function createPaginationPlugin(options = {}) {
|
|
|
5470
5765
|
return {
|
|
5471
5766
|
id: "pagination",
|
|
5472
5767
|
order: 50,
|
|
5473
|
-
initialState: {
|
|
5768
|
+
initialState: {
|
|
5769
|
+
current: options.defaultCurrent ?? 1,
|
|
5770
|
+
pageSize: options.defaultPageSize ?? 25,
|
|
5771
|
+
requestLoading: false
|
|
5772
|
+
},
|
|
5474
5773
|
onMount(context) {
|
|
5475
|
-
if (options.isFirstLoad)
|
|
5774
|
+
if (options.isFirstLoad)
|
|
5775
|
+
options.onChange?.(
|
|
5776
|
+
currentPage(context).current,
|
|
5777
|
+
currentPage(context).pageSize,
|
|
5778
|
+
true
|
|
5779
|
+
);
|
|
5476
5780
|
},
|
|
5477
5781
|
transformRows(rows, context) {
|
|
5478
5782
|
const page = currentPage(context);
|
|
5479
5783
|
const mode = options.mode ?? "auto";
|
|
5480
5784
|
const serverPagination = mode === "server" || mode === "auto" && options.totalCount != null && options.totalCount > context.sourceData.length;
|
|
5481
|
-
return serverPagination ? rows : rows.slice(
|
|
5785
|
+
return serverPagination ? rows : rows.slice(
|
|
5786
|
+
(page.current - 1) * page.pageSize,
|
|
5787
|
+
page.current * page.pageSize
|
|
5788
|
+
);
|
|
5482
5789
|
},
|
|
5483
5790
|
renderFooter(context) {
|
|
5484
5791
|
const page = currentPage(context);
|
|
@@ -5504,9 +5811,15 @@ function createPaginationPlugin(options = {}) {
|
|
|
5504
5811
|
setPage: (page) => setPage(page, context),
|
|
5505
5812
|
generatePageParams: (model) => {
|
|
5506
5813
|
const page = currentPage(context);
|
|
5507
|
-
const next = {
|
|
5814
|
+
const next = {
|
|
5815
|
+
current: typeof model.pageIndex === "number" ? model.pageIndex : page.current,
|
|
5816
|
+
pageSize: typeof model.pageSize === "number" ? model.pageSize : page.pageSize
|
|
5817
|
+
};
|
|
5508
5818
|
setPage(next, context, false);
|
|
5509
|
-
return {
|
|
5819
|
+
return {
|
|
5820
|
+
...model,
|
|
5821
|
+
...toTablePageParams(next.current, next.pageSize)
|
|
5822
|
+
};
|
|
5510
5823
|
},
|
|
5511
5824
|
requestCount: (model) => requestCount(model, context)
|
|
5512
5825
|
};
|
|
@@ -5518,17 +5831,36 @@ function createIndexPlugin(options = {}) {
|
|
|
5518
5831
|
id: "index",
|
|
5519
5832
|
order: 30,
|
|
5520
5833
|
transformColumns(columns, context) {
|
|
5521
|
-
const column = {
|
|
5522
|
-
|
|
5523
|
-
|
|
5524
|
-
|
|
5525
|
-
|
|
5526
|
-
|
|
5834
|
+
const column = {
|
|
5835
|
+
key: "__index__",
|
|
5836
|
+
title: options.title ?? "\u5E8F\u53F7",
|
|
5837
|
+
name: "\u5E8F\u53F7",
|
|
5838
|
+
width: options.width ?? 60,
|
|
5839
|
+
minWidth: 48,
|
|
5840
|
+
fixed: "left",
|
|
5841
|
+
align: "center",
|
|
5842
|
+
ellipsis: false,
|
|
5843
|
+
meta: { plugin: "index" },
|
|
5844
|
+
render: (_value, _record, _index, info) => {
|
|
5845
|
+
const page = context.getState("pagination");
|
|
5846
|
+
const offset = page ? ((page.current ?? 1) - 1) * (page.pageSize ?? 0) : 0;
|
|
5847
|
+
return (options.startIndex ?? 1) + offset + info.rowIndex;
|
|
5848
|
+
}
|
|
5849
|
+
};
|
|
5850
|
+
const selectionIndex = columns.findIndex(
|
|
5851
|
+
(item) => item.meta?.plugin === "selection"
|
|
5852
|
+
);
|
|
5527
5853
|
if (selectionIndex < 0) return [column, ...columns];
|
|
5528
|
-
return [
|
|
5854
|
+
return [
|
|
5855
|
+
...columns.slice(0, selectionIndex + 1),
|
|
5856
|
+
column,
|
|
5857
|
+
...columns.slice(selectionIndex + 1)
|
|
5858
|
+
];
|
|
5529
5859
|
},
|
|
5530
5860
|
getCellProps(_row, column, context) {
|
|
5531
|
-
const hasSelectionColumn = context.columns.some(
|
|
5861
|
+
const hasSelectionColumn = context.columns.some(
|
|
5862
|
+
(item) => item.meta?.plugin === "selection"
|
|
5863
|
+
);
|
|
5532
5864
|
return column.meta?.plugin === "index" && hasSelectionColumn ? { className: "sia-table__cell--index-action" } : void 0;
|
|
5533
5865
|
}
|
|
5534
5866
|
};
|
|
@@ -5536,18 +5868,24 @@ function createIndexPlugin(options = {}) {
|
|
|
5536
5868
|
function createTreePlugin(options = {}) {
|
|
5537
5869
|
const childKey = options.childrenColumnName ?? "children";
|
|
5538
5870
|
const current = (context) => options.expandedRowKeys ?? context.state.expandedKeys;
|
|
5539
|
-
const allExpandableKeys = (context) => flattenRecords(context.sourceData, childKey).filter(
|
|
5871
|
+
const allExpandableKeys = (context) => flattenRecords(context.sourceData, childKey).filter(
|
|
5872
|
+
(record) => Array.isArray(record[childKey]) && record[childKey].length > 0
|
|
5873
|
+
).map((record, index) => context.getRowKey(record, index));
|
|
5540
5874
|
const setKeys = (keys, context) => {
|
|
5541
5875
|
context.setState({ expandedKeys: keys });
|
|
5542
5876
|
options.onExpandedRowsChange?.(keys);
|
|
5543
5877
|
};
|
|
5544
|
-
const toggle = (key, context) => setKeys(
|
|
5878
|
+
const toggle = (key, context) => setKeys(
|
|
5879
|
+
current(context).includes(key) ? current(context).filter((item) => item !== key) : [...current(context), key],
|
|
5880
|
+
context
|
|
5881
|
+
);
|
|
5545
5882
|
return {
|
|
5546
5883
|
id: "tree",
|
|
5547
5884
|
order: 60,
|
|
5548
5885
|
initialState: { expandedKeys: options.defaultExpandedRowKeys ?? [] },
|
|
5549
5886
|
onMount(context) {
|
|
5550
|
-
if (options.defaultExpandAllRows && options.expandedRowKeys === void 0)
|
|
5887
|
+
if (options.defaultExpandAllRows && options.expandedRowKeys === void 0)
|
|
5888
|
+
setKeys(allExpandableKeys(context), context);
|
|
5551
5889
|
},
|
|
5552
5890
|
transformRows(rows, context) {
|
|
5553
5891
|
if (options.ignoreChildrenColumn ?? true) return rows;
|
|
@@ -5556,9 +5894,22 @@ function createTreePlugin(options = {}) {
|
|
|
5556
5894
|
for (const row of items) {
|
|
5557
5895
|
const children = row.record[childKey];
|
|
5558
5896
|
const hasChildren = Array.isArray(children) && children.length > 0 && (options.canExpand?.(row.record) ?? true);
|
|
5559
|
-
result.push({
|
|
5897
|
+
result.push({
|
|
5898
|
+
...row,
|
|
5899
|
+
depth,
|
|
5900
|
+
meta: { ...row.meta, treeHasChildren: hasChildren }
|
|
5901
|
+
});
|
|
5560
5902
|
if (hasChildren && current(context).includes(row.key)) {
|
|
5561
|
-
walk(
|
|
5903
|
+
walk(
|
|
5904
|
+
children.map((record, index) => ({
|
|
5905
|
+
key: context.getRowKey(record, index),
|
|
5906
|
+
record,
|
|
5907
|
+
sourceIndex: index,
|
|
5908
|
+
depth: depth + 1,
|
|
5909
|
+
meta: {}
|
|
5910
|
+
})),
|
|
5911
|
+
depth + 1
|
|
5912
|
+
);
|
|
5562
5913
|
}
|
|
5563
5914
|
}
|
|
5564
5915
|
};
|
|
@@ -5572,16 +5923,47 @@ function createTreePlugin(options = {}) {
|
|
|
5572
5923
|
if (wrapped || column.meta?.plugin) return column;
|
|
5573
5924
|
wrapped = true;
|
|
5574
5925
|
const previousRender = column.render;
|
|
5575
|
-
return {
|
|
5576
|
-
|
|
5577
|
-
|
|
5578
|
-
|
|
5579
|
-
|
|
5580
|
-
|
|
5581
|
-
|
|
5926
|
+
return {
|
|
5927
|
+
...column,
|
|
5928
|
+
render: (value, record, index, info) => /* @__PURE__ */ jsxs19(
|
|
5929
|
+
"span",
|
|
5930
|
+
{
|
|
5931
|
+
className: "sia-table__tree-cell",
|
|
5932
|
+
style: { paddingLeft: info.row.depth * 18 },
|
|
5933
|
+
children: [
|
|
5934
|
+
info.row.meta.treeHasChildren ? /* @__PURE__ */ jsx20(
|
|
5935
|
+
"button",
|
|
5936
|
+
{
|
|
5937
|
+
type: "button",
|
|
5938
|
+
className: "sia-table__tree-toggle",
|
|
5939
|
+
"aria-label": current(context).includes(info.row.key) ? "\u6536\u8D77\u5B50\u8282\u70B9" : "\u5C55\u5F00\u5B50\u8282\u70B9",
|
|
5940
|
+
"aria-expanded": current(context).includes(info.row.key),
|
|
5941
|
+
onClick: (event) => {
|
|
5942
|
+
event.stopPropagation();
|
|
5943
|
+
toggle(info.row.key, context);
|
|
5944
|
+
},
|
|
5945
|
+
children: /* @__PURE__ */ jsx20(
|
|
5946
|
+
Icon,
|
|
5947
|
+
{
|
|
5948
|
+
name: current(context).includes(info.row.key) ? "chevron-down" : "chevron-right",
|
|
5949
|
+
size: 13
|
|
5950
|
+
}
|
|
5951
|
+
)
|
|
5952
|
+
}
|
|
5953
|
+
) : /* @__PURE__ */ jsx20("span", { className: "sia-table__tree-placeholder" }),
|
|
5954
|
+
previousRender ? previousRender(value, record, index, info) : value
|
|
5955
|
+
]
|
|
5956
|
+
}
|
|
5957
|
+
)
|
|
5958
|
+
};
|
|
5582
5959
|
});
|
|
5583
5960
|
},
|
|
5584
|
-
getApi: (context) => ({
|
|
5961
|
+
getApi: (context) => ({
|
|
5962
|
+
getExpandedKeys: () => current(context),
|
|
5963
|
+
setExpandedKeys: (keys) => setKeys(keys, context),
|
|
5964
|
+
expandAll: () => setKeys(allExpandableKeys(context), context),
|
|
5965
|
+
collapseAll: () => setKeys([], context)
|
|
5966
|
+
})
|
|
5585
5967
|
};
|
|
5586
5968
|
}
|
|
5587
5969
|
function createSummaryPlugin(options) {
|
|
@@ -5590,8 +5972,19 @@ function createSummaryPlugin(options) {
|
|
|
5590
5972
|
order: 90,
|
|
5591
5973
|
renderSummary(context) {
|
|
5592
5974
|
const rows = [];
|
|
5593
|
-
if (options.subTotal)
|
|
5594
|
-
|
|
5975
|
+
if (options.subTotal)
|
|
5976
|
+
rows.push({
|
|
5977
|
+
key: "subtotal",
|
|
5978
|
+
label: options.subTotalLabel ?? "\u5C0F\u8BA1",
|
|
5979
|
+
values: typeof options.subTotal === "function" ? options.subTotal(context.rows.map((row) => row.record)) : options.subTotal
|
|
5980
|
+
});
|
|
5981
|
+
if (options.total)
|
|
5982
|
+
rows.push({
|
|
5983
|
+
key: "total",
|
|
5984
|
+
label: options.totalLabel ?? "\u603B\u8BA1",
|
|
5985
|
+
values: options.total,
|
|
5986
|
+
className: "sia-table__summary-row--total"
|
|
5987
|
+
});
|
|
5595
5988
|
return rows;
|
|
5596
5989
|
}
|
|
5597
5990
|
};
|
|
@@ -5614,9 +6007,11 @@ function EditableTableCell({
|
|
|
5614
6007
|
const editorRef = useRef14(null);
|
|
5615
6008
|
const editValueRef = useRef14(value);
|
|
5616
6009
|
const savingRef = useRef14(false);
|
|
5617
|
-
const saveRef = useRef14(
|
|
5618
|
-
|
|
5619
|
-
|
|
6010
|
+
const saveRef = useRef14(
|
|
6011
|
+
async () => {
|
|
6012
|
+
}
|
|
6013
|
+
);
|
|
6014
|
+
useEffect11(() => {
|
|
5620
6015
|
if (!active) return;
|
|
5621
6016
|
editValueRef.current = value;
|
|
5622
6017
|
setEditValue(value);
|
|
@@ -5647,42 +6042,89 @@ function EditableTableCell({
|
|
|
5647
6042
|
}
|
|
5648
6043
|
}
|
|
5649
6044
|
saveRef.current = save;
|
|
5650
|
-
|
|
6045
|
+
useEffect11(() => {
|
|
5651
6046
|
if (!active || config.type === "select" || config.type === "custom") return;
|
|
5652
6047
|
const handleOutsidePointerDown = (event) => {
|
|
5653
6048
|
const target = event.target;
|
|
5654
|
-
if (!(target instanceof Node) || editorRef.current?.contains(target))
|
|
6049
|
+
if (!(target instanceof Node) || editorRef.current?.contains(target))
|
|
6050
|
+
return;
|
|
5655
6051
|
void saveRef.current();
|
|
5656
6052
|
};
|
|
5657
6053
|
document.addEventListener("pointerdown", handleOutsidePointerDown, true);
|
|
5658
|
-
return () => document.removeEventListener(
|
|
6054
|
+
return () => document.removeEventListener(
|
|
6055
|
+
"pointerdown",
|
|
6056
|
+
handleOutsidePointerDown,
|
|
6057
|
+
true
|
|
6058
|
+
);
|
|
5659
6059
|
}, [active, config.type]);
|
|
5660
|
-
if (!active)
|
|
5661
|
-
/* @__PURE__ */
|
|
5662
|
-
|
|
5663
|
-
|
|
6060
|
+
if (!active)
|
|
6061
|
+
return /* @__PURE__ */ jsxs19(
|
|
6062
|
+
"div",
|
|
6063
|
+
{
|
|
6064
|
+
className: "sia-table__editable-display",
|
|
6065
|
+
onClick: trigger === "click" ? onStart : void 0,
|
|
6066
|
+
onDoubleClick: trigger === "doubleClick" ? onStart : void 0,
|
|
6067
|
+
children: [
|
|
6068
|
+
/* @__PURE__ */ jsx20("span", { children: content }),
|
|
6069
|
+
/* @__PURE__ */ jsx20(Icon, { name: "edit", size: 13 })
|
|
6070
|
+
]
|
|
6071
|
+
}
|
|
6072
|
+
);
|
|
5664
6073
|
let editor;
|
|
5665
6074
|
if (config.type === "custom" && config.editRender) {
|
|
5666
6075
|
editor = config.editRender(record, (next) => void save(next), onCancel);
|
|
5667
6076
|
} else if (config.type === "inputNumber") {
|
|
5668
|
-
editor = /* @__PURE__ */ jsx20(
|
|
5669
|
-
|
|
5670
|
-
|
|
5671
|
-
|
|
5672
|
-
|
|
6077
|
+
editor = /* @__PURE__ */ jsx20(
|
|
6078
|
+
InputNumber,
|
|
6079
|
+
{
|
|
6080
|
+
ref: inputRef,
|
|
6081
|
+
size: "small",
|
|
6082
|
+
value: typeof editValue === "number" ? editValue : null,
|
|
6083
|
+
onChange: updateEditValue,
|
|
6084
|
+
disabled: saving,
|
|
6085
|
+
onBlur: () => void save(),
|
|
6086
|
+
onKeyDown: (event) => {
|
|
6087
|
+
if (event.key === "Enter") {
|
|
6088
|
+
const rawValue = event.currentTarget.value.trim();
|
|
6089
|
+
const nextValue = rawValue === "" ? null : Number(rawValue);
|
|
6090
|
+
if (nextValue === null || Number.isFinite(nextValue))
|
|
6091
|
+
void save(nextValue);
|
|
6092
|
+
}
|
|
6093
|
+
if (event.key === "Escape") onCancel();
|
|
6094
|
+
}
|
|
5673
6095
|
}
|
|
5674
|
-
|
|
5675
|
-
} });
|
|
6096
|
+
);
|
|
5676
6097
|
} else if (config.type === "select") {
|
|
5677
|
-
editor = /* @__PURE__ */ jsx20(
|
|
5678
|
-
|
|
5679
|
-
|
|
5680
|
-
|
|
6098
|
+
editor = /* @__PURE__ */ jsx20(
|
|
6099
|
+
Select,
|
|
6100
|
+
{
|
|
6101
|
+
size: "small",
|
|
6102
|
+
value: editValue,
|
|
6103
|
+
options: config.options ?? [],
|
|
6104
|
+
disabled: saving,
|
|
6105
|
+
onChange: (next) => {
|
|
6106
|
+
updateEditValue(next);
|
|
6107
|
+
void save(next);
|
|
6108
|
+
}
|
|
6109
|
+
}
|
|
6110
|
+
);
|
|
5681
6111
|
} else {
|
|
5682
|
-
editor = /* @__PURE__ */ jsx20(
|
|
5683
|
-
|
|
5684
|
-
|
|
5685
|
-
|
|
6112
|
+
editor = /* @__PURE__ */ jsx20(
|
|
6113
|
+
Input,
|
|
6114
|
+
{
|
|
6115
|
+
ref: inputRef,
|
|
6116
|
+
size: "small",
|
|
6117
|
+
value: String(editValue ?? ""),
|
|
6118
|
+
disabled: saving,
|
|
6119
|
+
suffix: saving ? /* @__PURE__ */ jsx20(Icon, { name: "loader", size: 13, spin: true }) : null,
|
|
6120
|
+
onChange: (event) => updateEditValue(event.target.value),
|
|
6121
|
+
onBlur: () => void save(),
|
|
6122
|
+
onKeyDown: (event) => {
|
|
6123
|
+
if (event.key === "Enter") void save();
|
|
6124
|
+
if (event.key === "Escape") onCancel();
|
|
6125
|
+
}
|
|
6126
|
+
}
|
|
6127
|
+
);
|
|
5686
6128
|
}
|
|
5687
6129
|
return /* @__PURE__ */ jsx20("div", { ref: editorRef, className: "sia-table__editor", children: editor });
|
|
5688
6130
|
}
|
|
@@ -5696,26 +6138,60 @@ function createEditablePlugin(options = {}) {
|
|
|
5696
6138
|
return mapTableLeafColumns(columns, (column) => {
|
|
5697
6139
|
if (!column.editable) return column;
|
|
5698
6140
|
const previousRender = column.render;
|
|
5699
|
-
return {
|
|
5700
|
-
|
|
5701
|
-
|
|
5702
|
-
|
|
5703
|
-
|
|
5704
|
-
|
|
5705
|
-
|
|
5706
|
-
|
|
6141
|
+
return {
|
|
6142
|
+
...column,
|
|
6143
|
+
render: (value, record, index, info) => {
|
|
6144
|
+
const config = typeof column.editable === "object" ? column.editable : void 0;
|
|
6145
|
+
const canEdit = config?.canEdit?.(record) ?? true;
|
|
6146
|
+
const active = canEdit && context.state.editing?.rowKey === info.row.key && context.state.editing.columnKey === column.key;
|
|
6147
|
+
const content = previousRender ? previousRender(value, record, index, info) : value;
|
|
6148
|
+
if (!canEdit) return content;
|
|
6149
|
+
return /* @__PURE__ */ jsx20(
|
|
6150
|
+
EditableTableCell,
|
|
6151
|
+
{
|
|
6152
|
+
active,
|
|
6153
|
+
editable: column.editable,
|
|
6154
|
+
value,
|
|
6155
|
+
record,
|
|
6156
|
+
content,
|
|
6157
|
+
trigger,
|
|
6158
|
+
onStart: () => context.setState({
|
|
6159
|
+
editing: { rowKey: info.row.key, columnKey: column.key }
|
|
6160
|
+
}),
|
|
6161
|
+
onCancel: () => context.setState(
|
|
6162
|
+
(state) => state.editing?.rowKey === info.row.key && state.editing.columnKey === column.key ? { editing: null } : state
|
|
6163
|
+
),
|
|
6164
|
+
onSave: async (nextValue) => await options.onCellChange?.(
|
|
6165
|
+
column.key,
|
|
6166
|
+
record,
|
|
6167
|
+
nextValue
|
|
6168
|
+
) !== false
|
|
6169
|
+
}
|
|
6170
|
+
);
|
|
6171
|
+
}
|
|
6172
|
+
};
|
|
5707
6173
|
});
|
|
5708
6174
|
},
|
|
5709
|
-
getApi: (context) => ({
|
|
6175
|
+
getApi: (context) => ({
|
|
6176
|
+
cancel: () => context.setState({ editing: null }),
|
|
6177
|
+
getEditingCell: () => context.state.editing
|
|
6178
|
+
})
|
|
5710
6179
|
};
|
|
5711
6180
|
}
|
|
5712
6181
|
function createResizePlugin(options = {}) {
|
|
5713
6182
|
const enabled = options.enabled ?? true;
|
|
5714
6183
|
function setWidth(columnKey, width, context, notify = false) {
|
|
5715
|
-
context.setState((state) => ({
|
|
6184
|
+
context.setState((state) => ({
|
|
6185
|
+
...state,
|
|
6186
|
+
widths: { ...state.widths, [columnKey]: width }
|
|
6187
|
+
}));
|
|
5716
6188
|
if (notify) {
|
|
5717
6189
|
options.onResize?.(columnKey, width);
|
|
5718
|
-
context.emit({
|
|
6190
|
+
context.emit({
|
|
6191
|
+
type: "columnResize",
|
|
6192
|
+
source: "resize",
|
|
6193
|
+
payload: { columnKey, width }
|
|
6194
|
+
});
|
|
5719
6195
|
}
|
|
5720
6196
|
}
|
|
5721
6197
|
return {
|
|
@@ -5729,61 +6205,98 @@ function createResizePlugin(options = {}) {
|
|
|
5729
6205
|
const configuredWidth = context.state.widths[column.key] ?? column.width;
|
|
5730
6206
|
const width = configuredWidth ?? (autoWidth ? void 0 : 160);
|
|
5731
6207
|
const previousHeader = column.renderHeader;
|
|
5732
|
-
return {
|
|
5733
|
-
|
|
5734
|
-
|
|
5735
|
-
|
|
5736
|
-
|
|
5737
|
-
|
|
5738
|
-
|
|
5739
|
-
|
|
5740
|
-
|
|
5741
|
-
|
|
5742
|
-
|
|
5743
|
-
|
|
5744
|
-
|
|
5745
|
-
|
|
5746
|
-
|
|
5747
|
-
|
|
5748
|
-
|
|
5749
|
-
|
|
5750
|
-
|
|
5751
|
-
|
|
5752
|
-
|
|
5753
|
-
|
|
5754
|
-
|
|
5755
|
-
|
|
5756
|
-
|
|
5757
|
-
|
|
5758
|
-
|
|
5759
|
-
|
|
5760
|
-
|
|
5761
|
-
|
|
5762
|
-
|
|
5763
|
-
|
|
5764
|
-
|
|
5765
|
-
|
|
5766
|
-
|
|
5767
|
-
|
|
5768
|
-
|
|
5769
|
-
|
|
5770
|
-
|
|
5771
|
-
|
|
5772
|
-
|
|
5773
|
-
|
|
5774
|
-
|
|
5775
|
-
|
|
5776
|
-
|
|
5777
|
-
|
|
5778
|
-
|
|
5779
|
-
|
|
6208
|
+
return {
|
|
6209
|
+
...column,
|
|
6210
|
+
autoWidth,
|
|
6211
|
+
width,
|
|
6212
|
+
renderHeader: (currentColumn, coreContext) => /* @__PURE__ */ jsxs19("span", { className: "sia-table__resizable-header", children: [
|
|
6213
|
+
/* @__PURE__ */ jsx20("span", { children: previousHeader ? previousHeader(currentColumn, coreContext) : currentColumn.title ?? currentColumn.name ?? currentColumn.key }),
|
|
6214
|
+
/* @__PURE__ */ jsx20(
|
|
6215
|
+
"span",
|
|
6216
|
+
{
|
|
6217
|
+
className: "sia-table__resize-handle",
|
|
6218
|
+
role: "separator",
|
|
6219
|
+
"aria-label": `\u8C03\u6574${getColumnLabel(currentColumn)}\u5217\u5BBD`,
|
|
6220
|
+
onMouseDown: (event) => {
|
|
6221
|
+
if (event.button !== 0) return;
|
|
6222
|
+
event.preventDefault();
|
|
6223
|
+
event.stopPropagation();
|
|
6224
|
+
const startX = event.clientX;
|
|
6225
|
+
const header = event.currentTarget.closest("th");
|
|
6226
|
+
const table = header?.closest("table");
|
|
6227
|
+
const viewport = table?.closest(
|
|
6228
|
+
".sia-table__viewport"
|
|
6229
|
+
);
|
|
6230
|
+
const renderedWidths = {};
|
|
6231
|
+
table?.querySelectorAll(
|
|
6232
|
+
"colgroup > col[data-column-key]"
|
|
6233
|
+
).forEach((element) => {
|
|
6234
|
+
const measured = element.getBoundingClientRect().width;
|
|
6235
|
+
if (measured > 0)
|
|
6236
|
+
renderedWidths[element.dataset.columnKey] = measured;
|
|
6237
|
+
});
|
|
6238
|
+
const startWidth = header?.getBoundingClientRect().width ?? currentColumn.width ?? width ?? 160;
|
|
6239
|
+
const startScrollLeft = viewport?.scrollLeft ?? 0;
|
|
6240
|
+
const minWidth = column.minWidth ?? 56;
|
|
6241
|
+
const maxWidth = column.maxWidth ?? Number.POSITIVE_INFINITY;
|
|
6242
|
+
let finalWidth = startWidth;
|
|
6243
|
+
let moved = false;
|
|
6244
|
+
const previousCursor = document.body.style.cursor;
|
|
6245
|
+
const previousUserSelect = document.body.style.userSelect;
|
|
6246
|
+
const move = (moveEvent) => {
|
|
6247
|
+
const scrollDelta = normalizeFixed(column.fixed) ? 0 : (viewport?.scrollLeft ?? 0) - startScrollLeft;
|
|
6248
|
+
finalWidth = Math.min(
|
|
6249
|
+
maxWidth,
|
|
6250
|
+
Math.max(
|
|
6251
|
+
minWidth,
|
|
6252
|
+
startWidth + moveEvent.clientX - startX + scrollDelta
|
|
6253
|
+
)
|
|
6254
|
+
);
|
|
6255
|
+
moved = true;
|
|
6256
|
+
context.setState((state) => ({
|
|
6257
|
+
...state,
|
|
6258
|
+
manualLayout: true,
|
|
6259
|
+
widths: {
|
|
6260
|
+
...state.widths,
|
|
6261
|
+
...renderedWidths,
|
|
6262
|
+
[column.key]: finalWidth
|
|
6263
|
+
}
|
|
6264
|
+
}));
|
|
6265
|
+
};
|
|
6266
|
+
const up = () => {
|
|
6267
|
+
document.removeEventListener("mousemove", move);
|
|
6268
|
+
document.removeEventListener("mouseup", up);
|
|
6269
|
+
window.removeEventListener("blur", up);
|
|
6270
|
+
document.body.style.cursor = previousCursor;
|
|
6271
|
+
document.body.style.userSelect = previousUserSelect;
|
|
6272
|
+
if (moved) setWidth(column.key, finalWidth, context, true);
|
|
6273
|
+
};
|
|
6274
|
+
document.addEventListener("mousemove", move);
|
|
6275
|
+
document.addEventListener("mouseup", up);
|
|
6276
|
+
window.addEventListener("blur", up);
|
|
6277
|
+
document.body.style.cursor = "ew-resize";
|
|
6278
|
+
document.body.style.userSelect = "none";
|
|
6279
|
+
}
|
|
6280
|
+
}
|
|
6281
|
+
)
|
|
6282
|
+
] })
|
|
6283
|
+
};
|
|
5780
6284
|
});
|
|
5781
6285
|
},
|
|
5782
|
-
getApi: (context) => ({
|
|
6286
|
+
getApi: (context) => ({
|
|
6287
|
+
getWidths: () => context.state.widths,
|
|
6288
|
+
setWidth: (columnKey, width) => setWidth(columnKey, width, context, true)
|
|
6289
|
+
})
|
|
5783
6290
|
};
|
|
5784
6291
|
}
|
|
5785
6292
|
function createColumnSettingItems(columns, visibleKeys) {
|
|
5786
|
-
return flattenTableColumns(columns).map((column, order) => ({
|
|
6293
|
+
return flattenTableColumns(columns).map((column, order) => ({
|
|
6294
|
+
key: column.key,
|
|
6295
|
+
width: column.width,
|
|
6296
|
+
fixed: normalizeFixed(column.fixed),
|
|
6297
|
+
visible: !column.hidden && (!visibleKeys || visibleKeys.includes(column.key)),
|
|
6298
|
+
order
|
|
6299
|
+
}));
|
|
5787
6300
|
}
|
|
5788
6301
|
function applyColumnSettingsToTree(columns, items) {
|
|
5789
6302
|
const itemMap = new Map(items.map((item) => [item.key, item]));
|
|
@@ -5791,17 +6304,28 @@ function applyColumnSettingsToTree(columns, items) {
|
|
|
5791
6304
|
if (column.children?.length) {
|
|
5792
6305
|
const children = walk(column.children);
|
|
5793
6306
|
if (children.length === 0) return [];
|
|
5794
|
-
return [
|
|
5795
|
-
|
|
5796
|
-
|
|
5797
|
-
|
|
6307
|
+
return [
|
|
6308
|
+
{
|
|
6309
|
+
column: {
|
|
6310
|
+
...column,
|
|
6311
|
+
children: children.map((entry) => entry.column)
|
|
6312
|
+
},
|
|
6313
|
+
order: Math.min(...children.map((entry) => entry.order))
|
|
6314
|
+
}
|
|
6315
|
+
];
|
|
5798
6316
|
}
|
|
5799
6317
|
const item = itemMap.get(column.key);
|
|
5800
6318
|
if (item && !item.visible) return [];
|
|
5801
|
-
return [
|
|
5802
|
-
|
|
5803
|
-
|
|
5804
|
-
|
|
6319
|
+
return [
|
|
6320
|
+
{
|
|
6321
|
+
column: item ? {
|
|
6322
|
+
...column,
|
|
6323
|
+
width: item.width ?? column.width,
|
|
6324
|
+
fixed: item.fixed
|
|
6325
|
+
} : column,
|
|
6326
|
+
order: item?.order ?? items.length + sourceOrder
|
|
6327
|
+
}
|
|
6328
|
+
];
|
|
5805
6329
|
}).sort((left, right) => left.order - right.order);
|
|
5806
6330
|
return walk(columns).map((entry) => entry.column);
|
|
5807
6331
|
}
|
|
@@ -5809,17 +6333,31 @@ function orderColumnSettings(items) {
|
|
|
5809
6333
|
const rank = (item) => item.fixed === "left" ? 0 : item.fixed === "right" ? 2 : 1;
|
|
5810
6334
|
return [...items].sort((a, b) => rank(a) - rank(b)).map((item, order) => ({ ...item, order }));
|
|
5811
6335
|
}
|
|
5812
|
-
function ColumnSettingPanel({
|
|
6336
|
+
function ColumnSettingPanel({
|
|
6337
|
+
open,
|
|
6338
|
+
items,
|
|
6339
|
+
columns,
|
|
6340
|
+
loading,
|
|
6341
|
+
loadError,
|
|
6342
|
+
onRetry,
|
|
6343
|
+
onClose,
|
|
6344
|
+
onApply
|
|
6345
|
+
}) {
|
|
5813
6346
|
const [draft, setDraft] = useState16(items);
|
|
5814
6347
|
const listRef = useRef14(null);
|
|
5815
6348
|
const cancelDrag = useRef14(null);
|
|
5816
6349
|
const [preview, setPreview] = useState16(null);
|
|
5817
|
-
|
|
6350
|
+
useEffect11(() => {
|
|
5818
6351
|
cancelDrag.current?.();
|
|
5819
6352
|
if (open) setDraft(orderColumnSettings(items));
|
|
5820
6353
|
}, [items, open]);
|
|
5821
|
-
|
|
5822
|
-
const labels = new Map(
|
|
6354
|
+
useEffect11(() => () => cancelDrag.current?.(), []);
|
|
6355
|
+
const labels = new Map(
|
|
6356
|
+
flattenTableColumns(columns).map((column) => [
|
|
6357
|
+
column.key,
|
|
6358
|
+
getColumnLabel(column)
|
|
6359
|
+
])
|
|
6360
|
+
);
|
|
5823
6361
|
const visibleCount = draft.filter((item) => item.visible).length;
|
|
5824
6362
|
function setFixed(key, fixed) {
|
|
5825
6363
|
setDraft((previous) => {
|
|
@@ -5833,13 +6371,16 @@ function ColumnSettingPanel({ open, items, columns, loading, loadError, onRetry,
|
|
|
5833
6371
|
});
|
|
5834
6372
|
}
|
|
5835
6373
|
function startSort(event, key) {
|
|
5836
|
-
if (loading || loadError || event.button !== 0 || event.target.closest("button, input, label"))
|
|
6374
|
+
if (loading || loadError || event.button !== 0 || event.target.closest("button, input, label"))
|
|
6375
|
+
return;
|
|
5837
6376
|
const list = listRef.current;
|
|
5838
6377
|
if (!list) return;
|
|
5839
6378
|
cancelDrag.current?.();
|
|
5840
6379
|
const original = [...draft];
|
|
5841
6380
|
const from = original.findIndex((item) => item.key === key);
|
|
5842
|
-
const elements = Array.from(
|
|
6381
|
+
const elements = Array.from(
|
|
6382
|
+
list.querySelectorAll(".sia-table-settings__item")
|
|
6383
|
+
);
|
|
5843
6384
|
const rects = elements.map((element) => element.getBoundingClientRect());
|
|
5844
6385
|
const gap = parseFloat(getComputedStyle(list).rowGap) || 0;
|
|
5845
6386
|
const positions = original.map((_, index) => index);
|
|
@@ -5849,7 +6390,8 @@ function ColumnSettingPanel({ open, items, columns, loading, loadError, onRetry,
|
|
|
5849
6390
|
let next = original;
|
|
5850
6391
|
let frame = 0;
|
|
5851
6392
|
let scrollParent = list.parentElement;
|
|
5852
|
-
while (scrollParent && !(scrollParent.scrollHeight > scrollParent.clientHeight && /auto|scroll/.test(getComputedStyle(scrollParent).overflowY)))
|
|
6393
|
+
while (scrollParent && !(scrollParent.scrollHeight > scrollParent.clientHeight && /auto|scroll/.test(getComputedStyle(scrollParent).overflowY)))
|
|
6394
|
+
scrollParent = scrollParent.parentElement;
|
|
5853
6395
|
const initialScroll = scrollParent?.scrollTop ?? 0;
|
|
5854
6396
|
const target = event.currentTarget;
|
|
5855
6397
|
target.setPointerCapture(event.pointerId);
|
|
@@ -5862,7 +6404,8 @@ function ColumnSettingPanel({ open, items, columns, loading, loadError, onRetry,
|
|
|
5862
6404
|
const center = rects[from].top + rects[from].height / 2 + dy;
|
|
5863
6405
|
let to = from;
|
|
5864
6406
|
for (const index of positions) {
|
|
5865
|
-
if (index > from && center > rects[index].top + rects[index].height / 2)
|
|
6407
|
+
if (index > from && center > rects[index].top + rects[index].height / 2)
|
|
6408
|
+
to = index;
|
|
5866
6409
|
if (index < from && center < rects[index].top + rects[index].height / 2) {
|
|
5867
6410
|
to = index;
|
|
5868
6411
|
break;
|
|
@@ -5903,7 +6446,8 @@ function ColumnSettingPanel({ open, items, columns, loading, loadError, onRetry,
|
|
|
5903
6446
|
document.removeEventListener("keydown", escape, true);
|
|
5904
6447
|
window.removeEventListener("blur", cancel);
|
|
5905
6448
|
cancelAnimationFrame(frame);
|
|
5906
|
-
if (target.hasPointerCapture(event.pointerId))
|
|
6449
|
+
if (target.hasPointerCapture(event.pointerId))
|
|
6450
|
+
target.releasePointerCapture(event.pointerId);
|
|
5907
6451
|
document.body.style.userSelect = previousUserSelect;
|
|
5908
6452
|
cancelDrag.current = null;
|
|
5909
6453
|
setPreview(null);
|
|
@@ -5934,49 +6478,135 @@ function ColumnSettingPanel({ open, items, columns, loading, loadError, onRetry,
|
|
|
5934
6478
|
window.addEventListener("blur", cancel);
|
|
5935
6479
|
frame = requestAnimationFrame(tick);
|
|
5936
6480
|
}
|
|
5937
|
-
return /* @__PURE__ */ jsxs19(
|
|
5938
|
-
|
|
5939
|
-
|
|
5940
|
-
|
|
5941
|
-
|
|
5942
|
-
|
|
5943
|
-
|
|
5944
|
-
|
|
5945
|
-
|
|
5946
|
-
/* @__PURE__ */
|
|
5947
|
-
|
|
5948
|
-
|
|
5949
|
-
|
|
5950
|
-
|
|
5951
|
-
|
|
5952
|
-
|
|
5953
|
-
|
|
5954
|
-
|
|
5955
|
-
|
|
5956
|
-
|
|
5957
|
-
] })
|
|
6481
|
+
return /* @__PURE__ */ jsxs19(
|
|
6482
|
+
Drawer2,
|
|
6483
|
+
{
|
|
6484
|
+
open,
|
|
6485
|
+
title: "\u5217\u8BBE\u7F6E",
|
|
6486
|
+
size: 440,
|
|
6487
|
+
onOpenChange: (next) => {
|
|
6488
|
+
if (!next) onClose();
|
|
6489
|
+
},
|
|
6490
|
+
footer: /* @__PURE__ */ jsxs19(Fragment6, { children: [
|
|
6491
|
+
/* @__PURE__ */ jsx20(Button, { onClick: onClose, children: "\u53D6\u6D88" }),
|
|
6492
|
+
/* @__PURE__ */ jsx20(
|
|
6493
|
+
Button,
|
|
6494
|
+
{
|
|
6495
|
+
variant: "primary",
|
|
6496
|
+
disabled: loading || loadError,
|
|
6497
|
+
onClick: () => onApply(draft),
|
|
6498
|
+
children: "\u5E94\u7528"
|
|
6499
|
+
}
|
|
6500
|
+
)
|
|
5958
6501
|
] }),
|
|
5959
|
-
|
|
5960
|
-
"
|
|
5961
|
-
|
|
5962
|
-
"
|
|
5963
|
-
|
|
5964
|
-
|
|
5965
|
-
|
|
5966
|
-
|
|
5967
|
-
|
|
5968
|
-
|
|
5969
|
-
|
|
5970
|
-
|
|
5971
|
-
/* @__PURE__ */
|
|
5972
|
-
|
|
5973
|
-
|
|
5974
|
-
|
|
5975
|
-
|
|
5976
|
-
|
|
5977
|
-
|
|
5978
|
-
|
|
5979
|
-
|
|
6502
|
+
children: [
|
|
6503
|
+
loadError ? /* @__PURE__ */ jsxs19("p", { role: "alert", children: [
|
|
6504
|
+
"\u8BFB\u53D6\u5217\u914D\u7F6E\u5931\u8D25\u3002",
|
|
6505
|
+
/* @__PURE__ */ jsx20(Button, { variant: "link", onClick: onRetry, children: "\u91CD\u8BD5" })
|
|
6506
|
+
] }) : null,
|
|
6507
|
+
/* @__PURE__ */ jsx20(Spin, { spinning: Boolean(loading), className: "sia-table-settings__loading", "aria-label": loading ? "\u6B63\u5728\u8BFB\u53D6\u5217\u914D\u7F6E" : void 0, children: /* @__PURE__ */ jsxs19(
|
|
6508
|
+
"fieldset",
|
|
6509
|
+
{
|
|
6510
|
+
disabled: loading || loadError,
|
|
6511
|
+
style: { border: 0, padding: 0, margin: 0, minWidth: 0 },
|
|
6512
|
+
"aria-busy": loading,
|
|
6513
|
+
children: [
|
|
6514
|
+
/* @__PURE__ */ jsxs19("label", { className: "sia-table-settings__all", children: [
|
|
6515
|
+
/* @__PURE__ */ jsx20(
|
|
6516
|
+
TableCheckbox,
|
|
6517
|
+
{
|
|
6518
|
+
label: "\u5168\u9009\u5217",
|
|
6519
|
+
checked: visibleCount === draft.length && draft.length > 0,
|
|
6520
|
+
indeterminate: visibleCount > 0 && visibleCount < draft.length,
|
|
6521
|
+
onChange: (checked) => setDraft(
|
|
6522
|
+
(previous) => previous.map((item) => ({ ...item, visible: checked }))
|
|
6523
|
+
)
|
|
6524
|
+
}
|
|
6525
|
+
),
|
|
6526
|
+
/* @__PURE__ */ jsxs19("span", { children: [
|
|
6527
|
+
"\u5168\u9009\uFF08",
|
|
6528
|
+
visibleCount,
|
|
6529
|
+
"/",
|
|
6530
|
+
draft.length,
|
|
6531
|
+
"\uFF09"
|
|
6532
|
+
] })
|
|
6533
|
+
] }),
|
|
6534
|
+
/* @__PURE__ */ jsx20(
|
|
6535
|
+
"div",
|
|
6536
|
+
{
|
|
6537
|
+
ref: listRef,
|
|
6538
|
+
className: `sia-table-settings__list${preview ? " is-sorting" : ""}`,
|
|
6539
|
+
children: draft.map((item) => /* @__PURE__ */ jsxs19(
|
|
6540
|
+
"div",
|
|
6541
|
+
{
|
|
6542
|
+
"data-column-key": item.key,
|
|
6543
|
+
className: `sia-table-settings__item${preview?.key === item.key ? " is-dragging" : ""}`,
|
|
6544
|
+
style: preview ? {
|
|
6545
|
+
transform: `translateY(${preview.offsets[item.key] ?? 0}px)`
|
|
6546
|
+
} : void 0,
|
|
6547
|
+
onPointerDown: (event) => startSort(event, item.key),
|
|
6548
|
+
children: [
|
|
6549
|
+
/* @__PURE__ */ jsx20(Icon, { name: "menu", size: 15 }),
|
|
6550
|
+
/* @__PURE__ */ jsx20(
|
|
6551
|
+
TableCheckbox,
|
|
6552
|
+
{
|
|
6553
|
+
label: `\u663E\u793A${labels.get(item.key) ?? item.key}\u5217`,
|
|
6554
|
+
checked: item.visible,
|
|
6555
|
+
onChange: (checked) => setDraft(
|
|
6556
|
+
(previous) => previous.map(
|
|
6557
|
+
(entry) => entry.key === item.key ? { ...entry, visible: checked } : entry
|
|
6558
|
+
)
|
|
6559
|
+
)
|
|
6560
|
+
}
|
|
6561
|
+
),
|
|
6562
|
+
/* @__PURE__ */ jsx20(
|
|
6563
|
+
"span",
|
|
6564
|
+
{
|
|
6565
|
+
className: "sia-table-settings__name",
|
|
6566
|
+
title: labels.get(item.key) ?? item.key,
|
|
6567
|
+
children: labels.get(item.key) ?? item.key
|
|
6568
|
+
}
|
|
6569
|
+
),
|
|
6570
|
+
/* @__PURE__ */ jsxs19("div", { className: "sia-table-settings__actions", children: [
|
|
6571
|
+
/* @__PURE__ */ jsx20(
|
|
6572
|
+
Button,
|
|
6573
|
+
{
|
|
6574
|
+
size: "small",
|
|
6575
|
+
variant: (preview?.key === item.key ? preview.fixed : item.fixed) === "left" ? "primary" : "text",
|
|
6576
|
+
"aria-label": "\u5DE6\u56FA\u5B9A",
|
|
6577
|
+
onClick: () => setFixed(
|
|
6578
|
+
item.key,
|
|
6579
|
+
item.fixed === "left" ? void 0 : "left"
|
|
6580
|
+
),
|
|
6581
|
+
children: "\u5DE6"
|
|
6582
|
+
}
|
|
6583
|
+
),
|
|
6584
|
+
/* @__PURE__ */ jsx20(
|
|
6585
|
+
Button,
|
|
6586
|
+
{
|
|
6587
|
+
size: "small",
|
|
6588
|
+
variant: (preview?.key === item.key ? preview.fixed : item.fixed) === "right" ? "primary" : "text",
|
|
6589
|
+
"aria-label": "\u53F3\u56FA\u5B9A",
|
|
6590
|
+
onClick: () => setFixed(
|
|
6591
|
+
item.key,
|
|
6592
|
+
item.fixed === "right" ? void 0 : "right"
|
|
6593
|
+
),
|
|
6594
|
+
children: "\u53F3"
|
|
6595
|
+
}
|
|
6596
|
+
)
|
|
6597
|
+
] })
|
|
6598
|
+
]
|
|
6599
|
+
},
|
|
6600
|
+
item.key
|
|
6601
|
+
))
|
|
6602
|
+
}
|
|
6603
|
+
)
|
|
6604
|
+
]
|
|
6605
|
+
}
|
|
6606
|
+
) })
|
|
6607
|
+
]
|
|
6608
|
+
}
|
|
6609
|
+
);
|
|
5980
6610
|
}
|
|
5981
6611
|
var columnSettingLoadTokens = /* @__PURE__ */ new WeakMap();
|
|
5982
6612
|
function createColumnSettingPlugin(options = {}) {
|
|
@@ -5984,12 +6614,28 @@ function createColumnSettingPlugin(options = {}) {
|
|
|
5984
6614
|
const currentItems = (context) => context.state.items?.length ? context.state.items : baseItems(context);
|
|
5985
6615
|
const save = (snapshot) => options.adapter && options.scope ? options.adapter.save(options.scope, snapshot).catch(() => void 0) : Promise.resolve();
|
|
5986
6616
|
function apply(items, context, persist = true) {
|
|
5987
|
-
const normalized = orderColumnSettings(
|
|
6617
|
+
const normalized = orderColumnSettings(
|
|
6618
|
+
[...items].sort((a, b) => a.order - b.order)
|
|
6619
|
+
);
|
|
5988
6620
|
context.setState((state) => ({ ...state, items: normalized, open: false }));
|
|
5989
|
-
const columnMap = new Map(
|
|
5990
|
-
|
|
5991
|
-
|
|
5992
|
-
|
|
6621
|
+
const columnMap = new Map(
|
|
6622
|
+
flattenTableColumns(context.baseColumns).map((column) => [
|
|
6623
|
+
column.key,
|
|
6624
|
+
column
|
|
6625
|
+
])
|
|
6626
|
+
);
|
|
6627
|
+
options.onVisibleChange?.(
|
|
6628
|
+
normalized.filter((item) => item.visible).map((item) => columnMap.get(item.key)).filter(Boolean)
|
|
6629
|
+
);
|
|
6630
|
+
options.onOrderChange?.(
|
|
6631
|
+
normalized.map((item) => columnMap.get(item.key)).filter(Boolean)
|
|
6632
|
+
);
|
|
6633
|
+
if (persist)
|
|
6634
|
+
void save({
|
|
6635
|
+
columns: normalized,
|
|
6636
|
+
pageSize: context.state.pageSize,
|
|
6637
|
+
version: 1
|
|
6638
|
+
});
|
|
5993
6639
|
}
|
|
5994
6640
|
function loadSettings(context, open = false) {
|
|
5995
6641
|
const fallback = baseItems(context);
|
|
@@ -6006,20 +6652,31 @@ function createColumnSettingPlugin(options = {}) {
|
|
|
6006
6652
|
loadError: false,
|
|
6007
6653
|
loadToken: token
|
|
6008
6654
|
}));
|
|
6009
|
-
if (hasAdapter)
|
|
6010
|
-
|
|
6011
|
-
|
|
6012
|
-
|
|
6013
|
-
|
|
6014
|
-
|
|
6015
|
-
|
|
6016
|
-
|
|
6017
|
-
|
|
6018
|
-
|
|
6655
|
+
if (hasAdapter)
|
|
6656
|
+
void Promise.resolve().then(() => options.adapter.load(options.scope)).then((snapshot) => {
|
|
6657
|
+
if (cancelled || columnSettingLoadTokens.get(context.setPluginState) !== token)
|
|
6658
|
+
return;
|
|
6659
|
+
if (snapshot?.pageSize)
|
|
6660
|
+
context.setPluginState("pagination", (state) => ({
|
|
6661
|
+
...state,
|
|
6662
|
+
pageSize: snapshot.pageSize
|
|
6663
|
+
}));
|
|
6664
|
+
context.setState(
|
|
6665
|
+
(state) => state.loadToken !== token ? state : {
|
|
6666
|
+
...state,
|
|
6667
|
+
items: snapshot?.columns?.length ? snapshot.columns : fallback,
|
|
6668
|
+
pageSize: snapshot?.pageSize,
|
|
6669
|
+
loaded: true,
|
|
6670
|
+
loading: false,
|
|
6671
|
+
loadError: false
|
|
6672
|
+
}
|
|
6673
|
+
);
|
|
6674
|
+
}).catch(() => {
|
|
6675
|
+
if (!cancelled)
|
|
6676
|
+
context.setState(
|
|
6677
|
+
(state) => state.loadToken !== token ? state : { ...state, loading: false, loaded: true, loadError: true }
|
|
6678
|
+
);
|
|
6019
6679
|
});
|
|
6020
|
-
}).catch(() => {
|
|
6021
|
-
if (!cancelled) context.setState((state) => state.loadToken !== token ? state : { ...state, loading: false, loaded: true, loadError: true });
|
|
6022
|
-
});
|
|
6023
6680
|
return () => {
|
|
6024
6681
|
cancelled = true;
|
|
6025
6682
|
};
|
|
@@ -6037,9 +6694,15 @@ function createColumnSettingPlugin(options = {}) {
|
|
|
6037
6694
|
onEvent(event, context) {
|
|
6038
6695
|
if (event.type === "columnResize") {
|
|
6039
6696
|
const { columnKey, width } = event.payload;
|
|
6040
|
-
const next = currentItems(context).map(
|
|
6697
|
+
const next = currentItems(context).map(
|
|
6698
|
+
(item) => item.key === columnKey ? { ...item, width } : item
|
|
6699
|
+
);
|
|
6041
6700
|
context.setState((state) => ({ ...state, items: next }));
|
|
6042
|
-
void save({
|
|
6701
|
+
void save({
|
|
6702
|
+
columns: next,
|
|
6703
|
+
pageSize: context.state.pageSize,
|
|
6704
|
+
version: 1
|
|
6705
|
+
});
|
|
6043
6706
|
}
|
|
6044
6707
|
if (event.type === "pageSizeChange") {
|
|
6045
6708
|
const pageSize = event.payload;
|
|
@@ -6048,15 +6711,30 @@ function createColumnSettingPlugin(options = {}) {
|
|
|
6048
6711
|
}
|
|
6049
6712
|
},
|
|
6050
6713
|
renderToolbarEnd: options.showButton === false ? void 0 : (context) => {
|
|
6051
|
-
const exportApi = () => context.getPluginApi("export") ?? createExportPlugin().getApi({
|
|
6052
|
-
|
|
6053
|
-
|
|
6714
|
+
const exportApi = () => context.getPluginApi("export") ?? createExportPlugin().getApi({
|
|
6715
|
+
...context,
|
|
6716
|
+
state: void 0,
|
|
6717
|
+
setState: () => {
|
|
6718
|
+
}
|
|
6719
|
+
});
|
|
6720
|
+
const customItems = (options.menuItems ?? []).filter(
|
|
6721
|
+
(item) => !(item.hidden === true || typeof item.hidden === "function" && item.hidden(context))
|
|
6722
|
+
);
|
|
6054
6723
|
const items = [
|
|
6055
6724
|
...options.showExport === false ? [] : [
|
|
6056
|
-
{
|
|
6725
|
+
{
|
|
6726
|
+
key: "builtin:export",
|
|
6727
|
+
label: "\u8868\u683C\u5BFC\u51FA",
|
|
6728
|
+
icon: /* @__PURE__ */ jsx20(Icon, { name: "download", size: 18 }),
|
|
6729
|
+
disabled: exportApi().getRows().length === 0
|
|
6730
|
+
},
|
|
6057
6731
|
{ key: "builtin:divider", type: "divider" }
|
|
6058
6732
|
],
|
|
6059
|
-
{
|
|
6733
|
+
{
|
|
6734
|
+
key: "builtin:columns",
|
|
6735
|
+
label: "\u5217\u8BBE\u7F6E",
|
|
6736
|
+
icon: /* @__PURE__ */ jsx20(Icon, { name: "settings", size: 18 })
|
|
6737
|
+
},
|
|
6060
6738
|
...customItems.map((item) => ({
|
|
6061
6739
|
key: "custom:" + item.key,
|
|
6062
6740
|
label: item.label,
|
|
@@ -6065,33 +6743,67 @@ function createColumnSettingPlugin(options = {}) {
|
|
|
6065
6743
|
disabled: item.disabled === true || typeof item.disabled === "function" && item.disabled(context)
|
|
6066
6744
|
}))
|
|
6067
6745
|
];
|
|
6068
|
-
return /* @__PURE__ */ jsx20(
|
|
6069
|
-
|
|
6070
|
-
else if (key === "builtin:columns") loadSettings(context, true);
|
|
6071
|
-
else void customItems.find((item) => "custom:" + item.key === key)?.onClick?.(context);
|
|
6072
|
-
} }, children: /* @__PURE__ */ jsx20(
|
|
6073
|
-
Button,
|
|
6746
|
+
return /* @__PURE__ */ jsx20(
|
|
6747
|
+
Dropdown,
|
|
6074
6748
|
{
|
|
6075
|
-
|
|
6076
|
-
|
|
6077
|
-
|
|
6078
|
-
|
|
6079
|
-
|
|
6080
|
-
|
|
6749
|
+
disabled: options.buttonProps?.disabled || options.buttonProps?.loading,
|
|
6750
|
+
trigger: ["hover", "click"],
|
|
6751
|
+
placement: "bottomRight",
|
|
6752
|
+
popupClassName: "sia-table__settings-dropdown",
|
|
6753
|
+
menu: {
|
|
6754
|
+
items,
|
|
6755
|
+
onClick: ({ key }) => {
|
|
6756
|
+
if (key === "builtin:export") void exportApi().download();
|
|
6757
|
+
else if (key === "builtin:columns")
|
|
6758
|
+
loadSettings(context, true);
|
|
6759
|
+
else
|
|
6760
|
+
void customItems.find((item) => "custom:" + item.key === key)?.onClick?.(context);
|
|
6761
|
+
}
|
|
6762
|
+
},
|
|
6763
|
+
children: /* @__PURE__ */ jsx20(
|
|
6764
|
+
Button,
|
|
6765
|
+
{
|
|
6766
|
+
size: "small",
|
|
6767
|
+
variant: "text",
|
|
6768
|
+
icon: /* @__PURE__ */ jsx20(Icon, { name: "settings", size: 16 }),
|
|
6769
|
+
"aria-label": "\u8868\u683C\u8BBE\u7F6E",
|
|
6770
|
+
...options.buttonProps,
|
|
6771
|
+
className: `sia-table__settings-button${options.buttonProps?.children == null ? " sia-table__toolbar-icon" : ""} ${options.buttonProps?.className ?? ""}`.trim()
|
|
6772
|
+
}
|
|
6773
|
+
)
|
|
6081
6774
|
}
|
|
6082
|
-
)
|
|
6775
|
+
);
|
|
6083
6776
|
},
|
|
6084
|
-
renderOverlay: (context) => /* @__PURE__ */ jsx20(
|
|
6085
|
-
|
|
6086
|
-
|
|
6087
|
-
|
|
6777
|
+
renderOverlay: (context) => /* @__PURE__ */ jsx20(
|
|
6778
|
+
ColumnSettingPanel,
|
|
6779
|
+
{
|
|
6780
|
+
open: context.state.open,
|
|
6781
|
+
loading: context.state.loading,
|
|
6782
|
+
loadError: context.state.loadError,
|
|
6783
|
+
onRetry: () => loadSettings(context, true),
|
|
6784
|
+
items: currentItems(context),
|
|
6785
|
+
columns: context.baseColumns,
|
|
6786
|
+
onClose: () => context.setState((state) => ({ ...state, open: false })),
|
|
6787
|
+
onApply: (items) => apply(items, context)
|
|
6788
|
+
}
|
|
6789
|
+
),
|
|
6790
|
+
getApi: (context) => ({
|
|
6791
|
+
open: () => {
|
|
6792
|
+
loadSettings(context, true);
|
|
6793
|
+
},
|
|
6794
|
+
close: () => context.setState((state) => ({ ...state, open: false })),
|
|
6795
|
+
getSettings: () => currentItems(context),
|
|
6796
|
+
apply: (items) => apply(items, context)
|
|
6797
|
+
})
|
|
6088
6798
|
};
|
|
6089
6799
|
}
|
|
6090
6800
|
function createLocalStorageTableSettingsAdapter(prefix = "sia-table") {
|
|
6091
6801
|
return {
|
|
6092
6802
|
async load(scope) {
|
|
6093
6803
|
if (typeof localStorage === "undefined") return null;
|
|
6094
|
-
const raw = localStorage.getItem(
|
|
6804
|
+
const raw = localStorage.getItem(
|
|
6805
|
+
`${prefix}:${scope.moduleName}:${scope.businessKey}`
|
|
6806
|
+
);
|
|
6095
6807
|
if (!raw) return null;
|
|
6096
6808
|
try {
|
|
6097
6809
|
return JSON.parse(raw);
|
|
@@ -6101,20 +6813,41 @@ function createLocalStorageTableSettingsAdapter(prefix = "sia-table") {
|
|
|
6101
6813
|
},
|
|
6102
6814
|
async save(scope, settings) {
|
|
6103
6815
|
if (typeof localStorage === "undefined") return;
|
|
6104
|
-
localStorage.setItem(
|
|
6816
|
+
localStorage.setItem(
|
|
6817
|
+
`${prefix}:${scope.moduleName}:${scope.businessKey}`,
|
|
6818
|
+
JSON.stringify(settings)
|
|
6819
|
+
);
|
|
6105
6820
|
}
|
|
6106
6821
|
};
|
|
6107
6822
|
}
|
|
6108
|
-
function ToolbarItems({
|
|
6823
|
+
function ToolbarItems({
|
|
6824
|
+
items,
|
|
6825
|
+
context
|
|
6826
|
+
}) {
|
|
6109
6827
|
return /* @__PURE__ */ jsx20(Fragment6, { children: items.map((item) => {
|
|
6110
|
-
if (item.hidden === true || typeof item.hidden === "function" && item.hidden(context))
|
|
6828
|
+
if (item.hidden === true || typeof item.hidden === "function" && item.hidden(context))
|
|
6829
|
+
return null;
|
|
6111
6830
|
const disabled = item.disabled === true || typeof item.disabled === "function" && item.disabled(context);
|
|
6112
|
-
return /* @__PURE__ */ jsx20(
|
|
6831
|
+
return /* @__PURE__ */ jsx20(
|
|
6832
|
+
Button,
|
|
6833
|
+
{
|
|
6834
|
+
size: "small",
|
|
6835
|
+
danger: item.danger,
|
|
6836
|
+
icon: item.icon,
|
|
6837
|
+
disabled,
|
|
6838
|
+
title: typeof item.label === "string" ? item.label : void 0,
|
|
6839
|
+
onClick: () => void item.onClick?.(context),
|
|
6840
|
+
children: item.label
|
|
6841
|
+
},
|
|
6842
|
+
item.key
|
|
6843
|
+
);
|
|
6113
6844
|
}) });
|
|
6114
6845
|
}
|
|
6115
6846
|
function createToolbarPlugin(options) {
|
|
6116
6847
|
const allowed = (item) => options.canAccess?.(item) ?? true;
|
|
6117
|
-
const items = (position, inSettings = false) => (options.items ?? []).filter(
|
|
6848
|
+
const items = (position, inSettings = false) => (options.items ?? []).filter(
|
|
6849
|
+
(item) => allowed(item) && (item.position ?? "start") === position && Boolean(item.inSettings) === inSettings
|
|
6850
|
+
);
|
|
6118
6851
|
return {
|
|
6119
6852
|
id: "toolbar",
|
|
6120
6853
|
order: 5,
|
|
@@ -6133,10 +6866,13 @@ function createToolbarPlugin(options) {
|
|
|
6133
6866
|
};
|
|
6134
6867
|
}
|
|
6135
6868
|
function tableExportText(node) {
|
|
6136
|
-
if (node === null || node === void 0 || typeof node === "boolean")
|
|
6137
|
-
|
|
6869
|
+
if (node === null || node === void 0 || typeof node === "boolean")
|
|
6870
|
+
return "";
|
|
6871
|
+
if (typeof node === "string" || typeof node === "number" || typeof node === "bigint")
|
|
6872
|
+
return String(node);
|
|
6138
6873
|
if (Array.isArray(node)) return node.map(tableExportText).join("");
|
|
6139
|
-
if (isValidElement3(node))
|
|
6874
|
+
if (isValidElement3(node))
|
|
6875
|
+
return tableExportText(node.props.children);
|
|
6140
6876
|
return "";
|
|
6141
6877
|
}
|
|
6142
6878
|
function tableExportCell(value, sanitizeFormula) {
|
|
@@ -6149,7 +6885,8 @@ function tableExportEscape(value, delimiter) {
|
|
|
6149
6885
|
function createExportPlugin(options = {}) {
|
|
6150
6886
|
function getRows(context, scope = options.scope ?? "visible") {
|
|
6151
6887
|
if (scope === "all") return context.sourceData;
|
|
6152
|
-
if (scope === "selected")
|
|
6888
|
+
if (scope === "selected")
|
|
6889
|
+
return context.getPluginApi("selection")?.getSelectedRows() ?? [];
|
|
6153
6890
|
return context.rows.map((row) => row.record);
|
|
6154
6891
|
}
|
|
6155
6892
|
function getCsv(context, scope) {
|
|
@@ -6169,8 +6906,16 @@ function createExportPlugin(options = {}) {
|
|
|
6169
6906
|
meta: {}
|
|
6170
6907
|
};
|
|
6171
6908
|
return columns.map((column) => {
|
|
6172
|
-
const value = getTableValue(
|
|
6173
|
-
|
|
6909
|
+
const value = getTableValue(
|
|
6910
|
+
record,
|
|
6911
|
+
column.dataIndex,
|
|
6912
|
+
column.code ?? column.key
|
|
6913
|
+
);
|
|
6914
|
+
const rendered = column.exportRender?.(value, record, rowIndex, {
|
|
6915
|
+
row,
|
|
6916
|
+
rowIndex,
|
|
6917
|
+
column
|
|
6918
|
+
});
|
|
6174
6919
|
const text = rendered === void 0 ? tableExportCell(value, sanitizeFormula) : tableExportText(rendered);
|
|
6175
6920
|
return tableExportEscape(text, delimiter);
|
|
6176
6921
|
}).join(delimiter);
|
|
@@ -6488,7 +7233,7 @@ function TableInner(props, ref) {
|
|
|
6488
7233
|
});
|
|
6489
7234
|
pluginApisRef.current = nextApis;
|
|
6490
7235
|
contextsRef.current = contexts;
|
|
6491
|
-
|
|
7236
|
+
useEffect12(() => {
|
|
6492
7237
|
const activePlugins2 = new Map(sortedPlugins.map((plugin) => [plugin.id, plugin]));
|
|
6493
7238
|
for (const [pluginId, mounted] of mountedPluginsRef.current) {
|
|
6494
7239
|
if (activePlugins2.get(pluginId) === mounted.plugin) continue;
|
|
@@ -6500,7 +7245,7 @@ function TableInner(props, ref) {
|
|
|
6500
7245
|
mountedPluginsRef.current.set(plugin.id, { plugin, cleanup: plugin.onMount(contextsRef.current.get(plugin.id)) });
|
|
6501
7246
|
}
|
|
6502
7247
|
}, [sortedPlugins]);
|
|
6503
|
-
|
|
7248
|
+
useEffect12(() => () => {
|
|
6504
7249
|
for (const mounted of mountedPluginsRef.current.values()) mounted.cleanup?.();
|
|
6505
7250
|
mountedPluginsRef.current.clear();
|
|
6506
7251
|
}, []);
|
|
@@ -6540,7 +7285,7 @@ function TableInner(props, ref) {
|
|
|
6540
7285
|
root.style.setProperty("--sia-table-scrollbar-y-size", `${verticalThumb}px`);
|
|
6541
7286
|
root.style.setProperty("--sia-table-scrollbar-y-position", `${verticalPosition}px`);
|
|
6542
7287
|
}, []);
|
|
6543
|
-
|
|
7288
|
+
useEffect12(() => {
|
|
6544
7289
|
const element = scrollRef.current;
|
|
6545
7290
|
if (!element || typeof ResizeObserver === "undefined") return;
|
|
6546
7291
|
const observer = new ResizeObserver(() => {
|
|
@@ -6553,13 +7298,13 @@ function TableInner(props, ref) {
|
|
|
6553
7298
|
updateScrollMetrics();
|
|
6554
7299
|
return () => observer.disconnect();
|
|
6555
7300
|
}, [updateScrollMetrics]);
|
|
6556
|
-
|
|
7301
|
+
useEffect12(() => {
|
|
6557
7302
|
updateScrollMetrics();
|
|
6558
7303
|
});
|
|
6559
7304
|
const orderedColumns = useMemo9(() => sortTableColumnsByFixed(pipeline.columns), [pipeline.columns]);
|
|
6560
7305
|
const leafColumns = useMemo9(() => flattenTableColumns(orderedColumns), [orderedColumns]);
|
|
6561
7306
|
const headerRows = useMemo9(() => buildHeaderRows(orderedColumns), [orderedColumns]);
|
|
6562
|
-
|
|
7307
|
+
useEffect12(() => {
|
|
6563
7308
|
const autoWidthColumns = leafColumns.filter((column) => column.autoWidth && resizedWidths[column.key] === void 0);
|
|
6564
7309
|
const root = rootRef.current;
|
|
6565
7310
|
if (!root || autoWidthColumns.length === 0) return;
|
|
@@ -7011,317 +7756,6 @@ var ThemeSwitch = forwardRef6(function ThemeSwitch2({
|
|
|
7011
7756
|
);
|
|
7012
7757
|
});
|
|
7013
7758
|
|
|
7014
|
-
// src/components/FloatingScrollbarProvider.tsx
|
|
7015
|
-
import { useEffect as useEffect14 } from "react";
|
|
7016
|
-
var scrollableOverflow = /* @__PURE__ */ new Set(["auto", "scroll", "overlay"]);
|
|
7017
|
-
var clippingOverflow = /* @__PURE__ */ new Set(["auto", "scroll", "overlay", "hidden", "clip"]);
|
|
7018
|
-
function isRootScroller(target) {
|
|
7019
|
-
return target === document.scrollingElement || target === document.documentElement;
|
|
7020
|
-
}
|
|
7021
|
-
function canScroll(target, axis) {
|
|
7022
|
-
if (target.matches(".sia-table__viewport, [data-sia-native-scrollbar]")) return false;
|
|
7023
|
-
if (isRootScroller(target)) {
|
|
7024
|
-
return axis === "horizontal" ? target.scrollWidth > target.clientWidth + 1 : target.scrollHeight > target.clientHeight + 1;
|
|
7025
|
-
}
|
|
7026
|
-
const style = getComputedStyle(target);
|
|
7027
|
-
const overflow = axis === "horizontal" ? style.overflowX : style.overflowY;
|
|
7028
|
-
const hasOverflow = axis === "horizontal" ? target.scrollWidth > target.clientWidth + 1 : target.scrollHeight > target.clientHeight + 1;
|
|
7029
|
-
return hasOverflow && scrollableOverflow.has(overflow);
|
|
7030
|
-
}
|
|
7031
|
-
function visibleRect(target) {
|
|
7032
|
-
if (isRootScroller(target)) {
|
|
7033
|
-
return { top: 0, right: window.innerWidth, bottom: window.innerHeight, left: 0, width: window.innerWidth, height: window.innerHeight };
|
|
7034
|
-
}
|
|
7035
|
-
const ownRect = target.getBoundingClientRect();
|
|
7036
|
-
let top = Math.max(0, ownRect.top);
|
|
7037
|
-
let right = Math.min(window.innerWidth, ownRect.right);
|
|
7038
|
-
let bottom = Math.min(window.innerHeight, ownRect.bottom);
|
|
7039
|
-
let left = Math.max(0, ownRect.left);
|
|
7040
|
-
let parent = target.parentElement;
|
|
7041
|
-
while (parent && parent !== document.body && parent !== document.documentElement) {
|
|
7042
|
-
const style = getComputedStyle(parent);
|
|
7043
|
-
const clipX = clippingOverflow.has(style.overflowX);
|
|
7044
|
-
const clipY = clippingOverflow.has(style.overflowY);
|
|
7045
|
-
if (clipX || clipY) {
|
|
7046
|
-
const rect = parent.getBoundingClientRect();
|
|
7047
|
-
if (clipX) {
|
|
7048
|
-
left = Math.max(left, rect.left);
|
|
7049
|
-
right = Math.min(right, rect.right);
|
|
7050
|
-
}
|
|
7051
|
-
if (clipY) {
|
|
7052
|
-
top = Math.max(top, rect.top);
|
|
7053
|
-
bottom = Math.min(bottom, rect.bottom);
|
|
7054
|
-
}
|
|
7055
|
-
}
|
|
7056
|
-
parent = parent.parentElement;
|
|
7057
|
-
}
|
|
7058
|
-
return {
|
|
7059
|
-
top,
|
|
7060
|
-
right,
|
|
7061
|
-
bottom,
|
|
7062
|
-
left,
|
|
7063
|
-
width: Math.max(0, right - left),
|
|
7064
|
-
height: Math.max(0, bottom - top)
|
|
7065
|
-
};
|
|
7066
|
-
}
|
|
7067
|
-
function createTrack(axis) {
|
|
7068
|
-
const track = document.createElement("div");
|
|
7069
|
-
const thumb = document.createElement("div");
|
|
7070
|
-
track.className = `sia-scrollbar-track sia-floating-scrollbar sia-floating-scrollbar--${axis}`;
|
|
7071
|
-
thumb.className = "sia-floating-scrollbar__thumb";
|
|
7072
|
-
track.dataset.axis = axis;
|
|
7073
|
-
track.setAttribute("aria-hidden", "true");
|
|
7074
|
-
track.append(thumb);
|
|
7075
|
-
return { track, thumb };
|
|
7076
|
-
}
|
|
7077
|
-
function FloatingScrollbarProvider({ disabled = false }) {
|
|
7078
|
-
useScrollbarProximity();
|
|
7079
|
-
useEffect14(() => {
|
|
7080
|
-
if (disabled) return;
|
|
7081
|
-
const layer = document.createElement("div");
|
|
7082
|
-
layer.className = "sia-floating-scrollbar-layer";
|
|
7083
|
-
layer.setAttribute("aria-hidden", "true");
|
|
7084
|
-
document.body.append(layer);
|
|
7085
|
-
const entries = /* @__PURE__ */ new Map();
|
|
7086
|
-
let scanFrame = 0;
|
|
7087
|
-
let updateFrame = 0;
|
|
7088
|
-
const setEntryVisible = (entry, visible) => {
|
|
7089
|
-
entry.horizontalTrack.classList.toggle("sia-floating-scrollbar--visible", visible);
|
|
7090
|
-
entry.verticalTrack.classList.toggle("sia-floating-scrollbar--visible", visible);
|
|
7091
|
-
};
|
|
7092
|
-
const showEntry = (entry) => {
|
|
7093
|
-
if (entry.hideTimer !== null) window.clearTimeout(entry.hideTimer);
|
|
7094
|
-
entry.hideTimer = null;
|
|
7095
|
-
setEntryVisible(entry, true);
|
|
7096
|
-
};
|
|
7097
|
-
const scheduleHide = (entry, delay = 500) => {
|
|
7098
|
-
if (entry.hideTimer !== null) window.clearTimeout(entry.hideTimer);
|
|
7099
|
-
entry.hideTimer = window.setTimeout(() => {
|
|
7100
|
-
entry.hideTimer = null;
|
|
7101
|
-
if (!entry.hoveringTarget && !entry.hoveringTrack && !entry.dragging) setEntryVisible(entry, false);
|
|
7102
|
-
}, delay);
|
|
7103
|
-
};
|
|
7104
|
-
const updateEntry = (entry) => {
|
|
7105
|
-
const { target, horizontalTrack, horizontalThumb, verticalTrack, verticalThumb } = entry;
|
|
7106
|
-
const hasHorizontal = canScroll(target, "horizontal");
|
|
7107
|
-
const hasVertical = canScroll(target, "vertical");
|
|
7108
|
-
const rect = visibleRect(target);
|
|
7109
|
-
const thickness = 10;
|
|
7110
|
-
horizontalTrack.hidden = !hasHorizontal || rect.width <= thickness || rect.height <= 0;
|
|
7111
|
-
verticalTrack.hidden = !hasVertical || rect.height <= thickness || rect.width <= 0;
|
|
7112
|
-
if (!horizontalTrack.hidden) {
|
|
7113
|
-
const trackWidth = Math.max(0, rect.width - (hasVertical ? thickness : 0));
|
|
7114
|
-
const thumbWidth = Math.max(24, Math.min(trackWidth, trackWidth * target.clientWidth / target.scrollWidth));
|
|
7115
|
-
const travel = Math.max(0, trackWidth - thumbWidth);
|
|
7116
|
-
const maxScroll = Math.max(1, target.scrollWidth - target.clientWidth);
|
|
7117
|
-
horizontalTrack.style.left = `${rect.left}px`;
|
|
7118
|
-
horizontalTrack.style.top = `${rect.bottom - thickness}px`;
|
|
7119
|
-
horizontalTrack.style.width = `${trackWidth}px`;
|
|
7120
|
-
horizontalTrack.style.height = `${thickness}px`;
|
|
7121
|
-
horizontalThumb.style.width = `${thumbWidth}px`;
|
|
7122
|
-
horizontalThumb.style.transform = `translate3d(${travel * target.scrollLeft / maxScroll}px, 0, 0)`;
|
|
7123
|
-
}
|
|
7124
|
-
if (!verticalTrack.hidden) {
|
|
7125
|
-
const trackHeight = Math.max(0, rect.height - (hasHorizontal ? thickness : 0));
|
|
7126
|
-
const thumbHeight = Math.max(24, Math.min(trackHeight, trackHeight * target.clientHeight / target.scrollHeight));
|
|
7127
|
-
const travel = Math.max(0, trackHeight - thumbHeight);
|
|
7128
|
-
const maxScroll = Math.max(1, target.scrollHeight - target.clientHeight);
|
|
7129
|
-
verticalTrack.style.left = `${rect.right - thickness}px`;
|
|
7130
|
-
verticalTrack.style.top = `${rect.top}px`;
|
|
7131
|
-
verticalTrack.style.width = `${thickness}px`;
|
|
7132
|
-
verticalTrack.style.height = `${trackHeight}px`;
|
|
7133
|
-
verticalThumb.style.height = `${thumbHeight}px`;
|
|
7134
|
-
verticalThumb.style.transform = `translate3d(0, ${travel * target.scrollTop / maxScroll}px, 0)`;
|
|
7135
|
-
}
|
|
7136
|
-
};
|
|
7137
|
-
const scheduleUpdateAll = () => {
|
|
7138
|
-
if (updateFrame) return;
|
|
7139
|
-
updateFrame = window.requestAnimationFrame(() => {
|
|
7140
|
-
updateFrame = 0;
|
|
7141
|
-
entries.forEach(updateEntry);
|
|
7142
|
-
});
|
|
7143
|
-
};
|
|
7144
|
-
const bindTrackDrag = (entry, axis, track, thumb) => {
|
|
7145
|
-
const target = entry.target;
|
|
7146
|
-
const onTrackPointerEnter = () => {
|
|
7147
|
-
entry.hoveringTrack = true;
|
|
7148
|
-
showEntry(entry);
|
|
7149
|
-
};
|
|
7150
|
-
const onTrackPointerLeave = () => {
|
|
7151
|
-
entry.hoveringTrack = false;
|
|
7152
|
-
scheduleHide(entry);
|
|
7153
|
-
};
|
|
7154
|
-
const onTrackPointerDown = (event) => {
|
|
7155
|
-
if (event.target === thumb || event.button !== 0) return;
|
|
7156
|
-
event.preventDefault();
|
|
7157
|
-
event.stopPropagation();
|
|
7158
|
-
const trackRect = track.getBoundingClientRect();
|
|
7159
|
-
const thumbRect = thumb.getBoundingClientRect();
|
|
7160
|
-
const trackLength = axis === "vertical" ? trackRect.height : trackRect.width;
|
|
7161
|
-
const thumbLength = axis === "vertical" ? thumbRect.height : thumbRect.width;
|
|
7162
|
-
const pointer = axis === "vertical" ? event.clientY - trackRect.top : event.clientX - trackRect.left;
|
|
7163
|
-
const ratio = Math.max(0, Math.min(1, (pointer - thumbLength / 2) / Math.max(1, trackLength - thumbLength)));
|
|
7164
|
-
if (axis === "vertical") target.scrollTop = ratio * (target.scrollHeight - target.clientHeight);
|
|
7165
|
-
else target.scrollLeft = ratio * (target.scrollWidth - target.clientWidth);
|
|
7166
|
-
};
|
|
7167
|
-
const onThumbPointerDown = (event) => {
|
|
7168
|
-
if (event.button !== 0) return;
|
|
7169
|
-
event.preventDefault();
|
|
7170
|
-
event.stopPropagation();
|
|
7171
|
-
entry.dragging = true;
|
|
7172
|
-
showEntry(entry);
|
|
7173
|
-
thumb.setPointerCapture(event.pointerId);
|
|
7174
|
-
const startPointer = axis === "vertical" ? event.clientY : event.clientX;
|
|
7175
|
-
const startScroll = axis === "vertical" ? target.scrollTop : target.scrollLeft;
|
|
7176
|
-
const trackRect = track.getBoundingClientRect();
|
|
7177
|
-
const thumbRect = thumb.getBoundingClientRect();
|
|
7178
|
-
const trackLength = axis === "vertical" ? trackRect.height : trackRect.width;
|
|
7179
|
-
const thumbLength = axis === "vertical" ? thumbRect.height : thumbRect.width;
|
|
7180
|
-
const maxScroll = axis === "vertical" ? target.scrollHeight - target.clientHeight : target.scrollWidth - target.clientWidth;
|
|
7181
|
-
const travel = Math.max(1, trackLength - thumbLength);
|
|
7182
|
-
const onPointerMove = (moveEvent) => {
|
|
7183
|
-
if (moveEvent.pointerId !== event.pointerId) return;
|
|
7184
|
-
const pointer = axis === "vertical" ? moveEvent.clientY : moveEvent.clientX;
|
|
7185
|
-
const nextScroll = startScroll + (pointer - startPointer) * maxScroll / travel;
|
|
7186
|
-
if (axis === "vertical") target.scrollTop = nextScroll;
|
|
7187
|
-
else target.scrollLeft = nextScroll;
|
|
7188
|
-
};
|
|
7189
|
-
const onPointerUp = (upEvent) => {
|
|
7190
|
-
if (upEvent.pointerId !== event.pointerId) return;
|
|
7191
|
-
entry.dragging = false;
|
|
7192
|
-
thumb.releasePointerCapture(event.pointerId);
|
|
7193
|
-
window.removeEventListener("pointermove", onPointerMove);
|
|
7194
|
-
window.removeEventListener("pointerup", onPointerUp);
|
|
7195
|
-
window.removeEventListener("pointercancel", onPointerUp);
|
|
7196
|
-
scheduleHide(entry);
|
|
7197
|
-
};
|
|
7198
|
-
window.addEventListener("pointermove", onPointerMove);
|
|
7199
|
-
window.addEventListener("pointerup", onPointerUp);
|
|
7200
|
-
window.addEventListener("pointercancel", onPointerUp);
|
|
7201
|
-
};
|
|
7202
|
-
track.addEventListener("pointerenter", onTrackPointerEnter);
|
|
7203
|
-
track.addEventListener("pointerleave", onTrackPointerLeave);
|
|
7204
|
-
track.addEventListener("pointerdown", onTrackPointerDown);
|
|
7205
|
-
thumb.addEventListener("pointerdown", onThumbPointerDown);
|
|
7206
|
-
return () => {
|
|
7207
|
-
track.removeEventListener("pointerenter", onTrackPointerEnter);
|
|
7208
|
-
track.removeEventListener("pointerleave", onTrackPointerLeave);
|
|
7209
|
-
track.removeEventListener("pointerdown", onTrackPointerDown);
|
|
7210
|
-
thumb.removeEventListener("pointerdown", onThumbPointerDown);
|
|
7211
|
-
};
|
|
7212
|
-
};
|
|
7213
|
-
const resizeObserver = new ResizeObserver((observedEntries) => {
|
|
7214
|
-
observedEntries.forEach(({ target }) => {
|
|
7215
|
-
const entry = entries.get(target);
|
|
7216
|
-
if (entry) updateEntry(entry);
|
|
7217
|
-
});
|
|
7218
|
-
});
|
|
7219
|
-
const addTarget = (target) => {
|
|
7220
|
-
if (entries.has(target)) return;
|
|
7221
|
-
const horizontal = createTrack("horizontal");
|
|
7222
|
-
const vertical = createTrack("vertical");
|
|
7223
|
-
layer.append(horizontal.track, vertical.track);
|
|
7224
|
-
const onPointerEnter = () => {
|
|
7225
|
-
const entry2 = entries.get(target);
|
|
7226
|
-
if (!entry2) return;
|
|
7227
|
-
entry2.hoveringTarget = true;
|
|
7228
|
-
showEntry(entry2);
|
|
7229
|
-
};
|
|
7230
|
-
const onPointerLeave = () => {
|
|
7231
|
-
const entry2 = entries.get(target);
|
|
7232
|
-
if (!entry2) return;
|
|
7233
|
-
entry2.hoveringTarget = false;
|
|
7234
|
-
scheduleHide(entry2);
|
|
7235
|
-
};
|
|
7236
|
-
const onScroll = () => {
|
|
7237
|
-
const entry2 = entries.get(target);
|
|
7238
|
-
if (!entry2) return;
|
|
7239
|
-
updateEntry(entry2);
|
|
7240
|
-
showEntry(entry2);
|
|
7241
|
-
scheduleHide(entry2, 700);
|
|
7242
|
-
};
|
|
7243
|
-
target.addEventListener("pointerenter", onPointerEnter);
|
|
7244
|
-
target.addEventListener("pointerleave", onPointerLeave);
|
|
7245
|
-
target.addEventListener("scroll", onScroll, { passive: true });
|
|
7246
|
-
const entry = {
|
|
7247
|
-
target,
|
|
7248
|
-
horizontalTrack: horizontal.track,
|
|
7249
|
-
horizontalThumb: horizontal.thumb,
|
|
7250
|
-
verticalTrack: vertical.track,
|
|
7251
|
-
verticalThumb: vertical.thumb,
|
|
7252
|
-
hideTimer: null,
|
|
7253
|
-
hoveringTarget: target.matches(":hover"),
|
|
7254
|
-
hoveringTrack: false,
|
|
7255
|
-
dragging: false,
|
|
7256
|
-
cleanup: () => void 0
|
|
7257
|
-
};
|
|
7258
|
-
const cleanupHorizontal = bindTrackDrag(entry, "horizontal", horizontal.track, horizontal.thumb);
|
|
7259
|
-
const cleanupVertical = bindTrackDrag(entry, "vertical", vertical.track, vertical.thumb);
|
|
7260
|
-
entry.cleanup = () => {
|
|
7261
|
-
if (entry.hideTimer !== null) window.clearTimeout(entry.hideTimer);
|
|
7262
|
-
cleanupHorizontal();
|
|
7263
|
-
cleanupVertical();
|
|
7264
|
-
target.removeEventListener("pointerenter", onPointerEnter);
|
|
7265
|
-
target.removeEventListener("pointerleave", onPointerLeave);
|
|
7266
|
-
target.removeEventListener("scroll", onScroll);
|
|
7267
|
-
resizeObserver.unobserve(target);
|
|
7268
|
-
target.removeAttribute("data-sia-floating-scrollbar");
|
|
7269
|
-
horizontal.track.remove();
|
|
7270
|
-
vertical.track.remove();
|
|
7271
|
-
};
|
|
7272
|
-
entries.set(target, entry);
|
|
7273
|
-
target.setAttribute("data-sia-floating-scrollbar", "");
|
|
7274
|
-
resizeObserver.observe(target);
|
|
7275
|
-
updateEntry(entry);
|
|
7276
|
-
if (entry.hoveringTarget) showEntry(entry);
|
|
7277
|
-
};
|
|
7278
|
-
const removeTarget = (target) => {
|
|
7279
|
-
const entry = entries.get(target);
|
|
7280
|
-
if (!entry) return;
|
|
7281
|
-
entry.cleanup();
|
|
7282
|
-
entries.delete(target);
|
|
7283
|
-
};
|
|
7284
|
-
const scanTargets = () => {
|
|
7285
|
-
scanFrame = 0;
|
|
7286
|
-
const candidates = [document.scrollingElement, ...document.querySelectorAll("*")].filter((target) => target instanceof HTMLElement);
|
|
7287
|
-
const nextTargets = /* @__PURE__ */ new Set();
|
|
7288
|
-
candidates.forEach((target) => {
|
|
7289
|
-
if (canScroll(target, "horizontal") || canScroll(target, "vertical")) {
|
|
7290
|
-
nextTargets.add(target);
|
|
7291
|
-
addTarget(target);
|
|
7292
|
-
}
|
|
7293
|
-
});
|
|
7294
|
-
entries.forEach((_entry, target) => {
|
|
7295
|
-
if (!target.isConnected || !nextTargets.has(target)) removeTarget(target);
|
|
7296
|
-
else updateEntry(_entry);
|
|
7297
|
-
});
|
|
7298
|
-
};
|
|
7299
|
-
const scheduleScan = () => {
|
|
7300
|
-
if (scanFrame) return;
|
|
7301
|
-
scanFrame = window.requestAnimationFrame(scanTargets);
|
|
7302
|
-
};
|
|
7303
|
-
const mutationObserver = new MutationObserver((mutations) => {
|
|
7304
|
-
if (mutations.some((mutation) => !layer.contains(mutation.target))) scheduleScan();
|
|
7305
|
-
});
|
|
7306
|
-
mutationObserver.observe(document.documentElement, { subtree: true, childList: true, attributes: true });
|
|
7307
|
-
window.addEventListener("resize", scheduleScan);
|
|
7308
|
-
window.addEventListener("scroll", scheduleUpdateAll, true);
|
|
7309
|
-
scheduleScan();
|
|
7310
|
-
return () => {
|
|
7311
|
-
mutationObserver.disconnect();
|
|
7312
|
-
resizeObserver.disconnect();
|
|
7313
|
-
window.removeEventListener("resize", scheduleScan);
|
|
7314
|
-
window.removeEventListener("scroll", scheduleUpdateAll, true);
|
|
7315
|
-
if (scanFrame) window.cancelAnimationFrame(scanFrame);
|
|
7316
|
-
if (updateFrame) window.cancelAnimationFrame(updateFrame);
|
|
7317
|
-
entries.forEach((entry) => entry.cleanup());
|
|
7318
|
-
entries.clear();
|
|
7319
|
-
layer.remove();
|
|
7320
|
-
};
|
|
7321
|
-
}, [disabled]);
|
|
7322
|
-
return null;
|
|
7323
|
-
}
|
|
7324
|
-
|
|
7325
7759
|
// src/theme.ts
|
|
7326
7760
|
var SIA_THEME = {
|
|
7327
7761
|
colorPrimary: "#1677ff",
|
|
@@ -7345,7 +7779,7 @@ function applySiaTheme(mode, target = document.documentElement) {
|
|
|
7345
7779
|
}
|
|
7346
7780
|
|
|
7347
7781
|
// src/components/InputSelect.tsx
|
|
7348
|
-
import { forwardRef as forwardRef7, useEffect as
|
|
7782
|
+
import { forwardRef as forwardRef7, useEffect as useEffect13, useRef as useRef16, useState as useState18 } from "react";
|
|
7349
7783
|
import { jsx as jsx23, jsxs as jsxs22 } from "react/jsx-runtime";
|
|
7350
7784
|
var InputSelect = forwardRef7(function InputSelect2({
|
|
7351
7785
|
options,
|
|
@@ -7378,7 +7812,7 @@ var InputSelect = forwardRef7(function InputSelect2({
|
|
|
7378
7812
|
const values = current == null ? [] : Array.isArray(current) ? current : [current];
|
|
7379
7813
|
const text = values.map((item) => displayField === "label" ? String(options.find((option) => option.optionType !== "divider" && option.value === item)?.label ?? item) : String(item)).join(",");
|
|
7380
7814
|
const [draft, setDraft] = useState18(text);
|
|
7381
|
-
|
|
7815
|
+
useEffect13(() => {
|
|
7382
7816
|
setDraft(text);
|
|
7383
7817
|
}, [text, current]);
|
|
7384
7818
|
const [open, setOpen] = useState18(false);
|
|
@@ -7408,7 +7842,7 @@ var InputSelect = forwardRef7(function InputSelect2({
|
|
|
7408
7842
|
inputRef.current?.focus();
|
|
7409
7843
|
}
|
|
7410
7844
|
}
|
|
7411
|
-
|
|
7845
|
+
useEffect13(() => {
|
|
7412
7846
|
if (!open) return;
|
|
7413
7847
|
const outside = (event) => {
|
|
7414
7848
|
if (!rootRef.current?.contains(event.target) && !popupRef.current?.contains(event.target)) changeOpen(false);
|
|
@@ -7416,7 +7850,7 @@ var InputSelect = forwardRef7(function InputSelect2({
|
|
|
7416
7850
|
document.addEventListener("pointerdown", outside);
|
|
7417
7851
|
return () => document.removeEventListener("pointerdown", outside);
|
|
7418
7852
|
}, [open, onOpenChange]);
|
|
7419
|
-
|
|
7853
|
+
useEffect13(() => {
|
|
7420
7854
|
if (disabled || loading) {
|
|
7421
7855
|
changeOpen(false);
|
|
7422
7856
|
setModalOpen(false);
|
|
@@ -7547,6 +7981,293 @@ var InputSelect = forwardRef7(function InputSelect2({
|
|
|
7547
7981
|
)
|
|
7548
7982
|
] });
|
|
7549
7983
|
});
|
|
7984
|
+
|
|
7985
|
+
// src/components/QueryForm.tsx
|
|
7986
|
+
import { Children as Children4, useLayoutEffect as useLayoutEffect3, useRef as useRef17, useState as useState19 } from "react";
|
|
7987
|
+
import { jsx as jsx24, jsxs as jsxs23 } from "react/jsx-runtime";
|
|
7988
|
+
function QueryForm({
|
|
7989
|
+
fields,
|
|
7990
|
+
children,
|
|
7991
|
+
form: providedForm,
|
|
7992
|
+
onSearch,
|
|
7993
|
+
loading = false,
|
|
7994
|
+
fieldWidth = 220,
|
|
7995
|
+
collapsible = true,
|
|
7996
|
+
collapsed: controlledCollapsed,
|
|
7997
|
+
defaultCollapsed = false,
|
|
7998
|
+
collapsedCount = 3,
|
|
7999
|
+
onCollapsedChange,
|
|
8000
|
+
quickQueries = [],
|
|
8001
|
+
quickQuerySize = "small",
|
|
8002
|
+
savedQueries = [],
|
|
8003
|
+
shortcutsLoading = false,
|
|
8004
|
+
onSaveQuery,
|
|
8005
|
+
onRemoveQuery,
|
|
8006
|
+
onError,
|
|
8007
|
+
searchText = "\u67E5\u8BE2",
|
|
8008
|
+
resetText = "\u91CD\u7F6E",
|
|
8009
|
+
saveText = "\u53E6\u5B58\u4E3A\u5FEB\u6377\u67E5\u8BE2",
|
|
8010
|
+
resetSearch = true,
|
|
8011
|
+
actionsExtra,
|
|
8012
|
+
disabled = false,
|
|
8013
|
+
className = "",
|
|
8014
|
+
placeholderMode = "floating",
|
|
8015
|
+
onValuesChange,
|
|
8016
|
+
onFinishFailed,
|
|
8017
|
+
...formProps
|
|
8018
|
+
}) {
|
|
8019
|
+
const [form] = useForm(providedForm);
|
|
8020
|
+
const [internalCollapsed, setInternalCollapsed] = useState19(defaultCollapsed);
|
|
8021
|
+
const collapsed = collapsible && (controlledCollapsed ?? internalCollapsed);
|
|
8022
|
+
const [searching, setSearching] = useState19(false);
|
|
8023
|
+
const [saving, setSaving] = useState19(false);
|
|
8024
|
+
const [removing, setRemoving] = useState19(false);
|
|
8025
|
+
const [saveOpen, setSaveOpen] = useState19(false);
|
|
8026
|
+
const [saveName, setSaveName] = useState19("");
|
|
8027
|
+
const [saveError, setSaveError] = useState19("");
|
|
8028
|
+
const [error, setError] = useState19("");
|
|
8029
|
+
const [activeShortcut, setActiveShortcut] = useState19("");
|
|
8030
|
+
const source = useRef17({ source: "submit" });
|
|
8031
|
+
const searchLock = useRef17(false);
|
|
8032
|
+
const saveLock = useRef17(false);
|
|
8033
|
+
const removeLock = useRef17(false);
|
|
8034
|
+
const snapshot = useRef17();
|
|
8035
|
+
const busy = disabled || loading || searching;
|
|
8036
|
+
const shortcutBusy = busy || shortcutsLoading || saving || removing;
|
|
8037
|
+
const entries = fields ? fields.map(({ key, width, ...item }) => ({ key, width, content: /* @__PURE__ */ jsx24(Form.Item, { noStyle: true, ...item }) })) : Children4.toArray(children).map((content, index) => ({ key: String(index), width: void 0, content }));
|
|
8038
|
+
const limit = Math.max(1, Math.floor(collapsedCount));
|
|
8039
|
+
const rowRef = useRef17(null);
|
|
8040
|
+
const actionsRef = useRef17(null);
|
|
8041
|
+
const [fittingCount, setFittingCount] = useState19(limit);
|
|
8042
|
+
useLayoutEffect3(() => {
|
|
8043
|
+
if (!collapsed) return;
|
|
8044
|
+
const row = rowRef.current;
|
|
8045
|
+
const actions = actionsRef.current;
|
|
8046
|
+
if (!row || !actions) return;
|
|
8047
|
+
function measure() {
|
|
8048
|
+
if (!row || !actions) return;
|
|
8049
|
+
const gap = parseFloat(getComputedStyle(row).columnGap) || 0;
|
|
8050
|
+
let remaining = row.clientWidth - actions.getBoundingClientRect().width;
|
|
8051
|
+
let count = 0;
|
|
8052
|
+
for (const field of Array.from(row.querySelectorAll(":scope > .sia-query-form__field")).slice(0, limit)) {
|
|
8053
|
+
const width = parseFloat(getComputedStyle(field).width) || 220;
|
|
8054
|
+
if (remaining + 0.5 < width + gap) break;
|
|
8055
|
+
remaining -= width + gap;
|
|
8056
|
+
count++;
|
|
8057
|
+
}
|
|
8058
|
+
setFittingCount(count);
|
|
8059
|
+
}
|
|
8060
|
+
measure();
|
|
8061
|
+
const observer = new ResizeObserver(measure);
|
|
8062
|
+
observer.observe(row);
|
|
8063
|
+
observer.observe(actions);
|
|
8064
|
+
row.querySelectorAll(":scope > .sia-query-form__field").forEach((field) => observer.observe(field));
|
|
8065
|
+
return () => observer.disconnect();
|
|
8066
|
+
}, [collapsed, limit, fieldWidth, fields, children]);
|
|
8067
|
+
async function search(values) {
|
|
8068
|
+
const info = source.current;
|
|
8069
|
+
source.current = { source: "submit" };
|
|
8070
|
+
if (searchLock.current || disabled || loading) return;
|
|
8071
|
+
searchLock.current = true;
|
|
8072
|
+
setSearching(true);
|
|
8073
|
+
setError("");
|
|
8074
|
+
try {
|
|
8075
|
+
await onSearch(values, info);
|
|
8076
|
+
} catch (reason) {
|
|
8077
|
+
setError(reason instanceof Error ? reason.message : "\u67E5\u8BE2\u5931\u8D25\uFF0C\u8BF7\u91CD\u8BD5");
|
|
8078
|
+
onError?.(reason, "search");
|
|
8079
|
+
} finally {
|
|
8080
|
+
searchLock.current = false;
|
|
8081
|
+
setSearching(false);
|
|
8082
|
+
}
|
|
8083
|
+
}
|
|
8084
|
+
function applyShortcut(query, kind) {
|
|
8085
|
+
if (shortcutBusy || query.disabled) return;
|
|
8086
|
+
form.resetFields();
|
|
8087
|
+
form.setFieldsValue(query.values);
|
|
8088
|
+
source.current = { source: kind, shortcutKey: query.key };
|
|
8089
|
+
setActiveShortcut(`${kind}:${query.key}`);
|
|
8090
|
+
form.submit();
|
|
8091
|
+
}
|
|
8092
|
+
function reset() {
|
|
8093
|
+
if (busy) return;
|
|
8094
|
+
form.resetFields();
|
|
8095
|
+
setActiveShortcut("");
|
|
8096
|
+
setError("");
|
|
8097
|
+
if (resetSearch) {
|
|
8098
|
+
source.current = { source: "reset" };
|
|
8099
|
+
form.submit();
|
|
8100
|
+
}
|
|
8101
|
+
}
|
|
8102
|
+
async function save() {
|
|
8103
|
+
if (!onSaveQuery || saveLock.current) return false;
|
|
8104
|
+
const name = saveName.trim();
|
|
8105
|
+
if (!name) {
|
|
8106
|
+
setSaveError("\u8BF7\u8F93\u5165\u5FEB\u6377\u67E5\u8BE2\u540D\u79F0");
|
|
8107
|
+
return false;
|
|
8108
|
+
}
|
|
8109
|
+
if (!snapshot.current) return false;
|
|
8110
|
+
saveLock.current = true;
|
|
8111
|
+
setSaving(true);
|
|
8112
|
+
setSaveError("");
|
|
8113
|
+
try {
|
|
8114
|
+
await onSaveQuery({ name, values: snapshot.current });
|
|
8115
|
+
setSaveOpen(false);
|
|
8116
|
+
} catch (reason) {
|
|
8117
|
+
setSaveError(reason instanceof Error ? reason.message : "\u4FDD\u5B58\u5931\u8D25\uFF0C\u8BF7\u91CD\u8BD5");
|
|
8118
|
+
onError?.(reason, "save");
|
|
8119
|
+
return false;
|
|
8120
|
+
} finally {
|
|
8121
|
+
saveLock.current = false;
|
|
8122
|
+
setSaving(false);
|
|
8123
|
+
}
|
|
8124
|
+
}
|
|
8125
|
+
async function remove(query) {
|
|
8126
|
+
if (!onRemoveQuery || shortcutBusy || removeLock.current) return;
|
|
8127
|
+
removeLock.current = true;
|
|
8128
|
+
setRemoving(true);
|
|
8129
|
+
setError("");
|
|
8130
|
+
try {
|
|
8131
|
+
await onRemoveQuery(query);
|
|
8132
|
+
if (activeShortcut === `saved:${query.key}`) setActiveShortcut("");
|
|
8133
|
+
} catch (reason) {
|
|
8134
|
+
setError(reason instanceof Error ? reason.message : "\u5220\u9664\u5931\u8D25\uFF0C\u8BF7\u91CD\u8BD5");
|
|
8135
|
+
onError?.(reason, "remove");
|
|
8136
|
+
} finally {
|
|
8137
|
+
removeLock.current = false;
|
|
8138
|
+
setRemoving(false);
|
|
8139
|
+
}
|
|
8140
|
+
}
|
|
8141
|
+
return /* @__PURE__ */ jsxs23("div", { className: `sia-query-form ${className}`.trim(), children: [
|
|
8142
|
+
/* @__PURE__ */ jsxs23(
|
|
8143
|
+
Form,
|
|
8144
|
+
{
|
|
8145
|
+
...formProps,
|
|
8146
|
+
form,
|
|
8147
|
+
placeholderMode,
|
|
8148
|
+
disabled,
|
|
8149
|
+
onFinish: (values) => {
|
|
8150
|
+
void search(values);
|
|
8151
|
+
},
|
|
8152
|
+
onFinishFailed: (info) => {
|
|
8153
|
+
source.current = { source: "submit" };
|
|
8154
|
+
onFinishFailed?.(info);
|
|
8155
|
+
},
|
|
8156
|
+
onValuesChange: (changed, values) => {
|
|
8157
|
+
setActiveShortcut("");
|
|
8158
|
+
onValuesChange?.(changed, values);
|
|
8159
|
+
},
|
|
8160
|
+
children: [
|
|
8161
|
+
quickQueries.length ? /* @__PURE__ */ jsxs23("div", { className: "sia-query-form__quick", "aria-label": "\u9884\u8BBE\u5FEB\u6377\u67E5\u8BE2", children: [
|
|
8162
|
+
quickQueries.map((query) => /* @__PURE__ */ jsx24(Badge, { className: "sia-query-form__quick-badge", showZero: true, size: "small", title: query.count === void 0 ? void 0 : `\u5171 ${query.count} \u6761`, ...query.badgeProps, count: query.count, children: /* @__PURE__ */ jsx24(
|
|
8163
|
+
Button,
|
|
8164
|
+
{
|
|
8165
|
+
size: query.size ?? quickQuerySize,
|
|
8166
|
+
"aria-pressed": activeShortcut === `quick:${query.key}`,
|
|
8167
|
+
variant: activeShortcut === `quick:${query.key}` ? "primary" : "default",
|
|
8168
|
+
disabled: shortcutBusy || query.disabled,
|
|
8169
|
+
onClick: () => applyShortcut(query, "quick"),
|
|
8170
|
+
children: query.label
|
|
8171
|
+
}
|
|
8172
|
+
) }, query.key)),
|
|
8173
|
+
" "
|
|
8174
|
+
] }) : null,
|
|
8175
|
+
/* @__PURE__ */ jsxs23("div", { ref: rowRef, className: `sia-query-form__fields${collapsed ? " is-collapsed" : ""}`, style: { "--sia-query-field-width": typeof fieldWidth === "number" ? `${fieldWidth}px` : fieldWidth }, children: [
|
|
8176
|
+
entries.map((entry, index) => /* @__PURE__ */ jsx24(
|
|
8177
|
+
"div",
|
|
8178
|
+
{
|
|
8179
|
+
className: "sia-query-form__field",
|
|
8180
|
+
hidden: collapsed && index >= Math.min(limit, fittingCount),
|
|
8181
|
+
style: entry.width !== void 0 ? { flexBasis: entry.width, width: entry.width } : void 0,
|
|
8182
|
+
children: entry.content
|
|
8183
|
+
},
|
|
8184
|
+
entry.key
|
|
8185
|
+
)),
|
|
8186
|
+
/* @__PURE__ */ jsxs23("div", { ref: actionsRef, className: "sia-query-form__actions", children: [
|
|
8187
|
+
/* @__PURE__ */ jsxs23(Space.Compact, { children: [
|
|
8188
|
+
/* @__PURE__ */ jsx24(Button, { type: "submit", variant: "primary", loading: loading || searching, disabled, children: searchText }),
|
|
8189
|
+
/* @__PURE__ */ jsx24(Button, { disabled: busy, onClick: reset, children: resetText }),
|
|
8190
|
+
onSaveQuery ? /* @__PURE__ */ jsx24(Button, { disabled: shortcutBusy, onClick: () => {
|
|
8191
|
+
snapshot.current = form.getFieldsValue();
|
|
8192
|
+
setSaveName("");
|
|
8193
|
+
setSaveError("");
|
|
8194
|
+
setSaveOpen(true);
|
|
8195
|
+
}, children: saveText }) : null
|
|
8196
|
+
] }),
|
|
8197
|
+
collapsible && entries.length > 0 ? /* @__PURE__ */ jsx24(
|
|
8198
|
+
Button,
|
|
8199
|
+
{
|
|
8200
|
+
variant: "link",
|
|
8201
|
+
"aria-expanded": !collapsed,
|
|
8202
|
+
icon: /* @__PURE__ */ jsx24(Icon, { name: collapsed ? "chevron-down" : "chevron-up" }),
|
|
8203
|
+
iconPosition: "end",
|
|
8204
|
+
onClick: () => {
|
|
8205
|
+
setInternalCollapsed(!collapsed);
|
|
8206
|
+
onCollapsedChange?.(!collapsed);
|
|
8207
|
+
},
|
|
8208
|
+
children: collapsed ? "\u5C55\u5F00" : "\u6536\u8D77"
|
|
8209
|
+
}
|
|
8210
|
+
) : null,
|
|
8211
|
+
actionsExtra
|
|
8212
|
+
] })
|
|
8213
|
+
] }),
|
|
8214
|
+
savedQueries.length && !collapsed ? /* @__PURE__ */ jsxs23("div", { className: "sia-query-form__saved", "aria-label": "\u5DF2\u4FDD\u5B58\u5FEB\u6377\u67E5\u8BE2", children: [
|
|
8215
|
+
savedQueries.map((query, index) => /* @__PURE__ */ jsx24(
|
|
8216
|
+
Tag,
|
|
8217
|
+
{
|
|
8218
|
+
status: query.status ?? ["processing", "success", "warning", "error"][index % 4],
|
|
8219
|
+
variant: "soft",
|
|
8220
|
+
disabled: shortcutBusy || query.disabled,
|
|
8221
|
+
tabIndex: shortcutBusy || query.disabled ? -1 : 0,
|
|
8222
|
+
className: activeShortcut === `saved:${query.key}` ? "is-active" : "",
|
|
8223
|
+
closable: Boolean(onRemoveQuery),
|
|
8224
|
+
closeOnHover: true,
|
|
8225
|
+
onClose: () => {
|
|
8226
|
+
void remove(query);
|
|
8227
|
+
},
|
|
8228
|
+
onClick: () => applyShortcut(query, "saved"),
|
|
8229
|
+
onKeyDown: (event) => {
|
|
8230
|
+
if (event.target === event.currentTarget && (event.key === "Enter" || event.key === " ")) {
|
|
8231
|
+
event.preventDefault();
|
|
8232
|
+
applyShortcut(query, "saved");
|
|
8233
|
+
}
|
|
8234
|
+
},
|
|
8235
|
+
children: query.label
|
|
8236
|
+
},
|
|
8237
|
+
query.key
|
|
8238
|
+
)),
|
|
8239
|
+
" "
|
|
8240
|
+
] }) : null,
|
|
8241
|
+
error ? /* @__PURE__ */ jsx24("p", { className: "sia-query-form__error", role: "alert", children: error }) : null
|
|
8242
|
+
]
|
|
8243
|
+
}
|
|
8244
|
+
),
|
|
8245
|
+
/* @__PURE__ */ jsxs23(Modal, { open: saveOpen, title: "\u53E6\u5B58\u4E3A\u5FEB\u6377\u67E5\u8BE2", width: 420, confirmLoading: saving, onOk: save, onOpenChange: (next) => {
|
|
8246
|
+
if (!saveLock.current) setSaveOpen(next);
|
|
8247
|
+
}, children: [
|
|
8248
|
+
/* @__PURE__ */ jsx24(
|
|
8249
|
+
Input,
|
|
8250
|
+
{
|
|
8251
|
+
autoFocus: true,
|
|
8252
|
+
"aria-label": "\u5FEB\u6377\u67E5\u8BE2\u540D\u79F0",
|
|
8253
|
+
placeholder: "\u5FEB\u6377\u67E5\u8BE2\u540D\u79F0",
|
|
8254
|
+
value: saveName,
|
|
8255
|
+
maxLength: 80,
|
|
8256
|
+
disabled: saving,
|
|
8257
|
+
status: saveError ? "error" : "default",
|
|
8258
|
+
onChange: (event) => setSaveName(event.target.value),
|
|
8259
|
+
onKeyDown: (event) => {
|
|
8260
|
+
if (event.key === "Enter") {
|
|
8261
|
+
event.preventDefault();
|
|
8262
|
+
void save();
|
|
8263
|
+
}
|
|
8264
|
+
}
|
|
8265
|
+
}
|
|
8266
|
+
),
|
|
8267
|
+
saveError ? /* @__PURE__ */ jsx24("p", { className: "sia-query-form__error", role: "alert", children: saveError }) : null
|
|
8268
|
+
] })
|
|
8269
|
+
] });
|
|
8270
|
+
}
|
|
7550
8271
|
export {
|
|
7551
8272
|
Alert,
|
|
7552
8273
|
Badge,
|
|
@@ -7619,6 +8340,7 @@ export {
|
|
|
7619
8340
|
Popconfirm,
|
|
7620
8341
|
Popover,
|
|
7621
8342
|
Progress,
|
|
8343
|
+
QueryForm,
|
|
7622
8344
|
RadarChart,
|
|
7623
8345
|
Radio2 as Radio,
|
|
7624
8346
|
Rate,
|