@sia.soul/sia-react-ui 0.1.125 → 0.1.126

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/core.css CHANGED
@@ -8095,6 +8095,10 @@ body:has(.sia-window-frame[data-sia-text-selectable=false]) img {
8095
8095
  font-size: 12px;
8096
8096
  line-height: 1.45;
8097
8097
  }
8098
+ .sia-floating__overlay.sia-form-item__error-popover--obscured {
8099
+ opacity: 0;
8100
+ animation: none;
8101
+ }
8098
8102
  .sia-form-item__error-content {
8099
8103
  display: flex;
8100
8104
  align-items: center;
package/dist/index.cjs CHANGED
@@ -7599,7 +7599,7 @@ function FormItem({
7599
7599
  const id = (0, import_react34.useId)();
7600
7600
  const itemRef = (0, import_react34.useRef)(null);
7601
7601
  const errorContentRef = (0, import_react34.useRef)(null);
7602
- const [errorPlacement, setErrorPlacement] = (0, import_react34.useState)("bottom-start");
7602
+ const [errorObscured, setErrorObscured] = (0, import_react34.useState)(false);
7603
7603
  if (!form) throw new Error("Form.Item \u5FC5\u987B\u5728 Form \u5185\u4F7F\u7528");
7604
7604
  (0, import_react34.useSyncExternalStore)(form.subscribe, form.getSnapshot, form.getSnapshot);
7605
7605
  const path = name === void 0 ? void 0 : pathArray(name);
@@ -7612,7 +7612,7 @@ function FormItem({
7612
7612
  const errorId = `${id}-error`;
7613
7613
  const hasError = status === "error" && Boolean(helpContent);
7614
7614
  (0, import_react34.useEffect)(() => {
7615
- setErrorPlacement("bottom-start");
7615
+ setErrorObscured(false);
7616
7616
  if (!hasError || noStyle) return void 0;
7617
7617
  const doc = itemRef.current?.ownerDocument;
7618
7618
  const view = doc?.defaultView;
@@ -7623,7 +7623,13 @@ function FormItem({
7623
7623
  frame = 0;
7624
7624
  const overlay = errorContentRef.current?.closest(".sia-form-item__error-popover");
7625
7625
  const bounds = overlay?.getBoundingClientRect();
7626
- if (point && bounds && point.x >= bounds.left && point.x <= bounds.right && point.y >= bounds.top && point.y <= bounds.bottom) setErrorPlacement("top-start");
7626
+ if (!bounds) return;
7627
+ const pointerInside = !!point && point.x >= bounds.left - 4 && point.x <= bounds.right + 4 && point.y >= bounds.top - 4 && point.y <= bounds.bottom + 4;
7628
+ const active = doc.activeElement;
7629
+ const otherControl = active?.matches("input, textarea, button, select, [role='combobox'], [contenteditable='true']") && !itemRef.current?.contains(active);
7630
+ const focusedBounds = otherControl ? active?.getBoundingClientRect() : void 0;
7631
+ const coversFocus = !!focusedBounds && focusedBounds.width > 0 && focusedBounds.height > 0 && bounds.left < focusedBounds.right && bounds.right > focusedBounds.left && bounds.top < focusedBounds.bottom && bounds.bottom > focusedBounds.top;
7632
+ setErrorObscured(pointerInside || coversFocus);
7627
7633
  };
7628
7634
  const schedule = () => {
7629
7635
  if (!frame) frame = view.requestAnimationFrame(measure);
@@ -7637,14 +7643,23 @@ function FormItem({
7637
7643
  schedule();
7638
7644
  };
7639
7645
  doc.addEventListener("pointermove", move, { passive: true });
7646
+ doc.addEventListener("pointerdown", move, { passive: true });
7640
7647
  doc.addEventListener("pointerleave", leave);
7641
7648
  doc.addEventListener("scroll", schedule, true);
7649
+ doc.addEventListener("focusin", schedule);
7650
+ doc.addEventListener("focusout", schedule);
7651
+ view.addEventListener("resize", schedule);
7642
7652
  view.addEventListener("blur", leave);
7653
+ schedule();
7643
7654
  return () => {
7644
7655
  view.cancelAnimationFrame(frame);
7645
7656
  doc.removeEventListener("pointermove", move);
7657
+ doc.removeEventListener("pointerdown", move);
7646
7658
  doc.removeEventListener("pointerleave", leave);
7647
7659
  doc.removeEventListener("scroll", schedule, true);
7660
+ doc.removeEventListener("focusin", schedule);
7661
+ doc.removeEventListener("focusout", schedule);
7662
+ view.removeEventListener("resize", schedule);
7648
7663
  view.removeEventListener("blur", leave);
7649
7664
  };
7650
7665
  }, [hasError, noStyle, helpContent]);
@@ -7706,12 +7721,12 @@ function FormItem({
7706
7721
  /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(Icon, { className: "sia-form-item__error-icon", name: "circle-close", variant: "filled", size: 16, "aria-hidden": "true" }),
7707
7722
  /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("span", { children: helpContent })
7708
7723
  ] }) : null,
7709
- placement: errorPlacement,
7724
+ placement: "bottom-start",
7710
7725
  trigger: [],
7711
7726
  open: hasError,
7712
7727
  role: "alert",
7713
7728
  color: "var(--sia-color-error)",
7714
- overlayClassName: "sia-form-item__error-popover",
7729
+ overlayClassName: `sia-form-item__error-popover${errorObscured ? " sia-form-item__error-popover--obscured" : ""}`,
7715
7730
  children: inputWrap
7716
7731
  }
7717
7732
  ),
package/dist/index.css CHANGED
@@ -8095,6 +8095,10 @@ body:has(.sia-window-frame[data-sia-text-selectable=false]) img {
8095
8095
  font-size: 12px;
8096
8096
  line-height: 1.45;
8097
8097
  }
8098
+ .sia-floating__overlay.sia-form-item__error-popover--obscured {
8099
+ opacity: 0;
8100
+ animation: none;
8101
+ }
8098
8102
  .sia-form-item__error-content {
8099
8103
  display: flex;
8100
8104
  align-items: center;
package/dist/index.d.cts CHANGED
@@ -868,7 +868,7 @@ interface FormProps extends Omit<FormHTMLAttributes<HTMLFormElement>, "onSubmit"
868
868
  onValuesChange?: (changedValues: FormValues, values: FormValues) => void;
869
869
  }
870
870
  declare function FormRoot({ fill, form, initialValues, layout, size: sizeProp, placeholderMode, disabled, requiredMark, className, onFinish, onFinishFailed, onValuesChange, children, ...props }: FormProps): react.JSX.Element;
871
- /** 表单项的字段绑定、标签、校验及内容配置;错误气泡不占布局空间,默认在下方,鼠标进入气泡区域后移到上方。默认保留 8px 下外边距,noStyle 不生成布局容器或间距。 */
871
+ /** 表单项的字段绑定、标签、校验及内容配置;错误气泡不占布局空间,指针进入覆盖区域或被遮挡控件获得焦点时暂时隐藏。默认保留 8px 下外边距,noStyle 不生成布局容器或间距。 */
872
872
  interface FormItemProps {
873
873
  /** 绑定到表单值的字段名或嵌套路径,例如 ["user", "name"]。 */
874
874
  name?: NamePath;
@@ -887,7 +887,7 @@ interface FormItemProps {
887
887
  required?: boolean;
888
888
  /** 主体之外的补充内容或操作区。 */
889
889
  extra?: ReactNode;
890
- /** 字段下方的辅助说明或校验提示;错误气泡默认位于下方,鼠标进入后改为上方并保持,错误变化后恢复默认位置。视口空间不足时沿用浮层防溢出规则。 */
890
+ /** 字段下方的辅助说明或校验提示;错误气泡默认位于下方,指针进入覆盖区域或其他被遮挡控件获得焦点时暂时透明,移出且焦点离开后恢复。保留错误文本和无障碍关联,视口空间不足时沿用浮层防溢出规则。 */
891
891
  help?: ReactNode;
892
892
  /** 手动指定字段校验状态。 */
893
893
  validateStatus?: "success" | "warning" | "error" | "validating";
package/dist/index.d.ts CHANGED
@@ -868,7 +868,7 @@ interface FormProps extends Omit<FormHTMLAttributes<HTMLFormElement>, "onSubmit"
868
868
  onValuesChange?: (changedValues: FormValues, values: FormValues) => void;
869
869
  }
870
870
  declare function FormRoot({ fill, form, initialValues, layout, size: sizeProp, placeholderMode, disabled, requiredMark, className, onFinish, onFinishFailed, onValuesChange, children, ...props }: FormProps): react.JSX.Element;
871
- /** 表单项的字段绑定、标签、校验及内容配置;错误气泡不占布局空间,默认在下方,鼠标进入气泡区域后移到上方。默认保留 8px 下外边距,noStyle 不生成布局容器或间距。 */
871
+ /** 表单项的字段绑定、标签、校验及内容配置;错误气泡不占布局空间,指针进入覆盖区域或被遮挡控件获得焦点时暂时隐藏。默认保留 8px 下外边距,noStyle 不生成布局容器或间距。 */
872
872
  interface FormItemProps {
873
873
  /** 绑定到表单值的字段名或嵌套路径,例如 ["user", "name"]。 */
874
874
  name?: NamePath;
@@ -887,7 +887,7 @@ interface FormItemProps {
887
887
  required?: boolean;
888
888
  /** 主体之外的补充内容或操作区。 */
889
889
  extra?: ReactNode;
890
- /** 字段下方的辅助说明或校验提示;错误气泡默认位于下方,鼠标进入后改为上方并保持,错误变化后恢复默认位置。视口空间不足时沿用浮层防溢出规则。 */
890
+ /** 字段下方的辅助说明或校验提示;错误气泡默认位于下方,指针进入覆盖区域或其他被遮挡控件获得焦点时暂时透明,移出且焦点离开后恢复。保留错误文本和无障碍关联,视口空间不足时沿用浮层防溢出规则。 */
891
891
  help?: ReactNode;
892
892
  /** 手动指定字段校验状态。 */
893
893
  validateStatus?: "success" | "warning" | "error" | "validating";
package/dist/index.js CHANGED
@@ -2060,7 +2060,7 @@ function FormItem({
2060
2060
  const id = useId3();
2061
2061
  const itemRef = useRef8(null);
2062
2062
  const errorContentRef = useRef8(null);
2063
- const [errorPlacement, setErrorPlacement] = useState9("bottom-start");
2063
+ const [errorObscured, setErrorObscured] = useState9(false);
2064
2064
  if (!form) throw new Error("Form.Item \u5FC5\u987B\u5728 Form \u5185\u4F7F\u7528");
2065
2065
  useSyncExternalStore(form.subscribe, form.getSnapshot, form.getSnapshot);
2066
2066
  const path = name === void 0 ? void 0 : pathArray(name);
@@ -2073,7 +2073,7 @@ function FormItem({
2073
2073
  const errorId = `${id}-error`;
2074
2074
  const hasError = status === "error" && Boolean(helpContent);
2075
2075
  useEffect6(() => {
2076
- setErrorPlacement("bottom-start");
2076
+ setErrorObscured(false);
2077
2077
  if (!hasError || noStyle) return void 0;
2078
2078
  const doc = itemRef.current?.ownerDocument;
2079
2079
  const view = doc?.defaultView;
@@ -2084,7 +2084,13 @@ function FormItem({
2084
2084
  frame = 0;
2085
2085
  const overlay = errorContentRef.current?.closest(".sia-form-item__error-popover");
2086
2086
  const bounds = overlay?.getBoundingClientRect();
2087
- if (point && bounds && point.x >= bounds.left && point.x <= bounds.right && point.y >= bounds.top && point.y <= bounds.bottom) setErrorPlacement("top-start");
2087
+ if (!bounds) return;
2088
+ const pointerInside = !!point && point.x >= bounds.left - 4 && point.x <= bounds.right + 4 && point.y >= bounds.top - 4 && point.y <= bounds.bottom + 4;
2089
+ const active = doc.activeElement;
2090
+ const otherControl = active?.matches("input, textarea, button, select, [role='combobox'], [contenteditable='true']") && !itemRef.current?.contains(active);
2091
+ const focusedBounds = otherControl ? active?.getBoundingClientRect() : void 0;
2092
+ const coversFocus = !!focusedBounds && focusedBounds.width > 0 && focusedBounds.height > 0 && bounds.left < focusedBounds.right && bounds.right > focusedBounds.left && bounds.top < focusedBounds.bottom && bounds.bottom > focusedBounds.top;
2093
+ setErrorObscured(pointerInside || coversFocus);
2088
2094
  };
2089
2095
  const schedule = () => {
2090
2096
  if (!frame) frame = view.requestAnimationFrame(measure);
@@ -2098,14 +2104,23 @@ function FormItem({
2098
2104
  schedule();
2099
2105
  };
2100
2106
  doc.addEventListener("pointermove", move, { passive: true });
2107
+ doc.addEventListener("pointerdown", move, { passive: true });
2101
2108
  doc.addEventListener("pointerleave", leave);
2102
2109
  doc.addEventListener("scroll", schedule, true);
2110
+ doc.addEventListener("focusin", schedule);
2111
+ doc.addEventListener("focusout", schedule);
2112
+ view.addEventListener("resize", schedule);
2103
2113
  view.addEventListener("blur", leave);
2114
+ schedule();
2104
2115
  return () => {
2105
2116
  view.cancelAnimationFrame(frame);
2106
2117
  doc.removeEventListener("pointermove", move);
2118
+ doc.removeEventListener("pointerdown", move);
2107
2119
  doc.removeEventListener("pointerleave", leave);
2108
2120
  doc.removeEventListener("scroll", schedule, true);
2121
+ doc.removeEventListener("focusin", schedule);
2122
+ doc.removeEventListener("focusout", schedule);
2123
+ view.removeEventListener("resize", schedule);
2109
2124
  view.removeEventListener("blur", leave);
2110
2125
  };
2111
2126
  }, [hasError, noStyle, helpContent]);
@@ -2167,12 +2182,12 @@ function FormItem({
2167
2182
  /* @__PURE__ */ jsx11(Icon, { className: "sia-form-item__error-icon", name: "circle-close", variant: "filled", size: 16, "aria-hidden": "true" }),
2168
2183
  /* @__PURE__ */ jsx11("span", { children: helpContent })
2169
2184
  ] }) : null,
2170
- placement: errorPlacement,
2185
+ placement: "bottom-start",
2171
2186
  trigger: [],
2172
2187
  open: hasError,
2173
2188
  role: "alert",
2174
2189
  color: "var(--sia-color-error)",
2175
- overlayClassName: "sia-form-item__error-popover",
2190
+ overlayClassName: `sia-form-item__error-popover${errorObscured ? " sia-form-item__error-popover--obscured" : ""}`,
2176
2191
  children: inputWrap
2177
2192
  }
2178
2193
  ),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sia.soul/sia-react-ui",
3
- "version": "0.1.125",
3
+ "version": "0.1.126",
4
4
  "description": "Sia Design components and tokens for React",
5
5
  "publishConfig": {
6
6
  "access": "public",