@sia.soul/sia-react-ui 0.1.119 → 0.1.121

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
@@ -67,6 +67,7 @@ import {
67
67
  FloatButton,
68
68
  Image,
69
69
  ImagePreview,
70
+ ImagePreviewGroup,
70
71
  Popconfirm,
71
72
  Progress,
72
73
  Rate,
@@ -81,7 +82,7 @@ import {
81
82
  Watermark,
82
83
  message,
83
84
  notification
84
- } from "./chunk-BEVCKS5J.js";
85
+ } from "./chunk-UW2W7RYZ.js";
85
86
  import "./chunk-RX242MUO.js";
86
87
  import {
87
88
  MarkdownEditor
@@ -89,12 +90,12 @@ import {
89
90
  import {
90
91
  RichTextContent,
91
92
  RichTextEditor
92
- } from "./chunk-QBBIBJXW.js";
93
+ } from "./chunk-ODJNSVNB.js";
93
94
  import {
94
95
  DatePicker,
95
96
  SelectDateRange,
96
97
  TimePanel
97
- } from "./chunk-AOWWHL5Z.js";
98
+ } from "./chunk-RZR3EZRL.js";
98
99
  import {
99
100
  Checkbox,
100
101
  FloatingScrollbarProvider,
@@ -106,14 +107,14 @@ import {
106
107
  Tooltip,
107
108
  Tree,
108
109
  useScrollbarProximity
109
- } from "./chunk-BQIARYZB.js";
110
+ } from "./chunk-XDG736H7.js";
110
111
  import {
111
112
  Dropdown,
112
113
  Input,
113
114
  Menu,
114
115
  Segmented,
115
116
  Steps
116
- } from "./chunk-GKFFFHHU.js";
117
+ } from "./chunk-IRMKZYGV.js";
117
118
  import {
118
119
  TextArea
119
120
  } from "./chunk-SCEHVGKV.js";
@@ -124,7 +125,7 @@ import {
124
125
  Modal,
125
126
  OverlayPortal,
126
127
  useOverlayLifecycle
127
- } from "./chunk-6MGFX7B2.js";
128
+ } from "./chunk-ZD45Z2NI.js";
128
129
  import {
129
130
  Button
130
131
  } from "./chunk-CZ2ITBRW.js";
@@ -1839,6 +1840,21 @@ var FormStore = class {
1839
1840
  });
1840
1841
  this.notify();
1841
1842
  };
1843
+ setFields = (fields) => {
1844
+ if (!fields.length) return;
1845
+ fields.forEach((field) => {
1846
+ const path = pathArray(field.name);
1847
+ if (Object.prototype.hasOwnProperty.call(field, "value")) {
1848
+ if (!this.initialized) this.pendingWrites.push({ path: [...path], value: cloneFormValue(field.value) });
1849
+ this.values = setValue(this.values, path, field.value);
1850
+ }
1851
+ if (field.errors !== void 0) {
1852
+ if (field.errors.length) this.errors.set(pathKey2(path), [...field.errors]);
1853
+ else this.errors.delete(pathKey2(path));
1854
+ }
1855
+ });
1856
+ this.notify();
1857
+ };
1842
1858
  resetFields = (names) => {
1843
1859
  if (!names) {
1844
1860
  this.pendingWrites = [];
@@ -1925,6 +1941,7 @@ function useForm(form) {
1925
1941
  return [ref.current];
1926
1942
  }
1927
1943
  function FormRoot({
1944
+ fill = false,
1928
1945
  form,
1929
1946
  initialValues,
1930
1947
  layout = "horizontal",
@@ -1991,7 +2008,7 @@ function FormRoot({
1991
2008
  {
1992
2009
  ref: formRef,
1993
2010
  ...withTitleTooltip(props),
1994
- className: `sia-form sia-form--${layout} sia-form--${size}${disabled ? " is-disabled" : ""} ${className}`.trim(),
2011
+ className: `sia-form sia-form--${layout} sia-form--${size}${fill ? " sia-form--fill" : ""}${disabled ? " is-disabled" : ""} ${className}`.trim(),
1995
2012
  "data-required-mark": requiredMark,
1996
2013
  onSubmit: (event) => {
1997
2014
  event.preventDefault();
@@ -10136,6 +10153,7 @@ export {
10136
10153
  Icon,
10137
10154
  Image,
10138
10155
  ImagePreview,
10156
+ ImagePreviewGroup,
10139
10157
  Input,
10140
10158
  InputNumber,
10141
10159
  InputSelect,
@@ -2117,7 +2117,14 @@ function focusableElements(container) {
2117
2117
  'a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])'
2118
2118
  )].filter((element) => !element.hidden && element.getAttribute("aria-hidden") !== "true");
2119
2119
  }
2120
- function useOverlayLifecycle(open, panelRef, onRequestClose, keyboard = true) {
2120
+ function firstModalInput(panel) {
2121
+ const body = panel.querySelector(":scope > .sia-modal__body");
2122
+ const candidates = body?.querySelectorAll(
2123
+ 'input:not([type="hidden"]):not([type="button"]):not([type="submit"]):not([type="reset"]), textarea, select, [contenteditable="true"], [role="combobox"], .sia-picker__trigger, .sia-cascader__trigger, .sia-tree-select__trigger'
2124
+ );
2125
+ return [...candidates ?? []].find((element) => (element.tabIndex >= 0 || element.isContentEditable && !element.hasAttribute("tabindex")) && !element.matches(":disabled, [readonly], [aria-readonly='true']") && !element.closest('[hidden], [inert], [aria-hidden="true"], [aria-disabled="true"]') && element.getClientRects().length > 0 && getComputedStyle(element).visibility === "visible");
2126
+ }
2127
+ function useOverlayLifecycle(open, panelRef, onRequestClose, keyboard = true, autoFocusInput = false) {
2121
2128
  const overlayIdRef = (0, import_react9.useRef)(/* @__PURE__ */ Symbol("sia-overlay"));
2122
2129
  const closeRef = (0, import_react9.useRef)(onRequestClose);
2123
2130
  closeRef.current = onRequestClose;
@@ -2131,9 +2138,11 @@ function useOverlayLifecycle(open, panelRef, onRequestClose, keyboard = true) {
2131
2138
  const unlockBody = lockBodyScroll();
2132
2139
  const focusTimer = window.setTimeout(() => {
2133
2140
  const panel = panelRef.current;
2134
- if (!panel) return;
2141
+ if (!panel || overlayStack.at(-1) !== overlayId) return;
2142
+ if (panel.contains(document.activeElement) && document.activeElement !== panel) return;
2135
2143
  const [firstFocusable] = focusableElements(panel);
2136
- (firstFocusable ?? panel).focus({ preventScroll: true });
2144
+ const input = autoFocusInput ? firstModalInput(panel) : void 0;
2145
+ (input ?? firstFocusable ?? panel).focus({ preventScroll: true });
2137
2146
  }, 0);
2138
2147
  function handleKeyDown(event) {
2139
2148
  if (overlayStack.at(-1) !== overlayId) return;
@@ -2170,7 +2179,7 @@ function useOverlayLifecycle(open, panelRef, onRequestClose, keyboard = true) {
2170
2179
  unlockBody();
2171
2180
  previouslyFocused?.focus({ preventScroll: true });
2172
2181
  };
2173
- }, [keyboard, open, panelRef]);
2182
+ }, [keyboard, open, panelRef, autoFocusInput]);
2174
2183
  }
2175
2184
  function OverlayPortal({ children, container }) {
2176
2185
  if (typeof document === "undefined") return null;
@@ -2191,6 +2200,7 @@ var typeIcons = {
2191
2200
  };
2192
2201
  var ModalRoot = (0, import_react10.forwardRef)(function Modal({
2193
2202
  open,
2203
+ autoFocus = true,
2194
2204
  title,
2195
2205
  children,
2196
2206
  footer,
@@ -2280,7 +2290,7 @@ var ModalRoot = (0, import_react10.forwardRef)(function Modal({
2280
2290
  setSubmitting(false);
2281
2291
  }
2282
2292
  }
2283
- useOverlayLifecycle(rendered, localRef, requestClose, keyboard);
2293
+ useOverlayLifecycle(rendered, localRef, requestClose, keyboard, autoFocus);
2284
2294
  if (!rendered) return null;
2285
2295
  const mergedStyle = {
2286
2296
  ...height !== void 0 ? { display: "flex", flexDirection: "column", height, maxHeight: "calc(100dvh - 48px)" } : {},
@@ -1,10 +1,10 @@
1
1
  import {
2
2
  RichTextContent,
3
3
  RichTextEditor
4
- } from "./chunk-QBBIBJXW.js";
5
- import "./chunk-GKFFFHHU.js";
4
+ } from "./chunk-ODJNSVNB.js";
5
+ import "./chunk-IRMKZYGV.js";
6
6
  import "./chunk-SCEHVGKV.js";
7
- import "./chunk-6MGFX7B2.js";
7
+ import "./chunk-ZD45Z2NI.js";
8
8
  import "./chunk-CZ2ITBRW.js";
9
9
  import "./chunk-KY6A5IJH.js";
10
10
  import "./chunk-NZMUW5XI.js";
@@ -1,7 +1,7 @@
1
1
  import * as react from 'react';
2
2
  import { InputHTMLAttributes, ReactNode, HTMLAttributes, CSSProperties } from 'react';
3
3
  import { I as InputPlaceholderMode, C as ControlSize, a as ControlStatus } from './shared-Bx4B28Wh.js';
4
- import { S as SelectOption, j as SelectValue } from './Select-vjX7B63I.js';
4
+ import { S as SelectOption, j as SelectValue } from './Select-DgZW5a7j.js';
5
5
 
6
6
  /** 日期选择附带的时间选择配置。 */
7
7
  type DatePickerShowTime = boolean | {
@@ -1,7 +1,7 @@
1
1
  import * as react from 'react';
2
2
  import { InputHTMLAttributes, ReactNode, HTMLAttributes, CSSProperties } from 'react';
3
3
  import { I as InputPlaceholderMode, C as ControlSize, a as ControlStatus } from './shared-Bx4B28Wh.cjs';
4
- import { S as SelectOption, j as SelectValue } from './Select-BAFXKVZB.cjs';
4
+ import { S as SelectOption, j as SelectValue } from './Select-B9hlqeO5.cjs';
5
5
 
6
6
  /** 日期选择附带的时间选择配置。 */
7
7
  type DatePickerShowTime = boolean | {
@@ -2858,7 +2858,14 @@ function focusableElements(container) {
2858
2858
  'a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])'
2859
2859
  )].filter((element) => !element.hidden && element.getAttribute("aria-hidden") !== "true");
2860
2860
  }
2861
- function useOverlayLifecycle(open, panelRef, onRequestClose, keyboard = true) {
2861
+ function firstModalInput(panel) {
2862
+ const body = panel.querySelector(":scope > .sia-modal__body");
2863
+ const candidates = body?.querySelectorAll(
2864
+ 'input:not([type="hidden"]):not([type="button"]):not([type="submit"]):not([type="reset"]), textarea, select, [contenteditable="true"], [role="combobox"], .sia-picker__trigger, .sia-cascader__trigger, .sia-tree-select__trigger'
2865
+ );
2866
+ return [...candidates ?? []].find((element) => (element.tabIndex >= 0 || element.isContentEditable && !element.hasAttribute("tabindex")) && !element.matches(":disabled, [readonly], [aria-readonly='true']") && !element.closest('[hidden], [inert], [aria-hidden="true"], [aria-disabled="true"]') && element.getClientRects().length > 0 && getComputedStyle(element).visibility === "visible");
2867
+ }
2868
+ function useOverlayLifecycle(open, panelRef, onRequestClose, keyboard = true, autoFocusInput = false) {
2862
2869
  const overlayIdRef = (0, import_react10.useRef)(/* @__PURE__ */ Symbol("sia-overlay"));
2863
2870
  const closeRef = (0, import_react10.useRef)(onRequestClose);
2864
2871
  closeRef.current = onRequestClose;
@@ -2872,9 +2879,11 @@ function useOverlayLifecycle(open, panelRef, onRequestClose, keyboard = true) {
2872
2879
  const unlockBody = lockBodyScroll();
2873
2880
  const focusTimer = window.setTimeout(() => {
2874
2881
  const panel = panelRef.current;
2875
- if (!panel) return;
2882
+ if (!panel || overlayStack.at(-1) !== overlayId) return;
2883
+ if (panel.contains(document.activeElement) && document.activeElement !== panel) return;
2876
2884
  const [firstFocusable] = focusableElements(panel);
2877
- (firstFocusable ?? panel).focus({ preventScroll: true });
2885
+ const input = autoFocusInput ? firstModalInput(panel) : void 0;
2886
+ (input ?? firstFocusable ?? panel).focus({ preventScroll: true });
2878
2887
  }, 0);
2879
2888
  function handleKeyDown(event) {
2880
2889
  if (overlayStack.at(-1) !== overlayId) return;
@@ -2911,7 +2920,7 @@ function useOverlayLifecycle(open, panelRef, onRequestClose, keyboard = true) {
2911
2920
  unlockBody();
2912
2921
  previouslyFocused?.focus({ preventScroll: true });
2913
2922
  };
2914
- }, [keyboard, open, panelRef]);
2923
+ }, [keyboard, open, panelRef, autoFocusInput]);
2915
2924
  }
2916
2925
  function OverlayPortal({ children, container }) {
2917
2926
  if (typeof document === "undefined") return null;
@@ -2932,6 +2941,7 @@ var typeIcons = {
2932
2941
  };
2933
2942
  var ModalRoot = (0, import_react11.forwardRef)(function Modal({
2934
2943
  open,
2944
+ autoFocus = true,
2935
2945
  title,
2936
2946
  children,
2937
2947
  footer,
@@ -3021,7 +3031,7 @@ var ModalRoot = (0, import_react11.forwardRef)(function Modal({
3021
3031
  setSubmitting(false);
3022
3032
  }
3023
3033
  }
3024
- useOverlayLifecycle(rendered, localRef, requestClose, keyboard);
3034
+ useOverlayLifecycle(rendered, localRef, requestClose, keyboard, autoFocus);
3025
3035
  if (!rendered) return null;
3026
3036
  const mergedStyle = {
3027
3037
  ...height !== void 0 ? { display: "flex", flexDirection: "column", height, maxHeight: "calc(100dvh - 48px)" } : {},
@@ -1,5 +1,5 @@
1
- export { S as SelectDateRange, i as SelectDateRangeProps, j as SelectDateRangeValue } from './select-date-range-CIiI0F5o.cjs';
1
+ export { S as SelectDateRange, i as SelectDateRangeProps, j as SelectDateRangeValue } from './select-date-range-CZpQhFBu.cjs';
2
2
  import 'react';
3
3
  import './shared-Bx4B28Wh.cjs';
4
- import './Select-BAFXKVZB.cjs';
4
+ import './Select-B9hlqeO5.cjs';
5
5
  import './Button-O_pNB3SQ.cjs';
@@ -1,5 +1,5 @@
1
- export { S as SelectDateRange, i as SelectDateRangeProps, j as SelectDateRangeValue } from './select-date-range-C9jlUrCX.js';
1
+ export { S as SelectDateRange, i as SelectDateRangeProps, j as SelectDateRangeValue } from './select-date-range-BskjBzTI.js';
2
2
  import 'react';
3
3
  import './shared-Bx4B28Wh.js';
4
- import './Select-vjX7B63I.js';
4
+ import './Select-DgZW5a7j.js';
5
5
  import './Button-BiL3Wjsd.js';
@@ -1,10 +1,10 @@
1
1
  import {
2
2
  SelectDateRange
3
- } from "./chunk-AOWWHL5Z.js";
4
- import "./chunk-BQIARYZB.js";
5
- import "./chunk-GKFFFHHU.js";
3
+ } from "./chunk-RZR3EZRL.js";
4
+ import "./chunk-XDG736H7.js";
5
+ import "./chunk-IRMKZYGV.js";
6
6
  import "./chunk-SCEHVGKV.js";
7
- import "./chunk-6MGFX7B2.js";
7
+ import "./chunk-ZD45Z2NI.js";
8
8
  import "./chunk-CZ2ITBRW.js";
9
9
  import "./chunk-KY6A5IJH.js";
10
10
  import "./chunk-NZMUW5XI.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sia.soul/sia-react-ui",
3
- "version": "0.1.119",
3
+ "version": "0.1.121",
4
4
  "description": "Sia Design components and tokens for React",
5
5
  "publishConfig": {
6
6
  "access": "public",