@sia.soul/sia-react-ui 0.1.13 → 0.1.15
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/chart.cjs +21 -13
- package/dist/chart.js +4 -4
- package/dist/{chunk-RLTG3IK7.js → chunk-25BU7YTB.js} +21 -11
- package/dist/{chunk-EJDPRAU2.js → chunk-3VJ4CZDQ.js} +7 -0
- package/dist/{chunk-JJVD2ITI.js → chunk-ALWHRV4L.js} +7 -4
- package/dist/{chunk-MOOMDRAN.js → chunk-E7F47Z2C.js} +11 -8
- package/dist/{chunk-F3VH6LJH.js → chunk-MUTJVDM6.js} +3 -3
- package/dist/{chunk-Z3T6RDQP.js → chunk-OKP4DIQH.js} +2 -2
- package/dist/{chunk-5ZTWY3PG.js → chunk-QJ4OQNQ4.js} +3 -3
- package/dist/{chunk-BUMS62NO.js → chunk-R3TYVU53.js} +14 -8
- package/dist/{chunk-MBS2HXLZ.js → chunk-TZGUBGA4.js} +6 -1
- package/dist/{chunk-WHARTF2I.js → chunk-YT6E3X2K.js} +5 -2
- package/dist/{core-y0w5PBO2.d.cts → core-AeKYVPDZ.d.cts} +7 -4
- package/dist/{core-VmiEI1Jp.d.ts → core-DcSXqSRs.d.ts} +7 -4
- package/dist/core.cjs +56 -41
- package/dist/core.css +467 -40
- package/dist/core.d.cts +1 -1
- package/dist/core.d.ts +1 -1
- package/dist/core.js +6 -6
- package/dist/index.cjs +512 -112
- package/dist/index.css +467 -40
- package/dist/index.d.cts +77 -15
- package/dist/index.d.ts +77 -15
- package/dist/index.js +452 -76
- package/dist/markdown-editor.cjs +3 -2
- package/dist/markdown-editor.js +2 -2
- package/dist/rich-text-editor.cjs +9 -2
- package/dist/rich-text-editor.js +4 -4
- package/dist/{select-date-range-D-JMfpwD.d.ts → select-date-range-Bdb-hi9c.d.ts} +3 -3
- package/dist/{select-date-range-l-xgB959.d.cts → select-date-range-shDQ5uJA.d.cts} +3 -3
- package/dist/select-date-range.cjs +35 -15
- package/dist/select-date-range.d.cts +1 -1
- package/dist/select-date-range.d.ts +1 -1
- package/dist/select-date-range.js +5 -5
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -56,7 +56,7 @@ import {
|
|
|
56
56
|
smoothSvgPath,
|
|
57
57
|
svgArcPath,
|
|
58
58
|
transferCompositeValue
|
|
59
|
-
} from "./chunk-
|
|
59
|
+
} from "./chunk-OKP4DIQH.js";
|
|
60
60
|
import {
|
|
61
61
|
Badge,
|
|
62
62
|
Breadcrumb,
|
|
@@ -79,22 +79,22 @@ import {
|
|
|
79
79
|
Watermark,
|
|
80
80
|
message,
|
|
81
81
|
notification
|
|
82
|
-
} from "./chunk-
|
|
82
|
+
} from "./chunk-E7F47Z2C.js";
|
|
83
83
|
import {
|
|
84
84
|
TextArea
|
|
85
|
-
} from "./chunk-
|
|
85
|
+
} from "./chunk-YT6E3X2K.js";
|
|
86
86
|
import {
|
|
87
87
|
MarkdownEditor
|
|
88
|
-
} from "./chunk-
|
|
88
|
+
} from "./chunk-QJ4OQNQ4.js";
|
|
89
89
|
import {
|
|
90
90
|
RichTextContent,
|
|
91
91
|
RichTextEditor
|
|
92
|
-
} from "./chunk-
|
|
92
|
+
} from "./chunk-MUTJVDM6.js";
|
|
93
93
|
import {
|
|
94
94
|
DatePicker,
|
|
95
95
|
SelectDateRange,
|
|
96
96
|
TimePanel
|
|
97
|
-
} from "./chunk-
|
|
97
|
+
} from "./chunk-25BU7YTB.js";
|
|
98
98
|
import {
|
|
99
99
|
Checkbox,
|
|
100
100
|
Modal,
|
|
@@ -107,7 +107,7 @@ import {
|
|
|
107
107
|
Tooltip,
|
|
108
108
|
Tree,
|
|
109
109
|
useOverlayLifecycle
|
|
110
|
-
} from "./chunk-
|
|
110
|
+
} from "./chunk-R3TYVU53.js";
|
|
111
111
|
import {
|
|
112
112
|
Dropdown,
|
|
113
113
|
FILLED_ICON_NAMES,
|
|
@@ -118,16 +118,18 @@ import {
|
|
|
118
118
|
PopupPortal,
|
|
119
119
|
Segmented,
|
|
120
120
|
Steps
|
|
121
|
-
} from "./chunk-
|
|
121
|
+
} from "./chunk-ALWHRV4L.js";
|
|
122
122
|
import {
|
|
123
123
|
Button
|
|
124
|
-
} from "./chunk-
|
|
124
|
+
} from "./chunk-TZGUBGA4.js";
|
|
125
125
|
import {
|
|
126
|
+
ControlSizeContext,
|
|
126
127
|
PlaceholderModeContext,
|
|
128
|
+
useControlSize,
|
|
127
129
|
useControllableState,
|
|
128
130
|
useFloatingPlaceholder,
|
|
129
131
|
usePlaceholderMode
|
|
130
|
-
} from "./chunk-
|
|
132
|
+
} from "./chunk-3VJ4CZDQ.js";
|
|
131
133
|
|
|
132
134
|
// src/components/Alert.tsx
|
|
133
135
|
import { useState } from "react";
|
|
@@ -177,6 +179,7 @@ import { useState as useState2 } from "react";
|
|
|
177
179
|
import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
178
180
|
var DEFAULT_PAGE_SIZE_OPTIONS = [10, 25, 50, 100, 200, 500, 1e3, 2e3, 5e3];
|
|
179
181
|
function Pagination({
|
|
182
|
+
size: sizeProp,
|
|
180
183
|
total = 0,
|
|
181
184
|
current,
|
|
182
185
|
defaultCurrent = 1,
|
|
@@ -194,6 +197,7 @@ function Pagination({
|
|
|
194
197
|
className = "",
|
|
195
198
|
...props
|
|
196
199
|
}) {
|
|
200
|
+
const controlSize = useControlSize(sizeProp);
|
|
197
201
|
const [size, setSize] = useControllableState({ value: pageSize, defaultValue: Math.max(1, defaultPageSize) });
|
|
198
202
|
const [page, setPage] = useControllableState({ value: current, defaultValue: Math.max(1, defaultCurrent) });
|
|
199
203
|
const [internalRefreshing, setInternalRefreshing] = useState2(false);
|
|
@@ -225,14 +229,14 @@ function Pagination({
|
|
|
225
229
|
if (refreshing === void 0) setInternalRefreshing(false);
|
|
226
230
|
}
|
|
227
231
|
}
|
|
228
|
-
return /* @__PURE__ */ jsxs2("nav", { className: `sia-pagination ${className}`.trim(), "aria-label": "\u5206\u9875", ...props, children: [
|
|
232
|
+
return /* @__PURE__ */ jsxs2("nav", { className: `sia-pagination sia-pagination--${controlSize} ${className}`.trim(), "aria-label": "\u5206\u9875", ...props, children: [
|
|
229
233
|
showSizeChanger ? /* @__PURE__ */ jsxs2("div", { className: "sia-pagination__size", children: [
|
|
230
234
|
/* @__PURE__ */ jsx2("span", { children: "\u6BCF\u9875\u663E\u793A" }),
|
|
231
235
|
/* @__PURE__ */ jsx2(
|
|
232
236
|
Select,
|
|
233
237
|
{
|
|
234
238
|
className: "sia-pagination__size-select",
|
|
235
|
-
size:
|
|
239
|
+
size: controlSize,
|
|
236
240
|
"aria-label": "\u6BCF\u9875\u6761\u6570",
|
|
237
241
|
value: size,
|
|
238
242
|
options: sizes.map((value) => ({ label: `${value} \u6761`, value })),
|
|
@@ -247,7 +251,7 @@ function Pagination({
|
|
|
247
251
|
Button,
|
|
248
252
|
{
|
|
249
253
|
variant: "text",
|
|
250
|
-
size:
|
|
254
|
+
size: controlSize,
|
|
251
255
|
className: "sia-pagination__total",
|
|
252
256
|
disabled: disabled || !onRefreshTotal || loading,
|
|
253
257
|
title: onRefreshTotal ? "\u70B9\u51FB\u5237\u65B0\u603B\u8BB0\u5F55\u6570" : void 0,
|
|
@@ -262,15 +266,15 @@ function Pagination({
|
|
|
262
266
|
}
|
|
263
267
|
) : null,
|
|
264
268
|
/* @__PURE__ */ jsxs2("div", { className: "sia-pagination__buttons", children: [
|
|
265
|
-
/* @__PURE__ */ jsx2(Button, { size:
|
|
266
|
-
/* @__PURE__ */ jsx2(Button, { size:
|
|
269
|
+
/* @__PURE__ */ jsx2(Button, { size: controlSize, variant: "text", "aria-label": "\u7B2C\u4E00\u9875", disabled: disabled || safePage <= 1, onClick: () => change(1), children: /* @__PURE__ */ jsx2(Icon, { name: "double-left", size: 15 }) }),
|
|
270
|
+
/* @__PURE__ */ jsx2(Button, { size: controlSize, variant: "text", "aria-label": "\u4E0A\u4E00\u9875", disabled: disabled || safePage <= 1, onClick: () => change(safePage - 1), children: /* @__PURE__ */ jsx2(Icon, { name: "chevron-left", size: 15 }) }),
|
|
267
271
|
/* @__PURE__ */ jsxs2("span", { "aria-live": "polite", children: [
|
|
268
272
|
safePage,
|
|
269
273
|
" / ",
|
|
270
274
|
totalPages
|
|
271
275
|
] }),
|
|
272
|
-
/* @__PURE__ */ jsx2(Button, { size:
|
|
273
|
-
/* @__PURE__ */ jsx2(Button, { size:
|
|
276
|
+
/* @__PURE__ */ jsx2(Button, { size: controlSize, variant: "text", "aria-label": "\u4E0B\u4E00\u9875", disabled: disabled || safePage >= totalPages, onClick: () => change(safePage + 1), children: /* @__PURE__ */ jsx2(Icon, { name: "chevron-right", size: 15 }) }),
|
|
277
|
+
/* @__PURE__ */ jsx2(Button, { size: controlSize, variant: "text", "aria-label": "\u6700\u540E\u4E00\u9875", disabled: disabled || safePage >= totalPages, onClick: () => change(totalPages), children: /* @__PURE__ */ jsx2(Icon, { name: "double-right", size: 15 }) })
|
|
274
278
|
] })
|
|
275
279
|
] });
|
|
276
280
|
}
|
|
@@ -315,6 +319,7 @@ function Cascader({
|
|
|
315
319
|
options,
|
|
316
320
|
value,
|
|
317
321
|
defaultValue,
|
|
322
|
+
size: sizeProp,
|
|
318
323
|
multiple = false,
|
|
319
324
|
showSearch = false,
|
|
320
325
|
allowClear = false,
|
|
@@ -330,6 +335,7 @@ function Cascader({
|
|
|
330
335
|
className = "",
|
|
331
336
|
...props
|
|
332
337
|
}) {
|
|
338
|
+
const size = useControlSize(sizeProp);
|
|
333
339
|
const fields = useMemo(() => ({ label: fieldNames?.label ?? "label", value: fieldNames?.value ?? "value", children: fieldNames?.children ?? "children" }), [fieldNames]);
|
|
334
340
|
const rootRef = useRef(null);
|
|
335
341
|
const popupRef = useRef(null);
|
|
@@ -418,7 +424,7 @@ function Cascader({
|
|
|
418
424
|
if (children?.length) columns.push(children);
|
|
419
425
|
});
|
|
420
426
|
const floating = useFloatingPlaceholder({ mode: placeholderMode, placeholder, filled: selectedPaths.length > 0, active: open });
|
|
421
|
-
return /* @__PURE__ */ jsxs3("div", { ref: rootRef, className: `sia-cascader${open ? " is-open" : ""}${disabled ? " is-disabled" : ""} ${className}`.trim(), ...props, children: [
|
|
427
|
+
return /* @__PURE__ */ jsxs3("div", { ref: rootRef, className: `sia-cascader sia-cascader--${size}${open ? " is-open" : ""}${disabled ? " is-disabled" : ""} ${className}`.trim(), ...props, children: [
|
|
422
428
|
/* @__PURE__ */ jsxs3("button", { type: "button", className: `sia-cascader__trigger${floating.className}`, disabled, "aria-haspopup": "listbox", "aria-expanded": open, onClick: toggleOpen, children: [
|
|
423
429
|
/* @__PURE__ */ jsx3("span", { className: "sia-cascader__value", children: display ? multiple && Array.isArray(display) ? display.map((label, index) => /* @__PURE__ */ jsx3("span", { className: "sia-cascader__tag", children: label }, pathKey(selectedPaths[index] ?? []))) : display : /* @__PURE__ */ jsx3("span", { className: "sia-cascader__placeholder", children: placeholder }) }),
|
|
424
430
|
allowClear && selectedPaths.length ? /* @__PURE__ */ jsx3("span", { className: "sia-cascader__clear", role: "button", "aria-label": "\u6E05\u9664\u9009\u62E9", onClick: (event) => {
|
|
@@ -1388,6 +1394,7 @@ import { Fragment as Fragment3, jsx as jsx9, jsxs as jsxs9 } from "react/jsx-run
|
|
|
1388
1394
|
var Switch = forwardRef2(function Switch2({
|
|
1389
1395
|
label,
|
|
1390
1396
|
variant = "standard",
|
|
1397
|
+
size: sizeProp,
|
|
1391
1398
|
checkedContent,
|
|
1392
1399
|
uncheckedContent,
|
|
1393
1400
|
onChange,
|
|
@@ -1395,6 +1402,7 @@ var Switch = forwardRef2(function Switch2({
|
|
|
1395
1402
|
className = "",
|
|
1396
1403
|
...props
|
|
1397
1404
|
}, ref) {
|
|
1405
|
+
const size = useControlSize(sizeProp);
|
|
1398
1406
|
const hasContent = checkedContent !== void 0 || uncheckedContent !== void 0;
|
|
1399
1407
|
const checkedVisual = checkedContent ?? (variant === "segmented" ? "\u5F00" : null);
|
|
1400
1408
|
const uncheckedVisual = uncheckedContent ?? (variant === "segmented" ? "\u5173" : null);
|
|
@@ -1402,7 +1410,7 @@ var Switch = forwardRef2(function Switch2({
|
|
|
1402
1410
|
onCheckedChange?.(event.currentTarget.checked);
|
|
1403
1411
|
onChange?.(event);
|
|
1404
1412
|
};
|
|
1405
|
-
return /* @__PURE__ */ jsxs9("label", { className: `sia-switch-wrap ${className}`.trim(), children: [
|
|
1413
|
+
return /* @__PURE__ */ jsxs9("label", { className: `sia-switch-wrap sia-switch-wrap--${size} ${className}`.trim(), children: [
|
|
1406
1414
|
/* @__PURE__ */ jsx9("input", { ref, type: "checkbox", role: "switch", className: "sia-switch-input", onChange: handleChange, ...props }),
|
|
1407
1415
|
/* @__PURE__ */ jsxs9(
|
|
1408
1416
|
"span",
|
|
@@ -1611,6 +1619,7 @@ function FormRoot({
|
|
|
1611
1619
|
form,
|
|
1612
1620
|
initialValues,
|
|
1613
1621
|
layout = "horizontal",
|
|
1622
|
+
size: sizeProp,
|
|
1614
1623
|
placeholderMode,
|
|
1615
1624
|
disabled = false,
|
|
1616
1625
|
requiredMark = true,
|
|
@@ -1621,16 +1630,17 @@ function FormRoot({
|
|
|
1621
1630
|
children,
|
|
1622
1631
|
...props
|
|
1623
1632
|
}) {
|
|
1633
|
+
const size = useControlSize(sizeProp);
|
|
1624
1634
|
const resolvedPlaceholderMode = usePlaceholderMode(placeholderMode);
|
|
1625
1635
|
const [internalForm] = useForm(form);
|
|
1626
1636
|
const instance = internalForm;
|
|
1627
1637
|
instance.configure(initialValues, { onFinish, onFinishFailed, onValuesChange });
|
|
1628
1638
|
const context = useMemo4(() => instance, [instance]);
|
|
1629
|
-
return /* @__PURE__ */ jsx9(FormContext.Provider, { value: context, children: /* @__PURE__ */ jsx9(PlaceholderModeContext.Provider, { value: resolvedPlaceholderMode, children: /* @__PURE__ */ jsx9(
|
|
1639
|
+
return /* @__PURE__ */ jsx9(FormContext.Provider, { value: context, children: /* @__PURE__ */ jsx9(PlaceholderModeContext.Provider, { value: resolvedPlaceholderMode, children: /* @__PURE__ */ jsx9(ControlSizeContext.Provider, { value: size, children: /* @__PURE__ */ jsx9(
|
|
1630
1640
|
"form",
|
|
1631
1641
|
{
|
|
1632
1642
|
...props,
|
|
1633
|
-
className: `sia-form sia-form--${layout}${disabled ? " is-disabled" : ""} ${className}`.trim(),
|
|
1643
|
+
className: `sia-form sia-form--${layout} sia-form--${size}${disabled ? " is-disabled" : ""} ${className}`.trim(),
|
|
1634
1644
|
"data-required-mark": requiredMark,
|
|
1635
1645
|
onSubmit: (event) => {
|
|
1636
1646
|
event.preventDefault();
|
|
@@ -1638,7 +1648,7 @@ function FormRoot({
|
|
|
1638
1648
|
},
|
|
1639
1649
|
children: /* @__PURE__ */ jsx9("fieldset", { disabled, children })
|
|
1640
1650
|
}
|
|
1641
|
-
) }) });
|
|
1651
|
+
) }) }) });
|
|
1642
1652
|
}
|
|
1643
1653
|
function defaultEventValue(valuePropName, args) {
|
|
1644
1654
|
const first = args[0];
|
|
@@ -1786,12 +1796,13 @@ var Form = Object.assign(FormRoot, {
|
|
|
1786
1796
|
import { createContext as createContext3, forwardRef as forwardRef3, useContext as useContext3, useId as useId4, useMemo as useMemo5 } from "react";
|
|
1787
1797
|
import { jsx as jsx10, jsxs as jsxs10 } from "react/jsx-runtime";
|
|
1788
1798
|
var RadioContext = createContext3(null);
|
|
1789
|
-
var RadioRoot = forwardRef3(function Radio({ value, children, disabled, checked, defaultChecked, button = false, className = "", onChange, ...props }, ref) {
|
|
1799
|
+
var RadioRoot = forwardRef3(function Radio({ value, size: sizeProp, children, disabled, checked, defaultChecked, button = false, className = "", onChange, ...props }, ref) {
|
|
1800
|
+
const size = useControlSize(sizeProp);
|
|
1790
1801
|
const group = useContext3(RadioContext);
|
|
1791
1802
|
const fallbackId = useId4();
|
|
1792
1803
|
const grouped = group !== null;
|
|
1793
1804
|
const currentChecked = grouped ? group.value === value : checked;
|
|
1794
|
-
return /* @__PURE__ */ jsxs10("label", { className: `sia-radio${button ? " sia-radio--button" : ""}${button && group?.buttonStyle === "solid" ? " sia-radio--solid" : ""}${disabled || group?.disabled ? " is-disabled" : ""} ${className}`.trim(), children: [
|
|
1805
|
+
return /* @__PURE__ */ jsxs10("label", { className: `sia-radio sia-radio--${size}${button ? " sia-radio--button" : ""}${button && group?.buttonStyle === "solid" ? " sia-radio--solid" : ""}${disabled || group?.disabled ? " is-disabled" : ""} ${className}`.trim(), children: [
|
|
1795
1806
|
/* @__PURE__ */ jsx10(
|
|
1796
1807
|
"input",
|
|
1797
1808
|
{
|
|
@@ -1819,6 +1830,7 @@ function RadioButton(props) {
|
|
|
1819
1830
|
return /* @__PURE__ */ jsx10(RadioRoot, { ...props, button: true });
|
|
1820
1831
|
}
|
|
1821
1832
|
function RadioGroup({
|
|
1833
|
+
size: sizeProp,
|
|
1822
1834
|
value,
|
|
1823
1835
|
defaultValue,
|
|
1824
1836
|
options,
|
|
@@ -1830,6 +1842,7 @@ function RadioGroup({
|
|
|
1830
1842
|
children,
|
|
1831
1843
|
onChange
|
|
1832
1844
|
}) {
|
|
1845
|
+
const size = useControlSize(sizeProp);
|
|
1833
1846
|
const fallbackName = useId4();
|
|
1834
1847
|
const [currentValue, setValue2] = useControllableState({
|
|
1835
1848
|
value,
|
|
@@ -1846,13 +1859,13 @@ function RadioGroup({
|
|
|
1846
1859
|
setValue: setValue2
|
|
1847
1860
|
}), [buttonStyle, currentValue, disabled, fallbackName, name, setValue2]);
|
|
1848
1861
|
const Component = optionType === "button" ? RadioButton : RadioRoot;
|
|
1849
|
-
return /* @__PURE__ */ jsx10(RadioContext.Provider, { value: context, children: /* @__PURE__ */ jsxs10("div", { className: `sia-radio-group${optionType === "button" ? " sia-radio-group--button" : ""} ${className}`.trim(), role: "radiogroup", children: [
|
|
1862
|
+
return /* @__PURE__ */ jsx10(ControlSizeContext.Provider, { value: size, children: /* @__PURE__ */ jsx10(RadioContext.Provider, { value: context, children: /* @__PURE__ */ jsxs10("div", { className: `sia-radio-group${optionType === "button" ? " sia-radio-group--button" : ""} ${className}`.trim(), role: "radiogroup", children: [
|
|
1850
1863
|
options?.map((option) => {
|
|
1851
1864
|
const normalized = typeof option === "object" ? option : { label: String(option), value: option };
|
|
1852
1865
|
return /* @__PURE__ */ jsx10(Component, { value: normalized.value, disabled: normalized.disabled, children: normalized.label }, normalized.value);
|
|
1853
1866
|
}),
|
|
1854
1867
|
children
|
|
1855
|
-
] }) });
|
|
1868
|
+
] }) }) });
|
|
1856
1869
|
}
|
|
1857
1870
|
var Radio2 = Object.assign(RadioRoot, { Button: RadioButton, Group: RadioGroup });
|
|
1858
1871
|
|
|
@@ -2047,6 +2060,7 @@ function createDefaultStops(color) {
|
|
|
2047
2060
|
return [createStop(color, 0), createStop("#FFFFFF", 100)];
|
|
2048
2061
|
}
|
|
2049
2062
|
function ColorPicker({
|
|
2063
|
+
size: sizeProp,
|
|
2050
2064
|
value,
|
|
2051
2065
|
defaultValue = "#1677FF",
|
|
2052
2066
|
mode,
|
|
@@ -2064,6 +2078,7 @@ function ColorPicker({
|
|
|
2064
2078
|
onClear,
|
|
2065
2079
|
...props
|
|
2066
2080
|
}) {
|
|
2081
|
+
const size = useControlSize(sizeProp);
|
|
2067
2082
|
const rootRef = useRef6(null);
|
|
2068
2083
|
const popupRef = useRef6(null);
|
|
2069
2084
|
const lastEmittedValue = useRef6();
|
|
@@ -2164,7 +2179,7 @@ function ColorPicker({
|
|
|
2164
2179
|
const triggerBackground = color || "transparent";
|
|
2165
2180
|
const triggerText = color || "\u65E0\u8272";
|
|
2166
2181
|
const opaqueColor = rgbaToHex({ ...rgba, a: 100 }, false);
|
|
2167
|
-
return /* @__PURE__ */ jsxs12("div", { ref: rootRef, className: `sia-color-picker${disabled ? " is-disabled" : ""} ${className}`.trim(), ...props, children: [
|
|
2182
|
+
return /* @__PURE__ */ jsxs12("div", { ref: rootRef, className: `sia-color-picker sia-color-picker--${size}${disabled ? " is-disabled" : ""} ${className}`.trim(), ...props, children: [
|
|
2168
2183
|
/* @__PURE__ */ jsxs12(
|
|
2169
2184
|
"button",
|
|
2170
2185
|
{
|
|
@@ -2298,7 +2313,7 @@ function seconds(value) {
|
|
|
2298
2313
|
function TimePicker({
|
|
2299
2314
|
value,
|
|
2300
2315
|
defaultValue = "",
|
|
2301
|
-
size
|
|
2316
|
+
size: sizeProp,
|
|
2302
2317
|
status = "default",
|
|
2303
2318
|
allowClear = true,
|
|
2304
2319
|
use12Hours = false,
|
|
@@ -2318,6 +2333,7 @@ function TimePicker({
|
|
|
2318
2333
|
step,
|
|
2319
2334
|
...props
|
|
2320
2335
|
}) {
|
|
2336
|
+
const size = useControlSize(sizeProp);
|
|
2321
2337
|
const id = useId5();
|
|
2322
2338
|
const rootRef = useRef7(null);
|
|
2323
2339
|
const inputRef = useRef7(null);
|
|
@@ -2444,13 +2460,14 @@ function TimePicker({
|
|
|
2444
2460
|
] });
|
|
2445
2461
|
}
|
|
2446
2462
|
function TimeRangePicker({ value, defaultValue = ["", ""], placeholder = ["\u5F00\u59CB\u65F6\u95F4", "\u7ED3\u675F\u65F6\u95F4"], separator = "\u2192", onChange, className = "", style, ...props }) {
|
|
2463
|
+
const size = useControlSize(props.size);
|
|
2447
2464
|
const [currentValue, setValue2] = useControllableState({ value: value === void 0 ? void 0 : Array.isArray(value) ? value : ["", ""], defaultValue, onChange });
|
|
2448
2465
|
function update(index, next) {
|
|
2449
2466
|
const pair = [currentValue[0], currentValue[1]];
|
|
2450
2467
|
pair[index] = next;
|
|
2451
2468
|
setValue2(pair);
|
|
2452
2469
|
}
|
|
2453
|
-
return /* @__PURE__ */ jsxs13("span", { style, className: `sia-time-range sia-picker--${
|
|
2470
|
+
return /* @__PURE__ */ jsxs13("span", { style, className: `sia-time-range sia-picker--${size} sia-picker--${props.status ?? "default"}${props.disabled ? " is-disabled" : ""} ${className}`.trim(), children: [
|
|
2454
2471
|
/* @__PURE__ */ jsx13(TimePicker, { ...props, "aria-label": props["aria-label"] ? props["aria-label"] + "\u5F00\u59CB\u65F6\u95F4" : "\u5F00\u59CB\u65F6\u95F4", value: currentValue[0], placeholder: placeholder[0], max: currentValue[1] && (!props.max || seconds(currentValue[1]) < seconds(String(props.max))) ? currentValue[1] : props.max, onChange: (next) => update(0, next) }),
|
|
2455
2472
|
/* @__PURE__ */ jsx13("span", { className: "sia-time-range__separator", children: separator }),
|
|
2456
2473
|
/* @__PURE__ */ jsx13(TimePicker, { ...props, id: props.id ? props.id + "-end" : void 0, "aria-label": props["aria-label"] ? props["aria-label"] + "\u7ED3\u675F\u65F6\u95F4" : "\u7ED3\u675F\u65F6\u95F4", value: currentValue[1], placeholder: placeholder[1], min: currentValue[0] && (!props.min || seconds(currentValue[0]) > seconds(String(props.min))) ? currentValue[0] : props.min, onChange: (next) => update(1, next) })
|
|
@@ -2496,7 +2513,7 @@ function TreeSelect({
|
|
|
2496
2513
|
searchPlaceholder = "\u641C\u7D22\u8282\u70B9",
|
|
2497
2514
|
maxTagCount = 3,
|
|
2498
2515
|
disabled = false,
|
|
2499
|
-
size
|
|
2516
|
+
size: sizeProp,
|
|
2500
2517
|
status = "default",
|
|
2501
2518
|
className = "",
|
|
2502
2519
|
onChange,
|
|
@@ -2523,6 +2540,7 @@ function TreeSelect({
|
|
|
2523
2540
|
onDeselect,
|
|
2524
2541
|
...props
|
|
2525
2542
|
}) {
|
|
2543
|
+
const size = useControlSize(sizeProp);
|
|
2526
2544
|
const rootRef = useRef8(null);
|
|
2527
2545
|
const popupRef = useRef8(null);
|
|
2528
2546
|
const nodeIndex = useMemo6(() => {
|
|
@@ -3920,7 +3938,7 @@ var InputNumber = forwardRef4(function InputNumber2({
|
|
|
3920
3938
|
max,
|
|
3921
3939
|
step = 1,
|
|
3922
3940
|
precision,
|
|
3923
|
-
size
|
|
3941
|
+
size: sizeProp,
|
|
3924
3942
|
status = "default",
|
|
3925
3943
|
prefix,
|
|
3926
3944
|
suffix,
|
|
@@ -3935,6 +3953,7 @@ var InputNumber = forwardRef4(function InputNumber2({
|
|
|
3935
3953
|
onKeyDown,
|
|
3936
3954
|
...props
|
|
3937
3955
|
}, forwardedRef) {
|
|
3956
|
+
const size = useControlSize(sizeProp);
|
|
3938
3957
|
const fallbackId = useId7();
|
|
3939
3958
|
const inputId = id ?? fallbackId;
|
|
3940
3959
|
const localRef = useRef11(null);
|
|
@@ -5792,13 +5811,14 @@ function orderColumnSettings(items) {
|
|
|
5792
5811
|
}
|
|
5793
5812
|
function ColumnSettingPanel({ open, items, columns, loading, loadError, onRetry, onClose, onApply }) {
|
|
5794
5813
|
const [draft, setDraft] = useState16(items);
|
|
5795
|
-
const
|
|
5796
|
-
const
|
|
5814
|
+
const listRef = useRef14(null);
|
|
5815
|
+
const cancelDrag = useRef14(null);
|
|
5816
|
+
const [preview, setPreview] = useState16(null);
|
|
5797
5817
|
useEffect12(() => {
|
|
5818
|
+
cancelDrag.current?.();
|
|
5798
5819
|
if (open) setDraft(orderColumnSettings(items));
|
|
5799
|
-
drag.current = null;
|
|
5800
|
-
setDraggingKey(null);
|
|
5801
5820
|
}, [items, open]);
|
|
5821
|
+
useEffect12(() => () => cancelDrag.current?.(), []);
|
|
5802
5822
|
const labels = new Map(flattenTableColumns(columns).map((column) => [column.key, getColumnLabel(column)]));
|
|
5803
5823
|
const visibleCount = draft.filter((item) => item.visible).length;
|
|
5804
5824
|
function setFixed(key, fixed) {
|
|
@@ -5812,20 +5832,107 @@ function ColumnSettingPanel({ open, items, columns, loading, loadError, onRetry,
|
|
|
5812
5832
|
return orderColumnSettings(next);
|
|
5813
5833
|
});
|
|
5814
5834
|
}
|
|
5815
|
-
function
|
|
5816
|
-
|
|
5817
|
-
|
|
5818
|
-
|
|
5819
|
-
|
|
5820
|
-
|
|
5821
|
-
|
|
5822
|
-
|
|
5823
|
-
|
|
5824
|
-
|
|
5825
|
-
|
|
5826
|
-
|
|
5827
|
-
|
|
5828
|
-
|
|
5835
|
+
function startSort(event, key) {
|
|
5836
|
+
if (loading || loadError || event.button !== 0 || event.target.closest("button, input, label")) return;
|
|
5837
|
+
const list = listRef.current;
|
|
5838
|
+
if (!list) return;
|
|
5839
|
+
cancelDrag.current?.();
|
|
5840
|
+
const original = [...draft];
|
|
5841
|
+
const from = original.findIndex((item) => item.key === key);
|
|
5842
|
+
const elements = Array.from(list.querySelectorAll(".sia-table-settings__item"));
|
|
5843
|
+
const rects = elements.map((element) => element.getBoundingClientRect());
|
|
5844
|
+
const gap = parseFloat(getComputedStyle(list).rowGap) || 0;
|
|
5845
|
+
const positions = original.map((_, index) => index);
|
|
5846
|
+
const startY = event.clientY;
|
|
5847
|
+
let lastY = startY;
|
|
5848
|
+
let moved = false;
|
|
5849
|
+
let next = original;
|
|
5850
|
+
let frame = 0;
|
|
5851
|
+
let scrollParent = list.parentElement;
|
|
5852
|
+
while (scrollParent && !(scrollParent.scrollHeight > scrollParent.clientHeight && /auto|scroll/.test(getComputedStyle(scrollParent).overflowY))) scrollParent = scrollParent.parentElement;
|
|
5853
|
+
const initialScroll = scrollParent?.scrollTop ?? 0;
|
|
5854
|
+
const target = event.currentTarget;
|
|
5855
|
+
target.setPointerCapture(event.pointerId);
|
|
5856
|
+
const previousUserSelect = document.body.style.userSelect;
|
|
5857
|
+
function update() {
|
|
5858
|
+
const dy = lastY - startY + (scrollParent?.scrollTop ?? 0) - initialScroll;
|
|
5859
|
+
if (!moved && Math.abs(dy) < 4) return;
|
|
5860
|
+
moved = true;
|
|
5861
|
+
document.body.style.userSelect = "none";
|
|
5862
|
+
const center = rects[from].top + rects[from].height / 2 + dy;
|
|
5863
|
+
let to = from;
|
|
5864
|
+
for (const index of positions) {
|
|
5865
|
+
if (index > from && center > rects[index].top + rects[index].height / 2) to = index;
|
|
5866
|
+
if (index < from && center < rects[index].top + rects[index].height / 2) {
|
|
5867
|
+
to = index;
|
|
5868
|
+
break;
|
|
5869
|
+
}
|
|
5870
|
+
}
|
|
5871
|
+
next = [...original];
|
|
5872
|
+
const [item] = next.splice(from, 1);
|
|
5873
|
+
next.splice(to, 0, { ...item, fixed: original[to].fixed });
|
|
5874
|
+
const offsets = {};
|
|
5875
|
+
let top = rects[0].top;
|
|
5876
|
+
for (const entry of next) {
|
|
5877
|
+
const index = original.findIndex((item2) => item2.key === entry.key);
|
|
5878
|
+
offsets[entry.key] = entry.key === key ? dy : top - rects[index].top;
|
|
5879
|
+
top += rects[index].height + gap;
|
|
5880
|
+
}
|
|
5881
|
+
setPreview({ key, fixed: original[to].fixed, offsets });
|
|
5882
|
+
}
|
|
5883
|
+
function tick() {
|
|
5884
|
+
if (moved && scrollParent) {
|
|
5885
|
+
const bounds = scrollParent.getBoundingClientRect();
|
|
5886
|
+
const delta = lastY < bounds.top + 40 ? -10 : lastY > bounds.bottom - 40 ? 10 : 0;
|
|
5887
|
+
if (delta) {
|
|
5888
|
+
scrollParent.scrollTop += delta;
|
|
5889
|
+
update();
|
|
5890
|
+
}
|
|
5891
|
+
}
|
|
5892
|
+
frame = requestAnimationFrame(tick);
|
|
5893
|
+
}
|
|
5894
|
+
function move(moveEvent) {
|
|
5895
|
+
if (moveEvent.pointerId !== event.pointerId) return;
|
|
5896
|
+
lastY = moveEvent.clientY;
|
|
5897
|
+
update();
|
|
5898
|
+
}
|
|
5899
|
+
function finish(commit) {
|
|
5900
|
+
document.removeEventListener("pointermove", move);
|
|
5901
|
+
document.removeEventListener("pointerup", up);
|
|
5902
|
+
document.removeEventListener("pointercancel", cancel);
|
|
5903
|
+
document.removeEventListener("keydown", escape, true);
|
|
5904
|
+
window.removeEventListener("blur", cancel);
|
|
5905
|
+
cancelAnimationFrame(frame);
|
|
5906
|
+
if (target.hasPointerCapture(event.pointerId)) target.releasePointerCapture(event.pointerId);
|
|
5907
|
+
document.body.style.userSelect = previousUserSelect;
|
|
5908
|
+
cancelDrag.current = null;
|
|
5909
|
+
setPreview(null);
|
|
5910
|
+
if (commit && moved) setDraft(orderColumnSettings(next));
|
|
5911
|
+
}
|
|
5912
|
+
function up(upEvent) {
|
|
5913
|
+
if (upEvent.pointerId === event.pointerId) {
|
|
5914
|
+
lastY = upEvent.clientY;
|
|
5915
|
+
update();
|
|
5916
|
+
finish(true);
|
|
5917
|
+
}
|
|
5918
|
+
}
|
|
5919
|
+
function cancel() {
|
|
5920
|
+
finish(false);
|
|
5921
|
+
}
|
|
5922
|
+
function escape(event2) {
|
|
5923
|
+
if (event2.key === "Escape") {
|
|
5924
|
+
event2.preventDefault();
|
|
5925
|
+
event2.stopPropagation();
|
|
5926
|
+
cancel();
|
|
5927
|
+
}
|
|
5928
|
+
}
|
|
5929
|
+
cancelDrag.current = cancel;
|
|
5930
|
+
document.addEventListener("pointermove", move);
|
|
5931
|
+
document.addEventListener("pointerup", up);
|
|
5932
|
+
document.addEventListener("pointercancel", cancel);
|
|
5933
|
+
document.addEventListener("keydown", escape, true);
|
|
5934
|
+
window.addEventListener("blur", cancel);
|
|
5935
|
+
frame = requestAnimationFrame(tick);
|
|
5829
5936
|
}
|
|
5830
5937
|
return /* @__PURE__ */ jsxs19(Drawer2, { open, title: "\u5217\u8BBE\u7F6E", size: 440, onOpenChange: (next) => {
|
|
5831
5938
|
if (!next) onClose();
|
|
@@ -5849,40 +5956,20 @@ function ColumnSettingPanel({ open, items, columns, loading, loadError, onRetry,
|
|
|
5849
5956
|
"\uFF09"
|
|
5850
5957
|
] })
|
|
5851
5958
|
] }),
|
|
5852
|
-
/* @__PURE__ */ jsx20("div", { className:
|
|
5853
|
-
if (drag.current) event.preventDefault();
|
|
5854
|
-
}, onDrop: (event) => {
|
|
5855
|
-
event.preventDefault();
|
|
5856
|
-
if (drag.current) drag.current.dropped = true;
|
|
5857
|
-
}, children: draft.map((item) => /* @__PURE__ */ jsxs19(
|
|
5959
|
+
/* @__PURE__ */ jsx20("div", { ref: listRef, className: `sia-table-settings__list${preview ? " is-sorting" : ""}`, children: draft.map((item) => /* @__PURE__ */ jsxs19(
|
|
5858
5960
|
"div",
|
|
5859
5961
|
{
|
|
5860
5962
|
"data-column-key": item.key,
|
|
5861
|
-
className: `sia-table-settings__item${
|
|
5862
|
-
|
|
5863
|
-
|
|
5864
|
-
drag.current = { key: item.key, original: draft, dropped: false };
|
|
5865
|
-
event.dataTransfer.effectAllowed = "move";
|
|
5866
|
-
event.dataTransfer.setData("text/plain", item.key);
|
|
5867
|
-
setDraggingKey(item.key);
|
|
5868
|
-
},
|
|
5869
|
-
onDragOver: (event) => {
|
|
5870
|
-
event.preventDefault();
|
|
5871
|
-
event.dataTransfer.dropEffect = "move";
|
|
5872
|
-
previewMove(item.key, event.clientY, event.currentTarget);
|
|
5873
|
-
},
|
|
5874
|
-
onDragEnd: () => {
|
|
5875
|
-
if (drag.current && !drag.current.dropped) setDraft(drag.current.original);
|
|
5876
|
-
drag.current = null;
|
|
5877
|
-
setDraggingKey(null);
|
|
5878
|
-
},
|
|
5963
|
+
className: `sia-table-settings__item${preview?.key === item.key ? " is-dragging" : ""}`,
|
|
5964
|
+
style: preview ? { transform: `translateY(${preview.offsets[item.key] ?? 0}px)` } : void 0,
|
|
5965
|
+
onPointerDown: (event) => startSort(event, item.key),
|
|
5879
5966
|
children: [
|
|
5880
5967
|
/* @__PURE__ */ jsx20(Icon, { name: "menu", size: 15 }),
|
|
5881
5968
|
/* @__PURE__ */ jsx20(TableCheckbox, { label: `\u663E\u793A${labels.get(item.key) ?? item.key}\u5217`, checked: item.visible, onChange: (checked) => setDraft((previous) => previous.map((entry) => entry.key === item.key ? { ...entry, visible: checked } : entry)) }),
|
|
5882
5969
|
/* @__PURE__ */ jsx20("span", { className: "sia-table-settings__name", title: labels.get(item.key) ?? item.key, children: labels.get(item.key) ?? item.key }),
|
|
5883
5970
|
/* @__PURE__ */ jsxs19("div", { className: "sia-table-settings__actions", children: [
|
|
5884
|
-
/* @__PURE__ */ jsx20(Button, { size: "small", variant: item.fixed === "left" ? "primary" : "text", "aria-label": "\u5DE6\u56FA\u5B9A", onClick: () => setFixed(item.key, item.fixed === "left" ? void 0 : "left"), children: "\u5DE6" }),
|
|
5885
|
-
/* @__PURE__ */ jsx20(Button, { size: "small", variant: item.fixed === "right" ? "primary" : "text", "aria-label": "\u53F3\u56FA\u5B9A", onClick: () => setFixed(item.key, item.fixed === "right" ? void 0 : "right"), children: "\u53F3" })
|
|
5971
|
+
/* @__PURE__ */ jsx20(Button, { size: "small", variant: (preview?.key === item.key ? preview.fixed : item.fixed) === "left" ? "primary" : "text", "aria-label": "\u5DE6\u56FA\u5B9A", onClick: () => setFixed(item.key, item.fixed === "left" ? void 0 : "left"), children: "\u5DE6" }),
|
|
5972
|
+
/* @__PURE__ */ jsx20(Button, { size: "small", variant: (preview?.key === item.key ? preview.fixed : item.fixed) === "right" ? "primary" : "text", "aria-label": "\u53F3\u56FA\u5B9A", onClick: () => setFixed(item.key, item.fixed === "right" ? void 0 : "right"), children: "\u53F3" })
|
|
5886
5973
|
] })
|
|
5887
5974
|
]
|
|
5888
5975
|
},
|
|
@@ -7270,7 +7357,7 @@ var InputSelect = forwardRef7(function InputSelect2({
|
|
|
7270
7357
|
showValue = false,
|
|
7271
7358
|
placeholder = "\u8BF7\u9009\u62E9",
|
|
7272
7359
|
placeholderMode,
|
|
7273
|
-
size
|
|
7360
|
+
size: sizeProp,
|
|
7274
7361
|
status,
|
|
7275
7362
|
disabled = false,
|
|
7276
7363
|
loading = false,
|
|
@@ -7285,6 +7372,7 @@ var InputSelect = forwardRef7(function InputSelect2({
|
|
|
7285
7372
|
onOpenChange,
|
|
7286
7373
|
...inputProps
|
|
7287
7374
|
}, forwardedRef) {
|
|
7375
|
+
const size = useControlSize(sizeProp);
|
|
7288
7376
|
const [internal, setInternal] = useState18(defaultValue);
|
|
7289
7377
|
const current = value !== void 0 ? value : internal;
|
|
7290
7378
|
const values = current == null ? [] : Array.isArray(current) ? current : [current];
|
|
@@ -7459,6 +7547,293 @@ var InputSelect = forwardRef7(function InputSelect2({
|
|
|
7459
7547
|
)
|
|
7460
7548
|
] });
|
|
7461
7549
|
});
|
|
7550
|
+
|
|
7551
|
+
// src/components/QueryForm.tsx
|
|
7552
|
+
import { Children as Children4, useLayoutEffect as useLayoutEffect3, useRef as useRef17, useState as useState19 } from "react";
|
|
7553
|
+
import { jsx as jsx24, jsxs as jsxs23 } from "react/jsx-runtime";
|
|
7554
|
+
function QueryForm({
|
|
7555
|
+
fields,
|
|
7556
|
+
children,
|
|
7557
|
+
form: providedForm,
|
|
7558
|
+
onSearch,
|
|
7559
|
+
loading = false,
|
|
7560
|
+
fieldWidth = 220,
|
|
7561
|
+
collapsible = true,
|
|
7562
|
+
collapsed: controlledCollapsed,
|
|
7563
|
+
defaultCollapsed = false,
|
|
7564
|
+
collapsedCount = 3,
|
|
7565
|
+
onCollapsedChange,
|
|
7566
|
+
quickQueries = [],
|
|
7567
|
+
quickQuerySize = "small",
|
|
7568
|
+
savedQueries = [],
|
|
7569
|
+
shortcutsLoading = false,
|
|
7570
|
+
onSaveQuery,
|
|
7571
|
+
onRemoveQuery,
|
|
7572
|
+
onError,
|
|
7573
|
+
searchText = "\u67E5\u8BE2",
|
|
7574
|
+
resetText = "\u91CD\u7F6E",
|
|
7575
|
+
saveText = "\u53E6\u5B58\u4E3A\u5FEB\u6377\u67E5\u8BE2",
|
|
7576
|
+
resetSearch = true,
|
|
7577
|
+
actionsExtra,
|
|
7578
|
+
disabled = false,
|
|
7579
|
+
className = "",
|
|
7580
|
+
placeholderMode = "floating",
|
|
7581
|
+
onValuesChange,
|
|
7582
|
+
onFinishFailed,
|
|
7583
|
+
...formProps
|
|
7584
|
+
}) {
|
|
7585
|
+
const [form] = useForm(providedForm);
|
|
7586
|
+
const [internalCollapsed, setInternalCollapsed] = useState19(defaultCollapsed);
|
|
7587
|
+
const collapsed = collapsible && (controlledCollapsed ?? internalCollapsed);
|
|
7588
|
+
const [searching, setSearching] = useState19(false);
|
|
7589
|
+
const [saving, setSaving] = useState19(false);
|
|
7590
|
+
const [removing, setRemoving] = useState19(false);
|
|
7591
|
+
const [saveOpen, setSaveOpen] = useState19(false);
|
|
7592
|
+
const [saveName, setSaveName] = useState19("");
|
|
7593
|
+
const [saveError, setSaveError] = useState19("");
|
|
7594
|
+
const [error, setError] = useState19("");
|
|
7595
|
+
const [activeShortcut, setActiveShortcut] = useState19("");
|
|
7596
|
+
const source = useRef17({ source: "submit" });
|
|
7597
|
+
const searchLock = useRef17(false);
|
|
7598
|
+
const saveLock = useRef17(false);
|
|
7599
|
+
const removeLock = useRef17(false);
|
|
7600
|
+
const snapshot = useRef17();
|
|
7601
|
+
const busy = disabled || loading || searching;
|
|
7602
|
+
const shortcutBusy = busy || shortcutsLoading || saving || removing;
|
|
7603
|
+
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 }));
|
|
7604
|
+
const limit = Math.max(1, Math.floor(collapsedCount));
|
|
7605
|
+
const rowRef = useRef17(null);
|
|
7606
|
+
const actionsRef = useRef17(null);
|
|
7607
|
+
const [fittingCount, setFittingCount] = useState19(limit);
|
|
7608
|
+
useLayoutEffect3(() => {
|
|
7609
|
+
if (!collapsed) return;
|
|
7610
|
+
const row = rowRef.current;
|
|
7611
|
+
const actions = actionsRef.current;
|
|
7612
|
+
if (!row || !actions) return;
|
|
7613
|
+
function measure() {
|
|
7614
|
+
if (!row || !actions) return;
|
|
7615
|
+
const gap = parseFloat(getComputedStyle(row).columnGap) || 0;
|
|
7616
|
+
let remaining = row.clientWidth - actions.getBoundingClientRect().width;
|
|
7617
|
+
let count = 0;
|
|
7618
|
+
for (const field of Array.from(row.querySelectorAll(":scope > .sia-query-form__field")).slice(0, limit)) {
|
|
7619
|
+
const width = parseFloat(getComputedStyle(field).width) || 220;
|
|
7620
|
+
if (remaining + 0.5 < width + gap) break;
|
|
7621
|
+
remaining -= width + gap;
|
|
7622
|
+
count++;
|
|
7623
|
+
}
|
|
7624
|
+
setFittingCount(count);
|
|
7625
|
+
}
|
|
7626
|
+
measure();
|
|
7627
|
+
const observer = new ResizeObserver(measure);
|
|
7628
|
+
observer.observe(row);
|
|
7629
|
+
observer.observe(actions);
|
|
7630
|
+
row.querySelectorAll(":scope > .sia-query-form__field").forEach((field) => observer.observe(field));
|
|
7631
|
+
return () => observer.disconnect();
|
|
7632
|
+
}, [collapsed, limit, fieldWidth, fields, children]);
|
|
7633
|
+
async function search(values) {
|
|
7634
|
+
const info = source.current;
|
|
7635
|
+
source.current = { source: "submit" };
|
|
7636
|
+
if (searchLock.current || disabled || loading) return;
|
|
7637
|
+
searchLock.current = true;
|
|
7638
|
+
setSearching(true);
|
|
7639
|
+
setError("");
|
|
7640
|
+
try {
|
|
7641
|
+
await onSearch(values, info);
|
|
7642
|
+
} catch (reason) {
|
|
7643
|
+
setError(reason instanceof Error ? reason.message : "\u67E5\u8BE2\u5931\u8D25\uFF0C\u8BF7\u91CD\u8BD5");
|
|
7644
|
+
onError?.(reason, "search");
|
|
7645
|
+
} finally {
|
|
7646
|
+
searchLock.current = false;
|
|
7647
|
+
setSearching(false);
|
|
7648
|
+
}
|
|
7649
|
+
}
|
|
7650
|
+
function applyShortcut(query, kind) {
|
|
7651
|
+
if (shortcutBusy || query.disabled) return;
|
|
7652
|
+
form.resetFields();
|
|
7653
|
+
form.setFieldsValue(query.values);
|
|
7654
|
+
source.current = { source: kind, shortcutKey: query.key };
|
|
7655
|
+
setActiveShortcut(`${kind}:${query.key}`);
|
|
7656
|
+
form.submit();
|
|
7657
|
+
}
|
|
7658
|
+
function reset() {
|
|
7659
|
+
if (busy) return;
|
|
7660
|
+
form.resetFields();
|
|
7661
|
+
setActiveShortcut("");
|
|
7662
|
+
setError("");
|
|
7663
|
+
if (resetSearch) {
|
|
7664
|
+
source.current = { source: "reset" };
|
|
7665
|
+
form.submit();
|
|
7666
|
+
}
|
|
7667
|
+
}
|
|
7668
|
+
async function save() {
|
|
7669
|
+
if (!onSaveQuery || saveLock.current) return false;
|
|
7670
|
+
const name = saveName.trim();
|
|
7671
|
+
if (!name) {
|
|
7672
|
+
setSaveError("\u8BF7\u8F93\u5165\u5FEB\u6377\u67E5\u8BE2\u540D\u79F0");
|
|
7673
|
+
return false;
|
|
7674
|
+
}
|
|
7675
|
+
if (!snapshot.current) return false;
|
|
7676
|
+
saveLock.current = true;
|
|
7677
|
+
setSaving(true);
|
|
7678
|
+
setSaveError("");
|
|
7679
|
+
try {
|
|
7680
|
+
await onSaveQuery({ name, values: snapshot.current });
|
|
7681
|
+
setSaveOpen(false);
|
|
7682
|
+
} catch (reason) {
|
|
7683
|
+
setSaveError(reason instanceof Error ? reason.message : "\u4FDD\u5B58\u5931\u8D25\uFF0C\u8BF7\u91CD\u8BD5");
|
|
7684
|
+
onError?.(reason, "save");
|
|
7685
|
+
return false;
|
|
7686
|
+
} finally {
|
|
7687
|
+
saveLock.current = false;
|
|
7688
|
+
setSaving(false);
|
|
7689
|
+
}
|
|
7690
|
+
}
|
|
7691
|
+
async function remove(query) {
|
|
7692
|
+
if (!onRemoveQuery || shortcutBusy || removeLock.current) return;
|
|
7693
|
+
removeLock.current = true;
|
|
7694
|
+
setRemoving(true);
|
|
7695
|
+
setError("");
|
|
7696
|
+
try {
|
|
7697
|
+
await onRemoveQuery(query);
|
|
7698
|
+
if (activeShortcut === `saved:${query.key}`) setActiveShortcut("");
|
|
7699
|
+
} catch (reason) {
|
|
7700
|
+
setError(reason instanceof Error ? reason.message : "\u5220\u9664\u5931\u8D25\uFF0C\u8BF7\u91CD\u8BD5");
|
|
7701
|
+
onError?.(reason, "remove");
|
|
7702
|
+
} finally {
|
|
7703
|
+
removeLock.current = false;
|
|
7704
|
+
setRemoving(false);
|
|
7705
|
+
}
|
|
7706
|
+
}
|
|
7707
|
+
return /* @__PURE__ */ jsxs23("div", { className: `sia-query-form ${className}`.trim(), children: [
|
|
7708
|
+
/* @__PURE__ */ jsxs23(
|
|
7709
|
+
Form,
|
|
7710
|
+
{
|
|
7711
|
+
...formProps,
|
|
7712
|
+
form,
|
|
7713
|
+
placeholderMode,
|
|
7714
|
+
disabled,
|
|
7715
|
+
onFinish: (values) => {
|
|
7716
|
+
void search(values);
|
|
7717
|
+
},
|
|
7718
|
+
onFinishFailed: (info) => {
|
|
7719
|
+
source.current = { source: "submit" };
|
|
7720
|
+
onFinishFailed?.(info);
|
|
7721
|
+
},
|
|
7722
|
+
onValuesChange: (changed, values) => {
|
|
7723
|
+
setActiveShortcut("");
|
|
7724
|
+
onValuesChange?.(changed, values);
|
|
7725
|
+
},
|
|
7726
|
+
children: [
|
|
7727
|
+
quickQueries.length ? /* @__PURE__ */ jsxs23("div", { className: "sia-query-form__quick", "aria-label": "\u9884\u8BBE\u5FEB\u6377\u67E5\u8BE2", children: [
|
|
7728
|
+
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(
|
|
7729
|
+
Button,
|
|
7730
|
+
{
|
|
7731
|
+
size: query.size ?? quickQuerySize,
|
|
7732
|
+
"aria-pressed": activeShortcut === `quick:${query.key}`,
|
|
7733
|
+
variant: activeShortcut === `quick:${query.key}` ? "primary" : "default",
|
|
7734
|
+
disabled: shortcutBusy || query.disabled,
|
|
7735
|
+
onClick: () => applyShortcut(query, "quick"),
|
|
7736
|
+
children: query.label
|
|
7737
|
+
}
|
|
7738
|
+
) }, query.key)),
|
|
7739
|
+
" "
|
|
7740
|
+
] }) : null,
|
|
7741
|
+
/* @__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: [
|
|
7742
|
+
entries.map((entry, index) => /* @__PURE__ */ jsx24(
|
|
7743
|
+
"div",
|
|
7744
|
+
{
|
|
7745
|
+
className: "sia-query-form__field",
|
|
7746
|
+
hidden: collapsed && index >= Math.min(limit, fittingCount),
|
|
7747
|
+
style: entry.width !== void 0 ? { flexBasis: entry.width, width: entry.width } : void 0,
|
|
7748
|
+
children: entry.content
|
|
7749
|
+
},
|
|
7750
|
+
entry.key
|
|
7751
|
+
)),
|
|
7752
|
+
/* @__PURE__ */ jsxs23("div", { ref: actionsRef, className: "sia-query-form__actions", children: [
|
|
7753
|
+
/* @__PURE__ */ jsxs23(Space.Compact, { children: [
|
|
7754
|
+
/* @__PURE__ */ jsx24(Button, { type: "submit", variant: "primary", loading: loading || searching, disabled, children: searchText }),
|
|
7755
|
+
/* @__PURE__ */ jsx24(Button, { disabled: busy, onClick: reset, children: resetText }),
|
|
7756
|
+
onSaveQuery ? /* @__PURE__ */ jsx24(Button, { disabled: shortcutBusy, onClick: () => {
|
|
7757
|
+
snapshot.current = form.getFieldsValue();
|
|
7758
|
+
setSaveName("");
|
|
7759
|
+
setSaveError("");
|
|
7760
|
+
setSaveOpen(true);
|
|
7761
|
+
}, children: saveText }) : null
|
|
7762
|
+
] }),
|
|
7763
|
+
collapsible && entries.length > 0 ? /* @__PURE__ */ jsx24(
|
|
7764
|
+
Button,
|
|
7765
|
+
{
|
|
7766
|
+
variant: "link",
|
|
7767
|
+
"aria-expanded": !collapsed,
|
|
7768
|
+
icon: /* @__PURE__ */ jsx24(Icon, { name: collapsed ? "chevron-down" : "chevron-up" }),
|
|
7769
|
+
iconPosition: "end",
|
|
7770
|
+
onClick: () => {
|
|
7771
|
+
setInternalCollapsed(!collapsed);
|
|
7772
|
+
onCollapsedChange?.(!collapsed);
|
|
7773
|
+
},
|
|
7774
|
+
children: collapsed ? "\u5C55\u5F00" : "\u6536\u8D77"
|
|
7775
|
+
}
|
|
7776
|
+
) : null,
|
|
7777
|
+
actionsExtra
|
|
7778
|
+
] })
|
|
7779
|
+
] }),
|
|
7780
|
+
savedQueries.length && !collapsed ? /* @__PURE__ */ jsxs23("div", { className: "sia-query-form__saved", "aria-label": "\u5DF2\u4FDD\u5B58\u5FEB\u6377\u67E5\u8BE2", children: [
|
|
7781
|
+
savedQueries.map((query, index) => /* @__PURE__ */ jsx24(
|
|
7782
|
+
Tag,
|
|
7783
|
+
{
|
|
7784
|
+
status: query.status ?? ["processing", "success", "warning", "error"][index % 4],
|
|
7785
|
+
variant: "soft",
|
|
7786
|
+
disabled: shortcutBusy || query.disabled,
|
|
7787
|
+
tabIndex: shortcutBusy || query.disabled ? -1 : 0,
|
|
7788
|
+
className: activeShortcut === `saved:${query.key}` ? "is-active" : "",
|
|
7789
|
+
closable: Boolean(onRemoveQuery),
|
|
7790
|
+
closeOnHover: true,
|
|
7791
|
+
onClose: () => {
|
|
7792
|
+
void remove(query);
|
|
7793
|
+
},
|
|
7794
|
+
onClick: () => applyShortcut(query, "saved"),
|
|
7795
|
+
onKeyDown: (event) => {
|
|
7796
|
+
if (event.target === event.currentTarget && (event.key === "Enter" || event.key === " ")) {
|
|
7797
|
+
event.preventDefault();
|
|
7798
|
+
applyShortcut(query, "saved");
|
|
7799
|
+
}
|
|
7800
|
+
},
|
|
7801
|
+
children: query.label
|
|
7802
|
+
},
|
|
7803
|
+
query.key
|
|
7804
|
+
)),
|
|
7805
|
+
" "
|
|
7806
|
+
] }) : null,
|
|
7807
|
+
error ? /* @__PURE__ */ jsx24("p", { className: "sia-query-form__error", role: "alert", children: error }) : null
|
|
7808
|
+
]
|
|
7809
|
+
}
|
|
7810
|
+
),
|
|
7811
|
+
/* @__PURE__ */ jsxs23(Modal, { open: saveOpen, title: "\u53E6\u5B58\u4E3A\u5FEB\u6377\u67E5\u8BE2", width: 420, confirmLoading: saving, onOk: save, onOpenChange: (next) => {
|
|
7812
|
+
if (!saveLock.current) setSaveOpen(next);
|
|
7813
|
+
}, children: [
|
|
7814
|
+
/* @__PURE__ */ jsx24(
|
|
7815
|
+
Input,
|
|
7816
|
+
{
|
|
7817
|
+
autoFocus: true,
|
|
7818
|
+
"aria-label": "\u5FEB\u6377\u67E5\u8BE2\u540D\u79F0",
|
|
7819
|
+
placeholder: "\u5FEB\u6377\u67E5\u8BE2\u540D\u79F0",
|
|
7820
|
+
value: saveName,
|
|
7821
|
+
maxLength: 80,
|
|
7822
|
+
disabled: saving,
|
|
7823
|
+
status: saveError ? "error" : "default",
|
|
7824
|
+
onChange: (event) => setSaveName(event.target.value),
|
|
7825
|
+
onKeyDown: (event) => {
|
|
7826
|
+
if (event.key === "Enter") {
|
|
7827
|
+
event.preventDefault();
|
|
7828
|
+
void save();
|
|
7829
|
+
}
|
|
7830
|
+
}
|
|
7831
|
+
}
|
|
7832
|
+
),
|
|
7833
|
+
saveError ? /* @__PURE__ */ jsx24("p", { className: "sia-query-form__error", role: "alert", children: saveError }) : null
|
|
7834
|
+
] })
|
|
7835
|
+
] });
|
|
7836
|
+
}
|
|
7462
7837
|
export {
|
|
7463
7838
|
Alert,
|
|
7464
7839
|
Badge,
|
|
@@ -7531,6 +7906,7 @@ export {
|
|
|
7531
7906
|
Popconfirm,
|
|
7532
7907
|
Popover,
|
|
7533
7908
|
Progress,
|
|
7909
|
+
QueryForm,
|
|
7534
7910
|
RadarChart,
|
|
7535
7911
|
Radio2 as Radio,
|
|
7536
7912
|
Rate,
|