@geneui/components 3.0.0-next-9ffcb93-16102024 → 3.0.0-next-48d0ef7-31102024
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/Avatar.js +63 -0
- package/CHANGELOG.md +7 -0
- package/Divider.js +23 -0
- package/{GeneUIProvider/index.js → GeneUIProvider.js} +52 -65
- package/HelperText.js +69 -0
- package/Info.js +64 -0
- package/Label.js +38 -0
- package/Loader.js +21 -0
- package/Pill.js +64 -0
- package/TextLink.js +20 -0
- package/{index-65217440.js → Tooltip.js} +104 -80
- package/{lib → components}/atoms/Avatar/Avatar.d.ts +7 -6
- package/components/atoms/Avatar/index.d.ts +1 -0
- package/{lib → components}/atoms/Divider/Divider.d.ts +5 -5
- package/components/atoms/Divider/index.d.ts +1 -0
- package/{lib → components}/atoms/HelperText/HelperText.d.ts +6 -5
- package/components/atoms/HelperText/index.d.ts +1 -0
- package/{lib → components}/atoms/Info/Info.d.ts +5 -5
- package/components/atoms/Info/index.d.ts +1 -0
- package/{lib → components}/atoms/Label/Label.d.ts +3 -3
- package/components/atoms/Label/index.d.ts +1 -0
- package/{lib → components}/atoms/Loader/Loader.d.ts +5 -5
- package/components/atoms/Loader/index.d.ts +1 -0
- package/{lib → components}/atoms/Pill/Pill.d.ts +7 -6
- package/components/atoms/Pill/index.d.ts +1 -0
- package/{lib → components}/atoms/TextLink/TextLink.d.ts +5 -5
- package/components/atoms/TextLink/index.d.ts +1 -0
- package/{lib → components}/molecules/Tooltip/Tooltip.d.ts +26 -21
- package/components/molecules/Tooltip/index.d.ts +1 -0
- package/components/providers/GeneUIProvider/GeneUIProvider.d.ts +30 -0
- package/components/providers/GeneUIProvider/index.d.ts +1 -0
- package/hooks/index.d.ts +2 -20
- package/hooks/useDebounceCallback/index.d.ts +1 -0
- package/hooks/useDebounceCallback/useDebounceCallback.d.ts +2 -0
- package/hooks/useEllipsisDetection/index.d.ts +1 -1
- package/hooks/useEllipsisDetection/useEllipsisDetection.d.ts +2 -2
- package/{index-031ff73c.js → index-ce02421b.js} +4 -4
- package/index.d.ts +11 -121
- package/index.js +12 -159
- package/package.json +24 -43
- package/tokens-0abb4e1b.js +6 -0
- package/types/index.d.ts +0 -3
- package/useEllipsisDetection-46d712b6.js +34 -0
- package/ActionableList/index.js +0 -1694
- package/AdvancedSearch/index.js +0 -892
- package/Alert/index.js +0 -98
- package/Avatar/index.js +0 -58
- package/Badge/index.js +0 -29
- package/Breadcrumb/index.js +0 -130
- package/BusyLoader/index.js +0 -31
- package/Button/index.js +0 -30
- package/Card/index.js +0 -502
- package/CardList/index.js +0 -662
- package/CellMeasurerCache-80be385d.js +0 -229
- package/Charts/index.js +0 -17662
- package/Checkbox/index.js +0 -229
- package/CheckboxGroup/index.js +0 -203
- package/CheckboxGroupWithSearch/index.js +0 -280
- package/Collapse/index.js +0 -195
- package/ColorPicker/index.js +0 -210
- package/ComboBox/index.js +0 -524
- package/Copy/index.js +0 -56
- package/Counter/index.js +0 -312
- package/DateFilter/index.js +0 -183
- package/DatePicker/index.js +0 -1229
- package/DatePickerInput/index.js +0 -883
- package/Divider/index.js +0 -23
- package/Drawer/index.js +0 -261
- package/Dropdown/index.js +0 -43
- package/Editor/index.js +0 -22975
- package/Empty/index.js +0 -76
- package/ExtendedInput/index.js +0 -590
- package/Form/index.js +0 -85
- package/FormContainer/index.js +0 -189
- package/FormableCheckbox/index.js +0 -24
- package/FormableDatePicker/index.js +0 -43
- package/FormableDropdown/index.js +0 -50
- package/FormableEditor/index.js +0 -26
- package/FormableHOC-85f89a81.js +0 -83
- package/FormableMultiSelectDropdown/index.js +0 -50
- package/FormableNumberInput/index.js +0 -34
- package/FormableRadio/index.js +0 -22
- package/FormableSwitcher/index.js +0 -22
- package/FormableTextInput/index.js +0 -34
- package/FormableUploader/index.js +0 -44
- package/Grid/index.js +0 -167
- package/HelperText/index.js +0 -86
- package/Holder/index.js +0 -261
- package/Icon/index.js +0 -62
- package/Image/index.js +0 -45
- package/ImagePreview/index.js +0 -217
- package/Info/index.js +0 -41
- package/InfoOutline-dd2e89d9.js +0 -29
- package/InteractiveWidget/index.js +0 -78
- package/KeyValue/index.js +0 -22
- package/Label/index.js +0 -48
- package/LinkButton/index.js +0 -34
- package/Loader/index.js +0 -23
- package/Menu/index.js +0 -281
- package/MobileNavigation/index.js +0 -94
- package/MobilePopup/index.js +0 -182
- package/Modal/index.js +0 -251
- package/ModuleTitle/index.js +0 -141
- package/NavigationMenu/index.js +0 -222
- package/Notification/index.js +0 -120
- package/Option/index.js +0 -184
- package/Overlay/index.js +0 -187
- package/Overspread/index.js +0 -291
- package/Pagination/index.js +0 -261
- package/Paper/index.js +0 -96
- package/Pill/index.js +0 -67
- package/Popover/index.js +0 -725
- package/PopoverV2/index.js +0 -19
- package/Portal/index.js +0 -58
- package/Products/index.js +0 -115
- package/Profile/index.js +0 -589
- package/Progress/index.js +0 -200
- package/QRCode/index.js +0 -814
- package/Radio/index.js +0 -151
- package/RadioGroup/index.js +0 -104
- package/Range/index.js +0 -191
- package/Rating/index.js +0 -174
- package/RichEditor/index.js +0 -13
- package/RichEditor-78c2617e.js +0 -228
- package/Scrollbar/index.js +0 -1585
- package/Search/index.js +0 -75
- package/SearchWithDropdown/index.js +0 -140
- package/Section/index.js +0 -61
- package/SkeletonLoader/index.js +0 -81
- package/Slider/index.js +0 -261
- package/Status/index.js +0 -97
- package/Steps/index.js +0 -314
- package/SuggestionList/index.js +0 -385
- package/Switcher/index.js +0 -193
- package/Table/index.js +0 -57
- package/TableCompositions/index.js +0 -16995
- package/Tabs/index.js +0 -235
- package/Tag/index.js +0 -102
- package/TextLink/index.js +0 -20
- package/Textarea/index.js +0 -242
- package/Time/index.js +0 -62
- package/TimePicker/index.js +0 -575
- package/Timeline/index.js +0 -113
- package/Title/index.js +0 -65
- package/Toaster/index.js +0 -116
- package/Tooltip/index.js +0 -6
- package/TransferList/index.js +0 -493
- package/Uploader/index.js +0 -992
- package/ValidatableCheckbox/index.js +0 -123
- package/ValidatableDatePicker/index.js +0 -316
- package/ValidatableDropdown/index.js +0 -141
- package/ValidatableElements/index.js +0 -67
- package/ValidatableMultiSelectDropdown/index.js +0 -152
- package/ValidatableNumberInput/index.js +0 -204
- package/ValidatableRadio/index.js +0 -116
- package/ValidatableSwitcher/index.js +0 -93
- package/ValidatableTextInput/index.js +0 -167
- package/ValidatableTimeInput/index.js +0 -174
- package/ValidatableUploader/index.js +0 -98
- package/Widget/index.js +0 -225
- package/_commonjsHelpers-24198af3.js +0 -35
- package/_rollupPluginBabelHelpers-a83240e1.js +0 -11
- package/callAfterDelay-7272faca.js +0 -12
- package/checkTimeValidation-e56771be.js +0 -16
- package/checkboxRadioSwitcher-5b69d7bd.js +0 -4
- package/clsx.m-2bb6df4b.js +0 -3
- package/config-1053d64d.js +0 -20
- package/configs-00612ce0.js +0 -103
- package/configs.js +0 -111
- package/dateValidation-67caec66.js +0 -225
- package/debounce-4419bc2f.js +0 -17
- package/guid-8ddf77b3.js +0 -16
- package/hooks/useBodyScroll.js +0 -16
- package/hooks/useClick.js +0 -18
- package/hooks/useClickOutside.js +0 -25
- package/hooks/useDebounce.js +0 -28
- package/hooks/useDeviceType.js +0 -17
- package/hooks/useDidMount.js +0 -15
- package/hooks/useForceUpdate.js +0 -8
- package/hooks/useHover.js +0 -20
- package/hooks/useImgDownload.js +0 -18
- package/hooks/useKeyDown.js +0 -21
- package/hooks/useMount.js +0 -13
- package/hooks/useMutationObserver.js +0 -21
- package/hooks/usePrevious.js +0 -10
- package/hooks/useThrottle.js +0 -16
- package/hooks/useToggle.js +0 -11
- package/hooks/useUpdatableRef.js +0 -14
- package/hooks/useUpdate.js +0 -10
- package/hooks/useWidth.js +0 -16
- package/hooks/useWindowSize.js +0 -40
- package/index-122432cd.js +0 -270
- package/index-262edd7a.js +0 -77
- package/index-2f5aa51e.js +0 -6483
- package/index-370f9acd.js +0 -4
- package/index-45eafea6.js +0 -90
- package/index-480fd7d9.js +0 -10032
- package/index-5f37f281.js +0 -168
- package/index-73aaa093.js +0 -1940
- package/index.mobile.d.ts +0 -14
- package/lib/atoms/Avatar/index.d.ts +0 -1
- package/lib/atoms/Badge/Badge.d.ts +0 -36
- package/lib/atoms/Badge/index.d.ts +0 -1
- package/lib/atoms/BusyLoader/BusyLoader.d.ts +0 -32
- package/lib/atoms/BusyLoader/BusyLoaderHolderHOC.d.ts +0 -8
- package/lib/atoms/BusyLoader/index.d.ts +0 -1
- package/lib/atoms/Button/Button.d.ts +0 -70
- package/lib/atoms/Button/index.d.ts +0 -1
- package/lib/atoms/Divider/index.d.ts +0 -1
- package/lib/atoms/Empty/Empty.d.ts +0 -39
- package/lib/atoms/Empty/index.d.ts +0 -1
- package/lib/atoms/Empty/utils.d.ts +0 -9
- package/lib/atoms/HelperText/index.d.ts +0 -1
- package/lib/atoms/Image/Image.d.ts +0 -51
- package/lib/atoms/Image/index.d.ts +0 -1
- package/lib/atoms/ImagePreview/ImagePreview.d.ts +0 -56
- package/lib/atoms/ImagePreview/ImagePreviewHOC.d.ts +0 -4
- package/lib/atoms/ImagePreview/Magnifier.d.ts +0 -40
- package/lib/atoms/ImagePreview/index.d.ts +0 -1
- package/lib/atoms/Info/index.d.ts +0 -1
- package/lib/atoms/KeyValue/KeyValue.d.ts +0 -29
- package/lib/atoms/KeyValue/index.d.ts +0 -1
- package/lib/atoms/Label/index.d.ts +0 -1
- package/lib/atoms/LinkButton/LinkButton.d.ts +0 -46
- package/lib/atoms/LinkButton/index.d.ts +0 -1
- package/lib/atoms/Loader/index.d.ts +0 -1
- package/lib/atoms/Pill/index.d.ts +0 -1
- package/lib/atoms/Rating/DefaultSvg.d.ts +0 -3
- package/lib/atoms/Rating/Rating.d.ts +0 -49
- package/lib/atoms/Rating/index.d.ts +0 -1
- package/lib/atoms/TextLink/index.d.ts +0 -1
- package/lib/molecules/Copy/Copy.d.ts +0 -38
- package/lib/molecules/Copy/index.d.ts +0 -1
- package/lib/molecules/InteractiveWidget/InteractiveWidget.d.ts +0 -70
- package/lib/molecules/InteractiveWidget/InteractiveWidgetIcon.d.ts +0 -8
- package/lib/molecules/InteractiveWidget/index.d.ts +0 -1
- package/lib/molecules/Tooltip/index.d.ts +0 -1
- package/lib/providers/GeneUIProvider/GeneUIProvider.d.ts +0 -30
- package/lib/providers/GeneUIProvider/index.d.ts +0 -1
- package/localization-4ba17032.js +0 -46
- package/objectWithoutPropertiesLoose-e1596bdb.js +0 -62
- package/rangeAndSlider-693a3d41.js +0 -8684
- package/react-beautiful-dnd.esm-b637016a.js +0 -10116
- package/react-lifecycles-compat.es-6e1f3768.js +0 -158
- package/redux-e591c1b8.js +0 -536
- package/tokens-8ab1179c.js +0 -6
- package/tslib.es6-f211516f.js +0 -35
- package/useEllipsisDetection-c1c9ad94.js +0 -38
package/Uploader/index.js
DELETED
|
@@ -1,992 +0,0 @@
|
|
|
1
|
-
import { _ as _extends } from '../_rollupPluginBabelHelpers-a83240e1.js';
|
|
2
|
-
import React__default, { useState, useCallback, useEffect, forwardRef, useMemo, useRef } from 'react';
|
|
3
|
-
import PropTypes from 'prop-types';
|
|
4
|
-
import { c as classnames } from '../index-031ff73c.js';
|
|
5
|
-
import { u as uploaderConfig } from '../configs-00612ce0.js';
|
|
6
|
-
import { p as getImageDimensions, s as stopEvent, f as fileSizeDisplay, n as noop } from '../index-5f37f281.js';
|
|
7
|
-
import Button from '../Button/index.js';
|
|
8
|
-
import ExtendedInput from '../ExtendedInput/index.js';
|
|
9
|
-
import { Row, Col } from '../Grid/index.js';
|
|
10
|
-
import useKeyDown from '../hooks/useKeyDown.js';
|
|
11
|
-
import useImgDownload from '../hooks/useImgDownload.js';
|
|
12
|
-
import BusyLoader from '../BusyLoader/index.js';
|
|
13
|
-
import Icon from '../Icon/index.js';
|
|
14
|
-
import Image from '../Image/index.js';
|
|
15
|
-
import { T as Tooltip } from '../index-65217440.js';
|
|
16
|
-
import { s as styleInject } from '../style-inject.es-746bb8ed.js';
|
|
17
|
-
import '../dateValidation-67caec66.js';
|
|
18
|
-
import '../_commonjsHelpers-24198af3.js';
|
|
19
|
-
import 'react-dom';
|
|
20
|
-
import '../tslib.es6-f211516f.js';
|
|
21
|
-
import '../hooks/useDeviceType.js';
|
|
22
|
-
import '../hooks/useWindowSize.js';
|
|
23
|
-
import '../hooks/useDebounce.js';
|
|
24
|
-
import '../useEllipsisDetection-c1c9ad94.js';
|
|
25
|
-
import '../SuggestionList/index.js';
|
|
26
|
-
import '../hooks/useClickOutside.js';
|
|
27
|
-
import '../config-1053d64d.js';
|
|
28
|
-
import '../Scrollbar/index.js';
|
|
29
|
-
import '../callAfterDelay-7272faca.js';
|
|
30
|
-
import '../GeneUIProvider/index.js';
|
|
31
|
-
import '../hooks/useWidth.js';
|
|
32
|
-
import '../Empty/index.js';
|
|
33
|
-
import '../Checkbox/index.js';
|
|
34
|
-
import '../checkboxRadioSwitcher-5b69d7bd.js';
|
|
35
|
-
import '../guid-8ddf77b3.js';
|
|
36
|
-
|
|
37
|
-
// Helpers
|
|
38
|
-
const typeListReplacer = 'TYPE_LIST';
|
|
39
|
-
const maxFileSizeReplacer = 'MAX_FILE_SIZE';
|
|
40
|
-
const getFileByUrl = async (url, file, isImageUpload, customHeaders) => {
|
|
41
|
-
const res = await fetch(url, {
|
|
42
|
-
headers: {
|
|
43
|
-
...customHeaders
|
|
44
|
-
}
|
|
45
|
-
});
|
|
46
|
-
const blob = await res.blob();
|
|
47
|
-
const blobFile = {
|
|
48
|
-
blob,
|
|
49
|
-
...file
|
|
50
|
-
};
|
|
51
|
-
if (isImageUpload) {
|
|
52
|
-
blobFile.dimensions = await getImageDimensions(blob);
|
|
53
|
-
}
|
|
54
|
-
return blobFile;
|
|
55
|
-
};
|
|
56
|
-
const addDragEventListener = (element, handleDragIn, handleDragOut, handleDrop) => {
|
|
57
|
-
element.addEventListener('dragenter', handleDragIn);
|
|
58
|
-
element.addEventListener('dragover', handleDragIn);
|
|
59
|
-
element.addEventListener('dragleave', handleDragOut);
|
|
60
|
-
element.addEventListener('dragend', handleDragOut);
|
|
61
|
-
element.addEventListener('drop', handleDrop);
|
|
62
|
-
};
|
|
63
|
-
const removeDragEventListener = (element, handleDragIn, handleDragOut, handleDrop) => {
|
|
64
|
-
element.removeEventListener('dragenter', handleDragIn);
|
|
65
|
-
element.removeEventListener('dragover', handleDragIn);
|
|
66
|
-
element.removeEventListener('dragleave', handleDragOut);
|
|
67
|
-
element.removeEventListener('dragend', handleDragOut);
|
|
68
|
-
element.removeEventListener('drop', handleDrop);
|
|
69
|
-
};
|
|
70
|
-
const toBlobFile = async (file, isImageUpload) => {
|
|
71
|
-
const blob = new Blob([file], {
|
|
72
|
-
type: file.type
|
|
73
|
-
});
|
|
74
|
-
const blobFile = {
|
|
75
|
-
name: file.name,
|
|
76
|
-
blob,
|
|
77
|
-
path: URL.createObjectURL(blob)
|
|
78
|
-
};
|
|
79
|
-
if (isImageUpload) {
|
|
80
|
-
const dimensions = await getImageDimensions(blob);
|
|
81
|
-
blobFile.dimensions = dimensions;
|
|
82
|
-
}
|
|
83
|
-
return blobFile;
|
|
84
|
-
};
|
|
85
|
-
|
|
86
|
-
/**
|
|
87
|
-
* Checking the file for the size and type of rules
|
|
88
|
-
* and return each one of them.
|
|
89
|
-
*/
|
|
90
|
-
const isValidFile = _ref => {
|
|
91
|
-
var _file$name$split$pop;
|
|
92
|
-
let {
|
|
93
|
-
allTypesAccepted,
|
|
94
|
-
isImageUpload,
|
|
95
|
-
maxFileSize,
|
|
96
|
-
typesList,
|
|
97
|
-
file
|
|
98
|
-
} = _ref;
|
|
99
|
-
const fileType = file && file.name && ((_file$name$split$pop = file.name.split('.').pop()) === null || _file$name$split$pop === void 0 ? void 0 : _file$name$split$pop.toLowerCase());
|
|
100
|
-
return {
|
|
101
|
-
isValidSize: file.size <= maxFileSize,
|
|
102
|
-
isValidType: typesList.length ? typesList.includes(fileType) : allTypesAccepted
|
|
103
|
-
};
|
|
104
|
-
};
|
|
105
|
-
const generateFilesByPage = files => {
|
|
106
|
-
if (files && files.length) {
|
|
107
|
-
const data = files.map(path => {
|
|
108
|
-
const binary = new ArrayBuffer(path.length);
|
|
109
|
-
const blob = new Blob([binary], {
|
|
110
|
-
type: 'image/jpeg'
|
|
111
|
-
});
|
|
112
|
-
return {
|
|
113
|
-
blob,
|
|
114
|
-
path,
|
|
115
|
-
name: path.split('/').pop()
|
|
116
|
-
};
|
|
117
|
-
});
|
|
118
|
-
return data;
|
|
119
|
-
}
|
|
120
|
-
return [];
|
|
121
|
-
};
|
|
122
|
-
const getLastMod = (url, cb) => {
|
|
123
|
-
fetch(url).then(response => {
|
|
124
|
-
const headersObj = Object.fromEntries([...response.headers]);
|
|
125
|
-
return cb(headersObj['last-modified']);
|
|
126
|
-
});
|
|
127
|
-
};
|
|
128
|
-
|
|
129
|
-
var css_248z$3 = "[data-gene-ui-version=\"2.16.3\"] .media-preview-holder{background-color:#000c;color:#fff;display:flex;height:100%;left:0;position:fixed;top:0;width:100%;z-index:500}[data-gene-ui-version=\"2.16.3\"] .media-preview-holder .bc-icon-close{cursor:pointer;position:absolute;right:2.2rem;top:2.2rem}[data-gene-ui-version=\"2.16.3\"] .media-preview{display:flex;flex-direction:column;margin:auto;padding:3rem 0 0;position:relative}[data-gene-ui-version=\"2.16.3\"] .media-preview .mp-title{font:600 1.4rem/1.8rem var(--font-family);left:0;position:absolute;top:0;width:100%}[data-gene-ui-version=\"2.16.3\"] .mp-details{font:600 1.4rem/2rem var(--font-family);margin:.5rem 0 0}[data-gene-ui-version=\"2.16.3\"] .mp-details>li{margin:1rem 0 0}[data-gene-ui-version=\"2.16.3\"] .mp-details span{opacity:.7}[data-gene-ui-version=\"2.16.3\"] .mp-element{height:auto;max-height:calc(100vh - 20rem);max-width:100%;width:auto}";
|
|
130
|
-
styleInject(css_248z$3);
|
|
131
|
-
|
|
132
|
-
function Preview(_ref) {
|
|
133
|
-
let {
|
|
134
|
-
previewImage: {
|
|
135
|
-
name,
|
|
136
|
-
path,
|
|
137
|
-
blob: {
|
|
138
|
-
size
|
|
139
|
-
},
|
|
140
|
-
dimensions
|
|
141
|
-
},
|
|
142
|
-
hideName,
|
|
143
|
-
onClose
|
|
144
|
-
} = _ref;
|
|
145
|
-
return /*#__PURE__*/React__default.createElement("div", {
|
|
146
|
-
className: "media-preview-holder",
|
|
147
|
-
onClick: onClose
|
|
148
|
-
}, /*#__PURE__*/React__default.createElement(Icon, {
|
|
149
|
-
type: "bc-icon-close"
|
|
150
|
-
}), /*#__PURE__*/React__default.createElement("div", {
|
|
151
|
-
className: "media-preview",
|
|
152
|
-
onClick: stopEvent
|
|
153
|
-
}, /*#__PURE__*/React__default.createElement("div", {
|
|
154
|
-
className: "mp-title ellipsis-text"
|
|
155
|
-
}, !hideName && name), /*#__PURE__*/React__default.createElement("img", {
|
|
156
|
-
className: "mp-element",
|
|
157
|
-
src: path,
|
|
158
|
-
alt: name
|
|
159
|
-
}), /*#__PURE__*/React__default.createElement("ul", {
|
|
160
|
-
className: "mp-details"
|
|
161
|
-
}, /*#__PURE__*/React__default.createElement("li", null, /*#__PURE__*/React__default.createElement("span", null, "Image size:"), " ", fileSizeDisplay(size), ' '), dimensions && /*#__PURE__*/React__default.createElement("li", null, /*#__PURE__*/React__default.createElement("span", null, "Image dimensions: "), dimensions.width, " x ", dimensions.height))));
|
|
162
|
-
}
|
|
163
|
-
Preview.propTypes = {
|
|
164
|
-
previewImage: PropTypes.object.isRequired,
|
|
165
|
-
onClose: PropTypes.func.isRequired,
|
|
166
|
-
dimensions: PropTypes.object,
|
|
167
|
-
name: PropTypes.string,
|
|
168
|
-
path: PropTypes.string,
|
|
169
|
-
blob: PropTypes.object
|
|
170
|
-
};
|
|
171
|
-
Preview.defaultProps = {
|
|
172
|
-
dimensions: {}
|
|
173
|
-
};
|
|
174
|
-
|
|
175
|
-
var css_248z$2 = "[data-gene-ui-version=\"2.16.3\"] .uploaded-item{align-items:center;border-radius:.4rem;display:flex;height:2.8rem;padding:0 1px 0 .8rem;transition:background .4s,color .4s,border-color .4s;width:100%}html[dir=rtl] .uploaded-item{padding:0 .8rem 0 1px}[data-gene-ui-version=\"2.16.3\"] .uploaded-item:not(.error){cursor:pointer}[data-gene-ui-version=\"2.16.3\"] .uploaded-item>li{align-items:center;display:flex;flex-shrink:0}[data-gene-ui-version=\"2.16.3\"] .uploaded-item>li.ui-title{flex:auto;overflow:hidden}[data-gene-ui-version=\"2.16.3\"] .uploaded-item .ui-preview-holder{position:relative}[data-gene-ui-version=\"2.16.3\"] .uploaded-item .ui-preview-holder small{display:block;font:700 .5rem/.9rem var(--font-family);left:0;position:absolute;text-align:center;text-transform:uppercase;top:.8rem;width:100%}[data-gene-ui-version=\"2.16.3\"] .uploaded-item .ui-title{font:600 1.4rem/normal var(--font-family);padding:0 2rem}[data-gene-ui-version=\"2.16.3\"] .uploaded-item .ui-actions-holder small{display:block;font:600 1rem/1.4rem var(--font-family);opacity:.7;padding-inline-end:.8rem;text-transform:uppercase}[data-gene-ui-version=\"2.16.3\"] .uploaded-item .ui-actions-holder .icon{cursor:pointer;transition:opacity .4s}[data-gene-ui-version=\"2.16.3\"] .uploaded-item.ui-light .ui-actions-holder .icon,[data-gene-ui-version=\"2.16.3\"] .uploaded-item.ui-minimal .ui-actions-holder .icon{opacity:0}@media (hover:hover){[data-gene-ui-version=\"2.16.3\"] .uploaded-item.ui-light .ui-actions-holder .icon:hover,[data-gene-ui-version=\"2.16.3\"] .uploaded-item.ui-minimal .ui-actions-holder .icon:hover{opacity:1}[data-gene-ui-version=\"2.16.3\"] .uploaded-item.ui-light:hover,[data-gene-ui-version=\"2.16.3\"] .uploaded-item.ui-minimal:hover{background:rgba(var(--background-sc-rgb),.05)}[data-gene-ui-version=\"2.16.3\"] .uploaded-item.ui-light:hover .ui-actions-holder .icon:not(:hover),[data-gene-ui-version=\"2.16.3\"] .uploaded-item.ui-minimal:hover .ui-actions-holder .icon:not(:hover){opacity:.5}}[data-gene-ui-version=\"2.16.3\"] .uploaded-item.ui-light.error,[data-gene-ui-version=\"2.16.3\"] .uploaded-item.ui-minimal.error{color:var(--danger)}@media (hover:hover){[data-gene-ui-version=\"2.16.3\"] .uploaded-item.ui-light.error:hover,[data-gene-ui-version=\"2.16.3\"] .uploaded-item.ui-minimal.error:hover{background:rgba(var(--danger-rgb),.05)}}[data-gene-ui-version=\"2.16.3\"] .uploaded-item.ui-light.error .ui-actions-holder .icon:not(:hover),[data-gene-ui-version=\"2.16.3\"] .uploaded-item.ui-minimal.error .ui-actions-holder .icon:not(:hover){opacity:.5}[data-gene-ui-version=\"2.16.3\"] .uploaded-item.ui-detailed{border:1px solid rgba(var(--background-sc-rgb),.08);border-radius:.8rem;height:4.2rem;padding:0 .8rem 0 1.4rem}html[dir=rtl] .uploaded-item.ui-detailed{padding:0 1.4rem 0 .8rem}[data-gene-ui-version=\"2.16.3\"] .uploaded-item.ui-detailed img{border-radius:.4rem;height:2.6rem;object-fit:cover;width:2.6rem}[data-gene-ui-version=\"2.16.3\"] .uploaded-item.ui-detailed .ui-title{font-size:1.2rem;padding:0 1.4rem}[data-gene-ui-version=\"2.16.3\"] .uploaded-item.ui-detailed .ui-actions-holder .icon{opacity:.5}@media (hover:hover){[data-gene-ui-version=\"2.16.3\"] .uploaded-item.ui-detailed .ui-actions-holder .icon:hover{opacity:1}[data-gene-ui-version=\"2.16.3\"] .uploaded-item.ui-detailed:hover{border-color:rgba(var(--background-sc-rgb),.38)}}[data-gene-ui-version=\"2.16.3\"] .uploaded-item.ui-detailed.error{border-color:rgba(var(--danger-rgb),.5)}[data-gene-ui-version=\"2.16.3\"] .uploaded-item.ui-detailed.error .ui-actions-holder .icon{color:var(--danger)}@media (hover:hover){[data-gene-ui-version=\"2.16.3\"] .uploaded-item.ui-detailed.error:hover{border-color:var(--danger)}[data-gene-ui-version=\"2.16.3\"] .uploaded-item.ui-detailed.error:hover .ui-actions-holder .icon{opacity:1}}";
|
|
176
|
-
styleInject(css_248z$2);
|
|
177
|
-
|
|
178
|
-
function UploadedItem(_ref) {
|
|
179
|
-
let {
|
|
180
|
-
notUploadedFileList,
|
|
181
|
-
uploadErrorText,
|
|
182
|
-
metaDataHeaders,
|
|
183
|
-
customHeaders,
|
|
184
|
-
appearance,
|
|
185
|
-
retryIndex,
|
|
186
|
-
onRemove,
|
|
187
|
-
showTrash,
|
|
188
|
-
onRetry,
|
|
189
|
-
isBusy,
|
|
190
|
-
index,
|
|
191
|
-
file,
|
|
192
|
-
showDownloadButton,
|
|
193
|
-
showRemoveButton,
|
|
194
|
-
showResetButton,
|
|
195
|
-
showPreviewButton,
|
|
196
|
-
additionalContext,
|
|
197
|
-
hideName
|
|
198
|
-
} = _ref;
|
|
199
|
-
const [previewImage, setPreviewImage] = useState(null);
|
|
200
|
-
const [lastModifiedDate, setLastModifiedDate] = useState(null);
|
|
201
|
-
const toPreview = useCallback(image => {
|
|
202
|
-
if (file.blob.type.search('pdf') > -1) {
|
|
203
|
-
const link = document.createElement('a');
|
|
204
|
-
link.href = file.path;
|
|
205
|
-
link.target = '_blank';
|
|
206
|
-
link.click();
|
|
207
|
-
} else {
|
|
208
|
-
setPreviewImage(image);
|
|
209
|
-
}
|
|
210
|
-
}, []);
|
|
211
|
-
const doClosePreview = useCallback(() => setPreviewImage(null), []);
|
|
212
|
-
useKeyDown(doClosePreview, [], {
|
|
213
|
-
current: window
|
|
214
|
-
}, ['Escape']);
|
|
215
|
-
const {
|
|
216
|
-
name,
|
|
217
|
-
blob: {
|
|
218
|
-
size,
|
|
219
|
-
type
|
|
220
|
-
},
|
|
221
|
-
path,
|
|
222
|
-
dimensions
|
|
223
|
-
} = file;
|
|
224
|
-
useEffect(() => {
|
|
225
|
-
switch (metaDataHeaders === null || metaDataHeaders === void 0 ? void 0 : metaDataHeaders.type) {
|
|
226
|
-
case 'LAST-MODIFIED':
|
|
227
|
-
if (metaDataHeaders.formatter) {
|
|
228
|
-
getLastMod(path, date => {
|
|
229
|
-
date ? setLastModifiedDate(metaDataHeaders.formatter(date)) : setLastModifiedDate(metaDataHeaders.formatter(new Date(Date.now())));
|
|
230
|
-
});
|
|
231
|
-
} else {
|
|
232
|
-
getLastMod(path, date => {
|
|
233
|
-
date ? setLastModifiedDate(new Date(date).toLocaleDateString()) : setLastModifiedDate(new Date(Date.now()).toLocaleDateString());
|
|
234
|
-
});
|
|
235
|
-
}
|
|
236
|
-
break;
|
|
237
|
-
}
|
|
238
|
-
}, [file]);
|
|
239
|
-
const uploadedError = notUploadedFileList.find(item => item && item.file === file);
|
|
240
|
-
const [image, fileExtension] = type.split('/');
|
|
241
|
-
const isImage = image === 'image';
|
|
242
|
-
const renderPreview = () => {
|
|
243
|
-
switch (appearance) {
|
|
244
|
-
case uploaderConfig.uploadedItemsAppearance[0]:
|
|
245
|
-
return /*#__PURE__*/React__default.createElement(Icon, {
|
|
246
|
-
type: "bc-icon-attachment"
|
|
247
|
-
});
|
|
248
|
-
case uploaderConfig.uploadedItemsAppearance[1]:
|
|
249
|
-
return /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement(Icon, {
|
|
250
|
-
type: "bc-icon-file-type"
|
|
251
|
-
}), /*#__PURE__*/React__default.createElement("small", null, fileExtension));
|
|
252
|
-
case uploaderConfig.uploadedItemsAppearance[2]:
|
|
253
|
-
return isImage ? /*#__PURE__*/React__default.createElement("img", {
|
|
254
|
-
src: path,
|
|
255
|
-
alt: name
|
|
256
|
-
}) : /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement(Icon, {
|
|
257
|
-
type: "bc-icon-file-type"
|
|
258
|
-
}), /*#__PURE__*/React__default.createElement("small", null, fileExtension));
|
|
259
|
-
}
|
|
260
|
-
};
|
|
261
|
-
const onDownload = useImgDownload();
|
|
262
|
-
return previewImage ? /*#__PURE__*/React__default.createElement(Preview, {
|
|
263
|
-
onClose: doClosePreview,
|
|
264
|
-
previewImage: previewImage,
|
|
265
|
-
hideName: hideName
|
|
266
|
-
}) : /*#__PURE__*/React__default.createElement(BusyLoader, {
|
|
267
|
-
isBusy: isBusy && retryIndex === index,
|
|
268
|
-
loadingText: ""
|
|
269
|
-
}, /*#__PURE__*/React__default.createElement(Tooltip, {
|
|
270
|
-
title: uploadedError ? uploadErrorText : '',
|
|
271
|
-
text: uploadedError && uploadedError.error || ''
|
|
272
|
-
}, appearance === uploaderConfig.uploadedItemsAppearance[3] && isImage ? /*#__PURE__*/React__default.createElement(Image, {
|
|
273
|
-
src: path,
|
|
274
|
-
withBorder: true,
|
|
275
|
-
isValid: !uploadedError,
|
|
276
|
-
actions: /*#__PURE__*/React__default.createElement(React__default.Fragment, null, uploadedError && showResetButton ? /*#__PURE__*/React__default.createElement(Button, {
|
|
277
|
-
icon: "bc-icon-reset",
|
|
278
|
-
appearance: "minimal",
|
|
279
|
-
"data-index": index,
|
|
280
|
-
onClick: onRetry,
|
|
281
|
-
type: "button"
|
|
282
|
-
}) : showPreviewButton && /*#__PURE__*/React__default.createElement(Button, {
|
|
283
|
-
icon: "bc-icon-view",
|
|
284
|
-
appearance: "minimal",
|
|
285
|
-
onClick: () => toPreview(file),
|
|
286
|
-
type: "button"
|
|
287
|
-
}), showRemoveButton && /*#__PURE__*/React__default.createElement(Button, {
|
|
288
|
-
icon: "bc-icon-trash",
|
|
289
|
-
"data-index": index,
|
|
290
|
-
onClick: onRemove,
|
|
291
|
-
appearance: "minimal",
|
|
292
|
-
color: "danger",
|
|
293
|
-
type: "button"
|
|
294
|
-
}))
|
|
295
|
-
}) : /*#__PURE__*/React__default.createElement("ul", {
|
|
296
|
-
className: classnames('uploaded-item', "ui-".concat(appearance), {
|
|
297
|
-
error: uploadedError
|
|
298
|
-
})
|
|
299
|
-
}, /*#__PURE__*/React__default.createElement("li", {
|
|
300
|
-
className: "ui-preview-holder"
|
|
301
|
-
}, renderPreview()), /*#__PURE__*/React__default.createElement("li", {
|
|
302
|
-
className: "ui-title"
|
|
303
|
-
}, /*#__PURE__*/React__default.createElement("div", {
|
|
304
|
-
className: "ellipsis-text"
|
|
305
|
-
}, name)), /*#__PURE__*/React__default.createElement("li", {
|
|
306
|
-
className: "ui-actions-holder"
|
|
307
|
-
}, /*#__PURE__*/React__default.createElement("small", null, lastModifiedDate || fileSizeDisplay(size)), uploadedError && showResetButton && /*#__PURE__*/React__default.createElement(Icon, {
|
|
308
|
-
type: "bc-icon-upload-reset",
|
|
309
|
-
"data-index": index,
|
|
310
|
-
onClick: onRetry
|
|
311
|
-
}), showPreviewButton && /*#__PURE__*/React__default.createElement(Icon, {
|
|
312
|
-
type: "bc-icon-activate",
|
|
313
|
-
appearance: "minimal",
|
|
314
|
-
"data-index": index,
|
|
315
|
-
onClick: () => toPreview(file)
|
|
316
|
-
}), showRemoveButton && /*#__PURE__*/React__default.createElement(Icon, {
|
|
317
|
-
type: "bc-icon-trash",
|
|
318
|
-
appearance: "minimal",
|
|
319
|
-
"data-index": index,
|
|
320
|
-
onClick: onRemove
|
|
321
|
-
}), showDownloadButton && /*#__PURE__*/React__default.createElement(Icon, {
|
|
322
|
-
type: "bc-icon-download",
|
|
323
|
-
appearance: "minimal",
|
|
324
|
-
"data-index": index,
|
|
325
|
-
onClick: () => onDownload(file.path, file.name, customHeaders)
|
|
326
|
-
})))));
|
|
327
|
-
}
|
|
328
|
-
UploadedItem.propTypes = {
|
|
329
|
-
file: PropTypes.object,
|
|
330
|
-
index: PropTypes.number,
|
|
331
|
-
isBusy: PropTypes.bool,
|
|
332
|
-
showTrash: PropTypes.bool,
|
|
333
|
-
notUploadedFileList: PropTypes.array,
|
|
334
|
-
onRemove: PropTypes.func,
|
|
335
|
-
onRetry: PropTypes.func,
|
|
336
|
-
retryIndex: PropTypes.number,
|
|
337
|
-
uploadErrorText: PropTypes.string,
|
|
338
|
-
appearance: PropTypes.oneOf(uploaderConfig.uploadedItemsAppearance),
|
|
339
|
-
showDownloadButton: PropTypes.bool,
|
|
340
|
-
showRemoveButton: PropTypes.bool,
|
|
341
|
-
showResetButton: PropTypes.bool,
|
|
342
|
-
showPreviewButton: PropTypes.bool
|
|
343
|
-
};
|
|
344
|
-
UploadedItem.defaultProps = {
|
|
345
|
-
appearance: uploaderConfig.uploadedItemsAppearance[0],
|
|
346
|
-
isBusy: false,
|
|
347
|
-
uploadErrorText: 'Upload Error',
|
|
348
|
-
onRetry: noop,
|
|
349
|
-
onRemove: noop,
|
|
350
|
-
showDownloadButton: true,
|
|
351
|
-
showRemoveButton: true,
|
|
352
|
-
showResetButton: true,
|
|
353
|
-
showPreviewButton: true
|
|
354
|
-
};
|
|
355
|
-
|
|
356
|
-
var css_248z$1 = "[data-gene-ui-version=\"2.16.3\"] .drop-area-holder{max-width:100%;position:relative;transition:opacity .4s}[data-gene-ui-version=\"2.16.3\"] .drop-area-holder.disabled{opacity:.5;pointer-events:none}[data-gene-ui-version=\"2.16.3\"] .drop-area-holder:not(.ua-button){width:100%}[data-gene-ui-version=\"2.16.3\"] .drop-area-holder.ua-input .uploader-chooser-holder{display:grid;grid-template-areas:\"input button\";grid-template-columns:1fr auto;position:relative}[data-gene-ui-version=\"2.16.3\"] .drop-area-holder.ua-input .uploader-chooser-holder .input-holder{grid-area:input}html:not([dir=rtl]) .drop-area-holder.ua-input .uploader-chooser-holder .input-element-back{border-top-right-radius:0}html[dir=rtl] .drop-area-holder.ua-input .uploader-chooser-holder .input-element-back{border-top-left-radius:0}html:not([dir=rtl]) .drop-area-holder.ua-input .uploader-chooser-holder .input-element-back{border-bottom-right-radius:0}html[dir=rtl] .drop-area-holder.ua-input .uploader-chooser-holder .input-element-back{border-bottom-left-radius:0}html:not([dir=rtl]) .drop-area-holder.ua-input .uploader-chooser-holder .input-element-back{border-right:0}html[dir=rtl] .drop-area-holder.ua-input .uploader-chooser-holder .input-element-back{border-left:0}[data-gene-ui-version=\"2.16.3\"] .drop-area-holder.ua-input .uploader-chooser-holder .btn{grid-area:button}html:not([dir=rtl]) .drop-area-holder.ua-input .uploader-chooser-holder .btn{border-top-left-radius:0}html[dir=rtl] .drop-area-holder.ua-input .uploader-chooser-holder .btn{border-top-right-radius:0}html:not([dir=rtl]) .drop-area-holder.ua-input .uploader-chooser-holder .btn{border-bottom-left-radius:0}html[dir=rtl] .drop-area-holder.ua-input .uploader-chooser-holder .btn{border-bottom-right-radius:0}html:not([dir=rtl]) .drop-area-holder.ua-input .uploader-chooser-holder .btn{border-left:0}html[dir=rtl] .drop-area-holder.ua-input .uploader-chooser-holder .btn{border-right:0}[data-gene-ui-version=\"2.16.3\"] .drop-area-holder.ua-input .uploader-chooser-holder.dirty input[type=file]{grid-area:input}[data-gene-ui-version=\"2.16.3\"] .drop-area-holder.ua-box .uploader-chooser-holder{padding:100% 0 0;position:relative}[data-gene-ui-version=\"2.16.3\"] .uploader-chooser-holder{display:block;transition:opacity .4s}[data-gene-ui-version=\"2.16.3\"] .drop-area-holder.active .uploader-chooser-holder{opacity:0}[data-gene-ui-version=\"2.16.3\"] .uploader-chooser-holder input[type=file]{cursor:pointer;height:100%;left:0;opacity:0;position:absolute;top:0;width:100%;z-index:1}[data-gene-ui-version=\"2.16.3\"] .uploader-chooser-holder input[type=file]::-webkit-file-upload-button{visibility:hidden}[data-gene-ui-version=\"2.16.3\"] .drop-here-element{align-items:center;background:rgba(var(--hero-rgb),.1);border:1px dashed var(--hero);border-radius:1rem;color:var(--hero);display:flex;font:600 1.4rem/1.8rem var(--font-family);height:100%;justify-content:center;left:0;padding:0 1rem;pointer-events:none;position:absolute;top:0;transition:opacity .4s;width:100%;z-index:10}[data-gene-ui-version=\"2.16.3\"] .drop-area-holder:not(.active) .drop-here-element{opacity:0}[data-gene-ui-version=\"2.16.3\"] .ua-button .drop-here-element.cr-round,[data-gene-ui-version=\"2.16.3\"] .ua-input .drop-here-element.cr-round{border-radius:3.6rem}[data-gene-ui-version=\"2.16.3\"] .ua-button .drop-here-element.cr-smooth,[data-gene-ui-version=\"2.16.3\"] .ua-input .drop-here-element.cr-smooth{border-radius:.4rem}[data-gene-ui-version=\"2.16.3\"] .ua-cloud .drop-here-element{border-radius:.8rem}[data-gene-ui-version=\"2.16.3\"] .cloud-box-uploader{align-items:center;border:1px dashed rgba(var(--background-sc-rgb),.2);border-radius:.8rem;display:flex;flex-direction:column;font:600 2rem/2.4rem var(--font-family);justify-content:center;min-height:28rem;text-align:center;transition:background .4s,border-color .4s;width:100%}[data-gene-ui-version=\"2.16.3\"] .uploader-chooser-holder:hover .cloud-box-uploader{background:rgba(var(--hero-rgb),.02);border-color:var(--hero)}[data-gene-ui-version=\"2.16.3\"] .s-uploading .cloud-box-uploader{background:rgba(var(--background-sc-rgb),.01)}[data-gene-ui-version=\"2.16.3\"] .cloud-box-uploader.error{background:rgba(var(--danger-rgb),.02);border-color:var(--danger)}[data-gene-ui-version=\"2.16.3\"] .cloud-box-uploader>p{opacity:.8}[data-gene-ui-version=\"2.16.3\"] .cloud-box-uploader>.icon{font-size:9.6rem;margin:1rem 0 .4rem;opacity:.23}[data-gene-ui-version=\"2.16.3\"] .cloud-box-uploader>h5{font:inherit;opacity:.8}[data-gene-ui-version=\"2.16.3\"] .cloud-box-uploader>small{display:block;font:600 1.4rem/1.8rem var(--font-family);margin:1rem 0 1.5rem;opacity:.5}[data-gene-ui-version=\"2.16.3\"] .box-uploader{align-items:center;border:1px dashed rgba(var(--background-sc-rgb),.2);border-radius:1rem;display:flex;flex-direction:column;height:100%;justify-content:center;left:0;position:absolute;text-align:center;top:0;transition:background .4s,border-color .4s;width:100%}[data-gene-ui-version=\"2.16.3\"] .uploader-chooser-holder:hover .box-uploader{background:rgba(var(--hero-rgb),.02);border-color:var(--hero)}[data-gene-ui-version=\"2.16.3\"] .s-uploading .box-uploader{border-style:solid}[data-gene-ui-version=\"2.16.3\"] .box-uploader.error{background:rgba(var(--danger-rgb),.02);border-color:var(--danger)}[data-gene-ui-version=\"2.16.3\"] .box-uploader h5{font:600 1.4rem/normal var(--font-family);margin:1rem 0 0;opacity:.8}[data-gene-ui-version=\"2.16.3\"] .box-uploader .responsive-plus-icon-holder{max-height:6.4rem;max-width:6.4rem;min-height:3.6rem;min-width:3.6rem;opacity:.2;width:23.2456140351%}[data-gene-ui-version=\"2.16.3\"] .responsive-plus-icon{padding:100% 0 0;position:relative}[data-gene-ui-version=\"2.16.3\"] .responsive-plus-icon:after,[data-gene-ui-version=\"2.16.3\"] .responsive-plus-icon:before{background:var(--background-sc);border-radius:1rem;content:\"\";display:block;left:50%;padding:7.5471698113% 0 0;position:absolute;top:50%;width:88.679245283%}[data-gene-ui-version=\"2.16.3\"] .responsive-plus-icon:before{transform:translate(-50%,-50%)}[data-gene-ui-version=\"2.16.3\"] .responsive-plus-icon:after{transform:translate(-50%,-50%) rotate(90deg)}";
|
|
357
|
-
styleInject(css_248z$1);
|
|
358
|
-
|
|
359
|
-
const UploadView = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
360
|
-
let {
|
|
361
|
-
immediatelyUploadAfterSelect,
|
|
362
|
-
inputCornerRadius,
|
|
363
|
-
startUploadLabel,
|
|
364
|
-
chooseFileLabel,
|
|
365
|
-
dropHereLabel,
|
|
366
|
-
cornerRadius,
|
|
367
|
-
loadingLabel,
|
|
368
|
-
browseLabel,
|
|
369
|
-
appearance,
|
|
370
|
-
isDisabled,
|
|
371
|
-
className,
|
|
372
|
-
draggable,
|
|
373
|
-
typesList,
|
|
374
|
-
onUpload,
|
|
375
|
-
multiple,
|
|
376
|
-
isValid,
|
|
377
|
-
isBusy,
|
|
378
|
-
icon,
|
|
379
|
-
...restProps
|
|
380
|
-
} = _ref;
|
|
381
|
-
const handleChange = useCallback(e => {
|
|
382
|
-
onUpload && onUpload(e);
|
|
383
|
-
e.target.value = '';
|
|
384
|
-
}, [onUpload]);
|
|
385
|
-
const acceptTypes = useMemo(() => typesList.map(type => ".".concat(type)).toString(), [typesList]);
|
|
386
|
-
const dirty = false;
|
|
387
|
-
const renderUploadHolder = () => {
|
|
388
|
-
const placeholder = isBusy ? loadingLabel : chooseFileLabel;
|
|
389
|
-
switch (appearance) {
|
|
390
|
-
case uploaderConfig.uploaderAppearance[0]:
|
|
391
|
-
return /*#__PURE__*/React__default.createElement(Button, {
|
|
392
|
-
appearance: "outline",
|
|
393
|
-
cornerRadius: cornerRadius,
|
|
394
|
-
color: isValid ? '' : 'danger',
|
|
395
|
-
icon: isBusy ? 'bc-icon-loader' : icon
|
|
396
|
-
}, placeholder);
|
|
397
|
-
case uploaderConfig.uploaderAppearance[1]:
|
|
398
|
-
return /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement(ExtendedInput, {
|
|
399
|
-
cornerRadius: inputCornerRadius,
|
|
400
|
-
placeholder: placeholder,
|
|
401
|
-
inputSize: "big",
|
|
402
|
-
writeProtected: true,
|
|
403
|
-
colorBorderOnError: true,
|
|
404
|
-
isValid: isValid
|
|
405
|
-
}), /*#__PURE__*/React__default.createElement(Button, {
|
|
406
|
-
cornerRadius: cornerRadius,
|
|
407
|
-
size: "big",
|
|
408
|
-
icon: isBusy ? 'bc-icon-loader' : '',
|
|
409
|
-
color: isValid ? 'confirm' : 'danger'
|
|
410
|
-
}, browseLabel));
|
|
411
|
-
case uploaderConfig.uploaderAppearance[2]:
|
|
412
|
-
return /*#__PURE__*/React__default.createElement("div", {
|
|
413
|
-
className: classnames('cloud-box-uploader', {
|
|
414
|
-
error: !isValid
|
|
415
|
-
})
|
|
416
|
-
}, isBusy ? /*#__PURE__*/React__default.createElement("p", null, loadingLabel) : /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement(Icon, {
|
|
417
|
-
type: icon || 'bc-icon-cloud-upload'
|
|
418
|
-
}), /*#__PURE__*/React__default.createElement("h5", null, chooseFileLabel), /*#__PURE__*/React__default.createElement("small", null, "or"), /*#__PURE__*/React__default.createElement(Button, {
|
|
419
|
-
cornerRadius: cornerRadius,
|
|
420
|
-
color: isValid ? '' : 'danger'
|
|
421
|
-
}, browseLabel)));
|
|
422
|
-
case uploaderConfig.uploaderAppearance[3]:
|
|
423
|
-
return /*#__PURE__*/React__default.createElement("div", {
|
|
424
|
-
className: classnames('box-uploader', {
|
|
425
|
-
error: !isValid
|
|
426
|
-
})
|
|
427
|
-
}, /*#__PURE__*/React__default.createElement(BusyLoader, {
|
|
428
|
-
isBusy: isBusy,
|
|
429
|
-
loadingText: loadingLabel,
|
|
430
|
-
className: "p-absolute"
|
|
431
|
-
}, /*#__PURE__*/React__default.createElement("div", {
|
|
432
|
-
className: "responsive-plus-icon-holder"
|
|
433
|
-
}, /*#__PURE__*/React__default.createElement("div", {
|
|
434
|
-
className: "responsive-plus-icon"
|
|
435
|
-
})), /*#__PURE__*/React__default.createElement("h5", null, chooseFileLabel)));
|
|
436
|
-
}
|
|
437
|
-
};
|
|
438
|
-
return /*#__PURE__*/React__default.createElement("ul", _extends({
|
|
439
|
-
className: classnames('drop-area-holder', className, "ua-".concat(appearance), {
|
|
440
|
-
active: draggable,
|
|
441
|
-
disabled: isDisabled,
|
|
442
|
-
'pointer-events-none s-uploading': isBusy
|
|
443
|
-
}),
|
|
444
|
-
ref: ref
|
|
445
|
-
}, restProps), /*#__PURE__*/React__default.createElement("label", {
|
|
446
|
-
className: classnames('uploader-chooser-holder', {
|
|
447
|
-
dirty
|
|
448
|
-
})
|
|
449
|
-
}, renderUploadHolder(), /*#__PURE__*/React__default.createElement("input", {
|
|
450
|
-
type: "file",
|
|
451
|
-
onChange: handleChange,
|
|
452
|
-
disabled: isDisabled,
|
|
453
|
-
accept: acceptTypes,
|
|
454
|
-
title: "",
|
|
455
|
-
multiple: multiple
|
|
456
|
-
})), !isDisabled && /*#__PURE__*/React__default.createElement("div", {
|
|
457
|
-
className: classnames('drop-here-element', "cr-".concat(cornerRadius))
|
|
458
|
-
}, /*#__PURE__*/React__default.createElement("p", {
|
|
459
|
-
className: "ellipsis-text"
|
|
460
|
-
}, dropHereLabel)));
|
|
461
|
-
});
|
|
462
|
-
UploadView.propTypes = {
|
|
463
|
-
appearance: PropTypes.oneOf(uploaderConfig.uploaderAppearance),
|
|
464
|
-
immediatelyUploadAfterSelect: PropTypes.bool,
|
|
465
|
-
onUpload: PropTypes.func.isRequired,
|
|
466
|
-
draggable: PropTypes.bool,
|
|
467
|
-
icon: PropTypes.string,
|
|
468
|
-
cornerRadius: 'smooth',
|
|
469
|
-
inputCornerRadius: ExtendedInput.propTypes.cornerRadius,
|
|
470
|
-
isDisabled: PropTypes.bool,
|
|
471
|
-
isBusy: PropTypes.bool,
|
|
472
|
-
chooseFileLabel: PropTypes.string,
|
|
473
|
-
browseLabel: PropTypes.string,
|
|
474
|
-
startUploadLabel: PropTypes.string,
|
|
475
|
-
dropHereLabel: PropTypes.string,
|
|
476
|
-
loadingLabel: PropTypes.string,
|
|
477
|
-
className: PropTypes.string,
|
|
478
|
-
isValid: PropTypes.bool,
|
|
479
|
-
typesList: PropTypes.arrayOf(PropTypes.string)
|
|
480
|
-
};
|
|
481
|
-
UploadView.defaultProps = {
|
|
482
|
-
appearance: uploaderConfig.uploaderAppearance[0],
|
|
483
|
-
immediatelyUploadAfterSelect: true,
|
|
484
|
-
draggable: false,
|
|
485
|
-
cornerRadius: 'smooth',
|
|
486
|
-
inputCornerRadius: ExtendedInput.defaultProps.cornerRadius,
|
|
487
|
-
isDisabled: false,
|
|
488
|
-
isBusy: false,
|
|
489
|
-
chooseFileLabel: 'Upload File',
|
|
490
|
-
browseLabel: 'Browse',
|
|
491
|
-
startUploadLabel: 'Start Upload',
|
|
492
|
-
dropHereLabel: 'Drop here',
|
|
493
|
-
loadingLabel: 'Uploading...',
|
|
494
|
-
typesList: [],
|
|
495
|
-
isValid: true,
|
|
496
|
-
multiple: false
|
|
497
|
-
};
|
|
498
|
-
|
|
499
|
-
var css_248z = "[data-gene-ui-version=\"2.16.3\"] .uploader-holder{align-items:flex-start;display:flex;flex-direction:column;width:100%}[data-gene-ui-version=\"2.16.3\"] .uploader-holder .grid-child{min-height:2.8rem;position:relative}[data-gene-ui-version=\"2.16.3\"] .uploader-header{align-items:flex-start;display:flex;flex-direction:column;width:100%}[data-gene-ui-version=\"2.16.3\"] .uploader-header:not(.only-child){margin:0 0 1.4rem}[data-gene-ui-version=\"2.16.3\"] .uploader-footer{align-items:flex-start;display:flex;flex-direction:column;width:100%}[data-gene-ui-version=\"2.16.3\"] .ua-cloud>.uploader-footer{align-items:center}[data-gene-ui-version=\"2.16.3\"] .ua-input>.uploader-footer{padding:0 2rem}[data-gene-ui-version=\"2.16.3\"] .uploader-footer .uploader-footer-button{margin:1.8rem 0 0}";
|
|
500
|
-
styleInject(css_248z);
|
|
501
|
-
|
|
502
|
-
const lowGrid = 10;
|
|
503
|
-
const highGrid = 20;
|
|
504
|
-
function Uploader(_ref) {
|
|
505
|
-
let {
|
|
506
|
-
immediatelyUploadAfterSelect,
|
|
507
|
-
uploadedItemsAppearance,
|
|
508
|
-
informationMessage,
|
|
509
|
-
uploaderAppearance,
|
|
510
|
-
inputCornerRadius,
|
|
511
|
-
allTypesAccepted,
|
|
512
|
-
startUploadLabel,
|
|
513
|
-
noFileChosenText,
|
|
514
|
-
chooseFileLabel,
|
|
515
|
-
getInitialState,
|
|
516
|
-
showLocalErrors,
|
|
517
|
-
metaDataHeaders,
|
|
518
|
-
showDownloadButton,
|
|
519
|
-
showResetButton,
|
|
520
|
-
showPreviewButton,
|
|
521
|
-
uploadErrorText,
|
|
522
|
-
uploadingLabel,
|
|
523
|
-
fileChosenText,
|
|
524
|
-
fileAppearance,
|
|
525
|
-
customHeaders,
|
|
526
|
-
isImageUpload,
|
|
527
|
-
dropHereLabel,
|
|
528
|
-
maxFileCount,
|
|
529
|
-
cornerRadius,
|
|
530
|
-
deleteAction,
|
|
531
|
-
sizeErrorMsg,
|
|
532
|
-
typeErrorMsg,
|
|
533
|
-
isActiveDrop,
|
|
534
|
-
loadingLabel,
|
|
535
|
-
browseLabel,
|
|
536
|
-
maxFileSize,
|
|
537
|
-
isDisabled,
|
|
538
|
-
typesList,
|
|
539
|
-
showTrash,
|
|
540
|
-
className,
|
|
541
|
-
draggText,
|
|
542
|
-
onChange,
|
|
543
|
-
required,
|
|
544
|
-
multiple,
|
|
545
|
-
isValid,
|
|
546
|
-
upload,
|
|
547
|
-
icon,
|
|
548
|
-
data,
|
|
549
|
-
initialData,
|
|
550
|
-
images,
|
|
551
|
-
initialImages,
|
|
552
|
-
additionalContext,
|
|
553
|
-
hideName,
|
|
554
|
-
...restProps
|
|
555
|
-
} = _ref;
|
|
556
|
-
const isControlled = useMemo(() => Array.isArray(images), [images]);
|
|
557
|
-
const dropRef = useRef(null);
|
|
558
|
-
const [fileList, setFileList] = useState(generateFilesByPage(initialImages));
|
|
559
|
-
const [deletedFileList, setDeletedFileList] = useState([]);
|
|
560
|
-
const [errorMsg, setErrorMsg] = useState('');
|
|
561
|
-
const [notUploadedFileList, setNotUploadedFileList] = useState([]);
|
|
562
|
-
const [draggable, setDraggable] = useState(false);
|
|
563
|
-
const [isBusy, setIsBusy] = useState(false);
|
|
564
|
-
const [refreshIndex, setRefreshIndex] = useState(null);
|
|
565
|
-
const [valid, setValidation] = useState(true);
|
|
566
|
-
useEffect(() => {
|
|
567
|
-
isControlled && setFileList(generateFilesByPage(images));
|
|
568
|
-
}, [isControlled, images]);
|
|
569
|
-
useEffect(() => getInitialState && getInitialState(valid), [getInitialState, valid]);
|
|
570
|
-
useEffect(() => setValidation(required ? !!fileList.length : true), [fileList, required]);
|
|
571
|
-
useEffect(() => {
|
|
572
|
-
if (Array.isArray(data)) {
|
|
573
|
-
if (data && data.length > 0) {
|
|
574
|
-
setIsBusy(true);
|
|
575
|
-
Promise.all([...data.map(file => getFileByUrl(file.path, file, isImageUpload, customHeaders))]).then(res => {
|
|
576
|
-
setFileList(res);
|
|
577
|
-
}).finally(() => setIsBusy(false));
|
|
578
|
-
} else {
|
|
579
|
-
setFileList([]);
|
|
580
|
-
}
|
|
581
|
-
}
|
|
582
|
-
}, [data, isImageUpload]);
|
|
583
|
-
const startUpload = useCallback((uploadedFiles, deletedFiles) => {
|
|
584
|
-
setIsBusy(true);
|
|
585
|
-
return new Promise((resolve, reject) => {
|
|
586
|
-
upload({
|
|
587
|
-
uploadedFiles,
|
|
588
|
-
deletedFiles
|
|
589
|
-
}).then(resolve).catch(reject).finally(() => setIsBusy(false));
|
|
590
|
-
});
|
|
591
|
-
}, [upload]);
|
|
592
|
-
const fileChangeHandler = useCallback((newList, del) => {
|
|
593
|
-
!isControlled && (!multiple || del) && setFileList(prev => maxFileCount >= prev.length ? newList : prev);
|
|
594
|
-
!isControlled && multiple && !del && setFileList(prev => maxFileCount > prev.length ? [newList[0], ...prev] : prev);
|
|
595
|
-
onChange({
|
|
596
|
-
value: newList
|
|
597
|
-
});
|
|
598
|
-
}, [isControlled, onChange]);
|
|
599
|
-
const checkFileValidation = useCallback(file => {
|
|
600
|
-
if (file.size) {
|
|
601
|
-
const {
|
|
602
|
-
isValidSize,
|
|
603
|
-
isValidType
|
|
604
|
-
} = isValidFile({
|
|
605
|
-
allTypesAccepted,
|
|
606
|
-
isImageUpload,
|
|
607
|
-
maxFileSize,
|
|
608
|
-
typesList,
|
|
609
|
-
file
|
|
610
|
-
});
|
|
611
|
-
if (showLocalErrors) {
|
|
612
|
-
const msg = isValidSize ? isValidType ? '' : typeErrorMsg.replace(typeListReplacer, typesList.join(', ')) : sizeErrorMsg.replace(maxFileSizeReplacer, maxFileSize);
|
|
613
|
-
setErrorMsg(msg);
|
|
614
|
-
}
|
|
615
|
-
return isValidSize && isValidType;
|
|
616
|
-
}
|
|
617
|
-
}, [allTypesAccepted, isImageUpload, maxFileSize, typesList, showLocalErrors, typeErrorMsg, sizeErrorMsg]);
|
|
618
|
-
const addFile = useCallback(async file => {
|
|
619
|
-
if (checkFileValidation(file)) {
|
|
620
|
-
const blobFile = await toBlobFile(file, isImageUpload);
|
|
621
|
-
const newList = maxFileCount ? [blobFile, ...fileList].slice(0, maxFileCount) : [blobFile, ...fileList];
|
|
622
|
-
if (immediatelyUploadAfterSelect && upload) {
|
|
623
|
-
startUpload(newList, deletedFileList).catch(error => {
|
|
624
|
-
setNotUploadedFileList([{
|
|
625
|
-
file: blobFile,
|
|
626
|
-
error
|
|
627
|
-
}, ...notUploadedFileList]);
|
|
628
|
-
}).finally(() => {
|
|
629
|
-
fileChangeHandler(newList, false);
|
|
630
|
-
});
|
|
631
|
-
} else {
|
|
632
|
-
fileChangeHandler(newList, false);
|
|
633
|
-
}
|
|
634
|
-
}
|
|
635
|
-
}, [checkFileValidation, isImageUpload, maxFileCount, fileList.length, immediatelyUploadAfterSelect, upload, startUpload, deletedFileList, notUploadedFileList, fileChangeHandler]);
|
|
636
|
-
const handleDrop = useCallback(e => {
|
|
637
|
-
stopEvent(e, true);
|
|
638
|
-
setDraggable(false);
|
|
639
|
-
const {
|
|
640
|
-
dataTransfer: {
|
|
641
|
-
files = []
|
|
642
|
-
}
|
|
643
|
-
} = e;
|
|
644
|
-
if (isActiveDrop && files.length) {
|
|
645
|
-
addFile(files[0]);
|
|
646
|
-
}
|
|
647
|
-
}, [isActiveDrop, addFile]);
|
|
648
|
-
const handleDragIn = useCallback(e => {
|
|
649
|
-
stopEvent(e, true);
|
|
650
|
-
e.dataTransfer.items.length && setDraggable(true);
|
|
651
|
-
}, []);
|
|
652
|
-
const handleDragOut = useCallback(e => {
|
|
653
|
-
stopEvent(e, true);
|
|
654
|
-
setDraggable(false);
|
|
655
|
-
}, []);
|
|
656
|
-
useEffect(() => {
|
|
657
|
-
const div = dropRef.current;
|
|
658
|
-
if (div && !isBusy) {
|
|
659
|
-
addDragEventListener(div, handleDragIn, handleDragOut, handleDrop);
|
|
660
|
-
return () => {
|
|
661
|
-
removeDragEventListener(div, handleDragIn, handleDragOut, handleDrop);
|
|
662
|
-
};
|
|
663
|
-
}
|
|
664
|
-
}, [handleDrop, dropRef.current, isBusy]);
|
|
665
|
-
const onUpload = useCallback(e => {
|
|
666
|
-
for (const file in e.target.files) addFile(e.target.files[file]);
|
|
667
|
-
e.target.value = null;
|
|
668
|
-
}, [addFile]);
|
|
669
|
-
const doUpload = useCallback(e => {
|
|
670
|
-
stopEvent(e, true);
|
|
671
|
-
if (upload && fileList.length) {
|
|
672
|
-
setNotUploadedFileList([]);
|
|
673
|
-
startUpload(fileList, deletedFileList).then(_ref2 => {
|
|
674
|
-
let {
|
|
675
|
-
fileErrors
|
|
676
|
-
} = _ref2;
|
|
677
|
-
fileErrors && setNotUploadedFileList([...fileErrors]);
|
|
678
|
-
}).catch(() => setNotUploadedFileList([...fileList]));
|
|
679
|
-
}
|
|
680
|
-
}, [upload, fileList, startUpload, deletedFileList]);
|
|
681
|
-
const deleteItemByIndex = useCallback(e => {
|
|
682
|
-
const {
|
|
683
|
-
index
|
|
684
|
-
} = e.currentTarget.dataset;
|
|
685
|
-
const newList = [...fileList];
|
|
686
|
-
newList.splice(index, 1);
|
|
687
|
-
if (data && data.find(file => file.id === (fileList[index] && fileList[index].id))) {
|
|
688
|
-
setDeletedFileList([...deletedFileList, fileList[index]]);
|
|
689
|
-
if (isImageUpload) {
|
|
690
|
-
deleteAction(fileList[index]);
|
|
691
|
-
}
|
|
692
|
-
}
|
|
693
|
-
fileChangeHandler(newList, true);
|
|
694
|
-
}, [fileList, data, fileChangeHandler, deletedFileList, isImageUpload, deleteAction]);
|
|
695
|
-
const uploadRefresh = useCallback(e => {
|
|
696
|
-
const {
|
|
697
|
-
index
|
|
698
|
-
} = e.currentTarget.dataset;
|
|
699
|
-
const file = fileList[index];
|
|
700
|
-
if (file && upload) {
|
|
701
|
-
setRefreshIndex(Number(index));
|
|
702
|
-
startUpload(file, deletedFileList).then(() => {
|
|
703
|
-
const newList = notUploadedFileList.filter(notUploaded => notUploaded.file !== file);
|
|
704
|
-
setNotUploadedFileList(newList);
|
|
705
|
-
}).finally(() => setRefreshIndex(null));
|
|
706
|
-
}
|
|
707
|
-
}, [startUpload, notUploadedFileList, fileList, upload, deletedFileList]);
|
|
708
|
-
const isBoxApperance = uploaderAppearance === uploaderConfig.uploaderAppearance[3];
|
|
709
|
-
const gridGap = isBoxApperance ? highGrid : lowGrid;
|
|
710
|
-
const isExistFile = !!fileList.length;
|
|
711
|
-
return /*#__PURE__*/React__default.createElement("div", _extends({
|
|
712
|
-
className: classnames('uploader-holder', "ua-".concat(uploaderAppearance), className)
|
|
713
|
-
}, restProps), !isBoxApperance && /*#__PURE__*/React__default.createElement("div", {
|
|
714
|
-
className: classnames('uploader-header', {
|
|
715
|
-
'only-child': !isExistFile
|
|
716
|
-
})
|
|
717
|
-
}, /*#__PURE__*/React__default.createElement(UploadView, {
|
|
718
|
-
appearance: uploaderAppearance,
|
|
719
|
-
immediatelyUploadAfterSelect: immediatelyUploadAfterSelect,
|
|
720
|
-
onUpload: onUpload,
|
|
721
|
-
ref: dropRef,
|
|
722
|
-
draggable: draggable,
|
|
723
|
-
icon: icon,
|
|
724
|
-
cornerRadius: cornerRadius,
|
|
725
|
-
isDisabled: isDisabled,
|
|
726
|
-
isBusy: isBusy,
|
|
727
|
-
chooseFileLabel: chooseFileLabel,
|
|
728
|
-
browseLabel: browseLabel,
|
|
729
|
-
startUploadLabel: startUploadLabel,
|
|
730
|
-
dropHereLabel: dropHereLabel,
|
|
731
|
-
loadingLabel: loadingLabel,
|
|
732
|
-
isValid: isValid,
|
|
733
|
-
typesList: typesList,
|
|
734
|
-
multiple: multiple
|
|
735
|
-
})), (isExistFile || isBoxApperance) && /*#__PURE__*/React__default.createElement(Row, {
|
|
736
|
-
padding: gridGap,
|
|
737
|
-
gutter: gridGap
|
|
738
|
-
}, fileList.map((file, index) => /*#__PURE__*/React__default.createElement(Col, _extends({}, uploaderConfig.gridColumnSize, {
|
|
739
|
-
key: index
|
|
740
|
-
}), /*#__PURE__*/React__default.createElement(UploadedItem, {
|
|
741
|
-
file: file,
|
|
742
|
-
index: index,
|
|
743
|
-
isBusy: isBusy,
|
|
744
|
-
onRetry: uploadRefresh,
|
|
745
|
-
retryIndex: refreshIndex,
|
|
746
|
-
showRemoveButton: showTrash,
|
|
747
|
-
onRemove: deleteItemByIndex,
|
|
748
|
-
uploadErrorText: uploadErrorText,
|
|
749
|
-
showResetButton: showResetButton,
|
|
750
|
-
metaDataHeaders: metaDataHeaders,
|
|
751
|
-
appearance: uploadedItemsAppearance,
|
|
752
|
-
showPreviewButton: showPreviewButton,
|
|
753
|
-
additionalContext: additionalContext,
|
|
754
|
-
showDownloadButton: showDownloadButton,
|
|
755
|
-
notUploadedFileList: notUploadedFileList,
|
|
756
|
-
customHeaders: customHeaders,
|
|
757
|
-
hideName: hideName
|
|
758
|
-
}))), isBoxApperance && /*#__PURE__*/React__default.createElement(Col, uploaderConfig.gridColumnSize, /*#__PURE__*/React__default.createElement(UploadView, {
|
|
759
|
-
appearance: uploadedItemsAppearance
|
|
760
|
-
}))), /*#__PURE__*/React__default.createElement("div", {
|
|
761
|
-
className: "uploader-footer"
|
|
762
|
-
}, (informationMessage || showLocalErrors && errorMsg) && /*#__PURE__*/React__default.createElement("div", {
|
|
763
|
-
className: classnames('information-message', {
|
|
764
|
-
'color-danger': !!errorMsg
|
|
765
|
-
})
|
|
766
|
-
}, errorMsg || informationMessage), !immediatelyUploadAfterSelect && isExistFile && uploaderAppearance !== uploaderConfig.uploaderAppearance[1] && /*#__PURE__*/React__default.createElement("div", {
|
|
767
|
-
className: "uploader-footer-button"
|
|
768
|
-
}, /*#__PURE__*/React__default.createElement(Button, {
|
|
769
|
-
onClick: doUpload,
|
|
770
|
-
disabled: isDisabled || isBusy,
|
|
771
|
-
cornerRadius: cornerRadius
|
|
772
|
-
}, startUploadLabel))));
|
|
773
|
-
}
|
|
774
|
-
Uploader.propTypes = {
|
|
775
|
-
/**
|
|
776
|
-
* Disable type check
|
|
777
|
-
*/
|
|
778
|
-
allTypesAccepted: PropTypes.bool,
|
|
779
|
-
/**
|
|
780
|
-
* Browse label text
|
|
781
|
-
*/
|
|
782
|
-
browseLabel: PropTypes.string,
|
|
783
|
-
/**
|
|
784
|
-
* Choose file label text
|
|
785
|
-
*/
|
|
786
|
-
chooseFileLabel: PropTypes.string,
|
|
787
|
-
/**
|
|
788
|
-
* Your custom className, for div
|
|
789
|
-
*/
|
|
790
|
-
className: PropTypes.string,
|
|
791
|
-
/**
|
|
792
|
-
* Button corner radius
|
|
793
|
-
*/
|
|
794
|
-
cornerRadius: 'smooth',
|
|
795
|
-
/**
|
|
796
|
-
* ExtendedInput corner radius
|
|
797
|
-
*/
|
|
798
|
-
inputCornerRadius: ExtendedInput.propTypes.cornerRadius,
|
|
799
|
-
/**
|
|
800
|
-
* Default data for loaded items. The data array should have:
|
|
801
|
-
* path - URL to file/image,
|
|
802
|
-
* name - file/image display name,
|
|
803
|
-
* id - unique identifier,
|
|
804
|
-
*/
|
|
805
|
-
data: PropTypes.arrayOf(PropTypes.shape({
|
|
806
|
-
path: PropTypes.string,
|
|
807
|
-
name: PropTypes.string,
|
|
808
|
-
id: PropTypes.number
|
|
809
|
-
})),
|
|
810
|
-
/**
|
|
811
|
-
* Delete action to process delete default data deleteAction((file: deletedFile) => void)
|
|
812
|
-
*/
|
|
813
|
-
deleteAction: PropTypes.func,
|
|
814
|
-
/**
|
|
815
|
-
* Drop here label text
|
|
816
|
-
*/
|
|
817
|
-
dropHereLabel: PropTypes.string,
|
|
818
|
-
/**
|
|
819
|
-
* Size error message. If in the string you write MAX_FILE_SIZE it will be replaced maxFileSize prop.
|
|
820
|
-
*/
|
|
821
|
-
sizeErrorMsg: PropTypes.string,
|
|
822
|
-
/**
|
|
823
|
-
* Type error message. If in the string you write TYPE_LIST it will be replaced typesList prop.
|
|
824
|
-
*/
|
|
825
|
-
typeErrorMsg: PropTypes.string,
|
|
826
|
-
getInitialState: PropTypes.func,
|
|
827
|
-
/**
|
|
828
|
-
* Upload holder icon
|
|
829
|
-
*/
|
|
830
|
-
icon: PropTypes.string,
|
|
831
|
-
/**
|
|
832
|
-
* Immediate upload after selecting or using the "Start Upload" button.
|
|
833
|
-
*/
|
|
834
|
-
immediatelyUploadAfterSelect: PropTypes.bool,
|
|
835
|
-
/**
|
|
836
|
-
* Information message text
|
|
837
|
-
*/
|
|
838
|
-
informationMessage: PropTypes.string,
|
|
839
|
-
/**
|
|
840
|
-
* Activation drugover
|
|
841
|
-
*/
|
|
842
|
-
isActiveDrop: PropTypes.bool,
|
|
843
|
-
/**
|
|
844
|
-
* Disable uploader
|
|
845
|
-
*/
|
|
846
|
-
isDisabled: PropTypes.bool,
|
|
847
|
-
/**
|
|
848
|
-
* Enable image upload mode
|
|
849
|
-
*/
|
|
850
|
-
isImageUpload: PropTypes.bool,
|
|
851
|
-
/**
|
|
852
|
-
* Loading label text
|
|
853
|
-
*/
|
|
854
|
-
loadingLabel: PropTypes.string,
|
|
855
|
-
/**
|
|
856
|
-
* Max upload file size in bytes
|
|
857
|
-
*/
|
|
858
|
-
maxFileSize: PropTypes.number,
|
|
859
|
-
/**
|
|
860
|
-
* File list changes handling onChange((files: fileList) => void);
|
|
861
|
-
*/
|
|
862
|
-
onChange: PropTypes.func,
|
|
863
|
-
/**
|
|
864
|
-
* Required file
|
|
865
|
-
*/
|
|
866
|
-
required: PropTypes.bool,
|
|
867
|
-
/**
|
|
868
|
-
* Show local validation errors
|
|
869
|
-
*/
|
|
870
|
-
showLocalErrors: PropTypes.bool,
|
|
871
|
-
/**
|
|
872
|
-
* Start upload label text
|
|
873
|
-
*/
|
|
874
|
-
startUploadLabel: PropTypes.string,
|
|
875
|
-
/**
|
|
876
|
-
* Array of upload item types
|
|
877
|
-
*/
|
|
878
|
-
typesList: PropTypes.arrayOf(PropTypes.string),
|
|
879
|
-
/**
|
|
880
|
-
* Upload file function, upload((files: {uploadedFiles, deletedFiles}) => Promise);
|
|
881
|
-
*/
|
|
882
|
-
upload: PropTypes.func,
|
|
883
|
-
/**
|
|
884
|
-
* Uploaded items appearance
|
|
885
|
-
*/
|
|
886
|
-
uploadedItemsAppearance: PropTypes.oneOf(uploaderConfig.uploadedItemsAppearance),
|
|
887
|
-
/**
|
|
888
|
-
* Uploader appearance
|
|
889
|
-
*/
|
|
890
|
-
uploaderAppearance: PropTypes.oneOf(uploaderConfig.uploaderAppearance),
|
|
891
|
-
/**
|
|
892
|
-
* Upload error text showing in tooltip
|
|
893
|
-
*/
|
|
894
|
-
uploadErrorText: PropTypes.string,
|
|
895
|
-
/**
|
|
896
|
-
* Maximum upload file count
|
|
897
|
-
*/
|
|
898
|
-
maxFileCount: PropTypes.number,
|
|
899
|
-
/**
|
|
900
|
-
* Control Uploader validation.
|
|
901
|
-
*/
|
|
902
|
-
isValid: PropTypes.bool,
|
|
903
|
-
/**
|
|
904
|
-
* Show/Hide trash icon
|
|
905
|
-
*/
|
|
906
|
-
showTrash: PropTypes.bool,
|
|
907
|
-
/**
|
|
908
|
-
* Show/Hide Reset icon
|
|
909
|
-
*/
|
|
910
|
-
showResetButton: PropTypes.bool,
|
|
911
|
-
/**
|
|
912
|
-
* Show/Hide Preview icon
|
|
913
|
-
*/
|
|
914
|
-
showPreviewButton: PropTypes.bool,
|
|
915
|
-
/**
|
|
916
|
-
* Show/Hide Download icon
|
|
917
|
-
*/
|
|
918
|
-
showDownloadButton: PropTypes.bool,
|
|
919
|
-
/**
|
|
920
|
-
* initialImages - an array of URL strings. Use to specify the initial value of the component.
|
|
921
|
-
*
|
|
922
|
-
* NOTE: previously, data property could be used to handle the component value. Now, instead
|
|
923
|
-
* of using entire image objects, you can use just URL strings with images and initialImages props
|
|
924
|
-
*/
|
|
925
|
-
initialImages: PropTypes.arrayOf(PropTypes.string),
|
|
926
|
-
/**
|
|
927
|
-
* images - an array of URL strings; required for a controlled component
|
|
928
|
-
*/
|
|
929
|
-
images: PropTypes.arrayOf(PropTypes.string),
|
|
930
|
-
/**
|
|
931
|
-
* change files size with any custom string.
|
|
932
|
-
*/
|
|
933
|
-
additionalContext: PropTypes.string,
|
|
934
|
-
/**
|
|
935
|
-
* multi file upload option.
|
|
936
|
-
*/
|
|
937
|
-
multiple: PropTypes.bool,
|
|
938
|
-
/**
|
|
939
|
-
* This is for fetch image for example through this prop you can pass token.
|
|
940
|
-
* Provide an Object that will spread in Request Headers:{...customHeaders} in second parameter for fetch function.
|
|
941
|
-
* For example { 'Content-Type': 'application/json'} it will convert fetch(URL,{headers{'Content-Type': 'application/json'}})
|
|
942
|
-
*/
|
|
943
|
-
customHeaders: PropTypes.object,
|
|
944
|
-
/**
|
|
945
|
-
* set true to hide image name from preview mode.
|
|
946
|
-
*/
|
|
947
|
-
hideName: PropTypes.bool,
|
|
948
|
-
/**
|
|
949
|
-
* metaDataHeaders is an object where type can be "LAST-MODIFIED" (for future requirement can be added new types) and
|
|
950
|
-
* formatter that returns callback function with 'last modified data string' parameter that can be formatted and returned.
|
|
951
|
-
* {
|
|
952
|
-
* type: "LAST-MODIFIED",
|
|
953
|
-
* formatter:(date)=>{return new Date(date).toLocaleDateString()}
|
|
954
|
-
* }
|
|
955
|
-
*/
|
|
956
|
-
metaDataHeaders: PropTypes.shape({
|
|
957
|
-
type: PropTypes.string,
|
|
958
|
-
formatter: PropTypes.func
|
|
959
|
-
})
|
|
960
|
-
};
|
|
961
|
-
Uploader.defaultProps = {
|
|
962
|
-
allTypesAccepted: true,
|
|
963
|
-
browseLabel: 'Browse',
|
|
964
|
-
chooseFileLabel: 'Upload File',
|
|
965
|
-
cornerRadius: 'smooth',
|
|
966
|
-
inputCornerRadius: ExtendedInput.defaultProps.cornerRadius,
|
|
967
|
-
dropHereLabel: 'Drop here',
|
|
968
|
-
sizeErrorMsg: "File must be smaller than ".concat(maxFileSizeReplacer, " bytes."),
|
|
969
|
-
typeErrorMsg: "You can only upload ".concat(typeListReplacer, " File."),
|
|
970
|
-
immediatelyUploadAfterSelect: true,
|
|
971
|
-
isActiveDrop: false,
|
|
972
|
-
isDisabled: false,
|
|
973
|
-
isImageUpload: false,
|
|
974
|
-
loadingLabel: 'Uploading...',
|
|
975
|
-
maxFileSize: 5000000,
|
|
976
|
-
required: false,
|
|
977
|
-
showTrash: true,
|
|
978
|
-
showDownloadButton: true,
|
|
979
|
-
showResetButton: true,
|
|
980
|
-
showPreviewButton: true,
|
|
981
|
-
showLocalErrors: false,
|
|
982
|
-
startUploadLabel: 'Start Upload',
|
|
983
|
-
typesList: [],
|
|
984
|
-
uploadedItemsAppearance: uploaderConfig.uploadedItemsAppearance[0],
|
|
985
|
-
uploaderAppearance: uploaderConfig.uploaderAppearance[0],
|
|
986
|
-
uploadErrorText: 'Upload Error',
|
|
987
|
-
onChange: noop,
|
|
988
|
-
isValid: true,
|
|
989
|
-
hideName: false
|
|
990
|
-
};
|
|
991
|
-
|
|
992
|
-
export { Uploader as default };
|