sard 1.0.0-canary.0
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/dist/accordion/Item.d.ts +17 -0
- package/dist/accordion/Item.js +25 -0
- package/dist/accordion/index.d.ts +26 -0
- package/dist/accordion/index.js +27 -0
- package/dist/accordion/index.scss +49 -0
- package/dist/action-sheet/ActionSheet.d.ts +24 -0
- package/dist/action-sheet/ActionSheet.js +79 -0
- package/dist/action-sheet/Agent.d.ts +6 -0
- package/dist/action-sheet/Agent.js +7 -0
- package/dist/action-sheet/Item.d.ts +16 -0
- package/dist/action-sheet/Item.js +22 -0
- package/dist/action-sheet/imperative.d.ts +10 -0
- package/dist/action-sheet/imperative.js +22 -0
- package/dist/action-sheet/index.d.ts +12 -0
- package/dist/action-sheet/index.js +10 -0
- package/dist/action-sheet/index.scss +148 -0
- package/dist/animated/index.d.ts +62 -0
- package/dist/animated/index.js +101 -0
- package/dist/animated/index.rn.d.ts +4 -0
- package/dist/animated/index.rn.js +35 -0
- package/dist/avatar/Group.d.ts +9 -0
- package/dist/avatar/Group.js +27 -0
- package/dist/avatar/index.d.ts +17 -0
- package/dist/avatar/index.js +22 -0
- package/dist/avatar/index.scss +82 -0
- package/dist/badge/index.d.ts +13 -0
- package/dist/badge/index.js +16 -0
- package/dist/badge/index.scss +81 -0
- package/dist/base.d.ts +11 -0
- package/dist/base.js +1 -0
- package/dist/button/CustomButton.d.ts +9 -0
- package/dist/button/CustomButton.js +23 -0
- package/dist/button/index.d.ts +21 -0
- package/dist/button/index.js +34 -0
- package/dist/button/index.scss +346 -0
- package/dist/calendar/Day.d.ts +23 -0
- package/dist/calendar/Day.js +70 -0
- package/dist/calendar/MonthPicker.d.ts +13 -0
- package/dist/calendar/MonthPicker.js +22 -0
- package/dist/calendar/Toolbar.d.ts +11 -0
- package/dist/calendar/Toolbar.js +18 -0
- package/dist/calendar/Weeks.d.ts +6 -0
- package/dist/calendar/Weeks.js +18 -0
- package/dist/calendar/index.d.ts +48 -0
- package/dist/calendar/index.js +193 -0
- package/dist/calendar/index.scss +210 -0
- package/dist/card/index.d.ts +15 -0
- package/dist/card/index.js +14 -0
- package/dist/card/index.scss +64 -0
- package/dist/cascader/index.d.ts +43 -0
- package/dist/cascader/index.js +216 -0
- package/dist/cascader/index.scss +130 -0
- package/dist/checkbox/Group.d.ts +5 -0
- package/dist/checkbox/Group.js +5 -0
- package/dist/checkbox/index.d.ts +10 -0
- package/dist/checkbox/index.js +8 -0
- package/dist/checkbox/index.scss +78 -0
- package/dist/collapse/index.d.ts +14 -0
- package/dist/collapse/index.js +61 -0
- package/dist/collapse/index.rn.d.ts +14 -0
- package/dist/collapse/index.rn.js +76 -0
- package/dist/collapse/index.scss +31 -0
- package/dist/components.d.ts +66 -0
- package/dist/components.js +66 -0
- package/dist/components.scss +65 -0
- package/dist/config-provider/index.d.ts +21 -0
- package/dist/config-provider/index.js +20 -0
- package/dist/count-down/index.d.ts +26 -0
- package/dist/count-down/index.js +95 -0
- package/dist/datetime-picker/index.d.ts +36 -0
- package/dist/datetime-picker/index.js +230 -0
- package/dist/dialog/Agent.d.ts +6 -0
- package/dist/dialog/Agent.js +7 -0
- package/dist/dialog/Dialog.d.ts +31 -0
- package/dist/dialog/Dialog.js +103 -0
- package/dist/dialog/imperative.d.ts +17 -0
- package/dist/dialog/imperative.js +35 -0
- package/dist/dialog/index.d.ts +14 -0
- package/dist/dialog/index.js +12 -0
- package/dist/dialog/index.scss +156 -0
- package/dist/dropdown/Item.d.ts +33 -0
- package/dist/dropdown/Item.js +164 -0
- package/dist/dropdown/Option.d.ts +10 -0
- package/dist/dropdown/Option.js +12 -0
- package/dist/dropdown/index.d.ts +20 -0
- package/dist/dropdown/index.js +59 -0
- package/dist/dropdown/index.scss +236 -0
- package/dist/ellipsis/index.d.ts +8 -0
- package/dist/ellipsis/index.js +18 -0
- package/dist/ellipsis/index.scss +23 -0
- package/dist/empty/index.d.ts +10 -0
- package/dist/empty/index.js +14 -0
- package/dist/empty/index.scss +59 -0
- package/dist/footer-bar/index.d.ts +8 -0
- package/dist/footer-bar/index.js +15 -0
- package/dist/footer-bar/index.scss +29 -0
- package/dist/form/CustomForm.d.ts +13 -0
- package/dist/form/CustomForm.js +26 -0
- package/dist/form/ErrorList.d.ts +6 -0
- package/dist/form/ErrorList.js +15 -0
- package/dist/form/Field.d.ts +41 -0
- package/dist/form/Field.js +124 -0
- package/dist/form/FieldContext.d.ts +18 -0
- package/dist/form/FieldContext.js +8 -0
- package/dist/form/List.d.ts +31 -0
- package/dist/form/List.js +87 -0
- package/dist/form/Map.d.ts +17 -0
- package/dist/form/Map.js +24 -0
- package/dist/form/NodeContext.d.ts +12 -0
- package/dist/form/NodeContext.js +14 -0
- package/dist/form/Validator.d.ts +88 -0
- package/dist/form/Validator.js +268 -0
- package/dist/form/createFormStore.d.ts +36 -0
- package/dist/form/createFormStore.js +249 -0
- package/dist/form/index.d.ts +43 -0
- package/dist/form/index.js +109 -0
- package/dist/form/index.scss +200 -0
- package/dist/form/store/Context.d.ts +4 -0
- package/dist/form/store/Context.js +3 -0
- package/dist/form/store/createStore.d.ts +6 -0
- package/dist/form/store/createStore.js +28 -0
- package/dist/form/store/useDispatch.d.ts +2 -0
- package/dist/form/store/useDispatch.js +10 -0
- package/dist/form/store/useSelector.d.ts +7 -0
- package/dist/form/store/useSelector.js +35 -0
- package/dist/form/type.d.ts +20 -0
- package/dist/form/type.js +1 -0
- package/dist/form/useForm.d.ts +27 -0
- package/dist/form/useForm.js +14 -0
- package/dist/form/useInternalWatch.d.ts +3 -0
- package/dist/form/useInternalWatch.js +27 -0
- package/dist/form/useNode.d.ts +49 -0
- package/dist/form/useNode.js +284 -0
- package/dist/form/useValidator.d.ts +23 -0
- package/dist/form/useValidator.js +74 -0
- package/dist/form/useWatch.d.ts +4 -0
- package/dist/form/useWatch.js +24 -0
- package/dist/grid/Col.d.ts +9 -0
- package/dist/grid/Col.js +20 -0
- package/dist/grid/Row.d.ts +11 -0
- package/dist/grid/Row.js +34 -0
- package/dist/grid/index.d.ts +2 -0
- package/dist/grid/index.js +2 -0
- package/dist/grid/index.scss +56 -0
- package/dist/halfline/index.d.ts +10 -0
- package/dist/halfline/index.js +27 -0
- package/dist/halfline/index.scss +80 -0
- package/dist/icon/common.d.ts +15 -0
- package/dist/icon/common.js +1 -0
- package/dist/icon/font/iconfont.json +275 -0
- package/dist/icon/font/iconfont.rn.scss +0 -0
- package/dist/icon/font/iconfont.scss +164 -0
- package/dist/icon/font/iconfont.ttf +0 -0
- package/dist/icon/fontLoader.d.ts +7 -0
- package/dist/icon/fontLoader.js +14 -0
- package/dist/icon/fontLoader.rn.d.ts +6 -0
- package/dist/icon/fontLoader.rn.js +52 -0
- package/dist/icon/index.d.ts +21 -0
- package/dist/icon/index.js +41 -0
- package/dist/icon/index.scss +23 -0
- package/dist/index-bar/Item.d.ts +9 -0
- package/dist/index-bar/Item.js +11 -0
- package/dist/index-bar/Nav.d.ts +13 -0
- package/dist/index-bar/Nav.js +75 -0
- package/dist/index-bar/index.d.ts +19 -0
- package/dist/index-bar/index.js +142 -0
- package/dist/index-bar/index.scss +153 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +3 -0
- package/dist/index.scss +1 -0
- package/dist/input/index.d.ts +37 -0
- package/dist/input/index.js +116 -0
- package/dist/input/index.scss +249 -0
- package/dist/linear-gradient/index.d.ts +14 -0
- package/dist/linear-gradient/index.js +30 -0
- package/dist/linear-gradient/index.rn.d.ts +3 -0
- package/dist/linear-gradient/index.rn.js +3 -0
- package/dist/list/Item.d.ts +22 -0
- package/dist/list/Item.js +26 -0
- package/dist/list/ListContext.d.ts +9 -0
- package/dist/list/ListContext.js +2 -0
- package/dist/list/OrderContext.d.ts +8 -0
- package/dist/list/OrderContext.js +6 -0
- package/dist/list/index.d.ts +19 -0
- package/dist/list/index.js +29 -0
- package/dist/list/index.scss +257 -0
- package/dist/loading/index.d.ts +10 -0
- package/dist/loading/index.js +47 -0
- package/dist/loading/index.scss +25 -0
- package/dist/locale/index.d.ts +199 -0
- package/dist/locale/index.js +36 -0
- package/dist/locale/lang/en-US.d.ts +92 -0
- package/dist/locale/lang/en-US.js +92 -0
- package/dist/locale/lang/zh-CN.d.ts +92 -0
- package/dist/locale/lang/zh-CN.js +92 -0
- package/dist/locale/useTranslate.d.ts +7 -0
- package/dist/locale/useTranslate.js +41 -0
- package/dist/mask/index.d.ts +13 -0
- package/dist/mask/index.js +26 -0
- package/dist/mask/index.scss +24 -0
- package/dist/menu/Item.d.ts +15 -0
- package/dist/menu/Item.js +17 -0
- package/dist/menu/index.d.ts +17 -0
- package/dist/menu/index.js +15 -0
- package/dist/menu/index.scss +128 -0
- package/dist/mesh/Item.d.ts +16 -0
- package/dist/mesh/Item.js +16 -0
- package/dist/mesh/index.d.ts +14 -0
- package/dist/mesh/index.js +69 -0
- package/dist/mesh/index.scss +131 -0
- package/dist/mesh/type.d.ts +9 -0
- package/dist/mesh/type.js +1 -0
- package/dist/modal/index.d.ts +8 -0
- package/dist/modal/index.js +9 -0
- package/dist/modal/index.rn.d.ts +8 -0
- package/dist/modal/index.rn.js +8 -0
- package/dist/navbar/Item.d.ts +8 -0
- package/dist/navbar/Item.js +11 -0
- package/dist/navbar/index.d.ts +15 -0
- package/dist/navbar/index.js +16 -0
- package/dist/navbar/index.scss +128 -0
- package/dist/notice-bar/index.d.ts +28 -0
- package/dist/notice-bar/index.js +135 -0
- package/dist/notice-bar/index.scss +109 -0
- package/dist/notify/Agent.d.ts +6 -0
- package/dist/notify/Agent.js +7 -0
- package/dist/notify/Notify.d.ts +22 -0
- package/dist/notify/Notify.js +48 -0
- package/dist/notify/imperative.d.ts +18 -0
- package/dist/notify/imperative.js +35 -0
- package/dist/notify/index.d.ts +15 -0
- package/dist/notify/index.js +13 -0
- package/dist/notify/index.scss +65 -0
- package/dist/number-keyboard/index.d.ts +10 -0
- package/dist/number-keyboard/index.js +51 -0
- package/dist/number-keyboard/index.scss +93 -0
- package/dist/pagination/index.d.ts +20 -0
- package/dist/pagination/index.js +65 -0
- package/dist/pagination/index.scss +131 -0
- package/dist/pan-gesture-detector/index.d.ts +8 -0
- package/dist/pan-gesture-detector/index.js +11 -0
- package/dist/pan-gesture-detector/index.rn.d.ts +8 -0
- package/dist/pan-gesture-detector/index.rn.js +23 -0
- package/dist/pan-gesture-detector/usePan.d.ts +47 -0
- package/dist/pan-gesture-detector/usePan.js +146 -0
- package/dist/password-input/index.d.ts +22 -0
- package/dist/password-input/index.js +91 -0
- package/dist/password-input/index.scss +189 -0
- package/dist/picker/InertialMotion.d.ts +20 -0
- package/dist/picker/InertialMotion.js +141 -0
- package/dist/picker/PickerView.d.ts +1 -0
- package/dist/picker/PickerView.h5.d.ts +17 -0
- package/dist/picker/PickerView.h5.js +36 -0
- package/dist/picker/PickerView.js +1 -0
- package/dist/picker/PickerViewColumn copy.d.ts +9 -0
- package/dist/picker/PickerViewColumn copy.js +143 -0
- package/dist/picker/PickerViewColumn.d.ts +12 -0
- package/dist/picker/PickerViewColumn.js +238 -0
- package/dist/picker/index.d.ts +38 -0
- package/dist/picker/index.js +224 -0
- package/dist/picker/index.rn.scss +0 -0
- package/dist/picker/index.scss +138 -0
- package/dist/popout/index.d.ts +25 -0
- package/dist/popout/index.js +87 -0
- package/dist/popout/index.scss +136 -0
- package/dist/popout-input/index.d.ts +29 -0
- package/dist/popout-input/index.js +91 -0
- package/dist/popout-input/index.scss +53 -0
- package/dist/popover/index.d.ts +35 -0
- package/dist/popover/index.js +193 -0
- package/dist/popover/index.scss +94 -0
- package/dist/popover/utils.d.ts +23 -0
- package/dist/popover/utils.js +124 -0
- package/dist/popup/index.d.ts +29 -0
- package/dist/popup/index.js +60 -0
- package/dist/popup/index.scss +60 -0
- package/dist/pressable/index.d.ts +13 -0
- package/dist/pressable/index.js +58 -0
- package/dist/pressable/index.rn.d.ts +13 -0
- package/dist/pressable/index.rn.js +50 -0
- package/dist/progress-bar/index.d.ts +10 -0
- package/dist/progress-bar/index.js +22 -0
- package/dist/progress-bar/index.scss +45 -0
- package/dist/progress-circle/index.d.ts +11 -0
- package/dist/progress-circle/index.js +54 -0
- package/dist/progress-circle/index.scss +141 -0
- package/dist/radio/Group.d.ts +5 -0
- package/dist/radio/Group.js +5 -0
- package/dist/radio/index.d.ts +10 -0
- package/dist/radio/index.js +8 -0
- package/dist/radio/index.scss +77 -0
- package/dist/rate/index.d.ts +23 -0
- package/dist/rate/index.js +116 -0
- package/dist/rate/index.scss +99 -0
- package/dist/result/index.d.ts +12 -0
- package/dist/result/index.js +19 -0
- package/dist/result/index.scss +88 -0
- package/dist/safe-area/index.d.ts +7 -0
- package/dist/safe-area/index.js +35 -0
- package/dist/safe-area/index.scss +24 -0
- package/dist/scroll-view/index.d.ts +24 -0
- package/dist/scroll-view/index.js +72 -0
- package/dist/scroll-view/index.rn.d.ts +21 -0
- package/dist/scroll-view/index.rn.js +51 -0
- package/dist/search/index.d.ts +26 -0
- package/dist/search/index.js +35 -0
- package/dist/search/index.scss +75 -0
- package/dist/share-sheet/Item.d.ts +15 -0
- package/dist/share-sheet/Item.js +26 -0
- package/dist/share-sheet/Row.d.ts +10 -0
- package/dist/share-sheet/Row.js +26 -0
- package/dist/share-sheet/index.d.ts +26 -0
- package/dist/share-sheet/index.js +76 -0
- package/dist/share-sheet/index.scss +230 -0
- package/dist/skeleton/Avatar.d.ts +7 -0
- package/dist/skeleton/Avatar.js +17 -0
- package/dist/skeleton/Block.d.ts +8 -0
- package/dist/skeleton/Block.js +44 -0
- package/dist/skeleton/Paragraph.d.ts +7 -0
- package/dist/skeleton/Paragraph.js +13 -0
- package/dist/skeleton/Title.d.ts +7 -0
- package/dist/skeleton/Title.js +16 -0
- package/dist/skeleton/index.d.ts +28 -0
- package/dist/skeleton/index.js +22 -0
- package/dist/skeleton/index.scss +108 -0
- package/dist/slider/index.d.ts +36 -0
- package/dist/slider/index.js +187 -0
- package/dist/slider/index.scss +138 -0
- package/dist/space/index.d.ts +13 -0
- package/dist/space/index.js +33 -0
- package/dist/space/index.scss +36 -0
- package/dist/stepper/index.d.ts +26 -0
- package/dist/stepper/index.js +138 -0
- package/dist/stepper/index.scss +106 -0
- package/dist/steps/Step.d.ts +23 -0
- package/dist/steps/Step.js +41 -0
- package/dist/steps/index.d.ts +23 -0
- package/dist/steps/index.js +38 -0
- package/dist/steps/index.scss +300 -0
- package/dist/style/base.scss +3 -0
- package/dist/style/functions.scss +54 -0
- package/dist/style/index.d.ts +2 -0
- package/dist/style/index.js +2 -0
- package/dist/style/index.scss +0 -0
- package/dist/style/mixins/bem.scss +63 -0
- package/dist/style/mixins/border.scss +80 -0
- package/dist/style/mixins/disabled.scss +9 -0
- package/dist/style/mixins/env.rn.scss +11 -0
- package/dist/style/mixins/env.scss +11 -0
- package/dist/style/mixins/fixed.rn.scss +3 -0
- package/dist/style/mixins/fixed.scss +3 -0
- package/dist/style/mixins/sticky.rn.scss +3 -0
- package/dist/style/mixins/sticky.scss +3 -0
- package/dist/style/mixins/theme.scss +11 -0
- package/dist/style/mixins/universal.rn.scss +2 -0
- package/dist/style/mixins/universal.scss +6 -0
- package/dist/style/mixins.scss +8 -0
- package/dist/style/utils.scss +130 -0
- package/dist/style/variables.scss +422 -0
- package/dist/swiper/Item.d.ts +8 -0
- package/dist/swiper/Item.js +10 -0
- package/dist/swiper/index.d.ts +12 -0
- package/dist/swiper/index.js +13 -0
- package/dist/swiper/index.scss +10 -0
- package/dist/switch/index.d.ts +19 -0
- package/dist/switch/index.js +78 -0
- package/dist/switch/index.scss +106 -0
- package/dist/tabbar/Item.d.ts +17 -0
- package/dist/tabbar/Item.js +24 -0
- package/dist/tabbar/index.d.ts +17 -0
- package/dist/tabbar/index.js +33 -0
- package/dist/tabbar/index.scss +89 -0
- package/dist/tabs/Tab.d.ts +12 -0
- package/dist/tabs/Tab.js +17 -0
- package/dist/tabs/index.d.ts +23 -0
- package/dist/tabs/index.js +258 -0
- package/dist/tabs/index.scss +113 -0
- package/dist/tag/index.d.ts +17 -0
- package/dist/tag/index.js +21 -0
- package/dist/tag/index.scss +93 -0
- package/dist/template/index.d.ts +6 -0
- package/dist/template/index.js +10 -0
- package/dist/template/index.scss +16 -0
- package/dist/toast/Agent.d.ts +6 -0
- package/dist/toast/Agent.js +7 -0
- package/dist/toast/Toast.d.ts +24 -0
- package/dist/toast/Toast.js +43 -0
- package/dist/toast/imperative.d.ts +18 -0
- package/dist/toast/imperative.js +35 -0
- package/dist/toast/index.d.ts +15 -0
- package/dist/toast/index.js +13 -0
- package/dist/toast/index.scss +96 -0
- package/dist/transition/CSSTransition.d.ts +7 -0
- package/dist/transition/CSSTransition.js +49 -0
- package/dist/transition/CSSTransition.rn.d.ts +7 -0
- package/dist/transition/CSSTransition.rn.js +312 -0
- package/dist/transition/index.d.ts +43 -0
- package/dist/transition/index.js +156 -0
- package/dist/transition/index.rn.scss +0 -0
- package/dist/transition/index.scss +158 -0
- package/dist/upload/Preview.d.ts +35 -0
- package/dist/upload/Preview.js +41 -0
- package/dist/upload/PreviewVideo.d.ts +7 -0
- package/dist/upload/PreviewVideo.js +38 -0
- package/dist/upload/PreviewVideo.rn.d.ts +6 -0
- package/dist/upload/PreviewVideo.rn.js +24 -0
- package/dist/upload/chooseMedia.d.ts +26 -0
- package/dist/upload/chooseMedia.h5.d.ts +25 -0
- package/dist/upload/chooseMedia.h5.js +117 -0
- package/dist/upload/chooseMedia.js +55 -0
- package/dist/upload/index.d.ts +37 -0
- package/dist/upload/index.js +167 -0
- package/dist/upload/index.scss +247 -0
- package/dist/use/index.d.ts +20 -0
- package/dist/use/index.js +20 -0
- package/dist/use/useAutoplay.d.ts +1 -0
- package/dist/use/useAutoplay.js +34 -0
- package/dist/use/useBem.d.ts +9 -0
- package/dist/use/useBem.js +52 -0
- package/dist/use/useBrush.d.ts +23 -0
- package/dist/use/useBrush.js +61 -0
- package/dist/use/useControllableValue.d.ts +12 -0
- package/dist/use/useControllableValue.js +59 -0
- package/dist/use/useEvent.d.ts +4 -0
- package/dist/use/useEvent.js +12 -0
- package/dist/use/useForceRender.d.ts +5 -0
- package/dist/use/useForceRender.js +8 -0
- package/dist/use/useIndexableMap.d.ts +21 -0
- package/dist/use/useIndexableMap.js +65 -0
- package/dist/use/useInertRef.d.ts +7 -0
- package/dist/use/useInertRef.js +15 -0
- package/dist/use/useInternalSelect.d.ts +42 -0
- package/dist/use/useInternalSelect.js +64 -0
- package/dist/use/useLayoutUpdateEffect.d.ts +5 -0
- package/dist/use/useLayoutUpdateEffect.js +18 -0
- package/dist/use/usePropRef.d.ts +5 -0
- package/dist/use/usePropRef.js +9 -0
- package/dist/use/useResize.d.ts +2 -0
- package/dist/use/useResize.js +14 -0
- package/dist/use/useResizeObserver.d.ts +5 -0
- package/dist/use/useResizeObserver.js +38 -0
- package/dist/use/useSelect.d.ts +15 -0
- package/dist/use/useSelect.js +56 -0
- package/dist/use/useSelectorId.d.ts +1 -0
- package/dist/use/useSelectorId.js +5 -0
- package/dist/use/useSetTimeout.d.ts +10 -0
- package/dist/use/useSetTimeout.js +34 -0
- package/dist/use/useStopMovePropagate.d.ts +5 -0
- package/dist/use/useStopMovePropagate.js +28 -0
- package/dist/use/useThrottle.d.ts +8 -0
- package/dist/use/useThrottle.js +11 -0
- package/dist/use/useUpdateEffect.d.ts +5 -0
- package/dist/use/useUpdateEffect.js +18 -0
- package/dist/use/useUpdateWatchSync.d.ts +5 -0
- package/dist/use/useUpdateWatchSync.js +18 -0
- package/dist/use/useWatchStateSync.d.ts +4 -0
- package/dist/use/useWatchStateSync.js +18 -0
- package/dist/utils/animate.d.ts +28 -0
- package/dist/utils/animate.js +81 -0
- package/dist/utils/createPubSub.d.ts +8 -0
- package/dist/utils/createPubSub.js +53 -0
- package/dist/utils/date.d.ts +13 -0
- package/dist/utils/date.js +87 -0
- package/dist/utils/dom.d.ts +149 -0
- package/dist/utils/dom.js +297 -0
- package/dist/utils/file.d.ts +18 -0
- package/dist/utils/file.js +57 -0
- package/dist/utils/imperative.d.ts +20 -0
- package/dist/utils/imperative.js +37 -0
- package/dist/utils/index.d.ts +7 -0
- package/dist/utils/index.js +7 -0
- package/dist/utils/is.d.ts +16 -0
- package/dist/utils/is.js +57 -0
- package/dist/utils/measure.d.ts +8 -0
- package/dist/utils/measure.js +13 -0
- package/dist/utils/measure.rn.d.ts +8 -0
- package/dist/utils/measure.rn.js +15 -0
- package/dist/utils/platform.android.d.ts +2 -0
- package/dist/utils/platform.android.js +2 -0
- package/dist/utils/platform.d.ts +2 -0
- package/dist/utils/platform.ios.d.ts +2 -0
- package/dist/utils/platform.ios.js +2 -0
- package/dist/utils/platform.js +2 -0
- package/dist/utils/style.d.ts +10 -0
- package/dist/utils/style.js +34 -0
- package/dist/utils/utils.d.ts +199 -0
- package/dist/utils/utils.js +639 -0
- package/package.json +30 -0
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useEffect, useMemo, useRef, useState } from 'react';
|
|
3
|
+
import classNames from 'classnames';
|
|
4
|
+
import { CustomWrapper, ScrollView, Text, View } from '@tarojs/components';
|
|
5
|
+
import { Tabs } from '../tabs';
|
|
6
|
+
import Icon from '../icon';
|
|
7
|
+
import useTranslate from '../locale/useTranslate';
|
|
8
|
+
import { useBem, useControllableValue } from '../use';
|
|
9
|
+
import { isFunction, isNullish, isRN } from '../utils';
|
|
10
|
+
import Pressable from '../pressable';
|
|
11
|
+
import Popout from '../popout';
|
|
12
|
+
import { Animated, Easing } from '../animated';
|
|
13
|
+
import Loading from '../loading';
|
|
14
|
+
import CSSTransition from '../transition/CSSTransition';
|
|
15
|
+
const defaultFieldNames = {
|
|
16
|
+
label: 'label',
|
|
17
|
+
value: 'value',
|
|
18
|
+
disabled: 'disabled',
|
|
19
|
+
children: 'children',
|
|
20
|
+
};
|
|
21
|
+
function getSelectedOptionsByValue(options, value, fieldNames) {
|
|
22
|
+
for (const option of options) {
|
|
23
|
+
if (option[fieldNames.value] === value) {
|
|
24
|
+
return [option];
|
|
25
|
+
}
|
|
26
|
+
if (Array.isArray(option[fieldNames.children])) {
|
|
27
|
+
const selectedOptions = getSelectedOptionsByValue(option[fieldNames.children], value, fieldNames);
|
|
28
|
+
if (selectedOptions) {
|
|
29
|
+
return [option, ...selectedOptions];
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
function defaultOutletFormatter(labels) {
|
|
35
|
+
return labels.join('/');
|
|
36
|
+
}
|
|
37
|
+
function outletFormatter(props, value) {
|
|
38
|
+
if (isNullish(value)) {
|
|
39
|
+
return '';
|
|
40
|
+
}
|
|
41
|
+
const fieldNames = Object.assign({}, defaultFieldNames, props.fieldNames);
|
|
42
|
+
const selectedOptions = getSelectedOptionsByValue(props.options || [], value, fieldNames);
|
|
43
|
+
if (!selectedOptions) {
|
|
44
|
+
return '';
|
|
45
|
+
}
|
|
46
|
+
const labels = selectedOptions.map((option) => option[fieldNames.label]);
|
|
47
|
+
const formatter = props.outletFormatter ?? Cascader.defaultOutletFormatter;
|
|
48
|
+
return formatter(labels);
|
|
49
|
+
}
|
|
50
|
+
const defaultOptions = [];
|
|
51
|
+
export const Cascader = (props) => {
|
|
52
|
+
const { t } = useTranslate('cascader');
|
|
53
|
+
const { className, style, value, defaultValue, onChange, options = defaultOptions, fieldNames = {}, placeholder = t('pleaseSelect'), onSelect, labelRender, optionTop, optionBottom, withPopout, popoutProps, outletFormatter, ...restProps } = props;
|
|
54
|
+
void outletFormatter;
|
|
55
|
+
const [bem] = useBem('cascader');
|
|
56
|
+
const fieldkeys = useMemo(() => Object.assign({}, defaultFieldNames, fieldNames), [fieldNames]);
|
|
57
|
+
const [innerValue, setInnerValue] = useControllableValue({
|
|
58
|
+
value,
|
|
59
|
+
defaultValue,
|
|
60
|
+
trigger: onChange,
|
|
61
|
+
});
|
|
62
|
+
const tempValue = useRef(innerValue);
|
|
63
|
+
const [tabsActiveKey, setTabsActiveKey] = useState(0);
|
|
64
|
+
const handleTabsChange = (index) => {
|
|
65
|
+
setTabsActiveKey(index);
|
|
66
|
+
};
|
|
67
|
+
const [tabs, setTabs] = useState([]);
|
|
68
|
+
const updateTabs = () => {
|
|
69
|
+
let nextTabs;
|
|
70
|
+
if (tempValue.current === undefined) {
|
|
71
|
+
nextTabs = [
|
|
72
|
+
{
|
|
73
|
+
options,
|
|
74
|
+
selected: null,
|
|
75
|
+
},
|
|
76
|
+
];
|
|
77
|
+
}
|
|
78
|
+
else {
|
|
79
|
+
const selectedOptions = getSelectedOptionsByValue(options, tempValue.current, fieldkeys);
|
|
80
|
+
if (selectedOptions) {
|
|
81
|
+
let nextOptions = options;
|
|
82
|
+
nextTabs = selectedOptions.map((option) => {
|
|
83
|
+
const tab = {
|
|
84
|
+
options: nextOptions,
|
|
85
|
+
selected: option,
|
|
86
|
+
};
|
|
87
|
+
nextOptions = option.children;
|
|
88
|
+
return tab;
|
|
89
|
+
});
|
|
90
|
+
if (nextOptions) {
|
|
91
|
+
nextTabs.push({
|
|
92
|
+
options: nextOptions,
|
|
93
|
+
selected: null,
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
if (nextTabs) {
|
|
99
|
+
setTabs(nextTabs);
|
|
100
|
+
setTabsActiveKey(nextTabs.length - 1);
|
|
101
|
+
}
|
|
102
|
+
};
|
|
103
|
+
const isLastOption = (option) => {
|
|
104
|
+
return !Array.isArray(option[fieldkeys.children]);
|
|
105
|
+
};
|
|
106
|
+
const handleOptionClick = (option, tabIndex) => {
|
|
107
|
+
let nextTabs = tabs.slice();
|
|
108
|
+
nextTabs[tabIndex].selected = option;
|
|
109
|
+
const selectBack = tabIndex < nextTabs.length - 1;
|
|
110
|
+
if (selectBack) {
|
|
111
|
+
nextTabs = nextTabs.slice(0, tabIndex + 1);
|
|
112
|
+
}
|
|
113
|
+
if (!isLastOption(option)) {
|
|
114
|
+
const nextTab = {
|
|
115
|
+
options: option[fieldkeys.children],
|
|
116
|
+
selected: null,
|
|
117
|
+
};
|
|
118
|
+
nextTabs.push(nextTab);
|
|
119
|
+
setTabsActiveKey(nextTabs.length - 1);
|
|
120
|
+
}
|
|
121
|
+
else {
|
|
122
|
+
// finish
|
|
123
|
+
setTabsActiveKey(tabIndex);
|
|
124
|
+
setInnerValue(option[fieldkeys.value], nextTabs.map((tab) => tab.selected));
|
|
125
|
+
}
|
|
126
|
+
tempValue.current = option[fieldkeys.value];
|
|
127
|
+
setTabs(nextTabs);
|
|
128
|
+
onSelect?.(option, tabIndex);
|
|
129
|
+
};
|
|
130
|
+
useEffect(() => {
|
|
131
|
+
updateTabs();
|
|
132
|
+
}, [options]);
|
|
133
|
+
useEffect(() => {
|
|
134
|
+
if (value !== undefined) {
|
|
135
|
+
if (tabs.some((tab) => tab.selected?.[fieldkeys.value] === value)) {
|
|
136
|
+
return;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
tempValue.current = value;
|
|
140
|
+
updateTabs();
|
|
141
|
+
}, [value]);
|
|
142
|
+
const renderOption = (option, selectedOption, tabIndex) => {
|
|
143
|
+
const value = option[fieldkeys.value];
|
|
144
|
+
const selected = selectedOption && selectedOption[fieldkeys.value] === value;
|
|
145
|
+
return (_jsx(Pressable, { disabled: option[fieldkeys.disabled], children: ({ pressed }) => (_jsxs(View, { className: classNames(bem.e('option'), bem.em('option', 'selected', selected), bem.em('option', 'disabled', option[fieldkeys.disabled]), bem.em('option', 'pressed', pressed)), style: style, onClick: () => {
|
|
146
|
+
if (!option.disabled && (!selected || !isLastOption(option))) {
|
|
147
|
+
handleOptionClick(option, tabIndex);
|
|
148
|
+
}
|
|
149
|
+
}, children: [_jsx(Text, { className: classNames(bem.e('option-label'), bem.em('option-label', 'selected', selected)), children: labelRender
|
|
150
|
+
? labelRender(option, selected)
|
|
151
|
+
: option[fieldkeys.label] }), _jsx(Icon, { name: "success", className: classNames(bem.e('option-icon'), bem.em('option-icon', 'selected', selected)) })] })) }, value));
|
|
152
|
+
};
|
|
153
|
+
const renderOptions = (options, selectedOption, tabIndex) => {
|
|
154
|
+
return (_jsxs(View, { className: bem.e('options'), children: [_jsx(ScrollView, { scrollY: true, showScrollbar: false, className: bem.e('scroll'), children: options.map((option) => {
|
|
155
|
+
return renderOption(option, selectedOption, tabIndex);
|
|
156
|
+
}) }), _jsx(CSSTransition, { in: options.length === 0, effect: "fade", timeout: 300, appear: true, mountOnEnter: true, unmountOnExit: true, className: bem.e('loading-wrapper'), children: _jsx(Loading, { size: 24, className: bem.e('loading') }) })] }));
|
|
157
|
+
};
|
|
158
|
+
const renderTabs = () => {
|
|
159
|
+
return (_jsx(Tabs, { scrollable: true, ...restProps, activeKey: String(tabsActiveKey), onChange: handleTabsChange, className: classNames(bem.b(), className), children: tabs.map((tab, tabIndex) => {
|
|
160
|
+
const { selected } = tab;
|
|
161
|
+
const tabLabel = selected ? selected[fieldkeys.label] : placeholder;
|
|
162
|
+
return _jsx(Tabs.Tab, { children: tabLabel }, tabIndex);
|
|
163
|
+
}) }));
|
|
164
|
+
};
|
|
165
|
+
// Animated >>>
|
|
166
|
+
const layoutWidth = useRef(0);
|
|
167
|
+
const firstOnLayout = useRef(false);
|
|
168
|
+
const anim = useMemo(() => new Animated.Value(-layoutWidth.current * Number(tabsActiveKey)), []);
|
|
169
|
+
const animateTranslateX = () => {
|
|
170
|
+
Animated.timing(anim, {
|
|
171
|
+
toValue: -layoutWidth.current * Number(tabsActiveKey),
|
|
172
|
+
duration: 300,
|
|
173
|
+
easing: Easing.inOut(Easing.quad),
|
|
174
|
+
useNativeDriver: true,
|
|
175
|
+
}).start();
|
|
176
|
+
};
|
|
177
|
+
useEffect(() => {
|
|
178
|
+
isRN && animateTranslateX();
|
|
179
|
+
}, [tabsActiveKey]);
|
|
180
|
+
// <<< Animated
|
|
181
|
+
const renderPanes = () => {
|
|
182
|
+
return (_jsx(View, { className: classNames(bem.e('container')), children: _jsx(Animated.View, { className: classNames(bem.e('wrapper')), style: {
|
|
183
|
+
...(isRN
|
|
184
|
+
? { transform: [{ translateX: anim }] }
|
|
185
|
+
: {
|
|
186
|
+
transform: `translateX(${-Number(tabsActiveKey) * 100}%)`,
|
|
187
|
+
}),
|
|
188
|
+
}, ...(isRN
|
|
189
|
+
? {
|
|
190
|
+
onLayout: (event) => {
|
|
191
|
+
const width = event.nativeEvent.layout.width;
|
|
192
|
+
if (!firstOnLayout.current) {
|
|
193
|
+
anim.setValue(-width * Number(tabsActiveKey));
|
|
194
|
+
firstOnLayout.current = true;
|
|
195
|
+
}
|
|
196
|
+
layoutWidth.current = width;
|
|
197
|
+
},
|
|
198
|
+
}
|
|
199
|
+
: null), children: tabs.map((tab, tabIndex) => {
|
|
200
|
+
const { options, selected } = tab;
|
|
201
|
+
return (_jsxs(View, { className: classNames(bem.e('pane')), children: [isFunction(optionTop) ? optionTop(tabIndex) : optionTop, renderOptions(options, selected, tabIndex), isFunction(optionBottom)
|
|
202
|
+
? optionBottom(tabIndex)
|
|
203
|
+
: optionBottom] }, tabIndex));
|
|
204
|
+
}) }) }));
|
|
205
|
+
};
|
|
206
|
+
const renderElement = () => {
|
|
207
|
+
return (_jsxs(CustomWrapper, { children: [renderTabs(), renderPanes()] }));
|
|
208
|
+
};
|
|
209
|
+
if (withPopout) {
|
|
210
|
+
return _jsx(Popout, { ...popoutProps, children: renderElement() });
|
|
211
|
+
}
|
|
212
|
+
return renderElement();
|
|
213
|
+
};
|
|
214
|
+
Cascader.outletFormatter = outletFormatter;
|
|
215
|
+
Cascader.defaultOutletFormatter = defaultOutletFormatter;
|
|
216
|
+
export default Cascader;
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
@import '../style/base.scss';
|
|
2
|
+
// #variables
|
|
3
|
+
$sar-cascader-selected-color: $sar-primary !default;
|
|
4
|
+
|
|
5
|
+
$sar-cascader-options-height: 320px !default;
|
|
6
|
+
|
|
7
|
+
$sar-cascader-option-padding-y: 8px !default;
|
|
8
|
+
$sar-cascader-option-padding-x: 16px !default;
|
|
9
|
+
$sar-cascader-option-font-size: $sar-text-base !default;
|
|
10
|
+
$sar-cascader-option-line-height: 24px !default;
|
|
11
|
+
$sar-cascader-option-active-bg-color: $sar-active-bg-color !default;
|
|
12
|
+
|
|
13
|
+
$sar-cascader-loading-bg-color: $sar-emphasis-bg-color !default;
|
|
14
|
+
$sar-cascader-loading-color: $sar-tertiary-color !default;
|
|
15
|
+
|
|
16
|
+
// 暗黑模式
|
|
17
|
+
$sar-cascader-option-active-dark-bg-color: $sar-dark-active-bg-color !default;
|
|
18
|
+
$sar-cascader-loading-dark-bg-color: $sar-dark-emphasis-bg-color !default;
|
|
19
|
+
$sar-cascader-loading-dark-color: $sar-dark-tertiary-color !default;
|
|
20
|
+
// #endvariables
|
|
21
|
+
|
|
22
|
+
@include bem(cascader) {
|
|
23
|
+
@include b() {
|
|
24
|
+
@include universal;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
@include e(container) {
|
|
28
|
+
@include universal;
|
|
29
|
+
overflow: hidden;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
@include e(wrapper) {
|
|
33
|
+
@include universal;
|
|
34
|
+
width: 100%;
|
|
35
|
+
flex-direction: row;
|
|
36
|
+
flex-wrap: nowrap;
|
|
37
|
+
@include ifweb {
|
|
38
|
+
transition: transform $sar-duration;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
@include e(pane) {
|
|
43
|
+
@include universal;
|
|
44
|
+
width: 100%;
|
|
45
|
+
flex: none;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
@include e(options) {
|
|
49
|
+
@include universal;
|
|
50
|
+
flex-direction: row;
|
|
51
|
+
height: $sar-cascader-options-height;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
@include e(scroll) {
|
|
55
|
+
height: 100%;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
@include e(option) {
|
|
59
|
+
@include universal;
|
|
60
|
+
flex-direction: row;
|
|
61
|
+
padding: $sar-cascader-option-padding-y $sar-cascader-option-padding-x;
|
|
62
|
+
|
|
63
|
+
@include ifweb {
|
|
64
|
+
cursor: pointer;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
@include m(disabled) {
|
|
68
|
+
@include disabled;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
@include m(pressed) {
|
|
72
|
+
background-color: $sar-cascader-option-active-bg-color;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
@include e(option-label) {
|
|
77
|
+
font-size: $sar-cascader-option-font-size;
|
|
78
|
+
line-height: $sar-cascader-option-line-height;
|
|
79
|
+
|
|
80
|
+
@include m(selected) {
|
|
81
|
+
color: $sar-cascader-selected-color;
|
|
82
|
+
font-weight: $sar-font-bold;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
@include e(option-icon) {
|
|
87
|
+
display: none;
|
|
88
|
+
margin-left: auto;
|
|
89
|
+
|
|
90
|
+
@include m(selected) {
|
|
91
|
+
display: flex;
|
|
92
|
+
color: $sar-cascader-selected-color;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
@include e(loading-wrapper) {
|
|
97
|
+
@include universal;
|
|
98
|
+
position: absolute;
|
|
99
|
+
top: 0;
|
|
100
|
+
left: 0;
|
|
101
|
+
z-index: 2;
|
|
102
|
+
justify-content: center;
|
|
103
|
+
align-items: center;
|
|
104
|
+
width: 100%;
|
|
105
|
+
height: 100%;
|
|
106
|
+
background-color: $sar-cascader-loading-bg-color;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
@include e(loading) {
|
|
110
|
+
color: $sar-cascader-loading-color;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
@include theme(dark) {
|
|
115
|
+
@include bem(cascader) {
|
|
116
|
+
@include e(option) {
|
|
117
|
+
@include m(pressed) {
|
|
118
|
+
background-color: $sar-cascader-option-active-dark-bg-color;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
@include e(loading-wrapper) {
|
|
123
|
+
background-color: $sar-cascader-loading-dark-bg-color;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
@include e(loading) {
|
|
127
|
+
color: $sar-cascader-loading-dark-color;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { FC } from 'react';
|
|
2
|
+
import { CheckboxGroup } from './Group';
|
|
3
|
+
import { InternalCheckProps } from '../use/useInternalSelect';
|
|
4
|
+
export * from './Group';
|
|
5
|
+
export type CheckboxProps = InternalCheckProps;
|
|
6
|
+
export interface CheckboxFC extends FC<CheckboxProps> {
|
|
7
|
+
Group: typeof CheckboxGroup;
|
|
8
|
+
}
|
|
9
|
+
export declare const Checkbox: CheckboxFC;
|
|
10
|
+
export default Checkbox;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { CheckboxGroup } from './Group';
|
|
2
|
+
import { useInternalSelect } from '../use/useInternalSelect';
|
|
3
|
+
export * from './Group';
|
|
4
|
+
export const Checkbox = ((props) => {
|
|
5
|
+
return useInternalSelect('multiple', 'checkbox', props);
|
|
6
|
+
});
|
|
7
|
+
Checkbox.Group = CheckboxGroup;
|
|
8
|
+
export default Checkbox;
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
@import '../style/base.scss';
|
|
2
|
+
// #variables
|
|
3
|
+
$sar-checkbox-icon-font-size: 20px !default;
|
|
4
|
+
$sar-checkbox-icon-color: $sar-quaternary-color !default;
|
|
5
|
+
$sar-checkbox-icon-checked-color: $sar-primary !default;
|
|
6
|
+
$sar-checkbox-icon-transition-duration: $sar-duration !default;
|
|
7
|
+
|
|
8
|
+
$sar-checkbox-label-margin-left: 8px !default;
|
|
9
|
+
|
|
10
|
+
$sar-checkbox-margin-left: 20px !default;
|
|
11
|
+
$sar-checkbox-margin-top: 10px !default;
|
|
12
|
+
|
|
13
|
+
// 暗黑模式
|
|
14
|
+
$sar-checkbox-icon-dark-color: $sar-dark-quaternary-color !default;
|
|
15
|
+
$sar-checkbox-icon-checked-dark-color: $sar-primary !default;
|
|
16
|
+
// #endvariables
|
|
17
|
+
|
|
18
|
+
@include bem(checkbox) {
|
|
19
|
+
@include b() {
|
|
20
|
+
@include universal;
|
|
21
|
+
flex-direction: row;
|
|
22
|
+
align-items: center;
|
|
23
|
+
align-self: flex-start;
|
|
24
|
+
|
|
25
|
+
@include ifweb {
|
|
26
|
+
cursor: pointer;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
@include e(icon) {
|
|
31
|
+
@include universal;
|
|
32
|
+
font-size: $sar-checkbox-icon-font-size;
|
|
33
|
+
color: $sar-checkbox-icon-color;
|
|
34
|
+
@include ifweb {
|
|
35
|
+
transition: color $sar-checkbox-icon-transition-duration;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
@include m(checked) {
|
|
39
|
+
color: $sar-checkbox-icon-checked-color;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
@include m(disabled) {
|
|
43
|
+
color: $sar-disabled-deep-bg-color;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
@include e(label) {
|
|
48
|
+
@include universal;
|
|
49
|
+
flex-direction: row;
|
|
50
|
+
margin-left: $sar-checkbox-label-margin-left;
|
|
51
|
+
|
|
52
|
+
@include m(disabled) {
|
|
53
|
+
color: $sar-disabled-color;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
@include theme(dark) {
|
|
59
|
+
@include bem(checkbox) {
|
|
60
|
+
@include e(icon) {
|
|
61
|
+
color: $sar-checkbox-icon-dark-color;
|
|
62
|
+
|
|
63
|
+
@include m(checked) {
|
|
64
|
+
color: $sar-checkbox-icon-checked-dark-color;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
@include m(disabled) {
|
|
68
|
+
color: $sar-disabled-deep-bg-color;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
@include e(label) {
|
|
73
|
+
@include m(disabled) {
|
|
74
|
+
color: $sar-dark-disabled-color;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { FC } from 'react';
|
|
2
|
+
import { BaseProps } from '../base';
|
|
3
|
+
export interface CollapseProps extends BaseProps {
|
|
4
|
+
visible?: boolean;
|
|
5
|
+
duration?: number;
|
|
6
|
+
onEnter?: () => void;
|
|
7
|
+
onEntering?: () => void;
|
|
8
|
+
onEntered?: () => void;
|
|
9
|
+
onExit?: () => void;
|
|
10
|
+
onExiting?: () => void;
|
|
11
|
+
onExited?: () => void;
|
|
12
|
+
}
|
|
13
|
+
export declare const Collapse: FC<CollapseProps>;
|
|
14
|
+
export default Collapse;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useRef, useState } from 'react';
|
|
3
|
+
import classNames from 'classnames';
|
|
4
|
+
import { CustomWrapper, View } from '@tarojs/components';
|
|
5
|
+
import { Transition } from '../transition/index';
|
|
6
|
+
import { useBem, useEvent, useSelectorId, useSetTimeout } from '../use';
|
|
7
|
+
import { filterNullish, getRectByElement } from '../utils';
|
|
8
|
+
export const Collapse = (props) => {
|
|
9
|
+
const { className, style, children, visible, duration = 500, onEnter, onEntering, onEntered, onExit, onExiting, onExited, ...restProps } = props;
|
|
10
|
+
const [bem] = useBem('collapse');
|
|
11
|
+
const collapseRef = useRef(null);
|
|
12
|
+
const contextId = useSelectorId();
|
|
13
|
+
const [show, setShow] = useState(visible);
|
|
14
|
+
const [collapsing, setCollapsing] = useState(false);
|
|
15
|
+
const [height, setHeight] = useState();
|
|
16
|
+
const [setHeightLater] = useSetTimeout((height) => {
|
|
17
|
+
setHeight(height);
|
|
18
|
+
}, 100);
|
|
19
|
+
const handleEnter = useEvent(() => {
|
|
20
|
+
getRectByElement(collapseRef.current, contextId).then((res) => {
|
|
21
|
+
setHeight(0);
|
|
22
|
+
setShow(true);
|
|
23
|
+
setCollapsing(true);
|
|
24
|
+
setHeightLater(res.height);
|
|
25
|
+
});
|
|
26
|
+
onEnter?.();
|
|
27
|
+
});
|
|
28
|
+
const handleEntering = useEvent(() => {
|
|
29
|
+
onEntering?.();
|
|
30
|
+
});
|
|
31
|
+
const handleEntered = useEvent(() => {
|
|
32
|
+
setHeight(undefined);
|
|
33
|
+
setCollapsing(false);
|
|
34
|
+
onEntered?.();
|
|
35
|
+
});
|
|
36
|
+
const handleExit = useEvent(() => {
|
|
37
|
+
getRectByElement(collapseRef.current, contextId).then((res) => {
|
|
38
|
+
setHeight(res.height);
|
|
39
|
+
setCollapsing(true);
|
|
40
|
+
setHeightLater(0);
|
|
41
|
+
});
|
|
42
|
+
onExit?.();
|
|
43
|
+
});
|
|
44
|
+
const handleExiting = useEvent(() => {
|
|
45
|
+
onExiting?.();
|
|
46
|
+
});
|
|
47
|
+
const handleExited = useEvent(() => {
|
|
48
|
+
setHeight(undefined);
|
|
49
|
+
setCollapsing(false);
|
|
50
|
+
setShow(false);
|
|
51
|
+
onExited?.();
|
|
52
|
+
});
|
|
53
|
+
return (_jsx(CustomWrapper, { id: contextId, children: _jsx(Transition, { ...restProps, timeout: duration, in: visible, onEnter: handleEnter, onEntering: handleEntering, onEntered: handleEntered, onExit: handleExit, onExiting: handleExiting, onExited: handleExited, children: _jsx(View, { className: classNames(bem.b(), bem.m('show', show), bem.m('collapsing', collapsing), className), style: {
|
|
54
|
+
...style,
|
|
55
|
+
...filterNullish({
|
|
56
|
+
height,
|
|
57
|
+
}),
|
|
58
|
+
transitionDuration: duration + 'ms',
|
|
59
|
+
}, children: _jsx(View, { className: bem.e('content'), ref: collapseRef, children: children }) }) }) }));
|
|
60
|
+
};
|
|
61
|
+
export default Collapse;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { FC } from 'react';
|
|
2
|
+
import { BaseProps } from '../base';
|
|
3
|
+
export interface CollapseProps extends BaseProps {
|
|
4
|
+
visible?: boolean;
|
|
5
|
+
duration?: number;
|
|
6
|
+
onEnter?: () => void;
|
|
7
|
+
onEntering?: () => void;
|
|
8
|
+
onEntered?: () => void;
|
|
9
|
+
onExit?: () => void;
|
|
10
|
+
onExiting?: () => void;
|
|
11
|
+
onExited?: () => void;
|
|
12
|
+
}
|
|
13
|
+
export declare const Collapse: FC<CollapseProps>;
|
|
14
|
+
export default Collapse;
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useMemo, useRef, useState } from 'react';
|
|
3
|
+
import { Animated, View } from 'react-native';
|
|
4
|
+
import { Transition } from '../transition/index';
|
|
5
|
+
import { useEvent } from '../use';
|
|
6
|
+
export const Collapse = (props) => {
|
|
7
|
+
const { style, children, visible, duration = 500, onEnter, onEntering, onEntered, onExit, onExiting, onExited, } = props;
|
|
8
|
+
const layoutHeight = useRef(0);
|
|
9
|
+
const [collapsing, setCollapsing] = useState(false);
|
|
10
|
+
const anim = useMemo(() => new Animated.Value(0), []);
|
|
11
|
+
const firstOnLayout = useRef(false);
|
|
12
|
+
const [contentStyle, setContentStyle] = useState({
|
|
13
|
+
position: visible ? 'relative' : 'absolute',
|
|
14
|
+
});
|
|
15
|
+
const collapseIn = () => {
|
|
16
|
+
Animated.timing(anim, {
|
|
17
|
+
toValue: layoutHeight.current,
|
|
18
|
+
duration,
|
|
19
|
+
useNativeDriver: false,
|
|
20
|
+
}).start();
|
|
21
|
+
};
|
|
22
|
+
const collapseOut = () => {
|
|
23
|
+
Animated.timing(anim, {
|
|
24
|
+
toValue: 0,
|
|
25
|
+
duration,
|
|
26
|
+
useNativeDriver: false,
|
|
27
|
+
}).start();
|
|
28
|
+
};
|
|
29
|
+
const handleEnter = useEvent(() => {
|
|
30
|
+
setContentStyle({
|
|
31
|
+
position: 'relative',
|
|
32
|
+
});
|
|
33
|
+
onEnter?.();
|
|
34
|
+
});
|
|
35
|
+
const handleEntering = useEvent(() => {
|
|
36
|
+
collapseIn();
|
|
37
|
+
setCollapsing(true);
|
|
38
|
+
onEntering?.();
|
|
39
|
+
});
|
|
40
|
+
const handleEntered = useEvent(() => {
|
|
41
|
+
setCollapsing(false);
|
|
42
|
+
onEntered?.();
|
|
43
|
+
});
|
|
44
|
+
const handleExit = useEvent(() => {
|
|
45
|
+
onExit?.();
|
|
46
|
+
});
|
|
47
|
+
const handleExiting = useEvent(() => {
|
|
48
|
+
collapseOut();
|
|
49
|
+
setCollapsing(true);
|
|
50
|
+
onExiting?.();
|
|
51
|
+
});
|
|
52
|
+
const handleExited = useEvent(() => {
|
|
53
|
+
setContentStyle({
|
|
54
|
+
position: 'absolute',
|
|
55
|
+
});
|
|
56
|
+
setCollapsing(false);
|
|
57
|
+
onExited?.();
|
|
58
|
+
});
|
|
59
|
+
return (_jsx(Transition, { timeout: duration, in: visible, onEnter: handleEnter, onEntering: handleEntering, onEntered: handleEntered, onExit: handleExit, onExiting: handleExiting, onExited: handleExited, children: _jsx(Animated.View, { style: {
|
|
60
|
+
...style,
|
|
61
|
+
height: collapsing ? anim : visible ? undefined : 0,
|
|
62
|
+
position: 'relative',
|
|
63
|
+
overflow: collapsing || !visible ? 'hidden' : 'visible',
|
|
64
|
+
}, children: _jsx(View, { style: {
|
|
65
|
+
width: '100%',
|
|
66
|
+
...contentStyle,
|
|
67
|
+
}, onLayout: (event) => {
|
|
68
|
+
const height = event.nativeEvent.layout.height;
|
|
69
|
+
if (!firstOnLayout.current) {
|
|
70
|
+
anim.setValue(visible ? height : 0);
|
|
71
|
+
firstOnLayout.current = true;
|
|
72
|
+
}
|
|
73
|
+
layoutHeight.current = height;
|
|
74
|
+
}, children: children }) }) }));
|
|
75
|
+
};
|
|
76
|
+
export default Collapse;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
@import '../style/base.scss';
|
|
2
|
+
// #variables
|
|
3
|
+
$sar-collapse-transition-duration: $sar-duration-slow !default;
|
|
4
|
+
// #endvariables
|
|
5
|
+
|
|
6
|
+
@include bem(collapse) {
|
|
7
|
+
@include b() {
|
|
8
|
+
@include universal;
|
|
9
|
+
position: absolute;
|
|
10
|
+
z-index: -10;
|
|
11
|
+
width: 100%;
|
|
12
|
+
overflow: hidden;
|
|
13
|
+
@include ifweb {
|
|
14
|
+
visibility: hidden;
|
|
15
|
+
transition: height $sar-collapse-transition-duration;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
@include m(show) {
|
|
20
|
+
position: relative;
|
|
21
|
+
z-index: 0;
|
|
22
|
+
overflow: visible;
|
|
23
|
+
@include ifweb {
|
|
24
|
+
visibility: visible;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
@include m(collapsing) {
|
|
29
|
+
overflow: hidden;
|
|
30
|
+
}
|
|
31
|
+
}
|