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,1165 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
4
+ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
5
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
6
+ const Taro = require("@tarojs/taro");
7
+ function _interopNamespaceDefault(e) {
8
+ const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
9
+ if (e) {
10
+ for (const k in e) {
11
+ if (k !== "default") {
12
+ const d = Object.getOwnPropertyDescriptor(e, k);
13
+ Object.defineProperty(n, k, d.get ? d : {
14
+ enumerable: true,
15
+ get: () => e[k]
16
+ });
17
+ }
18
+ }
19
+ }
20
+ n.default = e;
21
+ return Object.freeze(n);
22
+ }
23
+ const Taro__namespace = /* @__PURE__ */ _interopNamespaceDefault(Taro);
24
+ const PLATFORM_NAMES = {
25
+ weapp: "微信小程序",
26
+ alipay: "支付宝小程序",
27
+ swan: "百度小程序",
28
+ tt: "字节跳动小程序",
29
+ qq: "QQ小程序",
30
+ h5: "H5",
31
+ rn: "React Native",
32
+ jd: "京东小程序"
33
+ };
34
+ const PLATFORM_FEATURES = {
35
+ weapp: {
36
+ supportsStorage: true,
37
+ supportsNetwork: true,
38
+ supportsLocation: true,
39
+ supportsCamera: true,
40
+ supportsPayment: true,
41
+ supportsShare: true,
42
+ supportsBiometrics: true
43
+ },
44
+ alipay: {
45
+ supportsStorage: true,
46
+ supportsNetwork: true,
47
+ supportsLocation: true,
48
+ supportsCamera: true,
49
+ supportsPayment: true,
50
+ supportsShare: true,
51
+ supportsBiometrics: true
52
+ },
53
+ swan: {
54
+ supportsStorage: true,
55
+ supportsNetwork: true,
56
+ supportsLocation: true,
57
+ supportsCamera: true,
58
+ supportsPayment: true,
59
+ supportsShare: true,
60
+ supportsBiometrics: false
61
+ },
62
+ tt: {
63
+ supportsStorage: true,
64
+ supportsNetwork: true,
65
+ supportsLocation: true,
66
+ supportsCamera: true,
67
+ supportsPayment: true,
68
+ supportsShare: true,
69
+ supportsBiometrics: false
70
+ },
71
+ qq: {
72
+ supportsStorage: true,
73
+ supportsNetwork: true,
74
+ supportsLocation: true,
75
+ supportsCamera: true,
76
+ supportsPayment: true,
77
+ supportsShare: true,
78
+ supportsBiometrics: false
79
+ },
80
+ h5: {
81
+ supportsStorage: true,
82
+ supportsNetwork: true,
83
+ supportsLocation: true,
84
+ supportsCamera: true,
85
+ supportsPayment: true,
86
+ supportsShare: true,
87
+ supportsBiometrics: false
88
+ },
89
+ rn: {
90
+ supportsStorage: true,
91
+ supportsNetwork: true,
92
+ supportsLocation: true,
93
+ supportsCamera: true,
94
+ supportsPayment: true,
95
+ supportsShare: true,
96
+ supportsBiometrics: true
97
+ },
98
+ jd: {
99
+ supportsStorage: true,
100
+ supportsNetwork: true,
101
+ supportsLocation: true,
102
+ supportsCamera: true,
103
+ supportsPayment: true,
104
+ supportsShare: true,
105
+ supportsBiometrics: false
106
+ }
107
+ };
108
+ const PLATFORM_APIS = {
109
+ weapp: {
110
+ request: "wx.request",
111
+ storage: {
112
+ set: "wx.setStorage",
113
+ get: "wx.getStorage",
114
+ remove: "wx.removeStorage",
115
+ clear: "wx.clearStorage"
116
+ },
117
+ location: {
118
+ get: "wx.getLocation",
119
+ open: "wx.openLocation"
120
+ },
121
+ camera: {
122
+ take: "wx.cameraTake",
123
+ choose: "wx.chooseImage"
124
+ }
125
+ },
126
+ alipay: {
127
+ request: "my.request",
128
+ storage: {
129
+ set: "my.setStorage",
130
+ get: "my.getStorage",
131
+ remove: "my.removeStorage",
132
+ clear: "my.clearStorage"
133
+ },
134
+ location: {
135
+ get: "my.getLocation",
136
+ open: "my.openLocation"
137
+ },
138
+ camera: {
139
+ take: "my.cameraTake",
140
+ choose: "my.chooseImage"
141
+ }
142
+ },
143
+ swan: {
144
+ request: "swan.request",
145
+ storage: {
146
+ set: "swan.setStorage",
147
+ get: "swan.getStorage",
148
+ remove: "swan.removeStorage",
149
+ clear: "swan.clearStorage"
150
+ },
151
+ location: {
152
+ get: "swan.getLocation",
153
+ open: "swan.openLocation"
154
+ },
155
+ camera: {
156
+ take: "swan.cameraTake",
157
+ choose: "swan.chooseImage"
158
+ }
159
+ },
160
+ tt: {
161
+ request: "tt.request",
162
+ storage: {
163
+ set: "tt.setStorage",
164
+ get: "tt.getStorage",
165
+ remove: "tt.removeStorage",
166
+ clear: "tt.clearStorage"
167
+ },
168
+ location: {
169
+ get: "tt.getLocation",
170
+ open: "tt.openLocation"
171
+ },
172
+ camera: {
173
+ take: "tt.cameraTake",
174
+ choose: "tt.chooseImage"
175
+ }
176
+ },
177
+ qq: {
178
+ request: "qq.request",
179
+ storage: {
180
+ set: "qq.setStorage",
181
+ get: "qq.getStorage",
182
+ remove: "qq.removeStorage",
183
+ clear: "qq.clearStorage"
184
+ },
185
+ location: {
186
+ get: "qq.getLocation",
187
+ open: "qq.openLocation"
188
+ },
189
+ camera: {
190
+ take: "qq.cameraTake",
191
+ choose: "qq.chooseImage"
192
+ }
193
+ },
194
+ h5: {
195
+ request: "fetch",
196
+ storage: {
197
+ set: "localStorage.setItem",
198
+ get: "localStorage.getItem",
199
+ remove: "localStorage.removeItem",
200
+ clear: "localStorage.clear"
201
+ },
202
+ location: {
203
+ get: "navigator.geolocation.getCurrentPosition",
204
+ open: "window.open"
205
+ },
206
+ camera: {
207
+ take: "navigator.mediaDevices.getUserMedia",
208
+ choose: "input[type=file].click()"
209
+ }
210
+ },
211
+ rn: {
212
+ request: "fetch",
213
+ storage: {
214
+ set: "AsyncStorage.setItem",
215
+ get: "AsyncStorage.getItem",
216
+ remove: "AsyncStorage.removeItem",
217
+ clear: "AsyncStorage.clear"
218
+ },
219
+ location: {
220
+ get: "Geolocation.getCurrentPosition",
221
+ open: "Linking.openURL"
222
+ },
223
+ camera: {
224
+ take: "Camera.takePictureAsync",
225
+ choose: "ImagePicker.launchImageLibrary"
226
+ }
227
+ },
228
+ jd: {
229
+ request: "jd.request",
230
+ storage: {
231
+ set: "jd.setStorage",
232
+ get: "jd.getStorage",
233
+ remove: "jd.removeStorage",
234
+ clear: "jd.clearStorage"
235
+ },
236
+ location: {
237
+ get: "jd.getLocation",
238
+ open: "jd.openLocation"
239
+ },
240
+ camera: {
241
+ take: "jd.cameraTake",
242
+ choose: "jd.chooseImage"
243
+ }
244
+ }
245
+ };
246
+ class WeappAdapter {
247
+ constructor() {
248
+ __publicField(this, "storage", {
249
+ async set(key, value) {
250
+ return new Promise((resolve, reject) => {
251
+ Taro__namespace.setStorage({
252
+ key,
253
+ data: value,
254
+ success: () => resolve(),
255
+ fail: reject
256
+ });
257
+ });
258
+ },
259
+ async get(key) {
260
+ return new Promise((resolve, reject) => {
261
+ Taro__namespace.getStorage({
262
+ key,
263
+ success: (res) => resolve(res.data),
264
+ fail: reject
265
+ });
266
+ });
267
+ },
268
+ async remove(key) {
269
+ return new Promise((resolve, reject) => {
270
+ Taro__namespace.removeStorage({
271
+ key,
272
+ success: () => resolve(),
273
+ fail: reject
274
+ });
275
+ });
276
+ },
277
+ async clear() {
278
+ return new Promise((resolve, reject) => {
279
+ Taro__namespace.clearStorage({
280
+ success: () => resolve(),
281
+ fail: reject
282
+ });
283
+ });
284
+ },
285
+ async getInfo() {
286
+ return new Promise((resolve, reject) => {
287
+ Taro__namespace.getStorageInfo({
288
+ success: (res) => resolve({
289
+ currentSize: res.currentSize,
290
+ limitSize: res.limitSize
291
+ }),
292
+ fail: reject
293
+ });
294
+ });
295
+ }
296
+ });
297
+ __publicField(this, "location", {
298
+ async getCurrentPosition() {
299
+ return new Promise((resolve, reject) => {
300
+ Taro__namespace.getLocation({
301
+ success: resolve,
302
+ fail: reject
303
+ });
304
+ });
305
+ },
306
+ async openLocation(options) {
307
+ return new Promise((resolve, reject) => {
308
+ Taro__namespace.openLocation({
309
+ ...options,
310
+ success: () => resolve(),
311
+ fail: reject
312
+ });
313
+ });
314
+ },
315
+ async chooseLocation() {
316
+ return new Promise((resolve, reject) => {
317
+ Taro__namespace.chooseLocation({
318
+ success: resolve,
319
+ fail: reject
320
+ });
321
+ });
322
+ }
323
+ });
324
+ __publicField(this, "camera", {
325
+ async takePhoto(options) {
326
+ return new Promise((resolve, reject) => {
327
+ Taro__namespace.cameraTakePhoto({
328
+ ...options,
329
+ success: resolve,
330
+ fail: reject
331
+ });
332
+ });
333
+ },
334
+ async chooseImage(options) {
335
+ return new Promise((resolve, reject) => {
336
+ Taro__namespace.chooseImage({
337
+ ...options,
338
+ success: resolve,
339
+ fail: reject
340
+ });
341
+ });
342
+ },
343
+ async chooseVideo(options) {
344
+ return new Promise((resolve, reject) => {
345
+ Taro__namespace.chooseVideo({
346
+ ...options,
347
+ success: resolve,
348
+ fail: reject
349
+ });
350
+ });
351
+ }
352
+ });
353
+ __publicField(this, "payment", {
354
+ async requestPayment(options) {
355
+ return new Promise((resolve, reject) => {
356
+ Taro__namespace.requestPayment({
357
+ ...options,
358
+ success: () => resolve(),
359
+ fail: reject
360
+ });
361
+ });
362
+ }
363
+ });
364
+ __publicField(this, "share", {
365
+ async shareAppMessage(options) {
366
+ return new Promise((resolve, reject) => {
367
+ Taro__namespace.shareAppMessage({
368
+ ...options,
369
+ success: () => resolve(),
370
+ fail: reject
371
+ });
372
+ });
373
+ },
374
+ async shareToTimeline(options) {
375
+ return new Promise((resolve, reject) => {
376
+ Taro__namespace.shareToTimeline({
377
+ ...options,
378
+ success: () => resolve(),
379
+ fail: reject
380
+ });
381
+ });
382
+ }
383
+ });
384
+ __publicField(this, "biometrics", {
385
+ async checkIsAvailable() {
386
+ return new Promise((resolve) => {
387
+ Taro__namespace.checkIsSoterEnrolledInDevice({
388
+ checkAuthMode: "fingerPrint",
389
+ success: (res) => resolve(res.isEnrolled),
390
+ fail: () => resolve(false)
391
+ });
392
+ });
393
+ },
394
+ async startVerify(options) {
395
+ return new Promise((resolve, reject) => {
396
+ Taro__namespace.startSoterAuthentication({
397
+ ...options,
398
+ success: resolve,
399
+ fail: reject
400
+ });
401
+ });
402
+ }
403
+ });
404
+ __publicField(this, "system", {
405
+ async getSystemInfo() {
406
+ return Promise.resolve(Taro__namespace.getSystemInfoSync());
407
+ },
408
+ async getNetworkType() {
409
+ return new Promise((resolve, reject) => {
410
+ Taro__namespace.getNetworkType({
411
+ success: resolve,
412
+ fail: reject
413
+ });
414
+ });
415
+ },
416
+ async getBatteryInfo() {
417
+ return new Promise((resolve, reject) => {
418
+ Taro__namespace.getBatteryInfo({
419
+ success: resolve,
420
+ fail: reject
421
+ });
422
+ });
423
+ },
424
+ async getScreenBrightness() {
425
+ return new Promise((resolve, reject) => {
426
+ Taro__namespace.getScreenBrightness({
427
+ success: (res) => resolve(res.value),
428
+ fail: reject
429
+ });
430
+ });
431
+ },
432
+ async setScreenBrightness(value) {
433
+ return new Promise((resolve, reject) => {
434
+ Taro__namespace.setScreenBrightness({
435
+ value,
436
+ success: () => resolve(),
437
+ fail: reject
438
+ });
439
+ });
440
+ },
441
+ async keepScreenOn(keepScreenOn) {
442
+ return new Promise((resolve, reject) => {
443
+ Taro__namespace.setKeepScreenOn({
444
+ keepScreenOn,
445
+ success: () => resolve(),
446
+ fail: reject
447
+ });
448
+ });
449
+ },
450
+ async vibrate() {
451
+ return new Promise((resolve, reject) => {
452
+ Taro__namespace.vibrate({
453
+ success: () => resolve(),
454
+ fail: reject
455
+ });
456
+ });
457
+ }
458
+ });
459
+ __publicField(this, "clipboard", {
460
+ async set(text) {
461
+ return new Promise((resolve, reject) => {
462
+ Taro__namespace.setClipboardData({
463
+ data: text,
464
+ success: () => resolve(),
465
+ fail: reject
466
+ });
467
+ });
468
+ },
469
+ async get() {
470
+ return new Promise((resolve, reject) => {
471
+ Taro__namespace.getClipboardData({
472
+ success: (res) => resolve(res.data),
473
+ fail: reject
474
+ });
475
+ });
476
+ }
477
+ });
478
+ __publicField(this, "scan", {
479
+ async scanCode(options) {
480
+ return new Promise((resolve, reject) => {
481
+ Taro__namespace.scanCode({
482
+ ...options,
483
+ success: resolve,
484
+ fail: reject
485
+ });
486
+ });
487
+ }
488
+ });
489
+ __publicField(this, "file", {
490
+ async saveFile(options) {
491
+ return new Promise((resolve, reject) => {
492
+ Taro__namespace.saveFile({
493
+ ...options,
494
+ success: resolve,
495
+ fail: reject
496
+ });
497
+ });
498
+ },
499
+ async getFileInfo(options) {
500
+ return new Promise((resolve, reject) => {
501
+ Taro__namespace.getFileInfo({
502
+ ...options,
503
+ success: resolve,
504
+ fail: reject
505
+ });
506
+ });
507
+ },
508
+ async getSavedFileList() {
509
+ return new Promise((resolve, reject) => {
510
+ Taro__namespace.getSavedFileList({
511
+ success: resolve,
512
+ fail: reject
513
+ });
514
+ });
515
+ },
516
+ async removeSavedFile(options) {
517
+ return new Promise((resolve, reject) => {
518
+ Taro__namespace.removeSavedFile({
519
+ ...options,
520
+ success: () => resolve(),
521
+ fail: reject
522
+ });
523
+ });
524
+ }
525
+ });
526
+ }
527
+ getPlatformInfo() {
528
+ const system = Taro__namespace.getSystemInfoSync();
529
+ const accountInfo = Taro__namespace.getAccountInfoSync();
530
+ return {
531
+ platform: "weapp",
532
+ isMiniProgram: true,
533
+ isH5: false,
534
+ isRN: false,
535
+ system,
536
+ SDKVersion: accountInfo.miniProgram.sdkVersion || accountInfo.miniProgram.version,
537
+ version: accountInfo.miniProgram.version
538
+ };
539
+ }
540
+ async request(config) {
541
+ return new Promise((resolve, reject) => {
542
+ Taro__namespace.request({
543
+ url: config.url,
544
+ method: config.method || "GET",
545
+ header: config.header,
546
+ data: config.data,
547
+ timeout: config.timeout,
548
+ success: (res) => {
549
+ resolve({
550
+ data: res.data,
551
+ statusCode: res.statusCode,
552
+ statusMessage: res.errMsg,
553
+ header: res.header
554
+ });
555
+ },
556
+ fail: (err) => {
557
+ const error = {
558
+ message: err.errMsg || "Request failed",
559
+ code: err.errCode,
560
+ detail: err
561
+ };
562
+ reject(error);
563
+ }
564
+ });
565
+ });
566
+ }
567
+ }
568
+ class H5Adapter {
569
+ constructor() {
570
+ __publicField(this, "storage", {
571
+ async set(key, value) {
572
+ localStorage.setItem(key, JSON.stringify(value));
573
+ },
574
+ async get(key) {
575
+ const value = localStorage.getItem(key);
576
+ return value ? JSON.parse(value) : null;
577
+ },
578
+ async remove(key) {
579
+ localStorage.removeItem(key);
580
+ },
581
+ async clear() {
582
+ localStorage.clear();
583
+ },
584
+ async getInfo() {
585
+ let size = 0;
586
+ for (let i = 0; i < localStorage.length; i++) {
587
+ const key = localStorage.key(i);
588
+ if (key) {
589
+ size += (key + localStorage.getItem(key)).length;
590
+ }
591
+ }
592
+ return {
593
+ currentSize: size,
594
+ limitSize: 5 * 1024 * 1024
595
+ // 5MB 估算
596
+ };
597
+ }
598
+ });
599
+ __publicField(this, "location", {
600
+ async getCurrentPosition() {
601
+ return new Promise((resolve, reject) => {
602
+ if (!navigator.geolocation) {
603
+ reject(new Error("Geolocation is not supported"));
604
+ return;
605
+ }
606
+ navigator.geolocation.getCurrentPosition(
607
+ (position) => {
608
+ resolve({
609
+ latitude: position.coords.latitude || 0,
610
+ longitude: position.coords.longitude || 0,
611
+ accuracy: position.coords.accuracy || 0,
612
+ altitude: position.coords.altitude || 0,
613
+ verticalAccuracy: position.coords.altitudeAccuracy || 0,
614
+ horizontalAccuracy: position.coords.accuracy || 0,
615
+ speed: position.coords.speed || 0,
616
+ errMsg: "getLocation:ok"
617
+ });
618
+ },
619
+ (error) => {
620
+ reject(error);
621
+ }
622
+ );
623
+ });
624
+ },
625
+ async openLocation(options) {
626
+ const url = `https://maps.google.com/maps?q=${options.latitude},${options.longitude}`;
627
+ window.open(url, "_blank");
628
+ },
629
+ async chooseLocation() {
630
+ throw new Error("chooseLocation is not supported in H5 environment");
631
+ }
632
+ });
633
+ __publicField(this, "camera", {
634
+ async takePhoto() {
635
+ throw new Error("takePhoto is not supported in H5 environment");
636
+ },
637
+ async chooseImage(options) {
638
+ return new Promise((resolve, reject) => {
639
+ const input = document.createElement("input");
640
+ input.type = "file";
641
+ input.accept = "image/*";
642
+ if ((options == null ? void 0 : options.count) && options.count > 1) {
643
+ input.multiple = true;
644
+ }
645
+ input.onchange = (event) => {
646
+ const files = Array.from(event.target.files || []);
647
+ const tempFilePaths = files.map((file) => URL.createObjectURL(file));
648
+ resolve({
649
+ tempFilePaths,
650
+ tempFiles: files.map((file) => ({
651
+ path: URL.createObjectURL(file),
652
+ size: file.size,
653
+ type: file.type,
654
+ originalFileObj: file
655
+ })),
656
+ errMsg: "chooseImage:ok"
657
+ });
658
+ };
659
+ input.onerror = () => {
660
+ reject(new Error("Failed to choose image"));
661
+ };
662
+ input.click();
663
+ });
664
+ },
665
+ async chooseVideo() {
666
+ return new Promise((resolve, reject) => {
667
+ const input = document.createElement("input");
668
+ input.type = "file";
669
+ input.accept = "video/*";
670
+ input.onchange = (event) => {
671
+ var _a;
672
+ const file = (_a = event.target.files) == null ? void 0 : _a[0];
673
+ if (!file) {
674
+ reject(new Error("No file selected"));
675
+ return;
676
+ }
677
+ resolve({
678
+ tempFilePath: URL.createObjectURL(file),
679
+ duration: 0,
680
+ // 需要额外的逻辑获取视频时长
681
+ size: file.size,
682
+ height: 0,
683
+ // 需要额外的逻辑获取视频尺寸
684
+ width: 0,
685
+ errMsg: "chooseVideo:ok"
686
+ });
687
+ };
688
+ input.onerror = () => {
689
+ reject(new Error("Failed to choose video"));
690
+ };
691
+ input.click();
692
+ });
693
+ }
694
+ });
695
+ __publicField(this, "payment", {
696
+ async requestPayment() {
697
+ throw new Error("Payment is not supported in H5 environment");
698
+ }
699
+ });
700
+ __publicField(this, "share", {
701
+ async shareAppMessage() {
702
+ if (navigator.share) {
703
+ await navigator.share({
704
+ title: document.title,
705
+ url: window.location.href
706
+ });
707
+ } else {
708
+ throw new Error("Web Share API is not supported");
709
+ }
710
+ },
711
+ async shareToTimeline() {
712
+ throw new Error("shareToTimeline is not supported in H5 environment");
713
+ }
714
+ });
715
+ __publicField(this, "biometrics", {
716
+ async checkIsAvailable() {
717
+ return false;
718
+ },
719
+ async startVerify() {
720
+ throw new Error("Biometric authentication is not supported in H5 environment");
721
+ }
722
+ });
723
+ __publicField(this, "system", {
724
+ async getSystemInfo() {
725
+ return Promise.resolve(Taro__namespace.getSystemInfoSync());
726
+ },
727
+ async getNetworkType() {
728
+ const connection = navigator.connection;
729
+ let networkType = "unknown";
730
+ if (connection) {
731
+ if (connection.effectiveType) {
732
+ networkType = connection.effectiveType;
733
+ }
734
+ }
735
+ return {
736
+ networkType,
737
+ errMsg: "getNetworkType:ok"
738
+ };
739
+ },
740
+ async getBatteryInfo() {
741
+ throw new Error("Battery API is not supported");
742
+ },
743
+ async getScreenBrightness() {
744
+ return 1;
745
+ },
746
+ async setScreenBrightness() {
747
+ },
748
+ async keepScreenOn() {
749
+ },
750
+ async vibrate() {
751
+ if (navigator.vibrate) {
752
+ navigator.vibrate(200);
753
+ }
754
+ }
755
+ });
756
+ __publicField(this, "clipboard", {
757
+ async set(text) {
758
+ if (navigator.clipboard) {
759
+ await navigator.clipboard.writeText(text);
760
+ } else {
761
+ const textArea = document.createElement("textarea");
762
+ textArea.value = text;
763
+ document.body.appendChild(textArea);
764
+ textArea.select();
765
+ document.execCommand("copy");
766
+ document.body.removeChild(textArea);
767
+ }
768
+ },
769
+ async get() {
770
+ if (navigator.clipboard) {
771
+ return await navigator.clipboard.readText();
772
+ } else {
773
+ return "";
774
+ }
775
+ }
776
+ });
777
+ __publicField(this, "scan", {
778
+ async scanCode() {
779
+ throw new Error("scanCode is not supported in H5 environment");
780
+ }
781
+ });
782
+ __publicField(this, "file", {
783
+ async saveFile() {
784
+ throw new Error("saveFile is not supported in H5 environment");
785
+ },
786
+ async getFileInfo() {
787
+ throw new Error("getFileInfo is not supported in H5 environment");
788
+ },
789
+ async getSavedFileList() {
790
+ throw new Error("getSavedFileList is not supported in H5 environment");
791
+ },
792
+ async removeSavedFile() {
793
+ throw new Error("removeSavedFile is not supported in H5 environment");
794
+ }
795
+ });
796
+ }
797
+ getPlatformInfo() {
798
+ const system = Taro__namespace.getSystemInfoSync();
799
+ return {
800
+ platform: "h5",
801
+ isMiniProgram: false,
802
+ isH5: true,
803
+ isRN: false,
804
+ system
805
+ };
806
+ }
807
+ /** Headers对象转普通对象 */
808
+ headersToObject(headers) {
809
+ const result = {};
810
+ headers.forEach((value, key) => {
811
+ result[key] = value;
812
+ });
813
+ return result;
814
+ }
815
+ async request(config) {
816
+ const url = new URL(config.url, window.location.origin);
817
+ if (config.params) {
818
+ Object.entries(config.params).forEach(([key, value]) => {
819
+ url.searchParams.append(key, String(value));
820
+ });
821
+ }
822
+ const options = {
823
+ method: config.method || "GET",
824
+ headers: {
825
+ "Content-Type": "application/json",
826
+ ...config.header
827
+ }
828
+ };
829
+ if (config.data && ["POST", "PUT", "PATCH"].includes(config.method || "GET")) {
830
+ options.body = JSON.stringify(config.data);
831
+ }
832
+ try {
833
+ const response = await fetch(url.toString(), options);
834
+ const data = await response.json();
835
+ return {
836
+ data,
837
+ statusCode: response.status,
838
+ statusMessage: response.statusText,
839
+ header: this.headersToObject(response.headers)
840
+ };
841
+ } catch (error) {
842
+ const requestError = {
843
+ message: error instanceof Error ? error.message : "Network error",
844
+ detail: error
845
+ };
846
+ throw requestError;
847
+ }
848
+ }
849
+ }
850
+ class RNAdapter {
851
+ constructor() {
852
+ // React Native的存储实现需要使用AsyncStorage
853
+ __publicField(this, "storage", {
854
+ async set(_key, _value) {
855
+ throw new Error("AsyncStorage not implemented");
856
+ },
857
+ async get(_key) {
858
+ throw new Error("AsyncStorage not implemented");
859
+ },
860
+ async remove(_key) {
861
+ throw new Error("AsyncStorage not implemented");
862
+ },
863
+ async clear() {
864
+ throw new Error("AsyncStorage not implemented");
865
+ },
866
+ async getInfo() {
867
+ throw new Error("Storage info not available in React Native");
868
+ }
869
+ });
870
+ // 其他React Native平台的实现...
871
+ // 由于React Native的API实现较为复杂,这里只提供基础框架
872
+ __publicField(this, "location", {
873
+ async getCurrentPosition() {
874
+ throw new Error("Location service not implemented");
875
+ },
876
+ async openLocation() {
877
+ throw new Error("openLocation not implemented");
878
+ },
879
+ async chooseLocation() {
880
+ throw new Error("chooseLocation not implemented");
881
+ }
882
+ });
883
+ __publicField(this, "camera", {
884
+ async takePhoto() {
885
+ throw new Error("Camera service not implemented");
886
+ },
887
+ async chooseImage() {
888
+ throw new Error("chooseImage not implemented");
889
+ },
890
+ async chooseVideo() {
891
+ throw new Error("chooseVideo not implemented");
892
+ }
893
+ });
894
+ __publicField(this, "payment", {
895
+ async requestPayment() {
896
+ throw new Error("Payment service not implemented");
897
+ }
898
+ });
899
+ __publicField(this, "share", {
900
+ async shareAppMessage() {
901
+ throw new Error("Share service not implemented");
902
+ },
903
+ async shareToTimeline() {
904
+ throw new Error("Share service not implemented");
905
+ }
906
+ });
907
+ __publicField(this, "biometrics", {
908
+ async checkIsAvailable() {
909
+ throw new Error("Biometric service not implemented");
910
+ },
911
+ async startVerify() {
912
+ throw new Error("Biometric service not implemented");
913
+ }
914
+ });
915
+ __publicField(this, "system", {
916
+ async getSystemInfo() {
917
+ return Promise.resolve(Taro__namespace.getSystemInfoSync());
918
+ },
919
+ async getNetworkType() {
920
+ throw new Error("Network type service not implemented");
921
+ },
922
+ async getBatteryInfo() {
923
+ throw new Error("Battery service not implemented");
924
+ },
925
+ async getScreenBrightness() {
926
+ throw new Error("Screen brightness service not implemented");
927
+ },
928
+ async setScreenBrightness() {
929
+ throw new Error("Screen brightness service not implemented");
930
+ },
931
+ async keepScreenOn() {
932
+ throw new Error("Keep screen on service not implemented");
933
+ },
934
+ async vibrate() {
935
+ throw new Error("Vibrate service not implemented");
936
+ }
937
+ });
938
+ __publicField(this, "clipboard", {
939
+ async set(_text) {
940
+ throw new Error("Clipboard service not implemented");
941
+ },
942
+ async get() {
943
+ throw new Error("Clipboard service not implemented");
944
+ }
945
+ });
946
+ __publicField(this, "scan", {
947
+ async scanCode() {
948
+ throw new Error("Scan service not implemented");
949
+ }
950
+ });
951
+ __publicField(this, "file", {
952
+ async saveFile() {
953
+ throw new Error("File service not implemented");
954
+ },
955
+ async getFileInfo() {
956
+ throw new Error("File service not implemented");
957
+ },
958
+ async getSavedFileList() {
959
+ throw new Error("File service not implemented");
960
+ },
961
+ async removeSavedFile() {
962
+ throw new Error("File service not implemented");
963
+ }
964
+ });
965
+ }
966
+ getPlatformInfo() {
967
+ const system = Taro__namespace.getSystemInfoSync();
968
+ return {
969
+ platform: "rn",
970
+ isMiniProgram: false,
971
+ isH5: false,
972
+ isRN: true,
973
+ system
974
+ };
975
+ }
976
+ /** Headers对象转普通对象 */
977
+ headersToObject(headers) {
978
+ const result = {};
979
+ headers.forEach((value, key) => {
980
+ result[key] = value;
981
+ });
982
+ return result;
983
+ }
984
+ async request(config) {
985
+ const url = new URL(config.url);
986
+ if (config.params) {
987
+ Object.entries(config.params).forEach(([key, value]) => {
988
+ url.searchParams.append(key, String(value));
989
+ });
990
+ }
991
+ const options = {
992
+ method: config.method || "GET",
993
+ headers: {
994
+ "Content-Type": "application/json",
995
+ ...config.header
996
+ }
997
+ };
998
+ if (config.data && ["POST", "PUT", "PATCH"].includes(config.method || "GET")) {
999
+ options.body = JSON.stringify(config.data);
1000
+ }
1001
+ try {
1002
+ const response = await fetch(url.toString(), options);
1003
+ const data = await response.json();
1004
+ return {
1005
+ data,
1006
+ statusCode: response.status,
1007
+ statusMessage: response.statusText,
1008
+ header: this.headersToObject(response.headers)
1009
+ };
1010
+ } catch (error) {
1011
+ const requestError = {
1012
+ message: error instanceof Error ? error.message : "Network error",
1013
+ detail: error
1014
+ };
1015
+ throw requestError;
1016
+ }
1017
+ }
1018
+ }
1019
+ const _PlatformManager = class _PlatformManager {
1020
+ constructor() {
1021
+ __publicField(this, "adapter");
1022
+ __publicField(this, "platformInfo");
1023
+ const platform = this.detectPlatform();
1024
+ this.adapter = this.createAdapter(platform);
1025
+ this.platformInfo = this.adapter.getPlatformInfo();
1026
+ }
1027
+ /** 获取单例实例 */
1028
+ static getInstance() {
1029
+ if (!_PlatformManager.instance) {
1030
+ _PlatformManager.instance = new _PlatformManager();
1031
+ }
1032
+ return _PlatformManager.instance;
1033
+ }
1034
+ /** 检测当前平台 */
1035
+ detectPlatform() {
1036
+ if (typeof window !== "undefined" && window.wx && window.wx.getSystemInfo) {
1037
+ return "weapp";
1038
+ } else if (typeof window !== "undefined" && window.my && window.my.getSystemInfo) {
1039
+ return "alipay";
1040
+ } else if (typeof window !== "undefined" && window.swan && window.swan.getSystemInfo) {
1041
+ return "swan";
1042
+ } else if (typeof window !== "undefined" && window.tt && window.tt.getSystemInfo) {
1043
+ return "tt";
1044
+ } else if (typeof window !== "undefined" && window.qq && window.qq.getSystemInfo) {
1045
+ return "qq";
1046
+ } else if (typeof window !== "undefined" && window.jd && window.jd.getSystemInfo) {
1047
+ return "jd";
1048
+ } else if (typeof navigator !== "undefined" && navigator.product === "ReactNative") {
1049
+ return "rn";
1050
+ } else {
1051
+ return "h5";
1052
+ }
1053
+ }
1054
+ /** 创建平台适配器 */
1055
+ createAdapter(platform) {
1056
+ switch (platform) {
1057
+ case "weapp":
1058
+ return new WeappAdapter();
1059
+ case "alipay":
1060
+ return new WeappAdapter();
1061
+ case "swan":
1062
+ return new WeappAdapter();
1063
+ case "tt":
1064
+ return new WeappAdapter();
1065
+ case "qq":
1066
+ return new WeappAdapter();
1067
+ case "jd":
1068
+ return new WeappAdapter();
1069
+ case "h5":
1070
+ return new H5Adapter();
1071
+ case "rn":
1072
+ return new RNAdapter();
1073
+ default:
1074
+ return new H5Adapter();
1075
+ }
1076
+ }
1077
+ /** 获取平台适配器 */
1078
+ getAdapter() {
1079
+ return this.adapter;
1080
+ }
1081
+ /** 获取平台信息 */
1082
+ getPlatformInfo() {
1083
+ return this.platformInfo;
1084
+ }
1085
+ /** 获取当前平台 */
1086
+ getPlatform() {
1087
+ return this.platformInfo.platform;
1088
+ }
1089
+ /** 判断是否为指定平台 */
1090
+ isPlatform(targetPlatform) {
1091
+ return this.platformInfo.platform === targetPlatform;
1092
+ }
1093
+ /** 判断是否为小程序环境 */
1094
+ isMiniProgram() {
1095
+ return this.platformInfo.isMiniProgram;
1096
+ }
1097
+ /** 判断是否为H5环境 */
1098
+ isH5() {
1099
+ return this.platformInfo.isH5;
1100
+ }
1101
+ /** 判断是否为React Native环境 */
1102
+ isRN() {
1103
+ return this.platformInfo.isRN;
1104
+ }
1105
+ /** 检查功能支持 */
1106
+ isFeatureSupported(feature) {
1107
+ var _a;
1108
+ const platform = this.platformInfo.platform;
1109
+ return ((_a = PLATFORM_FEATURES[platform]) == null ? void 0 : _a[feature]) || false;
1110
+ }
1111
+ /** 获取平台API映射 */
1112
+ getPlatformAPIs() {
1113
+ const platform = this.platformInfo.platform;
1114
+ return PLATFORM_APIS[platform] || PLATFORM_APIS.h5;
1115
+ }
1116
+ /** 获取平台名称 */
1117
+ getPlatformName() {
1118
+ const platform = this.platformInfo.platform;
1119
+ return PLATFORM_NAMES[platform] || "Unknown";
1120
+ }
1121
+ /** 重置平台管理器(主要用于测试) */
1122
+ reset() {
1123
+ _PlatformManager.instance = new _PlatformManager();
1124
+ }
1125
+ };
1126
+ __publicField(_PlatformManager, "instance");
1127
+ let PlatformManager = _PlatformManager;
1128
+ const platformManager = PlatformManager.getInstance();
1129
+ const platformAdapter = platformManager.getAdapter();
1130
+ const platformUtils = {
1131
+ getPlatform: () => platformManager.getPlatform(),
1132
+ getPlatformInfo: () => platformManager.getPlatformInfo(),
1133
+ isPlatform: (platform) => platformManager.isPlatform(platform),
1134
+ isMiniProgram: () => platformManager.isMiniProgram(),
1135
+ isH5: () => platformManager.isH5(),
1136
+ isRN: () => platformManager.isRN(),
1137
+ isFeatureSupported: (feature) => platformManager.isFeatureSupported(feature),
1138
+ getPlatformAPIs: () => platformManager.getPlatformAPIs(),
1139
+ getPlatformName: () => platformManager.getPlatformName()
1140
+ };
1141
+ const {
1142
+ getPlatform,
1143
+ getPlatformInfo,
1144
+ isPlatform,
1145
+ isMiniProgram,
1146
+ isH5,
1147
+ isRN,
1148
+ isFeatureSupported,
1149
+ getPlatformAPIs,
1150
+ getPlatformName
1151
+ } = platformUtils;
1152
+ exports.PlatformManager = PlatformManager;
1153
+ exports.getPlatform = getPlatform;
1154
+ exports.getPlatformAPIs = getPlatformAPIs;
1155
+ exports.getPlatformInfo = getPlatformInfo;
1156
+ exports.getPlatformName = getPlatformName;
1157
+ exports.isFeatureSupported = isFeatureSupported;
1158
+ exports.isH5 = isH5;
1159
+ exports.isMiniProgram = isMiniProgram;
1160
+ exports.isPlatform = isPlatform;
1161
+ exports.isRN = isRN;
1162
+ exports.platformAdapter = platformAdapter;
1163
+ exports.platformManager = platformManager;
1164
+ exports.platformUtils = platformUtils;
1165
+ //# sourceMappingURL=index-DFdcksbe.js.map