taro-ui 3.3.0 → 3.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- 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 -50
- 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/curtain.scss +3 -3
- 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/{dist → lib}/style/components/range.scss +2 -2
- package/{dist → lib}/style/components/toast.scss +1 -1
- 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 +45 -48
- 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/README.md +0 -85
- package/dist/index.esm.js +0 -8407
- package/dist/index.esm.js.map +0 -1
- package/dist/index.js +0 -8468
- 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/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/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/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,171 +1,220 @@
|
|
|
1
|
-
import classNames from
|
|
2
|
-
import PropTypes from
|
|
3
|
-
import React from
|
|
4
|
-
import Taro from
|
|
5
|
-
import { Text, View, MovableArea, MovableView } from
|
|
6
|
-
import { uuid, delayGetClientRect } from
|
|
7
|
-
import AtSwipeActionOptions from
|
|
8
|
-
|
|
9
|
-
|
|
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
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
1
|
+
import classNames from "classnames";
|
|
2
|
+
import PropTypes from "prop-types";
|
|
3
|
+
import React from "react";
|
|
4
|
+
import Taro from "@tarojs/taro";
|
|
5
|
+
import { Text, View, MovableArea, MovableView } from "@tarojs/components";
|
|
6
|
+
import { uuid, delayGetClientRect } from "../../common/utils";
|
|
7
|
+
import AtSwipeActionOptions from "./options/index";
|
|
8
|
+
class AtSwipeAction extends React.Component {
|
|
9
|
+
constructor(props) {
|
|
10
|
+
super(props);
|
|
11
|
+
this.handleOpened = (event) => {
|
|
12
|
+
const { onOpened } = this.props;
|
|
13
|
+
if (typeof onOpened === "function") {
|
|
14
|
+
onOpened(event);
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
this.handleClosed = (event) => {
|
|
18
|
+
const { onClosed } = this.props;
|
|
19
|
+
if (typeof onClosed === "function") {
|
|
20
|
+
onClosed(event);
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
this.handleClick = (item, index, event) => {
|
|
24
|
+
const { onClick, autoClose } = this.props;
|
|
25
|
+
if (typeof onClick === "function") {
|
|
26
|
+
onClick(item, index, event);
|
|
27
|
+
}
|
|
28
|
+
if (autoClose) {
|
|
29
|
+
this._reset(false);
|
|
30
|
+
this.handleClosed(event);
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
this.onTouchEnd = (e) => {
|
|
34
|
+
const { maxOffsetSize } = this.state;
|
|
35
|
+
if (Math.abs(this.moveX) < maxOffsetSize / 2) {
|
|
36
|
+
this._reset(false);
|
|
37
|
+
this.handleClosed(e);
|
|
38
|
+
} else {
|
|
39
|
+
this._reset(true);
|
|
40
|
+
this.handleOpened(e);
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
this.onChange = (e) => {
|
|
44
|
+
this.moveX = e.detail.x;
|
|
45
|
+
};
|
|
46
|
+
const { isOpened } = props;
|
|
47
|
+
this.state = {
|
|
48
|
+
componentId: uuid(),
|
|
49
|
+
// eslint-disable-next-line no-extra-boolean-cast
|
|
50
|
+
offsetSize: 0,
|
|
51
|
+
_isOpened: !!isOpened,
|
|
52
|
+
needAnimation: false,
|
|
53
|
+
eleWidth: 0,
|
|
54
|
+
maxOffsetSize: 0
|
|
55
|
+
};
|
|
56
|
+
this.moveX = this.state.offsetSize;
|
|
57
|
+
}
|
|
58
|
+
componentDidMount() {
|
|
59
|
+
this.getAreaWidth();
|
|
60
|
+
}
|
|
61
|
+
// 当 eleWidth 发生变化时,需要重新计算 maxOffsetSize
|
|
62
|
+
componentDidUpdate(_, prevState) {
|
|
63
|
+
const { eleWidth } = this.state;
|
|
64
|
+
if (prevState.eleWidth !== eleWidth) {
|
|
65
|
+
this.getMaxOffsetSize();
|
|
61
66
|
}
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
UNSAFE_componentWillReceiveProps(nextProps) {
|
|
70
|
-
const { isOpened } = nextProps;
|
|
71
|
-
const { _isOpened, maxOffsetSize } = this.state;
|
|
72
|
-
if (isOpened !== _isOpened) {
|
|
73
|
-
this.moveX = isOpened ? 0 : maxOffsetSize;
|
|
74
|
-
this._reset(!!isOpened); // TODO: Check behavior
|
|
75
|
-
}
|
|
67
|
+
}
|
|
68
|
+
UNSAFE_componentWillReceiveProps(nextProps) {
|
|
69
|
+
const { isOpened } = nextProps;
|
|
70
|
+
const { _isOpened, maxOffsetSize } = this.state;
|
|
71
|
+
if (isOpened !== _isOpened) {
|
|
72
|
+
this.moveX = isOpened ? 0 : maxOffsetSize;
|
|
73
|
+
this._reset(!!isOpened);
|
|
76
74
|
}
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* 获取滑动区域宽度
|
|
78
|
+
*/
|
|
79
|
+
async getAreaWidth() {
|
|
80
|
+
const systemInfo = await Taro.getSystemInfo();
|
|
81
|
+
this.setState({
|
|
82
|
+
eleWidth: systemInfo.windowWidth
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* 获取最大偏移量
|
|
87
|
+
*/
|
|
88
|
+
async getMaxOffsetSize() {
|
|
89
|
+
const { componentId } = this.state;
|
|
90
|
+
const actionOptionsRect = await delayGetClientRect({
|
|
91
|
+
selectorStr: `#swipeActionOptions-${componentId}`
|
|
92
|
+
});
|
|
93
|
+
const maxOffsetSize = actionOptionsRect[0].width;
|
|
94
|
+
this.setState({
|
|
95
|
+
maxOffsetSize
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
_reset(isOpened) {
|
|
99
|
+
if (isOpened) {
|
|
100
|
+
const { maxOffsetSize } = this.state;
|
|
101
|
+
if (process.env.TARO_ENV === "jd") {
|
|
82
102
|
this.setState({
|
|
83
|
-
|
|
103
|
+
_isOpened: true,
|
|
104
|
+
offsetSize: -maxOffsetSize + 0.01
|
|
84
105
|
});
|
|
85
|
-
|
|
86
|
-
/**
|
|
87
|
-
* 获取最大偏移量
|
|
88
|
-
*/
|
|
89
|
-
async getMaxOffsetSize() {
|
|
90
|
-
const { componentId } = this.state;
|
|
91
|
-
const actionOptionsRect = await delayGetClientRect({
|
|
92
|
-
selectorStr: `#swipeActionOptions-${componentId}`
|
|
93
|
-
});
|
|
94
|
-
const maxOffsetSize = actionOptionsRect[0].width;
|
|
106
|
+
} else {
|
|
95
107
|
this.setState({
|
|
96
|
-
|
|
108
|
+
_isOpened: true,
|
|
109
|
+
offsetSize: -maxOffsetSize
|
|
97
110
|
});
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
this.setState({
|
|
110
|
-
_isOpened: true,
|
|
111
|
-
offsetSize: -maxOffsetSize
|
|
112
|
-
});
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
else {
|
|
116
|
-
this.setState({
|
|
117
|
-
offsetSize: this.moveX
|
|
118
|
-
}, () => {
|
|
119
|
-
this.setState({
|
|
120
|
-
offsetSize: 0,
|
|
121
|
-
_isOpened: false
|
|
122
|
-
});
|
|
123
|
-
});
|
|
111
|
+
}
|
|
112
|
+
} else {
|
|
113
|
+
this.setState(
|
|
114
|
+
{
|
|
115
|
+
offsetSize: this.moveX
|
|
116
|
+
},
|
|
117
|
+
() => {
|
|
118
|
+
this.setState({
|
|
119
|
+
offsetSize: 0,
|
|
120
|
+
_isOpened: false
|
|
121
|
+
});
|
|
124
122
|
}
|
|
123
|
+
);
|
|
125
124
|
}
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
125
|
+
}
|
|
126
|
+
render() {
|
|
127
|
+
const { componentId, maxOffsetSize, eleWidth, offsetSize } = this.state;
|
|
128
|
+
const { options, disabled } = this.props;
|
|
129
|
+
const rootClass = classNames("at-swipe-action", this.props.className);
|
|
130
|
+
return /* @__PURE__ */ React.createElement(
|
|
131
|
+
View,
|
|
132
|
+
{
|
|
133
|
+
id: `swipeAction-${componentId}`,
|
|
134
|
+
className: rootClass,
|
|
135
|
+
style: {
|
|
136
|
+
width: `${eleWidth}px`
|
|
137
|
+
}
|
|
138
|
+
},
|
|
139
|
+
/* @__PURE__ */ React.createElement(
|
|
140
|
+
MovableArea,
|
|
141
|
+
{
|
|
142
|
+
className: "at-swipe-action__area",
|
|
143
|
+
style: {
|
|
144
|
+
width: `${eleWidth}px`
|
|
145
|
+
}
|
|
146
|
+
},
|
|
147
|
+
/* @__PURE__ */ React.createElement(
|
|
148
|
+
MovableView,
|
|
149
|
+
{
|
|
150
|
+
className: "at-swipe-action__content",
|
|
151
|
+
direction: "horizontal",
|
|
152
|
+
damping: 50,
|
|
153
|
+
x: offsetSize,
|
|
154
|
+
onTouchEnd: this.onTouchEnd,
|
|
155
|
+
onChange: this.onChange,
|
|
156
|
+
disabled,
|
|
157
|
+
style: {
|
|
158
|
+
width: `${eleWidth + maxOffsetSize}px`
|
|
159
|
+
}
|
|
160
|
+
},
|
|
161
|
+
this.props.children,
|
|
162
|
+
Array.isArray(options) && options.length > 0 ? /* @__PURE__ */ React.createElement(
|
|
163
|
+
AtSwipeActionOptions,
|
|
164
|
+
{
|
|
165
|
+
options,
|
|
166
|
+
componentId,
|
|
167
|
+
customStyle: {
|
|
168
|
+
opacity: maxOffsetSize ? 1 : 0
|
|
169
|
+
}
|
|
170
|
+
},
|
|
171
|
+
options.map((item, key) => /* @__PURE__ */ React.createElement(
|
|
172
|
+
View,
|
|
173
|
+
{
|
|
174
|
+
key: `${item.text}-${key}`,
|
|
175
|
+
style: item.style,
|
|
176
|
+
onClick: (e) => this.handleClick(item, key, e),
|
|
177
|
+
className: classNames(
|
|
178
|
+
"at-swipe-action__option",
|
|
179
|
+
item.className
|
|
180
|
+
)
|
|
181
|
+
},
|
|
182
|
+
/* @__PURE__ */ React.createElement(Text, { className: "option__text" }, item.text)
|
|
183
|
+
))
|
|
184
|
+
) : null
|
|
185
|
+
)
|
|
186
|
+
)
|
|
187
|
+
);
|
|
188
|
+
}
|
|
145
189
|
}
|
|
146
190
|
AtSwipeAction.defaultProps = {
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
191
|
+
options: [],
|
|
192
|
+
isOpened: false,
|
|
193
|
+
disabled: false,
|
|
194
|
+
autoClose: false,
|
|
195
|
+
maxDistance: 0,
|
|
196
|
+
areaWidth: 0
|
|
153
197
|
};
|
|
154
198
|
AtSwipeAction.propTypes = {
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
199
|
+
isOpened: PropTypes.bool,
|
|
200
|
+
disabled: PropTypes.bool,
|
|
201
|
+
autoClose: PropTypes.bool,
|
|
202
|
+
options: PropTypes.arrayOf(
|
|
203
|
+
PropTypes.shape({
|
|
204
|
+
text: PropTypes.string,
|
|
205
|
+
style: PropTypes.oneOfType([PropTypes.object, PropTypes.string]),
|
|
206
|
+
className: PropTypes.oneOfType([
|
|
207
|
+
PropTypes.object,
|
|
208
|
+
PropTypes.string,
|
|
209
|
+
PropTypes.array
|
|
210
|
+
])
|
|
211
|
+
})
|
|
212
|
+
),
|
|
213
|
+
onClick: PropTypes.func,
|
|
214
|
+
onOpened: PropTypes.func,
|
|
215
|
+
onClosed: PropTypes.func
|
|
216
|
+
};
|
|
217
|
+
export {
|
|
218
|
+
AtSwipeAction as default
|
|
170
219
|
};
|
|
171
220
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/swipe-action/index.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AAS,CAAC,SAAS,CAAC,CAAC,SAAS,CAAC,MAAM,EAAE,SAAS,CAAC,MAAM,CAAC,CAAC;QAChE,SAAS,EAAE,SAAS,CAAC,SAAS,CAAC;YAC7B,SAAS,CAAC,MAAM;YAChB,SAAS,CAAC,MAAM;YAChB,SAAS,CAAC,KAAK;SAChB,CAAC;KACH,CAAC,CACH;IAED,OAAO,EAAE,SAAS,CAAC,IAAI;IACvB,QAAQ,EAAE,SAAS,CAAC,IAAI;IACxB,QAAQ,EAAE,SAAS,CAAC,IAAI;CACzB,CAAA"}
|
|
1
|
+
{"version":3,"sources":["../../../src/components/swipe-action/index.tsx"],"sourcesContent":["import classNames from 'classnames'\nimport PropTypes, { InferProps } from 'prop-types'\nimport React from 'react'\nimport Taro from '@tarojs/taro'\nimport { Text, View, MovableArea, MovableView } from '@tarojs/components'\nimport { CommonEvent } from '@tarojs/components/types/common'\nimport {\n AtSwipeActionProps,\n AtSwipeActionState,\n SwipeActionOption\n} from '../../../types/swipe-action'\nimport { uuid, delayGetClientRect } from '../../common/utils'\nimport AtSwipeActionOptions from './options/index'\n\nexport default class AtSwipeAction extends React.Component<\n AtSwipeActionProps,\n AtSwipeActionState\n> {\n public static defaultProps: AtSwipeActionProps\n public static propTypes: InferProps<AtSwipeActionProps>\n\n private moveX: number\n\n public constructor(props: AtSwipeActionProps) {\n super(props)\n const { isOpened } = props\n this.state = {\n componentId: uuid(),\n // eslint-disable-next-line no-extra-boolean-cast\n offsetSize: 0,\n _isOpened: !!isOpened,\n needAnimation: false,\n eleWidth: 0,\n maxOffsetSize: 0\n }\n this.moveX = this.state.offsetSize\n }\n\n public componentDidMount(): void {\n this.getAreaWidth()\n }\n\n // 当 eleWidth 发生变化时,需要重新计算 maxOffsetSize\n public componentDidUpdate(_, prevState: AtSwipeActionState): void {\n const { eleWidth } = this.state\n if (prevState.eleWidth !== eleWidth) {\n this.getMaxOffsetSize()\n }\n }\n\n public UNSAFE_componentWillReceiveProps(nextProps: AtSwipeActionProps): void {\n const { isOpened } = nextProps\n const { _isOpened, maxOffsetSize } = this.state\n\n if (isOpened !== _isOpened) {\n this.moveX = isOpened ? 0 : maxOffsetSize\n this._reset(!!isOpened) // TODO: Check behavior\n }\n }\n\n /**\n * 获取滑动区域宽度\n */\n private async getAreaWidth(): Promise<void> {\n const systemInfo = await Taro.getSystemInfo()\n this.setState({\n eleWidth: systemInfo.windowWidth\n })\n }\n\n /**\n * 获取最大偏移量\n */\n private async getMaxOffsetSize(): Promise<void> {\n const { componentId } = this.state\n\n const actionOptionsRect = await delayGetClientRect({\n selectorStr: `#swipeActionOptions-${componentId}`\n })\n\n const maxOffsetSize = actionOptionsRect[0].width\n\n this.setState({\n maxOffsetSize\n })\n }\n\n private _reset(isOpened: boolean): void {\n if (isOpened) {\n const { maxOffsetSize } = this.state\n if (process.env.TARO_ENV === 'jd') {\n this.setState({\n _isOpened: true,\n offsetSize: -maxOffsetSize + 0.01\n })\n } else {\n this.setState({\n _isOpened: true,\n offsetSize: -maxOffsetSize\n })\n }\n } else {\n this.setState(\n {\n offsetSize: this.moveX\n },\n () => {\n this.setState({\n offsetSize: 0,\n _isOpened: false\n })\n }\n )\n }\n }\n\n private handleOpened = (event: CommonEvent): void => {\n const { onOpened } = this.props\n if (typeof onOpened === 'function') {\n onOpened(event)\n }\n }\n\n private handleClosed = (event: CommonEvent): void => {\n const { onClosed } = this.props\n if (typeof onClosed === 'function') {\n onClosed(event)\n }\n }\n\n private handleClick = (\n item: SwipeActionOption,\n index: number,\n event: CommonEvent\n ): void => {\n const { onClick, autoClose } = this.props\n\n if (typeof onClick === 'function') {\n onClick(item, index, event)\n }\n if (autoClose) {\n this._reset(false) // TODO: Check behavior\n this.handleClosed(event)\n }\n }\n\n onTouchEnd = e => {\n const { maxOffsetSize } = this.state\n if (Math.abs(this.moveX) < maxOffsetSize / 2) {\n this._reset(false)\n this.handleClosed(e)\n } else {\n this._reset(true)\n this.handleOpened(e)\n }\n }\n\n onChange = e => {\n this.moveX = e.detail.x\n }\n\n public render(): JSX.Element {\n const { componentId, maxOffsetSize, eleWidth, offsetSize } = this.state\n\n const { options, disabled } = this.props\n const rootClass = classNames('at-swipe-action', this.props.className)\n\n return (\n <View\n id={`swipeAction-${componentId}`}\n className={rootClass}\n style={{\n width: `${eleWidth}px`\n }}\n >\n <MovableArea\n className='at-swipe-action__area'\n style={{\n width: `${eleWidth}px`\n }}\n >\n <MovableView\n className='at-swipe-action__content'\n direction='horizontal'\n damping={50}\n x={offsetSize}\n onTouchEnd={this.onTouchEnd}\n onChange={this.onChange}\n disabled={disabled}\n style={{\n width: `${eleWidth + maxOffsetSize}px`\n }}\n >\n {this.props.children}\n {Array.isArray(options) && options.length > 0 ? (\n <AtSwipeActionOptions\n options={options}\n componentId={componentId}\n customStyle={{\n opacity: maxOffsetSize ? 1 : 0\n }}\n >\n {options.map((item, key) => (\n <View\n key={`${item.text}-${key}`}\n style={item.style}\n onClick={(e): void => this.handleClick(item, key, e)}\n className={classNames(\n 'at-swipe-action__option',\n item.className\n )}\n >\n <Text className='option__text'>{item.text}</Text>\n </View>\n ))}\n </AtSwipeActionOptions>\n ) : null}\n </MovableView>\n </MovableArea>\n </View>\n )\n }\n}\n\nAtSwipeAction.defaultProps = {\n options: [],\n isOpened: false,\n disabled: false,\n autoClose: false,\n maxDistance: 0,\n areaWidth: 0\n}\n\nAtSwipeAction.propTypes = {\n isOpened: PropTypes.bool,\n disabled: PropTypes.bool,\n autoClose: PropTypes.bool,\n options: PropTypes.arrayOf(\n PropTypes.shape({\n text: PropTypes.string,\n style: PropTypes.oneOfType([PropTypes.object, PropTypes.string]),\n className: PropTypes.oneOfType([\n PropTypes.object,\n PropTypes.string,\n PropTypes.array\n ])\n })\n ),\n\n onClick: PropTypes.func,\n onOpened: PropTypes.func,\n onClosed: PropTypes.func\n}\n"],"mappings":"AAAA,OAAO,gBAAgB;AACvB,OAAO,eAA+B;AACtC,OAAO,WAAW;AAClB,OAAO,UAAU;AACjB,SAAS,MAAM,M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,QAAK,WAAU,kBAAgB,KAAK,IAAK;AAAA,YAC5C,CACD;AAAA,UACH,IACE;AAAA,QACN;AAAA,MACF;AAAA,IACF;AAAA,EAEJ;AACF;AAEA,cAAc,eAAe;AAAA,EAC3B,SAAS,CAAC;AAAA,EACV,UAAU;AAAA,EACV,UAAU;AAAA,EACV,WAAW;AAAA,EACX,aAAa;AAAA,EACb,WAAW;AACb;AAEA,cAAc,YAAY;AAAA,EACxB,UAAU,UAAU;AAAA,EACpB,UAAU,UAAU;AAAA,EACpB,WAAW,UAAU;AAAA,EACrB,SAAS,UAAU;AAAA,IACjB,UAAU,MAAM;AAAA,MACd,MAAM,UAAU;AAAA,MAChB,OAAO,UAAU,UAAU,CAAC,UAAU,QAAQ,UAAU,MAAM,CAAC;AAAA,MAC/D,WAAW,UAAU,UAAU;AAAA,QAC7B,UAAU;AAAA,QACV,UAAU;AAAA,QACV,UAAU;AAAA,MACZ,CAAC;AAAA,IACH,CAAC;AAAA,EACH;AAAA,EAEA,SAAS,UAAU;AAAA,EACnB,UAAU,UAAU;AAAA,EACpB,UAAU,UAAU;AACtB;","names":[]}
|
|
@@ -1,10 +1,24 @@
|
|
|
1
|
-
import classNames from
|
|
2
|
-
import React from
|
|
3
|
-
import { View } from
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
import classNames from "classnames";
|
|
2
|
+
import React from "react";
|
|
3
|
+
import { View } from "@tarojs/components";
|
|
4
|
+
class AtSwipeActionOptions extends React.Component {
|
|
5
|
+
render() {
|
|
6
|
+
const rootClass = classNames(
|
|
7
|
+
"at-swipe-action__options",
|
|
8
|
+
this.props.className
|
|
9
|
+
);
|
|
10
|
+
return /* @__PURE__ */ React.createElement(
|
|
11
|
+
View,
|
|
12
|
+
{
|
|
13
|
+
id: `swipeActionOptions-${this.props.componentId}`,
|
|
14
|
+
className: rootClass,
|
|
15
|
+
style: this.props.customStyle
|
|
16
|
+
},
|
|
17
|
+
this.props.children
|
|
18
|
+
);
|
|
19
|
+
}
|
|
9
20
|
}
|
|
21
|
+
export {
|
|
22
|
+
AtSwipeActionOptions as default
|
|
23
|
+
};
|
|
10
24
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"sources":["../../../../src/components/swipe-action/options/index.tsx"],"sourcesContent":["import classNames from 'classnames'\nimport React from 'react'\nimport { View } from '@tarojs/components'\nimport { AtSwipeActionOptionsProps } from '../../../../types/swipe-action'\n\nexport default class AtSwipeActionOptions extends React.Component<AtSwipeActionOptionsProps> {\n public render(): JSX.Element {\n const rootClass = classNames(\n 'at-swipe-action__options',\n this.props.className\n )\n\n return (\n <View\n id={`swipeActionOptions-${this.props.componentId}`}\n className={rootClass}\n style={this.props.customStyle}\n >\n {this.props.children}\n </View>\n )\n }\n}\n"],"mappings":"AAAA,OAAO,gBAAgB;AACvB,OAAO,WAAW;AAClB,SAAS,YAAY;AAGrB,MAAO,6BAA2C,MAAM,UAAqC;AAAA,EACpF,SAAsB;AAC3B,UAAM,YAAY;AAAA,MAChB;AAAA,MACA,KAAK,MAAM;AAAA,IACb;AAEA,WACE;AAAA,MAAC;AAAA;AAAA,QACC,IAAI,sBAAsB,KAAK,MAAM,WAAW;AAAA,QAChD,WAAW;AAAA,QACX,OAAO,KAAK,MAAM;AAAA;AAAA,MAEjB,KAAK,MAAM;AAAA,IACd;AAAA,EAEJ;AACF;","names":[]}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { InferProps } from 'prop-types';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { AtSwitchProps } from '../../../types/switch';
|
|
4
|
+
export default class AtSwitch extends React.Component<AtSwitchProps> {
|
|
5
|
+
static defaultProps: AtSwitchProps;
|
|
6
|
+
static propTypes: InferProps<AtSwitchProps>;
|
|
7
|
+
private handleChange;
|
|
8
|
+
render(): JSX.Element;
|
|
9
|
+
}
|
|
@@ -1,48 +1,59 @@
|
|
|
1
|
-
import classNames from
|
|
2
|
-
import PropTypes from
|
|
3
|
-
import React from
|
|
4
|
-
import { Switch, View } from
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
1
|
+
import classNames from "classnames";
|
|
2
|
+
import PropTypes from "prop-types";
|
|
3
|
+
import React from "react";
|
|
4
|
+
import { Switch, View } from "@tarojs/components";
|
|
5
|
+
class AtSwitch extends React.Component {
|
|
6
|
+
constructor() {
|
|
7
|
+
super(...arguments);
|
|
8
|
+
this.handleChange = (event) => {
|
|
9
|
+
const { value, checked } = event.detail;
|
|
10
|
+
const state = typeof value === "undefined" ? checked : value;
|
|
11
|
+
this.props.onChange && this.props.onChange(state);
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
render() {
|
|
15
|
+
const { customStyle, className, disabled, border, title, checked, color } = this.props;
|
|
16
|
+
const rootCls = classNames(
|
|
17
|
+
"at-switch",
|
|
18
|
+
{
|
|
19
|
+
"at-switch--without-border": !border
|
|
20
|
+
},
|
|
21
|
+
className
|
|
22
|
+
);
|
|
23
|
+
const containerCls = classNames("at-switch__container", {
|
|
24
|
+
"at-switch--disabled": disabled
|
|
25
|
+
});
|
|
26
|
+
return /* @__PURE__ */ React.createElement(View, { className: rootCls, style: customStyle }, /* @__PURE__ */ React.createElement(View, { className: "at-switch__title" }, title), /* @__PURE__ */ React.createElement(View, { className: containerCls }, /* @__PURE__ */ React.createElement(View, { className: "at-switch__mask" }), /* @__PURE__ */ React.createElement(
|
|
27
|
+
Switch,
|
|
28
|
+
{
|
|
29
|
+
className: "at-switch__switch",
|
|
30
|
+
checked,
|
|
31
|
+
color,
|
|
32
|
+
onChange: this.handleChange
|
|
33
|
+
}
|
|
34
|
+
)));
|
|
35
|
+
}
|
|
28
36
|
}
|
|
29
37
|
AtSwitch.defaultProps = {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
38
|
+
customStyle: "",
|
|
39
|
+
className: "",
|
|
40
|
+
title: "",
|
|
41
|
+
color: "#6190e8",
|
|
42
|
+
border: true,
|
|
43
|
+
disabled: false,
|
|
44
|
+
checked: false
|
|
37
45
|
};
|
|
38
46
|
AtSwitch.propTypes = {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
+
customStyle: PropTypes.oneOfType([PropTypes.object, PropTypes.string]),
|
|
48
|
+
className: PropTypes.oneOfType([PropTypes.array, PropTypes.string]),
|
|
49
|
+
title: PropTypes.string,
|
|
50
|
+
color: PropTypes.string,
|
|
51
|
+
checked: PropTypes.bool,
|
|
52
|
+
border: PropTypes.bool,
|
|
53
|
+
disabled: PropTypes.bool,
|
|
54
|
+
onChange: PropTypes.func
|
|
55
|
+
};
|
|
56
|
+
export {
|
|
57
|
+
AtSwitch as default
|
|
47
58
|
};
|
|
48
59
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"sources":["../../../src/components/switch/index.tsx"],"sourcesContent":["import classNames from 'classnames'\nimport PropTypes, { InferProps } from 'prop-types'\nimport React from 'react'\nimport { Switch, View } from '@tarojs/components'\nimport { CommonEvent } from '@tarojs/components/types/common'\nimport { AtSwitchProps } from '../../../types/switch'\n\nexport default class AtSwitch extends React.Component<AtSwitchProps> {\n public static defaultProps: AtSwitchProps\n public static propTypes: InferProps<AtSwitchProps>\n\n private handleChange = (event: CommonEvent): void => {\n const { value, checked } = event.detail\n const state = typeof value === 'undefined' ? checked : value\n this.props.onChange && this.props.onChange(state)\n }\n\n public render(): JSX.Element {\n const { customStyle, className, disabled, border, title, checked, color } =\n this.props\n\n const rootCls = classNames(\n 'at-switch',\n {\n 'at-switch--without-border': !border\n },\n className\n )\n const containerCls = classNames('at-switch__container', {\n 'at-switch--disabled': disabled\n })\n\n return (\n <View className={rootCls} style={customStyle}>\n <View className='at-switch__title'>{title}</View>\n <View className={containerCls}>\n <View className='at-switch__mask'></View>\n <Switch\n className='at-switch__switch'\n checked={checked}\n color={color}\n onChange={this.handleChange}\n />\n </View>\n </View>\n )\n }\n}\n\nAtSwitch.defaultProps = {\n customStyle: '',\n className: '',\n title: '',\n color: '#6190e8',\n border: true,\n disabled: false,\n checked: false\n}\n\nAtSwitch.propTypes = {\n customStyle: PropTypes.oneOfType([PropTypes.object, PropTypes.string]),\n className: PropTypes.oneOfType([PropTypes.array, PropTypes.string]),\n title: PropTypes.string,\n color: PropTypes.string,\n checked: PropTypes.bool,\n border: PropTypes.bool,\n disabled: PropTypes.bool,\n onChange: PropTypes.func\n}\n"],"mappings":"AAAA,OAAO,gBAAgB;AACvB,OAAO,eAA+B;AACtC,OAAO,WAAW;AAClB,SAAS,QAAQ,YAAY;AAI7B,MAAO,iBAA+B,MAAM,UAAyB;AAAA,EAArE;AAAA;AAIE,SAAQ,eAAe,CAAC,UAA6B;AACnD,YAAM,EAAE,OAAO,QAAQ,IAAI,MAAM;AACjC,YAAM,QAAQ,OAAO,UAAU,cAAc,UAAU;AACvD,WAAK,MAAM,YAAY,KAAK,MAAM,SAAS,KAAK;AAAA,IAClD;AAAA;AAAA,EAEO,SAAsB;AAC3B,UAAM,EAAE,aAAa,WAAW,UAAU,QAAQ,OAAO,SAAS,MAAM,IACtE,KAAK;AAEP,UAAM,UAAU;AAAA,MACd;AAAA,MACA;AAAA,QACE,6BAA6B,CAAC;AAAA,MAChC;AAAA,MACA;AAAA,IACF;AACA,UAAM,eAAe,WAAW,wBAAwB;AAAA,MACtD,uBAAuB;AAAA,IACzB,CAAC;AAED,WACE,oCAAC,QAAK,WAAW,SAAS,OAAO,eAC/B,oCAAC,QAAK,WAAU,sBAAoB,KAAM,GAC1C,oCAAC,QAAK,WAAW,gBACf,oCAAC,QAAK,WAAU,mBAAkB,GAClC;AAAA,MAAC;AAAA;AAAA,QACC,WAAU;AAAA,QACV;AAAA,QACA;AAAA,QACA,UAAU,KAAK;AAAA;AAAA,IACjB,CACF,CACF;AAAA,EAEJ;AACF;AAEA,SAAS,eAAe;AAAA,EACtB,aAAa;AAAA,EACb,WAAW;AAAA,EACX,OAAO;AAAA,EACP,OAAO;AAAA,EACP,QAAQ;AAAA,EACR,UAAU;AAAA,EACV,SAAS;AACX;AAEA,SAAS,YAAY;AAAA,EACnB,aAAa,UAAU,UAAU,CAAC,UAAU,QAAQ,UAAU,MAAM,CAAC;AAAA,EACrE,WAAW,UAAU,UAAU,CAAC,UAAU,OAAO,UAAU,MAAM,CAAC;AAAA,EAClE,OAAO,UAAU;AAAA,EACjB,OAAO,UAAU;AAAA,EACjB,SAAS,UAAU;AAAA,EACnB,QAAQ,UAAU;AAAA,EAClB,UAAU,UAAU;AAAA,EACpB,UAAU,UAAU;AACtB;","names":[]}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { InferProps } from 'prop-types';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { AtTabBarProps } from '../../../types/tab-bar';
|
|
4
|
+
export default class AtTabBar extends React.Component<AtTabBarProps> {
|
|
5
|
+
static defaultProps: AtTabBarProps;
|
|
6
|
+
static propTypes: InferProps<AtTabBarProps>;
|
|
7
|
+
private handleClick;
|
|
8
|
+
render(): JSX.Element;
|
|
9
|
+
}
|