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