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,41 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import classNames from 'classnames';
|
|
3
|
+
import { Image, View } from '@tarojs/components';
|
|
4
|
+
import { Icon } from '../icon';
|
|
5
|
+
import { Loading } from '../loading';
|
|
6
|
+
import { isVideoUrl, isImageUrl } from '../utils';
|
|
7
|
+
import { useBem, useEvent } from '../use';
|
|
8
|
+
import Ellipsis from '../ellipsis';
|
|
9
|
+
import PreviewVideo from './PreviewVideo';
|
|
10
|
+
export const UploadPreview = (props) => {
|
|
11
|
+
const { className, style, index, removable = true, remove, beforeRemove, onRemove, disabled, readOnly, file, name, url, isImage: _isImage, isVideo: _isVideo, status = 'pending', message, onImageClick, mode = 'aspectFill', contextId, ...restProps } = props;
|
|
12
|
+
const [bem] = useBem('upload');
|
|
13
|
+
const handleRemove = useEvent(() => {
|
|
14
|
+
if (!removable || disabled || readOnly)
|
|
15
|
+
return;
|
|
16
|
+
function remove() {
|
|
17
|
+
onRemove?.(index);
|
|
18
|
+
}
|
|
19
|
+
if (beforeRemove) {
|
|
20
|
+
const ret = beforeRemove(index);
|
|
21
|
+
if (!ret) {
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
if (ret instanceof Promise) {
|
|
25
|
+
ret
|
|
26
|
+
.then(() => {
|
|
27
|
+
remove();
|
|
28
|
+
})
|
|
29
|
+
.catch(() => {
|
|
30
|
+
null;
|
|
31
|
+
});
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
remove();
|
|
36
|
+
});
|
|
37
|
+
const isImage = _isImage || file?.type === 'image' || (url && isImageUrl(url));
|
|
38
|
+
const isVideo = _isVideo || file?.type === 'video' || (url && isVideoUrl(url));
|
|
39
|
+
return (_jsxs(View, { ...restProps, className: classNames(bem.e('preview'), bem.em('preview', 'video', isVideo), className), style: style, children: [isImage ? (_jsx(Image, { mode: mode, className: bem.e('image'), src: url || file?.path || '', onClick: () => onImageClick?.(index) })) : isVideo ? (_jsx(PreviewVideo, { contextId: contextId, src: url || file?.path || '' })) : (_jsxs(View, { className: bem.e('file'), children: [_jsx(Icon, { className: bem.e('file-icon'), name: "file" }), _jsx(Ellipsis, { className: bem.e('file-name'), children: name })] })), (status === 'uploading' || status === 'failed') && (_jsxs(View, { className: bem.e('status'), children: [status === 'uploading' && (_jsx(Loading, { size: 24, className: bem.e('loading-icon') })), status === 'failed' && (_jsx(Icon, { name: "x-circle", className: bem.e('failed-icon') })), message && (_jsx(Ellipsis, { className: bem.e('status-message'), children: message }))] })), removable && !disabled && !readOnly && status !== 'uploading' && (_jsx(View, { className: bem.e('remove'), onClick: handleRemove, children: remove ?? (_jsx(View, { className: bem.e('close'), children: _jsx(Icon, { name: "close", className: bem.e('close-icon') }) })) }))] }));
|
|
40
|
+
};
|
|
41
|
+
export default UploadPreview;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { BaseProps } from '../base';
|
|
2
|
+
export interface CustomVideoProps extends BaseProps {
|
|
3
|
+
src?: string;
|
|
4
|
+
contextId?: string;
|
|
5
|
+
}
|
|
6
|
+
export declare const CustomVideo: (props: CustomVideoProps) => import("react/jsx-runtime").JSX.Element;
|
|
7
|
+
export default CustomVideo;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Video } from '@tarojs/components';
|
|
3
|
+
import { useEffect, useRef, useState } from 'react';
|
|
4
|
+
import { View } from '@tarojs/components';
|
|
5
|
+
import { useBem, useSelectorId } from '../use';
|
|
6
|
+
import Icon from '../icon';
|
|
7
|
+
import Taro from '@tarojs/taro';
|
|
8
|
+
import { getElementById, isBoolean } from '../utils';
|
|
9
|
+
export const CustomVideo = (props) => {
|
|
10
|
+
const { src = '', contextId } = props;
|
|
11
|
+
const [bem] = useBem('upload');
|
|
12
|
+
const videoId = useSelectorId();
|
|
13
|
+
const videoContext = useRef();
|
|
14
|
+
const [controlsVisible, setControlsVisible] = useState(false);
|
|
15
|
+
useEffect(() => {
|
|
16
|
+
videoContext.current = Taro.createVideoContext(videoId, contextId && getElementById(contextId)?.ctx);
|
|
17
|
+
}, []);
|
|
18
|
+
const handlePlayClick = () => {
|
|
19
|
+
videoContext.current?.requestFullScreen({
|
|
20
|
+
direction: 0,
|
|
21
|
+
});
|
|
22
|
+
videoContext.current?.play();
|
|
23
|
+
};
|
|
24
|
+
const handleFullScreenChange = (event) => {
|
|
25
|
+
const fullScreen = event.detail?.fullScreen;
|
|
26
|
+
if (isBoolean(fullScreen)) {
|
|
27
|
+
if (fullScreen) {
|
|
28
|
+
setControlsVisible(true);
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
videoContext.current?.pause();
|
|
32
|
+
setControlsVisible(false);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
return (_jsxs(View, { className: bem.e('video-wrapper'), children: [_jsx(Video, { id: videoId, objectFit: "contain", className: bem.e('video'), src: src, crossOrigin: 'anonymous', controls: controlsVisible, showCenterPlayBtn: controlsVisible, onFullscreenChange: handleFullScreenChange, onFullScreenChange: handleFullScreenChange }), _jsx(View, { className: bem.e('video-play'), onClick: handlePlayClick, children: _jsx(Icon, { name: "play", size: 40, className: bem.e('video-play-icon') }) })] }));
|
|
37
|
+
};
|
|
38
|
+
export default CustomVideo;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useRef } from 'react';
|
|
3
|
+
import { Video, ResizeMode } from 'expo-av';
|
|
4
|
+
import { View } from '@tarojs/components';
|
|
5
|
+
import { useBem } from '../use';
|
|
6
|
+
import Icon from '../icon';
|
|
7
|
+
export const CustomVideo = (props) => {
|
|
8
|
+
const { src = '' } = props;
|
|
9
|
+
const [bem] = useBem('upload');
|
|
10
|
+
const videoRef = useRef(null);
|
|
11
|
+
const handlePlayClick = () => {
|
|
12
|
+
videoRef.current?.presentFullscreenPlayer();
|
|
13
|
+
videoRef.current?.playAsync();
|
|
14
|
+
};
|
|
15
|
+
const handleFullscreenUpdate = (event) => {
|
|
16
|
+
if (event.fullscreenUpdate === 2) {
|
|
17
|
+
videoRef.current?.stopAsync();
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
return (_jsxs(View, { className: bem.e('video-wrapper'), children: [_jsx(Video, { ref: videoRef, style: { width: '100%', height: '100%' }, resizeMode: ResizeMode.CONTAIN, source: {
|
|
21
|
+
uri: src,
|
|
22
|
+
}, onFullscreenUpdate: handleFullscreenUpdate }), _jsx(View, { className: bem.e('video-play'), onClick: handlePlayClick, children: _jsx(Icon, { name: "play", size: 40, className: bem.e('video-play-icon') }) })] }));
|
|
23
|
+
};
|
|
24
|
+
export default CustomVideo;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import Taro from '@tarojs/taro';
|
|
2
|
+
interface chooseMediaOptions {
|
|
3
|
+
count?: number;
|
|
4
|
+
mediaType?: 'image' | 'video';
|
|
5
|
+
sourceType?: ('album' | 'camera')[];
|
|
6
|
+
maxDuration?: number;
|
|
7
|
+
sizeType?: ('original' | 'compressed')[];
|
|
8
|
+
camera?: 'back' | 'front';
|
|
9
|
+
success?: (result: chooseMediaResult) => void;
|
|
10
|
+
fail?: (err: any) => void;
|
|
11
|
+
complete?: () => void;
|
|
12
|
+
}
|
|
13
|
+
interface chooseMediaResult {
|
|
14
|
+
tempFiles: {
|
|
15
|
+
tempFilePath: string;
|
|
16
|
+
size: number;
|
|
17
|
+
duration: number;
|
|
18
|
+
height: number;
|
|
19
|
+
width: number;
|
|
20
|
+
thumbTempFilePath: string;
|
|
21
|
+
fileType: 'image' | 'video';
|
|
22
|
+
}[];
|
|
23
|
+
type: 'image' | 'video';
|
|
24
|
+
}
|
|
25
|
+
export declare function chooseMedia(options: chooseMediaOptions): Promise<Taro.chooseImage.SuccessCallbackResult> | Promise<Taro.chooseVideo.SuccessCallbackResult>;
|
|
26
|
+
export {};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
interface chooseMediaOptions {
|
|
2
|
+
count?: number;
|
|
3
|
+
mediaType?: 'image' | 'video';
|
|
4
|
+
sourceType?: ('album' | 'camera')[];
|
|
5
|
+
maxDuration?: number;
|
|
6
|
+
sizeType?: ('original' | 'compressed')[];
|
|
7
|
+
camera?: 'back' | 'front';
|
|
8
|
+
success?: (result: chooseMediaResult) => void;
|
|
9
|
+
fail?: (err: any) => void;
|
|
10
|
+
complete?: () => void;
|
|
11
|
+
}
|
|
12
|
+
interface chooseMediaResult {
|
|
13
|
+
tempFiles: {
|
|
14
|
+
tempFilePath: string;
|
|
15
|
+
size: number;
|
|
16
|
+
duration: number;
|
|
17
|
+
height: number;
|
|
18
|
+
width: number;
|
|
19
|
+
thumbTempFilePath: string;
|
|
20
|
+
fileType: 'image' | 'video';
|
|
21
|
+
}[];
|
|
22
|
+
type: 'image' | 'video';
|
|
23
|
+
}
|
|
24
|
+
export declare function chooseMedia(options: chooseMediaOptions): Promise<chooseMediaResult>;
|
|
25
|
+
export {};
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import ActionSheet from '../action-sheet';
|
|
2
|
+
let input;
|
|
3
|
+
export async function chooseMedia(options) {
|
|
4
|
+
const { count = 9, mediaType = 'image', sourceType = ['album', 'camera'], camera = 'back', success, fail, complete, } = options;
|
|
5
|
+
let finalSourceType = 'album';
|
|
6
|
+
if (sourceType.length > 1) {
|
|
7
|
+
const { index } = await ActionSheet.show({
|
|
8
|
+
itemList: ['拍摄', '从相册选择'],
|
|
9
|
+
cancel: '取消',
|
|
10
|
+
});
|
|
11
|
+
finalSourceType = index === 0 ? 'camera' : 'album';
|
|
12
|
+
}
|
|
13
|
+
else if (sourceType.length === 1) {
|
|
14
|
+
finalSourceType = sourceType[0];
|
|
15
|
+
}
|
|
16
|
+
if (!input) {
|
|
17
|
+
input = document.createElement('input');
|
|
18
|
+
input.type = 'file';
|
|
19
|
+
input.style.cssText =
|
|
20
|
+
'position: fixed; z-index: -100; opacity: 0; pointer-events: none';
|
|
21
|
+
}
|
|
22
|
+
input.multiple = count > 1;
|
|
23
|
+
if (finalSourceType === 'camera') {
|
|
24
|
+
input.setAttribute('capture', camera === 'back' ? 'environment' : 'user');
|
|
25
|
+
}
|
|
26
|
+
else {
|
|
27
|
+
input.removeAttribute('capture');
|
|
28
|
+
}
|
|
29
|
+
input.setAttribute('accept', mediaType === 'image' ? 'image/*' : 'video/*');
|
|
30
|
+
try {
|
|
31
|
+
const result = await new Promise((resolve, reject) => {
|
|
32
|
+
input.onchange = async () => {
|
|
33
|
+
const files = input.files || [];
|
|
34
|
+
const tempFiles = [];
|
|
35
|
+
try {
|
|
36
|
+
for (const file of [...files]) {
|
|
37
|
+
tempFiles.push(await loadMedia(file, mediaType));
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
catch (err) {
|
|
41
|
+
reject(err);
|
|
42
|
+
}
|
|
43
|
+
resolve({
|
|
44
|
+
tempFiles,
|
|
45
|
+
type: mediaType,
|
|
46
|
+
});
|
|
47
|
+
input.value = '';
|
|
48
|
+
};
|
|
49
|
+
input.click();
|
|
50
|
+
});
|
|
51
|
+
success?.(result);
|
|
52
|
+
return result;
|
|
53
|
+
}
|
|
54
|
+
catch (err) {
|
|
55
|
+
if (fail) {
|
|
56
|
+
fail(err);
|
|
57
|
+
}
|
|
58
|
+
else {
|
|
59
|
+
throw err;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
finally {
|
|
63
|
+
complete?.();
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
async function loadMedia(file, type) {
|
|
67
|
+
const url = URL.createObjectURL(file);
|
|
68
|
+
const result = {
|
|
69
|
+
tempFilePath: url,
|
|
70
|
+
size: file.size,
|
|
71
|
+
duration: 0,
|
|
72
|
+
height: 0,
|
|
73
|
+
width: 0,
|
|
74
|
+
thumbTempFilePath: '',
|
|
75
|
+
fileType: type,
|
|
76
|
+
};
|
|
77
|
+
if (type === 'video') {
|
|
78
|
+
await new Promise((resolve, reject) => {
|
|
79
|
+
const video = document.createElement('video');
|
|
80
|
+
video.crossOrigin = 'Anonymous';
|
|
81
|
+
video.preload = 'metadata';
|
|
82
|
+
video.src = url;
|
|
83
|
+
video.onloadedmetadata = () => {
|
|
84
|
+
result.duration = video.duration;
|
|
85
|
+
result.width = video.videoWidth;
|
|
86
|
+
result.height = video.videoHeight;
|
|
87
|
+
resolve();
|
|
88
|
+
};
|
|
89
|
+
video.onerror = () => {
|
|
90
|
+
reject();
|
|
91
|
+
};
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
else {
|
|
95
|
+
await new Promise((resolve, reject) => {
|
|
96
|
+
const img = new Image();
|
|
97
|
+
img.crossOrigin = url;
|
|
98
|
+
img.src = url;
|
|
99
|
+
if (img.complete) {
|
|
100
|
+
result.width = img.width;
|
|
101
|
+
result.height = img.height;
|
|
102
|
+
resolve();
|
|
103
|
+
}
|
|
104
|
+
else {
|
|
105
|
+
img.onload = () => {
|
|
106
|
+
result.width = img.width;
|
|
107
|
+
result.height = img.height;
|
|
108
|
+
resolve();
|
|
109
|
+
};
|
|
110
|
+
img.onerror = () => {
|
|
111
|
+
reject();
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
return result;
|
|
117
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import Taro from '@tarojs/taro';
|
|
2
|
+
export function chooseMedia(options) {
|
|
3
|
+
const { count = 9, mediaType = 'image', sourceType = ['album', 'camera'], maxDuration = 10, sizeType = ['original', 'compressed'], camera = 'back', success, fail, complete, } = options;
|
|
4
|
+
if (mediaType === 'image') {
|
|
5
|
+
return Taro.chooseImage({
|
|
6
|
+
count,
|
|
7
|
+
sizeType,
|
|
8
|
+
sourceType,
|
|
9
|
+
success(res) {
|
|
10
|
+
success?.({
|
|
11
|
+
type: 'image',
|
|
12
|
+
tempFiles: res.tempFiles.map((file) => {
|
|
13
|
+
return {
|
|
14
|
+
tempFilePath: file.path,
|
|
15
|
+
size: file.size,
|
|
16
|
+
duration: 0,
|
|
17
|
+
height: 0,
|
|
18
|
+
width: 0,
|
|
19
|
+
thumbTempFilePath: '',
|
|
20
|
+
fileType: 'image',
|
|
21
|
+
};
|
|
22
|
+
}),
|
|
23
|
+
});
|
|
24
|
+
},
|
|
25
|
+
fail,
|
|
26
|
+
complete,
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
return Taro.chooseVideo({
|
|
31
|
+
sourceType,
|
|
32
|
+
compressed: sizeType.includes('compressed'),
|
|
33
|
+
maxDuration,
|
|
34
|
+
camera,
|
|
35
|
+
success(res) {
|
|
36
|
+
success?.({
|
|
37
|
+
type: 'video',
|
|
38
|
+
tempFiles: [
|
|
39
|
+
{
|
|
40
|
+
tempFilePath: res.tempFilePath,
|
|
41
|
+
size: res.size,
|
|
42
|
+
duration: res.duration,
|
|
43
|
+
height: res.height,
|
|
44
|
+
width: res.width,
|
|
45
|
+
thumbTempFilePath: '',
|
|
46
|
+
fileType: 'video',
|
|
47
|
+
},
|
|
48
|
+
],
|
|
49
|
+
});
|
|
50
|
+
},
|
|
51
|
+
fail,
|
|
52
|
+
complete,
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { ForwardRefExoticComponent, PropsWithoutRef, ReactNode, RefAttributes } from 'react';
|
|
2
|
+
import { ImageProps } from '@tarojs/components';
|
|
3
|
+
import { UploadPreview, UploadFileItem, UploadFile } from './Preview';
|
|
4
|
+
import { BaseProps } from '../base';
|
|
5
|
+
export * from './Preview';
|
|
6
|
+
export interface UploadProps extends Omit<BaseProps, 'children'> {
|
|
7
|
+
accept?: 'image' | 'video';
|
|
8
|
+
multiple?: boolean;
|
|
9
|
+
sourceType?: ('album' | 'camera')[];
|
|
10
|
+
sizeType?: ('original' | 'compressed')[];
|
|
11
|
+
maxDuration?: number;
|
|
12
|
+
camera?: 'back' | 'front';
|
|
13
|
+
fileList?: UploadFileItem[];
|
|
14
|
+
defaultFileList?: UploadFileItem[];
|
|
15
|
+
onChange?: (fileItemList: UploadFileItem[]) => void;
|
|
16
|
+
maxCount?: number;
|
|
17
|
+
maxSize?: number | ((file: UploadFile) => boolean);
|
|
18
|
+
overSize?: (fileItem: UploadFileItem | UploadFileItem[]) => void;
|
|
19
|
+
select?: ReactNode;
|
|
20
|
+
disabled?: boolean;
|
|
21
|
+
readOnly?: boolean;
|
|
22
|
+
beforeRead?: (file: UploadFile) => boolean | Promise<UploadFile>;
|
|
23
|
+
afterRead?: (fileItem: UploadFileItem | UploadFileItem[]) => void;
|
|
24
|
+
removable?: boolean;
|
|
25
|
+
remove?: ReactNode;
|
|
26
|
+
beforeRemove?: (...args: unknown[]) => boolean | Promise<void>;
|
|
27
|
+
onRemove?: (index: number) => void;
|
|
28
|
+
mode?: ImageProps['mode'];
|
|
29
|
+
}
|
|
30
|
+
export interface UploadRef {
|
|
31
|
+
select: () => void;
|
|
32
|
+
}
|
|
33
|
+
export interface UploadFC extends ForwardRefExoticComponent<PropsWithoutRef<UploadProps> & RefAttributes<UploadRef>> {
|
|
34
|
+
Preview: typeof UploadPreview;
|
|
35
|
+
}
|
|
36
|
+
export declare const Upload: UploadFC;
|
|
37
|
+
export default Upload;
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { createElement as _createElement } from "react";
|
|
3
|
+
import { forwardRef, useImperativeHandle, } from 'react';
|
|
4
|
+
import classNames from 'classnames';
|
|
5
|
+
import Taro from '@tarojs/taro';
|
|
6
|
+
import { CustomWrapper, View } from '@tarojs/components';
|
|
7
|
+
import { useBem, useControllableValue, useEvent, useSelectorId } from '../use';
|
|
8
|
+
import { getFileName, isFunction, isImageUrl, noop } from '../utils';
|
|
9
|
+
import { Icon } from '../icon';
|
|
10
|
+
import { UploadPreview } from './Preview';
|
|
11
|
+
import Pressable from '../pressable';
|
|
12
|
+
import { chooseMedia } from './chooseMedia';
|
|
13
|
+
export * from './Preview';
|
|
14
|
+
export const Upload = forwardRef((props, ref) => {
|
|
15
|
+
const { className, style, accept = 'image', multiple, sourceType = ['album', 'camera'], sizeType = ['original', 'compressed'], maxDuration = 60, camera = 'back', fileList, defaultFileList, onChange, maxCount = Number.MAX_SAFE_INTEGER, maxSize = Number.MAX_SAFE_INTEGER, overSize, select, disabled, readOnly, beforeRead, afterRead, removable = true, remove, beforeRemove, onRemove, mode = 'aspectFill', ...restProps } = props;
|
|
16
|
+
const [bem] = useBem('upload');
|
|
17
|
+
const contextId = useSelectorId();
|
|
18
|
+
const [innerPreviewList, setInnerPreviewList] = useControllableValue({
|
|
19
|
+
value: fileList,
|
|
20
|
+
defaultValue: defaultFileList,
|
|
21
|
+
trigger: onChange,
|
|
22
|
+
initialValue: () => [],
|
|
23
|
+
});
|
|
24
|
+
const limitCountNode = (files, next) => {
|
|
25
|
+
const remainCount = maxCount - innerPreviewList.length;
|
|
26
|
+
if (files.length > remainCount) {
|
|
27
|
+
files = files.slice(0, remainCount);
|
|
28
|
+
}
|
|
29
|
+
next(files);
|
|
30
|
+
};
|
|
31
|
+
const beforeReadNode = (files, next) => {
|
|
32
|
+
Promise.allSettled(files.map((file) => new Promise((resolve, reject) => {
|
|
33
|
+
if (beforeRead) {
|
|
34
|
+
const ret = beforeRead(file);
|
|
35
|
+
if (!ret) {
|
|
36
|
+
reject();
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
if (ret instanceof Promise) {
|
|
40
|
+
ret
|
|
41
|
+
.then((mayNewFile) => {
|
|
42
|
+
resolve(mayNewFile ?? file);
|
|
43
|
+
})
|
|
44
|
+
.catch(() => {
|
|
45
|
+
reject();
|
|
46
|
+
});
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
resolve(file);
|
|
51
|
+
}))).then((results) => {
|
|
52
|
+
const fileList = results
|
|
53
|
+
.filter((result) => result.status === 'fulfilled')
|
|
54
|
+
.map((result) => result.value);
|
|
55
|
+
next(fileList);
|
|
56
|
+
});
|
|
57
|
+
};
|
|
58
|
+
const toUploadFileNode = (files, next) => {
|
|
59
|
+
const fileList = files.map((file) => {
|
|
60
|
+
return {
|
|
61
|
+
file,
|
|
62
|
+
name: file.path && getFileName(file.path),
|
|
63
|
+
};
|
|
64
|
+
});
|
|
65
|
+
next(fileList);
|
|
66
|
+
};
|
|
67
|
+
const limitSizeNode = (fileList, next) => {
|
|
68
|
+
const valid = [];
|
|
69
|
+
const invalid = [];
|
|
70
|
+
fileList.forEach((item) => {
|
|
71
|
+
const file = item.file;
|
|
72
|
+
const isFunc = isFunction(maxSize);
|
|
73
|
+
if ((isFunc && file && maxSize(file)) ||
|
|
74
|
+
(!isFunc && file && file.size && file.size > maxSize)) {
|
|
75
|
+
invalid.push(item);
|
|
76
|
+
}
|
|
77
|
+
else {
|
|
78
|
+
valid.push(item);
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
if (invalid.length) {
|
|
82
|
+
if (multiple) {
|
|
83
|
+
overSize?.(invalid);
|
|
84
|
+
}
|
|
85
|
+
else {
|
|
86
|
+
overSize?.(invalid[0]);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
if (valid.length) {
|
|
90
|
+
setInnerPreviewList([...innerPreviewList, ...valid]);
|
|
91
|
+
next(valid);
|
|
92
|
+
}
|
|
93
|
+
};
|
|
94
|
+
const afterReadNode = (fileList) => {
|
|
95
|
+
if (multiple) {
|
|
96
|
+
afterRead?.(fileList);
|
|
97
|
+
}
|
|
98
|
+
else {
|
|
99
|
+
afterRead?.(fileList[0]);
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
function toChain(files) {
|
|
103
|
+
const chain = [
|
|
104
|
+
limitCountNode,
|
|
105
|
+
beforeReadNode,
|
|
106
|
+
toUploadFileNode,
|
|
107
|
+
limitSizeNode,
|
|
108
|
+
afterReadNode,
|
|
109
|
+
].reduceRight((next, node) => (data) => {
|
|
110
|
+
node(data, next);
|
|
111
|
+
}, () => {
|
|
112
|
+
null;
|
|
113
|
+
});
|
|
114
|
+
chain(files);
|
|
115
|
+
}
|
|
116
|
+
const handleSelect = useEvent(() => {
|
|
117
|
+
if (disabled || readOnly || innerPreviewList.length >= maxCount) {
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
chooseMedia({
|
|
121
|
+
mediaType: accept,
|
|
122
|
+
count: multiple ? 9999 : 1,
|
|
123
|
+
sizeType,
|
|
124
|
+
sourceType,
|
|
125
|
+
maxDuration,
|
|
126
|
+
camera,
|
|
127
|
+
success(result) {
|
|
128
|
+
toChain(result.tempFiles.map((file) => {
|
|
129
|
+
return {
|
|
130
|
+
type: file.fileType,
|
|
131
|
+
size: file.size,
|
|
132
|
+
path: file.tempFilePath,
|
|
133
|
+
duration: file.duration,
|
|
134
|
+
width: file.width,
|
|
135
|
+
height: file.height,
|
|
136
|
+
originalFileObj: null,
|
|
137
|
+
};
|
|
138
|
+
}));
|
|
139
|
+
},
|
|
140
|
+
fail: noop,
|
|
141
|
+
}).catch(noop);
|
|
142
|
+
});
|
|
143
|
+
const handleRemove = useEvent((index, item) => {
|
|
144
|
+
const list = innerPreviewList.filter((_, i) => i !== index);
|
|
145
|
+
setInnerPreviewList(list);
|
|
146
|
+
item.onRemove?.(index);
|
|
147
|
+
onRemove?.(index);
|
|
148
|
+
});
|
|
149
|
+
const handleImageClick = useEvent((index) => {
|
|
150
|
+
const currentFileItem = innerPreviewList[index];
|
|
151
|
+
const fileList = innerPreviewList.filter((item) => (item.url && isImageUrl(item.url)) || item.file?.type === 'image');
|
|
152
|
+
const currentIndex = fileList.findIndex((item) => item === currentFileItem);
|
|
153
|
+
const urls = fileList.map((item) => (item.url || item.file?.path));
|
|
154
|
+
Taro.previewImage({
|
|
155
|
+
urls,
|
|
156
|
+
current: urls[currentIndex],
|
|
157
|
+
});
|
|
158
|
+
});
|
|
159
|
+
useImperativeHandle(ref, () => ({
|
|
160
|
+
select: handleSelect,
|
|
161
|
+
}), []);
|
|
162
|
+
return (_jsx(CustomWrapper, { id: contextId, children: _jsx(View, { ...restProps, className: classNames(bem.b(), bem.m('disabled', disabled), bem.m('readonly', readOnly), className), style: style, children: _jsxs(View, { className: bem.e('wrapper'), children: [innerPreviewList.map((item, index) => {
|
|
163
|
+
return (_createElement(UploadPreview, { ...item, key: index, index: index, disabled: disabled, readOnly: readOnly, removable: item.removable ?? removable, remove: item.remove ?? remove, beforeRemove: item.beforeRemove ?? beforeRemove, onRemove: (index) => handleRemove(index, item), onImageClick: handleImageClick, mode: mode, contextId: contextId }));
|
|
164
|
+
}), !disabled && !readOnly && innerPreviewList.length < maxCount && (_jsx(Pressable, { disabled: disabled || readOnly, children: ({ pressed }) => (_jsx(View, { className: classNames(bem.e('select'), bem.em('select', 'pressed', pressed)), onClick: handleSelect, children: select ?? (_jsx(Icon, { name: "plus", className: bem.e('select-icon') })) })) }))] }) }) }));
|
|
165
|
+
});
|
|
166
|
+
Upload.Preview = UploadPreview;
|
|
167
|
+
export default Upload;
|