@nutui/nutui-react-taro 2.0.0-alpha.0 → 2.0.0-alpha.10
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/CHANGELOG.md +137 -638
- package/dist/esm/ActionSheet.js +15 -16
- package/dist/esm/Address.js +19 -22
- package/dist/esm/Animate.js +7 -9
- package/dist/esm/AnimatingNumbers.js +8 -9
- package/dist/esm/Audio.js +18 -20
- package/dist/esm/Avatar.js +11 -12
- package/dist/esm/AvatarGroup.js +8 -13
- package/dist/esm/BackTop.js +9 -10
- package/dist/esm/Badge.js +7 -10
- package/dist/esm/Barrage.js +9 -10
- package/dist/esm/Button.js +8 -9
- package/dist/esm/Calendar.js +18 -21
- package/dist/esm/CalendarItem.js +11 -14
- package/dist/esm/Card.js +12 -13
- package/dist/esm/Cascader.js +16 -18
- package/dist/esm/Cell.js +7 -8
- package/dist/esm/CellGroup.js +7 -8
- package/dist/esm/Checkbox.js +9 -10
- package/dist/esm/CheckboxGroup.js +9 -10
- package/dist/esm/CircleProgress.js +8 -10
- package/dist/esm/Col.js +8 -8
- package/dist/esm/Collapse.js +8 -9
- package/dist/esm/CollapseItem.js +7 -8
- package/dist/esm/ConfigProvider.js +9 -9
- package/dist/esm/CountDown.js +8 -11
- package/dist/esm/DatePicker.js +20 -24
- package/dist/esm/Dialog.js +13 -15
- package/dist/esm/Divider.js +7 -7
- package/dist/esm/Drag.js +7 -9
- package/dist/esm/Elevator.js +9 -10
- package/dist/esm/Ellipsis.js +9 -11
- package/dist/esm/Empty.js +7 -11
- package/dist/esm/FixedNav.js +11 -14
- package/dist/esm/Form.js +10 -11
- package/dist/esm/FormItem.js +8 -9
- package/dist/esm/Grid.js +8 -11
- package/dist/esm/GridItem.js +7 -10
- package/dist/esm/Image.js +7 -10
- package/dist/esm/ImagePreview.js +18 -20
- package/dist/esm/Indicator.js +6 -7
- package/dist/esm/Infiniteloading.js +12 -15
- package/dist/esm/Input.js +11 -11
- package/dist/esm/InputNumber.js +9 -10
- package/dist/esm/Layout.js +5 -6
- package/dist/esm/Menu.js +8 -9
- package/dist/esm/MenuItem.js +13 -15
- package/dist/esm/NavBar.js +7 -11
- package/dist/esm/NoticeBar.js +9 -12
- package/dist/esm/Notify.js +8 -10
- package/dist/esm/NumberKeyboard.js +14 -19
- package/dist/esm/Overlay.js +8 -9
- package/dist/esm/Pagination.js +9 -12
- package/dist/esm/Picker.js +19 -23
- package/dist/esm/Popover.js +10 -11
- package/dist/esm/Popup.js +12 -15
- package/dist/esm/Price.js +6 -8
- package/dist/esm/Progress.js +7 -11
- package/dist/esm/PullToRefresh.js +9 -14
- package/dist/esm/Radio.js +9 -10
- package/dist/esm/RadioGroup.js +9 -10
- package/dist/esm/Range/style/index.js +1 -1
- package/dist/esm/Range.js +11 -16
- package/dist/esm/Rate.js +9 -10
- package/dist/esm/Row.js +8 -8
- package/dist/esm/SearchBar.js +11 -14
- package/dist/esm/ShortPassword.js +16 -19
- package/dist/esm/SideNavBar.js +14 -20
- package/dist/esm/SideNavBarItem.js +5 -6
- package/dist/esm/Signature.js +13 -16
- package/dist/esm/Skeleton.js +14 -13
- package/dist/esm/Step.js +8 -11
- package/dist/esm/Steps/style/index.js +1 -1
- package/dist/esm/Steps.js +8 -10
- package/dist/esm/Sticky.js +10 -12
- package/dist/esm/SubSideNavBar.js +6 -7
- package/dist/esm/Swipe.js +11 -12
- package/dist/esm/Swiper.js +8 -11
- package/dist/esm/SwiperItem.js +5 -10
- package/dist/esm/Switch.js +7 -8
- package/dist/esm/TabPane.js +6 -9
- package/dist/esm/Tabbar/style/index.js +1 -1
- package/dist/esm/Tabbar.js +10 -8
- package/dist/esm/TabbarItem.js +8 -10
- package/dist/esm/Table.js +9 -14
- package/dist/esm/Tabs.js +11 -12
- package/dist/esm/Tag.js +8 -9
- package/dist/esm/TextArea.js +11 -11
- package/dist/esm/TimeDetail.js +8 -11
- package/dist/esm/TimePannel.js +8 -11
- package/dist/esm/TimeSelect.js +18 -21
- package/dist/esm/Toast.js +9 -10
- package/dist/esm/TrendArrow.js +8 -9
- package/dist/esm/Uploader.js +14 -19
- package/dist/esm/UserContext-ab42ba7f.js +5 -0
- package/dist/esm/Video.js +8 -9
- package/dist/esm/VirtualList.js +8 -11
- package/dist/esm/WaterMark.js +10 -13
- package/dist/esm/actionsheet.taro-d2217152.js +61 -0
- package/dist/esm/address.taro-1a8ab3f1.js +470 -0
- package/dist/esm/animate.taro-c8b29242.js +44 -0
- package/dist/esm/animatingnumbers.taro-c2a52dbd.js +103 -0
- package/dist/esm/audio.taro-bbd39f93.js +185 -0
- package/dist/esm/avatar.taro-01536aff.js +100 -0
- package/dist/esm/avatargroup-ad5ffb46.js +34 -0
- package/dist/esm/backtop.taro-7de36464.js +48 -0
- package/dist/esm/badge.taro-872605bf.js +48 -0
- package/dist/esm/barrage.taro-c8cb9864.js +91 -0
- package/dist/esm/bem-cdccae08.js +5 -0
- package/dist/esm/button.taro-01eae688.js +72 -0
- package/dist/esm/calendar.taro-10a6cb11.js +70 -0
- package/dist/esm/calendaritem.taro-3e5f114e.js +732 -0
- package/dist/esm/can-use-dom-0e539bd3.js +4 -0
- package/dist/esm/card.taro-2080f4d2.js +51 -0
- package/dist/esm/cascader.taro-fb7a0230.js +471 -0
- package/dist/esm/cell.taro-4e31d1fa.js +48 -0
- package/dist/esm/cellgroup.taro-a790d91b.js +28 -0
- package/dist/esm/checkbox.taro-016074da.js +177 -0
- package/dist/esm/circleprogress.taro-7149e09d.js +104 -0
- package/dist/esm/col.taro-d6a46a7d.js +41 -0
- package/dist/esm/collapse.taro-3d997680.js +70 -0
- package/dist/esm/collapseitem-f4571575.js +76 -0
- package/dist/esm/configprovider.taro-25758d9f.js +462 -0
- package/dist/esm/context-ab42ba7f.js +5 -0
- package/dist/esm/context-d0fccf11.js +5 -0
- package/dist/esm/countdown.taro-22200811.js +210 -0
- package/dist/esm/datepicker.taro-65dbeceb.js +260 -0
- package/dist/esm/dialog.taro-290eb9a6.js +128 -0
- package/dist/esm/divider.taro-0cb5f894.js +31 -0
- package/dist/esm/drag.taro-48e1ff38.js +111 -0
- package/dist/esm/elevator.taro-df8fde9d.js +206 -0
- package/dist/esm/ellipsis.taro-f9688dd7.js +242 -0
- package/dist/esm/empty.taro-ca792f57.js +59 -0
- package/dist/esm/fixednav.taro-28e5f776.js +61 -0
- package/dist/esm/form.taro-b06754e8.js +182 -0
- package/dist/esm/formitem.taro-b326809d.js +108 -0
- package/dist/esm/grid.taro-fbbd8618.js +52 -0
- package/dist/esm/griditem.taro-b0c37077.js +85 -0
- package/dist/esm/image.taro-767aa000.js +65 -0
- package/dist/esm/imagepreview.taro-daa5a84f.js +180 -0
- package/dist/esm/index-e3184f19.js +9 -0
- package/dist/esm/indicator.taro-edbc71df.js +30 -0
- package/dist/esm/infiniteloading.taro-f8f23ac6.js +143 -0
- package/dist/esm/input.taro-27d686c9.js +164 -0
- package/dist/esm/inputnumber.taro-6657d2c1.js +197 -0
- package/dist/esm/layout.taro-9659a928.js +11 -0
- package/dist/esm/menu.taro-cd0fef41.js +122 -0
- package/dist/esm/menuitem.taro-6076bffa.js +142 -0
- package/dist/esm/navbar.taro-5e1a0835.js +61 -0
- package/dist/esm/noticebar.taro-2f02b2ad.js +369 -0
- package/dist/esm/notify.taro-5768403d.js +75 -0
- package/dist/esm/numberkeyboard.taro-ad8afaf9.js +136 -0
- package/dist/esm/nutui-react.es.js +206 -118
- package/dist/esm/offsetContext-f32a9246.js +5 -0
- package/dist/esm/overlay.taro-75012bd3.js +77 -0
- package/dist/esm/pagination.taro-63607c3b.js +94 -0
- package/dist/esm/picker.taro-0570ec32.js +481 -0
- package/dist/esm/popover.taro-ad483372.js +162 -0
- package/dist/esm/popup.taro-e756f3fc.js +150 -0
- package/dist/esm/price.taro-479f1b82.js +80 -0
- package/dist/esm/progress.taro-437b9f6a.js +66 -0
- package/dist/esm/pulltorefresh.taro-6afe4805.js +138 -0
- package/dist/esm/radio.taro-5d6ca4ad.js +153 -0
- package/dist/esm/range.taro-615e193a.js +259 -0
- package/dist/esm/rate.taro-78c66969.js +77 -0
- package/dist/esm/row.taro-8b7febd4.js +48 -0
- package/dist/esm/searchbar.taro-37ade36e.js +159 -0
- package/dist/esm/shortpassword.taro-f7292032.js +146 -0
- package/dist/esm/sidenavbar.taro-9f210df4.js +51 -0
- package/dist/esm/sidenavbaritem.taro-32a45ce6.js +12 -0
- package/dist/esm/signature.taro-c57469aa.js +146 -0
- package/dist/esm/skeleton.taro-9ff9baf4.js +71 -0
- package/dist/esm/step.taro-2f55e4f2.js +63 -0
- package/dist/esm/steps.taro-196c1f59.js +31 -0
- package/dist/esm/sticky.taro-f8ae8d5e.js +154 -0
- package/dist/esm/subsidenavbar.taro-abe07673.js +64 -0
- package/dist/esm/swipe.taro-de80fcd8.js +180 -0
- package/dist/esm/swiper.taro-4aeb8526.js +86 -0
- package/dist/esm/swiperitem.taro-ef7342e8.js +14 -0
- package/dist/esm/switch.taro-f0da73a3.js +44 -0
- package/dist/esm/tabbar.taro-18eee41f.js +55 -0
- package/dist/esm/tabbaritem.taro-89646ca1.js +47 -0
- package/dist/esm/table.taro-15a55c5d.js +100 -0
- package/dist/esm/tabpane.taro-f8d92ece.js +21 -0
- package/dist/esm/tabs.taro-66164782.js +146 -0
- package/dist/esm/tag.taro-1b4134a5.js +92 -0
- package/dist/esm/textarea.taro-c110565e.js +102 -0
- package/dist/esm/timedetail.taro-8d2acbbf.js +41 -0
- package/dist/esm/timepannel.taro-ee4c5dfa.js +22 -0
- package/dist/esm/timeselect.taro-069deedd.js +133 -0
- package/dist/esm/toast.taro-92c10e1d.js +114 -0
- package/dist/esm/trendarrow.taro-0cf43935.js +72 -0
- package/dist/esm/typings-11d83a22.js +7 -0
- package/dist/esm/uploader.taro-7e38fc37.js +519 -0
- package/dist/esm/use-client-rect-f317804e.js +10 -0
- package/dist/esm/use-props-value-7ac1b1b5.js +16 -0
- package/dist/esm/use-touch-ff43512c.js +69 -0
- package/dist/esm/video-5d106e33.js +73 -0
- package/dist/esm/virtuallist.taro-99f03769.js +195 -0
- package/dist/esm/watermark.taro-cef29c03.js +109 -0
- package/dist/locales/base.js +1 -1
- package/dist/locales/en-US.js +1 -1
- package/dist/locales/id-ID.js +1 -1
- package/dist/locales/zh-CN.js +1 -1
- package/dist/locales/zh-TW.js +1 -1
- package/dist/locales/zh-UG.js +1 -1
- package/dist/nutui.react.mjs +16980 -22641
- package/dist/nutui.react.umd.js +17061 -22738
- package/dist/packages/audio/audio.scss +2 -15
- package/dist/packages/badge/badge.scss +8 -18
- package/dist/packages/calendar/calendar.scss +0 -30
- package/dist/packages/cascader/cascader.scss +0 -26
- package/dist/packages/cellgroup/cellgroup.scss +20 -16
- package/dist/packages/checkbox/checkbox.scss +8 -11
- package/dist/packages/circleprogress/circleprogress.scss +0 -9
- package/dist/packages/dialog/dialog.scss +36 -65
- package/dist/packages/elevator/elevator.scss +2 -28
- package/dist/packages/empty/empty.scss +0 -9
- package/dist/packages/imagepreview/imagepreview.scss +52 -16
- package/dist/packages/input/input.scss +13 -180
- package/dist/packages/menu/menu.scss +44 -55
- package/dist/packages/menuitem/menuitem.scss +16 -26
- package/dist/packages/navbar/navbar.scss +16 -115
- package/dist/packages/noticebar/noticebar.scss +18 -19
- package/dist/packages/notify/notify.scss +1 -1
- package/dist/packages/numberkeyboard/numberkeyboard.scss +29 -77
- package/dist/packages/overlay/overlay.scss +11 -4
- package/dist/packages/picker/picker.scss +66 -137
- package/dist/packages/popup/popup.scss +0 -16
- package/dist/packages/price/price.scss +8 -0
- package/dist/packages/progress/progress.scss +19 -58
- package/dist/packages/pulltorefresh/pulltorefresh.scss +0 -8
- package/dist/packages/radio/radio.scss +13 -32
- package/dist/packages/radiogroup/radiogroup.scss +17 -51
- package/dist/packages/range/range.scss +24 -49
- package/dist/packages/row/row.scss +13 -31
- package/dist/packages/sidenavbar/sidenavbar.scss +0 -19
- package/dist/packages/step/step.scss +9 -62
- package/dist/packages/steps/steps.scss +2 -0
- package/dist/packages/swiper/swiper.scss +3 -18
- package/dist/packages/switch/switch.scss +13 -31
- package/dist/packages/tabbar/tabbar.scss +16 -22
- package/dist/packages/tabbaritem/tabbaritem.scss +9 -70
- package/dist/packages/table/table.scss +0 -56
- package/dist/packages/tabs/tabs.scss +196 -225
- package/dist/packages/textarea/textarea.scss +5 -12
- package/dist/packages/uploader/uploader.scss +2 -28
- package/dist/style.css +1 -1
- package/dist/style.mjs +1 -1
- package/dist/styles/themes/default.scss +17 -18
- package/dist/styles/variables-jmapp.scss +120 -240
- package/dist/styles/variables.scss +139 -252
- package/dist/types/index.d.ts +572 -722
- package/package.json +2 -2
- package/dist/esm/AvatarContext-c96afdcc.js +0 -5
- package/dist/esm/Icon.js +0 -64
- package/dist/esm/UserContext-0aac9a82.js +0 -5
- package/dist/esm/UserContext-e402e1a6.js +0 -5
- package/dist/esm/UserContext-e8176108.js +0 -5
- package/dist/esm/actionsheet.taro-b76a342e.js +0 -53
- package/dist/esm/address.taro-1812caeb.js +0 -461
- package/dist/esm/animate.taro-fb7986d6.js +0 -40
- package/dist/esm/animatingnumbers.taro-03e5d61d.js +0 -104
- package/dist/esm/audio.taro-f672a68c.js +0 -162
- package/dist/esm/avatar.taro-de157a1f.js +0 -105
- package/dist/esm/avatargroup-b476ac68.js +0 -34
- package/dist/esm/backtop.taro-ba271b8f.js +0 -52
- package/dist/esm/badge.taro-ae154f41.js +0 -50
- package/dist/esm/barrage.taro-80df08d3.js +0 -94
- package/dist/esm/bem-350c1702.js +0 -5
- package/dist/esm/button.taro-a1c9512f.js +0 -65
- package/dist/esm/calendar.taro-b6b147ca.js +0 -65
- package/dist/esm/calendaritem.taro-ae167e59.js +0 -787
- package/dist/esm/can-use-dom-3eeb5af4.js +0 -6
- package/dist/esm/card.taro-5e9b34c8.js +0 -33
- package/dist/esm/cascader.taro-9c0a1a38.js +0 -447
- package/dist/esm/cell.taro-26870740.js +0 -43
- package/dist/esm/cellgroup.taro-6e901b54.js +0 -24
- package/dist/esm/checkbox.taro-785c528b.js +0 -168
- package/dist/esm/circleprogress.taro-79854448.js +0 -109
- package/dist/esm/col.taro-53eed3cc.js +0 -41
- package/dist/esm/collapse.taro-35a8a0d6.js +0 -79
- package/dist/esm/collapseitem-690eb91c.js +0 -68
- package/dist/esm/configprovider-9960f0fb.js +0 -19
- package/dist/esm/configprovider.taro-c8c54556.js +0 -45
- package/dist/esm/countdown.taro-0e6bf7a2.js +0 -225
- package/dist/esm/datepicker.taro-439e2080.js +0 -275
- package/dist/esm/dialog.taro-00ac41fd.js +0 -118
- package/dist/esm/divider.taro-6c1657ce.js +0 -31
- package/dist/esm/drag.taro-79bb8744.js +0 -110
- package/dist/esm/elevator.taro-81a11ecc.js +0 -178
- package/dist/esm/ellipsis.taro-b6cda065.js +0 -241
- package/dist/esm/empty.taro-fde835ca.js +0 -62
- package/dist/esm/fixednav.taro-39fbd47a.js +0 -54
- package/dist/esm/form.taro-0d83f1e8.js +0 -179
- package/dist/esm/formitem.taro-0de07d1e.js +0 -89
- package/dist/esm/get-scroll-parent-b4a07e65.js +0 -25
- package/dist/esm/grid.taro-3797169c.js +0 -49
- package/dist/esm/griditem.taro-04f59ae1.js +0 -80
- package/dist/esm/image.taro-edb572bb.js +0 -64
- package/dist/esm/imagepreview.taro-867ee24a.js +0 -167
- package/dist/esm/index-5bcb0ff8.js +0 -7
- package/dist/esm/indicator.taro-c10334e8.js +0 -30
- package/dist/esm/infiniteloading.taro-73c9b8ca.js +0 -141
- package/dist/esm/input.taro-10ed5500.js +0 -237
- package/dist/esm/inputnumber.taro-108c4784.js +0 -199
- package/dist/esm/layout.taro-9046d093.js +0 -11
- package/dist/esm/menu.taro-54951911.js +0 -98
- package/dist/esm/menuitem.taro-86a6bb6c.js +0 -128
- package/dist/esm/navbar.taro-69f47d51.js +0 -77
- package/dist/esm/noticebar.taro-49e7441f.js +0 -427
- package/dist/esm/notify.taro-e17c6f82.js +0 -75
- package/dist/esm/numberkeyboard.taro-81b36e5e.js +0 -159
- package/dist/esm/offsetContext-c2a746fa.js +0 -5
- package/dist/esm/overlay.taro-ad0d4775.js +0 -75
- package/dist/esm/pagination.taro-60b22b27.js +0 -91
- package/dist/esm/picker.taro-5c9030a7.js +0 -423
- package/dist/esm/popover.taro-2a57eae4.js +0 -153
- package/dist/esm/popup.taro-124b9bab.js +0 -142
- package/dist/esm/price.taro-776ed16e.js +0 -83
- package/dist/esm/progress.taro-24392ef3.js +0 -88
- package/dist/esm/pulltorefresh.taro-d5fcfcb0.js +0 -181
- package/dist/esm/radio.taro-51e10152.js +0 -177
- package/dist/esm/range.taro-7a2b6ca1.js +0 -332
- package/dist/esm/rate.taro-57341aa9.js +0 -77
- package/dist/esm/row.taro-f64d4a13.js +0 -46
- package/dist/esm/searchbar.taro-eef468bb.js +0 -152
- package/dist/esm/shortpassword.taro-9a2c98ad.js +0 -119
- package/dist/esm/sidenavbar.taro-0265812f.js +0 -35
- package/dist/esm/sidenavbaritem.taro-bb80dbf4.js +0 -12
- package/dist/esm/signature.taro-f01b2b05.js +0 -143
- package/dist/esm/skeleton.taro-64e858a2.js +0 -62
- package/dist/esm/step.taro-2ec1f283.js +0 -58
- package/dist/esm/steps.taro-c82d2252.js +0 -30
- package/dist/esm/sticky.taro-b5bde7b1.js +0 -136
- package/dist/esm/subsidenavbar.taro-3cce8442.js +0 -63
- package/dist/esm/supports-passive-c85ef996.js +0 -18
- package/dist/esm/swipe.taro-350c9a94.js +0 -177
- package/dist/esm/swiper.taro-7a94e211.js +0 -451
- package/dist/esm/swiperitem-c9e3d0d5.js +0 -29
- package/dist/esm/switch.taro-34ca8228.js +0 -50
- package/dist/esm/tabbar.taro-9acfc2fa.js +0 -59
- package/dist/esm/tabbaritem.taro-42ba353f.js +0 -55
- package/dist/esm/table.taro-3946697c.js +0 -95
- package/dist/esm/tabpane.taro-4ca340ef.js +0 -23
- package/dist/esm/tabs.taro-be8cacb5.js +0 -140
- package/dist/esm/tag.taro-0c2567de.js +0 -92
- package/dist/esm/textarea.taro-a0f79515.js +0 -94
- package/dist/esm/timedetail.taro-fce4e614.js +0 -44
- package/dist/esm/timepannel.taro-fd3d008d.js +0 -22
- package/dist/esm/timeselect.taro-5b047850.js +0 -133
- package/dist/esm/toast.taro-e4f44812.js +0 -108
- package/dist/esm/trendarrow.taro-7cf90def.js +0 -70
- package/dist/esm/typings-d8491423.js +0 -6
- package/dist/esm/uploader.taro-0cca7e97.js +0 -496
- package/dist/esm/use-client-rect-1f8ed1fe.js +0 -18
- package/dist/esm/use-props-value-ae7ee726.js +0 -15
- package/dist/esm/use-touch-db24bb5c.js +0 -69
- package/dist/esm/video-7ed508cc.js +0 -67
- package/dist/esm/virtuallist.taro-35b9bd9a.js +0 -214
- package/dist/esm/watermark.taro-c780d360.js +0 -114
- package/dist/esm/zh-CN-b4f493ba.js +0 -131
- package/dist/packages/icon/icon.scss +0 -0
|
@@ -1,451 +0,0 @@
|
|
|
1
|
-
import React__default, { useRef, useState, useMemo, useEffect } from 'react';
|
|
2
|
-
import classNames from 'classnames';
|
|
3
|
-
import { nextTick, useReady, createSelectorQuery } from '@tarojs/taro';
|
|
4
|
-
import { D as DataContext } from './UserContext-e8176108.js';
|
|
5
|
-
import { c as cn } from './bem-350c1702.js';
|
|
6
|
-
|
|
7
|
-
const defaultProps = {
|
|
8
|
-
width: typeof window === 'object' ? window.innerWidth : 375,
|
|
9
|
-
height: 0,
|
|
10
|
-
duration: 500,
|
|
11
|
-
initPage: 0,
|
|
12
|
-
autoPlay: 0,
|
|
13
|
-
direction: 'horizontal',
|
|
14
|
-
paginationColor: '#fff',
|
|
15
|
-
paginationBgColor: '#ddd',
|
|
16
|
-
paginationVisible: false,
|
|
17
|
-
loop: true,
|
|
18
|
-
touchable: true,
|
|
19
|
-
isPreventDefault: true,
|
|
20
|
-
isStopPropagation: true,
|
|
21
|
-
isCenter: false,
|
|
22
|
-
className: '',
|
|
23
|
-
};
|
|
24
|
-
const DISTANCE = 5;
|
|
25
|
-
const Swiper = React__default.forwardRef((props, ref) => {
|
|
26
|
-
const propSwiper = { ...defaultProps, ...props };
|
|
27
|
-
const { children, direction, className, pageContent, onChange, initPage, paginationColor, paginationVisible, touchable, isPreventDefault, isStopPropagation, autoPlay, isCenter, ...rest } = propSwiper;
|
|
28
|
-
const container = useRef(null);
|
|
29
|
-
const innerRef = useRef(null);
|
|
30
|
-
const _swiper = useRef({
|
|
31
|
-
moving: false,
|
|
32
|
-
autoplayTimer: null,
|
|
33
|
-
width: 0,
|
|
34
|
-
height: 0,
|
|
35
|
-
offset: 0,
|
|
36
|
-
size: 0,
|
|
37
|
-
});
|
|
38
|
-
const [refRandomId] = useState(Math.random().toString(36).slice(-8));
|
|
39
|
-
const isVertical = direction === 'vertical';
|
|
40
|
-
const [rect, setRect] = useState(null);
|
|
41
|
-
// eslint-disable-next-line prefer-const
|
|
42
|
-
let [active, setActive] = useState(0);
|
|
43
|
-
const [width, setWidth] = useState(0);
|
|
44
|
-
const [height, setHeight] = useState(0);
|
|
45
|
-
const [offset, setOffset] = useState(0);
|
|
46
|
-
const [childOffset, setChildOffset] = useState([]);
|
|
47
|
-
const [ready, setReady] = useState(false);
|
|
48
|
-
let size = isVertical ? height : width;
|
|
49
|
-
const [touch, setTouch] = useState({
|
|
50
|
-
startX: 0,
|
|
51
|
-
startY: 0,
|
|
52
|
-
deltaX: 0,
|
|
53
|
-
deltaY: 0,
|
|
54
|
-
offsetX: 0,
|
|
55
|
-
offsetY: 0,
|
|
56
|
-
stateDirection: '',
|
|
57
|
-
delta: 0,
|
|
58
|
-
touchTime: 0,
|
|
59
|
-
});
|
|
60
|
-
const { childs, childCount } = useMemo(() => {
|
|
61
|
-
let childCount = 0;
|
|
62
|
-
const childs = React__default.Children.map(props.children, (child) => {
|
|
63
|
-
if (!React__default.isValidElement(child))
|
|
64
|
-
return null;
|
|
65
|
-
childCount++;
|
|
66
|
-
return child;
|
|
67
|
-
});
|
|
68
|
-
return {
|
|
69
|
-
childs,
|
|
70
|
-
childCount,
|
|
71
|
-
};
|
|
72
|
-
}, [props.children]);
|
|
73
|
-
let trackSize = childCount * Number(size);
|
|
74
|
-
// 父组件参数传入子组件item
|
|
75
|
-
const parent = {
|
|
76
|
-
propSwiper,
|
|
77
|
-
size,
|
|
78
|
-
};
|
|
79
|
-
const minOffset = (() => {
|
|
80
|
-
if (rect) {
|
|
81
|
-
const base = isVertical ? rect?.height : rect?.width;
|
|
82
|
-
return base - Number(size) * childCount;
|
|
83
|
-
}
|
|
84
|
-
return 0;
|
|
85
|
-
})();
|
|
86
|
-
// 清除定时器
|
|
87
|
-
const stopAutoPlay = () => {
|
|
88
|
-
clearTimeout(_swiper.current.autoplayTimer);
|
|
89
|
-
_swiper.current.autoplayTimer = null;
|
|
90
|
-
};
|
|
91
|
-
// 定时轮播
|
|
92
|
-
const autoplay = () => {
|
|
93
|
-
if (propSwiper.autoPlay <= 0 || childCount <= 1)
|
|
94
|
-
return;
|
|
95
|
-
stopAutoPlay();
|
|
96
|
-
_swiper.current.autoplayTimer = setTimeout(() => {
|
|
97
|
-
next();
|
|
98
|
-
autoplay();
|
|
99
|
-
}, Number(propSwiper.autoPlay));
|
|
100
|
-
};
|
|
101
|
-
// 重置首尾位置信息
|
|
102
|
-
const resettPosition = () => {
|
|
103
|
-
_swiper.current.moving = true;
|
|
104
|
-
if (active <= -1) {
|
|
105
|
-
move({ pace: childCount });
|
|
106
|
-
}
|
|
107
|
-
if (active >= childCount) {
|
|
108
|
-
move({ pace: -childCount });
|
|
109
|
-
}
|
|
110
|
-
};
|
|
111
|
-
// 上一页
|
|
112
|
-
const prev = () => {
|
|
113
|
-
resettPosition();
|
|
114
|
-
touchReset();
|
|
115
|
-
requestFrame(() => {
|
|
116
|
-
requestFrame(() => {
|
|
117
|
-
_swiper.current.moving = false;
|
|
118
|
-
move({
|
|
119
|
-
pace: -1,
|
|
120
|
-
isEmit: true,
|
|
121
|
-
});
|
|
122
|
-
});
|
|
123
|
-
});
|
|
124
|
-
};
|
|
125
|
-
// 下一页
|
|
126
|
-
const next = () => {
|
|
127
|
-
resettPosition();
|
|
128
|
-
touchReset();
|
|
129
|
-
requestFrame(() => {
|
|
130
|
-
requestFrame(() => {
|
|
131
|
-
_swiper.current.moving = false;
|
|
132
|
-
move({
|
|
133
|
-
pace: 1,
|
|
134
|
-
isEmit: true,
|
|
135
|
-
});
|
|
136
|
-
});
|
|
137
|
-
});
|
|
138
|
-
};
|
|
139
|
-
// 前往指定页
|
|
140
|
-
const to = (index) => {
|
|
141
|
-
resettPosition();
|
|
142
|
-
touchReset();
|
|
143
|
-
requestFrame(() => {
|
|
144
|
-
requestFrame(() => {
|
|
145
|
-
_swiper.current.moving = false;
|
|
146
|
-
let targetIndex;
|
|
147
|
-
if (props.loop && childCount === index) {
|
|
148
|
-
targetIndex = active === 0 ? 0 : index;
|
|
149
|
-
}
|
|
150
|
-
else {
|
|
151
|
-
targetIndex = index % childCount;
|
|
152
|
-
}
|
|
153
|
-
move({
|
|
154
|
-
pace: targetIndex - active,
|
|
155
|
-
isEmit: true,
|
|
156
|
-
});
|
|
157
|
-
});
|
|
158
|
-
});
|
|
159
|
-
};
|
|
160
|
-
const resize = () => {
|
|
161
|
-
init(active);
|
|
162
|
-
};
|
|
163
|
-
// 切换方法
|
|
164
|
-
const move = ({ pace = 0, offset = 0, isEmit = false, movingStatus = false, }) => {
|
|
165
|
-
if (childCount <= 1)
|
|
166
|
-
return;
|
|
167
|
-
const targetActive = getActive(pace);
|
|
168
|
-
// 父级容器偏移量
|
|
169
|
-
const targetOffset = getOffset(targetActive, offset);
|
|
170
|
-
// 如果循环,调整开头结尾图片位置
|
|
171
|
-
if (props.loop) {
|
|
172
|
-
if (Array.isArray(children) &&
|
|
173
|
-
children[0] &&
|
|
174
|
-
targetOffset !== minOffset) {
|
|
175
|
-
const rightBound = targetOffset < minOffset;
|
|
176
|
-
childOffset[0] = rightBound ? trackSize : 0;
|
|
177
|
-
}
|
|
178
|
-
if (Array.isArray(children) &&
|
|
179
|
-
children[childCount - 1] &&
|
|
180
|
-
targetOffset !== 0) {
|
|
181
|
-
const leftBound = targetOffset > 0;
|
|
182
|
-
childOffset[childCount - 1] = leftBound ? -trackSize : 0;
|
|
183
|
-
}
|
|
184
|
-
setChildOffset(childOffset);
|
|
185
|
-
}
|
|
186
|
-
if (isEmit && active !== targetActive) {
|
|
187
|
-
props.onChange && props.onChange((targetActive + childCount) % childCount);
|
|
188
|
-
}
|
|
189
|
-
active = targetActive;
|
|
190
|
-
setActive(targetActive);
|
|
191
|
-
setOffset(targetOffset);
|
|
192
|
-
getStyle(targetOffset);
|
|
193
|
-
};
|
|
194
|
-
// 确定当前active 元素
|
|
195
|
-
const getActive = (pace) => {
|
|
196
|
-
if (pace) {
|
|
197
|
-
const _active = active + pace;
|
|
198
|
-
if (props.loop) {
|
|
199
|
-
return range(_active, -1, childCount);
|
|
200
|
-
}
|
|
201
|
-
return range(_active, 0, childCount - 1);
|
|
202
|
-
}
|
|
203
|
-
return active;
|
|
204
|
-
};
|
|
205
|
-
// 计算位移
|
|
206
|
-
const getOffset = (active, offset = 0) => {
|
|
207
|
-
let currentPosition = active * Number(size);
|
|
208
|
-
if (!props.loop) {
|
|
209
|
-
currentPosition = Math.min(currentPosition, -minOffset);
|
|
210
|
-
}
|
|
211
|
-
let targetOffset = offset - currentPosition;
|
|
212
|
-
if (!props.loop) {
|
|
213
|
-
targetOffset = range(targetOffset, minOffset, 0);
|
|
214
|
-
}
|
|
215
|
-
return targetOffset;
|
|
216
|
-
};
|
|
217
|
-
// 浏览器 帧 事件
|
|
218
|
-
const requestFrame = (fn) => {
|
|
219
|
-
window.requestAnimationFrame.call(window, fn);
|
|
220
|
-
};
|
|
221
|
-
// 取值 方法
|
|
222
|
-
const range = (num, min, max) => {
|
|
223
|
-
return Math.min(Math.max(num, min), max);
|
|
224
|
-
};
|
|
225
|
-
const getDirection = (x, y) => {
|
|
226
|
-
if (x > y && x > DISTANCE)
|
|
227
|
-
return 'horizontal';
|
|
228
|
-
if (y > x && y > DISTANCE)
|
|
229
|
-
return 'vertical';
|
|
230
|
-
return '';
|
|
231
|
-
};
|
|
232
|
-
// 重置 全部位移信息
|
|
233
|
-
const touchReset = () => {
|
|
234
|
-
touch.startX = 0;
|
|
235
|
-
touch.startY = 0;
|
|
236
|
-
touch.deltaX = 0;
|
|
237
|
-
touch.deltaY = 0;
|
|
238
|
-
touch.offsetX = 0;
|
|
239
|
-
touch.offsetY = 0;
|
|
240
|
-
touch.delta = 0;
|
|
241
|
-
touch.stateDirection = '';
|
|
242
|
-
touch.touchTime = 0;
|
|
243
|
-
};
|
|
244
|
-
// 触摸事件开始
|
|
245
|
-
const touchStart = (e) => {
|
|
246
|
-
touchReset();
|
|
247
|
-
touch.startX = e.touches[0].clientX;
|
|
248
|
-
touch.startY = e.touches[0].clientY;
|
|
249
|
-
};
|
|
250
|
-
// 触摸事件移动
|
|
251
|
-
const touchMove = (e) => {
|
|
252
|
-
touch.deltaX = e.touches[0].clientX - touch.startX;
|
|
253
|
-
touch.deltaY = e.touches[0].clientY - touch.startY;
|
|
254
|
-
touch.offsetX = Math.abs(touch.deltaX);
|
|
255
|
-
touch.offsetY = Math.abs(touch.deltaY);
|
|
256
|
-
touch.delta = isVertical ? touch.deltaY : touch.deltaX;
|
|
257
|
-
if (!touch.stateDirection) {
|
|
258
|
-
touch.stateDirection = getDirection(touch.offsetX, touch.offsetY);
|
|
259
|
-
}
|
|
260
|
-
};
|
|
261
|
-
const b = cn('swiper');
|
|
262
|
-
const classes = classNames(b(''));
|
|
263
|
-
const contentClass = classNames({
|
|
264
|
-
[`${b('inner')}`]: true,
|
|
265
|
-
[`${b('vertical')}`]: isVertical,
|
|
266
|
-
});
|
|
267
|
-
const getStyle = (moveOffset = offset) => {
|
|
268
|
-
const target = innerRef.current;
|
|
269
|
-
let _offset = 0;
|
|
270
|
-
if (!isCenter) {
|
|
271
|
-
_offset = moveOffset;
|
|
272
|
-
}
|
|
273
|
-
else {
|
|
274
|
-
const _size = isVertical ? height : width;
|
|
275
|
-
const val = isVertical
|
|
276
|
-
? rect?.height - _size
|
|
277
|
-
: rect?.width - _size;
|
|
278
|
-
_offset =
|
|
279
|
-
moveOffset +
|
|
280
|
-
(active === childCount - 1 && !props.loop ? -val / 2 : val / 2);
|
|
281
|
-
}
|
|
282
|
-
target.style.transitionDuration = `${_swiper.current.moving ? 0 : props.duration}ms`;
|
|
283
|
-
target.style[isVertical ? 'height' : 'width'] = `${Number(size) * childCount}px`;
|
|
284
|
-
target.style[isVertical ? 'width' : 'height'] = `${isVertical ? width : height}px`;
|
|
285
|
-
target.style.transform = `translate3D${!isVertical ? `(${_offset}px,0,0)` : `(0,${_offset}px,0)`}`;
|
|
286
|
-
};
|
|
287
|
-
const onTouchStart = (e) => {
|
|
288
|
-
if (props.isPreventDefault)
|
|
289
|
-
e.preventDefault();
|
|
290
|
-
if (props.isStopPropagation)
|
|
291
|
-
e.stopPropagation();
|
|
292
|
-
if (!props.touchable)
|
|
293
|
-
return;
|
|
294
|
-
touchStart(e);
|
|
295
|
-
touch.touchTime = Date.now();
|
|
296
|
-
stopAutoPlay();
|
|
297
|
-
resettPosition();
|
|
298
|
-
};
|
|
299
|
-
const onTouchMove = (e) => {
|
|
300
|
-
if (props.touchable && _swiper.current.moving) {
|
|
301
|
-
touchMove(e);
|
|
302
|
-
if (touch.stateDirection === props.direction) {
|
|
303
|
-
move({
|
|
304
|
-
offset: touch.delta,
|
|
305
|
-
});
|
|
306
|
-
}
|
|
307
|
-
}
|
|
308
|
-
};
|
|
309
|
-
const onTouchEnd = (e) => {
|
|
310
|
-
if (!props.touchable || !_swiper.current.moving)
|
|
311
|
-
return;
|
|
312
|
-
const speed = touch.delta / (Date.now() - touch.touchTime);
|
|
313
|
-
const isShouldMove = Math.abs(speed) > 0.3 || Math.abs(touch.delta) > +(size / 2).toFixed(2);
|
|
314
|
-
let pace = 0;
|
|
315
|
-
_swiper.current.moving = false;
|
|
316
|
-
if (isShouldMove && touch.stateDirection === props.direction) {
|
|
317
|
-
const offset = isVertical ? touch.offsetY : touch.offsetX;
|
|
318
|
-
if (props.loop) {
|
|
319
|
-
if (offset > 0) {
|
|
320
|
-
pace = touch.delta > 0 ? -1 : 1;
|
|
321
|
-
}
|
|
322
|
-
else {
|
|
323
|
-
pace = 0;
|
|
324
|
-
}
|
|
325
|
-
}
|
|
326
|
-
else {
|
|
327
|
-
pace = -Math[touch.delta > 0 ? 'ceil' : 'floor'](touch.delta / size);
|
|
328
|
-
}
|
|
329
|
-
move({
|
|
330
|
-
pace,
|
|
331
|
-
isEmit: true,
|
|
332
|
-
});
|
|
333
|
-
}
|
|
334
|
-
else if (touch.delta) {
|
|
335
|
-
move({ pace: 0 });
|
|
336
|
-
}
|
|
337
|
-
else {
|
|
338
|
-
getStyle();
|
|
339
|
-
}
|
|
340
|
-
autoplay();
|
|
341
|
-
};
|
|
342
|
-
useEffect(() => {
|
|
343
|
-
_swiper.current.activePagination = (active + childCount) % childCount;
|
|
344
|
-
}, [active]);
|
|
345
|
-
const queryRect = (element) => {
|
|
346
|
-
return new Promise((resolve) => {
|
|
347
|
-
const query = createSelectorQuery();
|
|
348
|
-
query.select(`#${element.id}`) &&
|
|
349
|
-
query.select(`#${element.id}`).boundingClientRect();
|
|
350
|
-
query.exec((res) => {
|
|
351
|
-
resolve(res[0]);
|
|
352
|
-
});
|
|
353
|
-
});
|
|
354
|
-
};
|
|
355
|
-
const init = async (active = +propSwiper.initPage) => {
|
|
356
|
-
const rect = await queryRect(container.current);
|
|
357
|
-
const _active = Math.max(Math.min(childCount - 1, active), 0);
|
|
358
|
-
const _width = propSwiper.width ? +propSwiper.width : rect?.width;
|
|
359
|
-
const _height = propSwiper.height ? +propSwiper.height : rect?.height;
|
|
360
|
-
size = isVertical ? _height : _width;
|
|
361
|
-
trackSize = childCount * Number(size);
|
|
362
|
-
const targetOffset = getOffset(_active);
|
|
363
|
-
_swiper.current.moving = true;
|
|
364
|
-
if (ready) {
|
|
365
|
-
_swiper.current.moving = false;
|
|
366
|
-
}
|
|
367
|
-
setRect(rect);
|
|
368
|
-
setActive(_active);
|
|
369
|
-
setWidth(_width);
|
|
370
|
-
setHeight(_height);
|
|
371
|
-
setOffset(targetOffset);
|
|
372
|
-
setReady(true);
|
|
373
|
-
};
|
|
374
|
-
useEffect(() => {
|
|
375
|
-
if (ready) {
|
|
376
|
-
getStyle();
|
|
377
|
-
}
|
|
378
|
-
}, [isVertical, width, height, offset, ready]);
|
|
379
|
-
useEffect(() => {
|
|
380
|
-
if (ready) {
|
|
381
|
-
stopAutoPlay();
|
|
382
|
-
autoplay();
|
|
383
|
-
}
|
|
384
|
-
return () => {
|
|
385
|
-
setReady(false);
|
|
386
|
-
};
|
|
387
|
-
}, [ready]);
|
|
388
|
-
useEffect(() => {
|
|
389
|
-
stopAutoPlay();
|
|
390
|
-
autoplay();
|
|
391
|
-
}, [children]);
|
|
392
|
-
useEffect(() => {
|
|
393
|
-
nextTick(() => {
|
|
394
|
-
init();
|
|
395
|
-
});
|
|
396
|
-
}, [propSwiper.initPage]);
|
|
397
|
-
useEffect(() => {
|
|
398
|
-
return () => {
|
|
399
|
-
stopAutoPlay();
|
|
400
|
-
};
|
|
401
|
-
}, []);
|
|
402
|
-
useReady(() => {
|
|
403
|
-
nextTick(() => {
|
|
404
|
-
init();
|
|
405
|
-
});
|
|
406
|
-
});
|
|
407
|
-
const itemStyle = (index) => {
|
|
408
|
-
const style = {};
|
|
409
|
-
const _direction = propSwiper.direction || direction;
|
|
410
|
-
const _size = size;
|
|
411
|
-
if (_size) {
|
|
412
|
-
style[_direction === 'horizontal' ? 'width' : 'height'] = `${_size}px`;
|
|
413
|
-
}
|
|
414
|
-
const offset = childOffset[index];
|
|
415
|
-
if (offset) {
|
|
416
|
-
style.transform = `translate3D${_direction === 'horizontal' ? `(${offset}px,0,0)` : `(0,${offset}px,0)`}`;
|
|
417
|
-
}
|
|
418
|
-
return style;
|
|
419
|
-
};
|
|
420
|
-
React__default.useImperativeHandle(ref, () => ({
|
|
421
|
-
to,
|
|
422
|
-
next,
|
|
423
|
-
prev,
|
|
424
|
-
resize,
|
|
425
|
-
}));
|
|
426
|
-
return (React__default.createElement(DataContext.Provider, { value: parent },
|
|
427
|
-
React__default.createElement("div", { className: `${classes} ${className}`, ref: container, ...rest, id: `container-${refRandomId}`, onTouchStart: onTouchStart, onTouchMove: onTouchMove, onTouchEnd: onTouchEnd,
|
|
428
|
-
// @ts-ignore
|
|
429
|
-
catchMove: isVertical },
|
|
430
|
-
React__default.createElement("div", { className: contentClass, ref: innerRef }, React__default.Children.map(childs, (child, index) => {
|
|
431
|
-
return (React__default.createElement("div", { className: b('item-wrapper'), style: itemStyle(index), key: index }, child));
|
|
432
|
-
})),
|
|
433
|
-
propSwiper.paginationVisible && !('pageContent' in propSwiper) ? (React__default.createElement("div", { className: classNames({
|
|
434
|
-
[`${b('pagination')}`]: true,
|
|
435
|
-
[`${b('pagination-vertical')}`]: isVertical,
|
|
436
|
-
}) }, React__default.Children.map(childs, (item, index) => {
|
|
437
|
-
return (React__default.createElement("i", { style: (active + childCount) % childCount === index
|
|
438
|
-
? {
|
|
439
|
-
backgroundColor: propSwiper.paginationColor,
|
|
440
|
-
}
|
|
441
|
-
: {
|
|
442
|
-
backgroundColor: propSwiper.paginationBgColor,
|
|
443
|
-
}, className: classNames({
|
|
444
|
-
active: (active + childCount) % childCount === index,
|
|
445
|
-
}), key: index }));
|
|
446
|
-
}))) : (React__default.createElement("div", null, pageContent)))));
|
|
447
|
-
});
|
|
448
|
-
Swiper.defaultProps = defaultProps;
|
|
449
|
-
Swiper.displayName = 'NutSwiper';
|
|
450
|
-
|
|
451
|
-
export { Swiper as S };
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import React__default, { useContext } from 'react';
|
|
2
|
-
import classNames from 'classnames';
|
|
3
|
-
import { D as DataContext } from './UserContext-e8176108.js';
|
|
4
|
-
import { c as cn } from './bem-350c1702.js';
|
|
5
|
-
|
|
6
|
-
const defaultProps = {
|
|
7
|
-
direction: 'horizontal',
|
|
8
|
-
};
|
|
9
|
-
const SwiperItem = React__default.forwardRef((props, ref) => {
|
|
10
|
-
const _props = { ...defaultProps, ...props };
|
|
11
|
-
const { className, style, children, direction, size } = _props;
|
|
12
|
-
const parent = useContext(DataContext);
|
|
13
|
-
const b = cn('swiper-item');
|
|
14
|
-
const classes = classNames(b(''), className);
|
|
15
|
-
const getStyle = () => {
|
|
16
|
-
const style = {};
|
|
17
|
-
const _direction = parent?.propSwiper.direction || direction;
|
|
18
|
-
const _size = parent?.size || size;
|
|
19
|
-
if (_size) {
|
|
20
|
-
style[_direction === 'horizontal' ? 'width' : 'height'] = `${_size}px`;
|
|
21
|
-
}
|
|
22
|
-
return style;
|
|
23
|
-
};
|
|
24
|
-
return (React__default.createElement("div", { className: classes, style: { ...style, ...getStyle() } }, children));
|
|
25
|
-
});
|
|
26
|
-
SwiperItem.defaultProps = defaultProps;
|
|
27
|
-
SwiperItem.displayName = 'NutSwiperItem';
|
|
28
|
-
|
|
29
|
-
export { SwiperItem as S };
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import React__default, { useState, useEffect } from 'react';
|
|
2
|
-
import { c as cn } from './bem-350c1702.js';
|
|
3
|
-
|
|
4
|
-
const defaultProps = {
|
|
5
|
-
isAsync: false,
|
|
6
|
-
checked: false,
|
|
7
|
-
disable: false,
|
|
8
|
-
activeColor: '',
|
|
9
|
-
inactiveColor: '',
|
|
10
|
-
activeText: '',
|
|
11
|
-
inactiveText: '',
|
|
12
|
-
className: '',
|
|
13
|
-
};
|
|
14
|
-
const Switch = (props) => {
|
|
15
|
-
const { isAsync, checked, disable, activeColor, inactiveColor, activeText, inactiveText, onChange, className, style, } = {
|
|
16
|
-
...defaultProps,
|
|
17
|
-
...props,
|
|
18
|
-
};
|
|
19
|
-
const [value, setValue] = useState(false);
|
|
20
|
-
const b = cn('switch');
|
|
21
|
-
useEffect(() => {
|
|
22
|
-
setValue(checked);
|
|
23
|
-
}, [checked]);
|
|
24
|
-
const classes = () => {
|
|
25
|
-
return `${b()} ${value ? 'switch-open' : 'switch-close'} ${disable ? `${b()}-disable` : ''} ${`${b()}-base`} ${className}`;
|
|
26
|
-
};
|
|
27
|
-
const styles = () => {
|
|
28
|
-
const myStyle = {
|
|
29
|
-
backgroundColor: value ? activeColor : inactiveColor,
|
|
30
|
-
...(style || {}),
|
|
31
|
-
};
|
|
32
|
-
return myStyle;
|
|
33
|
-
};
|
|
34
|
-
const onClick = (event) => {
|
|
35
|
-
if (disable)
|
|
36
|
-
return;
|
|
37
|
-
if (!isAsync) {
|
|
38
|
-
setValue(!value);
|
|
39
|
-
}
|
|
40
|
-
onChange && onChange(!value, event);
|
|
41
|
-
};
|
|
42
|
-
return (React__default.createElement("div", { className: classes(), onClick: (e) => onClick(e), style: styles() },
|
|
43
|
-
React__default.createElement("div", { className: "switch-button" },
|
|
44
|
-
!value && React__default.createElement("div", { className: "close-line" }),
|
|
45
|
-
activeText && (React__default.createElement(React__default.Fragment, null, value ? (React__default.createElement("div", { className: `${b('label')} open` }, activeText)) : (React__default.createElement("div", { className: `${b('label')} close` }, inactiveText)))))));
|
|
46
|
-
};
|
|
47
|
-
Switch.defaultProps = defaultProps;
|
|
48
|
-
Switch.displayName = 'NutSwitch';
|
|
49
|
-
|
|
50
|
-
export { Switch as S };
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import React__default, { useState, useEffect } from 'react';
|
|
2
|
-
import { c as cn } from './bem-350c1702.js';
|
|
3
|
-
|
|
4
|
-
const defaultProps = {
|
|
5
|
-
visible: 0,
|
|
6
|
-
bottom: false,
|
|
7
|
-
size: 20,
|
|
8
|
-
unactiveColor: '',
|
|
9
|
-
activeColor: '',
|
|
10
|
-
safeAreaInsetBottom: false,
|
|
11
|
-
className: '',
|
|
12
|
-
style: {},
|
|
13
|
-
onSwitch: (child, activeVisible) => { },
|
|
14
|
-
};
|
|
15
|
-
const Tabbar = (props) => {
|
|
16
|
-
const { children, visible, activeVisible, bottom, size, activeColor, unactiveColor, safeAreaInsetBottom, className, style, onSwitch, } = {
|
|
17
|
-
...defaultProps,
|
|
18
|
-
...props,
|
|
19
|
-
};
|
|
20
|
-
const b = cn('tabbar');
|
|
21
|
-
const [selectIndex, setSelectIndex] = useState(activeVisible || visible);
|
|
22
|
-
const handleClick = (idx) => {
|
|
23
|
-
if (!('activeVisible' in props)) {
|
|
24
|
-
setSelectIndex(idx);
|
|
25
|
-
}
|
|
26
|
-
};
|
|
27
|
-
useEffect(() => {
|
|
28
|
-
if (activeVisible !== undefined) {
|
|
29
|
-
setSelectIndex(activeVisible);
|
|
30
|
-
}
|
|
31
|
-
}, [activeVisible]);
|
|
32
|
-
return (React__default.createElement("div", { className: [
|
|
33
|
-
`${b()}`,
|
|
34
|
-
bottom ? `${b('bottom')}` : '',
|
|
35
|
-
safeAreaInsetBottom ? `${b('bottom')} ${b('safebottom')}` : '',
|
|
36
|
-
className,
|
|
37
|
-
].join(' '), style: style }, React__default.Children.map(children, (child, idx) => {
|
|
38
|
-
if (!React__default.isValidElement(child)) {
|
|
39
|
-
return null;
|
|
40
|
-
}
|
|
41
|
-
const childProps = {
|
|
42
|
-
...child.props,
|
|
43
|
-
active: idx === selectIndex,
|
|
44
|
-
index: idx,
|
|
45
|
-
unactiveColor,
|
|
46
|
-
activeColor,
|
|
47
|
-
size,
|
|
48
|
-
handleClick: () => {
|
|
49
|
-
handleClick(idx);
|
|
50
|
-
onSwitch(child, idx);
|
|
51
|
-
},
|
|
52
|
-
};
|
|
53
|
-
return React__default.cloneElement(child, childProps);
|
|
54
|
-
})));
|
|
55
|
-
};
|
|
56
|
-
Tabbar.defaultProps = defaultProps;
|
|
57
|
-
Tabbar.displayName = 'NutTabbar';
|
|
58
|
-
|
|
59
|
-
export { Tabbar as T };
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import React__default, { useEffect } from 'react';
|
|
2
|
-
import Taro from '@tarojs/taro';
|
|
3
|
-
import { c as cn } from './bem-350c1702.js';
|
|
4
|
-
import { C as ComponentDefaults } from './typings-d8491423.js';
|
|
5
|
-
|
|
6
|
-
const defaultProps = {
|
|
7
|
-
...ComponentDefaults,
|
|
8
|
-
dot: false,
|
|
9
|
-
className: '',
|
|
10
|
-
tabTitle: '',
|
|
11
|
-
icon: null,
|
|
12
|
-
href: '',
|
|
13
|
-
to: '',
|
|
14
|
-
num: '',
|
|
15
|
-
active: false,
|
|
16
|
-
activeColor: '',
|
|
17
|
-
unactiveColor: '',
|
|
18
|
-
index: 0,
|
|
19
|
-
handleClick: (idx) => { },
|
|
20
|
-
};
|
|
21
|
-
const TabbarItem = (props) => {
|
|
22
|
-
const { dot, className, style, tabTitle, icon, href, to, num, active, activeColor, unactiveColor, index, handleClick, } = {
|
|
23
|
-
...defaultProps,
|
|
24
|
-
...props,
|
|
25
|
-
};
|
|
26
|
-
const b = cn('tabbar-item');
|
|
27
|
-
const bIcon = cn('tabbar-item__icon-box');
|
|
28
|
-
useEffect(() => {
|
|
29
|
-
if (active && href) {
|
|
30
|
-
window.location.href = href;
|
|
31
|
-
return;
|
|
32
|
-
}
|
|
33
|
-
if (active && to) {
|
|
34
|
-
Taro.navigateTo({
|
|
35
|
-
url: to,
|
|
36
|
-
});
|
|
37
|
-
}
|
|
38
|
-
}, [active, href, to]);
|
|
39
|
-
return (React__default.createElement("div", { className: `${b({ active })} ${className}`, style: {
|
|
40
|
-
...style,
|
|
41
|
-
color: active ? activeColor : unactiveColor,
|
|
42
|
-
}, onClick: () => {
|
|
43
|
-
handleClick(index);
|
|
44
|
-
} },
|
|
45
|
-
React__default.createElement("div", { className: `${bIcon()}` },
|
|
46
|
-
!dot ? (React__default.createElement(React__default.Fragment, null,
|
|
47
|
-
num && num <= 99 && (React__default.createElement("div", { className: `${bIcon('tips', [bIcon('num')])}` }, num)),
|
|
48
|
-
num && num >= 100 && (React__default.createElement("div", { className: `${bIcon('tips', [bIcon('nums')])}` }, "99+")))) : (React__default.createElement("div", { className: `${bIcon('tips', [bIcon('dot')])}` })),
|
|
49
|
-
icon || null),
|
|
50
|
-
tabTitle && (React__default.createElement("div", { className: bIcon({ 'nav-word': true }, [
|
|
51
|
-
bIcon({ 'big-word': !icon }),
|
|
52
|
-
]) }, tabTitle))));
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
export { TabbarItem as T };
|