taro-uno-ui 1.0.1 → 1.0.2

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 (414) hide show
  1. package/README.md +67 -30
  2. package/dist/js/{index-CDFsvu80.js → index-QpKiGsEQ.js} +39026 -28023
  3. package/dist/js/index-QpKiGsEQ.js.map +1 -0
  4. package/dist/js/{index-JffnTUrv.js → index-nnTHNhwl.js} +38743 -27720
  5. package/dist/js/index-nnTHNhwl.js.map +1 -0
  6. package/package.json +4 -4
  7. package/dist/js/index-CDFsvu80.js.map +0 -1
  8. package/dist/js/index-DFdcksbe.js +0 -1165
  9. package/dist/js/index-DFdcksbe.js.map +0 -1
  10. package/dist/js/index-DXRIkWX1.js +0 -1148
  11. package/dist/js/index-DXRIkWX1.js.map +0 -1
  12. package/dist/js/index-JffnTUrv.js.map +0 -1
  13. package/dist/utils/http/request.d.ts +0 -280
  14. package/src/app.config.ts +0 -55
  15. package/src/app.scss +0 -508
  16. package/src/app.tsx +0 -44
  17. package/src/components/basic/Button/Button.styles.ts +0 -130
  18. package/src/components/basic/Button/Button.test.tsx +0 -154
  19. package/src/components/basic/Button/Button.tsx +0 -133
  20. package/src/components/basic/Button/Button.types.ts +0 -81
  21. package/src/components/basic/Button/index.tsx +0 -6
  22. package/src/components/basic/Divider/Divider.styles.ts +0 -488
  23. package/src/components/basic/Divider/Divider.test.tsx +0 -551
  24. package/src/components/basic/Divider/Divider.tsx +0 -392
  25. package/src/components/basic/Divider/Divider.types.ts +0 -261
  26. package/src/components/basic/Divider/index.tsx +0 -25
  27. package/src/components/basic/Icon/Icon.data.ts +0 -474
  28. package/src/components/basic/Icon/Icon.styles.ts +0 -359
  29. package/src/components/basic/Icon/Icon.test.tsx +0 -357
  30. package/src/components/basic/Icon/Icon.tsx +0 -167
  31. package/src/components/basic/Icon/Icon.types.ts +0 -210
  32. package/src/components/basic/Icon/IconManager.ts +0 -229
  33. package/src/components/basic/Icon/index.tsx +0 -22
  34. package/src/components/basic/Text/Text.styles.ts +0 -500
  35. package/src/components/basic/Text/Text.test.tsx +0 -299
  36. package/src/components/basic/Text/Text.tsx +0 -340
  37. package/src/components/basic/Text/Text.types.ts +0 -329
  38. package/src/components/basic/Text/index.tsx +0 -27
  39. package/src/components/basic/Typography/Typography.styles.ts +0 -347
  40. package/src/components/basic/Typography/Typography.tsx +0 -207
  41. package/src/components/basic/Typography/Typography.types.ts +0 -296
  42. package/src/components/basic/Typography/index.tsx +0 -14
  43. package/src/components/basic/Video/Video.styles.ts +0 -777
  44. package/src/components/basic/Video/Video.test.tsx +0 -490
  45. package/src/components/basic/Video/Video.tsx +0 -1468
  46. package/src/components/basic/Video/Video.types.ts +0 -500
  47. package/src/components/basic/Video/index.tsx +0 -26
  48. package/src/components/basic/index.tsx +0 -300
  49. package/src/components/common/ErrorBoundary.tsx +0 -87
  50. package/src/components/common/LazyComponent.tsx +0 -247
  51. package/src/components/common/ResponsiveContainer.tsx +0 -93
  52. package/src/components/common/ResponsiveGrid.tsx +0 -183
  53. package/src/components/common/SecurityProvider.tsx +0 -98
  54. package/src/components/common/ThemeProvider.tsx +0 -115
  55. package/src/components/common/VirtualList.tsx +0 -350
  56. package/src/components/common/__tests__/ErrorBoundary.test.tsx +0 -249
  57. package/src/components/common/index.tsx +0 -32
  58. package/src/components/display/Avatar/Avatar.styles.ts +0 -62
  59. package/src/components/display/Avatar/Avatar.test.tsx +0 -390
  60. package/src/components/display/Avatar/Avatar.tsx +0 -66
  61. package/src/components/display/Avatar/Avatar.types.ts +0 -40
  62. package/src/components/display/Avatar/index.ts +0 -3
  63. package/src/components/display/Badge/Badge.tsx +0 -29
  64. package/src/components/display/Badge/Badge.types.ts +0 -29
  65. package/src/components/display/Badge/index.ts +0 -2
  66. package/src/components/display/Calendar/Calendar.styles.ts +0 -255
  67. package/src/components/display/Calendar/Calendar.test.tsx +0 -42
  68. package/src/components/display/Calendar/Calendar.tsx +0 -358
  69. package/src/components/display/Calendar/Calendar.types.ts +0 -91
  70. package/src/components/display/Calendar/index.ts +0 -3
  71. package/src/components/display/Card/Card.styles.ts +0 -89
  72. package/src/components/display/Card/Card.test.tsx +0 -182
  73. package/src/components/display/Card/Card.tsx +0 -135
  74. package/src/components/display/Card/Card.types.ts +0 -55
  75. package/src/components/display/Card/index.ts +0 -3
  76. package/src/components/display/Carousel/Carousel.styles.ts +0 -206
  77. package/src/components/display/Carousel/Carousel.tsx +0 -290
  78. package/src/components/display/Carousel/Carousel.types.ts +0 -57
  79. package/src/components/display/Carousel/index.ts +0 -3
  80. package/src/components/display/List/List.styles.ts +0 -79
  81. package/src/components/display/List/List.tsx +0 -114
  82. package/src/components/display/List/List.types.ts +0 -68
  83. package/src/components/display/List/index.ts +0 -3
  84. package/src/components/display/Rate/Rate.styles.ts +0 -254
  85. package/src/components/display/Rate/Rate.tsx +0 -324
  86. package/src/components/display/Rate/Rate.types.ts +0 -112
  87. package/src/components/display/Rate/index.ts +0 -20
  88. package/src/components/display/Table/Table.styles.ts +0 -269
  89. package/src/components/display/Table/Table.test.tsx +0 -345
  90. package/src/components/display/Table/Table.tsx +0 -426
  91. package/src/components/display/Table/Table.types.ts +0 -256
  92. package/src/components/display/Table/index.tsx +0 -16
  93. package/src/components/display/Tag/Tag.styles.ts +0 -197
  94. package/src/components/display/Tag/Tag.test.tsx +0 -541
  95. package/src/components/display/Tag/Tag.tsx +0 -139
  96. package/src/components/display/Tag/Tag.types.ts +0 -49
  97. package/src/components/display/Tag/index.ts +0 -3
  98. package/src/components/display/Timeline/Timeline.styles.ts +0 -211
  99. package/src/components/display/Timeline/Timeline.tsx +0 -220
  100. package/src/components/display/Timeline/Timeline.types.ts +0 -56
  101. package/src/components/display/Timeline/index.ts +0 -3
  102. package/src/components/display/index.tsx +0 -147
  103. package/src/components/feedback/Loading/Loading.styles.ts +0 -117
  104. package/src/components/feedback/Loading/Loading.test.tsx +0 -534
  105. package/src/components/feedback/Loading/Loading.tsx +0 -132
  106. package/src/components/feedback/Loading/Loading.types.ts +0 -33
  107. package/src/components/feedback/Loading/index.ts +0 -6
  108. package/src/components/feedback/Message/Message.styles.ts +0 -41
  109. package/src/components/feedback/Message/Message.test.tsx +0 -234
  110. package/src/components/feedback/Message/Message.tsx +0 -96
  111. package/src/components/feedback/Message/Message.types.ts +0 -37
  112. package/src/components/feedback/Message/index.ts +0 -6
  113. package/src/components/feedback/Modal/Modal.styles.ts +0 -21
  114. package/src/components/feedback/Modal/Modal.test.tsx +0 -11
  115. package/src/components/feedback/Modal/Modal.tsx +0 -269
  116. package/src/components/feedback/Modal/Modal.types.ts +0 -151
  117. package/src/components/feedback/Modal/index.tsx +0 -11
  118. package/src/components/feedback/Notification/Notification.styles.ts +0 -453
  119. package/src/components/feedback/Notification/Notification.test.tsx +0 -401
  120. package/src/components/feedback/Notification/Notification.tsx +0 -347
  121. package/src/components/feedback/Notification/Notification.types.ts +0 -339
  122. package/src/components/feedback/Notification/NotificationManager.tsx +0 -405
  123. package/src/components/feedback/Notification/index.ts +0 -40
  124. package/src/components/feedback/Notification/index.tsx +0 -154
  125. package/src/components/feedback/Progress/Progress.styles.ts +0 -469
  126. package/src/components/feedback/Progress/Progress.test.simple.tsx +0 -14
  127. package/src/components/feedback/Progress/Progress.test.tsx +0 -312
  128. package/src/components/feedback/Progress/Progress.tsx +0 -488
  129. package/src/components/feedback/Progress/Progress.types.ts +0 -163
  130. package/src/components/feedback/Progress/index.ts +0 -3
  131. package/src/components/feedback/Progress/index.tsx +0 -38
  132. package/src/components/feedback/Progress/utils/animation.ts +0 -193
  133. package/src/components/feedback/Progress/utils/index.ts +0 -26
  134. package/src/components/feedback/Progress/utils/progress-calculator.ts +0 -199
  135. package/src/components/feedback/Result/Result.styles.ts +0 -139
  136. package/src/components/feedback/Result/Result.tsx +0 -221
  137. package/src/components/feedback/Result/Result.types.ts +0 -128
  138. package/src/components/feedback/Result/index.tsx +0 -3
  139. package/src/components/feedback/Toast/Toast.styles.ts +0 -17
  140. package/src/components/feedback/Toast/Toast.test.tsx +0 -10
  141. package/src/components/feedback/Toast/Toast.tsx +0 -384
  142. package/src/components/feedback/Toast/Toast.types.ts +0 -86
  143. package/src/components/feedback/Toast/index.tsx +0 -3
  144. package/src/components/feedback/Tooltip/Tooltip.examples.tsx +0 -435
  145. package/src/components/feedback/Tooltip/Tooltip.styles.ts +0 -340
  146. package/src/components/feedback/Tooltip/Tooltip.test.tsx +0 -446
  147. package/src/components/feedback/Tooltip/Tooltip.tsx +0 -302
  148. package/src/components/feedback/Tooltip/Tooltip.types.ts +0 -166
  149. package/src/components/feedback/Tooltip/index.ts +0 -3
  150. package/src/components/feedback/Tooltip/index.tsx +0 -246
  151. package/src/components/feedback/index.tsx +0 -176
  152. package/src/components/form/Cascader/Cascader.styles.ts +0 -526
  153. package/src/components/form/Cascader/Cascader.test.tsx +0 -77
  154. package/src/components/form/Cascader/Cascader.tsx +0 -581
  155. package/src/components/form/Cascader/Cascader.types.ts +0 -581
  156. package/src/components/form/Cascader/hooks/index.ts +0 -3
  157. package/src/components/form/Cascader/hooks/useCascaderFieldNames.ts +0 -19
  158. package/src/components/form/Cascader/hooks/useCascaderOptions.ts +0 -127
  159. package/src/components/form/Cascader/hooks/useCascaderState.ts +0 -139
  160. package/src/components/form/Cascader/index.ts +0 -25
  161. package/src/components/form/Cascader/utils/formatDisplayValue.ts +0 -19
  162. package/src/components/form/Cascader/utils/index.ts +0 -1
  163. package/src/components/form/Checkbox/Checkbox.styles.ts +0 -607
  164. package/src/components/form/Checkbox/Checkbox.test.tsx +0 -1140
  165. package/src/components/form/Checkbox/Checkbox.tsx +0 -489
  166. package/src/components/form/Checkbox/Checkbox.types.ts +0 -472
  167. package/src/components/form/Checkbox/CheckboxGroup.tsx +0 -444
  168. package/src/components/form/Checkbox/index.tsx +0 -27
  169. package/src/components/form/DatePicker/DatePicker.styles.ts +0 -393
  170. package/src/components/form/DatePicker/DatePicker.test.tsx +0 -407
  171. package/src/components/form/DatePicker/DatePicker.tsx +0 -376
  172. package/src/components/form/DatePicker/DatePicker.types.ts +0 -250
  173. package/src/components/form/DatePicker/index.tsx +0 -15
  174. package/src/components/form/Form/Form.styles.ts +0 -357
  175. package/src/components/form/Form/Form.test.tsx +0 -122
  176. package/src/components/form/Form/Form.tsx +0 -257
  177. package/src/components/form/Form/Form.types.ts +0 -422
  178. package/src/components/form/Form/index.tsx +0 -31
  179. package/src/components/form/Form/useFormLogic.ts +0 -497
  180. package/src/components/form/Input/Input.styles.ts +0 -445
  181. package/src/components/form/Input/Input.test.tsx +0 -494
  182. package/src/components/form/Input/Input.tsx +0 -305
  183. package/src/components/form/Input/Input.types.ts +0 -297
  184. package/src/components/form/Input/index.tsx +0 -26
  185. package/src/components/form/Input/useInputLogic.test.ts +0 -82
  186. package/src/components/form/Input/useInputLogic.ts +0 -260
  187. package/src/components/form/InputNumber/InputNumber.styles.ts +0 -716
  188. package/src/components/form/InputNumber/InputNumber.tsx +0 -402
  189. package/src/components/form/InputNumber/InputNumber.types.ts +0 -336
  190. package/src/components/form/InputNumber/components/InputNumberClearButton.tsx +0 -24
  191. package/src/components/form/InputNumber/components/InputNumberControls.tsx +0 -33
  192. package/src/components/form/InputNumber/components/index.ts +0 -2
  193. package/src/components/form/InputNumber/hooks/index.ts +0 -4
  194. package/src/components/form/InputNumber/hooks/useInputNumberState.ts +0 -313
  195. package/src/components/form/InputNumber/hooks/useInputNumberValidation.ts +0 -148
  196. package/src/components/form/InputNumber/index.ts +0 -25
  197. package/src/components/form/Radio/Radio.styles.ts +0 -451
  198. package/src/components/form/Radio/Radio.test.tsx +0 -547
  199. package/src/components/form/Radio/Radio.tsx +0 -277
  200. package/src/components/form/Radio/Radio.types.ts +0 -414
  201. package/src/components/form/Radio/index.tsx +0 -21
  202. package/src/components/form/Select/Select.styles.ts +0 -518
  203. package/src/components/form/Select/Select.test.tsx +0 -648
  204. package/src/components/form/Select/Select.tsx +0 -474
  205. package/src/components/form/Select/Select.types.ts +0 -429
  206. package/src/components/form/Select/index.tsx +0 -30
  207. package/src/components/form/Slider/Slider.styles.ts +0 -139
  208. package/src/components/form/Slider/Slider.test.tsx +0 -553
  209. package/src/components/form/Slider/Slider.tsx +0 -312
  210. package/src/components/form/Slider/Slider.types.ts +0 -110
  211. package/src/components/form/Slider/index.tsx +0 -3
  212. package/src/components/form/Switch/Switch.styles.ts +0 -534
  213. package/src/components/form/Switch/Switch.test.tsx +0 -345
  214. package/src/components/form/Switch/Switch.tsx +0 -458
  215. package/src/components/form/Switch/Switch.types.ts +0 -386
  216. package/src/components/form/Switch/index.tsx +0 -26
  217. package/src/components/form/Textarea/Textarea.styles.ts +0 -592
  218. package/src/components/form/Textarea/Textarea.test.tsx +0 -1075
  219. package/src/components/form/Textarea/Textarea.tsx +0 -608
  220. package/src/components/form/Textarea/Textarea.types.ts +0 -374
  221. package/src/components/form/Textarea/index.tsx +0 -26
  222. package/src/components/form/TimePicker/TimePicker.styles.ts +0 -434
  223. package/src/components/form/TimePicker/TimePicker.test.tsx +0 -306
  224. package/src/components/form/TimePicker/TimePicker.tsx +0 -250
  225. package/src/components/form/TimePicker/TimePicker.types.ts +0 -385
  226. package/src/components/form/TimePicker/index.ts +0 -21
  227. package/src/components/form/Transfer/Transfer.styles.ts +0 -490
  228. package/src/components/form/Transfer/Transfer.test.tsx +0 -316
  229. package/src/components/form/Transfer/Transfer.tsx +0 -414
  230. package/src/components/form/Transfer/Transfer.types.ts +0 -565
  231. package/src/components/form/Transfer/components/TransferItem.tsx +0 -94
  232. package/src/components/form/Transfer/components/TransferList.tsx +0 -298
  233. package/src/components/form/Transfer/components/TransferOperations.tsx +0 -81
  234. package/src/components/form/Transfer/components/TransferPagination.tsx +0 -139
  235. package/src/components/form/Transfer/components/TransferSearch.tsx +0 -85
  236. package/src/components/form/Transfer/components/index.ts +0 -6
  237. package/src/components/form/Transfer/hooks/index.ts +0 -3
  238. package/src/components/form/Transfer/hooks/useTransferData.ts +0 -202
  239. package/src/components/form/Transfer/hooks/useTransferState.ts +0 -120
  240. package/src/components/form/Transfer/index.ts +0 -27
  241. package/src/components/form/Upload/Upload.styles.ts +0 -145
  242. package/src/components/form/Upload/Upload.test.tsx +0 -10
  243. package/src/components/form/Upload/Upload.tsx +0 -498
  244. package/src/components/form/Upload/Upload.types.ts +0 -200
  245. package/src/components/form/Upload/index.tsx +0 -12
  246. package/src/components/form/index.tsx +0 -152
  247. package/src/components/index.tsx +0 -145
  248. package/src/components/layout/Affix/Affix.styles.ts +0 -42
  249. package/src/components/layout/Affix/Affix.test.tsx +0 -10
  250. package/src/components/layout/Affix/Affix.tsx +0 -83
  251. package/src/components/layout/Affix/Affix.types.ts +0 -29
  252. package/src/components/layout/Affix/index.tsx +0 -3
  253. package/src/components/layout/Col/Col.styles.ts +0 -185
  254. package/src/components/layout/Col/Col.test.tsx +0 -537
  255. package/src/components/layout/Col/Col.tsx +0 -97
  256. package/src/components/layout/Col/Col.types.ts +0 -59
  257. package/src/components/layout/Col/index.tsx +0 -3
  258. package/src/components/layout/Container/Container.styles.ts +0 -163
  259. package/src/components/layout/Container/Container.test.tsx +0 -380
  260. package/src/components/layout/Container/Container.tsx +0 -123
  261. package/src/components/layout/Container/Container.types.ts +0 -63
  262. package/src/components/layout/Container/index.tsx +0 -3
  263. package/src/components/layout/Grid/Grid.styles.ts +0 -183
  264. package/src/components/layout/Grid/Grid.test.tsx +0 -637
  265. package/src/components/layout/Grid/Grid.tsx +0 -123
  266. package/src/components/layout/Grid/Grid.types.ts +0 -78
  267. package/src/components/layout/Grid/index.tsx +0 -3
  268. package/src/components/layout/Layout/Content.tsx +0 -30
  269. package/src/components/layout/Layout/Footer.tsx +0 -30
  270. package/src/components/layout/Layout/Header.tsx +0 -30
  271. package/src/components/layout/Layout/Layout.styles.ts +0 -84
  272. package/src/components/layout/Layout/Layout.test.tsx +0 -10
  273. package/src/components/layout/Layout/Layout.tsx +0 -28
  274. package/src/components/layout/Layout/Layout.types.ts +0 -58
  275. package/src/components/layout/Layout/Sider.tsx +0 -44
  276. package/src/components/layout/Layout/index.tsx +0 -22
  277. package/src/components/layout/Row/Row.styles.ts +0 -159
  278. package/src/components/layout/Row/Row.test.tsx +0 -467
  279. package/src/components/layout/Row/Row.tsx +0 -111
  280. package/src/components/layout/Row/Row.types.ts +0 -60
  281. package/src/components/layout/Row/index.tsx +0 -3
  282. package/src/components/layout/Space/Space.styles.ts +0 -255
  283. package/src/components/layout/Space/Space.test.tsx +0 -682
  284. package/src/components/layout/Space/Space.tsx +0 -203
  285. package/src/components/layout/Space/Space.types.ts +0 -92
  286. package/src/components/layout/Space/index.tsx +0 -12
  287. package/src/components/layout/index.tsx +0 -78
  288. package/src/components/navigation/Menu/Menu.constants.ts +0 -69
  289. package/src/components/navigation/Menu/Menu.stories.tsx +0 -107
  290. package/src/components/navigation/Menu/Menu.styles.ts +0 -767
  291. package/src/components/navigation/Menu/Menu.tsx +0 -352
  292. package/src/components/navigation/Menu/Menu.types.ts +0 -231
  293. package/src/components/navigation/Menu/Menu.utils.ts +0 -187
  294. package/src/components/navigation/Menu/MenuItem.tsx +0 -124
  295. package/src/components/navigation/Menu/SubMenu.tsx +0 -150
  296. package/src/components/navigation/Menu/index.tsx +0 -59
  297. package/src/components/navigation/NavBar/NavBar.styles.ts +0 -129
  298. package/src/components/navigation/NavBar/NavBar.test.tsx +0 -287
  299. package/src/components/navigation/NavBar/NavBar.tsx +0 -228
  300. package/src/components/navigation/NavBar/NavBar.types.ts +0 -54
  301. package/src/components/navigation/NavBar/index.tsx +0 -3
  302. package/src/components/navigation/Pagination/Pagination.styles.ts +0 -187
  303. package/src/components/navigation/Pagination/Pagination.test.tsx +0 -672
  304. package/src/components/navigation/Pagination/Pagination.tsx +0 -395
  305. package/src/components/navigation/Pagination/Pagination.types.ts +0 -87
  306. package/src/components/navigation/Pagination/index.ts +0 -24
  307. package/src/components/navigation/Pagination/index.tsx +0 -9
  308. package/src/components/navigation/Steps/Step.tsx +0 -36
  309. package/src/components/navigation/Steps/Steps.styles.ts +0 -169
  310. package/src/components/navigation/Steps/Steps.test.tsx +0 -14
  311. package/src/components/navigation/Steps/Steps.tsx +0 -112
  312. package/src/components/navigation/Steps/Steps.types.ts +0 -47
  313. package/src/components/navigation/Steps/index.tsx +0 -3
  314. package/src/components/navigation/Tabs/Tabs.styles.ts +0 -199
  315. package/src/components/navigation/Tabs/Tabs.test.tsx +0 -662
  316. package/src/components/navigation/Tabs/Tabs.tsx +0 -253
  317. package/src/components/navigation/Tabs/Tabs.types.ts +0 -115
  318. package/src/components/navigation/Tabs/index.tsx +0 -3
  319. package/src/components/navigation/index.tsx +0 -88
  320. package/src/constants/index.ts +0 -785
  321. package/src/hooks/index.ts +0 -60
  322. package/src/hooks/types.ts +0 -9
  323. package/src/hooks/useAsync.ts +0 -64
  324. package/src/hooks/useClickOutside.ts +0 -52
  325. package/src/hooks/useCounter.ts +0 -87
  326. package/src/hooks/useDebounce.ts +0 -150
  327. package/src/hooks/useDeepCompareEffect.ts +0 -88
  328. package/src/hooks/useEventHandling.ts +0 -444
  329. package/src/hooks/useEventListener.ts +0 -77
  330. package/src/hooks/useLifecycle.ts +0 -399
  331. package/src/hooks/useMediaQuery.ts +0 -75
  332. package/src/hooks/useMutation.ts +0 -233
  333. package/src/hooks/usePerformance.ts +0 -378
  334. package/src/hooks/usePerformanceMonitor.ts +0 -348
  335. package/src/hooks/usePlatform.ts +0 -64
  336. package/src/hooks/usePrevious.ts +0 -25
  337. package/src/hooks/useRequest.test.ts +0 -11
  338. package/src/hooks/useRequest.ts +0 -140
  339. package/src/hooks/useStateManagement.ts +0 -300
  340. package/src/hooks/useStorage.ts +0 -169
  341. package/src/hooks/useStyle.ts +0 -543
  342. package/src/hooks/useTheme.ts +0 -347
  343. package/src/hooks/useToggle.ts +0 -54
  344. package/src/hooks/useVirtualScroll.ts +0 -331
  345. package/src/index.ts +0 -323
  346. package/src/platform/index.ts +0 -1188
  347. package/src/providers/AppProvider.test.tsx +0 -63
  348. package/src/providers/AppProvider.tsx +0 -155
  349. package/src/providers/index.ts +0 -1
  350. package/src/theme/ThemeProvider.tsx +0 -279
  351. package/src/theme/ThemeProvider.types.ts +0 -26
  352. package/src/theme/animations.tsx +0 -660
  353. package/src/theme/defaults.ts +0 -188
  354. package/src/theme/design-system.ts +0 -562
  355. package/src/theme/design-tokens.ts +0 -1122
  356. package/src/theme/generated/dark-theme.scss +0 -120
  357. package/src/theme/generated/tokens.css +0 -441
  358. package/src/theme/generated/tokens.scss +0 -384
  359. package/src/theme/index.ts +0 -99
  360. package/src/theme/responsive.tsx +0 -195
  361. package/src/theme/styles/mixins.scss +0 -612
  362. package/src/theme/styles/variables.scss +0 -295
  363. package/src/theme/styles.ts +0 -403
  364. package/src/theme/tokens/colors.ts +0 -256
  365. package/src/theme/tokens/effects.ts +0 -260
  366. package/src/theme/tokens/index.ts +0 -217
  367. package/src/theme/tokens/spacing.ts +0 -137
  368. package/src/theme/tokens/typography.ts +0 -186
  369. package/src/theme/types.ts +0 -188
  370. package/src/theme/useThemeUtils.ts +0 -313
  371. package/src/theme/utils.ts +0 -501
  372. package/src/theme/variables.ts +0 -602
  373. package/src/types/accessibility.ts +0 -50
  374. package/src/types/button.ts +0 -560
  375. package/src/types/component-props.ts +0 -322
  376. package/src/types/env.d.ts +0 -20
  377. package/src/types/glob.d.ts +0 -4
  378. package/src/types/index.ts +0 -427
  379. package/src/types/modules.d.ts +0 -40
  380. package/src/types/standardized-components.ts +0 -550
  381. package/src/types/taro-adapter.d.ts +0 -174
  382. package/src/types/taro-components.d.ts +0 -73
  383. package/src/types/utils.ts +0 -400
  384. package/src/utils/__tests__/inputValidator.test.ts +0 -338
  385. package/src/utils/__tests__/responsiveUtils.test.ts +0 -311
  386. package/src/utils/__tests__/xssProtection.test.ts +0 -268
  387. package/src/utils/abort-controller.ts +0 -48
  388. package/src/utils/cache.ts +0 -79
  389. package/src/utils/createNamespace.ts +0 -24
  390. package/src/utils/environment.ts +0 -115
  391. package/src/utils/error-handler.ts +0 -88
  392. package/src/utils/errorLogger.ts +0 -193
  393. package/src/utils/formatUtils.ts +0 -412
  394. package/src/utils/http/error-codes.ts +0 -314
  395. package/src/utils/http/http-client.test.ts +0 -63
  396. package/src/utils/http/http-client.ts +0 -161
  397. package/src/utils/http/request-cache.ts +0 -127
  398. package/src/utils/http/request.ts +0 -954
  399. package/src/utils/http/taro-adapter.test.ts +0 -74
  400. package/src/utils/http/taro-adapter.ts +0 -24
  401. package/src/utils/http/types.ts +0 -414
  402. package/src/utils/http/web-adapter.ts +0 -33
  403. package/src/utils/index.ts +0 -112
  404. package/src/utils/inputValidator.ts +0 -264
  405. package/src/utils/performance/performance.ts +0 -839
  406. package/src/utils/responsiveUtils.ts +0 -348
  407. package/src/utils/rtl-support.ts +0 -354
  408. package/src/utils/security/api-security.ts +0 -394
  409. package/src/utils/security/xss-protection.ts +0 -69
  410. package/src/utils/securityHeaders.ts +0 -308
  411. package/src/utils/typeHelpers.ts +0 -16
  412. package/src/utils/types/dataProcessing.ts +0 -544
  413. package/src/utils/types/typeHelpers.ts +0 -197
  414. package/src/utils/xssProtection.ts +0 -468
@@ -1,347 +0,0 @@
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(
38
- (error: Error, context: string) => {
39
- console.error(`Notification error in ${context}:`, error);
40
- setHasError(true);
41
- setErrorMessage(error.message);
42
-
43
- // 自动关闭错误的通知
44
- if (timerRef.current) {
45
- clearTimeout(timerRef.current);
46
- timerRef.current = null;
47
- }
48
-
49
- // 延迟关闭以显示错误状态
50
- timerRef.current = setTimeout(() => {
51
- setVisible(false);
52
- setIsClosing(true);
53
- onClose?.();
54
- }, 3000) as unknown as number;
55
- },
56
- [onClose],
57
- );
58
-
59
- // 状态管理
60
- const [visible, setVisible] = useState(true);
61
- const [closeHovered, setCloseHovered] = useState(false);
62
- const [isClosing, setIsClosing] = useState(false);
63
- const [paused, setPaused] = useState(false);
64
-
65
- // 定时器引用
66
- const timerRef = useRef<number | null>(null);
67
- const startTimeRef = useRef<number>(0);
68
- const remainingTimeRef = useRef<number>(duration);
69
-
70
- // 处理自动关闭
71
- const handleAutoClose = useCallback(() => {
72
- try {
73
- if (!autoClose || duration <= 0 || paused) return;
74
-
75
- if (timerRef.current) {
76
- clearTimeout(timerRef.current);
77
- timerRef.current = null;
78
- }
79
-
80
- // 使用更安全的定时器处理
81
- const timeoutId = setTimeout(() => {
82
- try {
83
- setVisible(false);
84
- setIsClosing(true);
85
- onClose?.();
86
- } catch (error) {
87
- handleError(error as Error, 'autoCloseTimeout');
88
- }
89
- }, remainingTimeRef.current);
90
-
91
- timerRef.current = timeoutId as unknown as number;
92
- startTimeRef.current = Date.now();
93
- } catch (error) {
94
- handleError(error as Error, 'handleAutoClose');
95
- }
96
- }, [autoClose, duration, paused, onClose, remainingTimeRef, handleError]);
97
-
98
- // 暂停自动关闭
99
- const pauseProgress = useCallback(() => {
100
- try {
101
- if (timerRef.current) {
102
- clearTimeout(timerRef.current);
103
- const elapsed = Date.now() - startTimeRef.current;
104
- remainingTimeRef.current = Math.max(0, remainingTimeRef.current - elapsed);
105
- setPaused(true);
106
- timerRef.current = null;
107
- }
108
- } catch (error) {
109
- handleError(error as Error, 'pauseProgress');
110
- }
111
- }, [handleError]);
112
-
113
- // 恢复自动关闭
114
- const resumeProgress = useCallback(() => {
115
- try {
116
- setPaused(false);
117
- handleAutoClose();
118
- } catch (error) {
119
- handleError(error as Error, 'resumeProgress');
120
- }
121
- }, [handleAutoClose, handleError]);
122
-
123
- // 暴露方法给ref
124
- React.useImperativeHandle(ref, () => ({
125
- hide: () => {
126
- setVisible(false);
127
- setIsClosing(true);
128
- if (timerRef.current) {
129
- clearTimeout(timerRef.current);
130
- timerRef.current = null;
131
- }
132
- onClose?.();
133
- return true;
134
- },
135
- show: () => {
136
- setVisible(true);
137
- setIsClosing(false);
138
- remainingTimeRef.current = duration;
139
- handleAutoClose();
140
- return true;
141
- },
142
- update: (newProps: Partial<NotificationProps>) => {
143
- // 这里可以实现更新通知内容的逻辑
144
- console.log('Update notification:', newProps);
145
- return true;
146
- },
147
- pauseProgress,
148
- resumeProgress,
149
- getState: () => ({
150
- visible,
151
- paused,
152
- closing: isClosing,
153
- }),
154
- }));
155
-
156
- // 自动关闭效果
157
- useEffect(() => {
158
- handleAutoClose();
159
-
160
- return () => {
161
- // 清理定时器
162
- if (timerRef.current) {
163
- clearTimeout(timerRef.current);
164
- timerRef.current = null;
165
- }
166
- };
167
- }, [handleAutoClose]);
168
-
169
- // 组件卸载时的清理
170
- useEffect(() => {
171
- return () => {
172
- // 确保所有定时器都被清理
173
- if (timerRef.current) {
174
- clearTimeout(timerRef.current);
175
- timerRef.current = null;
176
- }
177
-
178
- // 清理状态引用
179
- setHasError(false);
180
- setErrorMessage(null);
181
- };
182
- }, []);
183
-
184
- // 关闭处理
185
- const handleClose = useCallback(
186
- (e?: any) => {
187
- e?.stopPropagation();
188
- setVisible(false);
189
- setIsClosing(true);
190
- if (timerRef.current) {
191
- clearTimeout(timerRef.current);
192
- timerRef.current = null;
193
- }
194
- onClose?.();
195
- },
196
- [onClose],
197
- );
198
-
199
- // 点击处理
200
- const handleClick = useCallback(
201
- (e?: any) => {
202
- try {
203
- onClick?.(e);
204
- } catch (error) {
205
- handleError(error as Error, 'handleClick');
206
- }
207
- },
208
- [onClick, handleError],
209
- );
210
-
211
- // 触摸开始处理(替代鼠标悬停)
212
- const handleTouchStart = useCallback(
213
- (_e?: any) => {
214
- try {
215
- setCloseHovered(true);
216
- if (autoClose) {
217
- pauseProgress();
218
- }
219
- } catch (error) {
220
- handleError(error as Error, 'handleTouchStart');
221
- }
222
- },
223
- [autoClose, pauseProgress, handleError],
224
- );
225
-
226
- // 触摸结束处理(替代鼠标离开)
227
- const handleTouchEnd = useCallback(
228
- (_e?: any) => {
229
- try {
230
- setCloseHovered(false);
231
- if (autoClose && paused) {
232
- resumeProgress();
233
- }
234
- } catch (error) {
235
- handleError(error as Error, 'handleTouchEnd');
236
- }
237
- },
238
- [autoClose, paused, resumeProgress, handleError],
239
- );
240
-
241
- // 渲染图标
242
- const renderIcon = useCallback(() => {
243
- try {
244
- if (!showIcon) return null;
245
-
246
- if (icon) {
247
- return <View className={notificationStyles['icon']}>{icon}</View>;
248
- }
249
-
250
- const defaultIcons: Record<NotificationType, string> = {
251
- success: '✓',
252
- error: '✕',
253
- warning: '⚠',
254
- info: 'ℹ',
255
- };
256
-
257
- return (
258
- <View className={notificationStyles['icon']}>
259
- <Text className={notificationStyles['iconText']}>{defaultIcons[type]}</Text>
260
- </View>
261
- );
262
- } catch (error) {
263
- handleError(error as Error, 'renderIcon');
264
- return null;
265
- }
266
- }, [showIcon, icon, type, handleError]);
267
-
268
- // 计算容器样式
269
- const containerStyle = React.useMemo(() => {
270
- try {
271
- const baseStyle = notificationStyleHelpers.getBaseStyle(placement, style);
272
- const typeStyle = notificationStyleHelpers.getTypeStyle(type);
273
- const animationStyle = notificationStyleHelpers.getAnimationStyle(animation, visible);
274
-
275
- return {
276
- ...baseStyle,
277
- ...typeStyle,
278
- ...animationStyle,
279
- };
280
- } catch (error) {
281
- handleError(error as Error, 'containerStyle');
282
- return notificationStyleHelpers.getBaseStyle(placement, style);
283
- }
284
- }, [placement, style, type, animation, visible, handleError]);
285
-
286
- // 计算类名
287
- const containerClassName = React.useMemo(() => {
288
- try {
289
- const classes = [
290
- 'taro-uno-notification',
291
- `taro-uno-notification-${type}`,
292
- `taro-uno-notification-${placement}`,
293
- isClosing && 'taro-uno-notification-closing',
294
- closeHovered && 'taro-uno-notification-hovered',
295
- paused && 'taro-uno-notification-paused',
296
- hasError && 'taro-uno-notification-error',
297
- className,
298
- ];
299
- return cn(...classes);
300
- } catch (error) {
301
- handleError(error as Error, 'containerClassName');
302
- return 'taro-uno-notification taro-uno-notification-error';
303
- }
304
- }, [type, placement, isClosing, closeHovered, paused, hasError, className, handleError]);
305
-
306
- // 如果不可见,返回null
307
- if (!visible) return null;
308
-
309
- return (
310
- <View
311
- style={containerStyle}
312
- className={containerClassName}
313
- onClick={handleClick}
314
- onTouchStart={handleTouchStart}
315
- onTouchEnd={handleTouchEnd}
316
- {...rest}
317
- >
318
- {renderIcon()}
319
-
320
- <View className={notificationStyles['content']}>
321
- {hasError ? (
322
- <Text className={notificationStyles['title']}>通知错误</Text>
323
- ) : (
324
- title && <Text className={notificationStyles['title']}>{title}</Text>
325
- )}
326
- {hasError ? (
327
- <Text className={notificationStyles['text']}>{errorMessage || '通知显示异常'}</Text>
328
- ) : (
329
- content && <Text className={notificationStyles['text']}>{content}</Text>
330
- )}
331
- </View>
332
-
333
- {showClose && closable && (
334
- <View
335
- className={cn(notificationStyles['close'], closeHovered && notificationStyles['closeHover'])}
336
- onClick={handleClose}
337
- >
338
- <Text className={notificationStyles['closeIcon']}>✕</Text>
339
- </View>
340
- )}
341
- </View>
342
- );
343
- });
344
-
345
- Notification.displayName = 'Notification';
346
-
347
- export default Notification;
@@ -1,339 +0,0 @@
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 NotificationUtilsType {
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: NotificationUtilsType = {
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 (
328
- config.placement !== undefined &&
329
- !['topRight', 'topLeft', 'bottomRight', 'bottomLeft', 'top', 'bottom'].includes(config.placement)
330
- ) {
331
- errors.push('placement must be one of: topRight, topLeft, bottomRight, bottomLeft, top, bottom');
332
- }
333
-
334
- return {
335
- valid: errors.length === 0,
336
- errors,
337
- };
338
- },
339
- } as const;