taro-ui 3.3.1 → 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.
- package/lib/common/component.d.ts +10 -0
- package/lib/common/component.js +27 -28
- package/lib/common/component.js.map +1 -1
- package/lib/common/utils.d.ts +41 -0
- package/lib/common/utils.js +169 -192
- package/lib/common/utils.js.map +1 -1
- package/lib/components/accordion/index.d.ts +14 -0
- package/lib/components/accordion/index.js +111 -106
- package/lib/components/accordion/index.js.map +1 -1
- package/lib/components/action-sheet/body/index.d.ts +5 -0
- package/lib/components/action-sheet/body/index.js +11 -8
- package/lib/components/action-sheet/body/index.js.map +1 -1
- package/lib/components/action-sheet/body/item/index.d.ts +9 -0
- package/lib/components/action-sheet/body/item/index.js +21 -18
- package/lib/components/action-sheet/body/item/index.js.map +1 -1
- package/lib/components/action-sheet/footer/index.d.ts +9 -0
- package/lib/components/action-sheet/footer/index.js +24 -18
- package/lib/components/action-sheet/footer/index.js.map +1 -1
- package/lib/components/action-sheet/header/index.d.ts +5 -0
- package/lib/components/action-sheet/header/index.js +14 -8
- package/lib/components/action-sheet/header/index.js.map +1 -1
- package/lib/components/action-sheet/index.d.ts +14 -0
- package/lib/components/action-sheet/index.js +69 -64
- package/lib/components/action-sheet/index.js.map +1 -1
- package/lib/components/activity-indicator/index.d.ts +8 -0
- package/lib/components/activity-indicator/index.js +33 -29
- package/lib/components/activity-indicator/index.js.map +1 -1
- package/lib/components/avatar/index.d.ts +9 -0
- package/lib/components/avatar/index.js +58 -55
- package/lib/components/avatar/index.js.map +1 -1
- package/lib/components/badge/index.d.ts +10 -0
- package/lib/components/badge/index.js +44 -35
- package/lib/components/badge/index.js.map +1 -1
- package/lib/components/button/index.d.ts +15 -0
- package/lib/components/button/index.js +165 -113
- package/lib/components/button/index.js.map +1 -1
- package/lib/components/calendar/body/index.d.ts +26 -0
- package/lib/components/calendar/body/index.js +279 -183
- package/lib/components/calendar/body/index.js.map +1 -1
- package/lib/components/calendar/common/constant.d.ts +3 -0
- package/lib/components/calendar/common/constant.js +8 -3
- package/lib/components/calendar/common/constant.js.map +1 -1
- package/lib/components/calendar/common/helper.d.ts +4 -0
- package/lib/components/calendar/common/helper.js +77 -76
- package/lib/components/calendar/common/helper.js.map +1 -1
- package/lib/components/calendar/common/plugins.d.ts +11 -0
- package/lib/components/calendar/common/plugins.js +50 -66
- package/lib/components/calendar/common/plugins.js.map +1 -1
- package/lib/components/calendar/controller/index.d.ts +5 -0
- package/lib/components/calendar/controller/index.js +49 -28
- package/lib/components/calendar/controller/index.js.map +1 -1
- package/lib/components/calendar/index.d.ts +20 -0
- package/lib/components/calendar/index.js +233 -196
- package/lib/components/calendar/index.js.map +1 -1
- package/lib/components/calendar/ui/date-list/index.d.ts +12 -0
- package/lib/components/calendar/ui/date-list/index.js +50 -39
- package/lib/components/calendar/ui/date-list/index.js.map +1 -1
- package/lib/components/calendar/ui/day-list/index.d.ts +4 -0
- package/lib/components/calendar/ui/day-list/index.js +9 -14
- package/lib/components/calendar/ui/day-list/index.js.map +1 -1
- package/lib/components/card/index.d.ts +9 -0
- package/lib/components/card/index.js +73 -52
- package/lib/components/card/index.js.map +1 -1
- package/lib/components/checkbox/index.d.ts +9 -0
- package/lib/components/checkbox/index.js +52 -48
- package/lib/components/checkbox/index.js.map +1 -1
- package/lib/components/countdown/index.d.ts +20 -0
- package/lib/components/countdown/index.js +140 -125
- package/lib/components/countdown/index.js.map +1 -1
- package/lib/components/countdown/item/index.d.ts +9 -0
- package/lib/components/countdown/item/index.js +18 -18
- package/lib/components/countdown/item/index.js.map +1 -1
- package/lib/components/curtain/index.d.ts +10 -0
- package/lib/components/curtain/index.js +56 -39
- package/lib/components/curtain/index.js.map +1 -1
- package/lib/components/divider/index.d.ts +8 -0
- package/lib/components/divider/index.js +51 -34
- package/lib/components/divider/index.js.map +1 -1
- package/lib/components/drawer/index.d.ts +16 -0
- package/lib/components/drawer/index.js +106 -85
- package/lib/components/drawer/index.js.map +1 -1
- package/lib/components/fab/index.d.ts +9 -0
- package/lib/components/fab/index.js +22 -19
- package/lib/components/fab/index.js.map +1 -1
- package/lib/components/flex/index.d.ts +7 -0
- package/lib/components/flex/index.js +37 -34
- package/lib/components/flex/index.js.map +1 -1
- package/lib/components/flex/item/index.d.ts +7 -0
- package/lib/components/flex/item/index.js +30 -27
- package/lib/components/flex/item/index.js.map +1 -1
- package/lib/components/float-layout/index.d.ts +13 -0
- package/lib/components/float-layout/index.js +96 -68
- package/lib/components/float-layout/index.js.map +1 -1
- package/lib/components/form/index.d.ts +10 -0
- package/lib/components/form/index.js +37 -24
- package/lib/components/form/index.js.map +1 -1
- package/lib/components/grid/index.d.ts +9 -0
- package/lib/components/grid/index.js +92 -62
- package/lib/components/grid/index.js.map +1 -1
- package/lib/components/icon/index.d.ts +9 -0
- package/lib/components/icon/index.js +48 -31
- package/lib/components/icon/index.js.map +1 -1
- package/lib/components/image-picker/index.d.ts +11 -0
- package/lib/components/image-picker/index.js +152 -126
- package/lib/components/image-picker/index.js.map +1 -1
- package/lib/components/indexes/index.d.ts +29 -0
- package/lib/components/indexes/index.js +255 -198
- package/lib/components/indexes/index.js.map +1 -1
- package/lib/components/input/index.d.ts +17 -0
- package/lib/components/input/index.js +224 -160
- package/lib/components/input/index.js.map +1 -1
- package/lib/components/input-number/index.d.ts +13 -0
- package/lib/components/input-number/index.js +180 -152
- package/lib/components/input-number/index.js.map +1 -1
- package/lib/components/list/index.d.ts +8 -0
- package/lib/components/list/index.js +20 -13
- package/lib/components/list/index.js.map +1 -1
- package/lib/components/list/item/index.d.ts +11 -0
- package/lib/components/list/item/index.js +146 -99
- package/lib/components/list/item/index.js.map +1 -1
- package/lib/components/load-more/index.d.ts +9 -0
- package/lib/components/load-more/index.js +65 -41
- package/lib/components/load-more/index.js.map +1 -1
- package/lib/components/loading/index.d.ts +12 -0
- package/lib/components/loading/index.js +26 -26
- package/lib/components/loading/index.js.map +1 -1
- package/lib/components/message/index.d.ts +15 -0
- package/lib/components/message/index.js +72 -63
- package/lib/components/message/index.js.map +1 -1
- package/lib/components/modal/action/index.d.ts +8 -0
- package/lib/components/modal/action/index.js +20 -14
- package/lib/components/modal/action/index.js.map +1 -1
- package/lib/components/modal/content/index.d.ts +5 -0
- package/lib/components/modal/content/index.js +11 -8
- package/lib/components/modal/content/index.js.map +1 -1
- package/lib/components/modal/header/index.d.ts +5 -0
- package/lib/components/modal/header/index.js +11 -8
- package/lib/components/modal/header/index.js.map +1 -1
- package/lib/components/modal/index.d.ts +15 -0
- package/lib/components/modal/index.js +96 -87
- package/lib/components/modal/index.js.map +1 -1
- package/lib/components/nav-bar/index.d.ts +12 -0
- package/lib/components/nav-bar/index.js +210 -98
- package/lib/components/nav-bar/index.js.map +1 -1
- package/lib/components/noticebar/index.d.ts +16 -0
- package/lib/components/noticebar/index.js +177 -154
- package/lib/components/noticebar/index.js.map +1 -1
- package/lib/components/pagination/index.d.ts +12 -0
- package/lib/components/pagination/index.js +133 -102
- package/lib/components/pagination/index.js.map +1 -1
- package/lib/components/progress/index.d.ts +7 -0
- package/lib/components/progress/index.js +48 -40
- package/lib/components/progress/index.js.map +1 -1
- package/lib/components/radio/index.d.ts +9 -0
- package/lib/components/radio/index.js +48 -37
- package/lib/components/radio/index.js.map +1 -1
- package/lib/components/range/index.d.ts +22 -0
- package/lib/components/range/index.js +197 -142
- package/lib/components/range/index.js.map +1 -1
- package/lib/components/rate/index.d.ts +9 -0
- package/lib/components/rate/index.js +74 -48
- package/lib/components/rate/index.js.map +1 -1
- package/lib/components/search-bar/index.d.ts +16 -0
- package/lib/components/search-bar/index.js +167 -112
- package/lib/components/search-bar/index.js.map +1 -1
- package/lib/components/segmented-control/index.d.ts +9 -0
- package/lib/components/segmented-control/index.js +78 -53
- package/lib/components/segmented-control/index.js.map +1 -1
- package/lib/components/slider/index.d.ts +13 -0
- package/lib/components/slider/index.js +107 -69
- package/lib/components/slider/index.js.map +1 -1
- package/lib/components/steps/index.d.ts +9 -0
- package/lib/components/steps/index.js +61 -44
- package/lib/components/steps/index.js.map +1 -1
- package/lib/components/swipe-action/index.d.ts +27 -0
- package/lib/components/swipe-action/index.js +206 -157
- package/lib/components/swipe-action/index.js.map +1 -1
- package/lib/components/swipe-action/options/index.d.ts +5 -0
- package/lib/components/swipe-action/options/index.js +22 -8
- package/lib/components/swipe-action/options/index.js.map +1 -1
- package/lib/components/switch/index.d.ts +9 -0
- package/lib/components/switch/index.js +53 -42
- package/lib/components/switch/index.js.map +1 -1
- package/lib/components/tab-bar/index.d.ts +9 -0
- package/lib/components/tab-bar/index.js +164 -90
- package/lib/components/tab-bar/index.js.map +1 -1
- package/lib/components/tabs/index.d.ts +24 -0
- package/lib/components/tabs/index.js +203 -174
- package/lib/components/tabs/index.js.map +1 -1
- package/lib/components/tabs-pane/index.d.ts +8 -0
- package/lib/components/tabs-pane/index.js +37 -24
- package/lib/components/tabs-pane/index.js.map +1 -1
- package/lib/components/tag/index.d.ts +9 -0
- package/lib/components/tag/index.js +64 -44
- package/lib/components/tag/index.js.map +1 -1
- package/lib/components/textarea/index.d.ts +13 -0
- package/lib/components/textarea/index.js +132 -86
- package/lib/components/textarea/index.js.map +1 -1
- package/lib/components/timeline/index.d.ts +8 -0
- package/lib/components/timeline/index.js +70 -47
- package/lib/components/timeline/index.js.map +1 -1
- package/lib/components/toast/img.json +6 -3
- package/lib/components/toast/index.d.ts +16 -0
- package/lib/components/toast/index.js +111 -104
- package/lib/components/toast/index.js.map +1 -1
- package/lib/index.d.ts +53 -0
- package/lib/index.js +108 -54
- package/lib/index.js.map +1 -1
- package/{dist → lib}/style/components/grid.scss +2 -2
- package/lib/style/components/index.scss +52 -0
- package/{dist → lib}/style/components/list.scss +2 -2
- package/lib/style/index.css +11754 -0
- package/lib/style/index.css.map +1 -0
- package/lib/style/mixins/index.scss +18 -0
- package/{dist → lib}/style/mixins/libs/shade.scss +4 -2
- package/{dist → lib}/style/mixins/libs/tint.scss +4 -2
- package/{dist → lib}/style/variables/default.scss +1 -1
- package/package.json +24 -32
- package/rn/components/action-sheet/index.tsx +8 -14
- package/rn/components/calendar/ui/date-list/index.tsx +1 -1
- package/rn/components/drawer/index.tsx +15 -15
- package/rn/components/float-layout/index.tsx +3 -2
- package/rn/components/input/index.tsx +14 -7
- package/rn/components/input-number/index.tsx +19 -19
- package/rn/components/message/index.tsx +1 -1
- package/rn/components/swipe-action/index.rn.tsx +4 -2
- package/rn/components/swipe-action/index.tsx +6 -5
- package/rn/components/tab-bar/index.tsx +1 -1
- package/rn/components/tabs/index.tsx +14 -14
- package/rn/components/textarea/index.tsx +2 -2
- package/dist/index.esm.js +0 -8506
- package/dist/index.esm.js.map +0 -1
- package/dist/index.js +0 -8567
- package/dist/index.js.map +0 -1
- package/dist/style/components/accordion.rn.scss +0 -79
- package/dist/style/components/action-sheet.rn.scss +0 -80
- package/dist/style/components/activity-indicator.rn.scss +0 -30
- package/dist/style/components/article.rn.scss +0 -59
- package/dist/style/components/avatar.rn.scss +0 -46
- package/dist/style/components/badge.rn.scss +0 -52
- package/dist/style/components/button.rn.scss +0 -80
- package/dist/style/components/calendar.rn.scss +0 -182
- package/dist/style/components/card.rn.scss +0 -88
- package/dist/style/components/checkbox.rn.scss +0 -108
- package/dist/style/components/countdown.rn.scss +0 -82
- package/dist/style/components/curtain.rn.scss +0 -129
- package/dist/style/components/divider.rn.scss +0 -33
- package/dist/style/components/drawer.rn.scss +0 -72
- package/dist/style/components/fab.rn.scss +0 -38
- package/dist/style/components/flex.rn.scss +0 -159
- package/dist/style/components/float-layout.rn.scss +0 -119
- package/dist/style/components/form.rn.scss +0 -12
- package/dist/style/components/grid.rn.scss +0 -104
- package/dist/style/components/icon.rn.scss +0 -221
- package/dist/style/components/image-picker.rn.scss +0 -108
- package/dist/style/components/index.rn.scss +0 -51
- package/dist/style/components/index.scss +0 -52
- package/dist/style/components/indexes.rn.scss +0 -53
- package/dist/style/components/input-number.rn.scss +0 -82
- package/dist/style/components/input.rn.scss +0 -149
- package/dist/style/components/list.rn.scss +0 -107
- package/dist/style/components/load-more.rn.scss +0 -28
- package/dist/style/components/loading.rn.scss +0 -45
- package/dist/style/components/message.rn.scss +0 -57
- package/dist/style/components/modal.rn.scss +0 -136
- package/dist/style/components/nav-bar.rn.scss +0 -123
- package/dist/style/components/noticebar.rn.scss +0 -111
- package/dist/style/components/pagination.rn.scss +0 -43
- package/dist/style/components/progress.rn.scss +0 -105
- package/dist/style/components/radio.rn.scss +0 -94
- package/dist/style/components/range.rn.scss +0 -52
- package/dist/style/components/rate.rn.scss +0 -48
- package/dist/style/components/search-bar.rn.scss +0 -134
- package/dist/style/components/segmented-control.rn.scss +0 -44
- package/dist/style/components/slider.rn.scss +0 -33
- package/dist/style/components/steps.rn.scss +0 -131
- package/dist/style/components/swipe-action.rn.scss +0 -53
- package/dist/style/components/switch.rn.scss +0 -61
- package/dist/style/components/tab-bar.rn.scss +0 -74
- package/dist/style/components/tabs.rn.scss +0 -205
- package/dist/style/components/tag.rn.scss +0 -74
- package/dist/style/components/textarea.rn.scss +0 -57
- package/dist/style/components/timeline.rn.scss +0 -89
- package/dist/style/components/toast.rn.scss +0 -112
- package/dist/style/index.rn.scss +0 -14
- package/dist/style/mixins/index.rn.scss +0 -18
- package/dist/style/mixins/index.scss +0 -18
- package/dist/style/mixins/libs/absolute-center.rn.scss +0 -9
- package/dist/style/mixins/libs/active.rn.scss +0 -10
- package/dist/style/mixins/libs/alignhack.rn.scss +0 -11
- package/dist/style/mixins/libs/border.rn.scss +0 -48
- package/dist/style/mixins/libs/clearfix.rn.scss +0 -21
- package/dist/style/mixins/libs/disabled.rn.scss +0 -6
- package/dist/style/mixins/libs/flex.rn.scss +0 -49
- package/dist/style/mixins/libs/hairline.rn.scss +0 -209
- package/dist/style/mixins/libs/line.rn.scss +0 -14
- package/dist/style/mixins/libs/overlay.rn.scss +0 -11
- package/dist/style/mixins/libs/placeholder.rn.scss +0 -12
- package/dist/style/mixins/libs/shade.rn.scss +0 -23
- package/dist/style/mixins/libs/tint.rn.scss +0 -23
- package/dist/style/themes/purple.rn.scss +0 -44
- package/dist/style/themes/red.rn.scss +0 -45
- package/dist/style/variables/default.rn.scss +0 -461
- package/types/accordion.d.ts +0 -49
- package/types/action-sheet.d.ts +0 -55
- package/types/activity-indicator.d.ts +0 -33
- package/types/avatar.d.ts +0 -39
- package/types/badge.d.ts +0 -24
- package/types/base.d.ts +0 -26
- package/types/button.d.ts +0 -70
- package/types/calendar.d.ts +0 -225
- package/types/card.d.ts +0 -48
- package/types/checkbox.d.ts +0 -24
- package/types/countdown.d.ts +0 -95
- package/types/curtain.d.ts +0 -26
- package/types/divider.d.ts +0 -33
- package/types/drawer.d.ts +0 -48
- package/types/fab.d.ts +0 -21
- package/types/flex.d.ts +0 -27
- package/types/float-button.d.ts +0 -26
- package/types/float-layout.d.ts +0 -73
- package/types/form.d.ts +0 -26
- package/types/grid.d.ts +0 -51
- package/types/icon.d.ts +0 -12
- package/types/image-picker.d.ts +0 -73
- package/types/index.d.ts +0 -55
- package/types/indexes.d.ts +0 -76
- package/types/input-number.d.ts +0 -89
- package/types/input.d.ts +0 -162
- package/types/list.d.ts +0 -84
- package/types/load-more.d.ts +0 -43
- package/types/message.d.ts +0 -43
- package/types/modal.d.ts +0 -62
- package/types/nav-bar.d.ts +0 -65
- package/types/noticebar.d.ts +0 -65
- package/types/pagination.d.ts +0 -51
- package/types/progress.d.ts +0 -30
- package/types/radio.d.ts +0 -47
- package/types/range.d.ts +0 -63
- package/types/rate.d.ts +0 -34
- package/types/search-bar.d.ts +0 -105
- package/types/segmented-control.d.ts +0 -44
- package/types/slider.d.ts +0 -73
- package/types/steps.d.ts +0 -69
- package/types/swipe-action.d.ts +0 -86
- package/types/switch.d.ts +0 -38
- package/types/tab-bar.d.ts +0 -98
- package/types/tabs-pane.d.ts +0 -25
- package/types/tabs.d.ts +0 -62
- package/types/tag.d.ts +0 -48
- package/types/textarea.d.ts +0 -113
- package/types/timeline.d.ts +0 -46
- package/types/toast.d.ts +0 -53
- /package/{dist → lib}/style/components/accordion.scss +0 -0
- /package/{dist → lib}/style/components/action-sheet.scss +0 -0
- /package/{dist → lib}/style/components/activity-indicator.scss +0 -0
- /package/{dist → lib}/style/components/article.scss +0 -0
- /package/{dist → lib}/style/components/avatar.scss +0 -0
- /package/{dist → lib}/style/components/badge.scss +0 -0
- /package/{dist → lib}/style/components/button.scss +0 -0
- /package/{dist → lib}/style/components/calendar.scss +0 -0
- /package/{dist → lib}/style/components/card.scss +0 -0
- /package/{dist → lib}/style/components/checkbox.scss +0 -0
- /package/{dist → lib}/style/components/countdown.scss +0 -0
- /package/{dist → lib}/style/components/curtain.scss +0 -0
- /package/{dist → lib}/style/components/divider.scss +0 -0
- /package/{dist → lib}/style/components/drawer.scss +0 -0
- /package/{dist → lib}/style/components/fab.scss +0 -0
- /package/{dist → lib}/style/components/flex.scss +0 -0
- /package/{dist → lib}/style/components/float-layout.scss +0 -0
- /package/{dist → lib}/style/components/form.scss +0 -0
- /package/{dist → lib}/style/components/icon.scss +0 -0
- /package/{dist → lib}/style/components/image-picker.scss +0 -0
- /package/{dist → lib}/style/components/indexes.scss +0 -0
- /package/{dist → lib}/style/components/input-number.scss +0 -0
- /package/{dist → lib}/style/components/input.scss +0 -0
- /package/{dist → lib}/style/components/load-more.scss +0 -0
- /package/{dist → lib}/style/components/loading.scss +0 -0
- /package/{dist → lib}/style/components/message.scss +0 -0
- /package/{dist → lib}/style/components/modal.scss +0 -0
- /package/{dist → lib}/style/components/nav-bar.scss +0 -0
- /package/{dist → lib}/style/components/noticebar.scss +0 -0
- /package/{dist → lib}/style/components/pagination.scss +0 -0
- /package/{dist → lib}/style/components/progress.scss +0 -0
- /package/{dist → lib}/style/components/radio.scss +0 -0
- /package/{dist → lib}/style/components/range.scss +0 -0
- /package/{dist → lib}/style/components/rate.scss +0 -0
- /package/{dist → lib}/style/components/search-bar.scss +0 -0
- /package/{dist → lib}/style/components/segmented-control.scss +0 -0
- /package/{dist → lib}/style/components/slider.scss +0 -0
- /package/{dist → lib}/style/components/steps.scss +0 -0
- /package/{dist → lib}/style/components/swipe-action.scss +0 -0
- /package/{dist → lib}/style/components/switch.scss +0 -0
- /package/{dist → lib}/style/components/tab-bar.scss +0 -0
- /package/{dist → lib}/style/components/tabs.scss +0 -0
- /package/{dist → lib}/style/components/tag.scss +0 -0
- /package/{dist → lib}/style/components/textarea.scss +0 -0
- /package/{dist → lib}/style/components/timeline.scss +0 -0
- /package/{dist → lib}/style/components/toast.scss +0 -0
- /package/{dist → lib}/style/index.scss +0 -0
- /package/{dist → lib}/style/mixins/libs/absolute-center.scss +0 -0
- /package/{dist → lib}/style/mixins/libs/active.scss +0 -0
- /package/{dist → lib}/style/mixins/libs/alignhack.scss +0 -0
- /package/{dist → lib}/style/mixins/libs/border.scss +0 -0
- /package/{dist → lib}/style/mixins/libs/clearfix.scss +0 -0
- /package/{dist → lib}/style/mixins/libs/disabled.scss +0 -0
- /package/{dist → lib}/style/mixins/libs/flex.scss +0 -0
- /package/{dist → lib}/style/mixins/libs/hairline.scss +0 -0
- /package/{dist → lib}/style/mixins/libs/line.scss +0 -0
- /package/{dist → lib}/style/mixins/libs/overlay.scss +0 -0
- /package/{dist → lib}/style/mixins/libs/placeholder.scss +0 -0
- /package/{dist → lib}/style/themes/purple.scss +0 -0
- /package/{dist → lib}/style/themes/red.scss +0 -0
|
@@ -1,163 +1,186 @@
|
|
|
1
|
-
import classNames from
|
|
2
|
-
import PropTypes from
|
|
3
|
-
import React from
|
|
4
|
-
import { Text, View } from
|
|
5
|
-
import Taro from
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
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
|
-
|
|
23
|
-
|
|
24
|
-
|
|
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
|
-
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
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
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
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
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
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,C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AAE,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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AA;AAAA,QAE/B,oCAAC,QAAK,WAAU,yBAAwB;AAAA,MAC1C;AAAA,MAEF,oCAAC,QAAK,WAAU,2BACb,QACC,oCAAC,QAAK,WAAU,gCAEd,oCAAC,QAAK,WAAW,WAAW,WAAW,SAAS,GAAG,CACrD,GAEF,oCAAC,QAAK,WAAU,gCACd;AAAA,QAAC;AAAA;AAAA,UACC,IAAI;AAAA,UACJ,WAAW;AAAA,UACX,WAAW,WAAW,cAAc;AAAA,UACpC;AAAA;AAAA,QAEC,KAAK,MAAM;AAAA,MACd,CACF,CACF;AAAA,MACC,YACC;AAAA,QAAC;AAAA;AAAA,UACC,WAAU;AAAA,UACV,SAAS,KAAK,WAAW,KAAK,IAAI;AAAA;AAAA,QAElC,oCAAC,QAAK,WAAU,UAAQ,QAAS;AAAA,QACjC,oCAAC,QAAK,WAAU,6BACd,oCAAC,QAAK,WAAU,iCAAgC,CAClD;AAAA,MACF;AAAA,IAEJ;AAAA,EAGN;AACF;AAEA,YAAY,eAAe;AAAA,EACzB,OAAO;AAAA,EACP,QAAQ;AAAA,EACR,SAAS;AAAA,EACT,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
|
|
2
|
-
import PropTypes from
|
|
3
|
-
import React from
|
|
4
|
-
import { Text, View } from
|
|
5
|
-
import AtButton from
|
|
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
|
-
|
|
9
|
-
|
|
10
|
-
return maxPage;
|
|
8
|
+
if (maxPage <= 0) return MIN_MAXPAGE;
|
|
9
|
+
return maxPage;
|
|
11
10
|
};
|
|
12
11
|
const createPickerRange = (max) => {
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
const range = new Array(max).fill(0).map((_val, index) => index + 1);
|
|
13
|
+
return range;
|
|
15
14
|
};
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
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
|
-
|
|
28
|
-
|
|
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
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
129
|
+
current: 1,
|
|
130
|
+
total: 0,
|
|
131
|
+
pageSize: 20,
|
|
132
|
+
icon: false,
|
|
133
|
+
customStyle: {}
|
|
106
134
|
};
|
|
107
135
|
AtPagination.propTypes = {
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
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
|