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,91 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { cloneElement, isValidElement, useMemo, useRef, } from 'react';
|
|
3
|
+
import classNames from 'classnames';
|
|
4
|
+
import { CustomWrapper, View } from '@tarojs/components';
|
|
5
|
+
import { useBem, useControllableValue, useEvent, useWatchStateSync, } from '../use';
|
|
6
|
+
import { Input } from '../input';
|
|
7
|
+
import Icon from '../icon';
|
|
8
|
+
import { isEmptyValue, isNullish } from '../utils';
|
|
9
|
+
import Pressable from '../pressable';
|
|
10
|
+
export const PopoutInput = (props) => {
|
|
11
|
+
const { className, style, value, defaultValue, onChange, trigger = 'onChange', valuePropName = 'value', inputProps, disabled, readOnly, visible, defaultVisible, onVisible, title, children, ...restProps } = props;
|
|
12
|
+
const [bem] = useBem('popout-input');
|
|
13
|
+
const [innerVisible, setInnerVisible] = useControllableValue({
|
|
14
|
+
value: visible,
|
|
15
|
+
defaultValue: defaultVisible,
|
|
16
|
+
trigger: onVisible,
|
|
17
|
+
initialValue: false,
|
|
18
|
+
});
|
|
19
|
+
const [innerValue, setInnerValue] = useControllableValue({
|
|
20
|
+
value,
|
|
21
|
+
defaultValue,
|
|
22
|
+
trigger: onChange,
|
|
23
|
+
});
|
|
24
|
+
const [tempValue, setTempValue] = useWatchStateSync(innerValue);
|
|
25
|
+
const alwaysHasValue = children?.type?.alwaysHasValue;
|
|
26
|
+
const targetRef = useRef();
|
|
27
|
+
const handleConfirm = useEvent(() => {
|
|
28
|
+
let currentTempValue = tempValue;
|
|
29
|
+
if (isNullish(tempValue) && alwaysHasValue) {
|
|
30
|
+
const value = targetRef.current.getValueForcibly();
|
|
31
|
+
currentTempValue = value;
|
|
32
|
+
}
|
|
33
|
+
setInnerValue(currentTempValue);
|
|
34
|
+
});
|
|
35
|
+
const confirmDisabled = useMemo(() => {
|
|
36
|
+
return isEmptyValue(tempValue);
|
|
37
|
+
}, [tempValue]);
|
|
38
|
+
const handlerClear = useEvent(() => {
|
|
39
|
+
setInnerValue(undefined);
|
|
40
|
+
});
|
|
41
|
+
const renderInput = ({ outletValue, disabled, readOnly, setVisible }) => {
|
|
42
|
+
return (_jsx(Pressable, { disabled: disabled || readOnly, children: ({ pressed }) => {
|
|
43
|
+
return (_jsx(View, { className: classNames(bem.b(), bem.m('disabled', disabled), bem.m('pressed', pressed)), onClick: (event) => {
|
|
44
|
+
if (!disabled && !readOnly) {
|
|
45
|
+
setVisible(true);
|
|
46
|
+
}
|
|
47
|
+
inputProps?.onClick?.(event);
|
|
48
|
+
}, children: _jsx(Input, { inlaid: true, readOnly: readOnly, disabled: disabled, append: _jsx(Icon, { className: bem.e('arrow'), name: "caret-right" }), ...inputProps, addon: _jsx(View, { className: bem.e('seal') }), value: isNullish(outletValue) ? '' : String(outletValue), onClear: (event) => {
|
|
49
|
+
handlerClear();
|
|
50
|
+
inputProps?.onClear?.(event);
|
|
51
|
+
}, style: inputProps?.style, className: inputProps?.className }) }));
|
|
52
|
+
} }));
|
|
53
|
+
};
|
|
54
|
+
const renderPopout = () => {
|
|
55
|
+
if (!isValidElement(children)) {
|
|
56
|
+
return null;
|
|
57
|
+
}
|
|
58
|
+
const targetProps = {
|
|
59
|
+
[valuePropName]: tempValue,
|
|
60
|
+
[trigger]: (value, ...restArgs) => {
|
|
61
|
+
setTempValue(value);
|
|
62
|
+
children.props?.[trigger]?.(value, ...restArgs);
|
|
63
|
+
},
|
|
64
|
+
withPopout: true,
|
|
65
|
+
popoutProps: {
|
|
66
|
+
...children.props.popoutProps,
|
|
67
|
+
title,
|
|
68
|
+
visible: innerVisible,
|
|
69
|
+
onVisible: setInnerVisible,
|
|
70
|
+
confirmProps: {
|
|
71
|
+
disabled: !alwaysHasValue && confirmDisabled,
|
|
72
|
+
},
|
|
73
|
+
onConfirm: handleConfirm,
|
|
74
|
+
},
|
|
75
|
+
};
|
|
76
|
+
if (alwaysHasValue) {
|
|
77
|
+
targetProps.ref = targetRef;
|
|
78
|
+
}
|
|
79
|
+
return cloneElement(children, targetProps);
|
|
80
|
+
};
|
|
81
|
+
const outletValue = useMemo(() => {
|
|
82
|
+
return children?.type?.outletFormatter?.(children.props, innerValue) || '';
|
|
83
|
+
}, [innerValue]);
|
|
84
|
+
return (_jsx(CustomWrapper, { children: _jsxs(View, { ...restProps, className: className, style: style, children: [renderInput({
|
|
85
|
+
outletValue,
|
|
86
|
+
disabled,
|
|
87
|
+
readOnly,
|
|
88
|
+
setVisible: setInnerVisible,
|
|
89
|
+
}), renderPopout()] }) }));
|
|
90
|
+
};
|
|
91
|
+
export default PopoutInput;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
@import '../style/base.scss';
|
|
2
|
+
// #variables
|
|
3
|
+
$sar-popout-input-arrow-font-size: $sar-text-base !default;
|
|
4
|
+
$sar-popout-input-arrow-color: $sar-border-color !default;
|
|
5
|
+
$sar-popout-input-active-opacity: $sar-active-opacity !default;
|
|
6
|
+
|
|
7
|
+
// 暗黑模式
|
|
8
|
+
$sar-popout-input-arrow-dark-color: $sar-dark-border-color !default;
|
|
9
|
+
// #endvariables
|
|
10
|
+
|
|
11
|
+
@include bem(popout-input) {
|
|
12
|
+
@include b() {
|
|
13
|
+
@include universal;
|
|
14
|
+
|
|
15
|
+
@include ifweb {
|
|
16
|
+
cursor: pointer;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
@include m(pressed) {
|
|
20
|
+
opacity: $sar-popout-input-active-opacity;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
@include m(disabled) {
|
|
24
|
+
@include ifweb {
|
|
25
|
+
cursor: not-allowed;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
@include e(seal) {
|
|
31
|
+
@include universal;
|
|
32
|
+
position: absolute;
|
|
33
|
+
top: 0;
|
|
34
|
+
left: 0;
|
|
35
|
+
right: 0;
|
|
36
|
+
bottom: 0;
|
|
37
|
+
z-index: 1;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
@include e(arrow) {
|
|
41
|
+
@include universal;
|
|
42
|
+
font-size: $sar-popout-input-arrow-font-size;
|
|
43
|
+
color: $sar-popout-input-arrow-color;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
@include theme(dark) {
|
|
48
|
+
@include bem(popout-input) {
|
|
49
|
+
@include e(arrow) {
|
|
50
|
+
color: $sar-popout-input-arrow-dark-color;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { FC, ReactElement, CSSProperties } from 'react';
|
|
2
|
+
import { ITouchEvent } from '@tarojs/components';
|
|
3
|
+
import { MenuOption } from '../menu';
|
|
4
|
+
import { Placement } from './utils';
|
|
5
|
+
import { BaseProps } from '../base';
|
|
6
|
+
import { PopupProps } from '../popup';
|
|
7
|
+
export type { Placement as PopoverPlacement, MenuOption as PopoverOption };
|
|
8
|
+
export interface PopoverProps extends BaseProps, PopupProps {
|
|
9
|
+
options?: MenuOption[];
|
|
10
|
+
reference?: ReactElement;
|
|
11
|
+
refGap?: number;
|
|
12
|
+
viewportGap?: number;
|
|
13
|
+
placement?: Placement;
|
|
14
|
+
direction?: 'vertical' | 'horizontal';
|
|
15
|
+
theme?: 'dark' | 'light';
|
|
16
|
+
zIndex?: number;
|
|
17
|
+
onSelect?: (option: MenuOption) => void;
|
|
18
|
+
visible?: boolean;
|
|
19
|
+
defaultVisible?: boolean;
|
|
20
|
+
onVisible?: (visible: boolean) => void;
|
|
21
|
+
duration?: number;
|
|
22
|
+
mask?: boolean;
|
|
23
|
+
transparent?: boolean;
|
|
24
|
+
maskClass?: string;
|
|
25
|
+
maskStyle?: CSSProperties;
|
|
26
|
+
onMaskClick?: (event: ITouchEvent) => void;
|
|
27
|
+
onEnter?: () => void;
|
|
28
|
+
onEntering?: () => void;
|
|
29
|
+
onEntered?: () => void;
|
|
30
|
+
onExit?: () => void;
|
|
31
|
+
onExiting?: () => void;
|
|
32
|
+
onExited?: () => void;
|
|
33
|
+
}
|
|
34
|
+
export declare const Popover: FC<PopoverProps>;
|
|
35
|
+
export default Popover;
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { useState, cloneElement, useLayoutEffect, useRef, useMemo, useEffect, } from 'react';
|
|
3
|
+
import classNames from 'classnames';
|
|
4
|
+
import { View } from '@tarojs/components';
|
|
5
|
+
import { Menu } from '../menu';
|
|
6
|
+
import { useBem, useControllableValue, useEvent, useSetTimeout } from '../use';
|
|
7
|
+
import { getRectByElement, isNumber, isRN } from '../utils';
|
|
8
|
+
import { getPopoverPosition } from './utils';
|
|
9
|
+
import Popup from '../popup';
|
|
10
|
+
import { Animated } from '../animated';
|
|
11
|
+
import { getTimeouts } from '../transition';
|
|
12
|
+
function mayAddPixel(value) {
|
|
13
|
+
return isNumber(value) ? value + 'px' : value;
|
|
14
|
+
}
|
|
15
|
+
const zoomAnim = (timeouts) => {
|
|
16
|
+
const opacityValue = new Animated.Value(0);
|
|
17
|
+
const scaleValue = new Animated.Value(0.5);
|
|
18
|
+
return {
|
|
19
|
+
enter() {
|
|
20
|
+
opacityValue.setValue(0);
|
|
21
|
+
scaleValue.setValue(0.4);
|
|
22
|
+
Animated.parallel([
|
|
23
|
+
Animated.timing(opacityValue, {
|
|
24
|
+
toValue: 1,
|
|
25
|
+
duration: timeouts.enter,
|
|
26
|
+
useNativeDriver: true,
|
|
27
|
+
}),
|
|
28
|
+
Animated.timing(scaleValue, {
|
|
29
|
+
toValue: 1,
|
|
30
|
+
duration: timeouts.enter,
|
|
31
|
+
useNativeDriver: true,
|
|
32
|
+
}),
|
|
33
|
+
], {
|
|
34
|
+
stopTogether: false,
|
|
35
|
+
}).start();
|
|
36
|
+
},
|
|
37
|
+
exit() {
|
|
38
|
+
Animated.parallel([
|
|
39
|
+
Animated.timing(opacityValue, {
|
|
40
|
+
toValue: 0,
|
|
41
|
+
duration: timeouts.exit,
|
|
42
|
+
useNativeDriver: true,
|
|
43
|
+
}),
|
|
44
|
+
Animated.timing(scaleValue, {
|
|
45
|
+
toValue: 0.4,
|
|
46
|
+
duration: timeouts.exit,
|
|
47
|
+
useNativeDriver: true,
|
|
48
|
+
}),
|
|
49
|
+
], {
|
|
50
|
+
stopTogether: false,
|
|
51
|
+
}).start(({ finished }) => {
|
|
52
|
+
if (finished) {
|
|
53
|
+
scaleValue.setValue(1);
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
},
|
|
57
|
+
style: {
|
|
58
|
+
opacity: opacityValue,
|
|
59
|
+
scale: scaleValue,
|
|
60
|
+
},
|
|
61
|
+
};
|
|
62
|
+
};
|
|
63
|
+
export const Popover = (props) => {
|
|
64
|
+
const { className, style, children, contentClass, contentStyle, options = [], reference, refGap = 10, viewportGap = 10, placement = 'bottom', direction = 'vertical', theme = 'light', zIndex, onSelect, visible, defaultVisible, onVisible, duration = 250, mask = true, transparent = true, maskClass, maskStyle, onMaskClick, onEnter, onEntering, onEntered, onExit, onExiting, onExited, ...restProps } = props;
|
|
65
|
+
const [bem] = useBem('popover');
|
|
66
|
+
const referenceRef = useRef();
|
|
67
|
+
const contentRef = useRef();
|
|
68
|
+
const [innerVisible, setInnerVisible] = useControllableValue({
|
|
69
|
+
value: visible,
|
|
70
|
+
defaultValue: defaultVisible,
|
|
71
|
+
trigger: onVisible,
|
|
72
|
+
initialValue: false,
|
|
73
|
+
});
|
|
74
|
+
// visible -> realVisible -> !visible -> !realVisible
|
|
75
|
+
const [realVisible, setRealVisible] = useState(false);
|
|
76
|
+
const handleRequestClose = useEvent(() => {
|
|
77
|
+
setInnerVisible(false);
|
|
78
|
+
});
|
|
79
|
+
const handleMaskClick = useEvent((event) => {
|
|
80
|
+
setInnerVisible(false);
|
|
81
|
+
onMaskClick?.(event);
|
|
82
|
+
});
|
|
83
|
+
const [popperRect, setPopperRect] = useState({
|
|
84
|
+
top: 0,
|
|
85
|
+
left: 0,
|
|
86
|
+
width: 0,
|
|
87
|
+
height: 0,
|
|
88
|
+
});
|
|
89
|
+
const [arrowPosition, setArrowPosition] = useState({ top: 0, left: 0 });
|
|
90
|
+
const getAndSetPosition = async () => {
|
|
91
|
+
const referenceRect = await getRectByElement(referenceRef.current);
|
|
92
|
+
const contentRect = await getRectByElement(contentRef.current);
|
|
93
|
+
if (referenceRect) {
|
|
94
|
+
const [popperPosition, arrowPosition] = getPopoverPosition(referenceRect, contentRect, {
|
|
95
|
+
refGap,
|
|
96
|
+
viewportGap,
|
|
97
|
+
placement,
|
|
98
|
+
});
|
|
99
|
+
setPopperRect({
|
|
100
|
+
...popperPosition,
|
|
101
|
+
width: contentRect.width,
|
|
102
|
+
height: contentRect.height,
|
|
103
|
+
});
|
|
104
|
+
setArrowPosition(arrowPosition);
|
|
105
|
+
setRealVisible(true);
|
|
106
|
+
onEntering?.();
|
|
107
|
+
showLater();
|
|
108
|
+
}
|
|
109
|
+
};
|
|
110
|
+
const [hideLater, cancelHide] = useSetTimeout(() => {
|
|
111
|
+
setRealVisible(false);
|
|
112
|
+
onExited?.();
|
|
113
|
+
}, duration, {
|
|
114
|
+
tailing: true,
|
|
115
|
+
});
|
|
116
|
+
const [showLater, cancelShow] = useSetTimeout(() => {
|
|
117
|
+
onEntered?.();
|
|
118
|
+
}, duration, {
|
|
119
|
+
tailing: true,
|
|
120
|
+
});
|
|
121
|
+
useLayoutEffect(() => {
|
|
122
|
+
if (innerVisible) {
|
|
123
|
+
cancelHide();
|
|
124
|
+
onEnter?.();
|
|
125
|
+
getAndSetPosition();
|
|
126
|
+
}
|
|
127
|
+
else {
|
|
128
|
+
cancelShow();
|
|
129
|
+
onExit?.();
|
|
130
|
+
anim.exit();
|
|
131
|
+
hideLater();
|
|
132
|
+
onExiting?.();
|
|
133
|
+
}
|
|
134
|
+
}, [innerVisible]);
|
|
135
|
+
const handleSelect = (option) => {
|
|
136
|
+
setInnerVisible(false);
|
|
137
|
+
onSelect?.(option);
|
|
138
|
+
};
|
|
139
|
+
// Animated >>>
|
|
140
|
+
const anim = useMemo(() => zoomAnim(getTimeouts(duration)), []);
|
|
141
|
+
useEffect(() => {
|
|
142
|
+
if (realVisible) {
|
|
143
|
+
anim.enter();
|
|
144
|
+
}
|
|
145
|
+
}, [realVisible]);
|
|
146
|
+
// <<< Animated
|
|
147
|
+
const getOriginX = () => {
|
|
148
|
+
return popperRect.width / 2 - arrowPosition.left;
|
|
149
|
+
};
|
|
150
|
+
const getOriginY = () => {
|
|
151
|
+
return popperRect.height / 2 - arrowPosition.top;
|
|
152
|
+
};
|
|
153
|
+
return (_jsxs(_Fragment, { children: [reference &&
|
|
154
|
+
cloneElement(reference, {
|
|
155
|
+
ref: referenceRef,
|
|
156
|
+
onClick(event) {
|
|
157
|
+
setInnerVisible(true);
|
|
158
|
+
reference.props.onClick?.(event);
|
|
159
|
+
},
|
|
160
|
+
}), _jsxs(Popup, { visible: innerVisible || realVisible, timeout: duration, mask: mask, maskStyle: maskStyle, maskClass: maskClass, transparent: transparent, onMaskClick: handleMaskClick, onRequestClose: handleRequestClose, zIndex: zIndex, catchMove: true, ...restProps, className: classNames(bem.e('popup'), className), style: style, contentClass: classNames(bem.b(), bem.m(theme), bem.m('zoom-enter', realVisible), bem.m('zoom-exit', !innerVisible), contentClass), contentStyle: {
|
|
161
|
+
top: popperRect.top,
|
|
162
|
+
left: popperRect.left,
|
|
163
|
+
...contentStyle,
|
|
164
|
+
display: innerVisible || realVisible ? 'flex' : 'none',
|
|
165
|
+
opacity: realVisible ? 1 : 0,
|
|
166
|
+
...(isRN
|
|
167
|
+
? {
|
|
168
|
+
opacity: anim.style.opacity,
|
|
169
|
+
transform: [
|
|
170
|
+
{
|
|
171
|
+
translateX: -getOriginX(),
|
|
172
|
+
},
|
|
173
|
+
{
|
|
174
|
+
translateY: -getOriginY(),
|
|
175
|
+
},
|
|
176
|
+
{
|
|
177
|
+
scale: anim.style.scale,
|
|
178
|
+
},
|
|
179
|
+
{
|
|
180
|
+
translateX: getOriginX(),
|
|
181
|
+
},
|
|
182
|
+
{
|
|
183
|
+
translateY: getOriginY(),
|
|
184
|
+
},
|
|
185
|
+
],
|
|
186
|
+
}
|
|
187
|
+
: {
|
|
188
|
+
transformOrigin: `${mayAddPixel(arrowPosition.left)} ${mayAddPixel(arrowPosition.top)}`,
|
|
189
|
+
animationDuration: duration + 'ms',
|
|
190
|
+
}),
|
|
191
|
+
}, children: [_jsx(View, { className: classNames(bem.e('content'), bem.em('content', direction)), ref: contentRef, children: children ?? (_jsx(Menu, { options: options, direction: direction, theme: theme, onSelect: handleSelect })) }), _jsx(View, { className: classNames(bem.e('arrow'), bem.m(theme)), style: arrowPosition })] })] }));
|
|
192
|
+
};
|
|
193
|
+
export default Popover;
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
@use 'sass:math';
|
|
2
|
+
@import '../style/base.scss';
|
|
3
|
+
// #variables
|
|
4
|
+
$sar-popover-bg-color: $sar-emphasis-bg-color !default;
|
|
5
|
+
$sar-popover-box-shadow: $sar-shadow-lg !default;
|
|
6
|
+
$sar-popover-min-width: 120px !default;
|
|
7
|
+
$sar-popover-border-radius: $sar-rounded !default;
|
|
8
|
+
|
|
9
|
+
$sar-popover-dark-bg-color: $sar-gray-800 !default;
|
|
10
|
+
$sar-popover-dark-color: $sar-white !default;
|
|
11
|
+
|
|
12
|
+
$sar-popover-arrow-size: 10px !default;
|
|
13
|
+
// #endvariables
|
|
14
|
+
|
|
15
|
+
@include bem(popover) {
|
|
16
|
+
@include b() {
|
|
17
|
+
@include universal;
|
|
18
|
+
position: absolute;
|
|
19
|
+
top: auto;
|
|
20
|
+
right: auto;
|
|
21
|
+
bottom: auto;
|
|
22
|
+
left: auto;
|
|
23
|
+
overflow: visible;
|
|
24
|
+
border-radius: $sar-popover-border-radius;
|
|
25
|
+
background-color: $sar-popover-bg-color;
|
|
26
|
+
box-shadow: $sar-popover-box-shadow;
|
|
27
|
+
@include ifweb {
|
|
28
|
+
touch-action: none;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
@include e(content) {
|
|
33
|
+
@include universal;
|
|
34
|
+
z-index: 1;
|
|
35
|
+
min-width: $sar-popover-min-width;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
@include e(arrow) {
|
|
39
|
+
@include universal;
|
|
40
|
+
position: absolute;
|
|
41
|
+
width: $sar-popover-arrow-size;
|
|
42
|
+
height: $sar-popover-arrow-size;
|
|
43
|
+
margin-left: math.div(-$sar-popover-arrow-size, 2);
|
|
44
|
+
margin-top: math.div(-$sar-popover-arrow-size, 2);
|
|
45
|
+
transform: rotate(45deg);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
@include m(light) {
|
|
49
|
+
background-color: $sar-popover-bg-color;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
@include m(dark) {
|
|
53
|
+
color: $sar-popover-dark-color;
|
|
54
|
+
background-color: $sar-popover-dark-bg-color;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// zoom
|
|
58
|
+
@include ifweb {
|
|
59
|
+
@include m(zoom-enter) {
|
|
60
|
+
animation: #{bem-ns(popover_zoom-enter)} $sar-duration-fast both;
|
|
61
|
+
}
|
|
62
|
+
@keyframes #{bem-ns(popover_zoom-enter)} {
|
|
63
|
+
from {
|
|
64
|
+
opacity: 0;
|
|
65
|
+
transform: scale(0.4);
|
|
66
|
+
}
|
|
67
|
+
to {
|
|
68
|
+
opacity: 1;
|
|
69
|
+
transform: scale(1);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
@include m(zoom-exit) {
|
|
73
|
+
animation: #{bem-ns(popover_zoom-exit)} $sar-duration-fast both;
|
|
74
|
+
}
|
|
75
|
+
@keyframes #{bem-ns(popover_zoom-exit)} {
|
|
76
|
+
from {
|
|
77
|
+
opacity: 1;
|
|
78
|
+
transform: scale(1);
|
|
79
|
+
}
|
|
80
|
+
to {
|
|
81
|
+
opacity: 0;
|
|
82
|
+
transform: scale(0.4);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
@include theme(dark) {
|
|
89
|
+
@include bem(popover) {
|
|
90
|
+
@include m(light) {
|
|
91
|
+
background-color: $sar-popover-dark-bg-color;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export type Placement = 'top' | 'top-start' | 'top-end' | 'right' | 'right-start' | 'right-end' | 'bottom' | 'bottom-start' | 'bottom-end' | 'left' | 'left-start' | 'left-end';
|
|
2
|
+
export interface Rect {
|
|
3
|
+
width: number;
|
|
4
|
+
height: number;
|
|
5
|
+
top: number;
|
|
6
|
+
right: number;
|
|
7
|
+
bottom: number;
|
|
8
|
+
left: number;
|
|
9
|
+
}
|
|
10
|
+
export type Direction = 'top' | 'right' | 'bottom' | 'left';
|
|
11
|
+
export type Side = 'start' | 'center' | 'end';
|
|
12
|
+
export type Axis = 'top' | 'left';
|
|
13
|
+
export declare function getPopoverPosition(refRect: Rect, popperRect: Rect, { refGap, placement, viewportGap, }: {
|
|
14
|
+
refGap: number;
|
|
15
|
+
placement: Placement;
|
|
16
|
+
viewportGap: number;
|
|
17
|
+
}): readonly [{
|
|
18
|
+
top: number;
|
|
19
|
+
left: number;
|
|
20
|
+
}, {
|
|
21
|
+
top: number;
|
|
22
|
+
left: number;
|
|
23
|
+
}];
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import Taro from '@tarojs/taro';
|
|
2
|
+
import { minmax } from '../utils';
|
|
3
|
+
const directions = ['top', 'right', 'bottom', 'left'];
|
|
4
|
+
function getReverseDirection(direction) {
|
|
5
|
+
const index = directions.indexOf(direction);
|
|
6
|
+
return directions[index + 2] ?? directions[index - 2];
|
|
7
|
+
}
|
|
8
|
+
function getAxis(direction) {
|
|
9
|
+
return ['top', 'bottom'].includes(direction) ? 'left' : 'top';
|
|
10
|
+
}
|
|
11
|
+
function getCrossAxis(axis) {
|
|
12
|
+
return axis === 'top' ? 'left' : 'top';
|
|
13
|
+
}
|
|
14
|
+
function getSizeNameByAxis(axis) {
|
|
15
|
+
return axis === 'top' ? 'height' : 'width';
|
|
16
|
+
}
|
|
17
|
+
function getArrowCrossOffset(direction, rect) {
|
|
18
|
+
const strategies = {
|
|
19
|
+
top() {
|
|
20
|
+
return rect.height;
|
|
21
|
+
},
|
|
22
|
+
right() {
|
|
23
|
+
return 0;
|
|
24
|
+
},
|
|
25
|
+
bottom() {
|
|
26
|
+
return 0;
|
|
27
|
+
},
|
|
28
|
+
left() {
|
|
29
|
+
return rect.width;
|
|
30
|
+
},
|
|
31
|
+
};
|
|
32
|
+
return strategies[direction]();
|
|
33
|
+
}
|
|
34
|
+
export function getPopoverPosition(refRect, popperRect, { refGap, placement, viewportGap, }) {
|
|
35
|
+
const breadth = popperRect.width + refGap;
|
|
36
|
+
const thickness = popperRect.height + refGap;
|
|
37
|
+
const systemInfo = Taro.getSystemInfoSync();
|
|
38
|
+
const windowWidth = systemInfo.windowWidth;
|
|
39
|
+
const windowHeight = systemInfo.windowHeight;
|
|
40
|
+
const gapBoundaries = {
|
|
41
|
+
top: refRect.top - thickness - viewportGap,
|
|
42
|
+
right: windowWidth - refRect.right - breadth - viewportGap,
|
|
43
|
+
bottom: windowHeight - refRect.bottom - thickness - viewportGap,
|
|
44
|
+
left: refRect.left - breadth - viewportGap,
|
|
45
|
+
};
|
|
46
|
+
// 确定方位
|
|
47
|
+
let [direction, side] = placement.split('-');
|
|
48
|
+
// 适当反转
|
|
49
|
+
if (gapBoundaries[direction] < 0) {
|
|
50
|
+
direction = getReverseDirection(direction);
|
|
51
|
+
if (gapBoundaries[direction] < 0) {
|
|
52
|
+
direction = getReverseDirection(direction);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
// 确定端点
|
|
56
|
+
side = side || 'center';
|
|
57
|
+
// 确定轴
|
|
58
|
+
const axis = getAxis(direction);
|
|
59
|
+
const crossAxis = getCrossAxis(axis);
|
|
60
|
+
// 确定尺寸
|
|
61
|
+
const sizeName = getSizeNameByAxis(axis);
|
|
62
|
+
const windowSize = axis === 'top' ? windowHeight : windowWidth;
|
|
63
|
+
const popperStyle = {
|
|
64
|
+
top: 0,
|
|
65
|
+
left: 0,
|
|
66
|
+
};
|
|
67
|
+
function getSideOffset() {
|
|
68
|
+
const strategies = {
|
|
69
|
+
start() {
|
|
70
|
+
return refRect[axis];
|
|
71
|
+
},
|
|
72
|
+
center() {
|
|
73
|
+
return refRect[axis] - (popperRect[sizeName] - refRect[sizeName]) / 2;
|
|
74
|
+
},
|
|
75
|
+
end() {
|
|
76
|
+
return refRect[axis] - (popperRect[sizeName] - refRect[sizeName]);
|
|
77
|
+
},
|
|
78
|
+
};
|
|
79
|
+
const offset = strategies[side]();
|
|
80
|
+
return minmax(offset, viewportGap, windowSize - popperRect[sizeName] - viewportGap);
|
|
81
|
+
}
|
|
82
|
+
function getDirectionOffset() {
|
|
83
|
+
const strategies = {
|
|
84
|
+
top() {
|
|
85
|
+
return refRect.top - refGap - popperRect.height;
|
|
86
|
+
},
|
|
87
|
+
right() {
|
|
88
|
+
return refRect.right + refGap;
|
|
89
|
+
},
|
|
90
|
+
bottom() {
|
|
91
|
+
return refRect.bottom + refGap;
|
|
92
|
+
},
|
|
93
|
+
left() {
|
|
94
|
+
return refRect.left - refGap - popperRect.width;
|
|
95
|
+
},
|
|
96
|
+
};
|
|
97
|
+
return strategies[direction]();
|
|
98
|
+
}
|
|
99
|
+
popperStyle[crossAxis] = getDirectionOffset();
|
|
100
|
+
popperStyle[axis] = getSideOffset();
|
|
101
|
+
const finalPopperRect = {
|
|
102
|
+
top: popperStyle.top,
|
|
103
|
+
left: popperStyle.left,
|
|
104
|
+
bottom: popperStyle.top + popperRect.height,
|
|
105
|
+
right: popperStyle.left + popperRect.width,
|
|
106
|
+
};
|
|
107
|
+
const arrowStyle = {
|
|
108
|
+
top: 0,
|
|
109
|
+
left: 0,
|
|
110
|
+
};
|
|
111
|
+
function getArrowOffset() {
|
|
112
|
+
const reverseDirection = getReverseDirection(axis);
|
|
113
|
+
let extra = refRect[axis] - finalPopperRect[axis];
|
|
114
|
+
if (extra < 0) {
|
|
115
|
+
extra = 0;
|
|
116
|
+
}
|
|
117
|
+
const intersection = Math.min(refRect[reverseDirection], finalPopperRect[reverseDirection]) -
|
|
118
|
+
Math.max(refRect[axis], finalPopperRect[axis]);
|
|
119
|
+
return extra + intersection / 2;
|
|
120
|
+
}
|
|
121
|
+
arrowStyle[axis] = getArrowOffset();
|
|
122
|
+
arrowStyle[crossAxis] = getArrowCrossOffset(direction, popperRect);
|
|
123
|
+
return [popperStyle, arrowStyle];
|
|
124
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { CSSProperties } from 'react';
|
|
2
|
+
import { ITouchEvent, View } from '@tarojs/components';
|
|
3
|
+
import { BaseProps } from '../base';
|
|
4
|
+
import { TransitionTimeout } from '../transition';
|
|
5
|
+
export interface PopupProps extends BaseProps {
|
|
6
|
+
visible?: boolean;
|
|
7
|
+
timeout?: TransitionTimeout;
|
|
8
|
+
effect?: 'slide-top' | 'slide-right' | 'slide-bottom' | 'slide-left' | 'zoom' | 'fade';
|
|
9
|
+
contentClass?: string;
|
|
10
|
+
contentStyle?: CSSProperties;
|
|
11
|
+
zIndex?: number;
|
|
12
|
+
mask?: boolean;
|
|
13
|
+
transparent?: boolean;
|
|
14
|
+
maskClass?: string;
|
|
15
|
+
maskStyle?: CSSProperties;
|
|
16
|
+
onMaskClick?: (event: ITouchEvent) => void;
|
|
17
|
+
onEnter?: () => void;
|
|
18
|
+
onEntering?: () => void;
|
|
19
|
+
onEntered?: () => void;
|
|
20
|
+
onExit?: () => void;
|
|
21
|
+
onExiting?: () => void;
|
|
22
|
+
onExited?: () => void;
|
|
23
|
+
catchMove?: boolean;
|
|
24
|
+
onlyPopup?: boolean;
|
|
25
|
+
onRequestClose?: () => void;
|
|
26
|
+
}
|
|
27
|
+
export type PopupRef = typeof View;
|
|
28
|
+
export declare const Popup: import("react").ForwardRefExoticComponent<PopupProps & import("react").RefAttributes<import("react").ComponentType<import("@tarojs/components/types/View").ViewProps>>>;
|
|
29
|
+
export default Popup;
|