@para-ui/core 3.0.55 → 3.0.56
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/AutoBox/index.d.ts +34 -0
- package/AutoBox/index.js +277 -0
- package/AutoBox/protal.d.ts +17 -0
- package/AutoTips/autoTipsMultiline/index.d.ts +18 -0
- package/AutoTips/index.d.ts +35 -0
- package/AutoTips/index.js +271 -0
- package/Breadcrumbs/index.d.ts +53 -0
- package/Breadcrumbs/index.js +266 -0
- package/Breadcrumbs/lang/en_US.d.ts +4 -0
- package/Breadcrumbs/lang/index.d.ts +9 -0
- package/Breadcrumbs/lang/zh_CN.d.ts +4 -0
- package/Button/SplitButton.d.ts +64 -0
- package/Button/index.d.ts +79 -0
- package/Button/index.js +376 -0
- package/Button/lang/en_US.d.ts +4 -0
- package/Button/lang/index.d.ts +9 -0
- package/Button/lang/zh_CN.d.ts +4 -0
- package/ButtonGroup/index.d.ts +33 -0
- package/ButtonGroup/index.js +124 -0
- package/Carousel/index.d.ts +38 -0
- package/Carousel/index.js +78 -0
- package/Cascader/index.d.ts +54 -0
- package/Cascader/index.js +159 -0
- package/Cascader/lang/en_US.d.ts +4 -0
- package/Cascader/lang/index.d.ts +9 -0
- package/Cascader/lang/zh_CN.d.ts +4 -0
- package/Checkbox/index.d.ts +40 -0
- package/Checkbox/index.js +109 -0
- package/CheckboxGroup/index.d.ts +45 -0
- package/CheckboxGroup/index.js +142 -0
- package/Collapse/collapsePanel.d.ts +30 -0
- package/Collapse/index.d.ts +57 -0
- package/Collapse/index.js +152 -0
- package/Collapse/motion.d.ts +5 -0
- package/Collapse/util.d.ts +11 -0
- package/CollapseBox/index.d.ts +27 -0
- package/CollapseBox/index.js +148 -0
- package/CollapseBox/util.d.ts +5 -0
- package/CollapseLayout/index.d.ts +53 -0
- package/CollapseLayout/index.js +176 -0
- package/ColorPicker/index.d.ts +4 -0
- package/ColorPicker/index.js +4 -0
- package/ComboSelect/index.d.ts +6 -0
- package/ComboSelect/index.js +1049 -0
- package/ComboSelect/interface.d.ts +146 -0
- package/ComboSelect/lang/en_US.d.ts +9 -0
- package/ComboSelect/lang/index.d.ts +19 -0
- package/ComboSelect/lang/zh_CN.d.ts +9 -0
- package/ComboSelect/utils.d.ts +9 -0
- package/Container/index.d.ts +77 -0
- package/Container/index.js +232 -0
- package/DatePicker/PickerButton.d.ts +3 -0
- package/DatePicker/PickerTag.d.ts +3 -0
- package/DatePicker/generatePicker/generateRangePicker.d.ts +4 -0
- package/DatePicker/generatePicker/generateSinglePicker.d.ts +11 -0
- package/DatePicker/generatePicker/index.d.ts +95 -0
- package/DatePicker/index.d.ts +18 -0
- package/DatePicker/index.js +633 -0
- package/DatePicker/lang/en_US.d.ts +3 -0
- package/DatePicker/lang/index.d.ts +7 -0
- package/DatePicker/lang/zh_CN.d.ts +3 -0
- package/DatePicker/util.d.ts +22 -0
- package/Desktop/index.d.ts +57 -0
- package/Desktop/index.js +746 -0
- package/DragVerify/index.d.ts +36 -0
- package/DragVerify/index.js +385 -0
- package/DragVerify/lang/en_US.d.ts +5 -0
- package/DragVerify/lang/index.d.ts +11 -0
- package/DragVerify/lang/zh_CN.d.ts +5 -0
- package/Drawer/index.d.ts +11 -0
- package/Drawer/index.js +235 -0
- package/Drawer/interface.d.ts +92 -0
- package/Drawer/lang/en_US.d.ts +5 -0
- package/Drawer/lang/index.d.ts +11 -0
- package/Drawer/lang/zh_CN.d.ts +5 -0
- package/Dropdown/index.d.ts +40 -0
- package/Dropdown/index.js +10 -0
- package/DynamicMultiBox/formItem.d.ts +14 -0
- package/DynamicMultiBox/index.d.ts +5 -0
- package/DynamicMultiBox/index.js +1323 -0
- package/DynamicMultiBox/interface.d.ts +165 -0
- package/DynamicMultiBox/rowForm.d.ts +24 -0
- package/Empty/images/index.d.ts +3 -0
- package/Empty/index.d.ts +30 -0
- package/Empty/index.js +642 -0
- package/Empty/lang/en_US.d.ts +6 -0
- package/Empty/lang/index.d.ts +13 -0
- package/Empty/lang/zh_CN.d.ts +6 -0
- package/Form/index.d.ts +187 -0
- package/Form/index.js +355 -0
- package/FormItem/compoments/defaultCompoments/index.d.ts +19 -0
- package/FormItem/compoments/formCheckboxGroup/index.d.ts +8 -0
- package/FormItem/compoments/formFile/index.d.ts +38 -0
- package/FormItem/compoments/formRadioGroup/index.d.ts +8 -0
- package/FormItem/compoments/formSelect/index.d.ts +18 -0
- package/FormItem/errorTips.d.ts +12 -0
- package/FormItem/index.d.ts +152 -0
- package/FormItem/index.js +78 -0
- package/FormItem/itemType.d.ts +42 -0
- package/FormItem/validateFunction.d.ts +15 -0
- package/FunctionModal/dialog.d.ts +58 -0
- package/FunctionModal/index.d.ts +8 -0
- package/FunctionModal/index.js +43 -0
- package/FunctionModal/modalContext.d.ts +15 -0
- package/GlobalContext/componentsProps.d.ts +21 -0
- package/GlobalContext/confirmLocale.d.ts +7 -0
- package/GlobalContext/constant.d.ts +8 -0
- package/GlobalContext/index.d.ts +28 -0
- package/GlobalContext/index.js +41 -0
- package/GlobalContext/intl.d.ts +34 -0
- package/GlobalContext/useFormatMessage.d.ts +3 -0
- package/GlobalContext/usePopupContainer.d.ts +4 -0
- package/Help/index.d.ts +24 -0
- package/Help/index.js +41 -0
- package/HelperText/index.d.ts +27 -0
- package/HelperText/index.js +34 -0
- package/Hooks/useGlobalProps.d.ts +1 -0
- package/InputLang/index.d.ts +57 -0
- package/InputLang/index.js +355 -0
- package/InputNumber/index.d.ts +71 -0
- package/InputNumber/index.js +277 -0
- package/Label/index.d.ts +37 -0
- package/Label/index.js +85 -0
- package/Loading/index.d.ts +17 -0
- package/Loading/index.js +47 -0
- package/Menu/footerExpansion.d.ts +9 -0
- package/Menu/index.d.ts +10 -0
- package/Menu/index.js +1105 -0
- package/Menu/interface.d.ts +141 -0
- package/Menu/logo.d.ts +9 -0
- package/Menu/verticalMenuList.d.ts +14 -0
- package/Message/index.d.ts +99 -0
- package/Message/index.js +246 -0
- package/Modal/Confirm/index.d.ts +65 -0
- package/Modal/index.d.ts +99 -0
- package/Modal/index.js +421 -0
- package/Modal/lang/en_US.d.ts +5 -0
- package/Modal/lang/index.d.ts +11 -0
- package/Modal/lang/zh_CN.d.ts +5 -0
- package/MultiBox/index.d.ts +60 -0
- package/MultiBox/index.js +277 -0
- package/MultiBox/lang/en_US.d.ts +4 -0
- package/MultiBox/lang/index.d.ts +9 -0
- package/MultiBox/lang/zh_CN.d.ts +4 -0
- package/Notification/index.d.ts +74 -0
- package/Notification/index.js +252 -0
- package/OperateBtn/index.d.ts +59 -0
- package/OperateBtn/index.js +237 -0
- package/OperateBtn/lang/en_US.d.ts +4 -0
- package/OperateBtn/lang/index.d.ts +9 -0
- package/OperateBtn/lang/zh_CN.d.ts +4 -0
- package/PageHeader/horizontalMeun.d.ts +9 -0
- package/PageHeader/horizontalMeunRight.d.ts +9 -0
- package/PageHeader/index.d.ts +10 -0
- package/PageHeader/index.js +1050 -0
- package/PageHeader/interface.d.ts +169 -0
- package/Pagination/index.d.ts +46 -0
- package/Pagination/index.js +461 -0
- package/Pagination/lang/en_US.d.ts +8 -0
- package/Pagination/lang/index.d.ts +17 -0
- package/Pagination/lang/zh_CN.d.ts +8 -0
- package/ParauiProvider/index.d.ts +8 -0
- package/ParauiProvider/index.js +52 -0
- package/PasswordRules/index.d.ts +55 -0
- package/PasswordRules/index.js +144 -0
- package/PopConfirm/index.d.ts +61 -0
- package/PopConfirm/index.js +194 -0
- package/PopConfirm/lang/en_US.d.ts +5 -0
- package/PopConfirm/lang/index.d.ts +11 -0
- package/PopConfirm/lang/zh_CN.d.ts +5 -0
- package/Popover/index.d.ts +16 -0
- package/Popover/index.js +59 -0
- package/Progress/Line.d.ts +47 -0
- package/Progress/Steps.d.ts +17 -0
- package/Progress/index.d.ts +83 -0
- package/Progress/index.js +323 -0
- package/Progress/utils.d.ts +6 -0
- package/Querying/images/index.d.ts +3 -0
- package/Querying/index.d.ts +26 -0
- package/Querying/index.js +760 -0
- package/Querying/lang/en_US.d.ts +4 -0
- package/Querying/lang/index.d.ts +9 -0
- package/Querying/lang/zh_CN.d.ts +4 -0
- package/README.md +6 -0
- package/Radio/index.d.ts +38 -0
- package/Radio/index.js +97 -0
- package/RadioGroup/index.d.ts +46 -0
- package/RadioGroup/index.js +134 -0
- package/Search/index.d.ts +57 -0
- package/Search/index.js +208 -0
- package/Select/index.d.ts +93 -0
- package/Select/index.js +1146 -0
- package/Select/lang/en_US.d.ts +5 -0
- package/Select/lang/index.d.ts +11 -0
- package/Select/lang/zh_CN.d.ts +5 -0
- package/SelectInput/index.d.ts +12 -0
- package/SelectInput/index.js +55 -0
- package/Selector/index.d.ts +11 -0
- package/Selector/index.js +2175 -0
- package/Selector/interface.d.ts +432 -0
- package/Selector/lang/en_US.d.ts +11 -0
- package/Selector/lang/index.d.ts +23 -0
- package/Selector/lang/zh_CN.d.ts +11 -0
- package/Selector/selectorData/index.d.ts +10 -0
- package/Selector/selectorMain/index.d.ts +10 -0
- package/Selector/selectorNode/index.d.ts +10 -0
- package/Selector/util.d.ts +15 -0
- package/SelectorPicker/index.d.ts +53 -0
- package/SelectorPicker/index.js +444 -0
- package/SelectorPicker/lang/en_US.d.ts +5 -0
- package/SelectorPicker/lang/index.d.ts +11 -0
- package/SelectorPicker/lang/zh_CN.d.ts +5 -0
- package/SingleBox/index.d.ts +44 -0
- package/SingleBox/index.js +224 -0
- package/SingleBox/lang/en_US.d.ts +4 -0
- package/SingleBox/lang/index.d.ts +9 -0
- package/SingleBox/lang/zh_CN.d.ts +4 -0
- package/Slider/index.d.ts +14 -0
- package/Slider/index.js +119 -0
- package/Slider/interface.d.ts +102 -0
- package/Split/index.d.ts +7 -0
- package/Split/index.js +123 -0
- package/Status/index.d.ts +21 -0
- package/Status/index.js +37 -0
- package/Stepper/icons.d.ts +5 -0
- package/Stepper/index.d.ts +59 -0
- package/Stepper/index.js +97 -0
- package/Switch/index.d.ts +78 -0
- package/Switch/index.js +71 -0
- package/Table/index.d.ts +10 -0
- package/Table/index.js +3001 -0
- package/Table/interface.d.ts +346 -0
- package/Table/lang/en_US.d.ts +8 -0
- package/Table/lang/index.d.ts +17 -0
- package/Table/lang/zh_CN.d.ts +8 -0
- package/Table/tableBody.d.ts +9 -0
- package/Table/tableBodyElement/index.d.ts +15 -0
- package/Table/tableBodyInterface.d.ts +73 -0
- package/Table/tableContainer/index.d.ts +16 -0
- package/Table/tableElement/index.d.ts +17 -0
- package/Table/tableHead.d.ts +9 -0
- package/Table/tableHeadElement/index.d.ts +15 -0
- package/Table/tableHeadInterface.d.ts +37 -0
- package/Table/tablePagination.d.ts +9 -0
- package/Table/tablePaginationInterface.d.ts +27 -0
- package/Table/tdElement/index.d.ts +15 -0
- package/Table/thElement/index.d.ts +28 -0
- package/Table/trElement/index.d.ts +15 -0
- package/Table/util.d.ts +34 -0
- package/Tabs/index.d.ts +69 -0
- package/Tabs/index.js +205 -0
- package/Tabs/lang/en_US.d.ts +4 -0
- package/Tabs/lang/index.d.ts +9 -0
- package/Tabs/lang/zh_CN.d.ts +4 -0
- package/Tag/TagGroup.d.ts +66 -0
- package/Tag/index.d.ts +34 -0
- package/Tag/index.js +259 -0
- package/TextEditor/common.d.ts +11 -0
- package/TextEditor/index.d.ts +127 -0
- package/TextEditor/index.js +286 -0
- package/TextField/index.d.ts +90 -0
- package/TextField/index.js +611 -0
- package/TimePicker/index.d.ts +22 -0
- package/TimePicker/index.js +80 -0
- package/TimePicker/locale/en_US.d.ts +3 -0
- package/TimePicker/locale/zh_CN.d.ts +3 -0
- package/TimePicker/style/index.d.ts +1 -0
- package/Timeline/TimelineItem.d.ts +30 -0
- package/Timeline/index.d.ts +32 -0
- package/Timeline/index.js +148 -0
- package/Title/index.d.ts +30 -0
- package/Title/index.js +50 -0
- package/ToggleButton/ToggleButtonGroup.d.ts +49 -0
- package/ToggleButton/index.d.ts +49 -0
- package/ToggleButton/index.js +193 -0
- package/Tooltip/index.d.ts +11 -0
- package/Tooltip/index.js +368 -0
- package/Tooltip/interface.d.ts +35 -0
- package/Tooltip/utils.d.ts +18 -0
- package/Transfer/box.d.ts +38 -0
- package/Transfer/index.d.ts +32 -0
- package/Transfer/index.js +611 -0
- package/Transfer/lang/en_US.d.ts +10 -0
- package/Transfer/lang/index.d.ts +21 -0
- package/Transfer/lang/zh_CN.d.ts +10 -0
- package/Transfer/useClick.d.ts +3 -0
- package/Tree/OperateBar/index.d.ts +13 -0
- package/Tree/Tree.d.ts +4 -0
- package/Tree/index.d.ts +5 -0
- package/Tree/index.js +38 -0
- package/Tree/interface.d.ts +210 -0
- package/Tree/lang/en_US.d.ts +8 -0
- package/Tree/lang/index.d.ts +17 -0
- package/Tree/lang/zh_CN.d.ts +8 -0
- package/Tree/utils/closestPolyfill.d.ts +0 -0
- package/Tree/utils/tools.d.ts +25 -0
- package/Tree/utils/treeUtil.d.ts +15 -0
- package/Upload/Dragger/index.d.ts +10 -0
- package/Upload/ErroTip/index.d.ts +13 -0
- package/Upload/ImageUpload/index.d.ts +16 -0
- package/Upload/ImgCrop/EasyCrop.d.ts +17 -0
- package/Upload/ImgCrop/constants.d.ts +7 -0
- package/Upload/ImgCrop/index.d.ts +6 -0
- package/Upload/ImgCrop/interface.d.ts +48 -0
- package/Upload/UploadList/index.d.ts +5 -0
- package/Upload/index.d.ts +15 -0
- package/Upload/index.js +1446 -0
- package/Upload/interface.d.ts +136 -0
- package/Upload/lang/en_US.d.ts +12 -0
- package/Upload/lang/index.d.ts +25 -0
- package/Upload/lang/zh_CN.d.ts +12 -0
- package/_verture/constant-66aa48a1.js +10 -0
- package/_verture/defineProperty-62acccfc.js +34 -0
- package/_verture/index-74f820ba.js +1355 -0
- package/_verture/index-77f9e0fb.js +236 -0
- package/_verture/index-a369ca3f.js +4 -0
- package/_verture/index-beef914f.js +340 -0
- package/_verture/index-d03136d4.js +711 -0
- package/_verture/index-e2881a53.js +16 -0
- package/_verture/intl-5cbb940c.js +57 -0
- package/_verture/modalContext-92bb0e16.js +201 -0
- package/_verture/slicedToArray-76060636.js +43 -0
- package/_verture/sortable.esm-49896035.js +3791 -0
- package/_verture/style-inject.es-300983ab.js +28 -0
- package/_verture/toConsumableArray-81040c9e.js +19 -0
- package/_verture/tslib.es6-55ed4bd2.js +38 -0
- package/_verture/typeof-498dd2b1.js +11 -0
- package/_verture/unsupportedIterableToArray-cb478f24.js +16 -0
- package/_verture/useFormatMessage-703f8b20.js +20 -0
- package/_verture/useGlobalProps-1b846a65.js +11 -0
- package/_verture/usePopupContainer-87febeb9.js +68 -0
- package/_verture/util-7e1fb1e2.js +18 -0
- package/index.d.ts +144 -0
- package/index.js +180 -0
- package/package.json +1 -1
- package/umd/AutoBox.js +43 -0
- package/umd/AutoTips.js +15 -0
- package/umd/Breadcrumbs.js +42 -0
- package/umd/Button.js +43 -0
- package/umd/ButtonGroup.js +43 -0
- package/umd/Carousel.js +6 -0
- package/umd/Cascader.js +43 -0
- package/umd/Checkbox.js +42 -0
- package/umd/CheckboxGroup.js +42 -0
- package/umd/Collapse.js +43 -0
- package/umd/CollapseBox.js +1 -0
- package/umd/CollapseLayout.js +29 -0
- package/umd/ColorPicker.js +1 -0
- package/umd/ComboSelect.js +42 -0
- package/umd/Container.js +1 -0
- package/umd/DatePicker.js +42 -0
- package/umd/Desktop.js +42 -0
- package/umd/DragVerify.js +28 -0
- package/umd/Drawer.js +43 -0
- package/umd/Dropdown.js +15 -0
- package/umd/DynamicMultiBox.js +54 -0
- package/umd/Empty.js +15 -0
- package/umd/Form.js +42 -0
- package/umd/FormItem.js +42 -0
- package/umd/FunctionModal.js +42 -0
- package/umd/GlobalContext.js +1 -0
- package/umd/Help.js +42 -0
- package/umd/HelperText.js +1 -0
- package/umd/InputLang.js +42 -0
- package/umd/InputNumber.js +42 -0
- package/umd/Label.js +42 -0
- package/umd/Loading.js +29 -0
- package/umd/Menu.js +29 -0
- package/umd/Message.js +30 -0
- package/umd/Modal.js +42 -0
- package/umd/MultiBox.js +42 -0
- package/umd/Notification.js +43 -0
- package/umd/OperateBtn.js +42 -0
- package/umd/PageHeader.js +42 -0
- package/umd/Pagination.js +42 -0
- package/umd/ParauiProvider.js +15 -0
- package/umd/PasswordRules.js +29 -0
- package/umd/PopConfirm.js +42 -0
- package/umd/Popover.js +15 -0
- package/umd/Progress.js +35 -0
- package/umd/Querying.js +15 -0
- package/umd/Radio.js +42 -0
- package/umd/RadioGroup.js +42 -0
- package/umd/Search.js +42 -0
- package/umd/Select.js +42 -0
- package/umd/SelectInput.js +42 -0
- package/umd/Selector.js +42 -0
- package/umd/SelectorPicker.js +42 -0
- package/umd/SingleBox.js +42 -0
- package/umd/Slider.js +15 -0
- package/umd/Split.js +1 -0
- package/umd/Status.js +1 -0
- package/umd/Stepper.js +42 -0
- package/umd/Switch.js +42 -0
- package/umd/Table.js +42 -0
- package/umd/Tabs.js +42 -0
- package/umd/Tag.js +43 -0
- package/umd/TextEditor.js +205 -0
- package/umd/TextField.js +42 -0
- package/umd/TimePicker.js +42 -0
- package/umd/Timeline.js +1 -0
- package/umd/Title.js +1 -0
- package/umd/ToggleButton.js +43 -0
- package/umd/Tooltip.js +15 -0
- package/umd/Transfer.js +49 -0
- package/umd/Tree.js +42 -0
- package/umd/Upload.js +56 -0
package/Upload/index.js
ADDED
|
@@ -0,0 +1,1446 @@
|
|
|
1
|
+
import { _ as _defineProperty } from '../_verture/defineProperty-62acccfc.js';
|
|
2
|
+
import { _ as _toConsumableArray } from '../_verture/toConsumableArray-81040c9e.js';
|
|
3
|
+
import { _ as _slicedToArray } from '../_verture/slicedToArray-76060636.js';
|
|
4
|
+
import { a as __awaiter, _ as __rest } from '../_verture/tslib.es6-55ed4bd2.js';
|
|
5
|
+
import { jsx, Fragment, jsxs } from 'react/jsx-runtime';
|
|
6
|
+
import { useState, useEffect, useRef, memo, forwardRef, useCallback, useImperativeHandle, useMemo } from 'react';
|
|
7
|
+
import RcUpload from 'rc-upload';
|
|
8
|
+
import UploadIcon from '@para-ui/icons/UploadFile';
|
|
9
|
+
import LoadingIcon from '@para-ui/icons/Loading';
|
|
10
|
+
import { _ as _typeof } from '../_verture/typeof-498dd2b1.js';
|
|
11
|
+
import { r as regenerator } from '../_verture/index-beef914f.js';
|
|
12
|
+
import Delete from '@para-ui/icons/Delete';
|
|
13
|
+
import TextIcon from '@para-ui/icons/Text';
|
|
14
|
+
import PhotoIcon from '@para-ui/icons/Photo';
|
|
15
|
+
import clsx from 'clsx';
|
|
16
|
+
import { $ as $prefixCls, a as $rcPrefixCls } from '../_verture/constant-66aa48a1.js';
|
|
17
|
+
import { s as styleInject } from '../_verture/style-inject.es-300983ab.js';
|
|
18
|
+
import Forbid from '@para-ui/icons/Forbid';
|
|
19
|
+
import { u as useFormatMessage } from '../_verture/useFormatMessage-703f8b20.js';
|
|
20
|
+
import EditOutline from '@para-ui/icons/EditOutline';
|
|
21
|
+
import { Button } from '../Button/index.js';
|
|
22
|
+
import { Slider } from '../Slider/index.js';
|
|
23
|
+
import Cropper from 'react-easy-crop';
|
|
24
|
+
import { Modal } from '../Modal/index.js';
|
|
25
|
+
import '../_verture/unsupportedIterableToArray-cb478f24.js';
|
|
26
|
+
import '@para-ui/core/GlobalContext';
|
|
27
|
+
import '@para-ui/icons/LoadingF';
|
|
28
|
+
import '../Tooltip/index.js';
|
|
29
|
+
import 'rc-tooltip';
|
|
30
|
+
import 'rc-tooltip/lib/placements';
|
|
31
|
+
import '@para-ui/icons/Down';
|
|
32
|
+
import '../_verture/index-77f9e0fb.js';
|
|
33
|
+
import 'rc-dropdown';
|
|
34
|
+
import '../_verture/usePopupContainer-87febeb9.js';
|
|
35
|
+
import 'dayjs';
|
|
36
|
+
import '@paraview/lib';
|
|
37
|
+
import 'rc-slider';
|
|
38
|
+
import 'rc-dialog';
|
|
39
|
+
import '@para-ui/icons/Close';
|
|
40
|
+
import '../_verture/index-e2881a53.js';
|
|
41
|
+
import 'react-dom';
|
|
42
|
+
import '@para-ui/icons/CheckCircleF';
|
|
43
|
+
import '@para-ui/icons/CloseCircleF';
|
|
44
|
+
import '@para-ui/icons/WarningCircle';
|
|
45
|
+
import '@para-ui/icons/WarningCircleF';
|
|
46
|
+
|
|
47
|
+
var css_248z$4 = "@charset \"UTF-8\";\n/**\n* @author Hanz\n* @date 2021/11/11 下午3:08\n* @description\n*/\n/**\n* @author Hanz\n* @date 2021/10/20 下午2:08\n* @description color\n*/\n.paraui-v3-upload-list-text .upload-list-item {\n margin-top: 8px;\n}\n.paraui-v3-upload-list-text .upload-list-item-info {\n display: flex;\n align-items: center;\n padding: 0 8px;\n line-height: 28px;\n font-size: 14px;\n color: rgb(46, 55, 67);\n border-radius: 4px;\n transition: background-color 0.3s;\n}\n.paraui-v3-upload-list-text .upload-list-item-info .upload-list-text {\n position: relative;\n display: inline-flex;\n align-items: center;\n}\n.paraui-v3-upload-list-text .upload-list-item-info .upload-list-text .upload-list-fileicon {\n line-height: 0;\n opacity: 1;\n transition: opacity 0.3s;\n}\n.paraui-v3-upload-list-text .upload-list-item-info .upload-list-text .upload-list-fileicon svg {\n color: inherit;\n font-size: inherit;\n}\n.paraui-v3-upload-list-text .upload-list-item-info .upload-list-text-name {\n margin-left: 10px;\n}\n.paraui-v3-upload-list-text .upload-list-item-info .upload-list-text .upload-list-actions {\n position: absolute;\n opacity: 0;\n visibility: hidden;\n line-height: 0;\n transition: opacity 0.3s;\n cursor: pointer;\n}\n.paraui-v3-upload-list-text .upload-list-item-info .upload-list-text .upload-list-actions svg {\n color: rgb(235, 96, 84);\n font-size: inherit;\n}\n.paraui-v3-upload-list-text .upload-list-item-info:hover {\n background-color: rgba(171, 176, 185, 0.12);\n}\n.paraui-v3-upload-list-text .upload-list-item-info:hover .upload-list-text .upload-list-actions {\n visibility: visible;\n opacity: 1;\n}\n.paraui-v3-upload-list-text .upload-list-item-info:hover .upload-list-text .upload-list-fileicon-active {\n opacity: 0;\n}\n.paraui-v3-upload-list-picture {\n display: inline-flex;\n align-items: center;\n}\n.paraui-v3-upload-list-picture .upload-list-picture-item {\n position: relative;\n display: inline-block;\n width: 100px;\n height: 100px;\n margin-right: 16px;\n border-radius: 4px;\n cursor: default;\n}\n.paraui-v3-upload-list-picture .upload-list-picture-item::before {\n content: \" \";\n position: absolute;\n left: 0;\n right: 0;\n bottom: 0;\n top: 0;\n background-color: rgba(46, 55, 67, 0.7);\n border-radius: 4px;\n opacity: 0;\n transition: 0.3s;\n}\n.paraui-v3-upload-list-picture .upload-list-picture-item img {\n width: 100%;\n height: 100%;\n border-radius: 4px;\n}\n.paraui-v3-upload-list-picture .upload-list-picture-item .upload-list-picture-name {\n position: absolute;\n bottom: 0;\n left: 0;\n width: 100%;\n padding: 0 10px;\n font-size: 12px;\n line-height: 24px;\n text-align: center;\n text-overflow: ellipsis;\n overflow: hidden;\n white-space: nowrap;\n background-color: rgba(46, 55, 67, 0.7);\n border-radius: 0 0 4px 4px;\n color: rgb(255, 255, 255);\n transition: 0.3s;\n}\n.paraui-v3-upload-list-picture .upload-list-picture-item .upload-list-actions {\n position: absolute;\n top: 50%;\n left: 50%;\n transform: translate(-50%, -50%);\n opacity: 0;\n line-height: 0;\n cursor: pointer;\n transition: 0.3s;\n}\n.paraui-v3-upload-list-picture .upload-list-picture-item .upload-list-actions svg {\n color: rgb(255, 255, 255);\n}\n.paraui-v3-upload-list-picture .upload-list-picture-item:hover:not(.upload-list-picture-item-readonly)::before {\n opacity: 1;\n}\n.paraui-v3-upload-list-picture .upload-list-picture-item:hover:not(.upload-list-picture-item-readonly) .upload-list-actions {\n opacity: 1;\n}\n.paraui-v3-upload-list-picture .upload-list-picture-item:hover:not(.upload-list-picture-item-readonly) .upload-list-picture-name {\n opacity: 0;\n}";
|
|
48
|
+
styleInject(css_248z$4);
|
|
49
|
+
|
|
50
|
+
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
|
51
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
52
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
53
|
+
//UploadList
|
|
54
|
+
var UploadList = function UploadList(props) {
|
|
55
|
+
var _props$listType = props.listType,
|
|
56
|
+
listType = _props$listType === void 0 ? 'text' : _props$listType,
|
|
57
|
+
_props$items = props.items,
|
|
58
|
+
items = _props$items === void 0 ? [] : _props$items,
|
|
59
|
+
onRemove = props.onRemove,
|
|
60
|
+
_props$showRemoveIcon = props.showRemoveIcon,
|
|
61
|
+
showRemoveIcon = _props$showRemoveIcon === void 0 ? true : _props$showRemoveIcon,
|
|
62
|
+
removeIcon = props.removeIcon,
|
|
63
|
+
itemRender = props.itemRender,
|
|
64
|
+
readonly = props.readonly;
|
|
65
|
+
var _useState = useState([]),
|
|
66
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
67
|
+
uploadList = _useState2[0],
|
|
68
|
+
setUploadList = _useState2[1];
|
|
69
|
+
//处理删除
|
|
70
|
+
var handleRemove = function handleRemove(file, evt) {
|
|
71
|
+
evt.stopPropagation();
|
|
72
|
+
onRemove === null || onRemove === void 0 ? void 0 : onRemove(file);
|
|
73
|
+
};
|
|
74
|
+
//渲染列表actions
|
|
75
|
+
var renderActions = function renderActions(file) {
|
|
76
|
+
return showRemoveIcon && !readonly && jsx("span", Object.assign({
|
|
77
|
+
className: 'upload-list-actions',
|
|
78
|
+
onClick: function onClick(evt) {
|
|
79
|
+
return handleRemove(file, evt);
|
|
80
|
+
}
|
|
81
|
+
}, {
|
|
82
|
+
children: removeIcon || jsx(Delete, {})
|
|
83
|
+
}));
|
|
84
|
+
};
|
|
85
|
+
//文件列表 text
|
|
86
|
+
var renderFileListText = function renderFileListText() {
|
|
87
|
+
if (!(uploadList === null || uploadList === void 0 ? void 0 : uploadList.length)) return null;
|
|
88
|
+
return uploadList.map(function (file, idx) {
|
|
89
|
+
var _a;
|
|
90
|
+
if (itemRender)
|
|
91
|
+
//自定义渲染
|
|
92
|
+
return itemRender(file, uploadList);
|
|
93
|
+
var isImage = !!((_a = file.type) === null || _a === void 0 ? void 0 : _a.includes('image/'));
|
|
94
|
+
return jsx("div", Object.assign({
|
|
95
|
+
className: 'upload-list-item'
|
|
96
|
+
}, {
|
|
97
|
+
children: jsx("div", Object.assign({
|
|
98
|
+
className: 'upload-list-item-info'
|
|
99
|
+
}, {
|
|
100
|
+
children: jsxs("span", Object.assign({
|
|
101
|
+
className: 'upload-list-text'
|
|
102
|
+
}, {
|
|
103
|
+
children: [jsx("span", Object.assign({
|
|
104
|
+
className: clsx('upload-list-fileicon', showRemoveIcon && 'upload-list-fileicon-active')
|
|
105
|
+
}, {
|
|
106
|
+
children: isImage ? jsx(PhotoIcon, {}) : jsx(TextIcon, {})
|
|
107
|
+
})), renderActions(file), jsx("span", Object.assign({
|
|
108
|
+
className: "upload-list-text-name"
|
|
109
|
+
}, {
|
|
110
|
+
children: file.name
|
|
111
|
+
}))]
|
|
112
|
+
}))
|
|
113
|
+
}))
|
|
114
|
+
}), idx);
|
|
115
|
+
});
|
|
116
|
+
};
|
|
117
|
+
//文件列表 picture-card
|
|
118
|
+
var renderFileListPicture = function renderFileListPicture() {
|
|
119
|
+
if (!(uploadList === null || uploadList === void 0 ? void 0 : uploadList.length)) return null;
|
|
120
|
+
return uploadList.map(function (file, idx) {
|
|
121
|
+
if (itemRender)
|
|
122
|
+
//自定义渲染
|
|
123
|
+
return itemRender(file, uploadList);
|
|
124
|
+
return jsxs("div", Object.assign({
|
|
125
|
+
className: "upload-list-picture-item ".concat(readonly ? 'upload-list-picture-item-readonly' : '')
|
|
126
|
+
}, {
|
|
127
|
+
children: [jsx("img", {
|
|
128
|
+
src: file.dataUrl || file.url,
|
|
129
|
+
alt: file.name
|
|
130
|
+
}), jsx("span", Object.assign({
|
|
131
|
+
className: 'upload-list-picture-name',
|
|
132
|
+
title: file.name
|
|
133
|
+
}, {
|
|
134
|
+
children: file.name
|
|
135
|
+
})), renderActions(file)]
|
|
136
|
+
}), idx);
|
|
137
|
+
});
|
|
138
|
+
};
|
|
139
|
+
//处理文件
|
|
140
|
+
var handleFileFormat = function handleFileFormat() {
|
|
141
|
+
return __awaiter(void 0, void 0, void 0, /*#__PURE__*/regenerator.mark(function _callee2() {
|
|
142
|
+
var readerFileAsDataUrl, _iterator, _step, file, dataUrl;
|
|
143
|
+
return regenerator.wrap(function _callee2$(_context2) {
|
|
144
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
145
|
+
case 0:
|
|
146
|
+
if (items === null || items === void 0 ? void 0 : items.length) {
|
|
147
|
+
_context2.next = 2;
|
|
148
|
+
break;
|
|
149
|
+
}
|
|
150
|
+
return _context2.abrupt("return", setUploadList([]));
|
|
151
|
+
case 2:
|
|
152
|
+
//读取file as DataUrl
|
|
153
|
+
readerFileAsDataUrl = function readerFileAsDataUrl(file) {
|
|
154
|
+
return __awaiter(void 0, void 0, void 0, /*#__PURE__*/regenerator.mark(function _callee() {
|
|
155
|
+
return regenerator.wrap(function _callee$(_context) {
|
|
156
|
+
while (1) switch (_context.prev = _context.next) {
|
|
157
|
+
case 0:
|
|
158
|
+
return _context.abrupt("return", new Promise(function (resolve) {
|
|
159
|
+
var fileReader = new FileReader();
|
|
160
|
+
if (file.originFileObj) {
|
|
161
|
+
fileReader.onload = function () {
|
|
162
|
+
resolve(fileReader.result);
|
|
163
|
+
};
|
|
164
|
+
fileReader.readAsDataURL(file.originFileObj);
|
|
165
|
+
} else resolve('');
|
|
166
|
+
}));
|
|
167
|
+
case 1:
|
|
168
|
+
case "end":
|
|
169
|
+
return _context.stop();
|
|
170
|
+
}
|
|
171
|
+
}, _callee);
|
|
172
|
+
}));
|
|
173
|
+
};
|
|
174
|
+
_iterator = _createForOfIteratorHelper(items);
|
|
175
|
+
_context2.prev = 4;
|
|
176
|
+
_iterator.s();
|
|
177
|
+
case 6:
|
|
178
|
+
if ((_step = _iterator.n()).done) {
|
|
179
|
+
_context2.next = 15;
|
|
180
|
+
break;
|
|
181
|
+
}
|
|
182
|
+
file = _step.value;
|
|
183
|
+
if (!file.originFileObj) {
|
|
184
|
+
_context2.next = 13;
|
|
185
|
+
break;
|
|
186
|
+
}
|
|
187
|
+
_context2.next = 11;
|
|
188
|
+
return readerFileAsDataUrl(file);
|
|
189
|
+
case 11:
|
|
190
|
+
dataUrl = _context2.sent;
|
|
191
|
+
file.dataUrl = dataUrl;
|
|
192
|
+
case 13:
|
|
193
|
+
_context2.next = 6;
|
|
194
|
+
break;
|
|
195
|
+
case 15:
|
|
196
|
+
_context2.next = 20;
|
|
197
|
+
break;
|
|
198
|
+
case 17:
|
|
199
|
+
_context2.prev = 17;
|
|
200
|
+
_context2.t0 = _context2["catch"](4);
|
|
201
|
+
_iterator.e(_context2.t0);
|
|
202
|
+
case 20:
|
|
203
|
+
_context2.prev = 20;
|
|
204
|
+
_iterator.f();
|
|
205
|
+
return _context2.finish(20);
|
|
206
|
+
case 23:
|
|
207
|
+
setUploadList(_toConsumableArray(items));
|
|
208
|
+
case 24:
|
|
209
|
+
case "end":
|
|
210
|
+
return _context2.stop();
|
|
211
|
+
}
|
|
212
|
+
}, _callee2, null, [[4, 17, 20, 23]]);
|
|
213
|
+
}));
|
|
214
|
+
};
|
|
215
|
+
useEffect(function () {
|
|
216
|
+
if (listType === 'picture-card') handleFileFormat();else setUploadList(function (pre) {
|
|
217
|
+
if (items) return _toConsumableArray(items);
|
|
218
|
+
return pre;
|
|
219
|
+
});
|
|
220
|
+
}, [items]);
|
|
221
|
+
return jsx(Fragment, {
|
|
222
|
+
children: listType === 'text' ? jsx("section", Object.assign({
|
|
223
|
+
className: "".concat($prefixCls, "-upload-list-text")
|
|
224
|
+
}, {
|
|
225
|
+
children: renderFileListText()
|
|
226
|
+
})) : jsx("section", Object.assign({
|
|
227
|
+
className: "".concat($prefixCls, "-upload-list-picture")
|
|
228
|
+
}, {
|
|
229
|
+
children: renderFileListPicture()
|
|
230
|
+
}))
|
|
231
|
+
});
|
|
232
|
+
};
|
|
233
|
+
|
|
234
|
+
var css_248z$3 = "@charset \"UTF-8\";\n/**\n* @author Hanz\n* @date 2021/11/15 下午7:12\n* @description\n*/\n/**\n* @author Hanz\n* @date 2021/10/20 下午2:08\n* @description color\n*/\n.paraui-v3-upload-error {\n position: absolute;\n left: 0;\n top: 100%;\n margin-top: 12px;\n display: inline-flex;\n align-items: center;\n padding: 0 12px;\n line-height: 28px;\n background-color: #FDF6F5;\n color: rgb(235, 96, 84);\n font-size: 14px;\n white-space: nowrap;\n border-radius: 4px;\n z-index: 1;\n}\n.paraui-v3-upload-error svg {\n margin-right: 4px;\n font-size: inherit;\n color: inherit;\n}\n.paraui-v3-upload-error-image {\n margin-top: 8px;\n}\n.paraui-v3-upload-error-drag {\n top: 20px;\n left: 50%;\n margin-top: 0;\n transform: translateX(-50%);\n}";
|
|
235
|
+
styleInject(css_248z$3);
|
|
236
|
+
|
|
237
|
+
//error tip
|
|
238
|
+
var ErrorTip = function ErrorTip(props) {
|
|
239
|
+
return jsxs("div", Object.assign({
|
|
240
|
+
className: clsx("".concat($prefixCls, "-upload-error"), props.className)
|
|
241
|
+
}, {
|
|
242
|
+
children: [jsx(Forbid, {}), props.message]
|
|
243
|
+
}));
|
|
244
|
+
};
|
|
245
|
+
|
|
246
|
+
var en = {
|
|
247
|
+
uploadError: 'Upload error',
|
|
248
|
+
uploading: 'Uploading',
|
|
249
|
+
clickUploadFile: 'Click to upload file',
|
|
250
|
+
dragFileUpload: 'After downloading the template and completing the information, you can directly drag and drop the file here to upload it. Supported formats: XLS, XLSX...',
|
|
251
|
+
add: 'Add',
|
|
252
|
+
edit: 'Edit',
|
|
253
|
+
disabled: 'Disabled',
|
|
254
|
+
delete: 'Delete',
|
|
255
|
+
editImage: 'Edit image'
|
|
256
|
+
};
|
|
257
|
+
|
|
258
|
+
var zh = {
|
|
259
|
+
uploadError: '上传失败',
|
|
260
|
+
uploading: '正在上传',
|
|
261
|
+
clickUploadFile: '点击上传文件',
|
|
262
|
+
dragFileUpload: '下载模板并完善信息后,可直接将文件拖拽到此处进行上传,支持格式:XLS、XLSX...',
|
|
263
|
+
add: '新增',
|
|
264
|
+
edit: '编辑',
|
|
265
|
+
disabled: '禁用',
|
|
266
|
+
delete: '删除',
|
|
267
|
+
editImage: '编辑图片'
|
|
268
|
+
};
|
|
269
|
+
|
|
270
|
+
var localeJson = {
|
|
271
|
+
zh: zh,
|
|
272
|
+
en: en
|
|
273
|
+
};
|
|
274
|
+
|
|
275
|
+
var css_248z$2 = "@charset \"UTF-8\";\n/**\n* @author Hanz\n* @date 2021/11/11 下午7:31\n* @description\n*/\n/**\n* @author Hanz\n* @date 2021/10/20 下午2:08\n* @description color\n*/\n.paraui-v3-upload-image {\n display: inline-flex;\n align-items: center;\n}\n.paraui-v3-upload-image .upload-image-select {\n position: relative;\n width: 100px;\n height: 100px;\n background-color: rgba(171, 176, 185, 0.12);\n border-radius: 4px;\n cursor: pointer;\n transition: 0.3s;\n}\n.paraui-v3-upload-image .upload-image-select-loading {\n pointer-events: none;\n}\n.paraui-v3-upload-image .upload-image-select .component-upload {\n display: inline-block;\n width: 100%;\n height: 100%;\n}\n.paraui-v3-upload-image .upload-image-select:hover {\n background-color: rgba(54, 102, 214, 0.05);\n}\n.paraui-v3-upload-image .upload-image-select:hover .upload-image-picture-card {\n color: rgb(54, 102, 214);\n}\n.paraui-v3-upload-image .upload-image-picture-card {\n display: inline-flex;\n flex-direction: column;\n width: 100%;\n height: 100%;\n align-items: center;\n justify-content: center;\n color: rgb(46, 55, 67);\n font-size: 14px;\n}\n.paraui-v3-upload-image .upload-image-picture-card .upload-img-wrapper {\n position: relative;\n width: 100%;\n height: 100%;\n cursor: default;\n}\n.paraui-v3-upload-image .upload-image-picture-card .upload-img-wrapper img {\n width: 100%;\n height: 100%;\n border-radius: 4px;\n}\n.paraui-v3-upload-image .upload-image-picture-card .upload-img-wrapper::before {\n content: \" \";\n position: absolute;\n left: 0;\n right: 0;\n bottom: 0;\n top: 0;\n background-color: rgba(46, 55, 67, 0.7);\n border-radius: 4px;\n opacity: 0;\n transition: 0.3s;\n}\n.paraui-v3-upload-image .upload-image-picture-card .upload-img-wrapper-name {\n position: absolute;\n bottom: 0;\n left: 0;\n width: 100%;\n padding: 0 10px;\n font-size: 12px;\n line-height: 24px;\n text-align: center;\n text-overflow: ellipsis;\n overflow: hidden;\n white-space: nowrap;\n background-color: rgba(46, 55, 67, 0.7);\n border-radius: 0 0 4px 4px;\n color: rgb(255, 255, 255);\n transition: 0.3s;\n}\n.paraui-v3-upload-image .upload-image-picture-card .upload-img-wrapper-action {\n position: absolute;\n top: 50%;\n left: 50%;\n transform: translate(-50%, -50%);\n opacity: 0;\n line-height: 0;\n cursor: pointer;\n transition: 0.3s;\n}\n.paraui-v3-upload-image .upload-image-picture-card .upload-img-wrapper-action svg {\n color: rgb(255, 255, 255);\n}\n.paraui-v3-upload-image .upload-image-picture-card .upload-img-wrapper:hover::before {\n opacity: 1;\n}\n.paraui-v3-upload-image .upload-image-picture-card .upload-img-wrapper:hover .upload-img-wrapper-name {\n opacity: 0;\n}\n.paraui-v3-upload-image .upload-image-picture-card .upload-img-wrapper:hover .upload-img-wrapper-action {\n opacity: 1;\n}\n.paraui-v3-upload-image .upload-image-picture-card .upload-image-icon {\n color: rgb(54, 102, 214);\n font-size: 30px;\n}\n.paraui-v3-upload-image .upload-image-picture-card .upload-image-loading {\n color: rgb(54, 102, 214);\n font-size: 30px;\n animation: imageLoadingCircle 1s infinite linear;\n}\n.paraui-v3-upload-image .upload-image-picture-card .upload-image-text {\n margin-top: 6px;\n color: inherit;\n transition: 0.3s;\n}\n.paraui-v3-upload-image .upload-image-picture-card .upload-image-text-loading {\n color: rgb(54, 102, 214);\n}\n@keyframes imageLoadingCircle {\n 100% {\n transform: rotate(360deg);\n }\n}";
|
|
276
|
+
styleInject(css_248z$2);
|
|
277
|
+
|
|
278
|
+
//ImageUpload
|
|
279
|
+
var ImageUpload = function ImageUpload(props) {
|
|
280
|
+
var className = props.className,
|
|
281
|
+
style = props.style,
|
|
282
|
+
_onStart = props.onStart,
|
|
283
|
+
_onSuccess = props.onSuccess,
|
|
284
|
+
_onError = props.onError,
|
|
285
|
+
_onProgress = props.onProgress,
|
|
286
|
+
onRemove = props.onRemove,
|
|
287
|
+
_beforeUpload = props.beforeUpload,
|
|
288
|
+
onChange = props.onChange,
|
|
289
|
+
_props$defaultFileLis = props.defaultFileList,
|
|
290
|
+
defaultFileList = _props$defaultFileLis === void 0 ? [] : _props$defaultFileLis,
|
|
291
|
+
fileList = props.fileList,
|
|
292
|
+
_props$showUploadList = props.showUploadList,
|
|
293
|
+
showUploadList = _props$showUploadList === void 0 ? true : _props$showUploadList,
|
|
294
|
+
maxCount = props.maxCount,
|
|
295
|
+
_props$children = props.children,
|
|
296
|
+
children = _props$children === void 0 ? null : _props$children,
|
|
297
|
+
itemRender = props.itemRender,
|
|
298
|
+
_props$showUploadErro = props.showUploadError,
|
|
299
|
+
showUploadError = _props$showUploadErro === void 0 ? true : _props$showUploadErro,
|
|
300
|
+
_props$stash = props.stash,
|
|
301
|
+
stash = _props$stash === void 0 ? false : _props$stash,
|
|
302
|
+
_props$uploading = props.uploading,
|
|
303
|
+
uploading = _props$uploading === void 0 ? true : _props$uploading,
|
|
304
|
+
_props$showLoading = props.showLoading,
|
|
305
|
+
loading = _props$showLoading === void 0 ? true : _props$showLoading,
|
|
306
|
+
defaultImage = props.defaultImage,
|
|
307
|
+
readonly = props.readonly,
|
|
308
|
+
restProps = __rest(props, ["className", "style", "onStart", "onSuccess", "onError", "onProgress", "onRemove", "beforeUpload", "onChange", "defaultFileList", "fileList", "showUploadList", "maxCount", "children", "itemRender", "showUploadError", "stash", "uploading", "showLoading", "defaultImage", "readonly"]);
|
|
309
|
+
var intl = useFormatMessage('Upload', localeJson);
|
|
310
|
+
var _useState = useState(defaultFileList),
|
|
311
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
312
|
+
uploadFileList = _useState2[0],
|
|
313
|
+
setUploadFileList = _useState2[1]; //文件列表
|
|
314
|
+
var _useState3 = useState(false),
|
|
315
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
316
|
+
showLoading = _useState4[0],
|
|
317
|
+
setShowLoading = _useState4[1]; //upload loading
|
|
318
|
+
var _useState5 = useState(false),
|
|
319
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
320
|
+
errTip = _useState6[0],
|
|
321
|
+
setErrTip = _useState6[1]; //upload error tip
|
|
322
|
+
var _useState7 = useState({
|
|
323
|
+
imageUrl: ''
|
|
324
|
+
}),
|
|
325
|
+
_useState8 = _slicedToArray(_useState7, 2),
|
|
326
|
+
avatar = _useState8[0],
|
|
327
|
+
setAvatar = _useState8[1]; //不显示列表时上传头像
|
|
328
|
+
var _ref = typeof showUploadList === 'boolean' ? {} : showUploadList,
|
|
329
|
+
showRemoveIcon = _ref.showRemoveIcon,
|
|
330
|
+
removeIcon = _ref.removeIcon; //显示上传列表
|
|
331
|
+
var _ref2 = typeof showUploadError === 'boolean' ? {} : showUploadError,
|
|
332
|
+
_ref2$uploadErrorMsg = _ref2.uploadErrorMsg,
|
|
333
|
+
uploadErrorMsg = _ref2$uploadErrorMsg === void 0 ? intl({
|
|
334
|
+
id: 'uploadError'
|
|
335
|
+
}) : _ref2$uploadErrorMsg,
|
|
336
|
+
_ref2$leaveDelay = _ref2.leaveDelay,
|
|
337
|
+
leaveDelay = _ref2$leaveDelay === void 0 ? 2000 : _ref2$leaveDelay; //错误信息提示
|
|
338
|
+
var cropFileRef = useRef(); //裁剪文件
|
|
339
|
+
//复写属性
|
|
340
|
+
var overrideProps = Object.assign(Object.assign({
|
|
341
|
+
accept: 'image/*'
|
|
342
|
+
}, restProps), {
|
|
343
|
+
beforeUpload: function beforeUpload(file, fileList) {
|
|
344
|
+
return __awaiter(void 0, void 0, void 0, /*#__PURE__*/regenerator.mark(function _callee() {
|
|
345
|
+
var result;
|
|
346
|
+
return regenerator.wrap(function _callee$(_context) {
|
|
347
|
+
while (1) switch (_context.prev = _context.next) {
|
|
348
|
+
case 0:
|
|
349
|
+
if (restProps.action && loading && uploading) setShowLoading(true);
|
|
350
|
+
_context.next = 3;
|
|
351
|
+
return _beforeUpload === null || _beforeUpload === void 0 ? void 0 : _beforeUpload(file, fileList);
|
|
352
|
+
case 3:
|
|
353
|
+
result = _context.sent;
|
|
354
|
+
if (!(result === false)) {
|
|
355
|
+
_context.next = 9;
|
|
356
|
+
break;
|
|
357
|
+
}
|
|
358
|
+
setShowLoading(false);
|
|
359
|
+
return _context.abrupt("return", false);
|
|
360
|
+
case 9:
|
|
361
|
+
if (!(_typeof(result) === 'object' && result)) {
|
|
362
|
+
_context.next = 16;
|
|
363
|
+
break;
|
|
364
|
+
}
|
|
365
|
+
if (!(result instanceof File || result instanceof Blob)) {
|
|
366
|
+
_context.next = 12;
|
|
367
|
+
break;
|
|
368
|
+
}
|
|
369
|
+
return _context.abrupt("return", result);
|
|
370
|
+
case 12:
|
|
371
|
+
cropFileRef.current = result.cropFile;
|
|
372
|
+
return _context.abrupt("return", result.isUpload);
|
|
373
|
+
case 16:
|
|
374
|
+
return _context.abrupt("return", true);
|
|
375
|
+
case 17:
|
|
376
|
+
case "end":
|
|
377
|
+
return _context.stop();
|
|
378
|
+
}
|
|
379
|
+
}, _callee);
|
|
380
|
+
}));
|
|
381
|
+
},
|
|
382
|
+
onStart: function onStart(file) {
|
|
383
|
+
_onStart === null || _onStart === void 0 ? void 0 : _onStart(file);
|
|
384
|
+
},
|
|
385
|
+
onSuccess: function onSuccess(response, file, xhr) {
|
|
386
|
+
setShowLoading(false);
|
|
387
|
+
errTip && showErrTip(false);
|
|
388
|
+
var nextFileList = updateFileList(file);
|
|
389
|
+
onInternalChange(nextFileList);
|
|
390
|
+
_onSuccess === null || _onSuccess === void 0 ? void 0 : _onSuccess(response, file, xhr);
|
|
391
|
+
},
|
|
392
|
+
onError: function onError(error, response, file) {
|
|
393
|
+
setShowLoading(false);
|
|
394
|
+
showErrTip(!!showUploadError);
|
|
395
|
+
_onError === null || _onError === void 0 ? void 0 : _onError(error, response, file);
|
|
396
|
+
},
|
|
397
|
+
onProgress: function onProgress(e, file) {
|
|
398
|
+
_onProgress === null || _onProgress === void 0 ? void 0 : _onProgress(e, file);
|
|
399
|
+
},
|
|
400
|
+
onBatchStart: function onBatchStart(fileList) {
|
|
401
|
+
if (stash) {
|
|
402
|
+
if (cropFileRef.current) {
|
|
403
|
+
var idx = fileList.findIndex(function (_) {
|
|
404
|
+
var _a;
|
|
405
|
+
return _.file.uid === ((_a = cropFileRef.current) === null || _a === void 0 ? void 0 : _a.uid);
|
|
406
|
+
});
|
|
407
|
+
if (idx > -1) {
|
|
408
|
+
fileList.splice(idx, 1, {
|
|
409
|
+
file: cropFileRef.current,
|
|
410
|
+
parsedFile: cropFileRef.current
|
|
411
|
+
});
|
|
412
|
+
}
|
|
413
|
+
}
|
|
414
|
+
var arr = fileList.map(function (_) {
|
|
415
|
+
return _.parsedFile || _.file;
|
|
416
|
+
});
|
|
417
|
+
var mList = mergedFileList(arr);
|
|
418
|
+
onInternalChange(mList);
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
});
|
|
422
|
+
//内部变化
|
|
423
|
+
var onInternalChange = function onInternalChange(changedFileList) {
|
|
424
|
+
return __awaiter(void 0, void 0, void 0, /*#__PURE__*/regenerator.mark(function _callee2() {
|
|
425
|
+
var cloneList, file, imageUrl;
|
|
426
|
+
return regenerator.wrap(function _callee2$(_context2) {
|
|
427
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
428
|
+
case 0:
|
|
429
|
+
cloneList = _toConsumableArray(changedFileList);
|
|
430
|
+
if (showUploadList) {
|
|
431
|
+
_context2.next = 13;
|
|
432
|
+
break;
|
|
433
|
+
}
|
|
434
|
+
//不显示上传列表
|
|
435
|
+
file = cloneList.slice(-1)[0];
|
|
436
|
+
if (!file) {
|
|
437
|
+
_context2.next = 11;
|
|
438
|
+
break;
|
|
439
|
+
}
|
|
440
|
+
_context2.next = 6;
|
|
441
|
+
return readerFileAsDataUrl(file);
|
|
442
|
+
case 6:
|
|
443
|
+
imageUrl = _context2.sent;
|
|
444
|
+
file.dataUrl = imageUrl;
|
|
445
|
+
avatar.imageUrl = imageUrl;
|
|
446
|
+
avatar.imageName = file.name;
|
|
447
|
+
setAvatar(Object.assign({}, avatar));
|
|
448
|
+
case 11:
|
|
449
|
+
onChange === null || onChange === void 0 ? void 0 : onChange([file]);
|
|
450
|
+
return _context2.abrupt("return");
|
|
451
|
+
case 13:
|
|
452
|
+
if (maxCount === 1) {
|
|
453
|
+
cloneList = cloneList.slice(-1);
|
|
454
|
+
} else if (maxCount) {
|
|
455
|
+
cloneList = cloneList.slice(0, maxCount);
|
|
456
|
+
}
|
|
457
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(cloneList);
|
|
458
|
+
setUploadFileList(cloneList);
|
|
459
|
+
case 16:
|
|
460
|
+
case "end":
|
|
461
|
+
return _context2.stop();
|
|
462
|
+
}
|
|
463
|
+
}, _callee2);
|
|
464
|
+
}));
|
|
465
|
+
};
|
|
466
|
+
//更新文件列表
|
|
467
|
+
var updateFileList = function updateFileList(file) {
|
|
468
|
+
var cloneList = _toConsumableArray(uploadFileList);
|
|
469
|
+
var fileObj = Object.assign(Object.assign({}, file), {
|
|
470
|
+
lastModified: file.lastModified,
|
|
471
|
+
lastModifiedDate: file.lastModifiedDate,
|
|
472
|
+
name: file.name,
|
|
473
|
+
size: file.size,
|
|
474
|
+
type: file.type,
|
|
475
|
+
uid: file.uid,
|
|
476
|
+
originFileObj: file
|
|
477
|
+
});
|
|
478
|
+
return cloneList.concat(fileObj);
|
|
479
|
+
};
|
|
480
|
+
//合并文件列表
|
|
481
|
+
var mergedFileList = function mergedFileList(fileList) {
|
|
482
|
+
var cloneList = _toConsumableArray(uploadFileList);
|
|
483
|
+
var newFileList = fileList.map(function (file) {
|
|
484
|
+
return Object.assign(Object.assign({}, file), {
|
|
485
|
+
lastModified: file.lastModified,
|
|
486
|
+
lastModifiedDate: file.lastModifiedDate,
|
|
487
|
+
name: file.name,
|
|
488
|
+
size: file.size,
|
|
489
|
+
type: file.type,
|
|
490
|
+
uid: file.uid,
|
|
491
|
+
originFileObj: file
|
|
492
|
+
});
|
|
493
|
+
});
|
|
494
|
+
return cloneList.concat(newFileList);
|
|
495
|
+
};
|
|
496
|
+
//删除文件
|
|
497
|
+
var handleRemove = function handleRemove(file) {
|
|
498
|
+
Promise.resolve(typeof onRemove === 'function' ? onRemove(file) : onRemove).then(function (ret) {
|
|
499
|
+
// Prevent removing file
|
|
500
|
+
if (ret === false) return;
|
|
501
|
+
var idx = uploadFileList.findIndex(function (_) {
|
|
502
|
+
return _.uid === file.uid;
|
|
503
|
+
});
|
|
504
|
+
if (idx > -1) uploadFileList.splice(idx, 1);
|
|
505
|
+
onInternalChange(uploadFileList);
|
|
506
|
+
});
|
|
507
|
+
};
|
|
508
|
+
//读取dataUrl
|
|
509
|
+
var readerFileAsDataUrl = function readerFileAsDataUrl(file) {
|
|
510
|
+
return __awaiter(void 0, void 0, void 0, /*#__PURE__*/regenerator.mark(function _callee3() {
|
|
511
|
+
return regenerator.wrap(function _callee3$(_context3) {
|
|
512
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
513
|
+
case 0:
|
|
514
|
+
return _context3.abrupt("return", new Promise(function (resolve) {
|
|
515
|
+
var fileReader = new FileReader();
|
|
516
|
+
if (file.originFileObj) {
|
|
517
|
+
fileReader.onload = function () {
|
|
518
|
+
resolve(fileReader.result);
|
|
519
|
+
};
|
|
520
|
+
fileReader.readAsDataURL(file.originFileObj);
|
|
521
|
+
} else resolve('');
|
|
522
|
+
}));
|
|
523
|
+
case 1:
|
|
524
|
+
case "end":
|
|
525
|
+
return _context3.stop();
|
|
526
|
+
}
|
|
527
|
+
}, _callee3);
|
|
528
|
+
}));
|
|
529
|
+
};
|
|
530
|
+
//显示错误提示
|
|
531
|
+
var showErrTip = function showErrTip(flag) {
|
|
532
|
+
setErrTip(flag);
|
|
533
|
+
if (leaveDelay < 0) return;
|
|
534
|
+
setTimeout(function () {
|
|
535
|
+
setErrTip(false);
|
|
536
|
+
}, leaveDelay);
|
|
537
|
+
};
|
|
538
|
+
useEffect(function () {
|
|
539
|
+
if (fileList) {
|
|
540
|
+
setUploadFileList(_toConsumableArray(fileList));
|
|
541
|
+
}
|
|
542
|
+
}, [fileList]);
|
|
543
|
+
useEffect(function () {
|
|
544
|
+
if (defaultImage) {
|
|
545
|
+
setAvatar(Object.assign({}, defaultImage));
|
|
546
|
+
}
|
|
547
|
+
}, [defaultImage]);
|
|
548
|
+
//渲染上传列表
|
|
549
|
+
var renderUploadList = function renderUploadList() {
|
|
550
|
+
return showUploadList && jsx(UploadList, {
|
|
551
|
+
listType: 'picture-card',
|
|
552
|
+
readonly: readonly,
|
|
553
|
+
items: uploadFileList,
|
|
554
|
+
showRemoveIcon: showRemoveIcon,
|
|
555
|
+
removeIcon: removeIcon,
|
|
556
|
+
onRemove: handleRemove,
|
|
557
|
+
itemRender: itemRender
|
|
558
|
+
});
|
|
559
|
+
};
|
|
560
|
+
//渲染内容
|
|
561
|
+
var renderUploadContent = function renderUploadContent() {
|
|
562
|
+
var _a;
|
|
563
|
+
if (!showUploadList && avatar.imageUrl && !showLoading) {
|
|
564
|
+
return jsxs("div", Object.assign({
|
|
565
|
+
className: 'upload-img-wrapper'
|
|
566
|
+
}, {
|
|
567
|
+
children: [jsx("img", {
|
|
568
|
+
src: avatar.imageUrl,
|
|
569
|
+
alt: (_a = avatar.imageName) !== null && _a !== void 0 ? _a : ''
|
|
570
|
+
}), avatar.imageName && jsx("span", Object.assign({
|
|
571
|
+
className: "upload-img-wrapper-name"
|
|
572
|
+
}, {
|
|
573
|
+
children: avatar.imageName
|
|
574
|
+
})), jsx("span", Object.assign({
|
|
575
|
+
className: 'upload-img-wrapper-action'
|
|
576
|
+
}, {
|
|
577
|
+
children: jsx(EditOutline, {})
|
|
578
|
+
}))]
|
|
579
|
+
}));
|
|
580
|
+
}
|
|
581
|
+
return jsxs(Fragment, {
|
|
582
|
+
children: [showLoading ? jsx(LoadingIcon, {
|
|
583
|
+
className: 'upload-image-loading'
|
|
584
|
+
}) : jsx(UploadIcon, {
|
|
585
|
+
className: 'upload-image-icon'
|
|
586
|
+
}), jsx("span", Object.assign({
|
|
587
|
+
className: clsx('upload-image-text', showLoading && 'upload-image-text-loading')
|
|
588
|
+
}, {
|
|
589
|
+
children: showLoading ? intl({
|
|
590
|
+
id: 'uploading'
|
|
591
|
+
}) : children
|
|
592
|
+
}))]
|
|
593
|
+
});
|
|
594
|
+
};
|
|
595
|
+
//渲染上传控件
|
|
596
|
+
var renderUploadSelector = function renderUploadSelector() {
|
|
597
|
+
if (readonly) return null;
|
|
598
|
+
return jsxs("div", Object.assign({
|
|
599
|
+
className: clsx('upload-image-select', showLoading && 'upload-image-select-loading')
|
|
600
|
+
}, {
|
|
601
|
+
children: [jsx(RcUpload, Object.assign({}, overrideProps, {
|
|
602
|
+
prefixCls: "".concat($rcPrefixCls, "-upload")
|
|
603
|
+
}, {
|
|
604
|
+
children: jsx("div", Object.assign({
|
|
605
|
+
className: 'upload-image-picture-card'
|
|
606
|
+
}, {
|
|
607
|
+
children: renderUploadContent()
|
|
608
|
+
}))
|
|
609
|
+
})), errTip && jsx(ErrorTip, {
|
|
610
|
+
message: uploadErrorMsg,
|
|
611
|
+
className: "".concat($prefixCls, "-upload-error-image")
|
|
612
|
+
})]
|
|
613
|
+
}));
|
|
614
|
+
};
|
|
615
|
+
return jsxs("div", Object.assign({
|
|
616
|
+
className: clsx("".concat($prefixCls, "-upload-image"), className),
|
|
617
|
+
style: style
|
|
618
|
+
}, {
|
|
619
|
+
children: [renderUploadList(), renderUploadSelector()]
|
|
620
|
+
}));
|
|
621
|
+
};
|
|
622
|
+
|
|
623
|
+
//Dragger upload
|
|
624
|
+
var Dragger = function Dragger(props) {
|
|
625
|
+
return jsx(Upload, Object.assign({}, props, {
|
|
626
|
+
type: 'drag'
|
|
627
|
+
}));
|
|
628
|
+
};
|
|
629
|
+
|
|
630
|
+
var PREFIX = "".concat($prefixCls, "-img-crop");
|
|
631
|
+
var INIT_ZOOM = 1;
|
|
632
|
+
var ZOOM_STEP = 0.1;
|
|
633
|
+
var INIT_ROTATE = 0;
|
|
634
|
+
var ROTATE_STEP = 1;
|
|
635
|
+
var MIN_ROTATE = -180;
|
|
636
|
+
var MAX_ROTATE = 180;
|
|
637
|
+
|
|
638
|
+
var EasyCrop = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
639
|
+
var cropperRef = props.cropperRef,
|
|
640
|
+
image = props.image,
|
|
641
|
+
aspect = props.aspect,
|
|
642
|
+
shape = props.shape,
|
|
643
|
+
grid = props.grid,
|
|
644
|
+
zoom = props.zoom,
|
|
645
|
+
rotate = props.rotate,
|
|
646
|
+
minZoom = props.minZoom,
|
|
647
|
+
maxZoom = props.maxZoom,
|
|
648
|
+
fixedCropSize = props.fixedCropSize,
|
|
649
|
+
cropperProps = props.cropperProps;
|
|
650
|
+
var _useState = useState({
|
|
651
|
+
x: 0,
|
|
652
|
+
y: 0
|
|
653
|
+
}),
|
|
654
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
655
|
+
crop = _useState2[0],
|
|
656
|
+
onCropChange = _useState2[1]; //裁剪变化
|
|
657
|
+
var _useState3 = useState({
|
|
658
|
+
width: 0,
|
|
659
|
+
height: 0
|
|
660
|
+
}),
|
|
661
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
662
|
+
cropSize = _useState4[0],
|
|
663
|
+
setCropSize = _useState4[1]; //裁剪大小
|
|
664
|
+
var _useState5 = useState(INIT_ZOOM),
|
|
665
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
666
|
+
zoomVal = _useState6[0],
|
|
667
|
+
setZoomVal = _useState6[1]; //缩放值
|
|
668
|
+
var _useState7 = useState(INIT_ROTATE),
|
|
669
|
+
_useState8 = _slicedToArray(_useState7, 2),
|
|
670
|
+
rotateVal = _useState8[0],
|
|
671
|
+
setRotateVal = _useState8[1]; //旋转值
|
|
672
|
+
var cropPixelsRef = useRef({
|
|
673
|
+
width: 0,
|
|
674
|
+
height: 0,
|
|
675
|
+
x: 0,
|
|
676
|
+
y: 0
|
|
677
|
+
}); //裁剪区域
|
|
678
|
+
//media 加载完成回调
|
|
679
|
+
var onMediaLoaded = useCallback(function (mediaSize) {
|
|
680
|
+
if (fixedCropSize) return;
|
|
681
|
+
var width = mediaSize.width,
|
|
682
|
+
height = mediaSize.height;
|
|
683
|
+
var ratioWidth = height * aspect;
|
|
684
|
+
if (width > ratioWidth) {
|
|
685
|
+
setCropSize({
|
|
686
|
+
width: ratioWidth,
|
|
687
|
+
height: height
|
|
688
|
+
});
|
|
689
|
+
} else {
|
|
690
|
+
setCropSize({
|
|
691
|
+
width: width,
|
|
692
|
+
height: width / aspect
|
|
693
|
+
});
|
|
694
|
+
}
|
|
695
|
+
}, [aspect]);
|
|
696
|
+
//裁剪完成回调
|
|
697
|
+
var onCropComplete = useCallback(function (croppedArea, croppedAreaPixels) {
|
|
698
|
+
cropPixelsRef.current = croppedAreaPixels;
|
|
699
|
+
}, []);
|
|
700
|
+
//ref 暴露方法
|
|
701
|
+
useImperativeHandle(ref, function () {
|
|
702
|
+
return {
|
|
703
|
+
rotateVal: rotateVal,
|
|
704
|
+
setZoomVal: setZoomVal,
|
|
705
|
+
setRotateVal: setRotateVal,
|
|
706
|
+
cropPixelsRef: cropPixelsRef
|
|
707
|
+
};
|
|
708
|
+
}, [rotateVal]);
|
|
709
|
+
return jsxs(Fragment, {
|
|
710
|
+
children: [jsx(Cropper, Object.assign({}, cropperProps, {
|
|
711
|
+
ref: cropperRef,
|
|
712
|
+
image: image,
|
|
713
|
+
crop: crop,
|
|
714
|
+
cropSize: !fixedCropSize ? cropSize : fixedCropSize,
|
|
715
|
+
onCropChange: onCropChange,
|
|
716
|
+
aspect: aspect,
|
|
717
|
+
cropShape: shape,
|
|
718
|
+
showGrid: grid,
|
|
719
|
+
zoomWithScroll: zoom,
|
|
720
|
+
zoom: zoomVal,
|
|
721
|
+
rotation: rotateVal,
|
|
722
|
+
onZoomChange: setZoomVal,
|
|
723
|
+
onRotationChange: setRotateVal,
|
|
724
|
+
minZoom: minZoom,
|
|
725
|
+
maxZoom: maxZoom,
|
|
726
|
+
onMediaLoaded: onMediaLoaded,
|
|
727
|
+
onCropComplete: onCropComplete,
|
|
728
|
+
classes: {
|
|
729
|
+
containerClassName: "".concat(PREFIX, "-container"),
|
|
730
|
+
mediaClassName: "".concat(PREFIX, "-media")
|
|
731
|
+
}
|
|
732
|
+
})), zoom && jsxs("section", Object.assign({
|
|
733
|
+
className: "".concat(PREFIX, "-control ").concat(PREFIX, "-control-zoom")
|
|
734
|
+
}, {
|
|
735
|
+
children: [jsx("button", Object.assign({
|
|
736
|
+
onClick: function onClick() {
|
|
737
|
+
return setZoomVal(zoomVal - ZOOM_STEP);
|
|
738
|
+
},
|
|
739
|
+
disabled: zoomVal - ZOOM_STEP < minZoom
|
|
740
|
+
}, {
|
|
741
|
+
children: "\uFF0D"
|
|
742
|
+
})), jsx(Slider, {
|
|
743
|
+
min: minZoom,
|
|
744
|
+
max: maxZoom,
|
|
745
|
+
step: ZOOM_STEP,
|
|
746
|
+
value: zoomVal,
|
|
747
|
+
onChange: setZoomVal
|
|
748
|
+
}), jsx("button", Object.assign({
|
|
749
|
+
onClick: function onClick() {
|
|
750
|
+
return setZoomVal(zoomVal + ZOOM_STEP);
|
|
751
|
+
},
|
|
752
|
+
disabled: zoomVal + ZOOM_STEP > maxZoom
|
|
753
|
+
}, {
|
|
754
|
+
children: "\uFF0B"
|
|
755
|
+
}))]
|
|
756
|
+
})), rotate && jsxs("section", Object.assign({
|
|
757
|
+
className: "".concat(PREFIX, "-control ").concat(PREFIX, "-control-rotate")
|
|
758
|
+
}, {
|
|
759
|
+
children: [jsx("button", Object.assign({
|
|
760
|
+
onClick: function onClick() {
|
|
761
|
+
return setRotateVal(rotateVal - ROTATE_STEP);
|
|
762
|
+
},
|
|
763
|
+
disabled: rotateVal === MIN_ROTATE
|
|
764
|
+
}, {
|
|
765
|
+
children: "\u21BA"
|
|
766
|
+
})), jsx(Slider, {
|
|
767
|
+
min: MIN_ROTATE,
|
|
768
|
+
max: MAX_ROTATE,
|
|
769
|
+
step: ROTATE_STEP,
|
|
770
|
+
value: rotateVal,
|
|
771
|
+
onChange: setRotateVal
|
|
772
|
+
}), jsx("button", Object.assign({
|
|
773
|
+
onClick: function onClick() {
|
|
774
|
+
return setRotateVal(rotateVal + ROTATE_STEP);
|
|
775
|
+
},
|
|
776
|
+
disabled: rotateVal === MAX_ROTATE
|
|
777
|
+
}, {
|
|
778
|
+
children: "\u21BB"
|
|
779
|
+
}))]
|
|
780
|
+
}))]
|
|
781
|
+
});
|
|
782
|
+
});
|
|
783
|
+
var EasyCrop$1 = /*#__PURE__*/memo(EasyCrop);
|
|
784
|
+
|
|
785
|
+
var css_248z$1 = "@charset \"UTF-8\";\n/**\n* @author Hanz\n* @date 2022/4/20 下午4:44\n* @description\n*/\n/**\n* @author Hanz\n* @date 2021/10/20 下午2:08\n* @description color\n*/\n.paraui-v3-img-crop-modal .paraui-v3-img-crop-container {\n position: relative;\n width: 100%;\n height: 40vh;\n}\n.paraui-v3-img-crop-modal .paraui-v3-img-crop-control {\n display: flex;\n align-items: center;\n width: 60%;\n margin-left: auto;\n margin-right: auto;\n}\n.paraui-v3-img-crop-modal .paraui-v3-img-crop-control:first-of-type {\n margin-top: 16px;\n}\n.paraui-v3-img-crop-modal .paraui-v3-img-crop-control:last-of-type {\n margin-bottom: -8px;\n}\n.paraui-v3-img-crop-modal .paraui-v3-img-crop-control button {\n display: flex;\n justify-content: center;\n align-items: center;\n width: 34px;\n height: 34px;\n padding: 0;\n font-style: normal;\n background: transparent;\n border: 0;\n outline: 0;\n cursor: pointer;\n}\n.paraui-v3-img-crop-modal .paraui-v3-img-crop-control button[disabled] {\n cursor: default;\n}\n.paraui-v3-img-crop-modal .paraui-v3-img-crop-control button + div:only-of-type {\n flex: 1;\n margin: 0 8px;\n}\n.paraui-v3-img-crop-modal .paraui-v3-img-crop-control-zoom button {\n font-size: 18px;\n}\n.paraui-v3-img-crop-modal .paraui-v3-img-crop-control-rotate button {\n font-size: 16px;\n}\n.paraui-v3-img-crop-modal .paraui-v3-img-crop-control-rotate button:first-of-type {\n transform: rotate(-20deg);\n}\n.paraui-v3-img-crop-modal .paraui-v3-img-crop-control-rotate button:last-of-type {\n transform: rotate(20deg);\n}";
|
|
786
|
+
styleInject(css_248z$1);
|
|
787
|
+
|
|
788
|
+
//图片裁剪组件
|
|
789
|
+
var ImgCrop = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
790
|
+
var _props$aspect = props.aspect,
|
|
791
|
+
aspect = _props$aspect === void 0 ? 1 : _props$aspect,
|
|
792
|
+
_props$shape = props.shape,
|
|
793
|
+
shape = _props$shape === void 0 ? 'rect' : _props$shape,
|
|
794
|
+
_props$grid = props.grid,
|
|
795
|
+
grid = _props$grid === void 0 ? false : _props$grid,
|
|
796
|
+
_props$quality = props.quality,
|
|
797
|
+
quality = _props$quality === void 0 ? 0.4 : _props$quality,
|
|
798
|
+
_props$fillColor = props.fillColor,
|
|
799
|
+
fillColor = _props$fillColor === void 0 ? 'transparent' : _props$fillColor,
|
|
800
|
+
_props$zoom = props.zoom,
|
|
801
|
+
zoom = _props$zoom === void 0 ? true : _props$zoom,
|
|
802
|
+
_props$rotate = props.rotate,
|
|
803
|
+
rotate = _props$rotate === void 0 ? false : _props$rotate,
|
|
804
|
+
_props$minZoom = props.minZoom,
|
|
805
|
+
minZoom = _props$minZoom === void 0 ? 1 : _props$minZoom,
|
|
806
|
+
_props$maxZoom = props.maxZoom,
|
|
807
|
+
maxZoom = _props$maxZoom === void 0 ? 3 : _props$maxZoom,
|
|
808
|
+
modalTitle = props.modalTitle,
|
|
809
|
+
modalWidth = props.modalWidth,
|
|
810
|
+
modalOk = props.modalOk,
|
|
811
|
+
modalCancel = props.modalCancel,
|
|
812
|
+
onModalOk = props.onModalOk,
|
|
813
|
+
onModalCancel = props.onModalCancel,
|
|
814
|
+
beforeCrop = props.beforeCrop,
|
|
815
|
+
onUploadFail = props.onUploadFail,
|
|
816
|
+
cropperProps = props.cropperProps,
|
|
817
|
+
children = props.children,
|
|
818
|
+
_props$fixedCropSize = props.fixedCropSize,
|
|
819
|
+
fixedCropSize = _props$fixedCropSize === void 0 ? {
|
|
820
|
+
width: 120,
|
|
821
|
+
height: 120
|
|
822
|
+
} : _props$fixedCropSize;
|
|
823
|
+
var intl = useFormatMessage('Upload', localeJson);
|
|
824
|
+
var _useState = useState(''),
|
|
825
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
826
|
+
image = _useState2[0],
|
|
827
|
+
setImage = _useState2[1];
|
|
828
|
+
var fileRef = useRef();
|
|
829
|
+
var beforeUploadRef = useRef();
|
|
830
|
+
var resolveRef = useRef();
|
|
831
|
+
var rejectRef = useRef();
|
|
832
|
+
//存储回调
|
|
833
|
+
var cbRef = useRef({});
|
|
834
|
+
cbRef.current.onModalOk = onModalOk;
|
|
835
|
+
cbRef.current.onModalCancel = onModalCancel;
|
|
836
|
+
cbRef.current.beforeCrop = beforeCrop;
|
|
837
|
+
cbRef.current.onUploadFail = onUploadFail;
|
|
838
|
+
var easyCropRef = useRef({});
|
|
839
|
+
//上传组件
|
|
840
|
+
var uploadComponent = useMemo(function () {
|
|
841
|
+
var upload = Array.isArray(children) ? children[0] : children;
|
|
842
|
+
var _a = upload.props,
|
|
843
|
+
beforeUpload = _a.beforeUpload,
|
|
844
|
+
accept = _a.accept,
|
|
845
|
+
restUploadProps = __rest(_a, ["beforeUpload", "accept"]);
|
|
846
|
+
beforeUploadRef.current = beforeUpload;
|
|
847
|
+
return Object.assign(Object.assign({}, upload), {
|
|
848
|
+
props: Object.assign(Object.assign({}, restUploadProps), {
|
|
849
|
+
accept: accept || 'image/*',
|
|
850
|
+
beforeUpload: function beforeUpload(file, fileList) {
|
|
851
|
+
return new Promise(function (resolve, reject) {
|
|
852
|
+
return __awaiter(void 0, void 0, void 0, /*#__PURE__*/regenerator.mark(function _callee() {
|
|
853
|
+
var reader;
|
|
854
|
+
return regenerator.wrap(function _callee$(_context) {
|
|
855
|
+
while (1) switch (_context.prev = _context.next) {
|
|
856
|
+
case 0:
|
|
857
|
+
_context.t0 = cbRef.current.beforeCrop;
|
|
858
|
+
if (!_context.t0) {
|
|
859
|
+
_context.next = 5;
|
|
860
|
+
break;
|
|
861
|
+
}
|
|
862
|
+
_context.next = 4;
|
|
863
|
+
return cbRef.current.beforeCrop(file, fileList);
|
|
864
|
+
case 4:
|
|
865
|
+
_context.t0 = !_context.sent;
|
|
866
|
+
case 5:
|
|
867
|
+
if (!_context.t0) {
|
|
868
|
+
_context.next = 8;
|
|
869
|
+
break;
|
|
870
|
+
}
|
|
871
|
+
reject();
|
|
872
|
+
return _context.abrupt("return");
|
|
873
|
+
case 8:
|
|
874
|
+
fileRef.current = file;
|
|
875
|
+
resolveRef.current = function (newFile) {
|
|
876
|
+
var flag = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
|
877
|
+
var _a, _b;
|
|
878
|
+
(_b = (_a = cbRef.current).onModalOk) === null || _b === void 0 ? void 0 : _b.call(_a, newFile);
|
|
879
|
+
if (!flag) return resolve({
|
|
880
|
+
cropFile: newFile,
|
|
881
|
+
isUpload: flag
|
|
882
|
+
});
|
|
883
|
+
resolve(newFile);
|
|
884
|
+
};
|
|
885
|
+
rejectRef.current = function (uploadErr) {
|
|
886
|
+
var _a, _b;
|
|
887
|
+
(_b = (_a = cbRef.current).onUploadFail) === null || _b === void 0 ? void 0 : _b.call(_a, uploadErr);
|
|
888
|
+
reject(uploadErr);
|
|
889
|
+
};
|
|
890
|
+
reader = new FileReader();
|
|
891
|
+
reader.addEventListener('load', function () {
|
|
892
|
+
return typeof reader.result === 'string' && setImage(reader.result);
|
|
893
|
+
});
|
|
894
|
+
reader.readAsDataURL(file);
|
|
895
|
+
case 14:
|
|
896
|
+
case "end":
|
|
897
|
+
return _context.stop();
|
|
898
|
+
}
|
|
899
|
+
}, _callee);
|
|
900
|
+
}));
|
|
901
|
+
});
|
|
902
|
+
}
|
|
903
|
+
})
|
|
904
|
+
});
|
|
905
|
+
}, [children]);
|
|
906
|
+
//modal 关闭后操作
|
|
907
|
+
var onClose = function onClose() {
|
|
908
|
+
setImage('');
|
|
909
|
+
easyCropRef.current.setZoomVal(INIT_ZOOM);
|
|
910
|
+
easyCropRef.current.setRotateVal(INIT_ROTATE);
|
|
911
|
+
};
|
|
912
|
+
//modal cancel
|
|
913
|
+
var onCancel = useCallback(function () {
|
|
914
|
+
var _a, _b;
|
|
915
|
+
(_b = (_a = cbRef.current).onModalCancel) === null || _b === void 0 ? void 0 : _b.call(_a);
|
|
916
|
+
onClose();
|
|
917
|
+
}, []);
|
|
918
|
+
//modal ok
|
|
919
|
+
var onOk = useCallback(function () {
|
|
920
|
+
return __awaiter(void 0, void 0, void 0, /*#__PURE__*/regenerator.mark(function _callee3() {
|
|
921
|
+
var canvas, ctx, imgSource, _easyCropRef$current$, cropWidth, cropHeight, cropX, cropY, imgWidth, imgHeight, angle, sine, cosine, squareWidth, squareHeight, squareHalfWidth, squareHalfHeight, imgX, imgY, imgData, changeImageSizeAfterCrop, _fileRef$current, type, name, uid, idx, onBlob;
|
|
922
|
+
return regenerator.wrap(function _callee3$(_context3) {
|
|
923
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
924
|
+
case 0:
|
|
925
|
+
onClose();
|
|
926
|
+
canvas = document.createElement('canvas');
|
|
927
|
+
ctx = canvas.getContext('2d');
|
|
928
|
+
imgSource = document.querySelector(".".concat(PREFIX, "-media"));
|
|
929
|
+
_easyCropRef$current$ = easyCropRef.current.cropPixelsRef.current, cropWidth = _easyCropRef$current$.width, cropHeight = _easyCropRef$current$.height, cropX = _easyCropRef$current$.x, cropY = _easyCropRef$current$.y;
|
|
930
|
+
if (rotate && easyCropRef.current.rotateVal !== INIT_ROTATE) {
|
|
931
|
+
imgWidth = imgSource.naturalWidth, imgHeight = imgSource.naturalHeight;
|
|
932
|
+
angle = easyCropRef.current.rotateVal * (Math.PI / 180); // get container for rotated image
|
|
933
|
+
sine = Math.abs(Math.sin(angle));
|
|
934
|
+
cosine = Math.abs(Math.cos(angle));
|
|
935
|
+
squareWidth = imgWidth * cosine + imgHeight * sine;
|
|
936
|
+
squareHeight = imgHeight * cosine + imgWidth * sine;
|
|
937
|
+
canvas.width = squareWidth;
|
|
938
|
+
canvas.height = squareHeight;
|
|
939
|
+
ctx.fillStyle = fillColor;
|
|
940
|
+
ctx.fillRect(0, 0, squareWidth, squareHeight);
|
|
941
|
+
// rotate container
|
|
942
|
+
squareHalfWidth = squareWidth / 2;
|
|
943
|
+
squareHalfHeight = squareHeight / 2;
|
|
944
|
+
ctx.translate(squareHalfWidth, squareHalfHeight);
|
|
945
|
+
ctx.rotate(angle);
|
|
946
|
+
ctx.translate(-squareHalfWidth, -squareHalfHeight);
|
|
947
|
+
// draw rotated image
|
|
948
|
+
imgX = (squareWidth - imgWidth) / 2;
|
|
949
|
+
imgY = (squareHeight - imgHeight) / 2;
|
|
950
|
+
ctx.drawImage(imgSource, 0, 0, imgWidth, imgHeight, imgX, imgY, imgWidth, imgHeight);
|
|
951
|
+
// crop rotated image
|
|
952
|
+
imgData = ctx.getImageData(0, 0, squareWidth, squareHeight);
|
|
953
|
+
canvas.width = cropWidth;
|
|
954
|
+
canvas.height = cropHeight;
|
|
955
|
+
ctx.putImageData(imgData, -cropX, -cropY);
|
|
956
|
+
} else {
|
|
957
|
+
canvas.width = cropWidth;
|
|
958
|
+
canvas.height = cropHeight;
|
|
959
|
+
ctx.fillStyle = fillColor;
|
|
960
|
+
ctx.fillRect(0, 0, cropWidth, cropHeight);
|
|
961
|
+
ctx.drawImage(imgSource, cropX, cropY, cropWidth, cropHeight, 0, 0, cropWidth, cropHeight);
|
|
962
|
+
}
|
|
963
|
+
//裁剪之后改变图片大小
|
|
964
|
+
changeImageSizeAfterCrop = function changeImageSizeAfterCrop(newFile) {
|
|
965
|
+
return new Promise(function (resolve) {
|
|
966
|
+
var name = newFile.name,
|
|
967
|
+
type = newFile.type,
|
|
968
|
+
uid = newFile.uid;
|
|
969
|
+
var width = fixedCropSize.width,
|
|
970
|
+
height = fixedCropSize.height; //固定裁剪大小
|
|
971
|
+
var changeCanvas = document.createElement('canvas');
|
|
972
|
+
var changeCtx = changeCanvas.getContext('2d');
|
|
973
|
+
var img = new Image();
|
|
974
|
+
img.onload = function () {
|
|
975
|
+
changeCanvas.width = width;
|
|
976
|
+
changeCanvas.height = height;
|
|
977
|
+
changeCtx.drawImage(img, 0, 0, width, height);
|
|
978
|
+
changeCanvas.toBlob(function (cBlob) {
|
|
979
|
+
var changeFile = Object.assign(new File([cBlob], name, {
|
|
980
|
+
type: type
|
|
981
|
+
}), {
|
|
982
|
+
uid: uid
|
|
983
|
+
});
|
|
984
|
+
resolve(changeFile);
|
|
985
|
+
}, type, quality);
|
|
986
|
+
};
|
|
987
|
+
img.onerror = function () {
|
|
988
|
+
resolve(newFile);
|
|
989
|
+
};
|
|
990
|
+
var fileReader = new FileReader();
|
|
991
|
+
fileReader.onload = function () {
|
|
992
|
+
img.src = fileReader.result;
|
|
993
|
+
};
|
|
994
|
+
fileReader.onerror = function () {
|
|
995
|
+
resolve(newFile);
|
|
996
|
+
};
|
|
997
|
+
fileReader.readAsDataURL(newFile);
|
|
998
|
+
});
|
|
999
|
+
}; // get the new image
|
|
1000
|
+
_fileRef$current = fileRef.current, type = _fileRef$current.type, name = _fileRef$current.name, uid = _fileRef$current.uid;
|
|
1001
|
+
if (/svg/ig.test(type)) {
|
|
1002
|
+
//svg 转为 png
|
|
1003
|
+
type = 'image/png';
|
|
1004
|
+
idx = name.lastIndexOf('.');
|
|
1005
|
+
if (idx > -1) name = name.substring(0, idx) + '.png';
|
|
1006
|
+
}
|
|
1007
|
+
//转为blob
|
|
1008
|
+
onBlob = function onBlob(blob) {
|
|
1009
|
+
return __awaiter(void 0, void 0, void 0, /*#__PURE__*/regenerator.mark(function _callee2() {
|
|
1010
|
+
var _a, _b, _c, _d, _e, _f, newFile, changeFile, res, passedFile;
|
|
1011
|
+
return regenerator.wrap(function _callee2$(_context2) {
|
|
1012
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
1013
|
+
case 0:
|
|
1014
|
+
newFile = Object.assign(new File([blob], name, {
|
|
1015
|
+
type: type
|
|
1016
|
+
}), {
|
|
1017
|
+
uid: uid
|
|
1018
|
+
});
|
|
1019
|
+
_context2.next = 3;
|
|
1020
|
+
return changeImageSizeAfterCrop(newFile);
|
|
1021
|
+
case 3:
|
|
1022
|
+
changeFile = _context2.sent;
|
|
1023
|
+
if (!(typeof beforeUploadRef.current !== 'function')) {
|
|
1024
|
+
_context2.next = 6;
|
|
1025
|
+
break;
|
|
1026
|
+
}
|
|
1027
|
+
return _context2.abrupt("return", (_a = resolveRef.current) === null || _a === void 0 ? void 0 : _a.call(resolveRef, changeFile));
|
|
1028
|
+
case 6:
|
|
1029
|
+
res = beforeUploadRef.current(changeFile, [changeFile]);
|
|
1030
|
+
if (!(typeof res !== 'boolean' && !res)) {
|
|
1031
|
+
_context2.next = 10;
|
|
1032
|
+
break;
|
|
1033
|
+
}
|
|
1034
|
+
console.error('beforeUpload must return a boolean or Promise');
|
|
1035
|
+
return _context2.abrupt("return");
|
|
1036
|
+
case 10:
|
|
1037
|
+
if (!(res === true)) {
|
|
1038
|
+
_context2.next = 12;
|
|
1039
|
+
break;
|
|
1040
|
+
}
|
|
1041
|
+
return _context2.abrupt("return", (_b = resolveRef.current) === null || _b === void 0 ? void 0 : _b.call(resolveRef, changeFile));
|
|
1042
|
+
case 12:
|
|
1043
|
+
if (!(res === false)) {
|
|
1044
|
+
_context2.next = 14;
|
|
1045
|
+
break;
|
|
1046
|
+
}
|
|
1047
|
+
return _context2.abrupt("return", (_c = resolveRef.current) === null || _c === void 0 ? void 0 : _c.call(resolveRef, changeFile, false));
|
|
1048
|
+
case 14:
|
|
1049
|
+
if (!(res && res instanceof Promise)) {
|
|
1050
|
+
_context2.next = 27;
|
|
1051
|
+
break;
|
|
1052
|
+
}
|
|
1053
|
+
_context2.prev = 15;
|
|
1054
|
+
_context2.next = 18;
|
|
1055
|
+
return res;
|
|
1056
|
+
case 18:
|
|
1057
|
+
passedFile = _context2.sent;
|
|
1058
|
+
if (!(passedFile instanceof File || passedFile instanceof Blob)) {
|
|
1059
|
+
_context2.next = 21;
|
|
1060
|
+
break;
|
|
1061
|
+
}
|
|
1062
|
+
return _context2.abrupt("return", (_d = resolveRef.current) === null || _d === void 0 ? void 0 : _d.call(resolveRef, passedFile));
|
|
1063
|
+
case 21:
|
|
1064
|
+
(_e = resolveRef.current) === null || _e === void 0 ? void 0 : _e.call(resolveRef, changeFile, passedFile);
|
|
1065
|
+
_context2.next = 27;
|
|
1066
|
+
break;
|
|
1067
|
+
case 24:
|
|
1068
|
+
_context2.prev = 24;
|
|
1069
|
+
_context2.t0 = _context2["catch"](15);
|
|
1070
|
+
(_f = rejectRef.current) === null || _f === void 0 ? void 0 : _f.call(rejectRef, _context2.t0);
|
|
1071
|
+
case 27:
|
|
1072
|
+
case "end":
|
|
1073
|
+
return _context2.stop();
|
|
1074
|
+
}
|
|
1075
|
+
}, _callee2, null, [[15, 24]]);
|
|
1076
|
+
}));
|
|
1077
|
+
};
|
|
1078
|
+
canvas.toBlob(onBlob, type, quality);
|
|
1079
|
+
case 11:
|
|
1080
|
+
case "end":
|
|
1081
|
+
return _context3.stop();
|
|
1082
|
+
}
|
|
1083
|
+
}, _callee3);
|
|
1084
|
+
}));
|
|
1085
|
+
}, [fillColor, quality, rotate]);
|
|
1086
|
+
//img crop 组件
|
|
1087
|
+
var getComponent = function getComponent(titleOfModal) {
|
|
1088
|
+
return jsxs(Fragment, {
|
|
1089
|
+
children: [uploadComponent, image && jsx(Modal, Object.assign({
|
|
1090
|
+
open: true,
|
|
1091
|
+
className: "".concat(PREFIX, "-modal"),
|
|
1092
|
+
size: 'md',
|
|
1093
|
+
title: titleOfModal !== null && titleOfModal !== void 0 ? titleOfModal : intl({
|
|
1094
|
+
id: 'editImage'
|
|
1095
|
+
}),
|
|
1096
|
+
onOk: onOk,
|
|
1097
|
+
onCancel: onCancel,
|
|
1098
|
+
okText: modalOk,
|
|
1099
|
+
cancelText: modalCancel,
|
|
1100
|
+
contentWidth: modalWidth
|
|
1101
|
+
}, {
|
|
1102
|
+
children: jsx(EasyCrop$1, {
|
|
1103
|
+
ref: easyCropRef,
|
|
1104
|
+
cropperRef: ref,
|
|
1105
|
+
image: image,
|
|
1106
|
+
aspect: aspect,
|
|
1107
|
+
shape: shape,
|
|
1108
|
+
grid: grid,
|
|
1109
|
+
zoom: zoom,
|
|
1110
|
+
rotate: rotate,
|
|
1111
|
+
minZoom: minZoom,
|
|
1112
|
+
maxZoom: maxZoom,
|
|
1113
|
+
fixedCropSize: fixedCropSize,
|
|
1114
|
+
cropperProps: cropperProps
|
|
1115
|
+
})
|
|
1116
|
+
}))]
|
|
1117
|
+
});
|
|
1118
|
+
};
|
|
1119
|
+
return jsx(Fragment, {
|
|
1120
|
+
children: getComponent(modalTitle)
|
|
1121
|
+
});
|
|
1122
|
+
});
|
|
1123
|
+
|
|
1124
|
+
var css_248z = "@charset \"UTF-8\";\n/**\n* @author Hanz\n* @date 2021/11/11 下午1:40\n* @description\n*/\n/**\n* @author Hanz\n* @date 2021/10/20 下午2:08\n* @description color\n*/\n.paraui-v3-upload .component-upload {\n position: relative;\n display: inline-block;\n}\n.paraui-v3-upload-loading {\n pointer-events: none;\n}\n.paraui-v3-upload .paraui-v3-button {\n color: rgb(54, 102, 214);\n border-color: rgb(54, 102, 214);\n}\n.paraui-v3-upload .paraui-v3-button:hover {\n border-color: rgba(54, 102, 214, 0.8);\n color: rgba(54, 102, 214, 0.8);\n}\n.paraui-v3-upload .paraui-v3-button-loading .button-icon {\n animation: uploadLoadingCircle 1s infinite linear;\n}\n.paraui-v3-upload-drag {\n position: relative;\n}\n.paraui-v3-upload-drag .component-upload {\n display: block;\n}\n.paraui-v3-upload-drag-loading {\n pointer-events: none;\n}\n.paraui-v3-upload-drag-hover .upload-drag-container {\n border-color: rgba(54, 102, 214, 0.4);\n background-color: rgba(54, 102, 214, 0.05);\n}\n.paraui-v3-upload-drag .upload-drag-container {\n display: inline-flex;\n width: 100%;\n max-width: 960px;\n height: 220px;\n flex-direction: column;\n justify-content: center;\n align-items: center;\n font-size: 14px;\n line-height: 1;\n border: 2px dashed rgba(171, 176, 185, 0.4);\n background-color: rgba(171, 176, 185, 0.12);\n border-radius: 4px;\n cursor: pointer;\n transition: 0.3s;\n}\n.paraui-v3-upload-drag .upload-drag-container:hover {\n border-color: rgba(54, 102, 214, 0.4);\n background-color: rgba(54, 102, 214, 0.05);\n}\n.paraui-v3-upload-drag .upload-drag-container .upload-drag-icon {\n line-height: 0;\n}\n.paraui-v3-upload-drag .upload-drag-container .upload-drag-icon svg {\n font-size: 48px;\n color: rgb(54, 102, 214);\n}\n.paraui-v3-upload-drag .upload-drag-container .upload-drag-icon .upload-drag-loading {\n animation: uploadLoadingCircle 1s infinite linear;\n}\n.paraui-v3-upload-drag .upload-drag-container .upload-drag-text {\n margin: 20px 0 12px 0;\n color: rgb(46, 55, 67);\n}\n.paraui-v3-upload-drag .upload-drag-container .upload-drag-text-loading {\n color: rgb(54, 102, 214);\n}\n.paraui-v3-upload-drag .upload-drag-container .upload-drag-text-filename {\n margin-right: 5px;\n color: rgb(46, 55, 67);\n}\n.paraui-v3-upload-drag .upload-drag-container .upload-drag-hint {\n color: rgba(46, 55, 67, 0.7);\n padding: 0 20px;\n text-align: center;\n}\n@keyframes uploadLoadingCircle {\n 100% {\n transform: rotate(360deg);\n }\n}";
|
|
1125
|
+
styleInject(css_248z);
|
|
1126
|
+
|
|
1127
|
+
//upload
|
|
1128
|
+
var InternalUpload = function InternalUpload(props) {
|
|
1129
|
+
var _props$type = props.type,
|
|
1130
|
+
type = _props$type === void 0 ? 'select' : _props$type,
|
|
1131
|
+
className = props.className,
|
|
1132
|
+
style = props.style,
|
|
1133
|
+
_onStart = props.onStart,
|
|
1134
|
+
_onSuccess = props.onSuccess,
|
|
1135
|
+
_onError = props.onError,
|
|
1136
|
+
_onProgress = props.onProgress,
|
|
1137
|
+
onRemove = props.onRemove,
|
|
1138
|
+
_beforeUpload = props.beforeUpload,
|
|
1139
|
+
onChange = props.onChange,
|
|
1140
|
+
onDrop = props.onDrop,
|
|
1141
|
+
_props$defaultFileLis = props.defaultFileList,
|
|
1142
|
+
defaultFileList = _props$defaultFileLis === void 0 ? [] : _props$defaultFileLis,
|
|
1143
|
+
fileList = props.fileList,
|
|
1144
|
+
_props$showUploadList = props.showUploadList,
|
|
1145
|
+
showUploadList = _props$showUploadList === void 0 ? true : _props$showUploadList,
|
|
1146
|
+
maxCount = props.maxCount,
|
|
1147
|
+
_props$children = props.children,
|
|
1148
|
+
children = _props$children === void 0 ? null : _props$children,
|
|
1149
|
+
itemRender = props.itemRender,
|
|
1150
|
+
_props$showUploadErro = props.showUploadError,
|
|
1151
|
+
showUploadError = _props$showUploadErro === void 0 ? true : _props$showUploadErro,
|
|
1152
|
+
_props$size = props.size,
|
|
1153
|
+
size = _props$size === void 0 ? 'large' : _props$size,
|
|
1154
|
+
_props$stash = props.stash,
|
|
1155
|
+
stash = _props$stash === void 0 ? false : _props$stash,
|
|
1156
|
+
_props$uploading = props.uploading,
|
|
1157
|
+
uploading = _props$uploading === void 0 ? true : _props$uploading,
|
|
1158
|
+
_props$showLoading = props.showLoading,
|
|
1159
|
+
loading = _props$showLoading === void 0 ? true : _props$showLoading,
|
|
1160
|
+
dragArea = props.dragArea,
|
|
1161
|
+
restProps = __rest(props, ["type", "className", "style", "onStart", "onSuccess", "onError", "onProgress", "onRemove", "beforeUpload", "onChange", "onDrop", "defaultFileList", "fileList", "showUploadList", "maxCount", "children", "itemRender", "showUploadError", "size", "stash", "uploading", "showLoading", "dragArea"]);
|
|
1162
|
+
var intl = useFormatMessage('Upload', localeJson);
|
|
1163
|
+
var _useState = useState(defaultFileList),
|
|
1164
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
1165
|
+
uploadFileList = _useState2[0],
|
|
1166
|
+
setUploadFileList = _useState2[1]; //文件列表
|
|
1167
|
+
var _useState3 = useState(false),
|
|
1168
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
1169
|
+
showLoading = _useState4[0],
|
|
1170
|
+
setShowLoading = _useState4[1]; //upload loading
|
|
1171
|
+
var _useState5 = useState(false),
|
|
1172
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
1173
|
+
errTip = _useState6[0],
|
|
1174
|
+
setErrTip = _useState6[1]; //upload error tip
|
|
1175
|
+
var _ref = typeof showUploadList === 'boolean' ? {} : showUploadList,
|
|
1176
|
+
showRemoveIcon = _ref.showRemoveIcon,
|
|
1177
|
+
removeIcon = _ref.removeIcon; //显示上传列表
|
|
1178
|
+
var _ref2 = typeof showUploadError === 'boolean' ? {} : showUploadError,
|
|
1179
|
+
_ref2$uploadErrorMsg = _ref2.uploadErrorMsg,
|
|
1180
|
+
uploadErrorMsg = _ref2$uploadErrorMsg === void 0 ? intl({
|
|
1181
|
+
id: 'uploadError'
|
|
1182
|
+
}) : _ref2$uploadErrorMsg,
|
|
1183
|
+
_ref2$leaveDelay = _ref2.leaveDelay,
|
|
1184
|
+
leaveDelay = _ref2$leaveDelay === void 0 ? 3000 : _ref2$leaveDelay; //错误信息提示
|
|
1185
|
+
var _useState7 = useState('drop'),
|
|
1186
|
+
_useState8 = _slicedToArray(_useState7, 2),
|
|
1187
|
+
dragState = _useState8[0],
|
|
1188
|
+
setDragState = _useState8[1]; //拖拽状态
|
|
1189
|
+
var curFileRef = useRef(); //正上传文件
|
|
1190
|
+
var recordNonAcceptFileRef = useRef(); //记录非accept推荐文件
|
|
1191
|
+
//复写属性
|
|
1192
|
+
var overrideProps = Object.assign(Object.assign({}, restProps), {
|
|
1193
|
+
beforeUpload: function beforeUpload(file, fileList) {
|
|
1194
|
+
if (restProps.action && loading && uploading) {
|
|
1195
|
+
setShowLoading(true);
|
|
1196
|
+
curFileRef.current = file;
|
|
1197
|
+
}
|
|
1198
|
+
var val = _beforeUpload === null || _beforeUpload === void 0 ? void 0 : _beforeUpload(file, fileList);
|
|
1199
|
+
if (val === false) {
|
|
1200
|
+
setShowLoading(false);
|
|
1201
|
+
curFileRef.current = null;
|
|
1202
|
+
return false;
|
|
1203
|
+
} else if (val instanceof Promise) return val;else return true;
|
|
1204
|
+
},
|
|
1205
|
+
onStart: function onStart(file) {
|
|
1206
|
+
_onStart === null || _onStart === void 0 ? void 0 : _onStart(file);
|
|
1207
|
+
},
|
|
1208
|
+
onSuccess: function onSuccess(response, file, xhr) {
|
|
1209
|
+
setShowLoading(false);
|
|
1210
|
+
curFileRef.current = null;
|
|
1211
|
+
errTip && showErrTip(false);
|
|
1212
|
+
var nextFileList = updateFileList(file);
|
|
1213
|
+
onInternalChange(nextFileList);
|
|
1214
|
+
_onSuccess === null || _onSuccess === void 0 ? void 0 : _onSuccess(response, file, xhr);
|
|
1215
|
+
},
|
|
1216
|
+
onError: function onError(error, response, file) {
|
|
1217
|
+
setShowLoading(false);
|
|
1218
|
+
curFileRef.current = null;
|
|
1219
|
+
showErrTip(!!showUploadError);
|
|
1220
|
+
_onError === null || _onError === void 0 ? void 0 : _onError(error, response, file);
|
|
1221
|
+
},
|
|
1222
|
+
onProgress: function onProgress(e, file) {
|
|
1223
|
+
_onProgress === null || _onProgress === void 0 ? void 0 : _onProgress(e, file);
|
|
1224
|
+
},
|
|
1225
|
+
onBatchStart: function onBatchStart(fileList) {
|
|
1226
|
+
if (stash) {
|
|
1227
|
+
var arr = fileList.map(function (_) {
|
|
1228
|
+
return _.file;
|
|
1229
|
+
});
|
|
1230
|
+
if (type === 'drag' && restProps.accept && recordNonAcceptFileRef.current) {
|
|
1231
|
+
arr.push(recordNonAcceptFileRef.current);
|
|
1232
|
+
recordNonAcceptFileRef.current = null;
|
|
1233
|
+
}
|
|
1234
|
+
var mList = mergedFileList(arr);
|
|
1235
|
+
onInternalChange(mList);
|
|
1236
|
+
}
|
|
1237
|
+
}
|
|
1238
|
+
});
|
|
1239
|
+
//内部变化
|
|
1240
|
+
var onInternalChange = function onInternalChange(changedFileList) {
|
|
1241
|
+
var cloneList = _toConsumableArray(changedFileList);
|
|
1242
|
+
// Cut to match count
|
|
1243
|
+
if (maxCount === 1) {
|
|
1244
|
+
cloneList = cloneList.slice(-1);
|
|
1245
|
+
} else if (maxCount) {
|
|
1246
|
+
cloneList = cloneList.slice(0, maxCount);
|
|
1247
|
+
}
|
|
1248
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(cloneList);
|
|
1249
|
+
setUploadFileList(cloneList);
|
|
1250
|
+
};
|
|
1251
|
+
//更新文件列表
|
|
1252
|
+
var updateFileList = function updateFileList(file) {
|
|
1253
|
+
var cloneList = _toConsumableArray(uploadFileList);
|
|
1254
|
+
var fileObj = Object.assign(Object.assign({}, file), {
|
|
1255
|
+
lastModified: file.lastModified,
|
|
1256
|
+
lastModifiedDate: file.lastModifiedDate,
|
|
1257
|
+
name: file.name,
|
|
1258
|
+
size: file.size,
|
|
1259
|
+
type: file.type,
|
|
1260
|
+
uid: file.uid,
|
|
1261
|
+
originFileObj: file
|
|
1262
|
+
});
|
|
1263
|
+
return cloneList.concat(fileObj);
|
|
1264
|
+
};
|
|
1265
|
+
//合并文件列表
|
|
1266
|
+
var mergedFileList = function mergedFileList(fileList) {
|
|
1267
|
+
var cloneList = _toConsumableArray(uploadFileList);
|
|
1268
|
+
var newFileList = fileList.map(function (file) {
|
|
1269
|
+
return Object.assign(Object.assign({}, file), {
|
|
1270
|
+
lastModified: file.lastModified,
|
|
1271
|
+
lastModifiedDate: file.lastModifiedDate,
|
|
1272
|
+
name: file.name,
|
|
1273
|
+
size: file.size,
|
|
1274
|
+
type: file.type,
|
|
1275
|
+
uid: file.uid || "rc-upload-".concat(Date.now()),
|
|
1276
|
+
originFileObj: file
|
|
1277
|
+
});
|
|
1278
|
+
});
|
|
1279
|
+
return cloneList.concat(newFileList);
|
|
1280
|
+
};
|
|
1281
|
+
//删除文件
|
|
1282
|
+
var handleRemove = function handleRemove(file) {
|
|
1283
|
+
Promise.resolve(typeof onRemove === 'function' ? onRemove(file) : onRemove).then(function (ret) {
|
|
1284
|
+
// Prevent removing file
|
|
1285
|
+
if (ret === false) return;
|
|
1286
|
+
var idx = uploadFileList.findIndex(function (_) {
|
|
1287
|
+
return _.uid === file.uid;
|
|
1288
|
+
});
|
|
1289
|
+
if (idx > -1) uploadFileList.splice(idx, 1);
|
|
1290
|
+
onInternalChange(uploadFileList);
|
|
1291
|
+
});
|
|
1292
|
+
};
|
|
1293
|
+
//拖拽区域
|
|
1294
|
+
var onFileDrop = function onFileDrop(e) {
|
|
1295
|
+
var _a, _b;
|
|
1296
|
+
setDragState(e.type);
|
|
1297
|
+
if (e.type === 'drop') {
|
|
1298
|
+
onDrop === null || onDrop === void 0 ? void 0 : onDrop(e);
|
|
1299
|
+
//拖拽且设置accept
|
|
1300
|
+
if (type === 'drag' && restProps.accept) {
|
|
1301
|
+
var dropFile = (_b = (_a = e.dataTransfer) === null || _a === void 0 ? void 0 : _a.files) === null || _b === void 0 ? void 0 : _b[0];
|
|
1302
|
+
if (dropFile) {
|
|
1303
|
+
var reg = new RegExp(restProps.accept, 'ig');
|
|
1304
|
+
if (!reg.test(dropFile.type)) {
|
|
1305
|
+
recordNonAcceptFileRef.current = dropFile;
|
|
1306
|
+
}
|
|
1307
|
+
}
|
|
1308
|
+
}
|
|
1309
|
+
}
|
|
1310
|
+
};
|
|
1311
|
+
//显示错误提示
|
|
1312
|
+
var showErrTip = function showErrTip(flag) {
|
|
1313
|
+
setErrTip(flag);
|
|
1314
|
+
if (leaveDelay < 0) return;
|
|
1315
|
+
setTimeout(function () {
|
|
1316
|
+
setErrTip(false);
|
|
1317
|
+
}, leaveDelay);
|
|
1318
|
+
};
|
|
1319
|
+
useEffect(function () {
|
|
1320
|
+
if (fileList) {
|
|
1321
|
+
setUploadFileList(_toConsumableArray(fileList));
|
|
1322
|
+
}
|
|
1323
|
+
}, [fileList]);
|
|
1324
|
+
//渲染上传列表
|
|
1325
|
+
var renderUploadList = function renderUploadList() {
|
|
1326
|
+
return showUploadList && jsx(UploadList, {
|
|
1327
|
+
listType: 'text',
|
|
1328
|
+
items: uploadFileList,
|
|
1329
|
+
showRemoveIcon: showRemoveIcon,
|
|
1330
|
+
removeIcon: removeIcon,
|
|
1331
|
+
onRemove: handleRemove,
|
|
1332
|
+
itemRender: itemRender
|
|
1333
|
+
});
|
|
1334
|
+
};
|
|
1335
|
+
//渲染上传按钮
|
|
1336
|
+
var renderButton = function renderButton() {
|
|
1337
|
+
var icon = jsx(UploadIcon, {});
|
|
1338
|
+
var text = children;
|
|
1339
|
+
if (showLoading) {
|
|
1340
|
+
icon = jsx(LoadingIcon, {});
|
|
1341
|
+
text = intl({
|
|
1342
|
+
id: 'uploading'
|
|
1343
|
+
});
|
|
1344
|
+
}
|
|
1345
|
+
return jsx(Button, Object.assign({
|
|
1346
|
+
variant: 'outlined',
|
|
1347
|
+
size: size,
|
|
1348
|
+
startIcon: icon,
|
|
1349
|
+
className: clsx(showLoading && "".concat($prefixCls, "-button-loading"))
|
|
1350
|
+
}, {
|
|
1351
|
+
children: text
|
|
1352
|
+
}));
|
|
1353
|
+
};
|
|
1354
|
+
//渲染拖拽区域
|
|
1355
|
+
var renderDragArea = function renderDragArea() {
|
|
1356
|
+
var _a;
|
|
1357
|
+
var icon = jsx(UploadIcon, {});
|
|
1358
|
+
var text = intl({
|
|
1359
|
+
id: 'clickUploadFile'
|
|
1360
|
+
});
|
|
1361
|
+
var hint = intl({
|
|
1362
|
+
id: 'dragFileUpload'
|
|
1363
|
+
});
|
|
1364
|
+
var _ref3 = dragArea !== null && dragArea !== void 0 ? dragArea : {},
|
|
1365
|
+
_ref3$areaIcon = _ref3.areaIcon,
|
|
1366
|
+
areaIcon = _ref3$areaIcon === void 0 ? icon : _ref3$areaIcon,
|
|
1367
|
+
_ref3$areaText = _ref3.areaText,
|
|
1368
|
+
areaText = _ref3$areaText === void 0 ? text : _ref3$areaText,
|
|
1369
|
+
_ref3$areaDesc = _ref3.areaDesc,
|
|
1370
|
+
areaDesc = _ref3$areaDesc === void 0 ? hint : _ref3$areaDesc;
|
|
1371
|
+
if (showLoading) {
|
|
1372
|
+
areaIcon = jsx(LoadingIcon, {
|
|
1373
|
+
className: 'upload-drag-loading'
|
|
1374
|
+
});
|
|
1375
|
+
areaText = jsxs("span", Object.assign({
|
|
1376
|
+
className: 'upload-drag-text-loading'
|
|
1377
|
+
}, {
|
|
1378
|
+
children: [jsx("span", Object.assign({
|
|
1379
|
+
className: 'upload-drag-text-filename'
|
|
1380
|
+
}, {
|
|
1381
|
+
children: (_a = curFileRef.current) === null || _a === void 0 ? void 0 : _a.name
|
|
1382
|
+
})), intl({
|
|
1383
|
+
id: 'uploading'
|
|
1384
|
+
}), "..."]
|
|
1385
|
+
}));
|
|
1386
|
+
}
|
|
1387
|
+
return jsx("div", Object.assign({
|
|
1388
|
+
className: 'upload-drag-container'
|
|
1389
|
+
}, {
|
|
1390
|
+
children: children ? children : jsxs(Fragment, {
|
|
1391
|
+
children: [jsx("p", Object.assign({
|
|
1392
|
+
className: 'upload-drag-icon'
|
|
1393
|
+
}, {
|
|
1394
|
+
children: areaIcon
|
|
1395
|
+
})), jsx("p", Object.assign({
|
|
1396
|
+
className: 'upload-drag-text'
|
|
1397
|
+
}, {
|
|
1398
|
+
children: areaText
|
|
1399
|
+
})), !showLoading && jsx("p", Object.assign({
|
|
1400
|
+
className: 'upload-drag-hint'
|
|
1401
|
+
}, {
|
|
1402
|
+
children: areaDesc
|
|
1403
|
+
}))]
|
|
1404
|
+
})
|
|
1405
|
+
}));
|
|
1406
|
+
};
|
|
1407
|
+
//拖拽上传
|
|
1408
|
+
if (type === 'drag') {
|
|
1409
|
+
var _clsx;
|
|
1410
|
+
var dragCls = clsx("".concat($prefixCls, "-upload-drag"), className, (_clsx = {}, _defineProperty(_clsx, "".concat($prefixCls, "-upload-drag-loading"), showLoading), _defineProperty(_clsx, "".concat($prefixCls, "-upload-drag-hover"), dragState === 'dragover'), _clsx));
|
|
1411
|
+
return jsxs("div", Object.assign({
|
|
1412
|
+
className: dragCls,
|
|
1413
|
+
onDrop: onFileDrop,
|
|
1414
|
+
onDragOver: onFileDrop,
|
|
1415
|
+
onDragLeave: onFileDrop
|
|
1416
|
+
}, {
|
|
1417
|
+
children: [jsx(RcUpload, Object.assign({}, overrideProps, {
|
|
1418
|
+
prefixCls: "".concat($rcPrefixCls, "-upload")
|
|
1419
|
+
}, {
|
|
1420
|
+
children: renderDragArea()
|
|
1421
|
+
})), renderUploadList(), errTip && jsx(ErrorTip, {
|
|
1422
|
+
message: uploadErrorMsg,
|
|
1423
|
+
className: "".concat($prefixCls, "-upload-error-drag")
|
|
1424
|
+
})]
|
|
1425
|
+
}));
|
|
1426
|
+
}
|
|
1427
|
+
var makeCls = clsx("".concat($prefixCls, "-upload"), className, showLoading && "".concat($prefixCls, "-upload-loading"));
|
|
1428
|
+
return jsxs("div", Object.assign({
|
|
1429
|
+
className: makeCls,
|
|
1430
|
+
style: style
|
|
1431
|
+
}, {
|
|
1432
|
+
children: [jsxs(RcUpload, Object.assign({}, overrideProps, {
|
|
1433
|
+
prefixCls: "".concat($rcPrefixCls, "-upload")
|
|
1434
|
+
}, {
|
|
1435
|
+
children: [renderButton(), errTip && jsx(ErrorTip, {
|
|
1436
|
+
message: uploadErrorMsg
|
|
1437
|
+
})]
|
|
1438
|
+
})), renderUploadList()]
|
|
1439
|
+
}));
|
|
1440
|
+
};
|
|
1441
|
+
var Upload = InternalUpload;
|
|
1442
|
+
Upload.ImageUpload = ImageUpload;
|
|
1443
|
+
Upload.Dragger = Dragger;
|
|
1444
|
+
Upload.ImgCrop = ImgCrop;
|
|
1445
|
+
|
|
1446
|
+
export { Upload as default };
|