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,116 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useState, useEffect } from 'react';
|
|
3
|
+
import classNames from 'classnames';
|
|
4
|
+
import { View, Input as TaroInput, Textarea, CustomWrapper, } from '@tarojs/components';
|
|
5
|
+
import { useBem, useControllableValue, useSelectorId, useSetTimeout, } from '../use';
|
|
6
|
+
import { Icon } from '../icon';
|
|
7
|
+
import { filterNullish, isBoolean, isH5, isNullish, isString } from '../utils';
|
|
8
|
+
import Halfline from '../halfline';
|
|
9
|
+
import Pressable from '../pressable';
|
|
10
|
+
const inputMinHeight = 24;
|
|
11
|
+
const textareaMinHeight = 52;
|
|
12
|
+
export const Input = (props) => {
|
|
13
|
+
const { style: { height, minHeight, maxHeight, color, textAlign, ...restStyle } = {}, className, value, defaultValue, onChange, disabled, readOnly, maxLength = 140, showCount, count = (currentCount, maxLength) => `${currentCount}${maxLength !== -1 && ' / ' + maxLength}`, autoHeight, borderless, inlaid, prepend, append, addon, clearable, showClearOnlyFocus, clear, onClear, onClick, onFocus, onBlur, focused, placeholder = '', placeholderClass, placeholderStyle, cursorSpacing = 10, type = 'text', confirmType, confirmHold, ...restProps } = props;
|
|
14
|
+
const [bem] = useBem('input');
|
|
15
|
+
const controlId = useSelectorId();
|
|
16
|
+
const [innerValue, setInnerValue] = useControllableValue({
|
|
17
|
+
value,
|
|
18
|
+
defaultValue,
|
|
19
|
+
trigger: onChange,
|
|
20
|
+
initialValue: '',
|
|
21
|
+
});
|
|
22
|
+
const [innerFocused, setInnerFocused] = useState(false);
|
|
23
|
+
const handleFocus = (event) => {
|
|
24
|
+
setInnerFocused(true);
|
|
25
|
+
onFocus?.(event);
|
|
26
|
+
};
|
|
27
|
+
const handleBlur = (event) => {
|
|
28
|
+
setInnerFocused(false);
|
|
29
|
+
onBlur?.(event);
|
|
30
|
+
};
|
|
31
|
+
const handleClear = (event) => {
|
|
32
|
+
event.stopPropagation?.();
|
|
33
|
+
setInnerValue('');
|
|
34
|
+
onClear?.('');
|
|
35
|
+
};
|
|
36
|
+
const handleTouchStart = (event) => {
|
|
37
|
+
event.stopPropagation?.();
|
|
38
|
+
if (showClearOnlyFocus) {
|
|
39
|
+
setClearVisible(true);
|
|
40
|
+
hideClearLater();
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
const handleChange = (event) => {
|
|
44
|
+
const text = event.detail.value;
|
|
45
|
+
setInnerValue(text);
|
|
46
|
+
return text;
|
|
47
|
+
};
|
|
48
|
+
const [clearVisible, setClearVisible] = useState(false);
|
|
49
|
+
const [hideClearLater] = useSetTimeout(() => {
|
|
50
|
+
setClearVisible(false);
|
|
51
|
+
}, 600);
|
|
52
|
+
useEffect(() => {
|
|
53
|
+
let style;
|
|
54
|
+
if (isH5 && placeholderStyle) {
|
|
55
|
+
style = document.createElement('style');
|
|
56
|
+
style.textContent = `#${controlId} input::-webkit-input-placeholder {${placeholderStyle}}`;
|
|
57
|
+
document.head.appendChild(style);
|
|
58
|
+
}
|
|
59
|
+
return () => {
|
|
60
|
+
if (style) {
|
|
61
|
+
document.head.removeChild(style);
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
}, [placeholderStyle]);
|
|
65
|
+
const finalMinHeight = minHeight ?? (type === 'textarea' ? textareaMinHeight : inputMinHeight);
|
|
66
|
+
const controlProps = {
|
|
67
|
+
...restProps,
|
|
68
|
+
id: controlId,
|
|
69
|
+
autoComplete: 'off',
|
|
70
|
+
value: String(innerValue),
|
|
71
|
+
placeholder,
|
|
72
|
+
placeholderStyle,
|
|
73
|
+
placeholderClass: classNames(placeholderClass, bem.e('placeholder')),
|
|
74
|
+
password: type === 'password',
|
|
75
|
+
maxlength: maxLength,
|
|
76
|
+
disabled: disabled || readOnly,
|
|
77
|
+
autoHeight,
|
|
78
|
+
onInput: handleChange,
|
|
79
|
+
onFocus: handleFocus,
|
|
80
|
+
onBlur: handleBlur,
|
|
81
|
+
cursorSpacing,
|
|
82
|
+
style: filterNullish({
|
|
83
|
+
height: autoHeight ? 'auto' : height ?? finalMinHeight,
|
|
84
|
+
minHeight: finalMinHeight,
|
|
85
|
+
maxHeight,
|
|
86
|
+
color,
|
|
87
|
+
textAlign,
|
|
88
|
+
}),
|
|
89
|
+
// rn
|
|
90
|
+
height: height ?? finalMinHeight,
|
|
91
|
+
minHeight: finalMinHeight,
|
|
92
|
+
maxHeight,
|
|
93
|
+
color,
|
|
94
|
+
textAlign,
|
|
95
|
+
};
|
|
96
|
+
const controlClass = classNames(bem.e('control'), bem.em('control', 'is-textarea', type === 'textarea'), bem.em('control', 'readonly', readOnly), bem.em('control', 'disabled', disabled));
|
|
97
|
+
const inputProps = {
|
|
98
|
+
...controlProps,
|
|
99
|
+
type: type === 'password' || type === 'textarea' ? 'text' : type,
|
|
100
|
+
confirmType: confirmType !== 'return' ? confirmType : undefined,
|
|
101
|
+
confirmHold: isBoolean(confirmHold) ? confirmHold : undefined,
|
|
102
|
+
};
|
|
103
|
+
const textareaProps = {
|
|
104
|
+
...controlProps,
|
|
105
|
+
confirmType,
|
|
106
|
+
confirmHold: isString(confirmHold) ? confirmHold : undefined,
|
|
107
|
+
};
|
|
108
|
+
return (_jsx(CustomWrapper, { children: _jsxs(View, { style: {
|
|
109
|
+
borderWidth: !inlaid && !borderless ? Halfline.lineWidth : 0,
|
|
110
|
+
...restStyle,
|
|
111
|
+
}, className: classNames(bem.b(), bem.m('inlaid', inlaid), bem.m('borderless', borderless), bem.m('disabled', disabled), bem.m('focused', focused || innerFocused), className), onClick: onClick, children: [_jsxs(View, { className: bem.e('content'), children: [!isNullish(prepend) && (_jsx(View, { className: bem.e('prepend'), children: prepend })), type === 'textarea' ? (_jsx(Textarea, { ...textareaProps, className: controlClass })) : (_jsx(TaroInput, { ...inputProps, className: controlClass })), clearable && innerValue && !disabled && !readOnly && (_jsx(Pressable, { onTouchStart: handleTouchStart, onTouchEnd: handleClear, children: () => {
|
|
112
|
+
return (_jsx(View, { className: classNames(bem.e('clear'), bem.em('clear', 'hide', showClearOnlyFocus &&
|
|
113
|
+
!(focused || innerFocused || clearVisible))), children: clear || (_jsx(Icon, { name: "x-circle-fill", className: bem.e('clear-icon') })) }));
|
|
114
|
+
} })), !isNullish(append) && (_jsx(View, { className: bem.e('append'), children: append })), addon] }), showCount && count && (_jsx(View, { className: classNames(bem.e('count'), bem.em('count', 'is-textarea', type === 'textarea')), children: count(String(innerValue).length, maxLength) }))] }) }));
|
|
115
|
+
};
|
|
116
|
+
export default Input;
|
|
@@ -0,0 +1,249 @@
|
|
|
1
|
+
@import '../style/base.scss';
|
|
2
|
+
// #variables
|
|
3
|
+
$sar-input-padding-y: 5px !default;
|
|
4
|
+
$sar-input-padding-borderless-y: 6px !default;
|
|
5
|
+
$sar-input-padding-x: 12px !default;
|
|
6
|
+
$sar-input-border-radius: $sar-rounded !default;
|
|
7
|
+
$sar-input-border-color: $sar-border-color !default;
|
|
8
|
+
$sar-input-transition-duration: $sar-duration !default;
|
|
9
|
+
|
|
10
|
+
$sar-input-focused-border-color: $sar-primary !default;
|
|
11
|
+
|
|
12
|
+
$sar-input-control-padding-y: 2px !default;
|
|
13
|
+
$sar-input-control-padding-x: 2px !default;
|
|
14
|
+
$sar-input-control-font-size: $sar-text-base !default;
|
|
15
|
+
$sar-input-control-line-height: 24px !default;
|
|
16
|
+
|
|
17
|
+
$sar-input-placeholder-color: $sar-deemphasis-color !default;
|
|
18
|
+
|
|
19
|
+
$sar-input-prepend-gap-right: 8px !default;
|
|
20
|
+
$sar-input-append-gap-left: 8px !default;
|
|
21
|
+
|
|
22
|
+
$sar-input-clear-margin-right: -8px !default;
|
|
23
|
+
$sar-input-clear-padding-x: 8px !default;
|
|
24
|
+
$sar-input-clear-color: $sar-quaternary-color !default;
|
|
25
|
+
|
|
26
|
+
$sar-input-count-font-size: $sar-text-sm !default;
|
|
27
|
+
$sar-input-count-color: $sar-tertiary-color !default;
|
|
28
|
+
|
|
29
|
+
// 暗黑模式
|
|
30
|
+
$sar-input-border-dark-color: $sar-dark-border-color !default;
|
|
31
|
+
$sar-input-placeholder-dark-color: $sar-dark-deemphasis-color !default;
|
|
32
|
+
$sar-input-clear-dark-color: $sar-dark-quaternary-color !default;
|
|
33
|
+
$sar-input-count-dark-color: $sar-dark-tertiary-color !default;
|
|
34
|
+
// #endvariables
|
|
35
|
+
|
|
36
|
+
@include bem(input) {
|
|
37
|
+
@include b() {
|
|
38
|
+
@include universal;
|
|
39
|
+
width: 100%;
|
|
40
|
+
padding: $sar-input-padding-y $sar-input-padding-x;
|
|
41
|
+
border: 1px solid $sar-input-border-color;
|
|
42
|
+
border-radius: $sar-input-border-radius;
|
|
43
|
+
font-family: inherit;
|
|
44
|
+
font-size: $sar-input-control-font-size;
|
|
45
|
+
line-height: $sar-input-control-line-height;
|
|
46
|
+
@include ifweb {
|
|
47
|
+
transition: $sar-input-transition-duration;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
@include m(borderless) {
|
|
51
|
+
padding-top: $sar-input-padding-borderless-y;
|
|
52
|
+
padding-bottom: $sar-input-padding-borderless-y;
|
|
53
|
+
border-width: 0;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
@include m(inlaid) {
|
|
57
|
+
padding: 0;
|
|
58
|
+
border-width: 0;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
@include m(focused) {
|
|
62
|
+
border-color: $sar-input-focused-border-color;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
@include m(disabled) {
|
|
66
|
+
background-color: $sar-disabled-shallow-bg-color;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
// 兼容H5文本域文本溢出问题
|
|
71
|
+
@include ifweb {
|
|
72
|
+
taro-textarea-core {
|
|
73
|
+
display: flex;
|
|
74
|
+
flex-direction: row;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
@include e(content) {
|
|
79
|
+
@include universal;
|
|
80
|
+
flex-direction: row;
|
|
81
|
+
flex-wrap: wrap;
|
|
82
|
+
align-items: center;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
@include e(control) {
|
|
86
|
+
@include universal;
|
|
87
|
+
z-index: 0;
|
|
88
|
+
flex: 1;
|
|
89
|
+
align-self: center;
|
|
90
|
+
width: 100%;
|
|
91
|
+
max-width: 100%;
|
|
92
|
+
min-width: 0;
|
|
93
|
+
margin: 0;
|
|
94
|
+
padding: 0 $sar-input-control-padding-x;
|
|
95
|
+
border-width: 0;
|
|
96
|
+
|
|
97
|
+
@include ifweb {
|
|
98
|
+
&,
|
|
99
|
+
.weui-input,
|
|
100
|
+
.taro-input,
|
|
101
|
+
.taro-textarea {
|
|
102
|
+
resize: none;
|
|
103
|
+
font-family: inherit;
|
|
104
|
+
font-size: inherit;
|
|
105
|
+
font-style: inherit;
|
|
106
|
+
font-weight: inherit;
|
|
107
|
+
line-height: inherit;
|
|
108
|
+
color: inherit;
|
|
109
|
+
text-align: inherit;
|
|
110
|
+
text-indent: inherit;
|
|
111
|
+
text-transform: inherit;
|
|
112
|
+
text-emphasis: inherit;
|
|
113
|
+
text-rendering: inherit;
|
|
114
|
+
letter-spacing: inherit;
|
|
115
|
+
word-spacing: inherit;
|
|
116
|
+
background-color: transparent;
|
|
117
|
+
|
|
118
|
+
&::-webkit-input-placeholder {
|
|
119
|
+
line-height: inherit;
|
|
120
|
+
color: $sar-input-placeholder-color;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
&:disabled {
|
|
124
|
+
cursor: not-allowed;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
.weui-input {
|
|
129
|
+
&:disabled {
|
|
130
|
+
// 覆盖 iphone的opacity: 0.4
|
|
131
|
+
opacity: 1;
|
|
132
|
+
}
|
|
133
|
+
min-height: 100%;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
&:focus,
|
|
137
|
+
&:active {
|
|
138
|
+
outline: none;
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
@include m(is-textarea) {
|
|
143
|
+
padding-top: $sar-input-control-padding-y;
|
|
144
|
+
padding-bottom: $sar-input-control-padding-y;
|
|
145
|
+
line-height: $sar-input-control-font-size * $sar-leading-tight;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
@include m(readonly) {
|
|
149
|
+
pointer-events: none;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
@include m(disabled) {
|
|
153
|
+
color: $sar-disabled-color;
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
@include e(placeholder) {
|
|
158
|
+
color: $sar-input-placeholder-color;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
@include e(prepend, append) {
|
|
162
|
+
@include universal;
|
|
163
|
+
align-items: center;
|
|
164
|
+
justify-content: center;
|
|
165
|
+
flex: none;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
@include e(prepend) {
|
|
169
|
+
margin-right: $sar-input-prepend-gap-right;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
@include e(append) {
|
|
173
|
+
margin-left: $sar-input-append-gap-left;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
@include e(clear) {
|
|
177
|
+
@include universal;
|
|
178
|
+
z-index: 2;
|
|
179
|
+
flex: none;
|
|
180
|
+
width: auto;
|
|
181
|
+
align-self: stretch;
|
|
182
|
+
justify-content: center;
|
|
183
|
+
align-items: center;
|
|
184
|
+
margin-right: $sar-input-clear-margin-right;
|
|
185
|
+
padding: 0 $sar-input-clear-padding-x;
|
|
186
|
+
@include ifweb {
|
|
187
|
+
cursor: pointer;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
@include m(hide) {
|
|
191
|
+
display: none;
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
@include e(clear-icon) {
|
|
196
|
+
color: $sar-input-clear-color;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
@include e(count) {
|
|
200
|
+
@include universal;
|
|
201
|
+
align-items: flex-end;
|
|
202
|
+
font-size: $sar-input-count-font-size;
|
|
203
|
+
line-height: $sar-input-count-font-size * $sar-leading-tight;
|
|
204
|
+
color: $sar-input-count-color;
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
@include theme(dark) {
|
|
209
|
+
@include bem(input) {
|
|
210
|
+
@include b() {
|
|
211
|
+
border-color: $sar-input-border-dark-color;
|
|
212
|
+
|
|
213
|
+
@include m(focused) {
|
|
214
|
+
border-color: $sar-input-focused-border-color;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
@include m(disabled) {
|
|
218
|
+
background-color: $sar-dark-disabled-shallow-bg-color;
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
@include e(control) {
|
|
223
|
+
&,
|
|
224
|
+
.weui-input,
|
|
225
|
+
.taro-input,
|
|
226
|
+
.taro-textarea {
|
|
227
|
+
&::-webkit-input-placeholder {
|
|
228
|
+
color: $sar-input-placeholder-dark-color;
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
@include m(disabled) {
|
|
233
|
+
color: $sar-dark-disabled-color;
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
@include e(placeholder) {
|
|
238
|
+
color: $sar-input-placeholder-dark-color;
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
@include e(clear-icon) {
|
|
242
|
+
color: $sar-input-clear-dark-color;
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
@include e(count) {
|
|
246
|
+
color: $sar-input-count-dark-color;
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { FC } from 'react';
|
|
2
|
+
import { BaseProps } from '../base';
|
|
3
|
+
export interface LinearGradientPoint {
|
|
4
|
+
x: number;
|
|
5
|
+
y: number;
|
|
6
|
+
}
|
|
7
|
+
export interface LinearGradientProps extends BaseProps {
|
|
8
|
+
colors?: string[];
|
|
9
|
+
start?: LinearGradientPoint;
|
|
10
|
+
end?: LinearGradientPoint;
|
|
11
|
+
locations?: number[];
|
|
12
|
+
}
|
|
13
|
+
export declare const LinearGradient: FC<LinearGradientProps>;
|
|
14
|
+
export default LinearGradient;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { View } from '@tarojs/components';
|
|
3
|
+
import { getAngle360, isNullish } from '../utils';
|
|
4
|
+
export const LinearGradient = (props) => {
|
|
5
|
+
const { className, style, children, colors = [], start = {
|
|
6
|
+
x: 0.5,
|
|
7
|
+
y: 0,
|
|
8
|
+
}, end = {
|
|
9
|
+
x: 0.5,
|
|
10
|
+
y: 1,
|
|
11
|
+
}, locations = [], ...restProps } = props;
|
|
12
|
+
const getAngle = () => {
|
|
13
|
+
return getAngle360(start, end);
|
|
14
|
+
};
|
|
15
|
+
const getColors = () => {
|
|
16
|
+
return colors
|
|
17
|
+
.map((color, index) => {
|
|
18
|
+
const location = locations[index];
|
|
19
|
+
return isNullish(location)
|
|
20
|
+
? color
|
|
21
|
+
: [color, location * 100 + '%'].join(' ');
|
|
22
|
+
})
|
|
23
|
+
.join(',');
|
|
24
|
+
};
|
|
25
|
+
return (_jsx(View, { ...restProps, className: className, style: {
|
|
26
|
+
...style,
|
|
27
|
+
backgroundImage: `linear-gradient(${getAngle()}deg, ${getColors()})`,
|
|
28
|
+
}, children: children }));
|
|
29
|
+
};
|
|
30
|
+
export default LinearGradient;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { CSSProperties, FC, ReactNode } from 'react';
|
|
2
|
+
import { ITouchEvent } from '@tarojs/components';
|
|
3
|
+
import { BaseProps } from '../base';
|
|
4
|
+
export interface ListItemProps extends BaseProps {
|
|
5
|
+
title?: ReactNode;
|
|
6
|
+
label?: ReactNode;
|
|
7
|
+
value?: ReactNode;
|
|
8
|
+
footer?: ReactNode;
|
|
9
|
+
linkable?: boolean;
|
|
10
|
+
clickable?: boolean;
|
|
11
|
+
arrowDirection?: 'up' | 'right' | 'down';
|
|
12
|
+
arrow?: ReactNode;
|
|
13
|
+
icon?: ReactNode;
|
|
14
|
+
inset?: boolean;
|
|
15
|
+
bodyStyle?: CSSProperties;
|
|
16
|
+
bodyClass?: string;
|
|
17
|
+
footerStyle?: CSSProperties;
|
|
18
|
+
footerClass?: string;
|
|
19
|
+
onClick?: (event: ITouchEvent) => void;
|
|
20
|
+
}
|
|
21
|
+
export declare const ListItem: FC<ListItemProps>;
|
|
22
|
+
export default ListItem;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { useContext } from 'react';
|
|
3
|
+
import classNames from 'classnames';
|
|
4
|
+
import { View } from '@tarojs/components';
|
|
5
|
+
import { useBem } from '../use';
|
|
6
|
+
import { isNullish, pickContextNullish } from '../utils';
|
|
7
|
+
import { OrderContext } from './OrderContext';
|
|
8
|
+
import { ListContext } from './ListContext';
|
|
9
|
+
import Icon from '../icon';
|
|
10
|
+
import Halfline from '../halfline';
|
|
11
|
+
import Pressable from '../pressable';
|
|
12
|
+
export const ListItem = (props) => {
|
|
13
|
+
const { className, style, children, title, label, value, footer, linkable, clickable, arrowDirection = 'right', arrow, icon, inset, bodyStyle, bodyClass, footerStyle, footerClass, onClick, ...restProps } = props;
|
|
14
|
+
const [bem] = useBem('list');
|
|
15
|
+
const { index, count, card } = useContext(OrderContext);
|
|
16
|
+
const listContext = useContext(ListContext);
|
|
17
|
+
const contextProps = pickContextNullish({
|
|
18
|
+
inset,
|
|
19
|
+
bodyStyle,
|
|
20
|
+
bodyClass,
|
|
21
|
+
footerStyle,
|
|
22
|
+
footerClass,
|
|
23
|
+
}, listContext);
|
|
24
|
+
return (_jsx(Pressable, { disabled: !clickable && (clickable === false || !linkable), children: ({ pressed }) => (_jsxs(View, { ...restProps, className: classNames(bem.e('item'), bem.em('item', 'first', index === 0), bem.em('item', 'first-card', index === 0 && card), bem.em('item', 'last', index === count - 1), bem.em('item', 'last-card', index === count - 1 && card), bem.em('item', 'pressed', pressed), bem.em('item', 'clickable', clickable || (clickable !== false && linkable)), className), style: style, onClick: onClick, children: [!isNullish(icon) && (_jsxs(View, { className: classNames(bem.e('item-header'), bem.em('item-header', 'inset-later', contextProps.inset && index > 0)), children: [_jsx(View, { className: bem.e('icon'), children: icon }), contextProps.inset && index > 0 && _jsx(Halfline, { direction: "top" })] })), _jsxs(View, { className: classNames(bem.e('item-content'), bem.em('item-content', 'custom', !!children), bem.em('item-content', 'later', index > 0)), children: [index > 0 && _jsx(Halfline, { direction: "top" }), children ?? (_jsxs(_Fragment, { children: [_jsxs(View, { className: classNames(bem.e('item-body'), contextProps.bodyClass), style: contextProps.bodyStyle, children: [!isNullish(title) && (_jsx(View, { className: classNames(bem.e('item-title')), children: title })), !isNullish(label) && (_jsx(View, { className: bem.e('item-label'), children: label }))] }), _jsx(View, { className: classNames(bem.e('item-footer'), bem.em('item-footer', 'custom', !isNullish(footer)), contextProps.footerClass), style: contextProps.footerStyle, children: footer ?? (_jsxs(_Fragment, { children: [!isNullish(value) && (_jsx(View, { className: bem.e('item-value'), children: value })), linkable && (_jsx(View, { className: bem.e('item-arrow'), children: arrow ?? (_jsx(Icon, { name: arrowDirection, className: bem.e('item-arrow-icon') })) }))] })) })] }))] })] })) }));
|
|
25
|
+
};
|
|
26
|
+
export default ListItem;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { CSSProperties } from 'react';
|
|
2
|
+
export interface ListContextValue {
|
|
3
|
+
inset?: boolean;
|
|
4
|
+
bodyStyle?: CSSProperties;
|
|
5
|
+
bodyClass?: string;
|
|
6
|
+
footerStyle?: CSSProperties;
|
|
7
|
+
footerClass?: string;
|
|
8
|
+
}
|
|
9
|
+
export declare const ListContext: import("react").Context<ListContextValue>;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { CSSProperties, FC, ReactNode } from 'react';
|
|
2
|
+
import { BaseProps } from '../base';
|
|
3
|
+
import { ListItem } from './Item';
|
|
4
|
+
export interface ListProps extends BaseProps {
|
|
5
|
+
title?: ReactNode;
|
|
6
|
+
label?: ReactNode;
|
|
7
|
+
inlaid?: boolean;
|
|
8
|
+
card?: boolean;
|
|
9
|
+
inset?: boolean;
|
|
10
|
+
bodyStyle?: CSSProperties;
|
|
11
|
+
bodyClass?: string;
|
|
12
|
+
footerStyle?: CSSProperties;
|
|
13
|
+
footerClass?: string;
|
|
14
|
+
}
|
|
15
|
+
export interface ListFC extends FC<ListProps> {
|
|
16
|
+
Item: typeof ListItem;
|
|
17
|
+
}
|
|
18
|
+
export declare const List: ListFC;
|
|
19
|
+
export default List;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Children, cloneElement, useMemo, } from 'react';
|
|
3
|
+
import classNames from 'classnames';
|
|
4
|
+
import { View } from '@tarojs/components';
|
|
5
|
+
import { isNullish } from '../utils';
|
|
6
|
+
import { useBem } from '../use';
|
|
7
|
+
import { ListItem } from './Item';
|
|
8
|
+
import { ListContext } from './ListContext';
|
|
9
|
+
import { OrderContext } from './OrderContext';
|
|
10
|
+
import Halfline from '../halfline';
|
|
11
|
+
export const List = (props) => {
|
|
12
|
+
const { className, style, children, title, label, inlaid, card = false, inset, bodyStyle, bodyClass, footerStyle, footerClass, ...restProps } = props;
|
|
13
|
+
const [bem] = useBem('list');
|
|
14
|
+
const listContextValue = useMemo(() => {
|
|
15
|
+
return {
|
|
16
|
+
inset,
|
|
17
|
+
bodyStyle,
|
|
18
|
+
bodyClass,
|
|
19
|
+
footerStyle,
|
|
20
|
+
footerClass,
|
|
21
|
+
};
|
|
22
|
+
}, [inset, bodyStyle, bodyClass, footerStyle, footerClass]);
|
|
23
|
+
const count = Children.count(children);
|
|
24
|
+
return (_jsxs(View, { ...restProps, className: classNames(bem.b(), bem.m('card', card), className), style: style, children: [!isNullish(title) && (_jsx(View, { className: bem.e('header'), children: _jsx(View, { className: bem.e('title'), children: title }) })), _jsxs(View, { className: classNames(bem.e('body'), bem.em('body', 'card', card)), children: [!inlaid && !card && _jsx(Halfline, { direction: "top" }), _jsx(ListContext.Provider, { value: listContextValue, children: Children.map(children, (element, index) => {
|
|
25
|
+
return (_jsx(OrderContext.Provider, { value: { index, count, card }, children: cloneElement(element) }));
|
|
26
|
+
}) }), !inlaid && !card && _jsx(Halfline, { direction: "bottom" })] }), !isNullish(label) && (_jsx(View, { className: bem.e('footer'), children: _jsx(View, { className: bem.e('label'), children: label }) }))] }));
|
|
27
|
+
};
|
|
28
|
+
List.Item = ListItem;
|
|
29
|
+
export default List;
|