@sia.soul/sia-react-ui 0.1.43 → 0.1.45
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-ORLXJLLW.js → chunk-KXPNW4E6.js} +3 -3
- package/dist/{chunk-3Q3S6CDZ.js → chunk-NYJSSPIX.js} +16 -3
- package/dist/{chunk-LWVZEUGJ.js → chunk-QIXU7N4X.js} +1 -1
- package/dist/core.cjs +18 -5
- package/dist/core.js +2 -2
- package/dist/index.cjs +1712 -1515
- package/dist/index.css +12 -0
- package/dist/index.d.cts +18 -5
- package/dist/index.d.ts +18 -5
- package/dist/index.js +385 -201
- package/dist/select-date-range.cjs +16 -3
- package/dist/select-date-range.js +2 -2
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -80,7 +80,7 @@ import {
|
|
|
80
80
|
Watermark,
|
|
81
81
|
message,
|
|
82
82
|
notification
|
|
83
|
-
} from "./chunk-
|
|
83
|
+
} from "./chunk-KXPNW4E6.js";
|
|
84
84
|
import {
|
|
85
85
|
TextArea
|
|
86
86
|
} from "./chunk-SMCYEPBL.js";
|
|
@@ -95,7 +95,7 @@ import {
|
|
|
95
95
|
DatePicker,
|
|
96
96
|
SelectDateRange,
|
|
97
97
|
TimePanel
|
|
98
|
-
} from "./chunk-
|
|
98
|
+
} from "./chunk-QIXU7N4X.js";
|
|
99
99
|
import {
|
|
100
100
|
Checkbox,
|
|
101
101
|
FloatingScrollbarProvider,
|
|
@@ -110,7 +110,7 @@ import {
|
|
|
110
110
|
Tree,
|
|
111
111
|
useOverlayLifecycle,
|
|
112
112
|
useScrollbarProximity
|
|
113
|
-
} from "./chunk-
|
|
113
|
+
} from "./chunk-NYJSSPIX.js";
|
|
114
114
|
import {
|
|
115
115
|
Dropdown,
|
|
116
116
|
FILLED_ICON_NAMES,
|
|
@@ -4652,6 +4652,22 @@ function Treemap({
|
|
|
4652
4652
|
// src/components/Table/TableCellContent.tsx
|
|
4653
4653
|
import { useLayoutEffect as useLayoutEffect2, useRef as useRef13, useState as useState16 } from "react";
|
|
4654
4654
|
import { jsx as jsx20 } from "react/jsx-runtime";
|
|
4655
|
+
var pendingLayouts = /* @__PURE__ */ new Map();
|
|
4656
|
+
var layoutFrame;
|
|
4657
|
+
function scheduleLayout(element, task) {
|
|
4658
|
+
pendingLayouts.set(element, task);
|
|
4659
|
+
if (layoutFrame !== void 0) return;
|
|
4660
|
+
layoutFrame = requestAnimationFrame(() => {
|
|
4661
|
+
layoutFrame = void 0;
|
|
4662
|
+
const tasks = [...pendingLayouts.values()];
|
|
4663
|
+
pendingLayouts.clear();
|
|
4664
|
+
const layouts = tasks.flatMap((task2) => task2.layouts());
|
|
4665
|
+
layouts.forEach((layout) => {
|
|
4666
|
+
if (!layout.hasAttribute("data-table-inline-layout")) layout.setAttribute("data-table-inline-layout", "");
|
|
4667
|
+
});
|
|
4668
|
+
tasks.forEach((task2) => task2.measure());
|
|
4669
|
+
});
|
|
4670
|
+
}
|
|
4655
4671
|
function TableCellContent({ children, ellipsis, title }) {
|
|
4656
4672
|
const ref = useRef13(null);
|
|
4657
4673
|
const [overflowing, setOverflowing] = useState16(false);
|
|
@@ -4659,39 +4675,40 @@ function TableCellContent({ children, ellipsis, title }) {
|
|
|
4659
4675
|
useLayoutEffect2(() => {
|
|
4660
4676
|
const element = ref.current;
|
|
4661
4677
|
if (!element || !ellipsis || !customContent) return;
|
|
4662
|
-
const
|
|
4663
|
-
const normalizeLayouts = (parent) => {
|
|
4678
|
+
const normalizeLayouts = (parent, layouts) => {
|
|
4664
4679
|
for (const child of parent.children) {
|
|
4665
4680
|
if (!(child instanceof HTMLElement)) continue;
|
|
4666
4681
|
const component = [...child.classList].some((name) => name.startsWith("sia-") && !name.startsWith("sia-space") && name !== "sia-flex");
|
|
4667
4682
|
if (component || child.matches("button, input, textarea, select, [contenteditable]")) continue;
|
|
4668
4683
|
const display = getComputedStyle(child).display;
|
|
4669
4684
|
if (["flex", "inline-flex", "grid", "inline-grid"].includes(display)) {
|
|
4670
|
-
child.setAttribute("data-table-inline-layout", "");
|
|
4671
4685
|
layouts.push(child);
|
|
4672
4686
|
}
|
|
4673
|
-
normalizeLayouts(child);
|
|
4687
|
+
normalizeLayouts(child, layouts);
|
|
4674
4688
|
}
|
|
4675
4689
|
};
|
|
4676
|
-
normalizeLayouts(element);
|
|
4677
4690
|
const update = () => setOverflowing(element.scrollWidth > element.clientWidth + 1 || element.scrollHeight > element.clientHeight + 1);
|
|
4678
|
-
|
|
4691
|
+
scheduleLayout(element, {
|
|
4692
|
+
layouts: () => {
|
|
4693
|
+
const layouts = [];
|
|
4694
|
+
normalizeLayouts(element, layouts);
|
|
4695
|
+
return layouts;
|
|
4696
|
+
},
|
|
4697
|
+
measure: update
|
|
4698
|
+
});
|
|
4679
4699
|
const observer = new ResizeObserver(update);
|
|
4680
4700
|
observer.observe(element);
|
|
4681
4701
|
for (const child of element.children) observer.observe(child);
|
|
4682
4702
|
return () => {
|
|
4683
4703
|
observer.disconnect();
|
|
4684
|
-
|
|
4704
|
+
pendingLayouts.delete(element);
|
|
4685
4705
|
};
|
|
4686
4706
|
}, [children, ellipsis, customContent]);
|
|
4687
4707
|
return /* @__PURE__ */ jsx20("div", { ref, className: "sia-table__cell-content", "data-custom-content": customContent || void 0, "data-content-overflow": ellipsis && customContent && overflowing || void 0, children: title ? /* @__PURE__ */ jsx20(Tooltip, { title, className: "sia-table__cell-tooltip", children: /* @__PURE__ */ jsx20("span", { children }) }) : children });
|
|
4688
4708
|
}
|
|
4689
4709
|
|
|
4690
|
-
// src/components/Table/
|
|
4691
|
-
import {
|
|
4692
|
-
|
|
4693
|
-
// src/components/Table/plugins.tsx
|
|
4694
|
-
import { isValidElement as isValidElement3, useEffect as useEffect11, useRef as useRef14, useState as useState17 } from "react";
|
|
4710
|
+
// src/components/Table/TableCanvasLayer.tsx
|
|
4711
|
+
import { useLayoutEffect as useLayoutEffect3, useRef as useRef14 } from "react";
|
|
4695
4712
|
|
|
4696
4713
|
// src/components/Table/utils.ts
|
|
4697
4714
|
var AUTO_WIDTH_COLUMN_KEYS = /* @__PURE__ */ new Set(["action", "actions", "operation", "operations"]);
|
|
@@ -4743,8 +4760,115 @@ function toTablePageParams(current, pageSize) {
|
|
|
4743
4760
|
return { current, pageIndex: current, pageSize, skipCount: Math.max(0, current - 1) * pageSize, maxResultCount: pageSize };
|
|
4744
4761
|
}
|
|
4745
4762
|
|
|
4763
|
+
// src/components/Table/TableCanvasLayer.tsx
|
|
4764
|
+
import { jsx as jsx21 } from "react/jsx-runtime";
|
|
4765
|
+
function TableCanvasLayer({ viewport, rows, columns, widths, rowHeight, headerHeight }) {
|
|
4766
|
+
const canvasRef = useRef14(null);
|
|
4767
|
+
useLayoutEffect3(() => {
|
|
4768
|
+
const canvas = canvasRef.current;
|
|
4769
|
+
const scroller = viewport.current;
|
|
4770
|
+
if (!canvas || !scroller) return;
|
|
4771
|
+
const ctx = canvas.getContext("2d");
|
|
4772
|
+
if (!ctx) return;
|
|
4773
|
+
let frame = 0;
|
|
4774
|
+
const draw = () => {
|
|
4775
|
+
frame = 0;
|
|
4776
|
+
const width = scroller.clientWidth, height = scroller.clientHeight;
|
|
4777
|
+
const ratio = window.devicePixelRatio || 1;
|
|
4778
|
+
if (canvas.width !== Math.round(width * ratio) || canvas.height !== Math.round(height * ratio)) {
|
|
4779
|
+
canvas.width = Math.round(width * ratio);
|
|
4780
|
+
canvas.height = Math.round(height * ratio);
|
|
4781
|
+
}
|
|
4782
|
+
canvas.style.width = `${width}px`;
|
|
4783
|
+
canvas.style.height = `${height}px`;
|
|
4784
|
+
ctx.setTransform(ratio, 0, 0, ratio, 0, 0);
|
|
4785
|
+
ctx.clearRect(0, 0, width, height);
|
|
4786
|
+
const style = getComputedStyle(scroller);
|
|
4787
|
+
const foreground = style.color;
|
|
4788
|
+
ctx.font = `${style.fontSize} ${style.fontFamily}`;
|
|
4789
|
+
ctx.textBaseline = "middle";
|
|
4790
|
+
const leftWidth = columns.reduce((n, c) => n + (normalizeFixed(c.fixed) === "left" ? widths.get(c.key) ?? 160 : 0), 0);
|
|
4791
|
+
const rightWidth = columns.reduce((n, c) => n + (normalizeFixed(c.fixed) === "right" ? widths.get(c.key) ?? 160 : 0), 0);
|
|
4792
|
+
let offset = 0, fixedLeft = 0, fixedRight = rightWidth;
|
|
4793
|
+
const geometry = columns.map((column) => {
|
|
4794
|
+
const cellWidth = widths.get(column.key) ?? 160;
|
|
4795
|
+
const fixed = normalizeFixed(column.fixed);
|
|
4796
|
+
const x = fixed === "left" ? fixedLeft : fixed === "right" ? width - fixedRight : offset - scroller.scrollLeft;
|
|
4797
|
+
offset += cellWidth;
|
|
4798
|
+
if (fixed === "left") fixedLeft += cellWidth;
|
|
4799
|
+
if (fixed === "right") fixedRight -= cellWidth;
|
|
4800
|
+
return { column, x, cellWidth, fixed };
|
|
4801
|
+
});
|
|
4802
|
+
const first = Math.max(0, Math.floor(scroller.scrollTop / rowHeight));
|
|
4803
|
+
const last = Math.min(rows.length, Math.ceil((scroller.scrollTop + height) / rowHeight));
|
|
4804
|
+
for (const { column, x, cellWidth, fixed } of geometry) {
|
|
4805
|
+
if (x + cellWidth <= 0 || x >= width || !column.canvasRender && column.render) continue;
|
|
4806
|
+
const clipLeft = Math.max(x, fixed ? 0 : leftWidth);
|
|
4807
|
+
const clipRight = Math.min(x + cellWidth, fixed ? width : width - rightWidth);
|
|
4808
|
+
if (clipRight <= clipLeft) continue;
|
|
4809
|
+
ctx.save();
|
|
4810
|
+
ctx.beginPath();
|
|
4811
|
+
ctx.rect(clipLeft, headerHeight, clipRight - clipLeft, height - headerHeight);
|
|
4812
|
+
ctx.clip();
|
|
4813
|
+
for (let index = first; index < last; index++) {
|
|
4814
|
+
const row = rows[index];
|
|
4815
|
+
const value = getTableValue(row.record, column.dataIndex, column.code ?? column.key);
|
|
4816
|
+
const content = column.canvasRender ? column.canvasRender(value, row.record, row.sourceIndex, { row, rowIndex: index, column }) : { text: value == null ? "" : String(value) };
|
|
4817
|
+
if (!content?.text) continue;
|
|
4818
|
+
const y = headerHeight + index * rowHeight - scroller.scrollTop + rowHeight / 2;
|
|
4819
|
+
const available = Math.max(0, cellWidth - (content.background ? 32 : 16));
|
|
4820
|
+
let text = content.text;
|
|
4821
|
+
if (ctx.measureText(text).width > available) {
|
|
4822
|
+
let lo = 0, hi = text.length;
|
|
4823
|
+
while (lo < hi) {
|
|
4824
|
+
const mid = Math.ceil((lo + hi) / 2);
|
|
4825
|
+
if (ctx.measureText(text.slice(0, mid) + "\u2026").width <= available) lo = mid;
|
|
4826
|
+
else hi = mid - 1;
|
|
4827
|
+
}
|
|
4828
|
+
text = text.slice(0, lo) + "\u2026";
|
|
4829
|
+
}
|
|
4830
|
+
const textWidth = ctx.measureText(text).width;
|
|
4831
|
+
const total = textWidth + (content.background ? 16 : 0);
|
|
4832
|
+
const tx = column.align === "right" ? x + cellWidth - total - 8 : column.align === "center" ? x + (cellWidth - total) / 2 : x + 8;
|
|
4833
|
+
if (content.background) {
|
|
4834
|
+
ctx.fillStyle = content.background;
|
|
4835
|
+
ctx.beginPath();
|
|
4836
|
+
ctx.roundRect(tx, y - 12, total, 24, 4);
|
|
4837
|
+
ctx.fill();
|
|
4838
|
+
}
|
|
4839
|
+
ctx.fillStyle = content.color ?? foreground;
|
|
4840
|
+
ctx.fillText(text, tx + (content.background ? 8 : 0), y);
|
|
4841
|
+
}
|
|
4842
|
+
ctx.restore();
|
|
4843
|
+
}
|
|
4844
|
+
};
|
|
4845
|
+
const schedule = () => {
|
|
4846
|
+
if (!frame) frame = requestAnimationFrame(draw);
|
|
4847
|
+
};
|
|
4848
|
+
scroller.addEventListener("scroll", schedule, { passive: true });
|
|
4849
|
+
const resize = new ResizeObserver(schedule);
|
|
4850
|
+
resize.observe(scroller);
|
|
4851
|
+
const theme = new MutationObserver(schedule);
|
|
4852
|
+
theme.observe(document.documentElement, { attributes: true });
|
|
4853
|
+
window.addEventListener("resize", schedule);
|
|
4854
|
+
draw();
|
|
4855
|
+
return () => {
|
|
4856
|
+
cancelAnimationFrame(frame);
|
|
4857
|
+
resize.disconnect();
|
|
4858
|
+
theme.disconnect();
|
|
4859
|
+
scroller.removeEventListener("scroll", schedule);
|
|
4860
|
+
window.removeEventListener("resize", schedule);
|
|
4861
|
+
};
|
|
4862
|
+
}, [viewport, rows, columns, widths, rowHeight, headerHeight]);
|
|
4863
|
+
return /* @__PURE__ */ jsx21("canvas", { ref: canvasRef, "aria-hidden": "true", className: "sia-table__canvas-layer" });
|
|
4864
|
+
}
|
|
4865
|
+
|
|
4866
|
+
// src/components/Table/Table.tsx
|
|
4867
|
+
import { Fragment as Fragment8, forwardRef as forwardRef5, isValidElement as isValidElement4, memo, useCallback as useCallback2, useEffect as useEffect12, useImperativeHandle, useMemo as useMemo9, useRef as useRef16, useState as useState18 } from "react";
|
|
4868
|
+
|
|
4746
4869
|
// src/components/Table/plugins.tsx
|
|
4747
|
-
import {
|
|
4870
|
+
import { isValidElement as isValidElement3, useEffect as useEffect11, useRef as useRef15, useState as useState17 } from "react";
|
|
4871
|
+
import { Fragment as Fragment7, jsx as jsx22, jsxs as jsxs20 } from "react/jsx-runtime";
|
|
4748
4872
|
function TableCheckbox({
|
|
4749
4873
|
checked,
|
|
4750
4874
|
indeterminate,
|
|
@@ -4752,7 +4876,7 @@ function TableCheckbox({
|
|
|
4752
4876
|
label,
|
|
4753
4877
|
onChange
|
|
4754
4878
|
}) {
|
|
4755
|
-
return /* @__PURE__ */
|
|
4879
|
+
return /* @__PURE__ */ jsx22(
|
|
4756
4880
|
Checkbox,
|
|
4757
4881
|
{
|
|
4758
4882
|
className: "sia-table__checkbox",
|
|
@@ -4977,6 +5101,7 @@ function createCellSelectionPlugin(options = {}) {
|
|
|
4977
5101
|
info
|
|
4978
5102
|
);
|
|
4979
5103
|
if (exported !== void 0) return tableExportText(exported);
|
|
5104
|
+
if (column.canvasRender) return column.canvasRender(value, row.record, row.sourceIndex, info)?.text ?? "";
|
|
4980
5105
|
if (column.editable) return tableExportCell(value, true);
|
|
4981
5106
|
const rendered = column.render?.(value, row.record, row.sourceIndex, info);
|
|
4982
5107
|
return rendered !== void 0 ? tableExportText(rendered) : tableExportCell(value, true);
|
|
@@ -5379,10 +5504,10 @@ function TableSelectedItemsPanel({
|
|
|
5379
5504
|
/* @__PURE__ */ jsxs20("div", { className: "sia-table-selection-panel__header", children: [
|
|
5380
5505
|
/* @__PURE__ */ jsxs20("strong", { children: [
|
|
5381
5506
|
"\u5DF2\u9009 ",
|
|
5382
|
-
/* @__PURE__ */
|
|
5507
|
+
/* @__PURE__ */ jsx22("span", { children: entries.length }),
|
|
5383
5508
|
" \u9879"
|
|
5384
5509
|
] }),
|
|
5385
|
-
/* @__PURE__ */
|
|
5510
|
+
/* @__PURE__ */ jsx22(
|
|
5386
5511
|
Button,
|
|
5387
5512
|
{
|
|
5388
5513
|
size: "small",
|
|
@@ -5393,15 +5518,15 @@ function TableSelectedItemsPanel({
|
|
|
5393
5518
|
}
|
|
5394
5519
|
)
|
|
5395
5520
|
] }),
|
|
5396
|
-
/* @__PURE__ */
|
|
5397
|
-
/* @__PURE__ */
|
|
5398
|
-
columns.map((column) => /* @__PURE__ */
|
|
5399
|
-
/* @__PURE__ */
|
|
5521
|
+
/* @__PURE__ */ jsx22("div", { className: "sia-table-selection-panel__body", children: /* @__PURE__ */ jsxs20("table", { children: [
|
|
5522
|
+
/* @__PURE__ */ jsx22("thead", { children: /* @__PURE__ */ jsxs20("tr", { children: [
|
|
5523
|
+
columns.map((column) => /* @__PURE__ */ jsx22("th", { children: getColumnLabel(column) }, column.key)),
|
|
5524
|
+
/* @__PURE__ */ jsx22("th", { "aria-label": "\u64CD\u4F5C" })
|
|
5400
5525
|
] }) }),
|
|
5401
|
-
/* @__PURE__ */
|
|
5526
|
+
/* @__PURE__ */ jsx22("tbody", { children: visibleEntries.map((entry, selectedIndex) => /* @__PURE__ */ jsxs20("tr", { children: [
|
|
5402
5527
|
columns.map((column) => {
|
|
5403
5528
|
if (column.meta?.plugin === "index")
|
|
5404
|
-
return /* @__PURE__ */
|
|
5529
|
+
return /* @__PURE__ */ jsx22("td", { children: entry.sourceIndex + 1 }, column.key);
|
|
5405
5530
|
const baseColumn = baseColumnMap.get(column.key) ?? column;
|
|
5406
5531
|
const value = getTableValue(
|
|
5407
5532
|
entry.record,
|
|
@@ -5421,9 +5546,9 @@ function TableSelectedItemsPanel({
|
|
|
5421
5546
|
entry.sourceIndex,
|
|
5422
5547
|
{ row, rowIndex: entry.sourceIndex, column: baseColumn }
|
|
5423
5548
|
) ?? value;
|
|
5424
|
-
return /* @__PURE__ */
|
|
5549
|
+
return /* @__PURE__ */ jsx22("td", { children: content }, column.key);
|
|
5425
5550
|
}),
|
|
5426
|
-
/* @__PURE__ */
|
|
5551
|
+
/* @__PURE__ */ jsx22("td", { children: /* @__PURE__ */ jsx22(
|
|
5427
5552
|
Button,
|
|
5428
5553
|
{
|
|
5429
5554
|
size: "small",
|
|
@@ -5438,7 +5563,7 @@ function TableSelectedItemsPanel({
|
|
|
5438
5563
|
"\u8FD8\u6709 ",
|
|
5439
5564
|
hiddenCount,
|
|
5440
5565
|
" \u9879\u672A\u5C55\u793A",
|
|
5441
|
-
/* @__PURE__ */
|
|
5566
|
+
/* @__PURE__ */ jsx22(Button, { size: "small", variant: "link", onClick: () => setShowAll(true), children: "\u5C55\u793A\u5168\u90E8" })
|
|
5442
5567
|
] }) : null
|
|
5443
5568
|
] });
|
|
5444
5569
|
}
|
|
@@ -5553,7 +5678,7 @@ function createSelectionPlugin(options = {}) {
|
|
|
5553
5678
|
const keys = selected(context);
|
|
5554
5679
|
const allChecked = enabledRows.length > 0 && enabledRows.every((row) => keys.includes(row.key));
|
|
5555
5680
|
const someChecked = enabledRows.some((row) => keys.includes(row.key));
|
|
5556
|
-
return /* @__PURE__ */
|
|
5681
|
+
return /* @__PURE__ */ jsx22(
|
|
5557
5682
|
TableCheckbox,
|
|
5558
5683
|
{
|
|
5559
5684
|
label: "\u9009\u62E9\u5F53\u524D\u9875\u5168\u90E8\u884C",
|
|
@@ -5569,7 +5694,7 @@ function createSelectionPlugin(options = {}) {
|
|
|
5569
5694
|
}
|
|
5570
5695
|
);
|
|
5571
5696
|
},
|
|
5572
|
-
render: (_value, record, _index, info) => mode === "single" ? /* @__PURE__ */
|
|
5697
|
+
render: (_value, record, _index, info) => mode === "single" ? /* @__PURE__ */ jsx22(
|
|
5573
5698
|
Radio2,
|
|
5574
5699
|
{
|
|
5575
5700
|
className: "sia-table__checkbox",
|
|
@@ -5580,7 +5705,7 @@ function createSelectionPlugin(options = {}) {
|
|
|
5580
5705
|
onClick: (event) => event.stopPropagation(),
|
|
5581
5706
|
onChange: () => toggle(info.row.key, record, context)
|
|
5582
5707
|
}
|
|
5583
|
-
) : /* @__PURE__ */
|
|
5708
|
+
) : /* @__PURE__ */ jsx22(
|
|
5584
5709
|
TableCheckbox,
|
|
5585
5710
|
{
|
|
5586
5711
|
label: `\u9009\u62E9\u7B2C ${info.rowIndex + 1} \u884C`,
|
|
@@ -5620,7 +5745,7 @@ function createSelectionPlugin(options = {}) {
|
|
|
5620
5745
|
(column) => !column.hidden && column.meta?.plugin !== "selection"
|
|
5621
5746
|
).slice(0, Math.max(1, options.selectionPanelColumnCount ?? 4));
|
|
5622
5747
|
return /* @__PURE__ */ jsxs20("span", { className: "sia-table__selection-footer", children: [
|
|
5623
|
-
/* @__PURE__ */
|
|
5748
|
+
/* @__PURE__ */ jsx22(
|
|
5624
5749
|
Popover,
|
|
5625
5750
|
{
|
|
5626
5751
|
placement: "top-start",
|
|
@@ -5628,7 +5753,7 @@ function createSelectionPlugin(options = {}) {
|
|
|
5628
5753
|
open: context.state.panelOpen && entries.length > 0,
|
|
5629
5754
|
onOpenChange: (panelOpen) => context.setState((state) => ({ ...state, panelOpen })),
|
|
5630
5755
|
overlayClassName: "sia-table-selection-popover",
|
|
5631
|
-
content: /* @__PURE__ */
|
|
5756
|
+
content: /* @__PURE__ */ jsx22(
|
|
5632
5757
|
TableSelectedItemsPanel,
|
|
5633
5758
|
{
|
|
5634
5759
|
entries,
|
|
@@ -5660,7 +5785,7 @@ function createSelectionPlugin(options = {}) {
|
|
|
5660
5785
|
)
|
|
5661
5786
|
}
|
|
5662
5787
|
),
|
|
5663
|
-
mode === "multiple" && options.showPreserveSelectedRowKeys !== false ? /* @__PURE__ */
|
|
5788
|
+
mode === "multiple" && options.showPreserveSelectedRowKeys !== false ? /* @__PURE__ */ jsx22(
|
|
5664
5789
|
Checkbox,
|
|
5665
5790
|
{
|
|
5666
5791
|
checked: preserving(context),
|
|
@@ -5718,8 +5843,8 @@ function createSortPlugin(options = {}) {
|
|
|
5718
5843
|
const order = info?.field === field ? info.order : null;
|
|
5719
5844
|
const sortHint = `${getColumnLabel(currentColumn)}\uFF1A${order === "ascend" ? "\u5F53\u524D\u5347\u5E8F\uFF0C\u70B9\u51FB\u5207\u6362\u4E3A\u964D\u5E8F" : order === "descend" ? "\u5F53\u524D\u964D\u5E8F\uFF0C\u70B9\u51FB\u53D6\u6D88\u6392\u5E8F" : "\u672A\u6392\u5E8F\uFF0C\u70B9\u51FB\u6309\u5347\u5E8F\u6392\u5E8F"}`;
|
|
5720
5845
|
return /* @__PURE__ */ jsxs20("span", { className: "sia-table__sortable-header", children: [
|
|
5721
|
-
/* @__PURE__ */
|
|
5722
|
-
/* @__PURE__ */
|
|
5846
|
+
/* @__PURE__ */ jsx22("span", { children: previousHeader ? previousHeader(currentColumn, coreContext) : currentColumn.title ?? currentColumn.name ?? currentColumn.key }),
|
|
5847
|
+
/* @__PURE__ */ jsx22(
|
|
5723
5848
|
"button",
|
|
5724
5849
|
{
|
|
5725
5850
|
type: "button",
|
|
@@ -5731,9 +5856,9 @@ function createSortPlugin(options = {}) {
|
|
|
5731
5856
|
event.stopPropagation();
|
|
5732
5857
|
cycle(field, context);
|
|
5733
5858
|
},
|
|
5734
|
-
children: order ? /* @__PURE__ */
|
|
5735
|
-
/* @__PURE__ */
|
|
5736
|
-
/* @__PURE__ */
|
|
5859
|
+
children: order ? /* @__PURE__ */ jsx22(Icon, { name: order === "ascend" ? "chevron-up" : "chevron-down", size: 18 }) : /* @__PURE__ */ jsxs20(Fragment7, { children: [
|
|
5860
|
+
/* @__PURE__ */ jsx22(Icon, { name: "chevron-up", size: 11 }),
|
|
5861
|
+
/* @__PURE__ */ jsx22(Icon, { name: "chevron-down", size: 11 })
|
|
5737
5862
|
] })
|
|
5738
5863
|
}
|
|
5739
5864
|
)
|
|
@@ -5779,8 +5904,8 @@ function TableFilterControl({
|
|
|
5779
5904
|
setOpen(false);
|
|
5780
5905
|
};
|
|
5781
5906
|
return /* @__PURE__ */ jsxs20("span", { className: "sia-table__filter-header", children: [
|
|
5782
|
-
/* @__PURE__ */
|
|
5783
|
-
/* @__PURE__ */
|
|
5907
|
+
/* @__PURE__ */ jsx22("span", { children: column.title ?? column.name ?? column.key }),
|
|
5908
|
+
/* @__PURE__ */ jsx22(
|
|
5784
5909
|
Popover,
|
|
5785
5910
|
{
|
|
5786
5911
|
open,
|
|
@@ -5788,7 +5913,7 @@ function TableFilterControl({
|
|
|
5788
5913
|
placement: "bottom-end",
|
|
5789
5914
|
overlayClassName: "sia-table-filter-popover",
|
|
5790
5915
|
content: /* @__PURE__ */ jsxs20("div", { className: "sia-table-filter-panel", children: [
|
|
5791
|
-
/* @__PURE__ */
|
|
5916
|
+
/* @__PURE__ */ jsx22(
|
|
5792
5917
|
Input,
|
|
5793
5918
|
{
|
|
5794
5919
|
size: "small",
|
|
@@ -5803,7 +5928,7 @@ function TableFilterControl({
|
|
|
5803
5928
|
}
|
|
5804
5929
|
),
|
|
5805
5930
|
/* @__PURE__ */ jsxs20("div", { className: "sia-table-filter-panel__actions", children: [
|
|
5806
|
-
/* @__PURE__ */
|
|
5931
|
+
/* @__PURE__ */ jsx22(
|
|
5807
5932
|
Button,
|
|
5808
5933
|
{
|
|
5809
5934
|
size: "small",
|
|
@@ -5815,7 +5940,7 @@ function TableFilterControl({
|
|
|
5815
5940
|
children: "\u6E05\u9664"
|
|
5816
5941
|
}
|
|
5817
5942
|
),
|
|
5818
|
-
/* @__PURE__ */
|
|
5943
|
+
/* @__PURE__ */ jsx22(
|
|
5819
5944
|
Button,
|
|
5820
5945
|
{
|
|
5821
5946
|
size: "small",
|
|
@@ -5826,7 +5951,7 @@ function TableFilterControl({
|
|
|
5826
5951
|
)
|
|
5827
5952
|
] })
|
|
5828
5953
|
] }),
|
|
5829
|
-
children: /* @__PURE__ */
|
|
5954
|
+
children: /* @__PURE__ */ jsx22(
|
|
5830
5955
|
"button",
|
|
5831
5956
|
{
|
|
5832
5957
|
type: "button",
|
|
@@ -5834,7 +5959,7 @@ function TableFilterControl({
|
|
|
5834
5959
|
"aria-label": `\u7B5B\u9009${label}`,
|
|
5835
5960
|
"aria-pressed": Boolean(value),
|
|
5836
5961
|
onClick: (event) => event.stopPropagation(),
|
|
5837
|
-
children: /* @__PURE__ */
|
|
5962
|
+
children: /* @__PURE__ */ jsx22(Icon, { name: "search", size: 13 })
|
|
5838
5963
|
}
|
|
5839
5964
|
)
|
|
5840
5965
|
}
|
|
@@ -5896,7 +6021,7 @@ function createFilterPlugin(options = {}) {
|
|
|
5896
6021
|
title: previousHeader ? previousHeader(currentColumn, coreContext) : currentColumn.title
|
|
5897
6022
|
};
|
|
5898
6023
|
const placeholder = typeof options.placeholder === "function" ? options.placeholder(currentColumn) : options.placeholder ?? `\u8F93\u5165${getColumnLabel(currentColumn)}\u7B5B\u9009`;
|
|
5899
|
-
return /* @__PURE__ */
|
|
6024
|
+
return /* @__PURE__ */ jsx22(
|
|
5900
6025
|
TableFilterControl,
|
|
5901
6026
|
{
|
|
5902
6027
|
column: renderedColumn,
|
|
@@ -5985,7 +6110,7 @@ function createPaginationPlugin(options = {}) {
|
|
|
5985
6110
|
const page = currentPage(context);
|
|
5986
6111
|
const filteredCount = context.getPluginApi("filter")?.getFilteredRows().length;
|
|
5987
6112
|
const totalRecords = options.totalCount ?? filteredCount ?? context.sourceData.length;
|
|
5988
|
-
return /* @__PURE__ */
|
|
6113
|
+
return /* @__PURE__ */ jsx22(
|
|
5989
6114
|
Pagination,
|
|
5990
6115
|
{
|
|
5991
6116
|
className: "sia-table__pagination",
|
|
@@ -6126,7 +6251,7 @@ function createTreePlugin(options = {}) {
|
|
|
6126
6251
|
className: "sia-table__tree-cell",
|
|
6127
6252
|
style: { paddingLeft: info.row.depth * 18 },
|
|
6128
6253
|
children: [
|
|
6129
|
-
info.row.meta.treeHasChildren ? /* @__PURE__ */
|
|
6254
|
+
info.row.meta.treeHasChildren ? /* @__PURE__ */ jsx22(
|
|
6130
6255
|
"button",
|
|
6131
6256
|
{
|
|
6132
6257
|
type: "button",
|
|
@@ -6137,7 +6262,7 @@ function createTreePlugin(options = {}) {
|
|
|
6137
6262
|
event.stopPropagation();
|
|
6138
6263
|
toggle(info.row.key, context);
|
|
6139
6264
|
},
|
|
6140
|
-
children: /* @__PURE__ */
|
|
6265
|
+
children: /* @__PURE__ */ jsx22(
|
|
6141
6266
|
Icon,
|
|
6142
6267
|
{
|
|
6143
6268
|
name: current(context).includes(info.row.key) ? "chevron-down" : "chevron-right",
|
|
@@ -6145,7 +6270,7 @@ function createTreePlugin(options = {}) {
|
|
|
6145
6270
|
}
|
|
6146
6271
|
)
|
|
6147
6272
|
}
|
|
6148
|
-
) : /* @__PURE__ */
|
|
6273
|
+
) : /* @__PURE__ */ jsx22("span", { className: "sia-table__tree-placeholder" }),
|
|
6149
6274
|
previousRender ? previousRender(value, record, index, info) : value
|
|
6150
6275
|
]
|
|
6151
6276
|
}
|
|
@@ -6198,11 +6323,11 @@ function EditableTableCell({
|
|
|
6198
6323
|
const config = typeof editable === "object" ? editable : { type: "input" };
|
|
6199
6324
|
const [editValue, setEditValue] = useState17(value);
|
|
6200
6325
|
const [saving, setSaving] = useState17(false);
|
|
6201
|
-
const inputRef =
|
|
6202
|
-
const editorRef =
|
|
6203
|
-
const editValueRef =
|
|
6204
|
-
const savingRef =
|
|
6205
|
-
const saveRef =
|
|
6326
|
+
const inputRef = useRef15(null);
|
|
6327
|
+
const editorRef = useRef15(null);
|
|
6328
|
+
const editValueRef = useRef15(value);
|
|
6329
|
+
const savingRef = useRef15(false);
|
|
6330
|
+
const saveRef = useRef15(
|
|
6206
6331
|
async () => {
|
|
6207
6332
|
}
|
|
6208
6333
|
);
|
|
@@ -6260,8 +6385,8 @@ function EditableTableCell({
|
|
|
6260
6385
|
onClick: trigger === "click" ? onStart : void 0,
|
|
6261
6386
|
onDoubleClick: trigger === "doubleClick" ? onStart : void 0,
|
|
6262
6387
|
children: [
|
|
6263
|
-
/* @__PURE__ */
|
|
6264
|
-
/* @__PURE__ */
|
|
6388
|
+
/* @__PURE__ */ jsx22("span", { children: content }),
|
|
6389
|
+
/* @__PURE__ */ jsx22(Icon, { name: "edit", size: 13 })
|
|
6265
6390
|
]
|
|
6266
6391
|
}
|
|
6267
6392
|
);
|
|
@@ -6269,7 +6394,7 @@ function EditableTableCell({
|
|
|
6269
6394
|
if (config.type === "custom" && config.editRender) {
|
|
6270
6395
|
editor = config.editRender(record, (next) => void save(next), onCancel);
|
|
6271
6396
|
} else if (config.type === "inputNumber") {
|
|
6272
|
-
editor = /* @__PURE__ */
|
|
6397
|
+
editor = /* @__PURE__ */ jsx22(
|
|
6273
6398
|
InputNumber,
|
|
6274
6399
|
{
|
|
6275
6400
|
ref: inputRef,
|
|
@@ -6290,7 +6415,7 @@ function EditableTableCell({
|
|
|
6290
6415
|
}
|
|
6291
6416
|
);
|
|
6292
6417
|
} else if (config.type === "select") {
|
|
6293
|
-
editor = /* @__PURE__ */
|
|
6418
|
+
editor = /* @__PURE__ */ jsx22(
|
|
6294
6419
|
Select,
|
|
6295
6420
|
{
|
|
6296
6421
|
size: "small",
|
|
@@ -6304,14 +6429,14 @@ function EditableTableCell({
|
|
|
6304
6429
|
}
|
|
6305
6430
|
);
|
|
6306
6431
|
} else {
|
|
6307
|
-
editor = /* @__PURE__ */
|
|
6432
|
+
editor = /* @__PURE__ */ jsx22(
|
|
6308
6433
|
Input,
|
|
6309
6434
|
{
|
|
6310
6435
|
ref: inputRef,
|
|
6311
6436
|
size: "small",
|
|
6312
6437
|
value: String(editValue ?? ""),
|
|
6313
6438
|
disabled: saving,
|
|
6314
|
-
suffix: saving ? /* @__PURE__ */
|
|
6439
|
+
suffix: saving ? /* @__PURE__ */ jsx22(Icon, { name: "loader", size: 13, spin: true }) : null,
|
|
6315
6440
|
onChange: (event) => updateEditValue(event.target.value),
|
|
6316
6441
|
onBlur: () => void save(),
|
|
6317
6442
|
onKeyDown: (event) => {
|
|
@@ -6321,7 +6446,7 @@ function EditableTableCell({
|
|
|
6321
6446
|
}
|
|
6322
6447
|
);
|
|
6323
6448
|
}
|
|
6324
|
-
return /* @__PURE__ */
|
|
6449
|
+
return /* @__PURE__ */ jsx22("div", { ref: editorRef, className: "sia-table__editor", children: editor });
|
|
6325
6450
|
}
|
|
6326
6451
|
function createEditablePlugin(options = {}) {
|
|
6327
6452
|
const trigger = options.trigger ?? "click";
|
|
@@ -6341,7 +6466,7 @@ function createEditablePlugin(options = {}) {
|
|
|
6341
6466
|
const active = canEdit && context.state.editing?.rowKey === info.row.key && context.state.editing.columnKey === column.key;
|
|
6342
6467
|
const content = previousRender ? previousRender(value, record, index, info) : value;
|
|
6343
6468
|
if (!canEdit) return content;
|
|
6344
|
-
return /* @__PURE__ */
|
|
6469
|
+
return /* @__PURE__ */ jsx22(
|
|
6345
6470
|
EditableTableCell,
|
|
6346
6471
|
{
|
|
6347
6472
|
active,
|
|
@@ -6405,8 +6530,8 @@ function createResizePlugin(options = {}) {
|
|
|
6405
6530
|
autoWidth,
|
|
6406
6531
|
width,
|
|
6407
6532
|
renderHeader: (currentColumn, coreContext) => /* @__PURE__ */ jsxs20("span", { className: "sia-table__resizable-header", children: [
|
|
6408
|
-
/* @__PURE__ */
|
|
6409
|
-
/* @__PURE__ */
|
|
6533
|
+
/* @__PURE__ */ jsx22("span", { children: previousHeader ? previousHeader(currentColumn, coreContext) : currentColumn.title ?? currentColumn.name ?? currentColumn.key }),
|
|
6534
|
+
/* @__PURE__ */ jsx22(
|
|
6410
6535
|
"span",
|
|
6411
6536
|
{
|
|
6412
6537
|
className: "sia-table__resize-handle",
|
|
@@ -6543,8 +6668,8 @@ function ColumnSettingPanel({
|
|
|
6543
6668
|
onApply
|
|
6544
6669
|
}) {
|
|
6545
6670
|
const [draft, setDraft] = useState17(items);
|
|
6546
|
-
const listRef =
|
|
6547
|
-
const cancelDrag =
|
|
6671
|
+
const listRef = useRef15(null);
|
|
6672
|
+
const cancelDrag = useRef15(null);
|
|
6548
6673
|
const [preview, setPreview] = useState17(null);
|
|
6549
6674
|
useEffect11(() => {
|
|
6550
6675
|
cancelDrag.current?.();
|
|
@@ -6687,8 +6812,8 @@ function ColumnSettingPanel({
|
|
|
6687
6812
|
if (!next) onClose();
|
|
6688
6813
|
},
|
|
6689
6814
|
footer: /* @__PURE__ */ jsxs20(Fragment7, { children: [
|
|
6690
|
-
/* @__PURE__ */
|
|
6691
|
-
/* @__PURE__ */
|
|
6815
|
+
/* @__PURE__ */ jsx22(Button, { onClick: onClose, children: "\u53D6\u6D88" }),
|
|
6816
|
+
/* @__PURE__ */ jsx22(
|
|
6692
6817
|
Button,
|
|
6693
6818
|
{
|
|
6694
6819
|
variant: "primary",
|
|
@@ -6701,9 +6826,9 @@ function ColumnSettingPanel({
|
|
|
6701
6826
|
children: [
|
|
6702
6827
|
loadError ? /* @__PURE__ */ jsxs20("p", { role: "alert", children: [
|
|
6703
6828
|
"\u8BFB\u53D6\u5217\u914D\u7F6E\u5931\u8D25\u3002",
|
|
6704
|
-
/* @__PURE__ */
|
|
6829
|
+
/* @__PURE__ */ jsx22(Button, { variant: "link", onClick: onRetry, children: "\u91CD\u8BD5" })
|
|
6705
6830
|
] }) : null,
|
|
6706
|
-
/* @__PURE__ */
|
|
6831
|
+
/* @__PURE__ */ jsx22(Spin, { spinning: Boolean(loading), className: "sia-table-settings__loading", "aria-label": loading ? "\u6B63\u5728\u8BFB\u53D6\u5217\u914D\u7F6E" : void 0, children: /* @__PURE__ */ jsxs20(
|
|
6707
6832
|
"fieldset",
|
|
6708
6833
|
{
|
|
6709
6834
|
disabled: loading || loadError,
|
|
@@ -6711,7 +6836,7 @@ function ColumnSettingPanel({
|
|
|
6711
6836
|
"aria-busy": loading,
|
|
6712
6837
|
children: [
|
|
6713
6838
|
/* @__PURE__ */ jsxs20("label", { className: "sia-table-settings__all", children: [
|
|
6714
|
-
/* @__PURE__ */
|
|
6839
|
+
/* @__PURE__ */ jsx22(
|
|
6715
6840
|
TableCheckbox,
|
|
6716
6841
|
{
|
|
6717
6842
|
label: "\u5168\u9009\u5217",
|
|
@@ -6730,7 +6855,7 @@ function ColumnSettingPanel({
|
|
|
6730
6855
|
"\uFF09"
|
|
6731
6856
|
] })
|
|
6732
6857
|
] }),
|
|
6733
|
-
/* @__PURE__ */
|
|
6858
|
+
/* @__PURE__ */ jsx22(
|
|
6734
6859
|
"div",
|
|
6735
6860
|
{
|
|
6736
6861
|
ref: listRef,
|
|
@@ -6745,8 +6870,8 @@ function ColumnSettingPanel({
|
|
|
6745
6870
|
} : void 0,
|
|
6746
6871
|
onPointerDown: (event) => startSort(event, item.key),
|
|
6747
6872
|
children: [
|
|
6748
|
-
/* @__PURE__ */
|
|
6749
|
-
/* @__PURE__ */
|
|
6873
|
+
/* @__PURE__ */ jsx22(Icon, { name: "menu", size: 15 }),
|
|
6874
|
+
/* @__PURE__ */ jsx22(
|
|
6750
6875
|
TableCheckbox,
|
|
6751
6876
|
{
|
|
6752
6877
|
label: `\u663E\u793A${labels.get(item.key) ?? item.key}\u5217`,
|
|
@@ -6758,7 +6883,7 @@ function ColumnSettingPanel({
|
|
|
6758
6883
|
)
|
|
6759
6884
|
}
|
|
6760
6885
|
),
|
|
6761
|
-
/* @__PURE__ */
|
|
6886
|
+
/* @__PURE__ */ jsx22(
|
|
6762
6887
|
"span",
|
|
6763
6888
|
{
|
|
6764
6889
|
className: "sia-table-settings__name",
|
|
@@ -6766,7 +6891,7 @@ function ColumnSettingPanel({
|
|
|
6766
6891
|
}
|
|
6767
6892
|
),
|
|
6768
6893
|
/* @__PURE__ */ jsxs20("div", { className: "sia-table-settings__actions", children: [
|
|
6769
|
-
/* @__PURE__ */
|
|
6894
|
+
/* @__PURE__ */ jsx22(
|
|
6770
6895
|
Button,
|
|
6771
6896
|
{
|
|
6772
6897
|
size: "small",
|
|
@@ -6779,7 +6904,7 @@ function ColumnSettingPanel({
|
|
|
6779
6904
|
children: "\u5DE6"
|
|
6780
6905
|
}
|
|
6781
6906
|
),
|
|
6782
|
-
/* @__PURE__ */
|
|
6907
|
+
/* @__PURE__ */ jsx22(
|
|
6783
6908
|
Button,
|
|
6784
6909
|
{
|
|
6785
6910
|
size: "small",
|
|
@@ -6927,7 +7052,7 @@ function createColumnSettingPlugin(options = {}) {
|
|
|
6927
7052
|
{
|
|
6928
7053
|
key: "builtin:export",
|
|
6929
7054
|
label: "\u8868\u683C\u5BFC\u51FA",
|
|
6930
|
-
icon: /* @__PURE__ */
|
|
7055
|
+
icon: /* @__PURE__ */ jsx22(Icon, { name: "download", size: 18 }),
|
|
6931
7056
|
disabled: exportApi().getRows().length === 0
|
|
6932
7057
|
},
|
|
6933
7058
|
{ key: "builtin:divider", type: "divider" }
|
|
@@ -6935,7 +7060,7 @@ function createColumnSettingPlugin(options = {}) {
|
|
|
6935
7060
|
{
|
|
6936
7061
|
key: "builtin:columns",
|
|
6937
7062
|
label: "\u5217\u8BBE\u7F6E",
|
|
6938
|
-
icon: /* @__PURE__ */
|
|
7063
|
+
icon: /* @__PURE__ */ jsx22(Icon, { name: "settings", size: 18 })
|
|
6939
7064
|
},
|
|
6940
7065
|
...customItems.map((item) => ({
|
|
6941
7066
|
key: "custom:" + item.key,
|
|
@@ -6945,7 +7070,7 @@ function createColumnSettingPlugin(options = {}) {
|
|
|
6945
7070
|
disabled: item.disabled === true || typeof item.disabled === "function" && item.disabled(context)
|
|
6946
7071
|
}))
|
|
6947
7072
|
];
|
|
6948
|
-
return /* @__PURE__ */
|
|
7073
|
+
return /* @__PURE__ */ jsx22(
|
|
6949
7074
|
Dropdown,
|
|
6950
7075
|
{
|
|
6951
7076
|
disabled: options.buttonProps?.disabled || options.buttonProps?.loading,
|
|
@@ -6962,12 +7087,12 @@ function createColumnSettingPlugin(options = {}) {
|
|
|
6962
7087
|
void customItems.find((item) => "custom:" + item.key === key)?.onClick?.(context);
|
|
6963
7088
|
}
|
|
6964
7089
|
},
|
|
6965
|
-
children: /* @__PURE__ */
|
|
7090
|
+
children: /* @__PURE__ */ jsx22(
|
|
6966
7091
|
Button,
|
|
6967
7092
|
{
|
|
6968
7093
|
size: "small",
|
|
6969
7094
|
variant: "text",
|
|
6970
|
-
icon: /* @__PURE__ */
|
|
7095
|
+
icon: /* @__PURE__ */ jsx22(Icon, { name: "settings", size: 16 }),
|
|
6971
7096
|
"aria-label": "\u8868\u683C\u8BBE\u7F6E",
|
|
6972
7097
|
...options.buttonProps,
|
|
6973
7098
|
className: `sia-table__settings-button${options.buttonProps?.children == null ? " sia-table__toolbar-icon" : ""} ${options.buttonProps?.className ?? ""}`.trim()
|
|
@@ -6976,7 +7101,7 @@ function createColumnSettingPlugin(options = {}) {
|
|
|
6976
7101
|
}
|
|
6977
7102
|
);
|
|
6978
7103
|
},
|
|
6979
|
-
renderOverlay: (context) => /* @__PURE__ */
|
|
7104
|
+
renderOverlay: (context) => /* @__PURE__ */ jsx22(
|
|
6980
7105
|
ColumnSettingPanel,
|
|
6981
7106
|
{
|
|
6982
7107
|
open: context.state.open,
|
|
@@ -7026,11 +7151,11 @@ function ToolbarItems({
|
|
|
7026
7151
|
items,
|
|
7027
7152
|
context
|
|
7028
7153
|
}) {
|
|
7029
|
-
return /* @__PURE__ */
|
|
7154
|
+
return /* @__PURE__ */ jsx22(Fragment7, { children: items.map((item) => {
|
|
7030
7155
|
if (item.hidden === true || typeof item.hidden === "function" && item.hidden(context))
|
|
7031
7156
|
return null;
|
|
7032
7157
|
const disabled = item.disabled === true || typeof item.disabled === "function" && item.disabled(context);
|
|
7033
|
-
return /* @__PURE__ */
|
|
7158
|
+
return /* @__PURE__ */ jsx22(
|
|
7034
7159
|
Button,
|
|
7035
7160
|
{
|
|
7036
7161
|
size: "small",
|
|
@@ -7054,14 +7179,14 @@ function createToolbarPlugin(options) {
|
|
|
7054
7179
|
order: 5,
|
|
7055
7180
|
renderToolbarStart: (context) => /* @__PURE__ */ jsxs20(Fragment7, { children: [
|
|
7056
7181
|
options.start,
|
|
7057
|
-
/* @__PURE__ */
|
|
7182
|
+
/* @__PURE__ */ jsx22(ToolbarItems, { items: items("start"), context })
|
|
7058
7183
|
] }),
|
|
7059
7184
|
renderToolbarEnd: (context) => /* @__PURE__ */ jsxs20(Fragment7, { children: [
|
|
7060
7185
|
options.end,
|
|
7061
|
-
/* @__PURE__ */
|
|
7186
|
+
/* @__PURE__ */ jsx22(ToolbarItems, { items: items("end"), context }),
|
|
7062
7187
|
items("end", true).length > 0 ? /* @__PURE__ */ jsxs20("details", { className: "sia-table__toolbar-menu", children: [
|
|
7063
|
-
/* @__PURE__ */
|
|
7064
|
-
/* @__PURE__ */
|
|
7188
|
+
/* @__PURE__ */ jsx22("summary", { "aria-label": "\u66F4\u591A\u8868\u683C\u64CD\u4F5C", children: /* @__PURE__ */ jsx22(Icon, { name: "more-horizontal", size: 16 }) }),
|
|
7189
|
+
/* @__PURE__ */ jsx22("div", { children: /* @__PURE__ */ jsx22(ToolbarItems, { items: items("end", true), context }) })
|
|
7065
7190
|
] }) : null
|
|
7066
7191
|
] })
|
|
7067
7192
|
};
|
|
@@ -7143,11 +7268,11 @@ function createExportPlugin(options = {}) {
|
|
|
7143
7268
|
return {
|
|
7144
7269
|
id: "export",
|
|
7145
7270
|
order: 95,
|
|
7146
|
-
renderToolbarEnd: options.showButton === false ? void 0 : (context) => /* @__PURE__ */
|
|
7271
|
+
renderToolbarEnd: options.showButton === false ? void 0 : (context) => /* @__PURE__ */ jsx22(
|
|
7147
7272
|
Button,
|
|
7148
7273
|
{
|
|
7149
7274
|
size: "small",
|
|
7150
|
-
icon: /* @__PURE__ */
|
|
7275
|
+
icon: /* @__PURE__ */ jsx22(Icon, { name: "download", size: 14 }),
|
|
7151
7276
|
disabled: getRows(context).length === 0,
|
|
7152
7277
|
onClick: () => void download(context),
|
|
7153
7278
|
children: options.buttonLabel ?? "\u5BFC\u51FA"
|
|
@@ -7162,7 +7287,7 @@ function createExportPlugin(options = {}) {
|
|
|
7162
7287
|
}
|
|
7163
7288
|
|
|
7164
7289
|
// src/components/Table/Table.tsx
|
|
7165
|
-
import { jsx as
|
|
7290
|
+
import { jsx as jsx23, jsxs as jsxs21 } from "react/jsx-runtime";
|
|
7166
7291
|
var EMPTY_DATA = [];
|
|
7167
7292
|
var EMPTY_COLUMNS = [];
|
|
7168
7293
|
var EMPTY_PLUGINS = [];
|
|
@@ -7224,10 +7349,9 @@ function buildHeaderRows(columns) {
|
|
|
7224
7349
|
function resolveInitialState(plugin) {
|
|
7225
7350
|
return typeof plugin.initialState === "function" ? plugin.initialState() : plugin.initialState;
|
|
7226
7351
|
}
|
|
7227
|
-
function
|
|
7352
|
+
function prepareTableCellMeasurement(cell) {
|
|
7228
7353
|
const content = cell.querySelector(":scope > .sia-table__cell-content");
|
|
7229
7354
|
const target = cell.classList.contains("sia-table__header-cell") ? cell.querySelector(".sia-table__resizable-header > span:first-child, .sia-table__header-label-content") : content;
|
|
7230
|
-
let contentWidth = cell.scrollWidth;
|
|
7231
7355
|
if (target) {
|
|
7232
7356
|
const measurement = target.cloneNode(true);
|
|
7233
7357
|
Object.assign(measurement.style, {
|
|
@@ -7245,17 +7369,16 @@ function measureTableCellContentWidth(cell) {
|
|
|
7245
7369
|
});
|
|
7246
7370
|
measurement.setAttribute("aria-hidden", "true");
|
|
7247
7371
|
cell.appendChild(measurement);
|
|
7248
|
-
|
|
7249
|
-
measurement.remove();
|
|
7372
|
+
return measurement;
|
|
7250
7373
|
}
|
|
7251
|
-
const style = window.getComputedStyle(cell);
|
|
7252
|
-
return contentWidth + (Number.parseFloat(style.paddingLeft) || 0) + (Number.parseFloat(style.paddingRight) || 0) + (Number.parseFloat(style.borderLeftWidth) || 0) + (Number.parseFloat(style.borderRightWidth) || 0);
|
|
7253
7374
|
}
|
|
7254
7375
|
function getTableHorizontalMetrics(viewport, table) {
|
|
7255
7376
|
const contentWidth = Math.max(viewport.clientWidth, table?.getBoundingClientRect().width ?? viewport.clientWidth);
|
|
7256
7377
|
return { contentWidth, maxLeft: Math.max(0, contentWidth - viewport.clientWidth) };
|
|
7257
7378
|
}
|
|
7258
7379
|
var TableBodyRow = memo(function TableBodyRow2({
|
|
7380
|
+
canvas,
|
|
7381
|
+
visibleColumns,
|
|
7259
7382
|
row,
|
|
7260
7383
|
rowIndex,
|
|
7261
7384
|
columns,
|
|
@@ -7278,7 +7401,7 @@ var TableBodyRow = memo(function TableBodyRow2({
|
|
|
7278
7401
|
onCellPointerDown,
|
|
7279
7402
|
onCellPointerMove
|
|
7280
7403
|
}) {
|
|
7281
|
-
return /* @__PURE__ */
|
|
7404
|
+
return /* @__PURE__ */ jsx23(
|
|
7282
7405
|
"tr",
|
|
7283
7406
|
{
|
|
7284
7407
|
className: `sia-table__row${striped && rowIndex % 2 === 1 ? " sia-table__row--striped" : ""} ${className}`.trim(),
|
|
@@ -7287,7 +7410,13 @@ var TableBodyRow = memo(function TableBodyRow2({
|
|
|
7287
7410
|
onDoubleClick,
|
|
7288
7411
|
onMouseEnter,
|
|
7289
7412
|
onMouseLeave,
|
|
7290
|
-
children: columns.map((column) => {
|
|
7413
|
+
children: columns.map((column, columnIndex) => {
|
|
7414
|
+
if (canvas && !visibleColumns.has(column.key)) {
|
|
7415
|
+
if (columnIndex > 0 && !visibleColumns.has(columns[columnIndex - 1].key)) return null;
|
|
7416
|
+
let count = 1;
|
|
7417
|
+
while (columnIndex + count < columns.length && !visibleColumns.has(columns[columnIndex + count].key)) count++;
|
|
7418
|
+
return /* @__PURE__ */ jsx23("td", { colSpan: count, "aria-hidden": "true", style: { padding: 0 } }, `spacer-${column.key}`);
|
|
7419
|
+
}
|
|
7291
7420
|
const pluginCellProps = getCellProps(column);
|
|
7292
7421
|
if (pluginCellProps.hidden) return null;
|
|
7293
7422
|
const value = getTableValue(row.record, column.dataIndex, column.code ?? column.key);
|
|
@@ -7296,10 +7425,11 @@ var TableBodyRow = memo(function TableBodyRow2({
|
|
|
7296
7425
|
const fixedStyle = fixed === "left" ? { left: leftOffsets.get(column.key) } : fixed === "right" ? { right: rightOffsets.get(column.key) } : void 0;
|
|
7297
7426
|
const fixedEdgeClass = fixed === "left" && column.key === leftFixedEdgeKey ? " sia-table__cell--fixed-left-edge" : fixed === "right" && column.key === rightFixedEdgeKey ? " sia-table__cell--fixed-right-edge" : "";
|
|
7298
7427
|
const autoWidthClass = column.autoWidth ? " sia-table__cell--auto-width" : "";
|
|
7299
|
-
return /* @__PURE__ */
|
|
7428
|
+
return /* @__PURE__ */ jsx23(
|
|
7300
7429
|
"td",
|
|
7301
7430
|
{
|
|
7302
7431
|
"data-column-key": column.key,
|
|
7432
|
+
"aria-label": canvas ? column.canvasRender?.(value, row.record, row.sourceIndex, { row, rowIndex, column })?.text ?? (value == null ? "" : String(value)) : void 0,
|
|
7303
7433
|
rowSpan: pluginCellProps.rowSpan,
|
|
7304
7434
|
colSpan: pluginCellProps.colSpan,
|
|
7305
7435
|
className: `sia-table__cell sia-table__cell--${column.align ?? "left"}${fixed ? ` sia-table__cell--fixed sia-table__cell--fixed-${fixed}` : ""}${fixedEdgeClass}${autoWidthClass}${column.ellipsis !== false ? " sia-table__cell--ellipsis" : ""} ${cellClass} ${pluginCellProps.className ?? ""}`.trim(),
|
|
@@ -7310,14 +7440,14 @@ var TableBodyRow = memo(function TableBodyRow2({
|
|
|
7310
7440
|
onContextMenu: (event) => onCellContextMenu(column, event),
|
|
7311
7441
|
onPointerDown: (event) => onCellPointerDown(column, event),
|
|
7312
7442
|
onPointerMove: (event) => onCellPointerMove(column, event),
|
|
7313
|
-
children: /* @__PURE__ */
|
|
7443
|
+
children: !canvas || visibleColumns.has(column.key) && (pluginCellProps.content !== void 0 || !column.canvasRender && column.render) ? /* @__PURE__ */ jsx23(
|
|
7314
7444
|
TableCellContent,
|
|
7315
7445
|
{
|
|
7316
7446
|
ellipsis: column.ellipsis !== false,
|
|
7317
7447
|
title: column.showTitle === true && column.ellipsis !== false && typeof value === "string" ? value : void 0,
|
|
7318
7448
|
children: pluginCellProps.content !== void 0 ? pluginCellProps.content : column.render ? column.render(value, row.record, row.sourceIndex, { row, rowIndex, column }) : value
|
|
7319
7449
|
}
|
|
7320
|
-
)
|
|
7450
|
+
) : null
|
|
7321
7451
|
},
|
|
7322
7452
|
column.key
|
|
7323
7453
|
);
|
|
@@ -7342,6 +7472,7 @@ function TableInner(props, ref) {
|
|
|
7342
7472
|
toolbarBordered = false,
|
|
7343
7473
|
striped = true,
|
|
7344
7474
|
virtual,
|
|
7475
|
+
renderMode = "dom",
|
|
7345
7476
|
virtualThreshold = 100,
|
|
7346
7477
|
rowHeight = SIZE_ROW_HEIGHT[size],
|
|
7347
7478
|
overscan = 6,
|
|
@@ -7358,13 +7489,14 @@ function TableInner(props, ref) {
|
|
|
7358
7489
|
style,
|
|
7359
7490
|
...htmlProps
|
|
7360
7491
|
} = props;
|
|
7361
|
-
const rootRef =
|
|
7362
|
-
const scrollRef =
|
|
7363
|
-
const tableRef =
|
|
7492
|
+
const rootRef = useRef16(null);
|
|
7493
|
+
const scrollRef = useRef16(null);
|
|
7494
|
+
const tableRef = useRef16(null);
|
|
7364
7495
|
useScrollbarProximity();
|
|
7365
|
-
const scrollbarDragRef =
|
|
7496
|
+
const scrollbarDragRef = useRef16(null);
|
|
7366
7497
|
const [internalLoading, setInternalLoading] = useState18(false);
|
|
7367
7498
|
const [scrollTop, setScrollTop] = useState18(0);
|
|
7499
|
+
const [scrollLeft, setScrollLeft] = useState18(0);
|
|
7368
7500
|
const [viewportHeight, setViewportHeight] = useState18(420);
|
|
7369
7501
|
const [viewportWidth, setViewportWidth] = useState18(0);
|
|
7370
7502
|
const [autoColumnWidths, setAutoColumnWidths] = useState18({});
|
|
@@ -7382,14 +7514,14 @@ function TableInner(props, ref) {
|
|
|
7382
7514
|
return plugins;
|
|
7383
7515
|
}, [builtInHighlightPlugin, builtInResizePlugin, builtInCellSelectionPlugin, builtInIndexPlugin, providedPlugins, resizable, cellSelection, showIndex]);
|
|
7384
7516
|
const sortedPlugins = useMemo9(() => [...activePlugins].sort((a, b) => (a.order ?? 100) - (b.order ?? 100)), [activePlugins]);
|
|
7385
|
-
const pluginsByIdRef =
|
|
7517
|
+
const pluginsByIdRef = useRef16(/* @__PURE__ */ new Map());
|
|
7386
7518
|
pluginsByIdRef.current = new Map(sortedPlugins.map((plugin) => [plugin.id, plugin]));
|
|
7387
7519
|
const [pluginStates, setPluginStates] = useState18(() => Object.fromEntries(
|
|
7388
7520
|
sortedPlugins.map((plugin) => [plugin.id, resolveInitialState(plugin)])
|
|
7389
7521
|
));
|
|
7390
|
-
const pluginApisRef =
|
|
7391
|
-
const contextsRef =
|
|
7392
|
-
const mountedPluginsRef =
|
|
7522
|
+
const pluginApisRef = useRef16({});
|
|
7523
|
+
const contextsRef = useRef16(/* @__PURE__ */ new Map());
|
|
7524
|
+
const mountedPluginsRef = useRef16(/* @__PURE__ */ new Map());
|
|
7393
7525
|
const pipeline = { columns: baseColumns, rows: createTableRows(dataSource, getRowKey) };
|
|
7394
7526
|
const nextApis = {};
|
|
7395
7527
|
const contexts = /* @__PURE__ */ new Map();
|
|
@@ -7470,18 +7602,22 @@ function TableInner(props, ref) {
|
|
|
7470
7602
|
if (element.scrollLeft > maxLeft) element.scrollLeft = maxLeft > 1 ? maxLeft : 0;
|
|
7471
7603
|
const logicalScrollLeft = Math.min(element.scrollLeft, maxLeft);
|
|
7472
7604
|
const maxTop = Math.max(0, element.scrollHeight - element.clientHeight);
|
|
7473
|
-
|
|
7474
|
-
|
|
7475
|
-
|
|
7476
|
-
|
|
7605
|
+
const setFlag = (key, value) => {
|
|
7606
|
+
const next = String(value);
|
|
7607
|
+
if (root.dataset[key] !== next) root.dataset[key] = next;
|
|
7608
|
+
};
|
|
7609
|
+
setFlag("overflowX", maxLeft > 1);
|
|
7610
|
+
setFlag("overflowY", maxTop > 1);
|
|
7611
|
+
const horizontalTrackElement = root.querySelector(".sia-table__scrollbar--horizontal");
|
|
7612
|
+
const verticalTrackElement = root.querySelector(".sia-table__scrollbar--vertical");
|
|
7613
|
+
const horizontalTrack = horizontalTrackElement?.clientWidth ?? 0;
|
|
7614
|
+
const verticalTrack = verticalTrackElement?.clientHeight ?? 0;
|
|
7477
7615
|
const horizontalThumb = maxLeft > 1 ? Math.min(horizontalTrack, Math.max(36, horizontalTrack * element.clientWidth / horizontalContentWidth)) : 0;
|
|
7478
7616
|
const verticalThumb = maxTop > 1 ? Math.min(verticalTrack, Math.max(36, verticalTrack * element.clientHeight / element.scrollHeight)) : 0;
|
|
7479
7617
|
const horizontalPosition = maxLeft > 0 ? logicalScrollLeft / maxLeft * Math.max(0, horizontalTrack - horizontalThumb) : 0;
|
|
7480
7618
|
const verticalPosition = maxTop > 0 ? element.scrollTop / maxTop * Math.max(0, verticalTrack - verticalThumb) : 0;
|
|
7481
|
-
|
|
7482
|
-
|
|
7483
|
-
root.dataset.overflowX = String(maxLeft > 1);
|
|
7484
|
-
root.dataset.overflowY = String(maxTop > 1);
|
|
7619
|
+
setFlag("scrolledLeft", logicalScrollLeft > 1);
|
|
7620
|
+
setFlag("scrolledRight", maxLeft > 1 && logicalScrollLeft < maxLeft - 1);
|
|
7485
7621
|
const viewportRect = element.getBoundingClientRect();
|
|
7486
7622
|
const leftEdge = root.querySelector(".sia-table__header-cell.sia-table__cell--fixed-left-edge");
|
|
7487
7623
|
const rightEdge = root.querySelector(".sia-table__header-cell.sia-table__cell--fixed-right-edge");
|
|
@@ -7493,10 +7629,10 @@ function TableInner(props, ref) {
|
|
|
7493
7629
|
const rightEdgeRect = rightEdge.getBoundingClientRect();
|
|
7494
7630
|
root.style.setProperty("--sia-table-fixed-right-width", `${Math.max(0, viewportRect.right - rightEdgeRect.left)}px`);
|
|
7495
7631
|
}
|
|
7496
|
-
|
|
7497
|
-
|
|
7498
|
-
|
|
7499
|
-
|
|
7632
|
+
horizontalTrackElement?.style.setProperty("--sia-table-scrollbar-x-size", `${horizontalThumb}px`);
|
|
7633
|
+
horizontalTrackElement?.style.setProperty("--sia-table-scrollbar-x-position", `${horizontalPosition}px`);
|
|
7634
|
+
verticalTrackElement?.style.setProperty("--sia-table-scrollbar-y-size", `${verticalThumb}px`);
|
|
7635
|
+
verticalTrackElement?.style.setProperty("--sia-table-scrollbar-y-position", `${verticalPosition}px`);
|
|
7500
7636
|
}, []);
|
|
7501
7637
|
useEffect12(() => {
|
|
7502
7638
|
const element = scrollRef.current;
|
|
@@ -7517,19 +7653,33 @@ function TableInner(props, ref) {
|
|
|
7517
7653
|
const orderedColumns = useMemo9(() => sortTableColumnsByFixed(pipeline.columns), [pipeline.columns]);
|
|
7518
7654
|
const leafColumns = useMemo9(() => flattenTableColumns(orderedColumns), [orderedColumns]);
|
|
7519
7655
|
const headerRows = useMemo9(() => buildHeaderRows(orderedColumns), [orderedColumns]);
|
|
7656
|
+
const measuredCells = useRef16(/* @__PURE__ */ new WeakSet());
|
|
7657
|
+
const autoWidthSignature = leafColumns.map((column) => `${column.key}:${column.autoWidth}:${resizedWidths[column.key] ?? ""}`).join("|");
|
|
7658
|
+
useEffect12(() => {
|
|
7659
|
+
measuredCells.current = /* @__PURE__ */ new WeakSet();
|
|
7660
|
+
setAutoColumnWidths({});
|
|
7661
|
+
}, [dataSource, baseColumns, size, autoWidthSignature]);
|
|
7520
7662
|
useEffect12(() => {
|
|
7521
7663
|
const autoWidthColumns = leafColumns.filter((column) => column.autoWidth && resizedWidths[column.key] === void 0);
|
|
7522
7664
|
const root = rootRef.current;
|
|
7523
7665
|
if (!root || autoWidthColumns.length === 0) return;
|
|
7524
7666
|
const frame = window.requestAnimationFrame(() => {
|
|
7525
7667
|
const measurements = {};
|
|
7526
|
-
const
|
|
7668
|
+
const columnsByKey = new Map(autoWidthColumns.map((column) => [column.key, column]));
|
|
7669
|
+
const cells = [...root.querySelectorAll("th[data-column-key], td[data-column-key]")].filter((cell) => columnsByKey.has(cell.dataset.columnKey) && !measuredCells.current.has(cell));
|
|
7670
|
+
if (cells.length === 0) return;
|
|
7671
|
+
const prepared = cells.map((cell) => ({ cell, node: prepareTableCellMeasurement(cell) }));
|
|
7672
|
+
for (const { cell, node } of prepared) {
|
|
7673
|
+
const key = cell.dataset.columnKey;
|
|
7674
|
+
const style2 = window.getComputedStyle(cell);
|
|
7675
|
+
const padding = (Number.parseFloat(style2.paddingLeft) || 0) + (Number.parseFloat(style2.paddingRight) || 0) + (Number.parseFloat(style2.borderLeftWidth) || 0) + (Number.parseFloat(style2.borderRightWidth) || 0);
|
|
7676
|
+
measurements[key] = Math.max(measurements[key] ?? 0, node ? Math.max(node.scrollWidth, node.getBoundingClientRect().width) + padding : cell.scrollWidth);
|
|
7677
|
+
measuredCells.current.add(cell);
|
|
7678
|
+
}
|
|
7679
|
+
prepared.forEach(({ node }) => node?.remove());
|
|
7527
7680
|
for (const column of autoWidthColumns) {
|
|
7528
|
-
|
|
7529
|
-
|
|
7530
|
-
if (cell.dataset.columnKey !== column.key) continue;
|
|
7531
|
-
width = Math.max(width, measureTableCellContentWidth(cell));
|
|
7532
|
-
}
|
|
7681
|
+
if (measurements[column.key] === void 0) continue;
|
|
7682
|
+
const width = Math.max(column.minWidth ?? 56, autoColumnWidths[column.key] ?? 0, measurements[column.key]);
|
|
7533
7683
|
measurements[column.key] = Math.ceil(Math.min(column.maxWidth ?? Number.POSITIVE_INFINITY, width));
|
|
7534
7684
|
}
|
|
7535
7685
|
setAutoColumnWidths((previous) => {
|
|
@@ -7578,29 +7728,54 @@ function TableInner(props, ref) {
|
|
|
7578
7728
|
}
|
|
7579
7729
|
const leftFixedEdgeKey = [...leafColumns].reverse().find((column) => normalizeFixed(column.fixed) === "left")?.key;
|
|
7580
7730
|
const rightFixedEdgeKey = leafColumns.find((column) => normalizeFixed(column.fixed) === "right")?.key;
|
|
7581
|
-
const
|
|
7731
|
+
const canvas = renderMode === "canvas" && !sortedPlugins.some((plugin) => plugin.disableVirtual);
|
|
7732
|
+
const shouldVirtualize = canvas || pipeline.rows.length > 100 || (virtual ?? pipeline.rows.length >= virtualThreshold) && !sortedPlugins.some((plugin) => plugin.disableVirtual);
|
|
7582
7733
|
const startIndex = shouldVirtualize ? Math.max(0, Math.floor(scrollTop / rowHeight) - overscan) : 0;
|
|
7583
7734
|
const visibleCount = shouldVirtualize ? Math.ceil(viewportHeight / rowHeight) + overscan * 2 : pipeline.rows.length;
|
|
7584
7735
|
const endIndex = shouldVirtualize ? Math.min(pipeline.rows.length, startIndex + visibleCount) : pipeline.rows.length;
|
|
7585
7736
|
const renderedRows = pipeline.rows.slice(startIndex, endIndex);
|
|
7737
|
+
const visibleColumns = /* @__PURE__ */ new Set();
|
|
7738
|
+
let columnLeft = 0;
|
|
7739
|
+
for (const column of leafColumns) {
|
|
7740
|
+
const width = columnWidths.get(column.key) ?? DEFAULT_WIDTH;
|
|
7741
|
+
if (normalizeFixed(column.fixed) || columnLeft + width >= scrollLeft && columnLeft <= scrollLeft + viewportWidth) visibleColumns.add(column.key);
|
|
7742
|
+
columnLeft += width;
|
|
7743
|
+
}
|
|
7586
7744
|
const topSpacer = shouldVirtualize ? startIndex * rowHeight : 0;
|
|
7587
7745
|
const bottomSpacer = shouldVirtualize ? Math.max(0, (pipeline.rows.length - endIndex) * rowHeight) : 0;
|
|
7746
|
+
const rowElements = useMemo9(() => /* @__PURE__ */ new Map(), [
|
|
7747
|
+
dataSource,
|
|
7748
|
+
baseColumns,
|
|
7749
|
+
sortedPlugins,
|
|
7750
|
+
pluginStates,
|
|
7751
|
+
autoColumnWidths,
|
|
7752
|
+
viewportWidth,
|
|
7753
|
+
rowHeight,
|
|
7754
|
+
striped,
|
|
7755
|
+
rowClassName,
|
|
7756
|
+
getRowKey,
|
|
7757
|
+
canvas,
|
|
7758
|
+
scrollLeft,
|
|
7759
|
+
onRowClick,
|
|
7760
|
+
onRowDoubleClick,
|
|
7761
|
+
onCellContextMenu
|
|
7762
|
+
]);
|
|
7588
7763
|
const toolbarStart = sortedPlugins.map((plugin) => {
|
|
7589
7764
|
const content = plugin.renderToolbarStart?.(getContext(plugin));
|
|
7590
|
-
return content ? /* @__PURE__ */
|
|
7765
|
+
return content ? /* @__PURE__ */ jsx23(Fragment8, { children: content }, `toolbar-start-${plugin.id}`) : null;
|
|
7591
7766
|
}).filter(Boolean);
|
|
7592
7767
|
const toolbarEnd = sortedPlugins.map((plugin) => {
|
|
7593
7768
|
const content = plugin.renderToolbarEnd?.(getContext(plugin));
|
|
7594
|
-
return content ? /* @__PURE__ */
|
|
7769
|
+
return content ? /* @__PURE__ */ jsx23(Fragment8, { children: content }, `toolbar-end-${plugin.id}`) : null;
|
|
7595
7770
|
}).filter(Boolean);
|
|
7596
7771
|
const summaries = sortedPlugins.flatMap((plugin) => plugin.renderSummary?.(getContext(plugin)) ?? []);
|
|
7597
7772
|
const footers = sortedPlugins.map((plugin) => {
|
|
7598
7773
|
const content = plugin.renderFooter?.(getContext(plugin));
|
|
7599
|
-
return content ? /* @__PURE__ */
|
|
7774
|
+
return content ? /* @__PURE__ */ jsx23(Fragment8, { children: content }, `footer-${plugin.id}`) : null;
|
|
7600
7775
|
}).filter(Boolean);
|
|
7601
7776
|
const overlays = sortedPlugins.map((plugin) => {
|
|
7602
7777
|
const content = plugin.renderOverlay?.(getContext(plugin));
|
|
7603
|
-
return content ? /* @__PURE__ */
|
|
7778
|
+
return content ? /* @__PURE__ */ jsx23(Fragment8, { children: content }, `overlay-${plugin.id}`) : null;
|
|
7604
7779
|
}).filter(Boolean);
|
|
7605
7780
|
const hasToolbar = toolbarStart.length > 0 || toolbarEnd.length > 0;
|
|
7606
7781
|
const effectiveHeight = height ?? tableHeight ?? (shouldVirtualize ? 420 : void 0);
|
|
@@ -7611,9 +7786,10 @@ function TableInner(props, ref) {
|
|
|
7611
7786
|
};
|
|
7612
7787
|
const handleScroll = useCallback2((event) => {
|
|
7613
7788
|
const element = event.currentTarget;
|
|
7614
|
-
if (shouldVirtualize) setScrollTop(element.scrollTop);
|
|
7789
|
+
if (shouldVirtualize) setScrollTop((previous) => Math.floor(previous / rowHeight) === Math.floor(element.scrollTop / rowHeight) ? previous : element.scrollTop);
|
|
7790
|
+
if (canvas) setScrollLeft(element.scrollLeft);
|
|
7615
7791
|
updateScrollMetrics();
|
|
7616
|
-
}, [shouldVirtualize, updateScrollMetrics]);
|
|
7792
|
+
}, [canvas, shouldVirtualize, rowHeight, updateScrollMetrics]);
|
|
7617
7793
|
const handleScrollbarPointerDown = useCallback2((axis, event, track = event.currentTarget) => {
|
|
7618
7794
|
const element = scrollRef.current;
|
|
7619
7795
|
const thumb = track.firstElementChild;
|
|
@@ -7697,8 +7873,8 @@ function TableInner(props, ref) {
|
|
|
7697
7873
|
function renderHeaderContent(column, content) {
|
|
7698
7874
|
const title = getHeaderTitleText(column.title ?? column.name) || column.name || column.key;
|
|
7699
7875
|
return /* @__PURE__ */ jsxs21("span", { className: "sia-table__header-label", children: [
|
|
7700
|
-
/* @__PURE__ */
|
|
7701
|
-
column.description != null && /* @__PURE__ */
|
|
7876
|
+
/* @__PURE__ */ jsx23("span", { className: "sia-table__header-label-content", ...withTitleTooltip({ title }), children: content }),
|
|
7877
|
+
column.description != null && /* @__PURE__ */ jsx23(Tooltip, { title: column.description, placement: "top", trigger: ["hover", "focus"], children: /* @__PURE__ */ jsx23("button", { type: "button", className: "sia-table__header-description", "aria-label": `${column.name ?? column.key}\u5217\u8BF4\u660E`, onClick: (event) => event.stopPropagation(), children: /* @__PURE__ */ jsx23(Icon, { name: "info", size: 14 }) }) })
|
|
7702
7878
|
] });
|
|
7703
7879
|
}
|
|
7704
7880
|
function getPluginCellProps(row, column) {
|
|
@@ -7738,14 +7914,14 @@ function TableInner(props, ref) {
|
|
|
7738
7914
|
}
|
|
7739
7915
|
function renderSummaryRow(summary) {
|
|
7740
7916
|
let labelRendered = false;
|
|
7741
|
-
return /* @__PURE__ */
|
|
7917
|
+
return /* @__PURE__ */ jsx23("tr", { className: `sia-table__summary-row ${summary.className ?? ""}`.trim(), children: leafColumns.map((column) => {
|
|
7742
7918
|
const value = summary.values[column.key];
|
|
7743
7919
|
const isLabel = value === void 0 && !labelRendered && summary.label !== void 0;
|
|
7744
7920
|
const content = value !== void 0 ? value : isLabel ? (labelRendered = true, summary.label) : null;
|
|
7745
7921
|
const fixed = normalizeFixed(column.fixed);
|
|
7746
7922
|
const fixedEdgeClass = fixed === "left" && column.key === leftFixedEdgeKey ? " sia-table__cell--fixed-left-edge" : fixed === "right" && column.key === rightFixedEdgeKey ? " sia-table__cell--fixed-right-edge" : "";
|
|
7747
7923
|
const autoWidthClass = column.autoWidth ? " sia-table__cell--auto-width" : "";
|
|
7748
|
-
return /* @__PURE__ */
|
|
7924
|
+
return /* @__PURE__ */ jsx23("td", { "data-column-key": column.key, className: `sia-table__cell sia-table__cell--${column.align ?? "left"} sia-table__summary-cell${isLabel ? " sia-table__summary-cell--label" : ""}${fixed ? ` sia-table__cell--fixed sia-table__cell--fixed-${fixed}` : ""}${fixedEdgeClass}${autoWidthClass}`, style: getFixedStyle(column), children: isLabel ? /* @__PURE__ */ jsx23("span", { className: "sia-table__summary-label", children: content }) : content }, column.key);
|
|
7749
7925
|
}) }, summary.key);
|
|
7750
7926
|
}
|
|
7751
7927
|
return /* @__PURE__ */ jsxs21(
|
|
@@ -7755,6 +7931,7 @@ function TableInner(props, ref) {
|
|
|
7755
7931
|
className: `sia-table sia-table--${size}${bordered ? " sia-table--bordered" : ""}${!rowBordered ? " sia-table--no-row-borders" : ""}${!columnBordered ? " sia-table--no-column-borders" : ""}${hasToolbar && !toolbarBordered ? " sia-table--borderless-toolbar" : ""} ${className}`.trim(),
|
|
7756
7932
|
style: rootStyle,
|
|
7757
7933
|
"data-has-fixed-left": left > 0,
|
|
7934
|
+
"data-render-mode": canvas ? "canvas" : "dom",
|
|
7758
7935
|
"data-has-fixed-right": right > 0,
|
|
7759
7936
|
"data-scrolled-left": "false",
|
|
7760
7937
|
"data-scrolled-right": "true",
|
|
@@ -7799,18 +7976,18 @@ function TableInner(props, ref) {
|
|
|
7799
7976
|
},
|
|
7800
7977
|
children: [
|
|
7801
7978
|
hasToolbar ? /* @__PURE__ */ jsxs21("div", { className: "sia-table__toolbar", children: [
|
|
7802
|
-
/* @__PURE__ */
|
|
7803
|
-
/* @__PURE__ */
|
|
7979
|
+
/* @__PURE__ */ jsx23("div", { children: toolbarStart }),
|
|
7980
|
+
/* @__PURE__ */ jsx23("div", { children: toolbarEnd })
|
|
7804
7981
|
] }) : null,
|
|
7805
7982
|
/* @__PURE__ */ jsxs21("div", { className: "sia-table__viewport-wrap", children: [
|
|
7806
|
-
/* @__PURE__ */
|
|
7807
|
-
/* @__PURE__ */
|
|
7808
|
-
/* @__PURE__ */
|
|
7983
|
+
/* @__PURE__ */ jsx23("div", { className: "sia-table__viewport", ref: scrollRef, onScroll: handleScroll, children: /* @__PURE__ */ jsxs21("table", { ref: tableRef, className: "sia-table__element", style: { width: Math.max(totalWidth, 1), ...manualColumnLayout ? { minWidth: 0 } : {}, ...tableStyle }, children: [
|
|
7984
|
+
/* @__PURE__ */ jsx23("colgroup", { children: leafColumns.map((column) => /* @__PURE__ */ jsx23("col", { "data-column-key": column.key, style: { width: columnWidths.get(column.key) ?? DEFAULT_WIDTH } }, column.key)) }),
|
|
7985
|
+
/* @__PURE__ */ jsx23("thead", { className: stickyHeader ? "sia-table__head sia-table__head--sticky" : "sia-table__head", children: headerRows.map((headerRow, depth) => /* @__PURE__ */ jsx23("tr", { children: headerRow.map((cell) => {
|
|
7809
7986
|
const fixed = cell.fixed;
|
|
7810
7987
|
const pluginHeaderProps = getPluginHeaderCellProps(cell.column);
|
|
7811
7988
|
const fixedEdgeClass = fixed === "left" && cell.column.key === leftFixedEdgeKey ? " sia-table__cell--fixed-left-edge" : fixed === "right" && cell.column.key === rightFixedEdgeKey ? " sia-table__cell--fixed-right-edge" : "";
|
|
7812
7989
|
const autoWidthClass = cell.column.autoWidth ? " sia-table__cell--auto-width" : "";
|
|
7813
|
-
return /* @__PURE__ */
|
|
7990
|
+
return /* @__PURE__ */ jsx23(
|
|
7814
7991
|
"th",
|
|
7815
7992
|
{
|
|
7816
7993
|
"data-column-key": cell.column.key,
|
|
@@ -7832,14 +8009,18 @@ function TableInner(props, ref) {
|
|
|
7832
8009
|
);
|
|
7833
8010
|
}) }, depth)) }),
|
|
7834
8011
|
/* @__PURE__ */ jsxs21("tbody", { children: [
|
|
7835
|
-
topSpacer > 0 ? /* @__PURE__ */
|
|
8012
|
+
topSpacer > 0 ? /* @__PURE__ */ jsx23("tr", { "aria-hidden": "true", children: /* @__PURE__ */ jsx23("td", { colSpan: leafColumns.length, style: { height: topSpacer, padding: 0, border: 0 } }) }) : null,
|
|
7836
8013
|
renderedRows.map((row, offset) => {
|
|
8014
|
+
const cached = rowElements.get(row.key);
|
|
8015
|
+
if (cached) return cached;
|
|
7837
8016
|
const rowIndex = startIndex + offset;
|
|
7838
8017
|
const pluginClasses = sortedPlugins.map((plugin) => plugin.getRowClassName?.(row, getContext(plugin))).filter(Boolean).join(" ");
|
|
7839
8018
|
const customClass = typeof rowClassName === "function" ? rowClassName(row.record, row.sourceIndex) : rowClassName ?? "";
|
|
7840
|
-
|
|
8019
|
+
const element = /* @__PURE__ */ jsx23(
|
|
7841
8020
|
TableBodyRow,
|
|
7842
8021
|
{
|
|
8022
|
+
canvas,
|
|
8023
|
+
visibleColumns,
|
|
7843
8024
|
row,
|
|
7844
8025
|
rowIndex,
|
|
7845
8026
|
columns: leafColumns,
|
|
@@ -7883,13 +8064,16 @@ function TableInner(props, ref) {
|
|
|
7883
8064
|
},
|
|
7884
8065
|
row.key
|
|
7885
8066
|
);
|
|
8067
|
+
rowElements.set(row.key, element);
|
|
8068
|
+
return element;
|
|
7886
8069
|
}),
|
|
7887
|
-
bottomSpacer > 0 ? /* @__PURE__ */
|
|
8070
|
+
bottomSpacer > 0 ? /* @__PURE__ */ jsx23("tr", { "aria-hidden": "true", children: /* @__PURE__ */ jsx23("td", { colSpan: leafColumns.length, style: { height: bottomSpacer, padding: 0, border: 0 } }) }) : null
|
|
7888
8071
|
] }),
|
|
7889
|
-
summaries.length > 0 ? /* @__PURE__ */
|
|
8072
|
+
summaries.length > 0 ? /* @__PURE__ */ jsx23("tfoot", { className: "sia-table__summary", children: summaries.map(renderSummaryRow) }) : null
|
|
7890
8073
|
] }) }),
|
|
7891
|
-
pipeline.rows.length === 0 ? /* @__PURE__ */
|
|
7892
|
-
/* @__PURE__ */
|
|
8074
|
+
pipeline.rows.length === 0 ? /* @__PURE__ */ jsx23("div", { className: "sia-table__empty", role: "status", children: emptyText }) : null,
|
|
8075
|
+
canvas ? /* @__PURE__ */ jsx23(TableCanvasLayer, { viewport: scrollRef, rows: pipeline.rows, columns: leafColumns, widths: columnWidths, rowHeight, headerHeight: headerRows.length * rowHeight }) : null,
|
|
8076
|
+
/* @__PURE__ */ jsx23(
|
|
7893
8077
|
"div",
|
|
7894
8078
|
{
|
|
7895
8079
|
className: "sia-scrollbar-track sia-table__scrollbar sia-table__scrollbar--horizontal",
|
|
@@ -7900,10 +8084,10 @@ function TableInner(props, ref) {
|
|
|
7900
8084
|
onPointerMove: handleScrollbarPointerMove,
|
|
7901
8085
|
onPointerUp: handleScrollbarPointerEnd,
|
|
7902
8086
|
onPointerCancel: handleScrollbarPointerEnd,
|
|
7903
|
-
children: /* @__PURE__ */
|
|
8087
|
+
children: /* @__PURE__ */ jsx23("div", { className: "sia-table__scrollbar-thumb" })
|
|
7904
8088
|
}
|
|
7905
8089
|
),
|
|
7906
|
-
/* @__PURE__ */
|
|
8090
|
+
/* @__PURE__ */ jsx23(
|
|
7907
8091
|
"div",
|
|
7908
8092
|
{
|
|
7909
8093
|
className: "sia-scrollbar-track sia-table__scrollbar sia-table__scrollbar--vertical",
|
|
@@ -7914,14 +8098,14 @@ function TableInner(props, ref) {
|
|
|
7914
8098
|
onPointerMove: handleScrollbarPointerMove,
|
|
7915
8099
|
onPointerUp: handleScrollbarPointerEnd,
|
|
7916
8100
|
onPointerCancel: handleScrollbarPointerEnd,
|
|
7917
|
-
children: /* @__PURE__ */
|
|
8101
|
+
children: /* @__PURE__ */ jsx23("div", { className: "sia-table__scrollbar-thumb" })
|
|
7918
8102
|
}
|
|
7919
8103
|
)
|
|
7920
8104
|
] }),
|
|
7921
|
-
footers.length > 0 ? /* @__PURE__ */
|
|
8105
|
+
footers.length > 0 ? /* @__PURE__ */ jsx23("div", { className: "sia-table__footer", children: footers }) : null,
|
|
7922
8106
|
loading || internalLoading ? /* @__PURE__ */ jsxs21("div", { className: "sia-table__loading", role: "status", children: [
|
|
7923
|
-
/* @__PURE__ */
|
|
7924
|
-
/* @__PURE__ */
|
|
8107
|
+
/* @__PURE__ */ jsx23(Icon, { name: "loader", size: 22, spin: true }),
|
|
8108
|
+
/* @__PURE__ */ jsx23("span", { children: "\u52A0\u8F7D\u4E2D" })
|
|
7925
8109
|
] }) : null,
|
|
7926
8110
|
overlays
|
|
7927
8111
|
]
|
|
@@ -7932,7 +8116,7 @@ var Table = forwardRef5(TableInner);
|
|
|
7932
8116
|
|
|
7933
8117
|
// src/components/ThemeSwitch.tsx
|
|
7934
8118
|
import { forwardRef as forwardRef6 } from "react";
|
|
7935
|
-
import { jsx as
|
|
8119
|
+
import { jsx as jsx24, jsxs as jsxs22 } from "react/jsx-runtime";
|
|
7936
8120
|
var ThemeSwitch = forwardRef6(function ThemeSwitch2({
|
|
7937
8121
|
checked,
|
|
7938
8122
|
onCheckedChange,
|
|
@@ -7958,12 +8142,12 @@ var ThemeSwitch = forwardRef6(function ThemeSwitch2({
|
|
|
7958
8142
|
onClick: handleClick,
|
|
7959
8143
|
...withTitleTooltip(props),
|
|
7960
8144
|
children: [
|
|
7961
|
-
/* @__PURE__ */
|
|
7962
|
-
/* @__PURE__ */
|
|
7963
|
-
/* @__PURE__ */
|
|
7964
|
-
/* @__PURE__ */
|
|
8145
|
+
/* @__PURE__ */ jsx24("span", { className: "sia-theme-switch__selection", "aria-hidden": "true" }),
|
|
8146
|
+
/* @__PURE__ */ jsx24("span", { className: `sia-theme-switch__icon${checked ? "" : " is-active"}`, "aria-hidden": "true", children: /* @__PURE__ */ jsxs22("svg", { viewBox: "0 0 24 24", children: [
|
|
8147
|
+
/* @__PURE__ */ jsx24("circle", { cx: "12", cy: "12", r: "3.5" }),
|
|
8148
|
+
/* @__PURE__ */ jsx24("path", { d: "M12 2.5v2M12 19.5v2M2.5 12h2M19.5 12h2M5.3 5.3l1.4 1.4M17.3 17.3l1.4 1.4M18.7 5.3l-1.4 1.4M6.7 17.3l-1.4 1.4" })
|
|
7965
8149
|
] }) }),
|
|
7966
|
-
/* @__PURE__ */
|
|
8150
|
+
/* @__PURE__ */ jsx24("span", { className: `sia-theme-switch__icon${checked ? " is-active" : ""}`, "aria-hidden": "true", children: /* @__PURE__ */ jsx24("svg", { viewBox: "0 0 24 24", children: /* @__PURE__ */ jsx24("path", { d: "M20 15.2A8 8 0 0 1 8.8 4 8.5 8.5 0 1 0 20 15.2Z" }) }) })
|
|
7967
8151
|
]
|
|
7968
8152
|
}
|
|
7969
8153
|
);
|
|
@@ -8006,8 +8190,8 @@ function applySiaTheme(mode, target = document.documentElement) {
|
|
|
8006
8190
|
}
|
|
8007
8191
|
|
|
8008
8192
|
// src/components/InputSelect.tsx
|
|
8009
|
-
import { forwardRef as forwardRef7, useEffect as useEffect13, useRef as
|
|
8010
|
-
import { jsx as
|
|
8193
|
+
import { forwardRef as forwardRef7, useEffect as useEffect13, useRef as useRef17, useState as useState19 } from "react";
|
|
8194
|
+
import { jsx as jsx25, jsxs as jsxs23 } from "react/jsx-runtime";
|
|
8011
8195
|
var InputSelect = forwardRef7(function InputSelect2({
|
|
8012
8196
|
options,
|
|
8013
8197
|
value,
|
|
@@ -8047,9 +8231,9 @@ var InputSelect = forwardRef7(function InputSelect2({
|
|
|
8047
8231
|
const [modalOpen, setModalOpen] = useState19(false);
|
|
8048
8232
|
const [modalValues, setModalValues] = useState19([]);
|
|
8049
8233
|
const [selectedOnly, setSelectedOnly] = useState19(false);
|
|
8050
|
-
const rootRef =
|
|
8051
|
-
const popupRef =
|
|
8052
|
-
const inputRef =
|
|
8234
|
+
const rootRef = useRef17(null);
|
|
8235
|
+
const popupRef = useRef17(null);
|
|
8236
|
+
const inputRef = useRef17(null);
|
|
8053
8237
|
const config = typeof enableModal === "object" ? enableModal : {};
|
|
8054
8238
|
function changeOpen(next) {
|
|
8055
8239
|
if (next && (disabled || loading)) return;
|
|
@@ -8097,7 +8281,7 @@ var InputSelect = forwardRef7(function InputSelect2({
|
|
|
8097
8281
|
inputRef.current?.focus();
|
|
8098
8282
|
}
|
|
8099
8283
|
}, children: [
|
|
8100
|
-
/* @__PURE__ */
|
|
8284
|
+
/* @__PURE__ */ jsx25(
|
|
8101
8285
|
Input,
|
|
8102
8286
|
{
|
|
8103
8287
|
...inputProps,
|
|
@@ -8135,25 +8319,25 @@ var InputSelect = forwardRef7(function InputSelect2({
|
|
|
8135
8319
|
changeOpen(true);
|
|
8136
8320
|
},
|
|
8137
8321
|
suffix: /* @__PURE__ */ jsxs23("span", { className: "sia-input-select__suffix", children: [
|
|
8138
|
-
allowClear && draft && !disabled && /* @__PURE__ */
|
|
8322
|
+
allowClear && draft && !disabled && /* @__PURE__ */ jsx25(Button, { variant: "text", size: "small", disabled: loading, "aria-label": "\u6E05\u9664\u8F93\u5165\u9009\u62E9", onClick: (event) => {
|
|
8139
8323
|
event.stopPropagation();
|
|
8140
8324
|
setDraft("");
|
|
8141
8325
|
emit(multiple ? [] : void 0);
|
|
8142
8326
|
inputRef.current?.focus();
|
|
8143
8327
|
}, children: "\xD7" }),
|
|
8144
8328
|
suffix,
|
|
8145
|
-
enableModal && /* @__PURE__ */
|
|
8329
|
+
enableModal && /* @__PURE__ */ jsx25(Button, { variant: "text", size: "small", disabled: disabled || loading, "aria-label": "\u6253\u5F00\u9009\u62E9\u5F39\u7A97", onClick: (event) => {
|
|
8146
8330
|
event.stopPropagation();
|
|
8147
8331
|
openModal();
|
|
8148
8332
|
}, children: "\u2026" }),
|
|
8149
|
-
/* @__PURE__ */
|
|
8333
|
+
/* @__PURE__ */ jsx25(Button, { variant: "text", size: "small", disabled: disabled || loading, "aria-label": "\u5C55\u5F00\u9009\u9879", onClick: (event) => {
|
|
8150
8334
|
event.stopPropagation();
|
|
8151
8335
|
changeOpen(!open);
|
|
8152
|
-
}, children: /* @__PURE__ */
|
|
8336
|
+
}, children: /* @__PURE__ */ jsx25(Icon, { name: loading ? "refresh" : open ? "chevron-up" : "chevron-down", size: 13 }) })
|
|
8153
8337
|
] })
|
|
8154
8338
|
}
|
|
8155
8339
|
),
|
|
8156
|
-
/* @__PURE__ */
|
|
8340
|
+
/* @__PURE__ */ jsx25(PopupPortal, { ref: popupRef, anchorRef: rootRef, open: open && !disabled && !loading, className: "sia-input-select__popup", children: /* @__PURE__ */ jsx25(
|
|
8157
8341
|
SelectionPanel,
|
|
8158
8342
|
{
|
|
8159
8343
|
options,
|
|
@@ -8182,14 +8366,14 @@ var InputSelect = forwardRef7(function InputSelect2({
|
|
|
8182
8366
|
},
|
|
8183
8367
|
children: [
|
|
8184
8368
|
/* @__PURE__ */ jsxs23("div", { className: "sia-selection-panel__actions", role: "tablist", "aria-label": "\u9009\u9879\u8303\u56F4", children: [
|
|
8185
|
-
/* @__PURE__ */
|
|
8369
|
+
/* @__PURE__ */ jsx25(Button, { role: "tab", "aria-selected": !selectedOnly, variant: !selectedOnly ? "primary" : "text", onClick: () => setSelectedOnly(false), children: "\u5168\u90E8" }),
|
|
8186
8370
|
/* @__PURE__ */ jsxs23(Button, { role: "tab", "aria-selected": selectedOnly, variant: selectedOnly ? "primary" : "text", onClick: () => setSelectedOnly(true), children: [
|
|
8187
8371
|
"\u5DF2\u9009\u9879(",
|
|
8188
8372
|
modalValues.length,
|
|
8189
8373
|
")"
|
|
8190
8374
|
] })
|
|
8191
8375
|
] }),
|
|
8192
|
-
modalOpen && /* @__PURE__ */
|
|
8376
|
+
modalOpen && /* @__PURE__ */ jsx25(
|
|
8193
8377
|
SelectionPanel,
|
|
8194
8378
|
{
|
|
8195
8379
|
options,
|
|
@@ -8210,8 +8394,8 @@ var InputSelect = forwardRef7(function InputSelect2({
|
|
|
8210
8394
|
});
|
|
8211
8395
|
|
|
8212
8396
|
// src/components/QueryForm.tsx
|
|
8213
|
-
import { Children as Children4, useLayoutEffect as
|
|
8214
|
-
import { jsx as
|
|
8397
|
+
import { Children as Children4, useLayoutEffect as useLayoutEffect4, useRef as useRef18, useState as useState20 } from "react";
|
|
8398
|
+
import { jsx as jsx26, jsxs as jsxs24 } from "react/jsx-runtime";
|
|
8215
8399
|
function QueryForm({
|
|
8216
8400
|
fields,
|
|
8217
8401
|
children,
|
|
@@ -8254,19 +8438,19 @@ function QueryForm({
|
|
|
8254
8438
|
const [saveError, setSaveError] = useState20("");
|
|
8255
8439
|
const [error, setError] = useState20("");
|
|
8256
8440
|
const [activeShortcut, setActiveShortcut] = useState20("");
|
|
8257
|
-
const source =
|
|
8258
|
-
const searchLock =
|
|
8259
|
-
const saveLock =
|
|
8260
|
-
const removeLock =
|
|
8261
|
-
const snapshot =
|
|
8441
|
+
const source = useRef18({ source: "submit" });
|
|
8442
|
+
const searchLock = useRef18(false);
|
|
8443
|
+
const saveLock = useRef18(false);
|
|
8444
|
+
const removeLock = useRef18(false);
|
|
8445
|
+
const snapshot = useRef18();
|
|
8262
8446
|
const busy = disabled || loading || searching;
|
|
8263
8447
|
const shortcutBusy = busy || shortcutsLoading || saving || removing;
|
|
8264
|
-
const entries = fields ? fields.map(({ key, width, ...item }) => ({ key, width, content: /* @__PURE__ */
|
|
8448
|
+
const entries = fields ? fields.map(({ key, width, ...item }) => ({ key, width, content: /* @__PURE__ */ jsx26(Form.Item, { noStyle: true, ...item }) })) : Children4.toArray(children).map((content, index) => ({ key: String(index), width: void 0, content }));
|
|
8265
8449
|
const limit = Math.max(1, Math.floor(collapsedCount));
|
|
8266
|
-
const rowRef =
|
|
8267
|
-
const actionsRef =
|
|
8450
|
+
const rowRef = useRef18(null);
|
|
8451
|
+
const actionsRef = useRef18(null);
|
|
8268
8452
|
const [fittingCount, setFittingCount] = useState20(limit);
|
|
8269
|
-
|
|
8453
|
+
useLayoutEffect4(() => {
|
|
8270
8454
|
if (!collapsed) return;
|
|
8271
8455
|
const row = rowRef.current;
|
|
8272
8456
|
const actions = actionsRef.current;
|
|
@@ -8386,7 +8570,7 @@ function QueryForm({
|
|
|
8386
8570
|
},
|
|
8387
8571
|
children: [
|
|
8388
8572
|
quickQueries.length ? /* @__PURE__ */ jsxs24("div", { className: "sia-query-form__quick", "aria-label": "\u9884\u8BBE\u5FEB\u6377\u67E5\u8BE2", children: [
|
|
8389
|
-
quickQueries.map((query) => /* @__PURE__ */
|
|
8573
|
+
quickQueries.map((query) => /* @__PURE__ */ jsx26(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__ */ jsx26(
|
|
8390
8574
|
Button,
|
|
8391
8575
|
{
|
|
8392
8576
|
size: query.size ?? quickQuerySize,
|
|
@@ -8400,7 +8584,7 @@ function QueryForm({
|
|
|
8400
8584
|
" "
|
|
8401
8585
|
] }) : null,
|
|
8402
8586
|
/* @__PURE__ */ jsxs24("div", { ref: rowRef, className: `sia-query-form__fields${collapsed ? " is-collapsed" : ""}`, style: { "--sia-query-field-width": typeof fieldWidth === "number" ? `${fieldWidth}px` : fieldWidth }, children: [
|
|
8403
|
-
entries.map((entry, index) => /* @__PURE__ */
|
|
8587
|
+
entries.map((entry, index) => /* @__PURE__ */ jsx26(
|
|
8404
8588
|
"div",
|
|
8405
8589
|
{
|
|
8406
8590
|
className: "sia-query-form__field",
|
|
@@ -8412,21 +8596,21 @@ function QueryForm({
|
|
|
8412
8596
|
)),
|
|
8413
8597
|
/* @__PURE__ */ jsxs24("div", { ref: actionsRef, className: "sia-query-form__actions", children: [
|
|
8414
8598
|
/* @__PURE__ */ jsxs24(Space.Compact, { children: [
|
|
8415
|
-
/* @__PURE__ */
|
|
8416
|
-
/* @__PURE__ */
|
|
8417
|
-
onSaveQuery ? /* @__PURE__ */
|
|
8599
|
+
/* @__PURE__ */ jsx26(Button, { type: "submit", variant: "primary", loading: loading || searching, disabled, children: searchText }),
|
|
8600
|
+
/* @__PURE__ */ jsx26(Button, { disabled: busy, onClick: reset, children: resetText }),
|
|
8601
|
+
onSaveQuery ? /* @__PURE__ */ jsx26(Button, { disabled: shortcutBusy, onClick: () => {
|
|
8418
8602
|
snapshot.current = form.getFieldsValue();
|
|
8419
8603
|
setSaveName("");
|
|
8420
8604
|
setSaveError("");
|
|
8421
8605
|
setSaveOpen(true);
|
|
8422
8606
|
}, children: saveText }) : null
|
|
8423
8607
|
] }),
|
|
8424
|
-
collapsible && entries.length > 0 ? /* @__PURE__ */
|
|
8608
|
+
collapsible && entries.length > 0 ? /* @__PURE__ */ jsx26(
|
|
8425
8609
|
Button,
|
|
8426
8610
|
{
|
|
8427
8611
|
variant: "link",
|
|
8428
8612
|
"aria-expanded": !collapsed,
|
|
8429
|
-
icon: /* @__PURE__ */
|
|
8613
|
+
icon: /* @__PURE__ */ jsx26(Icon, { name: collapsed ? "chevron-down" : "chevron-up" }),
|
|
8430
8614
|
iconPosition: "end",
|
|
8431
8615
|
onClick: () => {
|
|
8432
8616
|
setInternalCollapsed(!collapsed);
|
|
@@ -8439,7 +8623,7 @@ function QueryForm({
|
|
|
8439
8623
|
] })
|
|
8440
8624
|
] }),
|
|
8441
8625
|
savedQueries.length && !collapsed ? /* @__PURE__ */ jsxs24("div", { className: "sia-query-form__saved", "aria-label": "\u5DF2\u4FDD\u5B58\u5FEB\u6377\u67E5\u8BE2", children: [
|
|
8442
|
-
savedQueries.map((query, index) => /* @__PURE__ */
|
|
8626
|
+
savedQueries.map((query, index) => /* @__PURE__ */ jsx26(
|
|
8443
8627
|
Tag,
|
|
8444
8628
|
{
|
|
8445
8629
|
status: query.status ?? ["processing", "success", "warning", "error"][index % 4],
|
|
@@ -8465,14 +8649,14 @@ function QueryForm({
|
|
|
8465
8649
|
)),
|
|
8466
8650
|
" "
|
|
8467
8651
|
] }) : null,
|
|
8468
|
-
error ? /* @__PURE__ */
|
|
8652
|
+
error ? /* @__PURE__ */ jsx26("p", { className: "sia-query-form__error", role: "alert", children: error }) : null
|
|
8469
8653
|
]
|
|
8470
8654
|
}
|
|
8471
8655
|
),
|
|
8472
8656
|
/* @__PURE__ */ jsxs24(Modal, { open: saveOpen, title: "\u53E6\u5B58\u4E3A\u5FEB\u6377\u67E5\u8BE2", width: 420, confirmLoading: saving, onOk: save, onOpenChange: (next) => {
|
|
8473
8657
|
if (!saveLock.current) setSaveOpen(next);
|
|
8474
8658
|
}, children: [
|
|
8475
|
-
/* @__PURE__ */
|
|
8659
|
+
/* @__PURE__ */ jsx26(
|
|
8476
8660
|
Input,
|
|
8477
8661
|
{
|
|
8478
8662
|
autoFocus: true,
|
|
@@ -8491,7 +8675,7 @@ function QueryForm({
|
|
|
8491
8675
|
}
|
|
8492
8676
|
}
|
|
8493
8677
|
),
|
|
8494
|
-
saveError ? /* @__PURE__ */
|
|
8678
|
+
saveError ? /* @__PURE__ */ jsx26("p", { className: "sia-query-form__error", role: "alert", children: saveError }) : null
|
|
8495
8679
|
] })
|
|
8496
8680
|
] });
|
|
8497
8681
|
}
|