taro-ui 3.3.0 → 3.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (415) hide show
  1. package/LICENSE +21 -0
  2. package/lib/common/component.d.ts +10 -0
  3. package/lib/common/component.js +27 -28
  4. package/lib/common/component.js.map +1 -1
  5. package/lib/common/utils.d.ts +41 -0
  6. package/lib/common/utils.js +169 -192
  7. package/lib/common/utils.js.map +1 -1
  8. package/lib/components/accordion/index.d.ts +14 -0
  9. package/lib/components/accordion/index.js +111 -106
  10. package/lib/components/accordion/index.js.map +1 -1
  11. package/lib/components/action-sheet/body/index.d.ts +5 -0
  12. package/lib/components/action-sheet/body/index.js +11 -8
  13. package/lib/components/action-sheet/body/index.js.map +1 -1
  14. package/lib/components/action-sheet/body/item/index.d.ts +9 -0
  15. package/lib/components/action-sheet/body/item/index.js +21 -18
  16. package/lib/components/action-sheet/body/item/index.js.map +1 -1
  17. package/lib/components/action-sheet/footer/index.d.ts +9 -0
  18. package/lib/components/action-sheet/footer/index.js +24 -18
  19. package/lib/components/action-sheet/footer/index.js.map +1 -1
  20. package/lib/components/action-sheet/header/index.d.ts +5 -0
  21. package/lib/components/action-sheet/header/index.js +14 -8
  22. package/lib/components/action-sheet/header/index.js.map +1 -1
  23. package/lib/components/action-sheet/index.d.ts +14 -0
  24. package/lib/components/action-sheet/index.js +69 -64
  25. package/lib/components/action-sheet/index.js.map +1 -1
  26. package/lib/components/activity-indicator/index.d.ts +8 -0
  27. package/lib/components/activity-indicator/index.js +33 -29
  28. package/lib/components/activity-indicator/index.js.map +1 -1
  29. package/lib/components/avatar/index.d.ts +9 -0
  30. package/lib/components/avatar/index.js +58 -50
  31. package/lib/components/avatar/index.js.map +1 -1
  32. package/lib/components/badge/index.d.ts +10 -0
  33. package/lib/components/badge/index.js +44 -35
  34. package/lib/components/badge/index.js.map +1 -1
  35. package/lib/components/button/index.d.ts +15 -0
  36. package/lib/components/button/index.js +165 -113
  37. package/lib/components/button/index.js.map +1 -1
  38. package/lib/components/calendar/body/index.d.ts +26 -0
  39. package/lib/components/calendar/body/index.js +279 -183
  40. package/lib/components/calendar/body/index.js.map +1 -1
  41. package/lib/components/calendar/common/constant.d.ts +3 -0
  42. package/lib/components/calendar/common/constant.js +8 -3
  43. package/lib/components/calendar/common/constant.js.map +1 -1
  44. package/lib/components/calendar/common/helper.d.ts +4 -0
  45. package/lib/components/calendar/common/helper.js +77 -76
  46. package/lib/components/calendar/common/helper.js.map +1 -1
  47. package/lib/components/calendar/common/plugins.d.ts +11 -0
  48. package/lib/components/calendar/common/plugins.js +50 -66
  49. package/lib/components/calendar/common/plugins.js.map +1 -1
  50. package/lib/components/calendar/controller/index.d.ts +5 -0
  51. package/lib/components/calendar/controller/index.js +49 -28
  52. package/lib/components/calendar/controller/index.js.map +1 -1
  53. package/lib/components/calendar/index.d.ts +20 -0
  54. package/lib/components/calendar/index.js +233 -196
  55. package/lib/components/calendar/index.js.map +1 -1
  56. package/lib/components/calendar/ui/date-list/index.d.ts +12 -0
  57. package/lib/components/calendar/ui/date-list/index.js +50 -39
  58. package/lib/components/calendar/ui/date-list/index.js.map +1 -1
  59. package/lib/components/calendar/ui/day-list/index.d.ts +4 -0
  60. package/lib/components/calendar/ui/day-list/index.js +9 -14
  61. package/lib/components/calendar/ui/day-list/index.js.map +1 -1
  62. package/lib/components/card/index.d.ts +9 -0
  63. package/lib/components/card/index.js +73 -52
  64. package/lib/components/card/index.js.map +1 -1
  65. package/lib/components/checkbox/index.d.ts +9 -0
  66. package/lib/components/checkbox/index.js +52 -48
  67. package/lib/components/checkbox/index.js.map +1 -1
  68. package/lib/components/countdown/index.d.ts +20 -0
  69. package/lib/components/countdown/index.js +140 -125
  70. package/lib/components/countdown/index.js.map +1 -1
  71. package/lib/components/countdown/item/index.d.ts +9 -0
  72. package/lib/components/countdown/item/index.js +18 -18
  73. package/lib/components/countdown/item/index.js.map +1 -1
  74. package/lib/components/curtain/index.d.ts +10 -0
  75. package/lib/components/curtain/index.js +56 -39
  76. package/lib/components/curtain/index.js.map +1 -1
  77. package/lib/components/divider/index.d.ts +8 -0
  78. package/lib/components/divider/index.js +51 -34
  79. package/lib/components/divider/index.js.map +1 -1
  80. package/lib/components/drawer/index.d.ts +16 -0
  81. package/lib/components/drawer/index.js +106 -85
  82. package/lib/components/drawer/index.js.map +1 -1
  83. package/lib/components/fab/index.d.ts +9 -0
  84. package/lib/components/fab/index.js +22 -19
  85. package/lib/components/fab/index.js.map +1 -1
  86. package/lib/components/flex/index.d.ts +7 -0
  87. package/lib/components/flex/index.js +37 -34
  88. package/lib/components/flex/index.js.map +1 -1
  89. package/lib/components/flex/item/index.d.ts +7 -0
  90. package/lib/components/flex/item/index.js +30 -27
  91. package/lib/components/flex/item/index.js.map +1 -1
  92. package/lib/components/float-layout/index.d.ts +13 -0
  93. package/lib/components/float-layout/index.js +96 -68
  94. package/lib/components/float-layout/index.js.map +1 -1
  95. package/lib/components/form/index.d.ts +10 -0
  96. package/lib/components/form/index.js +37 -24
  97. package/lib/components/form/index.js.map +1 -1
  98. package/lib/components/grid/index.d.ts +9 -0
  99. package/lib/components/grid/index.js +92 -62
  100. package/lib/components/grid/index.js.map +1 -1
  101. package/lib/components/icon/index.d.ts +9 -0
  102. package/lib/components/icon/index.js +48 -31
  103. package/lib/components/icon/index.js.map +1 -1
  104. package/lib/components/image-picker/index.d.ts +11 -0
  105. package/lib/components/image-picker/index.js +152 -126
  106. package/lib/components/image-picker/index.js.map +1 -1
  107. package/lib/components/indexes/index.d.ts +29 -0
  108. package/lib/components/indexes/index.js +255 -198
  109. package/lib/components/indexes/index.js.map +1 -1
  110. package/lib/components/input/index.d.ts +17 -0
  111. package/lib/components/input/index.js +224 -160
  112. package/lib/components/input/index.js.map +1 -1
  113. package/lib/components/input-number/index.d.ts +13 -0
  114. package/lib/components/input-number/index.js +180 -152
  115. package/lib/components/input-number/index.js.map +1 -1
  116. package/lib/components/list/index.d.ts +8 -0
  117. package/lib/components/list/index.js +20 -13
  118. package/lib/components/list/index.js.map +1 -1
  119. package/lib/components/list/item/index.d.ts +11 -0
  120. package/lib/components/list/item/index.js +146 -99
  121. package/lib/components/list/item/index.js.map +1 -1
  122. package/lib/components/load-more/index.d.ts +9 -0
  123. package/lib/components/load-more/index.js +65 -41
  124. package/lib/components/load-more/index.js.map +1 -1
  125. package/lib/components/loading/index.d.ts +12 -0
  126. package/lib/components/loading/index.js +26 -26
  127. package/lib/components/loading/index.js.map +1 -1
  128. package/lib/components/message/index.d.ts +15 -0
  129. package/lib/components/message/index.js +72 -63
  130. package/lib/components/message/index.js.map +1 -1
  131. package/lib/components/modal/action/index.d.ts +8 -0
  132. package/lib/components/modal/action/index.js +20 -14
  133. package/lib/components/modal/action/index.js.map +1 -1
  134. package/lib/components/modal/content/index.d.ts +5 -0
  135. package/lib/components/modal/content/index.js +11 -8
  136. package/lib/components/modal/content/index.js.map +1 -1
  137. package/lib/components/modal/header/index.d.ts +5 -0
  138. package/lib/components/modal/header/index.js +11 -8
  139. package/lib/components/modal/header/index.js.map +1 -1
  140. package/lib/components/modal/index.d.ts +15 -0
  141. package/lib/components/modal/index.js +96 -87
  142. package/lib/components/modal/index.js.map +1 -1
  143. package/lib/components/nav-bar/index.d.ts +12 -0
  144. package/lib/components/nav-bar/index.js +210 -98
  145. package/lib/components/nav-bar/index.js.map +1 -1
  146. package/lib/components/noticebar/index.d.ts +16 -0
  147. package/lib/components/noticebar/index.js +177 -154
  148. package/lib/components/noticebar/index.js.map +1 -1
  149. package/lib/components/pagination/index.d.ts +12 -0
  150. package/lib/components/pagination/index.js +133 -102
  151. package/lib/components/pagination/index.js.map +1 -1
  152. package/lib/components/progress/index.d.ts +7 -0
  153. package/lib/components/progress/index.js +48 -40
  154. package/lib/components/progress/index.js.map +1 -1
  155. package/lib/components/radio/index.d.ts +9 -0
  156. package/lib/components/radio/index.js +48 -37
  157. package/lib/components/radio/index.js.map +1 -1
  158. package/lib/components/range/index.d.ts +22 -0
  159. package/lib/components/range/index.js +197 -142
  160. package/lib/components/range/index.js.map +1 -1
  161. package/lib/components/rate/index.d.ts +9 -0
  162. package/lib/components/rate/index.js +74 -48
  163. package/lib/components/rate/index.js.map +1 -1
  164. package/lib/components/search-bar/index.d.ts +16 -0
  165. package/lib/components/search-bar/index.js +167 -112
  166. package/lib/components/search-bar/index.js.map +1 -1
  167. package/lib/components/segmented-control/index.d.ts +9 -0
  168. package/lib/components/segmented-control/index.js +78 -53
  169. package/lib/components/segmented-control/index.js.map +1 -1
  170. package/lib/components/slider/index.d.ts +13 -0
  171. package/lib/components/slider/index.js +107 -69
  172. package/lib/components/slider/index.js.map +1 -1
  173. package/lib/components/steps/index.d.ts +9 -0
  174. package/lib/components/steps/index.js +61 -44
  175. package/lib/components/steps/index.js.map +1 -1
  176. package/lib/components/swipe-action/index.d.ts +27 -0
  177. package/lib/components/swipe-action/index.js +206 -157
  178. package/lib/components/swipe-action/index.js.map +1 -1
  179. package/lib/components/swipe-action/options/index.d.ts +5 -0
  180. package/lib/components/swipe-action/options/index.js +22 -8
  181. package/lib/components/swipe-action/options/index.js.map +1 -1
  182. package/lib/components/switch/index.d.ts +9 -0
  183. package/lib/components/switch/index.js +53 -42
  184. package/lib/components/switch/index.js.map +1 -1
  185. package/lib/components/tab-bar/index.d.ts +9 -0
  186. package/lib/components/tab-bar/index.js +164 -90
  187. package/lib/components/tab-bar/index.js.map +1 -1
  188. package/lib/components/tabs/index.d.ts +24 -0
  189. package/lib/components/tabs/index.js +203 -174
  190. package/lib/components/tabs/index.js.map +1 -1
  191. package/lib/components/tabs-pane/index.d.ts +8 -0
  192. package/lib/components/tabs-pane/index.js +37 -24
  193. package/lib/components/tabs-pane/index.js.map +1 -1
  194. package/lib/components/tag/index.d.ts +9 -0
  195. package/lib/components/tag/index.js +64 -44
  196. package/lib/components/tag/index.js.map +1 -1
  197. package/lib/components/textarea/index.d.ts +13 -0
  198. package/lib/components/textarea/index.js +132 -86
  199. package/lib/components/textarea/index.js.map +1 -1
  200. package/lib/components/timeline/index.d.ts +8 -0
  201. package/lib/components/timeline/index.js +70 -47
  202. package/lib/components/timeline/index.js.map +1 -1
  203. package/lib/components/toast/img.json +6 -3
  204. package/lib/components/toast/index.d.ts +16 -0
  205. package/lib/components/toast/index.js +111 -104
  206. package/lib/components/toast/index.js.map +1 -1
  207. package/lib/index.d.ts +53 -0
  208. package/lib/index.js +108 -54
  209. package/lib/index.js.map +1 -1
  210. package/{dist → lib}/style/components/curtain.scss +3 -3
  211. package/{dist → lib}/style/components/grid.scss +2 -2
  212. package/lib/style/components/index.scss +52 -0
  213. package/{dist → lib}/style/components/list.scss +2 -2
  214. package/{dist → lib}/style/components/range.scss +2 -2
  215. package/{dist → lib}/style/components/toast.scss +1 -1
  216. package/lib/style/index.css +11754 -0
  217. package/lib/style/index.css.map +1 -0
  218. package/lib/style/mixins/index.scss +18 -0
  219. package/{dist → lib}/style/mixins/libs/shade.scss +4 -2
  220. package/{dist → lib}/style/mixins/libs/tint.scss +4 -2
  221. package/{dist → lib}/style/variables/default.scss +1 -1
  222. package/package.json +45 -48
  223. package/rn/components/action-sheet/index.tsx +8 -14
  224. package/rn/components/calendar/ui/date-list/index.tsx +1 -1
  225. package/rn/components/drawer/index.tsx +15 -15
  226. package/rn/components/float-layout/index.tsx +3 -2
  227. package/rn/components/input/index.tsx +14 -7
  228. package/rn/components/input-number/index.tsx +19 -19
  229. package/rn/components/message/index.tsx +1 -1
  230. package/rn/components/swipe-action/index.rn.tsx +4 -2
  231. package/rn/components/swipe-action/index.tsx +6 -5
  232. package/rn/components/tab-bar/index.tsx +1 -1
  233. package/rn/components/tabs/index.tsx +14 -14
  234. package/rn/components/textarea/index.tsx +2 -2
  235. package/README.md +0 -85
  236. package/dist/index.esm.js +0 -8407
  237. package/dist/index.esm.js.map +0 -1
  238. package/dist/index.js +0 -8468
  239. package/dist/index.js.map +0 -1
  240. package/dist/style/components/accordion.rn.scss +0 -79
  241. package/dist/style/components/action-sheet.rn.scss +0 -80
  242. package/dist/style/components/activity-indicator.rn.scss +0 -30
  243. package/dist/style/components/article.rn.scss +0 -59
  244. package/dist/style/components/avatar.rn.scss +0 -46
  245. package/dist/style/components/badge.rn.scss +0 -52
  246. package/dist/style/components/button.rn.scss +0 -80
  247. package/dist/style/components/calendar.rn.scss +0 -182
  248. package/dist/style/components/card.rn.scss +0 -88
  249. package/dist/style/components/checkbox.rn.scss +0 -108
  250. package/dist/style/components/countdown.rn.scss +0 -82
  251. package/dist/style/components/curtain.rn.scss +0 -129
  252. package/dist/style/components/divider.rn.scss +0 -33
  253. package/dist/style/components/drawer.rn.scss +0 -72
  254. package/dist/style/components/fab.rn.scss +0 -38
  255. package/dist/style/components/flex.rn.scss +0 -159
  256. package/dist/style/components/float-layout.rn.scss +0 -119
  257. package/dist/style/components/form.rn.scss +0 -12
  258. package/dist/style/components/grid.rn.scss +0 -104
  259. package/dist/style/components/icon.rn.scss +0 -221
  260. package/dist/style/components/image-picker.rn.scss +0 -108
  261. package/dist/style/components/index.rn.scss +0 -51
  262. package/dist/style/components/index.scss +0 -52
  263. package/dist/style/components/indexes.rn.scss +0 -53
  264. package/dist/style/components/input-number.rn.scss +0 -82
  265. package/dist/style/components/input.rn.scss +0 -149
  266. package/dist/style/components/list.rn.scss +0 -107
  267. package/dist/style/components/load-more.rn.scss +0 -28
  268. package/dist/style/components/loading.rn.scss +0 -45
  269. package/dist/style/components/message.rn.scss +0 -57
  270. package/dist/style/components/modal.rn.scss +0 -136
  271. package/dist/style/components/nav-bar.rn.scss +0 -123
  272. package/dist/style/components/noticebar.rn.scss +0 -111
  273. package/dist/style/components/pagination.rn.scss +0 -43
  274. package/dist/style/components/progress.rn.scss +0 -105
  275. package/dist/style/components/radio.rn.scss +0 -94
  276. package/dist/style/components/range.rn.scss +0 -52
  277. package/dist/style/components/rate.rn.scss +0 -48
  278. package/dist/style/components/search-bar.rn.scss +0 -134
  279. package/dist/style/components/segmented-control.rn.scss +0 -44
  280. package/dist/style/components/slider.rn.scss +0 -33
  281. package/dist/style/components/steps.rn.scss +0 -131
  282. package/dist/style/components/swipe-action.rn.scss +0 -53
  283. package/dist/style/components/switch.rn.scss +0 -61
  284. package/dist/style/components/tab-bar.rn.scss +0 -74
  285. package/dist/style/components/tabs.rn.scss +0 -205
  286. package/dist/style/components/tag.rn.scss +0 -74
  287. package/dist/style/components/textarea.rn.scss +0 -57
  288. package/dist/style/components/timeline.rn.scss +0 -89
  289. package/dist/style/components/toast.rn.scss +0 -112
  290. package/dist/style/index.rn.scss +0 -14
  291. package/dist/style/mixins/index.rn.scss +0 -18
  292. package/dist/style/mixins/index.scss +0 -18
  293. package/dist/style/mixins/libs/absolute-center.rn.scss +0 -9
  294. package/dist/style/mixins/libs/active.rn.scss +0 -10
  295. package/dist/style/mixins/libs/alignhack.rn.scss +0 -11
  296. package/dist/style/mixins/libs/border.rn.scss +0 -48
  297. package/dist/style/mixins/libs/clearfix.rn.scss +0 -21
  298. package/dist/style/mixins/libs/disabled.rn.scss +0 -6
  299. package/dist/style/mixins/libs/flex.rn.scss +0 -49
  300. package/dist/style/mixins/libs/hairline.rn.scss +0 -209
  301. package/dist/style/mixins/libs/line.rn.scss +0 -14
  302. package/dist/style/mixins/libs/overlay.rn.scss +0 -11
  303. package/dist/style/mixins/libs/placeholder.rn.scss +0 -12
  304. package/dist/style/mixins/libs/shade.rn.scss +0 -23
  305. package/dist/style/mixins/libs/tint.rn.scss +0 -23
  306. package/dist/style/themes/purple.rn.scss +0 -44
  307. package/dist/style/themes/red.rn.scss +0 -45
  308. package/dist/style/variables/default.rn.scss +0 -461
  309. package/types/accordion.d.ts +0 -49
  310. package/types/action-sheet.d.ts +0 -55
  311. package/types/activity-indicator.d.ts +0 -33
  312. package/types/avatar.d.ts +0 -39
  313. package/types/badge.d.ts +0 -24
  314. package/types/base.d.ts +0 -26
  315. package/types/button.d.ts +0 -70
  316. package/types/calendar.d.ts +0 -225
  317. package/types/card.d.ts +0 -48
  318. package/types/checkbox.d.ts +0 -24
  319. package/types/countdown.d.ts +0 -95
  320. package/types/curtain.d.ts +0 -26
  321. package/types/divider.d.ts +0 -33
  322. package/types/drawer.d.ts +0 -48
  323. package/types/fab.d.ts +0 -21
  324. package/types/flex.d.ts +0 -27
  325. package/types/float-button.d.ts +0 -26
  326. package/types/float-layout.d.ts +0 -73
  327. package/types/form.d.ts +0 -26
  328. package/types/grid.d.ts +0 -51
  329. package/types/icon.d.ts +0 -12
  330. package/types/image-picker.d.ts +0 -73
  331. package/types/index.d.ts +0 -55
  332. package/types/indexes.d.ts +0 -76
  333. package/types/input-number.d.ts +0 -89
  334. package/types/input.d.ts +0 -162
  335. package/types/list.d.ts +0 -84
  336. package/types/load-more.d.ts +0 -43
  337. package/types/message.d.ts +0 -43
  338. package/types/modal.d.ts +0 -62
  339. package/types/nav-bar.d.ts +0 -65
  340. package/types/noticebar.d.ts +0 -65
  341. package/types/pagination.d.ts +0 -51
  342. package/types/progress.d.ts +0 -30
  343. package/types/radio.d.ts +0 -47
  344. package/types/range.d.ts +0 -63
  345. package/types/rate.d.ts +0 -34
  346. package/types/search-bar.d.ts +0 -105
  347. package/types/segmented-control.d.ts +0 -44
  348. package/types/slider.d.ts +0 -73
  349. package/types/steps.d.ts +0 -69
  350. package/types/swipe-action.d.ts +0 -86
  351. package/types/switch.d.ts +0 -38
  352. package/types/tab-bar.d.ts +0 -98
  353. package/types/tabs-pane.d.ts +0 -25
  354. package/types/tabs.d.ts +0 -62
  355. package/types/tag.d.ts +0 -48
  356. package/types/textarea.d.ts +0 -113
  357. package/types/timeline.d.ts +0 -46
  358. package/types/toast.d.ts +0 -53
  359. /package/{dist → lib}/style/components/accordion.scss +0 -0
  360. /package/{dist → lib}/style/components/action-sheet.scss +0 -0
  361. /package/{dist → lib}/style/components/activity-indicator.scss +0 -0
  362. /package/{dist → lib}/style/components/article.scss +0 -0
  363. /package/{dist → lib}/style/components/avatar.scss +0 -0
  364. /package/{dist → lib}/style/components/badge.scss +0 -0
  365. /package/{dist → lib}/style/components/button.scss +0 -0
  366. /package/{dist → lib}/style/components/calendar.scss +0 -0
  367. /package/{dist → lib}/style/components/card.scss +0 -0
  368. /package/{dist → lib}/style/components/checkbox.scss +0 -0
  369. /package/{dist → lib}/style/components/countdown.scss +0 -0
  370. /package/{dist → lib}/style/components/divider.scss +0 -0
  371. /package/{dist → lib}/style/components/drawer.scss +0 -0
  372. /package/{dist → lib}/style/components/fab.scss +0 -0
  373. /package/{dist → lib}/style/components/flex.scss +0 -0
  374. /package/{dist → lib}/style/components/float-layout.scss +0 -0
  375. /package/{dist → lib}/style/components/form.scss +0 -0
  376. /package/{dist → lib}/style/components/icon.scss +0 -0
  377. /package/{dist → lib}/style/components/image-picker.scss +0 -0
  378. /package/{dist → lib}/style/components/indexes.scss +0 -0
  379. /package/{dist → lib}/style/components/input-number.scss +0 -0
  380. /package/{dist → lib}/style/components/input.scss +0 -0
  381. /package/{dist → lib}/style/components/load-more.scss +0 -0
  382. /package/{dist → lib}/style/components/loading.scss +0 -0
  383. /package/{dist → lib}/style/components/message.scss +0 -0
  384. /package/{dist → lib}/style/components/modal.scss +0 -0
  385. /package/{dist → lib}/style/components/nav-bar.scss +0 -0
  386. /package/{dist → lib}/style/components/noticebar.scss +0 -0
  387. /package/{dist → lib}/style/components/pagination.scss +0 -0
  388. /package/{dist → lib}/style/components/progress.scss +0 -0
  389. /package/{dist → lib}/style/components/radio.scss +0 -0
  390. /package/{dist → lib}/style/components/rate.scss +0 -0
  391. /package/{dist → lib}/style/components/search-bar.scss +0 -0
  392. /package/{dist → lib}/style/components/segmented-control.scss +0 -0
  393. /package/{dist → lib}/style/components/slider.scss +0 -0
  394. /package/{dist → lib}/style/components/steps.scss +0 -0
  395. /package/{dist → lib}/style/components/swipe-action.scss +0 -0
  396. /package/{dist → lib}/style/components/switch.scss +0 -0
  397. /package/{dist → lib}/style/components/tab-bar.scss +0 -0
  398. /package/{dist → lib}/style/components/tabs.scss +0 -0
  399. /package/{dist → lib}/style/components/tag.scss +0 -0
  400. /package/{dist → lib}/style/components/textarea.scss +0 -0
  401. /package/{dist → lib}/style/components/timeline.scss +0 -0
  402. /package/{dist → lib}/style/index.scss +0 -0
  403. /package/{dist → lib}/style/mixins/libs/absolute-center.scss +0 -0
  404. /package/{dist → lib}/style/mixins/libs/active.scss +0 -0
  405. /package/{dist → lib}/style/mixins/libs/alignhack.scss +0 -0
  406. /package/{dist → lib}/style/mixins/libs/border.scss +0 -0
  407. /package/{dist → lib}/style/mixins/libs/clearfix.scss +0 -0
  408. /package/{dist → lib}/style/mixins/libs/disabled.scss +0 -0
  409. /package/{dist → lib}/style/mixins/libs/flex.scss +0 -0
  410. /package/{dist → lib}/style/mixins/libs/hairline.scss +0 -0
  411. /package/{dist → lib}/style/mixins/libs/line.scss +0 -0
  412. /package/{dist → lib}/style/mixins/libs/overlay.scss +0 -0
  413. /package/{dist → lib}/style/mixins/libs/placeholder.scss +0 -0
  414. /package/{dist → lib}/style/themes/purple.scss +0 -0
  415. /package/{dist → lib}/style/themes/red.scss +0 -0
@@ -1,163 +1,186 @@
1
- import classNames from 'classnames';
2
- import PropTypes from 'prop-types';
3
- import React from 'react';
4
- import { Text, View } from '@tarojs/components';
5
- import Taro from '@tarojs/taro';
6
- export default class AtNoticebar extends React.Component {
7
- constructor(props) {
8
- super(props);
9
- const animElemId = `J_${Math.ceil(Math.random() * 10e5).toString(36)}`;
10
- this.state = {
11
- show: true,
12
- animElemId,
13
- animationData: {
14
- actions: [{}]
15
- },
16
- dura: 0,
17
- isWEAPP: Taro.getEnv() === Taro.ENV_TYPE.WEAPP,
18
- isALIPAY: Taro.getEnv() === Taro.ENV_TYPE.ALIPAY,
19
- isWEB: Taro.getEnv() === Taro.ENV_TYPE.WEB
20
- };
1
+ import classNames from "classnames";
2
+ import PropTypes from "prop-types";
3
+ import React from "react";
4
+ import { Text, View } from "@tarojs/components";
5
+ import Taro from "@tarojs/taro";
6
+ class AtNoticebar extends React.Component {
7
+ constructor(props) {
8
+ super(props);
9
+ const animElemId = `J_${Math.ceil(Math.random() * 1e6).toString(36)}`;
10
+ this.state = {
11
+ show: true,
12
+ animElemId,
13
+ animationData: {
14
+ actions: [{}]
15
+ },
16
+ dura: 0,
17
+ isWEAPP: Taro.getEnv() === Taro.ENV_TYPE.WEAPP,
18
+ isALIPAY: Taro.getEnv() === Taro.ENV_TYPE.ALIPAY,
19
+ isWEB: Taro.getEnv() === Taro.ENV_TYPE.WEB
20
+ };
21
+ }
22
+ onClose(event) {
23
+ this.setState({
24
+ show: false
25
+ });
26
+ this.props.onClose && this.props.onClose(event);
27
+ }
28
+ onGotoMore(event) {
29
+ this.props.onGotoMore && this.props.onGotoMore(event);
30
+ }
31
+ UNSAFE_componentWillReceiveProps() {
32
+ if (!this.timeout) {
33
+ this.interval && clearInterval(this.interval);
34
+ this.initAnimation();
21
35
  }
22
- onClose(event) {
23
- this.setState({
24
- show: false
36
+ }
37
+ componentDidMount() {
38
+ if (!this.props.marquee) return;
39
+ this.initAnimation();
40
+ }
41
+ initAnimation() {
42
+ const { isWEAPP, isALIPAY } = this.state;
43
+ this.timeout = setTimeout(() => {
44
+ this.timeout = null;
45
+ if (this.state.isWEB) {
46
+ const { speed = 100 } = this.props;
47
+ const elem = document.querySelector(`.${this.state.animElemId}`);
48
+ if (!elem) return;
49
+ const width = elem.getBoundingClientRect().width;
50
+ const dura = width / +speed;
51
+ this.setState({ dura });
52
+ } else if (isWEAPP || isALIPAY) {
53
+ const query = Taro.createSelectorQuery();
54
+ query.select(`.${this.state.animElemId}`).boundingClientRect().exec((res) => {
55
+ const queryRes = res[0];
56
+ if (!queryRes) return;
57
+ const { width } = queryRes;
58
+ const { speed = 100 } = this.props;
59
+ const dura = width / +speed;
60
+ const animation = Taro.createAnimation({
61
+ duration: dura * 1e3,
62
+ timingFunction: "linear"
63
+ });
64
+ const resetAnimation = Taro.createAnimation({
65
+ duration: 0,
66
+ timingFunction: "linear"
67
+ });
68
+ const resetOpacityAnimation = Taro.createAnimation({
69
+ duration: 0,
70
+ timingFunction: "linear"
71
+ });
72
+ const animBody = () => {
73
+ resetOpacityAnimation.opacity(0).step();
74
+ this.setState({ animationData: resetOpacityAnimation.export() });
75
+ setTimeout(() => {
76
+ resetAnimation.translateX(0).step();
77
+ this.setState({ animationData: resetAnimation.export() });
78
+ }, 300);
79
+ setTimeout(() => {
80
+ resetOpacityAnimation.opacity(1).step();
81
+ this.setState({ animationData: resetOpacityAnimation.export() });
82
+ }, 600);
83
+ setTimeout(() => {
84
+ animation.translateX(-width).step();
85
+ this.setState({ animationData: animation.export() });
86
+ }, 900);
87
+ };
88
+ animBody();
89
+ this.interval = setInterval(animBody, dura * 1e3 + 1e3);
25
90
  });
26
- this.props.onClose && this.props.onClose(event);
27
- }
28
- onGotoMore(event) {
29
- this.props.onGotoMore && this.props.onGotoMore(event);
30
- }
31
- UNSAFE_componentWillReceiveProps() {
32
- if (!this.timeout) {
33
- this.interval && clearInterval(this.interval);
34
- this.initAnimation();
35
- }
36
- }
37
- componentDidMount() {
38
- if (!this.props.marquee)
39
- return;
40
- this.initAnimation();
41
- }
42
- initAnimation() {
43
- const { isWEAPP, isALIPAY } = this.state;
44
- this.timeout = setTimeout(() => {
45
- this.timeout = null;
46
- if (this.state.isWEB) {
47
- const { speed = 100 } = this.props;
48
- const elem = document.querySelector(`.${this.state.animElemId}`);
49
- if (!elem)
50
- return;
51
- const width = elem.getBoundingClientRect().width;
52
- const dura = width / +speed;
53
- this.setState({ dura });
54
- }
55
- else if (isWEAPP || isALIPAY) {
56
- const query = Taro.createSelectorQuery();
57
- query
58
- .select(`.${this.state.animElemId}`)
59
- .boundingClientRect()
60
- .exec(res => {
61
- const queryRes = res[0];
62
- if (!queryRes)
63
- return;
64
- const { width } = queryRes;
65
- const { speed = 100 } = this.props;
66
- const dura = width / +speed;
67
- const animation = Taro.createAnimation({
68
- duration: dura * 1000,
69
- timingFunction: 'linear'
70
- });
71
- const resetAnimation = Taro.createAnimation({
72
- duration: 0,
73
- timingFunction: 'linear'
74
- });
75
- const resetOpacityAnimation = Taro.createAnimation({
76
- duration: 0,
77
- timingFunction: 'linear'
78
- });
79
- const animBody = () => {
80
- resetOpacityAnimation.opacity(0).step();
81
- this.setState({ animationData: resetOpacityAnimation.export() });
82
- setTimeout(() => {
83
- resetAnimation.translateX(0).step();
84
- this.setState({ animationData: resetAnimation.export() });
85
- }, 300);
86
- setTimeout(() => {
87
- resetOpacityAnimation.opacity(1).step();
88
- this.setState({ animationData: resetOpacityAnimation.export() });
89
- }, 600);
90
- setTimeout(() => {
91
- animation.translateX(-width).step();
92
- this.setState({ animationData: animation.export() });
93
- }, 900);
94
- };
95
- animBody();
96
- this.interval = setInterval(animBody, dura * 1000 + 1000);
97
- });
98
- }
99
- }, 1000);
100
- }
101
- render() {
102
- const { single, icon, marquee, customStyle, className, moreText = '查看详情' } = this.props;
103
- let { showMore, close } = this.props;
104
- const { dura, show, animElemId, animationData, isWEAPP, isALIPAY } = this.state;
105
- const rootClassName = ['at-noticebar'];
106
- if (!single)
107
- showMore = false;
108
- const style = {};
109
- const innerClassName = ['at-noticebar__content-inner'];
110
- if (marquee) {
111
- close = false;
112
- innerClassName.push(animElemId);
113
- style['animation-delay'] = '3s';
114
- if (dura > 0) {
115
- style['animation-duration'] = `${dura}s`;
116
- style['animation-delay'] = '1s';
117
- }
118
- }
119
- const classObject = {
120
- 'at-noticebar--marquee': marquee,
121
- 'at-noticebar--weapp': marquee && (isWEAPP || isALIPAY),
122
- 'at-noticebar--single': !marquee && single
123
- };
124
- const iconClass = ['at-icon'];
125
- if (icon)
126
- iconClass.push(`at-icon-${icon}`);
127
- return (show && (React.createElement(View, { className: classNames(rootClassName, classObject, className), style: customStyle },
128
- close && (React.createElement(View, { className: 'at-noticebar__close', onClick: this.onClose.bind(this) },
129
- React.createElement(Text, { className: 'at-icon at-icon-close' }))),
130
- React.createElement(View, { className: 'at-noticebar__content' },
131
- icon && (React.createElement(View, { className: 'at-noticebar__content-icon' },
132
- React.createElement(Text, { className: classNames(iconClass, iconClass) }))),
133
- React.createElement(View, { className: 'at-noticebar__content-text' },
134
- React.createElement(View, { id: animElemId, animation: animationData, className: classNames(innerClassName), style: style }, this.props.children))),
135
- showMore && (React.createElement(View, { className: 'at-noticebar__more', onClick: this.onGotoMore.bind(this) },
136
- React.createElement(Text, { className: 'text' }, moreText),
137
- React.createElement(View, { className: 'at-noticebar__more-icon' },
138
- React.createElement(Text, { className: 'at-icon at-icon-chevron-right' })))))));
91
+ }
92
+ }, 1e3);
93
+ }
94
+ render() {
95
+ const {
96
+ single,
97
+ icon,
98
+ marquee,
99
+ customStyle,
100
+ className,
101
+ moreText = "\u67E5\u770B\u8BE6\u60C5"
102
+ } = this.props;
103
+ let { showMore, close } = this.props;
104
+ const { dura, show, animElemId, animationData, isWEAPP, isALIPAY } = this.state;
105
+ const rootClassName = ["at-noticebar"];
106
+ if (!single) showMore = false;
107
+ const style = {};
108
+ const innerClassName = ["at-noticebar__content-inner"];
109
+ if (marquee) {
110
+ close = false;
111
+ innerClassName.push(animElemId);
112
+ style["animation-delay"] = "3s";
113
+ if (dura > 0) {
114
+ style["animation-duration"] = `${dura}s`;
115
+ style["animation-delay"] = "1s";
116
+ }
139
117
  }
118
+ const classObject = {
119
+ "at-noticebar--marquee": marquee,
120
+ "at-noticebar--weapp": marquee && (isWEAPP || isALIPAY),
121
+ "at-noticebar--single": !marquee && single
122
+ };
123
+ const iconClass = ["at-icon"];
124
+ if (icon) iconClass.push(`at-icon-${icon}`);
125
+ return show && /* @__PURE__ */ React.createElement(
126
+ View,
127
+ {
128
+ className: classNames(rootClassName, classObject, className),
129
+ style: customStyle
130
+ },
131
+ close && /* @__PURE__ */ React.createElement(
132
+ View,
133
+ {
134
+ className: "at-noticebar__close",
135
+ onClick: this.onClose.bind(this)
136
+ },
137
+ /* @__PURE__ */ React.createElement(Text, { className: "at-icon at-icon-close" })
138
+ ),
139
+ /* @__PURE__ */ React.createElement(View, { className: "at-noticebar__content" }, icon && /* @__PURE__ */ React.createElement(View, { className: "at-noticebar__content-icon" }, /* @__PURE__ */ React.createElement(Text, { className: classNames(iconClass, iconClass) })), /* @__PURE__ */ React.createElement(View, { className: "at-noticebar__content-text" }, /* @__PURE__ */ React.createElement(
140
+ View,
141
+ {
142
+ id: animElemId,
143
+ animation: animationData,
144
+ className: classNames(innerClassName),
145
+ style
146
+ },
147
+ this.props.children
148
+ ))),
149
+ showMore && /* @__PURE__ */ React.createElement(
150
+ View,
151
+ {
152
+ className: "at-noticebar__more",
153
+ onClick: this.onGotoMore.bind(this)
154
+ },
155
+ /* @__PURE__ */ React.createElement(Text, { className: "text" }, moreText),
156
+ /* @__PURE__ */ React.createElement(View, { className: "at-noticebar__more-icon" }, /* @__PURE__ */ React.createElement(Text, { className: "at-icon at-icon-chevron-right" }))
157
+ )
158
+ );
159
+ }
140
160
  }
141
161
  AtNoticebar.defaultProps = {
142
- close: false,
143
- single: false,
144
- marquee: false,
145
- speed: 100,
146
- moreText: '查看详情',
147
- showMore: false,
148
- icon: '',
149
- customStyle: {}
162
+ close: false,
163
+ single: false,
164
+ marquee: false,
165
+ speed: 100,
166
+ moreText: "\u67E5\u770B\u8BE6\u60C5",
167
+ showMore: false,
168
+ icon: "",
169
+ customStyle: {}
150
170
  };
151
171
  AtNoticebar.propTypes = {
152
- close: PropTypes.bool,
153
- single: PropTypes.bool,
154
- marquee: PropTypes.bool,
155
- speed: PropTypes.number,
156
- moreText: PropTypes.string,
157
- showMore: PropTypes.bool,
158
- icon: PropTypes.string,
159
- customStyle: PropTypes.oneOfType([PropTypes.object, PropTypes.string]),
160
- onClose: PropTypes.func,
161
- onGotoMore: PropTypes.func
172
+ close: PropTypes.bool,
173
+ single: PropTypes.bool,
174
+ marquee: PropTypes.bool,
175
+ speed: PropTypes.number,
176
+ moreText: PropTypes.string,
177
+ showMore: PropTypes.bool,
178
+ icon: PropTypes.string,
179
+ customStyle: PropTypes.oneOfType([PropTypes.object, PropTypes.string]),
180
+ onClose: PropTypes.func,
181
+ onGotoMore: PropTypes.func
182
+ };
183
+ export {
184
+ AtNoticebar as default
162
185
  };
163
186
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/noticebar/index.tsx"],"names":[],"mappings":"AAAA,OAAO,UAAU,MAAM,YAAY,CAAA;AACnC,OAAO,SAAyB,MAAM,YAAY,CAAA;AAClD,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAA;AAE/C,OAAO,IAAI,MAAM,cAAc,CAAA;AAG/B,MAAM,CAAC,OAAO,OAAO,WAAY,SAAQ,KAAK,CAAC,SAG9C;IAOC,YAAmB,KAAuB;QACxC,KAAK,CAAC,KAAK,CAAC,CAAA;QACZ,MAAM,UAAU,GAAG,KAAK,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,IAAI,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,EAAE,CAAA;QACtE,IAAI,CAAC,KAAK,GAAG;YACX,IAAI,EAAE,IAAI;YACV,UAAU;YACV,aAAa,EAAE;gBACb,OAAO,EAAE,CAAC,EAAE,CAAC;aACd;YACD,IAAI,EAAE,CAAC;YACP,OAAO,EAAE,IAAI,CAAC,MAAM,EAAE,KAAK,IAAI,CAAC,QAAQ,CAAC,KAAK;YAC9C,QAAQ,EAAE,IAAI,CAAC,MAAM,EAAE,KAAK,IAAI,CAAC,QAAQ,CAAC,MAAM;YAChD,KAAK,EAAE,IAAI,CAAC,MAAM,EAAE,KAAK,IAAI,CAAC,QAAQ,CAAC,GAAG;SAC3C,CAAA;IACH,CAAC;IAEO,OAAO,CAAC,KAAkB;QAChC,IAAI,CAAC,QAAQ,CAAC;YACZ,IAAI,EAAE,KAAK;SACZ,CAAC,CAAA;QACF,IAAI,CAAC,KAAK,CAAC,OAAO,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAA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,CAAC,cAAc,CAAC,EACrC,KAAK,EAAE,KAAK,IAEX,IAAI,CAAC,KAAK,CAAC,QAAQ,CACf,CACF,CACF;YACN,QAAQ,IAAI,CACX,oBAAC,IAAI,IACH,SAAS,EAAC,oBAAoB,EAC9B,OAAO,EAAE,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC;gBAEnC,oBAAC,IAAI,IAAC,SAAS,EAAC,MAAM,IAAE,QAAQ,CAAQ;gBACxC,oBAAC,IAAI,IAAC,SAAS,EAAC,yBAAyB;oBACvC,oBAAC,IAAI,IAAC,SAAS,EAAC,+BAA+B,GAAQ,CAClD,CACF,CACR,CACI,CACR,CACF,CAAA;IACH,CAAC;CACF;AAED,WAAW,CAAC,YAAY,GAAG;IACzB,KAAK,EAAE,KAAK;IACZ,MAAM,EAAE,KAAK;IACb,OAAO,EAAE,KAAK;IACd,KAAK,EAAE,GAAG;IACV,QAAQ,EAAE,MAAM;IAChB,QAAQ,EAAE,KAAK;IACf,IAAI,EAAE,EAAE;IACR,WAAW,EAAE,EAAE;CAChB,CAAA;AAED,WAAW,CAAC,SAAS,GAAG;IACtB,KAAK,EAAE,SAAS,CAAC,IAAI;IACrB,MAAM,EAAE,SAAS,CAAC,IAAI;IACtB,OAAO,EAAE,SAAS,CAAC,IAAI;IACvB,KAAK,EAAE,SAAS,CAAC,MAAM;IACvB,QAAQ,EAAE,SAAS,CAAC,MAAM;IAC1B,QAAQ,EAAE,SAAS,CAAC,IAAI;IACxB,IAAI,EAAE,SAAS,CAAC,MAAM;IACtB,WAAW,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC,SAAS,CAAC,MAAM,EAAE,SAAS,CAAC,MAAM,CAAC,CAAC;IACtE,OAAO,EAAE,SAAS,CAAC,IAAI;IACvB,UAAU,EAAE,SAAS,CAAC,IAAI;CAC3B,CAAA"}
1
+ {"version":3,"sources":["../../../src/components/noticebar/index.tsx"],"sourcesContent":["import classNames from 'classnames'\nimport PropTypes, { InferProps } from 'prop-types'\nimport React from 'react'\nimport { Text, View } from '@tarojs/components'\nimport { CommonEvent } from '@tarojs/components/types/common'\nimport Taro from '@tarojs/taro'\nimport { AtNoticeBarProps, AtNoticeBarState } from '../../../types/noticebar'\n\nexport default class AtNoticebar extends React.Component<\n AtNoticeBarProps,\n AtNoticeBarState\n> {\n public static defaultProps: AtNoticeBarProps\n public static propTypes: InferProps<AtNoticeBarProps>\n\n private timeout: ReturnType<typeof setTimeout> | null\n private interval: ReturnType<typeof setInterval> | null\n\n public constructor(props: AtNoticeBarProps) {\n super(props)\n const animElemId = `J_${Math.ceil(Math.random() * 10e5).toString(36)}`\n this.state = {\n show: true,\n animElemId,\n animationData: {\n actions: [{}]\n },\n dura: 0,\n isWEAPP: Taro.getEnv() === Taro.ENV_TYPE.WEAPP,\n isALIPAY: Taro.getEnv() === Taro.ENV_TYPE.ALIPAY,\n isWEB: Taro.getEnv() === Taro.ENV_TYPE.WEB\n }\n }\n\n private onClose(event: CommonEvent): void {\n this.setState({\n show: false\n })\n this.props.onClose && this.props.onClose(event)\n }\n\n private onGotoMore(event: CommonEvent): void {\n this.props.onGotoMore && this.props.onGotoMore(event)\n }\n\n public UNSAFE_componentWillReceiveProps(): void {\n if (!this.timeout) {\n this.interval && clearInterval(this.interval)\n this.initAnimation()\n }\n }\n\n public componentDidMount(): void {\n if (!this.props.marquee) return\n this.initAnimation()\n }\n\n private initAnimation(): void {\n const { isWEAPP, isALIPAY } = this.state\n this.timeout = setTimeout(() => {\n this.timeout = null\n if (this.state.isWEB) {\n const { speed = 100 } = this.props\n const elem = document.querySelector(`.${this.state.animElemId}`)\n if (!elem) return\n const width = elem.getBoundingClientRect().width\n const dura = width / +speed\n this.setState({ dura })\n } else if (isWEAPP || isALIPAY) {\n const query = Taro.createSelectorQuery()\n query\n .select(`.${this.state.animElemId}`)\n .boundingClientRect()\n .exec(res => {\n const queryRes = res[0]\n if (!queryRes) return\n const { width } = queryRes\n const { speed = 100 } = this.props\n const dura = width / +speed\n const animation = Taro.createAnimation({\n duration: dura * 1000,\n timingFunction: 'linear'\n })\n const resetAnimation = Taro.createAnimation({\n duration: 0,\n timingFunction: 'linear'\n })\n const resetOpacityAnimation = Taro.createAnimation({\n duration: 0,\n timingFunction: 'linear'\n })\n const animBody = (): void => {\n resetOpacityAnimation.opacity(0).step()\n this.setState({ animationData: resetOpacityAnimation.export() })\n\n setTimeout(() => {\n resetAnimation.translateX(0).step()\n this.setState({ animationData: resetAnimation.export() })\n }, 300)\n\n setTimeout(() => {\n resetOpacityAnimation.opacity(1).step()\n this.setState({ animationData: resetOpacityAnimation.export() })\n }, 600)\n\n setTimeout(() => {\n animation.translateX(-width).step()\n this.setState({ animationData: animation.export() })\n }, 900)\n }\n animBody()\n this.interval = setInterval(animBody, dura * 1000 + 1000)\n })\n }\n }, 1000)\n }\n\n public render(): JSX.Element | boolean {\n const {\n single,\n icon,\n marquee,\n customStyle,\n className,\n moreText = '查看详情'\n } = this.props\n let { showMore, close } = this.props\n const { dura, show, animElemId, animationData, isWEAPP, isALIPAY } =\n this.state\n const rootClassName = ['at-noticebar']\n\n if (!single) showMore = false\n\n const style = {}\n const innerClassName = ['at-noticebar__content-inner']\n if (marquee) {\n close = false\n innerClassName.push(animElemId)\n style['animation-delay'] = '3s'\n\n if (dura > 0) {\n style['animation-duration'] = `${dura}s`\n style['animation-delay'] = '1s'\n }\n }\n\n const classObject = {\n 'at-noticebar--marquee': marquee,\n 'at-noticebar--weapp': marquee && (isWEAPP || isALIPAY),\n 'at-noticebar--single': !marquee && single\n }\n\n const iconClass = ['at-icon']\n if (icon) iconClass.push(`at-icon-${icon}`)\n\n return (\n show && (\n <View\n className={classNames(rootClassName, classObject, className)}\n style={customStyle}\n >\n {close && (\n <View\n className='at-noticebar__close'\n onClick={this.onClose.bind(this)}\n >\n <Text className='at-icon at-icon-close'></Text>\n </View>\n )}\n <View className='at-noticebar__content'>\n {icon && (\n <View className='at-noticebar__content-icon'>\n {/* start hack 百度小程序 */}\n <Text className={classNames(iconClass, iconClass)}></Text>\n </View>\n )}\n <View className='at-noticebar__content-text'>\n <View\n id={animElemId}\n animation={animationData}\n className={classNames(innerClassName)}\n style={style}\n >\n {this.props.children}\n </View>\n </View>\n </View>\n {showMore && (\n <View\n className='at-noticebar__more'\n onClick={this.onGotoMore.bind(this)}\n >\n <Text className='text'>{moreText}</Text>\n <View className='at-noticebar__more-icon'>\n <Text className='at-icon at-icon-chevron-right'></Text>\n </View>\n </View>\n )}\n </View>\n )\n )\n }\n}\n\nAtNoticebar.defaultProps = {\n close: false,\n single: false,\n marquee: false,\n speed: 100,\n moreText: '查看详情',\n showMore: false,\n icon: '',\n customStyle: {}\n}\n\nAtNoticebar.propTypes = {\n close: PropTypes.bool,\n single: PropTypes.bool,\n marquee: PropTypes.bool,\n speed: PropTypes.number,\n moreText: PropTypes.string,\n showMore: PropTypes.bool,\n icon: PropTypes.string,\n customStyle: PropTypes.oneOfType([PropTypes.object, PropTypes.string]),\n onClose: PropTypes.func,\n onGotoMore: PropTypes.func\n}\n"],"mappings":"AAAA,OAAO,gBAAgB;AACvB,OAAO,eAA+B;AACtC,OAAO,WAAW;AAClB,SAAS,MAAM,YAAY;AAE3B,OAAO,UAAU;AAGjB,MAAO,oBAAkC,MAAM,UAG7C;AAAA,EAOO,YAAY,OAAyB;AAC1C,UAAM,KAAK;AACX,UAAM,aAAa,KAAK,KAAK,KAAK,KAAK,OAAO,IAAI,GAAI,EAAE,SAAS,EAAE,CAAC;AACpE,SAAK,QAAQ;AAAA,MACX,MAAM;AAAA,MACN;AAAA,MACA,eAAe;AAAA,QACb,SAAS,CAAC,CAAC,CAAC;AAAA,MACd;AAAA,MACA,MAAM;AAAA,MACN,SAAS,KAAK,OAAO,MAAM,KAAK,SAAS;AAAA,MACzC,UAAU,KAAK,OAAO,MAAM,KAAK,SAAS;AAAA,MAC1C,OAAO,KAAK,OAAO,MAAM,KAAK,SAAS;AAAA,IACzC;AAAA,EACF;AAAA,EAEQ,QAAQ,O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T,OAAO;AAAA,EACP,UAAU;AAAA,EACV,UAAU;AAAA,EACV,MAAM;AAAA,EACN,aAAa,CAAC;AAChB;AAEA,YAAY,YAAY;AAAA,EACtB,OAAO,UAAU;AAAA,EACjB,QAAQ,UAAU;AAAA,EAClB,SAAS,UAAU;AAAA,EACnB,OAAO,UAAU;AAAA,EACjB,UAAU,UAAU;AAAA,EACpB,UAAU,UAAU;AAAA,EACpB,MAAM,UAAU;AAAA,EAChB,aAAa,UAAU,UAAU,CAAC,UAAU,QAAQ,UAAU,MAAM,CAAC;AAAA,EACrE,SAAS,UAAU;AAAA,EACnB,YAAY,UAAU;AACxB;","names":[]}
@@ -0,0 +1,12 @@
1
+ import { InferProps } from 'prop-types';
2
+ import React from 'react';
3
+ import { AtPaginationProps, AtPaginationState } from '../../../types/pagination';
4
+ export default class AtPagination extends React.Component<AtPaginationProps, AtPaginationState> {
5
+ static defaultProps: AtPaginationProps;
6
+ static propTypes: InferProps<AtPaginationProps>;
7
+ constructor(props: AtPaginationProps);
8
+ private onPrev;
9
+ private onNext;
10
+ UNSAFE_componentWillReceiveProps(props: AtPaginationProps): void;
11
+ render(): JSX.Element;
12
+ }
@@ -1,115 +1,146 @@
1
- import classNames from 'classnames';
2
- import PropTypes from 'prop-types';
3
- import React from 'react';
4
- import { Text, View } from '@tarojs/components';
5
- import AtButton from '../button/index';
1
+ import classNames from "classnames";
2
+ import PropTypes from "prop-types";
3
+ import React from "react";
4
+ import { Text, View } from "@tarojs/components";
5
+ import AtButton from "../button/index";
6
6
  const MIN_MAXPAGE = 1;
7
7
  const getMaxPage = (maxPage = 0) => {
8
- if (maxPage <= 0)
9
- return MIN_MAXPAGE;
10
- return maxPage;
8
+ if (maxPage <= 0) return MIN_MAXPAGE;
9
+ return maxPage;
11
10
  };
12
11
  const createPickerRange = (max) => {
13
- const range = new Array(max).fill(0).map((_val, index) => index + 1);
14
- return range;
12
+ const range = new Array(max).fill(0).map((_val, index) => index + 1);
13
+ return range;
15
14
  };
16
- export default class AtPagination extends React.Component {
17
- constructor(props) {
18
- super(props);
19
- const { current, pageSize = 20, total } = this.props;
20
- const maxPage = getMaxPage(Math.ceil(total / pageSize));
21
- this.state = {
22
- currentPage: current || 1,
23
- maxPage,
24
- pickerRange: createPickerRange(maxPage)
25
- };
15
+ class AtPagination extends React.Component {
16
+ constructor(props) {
17
+ super(props);
18
+ const { current, pageSize = 20, total } = this.props;
19
+ const maxPage = getMaxPage(Math.ceil(total / pageSize));
20
+ this.state = {
21
+ currentPage: current || 1,
22
+ maxPage,
23
+ pickerRange: createPickerRange(maxPage)
24
+ };
25
+ }
26
+ onPrev() {
27
+ let { currentPage } = this.state;
28
+ const originCur = currentPage;
29
+ currentPage -= 1;
30
+ currentPage = Math.max(1, currentPage);
31
+ if (originCur === currentPage) return;
32
+ this.props.onPageChange && this.props.onPageChange({ type: "prev", current: currentPage });
33
+ this.setState({ currentPage });
34
+ }
35
+ onNext() {
36
+ let { currentPage } = this.state;
37
+ const originCur = currentPage;
38
+ const { maxPage } = this.state;
39
+ currentPage += 1;
40
+ currentPage = Math.min(maxPage, currentPage);
41
+ if (originCur === currentPage) return;
42
+ this.props.onPageChange && this.props.onPageChange({ type: "next", current: currentPage });
43
+ this.setState({ currentPage });
44
+ }
45
+ UNSAFE_componentWillReceiveProps(props) {
46
+ const { total, pageSize = 20, current } = props;
47
+ const maxPage = getMaxPage(Math.ceil(total / pageSize));
48
+ if (maxPage !== this.state.maxPage) {
49
+ this.setState({
50
+ maxPage,
51
+ pickerRange: createPickerRange(maxPage)
52
+ });
26
53
  }
27
- onPrev() {
28
- let { currentPage } = this.state;
29
- const originCur = currentPage;
30
- currentPage -= 1;
31
- currentPage = Math.max(1, currentPage);
32
- if (originCur === currentPage)
33
- return;
34
- this.props.onPageChange &&
35
- this.props.onPageChange({ type: 'prev', current: currentPage });
36
- this.setState({ currentPage });
37
- }
38
- onNext() {
39
- let { currentPage } = this.state;
40
- const originCur = currentPage;
41
- const { maxPage } = this.state;
42
- currentPage += 1;
43
- currentPage = Math.min(maxPage, currentPage);
44
- if (originCur === currentPage)
45
- return;
46
- this.props.onPageChange &&
47
- this.props.onPageChange({ type: 'next', current: currentPage });
48
- this.setState({ currentPage });
49
- }
50
- UNSAFE_componentWillReceiveProps(props) {
51
- const { total, pageSize = 20, current } = props;
52
- const maxPage = getMaxPage(Math.ceil(total / pageSize));
53
- if (maxPage !== this.state.maxPage) {
54
- this.setState({
55
- maxPage,
56
- pickerRange: createPickerRange(maxPage)
57
- });
58
- }
59
- if (typeof current === 'number' && current !== this.state.currentPage) {
60
- this.setState({ currentPage: current });
61
- }
62
- }
63
- // onPickerChange (evt) {
64
- // const { value } = evt.detail
65
- // const current = +value + 1
66
- // if (current === this.state.currentPage) return
67
- // this.props.onPageChange && this.props.onPageChange({ type: 'pick', current })
68
- // this.setState({
69
- // currentPage: current,
70
- // })
71
- // }
72
- render() {
73
- const { icon,
74
- // pickerSelect,
75
- customStyle } = this.props;
76
- const { currentPage, maxPage
77
- // pickerRange,
78
- } = this.state;
79
- const rootClassName = ['at-pagination'];
80
- const prevDisabled = maxPage === MIN_MAXPAGE || currentPage === 1;
81
- const nextDisabled = maxPage === MIN_MAXPAGE || currentPage === maxPage;
82
- const classObject = {
83
- 'at-pagination--icon': icon
84
- };
85
- return (React.createElement(View, { className: classNames(rootClassName, classObject, this.props.className), style: customStyle },
86
- React.createElement(View, { className: 'at-pagination__btn-prev' },
87
- icon && (React.createElement(AtButton, { onClick: this.onPrev.bind(this), size: 'small', disabled: prevDisabled },
88
- React.createElement(Text, { className: 'at-icon at-icon-chevron-left' }))),
89
- !icon && (React.createElement(AtButton, { onClick: this.onPrev.bind(this), size: 'small', disabled: prevDisabled }, "\u4E0A\u4E00\u9875"))),
90
- React.createElement(View, { className: 'at-pagination__number' },
91
- React.createElement(Text, { className: 'at-pagination__number-current' }, currentPage),
92
- "/",
93
- maxPage),
94
- React.createElement(View, { className: 'at-pagination__btn-next' },
95
- icon && (React.createElement(AtButton, { onClick: this.onNext.bind(this), size: 'small', disabled: nextDisabled },
96
- React.createElement(Text, { className: 'at-icon at-icon-chevron-right' }))),
97
- !icon && (React.createElement(AtButton, { onClick: this.onNext.bind(this), size: 'small', disabled: nextDisabled }, "\u4E0B\u4E00\u9875")))));
54
+ if (typeof current === "number" && current !== this.state.currentPage) {
55
+ this.setState({ currentPage: current });
98
56
  }
57
+ }
58
+ // onPickerChange (evt) {
59
+ // const { value } = evt.detail
60
+ // const current = +value + 1
61
+ // if (current === this.state.currentPage) return
62
+ // this.props.onPageChange && this.props.onPageChange({ type: 'pick', current })
63
+ // this.setState({
64
+ // currentPage: current,
65
+ // })
66
+ // }
67
+ render() {
68
+ const {
69
+ icon,
70
+ // pickerSelect,
71
+ customStyle
72
+ } = this.props;
73
+ const {
74
+ currentPage,
75
+ maxPage
76
+ // pickerRange,
77
+ } = this.state;
78
+ const rootClassName = ["at-pagination"];
79
+ const prevDisabled = maxPage === MIN_MAXPAGE || currentPage === 1;
80
+ const nextDisabled = maxPage === MIN_MAXPAGE || currentPage === maxPage;
81
+ const classObject = {
82
+ "at-pagination--icon": icon
83
+ };
84
+ return /* @__PURE__ */ React.createElement(
85
+ View,
86
+ {
87
+ className: classNames(rootClassName, classObject, this.props.className),
88
+ style: customStyle
89
+ },
90
+ /* @__PURE__ */ React.createElement(View, { className: "at-pagination__btn-prev" }, icon && /* @__PURE__ */ React.createElement(
91
+ AtButton,
92
+ {
93
+ onClick: this.onPrev.bind(this),
94
+ size: "small",
95
+ disabled: prevDisabled
96
+ },
97
+ /* @__PURE__ */ React.createElement(Text, { className: "at-icon at-icon-chevron-left" })
98
+ ), !icon && /* @__PURE__ */ React.createElement(
99
+ AtButton,
100
+ {
101
+ onClick: this.onPrev.bind(this),
102
+ size: "small",
103
+ disabled: prevDisabled
104
+ },
105
+ "\u4E0A\u4E00\u9875"
106
+ )),
107
+ /* @__PURE__ */ React.createElement(View, { className: "at-pagination__number" }, /* @__PURE__ */ React.createElement(Text, { className: "at-pagination__number-current" }, currentPage), "/", maxPage),
108
+ /* @__PURE__ */ React.createElement(View, { className: "at-pagination__btn-next" }, icon && /* @__PURE__ */ React.createElement(
109
+ AtButton,
110
+ {
111
+ onClick: this.onNext.bind(this),
112
+ size: "small",
113
+ disabled: nextDisabled
114
+ },
115
+ /* @__PURE__ */ React.createElement(Text, { className: "at-icon at-icon-chevron-right" })
116
+ ), !icon && /* @__PURE__ */ React.createElement(
117
+ AtButton,
118
+ {
119
+ onClick: this.onNext.bind(this),
120
+ size: "small",
121
+ disabled: nextDisabled
122
+ },
123
+ "\u4E0B\u4E00\u9875"
124
+ ))
125
+ );
126
+ }
99
127
  }
100
128
  AtPagination.defaultProps = {
101
- current: 1,
102
- total: 0,
103
- pageSize: 20,
104
- icon: false,
105
- customStyle: {}
129
+ current: 1,
130
+ total: 0,
131
+ pageSize: 20,
132
+ icon: false,
133
+ customStyle: {}
106
134
  };
107
135
  AtPagination.propTypes = {
108
- current: PropTypes.number,
109
- total: PropTypes.number,
110
- pageSize: PropTypes.number,
111
- icon: PropTypes.bool,
112
- customStyle: PropTypes.oneOfType([PropTypes.object, PropTypes.string]),
113
- onPageChange: PropTypes.func
136
+ current: PropTypes.number,
137
+ total: PropTypes.number,
138
+ pageSize: PropTypes.number,
139
+ icon: PropTypes.bool,
140
+ customStyle: PropTypes.oneOfType([PropTypes.object, PropTypes.string]),
141
+ onPageChange: PropTypes.func
142
+ };
143
+ export {
144
+ AtPagination as default
114
145
  };
115
146
  //# sourceMappingURL=index.js.map