haze-ui 1.26.0 → 1.27.0

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 (392) hide show
  1. package/README.md +420 -36
  2. package/dist/components/Anchor/Anchor.js +78 -0
  3. package/dist/components/Anchor/index.js +3 -0
  4. package/dist/components/AppShell/AppShell.js +44 -0
  5. package/dist/components/AppShell/index.js +3 -0
  6. package/dist/components/AspectRatio/AspectRatio.js +0 -1
  7. package/dist/components/AspectRatio/index.js +0 -1
  8. package/dist/components/Badge/Badge.js +5 -17
  9. package/dist/components/Badge/badge-styles.js +15 -0
  10. package/dist/components/Badge/index.js +3 -3
  11. package/dist/components/BottomSheet/BottomSheet.js +133 -22
  12. package/dist/components/Button/index.js +4 -3
  13. package/dist/components/Calendar/Calendar.js +454 -78
  14. package/dist/components/Calendar/date.js +35 -2
  15. package/dist/components/Card/Card.js +0 -1
  16. package/dist/components/Card/index.js +0 -1
  17. package/dist/components/Carousel/Carousel.js +64 -41
  18. package/dist/components/Cascader/Cascader.js +185 -137
  19. package/dist/components/Chart/Chart.js +31 -0
  20. package/dist/components/Chart/chart-elements.js +88 -0
  21. package/dist/components/Chart/index.js +3 -0
  22. package/dist/components/ChatContainer/ChatContainer.js +36 -16
  23. package/dist/components/ChatInput/ChatInput.js +49 -29
  24. package/dist/components/ChatMessage/ChatMessage.js +76 -29
  25. package/dist/components/Checkbox/Checkbox.js +6 -5
  26. package/dist/components/Checkbox/CheckboxCore.js +6 -5
  27. package/dist/components/CodeBlock/CodeBlock.js +0 -1
  28. package/dist/components/CodeBlock/index.js +0 -1
  29. package/dist/components/Collapsible/Collapsible.js +23 -10
  30. package/dist/components/ColorPicker/ColorPicker.js +5 -4
  31. package/dist/components/ColorPicker/ColorPickerCore.js +5 -4
  32. package/dist/components/Combobox/Combobox.js +195 -76
  33. package/dist/components/Combobox/ComboboxGroup.js +23 -0
  34. package/dist/components/Combobox/ComboboxOption.js +7 -6
  35. package/dist/components/Combobox/index.js +4 -3
  36. package/dist/components/Command/Command.js +102 -59
  37. package/dist/components/Command/CommandDialog.js +48 -0
  38. package/dist/components/Command/command-filter.js +16 -0
  39. package/dist/components/Command/index.js +3 -2
  40. package/dist/components/ConfirmDialog/ConfirmDialog.js +3 -3
  41. package/dist/components/Container/Container.js +0 -1
  42. package/dist/components/Container/index.js +0 -1
  43. package/dist/components/ContextMenu/ContextMenuContent.js +4 -4
  44. package/dist/components/DataTable/CellEditor.js +38 -0
  45. package/dist/components/DataTable/DataTable.js +390 -142
  46. package/dist/components/DataTable/features.js +25 -0
  47. package/dist/components/DataTable/index.js +2 -1
  48. package/dist/components/DataTable/summary.js +17 -0
  49. package/dist/components/DateRangePicker/DateRangePicker.js +10 -7
  50. package/dist/components/DateRangePicker/DateRangePickerCore.js +59 -27
  51. package/dist/components/Datepicker/Datepicker.js +16 -12
  52. package/dist/components/Datepicker/DatepickerCore.js +50 -37
  53. package/dist/components/Dialog/Dialog.js +56 -32
  54. package/dist/components/Divider/Divider.js +0 -1
  55. package/dist/components/Divider/index.js +0 -1
  56. package/dist/components/Drawer/Drawer.js +49 -29
  57. package/dist/components/DropdownMenu/DropdownMenu.js +38 -26
  58. package/dist/components/DropdownMenu/DropdownMenuSub.js +23 -0
  59. package/dist/components/DropdownMenu/DropdownMenuSubContent.js +24 -0
  60. package/dist/components/DropdownMenu/DropdownMenuSubTrigger.js +30 -0
  61. package/dist/components/DropdownMenu/index.js +4 -1
  62. package/dist/components/Flex/Flex.js +0 -1
  63. package/dist/components/Flex/index.js +0 -1
  64. package/dist/components/Fullscreen/Fullscreen.js +29 -0
  65. package/dist/components/Fullscreen/index.js +3 -0
  66. package/dist/components/Grid/Grid.js +0 -1
  67. package/dist/components/Grid/GridItem.js +0 -1
  68. package/dist/components/Grid/index.js +0 -1
  69. package/dist/components/Icon/Icon.js +0 -1
  70. package/dist/components/Icon/index.js +0 -1
  71. package/dist/components/Image/Image.js +37 -19
  72. package/dist/components/Image/ImagePreview.js +233 -0
  73. package/dist/components/Input/Input.js +6 -5
  74. package/dist/components/Input/InputCore.js +3 -2
  75. package/dist/components/Kbd/Kbd.js +0 -1
  76. package/dist/components/Kbd/index.js +0 -1
  77. package/dist/components/LocaleProvider/LocaleProvider.js +16 -13
  78. package/dist/components/LocaleProvider/index.js +2 -1
  79. package/dist/components/LocaleProvider/locale.js +58 -2
  80. package/dist/components/LocaleProvider/strings.js +15 -0
  81. package/dist/components/LocaleProvider/zh-cn.js +58 -2
  82. package/dist/components/Mentions/Mentions.js +6 -5
  83. package/dist/components/Mentions/MentionsCore.js +69 -68
  84. package/dist/components/Menu/Menu.js +5 -5
  85. package/dist/components/Menu/MenuSub.js +23 -0
  86. package/dist/components/Menu/MenuSubContent.js +24 -0
  87. package/dist/components/Menu/MenuSubTrigger.js +30 -0
  88. package/dist/components/Menu/index.js +4 -1
  89. package/dist/components/NumberInput/NumberInput.js +6 -5
  90. package/dist/components/NumberInput/NumberInputCore.js +9 -8
  91. package/dist/components/OTPInput/OTPInput.js +5 -4
  92. package/dist/components/OTPInput/OTPInputCore.js +34 -33
  93. package/dist/components/PasswordInput/PasswordInput.js +5 -4
  94. package/dist/components/PasswordInput/PasswordInputCore.js +8 -7
  95. package/dist/components/Popover/Popover.js +43 -31
  96. package/dist/components/PromptInput/PromptInput.js +213 -0
  97. package/dist/components/PromptInput/index.js +3 -0
  98. package/dist/components/Radio/Radio.js +7 -6
  99. package/dist/components/Radio/RadioGroup.js +5 -4
  100. package/dist/components/Radio/RadioGroupCore.js +23 -14
  101. package/dist/components/Rating/Rating.js +5 -4
  102. package/dist/components/Rating/RatingCore.js +62 -28
  103. package/dist/components/Resizable/index.js +1 -1
  104. package/dist/components/Segmented/Segmented.js +5 -4
  105. package/dist/components/Segmented/SegmentedCore.js +22 -18
  106. package/dist/components/Select/OptionGroup.js +12 -0
  107. package/dist/components/Select/Select.js +19 -9
  108. package/dist/components/Select/SelectCore.js +73 -13
  109. package/dist/components/Select/SelectFloating.js +248 -0
  110. package/dist/components/Select/index.js +5 -4
  111. package/dist/components/Select/select-options.js +57 -0
  112. package/dist/components/Sidebar/Sidebar.js +9 -9
  113. package/dist/components/Skeleton/Skeleton.js +0 -1
  114. package/dist/components/Skeleton/index.js +0 -1
  115. package/dist/components/Slider/Slider.js +16 -8
  116. package/dist/components/Slider/SliderCore.js +75 -12
  117. package/dist/components/Stat/Stat.js +0 -1
  118. package/dist/components/Stat/index.js +0 -1
  119. package/dist/components/Switch/Switch.js +6 -5
  120. package/dist/components/Switch/SwitchCore.js +3 -2
  121. package/dist/components/Tabs/Tab.js +7 -4
  122. package/dist/components/Tabs/TabList.js +38 -7
  123. package/dist/components/Tabs/TabPanel.js +4 -3
  124. package/dist/components/Tabs/Tabs.js +11 -6
  125. package/dist/components/TagGroup/TagGroup.js +19 -7
  126. package/dist/components/TagGroup/TagGroupItem.js +17 -11
  127. package/dist/components/TagInput/TagInput.js +10 -8
  128. package/dist/components/TagInput/TagInputCore.js +94 -57
  129. package/dist/components/Textarea/Textarea.js +6 -5
  130. package/dist/components/Textarea/TextareaCore.js +3 -2
  131. package/dist/components/TimePicker/TimePicker.js +6 -5
  132. package/dist/components/TimePicker/TimePickerCore.js +3 -2
  133. package/dist/components/Toast/Toast.js +23 -22
  134. package/dist/components/Toast/ToastContainer.js +67 -47
  135. package/dist/components/Toast/ToastContext.js +23 -4
  136. package/dist/components/Toast/toast2.js +63 -28
  137. package/dist/components/Toast/useToast.js +9 -7
  138. package/dist/components/Toggle/Toggle.js +20 -0
  139. package/dist/components/Toggle/ToggleCore.js +31 -0
  140. package/dist/components/Toggle/index.js +4 -0
  141. package/dist/components/Toolbar/Toolbar.js +33 -32
  142. package/dist/components/Toolbar/ToolbarToggle.js +31 -0
  143. package/dist/components/Toolbar/index.js +2 -1
  144. package/dist/components/Tooltip/Tooltip.js +1 -1
  145. package/dist/components/Tour/Tour.js +57 -53
  146. package/dist/components/Tree/Tree.js +199 -77
  147. package/dist/components/Tree/TreeItem.js +17 -15
  148. package/dist/components/Tree/utils.js +26 -10
  149. package/dist/components/Typography/Typography.js +0 -1
  150. package/dist/components/Typography/index.js +0 -1
  151. package/dist/components/Upload/Upload.js +21 -8
  152. package/dist/components/Upload/UploadCore.js +224 -37
  153. package/dist/components/Upload/UploadList.js +172 -0
  154. package/dist/components/Upload/xhr-upload.js +22 -0
  155. package/dist/components/VirtualList/VirtualList.js +84 -56
  156. package/dist/components/Watermark/Watermark.js +55 -0
  157. package/dist/components/Watermark/index.js +3 -0
  158. package/dist/css/anchor.css +2 -0
  159. package/dist/css/app-shell.css +2 -0
  160. package/dist/css/badge.css +1 -1
  161. package/dist/css/bottom-sheet.css +1 -1
  162. package/dist/css/button.css +1 -1
  163. package/dist/css/calendar.css +1 -1
  164. package/dist/css/cascader.css +1 -1
  165. package/dist/css/chart.css +2 -0
  166. package/dist/css/chat-container.css +1 -1
  167. package/dist/css/chat-message.css +1 -1
  168. package/dist/css/combobox.css +3 -2
  169. package/dist/css/command.css +2 -1
  170. package/dist/css/context-menu.css +1 -1
  171. package/dist/css/data-table.css +2 -1
  172. package/dist/css/date-range-picker.css +1 -1
  173. package/dist/css/datepicker.css +2 -2
  174. package/dist/css/dialog.css +1 -1
  175. package/dist/css/dropdown-menu.css +4 -1
  176. package/dist/css/image.css +2 -1
  177. package/dist/css/menu.css +4 -1
  178. package/dist/css/popover.css +1 -1
  179. package/dist/css/prompt-input.css +2 -0
  180. package/dist/css/rating.css +1 -1
  181. package/dist/css/select.css +3 -1
  182. package/dist/css/slider.css +1 -1
  183. package/dist/css/tag-group.css +2 -0
  184. package/dist/css/tag-input.css +3 -1
  185. package/dist/css/toggle.css +2 -0
  186. package/dist/css/toolbar.css +1 -0
  187. package/dist/css/tooltip.css +1 -1
  188. package/dist/css/tree.css +1 -1
  189. package/dist/css/upload.css +2 -1
  190. package/dist/css/watermark.css +2 -0
  191. package/dist/css-manifest.json +60 -1
  192. package/dist/form/FormItem.js +55 -50
  193. package/dist/form/FormList.js +79 -0
  194. package/dist/form/index.js +5 -1
  195. package/dist/form/standard-schema.js +16 -0
  196. package/dist/haze-ui.css +51 -27
  197. package/dist/headless/index.js +7 -0
  198. package/dist/hooks/useClickOutside.js +24 -0
  199. package/dist/hooks/useFullscreen.js +42 -0
  200. package/dist/hooks/useHotkeys.js +77 -0
  201. package/dist/hooks/useInView.js +27 -0
  202. package/dist/hooks/useLocalStorage.js +8 -0
  203. package/dist/hooks/useMediaQuery.js +2 -1
  204. package/dist/hooks/usePrevious.js +11 -0
  205. package/dist/hooks/useSessionStorage.js +8 -0
  206. package/dist/hooks/useStorageState.js +80 -0
  207. package/dist/index.js +205 -171
  208. package/dist/registry.json +2259 -91
  209. package/dist/tokens/colors.js +0 -1
  210. package/dist/tokens/index.js +0 -1
  211. package/dist/tokens/motion.js +0 -1
  212. package/dist/tokens/oklch.js +0 -1
  213. package/dist/tokens/palette.js +0 -1
  214. package/dist/tokens/registry.js +17 -28
  215. package/dist/tokens/spacing.js +0 -1
  216. package/dist/tokens/typography.js +0 -1
  217. package/dist/types/components/Anchor/Anchor.d.ts +25 -0
  218. package/dist/types/components/Anchor/index.d.ts +2 -0
  219. package/dist/types/components/AppShell/AppShell.d.ts +17 -0
  220. package/dist/types/components/AppShell/index.d.ts +2 -0
  221. package/dist/types/components/Badge/badge-styles.d.ts +21 -0
  222. package/dist/types/components/Badge/index.d.ts +1 -0
  223. package/dist/types/components/BottomSheet/BottomSheet.d.ts +52 -3
  224. package/dist/types/components/BottomSheet/index.d.ts +1 -1
  225. package/dist/types/components/Button/Button.d.ts +7 -0
  226. package/dist/types/components/Button/ButtonLink.d.ts +3 -0
  227. package/dist/types/components/Button/index.d.ts +1 -0
  228. package/dist/types/components/Button/styles.d.ts +17 -0
  229. package/dist/types/components/Calendar/Calendar.d.ts +71 -7
  230. package/dist/types/components/Calendar/date.d.ts +52 -0
  231. package/dist/types/components/Calendar/index.d.ts +1 -1
  232. package/dist/types/components/Cascader/Cascader.d.ts +29 -3
  233. package/dist/types/components/Chart/Chart.d.ts +29 -0
  234. package/dist/types/components/Chart/chart-elements.d.ts +52 -0
  235. package/dist/types/components/Chart/index.d.ts +2 -0
  236. package/dist/types/components/ChatContainer/ChatContainer.d.ts +18 -3
  237. package/dist/types/components/ChatInput/ChatInput.d.ts +11 -1
  238. package/dist/types/components/ChatMessage/ChatMessage.d.ts +13 -1
  239. package/dist/types/components/Checkbox/Checkbox.d.ts +6 -2
  240. package/dist/types/components/Checkbox/CheckboxCore.d.ts +4 -2
  241. package/dist/types/components/Collapsible/Collapsible.d.ts +24 -2
  242. package/dist/types/components/Collapsible/index.d.ts +1 -1
  243. package/dist/types/components/ColorPicker/ColorPicker.d.ts +7 -1
  244. package/dist/types/components/ColorPicker/ColorPickerCore.d.ts +7 -1
  245. package/dist/types/components/Combobox/Combobox.d.ts +101 -7
  246. package/dist/types/components/Combobox/ComboboxGroup.d.ts +22 -0
  247. package/dist/types/components/Combobox/ComboboxOption.d.ts +7 -2
  248. package/dist/types/components/Combobox/index.d.ts +3 -1
  249. package/dist/types/components/Command/Command.d.ts +70 -6
  250. package/dist/types/components/Command/CommandDialog.d.ts +36 -0
  251. package/dist/types/components/Command/command-filter.d.ts +34 -0
  252. package/dist/types/components/Command/index.d.ts +4 -2
  253. package/dist/types/components/DataTable/CellEditor.d.ts +24 -0
  254. package/dist/types/components/DataTable/DataTable.d.ts +149 -32
  255. package/dist/types/components/DataTable/features.d.ts +118 -0
  256. package/dist/types/components/DataTable/index.d.ts +2 -1
  257. package/dist/types/components/DataTable/summary.d.ts +19 -0
  258. package/dist/types/components/DateRangePicker/DateRangePicker.d.ts +15 -1
  259. package/dist/types/components/DateRangePicker/DateRangePickerCore.d.ts +26 -2
  260. package/dist/types/components/DateRangePicker/index.d.ts +1 -1
  261. package/dist/types/components/Datepicker/Datepicker.d.ts +17 -1
  262. package/dist/types/components/Datepicker/DatepickerCore.d.ts +24 -2
  263. package/dist/types/components/Datepicker/index.d.ts +1 -1
  264. package/dist/types/components/Dialog/Dialog.d.ts +68 -3
  265. package/dist/types/components/Dialog/index.d.ts +1 -1
  266. package/dist/types/components/Drawer/Drawer.d.ts +33 -3
  267. package/dist/types/components/Drawer/index.d.ts +1 -1
  268. package/dist/types/components/DropdownMenu/DropdownMenu.d.ts +23 -3
  269. package/dist/types/components/DropdownMenu/DropdownMenuSub.d.ts +18 -0
  270. package/dist/types/components/DropdownMenu/DropdownMenuSubContent.d.ts +13 -0
  271. package/dist/types/components/DropdownMenu/DropdownMenuSubTrigger.d.ts +14 -0
  272. package/dist/types/components/DropdownMenu/index.d.ts +7 -1
  273. package/dist/types/components/Fullscreen/Fullscreen.d.ts +34 -0
  274. package/dist/types/components/Fullscreen/index.d.ts +3 -0
  275. package/dist/types/components/Image/Image.d.ts +20 -5
  276. package/dist/types/components/Image/ImagePreview.d.ts +13 -0
  277. package/dist/types/components/Image/index.d.ts +1 -1
  278. package/dist/types/components/Input/Input.d.ts +5 -2
  279. package/dist/types/components/Input/InputCore.d.ts +4 -2
  280. package/dist/types/components/LocaleProvider/LocaleContext.d.ts +9 -0
  281. package/dist/types/components/LocaleProvider/LocaleProvider.d.ts +12 -1
  282. package/dist/types/components/LocaleProvider/index.d.ts +2 -0
  283. package/dist/types/components/LocaleProvider/locale.d.ts +56 -0
  284. package/dist/types/components/LocaleProvider/strings.d.ts +28 -0
  285. package/dist/types/components/Mentions/Mentions.d.ts +5 -2
  286. package/dist/types/components/Mentions/MentionsCore.d.ts +4 -2
  287. package/dist/types/components/Menu/MenuSub.d.ts +18 -0
  288. package/dist/types/components/Menu/MenuSubContent.d.ts +12 -0
  289. package/dist/types/components/Menu/MenuSubTrigger.d.ts +14 -0
  290. package/dist/types/components/Menu/index.d.ts +6 -0
  291. package/dist/types/components/NumberInput/NumberInput.d.ts +5 -2
  292. package/dist/types/components/NumberInput/NumberInputCore.d.ts +4 -2
  293. package/dist/types/components/OTPInput/OTPInput.d.ts +5 -1
  294. package/dist/types/components/OTPInput/OTPInputCore.d.ts +4 -1
  295. package/dist/types/components/PasswordInput/PasswordInput.d.ts +5 -1
  296. package/dist/types/components/PasswordInput/PasswordInputCore.d.ts +4 -1
  297. package/dist/types/components/Popover/Popover.d.ts +41 -3
  298. package/dist/types/components/Popover/index.d.ts +1 -1
  299. package/dist/types/components/PromptInput/PromptInput.d.ts +46 -0
  300. package/dist/types/components/PromptInput/index.d.ts +2 -0
  301. package/dist/types/components/Radio/Radio.d.ts +5 -2
  302. package/dist/types/components/Radio/RadioGroup.d.ts +8 -2
  303. package/dist/types/components/Radio/RadioGroupCore.d.ts +7 -2
  304. package/dist/types/components/Rating/Rating.d.ts +8 -1
  305. package/dist/types/components/Rating/RatingCore.d.ts +7 -1
  306. package/dist/types/components/Resizable/index.d.ts +2 -0
  307. package/dist/types/components/Segmented/Segmented.d.ts +8 -1
  308. package/dist/types/components/Segmented/SegmentedCore.d.ts +7 -2
  309. package/dist/types/components/Select/OptionGroup.d.ts +16 -0
  310. package/dist/types/components/Select/Select.d.ts +66 -4
  311. package/dist/types/components/Select/SelectCore.d.ts +70 -6
  312. package/dist/types/components/Select/SelectFloating.d.ts +83 -0
  313. package/dist/types/components/Select/index.d.ts +2 -0
  314. package/dist/types/components/Select/select-options.d.ts +53 -0
  315. package/dist/types/components/Slider/Slider.d.ts +29 -4
  316. package/dist/types/components/Slider/SliderCore.d.ts +35 -6
  317. package/dist/types/components/Switch/Switch.d.ts +5 -2
  318. package/dist/types/components/Switch/SwitchCore.d.ts +4 -2
  319. package/dist/types/components/Tabs/TabList.d.ts +7 -0
  320. package/dist/types/components/Tabs/Tabs.d.ts +8 -1
  321. package/dist/types/components/Tabs/TabsContext.d.ts +20 -0
  322. package/dist/types/components/Tabs/index.d.ts +1 -0
  323. package/dist/types/components/TagGroup/TagGroup.d.ts +13 -1
  324. package/dist/types/components/TagInput/TagInput.d.ts +12 -1
  325. package/dist/types/components/TagInput/TagInputCore.d.ts +11 -1
  326. package/dist/types/components/Textarea/Textarea.d.ts +5 -2
  327. package/dist/types/components/Textarea/TextareaCore.d.ts +4 -2
  328. package/dist/types/components/TimePicker/TimePicker.d.ts +5 -2
  329. package/dist/types/components/TimePicker/TimePickerCore.d.ts +4 -2
  330. package/dist/types/components/Toast/Toast.d.ts +31 -2
  331. package/dist/types/components/Toast/ToastContainer.d.ts +11 -1
  332. package/dist/types/components/Toast/ToastContext.d.ts +44 -3
  333. package/dist/types/components/Toast/index.d.ts +1 -1
  334. package/dist/types/components/Toast/toast.d.ts +35 -4
  335. package/dist/types/components/Toast/useToast.d.ts +16 -4
  336. package/dist/types/components/Toggle/Toggle.d.ts +19 -0
  337. package/dist/types/components/Toggle/ToggleCore.d.ts +23 -0
  338. package/dist/types/components/Toggle/index.d.ts +4 -0
  339. package/dist/types/components/Toolbar/ToolbarToggle.d.ts +19 -0
  340. package/dist/types/components/Toolbar/index.d.ts +2 -0
  341. package/dist/types/components/Tour/Tour.d.ts +3 -3
  342. package/dist/types/components/Tree/Tree.d.ts +3 -3
  343. package/dist/types/components/Tree/TreeItem.d.ts +6 -1
  344. package/dist/types/components/Tree/types.d.ts +26 -0
  345. package/dist/types/components/Tree/utils.d.ts +32 -0
  346. package/dist/types/components/Upload/Upload.d.ts +38 -3
  347. package/dist/types/components/Upload/UploadCore.d.ts +75 -4
  348. package/dist/types/components/Upload/UploadList.d.ts +12 -0
  349. package/dist/types/components/Upload/index.d.ts +1 -0
  350. package/dist/types/components/Upload/types.d.ts +60 -0
  351. package/dist/types/components/Upload/xhr-upload.d.ts +20 -0
  352. package/dist/types/components/VirtualList/VirtualList.d.ts +16 -1
  353. package/dist/types/components/Watermark/Watermark.d.ts +32 -0
  354. package/dist/types/components/Watermark/index.d.ts +2 -0
  355. package/dist/types/form/FormItem.d.ts +33 -8
  356. package/dist/types/form/FormList.d.ts +113 -0
  357. package/dist/types/form/index.d.ts +26 -0
  358. package/dist/types/form/standard-schema.d.ts +30 -0
  359. package/dist/types/headless/index.d.ts +182 -0
  360. package/dist/types/hooks/index.d.ts +11 -0
  361. package/dist/types/hooks/useClickOutside.d.ts +46 -0
  362. package/dist/types/hooks/useFullscreen.d.ts +33 -0
  363. package/dist/types/hooks/useHotkeys.d.ts +53 -0
  364. package/dist/types/hooks/useInView.d.ts +32 -0
  365. package/dist/types/hooks/useLocalStorage.d.ts +33 -0
  366. package/dist/types/hooks/useMediaQuery.d.ts +3 -0
  367. package/dist/types/hooks/usePrevious.d.ts +18 -0
  368. package/dist/types/hooks/useSessionStorage.d.ts +26 -0
  369. package/dist/types/hooks/useStorageState.d.ts +12 -0
  370. package/dist/types/index.d.ts +57 -32
  371. package/dist/types/utils/collision.d.ts +39 -1
  372. package/dist/types/utils/direction.d.ts +22 -0
  373. package/dist/types/utils/floating.d.ts +32 -4
  374. package/dist/types/utils/focus-scope.d.ts +2 -1
  375. package/dist/types/utils/focus.d.ts +2 -1
  376. package/dist/types/utils/menuKeyboard.d.ts +19 -4
  377. package/dist/types/utils/refs.d.ts +16 -0
  378. package/dist/types/utils/sortable-shared.d.ts +42 -0
  379. package/dist/types/utils/sortable.d.ts +36 -0
  380. package/dist/types/utils/submenu.d.ts +63 -0
  381. package/dist/types/utils/view-transition.d.ts +28 -0
  382. package/dist/utils/classnames.js +0 -1
  383. package/dist/utils/collision.js +37 -26
  384. package/dist/utils/direction.js +34 -0
  385. package/dist/utils/floating.js +163 -143
  386. package/dist/utils/menuKeyboard.js +59 -46
  387. package/dist/utils/refs.js +9 -0
  388. package/dist/utils/sortable-shared.js +24 -0
  389. package/dist/utils/sortable.js +46 -0
  390. package/dist/utils/submenu.js +104 -0
  391. package/dist/utils/view-transition.js +26 -0
  392. package/package.json +109 -16
@@ -18,9 +18,14 @@ type TreeItemProps = {
18
18
  titleRender?: (node: TreeNodeData) => ReactNode;
19
19
  iconRender?: (node: TreeNodeData) => ReactNode;
20
20
  isLast: boolean[];
21
+ /**
22
+ * Roving-tabindex stop (WAI-ARIA tree pattern): `0` on the row that
23
+ * owns the tree's single tab stop, `-1` on every other row.
24
+ */
25
+ tabIndex: 0 | -1;
21
26
  onToggle: () => void;
22
27
  onSelect: () => void;
23
28
  onCheck: () => void;
24
29
  };
25
- export default function TreeItem({ node, level, expanded, selected, checked, disabled, checkable, selectable, blockNode, showLine, showIcon, switcherIcon, loadingIcon: loadingIconProp, loading, titleRender, iconRender, isLast, onToggle, onSelect, onCheck, }: TreeItemProps): import("react").JSX.Element;
30
+ export default function TreeItem({ node, level, expanded, selected, checked, disabled, checkable, selectable, blockNode, showLine, showIcon, switcherIcon, loadingIcon: loadingIconProp, loading, titleRender, iconRender, isLast, tabIndex, onToggle, onSelect, onCheck, }: TreeItemProps): import("react").JSX.Element;
26
31
  export {};
@@ -32,6 +32,20 @@ export type TreeState = {
32
32
  checkedKeys: string[];
33
33
  halfCheckedKeys: string[];
34
34
  };
35
+ /**
36
+ * Virtualized windowing metrics for `Tree.virtualized`.
37
+ */
38
+ export type TreeVirtualizedConfig = {
39
+ /** Scrollport height in px. Default `320`. */
40
+ height?: number;
41
+ /** Row height in px. Default `32` — the treeitem min-height (2rem). */
42
+ itemHeight?: number;
43
+ /**
44
+ * Extra rows kept mounted above/below the visible window. Defaults to
45
+ * `VirtualList`'s `5`.
46
+ */
47
+ overscan?: number;
48
+ };
35
49
  /**
36
50
  * Tree 组件 Props
37
51
  */
@@ -62,6 +76,18 @@ export type TreeProps = {
62
76
  titleRender?: (node: TreeNodeData) => ReactNode;
63
77
  /** 自定义节点图标渲染 */
64
78
  iconRender?: (node: TreeNodeData) => ReactNode;
79
+ /**
80
+ * Render the tree through `VirtualList` so large trees mount only the
81
+ * visible window (plus overscan) instead of the full DOM list: the
82
+ * visible rows are flattened depth-first (depth indent preserved) and
83
+ * windowed. `false`/omitted (default) keeps the plain nested DOM
84
+ * path; an object additionally customizes row metrics.
85
+ * `expandedKeys`/`selectedKeys`/`checkedKeys` semantics are identical
86
+ * in both paths, and roving-tabindex keyboard navigation works the
87
+ * same way — focus moves `scrollToIndex` the target row into the
88
+ * window before focusing it.
89
+ */
90
+ virtualized?: boolean | TreeVirtualizedConfig;
65
91
  /** (受控)展开的节点 */
66
92
  expandedKeys?: ControlOrValue<string[]>;
67
93
  /** (受控)选中的节点 */
@@ -1,4 +1,36 @@
1
1
  import type { TreeNodeData } from './types';
2
+ /**
3
+ * A visible tree row: one treeitem in the depth-first order the tree
4
+ * renders (parents before children, expanded subtrees only). Backs both
5
+ * the roving-tabindex keyboard navigation and the virtualized windowing,
6
+ * which need the flat "visible rows" list rather than the recursive
7
+ * structure.
8
+ */
9
+ export type VisibleTreeRow = {
10
+ key: string;
11
+ node: TreeNodeData;
12
+ /** Nesting depth; 0 for roots — matches TreeItem's `level` prop. */
13
+ level: number;
14
+ /** Parent row's key; null for roots. */
15
+ parentKey: string | null;
16
+ /**
17
+ * showLine guide chain: one "is a last child" flag per ancestor level
18
+ * (length === level), the same chain the recursive render builds.
19
+ */
20
+ isLast: boolean[];
21
+ /**
22
+ * Tree-level or per-node disabled flag. Disabled rows render (and can
23
+ * be expanded through controlled `expandedKeys`) but are skipped as
24
+ * keyboard focus stops.
25
+ */
26
+ disabled: boolean;
27
+ };
28
+ /**
29
+ * Flatten the tree to its currently visible rows: children of a node are
30
+ * included only while that node is expanded — the exact visibility rule
31
+ * of the recursive render (`children?.length && expandedKeys.has(key)`).
32
+ */
33
+ export declare function flattenVisibleTree(data: TreeNodeData[], expandedKeys: string[], treeDisabled: boolean): VisibleTreeRow[];
2
34
  export declare function flattenTreeData(data: TreeNodeData[]): TreeNodeData[];
3
35
  export declare function findNodeByKey(data: TreeNodeData[], key: string): TreeNodeData | null;
4
36
  export declare function getChildKeys(data: TreeNodeData[], parentKey: string): string[];
@@ -1,15 +1,50 @@
1
- import type { ReactNode } from 'react';
1
+ import type { ReactNode, Ref } from 'react';
2
2
  import type { ControlOrValue } from 'react-use-control';
3
+ import type { UploadFileStatus, UploadHandle, UploadListItemRender, UploadRequest } from './types';
3
4
  type UploadProps = {
4
5
  /** Selected files; uncontrolled (accumulating internally) when omitted. */
5
6
  value?: ControlOrValue<File[]>;
6
7
  accept?: string;
8
+ /** Renders the drag-and-drop drop area (default) or a plain
9
+ * click-only picker area — see `UploadCoreProps.droppable`. */
10
+ droppable?: boolean;
11
+ /** Gatekeeper for every picked or dropped file — see
12
+ * `UploadCoreProps.beforeUpload`. */
13
+ beforeUpload?: (file: File) => boolean | Promise<boolean>;
14
+ /** Cap for the committed list — see `UploadCoreProps.maxCount`. */
15
+ maxCount?: number;
7
16
  multiple?: boolean;
17
+ /** Custom upload executor — see `UploadCoreProps.request`. */
18
+ request?: UploadRequest;
19
+ /** Upload endpoint for the built-in XHR executor — see
20
+ * `UploadCoreProps.action`. */
21
+ action?: string;
22
+ /** HTTP method for `action` uploads (default `POST`). */
23
+ method?: string;
24
+ /** Extra request headers for `action` uploads. */
25
+ headers?: Record<string, string>;
26
+ /** Form field name carrying the file in `action` mode (default `file`). */
27
+ name?: string;
28
+ /** Extra form fields appended alongside the file in `action` mode. */
29
+ data?: Record<string, string | Blob>;
30
+ /** Picks only enter the list; uploads start via the `UploadHandle`
31
+ * ref — see `UploadCoreProps.manual`. */
32
+ manual?: boolean;
33
+ /** Built-in file list with progress and per-state actions — see
34
+ * `UploadCoreProps.showUploadList`. */
35
+ showUploadList?: boolean | {
36
+ itemRender?: UploadListItemRender;
37
+ };
38
+ /** Status-machine snapshot callback — see
39
+ * `UploadCoreProps.onStatusChange`. */
40
+ onStatusChange?: (files: UploadFileStatus[]) => void;
8
41
  /** Fires with the freshly picked files only — the accumulated list is
9
- * the `value` channel (or internal state when uncontrolled). */
42
+ * the `value` channel (or internal state when uncontrolled).
43
+ * Removals and `clear()` do not fire this (they are not picks). */
10
44
  onChange?: (files: File[]) => void;
11
45
  className?: string;
12
46
  children?: ReactNode;
47
+ ref?: Ref<UploadHandle>;
13
48
  };
14
- export default function Upload({ value: valueControl, accept, multiple, onChange, className, children, }: UploadProps): import("react").JSX.Element;
49
+ export default function Upload({ value: valueControl, accept, droppable, beforeUpload, maxCount, multiple, request, action, method, headers, name, data, manual, showUploadList, onStatusChange, onChange, className, children, ref, }: UploadProps): import("react").JSX.Element;
15
50
  export type { UploadProps };
@@ -1,15 +1,86 @@
1
- import type { ComponentPropsWithoutRef, ReactNode } from 'react';
1
+ import type { ComponentPropsWithoutRef, ReactNode, Ref } from 'react';
2
+ import type { UploadFileStatus, UploadHandle, UploadListItemRender, UploadRequest } from './types';
2
3
  type UploadCoreProps = {
3
4
  /** The selected files — the field value, emitted verbatim (as the
4
5
  * complete next list) by `onChange`. */
5
6
  value: File[];
6
7
  /** Emits the next file list: a single pick replaces `value`, a
7
- * `multiple` pick appends to it. */
8
+ * `multiple` pick appends to it. Removals from the built-in list
9
+ * (and `clear()`) also flow through here. */
8
10
  onChange: (files: File[]) => void;
11
+ /** Comma-separated accept tokens (`.txt`, `image/*`, `text/plain`) —
12
+ * the same grammar the native picker uses. Dropped files that do not
13
+ * match are discarded silently (the native dialog already enforces
14
+ * this for click picks). */
9
15
  accept?: string;
16
+ /** Gate for the drag-and-drop affordance. `true` (default) renders
17
+ * the dashed drop area with a drag-over highlight and accepts dropped
18
+ * files; `false` renders a plain click-only picker area. */
19
+ droppable?: boolean;
20
+ /** Gatekeeper applied to every file — click picks and drops alike —
21
+ * before it enters the value: return `false` (or a promise resolving
22
+ * to `false`) to drop the file. Verdicts for one pick are awaited
23
+ * together (`Promise.all`) and committed as a single `onChange` once
24
+ * every verdict resolved; the UI is not blocked while waiting.
25
+ * A refused file never enters the list, so it never uploads. */
26
+ beforeUpload?: (file: File) => boolean | Promise<boolean>;
27
+ /** Cap for the committed list. Applied last: existing entries win,
28
+ * then the freshly picked survivors; anything beyond the first
29
+ * `maxCount` entries is discarded silently. */
30
+ maxCount?: number;
31
+ /** A `multiple` pick appends to `value`, a single pick replaces it. */
10
32
  multiple?: boolean;
33
+ /**
34
+ * Custom upload executor. When given, every file entering the list
35
+ * (see `manual`) runs through it: call `options.onProgress` with a
36
+ * 0–100 percent, honor `options.signal` for cancellation, resolve on
37
+ * success and reject on failure. Takes precedence over `action`.
38
+ * Neither `request` nor `action` → pure collection mode, exactly the
39
+ * pre-executor behavior.
40
+ */
41
+ request?: UploadRequest;
42
+ /**
43
+ * Upload endpoint for the built-in XHR executor: the file is sent as
44
+ * multipart FormData (field `name`, extra fields `data`) with `method`
45
+ * and `headers`; progress is wired to `xhr.upload.onprogress` and
46
+ * cancellation to `xhr.abort()`. Ignored when `request` is given.
47
+ */
48
+ action?: string;
49
+ /** HTTP method for `action` uploads — defaults to `POST`. */
50
+ method?: string;
51
+ /** Extra request headers for `action` uploads. */
52
+ headers?: Record<string, string>;
53
+ /** Form field name carrying the file in `action` mode — defaults
54
+ * to `file`. */
55
+ name?: string;
56
+ /** Extra form fields appended alongside the file in `action` mode. */
57
+ data?: Record<string, string | Blob>;
58
+ /**
59
+ * `true` keeps picked files at `idle` — the upload only starts via
60
+ * the `UploadHandle` ref (`upload()`/`uploadAll()`). Only meaningful
61
+ * with `request` or `action`.
62
+ */
63
+ manual?: boolean;
64
+ /**
65
+ * Renders the built-in file list below the zone (default `false`):
66
+ * file name, live progress (reusing `Progress`), status icon and
67
+ * per-state actions — cancel while uploading, retry + remove on
68
+ * error, remove otherwise. Pass an `itemRender` to replace whole
69
+ * rows. Without `request`/`action` the list still tracks picks as
70
+ * `idle` rows with remove actions.
71
+ */
72
+ showUploadList?: boolean | {
73
+ itemRender?: UploadListItemRender;
74
+ };
75
+ /**
76
+ * Fires whenever the tracked entries change (added, removed, status
77
+ * or percent) with the complete snapshot in value order. Only tracks
78
+ * while `request`/`action` or `showUploadList` is in play.
79
+ */
80
+ onStatusChange?: (files: UploadFileStatus[]) => void;
11
81
  className?: string;
12
82
  children?: ReactNode;
13
- } & Omit<ComponentPropsWithoutRef<'div'>, 'value' | 'onChange' | 'children' | 'onClick' | 'onDrop' | 'onDragOver' | 'role' | 'tabIndex'>;
14
- export default function UploadCore({ value, onChange, accept, multiple, className, children, ...rest }: UploadCoreProps): import("react").JSX.Element;
83
+ ref?: Ref<UploadHandle>;
84
+ } & Omit<ComponentPropsWithoutRef<'div'>, 'value' | 'onChange' | 'children' | 'onClick' | 'onDrop' | 'onDragOver' | 'onDragEnter' | 'onDragLeave' | 'onKeyDown' | 'role' | 'tabIndex'>;
85
+ export default function UploadCore({ value, onChange, accept, droppable, beforeUpload, maxCount, multiple, request, action, method, headers, name, data, manual, showUploadList, onStatusChange, className, children, ref, ...rest }: UploadCoreProps): import("react").JSX.Element;
15
86
  export type { UploadCoreProps };
@@ -0,0 +1,12 @@
1
+ import type { UploadEntry, UploadListItemRender } from './types';
2
+ type UploadListProps = {
3
+ /** Tracked rows, in value order. */
4
+ entries: UploadEntry[];
5
+ /** Replaces the default row rendering entirely. */
6
+ itemRender?: UploadListItemRender;
7
+ onRemove: (file: File) => void;
8
+ onRetry: (file: File) => void;
9
+ onCancel: (file: File) => void;
10
+ };
11
+ export default function UploadList({ entries, itemRender, onRemove, onRetry, onCancel, }: UploadListProps): import("react").JSX.Element;
12
+ export type { UploadListProps };
@@ -2,3 +2,4 @@ export { default as Upload } from './Upload';
2
2
  export type { UploadProps } from './Upload';
3
3
  export { default as UploadCore } from './UploadCore';
4
4
  export type { UploadCoreProps } from './UploadCore';
5
+ export type { UploadHandle, UploadStatus, UploadFileStatus, UploadRequest, UploadRequestOptions, UploadListItemActions, UploadListItemRender, } from './types';
@@ -0,0 +1,60 @@
1
+ import type { ReactNode } from 'react';
2
+ /** Lifecycle of one tracked file while an upload executor (`request`
3
+ * or `action`) is armed. */
4
+ type UploadStatus = 'idle' | 'uploading' | 'success' | 'error';
5
+ /** Status snapshot for one tracked file — the shape surfaced through
6
+ * `onStatusChange` and `showUploadList.itemRender`. */
7
+ type UploadFileStatus = {
8
+ file: File;
9
+ status: UploadStatus;
10
+ /** 0–100, clamped; forced to 100 when the upload succeeds. */
11
+ percent: number;
12
+ };
13
+ /** Runtime handed to a custom `request` (and used internally by the
14
+ * XHR wrapper that `action` mode builds). */
15
+ type UploadRequestOptions = {
16
+ /** Report progress; values are clamped to 0–100. */
17
+ onProgress: (percent: number) => void;
18
+ /** Aborted when the upload is cancelled, removed or cleared — wire
19
+ * it to the underlying transport. */
20
+ signal: AbortSignal;
21
+ };
22
+ /** Custom upload executor: resolve on success, reject on failure.
23
+ * Rejecting with an `AbortError` `DOMException` (or after `signal`
24
+ * aborted) maps the file back to `idle` instead of `error`. */
25
+ type UploadRequest = (file: File, options: UploadRequestOptions) => Promise<void>;
26
+ /** Row-level callbacks handed to a custom `itemRender`. */
27
+ type UploadListItemActions = {
28
+ /** Abort the upload if in flight, then drop the file from the list. */
29
+ remove: () => void;
30
+ /** Re-run the upload. No-op unless the file errored. */
31
+ retry: () => void;
32
+ /** Abort the in-flight upload and drop the file (uploading state). */
33
+ cancel: () => void;
34
+ };
35
+ /** Custom renderer replacing a built-in list row. */
36
+ type UploadListItemRender = (file: File, status: UploadStatus, percent: number, actions: UploadListItemActions) => ReactNode;
37
+ /**
38
+ * Imperative surface (`ref.current?.…`) — the same React 19
39
+ * ref-as-prop channel `DialogHandle` uses:
40
+ *
41
+ * - `upload(file?)` — start every pending file (idle or error); with a
42
+ * `file`, (re)start just that one.
43
+ * - `uploadAll()` — (re)start every file that is not currently
44
+ * uploading, successful ones included.
45
+ * - `abort()` — abort every in-flight upload; aborted files return to
46
+ * `idle` and stay in the list.
47
+ * - `clear()` — abort everything and empty the list (`onChange([])`).
48
+ */
49
+ type UploadHandle = {
50
+ upload: (file?: File) => void;
51
+ uploadAll: () => void;
52
+ abort: () => void;
53
+ clear: () => void;
54
+ };
55
+ /** Internal tracked row: public status snapshot plus the stable uid the
56
+ * list keys on (File objects have no serializable identity). */
57
+ type UploadEntry = UploadFileStatus & {
58
+ uid: string;
59
+ };
60
+ export type { UploadStatus, UploadFileStatus, UploadRequestOptions, UploadRequest, UploadListItemActions, UploadListItemRender, UploadHandle, UploadEntry, };
@@ -0,0 +1,20 @@
1
+ import type { UploadRequest } from './types';
2
+ type XhrUploadConfig = {
3
+ /** Upload endpoint URL. */
4
+ action: string;
5
+ /** HTTP method — defaults to `POST`. */
6
+ method?: string;
7
+ /** Extra request headers. */
8
+ headers?: Record<string, string>;
9
+ /** Form field name carrying the file — defaults to `file`. */
10
+ name?: string;
11
+ /** Extra form fields appended alongside the file. */
12
+ data?: Record<string, string | Blob>;
13
+ };
14
+ /** Builds the executor used when only `action` (plus optional
15
+ * `method`/`headers`/`name`/`data`) is given: a multipart FormData
16
+ * upload via XHR with progress wired to `xhr.upload.onprogress` and
17
+ * abort wired to `xhr.abort()`. */
18
+ declare function createXhrRequest(config: XhrUploadConfig): UploadRequest;
19
+ export type { XhrUploadConfig };
20
+ export { createXhrRequest };
@@ -57,8 +57,23 @@ type VirtualListProps<T> = {
57
57
  renderItem: (item: T, index: number) => ReactNode;
58
58
  /** Extra rows kept mounted above/below the visible window. */
59
59
  overscan?: number;
60
+ /**
61
+ * Chat orientation (opt-in): rows anchor to the scrollport bottom with
62
+ * index 0 at the bottom edge and later indices stacking upward — the
63
+ * natural geometry for a newest-at-bottom log where new items are
64
+ * prepended. The viewport parks at the bottom on mount and stays glued
65
+ * there across appends while the user is parked at the bottom; a
66
+ * reader who scrolled up keeps their position (rows keep their
67
+ * top-origin coordinates as content grows upward, so nothing jumps).
68
+ *
69
+ * `scrollToIndex` keeps its signature; alignments mirror vertically —
70
+ * `'start'` pins the row's bottom edge to the viewport bottom,
71
+ * `'end'` its top edge to the viewport top. The `VirtualListHandle`
72
+ * API is unchanged.
73
+ */
74
+ reverse?: boolean;
60
75
  className?: string;
61
76
  ref?: Ref<VirtualListHandle>;
62
77
  } & Omit<ComponentPropsWithoutRef<'div'>, 'children'>;
63
- export default function VirtualList<T>({ items, height, itemHeight, estimatedItemHeight, groups, renderItem, overscan, className, style, ref, ...rest }: VirtualListProps<T>): import("react").JSX.Element;
78
+ export default function VirtualList<T>({ items, height, itemHeight, estimatedItemHeight, groups, renderItem, overscan, reverse, className, style, ref, ...rest }: VirtualListProps<T>): import("react").JSX.Element;
64
79
  export type { VirtualListProps, VirtualListHandle, VirtualListGroup, VirtualListAlign, };
@@ -0,0 +1,32 @@
1
+ import type { ComponentPropsWithoutRef, ReactNode } from 'react';
2
+ export type WatermarkFont = {
3
+ /** Font size in px (canvas metrics, not CSS). */
4
+ size?: number;
5
+ /** Any CSS color; defaults to the theme's `--haze-color-text-muted`. */
6
+ color?: string;
7
+ /** Numeric font weight. */
8
+ weight?: number;
9
+ /** CSS font-family stack; falls back to the page's sans stack. */
10
+ family?: string;
11
+ };
12
+ type WatermarkProps = {
13
+ /** Watermark text; an array renders stacked lines. */
14
+ content: string | string[];
15
+ /** Typography of the drawn text. */
16
+ font?: WatermarkFont;
17
+ /** Rotation in degrees. */
18
+ rotate?: number;
19
+ /** Space between tiles, in px — one number or `[x, y]`. */
20
+ gap?: number | [number, number];
21
+ /** `[x, y]` offset of the tile grid origin, in px. */
22
+ offset?: [number, number];
23
+ /** Overlay stacking order. */
24
+ zIndex?: number;
25
+ /** Span the whole viewport (fixed) instead of the container. */
26
+ fullscreen?: boolean;
27
+ /** Content to watermark; with children the component becomes its container. */
28
+ children?: ReactNode;
29
+ className?: string;
30
+ } & Omit<ComponentPropsWithoutRef<'div'>, 'children' | 'className' | 'content'>;
31
+ export default function Watermark({ content, font, rotate, gap, offset, zIndex, fullscreen, children, className, style, ...rest }: WatermarkProps): import("react").JSX.Element;
32
+ export type { WatermarkProps };
@@ -0,0 +1,2 @@
1
+ export { default as Watermark } from './Watermark';
2
+ export type { WatermarkProps, WatermarkFont } from './Watermark';
@@ -1,5 +1,5 @@
1
1
  import type { ComponentPropsWithoutRef, ComponentType, ReactNode } from 'react';
2
- import type { FieldError, FieldPath, FieldRules, Name, ValidationMode, FormInstance, PathValueOf } from 'react-f0rm';
2
+ import type { FieldError, FieldPath, FieldRules, Name, Path, ValidationMode, FormInstance, PathValueOf } from 'react-f0rm';
3
3
  /**
4
4
  * Field-level validator, structurally compatible with react-f0rm's
5
5
  * `Validator`: return an error (string, FieldError, or an array mixing
@@ -11,9 +11,15 @@ import type { FieldError, FieldPath, FieldRules, Name, ValidationMode, FormInsta
11
11
  * the value argument is `PathValueOf<TValues, P>` — the field's actual
12
12
  * type — instead of `any`. The bare defaults keep untyped call sites
13
13
  * exactly as permissive as before.
14
+ *
15
+ * The `meta` shape mirrors react-f0rm's `Validator` (`form`/`path`/
16
+ * `signal`) on purpose, so its resolver adapters — `zodResolver`,
17
+ * `standardSchemaResolver` from `react-f0rm/resolvers/*` — slot straight
18
+ * into `FormItem`'s `validate` prop without a wrapper.
14
19
  */
15
20
  export type FieldValidator<TValues extends Record<string, any> = any, P extends FieldPath<TValues> | Name = Name> = (value: PathValueOf<TValues, P>, meta: {
16
21
  form: FormInstance;
22
+ path: Path;
17
23
  signal: AbortSignal;
18
24
  }) => string | FieldError | (string | FieldError)[] | undefined | Promise<string | FieldError | (string | FieldError)[] | undefined>;
19
25
  /** Render binding handed to `FormItem`'s render-prop children. */
@@ -37,6 +43,15 @@ export type FormItemBinding<TValues, P extends FieldPath<TValues> | Name> = {
37
43
  * It routes through the same mode-gated, re-validating pipeline as
38
44
  * react-f0rm's built-in Field/Checkbox/Select. */
39
45
  onChange: (next: PathValueOf<TValues, P>) => void;
46
+ /**
47
+ * react-f0rm's focus channel (callback ref): attach it to the
48
+ * control's `ref` (`<InputCore ref={focusRef} />`) so
49
+ * `setFocus(form, name)` and a failed submit's first-error
50
+ * auto-focus can reach this field's element. Without it, focus
51
+ * requests aimed at this field are silent no-ops (react-f0rm's
52
+ * `setFocus` contract).
53
+ */
54
+ focusRef: (el: any) => void;
40
55
  };
41
56
  /**
42
57
  * Declarative `as` binding for `FormItem` — the same props shape as
@@ -87,7 +102,12 @@ export type FormItemRawElementBinding<TRawElement extends FormItemRawElement = F
87
102
  * consumes regardless of how the control is bound (render-prop, `as`
88
103
  * or `input`). */
89
104
  export type FormItemOwnProps<TValues extends Record<string, any> = any, P extends FieldPath<TValues> | Name = Name> = {
90
- form: FormInstance<TValues>;
105
+ /**
106
+ * 表单实例(`useForm()`/`createForm()` 的返回值)。可省略:省略时从
107
+ * 最近的 `<FormProvider value={form}>` 读取(react-f0rm 的 form
108
+ * context),显式传入的 `form` 总是优先。两者都没有时 throw。
109
+ */
110
+ form?: FormInstance<TValues>;
91
111
  name: P;
92
112
  label?: ReactNode;
93
113
  /** Field-level validator, registered through react-f0rm's own
@@ -131,6 +151,9 @@ export type FormItemOwnProps<TValues extends Record<string, any> = any, P extend
131
151
  */
132
152
  type FormItemWiredProps = {
133
153
  id?: unknown;
154
+ /** the focus channel: react-f0rm's `focusRef` rides the control's
155
+ * `ref` — `setFocus` and failed-submit auto-focus depend on it */
156
+ ref?: unknown;
134
157
  onBlur?: unknown;
135
158
  onChange?: unknown;
136
159
  /** the value channel: `value` directly, or the prop `valueToProps`
@@ -231,11 +254,13 @@ export type FormItemProps<TValues extends Record<string, any> = any, P extends F
231
254
  *
232
255
  * With `as`, the id/aria/onBlur/onChange wiring happens here: the control
233
256
  * gets `id`, `aria-invalid`/`aria-describedby` while the field errors,
234
- * and `onChange={(v) => onChange(toValue(v))}` where `toValue` defaults
257
+ * `onChange={(v) => onChange(toValue(v))}` where `toValue` defaults
235
258
  * to identity (haze cores emit plain values — pass
236
259
  * `eventToValue={(e) => e.target.value}` for a raw DOM element) and the
237
260
  * value lands as `{value}` or, with `valueToProps`, whatever props the
238
- * control wants (e.g. `{checked}` for CheckboxCore).
261
+ * control wants (e.g. `{checked}` for CheckboxCore). react-f0rm's focus
262
+ * channel rides the control's `ref`, so `setFocus(form, name)` and a
263
+ * failed submit's first-error auto-focus reach the field's element.
239
264
  *
240
265
  * The ergonomic form for haze-ui cores is `input`: the rest of the JSX
241
266
  * props — and JSX children, e.g. a `SelectCore`'s `<option>`s — are
@@ -252,10 +277,10 @@ export type FormItemProps<TValues extends Record<string, any> = any, P extends F
252
277
  * />
253
278
  * ```
254
279
  *
255
- * The same wiring as `as` applies (id, aria, onBlur, onChange, value);
256
- * wired and FormItem-owned prop names are reserved — a control prop that
257
- * collides (CheckboxCore's `label`) needs the render-prop or
258
- * `as`/`asProps` channel.
280
+ * The same wiring as `as` applies (id, aria, onBlur, onChange, value,
281
+ * and the `ref`-riding focus channel); wired and FormItem-owned prop
282
+ * names are reserved — a control prop that collides (CheckboxCore's
283
+ * `label`) needs the render-prop or `as`/`asProps` channel.
259
284
  *
260
285
  * `input` also accepts raw DOM bindings — no core required:
261
286
  *
@@ -0,0 +1,113 @@
1
+ import type { ReactNode } from 'react';
2
+ import type { FieldPath, FieldRules, FormInstance, Name } from 'react-f0rm';
3
+ /**
4
+ * `fields` 数组的元素 —— react-f0rm `useFieldArray` 的行描述透传:
5
+ * 稳定行 key、当前索引,以及 `keyName` 指定属性名下的同值别名
6
+ * (默认 `id`,自定义名如 `'key'` 用于避开行数据自带的同名字段)。
7
+ */
8
+ export type FormListField<K extends string = 'id'> = {
9
+ /** 行的稳定 id:跨 append/remove/swap/move 跟随数据行本身,
10
+ * 渲染列表时直接作 React key(绝不要用 index 当 key)。 */
11
+ id: string;
12
+ /** 行的当前位置:remove/move/swap/insert 之后随数据迁移。 */
13
+ index: number;
14
+ } & Record<K, string>;
15
+ /**
16
+ * FormList 的 render-prop 入参 —— react-f0rm `useFieldArray` 返回值
17
+ * (`UseFieldArrayResult`)的结构透传。f0rm 主入口不导出该类型,这里按
18
+ * 其形状镜像声明;`useFieldArray` 的真实返回值直接满足本类型。
19
+ */
20
+ export type FormListBinding<K extends string = 'id'> = {
21
+ /** 行列表:每行带稳定 key(`id` 或 `keyName` 指定的属性)与当前索引。 */
22
+ fields: FormListField<K>[];
23
+ /** 在数组末尾追加一行。 */
24
+ append: (value: any) => void;
25
+ /** 在数组头部插入一行。 */
26
+ prepend: (value: any) => void;
27
+ /** 在 `index` 处插入一行,其后各行顺移。 */
28
+ insert: (index: number, value: any) => void;
29
+ /** 删除 `index` 处的行,其后各行前移(行 key 随数据行消失)。 */
30
+ remove: (index: number) => void;
31
+ /** 交换两行位置:只动这两行,中间行不动。 */
32
+ swap: (from: number, to: number) => void;
33
+ /** 把 `from` 行移动到 `to` 位置,中间行整体顺移。 */
34
+ move: (from: number, to: number) => void;
35
+ /** 整表替换:清空后按 `values` 重建全部行。 */
36
+ replace: (values: any[]) => void;
37
+ /** 原位覆写 `index` 行的值:行 key 与位置保持不变。 */
38
+ update: (index: number, value: any) => void;
39
+ };
40
+ /** FormList 自身的 props —— `useFieldArray` 选项的组件化外壳。 */
41
+ export type FormListProps<TValues extends Record<string, any> = any, P extends FieldPath<TValues> | Name = Name, K extends string = 'id'> = {
42
+ /**
43
+ * 表单实例(`useForm()`/`createForm()` 的返回值)。可省略:省略时从
44
+ * 最近的 `<FormProvider value={form}>` 读取(react-f0rm 的 form
45
+ * context);显式传入的 `form` 总是优先。
46
+ */
47
+ form?: FormInstance<TValues>;
48
+ /** 数组字段的路径,如 `'tags'`。 */
49
+ name: P;
50
+ /**
51
+ * 稳定行 key 在每个 `fields` 条目上暴露的属性名(默认 `'id'`);
52
+ * 行数据自带同名字段时换一个(如 `'key'`)避免覆盖,底层 id 不变。
53
+ */
54
+ keyName?: K;
55
+ /**
56
+ * 声明式规则,对整个数组值校验(react-hook-form `useFieldArray` 的
57
+ * `rules`):`required` 空数组失败,`minLength`/`maxLength` 读行数。
58
+ * 与字段级规则一样在 submit 与 `trigger` 时运行。
59
+ */
60
+ rules?: FieldRules;
61
+ /**
62
+ * 卸载本组件时是否移除整个数组分支(含各行数据)。默认跟随表单级
63
+ * `shouldUnregister`;传 `false` 保留数据。
64
+ */
65
+ shouldUnregister?: boolean;
66
+ className?: string;
67
+ /** render-prop:收到数组操作句柄,渲染整张行列表。 */
68
+ children: (binding: FormListBinding<K>) => ReactNode;
69
+ };
70
+ /**
71
+ * 数组字段的组件外壳:包住 react-f0rm 1.3 的 `useFieldArray`,把行
72
+ * 列表与增删换位操作以 render-prop 交给消费者。headless —— 不带任何
73
+ * 内置布局,只渲染一个可挂 `className` 的壳 `<div>`;行怎么排、按钮
74
+ * 怎么放完全由 children 决定。
75
+ *
76
+ * `form` 可省略:省略时从最近的 `<FormProvider value={form}>` 回退读取;
77
+ * 两者都没有时 throw。`keyName`/`rules`/`shouldUnregister` 原样透传给
78
+ * `useFieldArray`。
79
+ *
80
+ * **行内编辑的保留(物化时机)**:react-f0rm 的数组操作从「数组层的
81
+ * 上一次物化」读取整表,行内控件(如 `name={['tags', i, 'label']}` 的
82
+ * FormItem)的编辑先是挂在更深层的待合并写入——直接 append/remove 会
83
+ * 让它们被下一代覆盖丢失。FormList 在每个读旧值的操作(append/
84
+ * prepend/insert/remove/swap/move/update)前,先用 `getValues()` 的
85
+ * 合并视图把数组分支物化一次,行内编辑因此跨操作保留——与
86
+ * react-hook-form / TanStack Form 的行为一致。`replace` 不读旧值,
87
+ * 原样透传;`update`/`replace` 的显式值仍然覆盖对应行的行内编辑。
88
+ *
89
+ * ```tsx
90
+ * <FormList form={form} name='tags'>
91
+ * {({fields, append, remove}) => (
92
+ * <>
93
+ * {fields.map((field) => (
94
+ * <div key={field.id}>
95
+ * <FormItem
96
+ * form={form}
97
+ * name={['tags', field.index, 'label']}
98
+ * input={InputCore}
99
+ * />
100
+ * <Button onClick={() => remove(field.index)}>Remove</Button>
101
+ * </div>
102
+ * ))}
103
+ * <Button onClick={() => append({label: ''})}>Add tag</Button>
104
+ * </>
105
+ * )}
106
+ * </FormList>
107
+ * ```
108
+ *
109
+ * 行 key 用 `field.id`(或 `keyName` 指定的属性)——不要用 index:
110
+ * remove/swap/move 之后 index 会迁移,index key 会让 React 把行状态
111
+ * 错配到别的数据行上。
112
+ */
113
+ export default function FormList<TValues extends Record<string, any> = any, P extends FieldPath<TValues> | Name = Name, K extends string = 'id'>({ form, name, keyName, rules, shouldUnregister, className, children }: FormListProps<TValues, P, K>): import("react").JSX.Element;
@@ -1,3 +1,29 @@
1
1
  export { default as FormItem } from './FormItem';
2
2
  export type { FieldValidator, FormItemAsProps, FormItemBinding, FormItemOwnProps, FormItemProps, FormItemRawElement, FormItemRawElementBinding } from './FormItem';
3
+ export { default as FormList } from './FormList';
4
+ export type { FormListBinding, FormListField, FormListProps } from './FormList';
3
5
  export type { FormInstance, PathValueOf } from 'react-f0rm';
6
+ /**
7
+ * react-f0rm 的上下文与命令式 API —— haze-ui form 层的官方透传出口。
8
+ * react-f0rm 是 haze-ui 的普通依赖,从这里 import 即可,无需再直接
9
+ * 依赖 react-f0rm。`<FormProvider value={form}>` 挂 context 后,子树里的
10
+ * `FormItem`/`FormList` 可以省略 `form` prop。
11
+ */
12
+ export { FormProvider, useFormContext, useFieldArray, useFieldArrayItem, useWatch, trigger, setFocus, setServerErrors, setValue, getValue, getValues, reset } from 'react-f0rm';
13
+ /**
14
+ * Standard Schema v1 适配器(react-f0rm/resolvers/standard-schema):
15
+ * 任何实现 `~standard` 的 schema 库通用 —— zod v3.24+/v4、valibot v1、
16
+ * arktype 等。`standardSchemaResolver` 是字段级(FormItem 的
17
+ * `validate`),`standardSchemaFormValidator` 是表单级
18
+ * (`createForm({validate})`,成功时把 schema 解析结果存为
19
+ * parsedValues;经 `./standard-schema` 兜底 react-f0rm 1.3.0 的
20
+ * 品牌符号打包缺陷)。`hasStandardProps` 运行时探测 schema 是否实现了
21
+ * Standard Schema。
22
+ */
23
+ export { hasStandardProps, standardSchemaFormValidator, standardSchemaResolver } from './standard-schema';
24
+ export type { StandardSchemaV1 } from './standard-schema';
25
+ /**
26
+ * zod 专用字段级适配器(react-f0rm/resolvers/zod):schema 实现了
27
+ * Standard Schema 时直接走通用通道,否则走 zod 的 safeParseAsync。
28
+ */
29
+ export { zodResolver } from 'react-f0rm/resolvers/zod';