@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/index.js CHANGED
@@ -80,7 +80,7 @@ import {
80
80
  Watermark,
81
81
  message,
82
82
  notification
83
- } from "./chunk-QJH7H3CB.js";
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 }) => ({ key, width, content: /* @__PURE__ */ jsx26(Form.Item, { noStyle: true, ...item }) })) : Children4.toArray(children).map((content, index) => ({ key: String(index), width: void 0, content }));
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(row.querySelectorAll(":scope > .sia-query-form__field"));
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((total, field) => total + field.getBoundingClientRect().width + gap, actions.getBoundingClientRect().width);
8642
- setNeedsCollapse(allFields.length > 0 && requiredWidth > row.clientWidth + 0.5);
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(row.querySelectorAll(":scope > .sia-query-form__field")).slice(0, limit)) {
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
- }, [collapsed, needsCollapse, collapsible, limit, fieldWidth, fields, children, actionsExtra, onSaveQuery, searchText, resetText, saveText]);
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(reason instanceof Error ? reason.message : "\u4FDD\u5B58\u5931\u8D25\uFF0C\u8BF7\u91CD\u8BD5");
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(Badge, { className: "sia-query-form__quick-badge", showZero: true, size: "small", title: query.count === void 0 ? void 0 : `\u5171 ${query.count} \u6761`, ...query.badgeProps, count: query.count, children: /* @__PURE__ */ jsx26(
8762
- Button,
8793
+ quickQueries.map((query) => /* @__PURE__ */ jsx26(
8794
+ Badge,
8763
8795
  {
8764
- size: query.size ?? quickQuerySize,
8765
- "aria-pressed": activeShortcut === `quick:${query.key}`,
8766
- variant: activeShortcut === `quick:${query.key}` ? "primary" : "default",
8767
- disabled: shortcutBusy || query.disabled,
8768
- onClick: () => applyShortcut(query, "quick"),
8769
- children: query.label
8770
- }
8771
- ) }, query.key)),
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("div", { ref: rowRef, className: `sia-query-form__fields${collapsed ? " is-collapsed" : ""}`, style: { "--sia-query-field-width": typeof fieldWidth === "number" ? `${fieldWidth}px` : fieldWidth }, children: [
8775
- entries.map((entry, index) => /* @__PURE__ */ jsx26(
8776
- "div",
8777
- {
8778
- className: "sia-query-form__field",
8779
- hidden: collapsed && index >= Math.min(limit, fittingCount),
8780
- style: entry.width !== void 0 ? { "--sia-query-item-width": typeof entry.width === "number" ? `${entry.width}px` : entry.width } : void 0,
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
- entry.key
8784
- )),
8785
- /* @__PURE__ */ jsxs24("div", { ref: actionsRef, className: "sia-query-form__actions", children: [
8786
- /* @__PURE__ */ jsxs24(Space.Compact, { children: [
8787
- /* @__PURE__ */ jsx26(Button, { type: "submit", variant: "primary", loading: loading || searching, disabled, children: searchText }),
8788
- /* @__PURE__ */ jsx26(Button, { disabled: busy, onClick: reset, children: resetText }),
8789
- onSaveQuery ? /* @__PURE__ */ jsx26(Button, { disabled: shortcutBusy, onClick: () => {
8790
- snapshot.current = form.getFieldsValue();
8791
- setSaveName("");
8792
- setSaveError("");
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
- children: collapsed ? "\u5C55\u5F00" : "\u6536\u8D77"
8808
- }
8809
- ) }) : null,
8810
- actionsExtra
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(Modal, { open: saveOpen, title: "\u53E6\u5B58\u4E3A\u5FEB\u6377\u67E5\u8BE2", width: 420, confirmLoading: saving, onOk: save, onOpenChange: (next) => {
8845
- if (!saveLock.current) setSaveOpen(next);
8846
- }, children: [
8847
- /* @__PURE__ */ jsx26(
8848
- Input,
8849
- {
8850
- autoFocus: true,
8851
- "aria-label": "\u5FEB\u6377\u67E5\u8BE2\u540D\u79F0",
8852
- placeholder: "\u5FEB\u6377\u67E5\u8BE2\u540D\u79F0",
8853
- value: saveName,
8854
- maxLength: 80,
8855
- disabled: saving,
8856
- status: saveError ? "error" : "default",
8857
- onChange: (event) => setSaveName(event.target.value),
8858
- onKeyDown: (event) => {
8859
- if (event.key === "Enter") {
8860
- event.preventDefault();
8861
- void save();
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
- saveError ? /* @__PURE__ */ jsx26("p", { className: "sia-query-form__error", role: "alert", children: saveError }) : null
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 {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sia.soul/sia-react-ui",
3
- "version": "0.1.60",
3
+ "version": "0.1.63",
4
4
  "description": "Sia Design components and tokens for React",
5
5
  "publishConfig": {
6
6
  "access": "public",