@para-ui/core 3.0.53 → 3.0.55
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/README.md +24 -0
- package/package.json +1 -1
- package/AutoBox/index.d.ts +0 -34
- package/AutoBox/index.js +0 -277
- package/AutoBox/protal.d.ts +0 -17
- package/AutoTips/autoTipsMultiline/index.d.ts +0 -18
- package/AutoTips/index.d.ts +0 -35
- package/AutoTips/index.js +0 -271
- package/Breadcrumbs/index.d.ts +0 -53
- package/Breadcrumbs/index.js +0 -266
- package/Breadcrumbs/lang/en_US.d.ts +0 -4
- package/Breadcrumbs/lang/index.d.ts +0 -9
- package/Breadcrumbs/lang/zh_CN.d.ts +0 -4
- package/Button/SplitButton.d.ts +0 -64
- package/Button/index.d.ts +0 -79
- package/Button/index.js +0 -376
- package/Button/lang/en_US.d.ts +0 -4
- package/Button/lang/index.d.ts +0 -9
- package/Button/lang/zh_CN.d.ts +0 -4
- package/ButtonGroup/index.d.ts +0 -33
- package/ButtonGroup/index.js +0 -124
- package/Carousel/index.d.ts +0 -38
- package/Carousel/index.js +0 -78
- package/Cascader/index.d.ts +0 -54
- package/Cascader/index.js +0 -159
- package/Cascader/lang/en_US.d.ts +0 -4
- package/Cascader/lang/index.d.ts +0 -9
- package/Cascader/lang/zh_CN.d.ts +0 -4
- package/Checkbox/index.d.ts +0 -40
- package/Checkbox/index.js +0 -109
- package/CheckboxGroup/index.d.ts +0 -45
- package/CheckboxGroup/index.js +0 -142
- package/Collapse/collapsePanel.d.ts +0 -30
- package/Collapse/index.d.ts +0 -57
- package/Collapse/index.js +0 -152
- package/Collapse/motion.d.ts +0 -5
- package/Collapse/util.d.ts +0 -11
- package/CollapseBox/index.d.ts +0 -27
- package/CollapseBox/index.js +0 -148
- package/CollapseBox/util.d.ts +0 -5
- package/CollapseLayout/index.d.ts +0 -53
- package/CollapseLayout/index.js +0 -176
- package/ColorPicker/index.d.ts +0 -4
- package/ColorPicker/index.js +0 -4
- package/ComboSelect/index.d.ts +0 -6
- package/ComboSelect/index.js +0 -1049
- package/ComboSelect/interface.d.ts +0 -146
- package/ComboSelect/lang/en_US.d.ts +0 -9
- package/ComboSelect/lang/index.d.ts +0 -19
- package/ComboSelect/lang/zh_CN.d.ts +0 -9
- package/ComboSelect/utils.d.ts +0 -9
- package/Container/index.d.ts +0 -77
- package/Container/index.js +0 -232
- package/DatePicker/PickerButton.d.ts +0 -3
- package/DatePicker/PickerTag.d.ts +0 -3
- package/DatePicker/generatePicker/generateRangePicker.d.ts +0 -4
- package/DatePicker/generatePicker/generateSinglePicker.d.ts +0 -11
- package/DatePicker/generatePicker/index.d.ts +0 -95
- package/DatePicker/index.d.ts +0 -18
- package/DatePicker/index.js +0 -633
- package/DatePicker/lang/en_US.d.ts +0 -3
- package/DatePicker/lang/index.d.ts +0 -7
- package/DatePicker/lang/zh_CN.d.ts +0 -3
- package/DatePicker/util.d.ts +0 -22
- package/Desktop/index.d.ts +0 -57
- package/Desktop/index.js +0 -746
- package/DragVerify/index.d.ts +0 -36
- package/DragVerify/index.js +0 -385
- package/DragVerify/lang/en_US.d.ts +0 -5
- package/DragVerify/lang/index.d.ts +0 -11
- package/DragVerify/lang/zh_CN.d.ts +0 -5
- package/Drawer/index.d.ts +0 -11
- package/Drawer/index.js +0 -235
- package/Drawer/interface.d.ts +0 -92
- package/Drawer/lang/en_US.d.ts +0 -5
- package/Drawer/lang/index.d.ts +0 -11
- package/Drawer/lang/zh_CN.d.ts +0 -5
- package/Dropdown/index.d.ts +0 -40
- package/Dropdown/index.js +0 -10
- package/DynamicMultiBox/formItem.d.ts +0 -14
- package/DynamicMultiBox/index.d.ts +0 -5
- package/DynamicMultiBox/index.js +0 -1313
- package/DynamicMultiBox/interface.d.ts +0 -161
- package/DynamicMultiBox/rowForm.d.ts +0 -24
- package/Empty/images/index.d.ts +0 -3
- package/Empty/index.d.ts +0 -30
- package/Empty/index.js +0 -642
- package/Empty/lang/en_US.d.ts +0 -6
- package/Empty/lang/index.d.ts +0 -13
- package/Empty/lang/zh_CN.d.ts +0 -6
- package/Form/index.d.ts +0 -187
- package/Form/index.js +0 -355
- package/FormItem/compoments/defaultCompoments/index.d.ts +0 -19
- package/FormItem/compoments/formCheckboxGroup/index.d.ts +0 -8
- package/FormItem/compoments/formFile/index.d.ts +0 -38
- package/FormItem/compoments/formRadioGroup/index.d.ts +0 -8
- package/FormItem/compoments/formSelect/index.d.ts +0 -18
- package/FormItem/errorTips.d.ts +0 -12
- package/FormItem/index.d.ts +0 -152
- package/FormItem/index.js +0 -78
- package/FormItem/itemType.d.ts +0 -42
- package/FormItem/validateFunction.d.ts +0 -15
- package/FunctionModal/dialog.d.ts +0 -58
- package/FunctionModal/index.d.ts +0 -8
- package/FunctionModal/index.js +0 -43
- package/FunctionModal/modalContext.d.ts +0 -15
- package/GlobalContext/componentsProps.d.ts +0 -21
- package/GlobalContext/confirmLocale.d.ts +0 -7
- package/GlobalContext/constant.d.ts +0 -8
- package/GlobalContext/index.d.ts +0 -28
- package/GlobalContext/index.js +0 -41
- package/GlobalContext/intl.d.ts +0 -34
- package/GlobalContext/useFormatMessage.d.ts +0 -3
- package/GlobalContext/usePopupContainer.d.ts +0 -4
- package/Help/index.d.ts +0 -24
- package/Help/index.js +0 -41
- package/HelperText/index.d.ts +0 -27
- package/HelperText/index.js +0 -34
- package/Hooks/useGlobalProps.d.ts +0 -1
- package/InputLang/index.d.ts +0 -46
- package/InputLang/index.js +0 -247
- package/InputNumber/index.d.ts +0 -71
- package/InputNumber/index.js +0 -277
- package/Label/index.d.ts +0 -37
- package/Label/index.js +0 -85
- package/Loading/index.d.ts +0 -17
- package/Loading/index.js +0 -47
- package/Menu/footerExpansion.d.ts +0 -9
- package/Menu/index.d.ts +0 -10
- package/Menu/index.js +0 -1105
- package/Menu/interface.d.ts +0 -141
- package/Menu/logo.d.ts +0 -9
- package/Menu/verticalMenuList.d.ts +0 -14
- package/Message/index.d.ts +0 -99
- package/Message/index.js +0 -246
- package/Modal/Confirm/index.d.ts +0 -65
- package/Modal/index.d.ts +0 -99
- package/Modal/index.js +0 -421
- package/Modal/lang/en_US.d.ts +0 -5
- package/Modal/lang/index.d.ts +0 -11
- package/Modal/lang/zh_CN.d.ts +0 -5
- package/MultiBox/index.d.ts +0 -58
- package/MultiBox/index.js +0 -272
- package/MultiBox/lang/en_US.d.ts +0 -4
- package/MultiBox/lang/index.d.ts +0 -9
- package/MultiBox/lang/zh_CN.d.ts +0 -4
- package/Notification/index.d.ts +0 -74
- package/Notification/index.js +0 -252
- package/OperateBtn/index.d.ts +0 -59
- package/OperateBtn/index.js +0 -237
- package/OperateBtn/lang/en_US.d.ts +0 -4
- package/OperateBtn/lang/index.d.ts +0 -9
- package/OperateBtn/lang/zh_CN.d.ts +0 -4
- package/PageHeader/horizontalMeun.d.ts +0 -9
- package/PageHeader/horizontalMeunRight.d.ts +0 -9
- package/PageHeader/index.d.ts +0 -10
- package/PageHeader/index.js +0 -1050
- package/PageHeader/interface.d.ts +0 -169
- package/Pagination/index.d.ts +0 -46
- package/Pagination/index.js +0 -461
- package/Pagination/lang/en_US.d.ts +0 -8
- package/Pagination/lang/index.d.ts +0 -17
- package/Pagination/lang/zh_CN.d.ts +0 -8
- package/ParauiProvider/index.d.ts +0 -8
- package/ParauiProvider/index.js +0 -52
- package/PasswordRules/index.d.ts +0 -46
- package/PasswordRules/index.js +0 -113
- package/PopConfirm/index.d.ts +0 -61
- package/PopConfirm/index.js +0 -194
- package/PopConfirm/lang/en_US.d.ts +0 -5
- package/PopConfirm/lang/index.d.ts +0 -11
- package/PopConfirm/lang/zh_CN.d.ts +0 -5
- package/Popover/index.d.ts +0 -16
- package/Popover/index.js +0 -59
- package/Progress/Line.d.ts +0 -47
- package/Progress/Steps.d.ts +0 -17
- package/Progress/index.d.ts +0 -83
- package/Progress/index.js +0 -323
- package/Progress/utils.d.ts +0 -6
- package/Querying/images/index.d.ts +0 -3
- package/Querying/index.d.ts +0 -26
- package/Querying/index.js +0 -760
- package/Querying/lang/en_US.d.ts +0 -4
- package/Querying/lang/index.d.ts +0 -9
- package/Querying/lang/zh_CN.d.ts +0 -4
- package/Radio/index.d.ts +0 -38
- package/Radio/index.js +0 -97
- package/RadioGroup/index.d.ts +0 -46
- package/RadioGroup/index.js +0 -134
- package/Search/index.d.ts +0 -57
- package/Search/index.js +0 -208
- package/Select/index.d.ts +0 -93
- package/Select/index.js +0 -1146
- package/Select/lang/en_US.d.ts +0 -5
- package/Select/lang/index.d.ts +0 -11
- package/Select/lang/zh_CN.d.ts +0 -5
- package/SelectInput/index.d.ts +0 -12
- package/SelectInput/index.js +0 -55
- package/Selector/index.d.ts +0 -11
- package/Selector/index.js +0 -2175
- package/Selector/interface.d.ts +0 -432
- package/Selector/lang/en_US.d.ts +0 -11
- package/Selector/lang/index.d.ts +0 -23
- package/Selector/lang/zh_CN.d.ts +0 -11
- package/Selector/selectorData/index.d.ts +0 -10
- package/Selector/selectorMain/index.d.ts +0 -10
- package/Selector/selectorNode/index.d.ts +0 -10
- package/Selector/util.d.ts +0 -15
- package/SelectorPicker/index.d.ts +0 -53
- package/SelectorPicker/index.js +0 -444
- package/SelectorPicker/lang/en_US.d.ts +0 -5
- package/SelectorPicker/lang/index.d.ts +0 -11
- package/SelectorPicker/lang/zh_CN.d.ts +0 -5
- package/SingleBox/index.d.ts +0 -44
- package/SingleBox/index.js +0 -224
- package/SingleBox/lang/en_US.d.ts +0 -4
- package/SingleBox/lang/index.d.ts +0 -9
- package/SingleBox/lang/zh_CN.d.ts +0 -4
- package/Slider/index.d.ts +0 -14
- package/Slider/index.js +0 -119
- package/Slider/interface.d.ts +0 -102
- package/Split/index.d.ts +0 -7
- package/Split/index.js +0 -123
- package/Status/index.d.ts +0 -21
- package/Status/index.js +0 -37
- package/Stepper/icons.d.ts +0 -5
- package/Stepper/index.d.ts +0 -59
- package/Stepper/index.js +0 -97
- package/Switch/index.d.ts +0 -78
- package/Switch/index.js +0 -71
- package/Table/index.d.ts +0 -10
- package/Table/index.js +0 -2999
- package/Table/interface.d.ts +0 -346
- package/Table/lang/en_US.d.ts +0 -8
- package/Table/lang/index.d.ts +0 -17
- package/Table/lang/zh_CN.d.ts +0 -8
- package/Table/tableBody.d.ts +0 -9
- package/Table/tableBodyElement/index.d.ts +0 -15
- package/Table/tableBodyInterface.d.ts +0 -73
- package/Table/tableContainer/index.d.ts +0 -16
- package/Table/tableElement/index.d.ts +0 -17
- package/Table/tableHead.d.ts +0 -9
- package/Table/tableHeadElement/index.d.ts +0 -15
- package/Table/tableHeadInterface.d.ts +0 -37
- package/Table/tablePagination.d.ts +0 -9
- package/Table/tablePaginationInterface.d.ts +0 -27
- package/Table/tdElement/index.d.ts +0 -15
- package/Table/thElement/index.d.ts +0 -28
- package/Table/trElement/index.d.ts +0 -15
- package/Table/util.d.ts +0 -34
- package/Tabs/index.d.ts +0 -69
- package/Tabs/index.js +0 -205
- package/Tabs/lang/en_US.d.ts +0 -4
- package/Tabs/lang/index.d.ts +0 -9
- package/Tabs/lang/zh_CN.d.ts +0 -4
- package/Tag/TagGroup.d.ts +0 -66
- package/Tag/index.d.ts +0 -34
- package/Tag/index.js +0 -259
- package/TextEditor/common.d.ts +0 -11
- package/TextEditor/index.d.ts +0 -127
- package/TextEditor/index.js +0 -286
- package/TextField/index.d.ts +0 -90
- package/TextField/index.js +0 -611
- package/TimePicker/index.d.ts +0 -22
- package/TimePicker/index.js +0 -80
- package/TimePicker/locale/en_US.d.ts +0 -3
- package/TimePicker/locale/zh_CN.d.ts +0 -3
- package/TimePicker/style/index.d.ts +0 -1
- package/Timeline/TimelineItem.d.ts +0 -30
- package/Timeline/index.d.ts +0 -32
- package/Timeline/index.js +0 -148
- package/Title/index.d.ts +0 -30
- package/Title/index.js +0 -50
- package/ToggleButton/ToggleButtonGroup.d.ts +0 -49
- package/ToggleButton/index.d.ts +0 -49
- package/ToggleButton/index.js +0 -193
- package/Tooltip/index.d.ts +0 -11
- package/Tooltip/index.js +0 -368
- package/Tooltip/interface.d.ts +0 -35
- package/Tooltip/utils.d.ts +0 -18
- package/Transfer/box.d.ts +0 -38
- package/Transfer/index.d.ts +0 -32
- package/Transfer/index.js +0 -611
- package/Transfer/lang/en_US.d.ts +0 -10
- package/Transfer/lang/index.d.ts +0 -21
- package/Transfer/lang/zh_CN.d.ts +0 -10
- package/Transfer/useClick.d.ts +0 -3
- package/Tree/OperateBar/index.d.ts +0 -13
- package/Tree/Tree.d.ts +0 -4
- package/Tree/index.d.ts +0 -5
- package/Tree/index.js +0 -38
- package/Tree/interface.d.ts +0 -210
- package/Tree/lang/en_US.d.ts +0 -8
- package/Tree/lang/index.d.ts +0 -17
- package/Tree/lang/zh_CN.d.ts +0 -8
- package/Tree/utils/closestPolyfill.d.ts +0 -0
- package/Tree/utils/tools.d.ts +0 -25
- package/Tree/utils/treeUtil.d.ts +0 -15
- package/Upload/Dragger/index.d.ts +0 -10
- package/Upload/ErroTip/index.d.ts +0 -13
- package/Upload/ImageUpload/index.d.ts +0 -16
- package/Upload/ImgCrop/EasyCrop.d.ts +0 -17
- package/Upload/ImgCrop/constants.d.ts +0 -7
- package/Upload/ImgCrop/index.d.ts +0 -6
- package/Upload/ImgCrop/interface.d.ts +0 -48
- package/Upload/UploadList/index.d.ts +0 -5
- package/Upload/index.d.ts +0 -15
- package/Upload/index.js +0 -1446
- package/Upload/interface.d.ts +0 -136
- package/Upload/lang/en_US.d.ts +0 -12
- package/Upload/lang/index.d.ts +0 -25
- package/Upload/lang/zh_CN.d.ts +0 -12
- package/_verture/constant-66aa48a1.js +0 -10
- package/_verture/defineProperty-62acccfc.js +0 -34
- package/_verture/index-74f820ba.js +0 -1355
- package/_verture/index-77f9e0fb.js +0 -236
- package/_verture/index-9fd86055.js +0 -711
- package/_verture/index-a369ca3f.js +0 -4
- package/_verture/index-beef914f.js +0 -340
- package/_verture/index-e2881a53.js +0 -16
- package/_verture/intl-5cbb940c.js +0 -57
- package/_verture/modalContext-92bb0e16.js +0 -201
- package/_verture/slicedToArray-76060636.js +0 -43
- package/_verture/sortable.esm-49896035.js +0 -3791
- package/_verture/style-inject.es-300983ab.js +0 -28
- package/_verture/toConsumableArray-81040c9e.js +0 -19
- package/_verture/tslib.es6-55ed4bd2.js +0 -38
- package/_verture/typeof-498dd2b1.js +0 -11
- package/_verture/unsupportedIterableToArray-cb478f24.js +0 -16
- package/_verture/useFormatMessage-703f8b20.js +0 -20
- package/_verture/useGlobalProps-1b846a65.js +0 -11
- package/_verture/usePopupContainer-87febeb9.js +0 -68
- package/_verture/util-7e1fb1e2.js +0 -18
- package/index.d.ts +0 -144
- package/index.js +0 -180
- package/umd/AutoBox.js +0 -43
- package/umd/AutoTips.js +0 -15
- package/umd/Breadcrumbs.js +0 -42
- package/umd/Button.js +0 -43
- package/umd/ButtonGroup.js +0 -43
- package/umd/Carousel.js +0 -6
- package/umd/Cascader.js +0 -43
- package/umd/Checkbox.js +0 -42
- package/umd/CheckboxGroup.js +0 -42
- package/umd/Collapse.js +0 -43
- package/umd/CollapseBox.js +0 -1
- package/umd/CollapseLayout.js +0 -29
- package/umd/ColorPicker.js +0 -1
- package/umd/ComboSelect.js +0 -42
- package/umd/Container.js +0 -1
- package/umd/DatePicker.js +0 -42
- package/umd/Desktop.js +0 -42
- package/umd/DragVerify.js +0 -28
- package/umd/Drawer.js +0 -43
- package/umd/Dropdown.js +0 -15
- package/umd/DynamicMultiBox.js +0 -54
- package/umd/Empty.js +0 -15
- package/umd/Form.js +0 -42
- package/umd/FormItem.js +0 -42
- package/umd/FunctionModal.js +0 -42
- package/umd/GlobalContext.js +0 -1
- package/umd/Help.js +0 -42
- package/umd/HelperText.js +0 -1
- package/umd/InputLang.js +0 -42
- package/umd/InputNumber.js +0 -42
- package/umd/Label.js +0 -42
- package/umd/Loading.js +0 -29
- package/umd/Menu.js +0 -29
- package/umd/Message.js +0 -30
- package/umd/Modal.js +0 -42
- package/umd/MultiBox.js +0 -42
- package/umd/Notification.js +0 -43
- package/umd/OperateBtn.js +0 -42
- package/umd/PageHeader.js +0 -42
- package/umd/Pagination.js +0 -42
- package/umd/ParauiProvider.js +0 -15
- package/umd/PasswordRules.js +0 -29
- package/umd/PopConfirm.js +0 -42
- package/umd/Popover.js +0 -15
- package/umd/Progress.js +0 -35
- package/umd/Querying.js +0 -15
- package/umd/Radio.js +0 -42
- package/umd/RadioGroup.js +0 -42
- package/umd/Search.js +0 -42
- package/umd/Select.js +0 -42
- package/umd/SelectInput.js +0 -42
- package/umd/Selector.js +0 -42
- package/umd/SelectorPicker.js +0 -42
- package/umd/SingleBox.js +0 -42
- package/umd/Slider.js +0 -15
- package/umd/Split.js +0 -1
- package/umd/Status.js +0 -1
- package/umd/Stepper.js +0 -42
- package/umd/Switch.js +0 -42
- package/umd/Table.js +0 -42
- package/umd/Tabs.js +0 -42
- package/umd/Tag.js +0 -43
- package/umd/TextEditor.js +0 -205
- package/umd/TextField.js +0 -42
- package/umd/TimePicker.js +0 -42
- package/umd/Timeline.js +0 -1
- package/umd/Title.js +0 -1
- package/umd/ToggleButton.js +0 -43
- package/umd/Tooltip.js +0 -15
- package/umd/Transfer.js +0 -49
- package/umd/Tree.js +0 -42
- package/umd/Upload.js +0 -56
package/Upload/index.js
DELETED
|
@@ -1,1446 +0,0 @@
|
|
|
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 };
|