@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
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
import React, { useCallback, useContext } from "react";
|
|
2
|
+
import { CheckChecked, CheckNormal } from "@nutui/icons-react-taro";
|
|
3
|
+
import classNames from "classnames";
|
|
4
|
+
import { C as ComponentDefaults } from "./typings-11d83a22.js";
|
|
5
|
+
import { u as usePropsValue } from "./use-props-value-7ac1b1b5.js";
|
|
6
|
+
const RadioContext = React.createContext(null);
|
|
7
|
+
const defaultProps$1 = {
|
|
8
|
+
labelPosition: "right",
|
|
9
|
+
onChange: (value) => {
|
|
10
|
+
},
|
|
11
|
+
direction: "vertical",
|
|
12
|
+
options: []
|
|
13
|
+
};
|
|
14
|
+
const classPrefix = "nut-radiogroup";
|
|
15
|
+
const RadioGroup = React.forwardRef((props, ref) => {
|
|
16
|
+
const { children, className, value, defaultValue, onChange, labelPosition, direction, options, disabled, ...rest } = { ...defaultProps$1, ...props };
|
|
17
|
+
const [val2State, setVal2State] = usePropsValue({
|
|
18
|
+
defaultValue: props.defaultValue,
|
|
19
|
+
value: props.value,
|
|
20
|
+
finalValue: "",
|
|
21
|
+
onChange
|
|
22
|
+
});
|
|
23
|
+
const renderOptionsChildren = useCallback(() => {
|
|
24
|
+
return options == null ? void 0 : options.map(({ label, value: value2, disabled: disabled2, onChange: onChange2, ...rest2 }) => {
|
|
25
|
+
return React.createElement(Radio, { ...rest2, key: value2 == null ? void 0 : value2.toString(), children: label, value: value2, disabled: disabled2, onChange: onChange2, labelPosition, checked: value2 === val2State });
|
|
26
|
+
});
|
|
27
|
+
}, [options]);
|
|
28
|
+
return React.createElement(
|
|
29
|
+
RadioContext.Provider,
|
|
30
|
+
{ value: {
|
|
31
|
+
labelPosition: labelPosition || "right",
|
|
32
|
+
disabled,
|
|
33
|
+
value: val2State,
|
|
34
|
+
check: (value2) => {
|
|
35
|
+
setVal2State(value2);
|
|
36
|
+
},
|
|
37
|
+
uncheck: () => {
|
|
38
|
+
setVal2State("");
|
|
39
|
+
}
|
|
40
|
+
} },
|
|
41
|
+
React.createElement("div", { className: classNames(classPrefix, className, {
|
|
42
|
+
[`${classPrefix}--${props.direction}`]: props.direction
|
|
43
|
+
}), ...rest }, (options == null ? void 0 : options.length) ? renderOptionsChildren() : children)
|
|
44
|
+
);
|
|
45
|
+
});
|
|
46
|
+
RadioGroup.defaultProps = defaultProps$1;
|
|
47
|
+
RadioGroup.displayName = "NutRadioGroup";
|
|
48
|
+
const defaultProps = {
|
|
49
|
+
...ComponentDefaults,
|
|
50
|
+
disabled: false,
|
|
51
|
+
shape: "round",
|
|
52
|
+
value: "",
|
|
53
|
+
labelPosition: "right",
|
|
54
|
+
icon: null,
|
|
55
|
+
activeIcon: null,
|
|
56
|
+
onChange: (checked) => {
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
const Radio = (props) => {
|
|
60
|
+
const classPrefix2 = "nut-radio";
|
|
61
|
+
const { children, className, style, checked, defaultChecked, shape, value, icon, activeIcon, onChange, ...others } = {
|
|
62
|
+
...defaultProps,
|
|
63
|
+
...props
|
|
64
|
+
};
|
|
65
|
+
let { labelPosition, disabled, ...rest } = others;
|
|
66
|
+
let [checkedStatement, setCheckedStatement] = usePropsValue({
|
|
67
|
+
value: checked,
|
|
68
|
+
defaultValue: defaultChecked,
|
|
69
|
+
finalValue: false,
|
|
70
|
+
onChange
|
|
71
|
+
});
|
|
72
|
+
const context = useContext(RadioContext);
|
|
73
|
+
if (context) {
|
|
74
|
+
checkedStatement = context.value === value;
|
|
75
|
+
if (context.labelPosition !== void 0) {
|
|
76
|
+
labelPosition = context.labelPosition;
|
|
77
|
+
}
|
|
78
|
+
if (context.disabled !== void 0) {
|
|
79
|
+
disabled = context.disabled;
|
|
80
|
+
}
|
|
81
|
+
setCheckedStatement = (value2) => {
|
|
82
|
+
if (value2) {
|
|
83
|
+
context.check(props.value === void 0 ? "" : props.value);
|
|
84
|
+
} else {
|
|
85
|
+
context.uncheck();
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
const renderLabel = () => {
|
|
90
|
+
return React.createElement("div", { className: classNames(`${classPrefix2}__label`, {
|
|
91
|
+
[`${classPrefix2}__label--disabled`]: disabled
|
|
92
|
+
}) }, children);
|
|
93
|
+
};
|
|
94
|
+
const renderButton = () => {
|
|
95
|
+
return React.createElement("div", { className: classNames(`${classPrefix2}__button`, {
|
|
96
|
+
[`${classPrefix2}__button--active`]: checkedStatement,
|
|
97
|
+
[`${classPrefix2}__button--disabled`]: disabled
|
|
98
|
+
}) }, children);
|
|
99
|
+
};
|
|
100
|
+
const color = () => {
|
|
101
|
+
return {
|
|
102
|
+
[`${classPrefix2}__icon--disable`]: disabled,
|
|
103
|
+
[`${classPrefix2}__icon`]: checkedStatement,
|
|
104
|
+
[`${classPrefix2}__icon--unchecked`]: !checkedStatement
|
|
105
|
+
};
|
|
106
|
+
};
|
|
107
|
+
const renderIcon = () => {
|
|
108
|
+
const { icon: icon2, activeIcon: activeIcon2 } = props;
|
|
109
|
+
if (checkedStatement) {
|
|
110
|
+
return React.isValidElement(activeIcon2) ? React.cloneElement(activeIcon2, {
|
|
111
|
+
...activeIcon2.props,
|
|
112
|
+
className: classNames(color())
|
|
113
|
+
}) : React.createElement(CheckChecked, { className: classNames(color()) });
|
|
114
|
+
}
|
|
115
|
+
return React.isValidElement(icon2) ? React.cloneElement(icon2, {
|
|
116
|
+
...icon2.props,
|
|
117
|
+
className: classNames(color())
|
|
118
|
+
}) : React.createElement(CheckNormal, { className: classNames(color()) });
|
|
119
|
+
};
|
|
120
|
+
const reverse = labelPosition === "left";
|
|
121
|
+
const renderRadioItem = () => {
|
|
122
|
+
if (shape === "button") {
|
|
123
|
+
return renderButton();
|
|
124
|
+
}
|
|
125
|
+
if (reverse) {
|
|
126
|
+
return React.createElement(
|
|
127
|
+
React.Fragment,
|
|
128
|
+
null,
|
|
129
|
+
renderLabel(),
|
|
130
|
+
renderIcon()
|
|
131
|
+
);
|
|
132
|
+
}
|
|
133
|
+
return React.createElement(
|
|
134
|
+
React.Fragment,
|
|
135
|
+
null,
|
|
136
|
+
renderIcon(),
|
|
137
|
+
renderLabel()
|
|
138
|
+
);
|
|
139
|
+
};
|
|
140
|
+
const handleClick = (e) => {
|
|
141
|
+
if (disabled || checkedStatement)
|
|
142
|
+
return;
|
|
143
|
+
setCheckedStatement(!checkedStatement);
|
|
144
|
+
};
|
|
145
|
+
return React.createElement("div", { className: `${classPrefix2} ${className} ${reverse ? `${classPrefix2}--reverse` : ""}`, style, onClick: handleClick, ...rest }, renderRadioItem());
|
|
146
|
+
};
|
|
147
|
+
Radio.defaultProps = defaultProps;
|
|
148
|
+
Radio.displayName = "NutRadio";
|
|
149
|
+
Radio.Group = RadioGroup;
|
|
150
|
+
export {
|
|
151
|
+
Radio as R,
|
|
152
|
+
RadioGroup as a
|
|
153
|
+
};
|
|
@@ -0,0 +1,259 @@
|
|
|
1
|
+
import React, { useState, useRef, useEffect, useCallback } from "react";
|
|
2
|
+
import classNames from "classnames";
|
|
3
|
+
import { View } from "@tarojs/components";
|
|
4
|
+
import { u as useTouch } from "./use-touch-ff43512c.js";
|
|
5
|
+
import { g as getRectByTaro } from "./use-client-rect-f317804e.js";
|
|
6
|
+
import { C as ComponentDefaults } from "./typings-11d83a22.js";
|
|
7
|
+
import { u as usePropsValue } from "./use-props-value-7ac1b1b5.js";
|
|
8
|
+
const defaultProps = {
|
|
9
|
+
...ComponentDefaults,
|
|
10
|
+
range: false,
|
|
11
|
+
min: 0,
|
|
12
|
+
max: 100,
|
|
13
|
+
step: 1,
|
|
14
|
+
vertical: false,
|
|
15
|
+
marks: {}
|
|
16
|
+
};
|
|
17
|
+
const Range = (props) => {
|
|
18
|
+
const { className, range, disabled, button, vertical, marks, onChange, onStart, onEnd, minDescription, maxDescription, currentDescription, min, max, step, value, defaultValue } = { ...defaultProps, ...props };
|
|
19
|
+
const classPrefix = "nut-range";
|
|
20
|
+
const [buttonIndex, setButtonIndex] = useState(0);
|
|
21
|
+
const [dragStatus, setDragStatus] = useState("start");
|
|
22
|
+
const touch = useTouch();
|
|
23
|
+
const root = useRef(null);
|
|
24
|
+
const [marksList, setMarksList] = useState([]);
|
|
25
|
+
const [startValue, setStartValue] = useState(0);
|
|
26
|
+
const handleChange = (value2) => {
|
|
27
|
+
onChange && onChange(value2);
|
|
28
|
+
};
|
|
29
|
+
const [current, setCurrent] = usePropsValue({
|
|
30
|
+
value,
|
|
31
|
+
defaultValue,
|
|
32
|
+
finalValue: 0,
|
|
33
|
+
onChange: handleChange
|
|
34
|
+
});
|
|
35
|
+
const [exactValue, setEaxctValue] = useState(() => value || defaultValue || 0);
|
|
36
|
+
useEffect(() => {
|
|
37
|
+
if (marks) {
|
|
38
|
+
const marksKeys = Object.keys(marks);
|
|
39
|
+
const list = marksKeys.map(parseFloat).sort((a, b) => a - b).filter((point) => point >= min && point <= max);
|
|
40
|
+
setMarksList(list);
|
|
41
|
+
}
|
|
42
|
+
}, [marks]);
|
|
43
|
+
const scope = () => {
|
|
44
|
+
return max - min;
|
|
45
|
+
};
|
|
46
|
+
const classes = classNames(classPrefix, {
|
|
47
|
+
[`${classPrefix}-disabled`]: disabled,
|
|
48
|
+
[`${classPrefix}-vertical`]: vertical
|
|
49
|
+
});
|
|
50
|
+
const containerClasses = classNames(`${classPrefix}-container`, className, {
|
|
51
|
+
[`${classPrefix}-container-vertical`]: vertical
|
|
52
|
+
});
|
|
53
|
+
const markClassName = useCallback((mark) => {
|
|
54
|
+
const classPrefix2 = "nut-range-mark";
|
|
55
|
+
let lowerBound = min;
|
|
56
|
+
let upperBound = max;
|
|
57
|
+
if (range && Array.isArray(current)) {
|
|
58
|
+
lowerBound = current[0];
|
|
59
|
+
upperBound = current[1];
|
|
60
|
+
} else {
|
|
61
|
+
upperBound = current;
|
|
62
|
+
}
|
|
63
|
+
const isActive = mark <= upperBound && mark >= lowerBound;
|
|
64
|
+
return [
|
|
65
|
+
`${classPrefix2}-text`,
|
|
66
|
+
`${isActive ? `${classPrefix2}-text-active` : ""}`
|
|
67
|
+
].join(" ");
|
|
68
|
+
}, [range, current, min, max]);
|
|
69
|
+
const isRange = (val) => {
|
|
70
|
+
return !!range && Array.isArray(val);
|
|
71
|
+
};
|
|
72
|
+
const calcMainAxis = () => {
|
|
73
|
+
const modelVal = current;
|
|
74
|
+
if (isRange(modelVal)) {
|
|
75
|
+
return `${(modelVal[1] - modelVal[0]) * 100 / scope()}%`;
|
|
76
|
+
}
|
|
77
|
+
return `${(modelVal - min) * 100 / scope()}%`;
|
|
78
|
+
};
|
|
79
|
+
const calcOffset = () => {
|
|
80
|
+
const modelVal = current;
|
|
81
|
+
if (isRange(modelVal)) {
|
|
82
|
+
return `${(modelVal[0] - min) * 100 / scope()}%`;
|
|
83
|
+
}
|
|
84
|
+
return `0%`;
|
|
85
|
+
};
|
|
86
|
+
const barStyle = () => {
|
|
87
|
+
if (vertical) {
|
|
88
|
+
return {
|
|
89
|
+
height: calcMainAxis(),
|
|
90
|
+
top: calcOffset(),
|
|
91
|
+
transition: dragStatus ? "none" : void 0
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
return {
|
|
95
|
+
width: calcMainAxis(),
|
|
96
|
+
left: calcOffset(),
|
|
97
|
+
transition: dragStatus ? "none" : void 0
|
|
98
|
+
};
|
|
99
|
+
};
|
|
100
|
+
const marksStyle = (mark) => {
|
|
101
|
+
let style = {
|
|
102
|
+
left: `${(mark - min) / scope() * 100}%`
|
|
103
|
+
};
|
|
104
|
+
if (vertical) {
|
|
105
|
+
style = {
|
|
106
|
+
top: `${(mark - min) / scope() * 100}%`
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
return style;
|
|
110
|
+
};
|
|
111
|
+
const tickClass = (mark) => {
|
|
112
|
+
if (range && Array.isArray(current)) {
|
|
113
|
+
return mark <= current[1] && mark >= current[0];
|
|
114
|
+
}
|
|
115
|
+
return mark <= current;
|
|
116
|
+
};
|
|
117
|
+
const format = (value2) => {
|
|
118
|
+
value2 = Math.max(+min, Math.min(value2, +max));
|
|
119
|
+
return Math.round(value2 / +step) * +step;
|
|
120
|
+
};
|
|
121
|
+
const isSameValue = (newValue, oldValue) => {
|
|
122
|
+
return JSON.stringify(newValue) === JSON.stringify(oldValue);
|
|
123
|
+
};
|
|
124
|
+
const handleOverlap = (value2) => {
|
|
125
|
+
if (value2[0] > value2[1]) {
|
|
126
|
+
return value2.slice(0).reverse();
|
|
127
|
+
}
|
|
128
|
+
return value2;
|
|
129
|
+
};
|
|
130
|
+
const updateValue = (value2, end) => {
|
|
131
|
+
if (isRange(value2)) {
|
|
132
|
+
value2 = handleOverlap(value2).map(format);
|
|
133
|
+
} else {
|
|
134
|
+
value2 = format(value2);
|
|
135
|
+
}
|
|
136
|
+
if (!isSameValue(value2, current)) {
|
|
137
|
+
setCurrent(value2);
|
|
138
|
+
}
|
|
139
|
+
end && onEnd && onEnd(value2);
|
|
140
|
+
};
|
|
141
|
+
const click = async (event) => {
|
|
142
|
+
if (disabled || !root.current) {
|
|
143
|
+
return;
|
|
144
|
+
}
|
|
145
|
+
setDragStatus("");
|
|
146
|
+
const rect = await getRectByTaro(root.current);
|
|
147
|
+
let delta = (event.detail.x ? event.detail.x : event.clientX) - rect.left;
|
|
148
|
+
let total = rect.width;
|
|
149
|
+
if (vertical) {
|
|
150
|
+
delta = (event.detail.y ? event.detail.y : event.clientY) - rect.top;
|
|
151
|
+
total = rect.height;
|
|
152
|
+
}
|
|
153
|
+
const value2 = min + delta / total * scope();
|
|
154
|
+
setEaxctValue(current);
|
|
155
|
+
if (isRange(current)) {
|
|
156
|
+
const [left, right] = current;
|
|
157
|
+
const middle = (left + right) / 2;
|
|
158
|
+
if (value2 <= middle) {
|
|
159
|
+
updateValue([value2, right], true);
|
|
160
|
+
} else {
|
|
161
|
+
updateValue([left, value2], true);
|
|
162
|
+
}
|
|
163
|
+
} else {
|
|
164
|
+
updateValue(value2, true);
|
|
165
|
+
}
|
|
166
|
+
};
|
|
167
|
+
const onTouchStart = (event) => {
|
|
168
|
+
if (disabled) {
|
|
169
|
+
return;
|
|
170
|
+
}
|
|
171
|
+
touch.start(event);
|
|
172
|
+
setEaxctValue(current);
|
|
173
|
+
if (isRange(current)) {
|
|
174
|
+
setStartValue(current.map(format));
|
|
175
|
+
} else {
|
|
176
|
+
setStartValue(format(current));
|
|
177
|
+
}
|
|
178
|
+
setDragStatus("start");
|
|
179
|
+
};
|
|
180
|
+
const onTouchMove = async (event) => {
|
|
181
|
+
if (disabled || !root.current) {
|
|
182
|
+
return;
|
|
183
|
+
}
|
|
184
|
+
if (dragStatus === "start") {
|
|
185
|
+
onStart && onStart();
|
|
186
|
+
}
|
|
187
|
+
touch.move(event);
|
|
188
|
+
setDragStatus("draging");
|
|
189
|
+
const rect = await getRectByTaro(root.current);
|
|
190
|
+
let delta = touch.deltaX;
|
|
191
|
+
let total = rect.width;
|
|
192
|
+
let diff = delta / total * scope();
|
|
193
|
+
if (vertical) {
|
|
194
|
+
delta = touch.deltaY;
|
|
195
|
+
total = rect.height;
|
|
196
|
+
diff = delta / total * scope();
|
|
197
|
+
}
|
|
198
|
+
let newValue;
|
|
199
|
+
if (isRange(startValue)) {
|
|
200
|
+
newValue = exactValue.slice();
|
|
201
|
+
newValue[buttonIndex] = startValue[buttonIndex] + diff;
|
|
202
|
+
} else {
|
|
203
|
+
newValue = startValue + diff;
|
|
204
|
+
}
|
|
205
|
+
setEaxctValue(newValue);
|
|
206
|
+
updateValue(newValue);
|
|
207
|
+
};
|
|
208
|
+
const onTouchEnd = (event) => {
|
|
209
|
+
if (disabled) {
|
|
210
|
+
return;
|
|
211
|
+
}
|
|
212
|
+
if (dragStatus === "draging") {
|
|
213
|
+
updateValue(current, true);
|
|
214
|
+
}
|
|
215
|
+
setDragStatus("");
|
|
216
|
+
};
|
|
217
|
+
const curValue = (idx) => {
|
|
218
|
+
const modelVal = current;
|
|
219
|
+
const value2 = typeof idx === "number" ? modelVal[idx] : modelVal;
|
|
220
|
+
return value2;
|
|
221
|
+
};
|
|
222
|
+
const renderButton = (index) => {
|
|
223
|
+
return React.createElement(React.Fragment, null, button || React.createElement("div", { className: "nut-range-button" }, currentDescription !== null && React.createElement("div", { className: "number" }, currentDescription ? currentDescription(curValue(index)) : curValue(index))));
|
|
224
|
+
};
|
|
225
|
+
return React.createElement(
|
|
226
|
+
"div",
|
|
227
|
+
{ className: containerClasses },
|
|
228
|
+
minDescription !== null && React.createElement("div", { className: "min" }, minDescription || min),
|
|
229
|
+
React.createElement(
|
|
230
|
+
"div",
|
|
231
|
+
{ ref: root, className: classes, onClick: (e) => click(e) },
|
|
232
|
+
marksList.length > 0 && React.createElement("div", { className: "nut-range-mark" }, marksList.map((marks2) => {
|
|
233
|
+
return React.createElement(
|
|
234
|
+
"span",
|
|
235
|
+
{ key: marks2, className: markClassName(marks2), style: marksStyle(marks2) },
|
|
236
|
+
marks2,
|
|
237
|
+
React.createElement("span", { className: classNames("nut-range-tick", {
|
|
238
|
+
active: tickClass(marks2)
|
|
239
|
+
}) })
|
|
240
|
+
);
|
|
241
|
+
})),
|
|
242
|
+
React.createElement("div", { className: "nut-range-bar", style: barStyle() }, range ? [0, 1].map((item, index) => {
|
|
243
|
+
return React.createElement("div", { key: index, className: `${index === 0 ? "nut-range-button-wrapper-left" : ""}
|
|
244
|
+
${index === 1 ? "nut-range-button-wrapper-right" : ""}`, onTouchStart: (e) => {
|
|
245
|
+
if (typeof index === "number") {
|
|
246
|
+
setButtonIndex(index);
|
|
247
|
+
}
|
|
248
|
+
onTouchStart(e);
|
|
249
|
+
}, onTouchMove: (e) => onTouchMove(e), onTouchEnd: (e) => onTouchEnd(), onTouchCancel: (e) => onTouchEnd(), onClick: (e) => e.stopPropagation() }, renderButton(index));
|
|
250
|
+
}) : React.createElement(View, { catchMove: true, className: "nut-range-button-wrapper", onTouchStart: (e) => onTouchStart(e), onTouchMove: (e) => onTouchMove(e), onTouchEnd: (e) => onTouchEnd(), onTouchCancel: (e) => onTouchEnd(), onClick: (e) => e.stopPropagation() }, renderButton()))
|
|
251
|
+
),
|
|
252
|
+
maxDescription !== null && React.createElement("div", { className: "max" }, maxDescription || max)
|
|
253
|
+
);
|
|
254
|
+
};
|
|
255
|
+
Range.defaultProps = defaultProps;
|
|
256
|
+
Range.displayName = "NutRange";
|
|
257
|
+
export {
|
|
258
|
+
Range as R
|
|
259
|
+
};
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import React, { useState, useEffect } from "react";
|
|
2
|
+
import classNames from "classnames";
|
|
3
|
+
import { StarFillN } from "@nutui/icons-react-taro";
|
|
4
|
+
import { C as ComponentDefaults } from "./typings-11d83a22.js";
|
|
5
|
+
import { u as usePropsValue } from "./use-props-value-7ac1b1b5.js";
|
|
6
|
+
const defaultProps = {
|
|
7
|
+
...ComponentDefaults,
|
|
8
|
+
count: 5,
|
|
9
|
+
min: 0,
|
|
10
|
+
checkedIcon: null,
|
|
11
|
+
uncheckedIcon: null,
|
|
12
|
+
disabled: false,
|
|
13
|
+
readOnly: false,
|
|
14
|
+
allowHalf: false
|
|
15
|
+
};
|
|
16
|
+
const Rate = (props) => {
|
|
17
|
+
const { className, style, count, value, defaultValue, min, checkedIcon, uncheckedIcon, disabled, readOnly, allowHalf, onChange } = {
|
|
18
|
+
...defaultProps,
|
|
19
|
+
...props
|
|
20
|
+
};
|
|
21
|
+
const classPrefix = "nut-rate";
|
|
22
|
+
const [countArray, setCountArray] = useState([1, 2, 3, 4, 5]);
|
|
23
|
+
const [score, setScore] = usePropsValue({
|
|
24
|
+
value,
|
|
25
|
+
defaultValue: Math.max(defaultValue || 0, min),
|
|
26
|
+
finalValue: 0,
|
|
27
|
+
onChange
|
|
28
|
+
});
|
|
29
|
+
useEffect(() => {
|
|
30
|
+
const tmp = [];
|
|
31
|
+
for (let i = 1; i <= Number(count); i++) {
|
|
32
|
+
tmp.push(i);
|
|
33
|
+
}
|
|
34
|
+
setCountArray(tmp);
|
|
35
|
+
}, [count]);
|
|
36
|
+
const renderIcon = (n) => {
|
|
37
|
+
return n <= score ? checkedIcon || React.createElement(StarFillN, null) : uncheckedIcon || (checkedIcon ? React.cloneElement(checkedIcon, {
|
|
38
|
+
color: void 0
|
|
39
|
+
}) : React.createElement(StarFillN, null));
|
|
40
|
+
};
|
|
41
|
+
const onClick = (e, index) => {
|
|
42
|
+
e.preventDefault();
|
|
43
|
+
e.stopPropagation();
|
|
44
|
+
if (disabled || readOnly)
|
|
45
|
+
return;
|
|
46
|
+
let value2 = 0;
|
|
47
|
+
if (!(index === 1 && score === index)) {
|
|
48
|
+
value2 = index;
|
|
49
|
+
}
|
|
50
|
+
value2 = Math.max(value2, min);
|
|
51
|
+
setScore(value2);
|
|
52
|
+
};
|
|
53
|
+
const onHalfClick = (event, n) => {
|
|
54
|
+
event.preventDefault();
|
|
55
|
+
event.stopPropagation();
|
|
56
|
+
const value2 = Math.max(min, n - 0.5);
|
|
57
|
+
setScore(value2);
|
|
58
|
+
};
|
|
59
|
+
return React.createElement("div", { className: classNames(classPrefix, className, {
|
|
60
|
+
disabled,
|
|
61
|
+
readonly: readOnly
|
|
62
|
+
}), style }, countArray.map((n) => {
|
|
63
|
+
return React.createElement(
|
|
64
|
+
"div",
|
|
65
|
+
{ className: `${classPrefix}-item`, key: n, onClick: (event) => onClick(event, n) },
|
|
66
|
+
React.createElement("div", { className: classNames(`${classPrefix}-item__icon`, {
|
|
67
|
+
[`${classPrefix}-item__icon--disabled`]: disabled || n > score
|
|
68
|
+
}) }, renderIcon(n)),
|
|
69
|
+
allowHalf && score > n - 1 && React.createElement("div", { className: classNames(`${classPrefix}-item__half`, `${classPrefix}-item__icon`, `${classPrefix}-item__icon--half`), onClick: (event) => onHalfClick(event, n) }, renderIcon(n))
|
|
70
|
+
);
|
|
71
|
+
}));
|
|
72
|
+
};
|
|
73
|
+
Rate.defaultProps = defaultProps;
|
|
74
|
+
Rate.displayName = "NutRate";
|
|
75
|
+
export {
|
|
76
|
+
Rate as R
|
|
77
|
+
};
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import classNames from "classnames";
|
|
3
|
+
import { D as DataContext } from "./UserContext-ab42ba7f.js";
|
|
4
|
+
import { C as ComponentDefaults } from "./typings-11d83a22.js";
|
|
5
|
+
const classPrefix = "nut-row";
|
|
6
|
+
const defaultProps = {
|
|
7
|
+
...ComponentDefaults,
|
|
8
|
+
type: "",
|
|
9
|
+
justify: "start",
|
|
10
|
+
align: "flex-start",
|
|
11
|
+
wrap: "nowrap",
|
|
12
|
+
gutter: "0"
|
|
13
|
+
};
|
|
14
|
+
const Row = (props) => {
|
|
15
|
+
const { className, style, children, type, justify, align, wrap, gutter, onClick } = {
|
|
16
|
+
...defaultProps,
|
|
17
|
+
...props
|
|
18
|
+
};
|
|
19
|
+
const getClass = (prefix, type2) => {
|
|
20
|
+
const classType = type2 ? `nut-row-${prefix}-${type2}` : "";
|
|
21
|
+
const className2 = prefix ? classType : `nut-row-${type2}`;
|
|
22
|
+
return className2;
|
|
23
|
+
};
|
|
24
|
+
const getClasses = () => {
|
|
25
|
+
return `
|
|
26
|
+
${getClass("", type)}
|
|
27
|
+
${getClass("justify", justify)}
|
|
28
|
+
${getClass("align", align)}
|
|
29
|
+
${getClass("flex", wrap)}
|
|
30
|
+
${classPrefix}
|
|
31
|
+
`;
|
|
32
|
+
};
|
|
33
|
+
const parentRow = {
|
|
34
|
+
gutter
|
|
35
|
+
};
|
|
36
|
+
return React.createElement(DataContext.Provider, { value: parentRow }, React.createElement("div", {
|
|
37
|
+
className: classNames(getClasses(), className),
|
|
38
|
+
style,
|
|
39
|
+
onClick: (e) => {
|
|
40
|
+
onClick && onClick(e, "row");
|
|
41
|
+
}
|
|
42
|
+
}, children));
|
|
43
|
+
};
|
|
44
|
+
Row.defaultProps = defaultProps;
|
|
45
|
+
Row.displayName = "NutRow";
|
|
46
|
+
export {
|
|
47
|
+
Row as R
|
|
48
|
+
};
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
import React, { useRef, useState, useEffect } from "react";
|
|
2
|
+
import { getEnv } from "@tarojs/taro";
|
|
3
|
+
import { Search, CircleClose } from "@nutui/icons-react-taro";
|
|
4
|
+
import { c as cn } from "./bem-cdccae08.js";
|
|
5
|
+
import { u as useConfig } from "./configprovider.taro-25758d9f.js";
|
|
6
|
+
import { C as ComponentDefaults } from "./typings-11d83a22.js";
|
|
7
|
+
const defaultProps = {
|
|
8
|
+
...ComponentDefaults,
|
|
9
|
+
placeholder: "",
|
|
10
|
+
shape: "square",
|
|
11
|
+
disabled: false,
|
|
12
|
+
maxLength: 9999,
|
|
13
|
+
clearable: true,
|
|
14
|
+
clearSize: "12px",
|
|
15
|
+
align: "left",
|
|
16
|
+
readonly: true,
|
|
17
|
+
autoFocus: false,
|
|
18
|
+
label: "",
|
|
19
|
+
leftinIcon: React.createElement(Search, { size: "12" })
|
|
20
|
+
};
|
|
21
|
+
const SearchBar = (props) => {
|
|
22
|
+
const searchbarBem = cn("searchbar");
|
|
23
|
+
const { locale } = useConfig();
|
|
24
|
+
const searchRef = useRef(null);
|
|
25
|
+
const [value, setValue] = useState(() => props.value);
|
|
26
|
+
const { placeholder, shape, className, disabled, maxLength, clearable, clearSize, align, readOnly, autoFocus, label, actionText, leftinIcon, rightinIcon, leftoutIcon, rightoutIcon, onChange, onFocus, onBlur, onClear, onCancel, onSearch, onClickInput, onClickLeftinIcon, onClickLeftoutIcon, onClickRightinIcon, onClickRightoutIcon } = {
|
|
27
|
+
...defaultProps,
|
|
28
|
+
...props
|
|
29
|
+
};
|
|
30
|
+
const alignClass = `${align}`;
|
|
31
|
+
const forceFocus = () => {
|
|
32
|
+
const searchSelf = searchRef.current;
|
|
33
|
+
searchSelf && searchSelf.focus();
|
|
34
|
+
};
|
|
35
|
+
const change = (event) => {
|
|
36
|
+
const { value: value2 } = event.target;
|
|
37
|
+
onChange && (onChange == null ? void 0 : onChange(value2, event));
|
|
38
|
+
setValue(value2);
|
|
39
|
+
value2 === "" && forceFocus();
|
|
40
|
+
};
|
|
41
|
+
const focus = (event) => {
|
|
42
|
+
const { value: value2 } = event.target;
|
|
43
|
+
onFocus && (onFocus == null ? void 0 : onFocus(value2, event));
|
|
44
|
+
};
|
|
45
|
+
const blur = (event) => {
|
|
46
|
+
const searchSelf = searchRef.current;
|
|
47
|
+
searchSelf && searchSelf.blur();
|
|
48
|
+
const { value: value2 } = event.target;
|
|
49
|
+
onBlur && (onBlur == null ? void 0 : onBlur(value2, event));
|
|
50
|
+
};
|
|
51
|
+
useEffect(() => {
|
|
52
|
+
setValue(props.value);
|
|
53
|
+
}, [props.value]);
|
|
54
|
+
useEffect(() => {
|
|
55
|
+
autoFocus && forceFocus();
|
|
56
|
+
}, [autoFocus]);
|
|
57
|
+
const renderField = () => {
|
|
58
|
+
return React.createElement("input", { className: `${searchbarBem("input")} ${searchbarBem(alignClass)} ${shape === "round" ? searchbarBem("round") : ""} ${clearable ? searchbarBem("input-clear") : ""}`, ref: searchRef, style: { ...props.style }, value: value || "", placeholder: placeholder || locale.placeholder, disabled, readOnly, maxLength, onKeyPress: onKeypress, onChange: (e) => change(e), onFocus: (e) => focus(e), onBlur: (e) => blur(e), onClick: (e) => clickInput(e) });
|
|
59
|
+
};
|
|
60
|
+
const clickInput = (e) => {
|
|
61
|
+
onClickInput && onClickInput(e);
|
|
62
|
+
};
|
|
63
|
+
const renderLeftinIcon = () => {
|
|
64
|
+
if (!leftinIcon)
|
|
65
|
+
return null;
|
|
66
|
+
return React.createElement("div", { className: `${searchbarBem("leftin-icon")} ${searchbarBem("icon")}`, onClick: (e) => clickLeftIcon("in-left", e) }, leftinIcon);
|
|
67
|
+
};
|
|
68
|
+
const renderLeftoutIcon = () => {
|
|
69
|
+
if (!leftoutIcon)
|
|
70
|
+
return null;
|
|
71
|
+
return React.createElement("div", { className: `${searchbarBem("leftout-icon")}`, onClick: (e) => clickLeftIcon("out-left", e) }, leftoutIcon);
|
|
72
|
+
};
|
|
73
|
+
const clickLeftIcon = (flag, event) => {
|
|
74
|
+
if (flag === "in-left") {
|
|
75
|
+
onClickLeftinIcon && onClickLeftinIcon(value, event);
|
|
76
|
+
} else {
|
|
77
|
+
onClickLeftoutIcon && onClickLeftoutIcon(value, event);
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
const renderRightinIcon = () => {
|
|
81
|
+
if (!rightinIcon)
|
|
82
|
+
return null;
|
|
83
|
+
return React.createElement("div", { className: `${searchbarBem("rightin-icon")} ${searchbarBem("icon")}`, onClick: (e) => clickRightIcon("in-right", e) }, rightinIcon);
|
|
84
|
+
};
|
|
85
|
+
const renderRightoutIcon = () => {
|
|
86
|
+
if (!rightoutIcon)
|
|
87
|
+
return null;
|
|
88
|
+
return React.createElement("div", { className: `${searchbarBem("rightout-icon")}`, onClick: (e) => clickRightIcon("out-right", e) }, rightoutIcon);
|
|
89
|
+
};
|
|
90
|
+
const clickRightIcon = (flag, event) => {
|
|
91
|
+
if (flag === "in-left") {
|
|
92
|
+
onClickRightinIcon && onClickRightinIcon(value, event);
|
|
93
|
+
} else {
|
|
94
|
+
onClickRightoutIcon && onClickRightoutIcon(value, event);
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
const handleClear = () => {
|
|
98
|
+
return React.createElement(
|
|
99
|
+
"div",
|
|
100
|
+
{ className: `${searchbarBem("clear")} ${rightinIcon ? "pos-right" : ""}`, onClick: (e) => clearaVal(e) },
|
|
101
|
+
React.createElement(CircleClose, { size: clearSize, color: "#555" })
|
|
102
|
+
);
|
|
103
|
+
};
|
|
104
|
+
const clearaVal = (event) => {
|
|
105
|
+
if (disabled || readOnly) {
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
setValue("");
|
|
109
|
+
onClear && onClear(event);
|
|
110
|
+
forceFocus();
|
|
111
|
+
};
|
|
112
|
+
const renderRightLabel = () => {
|
|
113
|
+
if (actionText) {
|
|
114
|
+
return React.createElement("div", { className: searchbarBem("action-text"), onClick: search }, actionText);
|
|
115
|
+
}
|
|
116
|
+
return null;
|
|
117
|
+
};
|
|
118
|
+
const onKeypress = (e) => {
|
|
119
|
+
if (e.keyCode === 13) {
|
|
120
|
+
if (typeof e.cancelable !== "boolean" || e.cancelable) {
|
|
121
|
+
e.preventDefault();
|
|
122
|
+
}
|
|
123
|
+
onSearch && onSearch(value);
|
|
124
|
+
}
|
|
125
|
+
};
|
|
126
|
+
const search = () => {
|
|
127
|
+
onSearch && onSearch(value);
|
|
128
|
+
};
|
|
129
|
+
const renderLabel = () => {
|
|
130
|
+
if (label) {
|
|
131
|
+
return React.createElement("div", { className: searchbarBem("label") }, label);
|
|
132
|
+
}
|
|
133
|
+
return null;
|
|
134
|
+
};
|
|
135
|
+
const envClass = () => {
|
|
136
|
+
return getEnv() === "WEB" ? "nut-searchbar-taro" : "";
|
|
137
|
+
};
|
|
138
|
+
return React.createElement(
|
|
139
|
+
"div",
|
|
140
|
+
{ className: `${searchbarBem()} ${envClass()} ${disabled ? searchbarBem("disabled") : ""} ${className || ""}`, style: { ...props.style, background: props.background } },
|
|
141
|
+
renderLeftoutIcon(),
|
|
142
|
+
renderLabel(),
|
|
143
|
+
React.createElement(
|
|
144
|
+
"div",
|
|
145
|
+
{ className: `${searchbarBem("content")}`, style: { background: props.inputBackground } },
|
|
146
|
+
renderLeftinIcon(),
|
|
147
|
+
React.createElement("div", { className: "nut-searchbar__input-box" }, renderField()),
|
|
148
|
+
renderRightinIcon(),
|
|
149
|
+
clearable && value && handleClear()
|
|
150
|
+
),
|
|
151
|
+
renderRightoutIcon(),
|
|
152
|
+
renderRightLabel()
|
|
153
|
+
);
|
|
154
|
+
};
|
|
155
|
+
SearchBar.defaultProps = defaultProps;
|
|
156
|
+
SearchBar.displayName = "NutSearchBar";
|
|
157
|
+
export {
|
|
158
|
+
SearchBar as S
|
|
159
|
+
};
|