@sia.soul/sia-react-ui 0.1.60 → 0.1.63
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-QJH7H3CB.js → chunk-NV4QPQSP.js} +10 -4
- package/dist/{core-BrQetGru.d.ts → core-BemUqBUF.d.ts} +12 -6
- package/dist/{core-MTKdBVk3.d.cts → core-C4ayGoM8.d.cts} +12 -6
- package/dist/core.cjs +10 -4
- package/dist/core.css +111 -4
- package/dist/core.d.cts +1 -1
- package/dist/core.d.ts +1 -1
- package/dist/core.js +1 -1
- package/dist/index.cjs +170 -81
- package/dist/index.css +111 -4
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +161 -78
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -80,7 +80,7 @@ import {
|
|
|
80
80
|
Watermark,
|
|
81
81
|
message,
|
|
82
82
|
notification
|
|
83
|
-
} from "./chunk-
|
|
83
|
+
} from "./chunk-NV4QPQSP.js";
|
|
84
84
|
import {
|
|
85
85
|
TextArea
|
|
86
86
|
} from "./chunk-SMCYEPBL.js";
|
|
@@ -8615,7 +8615,15 @@ function QueryForm({
|
|
|
8615
8615
|
const snapshot = useRef18();
|
|
8616
8616
|
const busy = disabled || loading || searching;
|
|
8617
8617
|
const shortcutBusy = busy || shortcutsLoading || saving || removing;
|
|
8618
|
-
const entries = fields ? fields.map(({ key, width, ...item }) => ({
|
|
8618
|
+
const entries = fields ? fields.map(({ key, width, ...item }) => ({
|
|
8619
|
+
key,
|
|
8620
|
+
width,
|
|
8621
|
+
content: /* @__PURE__ */ jsx26(Form.Item, { noStyle: true, ...item })
|
|
8622
|
+
})) : Children4.toArray(children).map((content, index) => ({
|
|
8623
|
+
key: String(index),
|
|
8624
|
+
width: void 0,
|
|
8625
|
+
content
|
|
8626
|
+
}));
|
|
8619
8627
|
const limit = Math.max(1, Math.floor(collapsedCount));
|
|
8620
8628
|
const rowRef = useRef18(null);
|
|
8621
8629
|
const actionsRef = useRef18(null);
|
|
@@ -8628,7 +8636,9 @@ function QueryForm({
|
|
|
8628
8636
|
function measure() {
|
|
8629
8637
|
if (!row || !actions) return;
|
|
8630
8638
|
const gap = parseFloat(getComputedStyle(row).columnGap) || 0;
|
|
8631
|
-
const allFields = Array.from(
|
|
8639
|
+
const allFields = Array.from(
|
|
8640
|
+
row.querySelectorAll(":scope > .sia-query-form__field")
|
|
8641
|
+
);
|
|
8632
8642
|
const hiddenFields = allFields.filter((field) => field.hidden);
|
|
8633
8643
|
const wasCollapsed = row.classList.contains("is-collapsed");
|
|
8634
8644
|
const toggle = toggleRef.current;
|
|
@@ -8638,8 +8648,13 @@ function QueryForm({
|
|
|
8638
8648
|
field.hidden = false;
|
|
8639
8649
|
});
|
|
8640
8650
|
if (toggle) toggle.hidden = true;
|
|
8641
|
-
const requiredWidth = allFields.reduce(
|
|
8642
|
-
|
|
8651
|
+
const requiredWidth = allFields.reduce(
|
|
8652
|
+
(total, field) => total + field.getBoundingClientRect().width + gap,
|
|
8653
|
+
actions.getBoundingClientRect().width
|
|
8654
|
+
);
|
|
8655
|
+
setNeedsCollapse(
|
|
8656
|
+
allFields.length > 0 && requiredWidth > row.clientWidth + 0.5
|
|
8657
|
+
);
|
|
8643
8658
|
if (toggle) toggle.hidden = Boolean(toggleHidden);
|
|
8644
8659
|
hiddenFields.forEach((field) => {
|
|
8645
8660
|
field.hidden = true;
|
|
@@ -8648,7 +8663,9 @@ function QueryForm({
|
|
|
8648
8663
|
if (!collapsed) return;
|
|
8649
8664
|
let remaining = row.clientWidth - actions.getBoundingClientRect().width;
|
|
8650
8665
|
let count = 0;
|
|
8651
|
-
for (const field of Array.from(
|
|
8666
|
+
for (const field of Array.from(
|
|
8667
|
+
row.querySelectorAll(":scope > .sia-query-form__field")
|
|
8668
|
+
).slice(0, limit)) {
|
|
8652
8669
|
const width = parseFloat(getComputedStyle(field).width) || 220;
|
|
8653
8670
|
if (remaining + 0.5 < width + gap) break;
|
|
8654
8671
|
remaining -= width + gap;
|
|
@@ -8662,7 +8679,20 @@ function QueryForm({
|
|
|
8662
8679
|
observer.observe(actions);
|
|
8663
8680
|
row.querySelectorAll(":scope > .sia-query-form__field").forEach((field) => observer.observe(field));
|
|
8664
8681
|
return () => observer.disconnect();
|
|
8665
|
-
}, [
|
|
8682
|
+
}, [
|
|
8683
|
+
collapsed,
|
|
8684
|
+
needsCollapse,
|
|
8685
|
+
collapsible,
|
|
8686
|
+
limit,
|
|
8687
|
+
fieldWidth,
|
|
8688
|
+
fields,
|
|
8689
|
+
children,
|
|
8690
|
+
actionsExtra,
|
|
8691
|
+
onSaveQuery,
|
|
8692
|
+
searchText,
|
|
8693
|
+
resetText,
|
|
8694
|
+
saveText
|
|
8695
|
+
]);
|
|
8666
8696
|
async function search(values) {
|
|
8667
8697
|
const info = source.current;
|
|
8668
8698
|
source.current = { source: "submit" };
|
|
@@ -8713,7 +8743,9 @@ function QueryForm({
|
|
|
8713
8743
|
await onSaveQuery({ name, values: snapshot.current });
|
|
8714
8744
|
setSaveOpen(false);
|
|
8715
8745
|
} catch (reason) {
|
|
8716
|
-
setSaveError(
|
|
8746
|
+
setSaveError(
|
|
8747
|
+
reason instanceof Error ? reason.message : "\u4FDD\u5B58\u5931\u8D25\uFF0C\u8BF7\u91CD\u8BD5"
|
|
8748
|
+
);
|
|
8717
8749
|
onError?.(reason, "save");
|
|
8718
8750
|
return false;
|
|
8719
8751
|
} finally {
|
|
@@ -8758,58 +8790,98 @@ function QueryForm({
|
|
|
8758
8790
|
},
|
|
8759
8791
|
children: [
|
|
8760
8792
|
quickQueries.length ? /* @__PURE__ */ jsxs24("div", { className: "sia-query-form__quick", "aria-label": "\u9884\u8BBE\u5FEB\u6377\u67E5\u8BE2", children: [
|
|
8761
|
-
quickQueries.map((query) => /* @__PURE__ */ jsx26(
|
|
8762
|
-
|
|
8793
|
+
quickQueries.map((query) => /* @__PURE__ */ jsx26(
|
|
8794
|
+
Badge,
|
|
8763
8795
|
{
|
|
8764
|
-
|
|
8765
|
-
|
|
8766
|
-
|
|
8767
|
-
|
|
8768
|
-
|
|
8769
|
-
|
|
8770
|
-
|
|
8771
|
-
|
|
8796
|
+
className: "sia-query-form__quick-badge",
|
|
8797
|
+
showZero: true,
|
|
8798
|
+
size: "small",
|
|
8799
|
+
title: query.count === void 0 ? void 0 : `\u5171 ${query.count} \u6761`,
|
|
8800
|
+
...query.badgeProps,
|
|
8801
|
+
count: query.count,
|
|
8802
|
+
children: /* @__PURE__ */ jsx26(
|
|
8803
|
+
Button,
|
|
8804
|
+
{
|
|
8805
|
+
size: query.size ?? quickQuerySize,
|
|
8806
|
+
"aria-pressed": activeShortcut === `quick:${query.key}`,
|
|
8807
|
+
variant: activeShortcut === `quick:${query.key}` ? "primary" : "default",
|
|
8808
|
+
disabled: shortcutBusy || query.disabled,
|
|
8809
|
+
onClick: () => applyShortcut(query, "quick"),
|
|
8810
|
+
children: query.label
|
|
8811
|
+
}
|
|
8812
|
+
)
|
|
8813
|
+
},
|
|
8814
|
+
query.key
|
|
8815
|
+
)),
|
|
8772
8816
|
" "
|
|
8773
8817
|
] }) : null,
|
|
8774
|
-
/* @__PURE__ */ jsxs24(
|
|
8775
|
-
|
|
8776
|
-
|
|
8777
|
-
|
|
8778
|
-
|
|
8779
|
-
|
|
8780
|
-
|
|
8781
|
-
children: entry.content
|
|
8818
|
+
/* @__PURE__ */ jsxs24(
|
|
8819
|
+
"div",
|
|
8820
|
+
{
|
|
8821
|
+
ref: rowRef,
|
|
8822
|
+
className: `sia-query-form__fields${collapsed ? " is-collapsed" : ""}`,
|
|
8823
|
+
style: {
|
|
8824
|
+
"--sia-query-field-width": typeof fieldWidth === "number" ? `${fieldWidth}px` : fieldWidth
|
|
8782
8825
|
},
|
|
8783
|
-
|
|
8784
|
-
|
|
8785
|
-
|
|
8786
|
-
|
|
8787
|
-
|
|
8788
|
-
|
|
8789
|
-
|
|
8790
|
-
|
|
8791
|
-
|
|
8792
|
-
|
|
8793
|
-
setSaveOpen(true);
|
|
8794
|
-
}, children: saveText }) : null
|
|
8795
|
-
] }),
|
|
8796
|
-
collapsible && entries.length > 0 ? /* @__PURE__ */ jsx26("span", { ref: toggleRef, hidden: !needsCollapse, children: /* @__PURE__ */ jsx26(
|
|
8797
|
-
Button,
|
|
8798
|
-
{
|
|
8799
|
-
variant: "link",
|
|
8800
|
-
"aria-expanded": !collapsed,
|
|
8801
|
-
icon: /* @__PURE__ */ jsx26(Icon, { name: collapsed ? "chevron-down" : "chevron-up" }),
|
|
8802
|
-
iconPosition: "end",
|
|
8803
|
-
onClick: () => {
|
|
8804
|
-
setInternalCollapsed(!collapsed);
|
|
8805
|
-
onCollapsedChange?.(!collapsed);
|
|
8826
|
+
children: [
|
|
8827
|
+
entries.map((entry, index) => /* @__PURE__ */ jsx26(
|
|
8828
|
+
"div",
|
|
8829
|
+
{
|
|
8830
|
+
className: "sia-query-form__field",
|
|
8831
|
+
hidden: collapsed && index >= Math.min(limit, fittingCount),
|
|
8832
|
+
style: entry.width !== void 0 ? {
|
|
8833
|
+
"--sia-query-item-width": typeof entry.width === "number" ? `${entry.width}px` : entry.width
|
|
8834
|
+
} : void 0,
|
|
8835
|
+
children: entry.content
|
|
8806
8836
|
},
|
|
8807
|
-
|
|
8808
|
-
|
|
8809
|
-
|
|
8810
|
-
|
|
8811
|
-
|
|
8812
|
-
|
|
8837
|
+
entry.key
|
|
8838
|
+
)),
|
|
8839
|
+
/* @__PURE__ */ jsxs24("div", { ref: actionsRef, className: "sia-query-form__actions", children: [
|
|
8840
|
+
/* @__PURE__ */ jsxs24(Space.Compact, { children: [
|
|
8841
|
+
/* @__PURE__ */ jsx26(
|
|
8842
|
+
Button,
|
|
8843
|
+
{
|
|
8844
|
+
type: "submit",
|
|
8845
|
+
variant: "primary",
|
|
8846
|
+
loading: loading || searching,
|
|
8847
|
+
disabled,
|
|
8848
|
+
children: searchText
|
|
8849
|
+
}
|
|
8850
|
+
),
|
|
8851
|
+
/* @__PURE__ */ jsx26(Button, { disabled: busy, onClick: reset, children: resetText }),
|
|
8852
|
+
onSaveQuery ? /* @__PURE__ */ jsx26(
|
|
8853
|
+
Button,
|
|
8854
|
+
{
|
|
8855
|
+
disabled: shortcutBusy,
|
|
8856
|
+
onClick: () => {
|
|
8857
|
+
snapshot.current = form.getFieldsValue();
|
|
8858
|
+
setSaveName("");
|
|
8859
|
+
setSaveError("");
|
|
8860
|
+
setSaveOpen(true);
|
|
8861
|
+
},
|
|
8862
|
+
children: saveText
|
|
8863
|
+
}
|
|
8864
|
+
) : null
|
|
8865
|
+
] }),
|
|
8866
|
+
collapsible && entries.length > 0 ? /* @__PURE__ */ jsx26("span", { ref: toggleRef, hidden: !needsCollapse, children: /* @__PURE__ */ jsx26(
|
|
8867
|
+
Button,
|
|
8868
|
+
{
|
|
8869
|
+
variant: "link",
|
|
8870
|
+
"aria-expanded": !collapsed,
|
|
8871
|
+
icon: /* @__PURE__ */ jsx26(Icon, { name: collapsed ? "chevron-down" : "chevron-up" }),
|
|
8872
|
+
iconPosition: "end",
|
|
8873
|
+
onClick: () => {
|
|
8874
|
+
setInternalCollapsed(!collapsed);
|
|
8875
|
+
onCollapsedChange?.(!collapsed);
|
|
8876
|
+
},
|
|
8877
|
+
children: collapsed ? "\u5C55\u5F00" : "\u6536\u8D77"
|
|
8878
|
+
}
|
|
8879
|
+
) }) : null,
|
|
8880
|
+
actionsExtra
|
|
8881
|
+
] })
|
|
8882
|
+
]
|
|
8883
|
+
}
|
|
8884
|
+
),
|
|
8813
8885
|
savedQueries.length && !collapsed ? /* @__PURE__ */ jsxs24("div", { className: "sia-query-form__saved", "aria-label": "\u5DF2\u4FDD\u5B58\u5FEB\u6377\u67E5\u8BE2", children: [
|
|
8814
8886
|
savedQueries.map((query, index) => /* @__PURE__ */ jsx26(
|
|
8815
8887
|
Tag,
|
|
@@ -8841,30 +8913,41 @@ function QueryForm({
|
|
|
8841
8913
|
]
|
|
8842
8914
|
}
|
|
8843
8915
|
),
|
|
8844
|
-
/* @__PURE__ */ jsxs24(
|
|
8845
|
-
|
|
8846
|
-
|
|
8847
|
-
|
|
8848
|
-
|
|
8849
|
-
|
|
8850
|
-
|
|
8851
|
-
|
|
8852
|
-
|
|
8853
|
-
|
|
8854
|
-
|
|
8855
|
-
|
|
8856
|
-
|
|
8857
|
-
|
|
8858
|
-
|
|
8859
|
-
|
|
8860
|
-
|
|
8861
|
-
|
|
8916
|
+
/* @__PURE__ */ jsxs24(
|
|
8917
|
+
Modal,
|
|
8918
|
+
{
|
|
8919
|
+
open: saveOpen,
|
|
8920
|
+
title: "\u53E6\u5B58\u4E3A\u5FEB\u6377\u67E5\u8BE2",
|
|
8921
|
+
width: 420,
|
|
8922
|
+
confirmLoading: saving,
|
|
8923
|
+
onOk: save,
|
|
8924
|
+
onOpenChange: (next) => {
|
|
8925
|
+
if (!saveLock.current) setSaveOpen(next);
|
|
8926
|
+
},
|
|
8927
|
+
children: [
|
|
8928
|
+
/* @__PURE__ */ jsx26(
|
|
8929
|
+
Input,
|
|
8930
|
+
{
|
|
8931
|
+
autoFocus: true,
|
|
8932
|
+
"aria-label": "\u5FEB\u6377\u67E5\u8BE2\u540D\u79F0",
|
|
8933
|
+
placeholder: "\u5FEB\u6377\u67E5\u8BE2\u540D\u79F0",
|
|
8934
|
+
value: saveName,
|
|
8935
|
+
maxLength: 80,
|
|
8936
|
+
disabled: saving,
|
|
8937
|
+
status: saveError ? "error" : "default",
|
|
8938
|
+
onChange: (event) => setSaveName(event.target.value),
|
|
8939
|
+
onKeyDown: (event) => {
|
|
8940
|
+
if (event.key === "Enter") {
|
|
8941
|
+
event.preventDefault();
|
|
8942
|
+
void save();
|
|
8943
|
+
}
|
|
8944
|
+
}
|
|
8862
8945
|
}
|
|
8863
|
-
|
|
8864
|
-
|
|
8865
|
-
|
|
8866
|
-
|
|
8867
|
-
|
|
8946
|
+
),
|
|
8947
|
+
saveError ? /* @__PURE__ */ jsx26("p", { className: "sia-query-form__error", role: "alert", children: saveError }) : null
|
|
8948
|
+
]
|
|
8949
|
+
}
|
|
8950
|
+
)
|
|
8868
8951
|
] });
|
|
8869
8952
|
}
|
|
8870
8953
|
export {
|