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,190 +1,219 @@
|
|
|
1
|
-
import classNames from
|
|
2
|
-
import PropTypes from
|
|
3
|
-
import React from
|
|
4
|
-
import { ScrollView, View } from
|
|
5
|
-
import Taro from
|
|
6
|
-
import { isTest, mergeStyle, uuid } from
|
|
1
|
+
import classNames from "classnames";
|
|
2
|
+
import PropTypes from "prop-types";
|
|
3
|
+
import React from "react";
|
|
4
|
+
import { ScrollView, View } from "@tarojs/components";
|
|
5
|
+
import Taro from "@tarojs/taro";
|
|
6
|
+
import { isTest, mergeStyle, uuid } from "../../common/utils";
|
|
7
7
|
const ENV = Taro.getEnv();
|
|
8
8
|
const MIN_DISTANCE = 100;
|
|
9
9
|
const MAX_INTERVAL = 10;
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
break;
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
};
|
|
43
|
-
this.state = {
|
|
44
|
-
_scrollLeft: 0,
|
|
45
|
-
_scrollTop: 0,
|
|
46
|
-
_scrollIntoView: ''
|
|
47
|
-
};
|
|
48
|
-
this._tabId = isTest() ? 'tabs-AOTU2018' : uuid();
|
|
49
|
-
// 触摸时的原点
|
|
50
|
-
this._touchDot = 0;
|
|
51
|
-
// 定时器
|
|
52
|
-
this._timer = null;
|
|
53
|
-
// 滑动时间间隔
|
|
54
|
-
this._interval = 0;
|
|
55
|
-
// 是否已经在滑动
|
|
56
|
-
this._isMoving = false;
|
|
57
|
-
}
|
|
58
|
-
handleClick(index, event) {
|
|
59
|
-
this.props.onClick(index, event);
|
|
60
|
-
}
|
|
61
|
-
handleTouchStart(e) {
|
|
62
|
-
const { swipeable, tabDirection } = this.props;
|
|
63
|
-
if (!swipeable || tabDirection === 'vertical')
|
|
64
|
-
return;
|
|
65
|
-
// 获取触摸时的原点
|
|
66
|
-
this._touchDot = e.touches[0].pageX;
|
|
67
|
-
// 使用js计时器记录时间
|
|
68
|
-
this._timer = setInterval(() => {
|
|
69
|
-
this._interval++;
|
|
70
|
-
}, 100);
|
|
71
|
-
}
|
|
72
|
-
handleTouchMove(e) {
|
|
73
|
-
const { swipeable, tabDirection, current, tabList } = this.props;
|
|
74
|
-
if (!swipeable || tabDirection === 'vertical')
|
|
75
|
-
return;
|
|
76
|
-
const touchMove = e.touches[0].pageX;
|
|
77
|
-
const moveDistance = touchMove - this._touchDot;
|
|
78
|
-
const maxIndex = tabList.length;
|
|
79
|
-
if (!this._isMoving &&
|
|
80
|
-
this._interval < MAX_INTERVAL &&
|
|
81
|
-
this._touchDot > 20) {
|
|
82
|
-
// 向左滑动
|
|
83
|
-
if (current + 1 < maxIndex && moveDistance <= -MIN_DISTANCE) {
|
|
84
|
-
this._isMoving = true;
|
|
85
|
-
this.handleClick(current + 1, e);
|
|
86
|
-
// 向右滑动
|
|
87
|
-
}
|
|
88
|
-
else if (current - 1 >= 0 && moveDistance >= MIN_DISTANCE) {
|
|
89
|
-
this._isMoving = true;
|
|
90
|
-
this.handleClick(current - 1, e);
|
|
91
|
-
}
|
|
10
|
+
class AtTabs extends React.Component {
|
|
11
|
+
constructor(props) {
|
|
12
|
+
super(props);
|
|
13
|
+
this.updateState = (idx) => {
|
|
14
|
+
if (this.props.scroll) {
|
|
15
|
+
switch (ENV) {
|
|
16
|
+
case Taro.ENV_TYPE.WEAPP:
|
|
17
|
+
case Taro.ENV_TYPE.ALIPAY:
|
|
18
|
+
case Taro.ENV_TYPE.SWAN: {
|
|
19
|
+
const index = Math.max(idx - 1, 0);
|
|
20
|
+
this.setState({
|
|
21
|
+
_scrollIntoView: `tab${this._tabId}${index}`
|
|
22
|
+
});
|
|
23
|
+
break;
|
|
24
|
+
}
|
|
25
|
+
case Taro.ENV_TYPE.WEB: {
|
|
26
|
+
const index = Math.max(idx - 1, 0);
|
|
27
|
+
const prevTabItem = this.tabHeaderRef.children[index];
|
|
28
|
+
prevTabItem && this.setState({
|
|
29
|
+
_scrollTop: prevTabItem.offsetTop,
|
|
30
|
+
_scrollLeft: prevTabItem.offsetLeft
|
|
31
|
+
});
|
|
32
|
+
break;
|
|
33
|
+
}
|
|
34
|
+
default: {
|
|
35
|
+
console.warn("AtTab \u7EC4\u4EF6\u5728\u8BE5\u73AF\u5883\u8FD8\u672A\u9002\u914D");
|
|
36
|
+
break;
|
|
37
|
+
}
|
|
92
38
|
}
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
this.state = {
|
|
42
|
+
_scrollLeft: 0,
|
|
43
|
+
_scrollTop: 0,
|
|
44
|
+
_scrollIntoView: ""
|
|
45
|
+
};
|
|
46
|
+
this._tabId = isTest() ? "tabs-AOTU2018" : uuid();
|
|
47
|
+
this._touchDot = 0;
|
|
48
|
+
this._timer = null;
|
|
49
|
+
this._interval = 0;
|
|
50
|
+
this._isMoving = false;
|
|
51
|
+
}
|
|
52
|
+
handleClick(index, event) {
|
|
53
|
+
this.props.onClick(index, event);
|
|
54
|
+
}
|
|
55
|
+
handleTouchStart(e) {
|
|
56
|
+
const { swipeable, tabDirection } = this.props;
|
|
57
|
+
if (!swipeable || tabDirection === "vertical") return;
|
|
58
|
+
this._touchDot = e.touches[0].pageX;
|
|
59
|
+
this._timer = setInterval(() => {
|
|
60
|
+
this._interval++;
|
|
61
|
+
}, 100);
|
|
62
|
+
}
|
|
63
|
+
handleTouchMove(e) {
|
|
64
|
+
const { swipeable, tabDirection, current, tabList } = this.props;
|
|
65
|
+
if (!swipeable || tabDirection === "vertical") return;
|
|
66
|
+
const touchMove = e.touches[0].pageX;
|
|
67
|
+
const moveDistance = touchMove - this._touchDot;
|
|
68
|
+
const maxIndex = tabList.length;
|
|
69
|
+
if (!this._isMoving && this._interval < MAX_INTERVAL && this._touchDot > 20) {
|
|
70
|
+
if (current + 1 < maxIndex && moveDistance <= -MIN_DISTANCE) {
|
|
71
|
+
this._isMoving = true;
|
|
72
|
+
this.handleClick(current + 1, e);
|
|
73
|
+
} else if (current - 1 >= 0 && moveDistance >= MIN_DISTANCE) {
|
|
74
|
+
this._isMoving = true;
|
|
75
|
+
this.handleClick(current - 1, e);
|
|
76
|
+
}
|
|
93
77
|
}
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
78
|
+
}
|
|
79
|
+
handleTouchEnd() {
|
|
80
|
+
const { swipeable, tabDirection } = this.props;
|
|
81
|
+
if (!swipeable || tabDirection === "vertical") return;
|
|
82
|
+
this._timer && clearInterval(this._timer);
|
|
83
|
+
this._interval = 0;
|
|
84
|
+
this._isMoving = false;
|
|
85
|
+
}
|
|
86
|
+
getTabHeaderRef() {
|
|
87
|
+
if (ENV === Taro.ENV_TYPE.WEB) {
|
|
88
|
+
this.tabHeaderRef = document.getElementById(this._tabId);
|
|
101
89
|
}
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
90
|
+
}
|
|
91
|
+
UNSAFE_componentWillReceiveProps(nextProps) {
|
|
92
|
+
if (nextProps.scroll !== this.props.scroll) {
|
|
93
|
+
this.getTabHeaderRef();
|
|
106
94
|
}
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
this.getTabHeaderRef();
|
|
110
|
-
}
|
|
111
|
-
if (nextProps.current !== this.props.current) {
|
|
112
|
-
this.updateState(nextProps.current);
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
componentDidMount() {
|
|
116
|
-
this.getTabHeaderRef();
|
|
117
|
-
this.updateState(this.props.current);
|
|
95
|
+
if (nextProps.current !== this.props.current) {
|
|
96
|
+
this.updateState(nextProps.current);
|
|
118
97
|
}
|
|
119
|
-
|
|
120
|
-
|
|
98
|
+
}
|
|
99
|
+
componentDidMount() {
|
|
100
|
+
this.getTabHeaderRef();
|
|
101
|
+
this.updateState(this.props.current);
|
|
102
|
+
}
|
|
103
|
+
componentWillUnmount() {
|
|
104
|
+
this.tabHeaderRef = null;
|
|
105
|
+
}
|
|
106
|
+
render() {
|
|
107
|
+
const {
|
|
108
|
+
customStyle = "",
|
|
109
|
+
className,
|
|
110
|
+
height,
|
|
111
|
+
tabDirection,
|
|
112
|
+
animated,
|
|
113
|
+
tabList,
|
|
114
|
+
scroll,
|
|
115
|
+
current
|
|
116
|
+
} = this.props;
|
|
117
|
+
const { _scrollLeft, _scrollTop, _scrollIntoView } = this.state;
|
|
118
|
+
const heightStyle = { height };
|
|
119
|
+
const underlineStyle = {
|
|
120
|
+
height: tabDirection === "vertical" ? `${tabList.length * 100}%` : "1PX",
|
|
121
|
+
width: tabDirection === "horizontal" ? `${tabList.length * 100}%` : "1PX"
|
|
122
|
+
};
|
|
123
|
+
const bodyStyle = {};
|
|
124
|
+
let transformStyle = `translate3d(0px, -${current * 100}%, 0px)`;
|
|
125
|
+
if (tabDirection === "horizontal") {
|
|
126
|
+
transformStyle = `translate3d(-${current * 100}%, 0px, 0px)`;
|
|
121
127
|
}
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
height: tabDirection === 'vertical' ? `${tabList.length * 100}%` : '1PX',
|
|
128
|
-
width: tabDirection === 'horizontal' ? `${tabList.length * 100}%` : '1PX'
|
|
129
|
-
};
|
|
130
|
-
const bodyStyle = {};
|
|
131
|
-
let transformStyle = `translate3d(0px, -${current * 100}%, 0px)`;
|
|
132
|
-
if (tabDirection === 'horizontal') {
|
|
133
|
-
transformStyle = `translate3d(-${current * 100}%, 0px, 0px)`;
|
|
134
|
-
}
|
|
135
|
-
Object.assign(bodyStyle, {
|
|
136
|
-
transform: transformStyle
|
|
137
|
-
});
|
|
138
|
-
if (!animated) {
|
|
139
|
-
bodyStyle.transition = 'unset';
|
|
140
|
-
}
|
|
141
|
-
const tabItems = tabList.map((item, idx) => {
|
|
142
|
-
const itemCls = classNames({
|
|
143
|
-
'at-tabs__item': true,
|
|
144
|
-
'at-tabs__item--active': current === idx
|
|
145
|
-
});
|
|
146
|
-
return (React.createElement(View, { className: itemCls, id: `tab${this._tabId}${idx}`, key: `at-tabs-item-${idx}`, onClick: this.handleClick.bind(this, idx) },
|
|
147
|
-
item.title,
|
|
148
|
-
React.createElement(View, { className: 'at-tabs__item-underline' })));
|
|
149
|
-
});
|
|
150
|
-
const rootCls = classNames({
|
|
151
|
-
'at-tabs': true,
|
|
152
|
-
'at-tabs--scroll': scroll,
|
|
153
|
-
[`at-tabs--${tabDirection}`]: true,
|
|
154
|
-
[`at-tabs--${ENV}`]: true
|
|
155
|
-
}, className);
|
|
156
|
-
const scrollX = tabDirection === 'horizontal';
|
|
157
|
-
const scrollY = tabDirection === 'vertical';
|
|
158
|
-
return (React.createElement(View, { className: rootCls, style: mergeStyle(heightStyle, customStyle) },
|
|
159
|
-
scroll ? (React.createElement(ScrollView, { id: this._tabId, className: 'at-tabs__header', style: heightStyle, scrollX: scrollX, scrollY: scrollY, scrollWithAnimation: true, scrollLeft: _scrollLeft, scrollTop: _scrollTop, scrollIntoView: _scrollIntoView }, tabItems)) : (React.createElement(View, { id: this._tabId, className: 'at-tabs__header' }, tabItems)),
|
|
160
|
-
React.createElement(View, { className: 'at-tabs__body', onTouchStart: this.handleTouchStart.bind(this), onTouchEnd: this.handleTouchEnd.bind(this), onTouchMove: this.handleTouchMove.bind(this), style: mergeStyle(bodyStyle, heightStyle) },
|
|
161
|
-
React.createElement(View, { className: 'at-tabs__underline', style: underlineStyle }),
|
|
162
|
-
this.props.children)));
|
|
128
|
+
Object.assign(bodyStyle, {
|
|
129
|
+
transform: transformStyle
|
|
130
|
+
});
|
|
131
|
+
if (!animated) {
|
|
132
|
+
bodyStyle.transition = "unset";
|
|
163
133
|
}
|
|
134
|
+
const tabItems = tabList.map((item, idx) => {
|
|
135
|
+
const itemCls = classNames({
|
|
136
|
+
"at-tabs__item": true,
|
|
137
|
+
"at-tabs__item--active": current === idx
|
|
138
|
+
});
|
|
139
|
+
return /* @__PURE__ */ React.createElement(
|
|
140
|
+
View,
|
|
141
|
+
{
|
|
142
|
+
className: itemCls,
|
|
143
|
+
id: `tab${this._tabId}${idx}`,
|
|
144
|
+
key: `at-tabs-item-${idx}`,
|
|
145
|
+
onClick: this.handleClick.bind(this, idx)
|
|
146
|
+
},
|
|
147
|
+
item.title,
|
|
148
|
+
/* @__PURE__ */ React.createElement(View, { className: "at-tabs__item-underline" })
|
|
149
|
+
);
|
|
150
|
+
});
|
|
151
|
+
const rootCls = classNames(
|
|
152
|
+
{
|
|
153
|
+
"at-tabs": true,
|
|
154
|
+
"at-tabs--scroll": scroll,
|
|
155
|
+
[`at-tabs--${tabDirection}`]: true,
|
|
156
|
+
[`at-tabs--${ENV}`]: true
|
|
157
|
+
},
|
|
158
|
+
className
|
|
159
|
+
);
|
|
160
|
+
const scrollX = tabDirection === "horizontal";
|
|
161
|
+
const scrollY = tabDirection === "vertical";
|
|
162
|
+
return /* @__PURE__ */ React.createElement(View, { className: rootCls, style: mergeStyle(heightStyle, customStyle) }, scroll ? /* @__PURE__ */ React.createElement(
|
|
163
|
+
ScrollView,
|
|
164
|
+
{
|
|
165
|
+
id: this._tabId,
|
|
166
|
+
className: "at-tabs__header",
|
|
167
|
+
style: heightStyle,
|
|
168
|
+
scrollX,
|
|
169
|
+
scrollY,
|
|
170
|
+
scrollWithAnimation: true,
|
|
171
|
+
scrollLeft: _scrollLeft,
|
|
172
|
+
scrollTop: _scrollTop,
|
|
173
|
+
scrollIntoView: _scrollIntoView
|
|
174
|
+
},
|
|
175
|
+
tabItems
|
|
176
|
+
) : /* @__PURE__ */ React.createElement(View, { id: this._tabId, className: "at-tabs__header" }, tabItems), /* @__PURE__ */ React.createElement(
|
|
177
|
+
View,
|
|
178
|
+
{
|
|
179
|
+
className: "at-tabs__body",
|
|
180
|
+
onTouchStart: this.handleTouchStart.bind(this),
|
|
181
|
+
onTouchEnd: this.handleTouchEnd.bind(this),
|
|
182
|
+
onTouchMove: this.handleTouchMove.bind(this),
|
|
183
|
+
style: mergeStyle(bodyStyle, heightStyle)
|
|
184
|
+
},
|
|
185
|
+
/* @__PURE__ */ React.createElement(View, { className: "at-tabs__underline", style: underlineStyle }),
|
|
186
|
+
this.props.children
|
|
187
|
+
));
|
|
188
|
+
}
|
|
164
189
|
}
|
|
165
190
|
AtTabs.defaultProps = {
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
191
|
+
customStyle: "",
|
|
192
|
+
className: "",
|
|
193
|
+
tabDirection: "horizontal",
|
|
194
|
+
height: "",
|
|
195
|
+
current: 0,
|
|
196
|
+
swipeable: true,
|
|
197
|
+
scroll: false,
|
|
198
|
+
animated: true,
|
|
199
|
+
tabList: [],
|
|
200
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
201
|
+
onClick: () => {
|
|
202
|
+
}
|
|
177
203
|
};
|
|
178
204
|
AtTabs.propTypes = {
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
205
|
+
customStyle: PropTypes.oneOfType([PropTypes.object, PropTypes.string]),
|
|
206
|
+
className: PropTypes.oneOfType([PropTypes.array, PropTypes.string]),
|
|
207
|
+
height: PropTypes.string,
|
|
208
|
+
tabDirection: PropTypes.oneOf(["horizontal", "vertical"]),
|
|
209
|
+
current: PropTypes.number,
|
|
210
|
+
swipeable: PropTypes.bool,
|
|
211
|
+
scroll: PropTypes.bool,
|
|
212
|
+
animated: PropTypes.bool,
|
|
213
|
+
tabList: PropTypes.array,
|
|
214
|
+
onClick: PropTypes.func
|
|
215
|
+
};
|
|
216
|
+
export {
|
|
217
|
+
AtTabs as default
|
|
189
218
|
};
|
|
190
219
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/tabs/index.tsx"],"names":[],"mappings":"AAAA,OAAO,UAAU,MAAM,YAAY,CAAA;AACnC,OAAO,SAAyB,MAAM,YAAY,CAAA;AAClD,OAAO,KAAK,MAAM,OAAO,CA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ACxB,CAAA;AAED,MAAM,CAAC,SAAS,GAAG;IACjB,WAAW,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC,SAAS,CAAC,MAAM,EAAE,SAAS,CAAC,MAAM,CAAC,CAAC;IACtE,SAAS,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC,SAAS,CAAC,KAAK,EAAE,SAAS,CAAC,MAAM,CAAC,CAAC;IACnE,MAAM,EAAE,SAAS,CAAC,MAAM;IACxB,YAAY,EAAE,SAAS,CAAC,KAAK,CAAC,CAAC,YAAY,EAAE,UAAU,CAAC,CAAC;IACzD,OAAO,EAAE,SAAS,CAAC,MAAM;IACzB,SAAS,EAAE,SAAS,CAAC,IAAI;IACzB,MAAM,EAAE,SAAS,CAAC,IAAI;IACtB,QAAQ,EAAE,SAAS,CAAC,IAAI;IACxB,OAAO,EAAE,SAAS,CAAC,KAAK;IACxB,OAAO,EAAE,SAAS,CAAC,IAAI;CACxB,CAAA"}
|
|
1
|
+
{"version":3,"sources":["../../../src/components/tabs/index.tsx"],"sourcesContent":["import classNames from 'classnames'\nimport PropTypes, { InferProps } from 'prop-types'\nimport React from 'react'\nimport { ScrollView, View } from '@tarojs/components'\nimport { CommonEvent, ITouchEvent } from '@tarojs/components/types/common'\nimport Taro from '@tarojs/taro'\nimport { AtTabsProps, AtTabsState } from '../../../types/tabs'\nimport { isTest, mergeStyle, uuid } from '../../common/utils'\n\nconst ENV = Taro.getEnv()\nconst MIN_DISTANCE = 100\nconst MAX_INTERVAL = 10\n\nexport default class AtTabs extends React.Component<AtTabsProps, AtTabsState> {\n public static defaultProps: AtTabsProps\n public static propTypes: InferProps<AtTabsProps>\n\n private _tabId: string\n private _touchDot: number\n private _timer: ReturnType<typeof setInterval> | null\n private _interval: number\n private _isMoving: boolean\n private tabHeaderRef: any\n\n public constructor(props: AtTabsProps) {\n super(props)\n this.state = {\n _scrollLeft: 0,\n _scrollTop: 0,\n _scrollIntoView: ''\n }\n this._tabId = isTest() ? 'tabs-AOTU2018' : uuid()\n // 触摸时的原点\n this._touchDot = 0\n // 定时器\n this._timer = null\n // 滑动时间间隔\n this._interval = 0\n // 是否已经在滑动\n this._isMoving = false\n }\n\n private updateState = (idx: number): void => {\n if (this.props.scroll) {\n // 标签栏滚动\n switch (ENV) {\n case Taro.ENV_TYPE.WEAPP:\n case Taro.ENV_TYPE.ALIPAY:\n case Taro.ENV_TYPE.SWAN: {\n const index = Math.max(idx - 1, 0)\n this.setState({\n _scrollIntoView: `tab${this._tabId}${index}`\n })\n break\n }\n case Taro.ENV_TYPE.WEB: {\n const index = Math.max(idx - 1, 0)\n const prevTabItem = this.tabHeaderRef.children[index]\n prevTabItem &&\n this.setState({\n _scrollTop: prevTabItem.offsetTop,\n _scrollLeft: prevTabItem.offsetLeft\n })\n break\n }\n default: {\n console.warn('AtTab 组件在该环境还未适配')\n break\n }\n }\n }\n }\n\n private handleClick(index: number, event: CommonEvent): void {\n this.props.onClick(index, event)\n }\n\n private handleTouchStart(e: ITouchEvent): void {\n const { swipeable, tabDirection } = this.props\n if (!swipeable || tabDirection === 'vertical') return\n // 获取触摸时的原点\n this._touchDot = e.touches[0].pageX\n // 使用js计时器记录时间\n this._timer = setInterval(() => {\n this._interval++\n }, 100)\n }\n\n private handleTouchMove(e: ITouchEvent): void {\n const { swipeable, tabDirection, current, tabList } = this.props\n if (!swipeable || tabDirection === 'vertical') return\n\n const touchMove = e.touches[0].pageX\n const moveDistance = touchMove - this._touchDot\n const maxIndex = tabList.length\n\n if (\n !this._isMoving &&\n this._interval < MAX_INTERVAL &&\n this._touchDot > 20\n ) {\n // 向左滑动\n if (current + 1 < maxIndex && moveDistance <= -MIN_DISTANCE) {\n this._isMoving = true\n this.handleClick(current + 1, e)\n\n // 向右滑动\n } else if (current - 1 >= 0 && moveDistance >= MIN_DISTANCE) {\n this._isMoving = true\n this.handleClick(current - 1, e)\n }\n }\n }\n\n private handleTouchEnd(): void {\n const { swipeable, tabDirection } = this.props\n if (!swipeable || tabDirection === 'vertical') return\n\n this._timer && clearInterval(this._timer)\n this._interval = 0\n this._isMoving = false\n }\n\n private getTabHeaderRef(): void {\n if (ENV === Taro.ENV_TYPE.WEB) {\n this.tabHeaderRef = document.getElementById(this._tabId)\n }\n }\n\n public UNSAFE_componentWillReceiveProps(nextProps: AtTabsProps): void {\n if (nextProps.scroll !== this.props.scroll) {\n this.getTabHeaderRef()\n }\n if (nextProps.current !== this.props.current) {\n this.updateState(nextProps.current)\n }\n }\n\n public componentDidMount(): void {\n this.getTabHeaderRef()\n this.updateState(this.props.current)\n }\n\n public componentWillUnmount(): void {\n this.tabHeaderRef = null\n }\n\n public render(): JSX.Element {\n const {\n customStyle = '',\n className,\n height,\n tabDirection,\n animated,\n tabList,\n scroll,\n current\n } = this.props\n const { _scrollLeft, _scrollTop, _scrollIntoView } = this.state\n\n const heightStyle = { height }\n const underlineStyle = {\n height: tabDirection === 'vertical' ? `${tabList.length * 100}%` : '1PX',\n width: tabDirection === 'horizontal' ? `${tabList.length * 100}%` : '1PX'\n }\n const bodyStyle: React.CSSProperties = {}\n let transformStyle = `translate3d(0px, -${current * 100}%, 0px)`\n if (tabDirection === 'horizontal') {\n transformStyle = `translate3d(-${current * 100}%, 0px, 0px)`\n }\n Object.assign(bodyStyle, {\n transform: transformStyle\n })\n if (!animated) {\n bodyStyle.transition = 'unset'\n }\n\n const tabItems = tabList.map((item, idx) => {\n const itemCls = classNames({\n 'at-tabs__item': true,\n 'at-tabs__item--active': current === idx\n })\n\n return (\n <View\n className={itemCls}\n id={`tab${this._tabId}${idx}`}\n key={`at-tabs-item-${idx}`}\n onClick={this.handleClick.bind(this, idx)}\n >\n {item.title}\n <View className='at-tabs__item-underline'></View>\n </View>\n )\n })\n const rootCls = classNames(\n {\n 'at-tabs': true,\n 'at-tabs--scroll': scroll,\n [`at-tabs--${tabDirection}`]: true,\n [`at-tabs--${ENV}`]: true\n },\n className\n )\n const scrollX = tabDirection === 'horizontal'\n const scrollY = tabDirection === 'vertical'\n\n return (\n <View className={rootCls} style={mergeStyle(heightStyle, customStyle)}>\n {scroll ? (\n <ScrollView\n id={this._tabId}\n className='at-tabs__header'\n style={heightStyle}\n scrollX={scrollX}\n scrollY={scrollY}\n scrollWithAnimation\n scrollLeft={_scrollLeft}\n scrollTop={_scrollTop}\n scrollIntoView={_scrollIntoView}\n >\n {tabItems}\n </ScrollView>\n ) : (\n <View id={this._tabId} className='at-tabs__header'>\n {tabItems}\n </View>\n )}\n <View\n className='at-tabs__body'\n onTouchStart={this.handleTouchStart.bind(this)}\n onTouchEnd={this.handleTouchEnd.bind(this)}\n onTouchMove={this.handleTouchMove.bind(this)}\n style={mergeStyle(bodyStyle, heightStyle)}\n >\n <View className='at-tabs__underline' style={underlineStyle}></View>\n {this.props.children}\n </View>\n </View>\n )\n }\n}\n\nAtTabs.defaultProps = {\n customStyle: '',\n className: '',\n tabDirection: 'horizontal',\n height: '',\n current: 0,\n swipeable: true,\n scroll: false,\n animated: true,\n tabList: [],\n // eslint-disable-next-line @typescript-eslint/no-empty-function\n onClick: (): void => {}\n}\n\nAtTabs.propTypes = {\n customStyle: PropTypes.oneOfType([PropTypes.object, PropTypes.string]),\n className: PropTypes.oneOfType([PropTypes.array, PropTypes.string]),\n height: PropTypes.string,\n tabDirection: PropTypes.oneOf(['horizontal', 'vertical']),\n current: PropTypes.number,\n swipeable: PropTypes.bool,\n scroll: PropTypes.bool,\n animated: PropTypes.bool,\n tabList: PropTypes.array,\n onClick: PropTypes.func\n}\n"],"mappings":"AAAA,OAAO,gBAAgB;AACvB,OAAO,eAA+B;AACtC,OAAO,WAAW;AAClB,SAAS,YAAY,YAAY;AAEjC,OAAO,UAAU;AAEjB,SAAS,QAAQ,YAAY,YAAY;AAEzC,MAAM,MAAM,KAAK,OAAO;AACxB,MAAM,eAAe;AACrB,MAAM,eAAe;AAErB,MAAO,eAA6B,MAAM,UAAoC;AAAA,EAWrE,YAAY,OAAoB;AACrC,UAAM,KAAK;AAiBb,SAAQ,cAAc,CAAC,QAAs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
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { InferProps } from 'prop-types';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { AtTabsPaneProps } from '../../../types/tabs-pane';
|
|
4
|
+
export default class AtTabsPane extends React.Component<AtTabsPaneProps> {
|
|
5
|
+
static defaultProps: AtTabsPaneProps;
|
|
6
|
+
static propTypes: InferProps<AtTabsPaneProps>;
|
|
7
|
+
render(): JSX.Element;
|
|
8
|
+
}
|
|
@@ -1,30 +1,43 @@
|
|
|
1
|
-
import classNames from
|
|
2
|
-
import PropTypes from
|
|
3
|
-
import React from
|
|
4
|
-
import { View } from
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
1
|
+
import classNames from "classnames";
|
|
2
|
+
import PropTypes from "prop-types";
|
|
3
|
+
import React from "react";
|
|
4
|
+
import { View } from "@tarojs/components";
|
|
5
|
+
class AtTabsPane extends React.Component {
|
|
6
|
+
render() {
|
|
7
|
+
const { customStyle, className, tabDirection, index, current } = this.props;
|
|
8
|
+
return /* @__PURE__ */ React.createElement(
|
|
9
|
+
View,
|
|
10
|
+
{
|
|
11
|
+
className: classNames(
|
|
12
|
+
{
|
|
13
|
+
"at-tabs-pane": true,
|
|
14
|
+
"at-tabs-pane--vertical": tabDirection === "vertical",
|
|
15
|
+
"at-tabs-pane--active": index === current,
|
|
16
|
+
"at-tabs-pane--inactive": index !== current
|
|
17
|
+
},
|
|
18
|
+
className
|
|
19
|
+
),
|
|
20
|
+
style: customStyle
|
|
21
|
+
},
|
|
22
|
+
this.props.children
|
|
23
|
+
);
|
|
24
|
+
}
|
|
15
25
|
}
|
|
16
26
|
AtTabsPane.defaultProps = {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
27
|
+
customStyle: "",
|
|
28
|
+
className: "",
|
|
29
|
+
tabDirection: "horizontal",
|
|
30
|
+
index: 0,
|
|
31
|
+
current: 0
|
|
22
32
|
};
|
|
23
33
|
AtTabsPane.propTypes = {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
34
|
+
customStyle: PropTypes.oneOfType([PropTypes.object, PropTypes.string]),
|
|
35
|
+
className: PropTypes.oneOfType([PropTypes.array, PropTypes.string]),
|
|
36
|
+
tabDirection: PropTypes.oneOf(["horizontal", "vertical"]),
|
|
37
|
+
index: PropTypes.number,
|
|
38
|
+
current: PropTypes.number
|
|
39
|
+
};
|
|
40
|
+
export {
|
|
41
|
+
AtTabsPane as default
|
|
29
42
|
};
|
|
30
43
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"sources":["../../../src/components/tabs-pane/index.tsx"],"sourcesContent":["import classNames from 'classnames'\nimport PropTypes, { InferProps } from 'prop-types'\nimport React from 'react'\nimport { View } from '@tarojs/components'\nimport { AtTabsPaneProps } from '../../../types/tabs-pane'\n\nexport default class AtTabsPane extends React.Component<AtTabsPaneProps> {\n public static defaultProps: AtTabsPaneProps\n public static propTypes: InferProps<AtTabsPaneProps>\n\n public render(): JSX.Element {\n const { customStyle, className, tabDirection, index, current } = this.props\n\n return (\n <View\n className={classNames(\n {\n 'at-tabs-pane': true,\n 'at-tabs-pane--vertical': tabDirection === 'vertical',\n 'at-tabs-pane--active': index === current,\n 'at-tabs-pane--inactive': index !== current\n },\n className\n )}\n style={customStyle}\n >\n {this.props.children}\n </View>\n )\n }\n}\n\nAtTabsPane.defaultProps = {\n customStyle: '',\n className: '',\n tabDirection: 'horizontal',\n index: 0,\n current: 0\n}\n\nAtTabsPane.propTypes = {\n customStyle: PropTypes.oneOfType([PropTypes.object, PropTypes.string]),\n className: PropTypes.oneOfType([PropTypes.array, PropTypes.string]),\n tabDirection: PropTypes.oneOf(['horizontal', 'vertical']),\n index: PropTypes.number,\n current: PropTypes.number\n}\n"],"mappings":"AAAA,OAAO,gBAAgB;AACvB,OAAO,eAA+B;AACtC,OAAO,WAAW;AAClB,SAAS,YAAY;AAGrB,MAAO,mBAAiC,MAAM,UAA2B;AAAA,EAIhE,SAAsB;AAC3B,UAAM,EAAE,aAAa,WAAW,cAAc,OAAO,QAAQ,IAAI,KAAK;AAEtE,WACE;AAAA,MAAC;AAAA;AAAA,QACC,WAAW;AAAA,UACT;AAAA,YACE,gBAAgB;AAAA,YAChB,0BAA0B,iBAAiB;AAAA,YAC3C,wBAAwB,UAAU;AAAA,YAClC,0BAA0B,UAAU;AAAA,UACtC;AAAA,UACA;AAAA,QACF;AAAA,QACA,OAAO;AAAA;AAAA,MAEN,KAAK,MAAM;AAAA,IACd;AAAA,EAEJ;AACF;AAEA,WAAW,eAAe;AAAA,EACxB,aAAa;AAAA,EACb,WAAW;AAAA,EACX,cAAc;AAAA,EACd,OAAO;AAAA,EACP,SAAS;AACX;AAEA,WAAW,YAAY;AAAA,EACrB,aAAa,UAAU,UAAU,CAAC,UAAU,QAAQ,UAAU,MAAM,CAAC;AAAA,EACrE,WAAW,UAAU,UAAU,CAAC,UAAU,OAAO,UAAU,MAAM,CAAC;AAAA,EAClE,cAAc,UAAU,MAAM,CAAC,cAAc,UAAU,CAAC;AAAA,EACxD,OAAO,UAAU;AAAA,EACjB,SAAS,UAAU;AACrB;","names":[]}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { InferProps } from 'prop-types';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { AtTagProps } from '../../../types/tag';
|
|
4
|
+
export default class AtTag extends React.Component<AtTagProps> {
|
|
5
|
+
static defaultProps: AtTagProps;
|
|
6
|
+
static propTypes: InferProps<AtTagProps>;
|
|
7
|
+
private onClick;
|
|
8
|
+
render(): JSX.Element;
|
|
9
|
+
}
|