@aloudata/aloudata-design 3.0.27 → 3.1.1

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.
Files changed (224) hide show
  1. package/dist/AProgress/index.js +10 -0
  2. package/dist/AProgress/index.js.map +1 -1
  3. package/dist/Alert/index.js +3 -1
  4. package/dist/Alert/index.js.map +1 -1
  5. package/dist/Badge/index.js +37 -11
  6. package/dist/Badge/index.js.map +1 -1
  7. package/dist/Breadcrumb/index.js +12 -2
  8. package/dist/Breadcrumb/index.js.map +1 -1
  9. package/dist/Button/index.d.ts +1 -1
  10. package/dist/Button/index.js +29 -9
  11. package/dist/Button/index.js.map +1 -1
  12. package/dist/Card/index.js +1 -1
  13. package/dist/Card/index.js.map +1 -1
  14. package/dist/Carousel/index.js +9 -1
  15. package/dist/Carousel/index.js.map +1 -1
  16. package/dist/Checkbox/index.js +25 -4
  17. package/dist/Checkbox/index.js.map +1 -1
  18. package/dist/Checkbox/type.d.ts +10 -2
  19. package/dist/Collapse/index.js +68 -22
  20. package/dist/Collapse/index.js.map +1 -1
  21. package/dist/ColorPicker/index.js +112 -46
  22. package/dist/ColorPicker/index.js.map +1 -1
  23. package/dist/DataPreviewTable/components/Body/Cell.d.ts +2 -0
  24. package/dist/DataPreviewTable/components/Body/Cell.js +9 -1
  25. package/dist/DataPreviewTable/components/Body/Cell.js.map +1 -1
  26. package/dist/DataPreviewTable/components/Body/index.d.ts +1 -0
  27. package/dist/DataPreviewTable/components/Body/index.js +35 -23
  28. package/dist/DataPreviewTable/components/Body/index.js.map +1 -1
  29. package/dist/DataPreviewTable/components/Header/index.d.ts +1 -0
  30. package/dist/DataPreviewTable/components/Header/index.js +36 -28
  31. package/dist/DataPreviewTable/components/Header/index.js.map +1 -1
  32. package/dist/DataPreviewTable/index.js +19 -2
  33. package/dist/DataPreviewTable/index.js.map +1 -1
  34. package/dist/Drawer/index.d.ts +4 -0
  35. package/dist/Drawer/index.js +91 -78
  36. package/dist/Drawer/index.js.map +1 -1
  37. package/dist/Dropdown/index.d.ts +1 -1
  38. package/dist/Dropdown/index.js +116 -98
  39. package/dist/Dropdown/index.js.map +1 -1
  40. package/dist/Form/FormItemContext.d.ts +1 -1
  41. package/dist/Form/FormItemContext.js.map +1 -1
  42. package/dist/Form/index.js +50 -7
  43. package/dist/Form/index.js.map +1 -1
  44. package/dist/IconButton/index.d.ts +2 -2
  45. package/dist/IconButton/index.js +9 -3
  46. package/dist/IconButton/index.js.map +1 -1
  47. package/dist/Input/components/Input/index.js +23 -7
  48. package/dist/Input/components/Input/index.js.map +1 -1
  49. package/dist/Input/components/TextArea/index.js +20 -2
  50. package/dist/Input/components/TextArea/index.js.map +1 -1
  51. package/dist/Input/privateSemanticOwner.d.ts +2 -0
  52. package/dist/Input/privateSemanticOwner.js +1 -0
  53. package/dist/InputNumber/index.js +19 -5
  54. package/dist/InputNumber/index.js.map +1 -1
  55. package/dist/InputNumber/type.d.ts +2 -2
  56. package/dist/LogicTree/components/LogicItem/index.d.ts +2 -1
  57. package/dist/LogicTree/components/LogicItem/index.js +13 -2
  58. package/dist/LogicTree/components/LogicItem/index.js.map +1 -1
  59. package/dist/LogicTree/index.js +2 -0
  60. package/dist/LogicTree/index.js.map +1 -1
  61. package/dist/MemberPicker/components/MemberSelection.d.ts +1 -0
  62. package/dist/MemberPicker/components/MemberSelection.js +83 -94
  63. package/dist/MemberPicker/components/MemberSelection.js.map +1 -1
  64. package/dist/MemberPicker/components/MultipleOption.js +12 -0
  65. package/dist/MemberPicker/components/MultipleOption.js.map +1 -1
  66. package/dist/MemberPicker/components/Panel.d.ts +1 -0
  67. package/dist/MemberPicker/components/Panel.js +4 -1
  68. package/dist/MemberPicker/components/Panel.js.map +1 -1
  69. package/dist/MemberPicker/components/SelectedMemberTags.js +14 -6
  70. package/dist/MemberPicker/components/SelectedMemberTags.js.map +1 -1
  71. package/dist/MemberPicker/components/SingleOption.js +12 -0
  72. package/dist/MemberPicker/components/SingleOption.js.map +1 -1
  73. package/dist/MemberPicker/components/UserGroupSelection.d.ts +2 -1
  74. package/dist/MemberPicker/components/UserGroupSelection.js +61 -48
  75. package/dist/MemberPicker/components/UserGroupSelection.js.map +1 -1
  76. package/dist/MemberPicker/index.js +134 -108
  77. package/dist/MemberPicker/index.js.map +1 -1
  78. package/dist/Menu/index.d.ts +8 -0
  79. package/dist/Menu/index.js +33 -3
  80. package/dist/Menu/index.js.map +1 -1
  81. package/dist/Modal/index.d.ts +4 -0
  82. package/dist/Modal/index.js +55 -66
  83. package/dist/Modal/index.js.map +1 -1
  84. package/dist/OverflowCount/index.js +10 -0
  85. package/dist/OverflowCount/index.js.map +1 -1
  86. package/dist/Pagination/PageSizeChanger.d.ts +1 -0
  87. package/dist/Pagination/PageSizeChanger.js +3 -2
  88. package/dist/Pagination/PageSizeChanger.js.map +1 -1
  89. package/dist/Pagination/index.js +34 -19
  90. package/dist/Pagination/index.js.map +1 -1
  91. package/dist/Pagination/types.d.ts +3 -0
  92. package/dist/Popconfirm/index.js +9 -1
  93. package/dist/Popconfirm/index.js.map +1 -1
  94. package/dist/Popover/index.js +52 -1
  95. package/dist/Popover/index.js.map +1 -1
  96. package/dist/Progress/index.js +4 -0
  97. package/dist/Progress/index.js.map +1 -1
  98. package/dist/Radio/components/Group/index.d.ts +5 -1
  99. package/dist/Radio/components/Group/index.js +7 -2
  100. package/dist/Radio/components/Group/index.js.map +1 -1
  101. package/dist/Radio/components/Radio/index.js +27 -1
  102. package/dist/Radio/components/Radio/index.js.map +1 -1
  103. package/dist/Radio/interface/radio.d.ts +7 -0
  104. package/dist/Radio/interface/radioGroup.d.ts +2 -0
  105. package/dist/RenameInput/index.js +11 -0
  106. package/dist/RenameInput/index.js.map +1 -1
  107. package/dist/Select/BaseSelect.d.ts +3 -0
  108. package/dist/Select/BaseSelect.js +235 -38
  109. package/dist/Select/BaseSelect.js.map +1 -1
  110. package/dist/Select/SelectTrigger.d.ts +2 -0
  111. package/dist/Select/SelectTrigger.js +13 -5
  112. package/dist/Select/SelectTrigger.js.map +1 -1
  113. package/dist/Select/Selector/FixedOverflow.d.ts +1 -0
  114. package/dist/Select/Selector/FixedOverflow.js +3 -3
  115. package/dist/Select/Selector/FixedOverflow.js.map +1 -1
  116. package/dist/Select/Selector/MultipleSelector.js +1 -0
  117. package/dist/Select/Selector/MultipleSelector.js.map +1 -1
  118. package/dist/Select/components/OptionCollection.d.ts +41 -0
  119. package/dist/Select/components/OptionCollection.js +124 -0
  120. package/dist/Select/components/OptionCollection.js.map +1 -0
  121. package/dist/Select/index.js +45 -3
  122. package/dist/Select/index.js.map +1 -1
  123. package/dist/Select/interface.d.ts +1 -1
  124. package/dist/Skeleton/index.js +1 -1
  125. package/dist/Skeleton/index.js.map +1 -1
  126. package/dist/Spin/index.d.ts +1 -1
  127. package/dist/Spin/index.js +22 -7
  128. package/dist/Spin/index.js.map +1 -1
  129. package/dist/Steps/index.js +66 -14
  130. package/dist/Steps/index.js.map +1 -1
  131. package/dist/Switch/index.d.ts +5 -0
  132. package/dist/Switch/index.js +22 -5
  133. package/dist/Switch/index.js.map +1 -1
  134. package/dist/Table/components/Cell.js +8 -3
  135. package/dist/Table/components/Cell.js.map +1 -1
  136. package/dist/Table/components/ExpandCell.js +6 -2
  137. package/dist/Table/components/ExpandCell.js.map +1 -1
  138. package/dist/Table/components/Footer/index.js +2 -1
  139. package/dist/Table/components/Footer/index.js.map +1 -1
  140. package/dist/Table/components/Header.js +25 -18
  141. package/dist/Table/components/Header.js.map +1 -1
  142. package/dist/Table/hooks/useRowSelection.js +14 -7
  143. package/dist/Table/hooks/useRowSelection.js.map +1 -1
  144. package/dist/Table/index.js +50 -29
  145. package/dist/Table/index.js.map +1 -1
  146. package/dist/Tabs/index.d.ts +1 -1
  147. package/dist/Tabs/index.js +92 -11
  148. package/dist/Tabs/index.js.map +1 -1
  149. package/dist/Tag/index.js +20 -1
  150. package/dist/Tag/index.js.map +1 -1
  151. package/dist/Tooltip/index.js +34 -5
  152. package/dist/Tooltip/index.js.map +1 -1
  153. package/dist/Tour/index.js +13 -1
  154. package/dist/Tour/index.js.map +1 -1
  155. package/dist/Tree/Tree2.js +2 -0
  156. package/dist/Tree/Tree2.js.map +1 -1
  157. package/dist/_utils/dialogAccessibility.d.ts +17 -0
  158. package/dist/_utils/dialogAccessibility.js +110 -0
  159. package/dist/_utils/dialogAccessibility.js.map +1 -0
  160. package/dist/_utils/formControlSemanticOwner.d.ts +3 -0
  161. package/dist/_utils/formControlSemanticOwner.js +17 -0
  162. package/dist/_utils/formControlSemanticOwner.js.map +1 -0
  163. package/dist/_utils/overlayCoordinator.js +1 -11
  164. package/dist/_utils/overlayCoordinator.js.map +1 -1
  165. package/dist/aloudata-design.css +1 -1
  166. package/dist/locale/default.d.ts +6 -0
  167. package/dist/locale/en_US.d.ts +6 -0
  168. package/dist/locale/en_US.js +6 -0
  169. package/dist/locale/en_US.js.map +1 -1
  170. package/dist/locale/zh_CN.d.ts +6 -0
  171. package/dist/locale/zh_CN.js +6 -0
  172. package/dist/locale/zh_CN.js.map +1 -1
  173. package/dist/theme/contract/baselineResolvedTokenValueManifest.d.ts +1 -1
  174. package/dist/theme/contract/controlStateColorArtifact.d.ts +73 -0
  175. package/dist/theme/contract/controlStateColorArtifact.js +2 -0
  176. package/dist/theme/contract/darkResolvedTokenValueManifest.d.ts +1 -1
  177. package/dist/theme/contract/focusRingArtifact.d.ts +51 -0
  178. package/dist/theme/contract/focusRingArtifact.js +2 -0
  179. package/dist/theme/contract/tokenOutputContract.d.ts +1 -1
  180. package/dist/theme/contract/tokenOutputContract.js +4 -0
  181. package/dist/theme/contract/tokenOutputContract.js.map +1 -1
  182. package/dist/theme/generator/acceptedColorValues.d.ts +2 -1
  183. package/dist/theme/generator/baselineTokenValueDelivery.d.ts +9 -1
  184. package/dist/theme/generator/minimalAcceptedColorValues.d.ts +2 -2
  185. package/dist/theme/generator/neutralSourceResolver.d.ts +28 -0
  186. package/dist/theme/generator/neutralSourceResolver.js +2 -0
  187. package/dist/theme/generator/neutralSourceValues.d.ts +27 -0
  188. package/dist/theme/generator/neutralSourceValues.js +2 -0
  189. package/dist/theme/index.d.ts +2 -0
  190. package/dist/theme/index.js +1 -0
  191. package/dist/theme/neutralSourceContract.d.ts +3 -0
  192. package/dist/theme/neutralSourceContract.js +11 -0
  193. package/dist/theme/neutralSourceContract.js.map +1 -0
  194. package/dist/theme/runtime/colorValueMode/generated/darkBaselineDeclarations.d.ts +1 -1
  195. package/dist/theme/runtime/colorValueMode/generated/darkBaselineDeclarations.js +47 -44
  196. package/dist/theme/runtime/colorValueMode/generated/darkBaselineDeclarations.js.map +1 -1
  197. package/dist/theme/runtime/colorValueMode/generated/slateDarkDeclarations.d.ts +3 -0
  198. package/dist/theme/runtime/colorValueMode/generated/slateDarkDeclarations.js +2 -0
  199. package/dist/theme/runtime/colorValueMode/generated/slateLightDeclarations.d.ts +3 -0
  200. package/dist/theme/runtime/colorValueMode/generated/slateLightDeclarations.js +2 -0
  201. package/dist/theme/runtime/colorValueMode/generated/stoneDarkDeclarations.d.ts +3 -0
  202. package/dist/theme/runtime/colorValueMode/generated/stoneDarkDeclarations.js +2 -0
  203. package/dist/theme/runtime/colorValueMode/generated/stoneLightDeclarations.d.ts +3 -0
  204. package/dist/theme/runtime/colorValueMode/generated/stoneLightDeclarations.js +2 -0
  205. package/dist/theme/runtime/colorValueMode/generated/v3BaselineDeclarations.d.ts +1 -1
  206. package/dist/theme/runtime/colorValueMode/generated/v3BaselineDeclarations.js +43 -40
  207. package/dist/theme/runtime/colorValueMode/generated/v3BaselineDeclarations.js.map +1 -1
  208. package/dist/theme/runtime/colorValueMode/index.js +2 -12
  209. package/dist/theme/runtime/colorValueMode/index.js.map +1 -1
  210. package/dist/theme/runtime/colorValueMode/legacyNeutralCompatibility.d.ts +2 -0
  211. package/dist/theme/runtime/colorValueMode/legacyNeutralCompatibility.js +48 -0
  212. package/dist/theme/runtime/colorValueMode/legacyNeutralCompatibility.js.map +1 -0
  213. package/dist/theme/runtime/colorValueMode/registry.d.ts +1 -1
  214. package/dist/theme/runtime/colorValueMode/registry.js +2 -1
  215. package/dist/theme/runtime/colorValueMode/registry.js.map +1 -1
  216. package/dist/theme/runtime/initAldTheme.js +1 -3
  217. package/dist/theme/runtime/initAldTheme.js.map +1 -1
  218. package/dist/theme/runtime/neutralSource/index.d.ts +6 -0
  219. package/dist/theme/runtime/neutralSource/index.js +11 -0
  220. package/dist/theme/runtime/neutralSource/index.js.map +1 -0
  221. package/dist/theme/runtime/neutralSource.d.ts +2 -0
  222. package/dist/theme/runtime/themeToCssVars.js +3 -0
  223. package/dist/theme/runtime/themeToCssVars.js.map +1 -1
  224. package/package.json +1 -1
@@ -3,6 +3,7 @@ import Memo from "../../../Icon/components/CloseCircleFill.js";
3
3
  import DisabledContext from "../../../ConfigProvider/DisabledContext.js";
4
4
  import SizeContext from "../../../ConfigProvider/sizeContext.js";
5
5
  import { useCompactItemContext } from "../../../Space/CompactContext.js";
6
+ import { getSemanticOwnerAriaProps } from "../../../_utils/formControlSemanticOwner.js";
6
7
  import React, { forwardRef, useContext, useRef, useState } from "react";
7
8
  import { jsx, jsxs } from "react/jsx-runtime";
8
9
  //#region src/Input/components/Input/index.tsx
@@ -15,7 +16,7 @@ function getSizeType(sizeType) {
15
16
  return "middle";
16
17
  }
17
18
  var Input = forwardRef((props, ref) => {
18
- const { size: customSize, className, bordered = true, status, disabled, allowClear, prefix, suffix, addonBefore, addonAfter, showCount, maxLength, minLength, value: controlledValue, defaultValue, onChange, onPressEnter, onBlur, onFocus, onKeyDown, onCompositionStart, onCompositionEnd, placeholder, type, id, autoComplete = "off", autoFocus, readOnly, width, style, "data-testid": dataTestid, "aria-label": ariaLabel, ...restInputProps } = props;
19
+ const { size: customSize, className, bordered = true, status, disabled, allowClear, prefix, suffix, addonBefore, addonAfter, showCount, maxLength, minLength, value: controlledValue, defaultValue, onChange, onPressEnter, onBlur, onFocus, onKeyDown, onCompositionStart, onCompositionEnd, placeholder, type, id, autoComplete = "off", autoFocus, readOnly, width, style, "data-testid": dataTestid, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy, "aria-describedby": ariaDescribedBy, "aria-invalid": ariaInvalid, "aria-required": ariaRequired, "aria-busy": ariaBusy, "aria-disabled": ariaDisabled, "aria-readonly": ariaReadonly, ...restInputProps } = props;
19
20
  const contextDisabled = useContext(DisabledContext);
20
21
  const mergedDisabled = disabled ?? contextDisabled;
21
22
  const contentSize = useContext(SizeContext);
@@ -54,7 +55,13 @@ var Input = forwardRef((props, ref) => {
54
55
  }) : showCount ? `${currentValue.length}${maxLength ? `/${maxLength}` : ""}` : null;
55
56
  const compactClasses = compactItemClassnames ? cn(!compactItemClassnames["ald-input-compact-first-item"] && "!tw-rounded-l-none", !compactItemClassnames["ald-input-compact-last-item"] && "!tw-rounded-r-none", !compactItemClassnames["ald-input-compact-first-item"] && "-tw-ml-px") : void 0;
56
57
  return /* @__PURE__ */ jsxs("span", {
57
- className: cn("ald-input ant-input-affix-wrapper tw-inline-flex tw-w-full tw-items-center tw-bg-[var(--background-default)]", bordered && "tw-rounded-r-75 tw-border tw-border-solid tw-border-[var(--border-neutral-subtle)]", focused && "ant-input-affix-wrapper-focused tw-border-[var(--border-brand-strong)]", !mergedDisabled && !focused && "hover:tw-border-[var(--border-brand-strong)]", `ald-input-${getSizeType(size)}`, "tw-text-typography-body-dense", size === "small" && "tw-h-7", size === "large" && "tw-h-9", (size === "middle" || !size) && "tw-h-8", status === "error" && `ald-input-error tw-border-[var(--border-negative-strong)]`, status === "warning" && `ald-input-warning tw-border-[var(--border-warning-subtle)]`, mergedDisabled && "ald-input-disabled tw-cursor-not-allowed tw-bg-[var(--background-neutral-on-subtle)] tw-text-[var(--content-secondary)]", compactClasses, className),
58
+ className: cn("ald-input ant-input-affix-wrapper tw-inline-flex tw-w-full tw-items-center tw-bg-[var(--background-default)] tw-transition-[border-color,box-shadow] tw-duration-150 tw-ease-out", bordered && "tw-rounded-r-75 tw-border tw-border-solid tw-border-[var(--border-neutral-subtle)]", !mergedDisabled && [
59
+ "has-[input:focus-visible]:tw-shadow-[inset_0_0_0_1px_var(--focus-ring)]",
60
+ "forced-colors:has-[input:focus-visible]:tw-outline",
61
+ "forced-colors:has-[input:focus-visible]:tw-outline-2",
62
+ "forced-colors:has-[input:focus-visible]:tw-outline-offset-2",
63
+ "forced-colors:has-[input:focus-visible]:tw-outline-[Highlight]"
64
+ ], focused && "ant-input-affix-wrapper-focused", focused && !status && "!tw-border-[var(--border-brand-strong)]", `ald-input-${getSizeType(size)}`, "tw-text-typography-body-dense", size === "small" && "tw-h-[28px]", size === "large" && "tw-h-[36px]", (size === "middle" || !size) && "tw-h-[32px]", status === "error" && `ald-input-error tw-border-[var(--border-negative-strong)]`, status === "warning" && `ald-input-warning tw-border-[var(--border-warning-subtle)]`, mergedDisabled && "ald-input-disabled tw-cursor-not-allowed tw-bg-[var(--background-neutral-subtle)] tw-text-[var(--content-secondary)]", compactClasses, className),
58
65
  style: {
59
66
  ...style,
60
67
  width
@@ -73,7 +80,7 @@ var Input = forwardRef((props, ref) => {
73
80
  children: addonBefore
74
81
  }),
75
82
  prefix && /* @__PURE__ */ jsx("span", {
76
- className: "ald-input-prefix ant-input-prefix tw-flex tw-items-center tw-pl-2 tw-text-[var(--content-secondary)]",
83
+ className: "ald-input-prefix ant-input-prefix tw-flex tw-shrink-0 tw-items-center tw-pl-2 tw-text-[var(--content-secondary)]",
77
84
  children: prefix
78
85
  }),
79
86
  /* @__PURE__ */ jsx("input", {
@@ -103,11 +110,20 @@ var Input = forwardRef((props, ref) => {
103
110
  readOnly,
104
111
  spellCheck: false,
105
112
  "data-testid": dataTestid,
106
- "aria-label": ariaLabel,
113
+ ...getSemanticOwnerAriaProps({
114
+ "aria-label": ariaLabel,
115
+ "aria-labelledby": ariaLabelledBy,
116
+ "aria-describedby": ariaDescribedBy,
117
+ "aria-invalid": ariaInvalid ?? (status === "error" ? true : void 0),
118
+ "aria-required": ariaRequired,
119
+ "aria-busy": ariaBusy,
120
+ "aria-disabled": ariaDisabled,
121
+ "aria-readonly": ariaReadonly
122
+ }),
107
123
  ...restInputProps
108
124
  }),
109
125
  showClearIcon && /* @__PURE__ */ jsx("span", {
110
- className: "ald-input-clear ant-input-clear-icon tw-flex tw-cursor-pointer tw-items-center tw-pr-1",
126
+ className: "ald-input-clear ant-input-clear-icon tw-flex tw-shrink-0 tw-cursor-pointer tw-items-center tw-pr-1",
111
127
  onClick: handleClear,
112
128
  children: /* @__PURE__ */ jsx(Memo, {
113
129
  size: 16,
@@ -115,11 +131,11 @@ var Input = forwardRef((props, ref) => {
115
131
  })
116
132
  }),
117
133
  suffix && /* @__PURE__ */ jsx("span", {
118
- className: "ald-input-suffix ant-input-suffix tw-flex tw-items-center tw-pr-2 tw-text-[var(--content-secondary)]",
134
+ className: "ald-input-suffix ant-input-suffix tw-flex tw-shrink-0 tw-items-center tw-pr-2 tw-text-[var(--content-secondary)]",
119
135
  children: suffix
120
136
  }),
121
137
  countInfo && /* @__PURE__ */ jsx("span", {
122
- className: "ald-input-count tw-pr-2 tw-text-[var(--content-tertiary)] tw-text-typography-caption",
138
+ className: "ald-input-count tw-shrink-0 tw-pr-2 tw-text-[var(--content-tertiary)] tw-text-typography-caption",
123
139
  children: countInfo
124
140
  }),
125
141
  addonAfter && /* @__PURE__ */ jsx("span", {
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../../../../src/Input/components/Input/index.tsx"],"sourcesContent":["import React, {\n ReactNode,\n forwardRef,\n useContext,\n useRef,\n useState,\n} from 'react';\nimport DisabledContext from '../../../ConfigProvider/DisabledContext';\nimport SizeContext, { SizeType } from '../../../ConfigProvider/sizeContext';\nimport { CloseCircleFill } from '../../../Icon';\nimport { cn } from '../../../lib/utils';\nimport { useCompactItemContext } from '../../../Space/CompactContext';\n\ninterface IShowCountProps {\n formatter: (args: { count: number; maxLength?: number }) => string;\n}\nexport type TSize = SizeType;\nexport type InputRef = HTMLInputElement & {\n /** antd v4 compat — points to the underlying <input> element */\n input?: HTMLInputElement | null;\n};\n\ntype ChangeEventHandler = (e: React.ChangeEvent<HTMLInputElement>) => void;\n\nexport interface IInputProps\n extends Omit<\n React.InputHTMLAttributes<HTMLInputElement>,\n | 'size'\n | 'prefix'\n | 'value'\n | 'defaultValue'\n | 'onChange'\n | 'disabled'\n | 'type'\n | 'max'\n > {\n addonAfter?: ReactNode;\n addonBefore?: ReactNode;\n size?: TSize;\n id?: string;\n prefix?: ReactNode;\n suffix?: ReactNode;\n allowClear?: boolean;\n disabled?: boolean;\n showCount?: boolean | IShowCountProps;\n maxLength?: number;\n minLength?: number;\n max?: number;\n value?: string;\n defaultValue?: string;\n onPressEnter?: React.KeyboardEventHandler<HTMLInputElement>;\n onChange?: ChangeEventHandler;\n className?: string;\n style?: React.CSSProperties;\n placeholder?: string;\n type?: string;\n bordered?: boolean;\n status?: 'error' | 'warning' | '';\n autoComplete?: string;\n autoFocus?: boolean;\n readOnly?: boolean;\n width?: number | string;\n onBlur?: React.FocusEventHandler<HTMLInputElement>;\n onFocus?: React.FocusEventHandler<HTMLInputElement>;\n onKeyDown?: React.KeyboardEventHandler<HTMLInputElement>;\n onCompositionStart?: React.CompositionEventHandler<HTMLInputElement>;\n onCompositionEnd?: React.CompositionEventHandler<HTMLInputElement>;\n /** 透传到内部 input 元素的 data-testid,用于自动化测试定位 */\n 'data-testid'?: string;\n /** 透传到内部 input 元素的 aria-label,用于可访问性与自动化测试定位 */\n 'aria-label'?: string;\n}\n\nexport function getSizeType(sizeType: TSize): TSize {\n if (['small', 'middle', 'large'].includes(sizeType || '')) {\n return sizeType;\n }\n return 'middle';\n}\n\nconst Input = forwardRef<InputRef, IInputProps>((props, ref) => {\n const {\n size: customSize,\n className,\n bordered = true,\n status,\n disabled,\n allowClear,\n prefix,\n suffix,\n addonBefore,\n addonAfter,\n showCount,\n maxLength,\n minLength,\n value: controlledValue,\n defaultValue,\n onChange,\n onPressEnter,\n onBlur,\n onFocus,\n onKeyDown,\n onCompositionStart,\n onCompositionEnd,\n placeholder,\n type,\n id,\n autoComplete = 'off',\n autoFocus,\n readOnly,\n width,\n style,\n 'data-testid': dataTestid,\n 'aria-label': ariaLabel,\n ...restInputProps\n } = props;\n\n const contextDisabled = useContext(DisabledContext);\n const mergedDisabled = disabled ?? contextDisabled;\n\n const contentSize = useContext(SizeContext);\n const { compactSize, compactItemClassnames } =\n useCompactItemContext('ald-input');\n const size = customSize || compactSize || contentSize || 'middle';\n\n const isControlled = 'value' in props;\n const [innerValue, setInnerValue] = useState(defaultValue ?? '');\n const currentValue = isControlled ? controlledValue ?? '' : innerValue;\n const [focused, setFocused] = useState(false);\n const inputRef = useRef<HTMLInputElement>(null);\n\n React.useImperativeHandle(ref, () => {\n const el = inputRef.current!;\n // Expose .input for antd v4 compat (ref.current.input.focus())\n (el as InputRef).input = el;\n return el as InputRef;\n });\n\n const handleChange = (e: React.ChangeEvent<HTMLInputElement>) => {\n if (!isControlled) setInnerValue(e.target.value);\n onChange?.(e);\n };\n\n const handleClear = () => {\n // 通过原生 input 事件统一触发 React onChange,确保事件契约完整且只回调一次。\n const nativeEvent = new Event('input', { bubbles: true });\n if (inputRef.current) {\n const nativeSetter = Object.getOwnPropertyDescriptor(\n HTMLInputElement.prototype,\n 'value',\n )?.set;\n nativeSetter?.call(inputRef.current, '');\n inputRef.current.dispatchEvent(nativeEvent);\n }\n if (!isControlled) setInnerValue('');\n };\n\n const handleKeyDown = (e: React.KeyboardEvent<HTMLInputElement>) => {\n if (e.key === 'Enter') onPressEnter?.(e);\n onKeyDown?.(e);\n };\n\n const showClearIcon = allowClear && currentValue && !mergedDisabled;\n\n const countInfo =\n showCount && typeof showCount === 'object'\n ? showCount.formatter({\n count: currentValue.length,\n maxLength,\n })\n : showCount\n ? `${currentValue.length}${maxLength ? `/${maxLength}` : ''}`\n : null;\n\n // Build compact-mode border-radius and margin overrides\n const compactClasses = compactItemClassnames\n ? cn(\n !compactItemClassnames['ald-input-compact-first-item'] &&\n '!tw-rounded-l-none',\n !compactItemClassnames['ald-input-compact-last-item'] &&\n '!tw-rounded-r-none',\n !compactItemClassnames['ald-input-compact-first-item'] && '-tw-ml-px',\n )\n : undefined;\n\n return (\n <span\n className={cn(\n // antd 兼容:保留 ant-* class,消费方 CSS 可能依赖该选择器\n 'ald-input ant-input-affix-wrapper tw-inline-flex tw-w-full tw-items-center tw-bg-[var(--background-default)]',\n bordered &&\n 'tw-rounded-r-75 tw-border tw-border-solid tw-border-[var(--border-neutral-subtle)]',\n // antd 兼容:保留 ant-* class,消费方 CSS 可能依赖该选择器\n // focus 仅变 border-color,不加额外 box-shadow/outline。\n // 消费方通过 CSS 将 border 设为 0 后 focus 高亮自然消失,和 antd 行为一致。\n focused &&\n 'ant-input-affix-wrapper-focused tw-border-[var(--border-brand-strong)]',\n !mergedDisabled &&\n !focused &&\n 'hover:tw-border-[var(--border-brand-strong)]',\n `ald-input-${getSizeType(size)}`,\n 'tw-text-typography-body-dense',\n size === 'small' && 'tw-h-7',\n size === 'large' && 'tw-h-9',\n (size === 'middle' || !size) && 'tw-h-8',\n status === 'error' &&\n `ald-input-error tw-border-[var(--border-negative-strong)]`,\n status === 'warning' &&\n `ald-input-warning tw-border-[var(--border-warning-subtle)]`,\n mergedDisabled &&\n 'ald-input-disabled tw-cursor-not-allowed tw-bg-[var(--background-neutral-on-subtle)] tw-text-[var(--content-secondary)]',\n compactClasses,\n className,\n )}\n style={{\n ...style,\n width,\n }}\n onMouseDown={(e) => {\n // 点击 wrapper 非 input 区域时:\n // 如果 input 已聚焦 → preventDefault 防止点击 wrapper 导致丢焦\n // 如果 input 未聚焦 → 不阻止默认行为,让浏览器正常处理 blur 上一个元素\n if (e.target !== inputRef.current) {\n if (document.activeElement === inputRef.current) {\n e.preventDefault();\n }\n }\n }}\n onMouseUp={(e) => {\n // 在 mouseUp 时将焦点转发给内部 input(兼容 prefix/suffix/padding 区域的点击)\n if (e.target !== inputRef.current && inputRef.current) {\n inputRef.current.focus();\n }\n }}\n >\n {addonBefore && (\n <span className=\"ald-input-addon tw-flex tw-shrink-0 tw-items-center tw-self-stretch tw-border-r tw-border-solid tw-border-[var(--border-default)] tw-bg-[var(--background-neutral-subtle)] tw-px-3 tw-text-[var(--content-secondary)]\">\n {addonBefore}\n </span>\n )}\n {/* antd 兼容:保留 ant-input-prefix class,消费方 CSS 可能依赖该选择器 */}\n {prefix && (\n <span className=\"ald-input-prefix ant-input-prefix tw-flex tw-items-center tw-pl-2 tw-text-[var(--content-secondary)]\">\n {prefix}\n </span>\n )}\n <input\n ref={inputRef}\n id={id}\n type={type || 'text'}\n className=\"tw-min-w-0 tw-flex-1 tw-self-stretch tw-border-0 tw-bg-[var(--action-ghost-normal)] tw-px-2 tw-text-[var(--content-primary)] tw-text-inherit tw-outline-none\"\n value={currentValue}\n onChange={handleChange}\n onBlur={(e) => {\n setFocused(false);\n onBlur?.(e);\n }}\n onFocus={(e) => {\n setFocused(true);\n onFocus?.(e);\n }}\n onKeyDown={handleKeyDown}\n onCompositionStart={onCompositionStart}\n onCompositionEnd={onCompositionEnd}\n disabled={mergedDisabled}\n placeholder={placeholder}\n maxLength={maxLength}\n minLength={minLength}\n autoComplete={autoComplete}\n autoFocus={autoFocus}\n readOnly={readOnly}\n spellCheck={false}\n data-testid={dataTestid}\n aria-label={ariaLabel}\n {...restInputProps}\n />\n {showClearIcon && (\n <span\n // antd 兼容:保留 ant-* class,消费方 CSS 可能依赖该选择器\n className=\"ald-input-clear ant-input-clear-icon tw-flex tw-cursor-pointer tw-items-center tw-pr-1\"\n onClick={handleClear}\n >\n <CloseCircleFill size={16} color=\"var(--content-secondary)\" />\n </span>\n )}\n {/* antd 兼容:保留 ant-input-suffix class,消费方 CSS 可能依赖该选择器 */}\n {suffix && (\n <span className=\"ald-input-suffix ant-input-suffix tw-flex tw-items-center tw-pr-2 tw-text-[var(--content-secondary)]\">\n {suffix}\n </span>\n )}\n {countInfo && (\n <span className=\"ald-input-count tw-pr-2 tw-text-[var(--content-tertiary)] tw-text-typography-caption\">\n {countInfo}\n </span>\n )}\n {addonAfter && (\n <span className=\"ald-input-addon tw-border-l tw-border-solid tw-border-[var(--border-default)] tw-px-2 tw-text-[var(--content-secondary)]\">\n {addonAfter}\n </span>\n )}\n </span>\n );\n});\n\nexport default Input;\n"],"mappings":";;;;;;;;AAyEA,SAAgB,YAAY,UAAwB;AAClD,KAAI;EAAC;EAAS;EAAU;EAAQ,CAAC,SAAS,YAAY,GAAG,CACvD,QAAO;AAET,QAAO;;AAGT,IAAM,QAAQ,YAAmC,OAAO,QAAQ;CAC9D,MAAM,EACJ,MAAM,YACN,WACA,WAAW,MACX,QACA,UACA,YACA,QACA,QACA,aACA,YACA,WACA,WACA,WACA,OAAO,iBACP,cACA,UACA,cACA,QACA,SACA,WACA,oBACA,kBACA,aACA,MACA,IACA,eAAe,OACf,WACA,UACA,OACA,OACA,eAAe,YACf,cAAc,WACd,GAAG,mBACD;CAEJ,MAAM,kBAAkB,WAAW,gBAAgB;CACnD,MAAM,iBAAiB,YAAY;CAEnC,MAAM,cAAc,WAAW,YAAY;CAC3C,MAAM,EAAE,aAAa,0BACnB,sBAAsB,YAAY;CACpC,MAAM,OAAO,cAAc,eAAe,eAAe;CAEzD,MAAM,eAAe,WAAW;CAChC,MAAM,CAAC,YAAY,iBAAiB,SAAS,gBAAgB,GAAG;CAChE,MAAM,eAAe,eAAe,mBAAmB,KAAK;CAC5D,MAAM,CAAC,SAAS,cAAc,SAAS,MAAM;CAC7C,MAAM,WAAW,OAAyB,KAAK;AAE/C,OAAM,oBAAoB,WAAW;EACnC,MAAM,KAAK,SAAS;AAEnB,KAAgB,QAAQ;AACzB,SAAO;GACP;CAEF,MAAM,gBAAgB,MAA2C;AAC/D,MAAI,CAAC,aAAc,eAAc,EAAE,OAAO,MAAM;AAChD,aAAW,EAAE;;CAGf,MAAM,oBAAoB;EAExB,MAAM,cAAc,IAAI,MAAM,SAAS,EAAE,SAAS,MAAM,CAAC;AACzD,MAAI,SAAS,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AU;IACV,SAAS,MAAM;AACb,gBAAW,MAAM;AACjB,cAAS,EAAE;;IAEb,UAAU,MAAM;AACd,gBAAW,KAAK;AAChB,eAAU,EAAE;;IAEd,WAAW;IACS;IACF;IAClB,UAAU;IACG;IACF;IACA;IACG;IACH;IACD;IACV,YAAY;IACZ,eAAa;IACb,cAAY;IACZ,GAAI;IACJ,CAAA;GACD,iBACC,oBAAC,QAAD;IAEE,WAAU;IACV,SAAS;cAET,oBAAC,MAAD;KAAiB,MAAM;KAAI,OAAM;KAA6B,CAAA;IACzD,CAAA;GAGR,UACC,oBAAC,QAAD;IAAM,WAAU;cACb;IACI,CAAA;GAER,aACC,oBAAC,QAAD;IAAM,WAAU;cACb;IACI,CAAA;GAER,cACC,oBAAC,QAAD;IAAM,WAAU;cACb;IACI,CAAA;GAEJ;;EAET"}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../../../src/Input/components/Input/index.tsx"],"sourcesContent":["import React, {\n ReactNode,\n forwardRef,\n useContext,\n useRef,\n useState,\n} from 'react';\nimport DisabledContext from '../../../ConfigProvider/DisabledContext';\nimport SizeContext, { SizeType } from '../../../ConfigProvider/sizeContext';\nimport { CloseCircleFill } from '../../../Icon';\nimport { cn } from '../../../lib/utils';\nimport { useCompactItemContext } from '../../../Space/CompactContext';\nimport { getSemanticOwnerAriaProps } from '../../privateSemanticOwner';\n\ninterface IShowCountProps {\n formatter: (args: { count: number; maxLength?: number }) => string;\n}\nexport type TSize = SizeType;\nexport type InputRef = HTMLInputElement & {\n /** antd v4 compat — points to the underlying <input> element */\n input?: HTMLInputElement | null;\n};\n\ntype ChangeEventHandler = (e: React.ChangeEvent<HTMLInputElement>) => void;\n\nexport interface IInputProps\n extends Omit<\n React.InputHTMLAttributes<HTMLInputElement>,\n | 'size'\n | 'prefix'\n | 'value'\n | 'defaultValue'\n | 'onChange'\n | 'disabled'\n | 'type'\n | 'max'\n > {\n addonAfter?: ReactNode;\n addonBefore?: ReactNode;\n size?: TSize;\n id?: string;\n prefix?: ReactNode;\n suffix?: ReactNode;\n allowClear?: boolean;\n disabled?: boolean;\n showCount?: boolean | IShowCountProps;\n maxLength?: number;\n minLength?: number;\n max?: number;\n value?: string;\n defaultValue?: string;\n onPressEnter?: React.KeyboardEventHandler<HTMLInputElement>;\n onChange?: ChangeEventHandler;\n className?: string;\n style?: React.CSSProperties;\n placeholder?: string;\n type?: string;\n bordered?: boolean;\n status?: 'error' | 'warning' | '';\n autoComplete?: string;\n autoFocus?: boolean;\n readOnly?: boolean;\n width?: number | string;\n onBlur?: React.FocusEventHandler<HTMLInputElement>;\n onFocus?: React.FocusEventHandler<HTMLInputElement>;\n onKeyDown?: React.KeyboardEventHandler<HTMLInputElement>;\n onCompositionStart?: React.CompositionEventHandler<HTMLInputElement>;\n onCompositionEnd?: React.CompositionEventHandler<HTMLInputElement>;\n /** 透传到内部 input 元素的 data-testid,用于自动化测试定位 */\n 'data-testid'?: string;\n /** 透传到内部 input 元素的 aria-label,用于可访问性与自动化测试定位 */\n 'aria-label'?: string;\n}\n\nexport function getSizeType(sizeType: TSize): TSize {\n if (['small', 'middle', 'large'].includes(sizeType || '')) {\n return sizeType;\n }\n return 'middle';\n}\n\nconst Input = forwardRef<InputRef, IInputProps>((props, ref) => {\n const {\n size: customSize,\n className,\n bordered = true,\n status,\n disabled,\n allowClear,\n prefix,\n suffix,\n addonBefore,\n addonAfter,\n showCount,\n maxLength,\n minLength,\n value: controlledValue,\n defaultValue,\n onChange,\n onPressEnter,\n onBlur,\n onFocus,\n onKeyDown,\n onCompositionStart,\n onCompositionEnd,\n placeholder,\n type,\n id,\n autoComplete = 'off',\n autoFocus,\n readOnly,\n width,\n style,\n 'data-testid': dataTestid,\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledBy,\n 'aria-describedby': ariaDescribedBy,\n 'aria-invalid': ariaInvalid,\n 'aria-required': ariaRequired,\n 'aria-busy': ariaBusy,\n 'aria-disabled': ariaDisabled,\n 'aria-readonly': ariaReadonly,\n ...restInputProps\n } = props;\n\n const contextDisabled = useContext(DisabledContext);\n const mergedDisabled = disabled ?? contextDisabled;\n\n const contentSize = useContext(SizeContext);\n const { compactSize, compactItemClassnames } =\n useCompactItemContext('ald-input');\n const size = customSize || compactSize || contentSize || 'middle';\n\n const isControlled = 'value' in props;\n const [innerValue, setInnerValue] = useState(defaultValue ?? '');\n const currentValue = isControlled ? controlledValue ?? '' : innerValue;\n const [focused, setFocused] = useState(false);\n const inputRef = useRef<HTMLInputElement>(null);\n\n React.useImperativeHandle(ref, () => {\n const el = inputRef.current!;\n // Expose .input for antd v4 compat (ref.current.input.focus())\n (el as InputRef).input = el;\n return el as InputRef;\n });\n\n const handleChange = (e: React.ChangeEvent<HTMLInputElement>) => {\n if (!isControlled) setInnerValue(e.target.value);\n onChange?.(e);\n };\n\n const handleClear = () => {\n // 通过原生 input 事件统一触发 React onChange,确保事件契约完整且只回调一次。\n const nativeEvent = new Event('input', { bubbles: true });\n if (inputRef.current) {\n const nativeSetter = Object.getOwnPropertyDescriptor(\n HTMLInputElement.prototype,\n 'value',\n )?.set;\n nativeSetter?.call(inputRef.current, '');\n inputRef.current.dispatchEvent(nativeEvent);\n }\n if (!isControlled) setInnerValue('');\n };\n\n const handleKeyDown = (e: React.KeyboardEvent<HTMLInputElement>) => {\n if (e.key === 'Enter') onPressEnter?.(e);\n onKeyDown?.(e);\n };\n\n const showClearIcon = allowClear && currentValue && !mergedDisabled;\n\n const countInfo =\n showCount && typeof showCount === 'object'\n ? showCount.formatter({\n count: currentValue.length,\n maxLength,\n })\n : showCount\n ? `${currentValue.length}${maxLength ? `/${maxLength}` : ''}`\n : null;\n\n // Build compact-mode border-radius and margin overrides\n const compactClasses = compactItemClassnames\n ? cn(\n !compactItemClassnames['ald-input-compact-first-item'] &&\n '!tw-rounded-l-none',\n !compactItemClassnames['ald-input-compact-last-item'] &&\n '!tw-rounded-r-none',\n !compactItemClassnames['ald-input-compact-first-item'] && '-tw-ml-px',\n )\n : undefined;\n\n return (\n <span\n className={cn(\n // antd 兼容:保留 ant-* class,消费方 CSS 可能依赖该选择器\n 'ald-input ant-input-affix-wrapper tw-inline-flex tw-w-full tw-items-center tw-bg-[var(--background-default)] tw-transition-[border-color,box-shadow] tw-duration-150 tw-ease-out',\n bordered &&\n 'tw-rounded-r-75 tw-border tw-border-solid tw-border-[var(--border-neutral-subtle)]',\n !mergedDisabled && [\n 'has-[input:focus-visible]:tw-shadow-[inset_0_0_0_1px_var(--focus-ring)]',\n 'forced-colors:has-[input:focus-visible]:tw-outline',\n 'forced-colors:has-[input:focus-visible]:tw-outline-2',\n 'forced-colors:has-[input:focus-visible]:tw-outline-offset-2',\n 'forced-colors:has-[input:focus-visible]:tw-outline-[Highlight]',\n ],\n // antd 兼容:保留 ant-* class,消费方 CSS 可能依赖该选择器\n // 保留既有 border 状态以维持 antd 兼容;焦点由上方的 Focus State Layer 独立呈现。\n focused && 'ant-input-affix-wrapper-focused',\n focused && !status && '!tw-border-[var(--border-brand-strong)]',\n `ald-input-${getSizeType(size)}`,\n // Typography Foundation: the wrapper owns the approved Body Dense\n // context for the editable value and placeholder. Count opts into its\n // approved Caption role below.\n 'tw-text-typography-body-dense',\n // Component Geometry: height belongs to the Input envelope, not to a\n // relationship-spacing Primitive.\n size === 'small' && 'tw-h-[28px]',\n size === 'large' && 'tw-h-[36px]',\n (size === 'middle' || !size) && 'tw-h-[32px]',\n status === 'error' &&\n `ald-input-error tw-border-[var(--border-negative-strong)]`,\n status === 'warning' &&\n `ald-input-warning tw-border-[var(--border-warning-subtle)]`,\n mergedDisabled &&\n 'ald-input-disabled tw-cursor-not-allowed tw-bg-[var(--background-neutral-subtle)] tw-text-[var(--content-secondary)]',\n compactClasses,\n className,\n )}\n style={{\n ...style,\n width,\n }}\n onMouseDown={(e) => {\n // 点击 wrapper 非 input 区域时:\n // 如果 input 已聚焦 → preventDefault 防止点击 wrapper 导致丢焦\n // 如果 input 未聚焦 → 不阻止默认行为,让浏览器正常处理 blur 上一个元素\n if (e.target !== inputRef.current) {\n if (document.activeElement === inputRef.current) {\n e.preventDefault();\n }\n }\n }}\n onMouseUp={(e) => {\n // 在 mouseUp 时将焦点转发给内部 input(兼容 prefix/suffix/padding 区域的点击)\n if (e.target !== inputRef.current && inputRef.current) {\n inputRef.current.focus();\n }\n }}\n >\n {addonBefore && (\n <span className=\"ald-input-addon tw-flex tw-shrink-0 tw-items-center tw-self-stretch tw-border-r tw-border-solid tw-border-[var(--border-default)] tw-bg-[var(--background-neutral-subtle)] tw-px-3 tw-text-[var(--content-secondary)]\">\n {addonBefore}\n </span>\n )}\n {/* antd 兼容:保留 ant-input-prefix class,消费方 CSS 可能依赖该选择器 */}\n {prefix && (\n <span className=\"ald-input-prefix ant-input-prefix tw-flex tw-shrink-0 tw-items-center tw-pl-2 tw-text-[var(--content-secondary)]\">\n {prefix}\n </span>\n )}\n {/*\n * Value Affordance and Text Containment remain Constraint-owned and\n * Blocked. These shrink guards reserve local Geometry for affordances;\n * they do not define a spacing Primitive or Mapping.\n */}\n <input\n ref={inputRef}\n id={id}\n type={type || 'text'}\n className=\"tw-min-w-0 tw-flex-1 tw-self-stretch tw-border-0 tw-bg-[var(--action-ghost-normal)] tw-px-2 tw-text-[var(--content-primary)] tw-text-inherit tw-outline-none\"\n value={currentValue}\n onChange={handleChange}\n onBlur={(e) => {\n setFocused(false);\n onBlur?.(e);\n }}\n onFocus={(e) => {\n setFocused(true);\n onFocus?.(e);\n }}\n onKeyDown={handleKeyDown}\n onCompositionStart={onCompositionStart}\n onCompositionEnd={onCompositionEnd}\n disabled={mergedDisabled}\n placeholder={placeholder}\n maxLength={maxLength}\n minLength={minLength}\n autoComplete={autoComplete}\n autoFocus={autoFocus}\n readOnly={readOnly}\n spellCheck={false}\n data-testid={dataTestid}\n {...getSemanticOwnerAriaProps({\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledBy,\n 'aria-describedby': ariaDescribedBy,\n 'aria-invalid':\n ariaInvalid ?? (status === 'error' ? true : undefined),\n 'aria-required': ariaRequired,\n 'aria-busy': ariaBusy,\n 'aria-disabled': ariaDisabled,\n 'aria-readonly': ariaReadonly,\n })}\n {...restInputProps}\n />\n {showClearIcon && (\n <span\n // antd 兼容:保留 ant-* class,消费方 CSS 可能依赖该选择器\n className=\"ald-input-clear ant-input-clear-icon tw-flex tw-shrink-0 tw-cursor-pointer tw-items-center tw-pr-1\"\n onClick={handleClear}\n >\n <CloseCircleFill size={16} color=\"var(--content-secondary)\" />\n </span>\n )}\n {/* antd 兼容:保留 ant-input-suffix class,消费方 CSS 可能依赖该选择器 */}\n {suffix && (\n <span className=\"ald-input-suffix ant-input-suffix tw-flex tw-shrink-0 tw-items-center tw-pr-2 tw-text-[var(--content-secondary)]\">\n {suffix}\n </span>\n )}\n {countInfo && (\n <span className=\"ald-input-count tw-shrink-0 tw-pr-2 tw-text-[var(--content-tertiary)] tw-text-typography-caption\">\n {countInfo}\n </span>\n )}\n {addonAfter && (\n <span className=\"ald-input-addon tw-border-l tw-border-solid tw-border-[var(--border-default)] tw-px-2 tw-text-[var(--content-secondary)]\">\n {addonAfter}\n </span>\n )}\n </span>\n );\n});\n\nexport default Input;\n"],"mappings":";;;;;;;;;AA0EA,SAAgB,YAAY,UAAwB;AAClD,KAAI;EAAC;EAAS;EAAU;EAAQ,CAAC,SAAS,YAAY,GAAG,CACvD,QAAO;AAET,QAAO;;AAGT,IAAM,QAAQ,YAAmC,OAAO,QAAQ;CAC9D,MAAM,EACJ,MAAM,YACN,WACA,WAAW,MACX,QACA,UACA,YACA,QACA,QACA,aACA,YACA,WACA,WACA,WACA,OAAO,iBACP,cACA,UACA,cACA,QACA,SACA,WACA,oBACA,kBACA,aACA,MACA,IACA,eAAe,OACf,WACA,UACA,OACA,OACA,eAAe,YACf,cAAc,WACd,mBAAmB,gBACnB,oBAAoB,iBACpB,gBAAgB,aAChB,iBAAiB,cACjB,aAAa,UACb,iBAAiB,cACjB,iBAAiB,cACjB,GAAG,mBACD;CAEJ,MA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;cACb;IACI,CAAA;GAER,aACC,oBAAC,QAAD;IAAM,WAAU;cACb;IACI,CAAA;GAER,cACC,oBAAC,QAAD;IAAM,WAAU;cACb;IACI,CAAA;GAEJ;;EAET"}
@@ -2,12 +2,13 @@ import { cn } from "../../../lib/utils.js";
2
2
  import Memo from "../../../Icon/components/CloseCircleFill.js";
3
3
  import DisabledContext from "../../../ConfigProvider/DisabledContext.js";
4
4
  import SizeContext from "../../../ConfigProvider/sizeContext.js";
5
+ import { getSemanticOwnerAriaProps } from "../../../_utils/formControlSemanticOwner.js";
5
6
  import { getSizeType } from "../Input/index.js";
6
7
  import React, { forwardRef, useContext, useRef, useState } from "react";
7
8
  import { jsx, jsxs } from "react/jsx-runtime";
8
9
  //#region src/Input/components/TextArea/index.tsx
9
10
  var TextArea_default = forwardRef((props, ref) => {
10
- const { bordered, border, size: customSize, disabled, className = "", allowClear = false, value: controlledValue, defaultValue, onChange, onPressEnter, maxLength, showCount, autoSize, placeholder, rows, onBlur, onFocus, onKeyDown, onCompositionStart, onCompositionEnd, style, ...restTextAreaProps } = props;
11
+ const { bordered, border, size: customSize, disabled, className = "", allowClear = false, value: controlledValue, defaultValue, onChange, onPressEnter, maxLength, showCount, autoSize, placeholder, rows, onBlur, onFocus, onKeyDown, onCompositionStart, onCompositionEnd, style, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy, "aria-describedby": ariaDescribedBy, "aria-invalid": ariaInvalid, "aria-required": ariaRequired, "aria-busy": ariaBusy, "aria-disabled": ariaDisabled, "aria-readonly": ariaReadonly, ...restTextAreaProps } = props;
11
12
  const isBordered = bordered ?? border ?? true;
12
13
  const contextDisabled = useContext(DisabledContext);
13
14
  const mergedDisabled = disabled ?? contextDisabled;
@@ -33,7 +34,14 @@ var TextArea_default = forwardRef((props, ref) => {
33
34
  const minRows = typeof autoSize === "object" ? autoSize.minRows : void 0;
34
35
  const maxRows = typeof autoSize === "object" ? autoSize.maxRows : void 0;
35
36
  return /* @__PURE__ */ jsxs("div", {
36
- className: cn("ald-input ald-input-textarea tw-relative", `ald-input-textarea-${getSizeType(size)}`, isBordered && "tw-rounded-r-75 tw-border tw-border-solid tw-border-[var(--border-neutral-subtle)]", mergedDisabled && "ald-input-disabled tw-opacity-50", className),
37
+ className: cn("ald-input ald-input-textarea tw-relative tw-transition-[border-color,box-shadow] tw-duration-150 tw-ease-out", `ald-input-textarea-${getSizeType(size)}`, isBordered && "tw-rounded-r-75 tw-border tw-border-solid tw-border-[var(--border-neutral-subtle)]", !mergedDisabled && [
38
+ "has-[textarea:focus]:!tw-border-[var(--border-brand-strong)]",
39
+ "has-[textarea:focus-visible]:tw-shadow-[inset_0_0_0_1px_var(--focus-ring)]",
40
+ "forced-colors:has-[textarea:focus-visible]:tw-outline",
41
+ "forced-colors:has-[textarea:focus-visible]:tw-outline-2",
42
+ "forced-colors:has-[textarea:focus-visible]:tw-outline-offset-2",
43
+ "forced-colors:has-[textarea:focus-visible]:tw-outline-[Highlight]"
44
+ ], mergedDisabled && "ald-input-disabled tw-cursor-not-allowed tw-bg-[var(--background-neutral-subtle)] tw-text-[var(--content-secondary)]", className),
37
45
  style,
38
46
  children: [
39
47
  /* @__PURE__ */ jsx("textarea", {
@@ -52,6 +60,16 @@ var TextArea_default = forwardRef((props, ref) => {
52
60
  rows: rows || (minRows ?? 3),
53
61
  spellCheck: false,
54
62
  autoComplete: "off",
63
+ ...getSemanticOwnerAriaProps({
64
+ "aria-label": ariaLabel,
65
+ "aria-labelledby": ariaLabelledBy,
66
+ "aria-describedby": ariaDescribedBy,
67
+ "aria-invalid": ariaInvalid,
68
+ "aria-required": ariaRequired,
69
+ "aria-busy": ariaBusy,
70
+ "aria-disabled": ariaDisabled,
71
+ "aria-readonly": ariaReadonly
72
+ }),
55
73
  ...restTextAreaProps,
56
74
  style: {
57
75
  minHeight: minRows ? `${minRows * 22}px` : void 0,
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../../../../src/Input/components/TextArea/index.tsx"],"sourcesContent":["import React, { forwardRef, useContext, useRef, useState } from 'react';\nimport DisabledContext from '../../../ConfigProvider/DisabledContext';\nimport SizeContext from '../../../ConfigProvider/sizeContext';\nimport { CloseCircleFill } from '../../../Icon';\nimport { cn } from '../../../lib/utils';\nimport { TSize, getSizeType } from '../Input';\n\nexport type TextAreaRef = HTMLTextAreaElement;\n\nexport interface ITextAreaProps\n extends Omit<\n React.TextareaHTMLAttributes<HTMLTextAreaElement>,\n 'size' | 'value' | 'defaultValue' | 'onChange' | 'disabled' | 'rows'\n > {\n autoFocus?: boolean;\n allowClear?: boolean;\n autoSize?: boolean | { minRows?: number; maxRows?: number };\n defaultValue?: string;\n maxLength?: number;\n showCount?:\n | boolean\n | { formatter: (args: { count: number; maxLength?: number }) => string };\n value?: string;\n onPressEnter?: React.KeyboardEventHandler<HTMLTextAreaElement>;\n onResize?: (size: { width: number; height: number }) => void;\n border?: boolean;\n bordered?: boolean;\n className?: string;\n size?: TSize;\n disabled?: boolean;\n placeholder?: string;\n rows?: number;\n onChange?: (e: React.ChangeEvent<HTMLTextAreaElement>) => void;\n onBlur?: React.FocusEventHandler<HTMLTextAreaElement>;\n onFocus?: React.FocusEventHandler<HTMLTextAreaElement>;\n onKeyDown?: React.KeyboardEventHandler<HTMLTextAreaElement>;\n onCompositionStart?: React.CompositionEventHandler<HTMLTextAreaElement>;\n onCompositionEnd?: React.CompositionEventHandler<HTMLTextAreaElement>;\n style?: React.CSSProperties;\n}\n\nexport default forwardRef<TextAreaRef, ITextAreaProps>((props, ref) => {\n const {\n bordered,\n border,\n size: customSize,\n disabled,\n className = '',\n allowClear = false,\n value: controlledValue,\n defaultValue,\n onChange,\n onPressEnter,\n maxLength,\n showCount,\n autoSize,\n placeholder,\n rows,\n onBlur,\n onFocus,\n onKeyDown,\n onCompositionStart,\n onCompositionEnd,\n style,\n ...restTextAreaProps\n } = props;\n\n const isBordered = bordered ?? border ?? true;\n\n const contextDisabled = useContext(DisabledContext);\n const mergedDisabled = disabled ?? contextDisabled;\n\n const contentSize = useContext(SizeContext);\n const size = customSize || contentSize || 'middle';\n const isControlled = 'value' in props;\n const [innerValue, setInnerValue] = useState(defaultValue ?? '');\n const currentValue = isControlled ? controlledValue ?? '' : innerValue;\n const textareaRef = useRef<HTMLTextAreaElement>(null);\n\n React.useImperativeHandle(ref, () => textareaRef.current!);\n\n const handleChange = (e: React.ChangeEvent<HTMLTextAreaElement>) => {\n if (!isControlled) setInnerValue(e.target.value);\n onChange?.(e);\n };\n\n const handleClear = () => {\n if (!isControlled) setInnerValue('');\n onChange?.({\n target: { value: '' },\n } as React.ChangeEvent<HTMLTextAreaElement>);\n };\n\n const handleKeyDown = (e: React.KeyboardEvent<HTMLTextAreaElement>) => {\n if (e.key === 'Enter') onPressEnter?.(e);\n onKeyDown?.(e);\n };\n\n const minRows = typeof autoSize === 'object' ? autoSize.minRows : undefined;\n const maxRows = typeof autoSize === 'object' ? autoSize.maxRows : undefined;\n\n return (\n <div\n className={cn(\n 'ald-input ald-input-textarea tw-relative',\n `ald-input-textarea-${getSizeType(size)}`,\n isBordered &&\n 'tw-rounded-r-75 tw-border tw-border-solid tw-border-[var(--border-neutral-subtle)]',\n mergedDisabled && 'ald-input-disabled tw-opacity-50',\n className,\n )}\n style={style}\n >\n <textarea\n ref={textareaRef}\n className=\"tw-w-full tw-resize-y tw-border-0 tw-bg-[var(--action-ghost-normal)] tw-px-3 tw-py-2 tw-text-[var(--content-primary)] tw-outline-none tw-text-typography-body-dense\"\n value={currentValue}\n onChange={handleChange}\n onBlur={onBlur}\n onFocus={onFocus}\n onKeyDown={handleKeyDown}\n onCompositionStart={onCompositionStart}\n onCompositionEnd={onCompositionEnd}\n disabled={mergedDisabled}\n placeholder={placeholder}\n maxLength={maxLength}\n rows={rows || (minRows ?? 3)}\n spellCheck={false}\n autoComplete=\"off\"\n {...restTextAreaProps}\n style={{\n minHeight: minRows ? `${minRows * 22}px` : undefined,\n maxHeight: maxRows ? `${maxRows * 22}px` : undefined,\n }}\n />\n {allowClear && currentValue && !mergedDisabled && (\n <span\n className=\"tw-absolute tw-right-2 tw-top-2 tw-cursor-pointer\"\n onClick={handleClear}\n >\n <CloseCircleFill size={16} color=\"var(--content-secondary)\" />\n </span>\n )}\n {showCount && (\n <div className=\"tw-px-2 tw-pb-1 tw-text-right tw-text-[var(--content-tertiary)] tw-text-typography-caption\">\n {typeof showCount === 'object'\n ? showCount.formatter({ count: currentValue.length, maxLength })\n : `${currentValue.length}${maxLength ? `/${maxLength}` : ''}`}\n </div>\n )}\n </div>\n );\n});\n"],"mappings":";;;;;;;;AAyCA,IAAA,mBAAe,YAAyC,OAAO,QAAQ;CACrE,MAAM,EACJ,UACA,QACA,MAAM,YACN,UACA,YAAY,IACZ,aAAa,OACb,OAAO,iBACP,cACA,UACA,cACA,WACA,WACA,UACA,aACA,MACA,QACA,SACA,WACA,oBACA,kBACA,OACA,GAAG,sBACD;CAEJ,MAAM,aAAa,YAAY,UAAU;CAEzC,MAAM,kBAAkB,WAAW,gBAAgB;CACnD,MAAM,iBAAiB,YAAY;CAEnC,MAAM,cAAc,WAAW,YAAY;CAC3C,MAAM,OAAO,cAAc,eAAe;CAC1C,MAAM,eAAe,WAAW;CAChC,MAAM,CAAC,YAAY,iBAAiB,SAAS,gBAAgB,GAAG;CAChE,MAAM,eAAe,eAAe,mBAAmB,KAAK;CAC5D,MAAM,cAAc,OAA4B,KAAK;AAErD,OAAM,oBAAoB,WAAW,YAAY,QAAS;CAE1D,MAAM,gBAAgB,MAA8C;AAClE,MAAI,CAAC,aAAc,eAAc,EAAE,OAAO,MAAM;AAChD,aAAW,EAAE;;CAGf,MAAM,oBAAoB;AACxB,MAAI,CAAC,aAAc,eAAc,GAAG;AACpC,aAAW,EACT,QAAQ,EAAE,OAAO,IAAI,EACtB,CAA2C;;CAG9C,MAAM,iBAAiB,MAAgD;AACrE,MAAI,EAAE,QAAQ,QAAS,gBAAe,EAAE;AACxC,cAAY,EAAE;;CAGhB,MAAM,UAAU,OAAO,aAAa,WAAW,SAAS,UAAU;CAClE,MAAM,UAAU,OAAO,aAAa,WAAW,SAAS,UAAU;AAElE,QACE,qBAAC,OAAD;EACE,WAAW,GACT,4CACA,sBAAsB,YAAY,KAAK,IACvC,cACE,sFACF,kBAAkB,oCAClB,UACD;EACM;YATT;GAWE,oBAAC,YAAD;IACE,KAAK;IACL,WAAU;IACV,OAAO;IACP,UAAU;IACF;IACC;IACT,WAAW;IACS;IACF;IAClB,UAAU;IACG;IACF;IACX,MAAM,SAAS,WAAW;IAC1B,YAAY;IACZ,cAAa;IACb,GAAI;IACJ,OAAO;KACL,WAAW,UAAU,GAAG,UAAU,GAAG,MAAM;KAC3C,WAAW,UAAU,GAAG,UAAU,GAAG,MAAM;KAC5C;IACD,CAAA;GACD,cAAc,gBAAgB,CAAC,kBAC9B,oBAAC,QAAD;IACE,WAAU;IACV,SAAS;cAET,oBAAC,MAAD;KAAiB,MAAM;KAAI,OAAM;KAA6B,CAAA;IACzD,CAAA;GAER,aACC,oBAAC,OAAD;IAAK,WAAU;cACZ,OAAO,cAAc,WAClB,UAAU,UAAU;KAAE,OAAO,aAAa;KAAQ;KAAW,CAAC,GAC9D,GAAG,aAAa,SAAS,YAAY,IAAI,cAAc;IACvD,CAAA;GAEJ;;EAER"}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../../../src/Input/components/TextArea/index.tsx"],"sourcesContent":["import React, { forwardRef, useContext, useRef, useState } from 'react';\nimport DisabledContext from '../../../ConfigProvider/DisabledContext';\nimport SizeContext from '../../../ConfigProvider/sizeContext';\nimport { CloseCircleFill } from '../../../Icon';\nimport { cn } from '../../../lib/utils';\nimport { TSize, getSizeType } from '../Input';\nimport { getSemanticOwnerAriaProps } from '../../privateSemanticOwner';\n\nexport type TextAreaRef = HTMLTextAreaElement;\n\nexport interface ITextAreaProps\n extends Omit<\n React.TextareaHTMLAttributes<HTMLTextAreaElement>,\n 'size' | 'value' | 'defaultValue' | 'onChange' | 'disabled' | 'rows'\n > {\n autoFocus?: boolean;\n allowClear?: boolean;\n autoSize?: boolean | { minRows?: number; maxRows?: number };\n defaultValue?: string;\n maxLength?: number;\n showCount?:\n | boolean\n | { formatter: (args: { count: number; maxLength?: number }) => string };\n value?: string;\n onPressEnter?: React.KeyboardEventHandler<HTMLTextAreaElement>;\n onResize?: (size: { width: number; height: number }) => void;\n border?: boolean;\n bordered?: boolean;\n className?: string;\n size?: TSize;\n disabled?: boolean;\n placeholder?: string;\n rows?: number;\n onChange?: (e: React.ChangeEvent<HTMLTextAreaElement>) => void;\n onBlur?: React.FocusEventHandler<HTMLTextAreaElement>;\n onFocus?: React.FocusEventHandler<HTMLTextAreaElement>;\n onKeyDown?: React.KeyboardEventHandler<HTMLTextAreaElement>;\n onCompositionStart?: React.CompositionEventHandler<HTMLTextAreaElement>;\n onCompositionEnd?: React.CompositionEventHandler<HTMLTextAreaElement>;\n style?: React.CSSProperties;\n}\n\nexport default forwardRef<TextAreaRef, ITextAreaProps>((props, ref) => {\n const {\n bordered,\n border,\n size: customSize,\n disabled,\n className = '',\n allowClear = false,\n value: controlledValue,\n defaultValue,\n onChange,\n onPressEnter,\n maxLength,\n showCount,\n autoSize,\n placeholder,\n rows,\n onBlur,\n onFocus,\n onKeyDown,\n onCompositionStart,\n onCompositionEnd,\n style,\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledBy,\n 'aria-describedby': ariaDescribedBy,\n 'aria-invalid': ariaInvalid,\n 'aria-required': ariaRequired,\n 'aria-busy': ariaBusy,\n 'aria-disabled': ariaDisabled,\n 'aria-readonly': ariaReadonly,\n ...restTextAreaProps\n } = props;\n\n const isBordered = bordered ?? border ?? true;\n\n const contextDisabled = useContext(DisabledContext);\n const mergedDisabled = disabled ?? contextDisabled;\n\n const contentSize = useContext(SizeContext);\n const size = customSize || contentSize || 'middle';\n const isControlled = 'value' in props;\n const [innerValue, setInnerValue] = useState(defaultValue ?? '');\n const currentValue = isControlled ? controlledValue ?? '' : innerValue;\n const textareaRef = useRef<HTMLTextAreaElement>(null);\n\n React.useImperativeHandle(ref, () => textareaRef.current!);\n\n const handleChange = (e: React.ChangeEvent<HTMLTextAreaElement>) => {\n if (!isControlled) setInnerValue(e.target.value);\n onChange?.(e);\n };\n\n const handleClear = () => {\n if (!isControlled) setInnerValue('');\n onChange?.({\n target: { value: '' },\n } as React.ChangeEvent<HTMLTextAreaElement>);\n };\n\n const handleKeyDown = (e: React.KeyboardEvent<HTMLTextAreaElement>) => {\n if (e.key === 'Enter') onPressEnter?.(e);\n onKeyDown?.(e);\n };\n\n const minRows = typeof autoSize === 'object' ? autoSize.minRows : undefined;\n const maxRows = typeof autoSize === 'object' ? autoSize.maxRows : undefined;\n\n return (\n <div\n className={cn(\n 'ald-input ald-input-textarea tw-relative tw-transition-[border-color,box-shadow] tw-duration-150 tw-ease-out',\n `ald-input-textarea-${getSizeType(size)}`,\n isBordered &&\n 'tw-rounded-r-75 tw-border tw-border-solid tw-border-[var(--border-neutral-subtle)]',\n !mergedDisabled && [\n 'has-[textarea:focus]:!tw-border-[var(--border-brand-strong)]',\n 'has-[textarea:focus-visible]:tw-shadow-[inset_0_0_0_1px_var(--focus-ring)]',\n 'forced-colors:has-[textarea:focus-visible]:tw-outline',\n 'forced-colors:has-[textarea:focus-visible]:tw-outline-2',\n 'forced-colors:has-[textarea:focus-visible]:tw-outline-offset-2',\n 'forced-colors:has-[textarea:focus-visible]:tw-outline-[Highlight]',\n ],\n mergedDisabled &&\n 'ald-input-disabled tw-cursor-not-allowed tw-bg-[var(--background-neutral-subtle)] tw-text-[var(--content-secondary)]',\n className,\n )}\n style={style}\n >\n <textarea\n ref={textareaRef}\n className=\"tw-w-full tw-resize-y tw-border-0 tw-bg-[var(--action-ghost-normal)] tw-px-3 tw-py-2 tw-text-[var(--content-primary)] tw-outline-none tw-text-typography-body-dense\"\n value={currentValue}\n onChange={handleChange}\n onBlur={onBlur}\n onFocus={onFocus}\n onKeyDown={handleKeyDown}\n onCompositionStart={onCompositionStart}\n onCompositionEnd={onCompositionEnd}\n disabled={mergedDisabled}\n placeholder={placeholder}\n maxLength={maxLength}\n rows={rows || (minRows ?? 3)}\n spellCheck={false}\n autoComplete=\"off\"\n {...getSemanticOwnerAriaProps({\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledBy,\n 'aria-describedby': ariaDescribedBy,\n 'aria-invalid': ariaInvalid,\n 'aria-required': ariaRequired,\n 'aria-busy': ariaBusy,\n 'aria-disabled': ariaDisabled,\n 'aria-readonly': ariaReadonly,\n })}\n {...restTextAreaProps}\n style={{\n minHeight: minRows ? `${minRows * 22}px` : undefined,\n maxHeight: maxRows ? `${maxRows * 22}px` : undefined,\n }}\n />\n {allowClear && currentValue && !mergedDisabled && (\n <span\n className=\"tw-absolute tw-right-2 tw-top-2 tw-cursor-pointer\"\n onClick={handleClear}\n >\n <CloseCircleFill size={16} color=\"var(--content-secondary)\" />\n </span>\n )}\n {showCount && (\n <div className=\"tw-px-2 tw-pb-1 tw-text-right tw-text-[var(--content-tertiary)] tw-text-typography-caption\">\n {typeof showCount === 'object'\n ? showCount.formatter({ count: currentValue.length, maxLength })\n : `${currentValue.length}${maxLength ? `/${maxLength}` : ''}`}\n </div>\n )}\n </div>\n );\n});\n"],"mappings":";;;;;;;;;AA0CA,IAAA,mBAAe,YAAyC,OAAO,QAAQ;CACrE,MAAM,EACJ,UACA,QACA,MAAM,YACN,UACA,YAAY,IACZ,aAAa,OACb,OAAO,iBACP,cACA,UACA,cACA,WACA,WACA,UACA,aACA,MACA,QACA,SACA,WACA,oBACA,kBACA,OACA,cAAc,WACd,mBAAmB,gBACnB,oBAAoB,iBACpB,gBAAgB,aAChB,iBAAiB,cACjB,aAAa,UACb,iBAAiB,cACjB,iBAAiB,cACjB,GAAG,sBACD;CAEJ,MAAM,aAAa,YAAY,UAAU;CAEzC,MAAM,kBAAkB,WAAW,gBAAgB;CACnD,MAAM,iBAAiB,YAAY;CAEnC,MAAM,cAAc,WAAW,YAAY;CAC3C,MAA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C9B,oBAAC,QAAD;IACE,WAAU;IACV,SAAS;cAET,oBAAC,MAAD;KAAiB,MAAM;KAAI,OAAM;KAA6B,CAAA;IACzD,CAAA;GAER,aACC,oBAAC,OAAD;IAAK,WAAU;cACZ,OAAO,cAAc,WAClB,UAAU,UAAU;KAAE,OAAO,aAAa;KAAQ;KAAW,CAAC,GAC9D,GAAG,aAAa,SAAS,YAAY,IAAI,cAAc;IACvD,CAAA;GAEJ;;EAER"}
@@ -0,0 +1,2 @@
1
+ export { getSemanticOwnerAriaProps } from '../_utils/formControlSemanticOwner';
2
+ export type { SemanticOwnerAriaProps } from '../_utils/formControlSemanticOwner';
@@ -0,0 +1 @@
1
+ import "../_utils/formControlSemanticOwner.js";
@@ -4,12 +4,19 @@ import SizeContext from "../ConfigProvider/sizeContext.js";
4
4
  import { useCallback, useContext, useEffect, useRef, useState } from "react";
5
5
  import { jsx, jsxs } from "react/jsx-runtime";
6
6
  //#region src/InputNumber/index.tsx
7
+ function pickAriaProps(props) {
8
+ return Object.keys(props).reduce((ariaProps, key) => {
9
+ if (key.startsWith("aria-")) ariaProps[key] = props[key];
10
+ return ariaProps;
11
+ }, {});
12
+ }
7
13
  function InputNumber(props) {
8
14
  const { className, disabled: customDisabled, size: customSize, status, value: controlledValue, defaultValue, min = -Infinity, max = Infinity, step = 1, precision, onChange, onPressEnter, onBlur, onFocus, formatter, parser, prefix, addonBefore, addonAfter, placeholder, autoFocus, bordered = true, keyboard = true, readonly: readOnly, style, id, "data-testid": dataTestId, "aria-label": ariaLabel } = props;
9
15
  const contentSize = useContext(SizeContext);
10
16
  const size = customSize || contentSize || "middle";
11
17
  const disabled = useContext(DisabledContext);
12
18
  const mergedDisabled = customDisabled ?? disabled;
19
+ const nativeInputAriaProps = pickAriaProps(props);
13
20
  const isControlled = "value" in props;
14
21
  const [innerValue, setInnerValue] = useState(defaultValue ?? null);
15
22
  const currentValue = isControlled ? controlledValue : innerValue;
@@ -83,19 +90,26 @@ function InputNumber(props) {
83
90
  const radiusClasses = cn(size === "large" && "tw-rounded-[8px]", size === "small" && "tw-rounded-[4px]", size !== "large" && size !== "small" && "tw-rounded-[6px]");
84
91
  const inputBox = /* @__PURE__ */ jsxs("div", {
85
92
  "data-testid": !hasAddon ? dataTestId : void 0,
86
- "aria-label": !hasAddon ? ariaLabel : void 0,
87
- className: cn("ald-input-number tw-inline-flex tw-w-[90px] tw-min-w-0 tw-items-center tw-overflow-hidden", bordered && "tw-border tw-border-solid tw-border-[var(--border-neutral-subtle)]", mergedDisabled ? "ald-input-number-disabled tw-cursor-not-allowed tw-bg-[var(--background-neutral-on-subtle)] tw-text-[var(--content-secondary)]" : "tw-bg-[var(--background-default)] tw-text-[var(--content-primary)] hover:tw-border-[var(--border-brand-strong)]", !hasAddon && sizeClasses, hasAddon ? "tw-h-auto tw-flex-1 tw-self-stretch tw-rounded-none" : radiusClasses, status === "error" && "tw-border-[var(--border-negative-strong)]", status === "warning" && "tw-border-[var(--border-warning-subtle)]", "focus-within:tw-border-[var(--border-brand-strong)] focus-within:tw-outline focus-within:tw-outline-1 focus-within:tw-outline-[var(--border-brand-strong)]", !hasAddon && className),
93
+ className: cn("ald-input-number tw-inline-flex tw-w-[90px] tw-min-w-0 tw-items-center tw-overflow-hidden tw-transition-[border-color,box-shadow] tw-duration-150 tw-ease-out", bordered && "tw-border tw-border-solid tw-border-[var(--border-neutral-subtle)]", mergedDisabled ? "ald-input-number-disabled tw-cursor-not-allowed tw-bg-[var(--background-neutral-subtle)] tw-text-[var(--content-secondary)]" : "tw-bg-[var(--background-default)] tw-text-[var(--content-primary)] hover:tw-border-[var(--border-brand-strong)]", !hasAddon && sizeClasses, hasAddon ? "tw-h-auto tw-flex-1 tw-self-stretch tw-rounded-none" : radiusClasses, status === "error" && "tw-border-[var(--border-negative-strong)]", status === "warning" && "tw-border-[var(--border-warning-subtle)]", !mergedDisabled && [
94
+ !status && "has-[input:focus]:!tw-border-[var(--border-brand-strong)]",
95
+ "has-[input:focus-visible]:tw-shadow-[inset_0_0_0_1px_var(--focus-ring)]",
96
+ "forced-colors:has-[input:focus-visible]:tw-outline",
97
+ "forced-colors:has-[input:focus-visible]:tw-outline-2",
98
+ "forced-colors:has-[input:focus-visible]:tw-outline-offset-2",
99
+ "forced-colors:has-[input:focus-visible]:tw-outline-[Highlight]"
100
+ ], !hasAddon && className),
88
101
  style: !hasAddon ? style : void 0,
89
102
  children: [prefix && /* @__PURE__ */ jsx("span", {
90
103
  className: "tw-px-2 tw-text-[var(--content-secondary)]",
91
104
  children: prefix
92
105
  }), /* @__PURE__ */ jsx("input", {
106
+ ...nativeInputAriaProps,
93
107
  ref: inputRef,
94
108
  id,
95
109
  type: "text",
96
110
  inputMode: "numeric",
97
111
  size: 1,
98
- className: cn("tw-min-w-0 tw-flex-1 tw-border-0 tw-bg-[var(--action-ghost-normal)] tw-px-[7px] tw-text-inherit tw-outline-none", mergedDisabled && "tw-cursor-not-allowed tw-text-[var(--content-secondary)]"),
112
+ className: cn("tw-min-w-0 tw-flex-1 tw-border-0 tw-bg-[var(--action-ghost-normal)] tw-px-[7px] tw-text-inherit tw-outline-none tw-text-typography-body-dense", mergedDisabled && "tw-cursor-not-allowed tw-text-[var(--content-secondary)]"),
99
113
  value: displayValue,
100
114
  onChange: handleChange,
101
115
  onBlur: handleBlur,
@@ -104,13 +118,13 @@ function InputNumber(props) {
104
118
  disabled: mergedDisabled,
105
119
  readOnly,
106
120
  autoFocus,
107
- placeholder
121
+ placeholder,
122
+ "aria-label": ariaLabel
108
123
  })]
109
124
  });
110
125
  if (!hasAddon) return inputBox;
111
126
  return /* @__PURE__ */ jsxs("div", {
112
127
  "data-testid": dataTestId,
113
- "aria-label": ariaLabel,
114
128
  className: cn("ald-input-number-group tw-inline-flex tw-min-w-0 tw-items-stretch", sizeClasses, radiusClasses, mergedDisabled && "ald-input-number-disabled", className),
115
129
  style,
116
130
  children: [
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../../src/InputNumber/index.tsx"],"sourcesContent":["import React, {\n useCallback,\n useContext,\n useEffect,\n useRef,\n useState,\n} from 'react';\nimport DisabledContext from '../ConfigProvider/DisabledContext';\nimport SizeContext from '../ConfigProvider/sizeContext';\nimport { cn } from '../lib/utils';\nimport { IInputNumberProps } from './type';\n\nexport default function InputNumber(props: IInputNumberProps) {\n const {\n className,\n disabled: customDisabled,\n size: customSize,\n status,\n value: controlledValue,\n defaultValue,\n min = -Infinity,\n max = Infinity,\n step = 1,\n precision,\n onChange,\n onPressEnter,\n onBlur,\n onFocus,\n formatter,\n parser,\n prefix,\n addonBefore,\n addonAfter,\n placeholder,\n autoFocus,\n bordered = true,\n keyboard = true,\n readonly: readOnly,\n style,\n id,\n 'data-testid': dataTestId,\n 'aria-label': ariaLabel,\n } = props;\n\n const contentSize = useContext(SizeContext);\n const size = customSize || contentSize || 'middle';\n const disabled = useContext(DisabledContext);\n const mergedDisabled = customDisabled ?? disabled;\n\n const isControlled = 'value' in props;\n const [innerValue, setInnerValue] = useState<number | null | undefined>(\n defaultValue ?? null,\n );\n const currentValue = isControlled ? controlledValue : innerValue;\n\n const [inputStr, setInputStr] = useState(\n currentValue !== null && currentValue !== undefined\n ? String(currentValue)\n : '',\n );\n const inputRef = useRef<HTMLInputElement>(null);\n\n useEffect(() => {\n if (currentValue !== null && currentValue !== undefined) {\n setInputStr(String(currentValue));\n } else {\n setInputStr('');\n }\n }, [currentValue]);\n\n const clamp = useCallback(\n (val: number) => {\n let v = Math.max(min, Math.min(max, val));\n if (precision !== undefined) {\n v = Number(v.toFixed(precision));\n }\n return v;\n },\n [min, max, precision],\n );\n\n const updateValue = useCallback(\n (newVal: number | null) => {\n const clamped = newVal !== null ? clamp(newVal) : null;\n if (!isControlled) setInnerValue(clamped);\n onChange?.(clamped);\n },\n [clamp, isControlled, onChange],\n );\n\n const handleChange = (e: React.ChangeEvent<HTMLInputElement>) => {\n const raw = e.target.value;\n setInputStr(raw);\n if (raw === '') {\n // 清空立即同步到 value,对齐 antd 行为。\n // 否则消费方\"清空后直接点确定\"(未 blur 触发 handleBlur 的 null 兜底)拿到的\n // 仍是旧值,把已清空的筛选条件错误带进 query(被 release-2.3_test 周期实例\n // 更多浮窗实测复现)。\n updateValue(null);\n return;\n }\n if (raw === '-') return;\n const parsed = parser ? parser(raw) : Number(raw);\n if (!isNaN(parsed)) {\n updateValue(parsed);\n }\n };\n\n const handleBlur = (e: React.FocusEvent<HTMLInputElement>) => {\n if (inputStr === '' || inputStr === '-') {\n updateValue(null);\n setInputStr('');\n } else {\n const parsed = parser ? parser(inputStr) : Number(inputStr);\n if (!isNaN(parsed)) {\n const clamped = clamp(parsed);\n updateValue(clamped);\n setInputStr(String(clamped));\n }\n }\n onBlur?.(e);\n };\n\n const handleKeyDown = (e: React.KeyboardEvent<HTMLInputElement>) => {\n if (e.key === 'Enter') {\n onPressEnter?.(e);\n }\n if (!keyboard) return;\n const numStep = typeof step === 'string' ? Number(step) : step;\n if (e.key === 'ArrowUp') {\n e.preventDefault();\n updateValue(clamp((currentValue ?? 0) + numStep));\n } else if (e.key === 'ArrowDown') {\n e.preventDefault();\n updateValue(clamp((currentValue ?? 0) - numStep));\n }\n };\n\n const displayValue = formatter\n ? formatter(currentValue ?? undefined, {\n userTyping: document.activeElement === inputRef.current,\n input: inputStr,\n })\n : inputStr;\n\n const hasAddon = addonBefore || addonAfter;\n\n const sizeClasses = cn(\n size === 'large' && 'ald-input-number-large tw-h-9 tw-text-base',\n size === 'small' && 'ald-input-number-small tw-h-7 tw-text-xs',\n size !== 'large' &&\n size !== 'small' &&\n 'ald-input-number-middle tw-h-8 tw-text-sm',\n );\n\n const radiusClasses = cn(\n size === 'large' && 'tw-rounded-[8px]',\n size === 'small' && 'tw-rounded-[4px]',\n size !== 'large' && size !== 'small' && 'tw-rounded-[6px]',\n );\n\n const inputBox = (\n <div\n data-testid={!hasAddon ? dataTestId : undefined}\n aria-label={!hasAddon ? ariaLabel : undefined}\n className={cn(\n // 默认宽度 90px 与 antd InputNumber 对齐:input 上 size={1} 会让 intrinsic\n // 宽度坍缩到 1 字符,若 wrapper 也不给宽度,整个组件在 flex / inline 上下\n // 文里就只剩 ~9px。消费方可通过 className(`w-[xxx]`)或 style 覆盖。\n 'ald-input-number tw-inline-flex tw-w-[90px] tw-min-w-0 tw-items-center tw-overflow-hidden',\n bordered &&\n 'tw-border tw-border-solid tw-border-[var(--border-neutral-subtle)]',\n mergedDisabled\n ? 'ald-input-number-disabled tw-cursor-not-allowed tw-bg-[var(--background-neutral-on-subtle)] tw-text-[var(--content-secondary)]'\n : 'tw-bg-[var(--background-default)] tw-text-[var(--content-primary)] hover:tw-border-[var(--border-brand-strong)]',\n !hasAddon && sizeClasses,\n hasAddon\n ? 'tw-h-auto tw-flex-1 tw-self-stretch tw-rounded-none'\n : radiusClasses,\n status === 'error' && 'tw-border-[var(--border-negative-strong)]',\n status === 'warning' && 'tw-border-[var(--border-warning-subtle)]',\n 'focus-within:tw-border-[var(--border-brand-strong)] focus-within:tw-outline focus-within:tw-outline-1 focus-within:tw-outline-[var(--border-brand-strong)]',\n !hasAddon && className,\n )}\n style={!hasAddon ? style : undefined}\n >\n {prefix && (\n <span className=\"tw-px-2 tw-text-[var(--content-secondary)]\">\n {prefix}\n </span>\n )}\n <input\n ref={inputRef}\n id={id}\n type=\"text\"\n inputMode=\"numeric\"\n // size=1 让 <input> 的 intrinsic 宽度坍缩到 1 个字符,\n // 在 flex 父容器中按 width / flex-1 受控,避免默认 size=20 把 inline-flex 外层撑出 ~150px 内容宽度。\n size={1}\n className={cn(\n 'tw-min-w-0 tw-flex-1 tw-border-0 tw-bg-[var(--action-ghost-normal)] tw-px-[7px] tw-text-inherit tw-outline-none',\n mergedDisabled &&\n 'tw-cursor-not-allowed tw-text-[var(--content-secondary)]',\n )}\n value={displayValue}\n onChange={handleChange}\n onBlur={handleBlur}\n onFocus={onFocus}\n onKeyDown={handleKeyDown}\n disabled={mergedDisabled}\n readOnly={readOnly}\n autoFocus={autoFocus}\n placeholder={placeholder}\n />\n </div>\n );\n\n if (!hasAddon) return inputBox;\n\n return (\n <div\n data-testid={dataTestId}\n aria-label={ariaLabel}\n className={cn(\n // 自然宽 = 内部 inputBox 默认 90px + addonBefore/After 内容宽。inline-flex\n // 让外层按内容宽呈现,不再 `tw-w-full` 强吞 flex 父级剩余空间——后者会把\n // 同 flex 行的 Slider 挤成 0 宽(看板\"图形宽度\"行只剩 thumb 圆点的根因)。\n // `tw-min-w-0` 让本身作为 flex item 时受消费方 `flex-basis` / `width`\n // 真正约束——默认 `min-width: auto = min-content` 会被内部 input(90px) +\n // addon 撑到 ~126px,覆盖消费方的 flex-basis。内部 inputBox 已 `tw-min-w-0\n // tw-overflow-hidden`,被约束后内容会按 input flex-1 收缩,不会溢出。\n // 消费方需要撑满显式加 `tw-w-full` className,需要更窄/更宽直接覆盖宽度。\n 'ald-input-number-group tw-inline-flex tw-min-w-0 tw-items-stretch',\n sizeClasses,\n radiusClasses,\n mergedDisabled && 'ald-input-number-disabled',\n className,\n )}\n style={style}\n >\n {addonBefore && (\n <span\n className={cn(\n 'ald-input-number-addon tw-flex tw-shrink-0 tw-items-center tw-border tw-border-r-0 tw-border-solid tw-border-[var(--border-neutral-subtle)] tw-bg-[var(--background-neutral-subtle)] tw-px-3 tw-text-[var(--content-secondary)]',\n size === 'large' && 'tw-rounded-l-[8px]',\n size === 'small' && 'tw-rounded-l-[4px]',\n size !== 'large' && size !== 'small' && 'tw-rounded-l-[6px]',\n )}\n >\n {addonBefore}\n </span>\n )}\n {inputBox}\n {addonAfter && (\n <span\n className={cn(\n 'ald-input-number-addon tw-flex tw-shrink-0 tw-items-center tw-border tw-border-l-0 tw-border-solid tw-border-[var(--border-neutral-subtle)] tw-bg-[var(--background-neutral-subtle)] tw-px-3 tw-text-[var(--content-secondary)]',\n size === 'large' && 'tw-rounded-r-[8px]',\n size === 'small' && 'tw-rounded-r-[4px]',\n size !== 'large' && size !== 'small' && 'tw-rounded-r-[6px]',\n )}\n >\n {addonAfter}\n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WAAW,YAAY;EACpC,WAAW,GAIT,6FACA,YACE,sEACF,iBACI,mIACA,mHACJ,CAAC,YAAY,aACb,WACI,wDACA,eACJ,WAAW,WAAW,6CACtB,WAAW,aAAa,4CACxB,8JACA,CAAC,YAAY,UACd;EACD,OAAO,CAAC,WAAW,QAAQ;YAtB7B,CAwBG,UACC,oBAAC,QAAD;GAAM,WAAU;aACb;GACI,CAAA,EAET,oBAAC,SAAD;GACE,KAAK;GACD;GACJ,MAAK;GACL,WAAU;GAGV,MAAM;GACN,WAAW,GACT,mHACA,kBACE,2DACH;GACD,OAAO;GACP,UAAU;GACV,QAAQ;GACC;GACT,WAAW;GACX,UAAU;GACA;GACC;GACE;GACb,CAAA,CACE;;AAGR,KAAI,CAAC,SAAU,QAAO;AAEtB,QACE,qBAAC,OAAD;EACE,eAAa;EACb,cAAY;EACZ,WAAW,GAST,qEACA,aACA,eACA,kBAAkB,6BAClB,UACD;EACM;YAlBT;GAoBG,eACC,oBAAC,QAAD;IACE,WAAW,GACT,mOACA,SAAS,WAAW,sBACpB,SAAS,WAAW,sBACpB,SAAS,WAAW,SAAS,WAAW,qBACzC;cAEA;IACI,CAAA;GAER;GACA,cACC,oBAAC,QAAD;IACE,WAAW,GACT,mOACA,SAAS,WAAW,sBACpB,SAAS,WAAW,sBACpB,SAAS,WAAW,SAAS,WAAW,qBACzC;cAEA;IACI,CAAA;GAEL"}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../src/InputNumber/index.tsx"],"sourcesContent":["import React, {\n useCallback,\n useContext,\n useEffect,\n useRef,\n useState,\n} from 'react';\nimport DisabledContext from '../ConfigProvider/DisabledContext';\nimport SizeContext from '../ConfigProvider/sizeContext';\nimport { cn } from '../lib/utils';\nimport { IInputNumberProps } from './type';\n\nfunction pickAriaProps(props: IInputNumberProps): Record<string, unknown> {\n return Object.keys(props).reduce<Record<string, unknown>>(\n (ariaProps, key) => {\n if (key.startsWith('aria-')) {\n ariaProps[key] = props[key as keyof IInputNumberProps];\n }\n return ariaProps;\n },\n {},\n );\n}\n\nexport default function InputNumber(props: IInputNumberProps) {\n const {\n className,\n disabled: customDisabled,\n size: customSize,\n status,\n value: controlledValue,\n defaultValue,\n min = -Infinity,\n max = Infinity,\n step = 1,\n precision,\n onChange,\n onPressEnter,\n onBlur,\n onFocus,\n formatter,\n parser,\n prefix,\n addonBefore,\n addonAfter,\n placeholder,\n autoFocus,\n bordered = true,\n keyboard = true,\n readonly: readOnly,\n style,\n id,\n 'data-testid': dataTestId,\n 'aria-label': ariaLabel,\n } = props;\n\n const contentSize = useContext(SizeContext);\n const size = customSize || contentSize || 'middle';\n const disabled = useContext(DisabledContext);\n const mergedDisabled = customDisabled ?? disabled;\n const nativeInputAriaProps = pickAriaProps(props);\n\n const isControlled = 'value' in props;\n const [innerValue, setInnerValue] = useState<number | null | undefined>(\n defaultValue ?? null,\n );\n const currentValue = isControlled ? controlledValue : innerValue;\n\n const [inputStr, setInputStr] = useState(\n currentValue !== null && currentValue !== undefined\n ? String(currentValue)\n : '',\n );\n const inputRef = useRef<HTMLInputElement>(null);\n\n useEffect(() => {\n if (currentValue !== null && currentValue !== undefined) {\n setInputStr(String(currentValue));\n } else {\n setInputStr('');\n }\n }, [currentValue]);\n\n const clamp = useCallback(\n (val: number) => {\n let v = Math.max(min, Math.min(max, val));\n if (precision !== undefined) {\n v = Number(v.toFixed(precision));\n }\n return v;\n },\n [min, max, precision],\n );\n\n const updateValue = useCallback(\n (newVal: number | null) => {\n const clamped = newVal !== null ? clamp(newVal) : null;\n if (!isControlled) setInnerValue(clamped);\n onChange?.(clamped);\n },\n [clamp, isControlled, onChange],\n );\n\n const handleChange = (e: React.ChangeEvent<HTMLInputElement>) => {\n const raw = e.target.value;\n setInputStr(raw);\n if (raw === '') {\n // 清空立即同步到 value,对齐 antd 行为。\n // 否则消费方\"清空后直接点确定\"(未 blur 触发 handleBlur 的 null 兜底)拿到的\n // 仍是旧值,把已清空的筛选条件错误带进 query(被 release-2.3_test 周期实例\n // 更多浮窗实测复现)。\n updateValue(null);\n return;\n }\n if (raw === '-') return;\n const parsed = parser ? parser(raw) : Number(raw);\n if (!isNaN(parsed)) {\n updateValue(parsed);\n }\n };\n\n const handleBlur = (e: React.FocusEvent<HTMLInputElement>) => {\n if (inputStr === '' || inputStr === '-') {\n updateValue(null);\n setInputStr('');\n } else {\n const parsed = parser ? parser(inputStr) : Number(inputStr);\n if (!isNaN(parsed)) {\n const clamped = clamp(parsed);\n updateValue(clamped);\n setInputStr(String(clamped));\n }\n }\n onBlur?.(e);\n };\n\n const handleKeyDown = (e: React.KeyboardEvent<HTMLInputElement>) => {\n if (e.key === 'Enter') {\n onPressEnter?.(e);\n }\n if (!keyboard) return;\n const numStep = typeof step === 'string' ? Number(step) : step;\n if (e.key === 'ArrowUp') {\n e.preventDefault();\n updateValue(clamp((currentValue ?? 0) + numStep));\n } else if (e.key === 'ArrowDown') {\n e.preventDefault();\n updateValue(clamp((currentValue ?? 0) - numStep));\n }\n };\n\n const displayValue = formatter\n ? formatter(currentValue ?? undefined, {\n userTyping: document.activeElement === inputRef.current,\n input: inputStr,\n })\n : inputStr;\n\n const hasAddon = addonBefore || addonAfter;\n\n const sizeClasses = cn(\n size === 'large' && 'ald-input-number-large tw-h-9 tw-text-base',\n size === 'small' && 'ald-input-number-small tw-h-7 tw-text-xs',\n size !== 'large' &&\n size !== 'small' &&\n 'ald-input-number-middle tw-h-8 tw-text-sm',\n );\n\n const radiusClasses = cn(\n size === 'large' && 'tw-rounded-[8px]',\n size === 'small' && 'tw-rounded-[4px]',\n size !== 'large' && size !== 'small' && 'tw-rounded-[6px]',\n );\n\n const inputBox = (\n <div\n data-testid={!hasAddon ? dataTestId : undefined}\n className={cn(\n // 默认宽度 90px 与 antd InputNumber 对齐:input 上 size={1} 会让 intrinsic\n // 宽度坍缩到 1 字符,若 wrapper 也不给宽度,整个组件在 flex / inline 上下\n // 文里就只剩 ~9px。消费方可通过 className(`w-[xxx]`)或 style 覆盖。\n 'ald-input-number tw-inline-flex tw-w-[90px] tw-min-w-0 tw-items-center tw-overflow-hidden tw-transition-[border-color,box-shadow] tw-duration-150 tw-ease-out',\n bordered &&\n 'tw-border tw-border-solid tw-border-[var(--border-neutral-subtle)]',\n mergedDisabled\n ? 'ald-input-number-disabled tw-cursor-not-allowed tw-bg-[var(--background-neutral-subtle)] tw-text-[var(--content-secondary)]'\n : 'tw-bg-[var(--background-default)] tw-text-[var(--content-primary)] hover:tw-border-[var(--border-brand-strong)]',\n !hasAddon && sizeClasses,\n hasAddon\n ? 'tw-h-auto tw-flex-1 tw-self-stretch tw-rounded-none'\n : radiusClasses,\n status === 'error' && 'tw-border-[var(--border-negative-strong)]',\n status === 'warning' && 'tw-border-[var(--border-warning-subtle)]',\n // Focus State Layer belongs to the field envelope, while the input\n // remains the native focus owner. It intentionally does not share\n // status, hover, or disabled styling and does not affect Geometry.\n !mergedDisabled && [\n !status &&\n 'has-[input:focus]:!tw-border-[var(--border-brand-strong)]',\n 'has-[input:focus-visible]:tw-shadow-[inset_0_0_0_1px_var(--focus-ring)]',\n 'forced-colors:has-[input:focus-visible]:tw-outline',\n 'forced-colors:has-[input:focus-visible]:tw-outline-2',\n 'forced-colors:has-[input:focus-visible]:tw-outline-offset-2',\n 'forced-colors:has-[input:focus-visible]:tw-outline-[Highlight]',\n ],\n !hasAddon && className,\n )}\n style={!hasAddon ? style : undefined}\n >\n {prefix && (\n <span className=\"tw-px-2 tw-text-[var(--content-secondary)]\">\n {prefix}\n </span>\n )}\n <input\n {...nativeInputAriaProps}\n ref={inputRef}\n id={id}\n type=\"text\"\n inputMode=\"numeric\"\n // size=1 让 <input> 的 intrinsic 宽度坍缩到 1 个字符,\n // 在 flex 父容器中按 width / flex-1 受控,避免默认 size=20 把 inline-flex 外层撑出 ~150px 内容宽度。\n size={1}\n className={cn(\n // Typography Foundation: editable numeric content and its placeholder\n // consume the same approved Body Dense contract as Input. Prefix and\n // add-on surfaces remain outside this Typography ownership.\n 'tw-min-w-0 tw-flex-1 tw-border-0 tw-bg-[var(--action-ghost-normal)] tw-px-[7px] tw-text-inherit tw-outline-none tw-text-typography-body-dense',\n mergedDisabled &&\n 'tw-cursor-not-allowed tw-text-[var(--content-secondary)]',\n )}\n value={displayValue}\n onChange={handleChange}\n onBlur={handleBlur}\n onFocus={onFocus}\n onKeyDown={handleKeyDown}\n disabled={mergedDisabled}\n readOnly={readOnly}\n autoFocus={autoFocus}\n placeholder={placeholder}\n aria-label={ariaLabel}\n />\n </div>\n );\n\n if (!hasAddon) return inputBox;\n\n return (\n <div\n data-testid={dataTestId}\n className={cn(\n // 自然宽 = 内部 inputBox 默认 90px + addonBefore/After 内容宽。inline-flex\n // 让外层按内容宽呈现,不再 `tw-w-full` 强吞 flex 父级剩余空间——后者会把\n // 同 flex 行的 Slider 挤成 0 宽(看板\"图形宽度\"行只剩 thumb 圆点的根因)。\n // `tw-min-w-0` 让本身作为 flex item 时受消费方 `flex-basis` / `width`\n // 真正约束——默认 `min-width: auto = min-content` 会被内部 input(90px) +\n // addon 撑到 ~126px,覆盖消费方的 flex-basis。内部 inputBox 已 `tw-min-w-0\n // tw-overflow-hidden`,被约束后内容会按 input flex-1 收缩,不会溢出。\n // 消费方需要撑满显式加 `tw-w-full` className,需要更窄/更宽直接覆盖宽度。\n 'ald-input-number-group tw-inline-flex tw-min-w-0 tw-items-stretch',\n sizeClasses,\n radiusClasses,\n mergedDisabled && 'ald-input-number-disabled',\n className,\n )}\n style={style}\n >\n {addonBefore && (\n <span\n className={cn(\n 'ald-input-number-addon tw-flex tw-shrink-0 tw-items-center tw-border tw-border-r-0 tw-border-solid tw-border-[var(--border-neutral-subtle)] tw-bg-[var(--background-neutral-subtle)] tw-px-3 tw-text-[var(--content-secondary)]',\n size === 'large' && 'tw-rounded-l-[8px]',\n size === 'small' && 'tw-rounded-l-[4px]',\n size !== 'large' && size !== 'small' && 'tw-rounded-l-[6px]',\n )}\n >\n {addonBefore}\n </span>\n )}\n {inputBox}\n {addonAfter && (\n <span\n className={cn(\n 'ald-input-number-addon tw-flex tw-shrink-0 tw-items-center tw-border tw-border-l-0 tw-border-solid tw-border-[var(--border-neutral-subtle)] tw-bg-[var(--background-neutral-subtle)] tw-px-3 tw-text-[var(--content-secondary)]',\n size === 'large' && 'tw-rounded-r-[8px]',\n size === 'small' && 'tw-rounded-r-[4px]',\n size !== 'large' && size !== 'small' && 'tw-rounded-r-[6px]',\n )}\n >\n {addonAfter}\n </span>\n )}\n </div>\n );\n}\n\nexport type { IInputNumberProps };\n"],"mappings":";;;;;;AAYA,SAAS,cAAc,OAAmD;AACxE,QAAO,OAAO,KAAK,MAAM,CAAC,QACvB,WAAW,QAAQ;AAClB,MAAI,IAAI,WAAW,QAAQ,CACzB,WAAU,OAAO,MAAM;AAEzB,SAAO;IAET,EAAE,CACH;;AAGH,SAAwB,YAAY,OAA0B;CAC5D,MAAM,EACJ,WACA,UAAU,gBACV,MAAM,YACN,QACA,OAAO,iBACP,cACA,MAAM,WACN,MAAM,UACN,OAAO,GACP,WACA,UACA,cACA,QACA,SACA,WACA,QACA,QACA,aACA,YACA,aACA,WACA,WAAW,MACX,WAAW,MACX,UAAU,UACV,OACA,IACA,eAAe,YACf,cAAc,cACZ;CAEJ,MAAM,cAAc,WAAW,YAAY;CAC3C,MAAM,OAAO,cAAc,eAAe;CAC1C,MAAM,WAAW,WAAW,gBAAgB;CAC5C,MAAM,iBAAiB,kBAAkB;CACzC,MAAM,uBAAuB,cAAc,MAAM;CAEjD,MAAM,eAAe,WAAW;CAChC,MAAM,CAAC,YAAY,iBAAiB,SAClC,gBAAgB,KACjB;CACD,MAAM,eAAe,eAAe,kBAAkB;CAEtD,MAAM,CAAC,UAAU,eAAe,SAC9B,iBAAiB,QAAQ,iBAAiB,SACtC,OAAO,aAAa,GACpB,GACL;CACD,MAAM,WAAW,OAAyB,KAAK;AAE/C,iBAAgB;AACd,MAAI,iBAAiB,QAAQ,iBAAiB,OAC5C,aAAY,OAAO,aAAa,CAAC;MAEjC,aA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CAAA;GAER;GACA,cACC,oBAAC,QAAD;IACE,WAAW,GACT,mOACA,SAAS,WAAW,sBACpB,SAAS,WAAW,sBACpB,SAAS,WAAW,SAAS,WAAW,qBACzC;cAEA;IACI,CAAA;GAEL"}
@@ -1,5 +1,5 @@
1
1
  /// <reference types="react" />
2
- export interface IInputNumberProps {
2
+ export interface IInputNumberProps extends React.AriaAttributes {
3
3
  addonBefore?: React.ReactNode;
4
4
  addonAfter?: React.ReactNode;
5
5
  autoFocus?: boolean;
@@ -42,6 +42,6 @@ export interface IInputNumberProps {
42
42
  onFocus?: React.FocusEventHandler<HTMLInputElement>;
43
43
  /** 透传到 InputNumber 根容器的 data-testid,用于自动化测试定位 */
44
44
  'data-testid'?: string;
45
- /** 透传到 InputNumber 根容器的 aria-label,用于可访问性与自动化测试定位 */
45
+ /** 透传到内部 input 元素的 aria-label,用于可访问性与自动化测试定位 */
46
46
  'aria-label'?: string;
47
47
  }
@@ -15,6 +15,7 @@ interface IProps<T> {
15
15
  hideBottomBtn?: {
16
16
  addRelation?: boolean;
17
17
  };
18
+ level?: number;
18
19
  }
19
- export default function LogicItem<T>({ value, addCondition, addRelation, changeRecordData, remove, changeRelation, renderCondition, onDragEnd, hoverId, setHoverId, isRoot, hideBottomBtn, }: IProps<T>): import("react/jsx-runtime").JSX.Element;
20
+ export default function LogicItem<T>({ value, addCondition, addRelation, changeRecordData, remove, changeRelation, renderCondition, onDragEnd, hoverId, setHoverId, isRoot, hideBottomBtn, level, }: IProps<T>): import("react/jsx-runtime").JSX.Element;
20
21
  export {};
@@ -15,7 +15,7 @@ import { DragPreviewImage, useDrag, useDrop } from "react-dnd";
15
15
  //#region src/LogicTree/components/LogicItem/index.tsx
16
16
  var dargPreviewImg = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAYAAACNiR0NAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAYSURBVHgB7cAxAQAAAMKg9U9tCU8oAPgYBlQAAX19SpgAAAAASUVORK5CYII=";
17
17
  var TWO = 2;
18
- function LogicItem({ value, addCondition, addRelation, changeRecordData, remove, changeRelation, renderCondition, onDragEnd, hoverId, setHoverId, isRoot = false, hideBottomBtn }) {
18
+ function LogicItem({ value, addCondition, addRelation, changeRecordData, remove, changeRelation, renderCondition, onDragEnd, hoverId, setHoverId, isRoot = false, hideBottomBtn, level = 1 }) {
19
19
  const [isHoverDragBox, setIsHoverDragBox] = useState(false);
20
20
  const [firstNodeHight, setFirstNodeHight] = useState(0);
21
21
  const [lastNodeHight, setLastNodeHight] = useState(0);
@@ -136,6 +136,10 @@ function LogicItem({ value, addCondition, addRelation, changeRecordData, remove,
136
136
  const { nodes, logicType } = value;
137
137
  const verticalLineHeight = nodes.length > 1 ? `calc(100% - ${firstNodeHight / TWO}px - ${lastNodeHight / TWO}px - 42px)` : `30px`;
138
138
  return /* @__PURE__ */ jsxs("div", {
139
+ role: "treeitem",
140
+ "aria-label": `${logicType} group`,
141
+ "aria-level": level,
142
+ "aria-expanded": nodes.length > 0,
139
143
  className: cn("ald-logic-tree-logic-node", {
140
144
  "is-hover-drag-box": isHoverDragBox,
141
145
  "is-dragging": isDragging,
@@ -157,6 +161,7 @@ function LogicItem({ value, addCondition, addRelation, changeRecordData, remove,
157
161
  if (index === 0) heightRef = firstRef;
158
162
  else if (index === nodes.length - 1) heightRef = lastRef;
159
163
  return /* @__PURE__ */ jsxs("div", {
164
+ role: "group",
160
165
  className: "ald-logic-tree-node-wrap",
161
166
  ref: heightRef,
162
167
  children: [/* @__PURE__ */ jsx("div", { className: "ald-logic-tree-horizontal-line" }), /* @__PURE__ */ jsx(LogicItem, {
@@ -169,7 +174,8 @@ function LogicItem({ value, addCondition, addRelation, changeRecordData, remove,
169
174
  changeRecordData,
170
175
  hoverId,
171
176
  setHoverId,
172
- onDragEnd
177
+ onDragEnd,
178
+ level: level + 1
173
179
  }, node.id)]
174
180
  }, node.id);
175
181
  }),
@@ -219,6 +225,7 @@ function LogicItem({ value, addCondition, addRelation, changeRecordData, remove,
219
225
  })
220
226
  }),
221
227
  /* @__PURE__ */ jsx(Select_default, {
228
+ "aria-label": `${logicType} relation`,
222
229
  options: logicOptions,
223
230
  className: cn("ald-logic-tree-select-relation", { "ald-logic-tree-select-relation-en": isEn }),
224
231
  size: "small",
@@ -237,6 +244,9 @@ function LogicItem({ value, addCondition, addRelation, changeRecordData, remove,
237
244
  connect: preview,
238
245
  src: dargPreviewImg
239
246
  }), /* @__PURE__ */ jsxs("div", {
247
+ role: "treeitem",
248
+ "aria-label": "Condition",
249
+ "aria-level": level,
240
250
  className: cn("ald-logic-tree-record-node", {
241
251
  "is-hover-drag-box": isHoverDragBox,
242
252
  "is-dragging": isDragging,
@@ -284,6 +294,7 @@ function LogicItem({ value, addCondition, addRelation, changeRecordData, remove,
284
294
  children: renderCondition(value.data, { changeData: onChangeRecordData }, value.id)
285
295
  }),
286
296
  /* @__PURE__ */ jsx(IconButton, {
297
+ "aria-label": "Remove condition",
287
298
  icon: /* @__PURE__ */ jsx(Memo$2, { size: 16 }),
288
299
  size: "small",
289
300
  onClick: onRemove
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../../../../src/LogicTree/components/LogicItem/index.tsx"],"sourcesContent":["import { cn } from '../../../lib/utils';\nimport _ from 'lodash';\nimport React, {\n useCallback,\n useContext,\n useEffect,\n useRef,\n useState,\n} from 'react';\nimport { DragPreviewImage, useDrag, useDrop } from 'react-dnd';\nimport { EPutPosition, TRenderCondition } from '../..';\nimport DragLightLine from '../../../Icon/components/DragLightLine';\nimport PlusIcon from '../../../Icon/components/SignLightLine';\nimport TrashLightLine from '../../../Icon/components/TrashLightLine';\nimport IconButton from '../../../IconButton';\nimport Select from '../../../Select';\nimport TextLink from '../../../TextLink';\nimport {\n ELangType,\n LocaleContext,\n getTranslator,\n} from '../../../locale/default';\nimport { ELogicType, ENodeType, TNode } from '../../type';\n\nconst dargPreviewImg =\n 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAYAAACNiR0NAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAYSURBVHgB7cAxAQAAAMKg9U9tCU8oAPgYBlQAAX19SpgAAAAASUVORK5CYII=';\n\ninterface IProps<T> {\n value: TNode<T>;\n addCondition: (id: string) => void;\n addRelation: (id: string) => void;\n remove: (id: string) => void;\n changeRecordData: (id: string, data: T) => void;\n changeRelation: (id: string, logicType: ELogicType) => void;\n renderCondition: TRenderCondition<T>;\n onDragEnd: (\n dragId: string,\n hoverId: string,\n dropPosition: EPutPosition,\n ) => void;\n hoverId: string;\n setHoverId: (id: string) => void;\n isRoot?: boolean;\n hideBottomBtn?: {\n addRelation?: boolean;\n };\n}\n\nconst TWO = 2;\n\nexport default function LogicItem<T>({\n value,\n addCondition,\n addRelation,\n changeRecordData,\n remove,\n changeRelation,\n renderCondition,\n onDragEnd,\n hoverId,\n setHoverId,\n isRoot = false,\n hideBottomBtn,\n}: IProps<T>) {\n const [isHoverDragBox, setIsHoverDragBox] = useState(false);\n const [firstNodeHight, setFirstNodeHight] = useState(0);\n const [lastNodeHight, setLastNodeHight] = useState(0);\n const [dropPosition, setDropPosition] = useState<EPutPosition>();\n\n const { locale } = useContext(LocaleContext);\n const t = getTranslator(locale);\n\n const logicOptions = [\n {\n value: ELogicType.AND,\n label: t.LogicTree.select.and,\n },\n {\n value: ELogicType.OR,\n label: t.LogicTree.select.or,\n },\n ];\n\n const { type } = value;\n\n const ref = useRef<HTMLDivElement>(null);\n const firstResizeObserverRef = useRef<ResizeObserver | null>(null);\n const lastResizeObserverRef = useRef<ResizeObserver | null>(null);\n\n const [{ isDragging }, drag, preview] = useDrag({\n type: 'LOGIC_ITEM',\n item: { id: value.id },\n collect: (monitor) => ({\n isDragging: monitor.isDragging(),\n }),\n canDrag: !isRoot && isHoverDragBox,\n });\n\n const [{ isOver, canDrop }, drop] = useDrop({\n accept: 'LOGIC_ITEM',\n hover(item: { id: string }, monitor) {\n if (!ref.current) {\n return;\n }\n const dragId = item.id;\n const hoverId = value.id;\n\n if (dragId === hoverId) {\n return;\n }\n // 检查是否为最顶层的放置目标\n if (monitor.didDrop()) {\n return;\n }\n\n // 获取鼠标位置和目标元素位置\n const hoverBoundingRect = ref.current.getBoundingClientRect();\n const hoverMiddleY =\n (hoverBoundingRect.bottom - hoverBoundingRect.top) / 2;\n const clientOffset = monitor.getClientOffset();\n if (clientOffset) {\n const hoverClientY = clientOffset.y - hoverBoundingRect.top;\n\n const dropPosition =\n hoverClientY < hoverMiddleY ? EPutPosition.TOP : EPutPosition.BOTTOM;\n\n setDropPosition(dropPosition);\n } else setDropPosition(undefined);\n },\n drop(item: { id: string }, monitor) {\n if (!ref.current) {\n return;\n }\n const dragId = item.id;\n const hoverId = value.id;\n\n if (dragId === hoverId) {\n return;\n }\n // 检查是否为最顶层的放置目标\n if (monitor.didDrop()) {\n return;\n }\n\n // 获取鼠标位置和目标元素位置\n const hoverBoundingRect = ref.current.getBoundingClientRect();\n const hoverMiddleY =\n (hoverBoundingRect.bottom - hoverBoundingRect.top) / 2;\n const clientOffset = monitor.getClientOffset();\n if (clientOffset) {\n const hoverClientY = clientOffset.y - hoverBoundingRect.top;\n\n // 确定放置位置\n const dropPosition =\n hoverClientY < hoverMiddleY ? EPutPosition.TOP : EPutPosition.BOTTOM;\n\n onDragEnd(dragId, hoverId, dropPosition);\n }\n },\n collect: (monitor) => ({\n isOver: monitor.isOver({ shallow: true }),\n canDrop: monitor.canDrop(),\n }),\n });\n\n drag(drop(ref));\n\n const isDragOver = isOver && canDrop && !isRoot;\n\n const firstRef = useCallback((node: HTMLElement | null) => {\n if (firstResizeObserverRef.current) {\n firstResizeObserverRef.current.disconnect();\n firstResizeObserverRef.current = null;\n }\n\n if (!node) return;\n\n const resizeObserver = new ResizeObserver((entries) => {\n for (const entry of entries) {\n const newHeight = entry.contentRect.height;\n if (newHeight > 0) {\n setFirstNodeHight(newHeight);\n }\n }\n });\n resizeObserver.observe(node);\n firstResizeObserverRef.current = resizeObserver;\n }, []);\n\n const lastRef = useCallback((node: HTMLElement | null) => {\n if (lastResizeObserverRef.current) {\n lastResizeObserverRef.current.disconnect();\n lastResizeObserverRef.current = null;\n }\n\n if (!node) return;\n\n const resizeObserver = new ResizeObserver((entries) => {\n for (const entry of entries) {\n const newHeight = entry.contentRect.height;\n if (newHeight > 0) {\n setLastNodeHight(newHeight);\n }\n }\n });\n resizeObserver.observe(node);\n lastResizeObserverRef.current = resizeObserver;\n }, []);\n\n const onAddCondition = () => {\n const { id } = value;\n addCondition(id);\n };\n\n const onAddRelation = () => {\n const { id } = value;\n addRelation(id);\n };\n\n const onRemove = () => {\n const { id } = value;\n remove(id);\n };\n\n const onChangeRelation = (logicType: ELogicType) => {\n const { id } = value;\n changeRelation(id, logicType);\n };\n\n const onChangeRecordData = (data: T) => {\n const { id } = value;\n changeRecordData(id, data);\n };\n\n useEffect(() => {\n return () => {\n if (firstResizeObserverRef.current) {\n firstResizeObserverRef.current.disconnect();\n firstResizeObserverRef.current = null;\n }\n if (lastResizeObserverRef.current) {\n lastResizeObserverRef.current.disconnect();\n lastResizeObserverRef.current = null;\n }\n };\n }, []);\n\n const isEn = locale === ELangType.EN;\n\n if (type === ENodeType.LOGIC) {\n const { nodes, logicType } = value;\n const verticalLineHeight =\n nodes.length > 1\n ? `calc(100% - ${firstNodeHight / TWO}px - ${\n lastNodeHight / TWO\n }px - 42px)`\n : `30px`;\n\n return (\n <div\n className={cn('ald-logic-tree-logic-node', {\n 'is-hover-drag-box': isHoverDragBox,\n 'is-dragging': isDragging,\n 'is-hover-top': isDragOver && dropPosition === EPutPosition.TOP,\n 'is-hover-bottom': isDragOver && dropPosition === EPutPosition.BOTTOM,\n })}\n onMouseMove={(e) => {\n e.stopPropagation();\n setHoverId(value.id);\n }}\n onMouseOut={(e) => {\n e.stopPropagation();\n setHoverId('');\n }}\n ref={ref}\n >\n {_.map(nodes, (node, index) => {\n let heightRef = null;\n if (index === 0) {\n heightRef = firstRef;\n } else if (index === nodes.length - 1) {\n heightRef = lastRef;\n }\n\n return (\n <div\n className=\"ald-logic-tree-node-wrap\"\n key={node.id}\n ref={heightRef}\n >\n <div className=\"ald-logic-tree-horizontal-line\" />\n <LogicItem\n key={node.id}\n value={node}\n addCondition={addCondition}\n addRelation={addRelation}\n remove={remove}\n changeRelation={changeRelation}\n renderCondition={renderCondition}\n changeRecordData={changeRecordData}\n hoverId={hoverId}\n setHoverId={setHoverId}\n onDragEnd={onDragEnd}\n />\n </div>\n );\n })}\n <div className=\"ald-logic-tree-operation\">\n <div className=\"ald-logic-tree-left-bottom-dash-line\" />\n <TextLink icon={<PlusIcon size={24} />} onClick={onAddCondition}>\n {t.LogicTree.btn.addCondition}\n </TextLink>\n {!hideBottomBtn?.addRelation && (\n <TextLink icon={<PlusIcon size={24} />} onClick={onAddRelation}>\n {t.LogicTree.btn.addRelation}\n </TextLink>\n )}\n </div>\n {!!_.size(nodes) && (\n <div\n className=\"ald-logic-tree-logic-vertical-line\"\n style={{\n height: verticalLineHeight,\n top: `${firstNodeHight / TWO + 4}px`,\n }}\n />\n )}\n {!isRoot && (hoverId === value.id || isDragging) && (\n <div\n className=\"ald-logic-tree-node-drag-icon-wrapper\"\n onMouseMove={(e) => {\n e.stopPropagation();\n setIsHoverDragBox(true);\n setHoverId(value.id);\n }}\n onMouseOut={(e) => {\n e.stopPropagation();\n setIsHoverDragBox(false);\n }}\n >\n <DragLightLine\n onMouseMove={(e) => {\n e.stopPropagation();\n setIsHoverDragBox(true);\n setHoverId(value.id);\n }}\n size={16}\n color=\"var(--content-secondary)\"\n className=\"ald-logic-tree-node-drag-icon\"\n />\n </div>\n )}\n\n <Select\n options={logicOptions}\n className={cn('ald-logic-tree-select-relation', {\n 'ald-logic-tree-select-relation-en': isEn,\n })}\n size=\"small\"\n popupMatchSelectWidth={false}\n value={logicType}\n onChange={onChangeRelation}\n />\n <DragPreviewImage connect={preview} src={dargPreviewImg} />\n </div>\n );\n }\n\n return (\n <>\n <DragPreviewImage connect={preview} src={dargPreviewImg} />\n <div\n className={cn('ald-logic-tree-record-node', {\n 'is-hover-drag-box': isHoverDragBox,\n 'is-dragging': isDragging,\n 'is-hover-top': isDragOver && dropPosition === EPutPosition.TOP,\n 'is-hover-bottom': isDragOver && dropPosition === EPutPosition.BOTTOM,\n })}\n ref={ref}\n onMouseMove={(e) => {\n e.stopPropagation();\n setHoverId(value.id);\n }}\n onMouseOut={(e) => {\n e.stopPropagation();\n setHoverId('');\n }}\n >\n <div\n className=\"ald-logic-tree-node-drag-icon-preview\"\n ref={preview}\n ></div>\n {(hoverId === value.id || isDragging) && (\n <div\n className=\"ald-logic-tree-record-node-drag-icon-wrapper\"\n onMouseMove={(e) => {\n e.stopPropagation();\n setIsHoverDragBox(true);\n setHoverId(value.id);\n }}\n onMouseOut={(e) => {\n e.stopPropagation();\n setIsHoverDragBox(false);\n }}\n >\n <DragLightLine\n onMouseMove={(e) => {\n e.stopPropagation();\n setIsHoverDragBox(true);\n setHoverId(value.id);\n }}\n size={16}\n color=\"var(--content-secondary)\"\n className=\"ald-logic-tree-record-node-drag-icon\"\n />\n </div>\n )}\n\n <div className=\"ald-logic-tree-render-condition-wrap\">\n {renderCondition(\n value.data,\n { changeData: onChangeRecordData },\n value.id,\n )}\n </div>\n <IconButton\n icon={<TrashLightLine size={16} />}\n size={'small'}\n onClick={onRemove}\n />\n </div>\n </>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;AAwBA,IAAM,iBACJ;AAuBF,IAAM,MAAM;AAEZ,SAAwB,UAAa,EACnC,OACA,cACA,aACA,kBACA,QACA,gBACA,iBACA,WACA,SACA,YACA,SAAS,OACT,iBACY;CACZ,MAAM,CAAC,gBAAgB,qBAAqB,SAAS,MAAM;CAC3D,MAAM,CAAC,gBAAgB,qBAAqB,SAAS,EAAE;CACvD,MAAM,CAAC,eAAe,oBAAoB,SAAS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MAAM;AAClB,KAAE,iBAAiB;AACnB,cAAW,MAAM,GAAG;;EAEtB,aAAa,MAAM;AACjB,KAAE,iBAAiB;AACnB,cAAW,GAAG;;YAdlB;GAiBE,oBAAC,OAAD;IACE,WAAU;IACV,KAAK;IACA,CAAA;IACL,YAAY,MAAM,MAAM,eACxB,oBAAC,OAAD;IACE,WAAU;IACV,cAAc,MAAM;AAClB,OAAE,iBAAiB;AACnB,uBAAkB,KAAK;AACvB,gBAAW,MAAM,GAAG;;IAEtB,aAAa,MAAM;AACjB,OAAE,iBAAiB;AACnB,uBAAkB,MAAM;;cAG1B,oBAAC,MAAD;KACE,cAAc,MAAM;AAClB,QAAE,iBAAiB;AACnB,wBAAkB,KAAK;AACvB,iBAAW,MAAM,GAAG;;KAEtB,MAAM;KACN,OAAM;KACN,WAAU;KACV,CAAA;IACE,CAAA;GAGR,oBAAC,OAAD;IAAK,WAAU;cACZ,gBACC,MAAM,MACN,EAAE,YAAY,oBAAoB,EAClC,MAAM,GACP;IACG,CAAA;GACN,oBAAC,YAAD;IACE,MAAM,oBAAC,QAAD,EAAgB,MAAM,IAAM,CAAA;IAClC,MAAM;IACN,SAAS;IACT,CAAA;GACE;IACL,EAAA,CAAA"}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../../../src/LogicTree/components/LogicItem/index.tsx"],"sourcesContent":["import { cn } from '../../../lib/utils';\nimport _ from 'lodash';\nimport React, {\n useCallback,\n useContext,\n useEffect,\n useRef,\n useState,\n} from 'react';\nimport { DragPreviewImage, useDrag, useDrop } from 'react-dnd';\nimport { EPutPosition, TRenderCondition } from '../..';\nimport DragLightLine from '../../../Icon/components/DragLightLine';\nimport PlusIcon from '../../../Icon/components/SignLightLine';\nimport TrashLightLine from '../../../Icon/components/TrashLightLine';\nimport IconButton from '../../../IconButton';\nimport Select from '../../../Select';\nimport TextLink from '../../../TextLink';\nimport {\n ELangType,\n LocaleContext,\n getTranslator,\n} from '../../../locale/default';\nimport { ELogicType, ENodeType, TNode } from '../../type';\n\nconst dargPreviewImg =\n 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAYAAACNiR0NAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAYSURBVHgB7cAxAQAAAMKg9U9tCU8oAPgYBlQAAX19SpgAAAAASUVORK5CYII=';\n\ninterface IProps<T> {\n value: TNode<T>;\n addCondition: (id: string) => void;\n addRelation: (id: string) => void;\n remove: (id: string) => void;\n changeRecordData: (id: string, data: T) => void;\n changeRelation: (id: string, logicType: ELogicType) => void;\n renderCondition: TRenderCondition<T>;\n onDragEnd: (\n dragId: string,\n hoverId: string,\n dropPosition: EPutPosition,\n ) => void;\n hoverId: string;\n setHoverId: (id: string) => void;\n isRoot?: boolean;\n hideBottomBtn?: {\n addRelation?: boolean;\n };\n level?: number;\n}\n\nconst TWO = 2;\n\nexport default function LogicItem<T>({\n value,\n addCondition,\n addRelation,\n changeRecordData,\n remove,\n changeRelation,\n renderCondition,\n onDragEnd,\n hoverId,\n setHoverId,\n isRoot = false,\n hideBottomBtn,\n level = 1,\n}: IProps<T>) {\n const [isHoverDragBox, setIsHoverDragBox] = useState(false);\n const [firstNodeHight, setFirstNodeHight] = useState(0);\n const [lastNodeHight, setLastNodeHight] = useState(0);\n const [dropPosition, setDropPosition] = useState<EPutPosition>();\n\n const { locale } = useContext(LocaleContext);\n const t = getTranslator(locale);\n\n const logicOptions = [\n {\n value: ELogicType.AND,\n label: t.LogicTree.select.and,\n },\n {\n value: ELogicType.OR,\n label: t.LogicTree.select.or,\n },\n ];\n\n const { type } = value;\n\n const ref = useRef<HTMLDivElement>(null);\n const firstResizeObserverRef = useRef<ResizeObserver | null>(null);\n const lastResizeObserverRef = useRef<ResizeObserver | null>(null);\n\n const [{ isDragging }, drag, preview] = useDrag({\n type: 'LOGIC_ITEM',\n item: { id: value.id },\n collect: (monitor) => ({\n isDragging: monitor.isDragging(),\n }),\n canDrag: !isRoot && isHoverDragBox,\n });\n\n const [{ isOver, canDrop }, drop] = useDrop({\n accept: 'LOGIC_ITEM',\n hover(item: { id: string }, monitor) {\n if (!ref.current) {\n return;\n }\n const dragId = item.id;\n const hoverId = value.id;\n\n if (dragId === hoverId) {\n return;\n }\n // 检查是否为最顶层的放置目标\n if (monitor.didDrop()) {\n return;\n }\n\n // 获取鼠标位置和目标元素位置\n const hoverBoundingRect = ref.current.getBoundingClientRect();\n const hoverMiddleY =\n (hoverBoundingRect.bottom - hoverBoundingRect.top) / 2;\n const clientOffset = monitor.getClientOffset();\n if (clientOffset) {\n const hoverClientY = clientOffset.y - hoverBoundingRect.top;\n\n const dropPosition =\n hoverClientY < hoverMiddleY ? EPutPosition.TOP : EPutPosition.BOTTOM;\n\n setDropPosition(dropPosition);\n } else setDropPosition(undefined);\n },\n drop(item: { id: string }, monitor) {\n if (!ref.current) {\n return;\n }\n const dragId = item.id;\n const hoverId = value.id;\n\n if (dragId === hoverId) {\n return;\n }\n // 检查是否为最顶层的放置目标\n if (monitor.didDrop()) {\n return;\n }\n\n // 获取鼠标位置和目标元素位置\n const hoverBoundingRect = ref.current.getBoundingClientRect();\n const hoverMiddleY =\n (hoverBoundingRect.bottom - hoverBoundingRect.top) / 2;\n const clientOffset = monitor.getClientOffset();\n if (clientOffset) {\n const hoverClientY = clientOffset.y - hoverBoundingRect.top;\n\n // 确定放置位置\n const dropPosition =\n hoverClientY < hoverMiddleY ? EPutPosition.TOP : EPutPosition.BOTTOM;\n\n onDragEnd(dragId, hoverId, dropPosition);\n }\n },\n collect: (monitor) => ({\n isOver: monitor.isOver({ shallow: true }),\n canDrop: monitor.canDrop(),\n }),\n });\n\n drag(drop(ref));\n\n const isDragOver = isOver && canDrop && !isRoot;\n\n const firstRef = useCallback((node: HTMLElement | null) => {\n if (firstResizeObserverRef.current) {\n firstResizeObserverRef.current.disconnect();\n firstResizeObserverRef.current = null;\n }\n\n if (!node) return;\n\n const resizeObserver = new ResizeObserver((entries) => {\n for (const entry of entries) {\n const newHeight = entry.contentRect.height;\n if (newHeight > 0) {\n setFirstNodeHight(newHeight);\n }\n }\n });\n resizeObserver.observe(node);\n firstResizeObserverRef.current = resizeObserver;\n }, []);\n\n const lastRef = useCallback((node: HTMLElement | null) => {\n if (lastResizeObserverRef.current) {\n lastResizeObserverRef.current.disconnect();\n lastResizeObserverRef.current = null;\n }\n\n if (!node) return;\n\n const resizeObserver = new ResizeObserver((entries) => {\n for (const entry of entries) {\n const newHeight = entry.contentRect.height;\n if (newHeight > 0) {\n setLastNodeHight(newHeight);\n }\n }\n });\n resizeObserver.observe(node);\n lastResizeObserverRef.current = resizeObserver;\n }, []);\n\n const onAddCondition = () => {\n const { id } = value;\n addCondition(id);\n };\n\n const onAddRelation = () => {\n const { id } = value;\n addRelation(id);\n };\n\n const onRemove = () => {\n const { id } = value;\n remove(id);\n };\n\n const onChangeRelation = (logicType: ELogicType) => {\n const { id } = value;\n changeRelation(id, logicType);\n };\n\n const onChangeRecordData = (data: T) => {\n const { id } = value;\n changeRecordData(id, data);\n };\n\n useEffect(() => {\n return () => {\n if (firstResizeObserverRef.current) {\n firstResizeObserverRef.current.disconnect();\n firstResizeObserverRef.current = null;\n }\n if (lastResizeObserverRef.current) {\n lastResizeObserverRef.current.disconnect();\n lastResizeObserverRef.current = null;\n }\n };\n }, []);\n\n const isEn = locale === ELangType.EN;\n\n if (type === ENodeType.LOGIC) {\n const { nodes, logicType } = value;\n const verticalLineHeight =\n nodes.length > 1\n ? `calc(100% - ${firstNodeHight / TWO}px - ${\n lastNodeHight / TWO\n }px - 42px)`\n : `30px`;\n\n return (\n <div\n role=\"treeitem\"\n aria-label={`${logicType} group`}\n aria-level={level}\n aria-expanded={nodes.length > 0}\n className={cn('ald-logic-tree-logic-node', {\n 'is-hover-drag-box': isHoverDragBox,\n 'is-dragging': isDragging,\n 'is-hover-top': isDragOver && dropPosition === EPutPosition.TOP,\n 'is-hover-bottom': isDragOver && dropPosition === EPutPosition.BOTTOM,\n })}\n onMouseMove={(e) => {\n e.stopPropagation();\n setHoverId(value.id);\n }}\n onMouseOut={(e) => {\n e.stopPropagation();\n setHoverId('');\n }}\n ref={ref}\n >\n {_.map(nodes, (node, index) => {\n let heightRef = null;\n if (index === 0) {\n heightRef = firstRef;\n } else if (index === nodes.length - 1) {\n heightRef = lastRef;\n }\n\n return (\n <div\n role=\"group\"\n className=\"ald-logic-tree-node-wrap\"\n key={node.id}\n ref={heightRef}\n >\n <div className=\"ald-logic-tree-horizontal-line\" />\n <LogicItem\n key={node.id}\n value={node}\n addCondition={addCondition}\n addRelation={addRelation}\n remove={remove}\n changeRelation={changeRelation}\n renderCondition={renderCondition}\n changeRecordData={changeRecordData}\n hoverId={hoverId}\n setHoverId={setHoverId}\n onDragEnd={onDragEnd}\n level={level + 1}\n />\n </div>\n );\n })}\n <div className=\"ald-logic-tree-operation\">\n <div className=\"ald-logic-tree-left-bottom-dash-line\" />\n <TextLink icon={<PlusIcon size={24} />} onClick={onAddCondition}>\n {t.LogicTree.btn.addCondition}\n </TextLink>\n {!hideBottomBtn?.addRelation && (\n <TextLink icon={<PlusIcon size={24} />} onClick={onAddRelation}>\n {t.LogicTree.btn.addRelation}\n </TextLink>\n )}\n </div>\n {!!_.size(nodes) && (\n <div\n className=\"ald-logic-tree-logic-vertical-line\"\n style={{\n height: verticalLineHeight,\n top: `${firstNodeHight / TWO + 4}px`,\n }}\n />\n )}\n {!isRoot && (hoverId === value.id || isDragging) && (\n <div\n className=\"ald-logic-tree-node-drag-icon-wrapper\"\n onMouseMove={(e) => {\n e.stopPropagation();\n setIsHoverDragBox(true);\n setHoverId(value.id);\n }}\n onMouseOut={(e) => {\n e.stopPropagation();\n setIsHoverDragBox(false);\n }}\n >\n <DragLightLine\n onMouseMove={(e) => {\n e.stopPropagation();\n setIsHoverDragBox(true);\n setHoverId(value.id);\n }}\n size={16}\n color=\"var(--content-secondary)\"\n className=\"ald-logic-tree-node-drag-icon\"\n />\n </div>\n )}\n\n <Select\n aria-label={`${logicType} relation`}\n options={logicOptions}\n className={cn('ald-logic-tree-select-relation', {\n 'ald-logic-tree-select-relation-en': isEn,\n })}\n size=\"small\"\n popupMatchSelectWidth={false}\n value={logicType}\n onChange={onChangeRelation}\n />\n <DragPreviewImage connect={preview} src={dargPreviewImg} />\n </div>\n );\n }\n\n return (\n <>\n <DragPreviewImage connect={preview} src={dargPreviewImg} />\n <div\n role=\"treeitem\"\n aria-label=\"Condition\"\n aria-level={level}\n className={cn('ald-logic-tree-record-node', {\n 'is-hover-drag-box': isHoverDragBox,\n 'is-dragging': isDragging,\n 'is-hover-top': isDragOver && dropPosition === EPutPosition.TOP,\n 'is-hover-bottom': isDragOver && dropPosition === EPutPosition.BOTTOM,\n })}\n ref={ref}\n onMouseMove={(e) => {\n e.stopPropagation();\n setHoverId(value.id);\n }}\n onMouseOut={(e) => {\n e.stopPropagation();\n setHoverId('');\n }}\n >\n <div\n className=\"ald-logic-tree-node-drag-icon-preview\"\n ref={preview}\n ></div>\n {(hoverId === value.id || isDragging) && (\n <div\n className=\"ald-logic-tree-record-node-drag-icon-wrapper\"\n onMouseMove={(e) => {\n e.stopPropagation();\n setIsHoverDragBox(true);\n setHoverId(value.id);\n }}\n onMouseOut={(e) => {\n e.stopPropagation();\n setIsHoverDragBox(false);\n }}\n >\n <DragLightLine\n onMouseMove={(e) => {\n e.stopPropagation();\n setIsHoverDragBox(true);\n setHoverId(value.id);\n }}\n size={16}\n color=\"var(--content-secondary)\"\n className=\"ald-logic-tree-record-node-drag-icon\"\n />\n </div>\n )}\n\n <div className=\"ald-logic-tree-render-condition-wrap\">\n {renderCondition(\n value.data,\n { changeData: onChangeRecordData },\n value.id,\n )}\n </div>\n <IconButton\n aria-label=\"Remove condition\"\n icon={<TrashLightLine size={16} />}\n size={'small'}\n onClick={onRemove}\n />\n </div>\n </>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;AAwBA,IAAM,iBACJ;AAwBF,IAAM,MAAM;AAEZ,SAAwB,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P,UAAU;KACV,CAAA;IACF,oBAAC,kBAAD;KAAkB,SAAS;KAAS,KAAK;KAAkB,CAAA;IACvD;;;AAIV,QACE,qBAAA,UAAA,EAAA,UAAA,CACE,oBAAC,kBAAD;EAAkB,SAAS;EAAS,KAAK;EAAkB,CAAA,EAC3D,qBAAC,OAAD;EACE,MAAK;EACL,cAAW;EACX,cAAY;EACZ,WAAW,GAAG,8BAA8B;GAC1C,qBAAqB;GACrB,eAAe;GACf,gBAAgB,cAAc,iBAAiB,aAAa;GAC5D,mBAAmB,cAAc,iBAAiB,aAAa;GAChE,CAAC;EACG;EACL,cAAc,MAAM;AAClB,KAAE,iBAAiB;AACnB,cAAW,MAAM,GAAG;;EAEtB,aAAa,MAAM;AACjB,KAAE,iBAAiB;AACnB,cAAW,GAAG;;YAjBlB;GAoBE,oBAAC,OAAD;IACE,WAAU;IACV,KAAK;IACA,CAAA;IACL,YAAY,MAAM,MAAM,eACxB,oBAAC,OAAD;IACE,WAAU;IACV,cAAc,MAAM;AAClB,OAAE,iBAAiB;AACnB,uBAAkB,KAAK;AACvB,gBAAW,MAAM,GAAG;;IAEtB,aAAa,MAAM;AACjB,OAAE,iBAAiB;AACnB,uBAAkB,MAAM;;cAG1B,oBAAC,MAAD;KACE,cAAc,MAAM;AAClB,QAAE,iBAAiB;AACnB,wBAAkB,KAAK;AACvB,iBAAW,MAAM,GAAG;;KAEtB,MAAM;KACN,OAAM;KACN,WAAU;KACV,CAAA;IACE,CAAA;GAGR,oBAAC,OAAD;IAAK,WAAU;cACZ,gBACC,MAAM,MACN,EAAE,YAAY,oBAAoB,EAClC,MAAM,GACP;IACG,CAAA;GACN,oBAAC,YAAD;IACE,cAAW;IACX,MAAM,oBAAC,QAAD,EAAgB,MAAM,IAAM,CAAA;IAClC,MAAM;IACN,SAAS;IACT,CAAA;GACE;IACL,EAAA,CAAA"}
@@ -96,6 +96,8 @@ function LogicTree(props) {
96
96
  if (!innerValue) return null;
97
97
  return /* @__PURE__ */ jsx(LogicTreeDndProvider, { children: /* @__PURE__ */ jsx("div", {
98
98
  className: cn("ald-logic-tree-wrap", className),
99
+ role: "tree",
100
+ "aria-label": "Logic tree",
99
101
  children: /* @__PURE__ */ jsx(LogicItem, {
100
102
  value: innerValue,
101
103
  addCondition: onAddCondition,