taro-uno-ui 0.9.0-beta

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 (397) hide show
  1. package/LICENSE +100 -0
  2. package/README.md +273 -0
  3. package/dist/js/index-6NJ3A1Dn.js +26535 -0
  4. package/dist/js/index-6NJ3A1Dn.js.map +1 -0
  5. package/dist/js/index-DFdcksbe.js +1165 -0
  6. package/dist/js/index-DFdcksbe.js.map +1 -0
  7. package/dist/js/index-DXRIkWX1.js +1148 -0
  8. package/dist/js/index-DXRIkWX1.js.map +1 -0
  9. package/dist/js/index-DffLRSro.js +26519 -0
  10. package/dist/js/index-DffLRSro.js.map +1 -0
  11. package/package.json +119 -0
  12. package/src/app.config.ts +55 -0
  13. package/src/app.scss +508 -0
  14. package/src/app.tsx +44 -0
  15. package/src/components/basic/Button/Button.styles.ts +130 -0
  16. package/src/components/basic/Button/Button.test.tsx +154 -0
  17. package/src/components/basic/Button/Button.tsx +93 -0
  18. package/src/components/basic/Button/Button.types.ts +45 -0
  19. package/src/components/basic/Button/index.tsx +6 -0
  20. package/src/components/basic/Divider/Divider.styles.ts +488 -0
  21. package/src/components/basic/Divider/Divider.test.tsx +551 -0
  22. package/src/components/basic/Divider/Divider.tsx +361 -0
  23. package/src/components/basic/Divider/Divider.types.ts +261 -0
  24. package/src/components/basic/Divider/index.tsx +25 -0
  25. package/src/components/basic/Icon/Icon.styles.ts +359 -0
  26. package/src/components/basic/Icon/Icon.test.tsx +357 -0
  27. package/src/components/basic/Icon/Icon.tsx +154 -0
  28. package/src/components/basic/Icon/Icon.types.ts +210 -0
  29. package/src/components/basic/Icon/index.tsx +22 -0
  30. package/src/components/basic/Text/Text.styles.ts +500 -0
  31. package/src/components/basic/Text/Text.test.tsx +299 -0
  32. package/src/components/basic/Text/Text.tsx +340 -0
  33. package/src/components/basic/Text/Text.types.ts +319 -0
  34. package/src/components/basic/Text/index.tsx +27 -0
  35. package/src/components/basic/Typography/Typography.styles.ts +346 -0
  36. package/src/components/basic/Typography/Typography.tsx +205 -0
  37. package/src/components/basic/Typography/Typography.types.ts +296 -0
  38. package/src/components/basic/Typography/index.tsx +14 -0
  39. package/src/components/basic/index.tsx +302 -0
  40. package/src/components/common/ErrorBoundary.tsx +87 -0
  41. package/src/components/common/LazyComponent.tsx +246 -0
  42. package/src/components/common/ResponsiveContainer.tsx +93 -0
  43. package/src/components/common/ResponsiveGrid.tsx +183 -0
  44. package/src/components/common/SecurityProvider.tsx +110 -0
  45. package/src/components/common/ThemeProvider.tsx +128 -0
  46. package/src/components/common/VirtualList.tsx +368 -0
  47. package/src/components/common/__tests__/ErrorBoundary.test.tsx +249 -0
  48. package/src/components/common/index.tsx +7 -0
  49. package/src/components/display/Avatar/Avatar.styles.ts +62 -0
  50. package/src/components/display/Avatar/Avatar.test.tsx +390 -0
  51. package/src/components/display/Avatar/Avatar.tsx +79 -0
  52. package/src/components/display/Avatar/Avatar.types.ts +40 -0
  53. package/src/components/display/Avatar/index.ts +3 -0
  54. package/src/components/display/Badge/Badge.tsx +42 -0
  55. package/src/components/display/Badge/Badge.types.ts +29 -0
  56. package/src/components/display/Badge/index.ts +2 -0
  57. package/src/components/display/Calendar/Calendar.styles.ts +255 -0
  58. package/src/components/display/Calendar/Calendar.test.tsx +30 -0
  59. package/src/components/display/Calendar/Calendar.tsx +337 -0
  60. package/src/components/display/Calendar/Calendar.types.ts +91 -0
  61. package/src/components/display/Calendar/index.ts +3 -0
  62. package/src/components/display/Card/Card.styles.ts +89 -0
  63. package/src/components/display/Card/Card.test.tsx +180 -0
  64. package/src/components/display/Card/Card.tsx +135 -0
  65. package/src/components/display/Card/Card.types.ts +55 -0
  66. package/src/components/display/Card/index.ts +3 -0
  67. package/src/components/display/Carousel/Carousel.styles.ts +206 -0
  68. package/src/components/display/Carousel/Carousel.tsx +295 -0
  69. package/src/components/display/Carousel/Carousel.types.ts +57 -0
  70. package/src/components/display/Carousel/index.ts +3 -0
  71. package/src/components/display/List/List.styles.ts +79 -0
  72. package/src/components/display/List/List.tsx +115 -0
  73. package/src/components/display/List/List.types.ts +68 -0
  74. package/src/components/display/List/index.ts +3 -0
  75. package/src/components/display/Rate/Rate.styles.ts +266 -0
  76. package/src/components/display/Rate/Rate.tsx +332 -0
  77. package/src/components/display/Rate/Rate.types.ts +111 -0
  78. package/src/components/display/Rate/index.ts +28 -0
  79. package/src/components/display/Table/Table.styles.ts +269 -0
  80. package/src/components/display/Table/Table.test.tsx +343 -0
  81. package/src/components/display/Table/Table.tsx +430 -0
  82. package/src/components/display/Table/Table.types.ts +255 -0
  83. package/src/components/display/Table/index.tsx +16 -0
  84. package/src/components/display/Tag/Tag.styles.ts +197 -0
  85. package/src/components/display/Tag/Tag.test.tsx +541 -0
  86. package/src/components/display/Tag/Tag.tsx +156 -0
  87. package/src/components/display/Tag/Tag.types.ts +49 -0
  88. package/src/components/display/Tag/index.ts +3 -0
  89. package/src/components/display/Timeline/Timeline.styles.ts +211 -0
  90. package/src/components/display/Timeline/Timeline.tsx +239 -0
  91. package/src/components/display/Timeline/Timeline.types.ts +56 -0
  92. package/src/components/display/Timeline/index.ts +3 -0
  93. package/src/components/display/index.tsx +143 -0
  94. package/src/components/feedback/Loading/Loading.styles.ts +117 -0
  95. package/src/components/feedback/Loading/Loading.test.tsx +534 -0
  96. package/src/components/feedback/Loading/Loading.tsx +127 -0
  97. package/src/components/feedback/Loading/Loading.types.ts +33 -0
  98. package/src/components/feedback/Loading/index.ts +9 -0
  99. package/src/components/feedback/Message/Message.styles.ts +41 -0
  100. package/src/components/feedback/Message/Message.test.tsx +234 -0
  101. package/src/components/feedback/Message/Message.tsx +96 -0
  102. package/src/components/feedback/Message/Message.types.ts +37 -0
  103. package/src/components/feedback/Message/index.ts +9 -0
  104. package/src/components/feedback/Modal/Modal.styles.ts +21 -0
  105. package/src/components/feedback/Modal/Modal.test.tsx +11 -0
  106. package/src/components/feedback/Modal/Modal.tsx +291 -0
  107. package/src/components/feedback/Modal/Modal.types.ts +141 -0
  108. package/src/components/feedback/Modal/index.tsx +11 -0
  109. package/src/components/feedback/Notification/Notification.styles.ts +443 -0
  110. package/src/components/feedback/Notification/Notification.test.tsx +401 -0
  111. package/src/components/feedback/Notification/Notification.tsx +370 -0
  112. package/src/components/feedback/Notification/Notification.types.ts +336 -0
  113. package/src/components/feedback/Notification/NotificationManager.tsx +376 -0
  114. package/src/components/feedback/Notification/index.ts +33 -0
  115. package/src/components/feedback/Notification/index.tsx +164 -0
  116. package/src/components/feedback/Progress/Progress.styles.ts +460 -0
  117. package/src/components/feedback/Progress/Progress.test.simple.tsx +14 -0
  118. package/src/components/feedback/Progress/Progress.test.tsx +312 -0
  119. package/src/components/feedback/Progress/Progress.tsx +508 -0
  120. package/src/components/feedback/Progress/Progress.types.ts +163 -0
  121. package/src/components/feedback/Progress/index.ts +3 -0
  122. package/src/components/feedback/Progress/index.tsx +38 -0
  123. package/src/components/feedback/Progress/utils/animation.ts +204 -0
  124. package/src/components/feedback/Progress/utils/index.ts +26 -0
  125. package/src/components/feedback/Progress/utils/progress-calculator.ts +217 -0
  126. package/src/components/feedback/Result/Result.styles.ts +139 -0
  127. package/src/components/feedback/Result/Result.tsx +233 -0
  128. package/src/components/feedback/Result/Result.types.ts +128 -0
  129. package/src/components/feedback/Result/index.tsx +3 -0
  130. package/src/components/feedback/Toast/Toast.styles.ts +17 -0
  131. package/src/components/feedback/Toast/Toast.test.tsx +10 -0
  132. package/src/components/feedback/Toast/Toast.tsx +372 -0
  133. package/src/components/feedback/Toast/Toast.types.ts +86 -0
  134. package/src/components/feedback/Toast/index.tsx +3 -0
  135. package/src/components/feedback/Tooltip/Tooltip.examples.tsx +458 -0
  136. package/src/components/feedback/Tooltip/Tooltip.styles.ts +346 -0
  137. package/src/components/feedback/Tooltip/Tooltip.test.tsx +446 -0
  138. package/src/components/feedback/Tooltip/Tooltip.tsx +283 -0
  139. package/src/components/feedback/Tooltip/Tooltip.types.ts +172 -0
  140. package/src/components/feedback/Tooltip/index.ts +3 -0
  141. package/src/components/feedback/Tooltip/index.tsx +258 -0
  142. package/src/components/feedback/index.tsx +164 -0
  143. package/src/components/form/Cascader/Cascader.styles.ts +526 -0
  144. package/src/components/form/Cascader/Cascader.test.tsx +77 -0
  145. package/src/components/form/Cascader/Cascader.tsx +585 -0
  146. package/src/components/form/Cascader/Cascader.types.ts +582 -0
  147. package/src/components/form/Cascader/hooks/index.ts +3 -0
  148. package/src/components/form/Cascader/hooks/useCascaderFieldNames.ts +16 -0
  149. package/src/components/form/Cascader/hooks/useCascaderOptions.ts +109 -0
  150. package/src/components/form/Cascader/hooks/useCascaderState.ts +133 -0
  151. package/src/components/form/Cascader/index.ts +25 -0
  152. package/src/components/form/Cascader/utils/formatDisplayValue.ts +19 -0
  153. package/src/components/form/Cascader/utils/index.ts +1 -0
  154. package/src/components/form/Checkbox/Checkbox.styles.ts +608 -0
  155. package/src/components/form/Checkbox/Checkbox.test.tsx +1140 -0
  156. package/src/components/form/Checkbox/Checkbox.tsx +496 -0
  157. package/src/components/form/Checkbox/Checkbox.types.ts +472 -0
  158. package/src/components/form/Checkbox/CheckboxGroup.tsx +444 -0
  159. package/src/components/form/Checkbox/index.tsx +27 -0
  160. package/src/components/form/DatePicker/DatePicker.styles.ts +393 -0
  161. package/src/components/form/DatePicker/DatePicker.test.tsx +407 -0
  162. package/src/components/form/DatePicker/DatePicker.tsx +360 -0
  163. package/src/components/form/DatePicker/DatePicker.types.ts +247 -0
  164. package/src/components/form/DatePicker/index.tsx +15 -0
  165. package/src/components/form/Form/Form.styles.ts +357 -0
  166. package/src/components/form/Form/Form.test.tsx +122 -0
  167. package/src/components/form/Form/Form.tsx +695 -0
  168. package/src/components/form/Form/Form.types.ts +407 -0
  169. package/src/components/form/Form/index.tsx +31 -0
  170. package/src/components/form/Input/Input.enhanced.tsx +732 -0
  171. package/src/components/form/Input/Input.styles.ts +438 -0
  172. package/src/components/form/Input/Input.test.tsx +494 -0
  173. package/src/components/form/Input/Input.tsx +541 -0
  174. package/src/components/form/Input/Input.types.ts +285 -0
  175. package/src/components/form/Input/index.tsx +26 -0
  176. package/src/components/form/InputNumber/InputNumber.styles.ts +665 -0
  177. package/src/components/form/InputNumber/InputNumber.tsx +370 -0
  178. package/src/components/form/InputNumber/InputNumber.types.ts +318 -0
  179. package/src/components/form/InputNumber/components/InputNumberClearButton.tsx +32 -0
  180. package/src/components/form/InputNumber/components/InputNumberControls.tsx +42 -0
  181. package/src/components/form/InputNumber/components/index.ts +2 -0
  182. package/src/components/form/InputNumber/hooks/index.ts +4 -0
  183. package/src/components/form/InputNumber/hooks/useInputNumberState.ts +315 -0
  184. package/src/components/form/InputNumber/hooks/useInputNumberValidation.ts +147 -0
  185. package/src/components/form/InputNumber/index.ts +25 -0
  186. package/src/components/form/Radio/Radio.styles.ts +458 -0
  187. package/src/components/form/Radio/Radio.test.tsx +547 -0
  188. package/src/components/form/Radio/Radio.tsx +283 -0
  189. package/src/components/form/Radio/Radio.types.ts +410 -0
  190. package/src/components/form/Radio/index.tsx +21 -0
  191. package/src/components/form/Select/Select.styles.ts +514 -0
  192. package/src/components/form/Select/Select.test.tsx +648 -0
  193. package/src/components/form/Select/Select.tsx +474 -0
  194. package/src/components/form/Select/Select.types.ts +428 -0
  195. package/src/components/form/Select/index.tsx +30 -0
  196. package/src/components/form/Slider/Slider.styles.ts +139 -0
  197. package/src/components/form/Slider/Slider.test.tsx +553 -0
  198. package/src/components/form/Slider/Slider.tsx +326 -0
  199. package/src/components/form/Slider/Slider.types.ts +108 -0
  200. package/src/components/form/Slider/index.tsx +10 -0
  201. package/src/components/form/Switch/Switch.styles.ts +540 -0
  202. package/src/components/form/Switch/Switch.test.tsx +345 -0
  203. package/src/components/form/Switch/Switch.tsx +464 -0
  204. package/src/components/form/Switch/Switch.types.ts +386 -0
  205. package/src/components/form/Switch/index.tsx +26 -0
  206. package/src/components/form/Textarea/Textarea.styles.ts +592 -0
  207. package/src/components/form/Textarea/Textarea.test.tsx +1075 -0
  208. package/src/components/form/Textarea/Textarea.tsx +602 -0
  209. package/src/components/form/Textarea/Textarea.types.ts +371 -0
  210. package/src/components/form/Textarea/index.tsx +26 -0
  211. package/src/components/form/TimePicker/TimePicker.styles.ts +438 -0
  212. package/src/components/form/TimePicker/TimePicker.test.tsx +306 -0
  213. package/src/components/form/TimePicker/TimePicker.tsx +228 -0
  214. package/src/components/form/TimePicker/TimePicker.types.ts +385 -0
  215. package/src/components/form/TimePicker/index.ts +21 -0
  216. package/src/components/form/Transfer/Transfer.styles.ts +502 -0
  217. package/src/components/form/Transfer/Transfer.test.tsx +316 -0
  218. package/src/components/form/Transfer/Transfer.tsx +402 -0
  219. package/src/components/form/Transfer/Transfer.types.ts +557 -0
  220. package/src/components/form/Transfer/components/TransferItem.tsx +101 -0
  221. package/src/components/form/Transfer/components/TransferList.tsx +285 -0
  222. package/src/components/form/Transfer/components/TransferOperations.tsx +84 -0
  223. package/src/components/form/Transfer/components/TransferPagination.tsx +135 -0
  224. package/src/components/form/Transfer/components/TransferSearch.tsx +88 -0
  225. package/src/components/form/Transfer/components/index.ts +6 -0
  226. package/src/components/form/Transfer/hooks/index.ts +3 -0
  227. package/src/components/form/Transfer/hooks/useTransferData.ts +192 -0
  228. package/src/components/form/Transfer/hooks/useTransferState.ts +114 -0
  229. package/src/components/form/Transfer/index.ts +33 -0
  230. package/src/components/form/Upload/Upload.styles.ts +145 -0
  231. package/src/components/form/Upload/Upload.test.tsx +10 -0
  232. package/src/components/form/Upload/Upload.tsx +451 -0
  233. package/src/components/form/Upload/Upload.types.ts +200 -0
  234. package/src/components/form/Upload/index.tsx +12 -0
  235. package/src/components/form/index.tsx +121 -0
  236. package/src/components/index.tsx +146 -0
  237. package/src/components/layout/Affix/Affix.styles.ts +37 -0
  238. package/src/components/layout/Affix/Affix.test.tsx +10 -0
  239. package/src/components/layout/Affix/Affix.tsx +91 -0
  240. package/src/components/layout/Affix/Affix.types.ts +29 -0
  241. package/src/components/layout/Affix/index.tsx +3 -0
  242. package/src/components/layout/Col/Col.styles.ts +185 -0
  243. package/src/components/layout/Col/Col.test.tsx +535 -0
  244. package/src/components/layout/Col/Col.tsx +115 -0
  245. package/src/components/layout/Col/Col.types.ts +59 -0
  246. package/src/components/layout/Col/index.tsx +3 -0
  247. package/src/components/layout/Container/Container.styles.ts +161 -0
  248. package/src/components/layout/Container/Container.test.tsx +380 -0
  249. package/src/components/layout/Container/Container.tsx +132 -0
  250. package/src/components/layout/Container/Container.types.ts +63 -0
  251. package/src/components/layout/Container/index.tsx +3 -0
  252. package/src/components/layout/Grid/Grid.styles.ts +183 -0
  253. package/src/components/layout/Grid/Grid.test.tsx +637 -0
  254. package/src/components/layout/Grid/Grid.tsx +173 -0
  255. package/src/components/layout/Grid/Grid.types.ts +78 -0
  256. package/src/components/layout/Grid/index.tsx +3 -0
  257. package/src/components/layout/Layout/Content.tsx +38 -0
  258. package/src/components/layout/Layout/Footer.tsx +38 -0
  259. package/src/components/layout/Layout/Header.tsx +38 -0
  260. package/src/components/layout/Layout/Layout.styles.ts +84 -0
  261. package/src/components/layout/Layout/Layout.test.tsx +10 -0
  262. package/src/components/layout/Layout/Layout.tsx +39 -0
  263. package/src/components/layout/Layout/Layout.types.ts +58 -0
  264. package/src/components/layout/Layout/Sider.tsx +56 -0
  265. package/src/components/layout/Layout/index.tsx +8 -0
  266. package/src/components/layout/Row/Row.styles.ts +159 -0
  267. package/src/components/layout/Row/Row.test.tsx +467 -0
  268. package/src/components/layout/Row/Row.tsx +139 -0
  269. package/src/components/layout/Row/Row.types.ts +60 -0
  270. package/src/components/layout/Row/index.tsx +3 -0
  271. package/src/components/layout/Space/Space.styles.ts +255 -0
  272. package/src/components/layout/Space/Space.test.tsx +682 -0
  273. package/src/components/layout/Space/Space.tsx +211 -0
  274. package/src/components/layout/Space/Space.types.ts +92 -0
  275. package/src/components/layout/Space/index.tsx +12 -0
  276. package/src/components/layout/index.tsx +68 -0
  277. package/src/components/navigation/Menu/Menu.styles.ts +779 -0
  278. package/src/components/navigation/Menu/Menu.tsx +355 -0
  279. package/src/components/navigation/Menu/Menu.types.ts +231 -0
  280. package/src/components/navigation/Menu/Menu.utils.ts +187 -0
  281. package/src/components/navigation/Menu/MenuItem.tsx +126 -0
  282. package/src/components/navigation/Menu/SubMenu.tsx +148 -0
  283. package/src/components/navigation/Menu/__tests__/Menu.test.tsx +687 -0
  284. package/src/components/navigation/Menu/index.tsx +124 -0
  285. package/src/components/navigation/NavBar/NavBar.styles.ts +129 -0
  286. package/src/components/navigation/NavBar/NavBar.test.tsx +287 -0
  287. package/src/components/navigation/NavBar/NavBar.tsx +231 -0
  288. package/src/components/navigation/NavBar/NavBar.types.ts +54 -0
  289. package/src/components/navigation/NavBar/index.tsx +3 -0
  290. package/src/components/navigation/Pagination/Pagination.styles.ts +187 -0
  291. package/src/components/navigation/Pagination/Pagination.test.tsx +673 -0
  292. package/src/components/navigation/Pagination/Pagination.tsx +395 -0
  293. package/src/components/navigation/Pagination/Pagination.types.ts +86 -0
  294. package/src/components/navigation/Pagination/index.ts +18 -0
  295. package/src/components/navigation/Pagination/index.tsx +9 -0
  296. package/src/components/navigation/Steps/Step.tsx +56 -0
  297. package/src/components/navigation/Steps/Steps.styles.ts +154 -0
  298. package/src/components/navigation/Steps/Steps.test.tsx +12 -0
  299. package/src/components/navigation/Steps/Steps.tsx +113 -0
  300. package/src/components/navigation/Steps/Steps.types.ts +47 -0
  301. package/src/components/navigation/Steps/index.tsx +3 -0
  302. package/src/components/navigation/Tabs/Tabs.styles.ts +199 -0
  303. package/src/components/navigation/Tabs/Tabs.test.tsx +661 -0
  304. package/src/components/navigation/Tabs/Tabs.tsx +253 -0
  305. package/src/components/navigation/Tabs/Tabs.types.ts +114 -0
  306. package/src/components/navigation/Tabs/index.tsx +3 -0
  307. package/src/components/navigation/Tree/Tree.styles.ts +553 -0
  308. package/src/components/navigation/Tree/Tree.test.basic.tsx +7 -0
  309. package/src/components/navigation/Tree/Tree.test.functional.tsx +496 -0
  310. package/src/components/navigation/Tree/Tree.test.import.check.tsx +6 -0
  311. package/src/components/navigation/Tree/Tree.test.import.tsx +6 -0
  312. package/src/components/navigation/Tree/Tree.test.minimal.tsx +5 -0
  313. package/src/components/navigation/Tree/Tree.test.simple.tsx +30 -0
  314. package/src/components/navigation/Tree/Tree.test.tsx +908 -0
  315. package/src/components/navigation/Tree/Tree.test.working.tsx +673 -0
  316. package/src/components/navigation/Tree/Tree.tsx +600 -0
  317. package/src/components/navigation/Tree/Tree.types.ts +909 -0
  318. package/src/components/navigation/Tree/Tree.utils.ts +452 -0
  319. package/src/components/navigation/Tree/index.ts +33 -0
  320. package/src/components/navigation/Tree/index.tsx +23 -0
  321. package/src/components/navigation/index.tsx +83 -0
  322. package/src/constants/index.ts +785 -0
  323. package/src/hooks/index.ts +110 -0
  324. package/src/hooks/types.ts +10 -0
  325. package/src/hooks/useAsync.ts +65 -0
  326. package/src/hooks/useEventHandling.ts +444 -0
  327. package/src/hooks/useLifecycle.ts +399 -0
  328. package/src/hooks/usePerformance.ts +441 -0
  329. package/src/hooks/usePerformanceMonitor.ts +348 -0
  330. package/src/hooks/usePlatform.ts +62 -0
  331. package/src/hooks/useRequest.test.ts +11 -0
  332. package/src/hooks/useRequest.ts +135 -0
  333. package/src/hooks/useStateManagement.ts +300 -0
  334. package/src/hooks/useStyle.ts +537 -0
  335. package/src/hooks/useTheme.ts +347 -0
  336. package/src/hooks/useVirtualScroll.ts +331 -0
  337. package/src/index.ts +298 -0
  338. package/src/platform/index.ts +1188 -0
  339. package/src/providers/AppProvider.test.tsx +63 -0
  340. package/src/providers/AppProvider.tsx +155 -0
  341. package/src/providers/index.ts +1 -0
  342. package/src/theme/ThemeProvider.tsx +283 -0
  343. package/src/theme/ThemeProvider.types.ts +26 -0
  344. package/src/theme/animations.tsx +660 -0
  345. package/src/theme/defaults.ts +188 -0
  346. package/src/theme/design-system.ts +562 -0
  347. package/src/theme/design-tokens.ts +1136 -0
  348. package/src/theme/generated/dark-theme.scss +120 -0
  349. package/src/theme/generated/tokens.css +441 -0
  350. package/src/theme/generated/tokens.scss +320 -0
  351. package/src/theme/index.ts +120 -0
  352. package/src/theme/responsive.tsx +193 -0
  353. package/src/theme/styles/mixins.scss +612 -0
  354. package/src/theme/styles/variables.scss +295 -0
  355. package/src/theme/styles.ts +403 -0
  356. package/src/theme/tokens/colors.ts +256 -0
  357. package/src/theme/tokens/effects.ts +260 -0
  358. package/src/theme/tokens/index.ts +217 -0
  359. package/src/theme/tokens/spacing.ts +137 -0
  360. package/src/theme/tokens/typography.ts +186 -0
  361. package/src/theme/types.ts +188 -0
  362. package/src/theme/useThemeUtils.ts +313 -0
  363. package/src/theme/utils.ts +501 -0
  364. package/src/theme/variables.ts +583 -0
  365. package/src/types/accessibility.ts +51 -0
  366. package/src/types/button.ts +562 -0
  367. package/src/types/component-props.ts +317 -0
  368. package/src/types/env.d.ts +20 -0
  369. package/src/types/index.ts +427 -0
  370. package/src/types/modules.d.ts +40 -0
  371. package/src/types/standardized-components.ts +544 -0
  372. package/src/types/taro-adapter.d.ts +174 -0
  373. package/src/types/taro-components.d.ts +73 -0
  374. package/src/types/utils.ts +410 -0
  375. package/src/utils/__tests__/inputValidator.test.ts +338 -0
  376. package/src/utils/__tests__/responsiveUtils.test.ts +310 -0
  377. package/src/utils/__tests__/xssProtection.test.ts +268 -0
  378. package/src/utils/cache.ts +83 -0
  379. package/src/utils/createNamespace.ts +24 -0
  380. package/src/utils/environment.ts +95 -0
  381. package/src/utils/error-handler.ts +88 -0
  382. package/src/utils/errorLogger.ts +197 -0
  383. package/src/utils/formatUtils.ts +444 -0
  384. package/src/utils/index.ts +115 -0
  385. package/src/utils/inputValidator.ts +261 -0
  386. package/src/utils/network/http-client.test.ts +18 -0
  387. package/src/utils/network/http-client.ts +151 -0
  388. package/src/utils/performance/performance.ts +850 -0
  389. package/src/utils/responsiveUtils.ts +357 -0
  390. package/src/utils/rtl-support.ts +344 -0
  391. package/src/utils/security/api-security.ts +386 -0
  392. package/src/utils/security/xss-protection.ts +69 -0
  393. package/src/utils/securityHeaders.ts +314 -0
  394. package/src/utils/typeHelpers.ts +16 -0
  395. package/src/utils/types/dataProcessing.ts +543 -0
  396. package/src/utils/types/typeHelpers.ts +187 -0
  397. package/src/utils/xssProtection.ts +420 -0
@@ -0,0 +1,732 @@
1
+ import React, { useRef, useState, useEffect, useCallback } from 'react';
2
+ import { Input as TaroInput, Text, View } from '@tarojs/components';
3
+ import { createComponent, PRESET_COMPONENT_CONFIGS } from '../../common/ComponentFactory';
4
+ import { useAccessibility, useKeyboardNavigation, useFocusManagement } from '../../common/Accessibility';
5
+ import { useThemeUtils } from '../../theme/useThemeUtils';
6
+ import { useControlledState } from '../../hooks/useStateManagement';
7
+ import type { ComponentSize, ComponentVariant, ComponentStatus } from '../../types/component-props';
8
+
9
+ // ==================== 增强输入框属性接口 ====================
10
+ export interface EnhancedInputProps {
11
+ /** 输入框值 */
12
+ value?: string;
13
+ /** 默认值 */
14
+ defaultValue?: string;
15
+ /** 占位符 */
16
+ placeholder?: string;
17
+ /** 输入框尺寸 */
18
+ size?: ComponentSize;
19
+ /** 输入框变体 */
20
+ variant?: ComponentVariant;
21
+ /** 输入框状态 */
22
+ status?: ComponentStatus;
23
+ /** 是否禁用 */
24
+ disabled?: boolean;
25
+ /** 是否只读 */
26
+ readonly?: boolean;
27
+ /** 是否多行输入 */
28
+ multiline?: boolean;
29
+ /** 行数 */
30
+ rows?: number;
31
+ /** 是否自动调整高度 */
32
+ autoHeight?: boolean;
33
+ /** 最大长度 */
34
+ maxLength?: number;
35
+ /** 最小长度 */
36
+ minLength?: number;
37
+ /** 输入框类型 */
38
+ type?: 'text' | 'password' | 'number' | 'email' | 'tel' | 'url' | 'search';
39
+ /** 是否显示清除按钮 */
40
+ clearable?: boolean;
41
+ /** 清除按钮触发方式 */
42
+ clearTrigger?: 'always' | 'focus' | 'never';
43
+ /** 前缀 */
44
+ prefix?: React.ReactNode;
45
+ /** 后缀 */
46
+ suffix?: React.ReactNode;
47
+ /** 标签 */
48
+ label?: React.ReactNode;
49
+ /** 帮助文本 */
50
+ helpText?: React.ReactNode;
51
+ /** 错误文本 */
52
+ errorText?: React.ReactNode;
53
+ /** 是否显示字数统计 */
54
+ showCount?: boolean;
55
+ /** 是否自动聚焦 */
56
+ autoFocus?: boolean;
57
+ /** 是否显示边框 */
58
+ bordered?: boolean;
59
+ /** 是否显示密码切换按钮 */
60
+ showPasswordToggle?: boolean;
61
+ /** 变化回调 */
62
+ onChange?: (value: string, event: any) => void;
63
+ /** 输入回调 */
64
+ onInput?: (value: string, event: any) => void;
65
+ /** 聚焦回调 */
66
+ onFocus?: (event: any) => void;
67
+ /** 失焦回调 */
68
+ onBlur?: (event: any) => void;
69
+ /** 确认回调 */
70
+ onConfirm?: (value: string, event: any) => void;
71
+ /** 清除回调 */
72
+ onClear?: (event: any) => void;
73
+ /** 键盘高度变化回调 */
74
+ onKeyboardHeightChange?: (height: number, event: any) => void;
75
+ /** 验证规则 */
76
+ rules?: Array<{
77
+ required?: boolean;
78
+ message?: string;
79
+ pattern?: RegExp;
80
+ validator?: (value: string) => boolean | string;
81
+ asyncValidator?: (value: string) => Promise<boolean | string>;
82
+ }>;
83
+ /** 验证触发时机 */
84
+ validateTrigger?: 'onChange' | 'onBlur' | 'onSubmit';
85
+ /** 是否立即验证 */
86
+ immediate?: boolean;
87
+ /** 自定义类名 */
88
+ className?: string;
89
+ /** 自定义样式 */
90
+ style?: React.CSSProperties;
91
+ }
92
+
93
+ // ==================== 增强输入框引用接口 ====================
94
+ export interface EnhancedInputRef {
95
+ /** DOM元素 */
96
+ element: HTMLInputElement | HTMLTextAreaElement | null;
97
+ /** 获取输入框值 */
98
+ getValue: () => string;
99
+ /** 设置输入框值 */
100
+ setValue: (value: string) => void;
101
+ /** 聚焦输入框 */
102
+ focus: () => void;
103
+ /** 失焦输入框 */
104
+ blur: () => void;
105
+ /** 选中输入框内容 */
106
+ select: () => void;
107
+ /** 设置选中范围 */
108
+ setSelectionRange: (start: number, end: number) => void;
109
+ /** 获取选中范围 */
110
+ getSelectionRange: () => { start: number; end: number };
111
+ /** 设置禁用状态 */
112
+ setDisabled: (disabled: boolean) => void;
113
+ /** 设置只读状态 */
114
+ setReadonly: (readonly: boolean) => void;
115
+ /** 设置状态 */
116
+ setStatus: (status: ComponentStatus) => void;
117
+ /** 获取状态 */
118
+ getStatus: () => ComponentStatus;
119
+ /** 验证输入框 */
120
+ validate: () => Promise<{ valid: boolean; message?: string }>;
121
+ /** 清除输入框 */
122
+ clear: () => void;
123
+ /** 重置输入框 */
124
+ reset: () => void;
125
+ }
126
+
127
+ // ==================== 增强输入框组件 ====================
128
+ const EnhancedInputComponent = createComponent<EnhancedInputProps>(
129
+ PRESET_COMPONENT_CONFIGS.input,
130
+ (props, ref, styles, mergedProps) => {
131
+ const {
132
+ value: controlledValue,
133
+ defaultValue = '',
134
+ placeholder,
135
+ size = 'md',
136
+ variant = 'outlined',
137
+ status: propStatus = 'default',
138
+ disabled = false,
139
+ readonly = false,
140
+ multiline = false,
141
+ rows = 3,
142
+ autoHeight = false,
143
+ maxLength,
144
+ minLength,
145
+ type = 'text',
146
+ clearable = false,
147
+ clearTrigger = 'focus',
148
+ prefix,
149
+ suffix,
150
+ label,
151
+ helpText,
152
+ errorText,
153
+ showCount = false,
154
+ autoFocus = false,
155
+ bordered = true,
156
+ showPasswordToggle = false,
157
+ onChange,
158
+ onInput,
159
+ onFocus,
160
+ onBlur,
161
+ onConfirm,
162
+ onClear,
163
+ onKeyboardHeightChange,
164
+ rules = [],
165
+ validateTrigger = 'onBlur',
166
+ immediate = false,
167
+ className = '',
168
+ style,
169
+ ...rest
170
+ } = props;
171
+
172
+ const { getColor, getSpacing, getBorderRadius, getFontSize } = useThemeUtils();
173
+ const inputRef = useRef<HTMLInputElement | HTMLTextAreaElement>(null);
174
+ const [internalValue, setInternalValue] = useState(defaultValue);
175
+ const [isFocused, setIsFocused] = useState(false);
176
+ const [showPassword, setShowPassword] = useState(false);
177
+ const [internalStatus, setInternalStatus] = useState(propStatus);
178
+ const [validationResult, setValidationResult] = useState<{ valid: boolean; message?: string } | null>(null);
179
+
180
+ // 处理受控/非受控模式
181
+ const isControlled = controlledValue !== undefined;
182
+ const value = isControlled ? controlledValue : internalValue;
183
+
184
+ // 更新内部状态
185
+ useEffect(() => {
186
+ setInternalStatus(propStatus);
187
+ }, [propStatus]);
188
+
189
+ // 自动聚焦
190
+ useEffect(() => {
191
+ if (autoFocus && inputRef.current) {
192
+ inputRef.current.focus();
193
+ }
194
+ }, [autoFocus]);
195
+
196
+ // 立即验证
197
+ useEffect(() => {
198
+ if (immediate && value) {
199
+ validateInput(value);
200
+ }
201
+ }, [immediate, value]);
202
+
203
+ // 验证输入值
204
+ const validateInput = useCallback(async (inputValue: string): Promise<{ valid: boolean; message?: string }> => {
205
+ // 验证长度
206
+ if (minLength !== undefined && inputValue.length < minLength) {
207
+ return { valid: false, message: `最少需要${minLength}个字符` };
208
+ }
209
+
210
+ if (maxLength !== undefined && inputValue.length > maxLength) {
211
+ return { valid: false, message: `最多允许${maxLength}个字符` };
212
+ }
213
+
214
+ // 验证规则
215
+ for (const rule of rules) {
216
+ if (rule.required && !inputValue.trim()) {
217
+ return { valid: false, message: rule.message || '此字段为必填项' };
218
+ }
219
+
220
+ if (rule.pattern && !rule.pattern.test(inputValue)) {
221
+ return { valid: false, message: rule.message || '输入格式不正确' };
222
+ }
223
+
224
+ if (rule.validator) {
225
+ const result = rule.validator(inputValue);
226
+ if (typeof result === 'string') {
227
+ return { valid: false, message: result };
228
+ }
229
+ if (!result) {
230
+ return { valid: false, message: rule.message || '输入格式不正确' };
231
+ }
232
+ }
233
+
234
+ if (rule.asyncValidator) {
235
+ try {
236
+ const result = await rule.asyncValidator(inputValue);
237
+ if (typeof result === 'string') {
238
+ return { valid: false, message: result };
239
+ }
240
+ if (!result) {
241
+ return { valid: false, message: rule.message || '输入格式不正确' };
242
+ }
243
+ } catch (error) {
244
+ return { valid: false, message: rule.message || '验证失败' };
245
+ }
246
+ }
247
+ }
248
+
249
+ return { valid: true };
250
+ }, [rules, minLength, maxLength]);
251
+
252
+ // 格式化输入值
253
+ const formatInputValue = useCallback((inputValue: string): string => {
254
+ let formattedValue = inputValue;
255
+
256
+ switch (type) {
257
+ case 'number':
258
+ formattedValue = inputValue.replace(/[^\d.-]/g, '');
259
+ break;
260
+ case 'tel':
261
+ formattedValue = inputValue.replace(/[^\d]/g, '');
262
+ break;
263
+ case 'email':
264
+ // 不自动格式化邮箱
265
+ break;
266
+ default:
267
+ break;
268
+ }
269
+
270
+ if (maxLength && formattedValue.length > maxLength) {
271
+ formattedValue = formattedValue.slice(0, maxLength);
272
+ }
273
+
274
+ return formattedValue;
275
+ }, [type, maxLength]);
276
+
277
+ // 处理输入变化
278
+ const handleValueChange = useCallback(async (newValue: string, event: any) => {
279
+ if (disabled || readonly) return;
280
+
281
+ const formattedValue = formatInputValue(newValue);
282
+
283
+ if (!isControlled) {
284
+ setInternalValue(formattedValue);
285
+ }
286
+
287
+ onInput?.(formattedValue, event);
288
+
289
+ // 验证输入
290
+ if (validateTrigger === 'onChange') {
291
+ const result = await validateInput(formattedValue);
292
+ setValidationResult(result);
293
+ setInternalStatus(result.valid ? 'default' : 'error');
294
+ }
295
+
296
+ onChange?.(formattedValue, event);
297
+ }, [disabled, readonly, isControlled, formatInputValue, onInput, validateTrigger, validateInput, onChange]);
298
+
299
+ // 处理聚焦事件
300
+ const handleFocus = useCallback(async (event: any) => {
301
+ if (disabled || readonly) return;
302
+
303
+ setIsFocused(true);
304
+ onFocus?.(event);
305
+
306
+ if (validateTrigger === 'onFocus') {
307
+ const result = await validateInput(value);
308
+ setValidationResult(result);
309
+ setInternalStatus(result.valid ? 'default' : 'error');
310
+ }
311
+ }, [disabled, readonly, onFocus, validateTrigger, validateInput, value]);
312
+
313
+ // 处理失焦事件
314
+ const handleBlur = useCallback(async (event: any) => {
315
+ if (disabled || readonly) return;
316
+
317
+ setIsFocused(false);
318
+ onBlur?.(event);
319
+
320
+ if (validateTrigger === 'onBlur') {
321
+ const result = await validateInput(value);
322
+ setValidationResult(result);
323
+ setInternalStatus(result.valid ? 'default' : 'error');
324
+ }
325
+ }, [disabled, readonly, onBlur, validateTrigger, validateInput, value]);
326
+
327
+ // 处理确认事件
328
+ const handleConfirm = useCallback(async (event: any) => {
329
+ if (disabled || readonly) return;
330
+
331
+ onConfirm?.(value, event);
332
+
333
+ if (validateTrigger === 'onSubmit') {
334
+ const result = await validateInput(value);
335
+ setValidationResult(result);
336
+ setInternalStatus(result.valid ? 'default' : 'error');
337
+ }
338
+ }, [disabled, readonly, onConfirm, validateTrigger, validateInput, value]);
339
+
340
+ // 处理清除事件
341
+ const handleClear = useCallback((event: any) => {
342
+ if (disabled || readonly) return;
343
+
344
+ const emptyValue = '';
345
+ if (!isControlled) {
346
+ setInternalValue(emptyValue);
347
+ }
348
+
349
+ setValidationResult(null);
350
+ setInternalStatus('default');
351
+ onClear?.(event);
352
+ onChange?.(emptyValue, event);
353
+ }, [disabled, readonly, isControlled, onClear, onChange]);
354
+
355
+ // 处理密码切换
356
+ const handlePasswordToggle = useCallback(() => {
357
+ setShowPassword(!showPassword);
358
+ }, [showPassword]);
359
+
360
+ // 计算是否显示清除按钮
361
+ const shouldShowClear = useCallback(() => {
362
+ if (!clearable || disabled || readonly) return false;
363
+
364
+ switch (clearTrigger) {
365
+ case 'always':
366
+ return !!value;
367
+ case 'focus':
368
+ return isFocused && !!value;
369
+ case 'never':
370
+ return false;
371
+ default:
372
+ return false;
373
+ }
374
+ }, [clearable, disabled, readonly, value, isFocused, clearTrigger]);
375
+
376
+ // 计算最终状态
377
+ const finalStatus = disabled ? 'disabled' :
378
+ validationResult?.valid === false || errorText ? 'error' :
379
+ internalStatus;
380
+
381
+ // 生成无障碍属性
382
+ const { errorId, helpId, ariaProps } = useAccessibility({
383
+ disabled,
384
+ readonly,
385
+ required: rules.some(rule => rule.required),
386
+ invalid: validationResult?.valid === false || !!errorText,
387
+ errorMessage: validationResult?.message || errorText,
388
+ helpText,
389
+ role: 'textbox',
390
+ ariaLabel: label?.toString() || placeholder,
391
+ });
392
+
393
+ // 键盘导航
394
+ const { onKeyDown } = useKeyboardNavigation(
395
+ { enableKeyboardNavigation: true },
396
+ {
397
+ onEnter: () => {
398
+ if (!disabled && !readonly) {
399
+ handleConfirm({} as any);
400
+ }
401
+ },
402
+ }
403
+ );
404
+
405
+ // 焦点管理
406
+ const { focusProps } = useFocusManagement({
407
+ autoFocus,
408
+ tabIndex: disabled ? -1 : 0,
409
+ });
410
+
411
+ // 生成输入框样式
412
+ const inputStyles: React.CSSProperties = {
413
+ ...styles,
414
+ border: bordered ? '1px solid' : 'none',
415
+ borderRadius: getBorderRadius('md'),
416
+ backgroundColor: getColor('background.primary'),
417
+ color: getColor('text.primary'),
418
+ opacity: disabled ? 0.5 : 1,
419
+ cursor: disabled ? 'not-allowed' : readonly ? 'default' : 'text',
420
+ transition: 'all 0.2s ease-in-out',
421
+ outline: 'none',
422
+ width: '100%',
423
+ boxSizing: 'border-box',
424
+ ...style,
425
+ };
426
+
427
+ // 根据状态调整样式
428
+ if (finalStatus === 'error') {
429
+ inputStyles.borderColor = getColor('error.500');
430
+ inputStyles.backgroundColor = getColor('error.50');
431
+ } else if (isFocused) {
432
+ inputStyles.borderColor = getColor('primary.500');
433
+ inputStyles.boxShadow = `0 0 0 2px ${getColor('primary.100')}`;
434
+ }
435
+
436
+ // 渲染输入框
437
+ const renderInput = () => {
438
+ const inputProps = {
439
+ ref: inputRef,
440
+ value: value || '',
441
+ placeholder,
442
+ type: showPassword ? 'text' : type,
443
+ disabled,
444
+ readOnly: readonly,
445
+ maxLength,
446
+ autoFocus,
447
+ style: inputStyles,
448
+ className: `taro-uno-input ${className}`.trim(),
449
+ onFocus: handleFocus,
450
+ onBlur: handleBlur,
451
+ onConfirm: handleConfirm,
452
+ onInput: (e: any) => handleValueChange(e.detail.value, e),
453
+ onKeyboardHeightChange: (e: any) => onKeyboardHeightChange?.(e.detail.height, e),
454
+ ...ariaProps,
455
+ ...focusProps,
456
+ onKeyDown,
457
+ };
458
+
459
+ if (multiline) {
460
+ return (
461
+ <TaroInput
462
+ {...inputProps}
463
+ type={'textarea' as any}
464
+ rows={rows}
465
+ autoHeight={autoHeight}
466
+ />
467
+ );
468
+ }
469
+
470
+ return <TaroInput {...inputProps} />;
471
+ };
472
+
473
+ // 计算字符长度
474
+ const calculateLength = (text: string) => {
475
+ if (!text) return 0;
476
+ return Array.from(text).reduce((len, char) => {
477
+ return len + (char.charCodeAt(0) > 127 ? 2 : 1);
478
+ }, 0);
479
+ };
480
+
481
+ const currentLength = calculateLength(String(value || ''));
482
+ const maxLengthToShow = maxLength || 100;
483
+
484
+ return (
485
+ <View style={{ width: '100%' }}>
486
+ {/* 标签 */}
487
+ {label && (
488
+ <Text style={{
489
+ display: 'block',
490
+ fontSize: getFontSize('sm'),
491
+ fontWeight: 500,
492
+ color: getColor('text.primary'),
493
+ marginBottom: getSpacing('1'),
494
+ }}>
495
+ {label}
496
+ {rules.some(rule => rule.required) && (
497
+ <Text style={{ color: getColor('error.500'), marginLeft: '2px' }}>*</Text>
498
+ )}
499
+ </Text>
500
+ )}
501
+
502
+ {/* 输入框容器 */}
503
+ <View style={{
504
+ position: 'relative',
505
+ display: 'flex',
506
+ alignItems: 'center',
507
+ width: '100%',
508
+ }}>
509
+ {/* 前缀 */}
510
+ {prefix && (
511
+ <View style={{
512
+ display: 'flex',
513
+ alignItems: 'center',
514
+ paddingLeft: getSpacing('2'),
515
+ color: getColor('text.secondary'),
516
+ }}>
517
+ {prefix}
518
+ </View>
519
+ )}
520
+
521
+ {/* 输入框 */}
522
+ <View style={{ flex: 1, position: 'relative' }}>
523
+ {renderInput()}
524
+
525
+ {/* 清除按钮 */}
526
+ {shouldShowClear() && (
527
+ <View
528
+ style={{
529
+ position: 'absolute',
530
+ right: getSpacing('2'),
531
+ top: '50%',
532
+ transform: 'translateY(-50%)',
533
+ width: '16px',
534
+ height: '16px',
535
+ borderRadius: '50%',
536
+ backgroundColor: getColor('text.secondary'),
537
+ color: getColor('background.primary'),
538
+ display: 'flex',
539
+ alignItems: 'center',
540
+ justifyContent: 'center',
541
+ cursor: 'pointer',
542
+ fontSize: '12px',
543
+ }}
544
+ onClick={handleClear}
545
+ >
546
+ ×
547
+ </View>
548
+ )}
549
+
550
+ {/* 密码切换按钮 */}
551
+ {showPasswordToggle && type === 'password' && (
552
+ <View
553
+ style={{
554
+ position: 'absolute',
555
+ right: getSpacing('2'),
556
+ top: '50%',
557
+ transform: 'translateY(-50%)',
558
+ cursor: 'pointer',
559
+ fontSize: '16px',
560
+ }}
561
+ onClick={handlePasswordToggle}
562
+ >
563
+ {showPassword ? '👁️' : '👁️‍🗨️'}
564
+ </View>
565
+ )}
566
+
567
+ {/* 后缀 */}
568
+ {suffix && (
569
+ <View style={{
570
+ position: 'absolute',
571
+ right: getSpacing('2'),
572
+ top: '50%',
573
+ transform: 'translateY(-50%)',
574
+ display: 'flex',
575
+ alignItems: 'center',
576
+ color: getColor('text.secondary'),
577
+ }}>
578
+ {suffix}
579
+ </View>
580
+ )}
581
+ </View>
582
+ </View>
583
+
584
+ {/* 帮助文本 */}
585
+ {helpText && finalStatus === 'default' && (
586
+ <Text
587
+ id={helpId}
588
+ style={{
589
+ display: 'block',
590
+ fontSize: getFontSize('xs'),
591
+ color: getColor('text.secondary'),
592
+ marginTop: getSpacing('1'),
593
+ }}
594
+ >
595
+ {helpText}
596
+ </Text>
597
+ )}
598
+
599
+ {/* 错误文本 */}
600
+ {errorText && finalStatus === 'error' && (
601
+ <Text
602
+ id={errorId}
603
+ style={{
604
+ display: 'block',
605
+ fontSize: getFontSize('xs'),
606
+ color: getColor('error.500'),
607
+ marginTop: getSpacing('1'),
608
+ }}
609
+ >
610
+ {errorText}
611
+ </Text>
612
+ )}
613
+
614
+ {/* 验证结果文本 */}
615
+ {validationResult?.message && finalStatus === 'error' && (
616
+ <Text
617
+ id={errorId}
618
+ style={{
619
+ display: 'block',
620
+ fontSize: getFontSize('xs'),
621
+ color: getColor('error.500'),
622
+ marginTop: getSpacing('1'),
623
+ }}
624
+ >
625
+ {validationResult.message}
626
+ </Text>
627
+ )}
628
+
629
+ {/* 字数统计 */}
630
+ {(showCount || maxLength) && (
631
+ <Text
632
+ style={{
633
+ display: 'block',
634
+ fontSize: getFontSize('xs'),
635
+ color: getColor('text.secondary'),
636
+ marginTop: getSpacing('1'),
637
+ textAlign: 'right',
638
+ }}
639
+ >
640
+ {currentLength}/{maxLengthToShow}
641
+ </Text>
642
+ )}
643
+ </View>
644
+ );
645
+ }
646
+ );
647
+
648
+ // ==================== 暴露引用方法 ====================
649
+ EnhancedInputComponent.displayName = 'EnhancedInput';
650
+
651
+ export const EnhancedInput = React.forwardRef<EnhancedInputRef, EnhancedInputProps>((props, ref) => {
652
+ const inputRef = useRef<HTMLInputElement | HTMLTextAreaElement>(null);
653
+ const [internalValue, setInternalValue] = useState(props.defaultValue || '');
654
+ const [internalDisabled, setInternalDisabled] = useState(props.disabled || false);
655
+ const [internalReadonly, setInternalReadonly] = useState(props.readonly || false);
656
+ const [internalStatus, setInternalStatus] = useState(props.status || 'default');
657
+
658
+ React.useImperativeHandle(ref, () => ({
659
+ element: inputRef.current,
660
+ getValue: () => {
661
+ return props.value !== undefined ? props.value || '' : internalValue;
662
+ },
663
+ setValue: (newValue: string) => {
664
+ if (props.value === undefined) {
665
+ setInternalValue(newValue);
666
+ }
667
+ },
668
+ focus: () => {
669
+ inputRef.current?.focus();
670
+ },
671
+ blur: () => {
672
+ inputRef.current?.blur();
673
+ },
674
+ select: () => {
675
+ if (inputRef.current && 'select' in inputRef.current) {
676
+ inputRef.current.select();
677
+ }
678
+ },
679
+ setSelectionRange: (start: number, end: number) => {
680
+ if (inputRef.current && 'setSelectionRange' in inputRef.current) {
681
+ inputRef.current.setSelectionRange(start, end);
682
+ }
683
+ },
684
+ getSelectionRange: () => {
685
+ if (inputRef.current && 'selectionStart' in inputRef.current) {
686
+ return {
687
+ start: inputRef.current.selectionStart || 0,
688
+ end: inputRef.current.selectionEnd || 0,
689
+ };
690
+ }
691
+ return { start: 0, end: 0 };
692
+ },
693
+ setDisabled: (newDisabled: boolean) => {
694
+ setInternalDisabled(newDisabled);
695
+ },
696
+ setReadonly: (newReadonly: boolean) => {
697
+ setInternalReadonly(newReadonly);
698
+ },
699
+ setStatus: (newStatus: any) => {
700
+ setInternalStatus(newStatus);
701
+ },
702
+ getStatus: () => internalStatus,
703
+ validate: async () => {
704
+ // 验证逻辑需要根据实际的验证规则实现
705
+ return { valid: true };
706
+ },
707
+ clear: () => {
708
+ if (props.value === undefined) {
709
+ setInternalValue('');
710
+ }
711
+ },
712
+ reset: () => {
713
+ if (props.value === undefined) {
714
+ setInternalValue(props.defaultValue || '');
715
+ }
716
+ setInternalStatus(props.status || 'default');
717
+ },
718
+ }));
719
+
720
+ return (
721
+ <EnhancedInputComponent
722
+ {...props}
723
+ ref={inputRef}
724
+ value={props.value !== undefined ? props.value : internalValue}
725
+ disabled={internalDisabled}
726
+ readonly={internalReadonly}
727
+ status={internalStatus}
728
+ />
729
+ );
730
+ });
731
+
732
+ export default EnhancedInput;