diginet-core-ui 1.3.85 → 1.3.86
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/components/accordion/css.js +10 -10
- package/components/accordion/details.js +2 -2
- package/components/alert/index.js +3 -3
- package/components/alert/notify.js +2 -2
- package/components/avatar/index.js +3 -3
- package/components/badge/index.js +6 -6
- package/components/button/icon.js +9 -9
- package/components/button/index.js +9 -9
- package/components/button/more.js +2 -2
- package/components/card/index.js +6 -6
- package/components/chip/index.js +7 -7
- package/components/form-control/attachment/index.js +335 -479
- package/components/form-control/calendar/function.js +5 -5
- package/components/form-control/checkbox/index.js +6 -6
- package/components/form-control/date-picker/index.js +2 -2
- package/components/form-control/date-range-picker/index.js +2 -2
- package/components/form-control/dropdown/index.js +335 -451
- package/components/form-control/dropdown-box/index.js +2 -2
- package/components/form-control/input-base/index.js +52 -58
- package/components/form-control/radio/index.js +4 -4
- package/components/form-control/toggle/index.js +2 -2
- package/components/grid/index.js +2 -2
- package/components/image/index.js +3 -3
- package/components/modal/body.js +2 -2
- package/components/modal/footer.js +3 -3
- package/components/modal/header.js +3 -3
- package/components/modal/modal.js +2 -2
- package/components/paging/page-info.js +6 -6
- package/components/paging/page-selector2.js +3 -3
- package/components/popover/footer.js +3 -3
- package/components/popover/header.js +3 -3
- package/components/popup/v2/index.js +5 -5
- package/components/rating/index.js +4 -4
- package/components/slider/slider-container.js +5 -5
- package/components/status/index.js +4 -4
- package/components/tab/tab-header.js +2 -2
- package/components/tab/tab-panel.js +2 -2
- package/components/tab/tab.js +7 -7
- package/components/tooltip/index.js +2 -2
- package/components/tree-view/css.js +4 -4
- package/components/tree-view/index.js +4 -4
- package/global/index.js +12 -0
- package/icons/effect.js +57 -59
- package/package.json +1 -1
- package/readme.md +6 -0
- package/styles/general.js +280 -114
- package/styles/utils.js +10 -0
- package/utils/array/array.js +18 -25
- package/utils/sb-template.js +2 -2
- package/utils/string/string.js +1 -9
- package/utils/validate.js +2 -2
|
@@ -5,17 +5,15 @@ import { ButtonIcon, HelperText, Label, LinearProgress, List, ListItem, ListItem
|
|
|
5
5
|
import { getGlobal } from "../../../global";
|
|
6
6
|
import { Another, Compressed, Image, Pdf, Presentation, Sheet, Word } from "../../../icons";
|
|
7
7
|
import PropTypes from 'prop-types';
|
|
8
|
-
import { forwardRef,
|
|
9
|
-
import
|
|
10
|
-
import { alignCenter, border, borderBox, borderRadius4px, borderRadius50, breakWord, cursorPointer, displayBlock, displayInlineBlock, displayNone, ellipsis, flexCol, flexRow, flexWrap, justifyBetween, justifyCenter, justifyStart, parseHeight, parseMaxHeight, parseMaxWidth, parseMaxWidthHeight, parseMinHeight, parseMinWidth, parseWidth, parseWidthHeight, pointerEventsNone, positionAbsolute, positionRelative, textCenter, userSelectNone } from "../../../styles/general";
|
|
8
|
+
import { forwardRef, memo, useEffect, useImperativeHandle, useMemo, useRef, useState } from 'react';
|
|
9
|
+
import { bgColor, border, borderRadius4px, borderRadius50, boxBorder, boxContent, cursorPointer, displayBlock, displayFlex, displayInlineBlock, displayNone, flexCol, flexRow, flexWrap, floatRight, gap, itemsCenter, justifyBetween, justifyCenter, justifyEnd, justifyStart, mg, mgb, mgl, mgr, mgx, parseHeight, parseMaxWidth, parseMaxWidthHeight, parseMinWidth, parseWidth, parseWidthHeight, pd, positionAbsolute, positionRelative, textCenter, textRight, truncate, userSelectNone } from "../../../styles/general";
|
|
11
10
|
import { useTheme } from "../../../theme";
|
|
12
11
|
import { classNames, date as moment, getFileType } from "../../../utils";
|
|
13
12
|
const {
|
|
14
13
|
colors: {
|
|
15
14
|
system: {
|
|
16
15
|
rest: systemRest,
|
|
17
|
-
white: systemWhite
|
|
18
|
-
dark: systemDark
|
|
16
|
+
white: systemWhite
|
|
19
17
|
},
|
|
20
18
|
semantic: {
|
|
21
19
|
success: semanticSuccess
|
|
@@ -31,13 +29,7 @@ const {
|
|
|
31
29
|
text: {
|
|
32
30
|
sub: textSub
|
|
33
31
|
}
|
|
34
|
-
}
|
|
35
|
-
typography: {
|
|
36
|
-
paragraph1,
|
|
37
|
-
paragraph2,
|
|
38
|
-
paragraph3
|
|
39
|
-
},
|
|
40
|
-
spacing
|
|
32
|
+
}
|
|
41
33
|
} = useTheme();
|
|
42
34
|
const icons = {
|
|
43
35
|
pdf: jsx(Pdf, {
|
|
@@ -92,15 +84,7 @@ const getType = data => {
|
|
|
92
84
|
};
|
|
93
85
|
const getDateTime = date => {
|
|
94
86
|
if (String(date) === 'Invalid Date') return 'unknown';
|
|
95
|
-
|
|
96
|
-
// const m = ('0' + (date.getMonth() + 1)).slice(-2);
|
|
97
|
-
// const y = date.getFullYear();
|
|
98
|
-
// const t = date.toTimeString().slice(0, 8);
|
|
99
|
-
return jsx(Fragment, null, moment(date).format('DD/MM/YYYY, HH:mm:ss'), ' ', jsx("span", {
|
|
100
|
-
style: {
|
|
101
|
-
display: 'none'
|
|
102
|
-
}
|
|
103
|
-
}, date.getMilliseconds()));
|
|
87
|
+
return moment(date).format('DD/MM/YYYY, HH:mm:ss');
|
|
104
88
|
};
|
|
105
89
|
const getNewUnitSize = (sizeName, totalSize, num) => {
|
|
106
90
|
if (sizeName === 'B' && num === 1 || sizeName === 'TB' && num === -1) return [sizeName, totalSize];
|
|
@@ -126,6 +110,17 @@ const getBit = (size, unit) => {
|
|
|
126
110
|
return size * 1024 * 1024;
|
|
127
111
|
}
|
|
128
112
|
};
|
|
113
|
+
const formatBytes = (bytes, decimals = 2) => {
|
|
114
|
+
if (!+bytes) return '0 Bytes';
|
|
115
|
+
const k = 1024;
|
|
116
|
+
const dm = decimals < 0 ? 0 : decimals;
|
|
117
|
+
const sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];
|
|
118
|
+
const i = Math.floor(Math.log(bytes) / Math.log(k));
|
|
119
|
+
|
|
120
|
+
// return `${parseFloat((bytes / Math.pow(k, i)).toFixed(dm))} ${sizes[i]}`
|
|
121
|
+
return [parseFloat((bytes / Math.pow(k, i)).toFixed(dm)), sizes[i]];
|
|
122
|
+
};
|
|
123
|
+
const divideSizeMap = new Map([['B', 1], ['KB', 1024], ['MB', 1024 ** 2], ['GB', 1024 ** 3], ['TB', 1024 ** 4]]);
|
|
129
124
|
const Attachment = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
130
125
|
accept,
|
|
131
126
|
allowSort,
|
|
@@ -149,12 +144,14 @@ const Attachment = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
149
144
|
onView: onViewProp,
|
|
150
145
|
ownerName,
|
|
151
146
|
readOnly,
|
|
147
|
+
//deprecated
|
|
152
148
|
required,
|
|
153
149
|
style,
|
|
154
150
|
unitSize,
|
|
155
151
|
uploadErrorInfo,
|
|
156
152
|
viewType
|
|
157
153
|
}, reference) => {
|
|
154
|
+
if (!reference) reference = useRef(null);
|
|
158
155
|
const ref = useRef(null);
|
|
159
156
|
const attachTextRef = useRef(null);
|
|
160
157
|
const attachmentHandleIconRef = useRef(null);
|
|
@@ -168,13 +165,15 @@ const Attachment = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
168
165
|
const removedAttachedRef = useRef([]);
|
|
169
166
|
const prevent = useRef(null);
|
|
170
167
|
const existClickOutOfItem = useRef(null);
|
|
171
|
-
const divideSize = useRef(null);
|
|
172
168
|
const maxSize = useRef(Infinity);
|
|
173
169
|
const timer = useRef(null);
|
|
174
170
|
const [showModal, setShowModal] = useState(false);
|
|
175
171
|
const [showPopup, setShowPopup] = useState(false);
|
|
176
172
|
const [viewTypeState, setViewTypeState] = useState(viewType);
|
|
177
173
|
const [isEmpty, setIsEmpty] = useState(null);
|
|
174
|
+
const [newDataState, setNewDataState] = useState([]);
|
|
175
|
+
const isEnable = !readOnly && !disabled;
|
|
176
|
+
const _AttachmentRootCSS = AttachmentRootCSS(isEmpty, isEnable);
|
|
178
177
|
|
|
179
178
|
// Start handler
|
|
180
179
|
const onSortElement = (e, type) => {
|
|
@@ -241,8 +240,10 @@ const Attachment = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
241
240
|
setIsEmpty(!length);
|
|
242
241
|
};
|
|
243
242
|
const onChangeFiles = async e => {
|
|
244
|
-
|
|
245
|
-
if (
|
|
243
|
+
var _e$target, _e$target$files;
|
|
244
|
+
if (!isEnable) return;
|
|
245
|
+
e.persist();
|
|
246
|
+
if (e !== null && e !== void 0 && (_e$target = e.target) !== null && _e$target !== void 0 && (_e$target$files = _e$target.files) !== null && _e$target$files !== void 0 && _e$target$files.length) {
|
|
246
247
|
let files = e.target.files;
|
|
247
248
|
const lengthAttached = attached.length;
|
|
248
249
|
for (let i = 0; i < files.length; i++) {
|
|
@@ -272,18 +273,17 @@ const Attachment = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
272
273
|
afterChangeFile(lengthAttached + length);
|
|
273
274
|
if (multiple || inputProps && inputProps.multiple) {
|
|
274
275
|
for (let i = 0; i < length; i++) {
|
|
275
|
-
|
|
276
|
-
|
|
276
|
+
files[i].FileName = files[i].name;
|
|
277
|
+
attached.push(files[i]);
|
|
277
278
|
}
|
|
279
|
+
setNewDataState([...newDataState, ...Array.from(files)]);
|
|
278
280
|
for (let i = 0; i < length; i++) {
|
|
279
|
-
// if (files[i].size > maxSize) continue;
|
|
280
281
|
files[i].URL = await onProgressing(files[i]);
|
|
281
|
-
files[i].FileName = files[i].name;
|
|
282
282
|
}
|
|
283
283
|
} else if (length) {
|
|
284
|
-
attachedRef.current.innerHTML = null;
|
|
285
284
|
files[0].FileName = files[0].name;
|
|
286
|
-
|
|
285
|
+
setNewDataState([...newDataState, files[0]]);
|
|
286
|
+
attached.push(files[0]);
|
|
287
287
|
files[0].URL = await onProgressing(files[0]);
|
|
288
288
|
}
|
|
289
289
|
insertAttached(files);
|
|
@@ -308,7 +308,6 @@ const Attachment = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
308
308
|
url = e.target.result;
|
|
309
309
|
};
|
|
310
310
|
reader.onloadstart = () => {
|
|
311
|
-
// console.log(attachedRef.current.querySelector(`.css-${AttachedLinear.name}-attached`).parentNode.parentNode.querySelector('.filesize').offsetWidth);
|
|
312
311
|
attachedRef.current.querySelector(`.css-${AttachedLinearCSS.name}-attached`).childNodes[0].style.width = '0%';
|
|
313
312
|
};
|
|
314
313
|
reader.onprogress = e => {
|
|
@@ -326,102 +325,20 @@ const Attachment = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
326
325
|
};
|
|
327
326
|
});
|
|
328
327
|
};
|
|
329
|
-
const addNewElement = (file, lengthAttached) => {
|
|
330
|
-
const newAttach = getItemDetailHTML(file, lengthAttached + 1);
|
|
331
|
-
attached.push(file);
|
|
332
|
-
const newElement = document.createElement('div');
|
|
333
|
-
newElement.className = 'attachment-row';
|
|
334
|
-
ReactDOM.render(newAttach, attachedRef.current.appendChild(newElement));
|
|
335
|
-
};
|
|
336
|
-
const getItemDetailHTML = (data, i) => {
|
|
337
|
-
const date = new Date();
|
|
338
|
-
data.CreateDate = date.toISOString();
|
|
339
|
-
const fileType = getType(data);
|
|
340
|
-
return jsx("div", {
|
|
341
|
-
css: AttachedItemCSS,
|
|
342
|
-
key: i,
|
|
343
|
-
onClick: e => onChooseItem(e),
|
|
344
|
-
onDoubleClick: e => onView(e.currentTarget.parentNode)
|
|
345
|
-
}, jsx("span", {
|
|
346
|
-
css: AttachedItemInfoCSS
|
|
347
|
-
}, jsx("span", {
|
|
348
|
-
css: AttachedItemInfoIconCSS,
|
|
349
|
-
className: 'new-file'
|
|
350
|
-
}, icons[fileType], jsx("span", {
|
|
351
|
-
className: 'filetype',
|
|
352
|
-
style: {
|
|
353
|
-
display: 'none'
|
|
354
|
-
}
|
|
355
|
-
}, fileType)), jsx("span", {
|
|
356
|
-
css: AttachedItemInfoNameCSS,
|
|
357
|
-
className: 'filename'
|
|
358
|
-
}, data.name)), jsx("span", {
|
|
359
|
-
css: AttachedItemOwnerCSS
|
|
360
|
-
}, jsx("span", {
|
|
361
|
-
className: 'detail-info'
|
|
362
|
-
}, jsx("span", {
|
|
363
|
-
className: 'username'
|
|
364
|
-
}, ownerName), jsx("span", {
|
|
365
|
-
className: 'datetime'
|
|
366
|
-
}, getDateTime(date)), jsx("span", {
|
|
367
|
-
className: 'filesize'
|
|
368
|
-
}, calculateSize(data.size))), jsx("span", {
|
|
369
|
-
css: AttachedLinearCSS
|
|
370
|
-
}, jsx(LinearProgress, {
|
|
371
|
-
className: `css-${AttachedLinearCSS.name}-attached`,
|
|
372
|
-
determinate: true,
|
|
373
|
-
percent: 0
|
|
374
|
-
}))));
|
|
375
|
-
};
|
|
376
|
-
const getItemHTMLFromData = (data, i) => {
|
|
377
|
-
const date = new Date(data.CreateDate);
|
|
378
|
-
const type = getType(data);
|
|
379
|
-
return jsx("div", {
|
|
380
|
-
css: AttachedItemCSS,
|
|
381
|
-
key: i,
|
|
382
|
-
onClick: e => onChooseItem(e),
|
|
383
|
-
onDoubleClick: e => onView(e.currentTarget.parentNode, data.AttachmentID)
|
|
384
|
-
}, jsx("span", {
|
|
385
|
-
css: AttachedItemInfoCSS
|
|
386
|
-
}, jsx("span", {
|
|
387
|
-
css: AttachedItemInfoIconCSS,
|
|
388
|
-
className: data.lastModifiedDate ? 'new-file' : ''
|
|
389
|
-
}, icons[type], jsx("span", {
|
|
390
|
-
className: 'filetype',
|
|
391
|
-
style: {
|
|
392
|
-
display: 'none'
|
|
393
|
-
}
|
|
394
|
-
}, type)), jsx("span", {
|
|
395
|
-
css: AttachedItemInfoNameCSS,
|
|
396
|
-
className: 'filename'
|
|
397
|
-
}, data.FileName)), jsx("span", {
|
|
398
|
-
css: AttachedItemOwnerCSS
|
|
399
|
-
}, jsx("span", {
|
|
400
|
-
className: 'detail-info'
|
|
401
|
-
}, jsx("span", {
|
|
402
|
-
className: 'username'
|
|
403
|
-
}, data.UserName || (data.lastModifiedDate ? ownerName : '')), jsx("span", {
|
|
404
|
-
className: 'datetime'
|
|
405
|
-
}, getDateTime(date)), jsx("span", {
|
|
406
|
-
className: 'filesize'
|
|
407
|
-
}, calculateSize(data.FileSize || data.size)))));
|
|
408
|
-
};
|
|
409
328
|
const calculateSize = size => {
|
|
410
329
|
if (!size && size !== 0) return 'unknown';
|
|
411
330
|
let totalSize;
|
|
412
331
|
let unitSizeName;
|
|
413
|
-
|
|
414
|
-
|
|
332
|
+
const divideSize = unitSize ? divideSizeMap.get(unitSize.toUpperCase()) : null;
|
|
333
|
+
if (divideSize) {
|
|
334
|
+
totalSize = size / divideSize;
|
|
415
335
|
unitSizeName = unitSize.toUpperCase();
|
|
416
336
|
while (totalSize < 0.01 && unitSizeName !== 'B') {
|
|
417
337
|
[unitSizeName, totalSize] = getNewUnitSize(unitSizeName, totalSize, 1);
|
|
418
338
|
}
|
|
419
339
|
} else {
|
|
420
|
-
|
|
421
|
-
unitSizeName =
|
|
422
|
-
while (totalSize > 1024 && unitSizeName !== 'TB') {
|
|
423
|
-
[unitSizeName, totalSize] = getNewUnitSize(unitSizeName, totalSize, -1);
|
|
424
|
-
}
|
|
340
|
+
// auto-detect unit size name
|
|
341
|
+
[totalSize, unitSizeName] = formatBytes(size);
|
|
425
342
|
}
|
|
426
343
|
if (totalSize < 1000) {
|
|
427
344
|
totalSize = Math.round(totalSize * 100) / 100;
|
|
@@ -526,23 +443,6 @@ const Attachment = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
526
443
|
}).catch(() => alert('File not found'));
|
|
527
444
|
if (onDownloadProp) onDownloadProp(url);
|
|
528
445
|
};
|
|
529
|
-
|
|
530
|
-
// const onRemove = (e, AttachmentID='') => {
|
|
531
|
-
// const parent = e.currentTarget.parentNode.parentNode.parentNode;
|
|
532
|
-
// const index = Array.from(attachedRef.current.children).indexOf(parent);
|
|
533
|
-
// attached.splice(index, 1);
|
|
534
|
-
// if (index < oldAttached.length) {
|
|
535
|
-
// oldAttached.splice(index, 1);
|
|
536
|
-
// } else {
|
|
537
|
-
// removeFileOutInputFiles(index - oldAttached.length);
|
|
538
|
-
// }
|
|
539
|
-
// parent.remove();
|
|
540
|
-
// if (!attached.length) {
|
|
541
|
-
// afterChangeFile();
|
|
542
|
-
// }
|
|
543
|
-
// if (onRemoveItem) onRemoveItem({index, element: parent, oldAttached, allNewAttached: allNewAttached.getAll('files'), AttachmentID});
|
|
544
|
-
// }
|
|
545
|
-
|
|
546
446
|
const removeFileOutInputFiles = (index, keeping) => {
|
|
547
447
|
const dt = new DataTransfer();
|
|
548
448
|
for (let file of attachmentInputRef.current.files) {
|
|
@@ -584,21 +484,6 @@ const Attachment = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
584
484
|
}
|
|
585
485
|
return false;
|
|
586
486
|
};
|
|
587
|
-
|
|
588
|
-
// const checkExistingFileInData = newFile => {
|
|
589
|
-
// const files = data;
|
|
590
|
-
|
|
591
|
-
// if (files && files.length) {
|
|
592
|
-
// const length = files.length;
|
|
593
|
-
|
|
594
|
-
// for (let i = 0; i < length; i++) {
|
|
595
|
-
// if (parseStringify2(newFile) === parseStringify2(files[i], true)) return true;
|
|
596
|
-
// }
|
|
597
|
-
// }
|
|
598
|
-
|
|
599
|
-
// return false;
|
|
600
|
-
// };
|
|
601
|
-
|
|
602
487
|
const checkAcceptFileType = newFile => {
|
|
603
488
|
if (!accept || !accept.length) return true;
|
|
604
489
|
const type = typeof accept === 'string' ? accept : accept.join('-');
|
|
@@ -802,13 +687,6 @@ const Attachment = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
802
687
|
type: fileInfo.type,
|
|
803
688
|
webkitRelativePath: fileInfo.webkitRelativePath
|
|
804
689
|
});
|
|
805
|
-
|
|
806
|
-
// const parseStringify2 = (fileInfo, inData) =>
|
|
807
|
-
// JSON.stringify({
|
|
808
|
-
// name: fileInfo?.[inData ? 'FileName' : 'name'],
|
|
809
|
-
// size: fileInfo?.[inData ? 'FileSize' : 'size'],
|
|
810
|
-
// });
|
|
811
|
-
|
|
812
690
|
const mountDomain = item => {
|
|
813
691
|
if (!item) return item;
|
|
814
692
|
const cloneItem = JSON.parse(JSON.stringify(item));
|
|
@@ -846,38 +724,6 @@ const Attachment = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
846
724
|
useEffect(() => {
|
|
847
725
|
setViewTypeState(viewType);
|
|
848
726
|
}, [viewType]);
|
|
849
|
-
useEffect(() => {
|
|
850
|
-
attachmentInputRef.current.addEventListener('change', onChangeFiles);
|
|
851
|
-
return () => {
|
|
852
|
-
attachmentInputRef.current && attachmentInputRef.current.removeEventListener('change', onChangeFiles);
|
|
853
|
-
};
|
|
854
|
-
}, [readOnly, disabled, uploadErrorInfo, inputProps, isStripDomain, domain]);
|
|
855
|
-
useEffect(() => {
|
|
856
|
-
switch (true) {
|
|
857
|
-
case /^B$/i.test(unitSize):
|
|
858
|
-
divideSize.current = 1;
|
|
859
|
-
break;
|
|
860
|
-
case /KB/i.test(unitSize):
|
|
861
|
-
divideSize.current = 1024;
|
|
862
|
-
break;
|
|
863
|
-
case /MB/i.test(unitSize):
|
|
864
|
-
divideSize.current = 1024 ** 2;
|
|
865
|
-
break;
|
|
866
|
-
case /GB/i.test(unitSize):
|
|
867
|
-
divideSize.current = 1024 ** 3;
|
|
868
|
-
break;
|
|
869
|
-
case /TB/i.test(unitSize):
|
|
870
|
-
divideSize.current = 1024 ** 4;
|
|
871
|
-
break;
|
|
872
|
-
default:
|
|
873
|
-
divideSize.current = null;
|
|
874
|
-
break;
|
|
875
|
-
}
|
|
876
|
-
attachmentInputRef.current.addEventListener('change', onChangeFiles);
|
|
877
|
-
return () => {
|
|
878
|
-
attachmentInputRef.current && attachmentInputRef.current.removeEventListener('change', onChangeFiles);
|
|
879
|
-
};
|
|
880
|
-
}, [unitSize, onChange]);
|
|
881
727
|
useEffect(() => {
|
|
882
728
|
if (maxSizeProp) {
|
|
883
729
|
if (!isNaN(maxSizeProp)) {
|
|
@@ -892,12 +738,7 @@ const Attachment = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
892
738
|
if (accept && typeof accept === 'string') {
|
|
893
739
|
attachmentInputRef.current.accept = `${accept}/*`.replace('/*/*', '/*');
|
|
894
740
|
}
|
|
895
|
-
attachmentInputRef.current.addEventListener('change', onChangeFiles);
|
|
896
741
|
return () => {
|
|
897
|
-
if (attachmentInputRef.current) {
|
|
898
|
-
attachmentInputRef.current.removeEventListener('change', onChangeFiles);
|
|
899
|
-
attachmentInputRef.current.accept = null;
|
|
900
|
-
}
|
|
901
742
|
maxSize.current = Infinity;
|
|
902
743
|
};
|
|
903
744
|
}, [maxFile, maxSizeProp, multiple, accept]);
|
|
@@ -909,7 +750,6 @@ const Attachment = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
909
750
|
// Load files data was uploaded
|
|
910
751
|
const length = data.length;
|
|
911
752
|
for (let i = 0; i < length; i++) {
|
|
912
|
-
const newAttach = getItemHTMLFromData(data[i], i);
|
|
913
753
|
if (Object.prototype.toString.call(data[i]) === '[object File]') {
|
|
914
754
|
allNewAttached.append('files', data[i]);
|
|
915
755
|
newAttachedRef.current.push(data[i]);
|
|
@@ -919,32 +759,13 @@ const Attachment = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
919
759
|
oldAttached.push(item);
|
|
920
760
|
attached.push(item);
|
|
921
761
|
}
|
|
922
|
-
const newElement = document.createElement('div');
|
|
923
|
-
newElement.className = 'attachment-row';
|
|
924
|
-
ReactDOM.render(newAttach, attachedRef.current.appendChild(newElement));
|
|
925
762
|
}
|
|
926
763
|
}
|
|
927
|
-
// if (newAttachedRef.current) {
|
|
928
|
-
// const length = newAttachedRef.current.length;
|
|
929
|
-
|
|
930
|
-
// for (let i = length - 1; i >= 0; i--) {
|
|
931
|
-
// const item = newAttachedRef.current[i];
|
|
932
|
-
// if (checkExistingFileInData(item)) {
|
|
933
|
-
// newAttachedRef.current.splice(i, 1);
|
|
934
|
-
// } else {
|
|
935
|
-
// const newAttach = getItemHTMLFromData(item, i);
|
|
936
|
-
// allNewAttached.append('files', item);
|
|
937
|
-
// attached.push(item);
|
|
938
|
-
// const newElement = document.createElement('div');
|
|
939
|
-
// newElement.className = 'attachment-row';
|
|
940
|
-
// ReactDOM.render(newAttach, attachedRef.current.appendChild(newElement));
|
|
941
|
-
// }
|
|
942
|
-
// }
|
|
943
|
-
// }
|
|
944
764
|
return () => {
|
|
945
|
-
if (attachedRef.current) {
|
|
946
|
-
|
|
947
|
-
}
|
|
765
|
+
// if (attachedRef.current) {
|
|
766
|
+
// attachedRef.current.innerHTML = null;
|
|
767
|
+
// }
|
|
768
|
+
setNewDataState([]);
|
|
948
769
|
oldAttached.length = 0;
|
|
949
770
|
attached.length = 0;
|
|
950
771
|
chosenItems.length = 0;
|
|
@@ -987,134 +808,6 @@ const Attachment = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
987
808
|
};
|
|
988
809
|
// End handler
|
|
989
810
|
|
|
990
|
-
// Start view
|
|
991
|
-
const AttachHeaderView = useMemo(() => jsx("div", {
|
|
992
|
-
css: AttachmentHeaderCSS,
|
|
993
|
-
className: 'DGN-UI-Attachment-Header'
|
|
994
|
-
}, jsx("div", {
|
|
995
|
-
css: AttachmentInfoCSS
|
|
996
|
-
}, jsx(Label, {
|
|
997
|
-
uppercase: true,
|
|
998
|
-
required: required,
|
|
999
|
-
disabled: disabled,
|
|
1000
|
-
type: 'h5',
|
|
1001
|
-
color: textSub,
|
|
1002
|
-
ref: attachTextRef
|
|
1003
|
-
}, label), error ? jsx(HelperText, null, error) : null), jsx("div", {
|
|
1004
|
-
css: AttachmentHeaderIconCSS
|
|
1005
|
-
}, jsx("div", {
|
|
1006
|
-
css: AttachmentHandleIconCSS,
|
|
1007
|
-
ref: attachmentHandleIconRef
|
|
1008
|
-
}, jsx(ButtonIcon, {
|
|
1009
|
-
viewType: 'ghost',
|
|
1010
|
-
className: 'view',
|
|
1011
|
-
name: 'view',
|
|
1012
|
-
onClick: () => onGetViewItem()
|
|
1013
|
-
}), jsx(ButtonIcon, {
|
|
1014
|
-
viewType: 'ghost',
|
|
1015
|
-
className: 'download',
|
|
1016
|
-
name: 'download',
|
|
1017
|
-
onClick: onDownloadMultiple
|
|
1018
|
-
}), !readOnly ? jsx(ButtonIcon, {
|
|
1019
|
-
viewType: 'ghost',
|
|
1020
|
-
className: 'delete',
|
|
1021
|
-
name: 'delete',
|
|
1022
|
-
onClick: onShowPopup
|
|
1023
|
-
}) : null), jsx("div", {
|
|
1024
|
-
css: isEmpty ? AttachmentImageEmptyCSS : AttachmentImageCSS
|
|
1025
|
-
}, !(readOnly || disabled) ? jsx("div", {
|
|
1026
|
-
css: AttachmentImageCenterCSS
|
|
1027
|
-
}, jsx(ButtonIcon, {
|
|
1028
|
-
css: isEmpty && ButtonAttachmentCSS,
|
|
1029
|
-
circular: isEmpty,
|
|
1030
|
-
viewType: isEmpty ? 'text' : 'ghost',
|
|
1031
|
-
name: 'Attachment',
|
|
1032
|
-
size: isEmpty ? 'extraGiant' : 'medium',
|
|
1033
|
-
onClick: triggerClickInput
|
|
1034
|
-
}), isEmpty ? jsx(Typography, {
|
|
1035
|
-
css: userSelectNone,
|
|
1036
|
-
type: 'p3',
|
|
1037
|
-
color: systemRest
|
|
1038
|
-
}, hintText) : null) : null), allowSort && !isEmpty ? jsx(Popover, {
|
|
1039
|
-
ref: popoverRef,
|
|
1040
|
-
anchor: jsx(ButtonIcon, {
|
|
1041
|
-
viewType: 'ghost',
|
|
1042
|
-
name: 'Sort',
|
|
1043
|
-
style: {
|
|
1044
|
-
marginRight: 8
|
|
1045
|
-
}
|
|
1046
|
-
}),
|
|
1047
|
-
width: 'max-content',
|
|
1048
|
-
removeAfterClose: false,
|
|
1049
|
-
anchorOrigin: {
|
|
1050
|
-
vertical: 'bottom',
|
|
1051
|
-
horizontal: 'right'
|
|
1052
|
-
},
|
|
1053
|
-
transformOrigin: {
|
|
1054
|
-
vertical: 'top',
|
|
1055
|
-
horizontal: 'right'
|
|
1056
|
-
}
|
|
1057
|
-
}, jsx(List, null, jsx(ListItem, {
|
|
1058
|
-
onClick: e => onSortElement(e, 'filename')
|
|
1059
|
-
}, jsx(ListItemText, null, "By name")), jsx(ListItem, {
|
|
1060
|
-
onClick: e => onSortElement(e, 'filetype')
|
|
1061
|
-
}, jsx(ListItemText, null, "By type")), jsx(ListItem, {
|
|
1062
|
-
onClick: e => onSortElement(e, 'filesize')
|
|
1063
|
-
}, jsx(ListItemText, null, "By size")), jsx(ListItem, {
|
|
1064
|
-
onClick: e => onSortElement(e, 'datetime')
|
|
1065
|
-
}, jsx(ListItemText, null, "By date")), jsx(ListItem, {
|
|
1066
|
-
onClick: e => onSortElement(e, 'username')
|
|
1067
|
-
}, jsx(ListItemText, null, "By owner")))) : null, !isEmpty ? jsx(ButtonIcon, {
|
|
1068
|
-
viewType: 'ghost',
|
|
1069
|
-
name: viewTypeState === 'detail' ? 'IconView' : 'ListView',
|
|
1070
|
-
onClick: () => setViewTypeState(viewTypeState === 'icon' ? 'detail' : 'icon')
|
|
1071
|
-
}) : null)), [error, allowSort, disabled, readOnly, label, required, hintText, domain, viewTypeState, isEmpty]);
|
|
1072
|
-
const AttachmentInputView = useMemo(() => jsx("div", {
|
|
1073
|
-
css: AttachmentInputCSS,
|
|
1074
|
-
className: 'DGN-UI-Attachment-Input'
|
|
1075
|
-
}, jsx("input", {
|
|
1076
|
-
type: "file",
|
|
1077
|
-
ref: attachmentInputRef,
|
|
1078
|
-
title: "",
|
|
1079
|
-
onDrop: onDropInput,
|
|
1080
|
-
onDragLeave: onDropInput,
|
|
1081
|
-
onClick: e => e.target.value = null // Fix not fire onChange when select same file
|
|
1082
|
-
,
|
|
1083
|
-
...inputProps
|
|
1084
|
-
})), [inputProps]);
|
|
1085
|
-
const AttachedView = useMemo(() => jsx(ScrollBar, {
|
|
1086
|
-
css: AttachmentListCSS,
|
|
1087
|
-
className: 'DGN-UI-Attachment-List'
|
|
1088
|
-
}, jsx("div", {
|
|
1089
|
-
css: AttachedCSS,
|
|
1090
|
-
ref: attachedRef,
|
|
1091
|
-
className: viewTypeState === 'icon' ? 'icon-view' : ''
|
|
1092
|
-
})), [viewTypeState]);
|
|
1093
|
-
const PopupView = useMemo(() => jsx(Popup, {
|
|
1094
|
-
open: showPopup,
|
|
1095
|
-
ref: popupRef,
|
|
1096
|
-
type: 'yesno',
|
|
1097
|
-
description: deleteNotifyText,
|
|
1098
|
-
pressESCToClose: true,
|
|
1099
|
-
onClose: onClosePopup,
|
|
1100
|
-
onConfirm: onRemoveMultiple,
|
|
1101
|
-
onCancel: onClosePopup
|
|
1102
|
-
}), [deleteNotifyText, onChange, onRemoveProp, showPopup]);
|
|
1103
|
-
const ModalView = useMemo(() => {
|
|
1104
|
-
if (!chosenItems.length) return setShowModal(false);
|
|
1105
|
-
const index = chosenItems[0];
|
|
1106
|
-
const data = mountDomain(attached[index]);
|
|
1107
|
-
// let data = oldAttached[index] || allNewAttached.getAll('files')[index-oldAttached.length];
|
|
1108
|
-
return jsx(ModalSample, {
|
|
1109
|
-
open: showModal,
|
|
1110
|
-
title: data.FileName,
|
|
1111
|
-
onClose: () => setShowModal(false)
|
|
1112
|
-
}, jsx(Slider, null, jsx(SliderItem, {
|
|
1113
|
-
url: data.URL
|
|
1114
|
-
})));
|
|
1115
|
-
}, [domain, showModal]);
|
|
1116
|
-
// End view
|
|
1117
|
-
|
|
1118
811
|
useImperativeHandle(reference, () => {
|
|
1119
812
|
stripDomain();
|
|
1120
813
|
const currentRef = ref.current || {};
|
|
@@ -1135,11 +828,210 @@ const Attachment = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
1135
828
|
currentRef.openFileDialog = triggerClickInput;
|
|
1136
829
|
return currentRef;
|
|
1137
830
|
});
|
|
831
|
+
|
|
832
|
+
// Start view
|
|
833
|
+
const AttachHeaderView = useMemo(() => {
|
|
834
|
+
return jsx("div", {
|
|
835
|
+
css: AttachmentHeaderCSS,
|
|
836
|
+
className: 'DGN-UI-Attachment-Header'
|
|
837
|
+
}, jsx("div", {
|
|
838
|
+
css: AttachmentInfoCSS
|
|
839
|
+
}, jsx(Label, {
|
|
840
|
+
uppercase: true,
|
|
841
|
+
required: required,
|
|
842
|
+
type: 'h5',
|
|
843
|
+
color: textSub,
|
|
844
|
+
ref: attachTextRef
|
|
845
|
+
}, label), error ? jsx(HelperText, null, error) : null), jsx("div", {
|
|
846
|
+
css: AttachmentHeaderIconCSS
|
|
847
|
+
}, jsx("div", {
|
|
848
|
+
css: AttachmentHandleIconCSS,
|
|
849
|
+
ref: attachmentHandleIconRef
|
|
850
|
+
}, jsx(ButtonIcon, {
|
|
851
|
+
viewType: 'ghost',
|
|
852
|
+
className: 'view',
|
|
853
|
+
name: 'view',
|
|
854
|
+
onClick: () => onGetViewItem()
|
|
855
|
+
}), jsx(ButtonIcon, {
|
|
856
|
+
viewType: 'ghost',
|
|
857
|
+
className: 'download',
|
|
858
|
+
name: 'download',
|
|
859
|
+
onClick: onDownloadMultiple
|
|
860
|
+
}), isEnable ? jsx(ButtonIcon, {
|
|
861
|
+
viewType: 'ghost',
|
|
862
|
+
className: 'delete',
|
|
863
|
+
name: 'delete',
|
|
864
|
+
onClick: onShowPopup
|
|
865
|
+
}) : null), jsx("div", {
|
|
866
|
+
css: isEmpty ? AttachmentImageEmptyCSS : AttachmentImageCSS
|
|
867
|
+
}, jsx("div", {
|
|
868
|
+
css: [AttachmentImageCenterCSS, !isEnable && [parseHeight('calc(100% - 32px)'), justifyEnd]]
|
|
869
|
+
}, isEnable ? jsx("div", {
|
|
870
|
+
css: AttachmentImageCenterCSS
|
|
871
|
+
}, jsx(ButtonIcon, {
|
|
872
|
+
css: isEmpty && ButtonAttachmentCSS,
|
|
873
|
+
circular: isEmpty,
|
|
874
|
+
viewType: isEmpty ? 'text' : 'ghost',
|
|
875
|
+
name: 'Attachment',
|
|
876
|
+
size: isEmpty ? 'extraGiant' : 'medium',
|
|
877
|
+
onClick: triggerClickInput
|
|
878
|
+
}), isEmpty ? jsx(Typography, {
|
|
879
|
+
css: userSelectNone,
|
|
880
|
+
type: 'p3',
|
|
881
|
+
color: systemRest
|
|
882
|
+
}, hintText) : null) : isEmpty ? jsx(Typography, {
|
|
883
|
+
css: userSelectNone,
|
|
884
|
+
type: 'p3',
|
|
885
|
+
color: systemRest
|
|
886
|
+
}, getGlobal('noFileText')) : null)), allowSort && !isEmpty ? jsx(Popover, {
|
|
887
|
+
ref: popoverRef,
|
|
888
|
+
anchor: jsx(ButtonIcon, {
|
|
889
|
+
viewType: 'ghost',
|
|
890
|
+
name: 'Sort',
|
|
891
|
+
style: {
|
|
892
|
+
marginRight: 8
|
|
893
|
+
}
|
|
894
|
+
}),
|
|
895
|
+
anchorOrigin: {
|
|
896
|
+
vertical: 'bottom',
|
|
897
|
+
horizontal: 'right'
|
|
898
|
+
},
|
|
899
|
+
transformOrigin: {
|
|
900
|
+
vertical: 'top',
|
|
901
|
+
horizontal: 'right'
|
|
902
|
+
}
|
|
903
|
+
}, jsx(List, null, jsx(ListItem, {
|
|
904
|
+
onClick: e => onSortElement(e, 'filename')
|
|
905
|
+
}, jsx(ListItemText, null, getGlobal('byName'))), jsx(ListItem, {
|
|
906
|
+
onClick: e => onSortElement(e, 'filetype')
|
|
907
|
+
}, jsx(ListItemText, null, getGlobal('byType'))), jsx(ListItem, {
|
|
908
|
+
onClick: e => onSortElement(e, 'filesize')
|
|
909
|
+
}, jsx(ListItemText, null, getGlobal('bySize'))), jsx(ListItem, {
|
|
910
|
+
onClick: e => onSortElement(e, 'datetime')
|
|
911
|
+
}, jsx(ListItemText, null, getGlobal('byDate'))), jsx(ListItem, {
|
|
912
|
+
onClick: e => onSortElement(e, 'username')
|
|
913
|
+
}, jsx(ListItemText, null, getGlobal('byOwner'))))) : null, !isEmpty ? jsx(ButtonIcon, {
|
|
914
|
+
viewType: 'ghost',
|
|
915
|
+
name: viewTypeState === 'detail' ? 'IconView' : 'ListView',
|
|
916
|
+
onClick: () => setViewTypeState(viewTypeState === 'icon' ? 'detail' : 'icon')
|
|
917
|
+
}) : null));
|
|
918
|
+
}, [allowSort, disabled, domain, error, hintText, label, readOnly, required, isEmpty, viewTypeState]);
|
|
919
|
+
const AttachmentInputView = useMemo(() => {
|
|
920
|
+
return jsx("div", {
|
|
921
|
+
css: AttachmentInputCSS,
|
|
922
|
+
className: 'DGN-UI-Attachment-Input'
|
|
923
|
+
}, jsx("input", {
|
|
924
|
+
type: "file",
|
|
925
|
+
ref: attachmentInputRef,
|
|
926
|
+
title: "",
|
|
927
|
+
onDrop: onDropInput,
|
|
928
|
+
onDragLeave: onDropInput,
|
|
929
|
+
onClick: e => e.target.value = null // Fix not fire onChange when select same file
|
|
930
|
+
,
|
|
931
|
+
onChange: onChangeFiles,
|
|
932
|
+
...inputProps
|
|
933
|
+
}));
|
|
934
|
+
}, [accept, disabled, domain, inputProps, isStripDomain, maxFile, multiple, onChange, readOnly, uploadErrorInfo, newDataState]);
|
|
935
|
+
const renderAttachmentItem = (item, idx, isNew = false) => {
|
|
936
|
+
const isViewTypeIcon = viewTypeState === 'icon';
|
|
937
|
+
const date = isNew ? new Date() : new Date(item.CreateDate);
|
|
938
|
+
if (isNew) item.CreateDate = date.toISOString();
|
|
939
|
+
const type = getType(item);
|
|
940
|
+
const name = isNew ? item.name : item.FileName;
|
|
941
|
+
return jsx("div", {
|
|
942
|
+
key: idx,
|
|
943
|
+
className: 'attachment-row'
|
|
944
|
+
}, jsx("div", {
|
|
945
|
+
css: AttachedItemCSS,
|
|
946
|
+
onClick: e => onChooseItem(e),
|
|
947
|
+
onDoubleClick: e => onView(e.currentTarget.parentNode, isNew ? null : item.AttachmentID)
|
|
948
|
+
}, jsx("span", {
|
|
949
|
+
css: AttachedItemInfoCSS
|
|
950
|
+
}, jsx("span", {
|
|
951
|
+
css: AttachedItemInfoIconCSS,
|
|
952
|
+
className: classNames((item.lastModifiedDate || isNew) && 'new-file')
|
|
953
|
+
}, icons[type], jsx("span", {
|
|
954
|
+
className: 'filetype',
|
|
955
|
+
style: {
|
|
956
|
+
display: 'none'
|
|
957
|
+
}
|
|
958
|
+
}, type)), jsx(Typography, {
|
|
959
|
+
className: 'filename',
|
|
960
|
+
css: [isViewTypeIcon ? mg([0, 2]) : mgl([3])],
|
|
961
|
+
type: isViewTypeIcon ? 'p3' : 'p1',
|
|
962
|
+
lineClamp: isViewTypeIcon ? 2 : 1
|
|
963
|
+
}, name)), jsx("span", {
|
|
964
|
+
css: AttachedItemOwnerCSS
|
|
965
|
+
}, !isViewTypeIcon ? jsx("span", {
|
|
966
|
+
css: DetailInfoCSS,
|
|
967
|
+
className: 'detail-info'
|
|
968
|
+
}, jsx(Typography, {
|
|
969
|
+
className: 'username',
|
|
970
|
+
type: 'p2',
|
|
971
|
+
color: textSub
|
|
972
|
+
}, (item === null || item === void 0 ? void 0 : item.UserName) || item.lastModifiedDate && ownerName || ''), jsx(Typography, {
|
|
973
|
+
className: 'datetime',
|
|
974
|
+
type: 'p2',
|
|
975
|
+
color: textSub
|
|
976
|
+
}, getDateTime(date)), jsx(Typography, {
|
|
977
|
+
className: 'filesize',
|
|
978
|
+
type: 'p2',
|
|
979
|
+
color: textSub
|
|
980
|
+
}, calculateSize(item.FileSize || item.size))) : null, isNew ? jsx("span", {
|
|
981
|
+
css: AttachedLinearCSS
|
|
982
|
+
}, jsx(LinearProgress, {
|
|
983
|
+
className: `css-${AttachedLinearCSS.name}-attached`,
|
|
984
|
+
determinate: true,
|
|
985
|
+
percent: 0
|
|
986
|
+
})) : null)));
|
|
987
|
+
};
|
|
988
|
+
const AttachedView = useMemo(() => {
|
|
989
|
+
const isViewTypeIcon = viewTypeState === 'icon';
|
|
990
|
+
return jsx(ScrollBar, {
|
|
991
|
+
css: AttachmentListCSS,
|
|
992
|
+
className: 'DGN-UI-Attachment-List'
|
|
993
|
+
}, jsx("div", {
|
|
994
|
+
css: AttachedCSS,
|
|
995
|
+
ref: attachedRef,
|
|
996
|
+
className: classNames(isViewTypeIcon && 'icon-view')
|
|
997
|
+
}, data.map((item, idx) => {
|
|
998
|
+
return renderAttachmentItem(item, idx);
|
|
999
|
+
}), newDataState.map((item, idx) => {
|
|
1000
|
+
return renderAttachmentItem(item, (data === null || data === void 0 ? void 0 : data.length) + idx, true);
|
|
1001
|
+
})));
|
|
1002
|
+
}, [data, onViewProp, unitSize, newDataState, viewTypeState]);
|
|
1003
|
+
const PopupView = useMemo(() => {
|
|
1004
|
+
return jsx(Popup, {
|
|
1005
|
+
open: showPopup,
|
|
1006
|
+
ref: popupRef,
|
|
1007
|
+
type: 'yesno',
|
|
1008
|
+
description: deleteNotifyText,
|
|
1009
|
+
pressESCToClose: true,
|
|
1010
|
+
onClose: onClosePopup,
|
|
1011
|
+
onConfirm: onRemoveMultiple,
|
|
1012
|
+
onCancel: onClosePopup
|
|
1013
|
+
});
|
|
1014
|
+
}, [deleteNotifyText, onChange, onRemoveProp, showPopup]);
|
|
1015
|
+
const ModalView = useMemo(() => {
|
|
1016
|
+
if (!chosenItems.length) return setShowModal(false);
|
|
1017
|
+
const index = chosenItems[0];
|
|
1018
|
+
const data = mountDomain(attached[index]);
|
|
1019
|
+
// let data = oldAttached[index] || allNewAttached.getAll('files')[index-oldAttached.length];
|
|
1020
|
+
return jsx(ModalSample, {
|
|
1021
|
+
open: showModal,
|
|
1022
|
+
title: data.FileName,
|
|
1023
|
+
onClose: () => setShowModal(false)
|
|
1024
|
+
}, jsx(Slider, null, jsx(SliderItem, {
|
|
1025
|
+
url: data.URL
|
|
1026
|
+
})));
|
|
1027
|
+
}, [domain, showModal]);
|
|
1028
|
+
// End view
|
|
1029
|
+
|
|
1138
1030
|
return jsx("div", {
|
|
1139
1031
|
ref: ref,
|
|
1140
|
-
css:
|
|
1032
|
+
css: _AttachmentRootCSS,
|
|
1141
1033
|
id: id,
|
|
1142
|
-
className: classNames('DGN-UI-Attachment',
|
|
1034
|
+
className: classNames('DGN-UI-Attachment', className),
|
|
1143
1035
|
style: style,
|
|
1144
1036
|
onDragEnter: onDragFileStart
|
|
1145
1037
|
}, AttachHeaderView, AttachmentInputView, AttachedView, PopupView, ModalView, jsx(Notify, {
|
|
@@ -1152,32 +1044,32 @@ const Attachment = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
1152
1044
|
const AttachmentHandleIconCSS = css`
|
|
1153
1045
|
${displayNone};
|
|
1154
1046
|
${parseHeight(24)};
|
|
1155
|
-
|
|
1047
|
+
${mgr([2])};
|
|
1156
1048
|
border-right: 1px solid ${lineNormal};
|
|
1157
1049
|
button {
|
|
1158
|
-
|
|
1050
|
+
${mgr([2])};
|
|
1159
1051
|
}
|
|
1160
1052
|
`;
|
|
1161
1053
|
const AttachmentHeaderCSS = css`
|
|
1162
|
-
${
|
|
1163
|
-
${
|
|
1054
|
+
${displayFlex};
|
|
1055
|
+
${itemsCenter};
|
|
1164
1056
|
${justifyBetween};
|
|
1165
|
-
${
|
|
1057
|
+
${boxBorder};
|
|
1166
1058
|
${parseWidth('100%')};
|
|
1167
|
-
|
|
1059
|
+
${pd([4, 4])};
|
|
1168
1060
|
`;
|
|
1169
1061
|
const AttachmentInfoCSS = css`
|
|
1170
|
-
${
|
|
1171
|
-
|
|
1062
|
+
${displayFlex};
|
|
1063
|
+
${gap([2])};
|
|
1172
1064
|
`;
|
|
1173
1065
|
const AttachmentHeaderIconCSS = css`
|
|
1174
|
-
${
|
|
1175
|
-
${
|
|
1066
|
+
${displayFlex};
|
|
1067
|
+
${itemsCenter};
|
|
1176
1068
|
`;
|
|
1177
1069
|
const AttachmentInputCSS = css`
|
|
1178
1070
|
${displayNone};
|
|
1179
1071
|
${positionAbsolute};
|
|
1180
|
-
${parseWidthHeight('100%'
|
|
1072
|
+
${parseWidthHeight('100%')};
|
|
1181
1073
|
top: 0;
|
|
1182
1074
|
left: 0;
|
|
1183
1075
|
input {
|
|
@@ -1187,183 +1079,154 @@ const AttachmentInputCSS = css`
|
|
|
1187
1079
|
}
|
|
1188
1080
|
`;
|
|
1189
1081
|
const AttachmentImageCenterCSS = css`
|
|
1082
|
+
${displayFlex};
|
|
1190
1083
|
${flexCol};
|
|
1191
1084
|
${justifyCenter};
|
|
1192
|
-
${
|
|
1193
|
-
${parseWidthHeight('100%'
|
|
1085
|
+
${itemsCenter};
|
|
1086
|
+
${parseWidthHeight('100%')};
|
|
1194
1087
|
`;
|
|
1195
1088
|
const ButtonAttachmentCSS = css`
|
|
1196
1089
|
border: 1px dashed ${lineNormal} !important;
|
|
1197
|
-
|
|
1090
|
+
${mg([0, 'auto', 4])};
|
|
1198
1091
|
`;
|
|
1199
1092
|
const AttachmentImageCSS = css`
|
|
1200
|
-
|
|
1093
|
+
${mgr([2])};
|
|
1201
1094
|
`;
|
|
1202
1095
|
const AttachmentImageEmptyCSS = css`
|
|
1203
1096
|
${positionAbsolute};
|
|
1204
|
-
${parseWidthHeight('100%'
|
|
1097
|
+
${parseWidthHeight('100%')};
|
|
1205
1098
|
top: 0;
|
|
1206
1099
|
left: 0;
|
|
1207
1100
|
`;
|
|
1208
1101
|
const AttachedItemInfoCSS = css`
|
|
1209
|
-
${
|
|
1210
|
-
${
|
|
1102
|
+
${displayFlex};
|
|
1103
|
+
${itemsCenter};
|
|
1211
1104
|
${borderRadius4px};
|
|
1212
1105
|
${userSelectNone};
|
|
1213
1106
|
${parseMinWidth('calc(50% - 10px)')};
|
|
1214
|
-
|
|
1107
|
+
${mgr([2])};
|
|
1215
1108
|
`;
|
|
1216
1109
|
const AttachedItemInfoIconCSS = css`
|
|
1217
1110
|
${flexRow};
|
|
1218
1111
|
${positionRelative};
|
|
1112
|
+
${boxContent};
|
|
1219
1113
|
${parseMaxWidthHeight(14, 16)};
|
|
1220
|
-
|
|
1221
|
-
box-sizing: content-box;
|
|
1114
|
+
${pd([1, 1.25])};
|
|
1222
1115
|
&.new-file:after {
|
|
1223
1116
|
content: '';
|
|
1224
1117
|
${positionAbsolute};
|
|
1225
1118
|
${borderRadius50};
|
|
1226
1119
|
${parseWidthHeight(4, 4)};
|
|
1120
|
+
${bgColor(semanticSuccess)};
|
|
1227
1121
|
top: 4.5px;
|
|
1228
1122
|
left: -2px;
|
|
1229
|
-
background: ${semanticSuccess};
|
|
1230
1123
|
}
|
|
1231
1124
|
`;
|
|
1232
|
-
const AttachedItemInfoNameCSS = css`
|
|
1233
|
-
${paragraph1};
|
|
1234
|
-
${ellipsis};
|
|
1235
|
-
color: ${systemDark};
|
|
1236
|
-
margin-left: ${spacing([3])};
|
|
1237
|
-
padding-top: ${spacing([0.25])};
|
|
1238
|
-
box-sizing: content-box;
|
|
1239
|
-
`;
|
|
1240
1125
|
const AttachedItemOwnerCSS = css`
|
|
1241
|
-
${
|
|
1242
|
-
${flexRow};
|
|
1126
|
+
${displayFlex};
|
|
1243
1127
|
${positionRelative};
|
|
1244
|
-
${
|
|
1128
|
+
${itemsCenter};
|
|
1245
1129
|
${userSelectNone};
|
|
1246
1130
|
${parseHeight('100%')};
|
|
1247
1131
|
color: ${textSub};
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
}
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
}
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
}
|
|
1132
|
+
`;
|
|
1133
|
+
const DetailInfoCSS = css`
|
|
1134
|
+
${displayFlex};
|
|
1135
|
+
${parseMinWidth(333)};
|
|
1136
|
+
.username {
|
|
1137
|
+
${displayInlineBlock};
|
|
1138
|
+
${truncate};
|
|
1139
|
+
${parseMinWidth(120)};
|
|
1140
|
+
${parseMaxWidth(120)};
|
|
1141
|
+
}
|
|
1142
|
+
.datetime {
|
|
1143
|
+
${displayInlineBlock};
|
|
1144
|
+
${parseMinWidth('max-content')};
|
|
1145
|
+
${parseMaxWidth('max-content')};
|
|
1146
|
+
}
|
|
1147
|
+
.filesize {
|
|
1148
|
+
${floatRight};
|
|
1149
|
+
${textRight};
|
|
1150
|
+
${mgl(['auto'])};
|
|
1267
1151
|
}
|
|
1268
1152
|
`;
|
|
1269
1153
|
const AttachedLinearCSS = css`
|
|
1270
|
-
${
|
|
1154
|
+
${displayFlex};
|
|
1271
1155
|
${positionAbsolute};
|
|
1272
|
-
${
|
|
1273
|
-
${
|
|
1156
|
+
${itemsCenter};
|
|
1157
|
+
${bgColor(systemWhite)};
|
|
1158
|
+
${parseWidthHeight('100%')};
|
|
1274
1159
|
top: 0;
|
|
1275
|
-
background: ${systemWhite};
|
|
1276
1160
|
`;
|
|
1277
1161
|
const AttachedItemCSS = css`
|
|
1278
|
-
${
|
|
1162
|
+
${displayFlex};
|
|
1279
1163
|
${justifyBetween};
|
|
1280
1164
|
${positionRelative};
|
|
1281
1165
|
${borderRadius4px};
|
|
1282
1166
|
${cursorPointer};
|
|
1283
1167
|
${parseHeight(24)};
|
|
1284
|
-
|
|
1168
|
+
${pd([0, 2])};
|
|
1285
1169
|
transition: padding 0.5s ease;
|
|
1286
1170
|
`;
|
|
1287
1171
|
const AttachedCSS = css`
|
|
1288
1172
|
${positionRelative};
|
|
1289
1173
|
${parseHeight('100%')};
|
|
1290
|
-
${
|
|
1291
|
-
margin-left: ${spacing([2])};
|
|
1292
|
-
margin-right: ${spacing([2])};
|
|
1293
|
-
z-index: 1;
|
|
1174
|
+
${mgx([2])};
|
|
1294
1175
|
overflow-y: visible;
|
|
1295
1176
|
.attachment-row {
|
|
1296
1177
|
${displayBlock};
|
|
1297
|
-
|
|
1178
|
+
${mgb([2])};
|
|
1298
1179
|
&:last-child {
|
|
1299
|
-
|
|
1180
|
+
${mgb(0)};
|
|
1300
1181
|
}
|
|
1301
1182
|
}
|
|
1302
1183
|
&.icon-view {
|
|
1303
|
-
${
|
|
1184
|
+
${displayFlex};
|
|
1304
1185
|
${flexWrap};
|
|
1305
1186
|
${justifyBetween};
|
|
1306
1187
|
&::after {
|
|
1307
1188
|
content: '';
|
|
1308
1189
|
flex: auto;
|
|
1309
1190
|
}
|
|
1310
|
-
${
|
|
1191
|
+
${parseMaxWidthHeight('calc(100% - 26px)', 200)};
|
|
1311
1192
|
${parseWidth('max-content')};
|
|
1312
|
-
${
|
|
1313
|
-
margin-left: 0;
|
|
1193
|
+
${mgl(0)};
|
|
1314
1194
|
.attachment-row {
|
|
1315
1195
|
${positionRelative};
|
|
1316
|
-
|
|
1196
|
+
${mgl([4])};
|
|
1317
1197
|
overflow-y: visible;
|
|
1318
1198
|
}
|
|
1319
1199
|
.css-${AttachedItemCSS.name} {
|
|
1320
1200
|
${displayBlock};
|
|
1321
|
-
${parseWidthHeight(80
|
|
1322
|
-
|
|
1323
|
-
position: initial;
|
|
1201
|
+
${parseWidthHeight(80)};
|
|
1202
|
+
${pd(0)};
|
|
1324
1203
|
.css-${AttachedItemInfoCSS.name} {
|
|
1325
1204
|
${displayBlock};
|
|
1326
1205
|
${positionRelative};
|
|
1327
1206
|
${textCenter};
|
|
1328
|
-
${
|
|
1207
|
+
${truncate};
|
|
1329
1208
|
${parseWidth('max-content')};
|
|
1330
1209
|
${parseMaxWidth(80)};
|
|
1331
1210
|
${parseMinWidth(70)};
|
|
1332
|
-
|
|
1333
|
-
margin-right: auto;
|
|
1211
|
+
${mgx(['auto'])};
|
|
1334
1212
|
.css-${AttachedItemInfoIconCSS.name} {
|
|
1335
1213
|
${displayBlock};
|
|
1336
|
-
${parseWidthHeight(40
|
|
1337
|
-
${parseMaxWidthHeight(40
|
|
1338
|
-
|
|
1339
|
-
|
|
1214
|
+
${parseWidthHeight(40)};
|
|
1215
|
+
${parseMaxWidthHeight(40)};
|
|
1216
|
+
${mg([1, 'auto', 0.5])};
|
|
1217
|
+
${pd(0)};
|
|
1340
1218
|
&.new-file:after {
|
|
1341
|
-
${parseWidthHeight(8
|
|
1219
|
+
${parseWidthHeight(8)};
|
|
1342
1220
|
top: -1px;
|
|
1343
1221
|
left: -7px;
|
|
1344
1222
|
}
|
|
1345
1223
|
}
|
|
1346
|
-
.css-${AttachedItemInfoNameCSS.name} {
|
|
1347
|
-
${paragraph3};
|
|
1348
|
-
${textCenter};
|
|
1349
|
-
${breakWord};
|
|
1350
|
-
${parseMaxWidth('100%')};
|
|
1351
|
-
margin: ${spacing([0, 2])};
|
|
1352
|
-
display: -webkit-box;
|
|
1353
|
-
white-space: pre-wrap;
|
|
1354
|
-
-webkit-line-clamp: 2;
|
|
1355
|
-
-webkit-box-orient: vertical;
|
|
1356
|
-
}
|
|
1357
1224
|
}
|
|
1358
1225
|
.css-${AttachedItemOwnerCSS.name} {
|
|
1359
|
-
${
|
|
1226
|
+
${parseHeight('auto')};
|
|
1360
1227
|
position: inherit;
|
|
1361
|
-
height: auto;
|
|
1362
|
-
.detail-info {
|
|
1363
|
-
${displayNone};
|
|
1364
|
-
}
|
|
1365
1228
|
.css-${AttachedLinearCSS.name} {
|
|
1366
|
-
|
|
1229
|
+
${parseHeight('auto')};
|
|
1367
1230
|
bottom: 0;
|
|
1368
1231
|
top: unset;
|
|
1369
1232
|
background: none;
|
|
@@ -1372,54 +1235,47 @@ const AttachedCSS = css`
|
|
|
1372
1235
|
}
|
|
1373
1236
|
}
|
|
1374
1237
|
&:not(.icon-view) {
|
|
1375
|
-
|
|
1238
|
+
${parseMinWidth(684)};
|
|
1376
1239
|
}
|
|
1377
1240
|
`;
|
|
1378
1241
|
const AttachmentListCSS = css`
|
|
1379
|
-
${
|
|
1380
|
-
|
|
1381
|
-
|
|
1242
|
+
${boxBorder};
|
|
1243
|
+
${mgr([1.25])};
|
|
1244
|
+
${pd([0, 1.75, 0])};
|
|
1382
1245
|
overflow-y: overlay;
|
|
1383
1246
|
`;
|
|
1384
|
-
const AttachmentRootCSS = css`
|
|
1247
|
+
const AttachmentRootCSS = (isEmpty, isEnable) => css`
|
|
1248
|
+
${displayFlex};
|
|
1385
1249
|
${flexCol};
|
|
1386
|
-
${flexWrap};
|
|
1387
1250
|
${justifyStart};
|
|
1388
1251
|
${positionRelative};
|
|
1389
1252
|
${borderRadius4px};
|
|
1390
|
-
${
|
|
1253
|
+
${boxBorder};
|
|
1391
1254
|
${border(1, lineNormal)};
|
|
1392
|
-
${
|
|
1393
|
-
|
|
1255
|
+
${parseHeight(isEmpty && !isEnable ? 120 : 280)};
|
|
1256
|
+
${bgColor(systemWhite)};
|
|
1394
1257
|
.css-${AttachedCSS.name} {
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
background-color: ${fillHover};
|
|
1401
|
-
}
|
|
1258
|
+
.css-${AttachedItemCSS.name} {
|
|
1259
|
+
&:hover {
|
|
1260
|
+
${bgColor(fillHover)};
|
|
1261
|
+
.css-${AttachedLinearCSS.name} {
|
|
1262
|
+
${bgColor(fillHover)};
|
|
1402
1263
|
}
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
}
|
|
1264
|
+
}
|
|
1265
|
+
&:active {
|
|
1266
|
+
${bgColor(fillPressed)};
|
|
1267
|
+
.css-${AttachedLinearCSS.name} {
|
|
1268
|
+
${bgColor(fillPressed)};
|
|
1408
1269
|
}
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
}
|
|
1270
|
+
}
|
|
1271
|
+
&.chosen {
|
|
1272
|
+
${bgColor(fillFocus)};
|
|
1273
|
+
.css-${AttachedItemInfoCSS.name}, .css-${AttachedItemOwnerCSS.name} {
|
|
1274
|
+
${bgColor(fillFocus)};
|
|
1414
1275
|
}
|
|
1415
1276
|
}
|
|
1416
1277
|
}
|
|
1417
1278
|
}
|
|
1418
|
-
&.disabled {
|
|
1419
|
-
.css-${AttachedItemCSS.name} {
|
|
1420
|
-
${pointerEventsNone};
|
|
1421
|
-
}
|
|
1422
|
-
}
|
|
1423
1279
|
@media (max-width: 716px) {
|
|
1424
1280
|
.css-${AttachedCSS.name}:not(.icon-view) {
|
|
1425
1281
|
${parseMinWidth(575)};
|
|
@@ -1439,7 +1295,7 @@ Attachment.defaultProps = {
|
|
|
1439
1295
|
label: getGlobal('attachText'),
|
|
1440
1296
|
maxFile: Infinity,
|
|
1441
1297
|
multiple: true,
|
|
1442
|
-
|
|
1298
|
+
style: {},
|
|
1443
1299
|
uploadErrorInfo: {
|
|
1444
1300
|
maxFile: getGlobal(['errorDefault', 'maxFile']),
|
|
1445
1301
|
maxSize: getGlobal(['errorDefault', 'maxSize']),
|
|
@@ -1509,12 +1365,12 @@ Attachment.propTypes = {
|
|
|
1509
1365
|
onView: PropTypes.func,
|
|
1510
1366
|
/** Name of the person who attached the file when uploading the file. */
|
|
1511
1367
|
ownerName: PropTypes.string,
|
|
1512
|
-
/** If `true`, the component is readOnly. */
|
|
1513
|
-
readOnly: PropTypes.bool,
|
|
1514
1368
|
/** At least one attachment is required. */
|
|
1515
1369
|
required: PropTypes.bool,
|
|
1516
1370
|
/** Style inline of component. */
|
|
1517
1371
|
style: PropTypes.object,
|
|
1372
|
+
/** Unit size name, default auto-detect. */
|
|
1373
|
+
unitSize: PropTypes.string,
|
|
1518
1374
|
/** Errors show up when the file upload is corrupted. */
|
|
1519
1375
|
uploadErrorInfo: PropTypes.object,
|
|
1520
1376
|
/** The view type of files. */
|