sard 1.0.0-canary.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (488) hide show
  1. package/dist/accordion/Item.d.ts +17 -0
  2. package/dist/accordion/Item.js +25 -0
  3. package/dist/accordion/index.d.ts +26 -0
  4. package/dist/accordion/index.js +27 -0
  5. package/dist/accordion/index.scss +49 -0
  6. package/dist/action-sheet/ActionSheet.d.ts +24 -0
  7. package/dist/action-sheet/ActionSheet.js +79 -0
  8. package/dist/action-sheet/Agent.d.ts +6 -0
  9. package/dist/action-sheet/Agent.js +7 -0
  10. package/dist/action-sheet/Item.d.ts +16 -0
  11. package/dist/action-sheet/Item.js +22 -0
  12. package/dist/action-sheet/imperative.d.ts +10 -0
  13. package/dist/action-sheet/imperative.js +22 -0
  14. package/dist/action-sheet/index.d.ts +12 -0
  15. package/dist/action-sheet/index.js +10 -0
  16. package/dist/action-sheet/index.scss +148 -0
  17. package/dist/animated/index.d.ts +62 -0
  18. package/dist/animated/index.js +101 -0
  19. package/dist/animated/index.rn.d.ts +4 -0
  20. package/dist/animated/index.rn.js +35 -0
  21. package/dist/avatar/Group.d.ts +9 -0
  22. package/dist/avatar/Group.js +27 -0
  23. package/dist/avatar/index.d.ts +17 -0
  24. package/dist/avatar/index.js +22 -0
  25. package/dist/avatar/index.scss +82 -0
  26. package/dist/badge/index.d.ts +13 -0
  27. package/dist/badge/index.js +16 -0
  28. package/dist/badge/index.scss +81 -0
  29. package/dist/base.d.ts +11 -0
  30. package/dist/base.js +1 -0
  31. package/dist/button/CustomButton.d.ts +9 -0
  32. package/dist/button/CustomButton.js +23 -0
  33. package/dist/button/index.d.ts +21 -0
  34. package/dist/button/index.js +34 -0
  35. package/dist/button/index.scss +346 -0
  36. package/dist/calendar/Day.d.ts +23 -0
  37. package/dist/calendar/Day.js +70 -0
  38. package/dist/calendar/MonthPicker.d.ts +13 -0
  39. package/dist/calendar/MonthPicker.js +22 -0
  40. package/dist/calendar/Toolbar.d.ts +11 -0
  41. package/dist/calendar/Toolbar.js +18 -0
  42. package/dist/calendar/Weeks.d.ts +6 -0
  43. package/dist/calendar/Weeks.js +18 -0
  44. package/dist/calendar/index.d.ts +48 -0
  45. package/dist/calendar/index.js +193 -0
  46. package/dist/calendar/index.scss +210 -0
  47. package/dist/card/index.d.ts +15 -0
  48. package/dist/card/index.js +14 -0
  49. package/dist/card/index.scss +64 -0
  50. package/dist/cascader/index.d.ts +43 -0
  51. package/dist/cascader/index.js +216 -0
  52. package/dist/cascader/index.scss +130 -0
  53. package/dist/checkbox/Group.d.ts +5 -0
  54. package/dist/checkbox/Group.js +5 -0
  55. package/dist/checkbox/index.d.ts +10 -0
  56. package/dist/checkbox/index.js +8 -0
  57. package/dist/checkbox/index.scss +78 -0
  58. package/dist/collapse/index.d.ts +14 -0
  59. package/dist/collapse/index.js +61 -0
  60. package/dist/collapse/index.rn.d.ts +14 -0
  61. package/dist/collapse/index.rn.js +76 -0
  62. package/dist/collapse/index.scss +31 -0
  63. package/dist/components.d.ts +66 -0
  64. package/dist/components.js +66 -0
  65. package/dist/components.scss +65 -0
  66. package/dist/config-provider/index.d.ts +21 -0
  67. package/dist/config-provider/index.js +20 -0
  68. package/dist/count-down/index.d.ts +26 -0
  69. package/dist/count-down/index.js +95 -0
  70. package/dist/datetime-picker/index.d.ts +36 -0
  71. package/dist/datetime-picker/index.js +230 -0
  72. package/dist/dialog/Agent.d.ts +6 -0
  73. package/dist/dialog/Agent.js +7 -0
  74. package/dist/dialog/Dialog.d.ts +31 -0
  75. package/dist/dialog/Dialog.js +103 -0
  76. package/dist/dialog/imperative.d.ts +17 -0
  77. package/dist/dialog/imperative.js +35 -0
  78. package/dist/dialog/index.d.ts +14 -0
  79. package/dist/dialog/index.js +12 -0
  80. package/dist/dialog/index.scss +156 -0
  81. package/dist/dropdown/Item.d.ts +33 -0
  82. package/dist/dropdown/Item.js +164 -0
  83. package/dist/dropdown/Option.d.ts +10 -0
  84. package/dist/dropdown/Option.js +12 -0
  85. package/dist/dropdown/index.d.ts +20 -0
  86. package/dist/dropdown/index.js +59 -0
  87. package/dist/dropdown/index.scss +236 -0
  88. package/dist/ellipsis/index.d.ts +8 -0
  89. package/dist/ellipsis/index.js +18 -0
  90. package/dist/ellipsis/index.scss +23 -0
  91. package/dist/empty/index.d.ts +10 -0
  92. package/dist/empty/index.js +14 -0
  93. package/dist/empty/index.scss +59 -0
  94. package/dist/footer-bar/index.d.ts +8 -0
  95. package/dist/footer-bar/index.js +15 -0
  96. package/dist/footer-bar/index.scss +29 -0
  97. package/dist/form/CustomForm.d.ts +13 -0
  98. package/dist/form/CustomForm.js +26 -0
  99. package/dist/form/ErrorList.d.ts +6 -0
  100. package/dist/form/ErrorList.js +15 -0
  101. package/dist/form/Field.d.ts +41 -0
  102. package/dist/form/Field.js +124 -0
  103. package/dist/form/FieldContext.d.ts +18 -0
  104. package/dist/form/FieldContext.js +8 -0
  105. package/dist/form/List.d.ts +31 -0
  106. package/dist/form/List.js +87 -0
  107. package/dist/form/Map.d.ts +17 -0
  108. package/dist/form/Map.js +24 -0
  109. package/dist/form/NodeContext.d.ts +12 -0
  110. package/dist/form/NodeContext.js +14 -0
  111. package/dist/form/Validator.d.ts +88 -0
  112. package/dist/form/Validator.js +268 -0
  113. package/dist/form/createFormStore.d.ts +36 -0
  114. package/dist/form/createFormStore.js +249 -0
  115. package/dist/form/index.d.ts +43 -0
  116. package/dist/form/index.js +109 -0
  117. package/dist/form/index.scss +200 -0
  118. package/dist/form/store/Context.d.ts +4 -0
  119. package/dist/form/store/Context.js +3 -0
  120. package/dist/form/store/createStore.d.ts +6 -0
  121. package/dist/form/store/createStore.js +28 -0
  122. package/dist/form/store/useDispatch.d.ts +2 -0
  123. package/dist/form/store/useDispatch.js +10 -0
  124. package/dist/form/store/useSelector.d.ts +7 -0
  125. package/dist/form/store/useSelector.js +35 -0
  126. package/dist/form/type.d.ts +20 -0
  127. package/dist/form/type.js +1 -0
  128. package/dist/form/useForm.d.ts +27 -0
  129. package/dist/form/useForm.js +14 -0
  130. package/dist/form/useInternalWatch.d.ts +3 -0
  131. package/dist/form/useInternalWatch.js +27 -0
  132. package/dist/form/useNode.d.ts +49 -0
  133. package/dist/form/useNode.js +284 -0
  134. package/dist/form/useValidator.d.ts +23 -0
  135. package/dist/form/useValidator.js +74 -0
  136. package/dist/form/useWatch.d.ts +4 -0
  137. package/dist/form/useWatch.js +24 -0
  138. package/dist/grid/Col.d.ts +9 -0
  139. package/dist/grid/Col.js +20 -0
  140. package/dist/grid/Row.d.ts +11 -0
  141. package/dist/grid/Row.js +34 -0
  142. package/dist/grid/index.d.ts +2 -0
  143. package/dist/grid/index.js +2 -0
  144. package/dist/grid/index.scss +56 -0
  145. package/dist/halfline/index.d.ts +10 -0
  146. package/dist/halfline/index.js +27 -0
  147. package/dist/halfline/index.scss +80 -0
  148. package/dist/icon/common.d.ts +15 -0
  149. package/dist/icon/common.js +1 -0
  150. package/dist/icon/font/iconfont.json +275 -0
  151. package/dist/icon/font/iconfont.rn.scss +0 -0
  152. package/dist/icon/font/iconfont.scss +164 -0
  153. package/dist/icon/font/iconfont.ttf +0 -0
  154. package/dist/icon/fontLoader.d.ts +7 -0
  155. package/dist/icon/fontLoader.js +14 -0
  156. package/dist/icon/fontLoader.rn.d.ts +6 -0
  157. package/dist/icon/fontLoader.rn.js +52 -0
  158. package/dist/icon/index.d.ts +21 -0
  159. package/dist/icon/index.js +41 -0
  160. package/dist/icon/index.scss +23 -0
  161. package/dist/index-bar/Item.d.ts +9 -0
  162. package/dist/index-bar/Item.js +11 -0
  163. package/dist/index-bar/Nav.d.ts +13 -0
  164. package/dist/index-bar/Nav.js +75 -0
  165. package/dist/index-bar/index.d.ts +19 -0
  166. package/dist/index-bar/index.js +142 -0
  167. package/dist/index-bar/index.scss +153 -0
  168. package/dist/index.d.ts +3 -0
  169. package/dist/index.js +3 -0
  170. package/dist/index.scss +1 -0
  171. package/dist/input/index.d.ts +37 -0
  172. package/dist/input/index.js +116 -0
  173. package/dist/input/index.scss +249 -0
  174. package/dist/linear-gradient/index.d.ts +14 -0
  175. package/dist/linear-gradient/index.js +30 -0
  176. package/dist/linear-gradient/index.rn.d.ts +3 -0
  177. package/dist/linear-gradient/index.rn.js +3 -0
  178. package/dist/list/Item.d.ts +22 -0
  179. package/dist/list/Item.js +26 -0
  180. package/dist/list/ListContext.d.ts +9 -0
  181. package/dist/list/ListContext.js +2 -0
  182. package/dist/list/OrderContext.d.ts +8 -0
  183. package/dist/list/OrderContext.js +6 -0
  184. package/dist/list/index.d.ts +19 -0
  185. package/dist/list/index.js +29 -0
  186. package/dist/list/index.scss +257 -0
  187. package/dist/loading/index.d.ts +10 -0
  188. package/dist/loading/index.js +47 -0
  189. package/dist/loading/index.scss +25 -0
  190. package/dist/locale/index.d.ts +199 -0
  191. package/dist/locale/index.js +36 -0
  192. package/dist/locale/lang/en-US.d.ts +92 -0
  193. package/dist/locale/lang/en-US.js +92 -0
  194. package/dist/locale/lang/zh-CN.d.ts +92 -0
  195. package/dist/locale/lang/zh-CN.js +92 -0
  196. package/dist/locale/useTranslate.d.ts +7 -0
  197. package/dist/locale/useTranslate.js +41 -0
  198. package/dist/mask/index.d.ts +13 -0
  199. package/dist/mask/index.js +26 -0
  200. package/dist/mask/index.scss +24 -0
  201. package/dist/menu/Item.d.ts +15 -0
  202. package/dist/menu/Item.js +17 -0
  203. package/dist/menu/index.d.ts +17 -0
  204. package/dist/menu/index.js +15 -0
  205. package/dist/menu/index.scss +128 -0
  206. package/dist/mesh/Item.d.ts +16 -0
  207. package/dist/mesh/Item.js +16 -0
  208. package/dist/mesh/index.d.ts +14 -0
  209. package/dist/mesh/index.js +69 -0
  210. package/dist/mesh/index.scss +131 -0
  211. package/dist/mesh/type.d.ts +9 -0
  212. package/dist/mesh/type.js +1 -0
  213. package/dist/modal/index.d.ts +8 -0
  214. package/dist/modal/index.js +9 -0
  215. package/dist/modal/index.rn.d.ts +8 -0
  216. package/dist/modal/index.rn.js +8 -0
  217. package/dist/navbar/Item.d.ts +8 -0
  218. package/dist/navbar/Item.js +11 -0
  219. package/dist/navbar/index.d.ts +15 -0
  220. package/dist/navbar/index.js +16 -0
  221. package/dist/navbar/index.scss +128 -0
  222. package/dist/notice-bar/index.d.ts +28 -0
  223. package/dist/notice-bar/index.js +135 -0
  224. package/dist/notice-bar/index.scss +109 -0
  225. package/dist/notify/Agent.d.ts +6 -0
  226. package/dist/notify/Agent.js +7 -0
  227. package/dist/notify/Notify.d.ts +22 -0
  228. package/dist/notify/Notify.js +48 -0
  229. package/dist/notify/imperative.d.ts +18 -0
  230. package/dist/notify/imperative.js +35 -0
  231. package/dist/notify/index.d.ts +15 -0
  232. package/dist/notify/index.js +13 -0
  233. package/dist/notify/index.scss +65 -0
  234. package/dist/number-keyboard/index.d.ts +10 -0
  235. package/dist/number-keyboard/index.js +51 -0
  236. package/dist/number-keyboard/index.scss +93 -0
  237. package/dist/pagination/index.d.ts +20 -0
  238. package/dist/pagination/index.js +65 -0
  239. package/dist/pagination/index.scss +131 -0
  240. package/dist/pan-gesture-detector/index.d.ts +8 -0
  241. package/dist/pan-gesture-detector/index.js +11 -0
  242. package/dist/pan-gesture-detector/index.rn.d.ts +8 -0
  243. package/dist/pan-gesture-detector/index.rn.js +23 -0
  244. package/dist/pan-gesture-detector/usePan.d.ts +47 -0
  245. package/dist/pan-gesture-detector/usePan.js +146 -0
  246. package/dist/password-input/index.d.ts +22 -0
  247. package/dist/password-input/index.js +91 -0
  248. package/dist/password-input/index.scss +189 -0
  249. package/dist/picker/InertialMotion.d.ts +20 -0
  250. package/dist/picker/InertialMotion.js +141 -0
  251. package/dist/picker/PickerView.d.ts +1 -0
  252. package/dist/picker/PickerView.h5.d.ts +17 -0
  253. package/dist/picker/PickerView.h5.js +36 -0
  254. package/dist/picker/PickerView.js +1 -0
  255. package/dist/picker/PickerViewColumn copy.d.ts +9 -0
  256. package/dist/picker/PickerViewColumn copy.js +143 -0
  257. package/dist/picker/PickerViewColumn.d.ts +12 -0
  258. package/dist/picker/PickerViewColumn.js +238 -0
  259. package/dist/picker/index.d.ts +38 -0
  260. package/dist/picker/index.js +224 -0
  261. package/dist/picker/index.rn.scss +0 -0
  262. package/dist/picker/index.scss +138 -0
  263. package/dist/popout/index.d.ts +25 -0
  264. package/dist/popout/index.js +87 -0
  265. package/dist/popout/index.scss +136 -0
  266. package/dist/popout-input/index.d.ts +29 -0
  267. package/dist/popout-input/index.js +91 -0
  268. package/dist/popout-input/index.scss +53 -0
  269. package/dist/popover/index.d.ts +35 -0
  270. package/dist/popover/index.js +193 -0
  271. package/dist/popover/index.scss +94 -0
  272. package/dist/popover/utils.d.ts +23 -0
  273. package/dist/popover/utils.js +124 -0
  274. package/dist/popup/index.d.ts +29 -0
  275. package/dist/popup/index.js +60 -0
  276. package/dist/popup/index.scss +60 -0
  277. package/dist/pressable/index.d.ts +13 -0
  278. package/dist/pressable/index.js +58 -0
  279. package/dist/pressable/index.rn.d.ts +13 -0
  280. package/dist/pressable/index.rn.js +50 -0
  281. package/dist/progress-bar/index.d.ts +10 -0
  282. package/dist/progress-bar/index.js +22 -0
  283. package/dist/progress-bar/index.scss +45 -0
  284. package/dist/progress-circle/index.d.ts +11 -0
  285. package/dist/progress-circle/index.js +54 -0
  286. package/dist/progress-circle/index.scss +141 -0
  287. package/dist/radio/Group.d.ts +5 -0
  288. package/dist/radio/Group.js +5 -0
  289. package/dist/radio/index.d.ts +10 -0
  290. package/dist/radio/index.js +8 -0
  291. package/dist/radio/index.scss +77 -0
  292. package/dist/rate/index.d.ts +23 -0
  293. package/dist/rate/index.js +116 -0
  294. package/dist/rate/index.scss +99 -0
  295. package/dist/result/index.d.ts +12 -0
  296. package/dist/result/index.js +19 -0
  297. package/dist/result/index.scss +88 -0
  298. package/dist/safe-area/index.d.ts +7 -0
  299. package/dist/safe-area/index.js +35 -0
  300. package/dist/safe-area/index.scss +24 -0
  301. package/dist/scroll-view/index.d.ts +24 -0
  302. package/dist/scroll-view/index.js +72 -0
  303. package/dist/scroll-view/index.rn.d.ts +21 -0
  304. package/dist/scroll-view/index.rn.js +51 -0
  305. package/dist/search/index.d.ts +26 -0
  306. package/dist/search/index.js +35 -0
  307. package/dist/search/index.scss +75 -0
  308. package/dist/share-sheet/Item.d.ts +15 -0
  309. package/dist/share-sheet/Item.js +26 -0
  310. package/dist/share-sheet/Row.d.ts +10 -0
  311. package/dist/share-sheet/Row.js +26 -0
  312. package/dist/share-sheet/index.d.ts +26 -0
  313. package/dist/share-sheet/index.js +76 -0
  314. package/dist/share-sheet/index.scss +230 -0
  315. package/dist/skeleton/Avatar.d.ts +7 -0
  316. package/dist/skeleton/Avatar.js +17 -0
  317. package/dist/skeleton/Block.d.ts +8 -0
  318. package/dist/skeleton/Block.js +44 -0
  319. package/dist/skeleton/Paragraph.d.ts +7 -0
  320. package/dist/skeleton/Paragraph.js +13 -0
  321. package/dist/skeleton/Title.d.ts +7 -0
  322. package/dist/skeleton/Title.js +16 -0
  323. package/dist/skeleton/index.d.ts +28 -0
  324. package/dist/skeleton/index.js +22 -0
  325. package/dist/skeleton/index.scss +108 -0
  326. package/dist/slider/index.d.ts +36 -0
  327. package/dist/slider/index.js +187 -0
  328. package/dist/slider/index.scss +138 -0
  329. package/dist/space/index.d.ts +13 -0
  330. package/dist/space/index.js +33 -0
  331. package/dist/space/index.scss +36 -0
  332. package/dist/stepper/index.d.ts +26 -0
  333. package/dist/stepper/index.js +138 -0
  334. package/dist/stepper/index.scss +106 -0
  335. package/dist/steps/Step.d.ts +23 -0
  336. package/dist/steps/Step.js +41 -0
  337. package/dist/steps/index.d.ts +23 -0
  338. package/dist/steps/index.js +38 -0
  339. package/dist/steps/index.scss +300 -0
  340. package/dist/style/base.scss +3 -0
  341. package/dist/style/functions.scss +54 -0
  342. package/dist/style/index.d.ts +2 -0
  343. package/dist/style/index.js +2 -0
  344. package/dist/style/index.scss +0 -0
  345. package/dist/style/mixins/bem.scss +63 -0
  346. package/dist/style/mixins/border.scss +80 -0
  347. package/dist/style/mixins/disabled.scss +9 -0
  348. package/dist/style/mixins/env.rn.scss +11 -0
  349. package/dist/style/mixins/env.scss +11 -0
  350. package/dist/style/mixins/fixed.rn.scss +3 -0
  351. package/dist/style/mixins/fixed.scss +3 -0
  352. package/dist/style/mixins/sticky.rn.scss +3 -0
  353. package/dist/style/mixins/sticky.scss +3 -0
  354. package/dist/style/mixins/theme.scss +11 -0
  355. package/dist/style/mixins/universal.rn.scss +2 -0
  356. package/dist/style/mixins/universal.scss +6 -0
  357. package/dist/style/mixins.scss +8 -0
  358. package/dist/style/utils.scss +130 -0
  359. package/dist/style/variables.scss +422 -0
  360. package/dist/swiper/Item.d.ts +8 -0
  361. package/dist/swiper/Item.js +10 -0
  362. package/dist/swiper/index.d.ts +12 -0
  363. package/dist/swiper/index.js +13 -0
  364. package/dist/swiper/index.scss +10 -0
  365. package/dist/switch/index.d.ts +19 -0
  366. package/dist/switch/index.js +78 -0
  367. package/dist/switch/index.scss +106 -0
  368. package/dist/tabbar/Item.d.ts +17 -0
  369. package/dist/tabbar/Item.js +24 -0
  370. package/dist/tabbar/index.d.ts +17 -0
  371. package/dist/tabbar/index.js +33 -0
  372. package/dist/tabbar/index.scss +89 -0
  373. package/dist/tabs/Tab.d.ts +12 -0
  374. package/dist/tabs/Tab.js +17 -0
  375. package/dist/tabs/index.d.ts +23 -0
  376. package/dist/tabs/index.js +258 -0
  377. package/dist/tabs/index.scss +113 -0
  378. package/dist/tag/index.d.ts +17 -0
  379. package/dist/tag/index.js +21 -0
  380. package/dist/tag/index.scss +93 -0
  381. package/dist/template/index.d.ts +6 -0
  382. package/dist/template/index.js +10 -0
  383. package/dist/template/index.scss +16 -0
  384. package/dist/toast/Agent.d.ts +6 -0
  385. package/dist/toast/Agent.js +7 -0
  386. package/dist/toast/Toast.d.ts +24 -0
  387. package/dist/toast/Toast.js +43 -0
  388. package/dist/toast/imperative.d.ts +18 -0
  389. package/dist/toast/imperative.js +35 -0
  390. package/dist/toast/index.d.ts +15 -0
  391. package/dist/toast/index.js +13 -0
  392. package/dist/toast/index.scss +96 -0
  393. package/dist/transition/CSSTransition.d.ts +7 -0
  394. package/dist/transition/CSSTransition.js +49 -0
  395. package/dist/transition/CSSTransition.rn.d.ts +7 -0
  396. package/dist/transition/CSSTransition.rn.js +312 -0
  397. package/dist/transition/index.d.ts +43 -0
  398. package/dist/transition/index.js +156 -0
  399. package/dist/transition/index.rn.scss +0 -0
  400. package/dist/transition/index.scss +158 -0
  401. package/dist/upload/Preview.d.ts +35 -0
  402. package/dist/upload/Preview.js +41 -0
  403. package/dist/upload/PreviewVideo.d.ts +7 -0
  404. package/dist/upload/PreviewVideo.js +38 -0
  405. package/dist/upload/PreviewVideo.rn.d.ts +6 -0
  406. package/dist/upload/PreviewVideo.rn.js +24 -0
  407. package/dist/upload/chooseMedia.d.ts +26 -0
  408. package/dist/upload/chooseMedia.h5.d.ts +25 -0
  409. package/dist/upload/chooseMedia.h5.js +117 -0
  410. package/dist/upload/chooseMedia.js +55 -0
  411. package/dist/upload/index.d.ts +37 -0
  412. package/dist/upload/index.js +167 -0
  413. package/dist/upload/index.scss +247 -0
  414. package/dist/use/index.d.ts +20 -0
  415. package/dist/use/index.js +20 -0
  416. package/dist/use/useAutoplay.d.ts +1 -0
  417. package/dist/use/useAutoplay.js +34 -0
  418. package/dist/use/useBem.d.ts +9 -0
  419. package/dist/use/useBem.js +52 -0
  420. package/dist/use/useBrush.d.ts +23 -0
  421. package/dist/use/useBrush.js +61 -0
  422. package/dist/use/useControllableValue.d.ts +12 -0
  423. package/dist/use/useControllableValue.js +59 -0
  424. package/dist/use/useEvent.d.ts +4 -0
  425. package/dist/use/useEvent.js +12 -0
  426. package/dist/use/useForceRender.d.ts +5 -0
  427. package/dist/use/useForceRender.js +8 -0
  428. package/dist/use/useIndexableMap.d.ts +21 -0
  429. package/dist/use/useIndexableMap.js +65 -0
  430. package/dist/use/useInertRef.d.ts +7 -0
  431. package/dist/use/useInertRef.js +15 -0
  432. package/dist/use/useInternalSelect.d.ts +42 -0
  433. package/dist/use/useInternalSelect.js +64 -0
  434. package/dist/use/useLayoutUpdateEffect.d.ts +5 -0
  435. package/dist/use/useLayoutUpdateEffect.js +18 -0
  436. package/dist/use/usePropRef.d.ts +5 -0
  437. package/dist/use/usePropRef.js +9 -0
  438. package/dist/use/useResize.d.ts +2 -0
  439. package/dist/use/useResize.js +14 -0
  440. package/dist/use/useResizeObserver.d.ts +5 -0
  441. package/dist/use/useResizeObserver.js +38 -0
  442. package/dist/use/useSelect.d.ts +15 -0
  443. package/dist/use/useSelect.js +56 -0
  444. package/dist/use/useSelectorId.d.ts +1 -0
  445. package/dist/use/useSelectorId.js +5 -0
  446. package/dist/use/useSetTimeout.d.ts +10 -0
  447. package/dist/use/useSetTimeout.js +34 -0
  448. package/dist/use/useStopMovePropagate.d.ts +5 -0
  449. package/dist/use/useStopMovePropagate.js +28 -0
  450. package/dist/use/useThrottle.d.ts +8 -0
  451. package/dist/use/useThrottle.js +11 -0
  452. package/dist/use/useUpdateEffect.d.ts +5 -0
  453. package/dist/use/useUpdateEffect.js +18 -0
  454. package/dist/use/useUpdateWatchSync.d.ts +5 -0
  455. package/dist/use/useUpdateWatchSync.js +18 -0
  456. package/dist/use/useWatchStateSync.d.ts +4 -0
  457. package/dist/use/useWatchStateSync.js +18 -0
  458. package/dist/utils/animate.d.ts +28 -0
  459. package/dist/utils/animate.js +81 -0
  460. package/dist/utils/createPubSub.d.ts +8 -0
  461. package/dist/utils/createPubSub.js +53 -0
  462. package/dist/utils/date.d.ts +13 -0
  463. package/dist/utils/date.js +87 -0
  464. package/dist/utils/dom.d.ts +149 -0
  465. package/dist/utils/dom.js +297 -0
  466. package/dist/utils/file.d.ts +18 -0
  467. package/dist/utils/file.js +57 -0
  468. package/dist/utils/imperative.d.ts +20 -0
  469. package/dist/utils/imperative.js +37 -0
  470. package/dist/utils/index.d.ts +7 -0
  471. package/dist/utils/index.js +7 -0
  472. package/dist/utils/is.d.ts +16 -0
  473. package/dist/utils/is.js +57 -0
  474. package/dist/utils/measure.d.ts +8 -0
  475. package/dist/utils/measure.js +13 -0
  476. package/dist/utils/measure.rn.d.ts +8 -0
  477. package/dist/utils/measure.rn.js +15 -0
  478. package/dist/utils/platform.android.d.ts +2 -0
  479. package/dist/utils/platform.android.js +2 -0
  480. package/dist/utils/platform.d.ts +2 -0
  481. package/dist/utils/platform.ios.d.ts +2 -0
  482. package/dist/utils/platform.ios.js +2 -0
  483. package/dist/utils/platform.js +2 -0
  484. package/dist/utils/style.d.ts +10 -0
  485. package/dist/utils/style.js +34 -0
  486. package/dist/utils/utils.d.ts +199 -0
  487. package/dist/utils/utils.js +639 -0
  488. package/package.json +30 -0
@@ -0,0 +1,639 @@
1
+ import classNames from 'classnames';
2
+ import { isPlainObject, isFunction, isNullish, isRN } from './is';
3
+ // eslint-disable-next-line @typescript-eslint/no-empty-function
4
+ export function noop() { }
5
+ /**
6
+ * @description: 确保目标是一个数组
7
+ * @param target 目标对象
8
+ * @return 原数组或新的数组
9
+ */
10
+ export function toArray(target) {
11
+ return Array.isArray(target) ? target : [target];
12
+ }
13
+ /**
14
+ * @description: 限定数值范围
15
+ * @param {number} n 被限定的值
16
+ * @param {number} min 最小值
17
+ * @param {number} max 最大值
18
+ * @return {number} 限定后的值
19
+ */
20
+ export function minmax(n, min, max) {
21
+ return n < min ? min : n > max ? max : n;
22
+ }
23
+ /**
24
+ * @description: 获取小数位数
25
+ * @param {number | string} n 要操作的数值
26
+ * @return {number}
27
+ */
28
+ export function getDecimalsLength(n) {
29
+ n = n.toString().split('.')[1];
30
+ return n ? n.length : 0;
31
+ }
32
+ /**
33
+ * @description: 把一个数四舍五入到指定位数小数
34
+ * @param {number} n 要操作的数值
35
+ * @param {number} precision 精准度,即小数个数
36
+ * @return {number}
37
+ */
38
+ export function round(n, precision = 0) {
39
+ return Math.round(+(n + 'e' + precision)) / 10 ** precision;
40
+ }
41
+ /**
42
+ * @description: 把一个数舍入到指定数的倍数
43
+ * @param {number} n 要舍入的数值
44
+ * @param {number} m 结果值的因数
45
+ * @return {number}
46
+ */
47
+ export function mround(n, m) {
48
+ return round(n - (n % m) + Math.round((n % m) / m) * m, getDecimalsLength(m));
49
+ }
50
+ /**
51
+ * @description: 生成唯一ID,用于设置元素的ID,以便获取
52
+ * @param {string} prefix
53
+ * @return {string}
54
+ */
55
+ export function uniqid(prefix = '__sar_') {
56
+ return prefix + (~~(Math.random() * 10e8)).toString(36);
57
+ }
58
+ /**
59
+ * @description: 回流
60
+ * @param {HTMLElement} el
61
+ * @return {void}
62
+ */
63
+ export function reflow(el) {
64
+ el.offsetHeight;
65
+ }
66
+ /**
67
+ * @description: 获取阻尼值
68
+ * @param {number} value
69
+ * @param {number} min
70
+ * @param {number} max
71
+ * @param {number} damping
72
+ * @return {number}
73
+ */
74
+ export function getDampingValue(value, min, max, damping) {
75
+ if (value < min) {
76
+ return min + (value - min) * damping;
77
+ }
78
+ if (value > max) {
79
+ return max + (value - max) * damping;
80
+ }
81
+ return value;
82
+ }
83
+ /**
84
+ * @description: 获取矩形阻尼值
85
+ * @param {number} offset 当前的偏移量
86
+ * @param {number} areaSize 范围值
87
+ * @param {number} viewSize 范围内某个视图尺寸值
88
+ * @param {number} damping 阻尼系数
89
+ * @return {number}
90
+ */
91
+ export function getRectDampingValue(offset, areaSize, viewSize, damping) {
92
+ const diff = areaSize - viewSize;
93
+ let min, max;
94
+ if (diff < 0) {
95
+ min = diff;
96
+ max = 0;
97
+ }
98
+ else {
99
+ min = 0;
100
+ max = diff;
101
+ }
102
+ return getDampingValue(offset, min, max, damping);
103
+ }
104
+ /**
105
+ * @description: 获取范围值
106
+ * @param {number} offset 当前的偏移量
107
+ * @param {number} areaSize 范围值
108
+ * @param {number} viewSize 范围内某个视图尺寸值
109
+ * @return {number}
110
+ */
111
+ export function getInBoundValue(offset, areaSize, viewSize) {
112
+ const diff = areaSize - viewSize;
113
+ const [min, max] = [0, diff].sort((a, b) => a - b);
114
+ return minmax(offset, min, max);
115
+ }
116
+ /**
117
+ * @description: 获取溢出值范围
118
+ * @param {number} overflow 最大溢出值
119
+ * @param {number} areaSize 范围值
120
+ * @param {number} viewSize 范围内某个视图尺寸值
121
+ * @return {*}
122
+ */
123
+ export function getOverflowRangeInArea(overflow, areaSize, viewSize) {
124
+ if (areaSize > viewSize) {
125
+ return [-overflow, areaSize + overflow];
126
+ }
127
+ else {
128
+ return [areaSize - viewSize - overflow, overflow];
129
+ }
130
+ }
131
+ /**
132
+ * @description: 扩散性遍历
133
+ * @param array 要遍历的数组
134
+ * @param callback 回调函数,接收当前元素、扩散性下标、迭代下标作为参数,
135
+ * 如果返回true,则中止遍历
136
+ * @param currIndex 遍历开始的下标
137
+ * @param direction 开始遍历的方向
138
+ * @return 扩散性下标、或开始下标
139
+ */
140
+ export function spreadEach(array, callback, startIndex = 0, direction = -1) {
141
+ const len = array.length;
142
+ let spreadIndex = startIndex;
143
+ let edge = 0;
144
+ direction = -direction;
145
+ for (let i = 0; i < len; i++) {
146
+ if (edge < 0) {
147
+ spreadIndex = len - 1 - i;
148
+ }
149
+ else if (edge > 0) {
150
+ spreadIndex = i;
151
+ }
152
+ else {
153
+ spreadIndex = spreadIndex + direction * i;
154
+ edge = spreadIndex === 0 ? 1 : spreadIndex === len - 1 ? -1 : 0;
155
+ direction = -direction;
156
+ }
157
+ if (isFunction(callback)) {
158
+ if (callback(array[spreadIndex], spreadIndex, i)) {
159
+ return spreadIndex;
160
+ }
161
+ }
162
+ }
163
+ return startIndex;
164
+ }
165
+ /**
166
+ * @description: 克隆对象
167
+ * @param {any} target
168
+ * @return {any}
169
+ */
170
+ export function deepClone(target) {
171
+ if (Array.isArray(target)) {
172
+ return target.map((item) => {
173
+ return deepClone(item);
174
+ });
175
+ }
176
+ if (isPlainObject(target)) {
177
+ const obj = {};
178
+ Object.keys(target).forEach((k) => {
179
+ obj[k] = deepClone(target[k]);
180
+ });
181
+ return obj;
182
+ }
183
+ return target;
184
+ }
185
+ /**
186
+ * @description: 深度合并其他对象到第一个对象
187
+ * @param {any[]} args
188
+ * @return {any} 第一个对象
189
+ */
190
+ export function deepMerge(...args) {
191
+ const target = args[0], l = args.length;
192
+ let i = 1, options, name, src, copy, copyIsArray, clone;
193
+ for (; i < l; i++) {
194
+ options = args[i];
195
+ if (!isNullish(options)) {
196
+ for (name in options) {
197
+ src = target[name];
198
+ copy = options[name];
199
+ // 防止有环
200
+ if (target === copy) {
201
+ continue;
202
+ }
203
+ // 深复制
204
+ if (isPlainObject(copy) || (copyIsArray = Array.isArray(copy))) {
205
+ if (copyIsArray) {
206
+ copyIsArray = false;
207
+ clone = Array.isArray(src) ? src : [];
208
+ }
209
+ else {
210
+ clone = isPlainObject(src) ? src : {};
211
+ }
212
+ target[name] = deepMerge(clone, copy);
213
+ // 不添加未定义的值
214
+ }
215
+ else if (copy !== undefined) {
216
+ target[name] = copy;
217
+ }
218
+ }
219
+ }
220
+ }
221
+ return target;
222
+ }
223
+ export function debounce(func, wait, options = {}) {
224
+ let lastArgs, lastThis, maxWait, result, timerId, lastCallTime;
225
+ let lastInvokeTime = 0;
226
+ let leading = false;
227
+ let maxing = false;
228
+ let trailing = true;
229
+ // Bypass `requestAnimationFrame` by explicitly setting `wait=0`.
230
+ const useRAF = !wait && wait !== 0 && isFunction(requestAnimationFrame);
231
+ if (typeof func !== 'function') {
232
+ throw new TypeError('Expected a function');
233
+ }
234
+ wait = +wait || 0;
235
+ if (isPlainObject(options)) {
236
+ leading = !!options.leading;
237
+ maxing = 'maxWait' in options;
238
+ maxWait = maxing
239
+ ? Math.max(+options.maxWait || 0, wait)
240
+ : maxWait;
241
+ trailing = 'trailing' in options ? !!options.trailing : trailing;
242
+ }
243
+ function invokeFunc(time) {
244
+ const args = lastArgs;
245
+ const thisArg = lastThis;
246
+ lastArgs = lastThis = undefined;
247
+ lastInvokeTime = time;
248
+ result = func.apply(thisArg, args);
249
+ return result;
250
+ }
251
+ function startTimer(pendingFunc, wait) {
252
+ if (useRAF) {
253
+ cancelAnimationFrame(timerId);
254
+ return requestAnimationFrame(pendingFunc);
255
+ }
256
+ return setTimeout(pendingFunc, wait);
257
+ }
258
+ function cancelTimer(id) {
259
+ if (useRAF) {
260
+ return cancelAnimationFrame(id);
261
+ }
262
+ clearTimeout(id);
263
+ }
264
+ function leadingEdge(time) {
265
+ // Reset unknown `maxWait` timer.
266
+ lastInvokeTime = time;
267
+ // Start the timer for the trailing edge.
268
+ timerId = startTimer(timerExpired, wait);
269
+ // Invoke the leading edge.
270
+ return leading ? invokeFunc(time) : result;
271
+ }
272
+ function remainingWait(time) {
273
+ const timeSinceLastCall = time - lastCallTime;
274
+ const timeSinceLastInvoke = time - lastInvokeTime;
275
+ const timeWaiting = wait - timeSinceLastCall;
276
+ return maxing
277
+ ? Math.min(timeWaiting, maxWait - timeSinceLastInvoke)
278
+ : timeWaiting;
279
+ }
280
+ function shouldInvoke(time) {
281
+ const timeSinceLastCall = time - lastCallTime;
282
+ const timeSinceLastInvoke = time - lastInvokeTime;
283
+ // Either this is the first call, activity has stopped and we're at the
284
+ // trailing edge, the system time has gone backwards and we're treating
285
+ // it as the trailing edge, or we've hit the `maxWait` limit.
286
+ return (lastCallTime === undefined ||
287
+ timeSinceLastCall >= wait ||
288
+ timeSinceLastCall < 0 ||
289
+ (maxing && timeSinceLastInvoke >= maxWait));
290
+ }
291
+ function timerExpired() {
292
+ const time = Date.now();
293
+ if (shouldInvoke(time)) {
294
+ return trailingEdge(time);
295
+ }
296
+ // Restart the timer.
297
+ timerId = startTimer(timerExpired, remainingWait(time));
298
+ }
299
+ function trailingEdge(time) {
300
+ timerId = undefined;
301
+ // Only invoke if we have `lastArgs` which means `func` has been
302
+ // debounced at least once.
303
+ if (trailing && lastArgs) {
304
+ return invokeFunc(time);
305
+ }
306
+ lastArgs = lastThis = undefined;
307
+ return result;
308
+ }
309
+ function cancel() {
310
+ if (timerId !== undefined) {
311
+ cancelTimer(timerId);
312
+ }
313
+ lastInvokeTime = 0;
314
+ lastArgs = lastCallTime = lastThis = timerId = undefined;
315
+ }
316
+ function flush() {
317
+ return timerId === undefined ? result : trailingEdge(Date.now());
318
+ }
319
+ function pending() {
320
+ return timerId !== undefined;
321
+ }
322
+ function debounced(...args) {
323
+ const time = Date.now();
324
+ const isInvoking = shouldInvoke(time);
325
+ lastArgs = args;
326
+ lastThis = this;
327
+ lastCallTime = time;
328
+ if (isInvoking) {
329
+ if (timerId === undefined) {
330
+ return leadingEdge(lastCallTime);
331
+ }
332
+ if (maxing) {
333
+ // Handle invocations in a tight loop.
334
+ timerId = startTimer(timerExpired, wait);
335
+ return invokeFunc(lastCallTime);
336
+ }
337
+ }
338
+ if (timerId === undefined) {
339
+ timerId = startTimer(timerExpired, wait);
340
+ }
341
+ return result;
342
+ }
343
+ debounced.cancel = cancel;
344
+ debounced.flush = flush;
345
+ debounced.pending = pending;
346
+ return debounced;
347
+ }
348
+ export function throttle(func, wait, options = {}) {
349
+ let leading = true;
350
+ let trailing = true;
351
+ if (typeof func !== 'function') {
352
+ throw new TypeError('Expected a function');
353
+ }
354
+ if (isPlainObject(options)) {
355
+ leading = 'leading' in options ? !!options.leading : leading;
356
+ trailing = 'trailing' in options ? !!options.trailing : trailing;
357
+ }
358
+ return debounce(func, wait, {
359
+ leading,
360
+ trailing,
361
+ maxWait: wait,
362
+ });
363
+ }
364
+ /**
365
+ * @description: 获取页面范围
366
+ * @param {number} current 当前页码
367
+ * @param {number} pageCount 总页数
368
+ * @param {number} pageItemCount 要展示的页数
369
+ * @return {[number, number]}
370
+ */
371
+ export function getPageRange(current, pageCount, pageItemCount) {
372
+ let min = current - Math.ceil((pageItemCount - 1) / 2);
373
+ let max = current + Math.floor((pageItemCount - 1) / 2);
374
+ const minLack = 1 - min;
375
+ const maxLack = max - pageCount;
376
+ if (maxLack > 0) {
377
+ min -= maxLack;
378
+ }
379
+ if (min < 1) {
380
+ min = 1;
381
+ }
382
+ if (minLack > 0) {
383
+ max += minLack;
384
+ }
385
+ if (max > pageCount) {
386
+ max = pageCount;
387
+ }
388
+ return [min, max];
389
+ }
390
+ export function treeToMap(tree, keyName, childrenName, parentName) {
391
+ const map = {};
392
+ function recurse(children, parent) {
393
+ children.forEach((node) => {
394
+ map[node[keyName]] = node;
395
+ node[parentName] = parent;
396
+ if (Array.isArray(node[childrenName])) {
397
+ recurse(node[childrenName], node);
398
+ }
399
+ });
400
+ }
401
+ recurse(tree, null);
402
+ return map;
403
+ }
404
+ /**
405
+ * 如果 subProps 指定属性为 null 或 undefined, 则从 parentProps 中提取
406
+ */
407
+ export function pickNonNullish(parentProps, subProps) {
408
+ return Object.keys(parentProps).reduce((result, prop) => {
409
+ result[prop] = subProps[prop] ?? parentProps[prop];
410
+ return result;
411
+ }, {});
412
+ }
413
+ export function pickContextNullish(props, contextProps) {
414
+ return Object.keys(props).reduce((result, prop) => {
415
+ result[prop] = props[prop] ?? contextProps[prop];
416
+ return result;
417
+ }, {});
418
+ }
419
+ /**
420
+ * @description 打乱数组
421
+ * @param arr 要打乱的数组
422
+ * @param inPlace 是否改变原数组
423
+ */
424
+ export function shuffle(arr, inPlace = false) {
425
+ if (!inPlace) {
426
+ arr = arr.slice();
427
+ }
428
+ const len = arr.length;
429
+ for (let i = len - 1; i >= 0; i--) {
430
+ const randomIndex = ~~(Math.random() * (i + 1));
431
+ const temp = arr[randomIndex];
432
+ arr[randomIndex] = arr[i];
433
+ arr[i] = temp;
434
+ }
435
+ return arr;
436
+ }
437
+ /**
438
+ * @description: 根据原始坐标尺寸和缩放后的坐标尺寸算出转换的原点
439
+ * @param {Rect} rect
440
+ * @param {Rect} scaleRect
441
+ * @return {[number, number]}
442
+ */
443
+ export function getTransformOrigin(rect, scaleRect) {
444
+ const ratio = scaleRect.width / rect.width;
445
+ const originX = (rect.x + rect.width / 2 - scaleRect.x - scaleRect.width / 2) /
446
+ (ratio - 1) +
447
+ rect.width / 2;
448
+ const originY = (rect.y + rect.height / 2 - scaleRect.y - scaleRect.height / 2) /
449
+ (ratio - 1) +
450
+ rect.height / 2;
451
+ return [originX, originY];
452
+ }
453
+ /**
454
+ * @description: 将一个可选单位的字符串或数值拆分为数值和单位组成的数组
455
+ * @param {number | string} target
456
+ * @return {[number, string]}
457
+ */
458
+ export function splitUnit(target) {
459
+ const result = /([+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|))([a-z]+|%|)$/i.exec(String(target)) || [0, ''];
460
+ return [+result[1], result[2]];
461
+ }
462
+ /**
463
+ * @description: 确保接收 children 为 ReactElement 数组
464
+ * @param {number | string} target
465
+ * @return {[number, string]}
466
+ */
467
+ export function toElementArray(children) {
468
+ if (Array.isArray(children)) {
469
+ return children;
470
+ }
471
+ return [children];
472
+ }
473
+ /**
474
+ * @description: 自定义 transitionEnd 事件
475
+ * @param {function} callback 结束后的回调
476
+ * @param {number} duration 结束的时间
477
+ * @return {{}}
478
+ */
479
+ export function transitionEnd(callback, duration = 300) {
480
+ let timer = 0;
481
+ const clear = () => {
482
+ if (timer) {
483
+ clearTimeout(timer);
484
+ timer = 0;
485
+ }
486
+ };
487
+ const start = () => {
488
+ clear();
489
+ timer = window.setTimeout(() => {
490
+ timer = 0;
491
+ callback();
492
+ }, duration);
493
+ };
494
+ const finish = () => {
495
+ if (timer) {
496
+ clear();
497
+ callback();
498
+ }
499
+ };
500
+ start();
501
+ return {
502
+ clear,
503
+ finish,
504
+ };
505
+ }
506
+ /**
507
+ * @description: 合并多个 props,非指定(第一个数组参数)的函数属性会合并调用,
508
+ * className 和 style 也会合并,其他则直接替换
509
+ * @param {array} args
510
+ * @return {*}
511
+ */
512
+ export function mergeProps(...args) {
513
+ const l = args.length;
514
+ let target = args[0], i = 1, options, name, src, copy, ignore;
515
+ if (Array.isArray(target)) {
516
+ target = args[1];
517
+ i = 2;
518
+ ignore = target;
519
+ }
520
+ for (; i < l; i++) {
521
+ options = args[i];
522
+ if (!isNullish(options)) {
523
+ for (name in options) {
524
+ src = target[name];
525
+ copy = options[name];
526
+ // 防止有环
527
+ if (target === copy) {
528
+ continue;
529
+ }
530
+ if (ignore && ignore.includes(name)) {
531
+ target[name] = copy;
532
+ continue;
533
+ }
534
+ if (isFunction(src)) {
535
+ if (isFunction(copy)) {
536
+ const srcRef = src;
537
+ const copyRef = copy;
538
+ target[name] = (...args) => {
539
+ srcRef(...args);
540
+ copyRef(...args);
541
+ };
542
+ }
543
+ }
544
+ else if (name === 'className') {
545
+ target[name] = classNames(src, copy);
546
+ }
547
+ else if (name === 'style') {
548
+ target[name] = Object.assign({}, src, copy);
549
+ }
550
+ else {
551
+ target[name] = copy;
552
+ }
553
+ }
554
+ }
555
+ }
556
+ return target;
557
+ }
558
+ // 链式获取对象值(字符串方式)
559
+ export function chainSelect(object, chain) {
560
+ let target = object;
561
+ if (chain) {
562
+ for (const link of chain.split('.')) {
563
+ if (target && typeof target === 'object') {
564
+ target = target[link];
565
+ }
566
+ else {
567
+ return target;
568
+ }
569
+ }
570
+ }
571
+ return target;
572
+ }
573
+ // 深度获取对象的值
574
+ export function getObjectValueInDepth(object, keys) {
575
+ return keys.reduce((object, key) => {
576
+ return object?.[key];
577
+ }, object);
578
+ }
579
+ // 重新排列数组元素的顺序
580
+ export function arrayMove(array, fromIndex, toIndex) {
581
+ if (fromIndex === toIndex ||
582
+ fromIndex < 0 ||
583
+ fromIndex >= array.length ||
584
+ toIndex < 0 ||
585
+ toIndex >= array.length) {
586
+ return array;
587
+ }
588
+ const element = array.splice(fromIndex, 1)[0];
589
+ array.splice(toIndex, 0, element);
590
+ return array;
591
+ }
592
+ // 删除数组中指定下标的元素,此函数会修改数组使其保存相同的引用
593
+ export function arrayRemoveAtIndexes(arr, indexes) {
594
+ indexes = indexes.sort((a, b) => b - a);
595
+ for (const index of indexes) {
596
+ if (index > -1 && index < arr.length) {
597
+ arr.splice(index, 1);
598
+ }
599
+ }
600
+ return arr;
601
+ }
602
+ // 判断两数组的每个元素是否相等
603
+ export function arrayEqual(arr1, arr2) {
604
+ return arr1.length === arr2.length && arr1.every((el, i) => el === arr2[i]);
605
+ }
606
+ // 将嵌套数据结构转换为多维数组
607
+ export function nestedToMulti(nested, values, fieldKeys) {
608
+ const columns = [];
609
+ function recurse(list, index = 0) {
610
+ columns.push(list);
611
+ const selectedValue = values[index];
612
+ let selectedOption = list.find((option) => option[fieldKeys.value] === selectedValue);
613
+ if (!selectedOption) {
614
+ selectedOption = list[0];
615
+ }
616
+ if (selectedOption) {
617
+ const nextList = selectedOption[fieldKeys.children];
618
+ if (Array.isArray(nextList)) {
619
+ recurse(nextList, ++index);
620
+ }
621
+ }
622
+ }
623
+ recurse(nested);
624
+ return columns;
625
+ }
626
+ // 过滤对象中值为非空的属性
627
+ export function filterNullish(object) {
628
+ return Object.keys(object).reduce((obj, key) => {
629
+ const value = object[key];
630
+ if (!isNullish(value)) {
631
+ obj[key] = value;
632
+ }
633
+ return obj;
634
+ }, {});
635
+ }
636
+ // 在web端(包括小程序)添加px单位
637
+ export function addPxInWeb(value) {
638
+ return isNullish(value) || isRN ? value : value + 'px';
639
+ }
package/package.json ADDED
@@ -0,0 +1,30 @@
1
+ {
2
+ "name": "sard",
3
+ "version": "1.0.0-canary.0",
4
+ "description": "Taro React 移动端 UI 组件库",
5
+ "type": "module",
6
+ "main": "dist/index.js",
7
+ "files": [
8
+ "dist/"
9
+ ],
10
+ "scripts": {
11
+ "dev": "sard dev",
12
+ "build:site": "sard build:site",
13
+ "build": "sard build",
14
+ "preview": "sard preview",
15
+ "test": "echo \"Error: no test specified\" && exit 1"
16
+ },
17
+ "author": "",
18
+ "license": "ISC",
19
+ "dependencies": {
20
+ "@tarojs/components": "^3.6.8",
21
+ "@tarojs/taro": "^3.6.8",
22
+ "classnames": "^2.3.2",
23
+ "react": "^18.2.0"
24
+ },
25
+ "types": "./dist/index.d.ts",
26
+ "directories": {
27
+ "doc": "docs"
28
+ },
29
+ "devDependencies": {}
30
+ }