@cloudbase/weda-ui 3.2.0 → 3.2.1
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/cypress/support/commands.d.ts +1 -0
- package/dist/cypress/support/commands.js +40 -0
- package/dist/cypress/support/e2e.d.ts +24 -0
- package/dist/cypress/support/e2e.js +22 -0
- package/dist/src/configs/actions/showModal.json +48 -0
- package/dist/src/configs/actions/showToast.json +41 -0
- package/dist/src/configs/components/auth.json +16 -0
- package/dist/src/configs/components/button.json +239 -0
- package/dist/src/configs/components/calendar.json +81 -0
- package/dist/src/configs/components/carousel.json +292 -0
- package/dist/src/configs/components/chart/bar.json +954 -0
- package/dist/src/configs/components/chart/line.json +870 -0
- package/dist/src/configs/components/chart/pie.json +677 -0
- package/dist/src/configs/components/chart/statisticsCard.json +376 -0
- package/dist/src/configs/components/container.json +50 -0
- package/dist/src/configs/components/dataView.json +247 -0
- package/dist/src/configs/components/drawer.json +115 -0
- package/dist/src/configs/components/form/checkbox.json +179 -0
- package/dist/src/configs/components/form/departTreeSelect.json +124 -0
- package/dist/src/configs/components/form/form.json +73 -0
- package/dist/src/configs/components/form/input.json +154 -0
- package/dist/src/configs/components/form/location.json +216 -0
- package/dist/src/configs/components/form/radio.json +203 -0
- package/dist/src/configs/components/form/richText.json +133 -0
- package/dist/src/configs/components/form/select.json +449 -0
- package/dist/src/configs/components/form/switch.json +58 -0
- package/dist/src/configs/components/form/textarea.json +116 -0
- package/dist/src/configs/components/form/tips.json +34 -0
- package/dist/src/configs/components/form/uploader.json +171 -0
- package/dist/src/configs/components/form/uploaderFile.json +158 -0
- package/dist/src/configs/components/form/userTreeSelect.json +128 -0
- package/dist/src/configs/components/formdetail.json +105 -0
- package/dist/src/configs/components/graphicCard.json +413 -0
- package/dist/src/configs/components/image.json +187 -0
- package/dist/src/configs/components/link.json +79 -0
- package/dist/src/configs/components/listView.json +378 -0
- package/dist/src/configs/components/lottery.json +163 -0
- package/dist/src/configs/components/modal.json +72 -0
- package/dist/src/configs/components/navLayout.json +368 -0
- package/dist/src/configs/components/navigationBar.json +62 -0
- package/dist/src/configs/components/richtextview.json +26 -0
- package/dist/src/configs/components/scrollVeiw.json +253 -0
- package/dist/src/configs/components/slot.json +17 -0
- package/dist/src/configs/components/swiper.json +90 -0
- package/dist/src/configs/components/tabs.json +122 -0
- package/dist/src/configs/components/text.json +95 -0
- package/dist/src/configs/components/wedaVideo.json +89 -0
- package/dist/src/configs/components/wxOpenApi/phone.json +127 -0
- package/dist/src/configs/components/wxOpenApi/phoneCode.json +109 -0
- package/dist/src/configs/components/wxOpenApi/share.json +160 -0
- package/dist/src/configs/components/wxOpenApi/userInfo.json +156 -0
- package/dist/src/configs/index.d.ts +103 -0
- package/dist/src/configs/index.js +111 -0
- package/dist/src/docs/common/format.d.ts +13 -0
- package/dist/src/docs/common/format.js +122 -0
- package/dist/src/docs/common/tableView.d.ts +30 -0
- package/dist/src/docs/common/tableView.js +156 -0
- package/dist/src/index.d.ts +2 -0
- package/dist/src/index.js +3 -0
- package/dist/src/setupTests.d.ts +2 -0
- package/dist/src/setupTests.js +19 -0
- package/dist/src/web/actions/index.d.ts +2 -0
- package/dist/src/web/actions/index.js +2 -0
- package/dist/src/web/actions/showModal/index.d.ts +4 -0
- package/dist/src/web/actions/showModal/index.js +67 -0
- package/dist/src/web/actions/showToast/index.d.ts +1 -0
- package/dist/src/web/actions/showToast/index.js +3 -0
- package/dist/src/web/components/button/index.d.ts +32 -0
- package/dist/src/web/components/button/index.js +48 -0
- package/dist/src/web/components/calendar/index.d.ts +19 -0
- package/dist/src/web/components/calendar/index.js +189 -0
- package/dist/src/web/components/calendar/util.d.ts +13 -0
- package/dist/src/web/components/calendar/util.js +74 -0
- package/dist/src/web/components/carousel/index.d.ts +41 -0
- package/dist/src/web/components/carousel/index.js +244 -0
- package/dist/src/web/components/chart/bar/index.d.ts +3 -0
- package/dist/src/web/components/chart/bar/index.js +41 -0
- package/dist/src/web/components/chart/bar/index.old.d.ts +40 -0
- package/dist/src/web/components/chart/bar/index.old.js +56 -0
- package/dist/src/web/components/chart/common/Chart.d.ts +9 -0
- package/dist/src/web/components/chart/common/Chart.js +23 -0
- package/dist/src/web/components/chart/common/chart-custom-connector.d.ts +6 -0
- package/dist/src/web/components/chart/common/chart-custom-connector.js +35 -0
- package/dist/src/web/components/chart/common/chart-error.d.ts +2 -0
- package/dist/src/web/components/chart/common/chart-error.js +2 -0
- package/dist/src/web/components/chart/common/config/bar.d.ts +48 -0
- package/dist/src/web/components/chart/common/config/bar.js +49 -0
- package/dist/src/web/components/chart/common/config/global.d.ts +13 -0
- package/dist/src/web/components/chart/common/config/global.js +16 -0
- package/dist/src/web/components/chart/common/config/line.d.ts +46 -0
- package/dist/src/web/components/chart/common/config/line.js +49 -0
- package/dist/src/web/components/chart/common/config/pie.d.ts +29 -0
- package/dist/src/web/components/chart/common/config/pie.js +36 -0
- package/dist/src/web/components/chart/common/core/eChartBar.d.ts +66 -0
- package/dist/src/web/components/chart/common/core/eChartBar.js +201 -0
- package/dist/src/web/components/chart/common/core/eChartBase.d.ts +127 -0
- package/dist/src/web/components/chart/common/core/eChartBase.js +394 -0
- package/dist/src/web/components/chart/common/core/eChartLine.d.ts +60 -0
- package/dist/src/web/components/chart/common/core/eChartLine.js +173 -0
- package/dist/src/web/components/chart/common/core/eChartPie.d.ts +48 -0
- package/dist/src/web/components/chart/common/core/eChartPie.js +135 -0
- package/dist/src/web/components/chart/common/core/type.d.ts +35 -0
- package/dist/src/web/components/chart/common/core/type.js +9 -0
- package/dist/src/web/components/chart/common/data-transform.d.ts +6 -0
- package/dist/src/web/components/chart/common/data-transform.js +246 -0
- package/dist/src/web/components/chart/common/echarts.d.ts +5 -0
- package/dist/src/web/components/chart/common/echarts.js +24 -0
- package/dist/src/web/components/chart/common/error-boundary.d.ts +5 -0
- package/dist/src/web/components/chart/common/error-boundary.js +26 -0
- package/dist/src/web/components/chart/common/useChart.d.ts +8 -0
- package/dist/src/web/components/chart/common/useChart.js +61 -0
- package/dist/src/web/components/chart/line/index.d.ts +3 -0
- package/dist/src/web/components/chart/line/index.js +42 -0
- package/dist/src/web/components/chart/line/index.old.d.ts +38 -0
- package/dist/src/web/components/chart/line/index.old.js +53 -0
- package/dist/src/web/components/chart/pie/index.d.ts +3 -0
- package/dist/src/web/components/chart/pie/index.js +42 -0
- package/dist/src/web/components/chart/pie/index.old.d.ts +27 -0
- package/dist/src/web/components/chart/pie/index.old.js +40 -0
- package/dist/src/web/components/chart/statisticsCard/index.d.ts +85 -0
- package/dist/src/web/components/chart/statisticsCard/index.js +203 -0
- package/dist/src/web/components/chart/statisticsCard/interface.d.ts +13 -0
- package/dist/src/web/components/chart/statisticsCard/interface.js +1 -0
- package/dist/src/web/components/common/portal.d.ts +7 -0
- package/dist/src/web/components/common/portal.js +14 -0
- package/dist/src/web/components/container/index.d.ts +6 -0
- package/dist/src/web/components/container/index.js +6 -0
- package/dist/src/web/components/dataView/index.d.ts +6 -0
- package/dist/src/web/components/dataView/index.js +8 -0
- package/dist/src/web/components/dataView/interface.d.ts +5 -0
- package/dist/src/web/components/dataView/interface.js +1 -0
- package/dist/src/web/components/drawer/index.d.ts +13 -0
- package/dist/src/web/components/drawer/index.js +12 -0
- package/dist/src/web/components/form/checkbox/index.d.ts +13 -0
- package/dist/src/web/components/form/checkbox/index.js +167 -0
- package/dist/src/web/components/form/enumSelect/MultipleSelect.d.ts +78 -0
- package/dist/src/web/components/form/enumSelect/MultipleSelect.js +52 -0
- package/dist/src/web/components/form/enumSelect/NormalSelect.d.ts +83 -0
- package/dist/src/web/components/form/enumSelect/NormalSelect.js +52 -0
- package/dist/src/web/components/form/enumSelect/SelectContainer.d.ts +16 -0
- package/dist/src/web/components/form/enumSelect/SelectContainer.js +30 -0
- package/dist/src/web/components/form/enumSelect/index.d.ts +82 -0
- package/dist/src/web/components/form/enumSelect/index.js +6 -0
- package/dist/src/web/components/form/enumSelect/props/defaultProps.d.ts +34 -0
- package/dist/src/web/components/form/enumSelect/props/defaultProps.js +40 -0
- package/dist/src/web/components/form/enumSelect/props/propsTypes.d.ts +39 -0
- package/dist/src/web/components/form/enumSelect/props/propsTypes.js +47 -0
- package/dist/src/web/components/form/form/index.d.ts +32 -0
- package/dist/src/web/components/form/form/index.js +141 -0
- package/dist/src/web/components/form/formcell/index.d.ts +8 -0
- package/dist/src/web/components/form/formcell/index.js +40 -0
- package/dist/src/web/components/form/input/index.d.ts +14 -0
- package/dist/src/web/components/form/input/index.js +86 -0
- package/dist/src/web/components/form/location/common/mapChoose.d.ts +15 -0
- package/dist/src/web/components/form/location/common/mapChoose.js +495 -0
- package/dist/src/web/components/form/location/common/mapView.d.ts +19 -0
- package/dist/src/web/components/form/location/common/mapView.js +172 -0
- package/dist/src/web/components/form/location/common/propsConfig.d.ts +59 -0
- package/dist/src/web/components/form/location/common/propsConfig.js +50 -0
- package/dist/src/web/components/form/location/common/selectModal.d.ts +21 -0
- package/dist/src/web/components/form/location/common/selectModal.js +44 -0
- package/dist/src/web/components/form/location/common/useLocationInfo.d.ts +36 -0
- package/dist/src/web/components/form/location/common/useLocationInfo.js +104 -0
- package/dist/src/web/components/form/location/components/LocationH5/location.h5.d.ts +8 -0
- package/dist/src/web/components/form/location/components/LocationH5/location.h5.js +325 -0
- package/dist/src/web/components/form/location/components/LocationPC/Header.d.ts +12 -0
- package/dist/src/web/components/form/location/components/LocationPC/Header.js +43 -0
- package/dist/src/web/components/form/location/components/LocationPC/location.PC.d.ts +8 -0
- package/dist/src/web/components/form/location/components/LocationPC/location.PC.js +224 -0
- package/dist/src/web/components/form/location/constants.d.ts +2 -0
- package/dist/src/web/components/form/location/constants.js +3 -0
- package/dist/src/web/components/form/location/index.d.ts +1 -0
- package/dist/src/web/components/form/location/index.js +17 -0
- package/dist/src/web/components/form/radio/index.d.ts +11 -0
- package/dist/src/web/components/form/radio/index.js +115 -0
- package/dist/src/web/components/form/renderDecorator.d.ts +6 -0
- package/dist/src/web/components/form/renderDecorator.js +20 -0
- package/dist/src/web/components/form/select/allTimePicker/calendar.d.ts +13 -0
- package/dist/src/web/components/form/select/allTimePicker/calendar.js +104 -0
- package/dist/src/web/components/form/select/allTimePicker/dataUtils.d.ts +24 -0
- package/dist/src/web/components/form/select/allTimePicker/dataUtils.js +265 -0
- package/dist/src/web/components/form/select/allTimePicker/index.d.ts +14 -0
- package/dist/src/web/components/form/select/allTimePicker/index.js +943 -0
- package/dist/src/web/components/form/select/dropdown-select/ui.d.ts +15 -0
- package/dist/src/web/components/form/select/dropdown-select/ui.js +55 -0
- package/dist/src/web/components/form/select/h5.d.ts +16 -0
- package/dist/src/web/components/form/select/h5.js +452 -0
- package/dist/src/web/components/form/select/index.d.ts +66 -0
- package/dist/src/web/components/form/select/index.js +241 -0
- package/dist/src/web/components/form/select/region/index.d.ts +6 -0
- package/dist/src/web/components/form/select/region/index.js +147 -0
- package/dist/src/web/components/form/select/time.d.ts +9 -0
- package/dist/src/web/components/form/select/time.js +146 -0
- package/dist/src/web/components/form/select/use-options.d.ts +26 -0
- package/dist/src/web/components/form/select/use-options.js +103 -0
- package/dist/src/web/components/form/select/year.d.ts +7 -0
- package/dist/src/web/components/form/select/year.js +72 -0
- package/dist/src/web/components/form/switch/index.d.ts +6 -0
- package/dist/src/web/components/form/switch/index.js +58 -0
- package/dist/src/web/components/form/textarea/index.d.ts +12 -0
- package/dist/src/web/components/form/textarea/index.js +66 -0
- package/dist/src/web/components/form/tips/index.d.ts +8 -0
- package/dist/src/web/components/form/tips/index.js +17 -0
- package/dist/src/web/components/form/uploader/index.d.ts +3 -0
- package/dist/src/web/components/form/uploader/index.js +42 -0
- package/dist/src/web/components/form/uploader/uploader.h5.d.ts +20 -0
- package/dist/src/web/components/form/uploader/uploader.h5.js +199 -0
- package/dist/src/web/components/form/uploader/uploader.pc.d.ts +29 -0
- package/dist/src/web/components/form/uploader/uploader.pc.js +208 -0
- package/dist/src/web/components/form/uploaderFile/index.d.ts +4 -0
- package/dist/src/web/components/form/uploaderFile/index.js +19 -0
- package/dist/src/web/components/form/uploaderFile/uploadFile.h5.d.ts +23 -0
- package/dist/src/web/components/form/uploaderFile/uploadFile.h5.js +328 -0
- package/dist/src/web/components/form/uploaderFile/uploadFile.pc.d.ts +24 -0
- package/dist/src/web/components/form/uploaderFile/uploadFile.pc.js +299 -0
- package/dist/src/web/components/form/userOrgSelect/comTool.d.ts +8 -0
- package/dist/src/web/components/form/userOrgSelect/comTool.js +107 -0
- package/dist/src/web/components/form/userOrgSelect/departTreeSelect/departTreeSelect.h5.d.ts +19 -0
- package/dist/src/web/components/form/userOrgSelect/departTreeSelect/departTreeSelect.h5.js +247 -0
- package/dist/src/web/components/form/userOrgSelect/departTreeSelect/departTreeSelect.pc.d.ts +4 -0
- package/dist/src/web/components/form/userOrgSelect/departTreeSelect/departTreeSelect.pc.js +158 -0
- package/dist/src/web/components/form/userOrgSelect/departTreeSelect/index.d.ts +2 -0
- package/dist/src/web/components/form/userOrgSelect/departTreeSelect/index.js +17 -0
- package/dist/src/web/components/form/userOrgSelect/index.d.ts +2 -0
- package/dist/src/web/components/form/userOrgSelect/index.js +17 -0
- package/dist/src/web/components/form/userOrgSelect/userTreeSelect.h5.d.ts +26 -0
- package/dist/src/web/components/form/userOrgSelect/userTreeSelect.h5.js +258 -0
- package/dist/src/web/components/form/userOrgSelect/userTreeSelect.pc.d.ts +9 -0
- package/dist/src/web/components/form/userOrgSelect/userTreeSelect.pc.js +271 -0
- package/dist/src/web/components/form/userOrgSelect/utils.d.ts +35 -0
- package/dist/src/web/components/form/userOrgSelect/utils.js +72 -0
- package/dist/src/web/components/formdetail/index.d.ts +28 -0
- package/dist/src/web/components/formdetail/index.js +170 -0
- package/dist/src/web/components/graphicCard/index.d.ts +46 -0
- package/dist/src/web/components/graphicCard/index.js +179 -0
- package/dist/src/web/components/image/image.d.ts +9 -0
- package/dist/src/web/components/image/image.js +119 -0
- package/dist/src/web/components/image/index.d.ts +13 -0
- package/dist/src/web/components/image/index.js +77 -0
- package/dist/src/web/components/index.d.ts +50 -0
- package/dist/src/web/components/index.js +99 -0
- package/dist/src/web/components/link/index.d.ts +24 -0
- package/dist/src/web/components/link/index.js +71 -0
- package/dist/src/web/components/listView/index.d.ts +7 -0
- package/dist/src/web/components/listView/index.js +296 -0
- package/dist/src/web/components/listView/interface.d.ts +127 -0
- package/dist/src/web/components/listView/interface.js +1 -0
- package/dist/src/web/components/lottery/index.d.ts +22 -0
- package/dist/src/web/components/lottery/index.js +391 -0
- package/dist/src/web/components/lottery/lotteryUtil.d.ts +23 -0
- package/dist/src/web/components/lottery/lotteryUtil.js +181 -0
- package/dist/src/web/components/modal/index.d.ts +17 -0
- package/dist/src/web/components/modal/index.js +11 -0
- package/dist/src/web/components/modal/modal.h5.d.ts +4 -0
- package/dist/src/web/components/modal/modal.h5.js +46 -0
- package/dist/src/web/components/modal/modal.pc.d.ts +3 -0
- package/dist/src/web/components/modal/modal.pc.js +31 -0
- package/dist/src/web/components/navLayout/index.d.ts +61 -0
- package/dist/src/web/components/navLayout/index.js +127 -0
- package/dist/src/web/components/navigationBar/common.d.ts +15 -0
- package/dist/src/web/components/navigationBar/common.js +127 -0
- package/dist/src/web/components/navigationBar/h5Menu.d.ts +14 -0
- package/dist/src/web/components/navigationBar/h5Menu.js +72 -0
- package/dist/src/web/components/navigationBar/horizontalMenu.d.ts +12 -0
- package/dist/src/web/components/navigationBar/horizontalMenu.js +99 -0
- package/dist/src/web/components/navigationBar/index.d.ts +13 -0
- package/dist/src/web/components/navigationBar/index.js +157 -0
- package/dist/src/web/components/navigationBar/verticalMenu.d.ts +13 -0
- package/dist/src/web/components/navigationBar/verticalMenu.js +38 -0
- package/dist/src/web/components/phone/index.d.ts +18 -0
- package/dist/src/web/components/phone/index.js +4 -0
- package/dist/src/web/components/phoneCode/index.d.ts +18 -0
- package/dist/src/web/components/phoneCode/index.js +4 -0
- package/dist/src/web/components/picker/datePicker.d.ts +10 -0
- package/dist/src/web/components/picker/datePicker.js +31 -0
- package/dist/src/web/components/picker/picker.d.ts +6 -0
- package/dist/src/web/components/picker/picker.js +45 -0
- package/dist/src/web/components/picker/timePicker.d.ts +7 -0
- package/dist/src/web/components/picker/timePicker.js +42 -0
- package/dist/src/web/components/richText/const.d.ts +1 -0
- package/dist/src/web/components/richText/const.js +2 -0
- package/dist/src/web/components/richText/index.d.ts +50 -0
- package/dist/src/web/components/richText/index.js +352 -0
- package/dist/src/web/components/richTextView/index.d.ts +7 -0
- package/dist/src/web/components/richTextView/index.js +44 -0
- package/dist/src/web/components/scrollView/index.d.ts +27 -0
- package/dist/src/web/components/scrollView/index.js +95 -0
- package/dist/src/web/components/share/index.d.ts +34 -0
- package/dist/src/web/components/share/index.js +4 -0
- package/dist/src/web/components/slot/index.d.ts +6 -0
- package/dist/src/web/components/slot/index.js +9 -0
- package/dist/src/web/components/swiper/index.d.ts +24 -0
- package/dist/src/web/components/swiper/index.js +153 -0
- package/dist/src/web/components/tabs/index.d.ts +13 -0
- package/dist/src/web/components/tabs/index.js +15 -0
- package/dist/src/web/components/tabs/tabs.h5.d.ts +4 -0
- package/dist/src/web/components/tabs/tabs.h5.js +42 -0
- package/dist/src/web/components/tabs/tabs.pc.d.ts +3 -0
- package/dist/src/web/components/tabs/tabs.pc.js +40 -0
- package/dist/src/web/components/text/index.d.ts +14 -0
- package/dist/src/web/components/text/index.js +17 -0
- package/dist/src/web/components/uploaderFileView/index.d.ts +10 -0
- package/dist/src/web/components/uploaderFileView/index.js +46 -0
- package/dist/src/web/components/uploaderView/index.d.ts +17 -0
- package/dist/src/web/components/uploaderView/index.js +48 -0
- package/dist/src/web/components/userInfo/index.d.ts +26 -0
- package/dist/src/web/components/userInfo/index.js +4 -0
- package/dist/src/web/components/wedaVideo/index.d.ts +17 -0
- package/dist/src/web/components/wedaVideo/index.js +144 -0
- package/dist/src/web/index.d.ts +8 -0
- package/dist/src/web/index.js +4 -0
- package/dist/src/web/utils/classnames.d.ts +2 -0
- package/dist/src/web/utils/classnames.js +37 -0
- package/dist/src/web/utils/constant.d.ts +23 -0
- package/dist/src/web/utils/constant.js +24 -0
- package/dist/src/web/utils/debounce.d.ts +2 -0
- package/dist/src/web/utils/debounce.js +92 -0
- package/dist/src/web/utils/getLocalCounter.d.ts +1 -0
- package/dist/src/web/utils/getLocalCounter.js +4 -0
- package/dist/src/web/utils/getUserService.d.ts +11 -0
- package/dist/src/web/utils/getUserService.js +156 -0
- package/dist/src/web/utils/isObjectEqual.d.ts +2 -0
- package/dist/src/web/utils/isObjectEqual.js +12 -0
- package/dist/src/web/utils/loading-fallback.d.ts +2 -0
- package/dist/src/web/utils/loading-fallback.js +2 -0
- package/dist/src/web/utils/lodash.d.ts +1 -0
- package/dist/src/web/utils/lodash.js +2 -0
- package/dist/src/web/utils/platform.d.ts +18 -0
- package/dist/src/web/utils/platform.js +193 -0
- package/dist/src/web/utils/tcb.d.ts +33 -0
- package/dist/src/web/utils/tcb.js +118 -0
- package/dist/src/web/utils/tmap.d.ts +3 -0
- package/dist/src/web/utils/tmap.js +21 -0
- package/dist/src/web/utils/use-cloud-id-temp-url.d.ts +1 -0
- package/dist/src/web/utils/use-cloud-id-temp-url.js +15 -0
- package/dist/src/web/utils/useSetState.d.ts +1 -0
- package/dist/src/web/utils/useSetState.js +8 -0
- package/dist/src/web/utils/useSyncValue.d.ts +4 -0
- package/dist/src/web/utils/useSyncValue.js +15 -0
- package/dist/src/web/utils/weui.d.ts +1 -0
- package/dist/src/web/utils/weui.js +2 -0
- package/dist/web/components/form/select/allTimePicker/calendar.css +114 -0
- package/dist/web/components/form/select/allTimePicker/index.css +136 -0
- package/dist/web/components/form/userOrgSelect/userOrgSelect.css +805 -0
- package/package.json +15 -2
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { Upload, Button, Icon, message, ErrorTip, ImagePreview, ConfigProvider, } from 'tea-component';
|
|
3
|
+
import classNames from '../../../utils/classnames';
|
|
4
|
+
import { getCloudInstance } from '../../../utils/tcb';
|
|
5
|
+
import { randomStr } from '../../../utils/platform';
|
|
6
|
+
import isObjectEqual from '../../../utils/isObjectEqual';
|
|
7
|
+
import { emptyObject } from '../../../utils/constant';
|
|
8
|
+
import { useTempUrl } from '../../../utils/use-cloud-id-temp-url';
|
|
9
|
+
// 默认组件类前缀
|
|
10
|
+
export const CLASS_PREFIX = 'weda-uploader-pc';
|
|
11
|
+
// 默认图片类型
|
|
12
|
+
export const IMAGE_TYPES = [
|
|
13
|
+
'image/jpg',
|
|
14
|
+
'image/png',
|
|
15
|
+
'image/tif',
|
|
16
|
+
'image/bmp',
|
|
17
|
+
'image/jpeg',
|
|
18
|
+
'image/tiff',
|
|
19
|
+
'image/gif',
|
|
20
|
+
];
|
|
21
|
+
/**
|
|
22
|
+
* 上传图片-官方组件
|
|
23
|
+
*/
|
|
24
|
+
// eslint-disable-next-line react/prop-types
|
|
25
|
+
export function UploaderPC({ layout, className, id, style, title, tips, ...props }) {
|
|
26
|
+
const cls = classNames({
|
|
27
|
+
'weda-ui': true,
|
|
28
|
+
[CLASS_PREFIX]: true,
|
|
29
|
+
[layout]: layout,
|
|
30
|
+
[className]: className,
|
|
31
|
+
});
|
|
32
|
+
return (React.createElement("div", { className: cls, id: id, style: style },
|
|
33
|
+
React.createElement("div", { className: `${CLASS_PREFIX}__header` },
|
|
34
|
+
title && React.createElement("div", { className: `${CLASS_PREFIX}__title` }, title),
|
|
35
|
+
tips && (React.createElement("div", { className: `${CLASS_PREFIX}__description` }, tips || ''))),
|
|
36
|
+
React.createElement(UploaderPCInner, { ...props })));
|
|
37
|
+
}
|
|
38
|
+
export function UploaderPCInner(props) {
|
|
39
|
+
const { tips = '', btnTitle = '上传图片', maxUploadCount = 9, maxSize = 10, value: defaultValue, // 需要兼容 cloud:和https: 协议,需要兼容 字符串和字符串数组
|
|
40
|
+
acceptTypes = IMAGE_TYPES, uploadPath = 'weda-uploader', events = emptyObject, single = false, disabled = false, onChange, } = props;
|
|
41
|
+
// 上传中
|
|
42
|
+
const [uploading, setUploading] = React.useState(false);
|
|
43
|
+
//上传进度
|
|
44
|
+
const [progress, setProgress] = React.useState(0);
|
|
45
|
+
// 文件列表
|
|
46
|
+
const [fileIDList, setfileIDList] = React.useState([]);
|
|
47
|
+
const fileRef = React.useRef([]);
|
|
48
|
+
React.useEffect(() => {
|
|
49
|
+
let initialValue = []
|
|
50
|
+
.concat(defaultValue)
|
|
51
|
+
.filter((d) => typeof d === 'string' && d !== '');
|
|
52
|
+
if (single) {
|
|
53
|
+
initialValue = initialValue[0] ? [initialValue[0]] : [];
|
|
54
|
+
}
|
|
55
|
+
setfileIDList(initialValue);
|
|
56
|
+
}, [defaultValue]);
|
|
57
|
+
// 值变化事件
|
|
58
|
+
React.useEffect(() => {
|
|
59
|
+
if (!isObjectEqual(fileRef.current, fileIDList)) {
|
|
60
|
+
if (single) {
|
|
61
|
+
const file = fileIDList[0] || '';
|
|
62
|
+
onChange && onChange(file);
|
|
63
|
+
events.change && events.change({ value: file });
|
|
64
|
+
}
|
|
65
|
+
else {
|
|
66
|
+
onChange && onChange(fileIDList);
|
|
67
|
+
events.change && events.change({ value: fileIDList });
|
|
68
|
+
}
|
|
69
|
+
fileRef.current = fileIDList;
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
//验证上传文件类型是否合法
|
|
73
|
+
const islegalType = (files, accepts) => {
|
|
74
|
+
const illegalType = [];
|
|
75
|
+
let isImage = true;
|
|
76
|
+
for (const file of files) {
|
|
77
|
+
if ((file === null || file === void 0 ? void 0 : file.type.split('/')[0]) !== 'image') {
|
|
78
|
+
message.error({ content: '请上传图片' });
|
|
79
|
+
isImage = false;
|
|
80
|
+
break;
|
|
81
|
+
}
|
|
82
|
+
accepts.some((item) => item === (file === null || file === void 0 ? void 0 : file.type))
|
|
83
|
+
? null
|
|
84
|
+
: illegalType.push(file === null || file === void 0 ? void 0 : file.type);
|
|
85
|
+
}
|
|
86
|
+
if (!isImage)
|
|
87
|
+
return false;
|
|
88
|
+
if (illegalType.length > 0) {
|
|
89
|
+
message.error({
|
|
90
|
+
content: '不支持上传' +
|
|
91
|
+
Array.from(new Set(illegalType)).join(',') +
|
|
92
|
+
'格式图片',
|
|
93
|
+
});
|
|
94
|
+
return false;
|
|
95
|
+
}
|
|
96
|
+
return true;
|
|
97
|
+
};
|
|
98
|
+
// 方法:上传前,判断图片大小、数量是否满足,取消默认组件的上传事件,用自定义的 tcb 上传方法
|
|
99
|
+
const beforeHandle = (file, fileList, isAccepted, error) => {
|
|
100
|
+
if (!islegalType(fileList, extraProps['accept']))
|
|
101
|
+
return;
|
|
102
|
+
if (!isAccepted) {
|
|
103
|
+
try {
|
|
104
|
+
const errorList = [];
|
|
105
|
+
if (error.find((item) => (item === null || item === void 0 ? void 0 : item.code) === 'file-invalid-type')) {
|
|
106
|
+
errorList.push('上传图片类型错误');
|
|
107
|
+
}
|
|
108
|
+
if (error.find((item) => (item === null || item === void 0 ? void 0 : item.code) === 'file-too-large')) {
|
|
109
|
+
errorList.push(`上传图片大小不能超过${maxSize}M`);
|
|
110
|
+
}
|
|
111
|
+
message.error({ content: errorList.join(', ') });
|
|
112
|
+
}
|
|
113
|
+
catch (e) { }
|
|
114
|
+
return false;
|
|
115
|
+
}
|
|
116
|
+
uploadTcb(file);
|
|
117
|
+
return false;
|
|
118
|
+
};
|
|
119
|
+
// 自定义上传到 Tcb 的 COS
|
|
120
|
+
const uploadTcb = (file) => {
|
|
121
|
+
setUploading(true);
|
|
122
|
+
getCloudInstance().then(async (tcb) => {
|
|
123
|
+
try {
|
|
124
|
+
const cloudPath = `${uploadPath}/${randomStr()}-${file === null || file === void 0 ? void 0 : file.name}`;
|
|
125
|
+
const { fileID } = await tcb.uploadFile({
|
|
126
|
+
cloudPath,
|
|
127
|
+
filePath: file,
|
|
128
|
+
onUploadProgress: onProgress,
|
|
129
|
+
});
|
|
130
|
+
fileID && setfileIDList((list) => [...list, fileID]);
|
|
131
|
+
fileID && events.success && events.success({ value: fileID, file });
|
|
132
|
+
}
|
|
133
|
+
catch (err) {
|
|
134
|
+
message.error({ content: '上传失败,请检查网络后重试' });
|
|
135
|
+
events.error && events.error(err);
|
|
136
|
+
}
|
|
137
|
+
finally {
|
|
138
|
+
setUploading(false);
|
|
139
|
+
setProgress(0);
|
|
140
|
+
}
|
|
141
|
+
});
|
|
142
|
+
};
|
|
143
|
+
// 计算上传进度
|
|
144
|
+
const onProgress = (progressEvent) => {
|
|
145
|
+
let percentCompleted = 0;
|
|
146
|
+
try {
|
|
147
|
+
percentCompleted = Math.round((progressEvent.loaded * 100) / progressEvent.total);
|
|
148
|
+
percentCompleted < 100 ? percentCompleted : 100;
|
|
149
|
+
}
|
|
150
|
+
catch (e) { }
|
|
151
|
+
setProgress(percentCompleted);
|
|
152
|
+
};
|
|
153
|
+
// 删除图片
|
|
154
|
+
const deleteHandle = (fileID) => {
|
|
155
|
+
setfileIDList((list) => list.filter((d) => d !== fileID));
|
|
156
|
+
};
|
|
157
|
+
// 转换后的属性
|
|
158
|
+
const extraProps = {};
|
|
159
|
+
extraProps['accept'] =
|
|
160
|
+
acceptTypes.includes('image/*') || acceptTypes.length === 0
|
|
161
|
+
? IMAGE_TYPES
|
|
162
|
+
: Array.from(new Set(acceptTypes));
|
|
163
|
+
tips && (extraProps['title'] = tips);
|
|
164
|
+
maxSize && (extraProps['maxSize'] = maxSize * 1024 * 1024);
|
|
165
|
+
return (React.createElement(ConfigProvider, { classPrefix: "wedatea2td" },
|
|
166
|
+
React.createElement("div", { className: "_weda-fn-upload-result" },
|
|
167
|
+
fileIDList.map((d) => (React.createElement("div", { className: "_weda-fn-upload-result__item", key: d },
|
|
168
|
+
React.createElement(TcbImage, { fileID: d }),
|
|
169
|
+
React.createElement("div", { className: "_weda-fn-upload-result__op" },
|
|
170
|
+
React.createElement(Button, { disabled: disabled, onClick: () => deleteHandle(d), className: `${CLASS_PREFIX}__btn` }, "\u5220\u9664"))))),
|
|
171
|
+
uploading && (React.createElement("div", { className: "_weda-fn-upload-result__item" },
|
|
172
|
+
React.createElement("div", { className: "_weda-fn-upload-result__status", key: "_place_image" },
|
|
173
|
+
React.createElement(Icon, { type: "loading" }),
|
|
174
|
+
!!progress && (React.createElement("span", { className: "wedatea2td-mt-1n wedatea2td-text-label wedatea2td-fz-reset" },
|
|
175
|
+
"\u4E0A\u4F20",
|
|
176
|
+
progress,
|
|
177
|
+
"%..."))))),
|
|
178
|
+
React.createElement("div", { className: `${CLASS_PREFIX}__input-box` }, disabled ? (React.createElement("li", { className: "_weda-fn-upload-result__item wedatea2td-disabled" },
|
|
179
|
+
React.createElement("div", { className: "_weda-fn-upload-result__status" },
|
|
180
|
+
React.createElement("i", { className: "wedatea2td-icon wedatea2td-icon-plus", role: "img", "aria-label": "plus" }),
|
|
181
|
+
React.createElement("span", { className: "wedatea2td-mt-1n wedatea2td-text-label wedatea2td-fz-reset" }, btnTitle)))) : (((!single && fileIDList.length < maxUploadCount) ||
|
|
182
|
+
(single && fileIDList.length < 1 && !uploading)) && ( // single 模式时,当数组为空且不在上传文件过程中时显示
|
|
183
|
+
React.createElement(Upload, { ...extraProps, beforeUpload: beforeHandle },
|
|
184
|
+
React.createElement("li", { className: "_weda-fn-upload-result__item _weda-fn-upload-result__item--upload" },
|
|
185
|
+
React.createElement("div", { className: "_weda-fn-upload-result__status" },
|
|
186
|
+
React.createElement("i", { className: "wedatea2td-icon wedatea2td-icon-plus", role: "img", "aria-label": "plus" }),
|
|
187
|
+
React.createElement("span", { className: "wedatea2td-mt-1n wedatea2td-text-label wedatea2td-fz-reset" }, btnTitle))))))))));
|
|
188
|
+
}
|
|
189
|
+
export const TcbImage = (props) => {
|
|
190
|
+
const { fileID, isZoom, ...rest } = props;
|
|
191
|
+
const [isError, setIsError] = React.useState(false);
|
|
192
|
+
const { data: src, error: requestError } = useTempUrl(fileID);
|
|
193
|
+
if (isError || requestError) {
|
|
194
|
+
return React.createElement(ErrorTip, null);
|
|
195
|
+
}
|
|
196
|
+
if (src) {
|
|
197
|
+
return isZoom ? (React.createElement(ImagePreview, { key: fileID, className: `${CLASS_PREFIX}__image`, ...rest, src: encodeURI(src), previewSrc: encodeURI(src),
|
|
198
|
+
/** @ts-expect-error tea imagepreview onError */
|
|
199
|
+
onError: (e) => {
|
|
200
|
+
setIsError(true);
|
|
201
|
+
(props === null || props === void 0 ? void 0 : props.onError) && props.onError(e);
|
|
202
|
+
} })) : (React.createElement("img", { key: fileID, className: `${CLASS_PREFIX}__image`, ...rest, src: encodeURI(src), onError: (e) => {
|
|
203
|
+
setIsError(true);
|
|
204
|
+
(props === null || props === void 0 ? void 0 : props.onError) && props.onError(e);
|
|
205
|
+
} }));
|
|
206
|
+
}
|
|
207
|
+
return null;
|
|
208
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/* eslint-disable react/prop-types */
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import { usePlatform } from '../../../utils/platform';
|
|
4
|
+
import { UploadFileH5 as UploaderH5 } from './uploadFile.h5';
|
|
5
|
+
import { UploadFilePc } from './uploadFile.pc';
|
|
6
|
+
import './index.css';
|
|
7
|
+
/**
|
|
8
|
+
* 文件组件上传,区分 h5端/pc端
|
|
9
|
+
*/
|
|
10
|
+
export default function UploaderFile(props) {
|
|
11
|
+
const platform = usePlatform();
|
|
12
|
+
if ((props === null || props === void 0 ? void 0 : props.showType) === 'pc') {
|
|
13
|
+
return React.createElement(UploadFilePc, { ...props });
|
|
14
|
+
}
|
|
15
|
+
if ((props === null || props === void 0 ? void 0 : props.showType) === 'h5') {
|
|
16
|
+
return React.createElement(UploaderH5, { ...props });
|
|
17
|
+
}
|
|
18
|
+
return platform === 'h5' ? (React.createElement(UploaderH5, { ...props })) : (React.createElement(UploadFilePc, { ...props }));
|
|
19
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import type { CommonFormPropsType } from '../types';
|
|
3
|
+
export declare const FILES_TYPES: string[];
|
|
4
|
+
export declare function UploadFileH5({ layout, id, style, labelVisible, label, requiredFlag, disabled, className, acceptTypes, tips, btnTitle, maxUploadCount, maxSize, deleteVisible, downloadVisible, value, // 需要兼容 cloud:和https: 协议,需要兼容字符串和字符串数组
|
|
5
|
+
events, defaultValue, uploadPath, single, onChange, isEdit, }: IUploadFileH5): JSX.Element;
|
|
6
|
+
export interface IUploadFileH5 extends CommonFormPropsType {
|
|
7
|
+
className?: string;
|
|
8
|
+
label?: string;
|
|
9
|
+
tips?: string;
|
|
10
|
+
btnTitle?: string;
|
|
11
|
+
maxUploadCount?: number;
|
|
12
|
+
deleteVisible?: boolean;
|
|
13
|
+
downloadVisible?: boolean;
|
|
14
|
+
acceptTypes?: Readonly<string[] | string>;
|
|
15
|
+
disabled?: boolean;
|
|
16
|
+
defaultValue?: string | string[];
|
|
17
|
+
maxSize?: number;
|
|
18
|
+
value?: Readonly<string | string[]>;
|
|
19
|
+
uploadPath?: string;
|
|
20
|
+
single?: boolean;
|
|
21
|
+
onChange?: (v: any) => void;
|
|
22
|
+
isEdit: boolean;
|
|
23
|
+
}
|
|
@@ -0,0 +1,328 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import weui from '../../../utils/weui';
|
|
3
|
+
import isObjectEqual from '../../../utils/isObjectEqual';
|
|
4
|
+
import { ConfigProvider, Button, Icon, Text, List, Progress, Tooltip, message, } from 'tea-component';
|
|
5
|
+
import { filterStrList, isCloudFileID, isHttpFileID, transSize, downloadFile, transFileCloudidToName, randomStr, } from '../../../utils/platform';
|
|
6
|
+
import { getCloudInstance } from '../../../utils/tcb';
|
|
7
|
+
import classNames from '../../../utils/classnames';
|
|
8
|
+
import { renderDecorator } from '../renderDecorator';
|
|
9
|
+
import { emptyArray, emptyObject } from '../../../utils/constant';
|
|
10
|
+
import { useTempUrl } from '../../../utils/use-cloud-id-temp-url';
|
|
11
|
+
// 默认组件类前缀
|
|
12
|
+
const CLASS_PREFIX = 'weda-upload-file-mobile';
|
|
13
|
+
// 默认图片类型
|
|
14
|
+
export const FILES_TYPES = [
|
|
15
|
+
'.doc',
|
|
16
|
+
'.docx',
|
|
17
|
+
'.xml',
|
|
18
|
+
'application/msword',
|
|
19
|
+
'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
|
|
20
|
+
];
|
|
21
|
+
// 上传状态字典
|
|
22
|
+
const statusMap = {
|
|
23
|
+
UPLOAD_STATUS_PENDING: { title: '等待上传', icon: 'pending' },
|
|
24
|
+
UPLOAD_STATUS_LOADING: { title: '上传中', icon: 'loading' },
|
|
25
|
+
UPLOAD_STATUS_SUCCESS: { title: '上传成功', icon: 'success' },
|
|
26
|
+
UPLOAD_STATUS_ERROR: { title: '上传失败', icon: 'error' },
|
|
27
|
+
};
|
|
28
|
+
// 上传文件Context
|
|
29
|
+
const FileContext = React.createContext(null);
|
|
30
|
+
/**
|
|
31
|
+
* 上传文件 H5 版本
|
|
32
|
+
*/
|
|
33
|
+
const defaultStyle = { margin: '0,-5px' };
|
|
34
|
+
export function UploadFileH5({
|
|
35
|
+
// 系统属性
|
|
36
|
+
layout, id = '', style = defaultStyle, labelVisible = true, label = '上传文件', requiredFlag = false, disabled = false, className = '', acceptTypes = emptyArray,
|
|
37
|
+
// 组件属性
|
|
38
|
+
tips = '', btnTitle = '点击上传', maxUploadCount = 9, maxSize = 10, deleteVisible = true, downloadVisible = true, value = emptyArray, // 需要兼容 cloud:和https: 协议,需要兼容字符串和字符串数组
|
|
39
|
+
events = emptyObject, defaultValue, uploadPath = 'weda-uploader', single = true, onChange = null, isEdit = true, }) {
|
|
40
|
+
const [fileIDList, setfileIDList] = React.useState(filterStrList([].concat(defaultValue, value))); // 上传成功文件ID列表,fileID[]
|
|
41
|
+
const [fileList, setFileList] = React.useState([]); // 上传中的文件列表,file[],file为原始文件 + uuid属性
|
|
42
|
+
const [fileSizeObj, setFileSizeObj] = React.useState({}); // 管理上传文件大小 {uuid:size}
|
|
43
|
+
// 两次默认值不同, 需要刷新
|
|
44
|
+
const prevDefaultRef = React.useRef([]);
|
|
45
|
+
const fileRef = React.useRef(fileIDList);
|
|
46
|
+
React.useMemo(() => {
|
|
47
|
+
//有有效默认值时不刷新,解决初次渲染默认值不显示问题
|
|
48
|
+
if (defaultValue &&
|
|
49
|
+
!isObjectEqual(prevDefaultRef.current, defaultValue) &&
|
|
50
|
+
(JSON.stringify(prevDefaultRef.current) == '[]' ||
|
|
51
|
+
!prevDefaultRef.current)) {
|
|
52
|
+
prevDefaultRef.current = defaultValue;
|
|
53
|
+
setfileIDList(filterStrList([].concat(defaultValue)));
|
|
54
|
+
}
|
|
55
|
+
}, [defaultValue]);
|
|
56
|
+
React.useEffect(() => {
|
|
57
|
+
var _a, _b, _c;
|
|
58
|
+
// 外部 onChange 事件
|
|
59
|
+
const pureFileIDList = fileIDList.filter((d) => isCloudFileID(d) || isHttpFileID(d));
|
|
60
|
+
if (single) {
|
|
61
|
+
const file = pureFileIDList[0] || '';
|
|
62
|
+
file && onChange && onChange(file);
|
|
63
|
+
(_a = events === null || events === void 0 ? void 0 : events.change) === null || _a === void 0 ? void 0 : _a.call(events, { value: file });
|
|
64
|
+
}
|
|
65
|
+
else {
|
|
66
|
+
onChange && onChange(pureFileIDList);
|
|
67
|
+
(_b = events === null || events === void 0 ? void 0 : events.change) === null || _b === void 0 ? void 0 : _b.call(events, { value: pureFileIDList });
|
|
68
|
+
}
|
|
69
|
+
if (!isObjectEqual(fileRef.current, fileIDList)) {
|
|
70
|
+
(_c = events === null || events === void 0 ? void 0 : events.success) === null || _c === void 0 ? void 0 : _c.call(events, { value: pureFileIDList });
|
|
71
|
+
fileRef.current = fileIDList;
|
|
72
|
+
}
|
|
73
|
+
}, [fileIDList]);
|
|
74
|
+
// 外层组件类
|
|
75
|
+
const cls = classNames({
|
|
76
|
+
'weda-ui': true,
|
|
77
|
+
//'weui-cells': true,
|
|
78
|
+
//'weui-cells_form': true,
|
|
79
|
+
'weui-cells_checkbox': true,
|
|
80
|
+
[className]: className,
|
|
81
|
+
});
|
|
82
|
+
const accepts = React.useMemo(() => {
|
|
83
|
+
return acceptTypes.includes('*') || acceptTypes.length === 0
|
|
84
|
+
? ['*']
|
|
85
|
+
: Array.from(new Set(acceptTypes));
|
|
86
|
+
}, [acceptTypes]);
|
|
87
|
+
const islegalType = (files, accepts) => {
|
|
88
|
+
const illegalType = [];
|
|
89
|
+
for (const file of files) {
|
|
90
|
+
accepts.some((item) => item === (file === null || file === void 0 ? void 0 : file.type))
|
|
91
|
+
? null
|
|
92
|
+
: illegalType.push(file === null || file === void 0 ? void 0 : file.type);
|
|
93
|
+
}
|
|
94
|
+
if (illegalType.length > 0) {
|
|
95
|
+
weui.alert('不支持上传' + Array.from(new Set(illegalType)).join(',') + '格式文件');
|
|
96
|
+
return false;
|
|
97
|
+
}
|
|
98
|
+
return true;
|
|
99
|
+
};
|
|
100
|
+
// 上传后文件列表 fileIDList 改变事件,'add'|'delete'
|
|
101
|
+
const handleChange = ({ fileID, uuid, type, size }) => {
|
|
102
|
+
// 上传时新增事件
|
|
103
|
+
if (type === 'add') {
|
|
104
|
+
fileID && setFileSizeObj((obj) => ({ ...obj, [fileID]: size }));
|
|
105
|
+
fileID && setfileIDList((fileIDList) => [...fileIDList, fileID]);
|
|
106
|
+
}
|
|
107
|
+
else {
|
|
108
|
+
fileID &&
|
|
109
|
+
setfileIDList((fileIDList) => fileIDList.filter((f) => f !== fileID));
|
|
110
|
+
}
|
|
111
|
+
uuid && setFileList((list) => list.filter((item) => uuid !== (item === null || item === void 0 ? void 0 : item._uuid)));
|
|
112
|
+
};
|
|
113
|
+
// 上传组件属性
|
|
114
|
+
const uploadProps = {
|
|
115
|
+
multiple: !single,
|
|
116
|
+
};
|
|
117
|
+
tips && (uploadProps['label'] = tips);
|
|
118
|
+
maxSize && (uploadProps['maxSize'] = maxSize * 1024 * 1024);
|
|
119
|
+
const btnDisabled = fileIDList.length >= maxUploadCount ||
|
|
120
|
+
(single && fileIDList.length > 0) ||
|
|
121
|
+
disabled;
|
|
122
|
+
return renderDecorator(React.createElement(ConfigProvider, { classPrefix: "wedatea2td" },
|
|
123
|
+
React.createElement(FileContext.Provider, { value: {
|
|
124
|
+
uploadPath,
|
|
125
|
+
downloadVisible,
|
|
126
|
+
deleteVisible,
|
|
127
|
+
onChange: handleChange,
|
|
128
|
+
isEdit,
|
|
129
|
+
events,
|
|
130
|
+
fileSizeObj,
|
|
131
|
+
} },
|
|
132
|
+
React.createElement("div", { "data-testid": "uploadFileH5", className: cls, id: id, style: style },
|
|
133
|
+
React.createElement("div", { className: classNames(`${CLASS_PREFIX}`) },
|
|
134
|
+
isEdit && (React.createElement("div", { className: classNames(`${CLASS_PREFIX}__hd`, layout) },
|
|
135
|
+
React.createElement("div", null, btnDisabled ? (React.createElement(Button, { type: "weak", className: classNames(`${CLASS_PREFIX}__btn--weak`), disabled: btnDisabled }, btnTitle)) : (React.createElement("div", null,
|
|
136
|
+
React.createElement("input", { id: "uploaderInput", type: "file", "data-testid": "button-up", className: "weui-uploader-mobile__input", accept: accepts.join(','), multiple: !single, onChange: (e) => {
|
|
137
|
+
const fileList = [...e.target.files];
|
|
138
|
+
//校验逻辑与图片有出入,文件类型限制为全部时,不设限
|
|
139
|
+
if (!(accepts.includes('*') ||
|
|
140
|
+
accepts.includes('') ||
|
|
141
|
+
accepts.length === 0) &&
|
|
142
|
+
!islegalType(fileList, accepts))
|
|
143
|
+
return;
|
|
144
|
+
if (single && fileList.length > 1) {
|
|
145
|
+
weui.alert(`上传文件总数不能超过1个`);
|
|
146
|
+
return false;
|
|
147
|
+
}
|
|
148
|
+
if (fileList.length + fileIDList.length >
|
|
149
|
+
maxUploadCount) {
|
|
150
|
+
weui.alert(`上传文件总数不能超过${maxUploadCount}个`);
|
|
151
|
+
return false;
|
|
152
|
+
}
|
|
153
|
+
if (maxSize &&
|
|
154
|
+
fileList.some((f) => f.size > maxSize * 1024 * 1024)) {
|
|
155
|
+
weui.alert(`请上传不超过${maxSize}M的文件`);
|
|
156
|
+
return false;
|
|
157
|
+
}
|
|
158
|
+
if (fileList.some((f) => f.size > 1024 * 1024 * 1024)) {
|
|
159
|
+
weui.alert(`请上传不超过1024M的文件`);
|
|
160
|
+
return false;
|
|
161
|
+
}
|
|
162
|
+
fileList.forEach((f) => (f['_uuid'] = randomStr()));
|
|
163
|
+
setFileList((list) => [...list, ...fileList]);
|
|
164
|
+
} }),
|
|
165
|
+
React.createElement("a", { type: "weak", className: "wedatea2td-btn wedatea2td-btn--weak", style: { fontSize: '1em' } }, "\u70B9\u51FB\u4E0A\u4F20"),
|
|
166
|
+
!single && (React.createElement(Text, { className: `${CLASS_PREFIX}__tips` }, "\u652F\u6301\u6279\u91CF\u4E0A\u4F20"))))))),
|
|
167
|
+
React.createElement("div", { className: `${CLASS_PREFIX}__bd` },
|
|
168
|
+
React.createElement(List, null,
|
|
169
|
+
fileIDList.map((d) => (React.createElement(List.Item, { key: d }, React.createElement(TcbFileEcho, { fileID: d, fileList: fileList, onChange: handleChange, disabled: disabled, deleteVisible: deleteVisible, downloadVisible: downloadVisible })))),
|
|
170
|
+
fileList.map((item) => (React.createElement(List.Item, { key: item === null || item === void 0 ? void 0 : item._uuid }, React.createElement(TcbFileUpload, { disabled: disabled, file: item, downloadVisible: downloadVisible, deleteVisible: deleteVisible && !disabled })))))))))))({
|
|
171
|
+
id,
|
|
172
|
+
className: cls,
|
|
173
|
+
style,
|
|
174
|
+
label: labelVisible ? label : null,
|
|
175
|
+
layout,
|
|
176
|
+
multiCell: false,
|
|
177
|
+
requiredFlag,
|
|
178
|
+
});
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* 基于 FileID 文件回显组件
|
|
182
|
+
*/
|
|
183
|
+
const TcbFileEcho = ({ fileID, disabled }) => {
|
|
184
|
+
const { fileSizeObj } = React.useContext(FileContext) || {};
|
|
185
|
+
const { data: src, error } = useTempUrl(fileID);
|
|
186
|
+
if (error) {
|
|
187
|
+
message.error({
|
|
188
|
+
content: `cloud id ${fileID} 资源获取错误`,
|
|
189
|
+
});
|
|
190
|
+
}
|
|
191
|
+
//上传文件名称
|
|
192
|
+
const label = React.useMemo(() => {
|
|
193
|
+
if (isCloudFileID(fileID)) {
|
|
194
|
+
return transFileCloudidToName(fileID);
|
|
195
|
+
}
|
|
196
|
+
else {
|
|
197
|
+
return fileID;
|
|
198
|
+
}
|
|
199
|
+
}, [fileID]);
|
|
200
|
+
//上传文件列表展示
|
|
201
|
+
return (React.createElement("div", { className: `${CLASS_PREFIX}__item` },
|
|
202
|
+
React.createElement("div", { className: `${CLASS_PREFIX}__item-left` },
|
|
203
|
+
React.createElement(UploadFileStatus, { title: label, size: fileSizeObj[fileID] || '--' })),
|
|
204
|
+
React.createElement("div", { className: `${CLASS_PREFIX}__btn-group` },
|
|
205
|
+
React.createElement(UploadFileAction, { disabled: disabled, status: "UPLOAD_STATUS_SUCCESS", fileID: fileID, src: src }))));
|
|
206
|
+
};
|
|
207
|
+
/**
|
|
208
|
+
* 基于 File 上传文件过程组件
|
|
209
|
+
*/
|
|
210
|
+
const TcbFileUpload = ({ file, disabled }) => {
|
|
211
|
+
const { uploadPath, onChange, events } = React.useContext(FileContext) || {};
|
|
212
|
+
const [percent, setPercent] = React.useState(0); // 上传进度
|
|
213
|
+
const [status, setStatus] = React.useState('UPLOAD_STATUS_PENDING'); // 上传状态
|
|
214
|
+
const cancleRef = React.useRef(''); // 取消的uuid
|
|
215
|
+
// 上传文件相关属性
|
|
216
|
+
const { size, title, uuid } = React.useMemo(() => {
|
|
217
|
+
const size = transSize(file === null || file === void 0 ? void 0 : file.size);
|
|
218
|
+
const title = (file === null || file === void 0 ? void 0 : file.name) || '';
|
|
219
|
+
const uuid = file === null || file === void 0 ? void 0 : file._uuid;
|
|
220
|
+
return { size, title, uuid };
|
|
221
|
+
}, [file === null || file === void 0 ? void 0 : file._uuid]);
|
|
222
|
+
React.useEffect(() => {
|
|
223
|
+
handleUpload(file);
|
|
224
|
+
}, [file === null || file === void 0 ? void 0 : file._uuid]);
|
|
225
|
+
// 上传过程
|
|
226
|
+
const handleUpload = async (file) => {
|
|
227
|
+
var _a;
|
|
228
|
+
const tcb = await getCloudInstance();
|
|
229
|
+
try {
|
|
230
|
+
setStatus('UPLOAD_STATUS_PENDING');
|
|
231
|
+
const { fileID } = await tcb.uploadFile({
|
|
232
|
+
cloudPath: `${uploadPath}/${randomStr()}-${file === null || file === void 0 ? void 0 : file.name}`,
|
|
233
|
+
filePath: file,
|
|
234
|
+
onUploadProgress: (progressEvent) => {
|
|
235
|
+
let percent = 0;
|
|
236
|
+
percent = Math.round((progressEvent.loaded * 100) / progressEvent.total);
|
|
237
|
+
setStatus('UPLOAD_STATUS_LOADING');
|
|
238
|
+
setPercent(percent < 100 ? percent : 100);
|
|
239
|
+
},
|
|
240
|
+
});
|
|
241
|
+
!cancleRef.current && (onChange === null || onChange === void 0 ? void 0 : onChange({ fileID, type: 'add', uuid, size }));
|
|
242
|
+
setStatus('UPLOAD_STATUS_SUCCESS');
|
|
243
|
+
}
|
|
244
|
+
catch (err) {
|
|
245
|
+
setStatus('UPLOAD_STATUS_ERROR');
|
|
246
|
+
(_a = events === null || events === void 0 ? void 0 : events.error) === null || _a === void 0 ? void 0 : _a.call(events, err);
|
|
247
|
+
}
|
|
248
|
+
};
|
|
249
|
+
return (React.createElement("div", { className: `${CLASS_PREFIX}__item`, role: "TcbFileUpload" },
|
|
250
|
+
React.createElement("div", { className: `${CLASS_PREFIX}__item-left` },
|
|
251
|
+
React.createElement(UploadFileStatus, { status: status, percent: percent, size: size, title: title, percentSize: (((file === null || file === void 0 ? void 0 : file.size) / 1024) * percent) / 100 })),
|
|
252
|
+
React.createElement("div", { className: `${CLASS_PREFIX}__btn-group` },
|
|
253
|
+
React.createElement(UploadFileAction, { file: file, uuid: file === null || file === void 0 ? void 0 : file._uuid, status: status, onCancel: (uuid) => {
|
|
254
|
+
cancleRef.current = uuid;
|
|
255
|
+
onChange === null || onChange === void 0 ? void 0 : onChange({ type: 'delete', uuid });
|
|
256
|
+
}, onReLoad: handleUpload, disabled: disabled }))));
|
|
257
|
+
};
|
|
258
|
+
/**
|
|
259
|
+
* 上传文件状态组件
|
|
260
|
+
*/
|
|
261
|
+
const UploadFileStatus = ({ status = 'UPLOAD_STATUS_SUCCESS', percent = 0, size, title = null, percentSize = 0, }) => {
|
|
262
|
+
var _a, _b;
|
|
263
|
+
const { isEdit } = React.useContext(FileContext) || {};
|
|
264
|
+
//上传中、待上传状态
|
|
265
|
+
if (status == 'UPLOAD_STATUS_LOADING' ||
|
|
266
|
+
(status == 'UPLOAD_STATUS_PENDING' && percent)) {
|
|
267
|
+
return (React.createElement(React.Fragment, null,
|
|
268
|
+
React.createElement("div", { className: `${CLASS_PREFIX}__file-detail` },
|
|
269
|
+
React.createElement(Text, { className: `${CLASS_PREFIX}__file-name` }, title),
|
|
270
|
+
React.createElement("div", { className: `${CLASS_PREFIX}__file-status` },
|
|
271
|
+
React.createElement("div", { className: `${CLASS_PREFIX}__file-status` },
|
|
272
|
+
React.createElement(Progress, { percent: percent, theme: "default", strokeColor: '#0052D9', className: `${CLASS_PREFIX}__file-progress` })))),
|
|
273
|
+
React.createElement("div", { className: `${CLASS_PREFIX}__file-foot` },
|
|
274
|
+
React.createElement("div", null,
|
|
275
|
+
React.createElement(Text, null,
|
|
276
|
+
Math.floor(percentSize),
|
|
277
|
+
"K/"),
|
|
278
|
+
React.createElement(Text, null, size)),
|
|
279
|
+
React.createElement(Text, null, status === 'UPLOAD_STATUS_PENDING' ? '等待上传' : '上传中'))));
|
|
280
|
+
}
|
|
281
|
+
return (React.createElement(React.Fragment, null,
|
|
282
|
+
React.createElement("div", { className: `${CLASS_PREFIX}__file-detail` },
|
|
283
|
+
React.createElement(Tooltip, { title: title },
|
|
284
|
+
React.createElement(Text, { className: `${CLASS_PREFIX}__file-name` }, title)),
|
|
285
|
+
isEdit && (React.createElement("div", { className: `${CLASS_PREFIX}__file-status` },
|
|
286
|
+
React.createElement(Icon, { type: ((_a = statusMap[status]) === null || _a === void 0 ? void 0 : _a.icon) ||
|
|
287
|
+
statusMap['UPLOAD_STATUS_PENDING'].icon }),
|
|
288
|
+
React.createElement(Text, { className: `${CLASS_PREFIX}__file-status--msg` }, ((_b = statusMap[status]) === null || _b === void 0 ? void 0 : _b.title) ||
|
|
289
|
+
statusMap['UPLOAD_STATUS_PENDING'].title)))),
|
|
290
|
+
isEdit && (React.createElement("div", { className: `${CLASS_PREFIX}__file-foot` },
|
|
291
|
+
React.createElement("div", null,
|
|
292
|
+
React.createElement(Text, null, size))))));
|
|
293
|
+
};
|
|
294
|
+
/**
|
|
295
|
+
* 操作列组件, onChange 从最外层 UploadFilePc 传进来
|
|
296
|
+
* props: { status, fileID, uuid, src, onChange }
|
|
297
|
+
*/
|
|
298
|
+
const UploadFileAction = ({ status = 'UPLOAD_STATUS_PENDING', fileID = '', uuid = '', src = '', file = null, onReLoad = null, onCancel = null, disabled, }) => {
|
|
299
|
+
const { onChange, downloadVisible, deleteVisible, isEdit } = React.useContext(FileContext) || {};
|
|
300
|
+
// 操作列按钮-删除
|
|
301
|
+
const renderDelete = () => isEdit && (React.createElement(Button, { icon: "delete", onClick: () => onChange === null || onChange === void 0 ? void 0 : onChange({ fileID, uuid, type: 'delete' }), disabled: disabled }));
|
|
302
|
+
// 操作列按钮-取消
|
|
303
|
+
const renderCancel = () => isEdit && React.createElement(Button, { icon: "dismiss", onClick: () => onCancel === null || onCancel === void 0 ? void 0 : onCancel(uuid) });
|
|
304
|
+
// 操作列按钮-重新上传
|
|
305
|
+
const renderReLoad = () => isEdit && (React.createElement(Button, { icon: "refresh", onClick: () => {
|
|
306
|
+
onReLoad === null || onReLoad === void 0 ? void 0 : onReLoad(file);
|
|
307
|
+
} }));
|
|
308
|
+
// 操作列按钮-下载
|
|
309
|
+
const renderDownLoad = () => (React.createElement(Button, { icon: "download", onClick: () => downloadFile(src) }));
|
|
310
|
+
switch (status) {
|
|
311
|
+
case 'UPLOAD_STATUS_PENDING':
|
|
312
|
+
return renderCancel();
|
|
313
|
+
case 'UPLOAD_STATUS_LOADING':
|
|
314
|
+
return renderCancel();
|
|
315
|
+
case 'UPLOAD_STATUS_SUCCESS':
|
|
316
|
+
return (React.createElement(React.Fragment, null,
|
|
317
|
+
deleteVisible && renderDelete(),
|
|
318
|
+
' ',
|
|
319
|
+
downloadVisible && renderDownLoad()));
|
|
320
|
+
case 'UPLOAD_STATUS_ERROR':
|
|
321
|
+
return (React.createElement(React.Fragment, null,
|
|
322
|
+
deleteVisible && renderDelete(),
|
|
323
|
+
" ",
|
|
324
|
+
renderReLoad()));
|
|
325
|
+
default:
|
|
326
|
+
return null;
|
|
327
|
+
}
|
|
328
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import type { CommonFormPropsType } from '../types';
|
|
3
|
+
import type { unknownFunction } from '../../../types';
|
|
4
|
+
/**
|
|
5
|
+
* 上传文件 PC 版本
|
|
6
|
+
*/
|
|
7
|
+
export declare function UploadFilePc({ layout, id, style, labelVisible, label, requiredFlag, disabled, className, events, decorator, tips, btnTitle, maxUploadCount, maxSize, single, defaultValue, // 组件默认初始化值
|
|
8
|
+
value, // 用于模型组件中 formily 的值管理
|
|
9
|
+
acceptTypes, downloadVisible, deleteVisible, uploadPath, onChange, isEdit, }: IUploaderFilePc): JSX.Element;
|
|
10
|
+
export interface IUploaderFilePc extends CommonFormPropsType {
|
|
11
|
+
btnTitle?: string;
|
|
12
|
+
maxUploadCount?: number;
|
|
13
|
+
downloadVisible?: boolean;
|
|
14
|
+
deleteVisible?: boolean;
|
|
15
|
+
defaultValue?: Readonly<string | string[]>;
|
|
16
|
+
maxSize?: number;
|
|
17
|
+
single?: boolean;
|
|
18
|
+
acceptTypes?: Readonly<string[]>;
|
|
19
|
+
tips?: string;
|
|
20
|
+
value?: Readonly<string | string[]>;
|
|
21
|
+
uploadPath?: string;
|
|
22
|
+
isEdit?: boolean;
|
|
23
|
+
onChange?: unknownFunction;
|
|
24
|
+
}
|