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,370 @@
1
+ import React, { forwardRef, useRef, useEffect, useState, useCallback } from 'react';
2
+ import { View, Text } from '@tarojs/components';
3
+ import {
4
+ NotificationProps,
5
+ NotificationRef,
6
+ NotificationType,
7
+ DEFAULT_NOTIFICATION_CONFIG
8
+ } from './Notification.types';
9
+ import { notificationStyles, notificationStyleHelpers } from './Notification.styles';
10
+ import { cn } from '../../../utils';
11
+
12
+ export const Notification = forwardRef<NotificationRef, NotificationProps>((props, ref) => {
13
+ const {
14
+ type = 'info',
15
+ title,
16
+ content,
17
+ icon,
18
+ closable = DEFAULT_NOTIFICATION_CONFIG.defaultClosable,
19
+ duration = DEFAULT_NOTIFICATION_CONFIG.defaultDuration,
20
+ placement = DEFAULT_NOTIFICATION_CONFIG.defaultPlacement,
21
+ className,
22
+ style,
23
+ onClose,
24
+ onClick,
25
+ showClose = DEFAULT_NOTIFICATION_CONFIG.defaultShowClose,
26
+ showIcon = DEFAULT_NOTIFICATION_CONFIG.defaultShowIcon,
27
+ autoClose = DEFAULT_NOTIFICATION_CONFIG.defaultAutoClose,
28
+ animation = DEFAULT_NOTIFICATION_CONFIG.defaultAnimation,
29
+ ...rest
30
+ } = props;
31
+
32
+ // 错误状态管理
33
+ const [hasError, setHasError] = useState(false);
34
+ const [errorMessage, setErrorMessage] = useState<string | null>(null);
35
+
36
+ // 错误边界处理
37
+ const handleError = useCallback((error: Error, context: string) => {
38
+ console.error(`Notification error in ${context}:`, error);
39
+ setHasError(true);
40
+ setErrorMessage(error.message);
41
+
42
+ // 自动关闭错误的通知
43
+ if (timerRef.current) {
44
+ clearTimeout(timerRef.current);
45
+ timerRef.current = null;
46
+ }
47
+
48
+ // 延迟关闭以显示错误状态
49
+ timerRef.current = setTimeout(() => {
50
+ setVisible(false);
51
+ setIsClosing(true);
52
+ onClose?.();
53
+ }, 3000) as unknown as number;
54
+ }, [onClose]);
55
+
56
+ // 状态管理
57
+ const [visible, setVisible] = useState(true);
58
+ const [closeHovered, setCloseHovered] = useState(false);
59
+ const [isClosing, setIsClosing] = useState(false);
60
+ const [paused, setPaused] = useState(false);
61
+
62
+ // 定时器引用
63
+ const timerRef = useRef<number | null>(null);
64
+ const startTimeRef = useRef<number>(0);
65
+ const remainingTimeRef = useRef<number>(duration);
66
+
67
+
68
+ // 处理自动关闭
69
+ const handleAutoClose = useCallback(() => {
70
+ try {
71
+ if (!autoClose || duration <= 0 || paused) return;
72
+
73
+ if (timerRef.current) {
74
+ clearTimeout(timerRef.current);
75
+ timerRef.current = null;
76
+ }
77
+
78
+ // 使用更安全的定时器处理
79
+ const timeoutId = setTimeout(() => {
80
+ try {
81
+ setVisible(false);
82
+ setIsClosing(true);
83
+ onClose?.();
84
+ } catch (error) {
85
+ handleError(error as Error, 'autoCloseTimeout');
86
+ }
87
+ }, remainingTimeRef.current);
88
+
89
+ timerRef.current = timeoutId as unknown as number;
90
+ startTimeRef.current = Date.now();
91
+ } catch (error) {
92
+ handleError(error as Error, 'handleAutoClose');
93
+ }
94
+ }, [autoClose, duration, paused, onClose, remainingTimeRef, handleError]);
95
+
96
+ // 暂停自动关闭
97
+ const pauseProgress = useCallback(() => {
98
+ try {
99
+ if (timerRef.current) {
100
+ clearTimeout(timerRef.current);
101
+ const elapsed = Date.now() - startTimeRef.current;
102
+ remainingTimeRef.current = Math.max(0, remainingTimeRef.current - elapsed);
103
+ setPaused(true);
104
+ timerRef.current = null;
105
+ }
106
+ } catch (error) {
107
+ handleError(error as Error, 'pauseProgress');
108
+ }
109
+ }, [handleError]);
110
+
111
+ // 恢复自动关闭
112
+ const resumeProgress = useCallback(() => {
113
+ try {
114
+ setPaused(false);
115
+ handleAutoClose();
116
+ } catch (error) {
117
+ handleError(error as Error, 'resumeProgress');
118
+ }
119
+ }, [handleAutoClose, handleError]);
120
+
121
+ // 暴露方法给ref
122
+ React.useImperativeHandle(ref, () => ({
123
+ hide: () => {
124
+ setVisible(false);
125
+ setIsClosing(true);
126
+ if (timerRef.current) {
127
+ clearTimeout(timerRef.current);
128
+ timerRef.current = null;
129
+ }
130
+ onClose?.();
131
+ return true;
132
+ },
133
+ show: () => {
134
+ setVisible(true);
135
+ setIsClosing(false);
136
+ remainingTimeRef.current = duration;
137
+ handleAutoClose();
138
+ return true;
139
+ },
140
+ update: (newProps: Partial<NotificationProps>) => {
141
+ // 这里可以实现更新通知内容的逻辑
142
+ console.log('Update notification:', newProps);
143
+ return true;
144
+ },
145
+ pauseProgress,
146
+ resumeProgress,
147
+ getState: () => ({
148
+ visible,
149
+ paused,
150
+ closing: isClosing,
151
+ }),
152
+ }));
153
+
154
+ // 自动关闭效果
155
+ useEffect(() => {
156
+ handleAutoClose();
157
+
158
+ return () => {
159
+ // 清理定时器
160
+ if (timerRef.current) {
161
+ clearTimeout(timerRef.current);
162
+ timerRef.current = null;
163
+ }
164
+ };
165
+ }, [handleAutoClose]);
166
+
167
+ // 组件卸载时的清理
168
+ useEffect(() => {
169
+ return () => {
170
+ // 确保所有定时器都被清理
171
+ if (timerRef.current) {
172
+ clearTimeout(timerRef.current);
173
+ timerRef.current = null;
174
+ }
175
+
176
+ // 清理状态引用
177
+ setHasError(false);
178
+ setErrorMessage(null);
179
+ };
180
+ }, []);
181
+
182
+ // 关闭处理
183
+ const handleClose = useCallback((e?: any) => {
184
+ e?.stopPropagation();
185
+ setVisible(false);
186
+ setIsClosing(true);
187
+ if (timerRef.current) {
188
+ clearTimeout(timerRef.current);
189
+ timerRef.current = null;
190
+ }
191
+ onClose?.();
192
+ }, [onClose]);
193
+
194
+ // 点击处理
195
+ const handleClick = useCallback((e?: any) => {
196
+ try {
197
+ onClick?.(e);
198
+ } catch (error) {
199
+ handleError(error as Error, 'handleClick');
200
+ }
201
+ }, [onClick, handleError]);
202
+
203
+ // 触摸开始处理(替代鼠标悬停)
204
+ const handleTouchStart = useCallback((_e?: any) => {
205
+ try {
206
+ setCloseHovered(true);
207
+ if (autoClose) {
208
+ pauseProgress();
209
+ }
210
+ } catch (error) {
211
+ handleError(error as Error, 'handleTouchStart');
212
+ }
213
+ }, [autoClose, pauseProgress, handleError]);
214
+
215
+ // 触摸结束处理(替代鼠标离开)
216
+ const handleTouchEnd = useCallback((_e?: any) => {
217
+ try {
218
+ setCloseHovered(false);
219
+ if (autoClose && paused) {
220
+ resumeProgress();
221
+ }
222
+ } catch (error) {
223
+ handleError(error as Error, 'handleTouchEnd');
224
+ }
225
+ }, [autoClose, paused, resumeProgress, handleError]);
226
+
227
+ // 渲染图标
228
+ const renderIcon = useCallback(() => {
229
+ try {
230
+ if (!showIcon) return null;
231
+
232
+ if (icon) {
233
+ return (
234
+ <View
235
+ className={notificationStyles['icon']}
236
+ >
237
+ {icon}
238
+ </View>
239
+ );
240
+ }
241
+
242
+ const defaultIcons: Record<NotificationType, string> = {
243
+ success: '✓',
244
+ error: '✕',
245
+ warning: '⚠',
246
+ info: 'ℹ',
247
+ };
248
+
249
+ return (
250
+ <View
251
+ className={notificationStyles['icon']}
252
+ >
253
+ <Text
254
+ className={notificationStyles['iconText']}
255
+ >
256
+ {defaultIcons[type]}
257
+ </Text>
258
+ </View>
259
+ );
260
+ } catch (error) {
261
+ handleError(error as Error, 'renderIcon');
262
+ return null;
263
+ }
264
+ }, [showIcon, icon, type, handleError]);
265
+
266
+ // 计算容器样式
267
+ const containerStyle = React.useMemo(() => {
268
+ try {
269
+ const baseStyle = notificationStyleHelpers.getBaseStyle(placement, style);
270
+ const typeStyle = notificationStyleHelpers.getTypeStyle(type);
271
+ const animationStyle = notificationStyleHelpers.getAnimationStyle(animation, visible);
272
+
273
+ return {
274
+ ...baseStyle,
275
+ ...typeStyle,
276
+ ...animationStyle,
277
+ };
278
+ } catch (error) {
279
+ handleError(error as Error, 'containerStyle');
280
+ return notificationStyleHelpers.getBaseStyle(placement, style);
281
+ }
282
+ }, [placement, style, type, animation, visible, handleError]);
283
+
284
+ // 计算类名
285
+ const containerClassName = React.useMemo(() => {
286
+ try {
287
+ const classes = [
288
+ 'taro-uno-notification',
289
+ `taro-uno-notification-${type}`,
290
+ `taro-uno-notification-${placement}`,
291
+ isClosing && 'taro-uno-notification-closing',
292
+ closeHovered && 'taro-uno-notification-hovered',
293
+ paused && 'taro-uno-notification-paused',
294
+ hasError && 'taro-uno-notification-error',
295
+ className
296
+ ];
297
+ return cn(...classes);
298
+ } catch (error) {
299
+ handleError(error as Error, 'containerClassName');
300
+ return 'taro-uno-notification taro-uno-notification-error';
301
+ }
302
+ }, [type, placement, isClosing, closeHovered, paused, hasError, className, handleError]);
303
+
304
+ // 如果不可见,返回null
305
+ if (!visible) return null;
306
+
307
+ return (
308
+ <View
309
+ style={containerStyle}
310
+ className={containerClassName}
311
+ onClick={handleClick}
312
+ onTouchStart={handleTouchStart}
313
+ onTouchEnd={handleTouchEnd}
314
+ {...rest}
315
+ >
316
+ {renderIcon()}
317
+
318
+ <View
319
+ className={notificationStyles['content']}
320
+ >
321
+ {hasError ? (
322
+ <Text
323
+ className={notificationStyles['title']}
324
+ >
325
+ 通知错误
326
+ </Text>
327
+ ) : title && (
328
+ <Text
329
+ className={notificationStyles['title']}
330
+ >
331
+ {title}
332
+ </Text>
333
+ )}
334
+ {hasError ? (
335
+ <Text
336
+ className={notificationStyles['text']}
337
+ >
338
+ {errorMessage || '通知显示异常'}
339
+ </Text>
340
+ ) : content && (
341
+ <Text
342
+ className={notificationStyles['text']}
343
+ >
344
+ {content}
345
+ </Text>
346
+ )}
347
+ </View>
348
+
349
+ {showClose && closable && (
350
+ <View
351
+ className={cn(
352
+ notificationStyles['close'],
353
+ closeHovered && notificationStyles['closeHover']
354
+ )}
355
+ onClick={handleClose}
356
+ >
357
+ <Text
358
+ className={notificationStyles['closeIcon']}
359
+ >
360
+
361
+ </Text>
362
+ </View>
363
+ )}
364
+ </View>
365
+ );
366
+ });
367
+
368
+ Notification.displayName = 'Notification';
369
+
370
+ export default Notification;
@@ -0,0 +1,336 @@
1
+ import React from 'react';
2
+ import { ITouchEvent } from '@tarojs/components';
3
+
4
+ /** 通知类型 */
5
+ export type NotificationType = 'success' | 'error' | 'warning' | 'info';
6
+
7
+ /** 通知位置 */
8
+ export type NotificationPlacement = 'topRight' | 'topLeft' | 'bottomRight' | 'bottomLeft' | 'top' | 'bottom';
9
+
10
+ /** 通知动画类型 */
11
+ export type NotificationAnimation = 'fade' | 'slide' | 'scale' | 'bounce' | 'none';
12
+
13
+ /** 通知项接口 */
14
+ export interface NotificationItem {
15
+ /** 通知唯一标识 */
16
+ key: string;
17
+ /** 通知类型 */
18
+ type?: NotificationType;
19
+ /** 通知标题 */
20
+ title?: React.ReactNode;
21
+ /** 通知内容 */
22
+ content?: React.ReactNode;
23
+ /** 自定义图标 */
24
+ icon?: React.ReactNode;
25
+ /** 是否可关闭 */
26
+ closable?: boolean;
27
+ /** 显示时长(毫秒) */
28
+ duration?: number;
29
+ /** 通知位置 */
30
+ placement?: NotificationPlacement;
31
+ /** 自定义类名 */
32
+ className?: string;
33
+ /** 自定义样式 */
34
+ style?: React.CSSProperties;
35
+ /** 关闭回调 */
36
+ onClose?: (_key: string) => void;
37
+ /** 点击回调 */
38
+ onClick?: () => void;
39
+ /** 显示关闭按钮 */
40
+ showClose?: boolean;
41
+ /** 显示图标 */
42
+ showIcon?: boolean;
43
+ /** 动画类型 */
44
+ animation?: NotificationAnimation;
45
+ /** 创建时间 */
46
+ createdAt: number;
47
+ }
48
+
49
+ /** 通知组件属性 */
50
+ export interface NotificationProps {
51
+ /** 通知类型 */
52
+ type?: NotificationType;
53
+ /** 通知标题 */
54
+ title?: React.ReactNode;
55
+ /** 通知内容 */
56
+ content?: React.ReactNode;
57
+ /** 自定义图标 */
58
+ icon?: React.ReactNode;
59
+ /** 是否可关闭 */
60
+ closable?: boolean;
61
+ /** 显示时长(毫秒) */
62
+ duration?: number;
63
+ /** 通知位置 */
64
+ placement?: NotificationPlacement;
65
+ /** 自定义类名 */
66
+ className?: string;
67
+ /** 自定义样式 */
68
+ style?: React.CSSProperties;
69
+ /** 关闭回调 */
70
+ onClose?: () => void;
71
+ /** 点击回调 */
72
+ onClick?: (event?: ITouchEvent) => void;
73
+ /** 显示关闭按钮 */
74
+ showClose?: boolean;
75
+ /** 显示图标 */
76
+ showIcon?: boolean;
77
+ /** 动画类型 */
78
+ animation?: NotificationAnimation;
79
+ /** 是否自动关闭 */
80
+ autoClose?: boolean;
81
+ /** 是否可拖拽 */
82
+ draggable?: boolean;
83
+ /** 拖拽阈值 */
84
+ dragThreshold?: number;
85
+ /** 堆叠索引 */
86
+ stackIndex?: number;
87
+ /** 悬停状态 */
88
+ hovered?: boolean;
89
+ /** 是否正在关闭 */
90
+ isClosing?: boolean;
91
+ }
92
+
93
+ /** 通知组件引用 */
94
+ export interface NotificationRef {
95
+ /** 显示通知 */
96
+ show: () => boolean;
97
+ /** 隐藏通知 */
98
+ hide: () => boolean;
99
+ /** 更新通知内容 */
100
+ update: (_props: Partial<NotificationProps>) => boolean;
101
+ /** 暂停自动关闭 */
102
+ pauseProgress?: () => void;
103
+ /** 恢复自动关闭 */
104
+ resumeProgress?: () => void;
105
+ /** 获取通知状态 */
106
+ getState: () => {
107
+ visible: boolean;
108
+ paused: boolean;
109
+ closing: boolean;
110
+ };
111
+ }
112
+
113
+ /** 通知管理器属性 */
114
+ export interface NotificationManagerProps {
115
+ /** 最大通知数量 */
116
+ maxCount?: number;
117
+ /** 默认位置 */
118
+ defaultPlacement?: NotificationPlacement;
119
+ /** 默认时长 */
120
+ defaultDuration?: number;
121
+ /** 默认动画 */
122
+ defaultAnimation?: NotificationAnimation;
123
+ /** 是否堆叠 */
124
+ stack?: boolean;
125
+ /** 堆叠最大数量 */
126
+ stackMaxCount?: number;
127
+ /** 允许拖拽 */
128
+ allowDrag?: boolean;
129
+ /** 拖拽阈值 */
130
+ dragThreshold?: number;
131
+ /** 显示分组 */
132
+ showGroup?: boolean;
133
+ /** 分组间隔 */
134
+ groupInterval?: number;
135
+ /** 自定义样式 */
136
+ style?: React.CSSProperties;
137
+ /** 自定义类名 */
138
+ className?: string;
139
+ /** 容器样式 */
140
+ containerStyle?: React.CSSProperties;
141
+ /** 容器类名 */
142
+ containerClassName?: string;
143
+ /** 进入回调 */
144
+ onEnter?: (_key: string) => void;
145
+ /** 离开回调 */
146
+ onLeave?: (_key: string) => void;
147
+ /** 全部关闭回调 */
148
+ onAllClose?: () => void;
149
+ /** 通知配置更新回调 */
150
+ onUpdate?: (_key: string, config: Partial<NotificationItem>) => void;
151
+ }
152
+
153
+ /** 通知管理器引用 */
154
+ export interface NotificationManagerRef {
155
+ /** 显示通知 */
156
+ open: (_config: Omit<NotificationItem, 'key' | 'createdAt'>) => string;
157
+ /** 显示成功通知 */
158
+ success: (_config: Omit<NotificationItem, 'key' | 'createdAt' | 'type'>) => string;
159
+ /** 显示信息通知 */
160
+ info: (_config: Omit<NotificationItem, 'key' | 'createdAt' | 'type'>) => string;
161
+ /** 显示警告通知 */
162
+ warning: (_config: Omit<NotificationItem, 'key' | 'createdAt' | 'type'>) => string;
163
+ /** 显示错误通知 */
164
+ error: (_config: Omit<NotificationItem, 'key' | 'createdAt' | 'type'>) => string;
165
+ /** 关闭指定通知 */
166
+ close: (_key: string) => void;
167
+ /** 关闭所有通知 */
168
+ destroyAll: () => void;
169
+ /** 更新通知 */
170
+ update: (_key: string, config: Partial<NotificationItem>) => void;
171
+ /** 获取所有通知 */
172
+ getNotifications: () => NotificationItem[];
173
+ /** 获取通知数量 */
174
+ getCount: () => number;
175
+ /** 设置最大数量 */
176
+ setMaxCount: (_count: number) => void;
177
+ /** 设置默认位置 */
178
+ setDefaultPlacement: (_placement: NotificationPlacement) => void;
179
+ /** 设置默认时长 */
180
+ setDefaultDuration: (_duration: number) => void;
181
+ /** 暂停所有通知自动关闭 */
182
+ pauseAll: () => void;
183
+ /** 恢复所有通知自动关闭 */
184
+ resumeAll: () => void;
185
+ /** 清空历史记录 */
186
+ clearHistory: () => void;
187
+ /** 获取通知历史 */
188
+ getHistory: () => NotificationItem[];
189
+ }
190
+
191
+ /** 通知样式配置 */
192
+ export interface NotificationStyleConfig {
193
+ /** 基础样式 */
194
+ base: React.CSSProperties;
195
+ /** 类型样式 */
196
+ type: Record<NotificationType, React.CSSProperties>;
197
+ /** 位置样式 */
198
+ placement: Record<NotificationPlacement, React.CSSProperties>;
199
+ /** 图标样式 */
200
+ icon: React.CSSProperties;
201
+ /** 内容样式 */
202
+ content: React.CSSProperties;
203
+ /** 标题样式 */
204
+ title: React.CSSProperties;
205
+ /** 文本样式 */
206
+ text: React.CSSProperties;
207
+ /** 关闭按钮样式 */
208
+ close: React.CSSProperties;
209
+ /** 悬停样式 */
210
+ closeHover: React.CSSProperties;
211
+ /** 关闭图标样式 */
212
+ closeIcon: React.CSSProperties;
213
+ /** 动画样式 */
214
+ animation: {
215
+ enter: React.CSSProperties;
216
+ enterActive: React.CSSProperties;
217
+ exit: React.CSSProperties;
218
+ exitActive: React.CSSProperties;
219
+ };
220
+ }
221
+
222
+ /** 通知配置 */
223
+ export type NotificationConfig = Partial<NotificationItem>;
224
+
225
+ /** 通知样式集合 */
226
+ export type NotificationStyles = {
227
+ [key in NotificationType]: React.CSSProperties;
228
+ };
229
+
230
+ /** 通知位置样式 */
231
+ export type NotificationPlacementStyles = {
232
+ [key in NotificationPlacement]: React.CSSProperties;
233
+ };
234
+
235
+ /** 通知动画样式 */
236
+ export type NotificationAnimationStyles = {
237
+ enter: React.CSSProperties;
238
+ enterActive: React.CSSProperties;
239
+ exit: React.CSSProperties;
240
+ exitActive: React.CSSProperties;
241
+ };
242
+
243
+ /** 通知工具函数 */
244
+ export interface NotificationUtils {
245
+ /** 生成唯一键 */
246
+ generateKey: () => string;
247
+ /** 排序通知 */
248
+ sortNotifications: (_notifications: NotificationItem[]) => NotificationItem[];
249
+ /** 计算堆叠偏移 */
250
+ calculateStackOffset: (_index: number, baseOffset: number) => number;
251
+ /** 格式化持续时间 */
252
+ formatDuration: (_duration: number) => string;
253
+ /** 验证通知配置 */
254
+ validateConfig: (_config: Partial<NotificationItem>) => { valid: boolean; errors: string[] };
255
+ }
256
+
257
+ /** 默认通知配置 */
258
+ export const DEFAULT_NOTIFICATION_CONFIG = {
259
+ /** 默认最大数量 */
260
+ defaultMaxCount: 5,
261
+ /** 默认位置 */
262
+ defaultPlacement: 'topRight' as NotificationPlacement,
263
+ /** 默认时长 */
264
+ defaultDuration: 4500,
265
+ /** 默认动画 */
266
+ defaultAnimation: 'fade' as NotificationAnimation,
267
+ /** 默认堆叠 */
268
+ defaultStack: true,
269
+ /** 默认堆叠最大数量 */
270
+ defaultStackMaxCount: 3,
271
+ /** 默认允许拖拽 */
272
+ defaultAllowDrag: false,
273
+ /** 默认拖拽阈值 */
274
+ defaultDragThreshold: 100,
275
+ /** 默认显示分组 */
276
+ defaultShowGroup: false,
277
+ /** 默认分组间隔 */
278
+ defaultGroupInterval: 1000,
279
+ /** 最大历史记录数量 */
280
+ maxHistoryCount: 50,
281
+ /** 默认自动关闭 */
282
+ defaultAutoClose: true,
283
+ /** 默认显示关闭按钮 */
284
+ defaultShowClose: true,
285
+ /** 默认显示图标 */
286
+ defaultShowIcon: true,
287
+ /** 默认可关闭 */
288
+ defaultClosable: true,
289
+ } as const;
290
+
291
+ /** 通知工具类 */
292
+ export const NotificationUtils = {
293
+ /** 生成唯一键 */
294
+ generateKey: (): string => {
295
+ return `notification_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`;
296
+ },
297
+
298
+ /** 排序通知 */
299
+ sortNotifications: (notifications: NotificationItem[]): NotificationItem[] => {
300
+ return [...notifications].sort((a, b) => a.createdAt - b.createdAt);
301
+ },
302
+
303
+ /** 计算堆叠偏移 */
304
+ calculateStackOffset: (index: number, baseOffset: number = 8): number => {
305
+ return index * baseOffset;
306
+ },
307
+
308
+ /** 格式化持续时间 */
309
+ formatDuration: (duration: number): string => {
310
+ if (duration < 1000) return `${duration}ms`;
311
+ if (duration < 60000) return `${(duration / 1000).toFixed(1)}s`;
312
+ return `${(duration / 60000).toFixed(1)}min`;
313
+ },
314
+
315
+ /** 验证通知配置 */
316
+ validateConfig: (config: Partial<NotificationItem>): { valid: boolean; errors: string[] } => {
317
+ const errors: string[] = [];
318
+
319
+ if (config.duration !== undefined && (config.duration < 0 || config.duration > 60000)) {
320
+ errors.push('duration must be between 0 and 60000ms');
321
+ }
322
+
323
+ if (config.type !== undefined && !['success', 'error', 'warning', 'info'].includes(config.type)) {
324
+ errors.push('type must be one of: success, error, warning, info');
325
+ }
326
+
327
+ if (config.placement !== undefined && !['topRight', 'topLeft', 'bottomRight', 'bottomLeft', 'top', 'bottom'].includes(config.placement)) {
328
+ errors.push('placement must be one of: topRight, topLeft, bottomRight, bottomLeft, top, bottom');
329
+ }
330
+
331
+ return {
332
+ valid: errors.length === 0,
333
+ errors,
334
+ };
335
+ },
336
+ } as const;