@sheinx/base 3.8.0-beta.2 → 3.8.0-beta.21

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 (331) hide show
  1. package/cjs/absolute-list/absolute-list.js +2 -2
  2. package/cjs/alert/alert.d.ts.map +1 -1
  3. package/cjs/alert/alert.js +1 -1
  4. package/cjs/avatar/avatar.type.d.ts +5 -0
  5. package/cjs/avatar/avatar.type.d.ts.map +1 -1
  6. package/cjs/avatar/group.js +1 -1
  7. package/cjs/breadcrumb/breadcrumb-item.d.ts +11 -0
  8. package/cjs/breadcrumb/breadcrumb-item.d.ts.map +1 -0
  9. package/cjs/breadcrumb/breadcrumb-item.js +83 -0
  10. package/cjs/breadcrumb/breadcrumb.d.ts.map +1 -1
  11. package/cjs/breadcrumb/breadcrumb.js +34 -32
  12. package/cjs/breadcrumb/breadcrumb.type.d.ts +4 -0
  13. package/cjs/breadcrumb/breadcrumb.type.d.ts.map +1 -1
  14. package/cjs/cascader/cascader.d.ts.map +1 -1
  15. package/cjs/cascader/cascader.js +29 -7
  16. package/cjs/cascader/cascader.type.d.ts +8 -0
  17. package/cjs/cascader/cascader.type.d.ts.map +1 -1
  18. package/cjs/cascader/list.d.ts.map +1 -1
  19. package/cjs/cascader/list.js +0 -13
  20. package/cjs/cascader/node.d.ts.map +1 -1
  21. package/cjs/cascader/node.js +13 -11
  22. package/cjs/cascader/node.type.d.ts +0 -2
  23. package/cjs/cascader/node.type.d.ts.map +1 -1
  24. package/cjs/common/use-tip.js +1 -1
  25. package/cjs/config/locale/en_US.d.ts +3 -0
  26. package/cjs/config/locale/en_US.d.ts.map +1 -1
  27. package/cjs/config/locale/en_US.js +3 -0
  28. package/cjs/config/locale/zh-CN.d.ts +3 -0
  29. package/cjs/config/locale/zh-CN.d.ts.map +1 -1
  30. package/cjs/config/locale/zh-CN.js +3 -0
  31. package/cjs/date-picker/date-picker.d.ts.map +1 -1
  32. package/cjs/date-picker/date-picker.js +6 -2
  33. package/cjs/date-picker/date-picker.type.d.ts +3 -3
  34. package/cjs/date-picker/date-picker.type.d.ts.map +1 -1
  35. package/cjs/date-picker/day.d.ts.map +1 -1
  36. package/cjs/date-picker/day.js +3 -1
  37. package/cjs/date-picker/picker.d.ts.map +1 -1
  38. package/cjs/date-picker/picker.js +1 -0
  39. package/cjs/date-picker/picker.type.d.ts +2 -1
  40. package/cjs/date-picker/picker.type.d.ts.map +1 -1
  41. package/cjs/date-picker/result.d.ts +4 -4
  42. package/cjs/date-picker/result.d.ts.map +1 -1
  43. package/cjs/date-picker/result.js +1 -1
  44. package/cjs/date-picker/time.d.ts.map +1 -1
  45. package/cjs/date-picker/time.js +5 -2
  46. package/cjs/dropdown/Item.d.ts.map +1 -1
  47. package/cjs/dropdown/Item.js +3 -1
  48. package/cjs/form/form-field.d.ts.map +1 -1
  49. package/cjs/form/form-field.js +25 -2
  50. package/cjs/form/form-field.type.d.ts +12 -21
  51. package/cjs/form/form-field.type.d.ts.map +1 -1
  52. package/cjs/form/form-fieldset.d.ts.map +1 -1
  53. package/cjs/form/form-fieldset.js +12 -2
  54. package/cjs/form/form-fieldset.type.d.ts +35 -23
  55. package/cjs/form/form-fieldset.type.d.ts.map +1 -1
  56. package/cjs/form/form-flow.type.d.ts +11 -7
  57. package/cjs/form/form-flow.type.d.ts.map +1 -1
  58. package/cjs/form/form-item.d.ts.map +1 -1
  59. package/cjs/form/form-item.js +19 -6
  60. package/cjs/form/form-item.type.d.ts +1 -0
  61. package/cjs/form/form-item.type.d.ts.map +1 -1
  62. package/cjs/form/form.d.ts.map +1 -1
  63. package/cjs/form/form.js +2 -1
  64. package/cjs/form/form.type.d.ts +34 -24
  65. package/cjs/form/form.type.d.ts.map +1 -1
  66. package/cjs/form/form.type.js +4 -0
  67. package/cjs/form/index.d.ts +1 -1
  68. package/cjs/form/index.d.ts.map +1 -1
  69. package/cjs/input/input-password.d.ts.map +1 -1
  70. package/cjs/input/input-password.js +2 -1
  71. package/cjs/input/input.d.ts.map +1 -1
  72. package/cjs/input/input.js +1 -0
  73. package/cjs/input/input.type.d.ts +11 -5
  74. package/cjs/input/input.type.d.ts.map +1 -1
  75. package/cjs/input/simple-input.d.ts.map +1 -1
  76. package/cjs/input/simple-input.js +31 -5
  77. package/cjs/input/use-input-common.d.ts +1 -1
  78. package/cjs/input/use-input-common.d.ts.map +1 -1
  79. package/cjs/input/use-input-common.js +42 -19
  80. package/cjs/modal/modal-content.d.ts.map +1 -1
  81. package/cjs/modal/modal-content.js +31 -17
  82. package/cjs/select/list-columns.d.ts.map +1 -1
  83. package/cjs/select/list-columns.js +2 -1
  84. package/cjs/select/list.d.ts.map +1 -1
  85. package/cjs/select/list.js +2 -0
  86. package/cjs/select/result-more.d.ts.map +1 -1
  87. package/cjs/select/result-more.js +5 -15
  88. package/cjs/select/result-more.type.d.ts +0 -1
  89. package/cjs/select/result-more.type.d.ts.map +1 -1
  90. package/cjs/select/result.d.ts.map +1 -1
  91. package/cjs/select/result.js +24 -8
  92. package/cjs/select/result.type.d.ts +1 -0
  93. package/cjs/select/result.type.d.ts.map +1 -1
  94. package/cjs/select/select.d.ts.map +1 -1
  95. package/cjs/select/select.js +11 -2
  96. package/cjs/select/select.type.d.ts +9 -0
  97. package/cjs/select/select.type.d.ts.map +1 -1
  98. package/cjs/sticky/sticky.d.ts.map +1 -1
  99. package/cjs/sticky/sticky.js +104 -21
  100. package/cjs/sticky/sticky.type.d.ts +6 -0
  101. package/cjs/sticky/sticky.type.d.ts.map +1 -1
  102. package/cjs/table/table.d.ts.map +1 -1
  103. package/cjs/table/table.js +43 -21
  104. package/cjs/table/table.type.d.ts +88 -82
  105. package/cjs/table/table.type.d.ts.map +1 -1
  106. package/cjs/table/td.d.ts.map +1 -1
  107. package/cjs/table/td.js +5 -23
  108. package/cjs/table/tfoot.d.ts.map +1 -1
  109. package/cjs/table/tfoot.js +6 -2
  110. package/cjs/table/tfoot.type.d.ts +1 -0
  111. package/cjs/table/tfoot.type.d.ts.map +1 -1
  112. package/cjs/table/thead-filter.d.ts.map +1 -1
  113. package/cjs/table/thead-filter.js +17 -7
  114. package/cjs/table/thead.d.ts.map +1 -1
  115. package/cjs/table/thead.js +17 -1
  116. package/cjs/table/thead.type.d.ts +1 -1
  117. package/cjs/table/thead.type.d.ts.map +1 -1
  118. package/cjs/tabs/tabs-header.d.ts.map +1 -1
  119. package/cjs/tabs/tabs-header.js +18 -11
  120. package/cjs/textarea/simple-textarea.d.ts.map +1 -1
  121. package/cjs/textarea/simple-textarea.js +4 -1
  122. package/cjs/textarea/textarea.d.ts.map +1 -1
  123. package/cjs/textarea/textarea.js +2 -1
  124. package/cjs/tooltip/tooltip.type.d.ts +0 -6
  125. package/cjs/tooltip/tooltip.type.d.ts.map +1 -1
  126. package/cjs/transfer/transfer-list-item.d.ts.map +1 -1
  127. package/cjs/transfer/transfer-list-item.js +14 -3
  128. package/cjs/transfer/transfer-list-item.type.d.ts +2 -1
  129. package/cjs/transfer/transfer-list-item.type.d.ts.map +1 -1
  130. package/cjs/transfer/transfer-list.js +1 -1
  131. package/cjs/transfer/transfer.d.ts.map +1 -1
  132. package/cjs/transfer/transfer.js +12 -5
  133. package/cjs/transfer/transfer.type.d.ts +8 -1
  134. package/cjs/transfer/transfer.type.d.ts.map +1 -1
  135. package/cjs/tree/tree-content.d.ts.map +1 -1
  136. package/cjs/tree/tree-content.js +2 -0
  137. package/cjs/tree/tree-content.type.d.ts +1 -0
  138. package/cjs/tree/tree-content.type.d.ts.map +1 -1
  139. package/cjs/tree/tree-node.type.d.ts +1 -0
  140. package/cjs/tree/tree-node.type.d.ts.map +1 -1
  141. package/cjs/tree/tree-simple-node.d.ts.map +1 -1
  142. package/cjs/tree/tree-simple-node.js +3 -1
  143. package/cjs/tree/tree-virtual-node.d.ts.map +1 -1
  144. package/cjs/tree/tree-virtual-node.js +15 -2
  145. package/cjs/tree/tree-virtual.d.ts.map +1 -1
  146. package/cjs/tree/tree-virtual.js +9 -2
  147. package/cjs/tree/tree.type.d.ts +2 -1
  148. package/cjs/tree/tree.type.d.ts.map +1 -1
  149. package/cjs/tree-select/tree-select.d.ts.map +1 -1
  150. package/cjs/tree-select/tree-select.js +19 -4
  151. package/cjs/tree-select/tree-select.type.d.ts +1 -0
  152. package/cjs/tree-select/tree-select.type.d.ts.map +1 -1
  153. package/cjs/upload/button.d.ts.map +1 -1
  154. package/cjs/upload/button.js +0 -1
  155. package/cjs/upload/button.type.d.ts +1 -1
  156. package/cjs/upload/button.type.d.ts.map +1 -1
  157. package/cjs/upload/useInputClick.d.ts +1 -0
  158. package/cjs/upload/useInputClick.d.ts.map +1 -1
  159. package/cjs/upload/useInputClick.js +4 -0
  160. package/cjs/virtual-scroll/scroll-table.d.ts.map +1 -1
  161. package/cjs/virtual-scroll/scroll-table.js +6 -2
  162. package/cjs/virtual-scroll/virtual-scroll-list.d.ts.map +1 -1
  163. package/cjs/virtual-scroll/virtual-scroll-list.js +8 -2
  164. package/cjs/virtual-scroll/virtual-scroll-list.type.d.ts +1 -0
  165. package/cjs/virtual-scroll/virtual-scroll-list.type.d.ts.map +1 -1
  166. package/esm/absolute-list/absolute-list.js +2 -2
  167. package/esm/alert/alert.d.ts.map +1 -1
  168. package/esm/alert/alert.js +1 -1
  169. package/esm/avatar/avatar.type.d.ts +5 -0
  170. package/esm/avatar/avatar.type.d.ts.map +1 -1
  171. package/esm/avatar/group.js +1 -1
  172. package/esm/breadcrumb/breadcrumb-item.d.ts +11 -0
  173. package/esm/breadcrumb/breadcrumb-item.d.ts.map +1 -0
  174. package/esm/breadcrumb/breadcrumb-item.js +76 -0
  175. package/esm/breadcrumb/breadcrumb.d.ts.map +1 -1
  176. package/esm/breadcrumb/breadcrumb.js +34 -33
  177. package/esm/breadcrumb/breadcrumb.type.d.ts +4 -0
  178. package/esm/breadcrumb/breadcrumb.type.d.ts.map +1 -1
  179. package/esm/cascader/cascader.d.ts.map +1 -1
  180. package/esm/cascader/cascader.js +29 -7
  181. package/esm/cascader/cascader.type.d.ts +8 -0
  182. package/esm/cascader/cascader.type.d.ts.map +1 -1
  183. package/esm/cascader/list.d.ts.map +1 -1
  184. package/esm/cascader/list.js +1 -14
  185. package/esm/cascader/node.d.ts.map +1 -1
  186. package/esm/cascader/node.js +13 -11
  187. package/esm/cascader/node.type.d.ts +0 -2
  188. package/esm/cascader/node.type.d.ts.map +1 -1
  189. package/esm/common/use-tip.js +1 -1
  190. package/esm/config/locale/en_US.d.ts +3 -0
  191. package/esm/config/locale/en_US.d.ts.map +1 -1
  192. package/esm/config/locale/en_US.js +3 -0
  193. package/esm/config/locale/zh-CN.d.ts +3 -0
  194. package/esm/config/locale/zh-CN.d.ts.map +1 -1
  195. package/esm/config/locale/zh-CN.js +3 -0
  196. package/esm/date-picker/date-picker.d.ts.map +1 -1
  197. package/esm/date-picker/date-picker.js +6 -2
  198. package/esm/date-picker/date-picker.type.d.ts +3 -3
  199. package/esm/date-picker/date-picker.type.d.ts.map +1 -1
  200. package/esm/date-picker/day.d.ts.map +1 -1
  201. package/esm/date-picker/day.js +3 -1
  202. package/esm/date-picker/picker.d.ts.map +1 -1
  203. package/esm/date-picker/picker.js +1 -0
  204. package/esm/date-picker/picker.type.d.ts +2 -1
  205. package/esm/date-picker/picker.type.d.ts.map +1 -1
  206. package/esm/date-picker/result.d.ts +4 -4
  207. package/esm/date-picker/result.d.ts.map +1 -1
  208. package/esm/date-picker/result.js +1 -1
  209. package/esm/date-picker/time.d.ts.map +1 -1
  210. package/esm/date-picker/time.js +5 -2
  211. package/esm/dropdown/Item.d.ts.map +1 -1
  212. package/esm/dropdown/Item.js +3 -1
  213. package/esm/form/form-field.d.ts.map +1 -1
  214. package/esm/form/form-field.js +26 -3
  215. package/esm/form/form-field.type.d.ts +12 -21
  216. package/esm/form/form-field.type.d.ts.map +1 -1
  217. package/esm/form/form-fieldset.d.ts.map +1 -1
  218. package/esm/form/form-fieldset.js +12 -2
  219. package/esm/form/form-fieldset.type.d.ts +35 -23
  220. package/esm/form/form-fieldset.type.d.ts.map +1 -1
  221. package/esm/form/form-flow.type.d.ts +11 -7
  222. package/esm/form/form-flow.type.d.ts.map +1 -1
  223. package/esm/form/form-item.d.ts.map +1 -1
  224. package/esm/form/form-item.js +17 -6
  225. package/esm/form/form-item.type.d.ts +1 -0
  226. package/esm/form/form-item.type.d.ts.map +1 -1
  227. package/esm/form/form.d.ts.map +1 -1
  228. package/esm/form/form.js +2 -1
  229. package/esm/form/form.type.d.ts +34 -24
  230. package/esm/form/form.type.d.ts.map +1 -1
  231. package/esm/form/form.type.js +5 -0
  232. package/esm/form/index.d.ts +1 -1
  233. package/esm/form/index.d.ts.map +1 -1
  234. package/esm/input/input-password.d.ts.map +1 -1
  235. package/esm/input/input-password.js +2 -1
  236. package/esm/input/input.d.ts.map +1 -1
  237. package/esm/input/input.js +1 -0
  238. package/esm/input/input.type.d.ts +11 -5
  239. package/esm/input/input.type.d.ts.map +1 -1
  240. package/esm/input/simple-input.d.ts.map +1 -1
  241. package/esm/input/simple-input.js +32 -6
  242. package/esm/input/use-input-common.d.ts +1 -1
  243. package/esm/input/use-input-common.d.ts.map +1 -1
  244. package/esm/input/use-input-common.js +42 -19
  245. package/esm/modal/modal-content.d.ts.map +1 -1
  246. package/esm/modal/modal-content.js +31 -17
  247. package/esm/select/list-columns.d.ts.map +1 -1
  248. package/esm/select/list-columns.js +2 -1
  249. package/esm/select/list.d.ts.map +1 -1
  250. package/esm/select/list.js +2 -0
  251. package/esm/select/result-more.d.ts.map +1 -1
  252. package/esm/select/result-more.js +5 -15
  253. package/esm/select/result-more.type.d.ts +0 -1
  254. package/esm/select/result-more.type.d.ts.map +1 -1
  255. package/esm/select/result.d.ts.map +1 -1
  256. package/esm/select/result.js +24 -8
  257. package/esm/select/result.type.d.ts +1 -0
  258. package/esm/select/result.type.d.ts.map +1 -1
  259. package/esm/select/select.d.ts.map +1 -1
  260. package/esm/select/select.js +11 -2
  261. package/esm/select/select.type.d.ts +9 -0
  262. package/esm/select/select.type.d.ts.map +1 -1
  263. package/esm/sticky/sticky.d.ts.map +1 -1
  264. package/esm/sticky/sticky.js +104 -21
  265. package/esm/sticky/sticky.type.d.ts +6 -0
  266. package/esm/sticky/sticky.type.d.ts.map +1 -1
  267. package/esm/table/table.d.ts.map +1 -1
  268. package/esm/table/table.js +44 -22
  269. package/esm/table/table.type.d.ts +88 -82
  270. package/esm/table/table.type.d.ts.map +1 -1
  271. package/esm/table/td.d.ts.map +1 -1
  272. package/esm/table/td.js +4 -20
  273. package/esm/table/tfoot.d.ts.map +1 -1
  274. package/esm/table/tfoot.js +6 -2
  275. package/esm/table/tfoot.type.d.ts +1 -0
  276. package/esm/table/tfoot.type.d.ts.map +1 -1
  277. package/esm/table/thead-filter.d.ts.map +1 -1
  278. package/esm/table/thead-filter.js +17 -7
  279. package/esm/table/thead.d.ts.map +1 -1
  280. package/esm/table/thead.js +17 -1
  281. package/esm/table/thead.type.d.ts +1 -1
  282. package/esm/table/thead.type.d.ts.map +1 -1
  283. package/esm/tabs/tabs-header.d.ts.map +1 -1
  284. package/esm/tabs/tabs-header.js +18 -11
  285. package/esm/textarea/simple-textarea.d.ts.map +1 -1
  286. package/esm/textarea/simple-textarea.js +4 -1
  287. package/esm/textarea/textarea.d.ts.map +1 -1
  288. package/esm/textarea/textarea.js +2 -1
  289. package/esm/tooltip/tooltip.type.d.ts +0 -6
  290. package/esm/tooltip/tooltip.type.d.ts.map +1 -1
  291. package/esm/transfer/transfer-list-item.d.ts.map +1 -1
  292. package/esm/transfer/transfer-list-item.js +16 -5
  293. package/esm/transfer/transfer-list-item.type.d.ts +2 -1
  294. package/esm/transfer/transfer-list-item.type.d.ts.map +1 -1
  295. package/esm/transfer/transfer-list.js +1 -1
  296. package/esm/transfer/transfer.d.ts.map +1 -1
  297. package/esm/transfer/transfer.js +13 -6
  298. package/esm/transfer/transfer.type.d.ts +8 -1
  299. package/esm/transfer/transfer.type.d.ts.map +1 -1
  300. package/esm/tree/tree-content.d.ts.map +1 -1
  301. package/esm/tree/tree-content.js +2 -0
  302. package/esm/tree/tree-content.type.d.ts +1 -0
  303. package/esm/tree/tree-content.type.d.ts.map +1 -1
  304. package/esm/tree/tree-node.type.d.ts +1 -0
  305. package/esm/tree/tree-node.type.d.ts.map +1 -1
  306. package/esm/tree/tree-simple-node.d.ts.map +1 -1
  307. package/esm/tree/tree-simple-node.js +3 -1
  308. package/esm/tree/tree-virtual-node.d.ts.map +1 -1
  309. package/esm/tree/tree-virtual-node.js +15 -2
  310. package/esm/tree/tree-virtual.d.ts.map +1 -1
  311. package/esm/tree/tree-virtual.js +9 -2
  312. package/esm/tree/tree.type.d.ts +2 -1
  313. package/esm/tree/tree.type.d.ts.map +1 -1
  314. package/esm/tree-select/tree-select.d.ts.map +1 -1
  315. package/esm/tree-select/tree-select.js +19 -4
  316. package/esm/tree-select/tree-select.type.d.ts +1 -0
  317. package/esm/tree-select/tree-select.type.d.ts.map +1 -1
  318. package/esm/upload/button.d.ts.map +1 -1
  319. package/esm/upload/button.js +0 -1
  320. package/esm/upload/button.type.d.ts +1 -1
  321. package/esm/upload/button.type.d.ts.map +1 -1
  322. package/esm/upload/useInputClick.d.ts +1 -0
  323. package/esm/upload/useInputClick.d.ts.map +1 -1
  324. package/esm/upload/useInputClick.js +4 -0
  325. package/esm/virtual-scroll/scroll-table.d.ts.map +1 -1
  326. package/esm/virtual-scroll/scroll-table.js +6 -2
  327. package/esm/virtual-scroll/virtual-scroll-list.d.ts.map +1 -1
  328. package/esm/virtual-scroll/virtual-scroll-list.js +8 -2
  329. package/esm/virtual-scroll/virtual-scroll-list.type.d.ts +1 -0
  330. package/esm/virtual-scroll/virtual-scroll-list.type.d.ts.map +1 -1
  331. package/package.json +3 -3
@@ -1,5 +1,5 @@
1
1
  import React, { useContext, useMemo } from 'react';
2
- import { useFormConfig, useFormControl, usePersistFn, util, FieldsetContext } from '@sheinx/hooks';
2
+ import { useFormConfig, useFormControl, usePersistFn, util, FieldsetContext, FormItemContext, useFormSchema } from '@sheinx/hooks';
3
3
  import { FormFieldContext } from "./form-field-context";
4
4
  import { jsx as _jsx } from "react/jsx-runtime";
5
5
  var FormField = function FormField(props) {
@@ -18,7 +18,8 @@ var FormField = function FormField(props) {
18
18
  rules: props.rules,
19
19
  onError: props.onError,
20
20
  bind: props.bind,
21
- getValidateProps: getValidateProps
21
+ getValidateProps: getValidateProps,
22
+ clearToUndefined: props.clearToUndefined
22
23
  });
23
24
  var handleChange = usePersistFn(function (value) {
24
25
  for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
@@ -73,9 +74,31 @@ var FormField = function FormField(props) {
73
74
  } else {
74
75
  finalChildren = children;
75
76
  }
77
+ var formSchema = useFormSchema();
78
+ var _useContext3 = useContext(FormItemContext),
79
+ label = _useContext3.label;
80
+ var finalFieldId = formFieldId || fieldId || fieldsetPathId;
81
+
82
+ // 只有当 formConfig.formName 存在时才运行 schema 逻辑
83
+ if (formConfig.formName && formSchema && finalFieldId) {
84
+ var schemaFields = finalFieldId.split(separator) || [];
85
+ var schemaMeta = formSchema.buildSchemaFromComponent({
86
+ componentElement: finalChildren,
87
+ rules: props.rules,
88
+ label: label,
89
+ finalFieldId: finalFieldId,
90
+ separator: separator
91
+ });
92
+ schemaFields.forEach(function (field) {
93
+ formSchema.updateSchema({
94
+ path: util.getOriginField(field, formConfig.formName),
95
+ meta: schemaMeta
96
+ });
97
+ });
98
+ }
76
99
  return /*#__PURE__*/_jsx(FormFieldContext.Provider, {
77
100
  value: {
78
- fieldId: formFieldId || fieldId || fieldsetPathId,
101
+ fieldId: finalFieldId,
79
102
  separator: separator
80
103
  },
81
104
  children: finalChildren
@@ -12,38 +12,29 @@ export interface FieldControlProps<T> {
12
12
  export type FormFieldChildrenFunc<T> = (props: FieldControlProps<T>) => React.ReactElement;
13
13
  export interface FormFieldProps<T> extends Partial<BaseFormControlProps<T>> {
14
14
  /**
15
- * @en Form field, used with Form
16
- * @cn 表单字段, 配合 Form 使用
15
+ * @en The field name that binds to form data. Supports nested object access with dot notation (e.g., 'user.name') or array syntax (e.g. ['user', 'name']). Used to identify and manage specific form field data
16
+ * @cn 绑定到表单数据的字段名称。支持点表示法访问嵌套对象(如 'user.name')或数组语法(如 ['user', 'name'])。用于标识和管理特定的表单字段数据
17
17
  */
18
18
  name: string | string[];
19
19
  /**
20
- * @en If set to true, the form will not automatically delete the data after the component is uninstalled
21
- * @cn 设置为 true 组件卸载后表单不自动删除数据
20
+ * @en Controls whether to preserve field data when component unmounts. Set to true to keep data in form state after component removal. Useful for dynamic forms, conditional fields, or when temporarily hiding/showing fields while preserving their values
21
+ * @cn 控制组件卸载时是否保留字段数据。设置为 true 时,组件移除后在表单状态中保留数据。适用于动态表单、条件字段,或需要临时隐藏/显示字段但保留其值的场景
22
22
  */
23
23
  reserveAble?: boolean;
24
24
  /**
25
- * @en default Value
26
- * @cn 默认值
25
+ * @en The initial value for the field when form first renders. Only takes effect during component initialization and won't update if changed later. Commonly used to set initial state for new records or provide fallback values
26
+ * @cn 表单首次渲染时字段的初始值。仅在组件初始化时生效,后续更改不会更新。常用于为新记录设置初始状态或提供默认值
27
27
  */
28
28
  defaultValue?: T;
29
29
  /**
30
- * @en Validation rules, see [Rule](/components/rule) usage for details
31
- * @cn 校验规则 详见 [Rule](/components/rule)
30
+ * @en Array of validation rules to validate field value. Each rule can be a function, regular expression, or rule object. Supports built-in rules (required, email, etc.) and custom validation logic. See [Rule](/components/rule) for detailed configuration
31
+ * @cn 用于校验字段值的规则数组。每个规则可以是函数、正则表达式或规则对象。支持内置规则(必填、邮箱等)和自定义校验逻辑。详细配置参见 [Rule](/components/rule)
32
32
  * @override RuleItem[]
33
33
  */
34
34
  rules?: FormItemRule<any>;
35
35
  /**
36
- * @en React components that support value and onChange or function. The function object attribute is as follows:
37
- * value: The value obtained from the parent Form or Form.Block by name.
38
- * error: the error information of data validation. type is Error.
39
- * onChange: The callback when the value is changing.
40
- * disabled: inherit the disabled attribute of Form.
41
- *
42
- * @cn 支持 value 和 onChange 的 React 组件,或者函数,函数object属性如下
43
- * value: 根据 name 从上级 Form 或 Form.Block 获取的值
44
- * error:数据校验错误信息,类型为 Error
45
- * onChange: 值改变回调函数
46
- * disabled: 继承 Form 的 disabled 属性
36
+ * @en The form control to render. Can be either a React element with value/onChange props or a render function. When using render function, it receives an object with: value (current field value), onChange (value change handler), error (validation error), disabled (inherited from form), status (field status). Perfect for custom components, third-party controls, or complex input scenarios
37
+ * @cn 要渲染的表单控件。可以是具有 value/onChange 属性的 React 元素,或渲染函数。使用渲染函数时,会接收包含以下属性的对象:value(当前字段值)、onChange(值变更处理器)、error(校验错误)、disabled(继承自表单)、status(字段状态)。适用于自定义组件、第三方控件或复杂输入场景
47
38
  *
48
39
  * @override ((opts: object) => ReactNode) | ReactNode
49
40
  */
@@ -57,8 +48,8 @@ export interface FormFieldProps<T> extends Partial<BaseFormControlProps<T>> {
57
48
  */
58
49
  onChange?: (value: T, ...rest: any) => void;
59
50
  /**
60
- * @en rules validation callback
61
- * @cn rules 校验回调
51
+ * @en Callback function triggered when validation completes. Receives validation error (if any) as parameter. Useful for custom error handling, logging validation results, or triggering side effects based on validation state
52
+ * @cn 校验完成时触发的回调函数。接收校验错误(如果有)作为参数。适用于自定义错误处理、记录校验结果,或根据校验状态触发副作用
62
53
  */
63
54
  onError?: (error?: Error) => void;
64
55
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"form-field.type.d.ts","sourceRoot":"","sources":["form-field.type.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,oBAAoB,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAE/E,MAAM,WAAW,iBAAiB,CAAC,CAAC;IAClC,KAAK,CAAC,EAAE,CAAC,CAAC;IACV,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,CAAC,EAAE,GAAG,IAAI,EAAE,GAAG,KAAK,IAAI,CAAC;IAC5C,MAAM,CAAC,EA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AAK,IAAI,CAAC;IAClC;;OAEG;IACH,gBAAgB,CAAC,EAAE,MAAM,UAAU,CAAC;CACrC"}
@@ -1 +1 @@
1
- {"version":3,"file":"form-fieldset.d.ts","sourceRoot":"","sources":["form-fieldset.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAGzD,QAAA,MAAM,YAAY,yCA6FjB,CAAC;AAEF,eAAe,YAAY,CAAC"}
1
+ {"version":3,"file":"form-fieldset.d.ts","sourceRoot":"","sources":["form-fieldset.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAGzD,QAAA,MAAM,YAAY,yCAuGjB,CAAC;AAEF,eAAe,YAAY,CAAC"}
@@ -87,8 +87,13 @@ var FormFieldSet = function FormFieldSet(props) {
87
87
  },
88
88
  onInsert: function onInsert(val) {
89
89
  var oldValue = formFunc === null || formFunc === void 0 ? void 0 : formFunc.getValue(name);
90
+ var insertValue = val;
91
+ var valueTemplate = oldValue[i];
92
+ if (insertValue === undefined) {
93
+ insertValue = util.clearValue(util.deepClone(valueTemplate));
94
+ }
90
95
  var newValue = produce(oldValue, function (draft) {
91
- draft.splice(i, 0, val);
96
+ draft.splice(i, 0, insertValue);
92
97
  });
93
98
  _onChange(newValue);
94
99
  // context.ids.splice(i, 0, util.generateUUID());
@@ -96,8 +101,13 @@ var FormFieldSet = function FormFieldSet(props) {
96
101
  },
97
102
  onAppend: function onAppend(val) {
98
103
  var oldValue = formFunc === null || formFunc === void 0 ? void 0 : formFunc.getValue(name);
104
+ var insertValue = val;
105
+ var valueTemplate = oldValue[i];
106
+ if (insertValue === undefined) {
107
+ insertValue = util.clearValue(util.deepClone(valueTemplate));
108
+ }
99
109
  var newValue = produce(oldValue, function (draft) {
100
- draft.splice(i + 1, 0, val);
110
+ draft.splice(i + 1, 0, insertValue);
101
111
  });
102
112
  _onChange(newValue);
103
113
  // context.ids.splice(i + 1, 0, util.generateUUID());
@@ -17,37 +17,49 @@ export interface FormFieldSetChildrenFunc<ValueItem = any> {
17
17
  }
18
18
  export interface FormFieldSetProps<T> extends Partial<BaseFormFieldSetProps<T>> {
19
19
  /**
20
- * @en The name that accesses data from from
21
- * @cn Form 中存取数据的名称
20
+ * @en The field name that binds to form data for the fieldset. Used to identify and manage a group of related form fields or array data. Supports nested object access with dot notation (e.g., 'users', 'company.employees')
21
+ * @cn 绑定到表单数据的字段集名称。用于标识和管理一组相关的表单字段或数组数据。支持点表示法访问嵌套对象(如 'users'、'company.employees')
22
22
  */
23
23
  name: string;
24
24
  /**
25
- * @en When children type is not function, handle a set data type of object
26
- * When children type is function, handle a group of data type of array. options property:
27
- * list: all data of name.
28
- * value: a single piece of data for the value obtained by name.
29
- * onChange: a callback when the value is changing.
30
- * onRemove: a callback when a child component is removed.
31
- * index: the current index.
32
- * onInsert: Insert a piece of data before the current item.
33
- * onAppend: Insert a piece of data after the current item.
34
- *
35
- * @cn children 不为 function,用来处理 object 类型数据,children 内的 name 会拼接 FieldSet name,如 FieldSet name 为 'a', children 元素name 为 b,children 实际处理的数据为 a.b;
36
- * children function 时,用来处理数组数据。options 属性为
37
- * list: name 下的全部数据。
38
- * value: 根据name获取的值的单条数据。
39
- * onChange: 子组件数据改变回调。
40
- * onRemove: 子组件删除回调。
41
- * index: 当前项索引。
42
- * onInsert: 在当前项之前插入一条数据。
43
- * onAppend: 在当前项之后附加一条数据。
25
+ * @en Content to render within the fieldset. Supports two modes:
26
+ *
27
+ * **Object Mode** (React element): For managing nested object fields. Child field names are automatically prefixed with fieldset name. Perfect for grouping related form fields like address, contact info, or user profile sections.
28
+ *
29
+ * **Array Mode** (render function): For managing dynamic array data. The function receives an object with:
30
+ * - `list`: Complete array data for this fieldset
31
+ * - `value`: Current item data at this index
32
+ * - `index`: Current item index in the array
33
+ * - `error`: Validation errors for current item
34
+ * - `onChange`: Update current item data
35
+ * - `onInsert`: Insert new item before current position
36
+ * - `onAppend`: Insert new item after current position
37
+ * - `onRemove`: Remove current item from array
38
+ *
39
+ * Ideal for dynamic lists, repeatable form sections, or editable tables.
40
+ *
41
+ * @cn 在字段集内渲染的内容。支持两种模式:
42
+ *
43
+ * **对象模式**(React 元素):用于管理嵌套对象字段。子字段名称会自动加上字段集名称前缀。适用于分组相关表单字段,如地址、联系信息或用户资料等部分。
44
+ *
45
+ * **数组模式**(渲染函数):用于管理动态数组数据。函数接收包含以下属性的对象:
46
+ * - `list`:该字段集的完整数组数据
47
+ * - `value`:当前索引位置的数据项
48
+ * - `index`:当前数据项在数组中的索引
49
+ * - `error`:当前数据项的校验错误
50
+ * - `onChange`:更新当前数据项
51
+ * - `onInsert`:在当前位置之前插入新数据项
52
+ * - `onAppend`:在当前位置之后插入新数据项
53
+ * - `onRemove`:从数组中移除当前数据项
54
+ *
55
+ * 适用于动态列表、可重复表单部分或可编辑表格。
44
56
  *
45
57
  * @override ((opts: object) => ReactNode) |ReactNode
46
58
  */
47
59
  children: React.ReactNode | FormFieldSetChildrenFunc<T extends (infer ValueItem)[] ? ValueItem : never>;
48
60
  /**
49
- * @en Show content when data is empty. (only valid when children is function)
50
- * @cn 数据为空时展示内容。(仅在children为function时有效)
61
+ * @en Content to display when the array is empty. Only effective in array mode (when children is a function). The render function receives an `insert` callback to add the first item. Perfect for showing "Add first item" buttons, empty state messages, or onboarding guidance for dynamic lists
62
+ * @cn 数组为空时显示的内容。仅在数组模式下(children 为函数时)有效。渲染函数接收 `insert` 回调来添加第一个数据项。适用于显示“添加第一个项目”按钮、空状态提示或动态列表的引导信息
51
63
  */
52
64
  empty?: (insert: (val: any) => void) => React.ReactNode;
53
65
  }
@@ -1 +1 @@
1
- {"version":3,"file":"form-fieldset.type.d.ts","sourceRoot":"","sources":["form-fieldset.type.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AACtD,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,UAAU,mCAAmC;IAE3C,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,CAAC,SAAS,GAAG,GAAG;IACvD,CAAC,MAAM,EAAE;QACP,IAAI,EAAE,SAAS,EAAE,CAAC;QAClB,KAAK,EAAE,SAAS,CAAC;QACjB,QAAQ,EAAE,CAAC,KAAK,EAAE,SAAS,EAAE,OAAO,CAAC,EAAE,mCAAmC,KAAK,IAAI,CAAC;QACpF,QAAQ,EAAE,MAAM,IAAI,CAAC;QACrB,KAAK,EAAE,MAAM,CAAC;QACd,QAAQ,EAAE,CAAC,KAAK,EAAE,SAAS,KAAK,IAAI,CAAC;QACrC,QAAQ,EAAE,CAAC,KAAK,EAAE,SAAS,KAAK,IAAI,CAAC;QACrC,KAAK,EAAE,KAAK,EAAE,CAAC;KAChB,GAAG,KAAK,CAAC,SAAS,CAAC;CACrB;AAED,MAAM,WAAW,iBAAiB,CAAC,CAAC,CAAE,SAAQ,OAAO,CAAC,qBAAqB,CAAC,CAAC,CAAC,CAAC;IAC7E;;;OAGG;IACH,IAAI,EAAE,MAAM,CAAC;IACb;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAkCG;IACH,QAAQ,EACJ,KAAK,CAAC,SAAS,GACf,wBAAwB,CAAC,CAAC,SAAS,CAAC,MAAM,SAAS,CAAC,EAAE,GAAG,SAAS,GAAG,KAAK,CAAC,CAAC;IAChF;;;OAGG;IACH,KAAK,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,GAAG,KAAK,IAAI,KAAK,KAAK,CAAC,SAAS,CAAC;CACzD"}
@@ -1,26 +1,30 @@
1
1
  import React from 'react';
2
- import { UseFormFlowProps, FormDatum } from '@sheinx/hooks';
2
+ import { UseFormFlowProps, FormDatum as UiFormDatum } from '@sheinx/hooks';
3
3
  /**
4
4
  * @title FormFlow
5
5
  */
6
6
  export interface FormFlowProps extends UseFormFlowProps {
7
7
  /**
8
- * @en datum is the object of Datum.Form.
9
- * @cn datum Datum.Form 对象
8
+ * @en Render function that receives the form data manager (datum) and returns React nodes. The datum object provides methods to get/set form values dynamically. Perfect for creating form field dependencies, conditional rendering based on form state, or performing actions that need access to multiple form values
9
+ * @cn 渲染函数,接收表单数据管理器(datum)并返回 React 节点。datum 对象提供了动态获取/设置表单值的方法。适用于创建表单字段依赖关系、基于表单状态的条件渲染,或执行需要访问多个表单值的操作
10
10
  * @override (datum: FormDatum) => ReactNode
11
11
  */
12
12
  children: ((datum?: FormDatum) => React.ReactNode) | React.ReactNode;
13
13
  /**
14
- * @en Specifying which fields to change trigger the Flow update.
15
- * @cn names 为空时,Form 内任意值变化会触发 Flow 更新;不为空时,只监听指定字段变化
14
+ * @en Array of field names to watch for changes. When empty or undefined, any form value change triggers re-render. When specified, only changes to these fields trigger updates. Supports nested paths like "user.name" or "items[0].price". Use this to optimize performance by limiting unnecessary re-renders
15
+ * @cn 要监听变化的字段名称数组。为空或未定义时,表单内任意值变化都会触发重新渲染。指定后,仅这些字段的变化会触发更新。支持嵌套路径如 "user.name" "items[0].price"。通过限制不必要的重新渲染来优化性能
16
16
  */
17
17
  names?: string[];
18
18
  /**
19
- * @en Whether to strictly follow the watch rules.
20
- * @cn 严格根据 names 配置监听变化
19
+ * @en When true, uses memoization to prevent re-renders unless watched field values actually change. In strict mode, children only re-render when the specified names fields change their values (not just references). Useful for performance optimization in complex forms with expensive render operations
20
+ * @cn 设为 true 时,使用缓存机制防止重新渲染,除非监听的字段值真正发生变化。在严格模式下,只有指定的 names 字段值(而非仅引用)改变时才重新渲染子组件。适用于包含昂贵渲染操作的复杂表单的性能优化
21
21
  * @default false
22
22
  * @version 3.6.0
23
23
  */
24
24
  strict?: boolean;
25
25
  }
26
+ /**
27
+ * @title FormDatum
28
+ */
29
+ export type FormDatum = UiFormDatum;
26
30
  //# sourceMappingURL=form-flow.type.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"form-flow.type.d.ts","sourceRoot":"","sources":["form-flow.type.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,gBAAgB,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAE5D;;GAEG;AACH,MAAM,WAAW,aAAc,SAAQ,gBAAgB;IACrD;;;;OAIG;IACH,QAAQ,EAAE,CAAC,CAAC,KAAK,CAAC,EAAE,SAAS,KAAK,KAAK,CAAC,SAAS,CAAC,GAAG,KAAK,CAAC,SAAS,CAAC;IACrE;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;IAEjB;;;;;OAKG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB"}
1
+ {"version":3,"file":"form-flow.type.d.ts","sourceRoot":"","sources":["form-flow.type.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,gBAAgB,EAAE,SAAS,IAAI,WAAW,EAAE,MAAM,eAAe,CAAC;AAE3E;;GAEG;AACH,MAAM,WAAW,aAAc,SAAQ,gBAAgB;IACrD;;;;OAIG;IACH,QAAQ,EAAE,CAAC,CAAC,KAAK,CAAC,EAAE,SAAS,KAAK,KAAK,CAAC,SAAS,CAAC,GAAG,KAAK,CAAC,SAAS,CAAC;IACrE;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;IAEjB;;;;;OAKG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AAED;;GAEG;AACH,MAAM,MAAM,SAAS,GAAG,WAAW,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"form-item.d.ts","sourceRoot":"","sources":["form-item.tsx"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAmB,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAEvE,QAAA,MAAM,QAAQ,UAAW,aAAa,4CA6GrC,CAAC;AAEF,eAAe,QAAQ,CAAC"}
1
+ {"version":3,"file":"form-item.d.ts","sourceRoot":"","sources":["form-item.tsx"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAmB,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAEvE,QAAA,MAAM,QAAQ,UAAW,aAAa,4CAsHrC,CAAC;AAEF,eAAe,QAAQ,CAAC"}
@@ -7,7 +7,7 @@ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol"
7
7
  function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
8
8
  function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
9
9
  function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
10
- import React from 'react';
10
+ import React, { useRef } from 'react';
11
11
  import { useFormItem, util } from '@sheinx/hooks';
12
12
  import { useTooltipStyle } from '@sheinx/shineout-style';
13
13
  import classNames from 'classnames';
@@ -18,7 +18,7 @@ import { jsx as _jsx } from "react/jsx-runtime";
18
18
  import { Fragment as _Fragment } from "react/jsx-runtime";
19
19
  import { jsxs as _jsxs } from "react/jsx-runtime";
20
20
  var FormItem = function FormItem(props) {
21
- var _jssStyle$formItem;
21
+ var _jssStyle$formItem, _labelRef$current, _labelTipRef$current;
22
22
  var children = props.children,
23
23
  jssStyle = props.jssStyle,
24
24
  className = props.className,
@@ -29,7 +29,7 @@ var FormItem = function FormItem(props) {
29
29
  rest = _objectWithoutProperties(props, _excluded);
30
30
  var formItemClasses = jssStyle === null || jssStyle === void 0 || (_jssStyle$formItem = jssStyle.formItem) === null || _jssStyle$formItem === void 0 ? void 0 : _jssStyle$formItem.call(jssStyle);
31
31
  var _useFormItem = useFormItem(),
32
- Provider = _useFormItem.Provider,
32
+ FormItemContextProvider = _useFormItem.Provider,
33
33
  ProviderValue = _useFormItem.ProviderValue,
34
34
  labelConfig = _useFormItem.labelConfig,
35
35
  errors = _useFormItem.errors,
@@ -89,11 +89,19 @@ var FormItem = function FormItem(props) {
89
89
  children: label
90
90
  });
91
91
  };
92
+ var labelRef = useRef(null);
93
+ var labelTipRef = useRef(null);
94
+ var labelText = (_labelRef$current = labelRef.current) === null || _labelRef$current === void 0 ? void 0 : _labelRef$current.textContent;
95
+ if ((_labelTipRef$current = labelTipRef.current) !== null && _labelTipRef$current !== void 0 && _labelTipRef$current.textContent) {
96
+ var _labelTipRef$current2;
97
+ labelText += " (tip: ".concat((_labelTipRef$current2 = labelTipRef.current) === null || _labelTipRef$current2 === void 0 ? void 0 : _labelTipRef$current2.textContent, ")");
98
+ }
92
99
  return /*#__PURE__*/_jsxs("div", _objectSpread(_objectSpread({
93
- className: classNames(className, formItemClasses === null || formItemClasses === void 0 ? void 0 : formItemClasses.wrapper, _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty({}, formItemClasses === null || formItemClasses === void 0 ? void 0 : formItemClasses.wrapperLabelTop, labelAlign === 'top'), formItemClasses === null || formItemClasses === void 0 ? void 0 : formItemClasses.wrapperLabelVerticalMiddle, labelAlign !== 'top' && labelVerticalAlign === 'middle'), formItemClasses === null || formItemClasses === void 0 ? void 0 : formItemClasses.wrapperLabelVerticalBottom, labelAlign !== 'top' && labelVerticalAlign === 'bottom'), formItemClasses === null || formItemClasses === void 0 ? void 0 : formItemClasses.wrapperInline, inline), formItemClasses === null || formItemClasses === void 0 ? void 0 : formItemClasses.wrapperKeepHeight, keepErrorHeight), formItemClasses === null || formItemClasses === void 0 ? void 0 : formItemClasses.wrapperRequired, required), formItemClasses === null || formItemClasses === void 0 ? void 0 : formItemClasses.wrapperTip, showError || tip))
100
+ className: classNames(className, formItemClasses === null || formItemClasses === void 0 ? void 0 : formItemClasses.wrapper, _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty({}, formItemClasses === null || formItemClasses === void 0 ? void 0 : formItemClasses.wrapperLabelTop, labelAlign === 'top'), formItemClasses === null || formItemClasses === void 0 ? void 0 : formItemClasses.wrapperLabelVerticalMiddle, labelAlign !== 'top' && labelVerticalAlign === 'middle'), formItemClasses === null || formItemClasses === void 0 ? void 0 : formItemClasses.wrapperLabelVerticalBottom, labelAlign !== 'top' && labelVerticalAlign === 'bottom'), formItemClasses === null || formItemClasses === void 0 ? void 0 : formItemClasses.wrapperInline, inline), formItemClasses === null || formItemClasses === void 0 ? void 0 : formItemClasses.wrapperKeepHeight, keepErrorHeight), formItemClasses === null || formItemClasses === void 0 ? void 0 : formItemClasses.wrapperRequired, required), formItemClasses === null || formItemClasses === void 0 ? void 0 : formItemClasses.wrapperHideRequired, required === false), formItemClasses === null || formItemClasses === void 0 ? void 0 : formItemClasses.wrapperTip, showError || tip))
94
101
  }, attributes), {}, {
95
102
  style: style,
96
103
  children: [label !== undefined ? /*#__PURE__*/_jsx("div", {
104
+ ref: labelRef,
97
105
  className: classNames(formItemClasses === null || formItemClasses === void 0 ? void 0 : formItemClasses.label, _defineProperty(_defineProperty(_defineProperty({}, formItemClasses === null || formItemClasses === void 0 ? void 0 : formItemClasses.labelLeft, labelAlign === 'left'), formItemClasses === null || formItemClasses === void 0 ? void 0 : formItemClasses.labelWithColon, colon), formItemClasses === null || formItemClasses === void 0 ? void 0 : formItemClasses.labelWithTooltip, label && _typeof(label) === 'object' && 'tooltip' in label)),
98
106
  style: labelAlign !== 'top' || inline ? {
99
107
  width: labelWidth
@@ -104,10 +112,13 @@ var FormItem = function FormItem(props) {
104
112
  }, util.getDataAttribute({
105
113
  role: 'form-control'
106
114
  })), {}, {
107
- children: [/*#__PURE__*/_jsx(Provider, {
108
- value: ProviderValue,
115
+ children: [/*#__PURE__*/_jsx(FormItemContextProvider, {
116
+ value: _objectSpread(_objectSpread({}, ProviderValue), {}, {
117
+ label: labelText
118
+ }),
109
119
  children: children
110
120
  }), !!tip && (!showError || keepErrorBelow) && /*#__PURE__*/_jsx("div", {
121
+ ref: labelTipRef,
111
122
  className: formItemClasses === null || formItemClasses === void 0 ? void 0 : formItemClasses.tip,
112
123
  children: tip
113
124
  }), showError && /*#__PURE__*/_jsx("div", {
@@ -11,6 +11,7 @@ export interface FormItemClasses {
11
11
  wrapperLabelVerticalBottom: string;
12
12
  wrapperKeepHeight: string;
13
13
  wrapperRequired: string;
14
+ wrapperHideRequired: string;
14
15
  wrapperTip: string;
15
16
  label: string;
16
17
  labelWithColon: string;
@@ -1 +1 @@
1
- {"version":3,"file":"form-item.type.d.ts","sourceRoot":"","sources":["form-item.type.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAEvD,MAAM,WAAW,eAAe;IAC9B,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,eAAe,EAAE,MAAM,CAAC;IACxB,aAAa,EAAE,MAAM,CAAC;IACtB,0BAA0B,EAAE,MAAM,CAAC;IACnC,0BAA0B,EAAE,MAAM,CAAC;IACnC,iBAAiB,EAAE,MAAM,CAAC;IAC1B,eAAe,EAAE,MAAM,CAAC;IACxB,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,MAAM,CAAC;IACd,cAAc,EAAE,MAAM,CAAC;IACvB,gBAAgB,EAAE,MAAM,CAAC;IACzB,YAAY,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE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A,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAGhD,QAAA,MAAM,IAAI,wFA6HT,CAAC;AAEF,eAAe,IAAI,CAAC"}
1
+ {"version":3,"file":"form.d.ts","sourceRoot":"","sources":["form.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAGhD,QAAA,MAAM,IAAI,wFA8HT,CAAC;AAEF,eAAe,IAAI,CAAC"}
package/esm/form/form.js CHANGED
@@ -66,7 +66,8 @@ var Form = function Form(props) {
66
66
  validateFieldsWithValue: validateFieldsWithValue,
67
67
  validateFieldsWithError: formFunc.validateFields,
68
68
  set: formFunc.setValue,
69
- scrollToField: formFunc.scrollToField
69
+ scrollToField: formFunc.scrollToField,
70
+ getFormSchema: formFunc.getFormSchema
70
71
  });
71
72
  React.useEffect(function () {
72
73
  if (formRef) {
@@ -14,50 +14,54 @@ export interface FormValidateFn<FormValue> {
14
14
  */
15
15
  (fields?: string | string[]): Promise<FormValue>;
16
16
  }
17
+ /**
18
+ * FormValue 泛型表示表单数据的类型,通常是一个对象类型
19
+ * 例如:{ name: string, age: number, address: { city: string } }
20
+ */
17
21
  export interface FormRef<FormValue> {
18
22
  /**
19
- * @en return form value
20
- * @cn 返回表单的值
23
+ * @en Get form data. Returns the entire form data object (FormValue type) when no parameter is passed, returns the value of the specified field when a field path is passed. Field paths support dot notation and array indexes, such as 'user.name' (get nested object), 'list[0].id' (get array element). Commonly used to get form data for other operations
24
+ * @cn 获取表单数据。不传参数时返回整个表单的数据对象(FormValue 类型),传入字段路径时返回指定字段的值。字段路径支持点表示法和数组索引,如 'user.name'(获取嵌套对象)、'list[0].id'(获取数组元素)。常用于获取表单数据进行其他操作
21
25
  */
22
26
  getValue: (name?: string) => any | FormValue;
23
27
  /**
24
- * @en Validate form
25
- * @cn 校验表单
28
+ * @en Validate all fields in the entire form. Returns a Promise that resolves with the entire form data object (FormValue type) on successful validation, and rejects with error information on failure. Usually called before form submission to ensure all data validity
29
+ * @cn 校验整个表单的所有字段。返回一个 Promise,校验成功时 resolve 整个表单的数据对象(FormValue 类型),失败时 reject 错误信息。通常在提交表单前调用以确保所有数据的有效性
26
30
  */
27
31
  validate: () => Promise<any>;
28
32
  /**
29
- * @en Validation form fields
30
- * @cn 校验表单指定字段
33
+ * @en Validate specified form fields. The fields parameter is a field path, which can be a single path string or an array of paths. Field paths support: 'name' (top-level field), 'user.email' (nested object), 'list[0].name' (array element). Returns a Promise that resolves with the specified field data on success, and rejects with the first error encountered on failure. Suitable for step-by-step forms or partial validation scenarios
34
+ * @cn 校验指定的表单字段。fields 参数为字段路径,可以是单个路径字符串或路径数组。字段路径支持:'name'(顶层字段)、'user.email'(嵌套对象)、'list[0].name'(数组元素)。返回 Promise,成功时 resolve 指定字段的数据,失败时 reject 第一个遇到的错误。适用于分步表单或部分校验场景
31
35
  */
32
36
  validateFields: (fields: string | string[]) => Promise<any>;
33
37
  /**
34
- * @en Validation form fields and return the value
35
- * @cn 校验表单指定字段并返回值, 也可以通过 catch 获取报错信息
38
+ * @en Validate specified fields and always return form data. The fields parameter is a field path, validates all fields when not passed. Resolves with specified field data on success, rejects with a ValidationError object on failure, containing: values (form data) and errorFields (array containing name and errors information for each error field). Suitable for scenarios that need to get both form data and detailed error information
39
+ * @cn 校验指定字段并始终返回表单数据。fields 参数为字段路径,不传时校验所有字段。成功时 resolve 指定字段的数据,失败时 reject 一个 ValidationError 对象,包含:values(表单数据)和 errorFields(数组,包含每个错误字段的 name 和 errors 信息)。适用于需要同时获取表单数据和详细错误信息的场景
36
40
  */
37
41
  validateFieldsWithValue: (fields?: (string | keyof FormValue) | (string | keyof FormValue)[]) => Promise<any>;
38
42
  /**
39
- * @en The verification can get the error message through Promise.catch
40
- * @cn 校验可以通过 catch 获取报错信息
43
+ * @en Validate specified fields and return the first error encountered. The fields parameter is a field path. Same functionality as validateFields, but the name more clearly indicates that it will return error information. Rejects with a FormError object (containing only the first error) on failure. Suitable for scenarios that only care about the first error
44
+ * @cn 校验指定字段并返回第一个遇到的错误。fields 参数为字段路径。与 validateFields 功能相同,但名称更明确地表示会返回错误信息。失败时 reject 一个 FormError 对象(仅包含第一个错误)。适用于只关心第一个错误的场景
41
45
  */
42
46
  validateFieldsWithError: (fields: string | string[]) => Promise<any>;
43
47
  /**
44
- * @en Clear check
45
- * @cn 清除校验
48
+ * @en Clear validation error information for specified fields. The names parameter is an array of field paths, clears errors for all fields when not passed. Field paths support formats like 'name', 'user.email', 'list[0].id'. Commonly used for resetting form state, clearing specific field errors, etc.
49
+ * @cn 清除指定字段的校验错误信息。names 参数为字段路径数组,不传时清除所有字段的错误。字段路径支持 'name'、'user.email'、'list[0].id' 等格式。常用于重置表单状态、清除特定字段错误等场景
46
50
  */
47
51
  clearValidate: (names?: string[]) => void;
48
52
  /**
49
- * @en Submit Form, withValidate: Whether to verify
50
- * @cn 提交表单, withValidate: 是否校验
53
+ * @en Manually trigger form submission. The withValidate parameter controls whether to validate before submission, default is true. After validation passes, it will call the Form's onSubmit callback with the entire form data object (FormValue type). Usually used for custom submit buttons or programmatic submission
54
+ * @cn 手动触发表单提交。withValidate 参数控制是否在提交前进行校验,默认为 true。校验通过后会调用 Form 的 onSubmit 回调,传入整个表单的数据对象(FormValue 类型)。通常用于自定义提交按钮或程序化提交
51
55
  */
52
56
  submit: (withValidate?: boolean) => void;
53
57
  /**
54
- * @en reset form
55
- * @cn 重置表单
58
+ * @en Reset the form to its initial state. Restores form data to defaultValue (uncontrolled) or empty object (controlled), and clears all validation errors. Will trigger the Form's onReset callback
59
+ * @cn 重置表单到初始状态。将表单数据恢复为 defaultValue(非受控)或空对象(受控),并清除所有校验错误。会触发 Form 的 onReset 回调
56
60
  */
57
61
  reset: () => void;
58
62
  /**
59
- * @en set field value, key is field path, Example: { 'name': 'sanmao', 'account.name': 'sanmao', 'friends[0].name': 'sanmao' }
60
- * @cn 设置字段值, key为字段路径,示例:{ 'name': 'sanmao', 'account.name': 'sanmao', 'friends[0].name': 'sanmao' }
63
+ * @en Batch set form field values. Pass in an object where key is the field path and value is the value to set. Field paths support: dot notation ('user.name') to access nested objects, array indexes ('list[0].id') to access array elements. Options parameters: validate controls whether to trigger validation (default false), forceUpdate controls whether to force update (default false). Suitable for dynamically setting form values, linked updates, etc.
64
+ * @cn 批量设置表单字段值。传入一个对象,key 为字段路径,value 为要设置的值。字段路径支持:点表示法('user.name')访问嵌套对象,数组索引('list[0].id')访问数组元素。options 参数:validate 控制是否触发校验(默认 false),forceUpdate 控制是否强制更新(默认 false)。适用于动态设置表单值、联动更新等场景
61
65
  */
62
66
  set: (value: {
63
67
  [key: string]: any;
@@ -66,10 +70,16 @@ export interface FormRef<FormValue> {
66
70
  forceUpdate?: boolean;
67
71
  }) => void;
68
72
  /**
69
- * @en Scroll to the position of the specified field
70
- * @cn 滚动到指定字段的位置
73
+ * @en Scroll the page to the position of the specified form field. The name parameter is a field path, supporting formats like 'name', 'user.email', 'list[0].id'. Requires the Form to set the name property to work properly. The scrollIntoViewOptions parameter conforms to the standard ScrollIntoViewOptions interface, which can control scrolling behavior, position, etc. Commonly used for error positioning, step-by-step form navigation, etc.
74
+ * @cn 滚动页面到指定表单字段的位置。name 参数为字段路径,支持 'name'、'user.email'、'list[0].id' 等格式。需要 Form 设置 name 属性才能正常工作。scrollIntoViewOptions 参数符合标准 ScrollIntoViewOptions 接口,可以控制滚动行为、位置等。常用于错误定位、分步表单导航等
71
75
  */
72
76
  scrollToField: (name: string, scrollIntoViewOptions?: ScrollIntoViewOptions) => void;
77
+ /**
78
+ * @en Get the JSON Schema of the form structure. Returns a standard JSON Schema object that describes the form's structure, field types, validation rules, and constraints. Useful for form documentation, validation, and integration with JSON Schema-based tools
79
+ * @cn 获取表单结构的 JSON Schema。返回一个标准的 JSON Schema 对象,描述表单的结构、字段类型、验证规则和约束。用于表单文档化、验证以及与基于 JSON Schema 的工具集成
80
+ * @version 3.8.0
81
+ */
82
+ getFormSchema: () => any;
73
83
  }
74
84
  export interface FormProps<V extends ObjectType> extends Partial<BaseFormProps<V>>, Pick<CommonType, 'className' | 'style'> {
75
85
  jssStyle: {
@@ -87,16 +97,16 @@ export interface FormProps<V extends ObjectType> extends Partial<BaseFormProps<V
87
97
  */
88
98
  scrollToError?: boolean | number;
89
99
  /**
90
- * @en bind form ref, Can call some form methods
91
- * @cn 绑定 form 的引用, 可以调用某些 form 的方法
100
+ * @en Get a reference to the form instance. Supports both function callback and ref object methods. Through formRef, you can call various form methods, such as manually triggering validation (validate, validateFields), submission (submit), reset (reset), getting/setting values (getValue, set), etc. The generic V in FormRef<V> represents the type of form data
101
+ * @cn 获取表单实例的引用。支持函数回调和 ref 对象两种方式。通过 formRef 可以调用表单的各种方法,如手动触发校验(validate、validateFields)、提交(submit)、重置(reset)、获取/设置值(getValue、set)等。FormRef<V> 中的泛型 V 表示表单数据的类型
92
102
  * @override
93
103
  */
94
104
  formRef?: ((form: FormRef<V>) => void) | {
95
105
  current?: FormRef<V>;
96
106
  };
97
107
  /**
98
- * @en When using hooks, set the form ref
99
- * @cn hooks用法下,设置 form 的引用
108
+ * @en Callback function for setting form reference when using Form.useForm() hooks. Usually doesn't need to be set manually, the Form component will handle it automatically. But may be needed in some special scenarios (such as cross-component communication)
109
+ * @cn 在使用 Form.useForm() hooks 时,用于设置表单引用的回调函数。通常不需要手动设置,Form 组件会自动处理。但在某些特殊场景(如跨组件通信)可能需要使用
100
110
  */
101
111
  setForm?: (form: FormRef<V>) => void;
102
112
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"form.type.d.ts","sourceRoot":"","sources":["form.type.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC1D,OAAO,EAAE,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AG,CAAA;KAAE,EAAE,OAAO,CAAC,EAAE;QAAC,QAAQ,CAAC,EAAE,OAAO,CAAC;QAAC,WAAW,CAAC,EAAE,OAAO,CAAA;KAAC,KAAK,IAAI,CAAC;IACpG;;;OAGG;IACH,aAAa,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,qBAAqB,CAAC,EAAE,qBAAqB,KAAK,IAAI,CAAC;IAErF;;;;OAIG;IACH,aAAa,EAAE,MAAM,GAAG,CAAC;CAC1B;AACD,MAAM,WAAW,SAAS,CAAC,CAAC,SAAS,UAAU,CAC7C,SAAQ,OAAO,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,EAC/B,IAAI,CAAC,UAAU,EAAE,WAAW,GAAG,OAAO,CAAC;IACzC,QAAQ,EAAE;QACR,IAAI,CAAC,EAAE,MAAM,WAAW,CAAC;KAC1B,CAAC;IACF;;;OAGG;IACH,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC3B;;;;OAIG;IACH,aAAa,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC;IACjC;;;;OAIG;IACH,OAAO,CAAC,EAAE,CAAC,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,GAAG;QAAE,OAAO,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC,CAAA;KAAE,CAAC;IAElE;;;OAGG;IACH,OAAO,CAAC,EAAE,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC;IACrC;;OAEG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;;AACD,wBAAkB"}
@@ -1 +1,6 @@
1
+ /**
2
+ * FormValue 泛型表示表单数据的类型,通常是一个对象类型
3
+ * 例如:{ name: string, age: number, address: { city: string } }
4
+ */
5
+
1
6
  export default {};
@@ -8,5 +8,5 @@ export type { FormProps, FormRef, FormClasses } from './form.type';
8
8
  export type { FormItemProps, FormItemClasses } from './form-item.type';
9
9
  export type { FormFieldProps, FormFieldChildrenFunc } from './form-field.type';
10
10
  export type { FormFieldSetProps, FormFieldSetChildrenFunc } from './form-fieldset.type';
11
- export type { FormFlowProps } from './form-flow.type';
11
+ export type { FormFlowProps, FormDatum } from './form-flow.type';
12
12
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,OAAO,IAAI,IAAI,EAAE,MAAM,QAAQ,CAAC;AAClD,OAAO,EAAE,OAAO,IAAI,QAAQ,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,EAAE,OAAO,IAAI,SAAS,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC1D,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,eAAe,CAAC;AACtD,OAAO,EAAE,OAAO,IAAI,QAAQ,EAAE,MAAM,aAAa,CAAC;AAElD,YAAY,EAAE,SAAS,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AACnE,YAAY,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACvE,YAAY,EAAE,cAAc,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAC/E,YAAY,EAAE,iBAAiB,EAAE,wBAAwB,EAAE,MAAM,sBAAsB,CAAC;AACxF,YAAY,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,OAAO,IAAI,IAAI,EAAE,MAAM,QAAQ,CAAC;AAClD,OAAO,EAAE,OAAO,IAAI,QAAQ,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,EAAE,OAAO,IAAI,SAAS,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC1D,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,eAAe,CAAC;AACtD,OAAO,EAAE,OAAO,IAAI,QAAQ,EAAE,MAAM,aAAa,CAAC;AAElD,YAAY,EAAE,SAAS,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AACnE,YAAY,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACvE,YAAY,EAAE,cAAc,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAC/E,YAAY,EAAE,iBAAiB,EAAE,wBAAwB,EAAE,MAAM,sBAAsB,CAAC;AACxF,YAAY,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"input-password.d.ts","sourceRoot":"","sources":["input-password.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAK1B,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;;AAmD3D,wBAAoC"}
1
+ {"version":3,"file":"input-password.d.ts","sourceRoot":"","sources":["input-password.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAK1B,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;;AAoD3D,wBAAoC"}
@@ -45,7 +45,8 @@ var Password = function Password(props) {
45
45
  return /*#__PURE__*/_jsx(SimpleInput, _objectSpread(_objectSpread(_objectSpread({}, forwardProps), inputProps), {}, {
46
46
  className: props.className,
47
47
  suffix: suffix,
48
- hasSuffix: true
48
+ hasSuffix: true,
49
+ showClear: props.showClear
49
50
  }));
50
51
  };
51
52
  export default /*#__PURE__*/React.memo(Password);
@@ -1 +1 @@
1
- {"version":3,"file":"input.d.ts","sourceRoot":"","sources":["input.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAG1C,OAAO,KAAK,MAAM,OAAO,CAAC;;AA4C1B,wBAAiC"}
1
+ {"version":3,"file":"input.d.ts","sourceRoot":"","sources":["input.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAG1C,OAAO,KAAK,MAAM,OAAO,CAAC;;AA6C1B,wBAAiC"}
@@ -33,6 +33,7 @@ var Input = function Input(props) {
33
33
  return /*#__PURE__*/_jsx(SimpleInputInput, _objectSpread(_objectSpread(_objectSpread({}, forwardProps), inputFormatProps), {}, {
34
34
  value: (_inputFormatProps$val = inputFormatProps.value) !== null && _inputFormatProps$val !== void 0 ? _inputFormatProps$val : '',
35
35
  hasSuffix: !!props.suffix,
36
+ showClear: props.showClear,
36
37
  onKeyDown: function onKeyDown(e) {
37
38
  var _props$onKeyDown;
38
39
  if (e.key === 'Enter' && !e.defaultPrevented) {