@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.cjs
CHANGED
|
@@ -101,6 +101,7 @@ __export(index_exports, {
|
|
|
101
101
|
Popconfirm: () => Popconfirm,
|
|
102
102
|
Popover: () => Popover,
|
|
103
103
|
Progress: () => Progress,
|
|
104
|
+
QueryForm: () => QueryForm,
|
|
104
105
|
RadarChart: () => RadarChart,
|
|
105
106
|
Radio: () => Radio2,
|
|
106
107
|
Rate: () => Rate,
|
|
@@ -1039,11 +1040,35 @@ function Alert({
|
|
|
1039
1040
|
] });
|
|
1040
1041
|
}
|
|
1041
1042
|
|
|
1043
|
+
// src/components/shared.ts
|
|
1044
|
+
var import_react3 = require("react");
|
|
1045
|
+
var ControlSizeContext = (0, import_react3.createContext)("medium");
|
|
1046
|
+
function useControlSize(size) {
|
|
1047
|
+
const inherited = (0, import_react3.useContext)(ControlSizeContext);
|
|
1048
|
+
return size ?? inherited;
|
|
1049
|
+
}
|
|
1050
|
+
var PlaceholderModeContext = (0, import_react3.createContext)("default");
|
|
1051
|
+
function usePlaceholderMode(mode) {
|
|
1052
|
+
const inherited = (0, import_react3.useContext)(PlaceholderModeContext);
|
|
1053
|
+
return mode ?? inherited;
|
|
1054
|
+
}
|
|
1055
|
+
function useControllableState({ value, defaultValue, onChange }) {
|
|
1056
|
+
const [internalValue, setInternalValue] = (0, import_react3.useState)(defaultValue);
|
|
1057
|
+
const controlled = value !== void 0;
|
|
1058
|
+
const currentValue = controlled ? value : internalValue;
|
|
1059
|
+
const setValue2 = (0, import_react3.useCallback)((nextValue) => {
|
|
1060
|
+
if (Object.is(currentValue, nextValue)) return;
|
|
1061
|
+
if (!controlled) setInternalValue(nextValue);
|
|
1062
|
+
onChange?.(nextValue);
|
|
1063
|
+
}, [controlled, currentValue, onChange]);
|
|
1064
|
+
return [currentValue, setValue2];
|
|
1065
|
+
}
|
|
1066
|
+
|
|
1042
1067
|
// src/components/Navigation.tsx
|
|
1043
1068
|
var import_react5 = require("react");
|
|
1044
1069
|
|
|
1045
1070
|
// src/components/PopupPortal.tsx
|
|
1046
|
-
var
|
|
1071
|
+
var import_react4 = require("react");
|
|
1047
1072
|
var import_react_dom = require("react-dom");
|
|
1048
1073
|
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
1049
1074
|
function setForwardedRef(ref, value) {
|
|
@@ -1053,7 +1078,7 @@ function setForwardedRef(ref, value) {
|
|
|
1053
1078
|
function clamp(value, min, max) {
|
|
1054
1079
|
return Math.min(Math.max(value, min), Math.max(min, max));
|
|
1055
1080
|
}
|
|
1056
|
-
var PopupPortal = (0,
|
|
1081
|
+
var PopupPortal = (0, import_react4.forwardRef)(function PopupPortal2({
|
|
1057
1082
|
anchorRef,
|
|
1058
1083
|
open = true,
|
|
1059
1084
|
placement = "bottom-start",
|
|
@@ -1064,9 +1089,9 @@ var PopupPortal = (0, import_react3.forwardRef)(function PopupPortal2({
|
|
|
1064
1089
|
children,
|
|
1065
1090
|
...props
|
|
1066
1091
|
}, forwardedRef) {
|
|
1067
|
-
const popupRef = (0,
|
|
1068
|
-
const [position, setPosition] = (0,
|
|
1069
|
-
(0,
|
|
1092
|
+
const popupRef = (0, import_react4.useRef)(null);
|
|
1093
|
+
const [position, setPosition] = (0, import_react4.useState)();
|
|
1094
|
+
(0, import_react4.useLayoutEffect)(() => {
|
|
1070
1095
|
if (!open || typeof document === "undefined") {
|
|
1071
1096
|
setPosition(void 0);
|
|
1072
1097
|
return;
|
|
@@ -1157,25 +1182,6 @@ var PopupPortal = (0, import_react3.forwardRef)(function PopupPortal2({
|
|
|
1157
1182
|
);
|
|
1158
1183
|
});
|
|
1159
1184
|
|
|
1160
|
-
// src/components/shared.ts
|
|
1161
|
-
var import_react4 = require("react");
|
|
1162
|
-
var PlaceholderModeContext = (0, import_react4.createContext)("default");
|
|
1163
|
-
function usePlaceholderMode(mode) {
|
|
1164
|
-
const inherited = (0, import_react4.useContext)(PlaceholderModeContext);
|
|
1165
|
-
return mode ?? inherited;
|
|
1166
|
-
}
|
|
1167
|
-
function useControllableState({ value, defaultValue, onChange }) {
|
|
1168
|
-
const [internalValue, setInternalValue] = (0, import_react4.useState)(defaultValue);
|
|
1169
|
-
const controlled = value !== void 0;
|
|
1170
|
-
const currentValue = controlled ? value : internalValue;
|
|
1171
|
-
const setValue2 = (0, import_react4.useCallback)((nextValue) => {
|
|
1172
|
-
if (Object.is(currentValue, nextValue)) return;
|
|
1173
|
-
if (!controlled) setInternalValue(nextValue);
|
|
1174
|
-
onChange?.(nextValue);
|
|
1175
|
-
}, [controlled, currentValue, onChange]);
|
|
1176
|
-
return [currentValue, setValue2];
|
|
1177
|
-
}
|
|
1178
|
-
|
|
1179
1185
|
// src/components/Navigation.tsx
|
|
1180
1186
|
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
1181
1187
|
function MenuPopup({
|
|
@@ -1377,7 +1383,8 @@ function Steps({ items, current = 0, initial: initial3 = 0, direction = "horizon
|
|
|
1377
1383
|
] }, index);
|
|
1378
1384
|
}) });
|
|
1379
1385
|
}
|
|
1380
|
-
function Segmented({ options, value, defaultValue, size
|
|
1386
|
+
function Segmented({ options, value, defaultValue, size: sizeProp, block = false, vertical = false, disabled = false, onChange, className = "", onKeyDown, ...props }) {
|
|
1387
|
+
const size = useControlSize(sizeProp);
|
|
1381
1388
|
const normalized = (0, import_react5.useMemo)(() => options.map((option) => typeof option === "object" ? option : { label: option, value: option }), [options]);
|
|
1382
1389
|
const [current, setCurrent] = useControllableState({ value, defaultValue: defaultValue ?? normalized[0]?.value, onChange: (next) => next !== void 0 && onChange?.(next) });
|
|
1383
1390
|
function keyboard(event) {
|
|
@@ -1403,7 +1410,7 @@ var import_react6 = require("react");
|
|
|
1403
1410
|
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
1404
1411
|
var Button = (0, import_react6.forwardRef)(function Button2({
|
|
1405
1412
|
variant = "default",
|
|
1406
|
-
size
|
|
1413
|
+
size: sizeProp,
|
|
1407
1414
|
loading = false,
|
|
1408
1415
|
block = false,
|
|
1409
1416
|
danger = false,
|
|
@@ -1416,6 +1423,7 @@ var Button = (0, import_react6.forwardRef)(function Button2({
|
|
|
1416
1423
|
style,
|
|
1417
1424
|
...props
|
|
1418
1425
|
}, forwardedRef) {
|
|
1426
|
+
const size = useControlSize(sizeProp);
|
|
1419
1427
|
const localRef = (0, import_react6.useRef)(null);
|
|
1420
1428
|
function setRef(node) {
|
|
1421
1429
|
localRef.current = node;
|
|
@@ -2027,7 +2035,7 @@ var Input = (0, import_react10.forwardRef)(function Input2({
|
|
|
2027
2035
|
label,
|
|
2028
2036
|
hint,
|
|
2029
2037
|
status = "default",
|
|
2030
|
-
size
|
|
2038
|
+
size: sizeProp,
|
|
2031
2039
|
prefix,
|
|
2032
2040
|
suffix,
|
|
2033
2041
|
allowClear = false,
|
|
@@ -2044,6 +2052,7 @@ var Input = (0, import_react10.forwardRef)(function Input2({
|
|
|
2044
2052
|
onChange,
|
|
2045
2053
|
...props
|
|
2046
2054
|
}, forwardedRef) {
|
|
2055
|
+
const size = useControlSize(sizeProp);
|
|
2047
2056
|
const fallbackId = (0, import_react10.useId)();
|
|
2048
2057
|
const inputId = id ?? fallbackId;
|
|
2049
2058
|
const localRef = (0, import_react10.useRef)(null);
|
|
@@ -2127,7 +2136,8 @@ var Input = (0, import_react10.forwardRef)(function Input2({
|
|
|
2127
2136
|
var import_react11 = require("react");
|
|
2128
2137
|
var import_jsx_runtime11 = require("react/jsx-runtime");
|
|
2129
2138
|
var CheckboxGroupContext = (0, import_react11.createContext)(null);
|
|
2130
|
-
var CheckboxRoot = (0, import_react11.forwardRef)(function Checkbox({ value, indeterminate = false, children, disabled, checked, defaultChecked, className = "", onChange, ...props }, forwardedRef) {
|
|
2139
|
+
var CheckboxRoot = (0, import_react11.forwardRef)(function Checkbox({ value, size: sizeProp, indeterminate = false, children, disabled, checked, defaultChecked, className = "", onChange, ...props }, forwardedRef) {
|
|
2140
|
+
const size = useControlSize(sizeProp);
|
|
2131
2141
|
const group = (0, import_react11.useContext)(CheckboxGroupContext);
|
|
2132
2142
|
const localRef = (0, import_react11.useRef)(null);
|
|
2133
2143
|
const fallbackId = (0, import_react11.useId)();
|
|
@@ -2141,7 +2151,7 @@ var CheckboxRoot = (0, import_react11.forwardRef)(function Checkbox({ value, ind
|
|
|
2141
2151
|
if (typeof forwardedRef === "function") forwardedRef(node);
|
|
2142
2152
|
else if (forwardedRef) forwardedRef.current = node;
|
|
2143
2153
|
}
|
|
2144
|
-
return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("label", { className: `sia-checkbox${disabled || group?.disabled ? " is-disabled" : ""} ${className}`.trim(), children: [
|
|
2154
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("label", { className: `sia-checkbox sia-checkbox--${size}${disabled || group?.disabled ? " is-disabled" : ""} ${className}`.trim(), children: [
|
|
2145
2155
|
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
2146
2156
|
"input",
|
|
2147
2157
|
{
|
|
@@ -2166,6 +2176,7 @@ var CheckboxRoot = (0, import_react11.forwardRef)(function Checkbox({ value, ind
|
|
|
2166
2176
|
] });
|
|
2167
2177
|
});
|
|
2168
2178
|
function CheckboxGroup({
|
|
2179
|
+
size: sizeProp,
|
|
2169
2180
|
value,
|
|
2170
2181
|
defaultValue = [],
|
|
2171
2182
|
options,
|
|
@@ -2175,6 +2186,7 @@ function CheckboxGroup({
|
|
|
2175
2186
|
children,
|
|
2176
2187
|
onChange
|
|
2177
2188
|
}) {
|
|
2189
|
+
const size = useControlSize(sizeProp);
|
|
2178
2190
|
const [values, setValues] = useControllableState({ value, defaultValue, onChange });
|
|
2179
2191
|
const context = (0, import_react11.useMemo)(() => ({
|
|
2180
2192
|
values,
|
|
@@ -2185,13 +2197,13 @@ function CheckboxGroup({
|
|
|
2185
2197
|
setValues(next);
|
|
2186
2198
|
}
|
|
2187
2199
|
}), [disabled, name, setValues, values]);
|
|
2188
|
-
return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(CheckboxGroupContext.Provider, { value: context, children: /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: `sia-checkbox-group ${className}`.trim(), role: "group", children: [
|
|
2200
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(ControlSizeContext.Provider, { value: size, children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(CheckboxGroupContext.Provider, { value: context, children: /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: `sia-checkbox-group ${className}`.trim(), role: "group", children: [
|
|
2189
2201
|
options?.map((option) => {
|
|
2190
2202
|
const normalized = typeof option === "object" ? option : { label: String(option), value: option };
|
|
2191
2203
|
return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(CheckboxRoot, { value: normalized.value, disabled: normalized.disabled, children: normalized.label }, normalized.value);
|
|
2192
2204
|
}),
|
|
2193
2205
|
children
|
|
2194
|
-
] }) });
|
|
2206
|
+
] }) }) });
|
|
2195
2207
|
}
|
|
2196
2208
|
var Checkbox2 = Object.assign(CheckboxRoot, { Group: CheckboxGroup });
|
|
2197
2209
|
|
|
@@ -2885,7 +2897,7 @@ var Select = (0, import_react15.forwardRef)(function Select2({
|
|
|
2885
2897
|
onChange,
|
|
2886
2898
|
placeholder = "\u8BF7\u9009\u62E9",
|
|
2887
2899
|
placeholderMode,
|
|
2888
|
-
size
|
|
2900
|
+
size: sizeProp,
|
|
2889
2901
|
status = "default",
|
|
2890
2902
|
allowClear = false,
|
|
2891
2903
|
loading = false,
|
|
@@ -2911,6 +2923,7 @@ var Select = (0, import_react15.forwardRef)(function Select2({
|
|
|
2911
2923
|
onKeyDown,
|
|
2912
2924
|
...props
|
|
2913
2925
|
}, forwardedRef) {
|
|
2926
|
+
const size = useControlSize(sizeProp);
|
|
2914
2927
|
const fallbackId = (0, import_react15.useId)();
|
|
2915
2928
|
const selectId = id ?? fallbackId;
|
|
2916
2929
|
const listboxId = `${selectId}-listbox`;
|
|
@@ -3297,6 +3310,7 @@ var Select = (0, import_react15.forwardRef)(function Select2({
|
|
|
3297
3310
|
var import_jsx_runtime16 = require("react/jsx-runtime");
|
|
3298
3311
|
var DEFAULT_PAGE_SIZE_OPTIONS = [10, 25, 50, 100, 200, 500, 1e3, 2e3, 5e3];
|
|
3299
3312
|
function Pagination({
|
|
3313
|
+
size: sizeProp,
|
|
3300
3314
|
total = 0,
|
|
3301
3315
|
current,
|
|
3302
3316
|
defaultCurrent = 1,
|
|
@@ -3314,6 +3328,7 @@ function Pagination({
|
|
|
3314
3328
|
className = "",
|
|
3315
3329
|
...props
|
|
3316
3330
|
}) {
|
|
3331
|
+
const controlSize = useControlSize(sizeProp);
|
|
3317
3332
|
const [size, setSize] = useControllableState({ value: pageSize, defaultValue: Math.max(1, defaultPageSize) });
|
|
3318
3333
|
const [page, setPage] = useControllableState({ value: current, defaultValue: Math.max(1, defaultCurrent) });
|
|
3319
3334
|
const [internalRefreshing, setInternalRefreshing] = (0, import_react16.useState)(false);
|
|
@@ -3345,14 +3360,14 @@ function Pagination({
|
|
|
3345
3360
|
if (refreshing === void 0) setInternalRefreshing(false);
|
|
3346
3361
|
}
|
|
3347
3362
|
}
|
|
3348
|
-
return /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("nav", { className: `sia-pagination ${className}`.trim(), "aria-label": "\u5206\u9875", ...props, children: [
|
|
3363
|
+
return /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("nav", { className: `sia-pagination sia-pagination--${controlSize} ${className}`.trim(), "aria-label": "\u5206\u9875", ...props, children: [
|
|
3349
3364
|
showSizeChanger ? /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { className: "sia-pagination__size", children: [
|
|
3350
3365
|
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)("span", { children: "\u6BCF\u9875\u663E\u793A" }),
|
|
3351
3366
|
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
3352
3367
|
Select,
|
|
3353
3368
|
{
|
|
3354
3369
|
className: "sia-pagination__size-select",
|
|
3355
|
-
size:
|
|
3370
|
+
size: controlSize,
|
|
3356
3371
|
"aria-label": "\u6BCF\u9875\u6761\u6570",
|
|
3357
3372
|
value: size,
|
|
3358
3373
|
options: sizes.map((value) => ({ label: `${value} \u6761`, value })),
|
|
@@ -3367,7 +3382,7 @@ function Pagination({
|
|
|
3367
3382
|
Button,
|
|
3368
3383
|
{
|
|
3369
3384
|
variant: "text",
|
|
3370
|
-
size:
|
|
3385
|
+
size: controlSize,
|
|
3371
3386
|
className: "sia-pagination__total",
|
|
3372
3387
|
disabled: disabled || !onRefreshTotal || loading,
|
|
3373
3388
|
title: onRefreshTotal ? "\u70B9\u51FB\u5237\u65B0\u603B\u8BB0\u5F55\u6570" : void 0,
|
|
@@ -3382,15 +3397,15 @@ function Pagination({
|
|
|
3382
3397
|
}
|
|
3383
3398
|
) : null,
|
|
3384
3399
|
/* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { className: "sia-pagination__buttons", children: [
|
|
3385
|
-
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)(Button, { size:
|
|
3386
|
-
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)(Button, { size:
|
|
3400
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)(Button, { size: controlSize, variant: "text", "aria-label": "\u7B2C\u4E00\u9875", disabled: disabled || safePage <= 1, onClick: () => change(1), children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(Icon, { name: "double-left", size: 15 }) }),
|
|
3401
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)(Button, { size: controlSize, variant: "text", "aria-label": "\u4E0A\u4E00\u9875", disabled: disabled || safePage <= 1, onClick: () => change(safePage - 1), children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(Icon, { name: "chevron-left", size: 15 }) }),
|
|
3387
3402
|
/* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("span", { "aria-live": "polite", children: [
|
|
3388
3403
|
safePage,
|
|
3389
3404
|
" / ",
|
|
3390
3405
|
totalPages
|
|
3391
3406
|
] }),
|
|
3392
|
-
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)(Button, { size:
|
|
3393
|
-
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)(Button, { size:
|
|
3407
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)(Button, { size: controlSize, variant: "text", "aria-label": "\u4E0B\u4E00\u9875", disabled: disabled || safePage >= totalPages, onClick: () => change(safePage + 1), children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(Icon, { name: "chevron-right", size: 15 }) }),
|
|
3408
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)(Button, { size: controlSize, variant: "text", "aria-label": "\u6700\u540E\u4E00\u9875", disabled: disabled || safePage >= totalPages, onClick: () => change(totalPages), children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(Icon, { name: "double-right", size: 15 }) })
|
|
3394
3409
|
] })
|
|
3395
3410
|
] });
|
|
3396
3411
|
}
|
|
@@ -3435,6 +3450,7 @@ function Cascader({
|
|
|
3435
3450
|
options,
|
|
3436
3451
|
value,
|
|
3437
3452
|
defaultValue,
|
|
3453
|
+
size: sizeProp,
|
|
3438
3454
|
multiple = false,
|
|
3439
3455
|
showSearch = false,
|
|
3440
3456
|
allowClear = false,
|
|
@@ -3450,6 +3466,7 @@ function Cascader({
|
|
|
3450
3466
|
className = "",
|
|
3451
3467
|
...props
|
|
3452
3468
|
}) {
|
|
3469
|
+
const size = useControlSize(sizeProp);
|
|
3453
3470
|
const fields = (0, import_react17.useMemo)(() => ({ label: fieldNames?.label ?? "label", value: fieldNames?.value ?? "value", children: fieldNames?.children ?? "children" }), [fieldNames]);
|
|
3454
3471
|
const rootRef = (0, import_react17.useRef)(null);
|
|
3455
3472
|
const popupRef = (0, import_react17.useRef)(null);
|
|
@@ -3538,7 +3555,7 @@ function Cascader({
|
|
|
3538
3555
|
if (children?.length) columns.push(children);
|
|
3539
3556
|
});
|
|
3540
3557
|
const floating = useFloatingPlaceholder({ mode: placeholderMode, placeholder, filled: selectedPaths.length > 0, active: open });
|
|
3541
|
-
return /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { ref: rootRef, className: `sia-cascader${open ? " is-open" : ""}${disabled ? " is-disabled" : ""} ${className}`.trim(), ...props, children: [
|
|
3558
|
+
return /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { ref: rootRef, className: `sia-cascader sia-cascader--${size}${open ? " is-open" : ""}${disabled ? " is-disabled" : ""} ${className}`.trim(), ...props, children: [
|
|
3542
3559
|
/* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("button", { type: "button", className: `sia-cascader__trigger${floating.className}`, disabled, "aria-haspopup": "listbox", "aria-expanded": open, onClick: toggleOpen, children: [
|
|
3543
3560
|
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)("span", { className: "sia-cascader__value", children: display ? multiple && Array.isArray(display) ? display.map((label, index) => /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("span", { className: "sia-cascader__tag", children: label }, pathKey(selectedPaths[index] ?? []))) : display : /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("span", { className: "sia-cascader__placeholder", children: placeholder }) }),
|
|
3544
3561
|
allowClear && selectedPaths.length ? /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("span", { className: "sia-cascader__clear", role: "button", "aria-label": "\u6E05\u9664\u9009\u62E9", onClick: (event) => {
|
|
@@ -3604,14 +3621,15 @@ function Cascader({
|
|
|
3604
3621
|
var import_react18 = require("react");
|
|
3605
3622
|
var import_react_dom4 = require("react-dom");
|
|
3606
3623
|
var import_jsx_runtime18 = require("react/jsx-runtime");
|
|
3607
|
-
function Rate({ value, defaultValue = 0, count = 5, allowHalf = false, allowClear = true, disabled = false, character, tooltips, onChange, onHoverChange, className = "", ...props }) {
|
|
3624
|
+
function Rate({ value, size: sizeProp, defaultValue = 0, count = 5, allowHalf = false, allowClear = true, disabled = false, character, tooltips, onChange, onHoverChange, className = "", ...props }) {
|
|
3625
|
+
const size = useControlSize(sizeProp);
|
|
3608
3626
|
const [current, setCurrent] = useControllableState({ value, defaultValue, onChange });
|
|
3609
3627
|
const [hover, setHover] = (0, import_react18.useState)(0);
|
|
3610
3628
|
const shown = hover || current;
|
|
3611
3629
|
function choose(next) {
|
|
3612
3630
|
setCurrent(allowClear && next === current ? 0 : next);
|
|
3613
3631
|
}
|
|
3614
|
-
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", { className: `sia-rate${disabled ? " is-disabled" : ""} ${className}`.trim(), role: "radiogroup", "aria-label": "\u8BC4\u5206", onMouseLeave: () => {
|
|
3632
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", { className: `sia-rate sia-rate--${size}${disabled ? " is-disabled" : ""} ${className}`.trim(), role: "radiogroup", "aria-label": "\u8BC4\u5206", onMouseLeave: () => {
|
|
3615
3633
|
setHover(0);
|
|
3616
3634
|
onHoverChange?.(0);
|
|
3617
3635
|
}, ...props, children: Array.from({ length: count }, (_, index) => {
|
|
@@ -5069,6 +5087,7 @@ var import_jsx_runtime26 = require("react/jsx-runtime");
|
|
|
5069
5087
|
var Switch = (0, import_react25.forwardRef)(function Switch2({
|
|
5070
5088
|
label,
|
|
5071
5089
|
variant = "standard",
|
|
5090
|
+
size: sizeProp,
|
|
5072
5091
|
checkedContent,
|
|
5073
5092
|
uncheckedContent,
|
|
5074
5093
|
onChange,
|
|
@@ -5076,6 +5095,7 @@ var Switch = (0, import_react25.forwardRef)(function Switch2({
|
|
|
5076
5095
|
className = "",
|
|
5077
5096
|
...props
|
|
5078
5097
|
}, ref) {
|
|
5098
|
+
const size = useControlSize(sizeProp);
|
|
5079
5099
|
const hasContent = checkedContent !== void 0 || uncheckedContent !== void 0;
|
|
5080
5100
|
const checkedVisual = checkedContent ?? (variant === "segmented" ? "\u5F00" : null);
|
|
5081
5101
|
const uncheckedVisual = uncheckedContent ?? (variant === "segmented" ? "\u5173" : null);
|
|
@@ -5083,7 +5103,7 @@ var Switch = (0, import_react25.forwardRef)(function Switch2({
|
|
|
5083
5103
|
onCheckedChange?.(event.currentTarget.checked);
|
|
5084
5104
|
onChange?.(event);
|
|
5085
5105
|
};
|
|
5086
|
-
return /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)("label", { className: `sia-switch-wrap ${className}`.trim(), children: [
|
|
5106
|
+
return /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)("label", { className: `sia-switch-wrap sia-switch-wrap--${size} ${className}`.trim(), children: [
|
|
5087
5107
|
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)("input", { ref, type: "checkbox", role: "switch", className: "sia-switch-input", onChange: handleChange, ...props }),
|
|
5088
5108
|
/* @__PURE__ */ (0, import_jsx_runtime26.jsxs)(
|
|
5089
5109
|
"span",
|
|
@@ -5292,6 +5312,7 @@ function FormRoot({
|
|
|
5292
5312
|
form,
|
|
5293
5313
|
initialValues,
|
|
5294
5314
|
layout = "horizontal",
|
|
5315
|
+
size: sizeProp,
|
|
5295
5316
|
placeholderMode,
|
|
5296
5317
|
disabled = false,
|
|
5297
5318
|
requiredMark = true,
|
|
@@ -5302,16 +5323,17 @@ function FormRoot({
|
|
|
5302
5323
|
children,
|
|
5303
5324
|
...props
|
|
5304
5325
|
}) {
|
|
5326
|
+
const size = useControlSize(sizeProp);
|
|
5305
5327
|
const resolvedPlaceholderMode = usePlaceholderMode(placeholderMode);
|
|
5306
5328
|
const [internalForm] = useForm(form);
|
|
5307
5329
|
const instance = internalForm;
|
|
5308
5330
|
instance.configure(initialValues, { onFinish, onFinishFailed, onValuesChange });
|
|
5309
5331
|
const context = (0, import_react25.useMemo)(() => instance, [instance]);
|
|
5310
|
-
return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(FormContext.Provider, { value: context, children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(PlaceholderModeContext.Provider, { value: resolvedPlaceholderMode, children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
5332
|
+
return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(FormContext.Provider, { value: context, children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(PlaceholderModeContext.Provider, { value: resolvedPlaceholderMode, children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(ControlSizeContext.Provider, { value: size, children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
5311
5333
|
"form",
|
|
5312
5334
|
{
|
|
5313
5335
|
...props,
|
|
5314
|
-
className: `sia-form sia-form--${layout}${disabled ? " is-disabled" : ""} ${className}`.trim(),
|
|
5336
|
+
className: `sia-form sia-form--${layout} sia-form--${size}${disabled ? " is-disabled" : ""} ${className}`.trim(),
|
|
5315
5337
|
"data-required-mark": requiredMark,
|
|
5316
5338
|
onSubmit: (event) => {
|
|
5317
5339
|
event.preventDefault();
|
|
@@ -5319,7 +5341,7 @@ function FormRoot({
|
|
|
5319
5341
|
},
|
|
5320
5342
|
children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("fieldset", { disabled, children })
|
|
5321
5343
|
}
|
|
5322
|
-
) }) });
|
|
5344
|
+
) }) }) });
|
|
5323
5345
|
}
|
|
5324
5346
|
function defaultEventValue(valuePropName, args) {
|
|
5325
5347
|
const first = args[0];
|
|
@@ -5467,12 +5489,13 @@ var Form = Object.assign(FormRoot, {
|
|
|
5467
5489
|
var import_react26 = require("react");
|
|
5468
5490
|
var import_jsx_runtime27 = require("react/jsx-runtime");
|
|
5469
5491
|
var RadioContext = (0, import_react26.createContext)(null);
|
|
5470
|
-
var RadioRoot = (0, import_react26.forwardRef)(function Radio({ value, children, disabled, checked, defaultChecked, button = false, className = "", onChange, ...props }, ref) {
|
|
5492
|
+
var RadioRoot = (0, import_react26.forwardRef)(function Radio({ value, size: sizeProp, children, disabled, checked, defaultChecked, button = false, className = "", onChange, ...props }, ref) {
|
|
5493
|
+
const size = useControlSize(sizeProp);
|
|
5471
5494
|
const group = (0, import_react26.useContext)(RadioContext);
|
|
5472
5495
|
const fallbackId = (0, import_react26.useId)();
|
|
5473
5496
|
const grouped = group !== null;
|
|
5474
5497
|
const currentChecked = grouped ? group.value === value : checked;
|
|
5475
|
-
return /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("label", { className: `sia-radio${button ? " sia-radio--button" : ""}${button && group?.buttonStyle === "solid" ? " sia-radio--solid" : ""}${disabled || group?.disabled ? " is-disabled" : ""} ${className}`.trim(), children: [
|
|
5498
|
+
return /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("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: [
|
|
5476
5499
|
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
|
|
5477
5500
|
"input",
|
|
5478
5501
|
{
|
|
@@ -5500,6 +5523,7 @@ function RadioButton(props) {
|
|
|
5500
5523
|
return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(RadioRoot, { ...props, button: true });
|
|
5501
5524
|
}
|
|
5502
5525
|
function RadioGroup({
|
|
5526
|
+
size: sizeProp,
|
|
5503
5527
|
value,
|
|
5504
5528
|
defaultValue,
|
|
5505
5529
|
options,
|
|
@@ -5511,6 +5535,7 @@ function RadioGroup({
|
|
|
5511
5535
|
children,
|
|
5512
5536
|
onChange
|
|
5513
5537
|
}) {
|
|
5538
|
+
const size = useControlSize(sizeProp);
|
|
5514
5539
|
const fallbackName = (0, import_react26.useId)();
|
|
5515
5540
|
const [currentValue, setValue2] = useControllableState({
|
|
5516
5541
|
value,
|
|
@@ -5527,13 +5552,13 @@ function RadioGroup({
|
|
|
5527
5552
|
setValue: setValue2
|
|
5528
5553
|
}), [buttonStyle, currentValue, disabled, fallbackName, name, setValue2]);
|
|
5529
5554
|
const Component = optionType === "button" ? RadioButton : RadioRoot;
|
|
5530
|
-
return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(RadioContext.Provider, { value: context, children: /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("div", { className: `sia-radio-group${optionType === "button" ? " sia-radio-group--button" : ""} ${className}`.trim(), role: "radiogroup", children: [
|
|
5555
|
+
return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(ControlSizeContext.Provider, { value: size, children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(RadioContext.Provider, { value: context, children: /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("div", { className: `sia-radio-group${optionType === "button" ? " sia-radio-group--button" : ""} ${className}`.trim(), role: "radiogroup", children: [
|
|
5531
5556
|
options?.map((option) => {
|
|
5532
5557
|
const normalized = typeof option === "object" ? option : { label: String(option), value: option };
|
|
5533
5558
|
return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(Component, { value: normalized.value, disabled: normalized.disabled, children: normalized.label }, normalized.value);
|
|
5534
5559
|
}),
|
|
5535
5560
|
children
|
|
5536
|
-
] }) });
|
|
5561
|
+
] }) }) });
|
|
5537
5562
|
}
|
|
5538
5563
|
var Radio2 = Object.assign(RadioRoot, { Button: RadioButton, Group: RadioGroup });
|
|
5539
5564
|
|
|
@@ -5728,6 +5753,7 @@ function createDefaultStops(color) {
|
|
|
5728
5753
|
return [createStop(color, 0), createStop("#FFFFFF", 100)];
|
|
5729
5754
|
}
|
|
5730
5755
|
function ColorPicker({
|
|
5756
|
+
size: sizeProp,
|
|
5731
5757
|
value,
|
|
5732
5758
|
defaultValue = "#1677FF",
|
|
5733
5759
|
mode,
|
|
@@ -5745,6 +5771,7 @@ function ColorPicker({
|
|
|
5745
5771
|
onClear,
|
|
5746
5772
|
...props
|
|
5747
5773
|
}) {
|
|
5774
|
+
const size = useControlSize(sizeProp);
|
|
5748
5775
|
const rootRef = (0, import_react28.useRef)(null);
|
|
5749
5776
|
const popupRef = (0, import_react28.useRef)(null);
|
|
5750
5777
|
const lastEmittedValue = (0, import_react28.useRef)();
|
|
@@ -5845,7 +5872,7 @@ function ColorPicker({
|
|
|
5845
5872
|
const triggerBackground = color || "transparent";
|
|
5846
5873
|
const triggerText = color || "\u65E0\u8272";
|
|
5847
5874
|
const opaqueColor = rgbaToHex({ ...rgba, a: 100 }, false);
|
|
5848
|
-
return /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)("div", { ref: rootRef, className: `sia-color-picker${disabled ? " is-disabled" : ""} ${className}`.trim(), ...props, children: [
|
|
5875
|
+
return /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)("div", { ref: rootRef, className: `sia-color-picker sia-color-picker--${size}${disabled ? " is-disabled" : ""} ${className}`.trim(), ...props, children: [
|
|
5849
5876
|
/* @__PURE__ */ (0, import_jsx_runtime29.jsxs)(
|
|
5850
5877
|
"button",
|
|
5851
5878
|
{
|
|
@@ -6233,7 +6260,7 @@ function DatePicker({
|
|
|
6233
6260
|
value,
|
|
6234
6261
|
defaultValue,
|
|
6235
6262
|
picker = "date",
|
|
6236
|
-
size
|
|
6263
|
+
size: sizeProp,
|
|
6237
6264
|
status = "default",
|
|
6238
6265
|
allowClear = true,
|
|
6239
6266
|
multiple = false,
|
|
@@ -6257,6 +6284,7 @@ function DatePicker({
|
|
|
6257
6284
|
renderExtraFooter,
|
|
6258
6285
|
...props
|
|
6259
6286
|
}) {
|
|
6287
|
+
const size = useControlSize(sizeProp);
|
|
6260
6288
|
const id = (0, import_react30.useId)();
|
|
6261
6289
|
const rootRef = (0, import_react30.useRef)(null);
|
|
6262
6290
|
const popupRef = (0, import_react30.useRef)(null);
|
|
@@ -6417,7 +6445,7 @@ function DateRangePicker({
|
|
|
6417
6445
|
maxRangeDays,
|
|
6418
6446
|
allowEmpty = [false, false],
|
|
6419
6447
|
endpointDisabled = [false, false],
|
|
6420
|
-
size
|
|
6448
|
+
size: sizeProp,
|
|
6421
6449
|
status = "default",
|
|
6422
6450
|
allowClear = true,
|
|
6423
6451
|
needConfirm,
|
|
@@ -6438,6 +6466,7 @@ function DateRangePicker({
|
|
|
6438
6466
|
renderExtraFooter,
|
|
6439
6467
|
...props
|
|
6440
6468
|
}) {
|
|
6469
|
+
const size = useControlSize(sizeProp);
|
|
6441
6470
|
const id = (0, import_react30.useId)();
|
|
6442
6471
|
const rootRef = (0, import_react30.useRef)(null);
|
|
6443
6472
|
const popupRef = (0, import_react30.useRef)(null);
|
|
@@ -6678,8 +6707,9 @@ function DateRangePicker({
|
|
|
6678
6707
|
endpointLabel
|
|
6679
6708
|
);
|
|
6680
6709
|
}
|
|
6681
|
-
const
|
|
6682
|
-
|
|
6710
|
+
const startFloating = useFloatingPlaceholder({ mode: placeholderMode, placeholder: placeholder[0], filled: Boolean(currentValue[0]), active: visible });
|
|
6711
|
+
const endFloating = useFloatingPlaceholder({ mode: placeholderMode, placeholder: placeholder[1], filled: Boolean(currentValue[1]), active: visible });
|
|
6712
|
+
return /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)("span", { ref: rootRef, className: `sia-picker sia-picker-range-control sia-picker--${size} sia-picker--${status}${visible ? " is-open" : ""}${disabled ? " is-disabled" : ""} ${className}`.trim(), children: [
|
|
6683
6713
|
/* @__PURE__ */ (0, import_jsx_runtime31.jsxs)(
|
|
6684
6714
|
"button",
|
|
6685
6715
|
{
|
|
@@ -6696,14 +6726,19 @@ function DateRangePicker({
|
|
|
6696
6726
|
disabled,
|
|
6697
6727
|
onClick: () => changeOpen(!visible),
|
|
6698
6728
|
children: [
|
|
6699
|
-
/* @__PURE__ */ (0, import_jsx_runtime31.
|
|
6729
|
+
/* @__PURE__ */ (0, import_jsx_runtime31.jsxs)("span", { className: `sia-picker-range-control__field${startFloating.className}`, children: [
|
|
6730
|
+
/* @__PURE__ */ (0, import_jsx_runtime31.jsx)("span", { className: `sia-picker-range-control__value${currentValue[0] ? "" : " is-placeholder"}`, children: currentValue[0] ? formatValue2(currentValue[0]) : placeholder[0] }),
|
|
6731
|
+
startFloating.label
|
|
6732
|
+
] }),
|
|
6700
6733
|
/* @__PURE__ */ (0, import_jsx_runtime31.jsx)("span", { className: "sia-picker-range-control__separator", children: separator }),
|
|
6701
|
-
/* @__PURE__ */ (0, import_jsx_runtime31.
|
|
6734
|
+
/* @__PURE__ */ (0, import_jsx_runtime31.jsxs)("span", { className: `sia-picker-range-control__field${endFloating.className}`, children: [
|
|
6735
|
+
/* @__PURE__ */ (0, import_jsx_runtime31.jsx)("span", { className: `sia-picker-range-control__value${currentValue[1] ? "" : " is-placeholder"}`, children: currentValue[1] ? formatValue2(currentValue[1]) : placeholder[1] }),
|
|
6736
|
+
endFloating.label
|
|
6737
|
+
] }),
|
|
6702
6738
|
/* @__PURE__ */ (0, import_jsx_runtime31.jsx)("span", { className: "sia-picker__icon", "aria-hidden": "true", children: suffixIcon ?? /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(Icon, { name: "calendar", size: 16 }) })
|
|
6703
6739
|
]
|
|
6704
6740
|
}
|
|
6705
6741
|
),
|
|
6706
|
-
floating.label,
|
|
6707
6742
|
allowClear && (currentValue[0] || currentValue[1]) && !disabled ? /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("button", { type: "button", className: "sia-picker__clear", "aria-label": "\u6E05\u9664\u65E5\u671F\u8303\u56F4", onClick: clearValue, children: /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(Icon, { name: "circle-close", variant: "filled", size: 15 }) }) : null,
|
|
6708
6743
|
/* @__PURE__ */ (0, import_jsx_runtime31.jsxs)(PopupPortal, { ref: popupRef, anchorRef: rootRef, open: visible, className: `sia-date-panel sia-date-panel--range${showTime ? ` sia-date-panel--with-time sia-date-panel--range-time-${compactDateTime ? "compact" : "paired"}` : ""}${presets?.length ? " sia-date-panel--with-presets" : ""}`, role: "dialog", "aria-label": "\u65E5\u671F\u8303\u56F4\u9009\u62E9\u9762\u677F", children: [
|
|
6709
6744
|
/* @__PURE__ */ (0, import_jsx_runtime31.jsx)("div", { className: "sia-date-panel__body", children: showTime ? /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("div", { className: "sia-date-panel__range-date-time", children: compactDateTime ? renderDateTimeGroup(activeIndex) : /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)(import_jsx_runtime31.Fragment, { children: [
|
|
@@ -6779,7 +6814,7 @@ function SelectDateRange({
|
|
|
6779
6814
|
selectAriaLabel = "\u9009\u62E9\u7C7B\u578B",
|
|
6780
6815
|
rangeAriaLabel = "\u65E5\u671F\u8303\u56F4",
|
|
6781
6816
|
presets,
|
|
6782
|
-
size
|
|
6817
|
+
size: sizeProp,
|
|
6783
6818
|
status = "default",
|
|
6784
6819
|
disabled = false,
|
|
6785
6820
|
onChange,
|
|
@@ -6787,6 +6822,7 @@ function SelectDateRange({
|
|
|
6787
6822
|
style,
|
|
6788
6823
|
...props
|
|
6789
6824
|
}) {
|
|
6825
|
+
const size = useControlSize(sizeProp);
|
|
6790
6826
|
const initialValue = defaultValue ?? { select: options[0]?.value ?? "", range: ["", ""] };
|
|
6791
6827
|
const [currentValue, setCurrentValue] = useControllableState({ value: value === void 0 ? void 0 : value && typeof value === "object" ? value : { select: "", range: ["", ""] }, defaultValue: initialValue, onChange });
|
|
6792
6828
|
return /* @__PURE__ */ (0, import_jsx_runtime32.jsxs)("div", { className: `sia-select-date-range sia-select-date-range--${size} ${className}`.trim(), role: "group", "aria-label": `${selectAriaLabel}\u4E0E${rangeAriaLabel}`, ...props, style: { ...style, "--sia-select-date-range-select-width": typeof selectWidth === "number" ? `${selectWidth}px` : selectWidth }, children: [
|
|
@@ -6836,7 +6872,7 @@ function seconds(value) {
|
|
|
6836
6872
|
function TimePicker({
|
|
6837
6873
|
value,
|
|
6838
6874
|
defaultValue = "",
|
|
6839
|
-
size
|
|
6875
|
+
size: sizeProp,
|
|
6840
6876
|
status = "default",
|
|
6841
6877
|
allowClear = true,
|
|
6842
6878
|
use12Hours = false,
|
|
@@ -6856,6 +6892,7 @@ function TimePicker({
|
|
|
6856
6892
|
step,
|
|
6857
6893
|
...props
|
|
6858
6894
|
}) {
|
|
6895
|
+
const size = useControlSize(sizeProp);
|
|
6859
6896
|
const id = (0, import_react31.useId)();
|
|
6860
6897
|
const rootRef = (0, import_react31.useRef)(null);
|
|
6861
6898
|
const inputRef = (0, import_react31.useRef)(null);
|
|
@@ -6982,13 +7019,14 @@ function TimePicker({
|
|
|
6982
7019
|
] });
|
|
6983
7020
|
}
|
|
6984
7021
|
function TimeRangePicker({ value, defaultValue = ["", ""], placeholder = ["\u5F00\u59CB\u65F6\u95F4", "\u7ED3\u675F\u65F6\u95F4"], separator = "\u2192", onChange, className = "", style, ...props }) {
|
|
7022
|
+
const size = useControlSize(props.size);
|
|
6985
7023
|
const [currentValue, setValue2] = useControllableState({ value: value === void 0 ? void 0 : Array.isArray(value) ? value : ["", ""], defaultValue, onChange });
|
|
6986
7024
|
function update(index, next) {
|
|
6987
7025
|
const pair = [currentValue[0], currentValue[1]];
|
|
6988
7026
|
pair[index] = next;
|
|
6989
7027
|
setValue2(pair);
|
|
6990
7028
|
}
|
|
6991
|
-
return /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)("span", { style, className: `sia-time-range sia-picker--${
|
|
7029
|
+
return /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)("span", { style, className: `sia-time-range sia-picker--${size} sia-picker--${props.status ?? "default"}${props.disabled ? " is-disabled" : ""} ${className}`.trim(), children: [
|
|
6992
7030
|
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)(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) }),
|
|
6993
7031
|
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)("span", { className: "sia-time-range__separator", children: separator }),
|
|
6994
7032
|
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)(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) })
|
|
@@ -7034,7 +7072,7 @@ function TreeSelect({
|
|
|
7034
7072
|
searchPlaceholder = "\u641C\u7D22\u8282\u70B9",
|
|
7035
7073
|
maxTagCount = 3,
|
|
7036
7074
|
disabled = false,
|
|
7037
|
-
size
|
|
7075
|
+
size: sizeProp,
|
|
7038
7076
|
status = "default",
|
|
7039
7077
|
className = "",
|
|
7040
7078
|
onChange,
|
|
@@ -7061,6 +7099,7 @@ function TreeSelect({
|
|
|
7061
7099
|
onDeselect,
|
|
7062
7100
|
...props
|
|
7063
7101
|
}) {
|
|
7102
|
+
const size = useControlSize(sizeProp);
|
|
7064
7103
|
const rootRef = (0, import_react32.useRef)(null);
|
|
7065
7104
|
const popupRef = (0, import_react32.useRef)(null);
|
|
7066
7105
|
const nodeIndex = (0, import_react32.useMemo)(() => {
|
|
@@ -7453,6 +7492,7 @@ var TextArea = (0, import_react34.forwardRef)(function TextArea2({
|
|
|
7453
7492
|
label,
|
|
7454
7493
|
hint,
|
|
7455
7494
|
status = "default",
|
|
7495
|
+
size: sizeProp,
|
|
7456
7496
|
showCount = false,
|
|
7457
7497
|
placeholder,
|
|
7458
7498
|
placeholderMode,
|
|
@@ -7465,6 +7505,7 @@ var TextArea = (0, import_react34.forwardRef)(function TextArea2({
|
|
|
7465
7505
|
onChange,
|
|
7466
7506
|
...props
|
|
7467
7507
|
}, ref) {
|
|
7508
|
+
const size = useControlSize(sizeProp);
|
|
7468
7509
|
const fallbackId = (0, import_react34.useId)();
|
|
7469
7510
|
const textAreaId = id ?? fallbackId;
|
|
7470
7511
|
const [uncontrolledValue, setUncontrolledValue] = (0, import_react34.useState)(() => defaultValue === void 0 ? "" : String(defaultValue));
|
|
@@ -7476,7 +7517,7 @@ var TextArea = (0, import_react34.forwardRef)(function TextArea2({
|
|
|
7476
7517
|
setUncontrolledValue(event.target.value);
|
|
7477
7518
|
onChange?.(event);
|
|
7478
7519
|
}
|
|
7479
|
-
const control = /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)("span", { className: `sia-textarea-control sia-textarea-control--${status}${floating.className}${disabled ? " is-disabled" : ""}`, children: [
|
|
7520
|
+
const control = /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)("span", { className: `sia-textarea-control sia-textarea-control--${size} sia-textarea-control--${status}${floating.className}${disabled ? " is-disabled" : ""}`, children: [
|
|
7480
7521
|
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
|
7481
7522
|
"textarea",
|
|
7482
7523
|
{
|
|
@@ -8067,7 +8108,7 @@ function MarkdownEditor({
|
|
|
8067
8108
|
width: "100%",
|
|
8068
8109
|
height: "100%",
|
|
8069
8110
|
minHeight: typeof minHeight === "number" ? minHeight : void 0,
|
|
8070
|
-
placeholder,
|
|
8111
|
+
placeholder: floating.enabled ? "" : placeholder,
|
|
8071
8112
|
cdn: assetBaseUrl,
|
|
8072
8113
|
cache: { enable: false },
|
|
8073
8114
|
toolbar,
|
|
@@ -8147,7 +8188,7 @@ function MarkdownEditor({
|
|
|
8147
8188
|
if (editorRef.current === createdEditor) editorRef.current = null;
|
|
8148
8189
|
if (editorInitialized) createdEditor?.destroy();
|
|
8149
8190
|
};
|
|
8150
|
-
}, [ariaLabel, assetBaseUrl, hasImageUpload, minHeight, mode, placeholder]);
|
|
8191
|
+
}, [ariaLabel, assetBaseUrl, hasImageUpload, minHeight, mode, placeholder, floating.enabled]);
|
|
8151
8192
|
(0, import_react36.useEffect)(() => {
|
|
8152
8193
|
const editor = editorRef.current;
|
|
8153
8194
|
if (!editor || value === void 0) return;
|
|
@@ -9328,7 +9369,7 @@ var InputNumber = (0, import_react39.forwardRef)(function InputNumber2({
|
|
|
9328
9369
|
max,
|
|
9329
9370
|
step = 1,
|
|
9330
9371
|
precision,
|
|
9331
|
-
size
|
|
9372
|
+
size: sizeProp,
|
|
9332
9373
|
status = "default",
|
|
9333
9374
|
prefix,
|
|
9334
9375
|
suffix,
|
|
@@ -9343,6 +9384,7 @@ var InputNumber = (0, import_react39.forwardRef)(function InputNumber2({
|
|
|
9343
9384
|
onKeyDown,
|
|
9344
9385
|
...props
|
|
9345
9386
|
}, forwardedRef) {
|
|
9387
|
+
const size = useControlSize(sizeProp);
|
|
9346
9388
|
const fallbackId = (0, import_react39.useId)();
|
|
9347
9389
|
const inputId = id ?? fallbackId;
|
|
9348
9390
|
const localRef = (0, import_react39.useRef)(null);
|
|
@@ -9544,6 +9586,7 @@ function Tag({
|
|
|
9544
9586
|
variant = "soft",
|
|
9545
9587
|
icon,
|
|
9546
9588
|
closable = false,
|
|
9589
|
+
closeOnHover = false,
|
|
9547
9590
|
disabled = false,
|
|
9548
9591
|
onClose,
|
|
9549
9592
|
className = "",
|
|
@@ -9553,7 +9596,7 @@ function Tag({
|
|
|
9553
9596
|
return /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)(
|
|
9554
9597
|
"span",
|
|
9555
9598
|
{
|
|
9556
|
-
className: `sia-tag sia-tag--${status} sia-tag--${variant}${compact ? " sia-tag--compact" : ""}${disabled ? " sia-tag--disabled" : ""} ${className}`.trim(),
|
|
9599
|
+
className: `sia-tag${closable && closeOnHover ? " sia-tag--close-on-hover" : ""} sia-tag--${status} sia-tag--${variant}${compact ? " sia-tag--compact" : ""}${disabled ? " sia-tag--disabled" : ""} ${className}`.trim(),
|
|
9557
9600
|
"aria-disabled": disabled || void 0,
|
|
9558
9601
|
...props,
|
|
9559
9602
|
children: [
|
|
@@ -11549,13 +11592,14 @@ function orderColumnSettings(items) {
|
|
|
11549
11592
|
}
|
|
11550
11593
|
function ColumnSettingPanel({ open, items, columns, loading, loadError, onRetry, onClose, onApply }) {
|
|
11551
11594
|
const [draft, setDraft] = (0, import_react44.useState)(items);
|
|
11552
|
-
const
|
|
11553
|
-
const
|
|
11595
|
+
const listRef = (0, import_react44.useRef)(null);
|
|
11596
|
+
const cancelDrag = (0, import_react44.useRef)(null);
|
|
11597
|
+
const [preview, setPreview] = (0, import_react44.useState)(null);
|
|
11554
11598
|
(0, import_react44.useEffect)(() => {
|
|
11599
|
+
cancelDrag.current?.();
|
|
11555
11600
|
if (open) setDraft(orderColumnSettings(items));
|
|
11556
|
-
drag.current = null;
|
|
11557
|
-
setDraggingKey(null);
|
|
11558
11601
|
}, [items, open]);
|
|
11602
|
+
(0, import_react44.useEffect)(() => () => cancelDrag.current?.(), []);
|
|
11559
11603
|
const labels = new Map(flattenTableColumns(columns).map((column) => [column.key, getColumnLabel(column)]));
|
|
11560
11604
|
const visibleCount = draft.filter((item) => item.visible).length;
|
|
11561
11605
|
function setFixed(key, fixed) {
|
|
@@ -11569,20 +11613,107 @@ function ColumnSettingPanel({ open, items, columns, loading, loadError, onRetry,
|
|
|
11569
11613
|
return orderColumnSettings(next);
|
|
11570
11614
|
});
|
|
11571
11615
|
}
|
|
11572
|
-
function
|
|
11573
|
-
|
|
11574
|
-
|
|
11575
|
-
|
|
11576
|
-
|
|
11577
|
-
|
|
11578
|
-
|
|
11579
|
-
|
|
11580
|
-
|
|
11581
|
-
|
|
11582
|
-
|
|
11583
|
-
|
|
11584
|
-
|
|
11585
|
-
|
|
11616
|
+
function startSort(event, key) {
|
|
11617
|
+
if (loading || loadError || event.button !== 0 || event.target.closest("button, input, label")) return;
|
|
11618
|
+
const list = listRef.current;
|
|
11619
|
+
if (!list) return;
|
|
11620
|
+
cancelDrag.current?.();
|
|
11621
|
+
const original = [...draft];
|
|
11622
|
+
const from = original.findIndex((item) => item.key === key);
|
|
11623
|
+
const elements = Array.from(list.querySelectorAll(".sia-table-settings__item"));
|
|
11624
|
+
const rects = elements.map((element) => element.getBoundingClientRect());
|
|
11625
|
+
const gap = parseFloat(getComputedStyle(list).rowGap) || 0;
|
|
11626
|
+
const positions = original.map((_, index) => index);
|
|
11627
|
+
const startY = event.clientY;
|
|
11628
|
+
let lastY = startY;
|
|
11629
|
+
let moved = false;
|
|
11630
|
+
let next = original;
|
|
11631
|
+
let frame = 0;
|
|
11632
|
+
let scrollParent = list.parentElement;
|
|
11633
|
+
while (scrollParent && !(scrollParent.scrollHeight > scrollParent.clientHeight && /auto|scroll/.test(getComputedStyle(scrollParent).overflowY))) scrollParent = scrollParent.parentElement;
|
|
11634
|
+
const initialScroll = scrollParent?.scrollTop ?? 0;
|
|
11635
|
+
const target = event.currentTarget;
|
|
11636
|
+
target.setPointerCapture(event.pointerId);
|
|
11637
|
+
const previousUserSelect = document.body.style.userSelect;
|
|
11638
|
+
function update() {
|
|
11639
|
+
const dy = lastY - startY + (scrollParent?.scrollTop ?? 0) - initialScroll;
|
|
11640
|
+
if (!moved && Math.abs(dy) < 4) return;
|
|
11641
|
+
moved = true;
|
|
11642
|
+
document.body.style.userSelect = "none";
|
|
11643
|
+
const center = rects[from].top + rects[from].height / 2 + dy;
|
|
11644
|
+
let to = from;
|
|
11645
|
+
for (const index of positions) {
|
|
11646
|
+
if (index > from && center > rects[index].top + rects[index].height / 2) to = index;
|
|
11647
|
+
if (index < from && center < rects[index].top + rects[index].height / 2) {
|
|
11648
|
+
to = index;
|
|
11649
|
+
break;
|
|
11650
|
+
}
|
|
11651
|
+
}
|
|
11652
|
+
next = [...original];
|
|
11653
|
+
const [item] = next.splice(from, 1);
|
|
11654
|
+
next.splice(to, 0, { ...item, fixed: original[to].fixed });
|
|
11655
|
+
const offsets = {};
|
|
11656
|
+
let top = rects[0].top;
|
|
11657
|
+
for (const entry of next) {
|
|
11658
|
+
const index = original.findIndex((item2) => item2.key === entry.key);
|
|
11659
|
+
offsets[entry.key] = entry.key === key ? dy : top - rects[index].top;
|
|
11660
|
+
top += rects[index].height + gap;
|
|
11661
|
+
}
|
|
11662
|
+
setPreview({ key, fixed: original[to].fixed, offsets });
|
|
11663
|
+
}
|
|
11664
|
+
function tick() {
|
|
11665
|
+
if (moved && scrollParent) {
|
|
11666
|
+
const bounds = scrollParent.getBoundingClientRect();
|
|
11667
|
+
const delta = lastY < bounds.top + 40 ? -10 : lastY > bounds.bottom - 40 ? 10 : 0;
|
|
11668
|
+
if (delta) {
|
|
11669
|
+
scrollParent.scrollTop += delta;
|
|
11670
|
+
update();
|
|
11671
|
+
}
|
|
11672
|
+
}
|
|
11673
|
+
frame = requestAnimationFrame(tick);
|
|
11674
|
+
}
|
|
11675
|
+
function move(moveEvent) {
|
|
11676
|
+
if (moveEvent.pointerId !== event.pointerId) return;
|
|
11677
|
+
lastY = moveEvent.clientY;
|
|
11678
|
+
update();
|
|
11679
|
+
}
|
|
11680
|
+
function finish(commit) {
|
|
11681
|
+
document.removeEventListener("pointermove", move);
|
|
11682
|
+
document.removeEventListener("pointerup", up);
|
|
11683
|
+
document.removeEventListener("pointercancel", cancel);
|
|
11684
|
+
document.removeEventListener("keydown", escape, true);
|
|
11685
|
+
window.removeEventListener("blur", cancel);
|
|
11686
|
+
cancelAnimationFrame(frame);
|
|
11687
|
+
if (target.hasPointerCapture(event.pointerId)) target.releasePointerCapture(event.pointerId);
|
|
11688
|
+
document.body.style.userSelect = previousUserSelect;
|
|
11689
|
+
cancelDrag.current = null;
|
|
11690
|
+
setPreview(null);
|
|
11691
|
+
if (commit && moved) setDraft(orderColumnSettings(next));
|
|
11692
|
+
}
|
|
11693
|
+
function up(upEvent) {
|
|
11694
|
+
if (upEvent.pointerId === event.pointerId) {
|
|
11695
|
+
lastY = upEvent.clientY;
|
|
11696
|
+
update();
|
|
11697
|
+
finish(true);
|
|
11698
|
+
}
|
|
11699
|
+
}
|
|
11700
|
+
function cancel() {
|
|
11701
|
+
finish(false);
|
|
11702
|
+
}
|
|
11703
|
+
function escape(event2) {
|
|
11704
|
+
if (event2.key === "Escape") {
|
|
11705
|
+
event2.preventDefault();
|
|
11706
|
+
event2.stopPropagation();
|
|
11707
|
+
cancel();
|
|
11708
|
+
}
|
|
11709
|
+
}
|
|
11710
|
+
cancelDrag.current = cancel;
|
|
11711
|
+
document.addEventListener("pointermove", move);
|
|
11712
|
+
document.addEventListener("pointerup", up);
|
|
11713
|
+
document.addEventListener("pointercancel", cancel);
|
|
11714
|
+
document.addEventListener("keydown", escape, true);
|
|
11715
|
+
window.addEventListener("blur", cancel);
|
|
11716
|
+
frame = requestAnimationFrame(tick);
|
|
11586
11717
|
}
|
|
11587
11718
|
return /* @__PURE__ */ (0, import_jsx_runtime47.jsxs)(Drawer2, { open, title: "\u5217\u8BBE\u7F6E", size: 440, onOpenChange: (next) => {
|
|
11588
11719
|
if (!next) onClose();
|
|
@@ -11606,40 +11737,20 @@ function ColumnSettingPanel({ open, items, columns, loading, loadError, onRetry,
|
|
|
11606
11737
|
"\uFF09"
|
|
11607
11738
|
] })
|
|
11608
11739
|
] }),
|
|
11609
|
-
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)("div", { className:
|
|
11610
|
-
if (drag.current) event.preventDefault();
|
|
11611
|
-
}, onDrop: (event) => {
|
|
11612
|
-
event.preventDefault();
|
|
11613
|
-
if (drag.current) drag.current.dropped = true;
|
|
11614
|
-
}, children: draft.map((item) => /* @__PURE__ */ (0, import_jsx_runtime47.jsxs)(
|
|
11740
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)("div", { ref: listRef, className: `sia-table-settings__list${preview ? " is-sorting" : ""}`, children: draft.map((item) => /* @__PURE__ */ (0, import_jsx_runtime47.jsxs)(
|
|
11615
11741
|
"div",
|
|
11616
11742
|
{
|
|
11617
11743
|
"data-column-key": item.key,
|
|
11618
|
-
className: `sia-table-settings__item${
|
|
11619
|
-
|
|
11620
|
-
|
|
11621
|
-
drag.current = { key: item.key, original: draft, dropped: false };
|
|
11622
|
-
event.dataTransfer.effectAllowed = "move";
|
|
11623
|
-
event.dataTransfer.setData("text/plain", item.key);
|
|
11624
|
-
setDraggingKey(item.key);
|
|
11625
|
-
},
|
|
11626
|
-
onDragOver: (event) => {
|
|
11627
|
-
event.preventDefault();
|
|
11628
|
-
event.dataTransfer.dropEffect = "move";
|
|
11629
|
-
previewMove(item.key, event.clientY, event.currentTarget);
|
|
11630
|
-
},
|
|
11631
|
-
onDragEnd: () => {
|
|
11632
|
-
if (drag.current && !drag.current.dropped) setDraft(drag.current.original);
|
|
11633
|
-
drag.current = null;
|
|
11634
|
-
setDraggingKey(null);
|
|
11635
|
-
},
|
|
11744
|
+
className: `sia-table-settings__item${preview?.key === item.key ? " is-dragging" : ""}`,
|
|
11745
|
+
style: preview ? { transform: `translateY(${preview.offsets[item.key] ?? 0}px)` } : void 0,
|
|
11746
|
+
onPointerDown: (event) => startSort(event, item.key),
|
|
11636
11747
|
children: [
|
|
11637
11748
|
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)(Icon, { name: "menu", size: 15 }),
|
|
11638
11749
|
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)(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)) }),
|
|
11639
11750
|
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)("span", { className: "sia-table-settings__name", title: labels.get(item.key) ?? item.key, children: labels.get(item.key) ?? item.key }),
|
|
11640
11751
|
/* @__PURE__ */ (0, import_jsx_runtime47.jsxs)("div", { className: "sia-table-settings__actions", children: [
|
|
11641
|
-
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)(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" }),
|
|
11642
|
-
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)(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" })
|
|
11752
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)(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" }),
|
|
11753
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)(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" })
|
|
11643
11754
|
] })
|
|
11644
11755
|
]
|
|
11645
11756
|
},
|
|
@@ -20594,7 +20705,7 @@ var InputSelect = (0, import_react86.forwardRef)(function InputSelect2({
|
|
|
20594
20705
|
showValue = false,
|
|
20595
20706
|
placeholder = "\u8BF7\u9009\u62E9",
|
|
20596
20707
|
placeholderMode,
|
|
20597
|
-
size
|
|
20708
|
+
size: sizeProp,
|
|
20598
20709
|
status,
|
|
20599
20710
|
disabled = false,
|
|
20600
20711
|
loading = false,
|
|
@@ -20609,6 +20720,7 @@ var InputSelect = (0, import_react86.forwardRef)(function InputSelect2({
|
|
|
20609
20720
|
onOpenChange,
|
|
20610
20721
|
...inputProps
|
|
20611
20722
|
}, forwardedRef) {
|
|
20723
|
+
const size = useControlSize(sizeProp);
|
|
20612
20724
|
const [internal, setInternal] = (0, import_react86.useState)(defaultValue);
|
|
20613
20725
|
const current = value !== void 0 ? value : internal;
|
|
20614
20726
|
const values = current == null ? [] : Array.isArray(current) ? current : [current];
|
|
@@ -20783,6 +20895,293 @@ var InputSelect = (0, import_react86.forwardRef)(function InputSelect2({
|
|
|
20783
20895
|
)
|
|
20784
20896
|
] });
|
|
20785
20897
|
});
|
|
20898
|
+
|
|
20899
|
+
// src/components/QueryForm.tsx
|
|
20900
|
+
var import_react87 = require("react");
|
|
20901
|
+
var import_jsx_runtime87 = require("react/jsx-runtime");
|
|
20902
|
+
function QueryForm({
|
|
20903
|
+
fields,
|
|
20904
|
+
children,
|
|
20905
|
+
form: providedForm,
|
|
20906
|
+
onSearch,
|
|
20907
|
+
loading = false,
|
|
20908
|
+
fieldWidth = 220,
|
|
20909
|
+
collapsible = true,
|
|
20910
|
+
collapsed: controlledCollapsed,
|
|
20911
|
+
defaultCollapsed = false,
|
|
20912
|
+
collapsedCount = 3,
|
|
20913
|
+
onCollapsedChange,
|
|
20914
|
+
quickQueries = [],
|
|
20915
|
+
quickQuerySize = "small",
|
|
20916
|
+
savedQueries = [],
|
|
20917
|
+
shortcutsLoading = false,
|
|
20918
|
+
onSaveQuery,
|
|
20919
|
+
onRemoveQuery,
|
|
20920
|
+
onError,
|
|
20921
|
+
searchText = "\u67E5\u8BE2",
|
|
20922
|
+
resetText = "\u91CD\u7F6E",
|
|
20923
|
+
saveText = "\u53E6\u5B58\u4E3A\u5FEB\u6377\u67E5\u8BE2",
|
|
20924
|
+
resetSearch = true,
|
|
20925
|
+
actionsExtra,
|
|
20926
|
+
disabled = false,
|
|
20927
|
+
className = "",
|
|
20928
|
+
placeholderMode = "floating",
|
|
20929
|
+
onValuesChange,
|
|
20930
|
+
onFinishFailed,
|
|
20931
|
+
...formProps
|
|
20932
|
+
}) {
|
|
20933
|
+
const [form] = useForm(providedForm);
|
|
20934
|
+
const [internalCollapsed, setInternalCollapsed] = (0, import_react87.useState)(defaultCollapsed);
|
|
20935
|
+
const collapsed = collapsible && (controlledCollapsed ?? internalCollapsed);
|
|
20936
|
+
const [searching, setSearching] = (0, import_react87.useState)(false);
|
|
20937
|
+
const [saving, setSaving] = (0, import_react87.useState)(false);
|
|
20938
|
+
const [removing, setRemoving] = (0, import_react87.useState)(false);
|
|
20939
|
+
const [saveOpen, setSaveOpen] = (0, import_react87.useState)(false);
|
|
20940
|
+
const [saveName, setSaveName] = (0, import_react87.useState)("");
|
|
20941
|
+
const [saveError, setSaveError] = (0, import_react87.useState)("");
|
|
20942
|
+
const [error, setError] = (0, import_react87.useState)("");
|
|
20943
|
+
const [activeShortcut, setActiveShortcut] = (0, import_react87.useState)("");
|
|
20944
|
+
const source = (0, import_react87.useRef)({ source: "submit" });
|
|
20945
|
+
const searchLock = (0, import_react87.useRef)(false);
|
|
20946
|
+
const saveLock = (0, import_react87.useRef)(false);
|
|
20947
|
+
const removeLock = (0, import_react87.useRef)(false);
|
|
20948
|
+
const snapshot = (0, import_react87.useRef)();
|
|
20949
|
+
const busy = disabled || loading || searching;
|
|
20950
|
+
const shortcutBusy = busy || shortcutsLoading || saving || removing;
|
|
20951
|
+
const entries = fields ? fields.map(({ key, width, ...item }) => ({ key, width, content: /* @__PURE__ */ (0, import_jsx_runtime87.jsx)(Form.Item, { noStyle: true, ...item }) })) : import_react87.Children.toArray(children).map((content, index) => ({ key: String(index), width: void 0, content }));
|
|
20952
|
+
const limit = Math.max(1, Math.floor(collapsedCount));
|
|
20953
|
+
const rowRef = (0, import_react87.useRef)(null);
|
|
20954
|
+
const actionsRef = (0, import_react87.useRef)(null);
|
|
20955
|
+
const [fittingCount, setFittingCount] = (0, import_react87.useState)(limit);
|
|
20956
|
+
(0, import_react87.useLayoutEffect)(() => {
|
|
20957
|
+
if (!collapsed) return;
|
|
20958
|
+
const row = rowRef.current;
|
|
20959
|
+
const actions = actionsRef.current;
|
|
20960
|
+
if (!row || !actions) return;
|
|
20961
|
+
function measure() {
|
|
20962
|
+
if (!row || !actions) return;
|
|
20963
|
+
const gap = parseFloat(getComputedStyle(row).columnGap) || 0;
|
|
20964
|
+
let remaining = row.clientWidth - actions.getBoundingClientRect().width;
|
|
20965
|
+
let count = 0;
|
|
20966
|
+
for (const field of Array.from(row.querySelectorAll(":scope > .sia-query-form__field")).slice(0, limit)) {
|
|
20967
|
+
const width = parseFloat(getComputedStyle(field).width) || 220;
|
|
20968
|
+
if (remaining + 0.5 < width + gap) break;
|
|
20969
|
+
remaining -= width + gap;
|
|
20970
|
+
count++;
|
|
20971
|
+
}
|
|
20972
|
+
setFittingCount(count);
|
|
20973
|
+
}
|
|
20974
|
+
measure();
|
|
20975
|
+
const observer = new ResizeObserver(measure);
|
|
20976
|
+
observer.observe(row);
|
|
20977
|
+
observer.observe(actions);
|
|
20978
|
+
row.querySelectorAll(":scope > .sia-query-form__field").forEach((field) => observer.observe(field));
|
|
20979
|
+
return () => observer.disconnect();
|
|
20980
|
+
}, [collapsed, limit, fieldWidth, fields, children]);
|
|
20981
|
+
async function search(values) {
|
|
20982
|
+
const info = source.current;
|
|
20983
|
+
source.current = { source: "submit" };
|
|
20984
|
+
if (searchLock.current || disabled || loading) return;
|
|
20985
|
+
searchLock.current = true;
|
|
20986
|
+
setSearching(true);
|
|
20987
|
+
setError("");
|
|
20988
|
+
try {
|
|
20989
|
+
await onSearch(values, info);
|
|
20990
|
+
} catch (reason) {
|
|
20991
|
+
setError(reason instanceof Error ? reason.message : "\u67E5\u8BE2\u5931\u8D25\uFF0C\u8BF7\u91CD\u8BD5");
|
|
20992
|
+
onError?.(reason, "search");
|
|
20993
|
+
} finally {
|
|
20994
|
+
searchLock.current = false;
|
|
20995
|
+
setSearching(false);
|
|
20996
|
+
}
|
|
20997
|
+
}
|
|
20998
|
+
function applyShortcut(query, kind) {
|
|
20999
|
+
if (shortcutBusy || query.disabled) return;
|
|
21000
|
+
form.resetFields();
|
|
21001
|
+
form.setFieldsValue(query.values);
|
|
21002
|
+
source.current = { source: kind, shortcutKey: query.key };
|
|
21003
|
+
setActiveShortcut(`${kind}:${query.key}`);
|
|
21004
|
+
form.submit();
|
|
21005
|
+
}
|
|
21006
|
+
function reset() {
|
|
21007
|
+
if (busy) return;
|
|
21008
|
+
form.resetFields();
|
|
21009
|
+
setActiveShortcut("");
|
|
21010
|
+
setError("");
|
|
21011
|
+
if (resetSearch) {
|
|
21012
|
+
source.current = { source: "reset" };
|
|
21013
|
+
form.submit();
|
|
21014
|
+
}
|
|
21015
|
+
}
|
|
21016
|
+
async function save() {
|
|
21017
|
+
if (!onSaveQuery || saveLock.current) return false;
|
|
21018
|
+
const name = saveName.trim();
|
|
21019
|
+
if (!name) {
|
|
21020
|
+
setSaveError("\u8BF7\u8F93\u5165\u5FEB\u6377\u67E5\u8BE2\u540D\u79F0");
|
|
21021
|
+
return false;
|
|
21022
|
+
}
|
|
21023
|
+
if (!snapshot.current) return false;
|
|
21024
|
+
saveLock.current = true;
|
|
21025
|
+
setSaving(true);
|
|
21026
|
+
setSaveError("");
|
|
21027
|
+
try {
|
|
21028
|
+
await onSaveQuery({ name, values: snapshot.current });
|
|
21029
|
+
setSaveOpen(false);
|
|
21030
|
+
} catch (reason) {
|
|
21031
|
+
setSaveError(reason instanceof Error ? reason.message : "\u4FDD\u5B58\u5931\u8D25\uFF0C\u8BF7\u91CD\u8BD5");
|
|
21032
|
+
onError?.(reason, "save");
|
|
21033
|
+
return false;
|
|
21034
|
+
} finally {
|
|
21035
|
+
saveLock.current = false;
|
|
21036
|
+
setSaving(false);
|
|
21037
|
+
}
|
|
21038
|
+
}
|
|
21039
|
+
async function remove(query) {
|
|
21040
|
+
if (!onRemoveQuery || shortcutBusy || removeLock.current) return;
|
|
21041
|
+
removeLock.current = true;
|
|
21042
|
+
setRemoving(true);
|
|
21043
|
+
setError("");
|
|
21044
|
+
try {
|
|
21045
|
+
await onRemoveQuery(query);
|
|
21046
|
+
if (activeShortcut === `saved:${query.key}`) setActiveShortcut("");
|
|
21047
|
+
} catch (reason) {
|
|
21048
|
+
setError(reason instanceof Error ? reason.message : "\u5220\u9664\u5931\u8D25\uFF0C\u8BF7\u91CD\u8BD5");
|
|
21049
|
+
onError?.(reason, "remove");
|
|
21050
|
+
} finally {
|
|
21051
|
+
removeLock.current = false;
|
|
21052
|
+
setRemoving(false);
|
|
21053
|
+
}
|
|
21054
|
+
}
|
|
21055
|
+
return /* @__PURE__ */ (0, import_jsx_runtime87.jsxs)("div", { className: `sia-query-form ${className}`.trim(), children: [
|
|
21056
|
+
/* @__PURE__ */ (0, import_jsx_runtime87.jsxs)(
|
|
21057
|
+
Form,
|
|
21058
|
+
{
|
|
21059
|
+
...formProps,
|
|
21060
|
+
form,
|
|
21061
|
+
placeholderMode,
|
|
21062
|
+
disabled,
|
|
21063
|
+
onFinish: (values) => {
|
|
21064
|
+
void search(values);
|
|
21065
|
+
},
|
|
21066
|
+
onFinishFailed: (info) => {
|
|
21067
|
+
source.current = { source: "submit" };
|
|
21068
|
+
onFinishFailed?.(info);
|
|
21069
|
+
},
|
|
21070
|
+
onValuesChange: (changed, values) => {
|
|
21071
|
+
setActiveShortcut("");
|
|
21072
|
+
onValuesChange?.(changed, values);
|
|
21073
|
+
},
|
|
21074
|
+
children: [
|
|
21075
|
+
quickQueries.length ? /* @__PURE__ */ (0, import_jsx_runtime87.jsxs)("div", { className: "sia-query-form__quick", "aria-label": "\u9884\u8BBE\u5FEB\u6377\u67E5\u8BE2", children: [
|
|
21076
|
+
quickQueries.map((query) => /* @__PURE__ */ (0, import_jsx_runtime87.jsx)(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__ */ (0, import_jsx_runtime87.jsx)(
|
|
21077
|
+
Button,
|
|
21078
|
+
{
|
|
21079
|
+
size: query.size ?? quickQuerySize,
|
|
21080
|
+
"aria-pressed": activeShortcut === `quick:${query.key}`,
|
|
21081
|
+
variant: activeShortcut === `quick:${query.key}` ? "primary" : "default",
|
|
21082
|
+
disabled: shortcutBusy || query.disabled,
|
|
21083
|
+
onClick: () => applyShortcut(query, "quick"),
|
|
21084
|
+
children: query.label
|
|
21085
|
+
}
|
|
21086
|
+
) }, query.key)),
|
|
21087
|
+
" "
|
|
21088
|
+
] }) : null,
|
|
21089
|
+
/* @__PURE__ */ (0, import_jsx_runtime87.jsxs)("div", { ref: rowRef, className: `sia-query-form__fields${collapsed ? " is-collapsed" : ""}`, style: { "--sia-query-field-width": typeof fieldWidth === "number" ? `${fieldWidth}px` : fieldWidth }, children: [
|
|
21090
|
+
entries.map((entry, index) => /* @__PURE__ */ (0, import_jsx_runtime87.jsx)(
|
|
21091
|
+
"div",
|
|
21092
|
+
{
|
|
21093
|
+
className: "sia-query-form__field",
|
|
21094
|
+
hidden: collapsed && index >= Math.min(limit, fittingCount),
|
|
21095
|
+
style: entry.width !== void 0 ? { flexBasis: entry.width, width: entry.width } : void 0,
|
|
21096
|
+
children: entry.content
|
|
21097
|
+
},
|
|
21098
|
+
entry.key
|
|
21099
|
+
)),
|
|
21100
|
+
/* @__PURE__ */ (0, import_jsx_runtime87.jsxs)("div", { ref: actionsRef, className: "sia-query-form__actions", children: [
|
|
21101
|
+
/* @__PURE__ */ (0, import_jsx_runtime87.jsxs)(Space.Compact, { children: [
|
|
21102
|
+
/* @__PURE__ */ (0, import_jsx_runtime87.jsx)(Button, { type: "submit", variant: "primary", loading: loading || searching, disabled, children: searchText }),
|
|
21103
|
+
/* @__PURE__ */ (0, import_jsx_runtime87.jsx)(Button, { disabled: busy, onClick: reset, children: resetText }),
|
|
21104
|
+
onSaveQuery ? /* @__PURE__ */ (0, import_jsx_runtime87.jsx)(Button, { disabled: shortcutBusy, onClick: () => {
|
|
21105
|
+
snapshot.current = form.getFieldsValue();
|
|
21106
|
+
setSaveName("");
|
|
21107
|
+
setSaveError("");
|
|
21108
|
+
setSaveOpen(true);
|
|
21109
|
+
}, children: saveText }) : null
|
|
21110
|
+
] }),
|
|
21111
|
+
collapsible && entries.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime87.jsx)(
|
|
21112
|
+
Button,
|
|
21113
|
+
{
|
|
21114
|
+
variant: "link",
|
|
21115
|
+
"aria-expanded": !collapsed,
|
|
21116
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime87.jsx)(Icon, { name: collapsed ? "chevron-down" : "chevron-up" }),
|
|
21117
|
+
iconPosition: "end",
|
|
21118
|
+
onClick: () => {
|
|
21119
|
+
setInternalCollapsed(!collapsed);
|
|
21120
|
+
onCollapsedChange?.(!collapsed);
|
|
21121
|
+
},
|
|
21122
|
+
children: collapsed ? "\u5C55\u5F00" : "\u6536\u8D77"
|
|
21123
|
+
}
|
|
21124
|
+
) : null,
|
|
21125
|
+
actionsExtra
|
|
21126
|
+
] })
|
|
21127
|
+
] }),
|
|
21128
|
+
savedQueries.length && !collapsed ? /* @__PURE__ */ (0, import_jsx_runtime87.jsxs)("div", { className: "sia-query-form__saved", "aria-label": "\u5DF2\u4FDD\u5B58\u5FEB\u6377\u67E5\u8BE2", children: [
|
|
21129
|
+
savedQueries.map((query, index) => /* @__PURE__ */ (0, import_jsx_runtime87.jsx)(
|
|
21130
|
+
Tag,
|
|
21131
|
+
{
|
|
21132
|
+
status: query.status ?? ["processing", "success", "warning", "error"][index % 4],
|
|
21133
|
+
variant: "soft",
|
|
21134
|
+
disabled: shortcutBusy || query.disabled,
|
|
21135
|
+
tabIndex: shortcutBusy || query.disabled ? -1 : 0,
|
|
21136
|
+
className: activeShortcut === `saved:${query.key}` ? "is-active" : "",
|
|
21137
|
+
closable: Boolean(onRemoveQuery),
|
|
21138
|
+
closeOnHover: true,
|
|
21139
|
+
onClose: () => {
|
|
21140
|
+
void remove(query);
|
|
21141
|
+
},
|
|
21142
|
+
onClick: () => applyShortcut(query, "saved"),
|
|
21143
|
+
onKeyDown: (event) => {
|
|
21144
|
+
if (event.target === event.currentTarget && (event.key === "Enter" || event.key === " ")) {
|
|
21145
|
+
event.preventDefault();
|
|
21146
|
+
applyShortcut(query, "saved");
|
|
21147
|
+
}
|
|
21148
|
+
},
|
|
21149
|
+
children: query.label
|
|
21150
|
+
},
|
|
21151
|
+
query.key
|
|
21152
|
+
)),
|
|
21153
|
+
" "
|
|
21154
|
+
] }) : null,
|
|
21155
|
+
error ? /* @__PURE__ */ (0, import_jsx_runtime87.jsx)("p", { className: "sia-query-form__error", role: "alert", children: error }) : null
|
|
21156
|
+
]
|
|
21157
|
+
}
|
|
21158
|
+
),
|
|
21159
|
+
/* @__PURE__ */ (0, import_jsx_runtime87.jsxs)(Modal2, { open: saveOpen, title: "\u53E6\u5B58\u4E3A\u5FEB\u6377\u67E5\u8BE2", width: 420, confirmLoading: saving, onOk: save, onOpenChange: (next) => {
|
|
21160
|
+
if (!saveLock.current) setSaveOpen(next);
|
|
21161
|
+
}, children: [
|
|
21162
|
+
/* @__PURE__ */ (0, import_jsx_runtime87.jsx)(
|
|
21163
|
+
Input,
|
|
21164
|
+
{
|
|
21165
|
+
autoFocus: true,
|
|
21166
|
+
"aria-label": "\u5FEB\u6377\u67E5\u8BE2\u540D\u79F0",
|
|
21167
|
+
placeholder: "\u5FEB\u6377\u67E5\u8BE2\u540D\u79F0",
|
|
21168
|
+
value: saveName,
|
|
21169
|
+
maxLength: 80,
|
|
21170
|
+
disabled: saving,
|
|
21171
|
+
status: saveError ? "error" : "default",
|
|
21172
|
+
onChange: (event) => setSaveName(event.target.value),
|
|
21173
|
+
onKeyDown: (event) => {
|
|
21174
|
+
if (event.key === "Enter") {
|
|
21175
|
+
event.preventDefault();
|
|
21176
|
+
void save();
|
|
21177
|
+
}
|
|
21178
|
+
}
|
|
21179
|
+
}
|
|
21180
|
+
),
|
|
21181
|
+
saveError ? /* @__PURE__ */ (0, import_jsx_runtime87.jsx)("p", { className: "sia-query-form__error", role: "alert", children: saveError }) : null
|
|
21182
|
+
] })
|
|
21183
|
+
] });
|
|
21184
|
+
}
|
|
20786
21185
|
// Annotate the CommonJS export names for ESM import in node:
|
|
20787
21186
|
0 && (module.exports = {
|
|
20788
21187
|
Alert,
|
|
@@ -20856,6 +21255,7 @@ var InputSelect = (0, import_react86.forwardRef)(function InputSelect2({
|
|
|
20856
21255
|
Popconfirm,
|
|
20857
21256
|
Popover,
|
|
20858
21257
|
Progress,
|
|
21258
|
+
QueryForm,
|
|
20859
21259
|
RadarChart,
|
|
20860
21260
|
Radio,
|
|
20861
21261
|
Rate,
|