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,103 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef, useImperativeHandle, useState, } from 'react';
|
|
3
|
+
import classNames from 'classnames';
|
|
4
|
+
import { View } from '@tarojs/components';
|
|
5
|
+
import { Popup } from '../popup';
|
|
6
|
+
import { Button } from '../button';
|
|
7
|
+
import { useBem, useControllableValue, useEvent } from '../use';
|
|
8
|
+
import useTranslate from '../locale/useTranslate';
|
|
9
|
+
import { isFunction, isNullish, noop } from '../utils';
|
|
10
|
+
import Halfline from '../halfline';
|
|
11
|
+
const CLOSE = 'close';
|
|
12
|
+
const CANCEL = 'cancel';
|
|
13
|
+
const CONFIRM = 'confirm';
|
|
14
|
+
const buttonProps = {
|
|
15
|
+
text: {
|
|
16
|
+
cancel: {
|
|
17
|
+
type: 'text',
|
|
18
|
+
theme: 'secondary',
|
|
19
|
+
size: 'large',
|
|
20
|
+
},
|
|
21
|
+
confirm: {
|
|
22
|
+
type: 'text',
|
|
23
|
+
theme: 'primary',
|
|
24
|
+
size: 'large',
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
round: {
|
|
28
|
+
cancel: {
|
|
29
|
+
type: 'pale',
|
|
30
|
+
theme: 'primary',
|
|
31
|
+
round: true,
|
|
32
|
+
},
|
|
33
|
+
confirm: {
|
|
34
|
+
type: 'default',
|
|
35
|
+
theme: 'primary',
|
|
36
|
+
round: true,
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
};
|
|
40
|
+
export const Dialog = forwardRef((props, ref) => {
|
|
41
|
+
const { t } = useTranslate('dialog');
|
|
42
|
+
const { className, style, children, contentClass, contentStyle, title, message, header, headed, footer, buttonType = 'text', showCancel = false, cancelText = t('cancel'), cancelProps, showConfirm = true, confirmText = t('confirm'), confirmProps, maskClosable = false, onClose, onCancel, onConfirm, visible, defaultVisible, onVisible, onMaskClick, timeout, ...restProps } = props;
|
|
43
|
+
const [bem] = useBem('dialog');
|
|
44
|
+
const [loading, setLoading] = useState({
|
|
45
|
+
cancel: false,
|
|
46
|
+
confirm: false,
|
|
47
|
+
});
|
|
48
|
+
const [innerVisible, setInnerVisible] = useControllableValue({
|
|
49
|
+
value: visible,
|
|
50
|
+
defaultValue: defaultVisible,
|
|
51
|
+
trigger: onVisible,
|
|
52
|
+
initialValue: false,
|
|
53
|
+
});
|
|
54
|
+
const perhapsClose = (type, callback) => {
|
|
55
|
+
function toggleLoading(play) {
|
|
56
|
+
setLoading((loading) => ({
|
|
57
|
+
...loading,
|
|
58
|
+
[type]: play,
|
|
59
|
+
}));
|
|
60
|
+
}
|
|
61
|
+
if (isFunction(callback)) {
|
|
62
|
+
const result = callback();
|
|
63
|
+
if (result instanceof Promise) {
|
|
64
|
+
toggleLoading(true);
|
|
65
|
+
return result
|
|
66
|
+
.then(() => {
|
|
67
|
+
setInnerVisible?.(false);
|
|
68
|
+
})
|
|
69
|
+
.catch(noop)
|
|
70
|
+
.finally(() => {
|
|
71
|
+
toggleLoading(false);
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
setInnerVisible?.(false);
|
|
76
|
+
};
|
|
77
|
+
const handleRequestClose = useEvent(() => {
|
|
78
|
+
setInnerVisible(false);
|
|
79
|
+
});
|
|
80
|
+
const handleMaskClick = useEvent((event) => {
|
|
81
|
+
onMaskClick?.(event);
|
|
82
|
+
if (maskClosable) {
|
|
83
|
+
perhapsClose(CLOSE, onClose);
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
const handleClose = () => {
|
|
87
|
+
perhapsClose(CLOSE, onClose);
|
|
88
|
+
};
|
|
89
|
+
const handleCancel = () => {
|
|
90
|
+
perhapsClose(CANCEL, onCancel);
|
|
91
|
+
};
|
|
92
|
+
const handleConfirm = () => {
|
|
93
|
+
perhapsClose(CONFIRM, onConfirm);
|
|
94
|
+
};
|
|
95
|
+
useImperativeHandle(ref, () => ({}), []);
|
|
96
|
+
const renderTitle = () => {
|
|
97
|
+
return (_jsx(View, { className: classNames(bem.e('title'), bem.em('title', 'headed', headed), bem.em('title', 'headless', !headed), bem.em('title', 'headless-message', !headed && !isNullish(message))), children: title }));
|
|
98
|
+
};
|
|
99
|
+
return (_jsxs(Popup, { ...restProps, effect: "zoom", visible: innerVisible, mask: true, timeout: timeout, onMaskClick: handleMaskClick, onRequestClose: handleRequestClose, className: classNames(bem.e('popup'), className), style: style, contentClass: classNames(bem.b(), bem.m('headed', headed), contentClass), contentStyle: contentStyle, children: [headed && (_jsxs(View, { className: classNames(bem.e('header'), bem.em('header', 'titled', !isNullish(title))), children: [header ?? renderTitle(), _jsx(Button, { className: bem.e('close'), type: "pale-text", theme: "secondary", size: "large", onClick: handleClose, iconProps: {
|
|
100
|
+
name: 'close',
|
|
101
|
+
} }), !isNullish(title) && _jsx(Halfline, { direction: "bottom" })] })), _jsx(View, { className: classNames(bem.e('body'), bem.em('body', 'untitled', isNullish(title))), children: children ?? (_jsxs(_Fragment, { children: [!headed && !isNullish(title) && renderTitle(), !isNullish(message) && (_jsx(View, { className: classNames(bem.e('message'), bem.em('message', 'headless-titled', !headed && !isNullish(title)), bem.em('message', 'headed-untitled', headed && isNullish(title))), children: message }))] })) }), _jsxs(View, { className: classNames(bem.e('footer'), bem.em('footer', 'text-button', buttonType === 'text'), bem.em('footer', 'round-button', buttonType === 'round')), children: [footer ?? (_jsxs(_Fragment, { children: [showCancel && (_jsx(Button, { ...buttonProps[buttonType].cancel, className: classNames(bem.e('button'), bem.e('cancel'), bem.em('button', 'text', buttonType === 'text'), bem.em('button', 'text-first', buttonType === 'text'), bem.em('button', 'text-last', buttonType === 'text' && !showConfirm)), ...cancelProps, loading: loading.cancel, onClick: handleCancel, children: cancelText })), showCancel && buttonType === 'text' && (_jsx(View, { className: bem.e('divider'), children: _jsx(Halfline, { direction: "left" }) })), showConfirm && (_jsx(Button, { ...buttonProps[buttonType].confirm, className: classNames(bem.e('button'), bem.e('confirm'), bem.em('button', 'text', buttonType === 'text'), bem.em('button', 'text-last', buttonType === 'text'), bem.em('button', 'text-first', buttonType === 'text' && !showCancel), bem.em('button', 'round-later', showCancel && buttonType === 'round')), ...confirmProps, loading: loading.confirm, onClick: handleConfirm, children: confirmText }))] })), buttonType === 'text' && _jsx(Halfline, { direction: "top" })] })] }));
|
|
102
|
+
});
|
|
103
|
+
export default Dialog;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { DialogProps } from './Dialog';
|
|
2
|
+
import { ReactNode } from 'react';
|
|
3
|
+
export interface DialogOptions extends DialogProps {
|
|
4
|
+
id?: string;
|
|
5
|
+
}
|
|
6
|
+
export interface DialogShow {
|
|
7
|
+
(options: DialogOptions): void;
|
|
8
|
+
(title: ReactNode, options?: DialogOptions): void;
|
|
9
|
+
}
|
|
10
|
+
export interface DialogInternalShow {
|
|
11
|
+
(optionsOrTitle: ReactNode | DialogOptions, options: DialogOptions, internalOptions: DialogOptions): void;
|
|
12
|
+
}
|
|
13
|
+
export declare const show: DialogShow;
|
|
14
|
+
export declare const alert: DialogShow;
|
|
15
|
+
export declare const confirm: DialogShow;
|
|
16
|
+
export declare const hide: (id?: string) => void;
|
|
17
|
+
export declare const hideAll: () => void;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { mapIdAgent } from './Agent';
|
|
2
|
+
import { isNotReactNode } from '../utils';
|
|
3
|
+
const internalShow = (optionsOrTitle, options, internalOptions) => {
|
|
4
|
+
if (isNotReactNode(optionsOrTitle)) {
|
|
5
|
+
options = optionsOrTitle;
|
|
6
|
+
}
|
|
7
|
+
else {
|
|
8
|
+
options.title = optionsOrTitle;
|
|
9
|
+
}
|
|
10
|
+
const { id = 'dialog' } = options;
|
|
11
|
+
const ref = mapIdAgent[id];
|
|
12
|
+
if (ref) {
|
|
13
|
+
ref.current?.show({
|
|
14
|
+
...options,
|
|
15
|
+
...internalOptions,
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
export const show = (optionsOrTitle, options) => {
|
|
20
|
+
internalShow(optionsOrTitle, options, { showCancel: false });
|
|
21
|
+
};
|
|
22
|
+
export const alert = (optionsOrTitle, options) => {
|
|
23
|
+
internalShow(optionsOrTitle, options, { showCancel: false });
|
|
24
|
+
};
|
|
25
|
+
export const confirm = (optionsOrTitle, options) => {
|
|
26
|
+
internalShow(optionsOrTitle, options, {
|
|
27
|
+
showCancel: true,
|
|
28
|
+
});
|
|
29
|
+
};
|
|
30
|
+
export const hide = (id = 'dialog') => {
|
|
31
|
+
mapIdAgent[id]?.current?.hide();
|
|
32
|
+
};
|
|
33
|
+
export const hideAll = () => {
|
|
34
|
+
Object.keys(mapIdAgent).forEach((key) => mapIdAgent[key]?.current?.hide());
|
|
35
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { DialogFC as DialogOriginFC, DialogProps, DialogRef, DialogCloseType } from './Dialog';
|
|
2
|
+
import { DialogAgent } from './Agent';
|
|
3
|
+
import { show, alert, confirm, hide, hideAll } from './imperative';
|
|
4
|
+
interface DialogFC extends DialogOriginFC {
|
|
5
|
+
show: typeof show;
|
|
6
|
+
alert: typeof alert;
|
|
7
|
+
confirm: typeof confirm;
|
|
8
|
+
hide: typeof hide;
|
|
9
|
+
hideAll: typeof hideAll;
|
|
10
|
+
Agent: typeof DialogAgent;
|
|
11
|
+
}
|
|
12
|
+
declare const Dialog: DialogFC;
|
|
13
|
+
export { Dialog, DialogProps, DialogRef, DialogAgent, DialogCloseType };
|
|
14
|
+
export default Dialog;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Dialog as DialogOrigin } from './Dialog';
|
|
2
|
+
import { DialogAgent } from './Agent';
|
|
3
|
+
import { show, alert, confirm, hide, hideAll } from './imperative';
|
|
4
|
+
const Dialog = DialogOrigin;
|
|
5
|
+
Dialog.show = show;
|
|
6
|
+
Dialog.alert = alert;
|
|
7
|
+
Dialog.confirm = confirm;
|
|
8
|
+
Dialog.hide = hide;
|
|
9
|
+
Dialog.hideAll = hideAll;
|
|
10
|
+
Dialog.Agent = DialogAgent;
|
|
11
|
+
export { Dialog, DialogAgent };
|
|
12
|
+
export default Dialog;
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
@import '../style/base.scss';
|
|
2
|
+
// #variables
|
|
3
|
+
$sar-dialog-z-index: 1110 !default;
|
|
4
|
+
|
|
5
|
+
$sar-dialog-width: 320px !default;
|
|
6
|
+
$sar-dialog-max-width: 90% !default;
|
|
7
|
+
$sar-dialog-bg-color: $sar-emphasis-bg-color !default;
|
|
8
|
+
$sar-dialog-border-radius: $sar-rounded-xl !default;
|
|
9
|
+
|
|
10
|
+
$sar-dialog-header-padding-y: 16px !default;
|
|
11
|
+
$sar-dialog-header-padding-x: 16px !default;
|
|
12
|
+
|
|
13
|
+
$sar-dialog-title-padding-x: 16px !default;
|
|
14
|
+
$sar-dialog-title-padding-y: 24px !default;
|
|
15
|
+
$sar-dialog-title-headless-message-padding-bottom: 4px !default;
|
|
16
|
+
$sar-dialog-title-font-size: $sar-text-lg !default;
|
|
17
|
+
$sar-dialog-headed-title-font-size: $sar-text-base !default;
|
|
18
|
+
|
|
19
|
+
$sar-dialog-close-padding: 16px !default;
|
|
20
|
+
$sar-dialog-close-font-size: $sar-text-lg !default;
|
|
21
|
+
|
|
22
|
+
$sar-dialog-message-padding-y: 24px !default;
|
|
23
|
+
$sar-dialog-message-padding-x: 16px !default;
|
|
24
|
+
$sar-dialog-message-less-padding-top: 4px !default;
|
|
25
|
+
$sar-dialog-message-font-size: $sar-text-base !default;
|
|
26
|
+
$sar-dialog-message-color: $sar-secondary-color !default;
|
|
27
|
+
|
|
28
|
+
$sar-dialog-round-button-footer-padding-x: 16px !default;
|
|
29
|
+
$sar-dialog-round-button-footer-padding-y: 16px !default;
|
|
30
|
+
$sar-dialog-round-button-button-gap: 16px !default;
|
|
31
|
+
|
|
32
|
+
// 暗黑模式
|
|
33
|
+
$sar-dialog-dark-bg-color: $sar-dark-emphasis-bg-color !default;
|
|
34
|
+
$sar-dialog-message-dark-color: $sar-dark-secondary-color !default;
|
|
35
|
+
// #endvariables
|
|
36
|
+
|
|
37
|
+
@include bem(dialog) {
|
|
38
|
+
@include b() {
|
|
39
|
+
@include universal;
|
|
40
|
+
width: $sar-dialog-width;
|
|
41
|
+
max-width: $sar-dialog-max-width;
|
|
42
|
+
background-color: $sar-dialog-bg-color;
|
|
43
|
+
border-radius: $sar-dialog-border-radius;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
@include e(popup) {
|
|
47
|
+
z-index: $sar-dialog-z-index;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
@include e(header) {
|
|
51
|
+
@include universal;
|
|
52
|
+
flex-direction: row;
|
|
53
|
+
justify-content: space-between;
|
|
54
|
+
align-items: center;
|
|
55
|
+
padding-top: $sar-dialog-header-padding-y;
|
|
56
|
+
padding-left: $sar-dialog-header-padding-x;
|
|
57
|
+
padding-right: $sar-dialog-header-padding-x;
|
|
58
|
+
|
|
59
|
+
@include m(titled) {
|
|
60
|
+
padding-bottom: $sar-dialog-header-padding-y;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
@include e(title) {
|
|
65
|
+
@include universal;
|
|
66
|
+
font-size: $sar-dialog-title-font-size;
|
|
67
|
+
font-weight: $sar-font-bold;
|
|
68
|
+
text-align: center;
|
|
69
|
+
|
|
70
|
+
@include m(headed) {
|
|
71
|
+
font-size: $sar-dialog-headed-title-font-size;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
@include m(headless) {
|
|
75
|
+
padding: $sar-dialog-title-padding-y $sar-dialog-title-padding-x;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
@include m(headless-message) {
|
|
79
|
+
padding-bottom: $sar-dialog-title-headless-message-padding-bottom;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
@include e(close) {
|
|
84
|
+
@include universal;
|
|
85
|
+
margin-top: $sar-dialog-header-padding-y * -1;
|
|
86
|
+
margin-right: $sar-dialog-header-padding-x * -1;
|
|
87
|
+
margin-bottom: $sar-dialog-header-padding-y * -1;
|
|
88
|
+
padding: $sar-dialog-close-padding;
|
|
89
|
+
border-width: 0;
|
|
90
|
+
font-size: $sar-dialog-close-font-size;
|
|
91
|
+
line-height: $sar-dialog-close-font-size * $sar-leading-none;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
@include e(message) {
|
|
95
|
+
@include universal;
|
|
96
|
+
padding: $sar-dialog-message-padding-y $sar-dialog-message-padding-x;
|
|
97
|
+
font-size: $sar-dialog-message-font-size;
|
|
98
|
+
text-align: center;
|
|
99
|
+
color: $sar-dialog-message-color;
|
|
100
|
+
|
|
101
|
+
@include m(headless-titled, headed-untitled) {
|
|
102
|
+
padding-top: $sar-dialog-message-less-padding-top;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
@include e(footer) {
|
|
107
|
+
@include universal;
|
|
108
|
+
flex-direction: row;
|
|
109
|
+
|
|
110
|
+
@include m(round-button) {
|
|
111
|
+
padding-left: $sar-dialog-round-button-footer-padding-x;
|
|
112
|
+
padding-right: $sar-dialog-round-button-footer-padding-x;
|
|
113
|
+
padding-bottom: $sar-dialog-round-button-footer-padding-y;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
@include e(button) {
|
|
118
|
+
flex-grow: 1;
|
|
119
|
+
flex-shrink: 1;
|
|
120
|
+
flex-basis: 0;
|
|
121
|
+
margin: 0;
|
|
122
|
+
|
|
123
|
+
@include m(text) {
|
|
124
|
+
border-radius: 0;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
@include m(text-first) {
|
|
128
|
+
border-bottom-left-radius: $sar-dialog-border-radius;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
@include m(text-last) {
|
|
132
|
+
border-bottom-right-radius: $sar-dialog-border-radius;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
@include m(round-later) {
|
|
136
|
+
margin-left: $sar-dialog-round-button-button-gap;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
@include e(divider) {
|
|
141
|
+
@include universal;
|
|
142
|
+
flex: none;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
@include theme(dark) {
|
|
147
|
+
@include bem(dialog) {
|
|
148
|
+
@include b() {
|
|
149
|
+
background-color: $sar-dialog-dark-bg-color;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
@include e(message) {
|
|
153
|
+
color: $sar-dialog-message-dark-color;
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { ReactNode, ForwardRefExoticComponent, PropsWithoutRef, RefAttributes } from 'react';
|
|
2
|
+
import { ITouchEvent } from '@tarojs/components';
|
|
3
|
+
import { PopupProps } from '../popup';
|
|
4
|
+
import { DropdownOptionProps } from './Option';
|
|
5
|
+
import { BaseProps } from '../base';
|
|
6
|
+
export interface DropdownItemProps extends BaseProps {
|
|
7
|
+
title?: ReactNode;
|
|
8
|
+
label?: ReactNode;
|
|
9
|
+
options?: DropdownOptionProps[];
|
|
10
|
+
direction?: 'down' | 'up';
|
|
11
|
+
disabled?: boolean;
|
|
12
|
+
value?: number | string;
|
|
13
|
+
defaultValue?: number | string;
|
|
14
|
+
onChange?: (value: number | string) => void;
|
|
15
|
+
visible?: boolean;
|
|
16
|
+
defaultVisible?: boolean;
|
|
17
|
+
onVisible?: (visible: boolean) => void;
|
|
18
|
+
onVisibleChange?: (visible: boolean) => void;
|
|
19
|
+
awayClosable?: boolean;
|
|
20
|
+
maskClosable?: boolean;
|
|
21
|
+
arrow?: (visible: boolean, direction: DropdownItemProps['direction']) => ReactNode;
|
|
22
|
+
onClick?: (event: ITouchEvent) => void;
|
|
23
|
+
popupProps?: PopupProps;
|
|
24
|
+
separator?: string;
|
|
25
|
+
placeholder?: ReactNode;
|
|
26
|
+
_itemShow?: boolean;
|
|
27
|
+
}
|
|
28
|
+
export interface DropdownItemRef {
|
|
29
|
+
toggle: (visible?: boolean) => void;
|
|
30
|
+
}
|
|
31
|
+
export type DropdownItemFC = ForwardRefExoticComponent<PropsWithoutRef<DropdownItemProps> & RefAttributes<DropdownItemRef>>;
|
|
32
|
+
export declare const DropdownItem: DropdownItemFC;
|
|
33
|
+
export default DropdownItem;
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
import { createElement as _createElement } from "react";
|
|
2
|
+
import { jsxs as _jsxs, jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
|
+
import { useEffect, useState, forwardRef, useImperativeHandle, useRef, } from 'react';
|
|
4
|
+
import classNames from 'classnames';
|
|
5
|
+
import Taro from '@tarojs/taro';
|
|
6
|
+
import { View } from '@tarojs/components';
|
|
7
|
+
import { useBem, useControllableValue, useResize } from '../use';
|
|
8
|
+
import { Popup } from '../popup';
|
|
9
|
+
import { DropdownOption } from './Option';
|
|
10
|
+
import { Icon } from '../icon';
|
|
11
|
+
import { useEvent } from '../use';
|
|
12
|
+
import { getRectByElement, isBoolean, isNullish } from '../utils';
|
|
13
|
+
import List from '../list';
|
|
14
|
+
import Pressable from '../pressable';
|
|
15
|
+
import Ellipsis from '../ellipsis';
|
|
16
|
+
import Modal from '../modal';
|
|
17
|
+
import Halfline from '../halfline';
|
|
18
|
+
const mapDirectionPlacement = {
|
|
19
|
+
down: 'slide-top',
|
|
20
|
+
up: 'slide-bottom',
|
|
21
|
+
};
|
|
22
|
+
export const DropdownItem = forwardRef((props, ref) => {
|
|
23
|
+
const { className, style, children, title, label, options = [], direction = 'down', disabled, value, defaultValue, onChange, visible, defaultVisible, onVisible, onVisibleChange, awayClosable = true, maskClosable = true, arrow, onClick, popupProps, separator, placeholder, _itemShow, ...restProps } = props;
|
|
24
|
+
const [bem] = useBem('dropdown');
|
|
25
|
+
const itemRef = useRef(null);
|
|
26
|
+
const [innerValue, setInnerValue] = useControllableValue({
|
|
27
|
+
value,
|
|
28
|
+
defaultValue,
|
|
29
|
+
trigger: onChange,
|
|
30
|
+
});
|
|
31
|
+
const [innerVisible, setInnerVisible] = useControllableValue({
|
|
32
|
+
value: visible,
|
|
33
|
+
defaultValue: defaultVisible,
|
|
34
|
+
trigger: onVisible,
|
|
35
|
+
initialValue: false,
|
|
36
|
+
});
|
|
37
|
+
const [popoverVisible, setPopoverVisible] = useState(innerVisible);
|
|
38
|
+
const [realVisible, setRealVisible] = useState(innerVisible);
|
|
39
|
+
const handleOptionClick = useEvent((option) => {
|
|
40
|
+
if (!isNullish(option.value) && option.value !== innerValue) {
|
|
41
|
+
setInnerValue(option.value);
|
|
42
|
+
}
|
|
43
|
+
setInnerVisible(false);
|
|
44
|
+
});
|
|
45
|
+
const handleItemClick = useEvent((event) => {
|
|
46
|
+
if (!disabled) {
|
|
47
|
+
onClick?.(event);
|
|
48
|
+
setInnerVisible(!innerVisible);
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
const handleRequestClose = useEvent(() => {
|
|
52
|
+
setInnerVisible(false);
|
|
53
|
+
});
|
|
54
|
+
const handleMaskClick = useEvent(() => {
|
|
55
|
+
if (maskClosable) {
|
|
56
|
+
setInnerVisible(false);
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
const handleAwayClick = useEvent(() => {
|
|
60
|
+
if (awayClosable) {
|
|
61
|
+
setInnerVisible(false);
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
const [popupInset, setPopupInset] = useState({
|
|
65
|
+
top: 0,
|
|
66
|
+
right: 0,
|
|
67
|
+
bottom: 0,
|
|
68
|
+
left: 0,
|
|
69
|
+
});
|
|
70
|
+
const [awayInset, setAwayInset] = useState({
|
|
71
|
+
top: 0,
|
|
72
|
+
right: 0,
|
|
73
|
+
bottom: 0,
|
|
74
|
+
left: 0,
|
|
75
|
+
});
|
|
76
|
+
const setPosition = useEvent(() => {
|
|
77
|
+
if (innerVisible) {
|
|
78
|
+
getRectByElement(itemRef.current).then((res) => {
|
|
79
|
+
const info = Taro.getSystemInfoSync();
|
|
80
|
+
const popupInset = {
|
|
81
|
+
left: 0,
|
|
82
|
+
right: 0,
|
|
83
|
+
top: 0,
|
|
84
|
+
bottom: 0,
|
|
85
|
+
};
|
|
86
|
+
const awayInset = {
|
|
87
|
+
left: 0,
|
|
88
|
+
right: 0,
|
|
89
|
+
top: 0,
|
|
90
|
+
bottom: 0,
|
|
91
|
+
};
|
|
92
|
+
if (direction === 'down') {
|
|
93
|
+
popupInset.top = res.bottom;
|
|
94
|
+
popupInset.bottom = 0;
|
|
95
|
+
awayInset.top = 0;
|
|
96
|
+
awayInset.bottom = info.windowHeight - res.bottom;
|
|
97
|
+
}
|
|
98
|
+
else {
|
|
99
|
+
popupInset.top = 0;
|
|
100
|
+
popupInset.bottom = info.windowHeight - res.top;
|
|
101
|
+
awayInset.top = res.top;
|
|
102
|
+
awayInset.bottom = 0;
|
|
103
|
+
}
|
|
104
|
+
setPopupInset(popupInset);
|
|
105
|
+
setAwayInset(awayInset);
|
|
106
|
+
setRealVisible(true);
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
});
|
|
110
|
+
useEffect(() => {
|
|
111
|
+
setPosition();
|
|
112
|
+
if (!innerVisible) {
|
|
113
|
+
setRealVisible(false);
|
|
114
|
+
}
|
|
115
|
+
}, [innerVisible, direction]);
|
|
116
|
+
useResize(() => {
|
|
117
|
+
setPosition();
|
|
118
|
+
}, 150);
|
|
119
|
+
const handleEnter = () => {
|
|
120
|
+
setPopoverVisible(true);
|
|
121
|
+
onVisibleChange?.(true);
|
|
122
|
+
};
|
|
123
|
+
const handleExited = () => {
|
|
124
|
+
setPopoverVisible(false);
|
|
125
|
+
onVisibleChange?.(false);
|
|
126
|
+
};
|
|
127
|
+
const toggle = useEvent((visible) => {
|
|
128
|
+
if (isBoolean(visible)) {
|
|
129
|
+
setInnerVisible(visible);
|
|
130
|
+
}
|
|
131
|
+
else {
|
|
132
|
+
setInnerVisible(!setInnerVisible);
|
|
133
|
+
}
|
|
134
|
+
});
|
|
135
|
+
useImperativeHandle(ref, () => ({
|
|
136
|
+
toggle,
|
|
137
|
+
}), []);
|
|
138
|
+
const renderLabel = () => {
|
|
139
|
+
return (!isNullish(label) && (_jsxs(Ellipsis, { className: classNames(bem.e('label'), bem.em('label', 'disabled', disabled)), children: [label, !isNullish(title) || !isNullish(innerValue) ? separator : null] })));
|
|
140
|
+
};
|
|
141
|
+
const renderTitle = () => {
|
|
142
|
+
return (!isNullish(title) && (_jsx(Ellipsis, { className: classNames(bem.e('title'), bem.em('title', 'disabled', disabled), bem.em('title', 'has-label', !!label)), children: title })));
|
|
143
|
+
};
|
|
144
|
+
const renderPlaceholder = () => {
|
|
145
|
+
return (!isNullish(placeholder) && (_jsx(View, { className: classNames(bem.e('placeholder'), bem.em('placeholder', 'has-label', !!label)), children: placeholder })));
|
|
146
|
+
};
|
|
147
|
+
const renderValue = () => {
|
|
148
|
+
return !isNullish(innerValue) ? (_jsx(Ellipsis, { className: classNames(bem.e('value'), bem.em('value', 'disabled', disabled), bem.em('value', 'has-label', !!label)), children: options.find((option) => option.value === innerValue)?.label })) : (renderPlaceholder());
|
|
149
|
+
};
|
|
150
|
+
const renderArrow = () => {
|
|
151
|
+
return (_jsx(View, { className: classNames(bem.e('arrow'), bem.em('arrow', direction)), children: arrow ? (arrow(realVisible, direction)) : (_jsx(Icon, { name: realVisible ? 'caret-up' : 'caret-down', className: classNames(bem.e('arrow-icon'), bem.em('arrow-icon', 'show', realVisible)) })) }));
|
|
152
|
+
};
|
|
153
|
+
const renderAway = () => {
|
|
154
|
+
return (_jsx(View, { style: awayInset, className: classNames(bem.e('away'), bem.em('away', 'show', realVisible)), onClick: handleAwayClick, catchMove: true }));
|
|
155
|
+
};
|
|
156
|
+
const renderPopover = () => {
|
|
157
|
+
return (_jsx(View, { className: classNames(bem.e('popover')), style: popupInset, children: _jsxs(Popup, { ...popupProps, effect: mapDirectionPlacement[direction], visible: realVisible, className: bem.e('popup'), contentClass: bem.e('content'), onEnter: handleEnter, onExited: handleExited, onMaskClick: handleMaskClick, catchMove: true, onlyPopup: true, onRequestClose: handleRequestClose, children: [children ?? (_jsx(List, { className: bem.e('options'), inlaid: true, children: options.map((option, index) => {
|
|
158
|
+
const { value, ...restProps } = option;
|
|
159
|
+
return (_createElement(DropdownOption, { ...restProps, key: index, active: value === innerValue, onClick: () => handleOptionClick(option) }));
|
|
160
|
+
}) })), _jsx(Halfline, { direction: direction === 'up' ? 'bottom' : 'top' })] }) }));
|
|
161
|
+
};
|
|
162
|
+
return (_jsxs(_Fragment, { children: [_jsx(Pressable, { disabled: disabled, children: ({ pressed }) => (_jsxs(View, { ...restProps, className: classNames(bem.e('item'), bem.em('item', 'show', realVisible), bem.em('item', 'some-show', _itemShow), bem.em('item', 'disabled', disabled), bem.em('item', 'pressed', pressed), className), style: style, ref: itemRef, onClick: handleItemClick, children: [renderLabel(), renderTitle(), renderValue(), renderArrow()] })) }), _jsxs(Modal, { visible: realVisible || innerVisible || popoverVisible, children: [renderPopover(), renderAway()] })] }));
|
|
163
|
+
});
|
|
164
|
+
export default DropdownItem;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { FC, ReactNode } from 'react';
|
|
2
|
+
import { BaseProps } from '../base';
|
|
3
|
+
export interface DropdownOptionProps extends Omit<BaseProps, 'children'> {
|
|
4
|
+
label?: ReactNode;
|
|
5
|
+
value?: number | string;
|
|
6
|
+
active?: boolean;
|
|
7
|
+
onClick?: () => void;
|
|
8
|
+
}
|
|
9
|
+
export declare const DropdownOption: FC<DropdownOptionProps>;
|
|
10
|
+
export default DropdownOption;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import classNames from 'classnames';
|
|
3
|
+
import { Icon } from '../icon';
|
|
4
|
+
import { List } from '../list';
|
|
5
|
+
import { useBem } from '../use';
|
|
6
|
+
import { Text } from '@tarojs/components';
|
|
7
|
+
export const DropdownOption = (props) => {
|
|
8
|
+
const { className, style, label, active, onClick, ...restProps } = props;
|
|
9
|
+
const [bem] = useBem('dropdown');
|
|
10
|
+
return (_jsx(List.Item, { ...restProps, className: classNames(bem.e('option'), bem.em('option', 'active', active), className), style: style, title: _jsx(Text, { className: classNames(bem.e('option-label'), bem.em('option-label', 'active', active)), children: label }), linkable: true, arrow: _jsx(Icon, { name: "success", className: classNames(bem.e('option-icon'), bem.em('option-icon', 'active', active)) }), onClick: onClick }));
|
|
11
|
+
};
|
|
12
|
+
export default DropdownOption;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { FC, ReactElement, ReactNode } from 'react';
|
|
2
|
+
import { DropdownItem, DropdownItemProps } from './Item';
|
|
3
|
+
import { DropdownOption } from './Option';
|
|
4
|
+
import { BaseProps } from '../base';
|
|
5
|
+
export * from './Item';
|
|
6
|
+
export * from './Option';
|
|
7
|
+
export interface DropdownProps extends Omit<BaseProps, 'children'> {
|
|
8
|
+
children?: ReactElement | ReactElement[];
|
|
9
|
+
direction?: DropdownItemProps['direction'];
|
|
10
|
+
disabled?: boolean;
|
|
11
|
+
awayClosable?: boolean;
|
|
12
|
+
maskClosable?: boolean;
|
|
13
|
+
arrow?: (visible: boolean) => ReactNode;
|
|
14
|
+
}
|
|
15
|
+
export interface DropdownFC extends FC<DropdownProps> {
|
|
16
|
+
Item: typeof DropdownItem;
|
|
17
|
+
Option: typeof DropdownOption;
|
|
18
|
+
}
|
|
19
|
+
export declare const Dropdown: DropdownFC;
|
|
20
|
+
export default Dropdown;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Children, cloneElement, useMemo, useState, useRef, } from 'react';
|
|
3
|
+
import classNames from 'classnames';
|
|
4
|
+
import { View } from '@tarojs/components';
|
|
5
|
+
import { DropdownItem } from './Item';
|
|
6
|
+
import { DropdownOption } from './Option';
|
|
7
|
+
import { pickNonNullish } from '../utils';
|
|
8
|
+
import { useBem, useEvent } from '../use';
|
|
9
|
+
export * from './Item';
|
|
10
|
+
export * from './Option';
|
|
11
|
+
export const Dropdown = (props) => {
|
|
12
|
+
const { className, style, children, direction, disabled, awayClosable, maskClosable, arrow, ...restProps } = props;
|
|
13
|
+
const [bem] = useBem('dropdown');
|
|
14
|
+
const [visibleList, setVisibleList] = useState([]);
|
|
15
|
+
const show = useMemo(() => {
|
|
16
|
+
return visibleList.some((item) => item);
|
|
17
|
+
}, [visibleList]);
|
|
18
|
+
const handleVisible = (visible, index) => {
|
|
19
|
+
setVisibleList((visibleList) => {
|
|
20
|
+
visibleList[index] = visible;
|
|
21
|
+
return [...visibleList];
|
|
22
|
+
});
|
|
23
|
+
};
|
|
24
|
+
const elementsRef = useRef([]);
|
|
25
|
+
const collectElements = useEvent((element, index) => {
|
|
26
|
+
elementsRef.current[index] = element;
|
|
27
|
+
});
|
|
28
|
+
const toggleItem = (activeIndex) => {
|
|
29
|
+
elementsRef.current.forEach((item, index) => {
|
|
30
|
+
if (activeIndex !== index) {
|
|
31
|
+
item.toggle(false);
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
};
|
|
35
|
+
return (_jsx(View, { ...restProps, className: classNames(bem.b(), bem.m('show', show), className), style: style, children: Children.toArray(children).map((element, index) => {
|
|
36
|
+
return cloneElement(element, {
|
|
37
|
+
ref: (el) => collectElements(el, index),
|
|
38
|
+
onVisibleChange(visible) {
|
|
39
|
+
handleVisible(visible, index);
|
|
40
|
+
element.props.onVisibleChange?.(visible);
|
|
41
|
+
},
|
|
42
|
+
onClick(event) {
|
|
43
|
+
toggleItem(index);
|
|
44
|
+
element.props.onClick?.(event);
|
|
45
|
+
},
|
|
46
|
+
_itemShow: show,
|
|
47
|
+
...pickNonNullish({
|
|
48
|
+
direction,
|
|
49
|
+
disabled,
|
|
50
|
+
awayClosable,
|
|
51
|
+
maskClosable,
|
|
52
|
+
arrow,
|
|
53
|
+
}, element.props),
|
|
54
|
+
});
|
|
55
|
+
}) }));
|
|
56
|
+
};
|
|
57
|
+
Dropdown.Item = DropdownItem;
|
|
58
|
+
Dropdown.Option = DropdownOption;
|
|
59
|
+
export default Dropdown;
|