diginet-core-ui 1.4.10-beta.3 → 1.4.11

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.
@@ -1,12 +1,51 @@
1
1
  /** @jsxRuntime classic */
2
2
  /** @jsx jsx */
3
3
  import { css, jsx } from '@emotion/core';
4
- import { ButtonIcon, Grid, HelperText, Icon, Image, Label, LinearProgress, List, ListItem, ListItemText, ModalSample, Notify, Popover, Popup, ScrollBar, Slider, SliderItem, Typography } from "../..";
4
+ import { ButtonIcon, HelperText, Label, LinearProgress, List, ListItem, ListItemText, ModalSample, Notify, Popover, Popup, ScrollBar, Slider, SliderItem, Typography } from "../..";
5
5
  import { getGlobal } from "../../../global";
6
+ import { Another, Compressed, Image, Pdf, Presentation, Sheet, Word } from "../../../icons";
6
7
  import PropTypes from 'prop-types';
7
- import { forwardRef, memo, useEffect, useImperativeHandle, useLayoutEffect, useMemo, useRef, useState } from 'react';
8
- import { aspectSquare, bgColor, border, borderDashed, borderRadius4px, borderRadius50, borderRight, bottom, boxBorder, cursorPointer, displayFlex, displayInlineBlock, displayNone, flexCol, floatRight, gap, itemsCenter, justifyBetween, justifyCenter, justifyEnd, justifyStart, left, mg, mgl, mgr, overflowHidden, parseHeight, parseMaxWidth, parseMinHeight, parseMinWidth, parseWidth, parseWidthHeight, pd, positionAbsolute, positionRelative, textCenter, textColor, textLeft, textRight, top, truncate, userSelectNone } from "../../../styles/general";
9
- import { classNames, getFileType, date as moment } from "../../../utils";
8
+ import { forwardRef, memo, useEffect, useImperativeHandle, useMemo, useRef, useState } from 'react';
9
+ import { bgColor, border, borderRadius4px, borderRadius50, bottom, boxBorder, boxContent, cursorPointer, displayBlock, displayFlex, displayInlineBlock, displayNone, flexCol, flexRow, flexWrap, floatRight, gap, itemsCenter, justifyBetween, justifyCenter, justifyEnd, justifyStart, left, mg, mgb, mgl, mgr, mgx, parseHeight, parseMaxWidth, parseMaxWidthHeight, parseMinWidth, parseWidth, parseWidthHeight, pd, positionAbsolute, positionRelative, textCenter, textColor, textRight, top, truncate, userSelectNone } from "../../../styles/general";
10
+ import { useTheme } from "../../../theme";
11
+ import { classNames, date as moment, getFileType } from "../../../utils";
12
+ const {
13
+ colors: {
14
+ line: {
15
+ normal: lineNormal
16
+ }
17
+ }
18
+ } = useTheme();
19
+ const icons = {
20
+ pdf: jsx(Pdf, {
21
+ width: '100%',
22
+ height: '100%'
23
+ }),
24
+ word: jsx(Word, {
25
+ width: '100%',
26
+ height: '100%'
27
+ }),
28
+ sheet: jsx(Sheet, {
29
+ width: '100%',
30
+ height: '100%'
31
+ }),
32
+ presentation: jsx(Presentation, {
33
+ width: '100%',
34
+ height: '100%'
35
+ }),
36
+ image: jsx(Image, {
37
+ width: '100%',
38
+ height: '100%'
39
+ }),
40
+ compressed: jsx(Compressed, {
41
+ width: '100%',
42
+ height: '100%'
43
+ }),
44
+ default: jsx(Another, {
45
+ width: '100%',
46
+ height: '100%'
47
+ })
48
+ };
10
49
  const oldAttached = [];
11
50
  const allNewAttached = new FormData();
12
51
  const attached = []; // attached = [...dataState, ...newDataState]
@@ -25,22 +64,13 @@ const getType = data => {
25
64
  } else {
26
65
  var _data$FileName;
27
66
  const FileExt = (_data$FileName = data.FileName) === null || _data$FileName === void 0 ? void 0 : _data$FileName.slice(data.FileName.lastIndexOf('.'));
28
- return getFileType(FileExt) || 'default';
67
+ return getFileType(FileExt, 'default');
29
68
  }
30
69
  };
31
70
  const getDateTime = date => {
32
- if (!(date instanceof Date && !isNaN(date))) return 'unknown';
33
- const formatter = new Intl.DateTimeFormat('en-GB', {
34
- day: '2-digit',
35
- month: '2-digit',
36
- year: 'numeric',
37
- hour: '2-digit',
38
- minute: '2-digit',
39
- second: '2-digit'
40
- });
41
- return formatter.format(date); // DD/MM/YYYY, HH:mm:ss
71
+ if (String(date) === 'Invalid Date') return 'unknown';
72
+ return moment(date).format('DD/MM/YYYY, HH:mm:ss');
42
73
  };
43
-
44
74
  const getNewUnitSize = (sizeName, totalSize, num) => {
45
75
  if (sizeName === 'B' && num === 1 || sizeName === 'TB' && num === -1) return [sizeName, totalSize];
46
76
  const arraySize = ['TB', 'GB', 'MB', 'KB', 'B'];
@@ -50,16 +80,20 @@ const getNewUnitSize = (sizeName, totalSize, num) => {
50
80
  return [arraySize[index + num], newTotalSize];
51
81
  };
52
82
  const getBit = (size, unit) => {
53
- const units = {
54
- B: 1,
55
- KB: 1024,
56
- MB: 1024 ** 2,
57
- GB: 1024 ** 3,
58
- TB: 1024 ** 4
59
- };
60
- const normalizedUnit = unit.toUpperCase();
61
- const multiplier = units[normalizedUnit] || 1024 * 1024;
62
- return size * multiplier;
83
+ switch (true) {
84
+ case /^B$/i.test(unit):
85
+ return size * 1;
86
+ case /KB/i.test(unit):
87
+ return size * 1024;
88
+ case /MB/i.test(unit):
89
+ return size * 1024 ** 2;
90
+ case /GB/i.test(unit):
91
+ return size * 1024 ** 3;
92
+ case /TB/i.test(unit):
93
+ return size * 1024 ** 4;
94
+ default:
95
+ return size * 1024 * 1024;
96
+ }
63
97
  };
64
98
  const formatBytes = (bytes, decimals = 2) => {
65
99
  if (!+bytes) return '0 Bytes';
@@ -72,8 +106,6 @@ const formatBytes = (bytes, decimals = 2) => {
72
106
  return [parseFloat((bytes / Math.pow(k, i)).toFixed(dm)), sizes[i]];
73
107
  };
74
108
  const divideSizeMap = new Map([['B', 1], ['KB', 1024], ['MB', 1024 ** 2], ['GB', 1024 ** 3], ['TB', 1024 ** 4]]);
75
- const viewTypeIconMap = new Map([['detail', 'ListView'], ['icon', 'IconView'], ['picture', 'ModuleView']]);
76
- const viewTypeSwitchMap = new Map([['detail', 'icon'], ['icon', 'picture'], ['picture', 'detail']]);
77
109
  const Attachment = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
78
110
  accept,
79
111
  allowSort,
@@ -83,7 +115,6 @@ const Attachment = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
83
115
  disabled,
84
116
  domain,
85
117
  error,
86
- height,
87
118
  hintText,
88
119
  id,
89
120
  inputProps,
@@ -106,7 +137,6 @@ const Attachment = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
106
137
  viewType
107
138
  }, reference) => {
108
139
  if (!reference) reference = useRef(null);
109
- if (maxFile === 1) multiple = false;
110
140
  const ref = useRef(null);
111
141
  const attachTextRef = useRef(null);
112
142
  const attachmentHandleIconRef = useRef(null);
@@ -127,11 +157,9 @@ const Attachment = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
127
157
  const [viewTypeState, setViewTypeState] = useState(viewType);
128
158
  const [newDataState, setNewDataState] = useState([]);
129
159
  const [dataState, setDataState] = useState([]);
130
- const [sizeByHeight, setSizeByHeight] = useState([]);
131
- const isSpecialCase = viewTypeState === 'picture' && maxFile === 1;
132
160
  const isEnable = !readOnly && !disabled;
133
161
  const isEmpty = !((dataState === null || dataState === void 0 ? void 0 : dataState.length) + (newDataState === null || newDataState === void 0 ? void 0 : newDataState.length));
134
- const _AttachmentRootCSS = AttachmentRootCSS(isEmpty, isEnable, height);
162
+ const _AttachmentRootCSS = AttachmentRootCSS(isEmpty, isEnable);
135
163
 
136
164
  // Start handler
137
165
  const onSortElement = (e, type) => {
@@ -204,13 +232,11 @@ const Attachment = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
204
232
  if (!isEnable) return;
205
233
  e.persist();
206
234
  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) {
207
- var _ref;
208
235
  let files = e.target.files;
209
- // const lengthAttached = attached.length;
210
- const lengthAttached = (_ref = [...dataState, ...newDataState]) === null || _ref === void 0 ? void 0 : _ref.length;
236
+ const lengthAttached = attached.length;
211
237
  for (let i = 0; i < files.length; i++) {
212
- if (i + 1 > maxFile - lengthAttached && !isSpecialCase || files[i].size > maxSize.current || checkExistingFile(files[i]) || !checkAcceptFileType(files[i])) {
213
- if (i + 1 > maxFile - lengthAttached && !isSpecialCase) {
238
+ if (i + 1 > maxFile - lengthAttached || files[i].size > maxSize.current || checkExistingFile(files[i]) || !checkAcceptFileType(files[i])) {
239
+ if (i + 1 > maxFile - lengthAttached) {
214
240
  var _files$i;
215
241
  notifyRef.current.instance.show(`${(_files$i = files[i]) === null || _files$i === void 0 ? void 0 : _files$i.name} - ${uploadErrorInfo['maxFile']}`);
216
242
  } else if (files[i].size > maxSize.current) {
@@ -238,13 +264,13 @@ const Attachment = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
238
264
  files[i].FileName = files[i].name;
239
265
  attached.push(files[i]);
240
266
  }
241
- // setNewDataState([...newDataState, ...Array.from(files)]);
267
+ setNewDataState([...newDataState, ...Array.from(files)]);
242
268
  for (let i = 0; i < length; i++) {
243
269
  files[i].URL = await onProgressing(files[i]);
244
270
  }
245
271
  } else if (length) {
246
272
  files[0].FileName = files[0].name;
247
- if (isSpecialCase) attached.splice(0, 1);
273
+ setNewDataState([...newDataState, files[0]]);
248
274
  attached.push(files[0]);
249
275
  files[0].URL = await onProgressing(files[0]);
250
276
  }
@@ -257,7 +283,6 @@ const Attachment = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
257
283
  newAttached: files,
258
284
  allNewAttached: allNewAttached.getAll('files')
259
285
  });
260
- if (maxFile === 1) updateSize();
261
286
  }
262
287
  // else if (!attached.length) {
263
288
  // afterChangeFile();
@@ -265,7 +290,6 @@ const Attachment = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
265
290
  };
266
291
 
267
292
  const onProgressing = file => {
268
- const key = (file === null || file === void 0 ? void 0 : file.lastModified) + (file === null || file === void 0 ? void 0 : file.size);
269
293
  return new Promise((resolve, reject) => {
270
294
  const reader = new FileReader();
271
295
  let url;
@@ -274,24 +298,16 @@ const Attachment = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
274
298
  url = e.target.result;
275
299
  };
276
300
  reader.onloadstart = () => {
277
- const LinearProgressEl = attachedRef.current.querySelector(`.DGN-UI-LinearProgress-${key}`);
278
- if (LinearProgressEl) {
279
- LinearProgressEl.parentNode.style.display = 'flex';
280
- LinearProgressEl.childNodes[0].style.width = '0%';
281
- }
301
+ attachedRef.current.querySelector(`.css-${AttachedLinearCSS.name}-attached`).childNodes[0].style.width = '0%';
282
302
  };
283
303
  reader.onprogress = e => {
284
- const LinearProgressEl = attachedRef.current.querySelector(`.DGN-UI-LinearProgress-${key}`);
285
- if (LinearProgressEl) {
286
- LinearProgressEl.childNodes[0].style.width = e.loaded / e.total * 100 + '%';
287
- }
304
+ attachedRef.current.querySelector(`.css-${AttachedLinearCSS.name}-attached`).childNodes[0].style.width = e.loaded / e.total * 100 + '%';
288
305
  };
289
306
  reader.onloadend = () => {
290
- const LinearProgressEl = attachedRef.current.querySelector(`.DGN-UI-LinearProgress-${key}`);
291
- if (LinearProgressEl) {
292
- LinearProgressEl.parentNode.style.display = 'none';
293
- }
294
- resolve(url);
307
+ setTimeout(() => {
308
+ attachedRef.current.querySelector(`.css-${AttachedLinearCSS.name}-attached`).parentNode.remove();
309
+ resolve(url);
310
+ }, 200);
295
311
  };
296
312
  reader.onerror = () => {
297
313
  console.log('Upload file fail');
@@ -351,7 +367,8 @@ const Attachment = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
351
367
  const tempDataState = [...dataState];
352
368
  const tempNewDataState = [...newDataState];
353
369
  nodeList.forEach(itemEl => {
354
- const index = Array.from(attachedRef.current.children).indexOf(itemEl.parentNode);
370
+ const parent = itemEl.parentNode;
371
+ const index = Array.from(attachedRef.current.children).indexOf(parent);
355
372
  const deletedFile = attachedItems[index];
356
373
  removedAttachedRef.current.push(deletedFile);
357
374
  recentRemovedAttached.push(deletedFile);
@@ -382,9 +399,9 @@ const Attachment = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
382
399
  onClosePopup();
383
400
  };
384
401
  const clearAllAttached = (confirmPopup = false) => {
385
- const allAttachEl = Array.from(attachedRef.current.querySelectorAll('.attachment-row')).map(item => item.firstChild);
402
+ const allAttachEl = attachedRef.current.querySelectorAll('.attachment-row');
386
403
  if (allAttachEl && allAttachEl.length) {
387
- allAttachEl.forEach(attachEl => attachEl.classList.add('chosen'));
404
+ allAttachEl.forEach(attachEl => attachEl.firstChild.classList.add('chosen'));
388
405
  isDeleteAll.current = true;
389
406
  confirmPopup ? onShowPopup() : onRemoveMultiple();
390
407
  }
@@ -396,10 +413,17 @@ const Attachment = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
396
413
  onView(node, AttachmentID);
397
414
  };
398
415
  const onView = (node, AttachmentID) => {
399
- const index = Array.from(attachedRef.current.children).indexOf(node === null || node === void 0 ? void 0 : node.parentNode);
416
+ if (timer.current) {
417
+ prevent.current = true;
418
+ clearTimeout(timer.current);
419
+ }
420
+ const index = Array.from(attachedRef.current.children).indexOf(node);
400
421
  if (onViewProp) onViewProp(AttachmentID, index);else {
401
422
  setShowModal(true);
402
423
  }
424
+ setTimeout(() => {
425
+ prevent.current = false;
426
+ }, 110);
403
427
  };
404
428
  const onDownload = (url, name) => {
405
429
  if (!url) return;
@@ -448,10 +472,7 @@ const Attachment = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
448
472
  allNewAttached.delete('files');
449
473
  allNewAttached.append('files', files[0]);
450
474
  // newAttachedRef.current = [files[0]];
451
- if (isSpecialCase) setDataState([]);
452
- setTimeout(() => {
453
- setNewDataState([files[0]]);
454
- });
475
+ setNewDataState([files[0]]);
455
476
  }
456
477
  // attachmentInputRef.current.files = allNewAttached.getAll('files');
457
478
  };
@@ -479,65 +500,64 @@ const Attachment = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
479
500
  const extFile = newFile.name.slice(newFile.name.lastIndexOf('.') + 1);
480
501
  return accept.join('-').includes(extFile);
481
502
  };
482
- const onChooseItem = (e, idx) => {
503
+ const onChooseItem = e => {
483
504
  const ctrlKey = e.ctrlKey;
484
505
  const shiftKey = e.shiftKey;
485
- const itemEl = e.currentTarget.firstChild;
486
- // timer.current = setTimeout(() => {
487
- if (!prevent.current) {
488
- if (shiftKey && !ctrlKey) {
489
- let startIndex = chosenItems[chosenItems.length - 1] || 0;
490
- let endIndex = idx;
491
- if (startIndex > endIndex) {
492
- endIndex = startIndex;
493
- startIndex = idx;
494
- }
495
- chosenItems.length = 0;
496
- attachedRef.current.querySelectorAll(`.DGN-UI-Attachment-List-Attached-Row`).forEach((itemEl, indexEl) => {
497
- const _itemEl = itemEl.firstChild;
498
- if (startIndex <= indexEl && indexEl <= endIndex) {
499
- if (!_itemEl.classList.contains('chosen')) {
500
- _itemEl.classList.add('chosen');
506
+ const itemEl = e.currentTarget;
507
+ timer.current = setTimeout(() => {
508
+ if (!prevent.current) {
509
+ const index = Array.from(attachedRef.current.children).indexOf(itemEl.parentNode);
510
+ if (shiftKey && !ctrlKey) {
511
+ let startIndex = chosenItems[chosenItems.length - 1] || 0;
512
+ let endIndex = index;
513
+ if (startIndex > endIndex) {
514
+ endIndex = startIndex;
515
+ startIndex = index;
516
+ }
517
+ chosenItems.length = 0;
518
+ attachedRef.current.querySelectorAll(`.css-${AttachedItemCSS.name}`).forEach((itemEl, indexEl) => {
519
+ if (startIndex <= indexEl && indexEl <= endIndex) {
520
+ if (!itemEl.classList.contains('chosen')) {
521
+ itemEl.classList.add('chosen');
522
+ }
523
+ chosenItems.push(indexEl);
524
+ } else if (itemEl.classList.contains('chosen')) {
525
+ itemEl.classList.remove('chosen');
501
526
  }
502
- chosenItems.push(indexEl);
503
- } else if (_itemEl.classList.contains('chosen')) {
504
- _itemEl.classList.remove('chosen');
527
+ });
528
+ if (chosenItems[chosenItems.length - 1] !== index) {
529
+ chosenItems.shift();
530
+ chosenItems.push(index);
505
531
  }
506
- });
507
- if (chosenItems[chosenItems.length - 1] !== idx) {
508
- chosenItems.shift();
509
- chosenItems.push(idx);
532
+ } else if (!ctrlKey) {
533
+ chosenItems.length = 0;
534
+ removeActiveChosenItem();
535
+ chosenItems.push(index);
536
+ itemEl.classList.add('chosen');
537
+ } else if (itemEl.classList.contains('chosen')) {
538
+ chosenItems.splice(chosenItems.indexOf(index));
539
+ itemEl.classList.remove('chosen');
540
+ if (!chosenItems.length) {
541
+ setTimeout(() => {
542
+ removeAllChosenItems();
543
+ }, 0);
544
+ }
545
+ } else {
546
+ chosenItems.push(index);
547
+ itemEl.classList.add('chosen');
510
548
  }
511
- } else if (!ctrlKey) {
512
- chosenItems.length = 0;
513
- removeActiveChosenItem();
514
- chosenItems.push(idx);
515
- itemEl.classList.add('chosen');
516
- } else if (itemEl.classList.contains('chosen')) {
517
- chosenItems.splice(chosenItems.indexOf(idx));
518
- itemEl.classList.remove('chosen');
519
- if (!chosenItems.length) {
520
- setTimeout(() => {
521
- removeAllChosenItems();
522
- }, 0);
549
+ // Add event listener click out of item
550
+ if (!existClickOutOfItem.current) {
551
+ existClickOutOfItem.current = true;
552
+ attachmentHandleIconRef.current.style.display = 'block';
553
+ document.addEventListener('keydown', onKeyDown);
554
+ document.addEventListener('click', clickOutOfItem);
523
555
  }
524
- } else {
525
- chosenItems.push(idx);
526
- itemEl.classList.add('chosen');
527
- }
528
- // Add event listener click out of item
529
- if (!existClickOutOfItem.current) {
530
- existClickOutOfItem.current = true;
531
- attachmentHandleIconRef.current.style.display = 'block';
532
- document.addEventListener('keydown', onKeyDown);
533
- document.addEventListener('click', clickOutOfItem);
556
+ checkChosenMultiple();
534
557
  }
535
- checkChosenMultiple();
536
- }
537
- prevent.current = false;
538
- // }, 100);
558
+ prevent.current = false;
559
+ }, 100);
539
560
  };
540
-
541
561
  const removeActiveChosenItem = () => {
542
562
  attachedRef.current.querySelectorAll('.chosen').forEach(itemEl => {
543
563
  itemEl.classList.remove('chosen');
@@ -564,22 +584,22 @@ const Attachment = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
564
584
  }
565
585
  } else if (/a/i.test(key) && event.ctrlKey) {
566
586
  chosenItems.length = 0;
567
- const allAttachEl = Array.from(attachedRef.current.querySelectorAll('.attachment-row')).map(item => item.firstChild);
587
+ const allAttachEl = attachedRef.current.querySelectorAll('.attachment-row');
568
588
  if (allAttachEl && allAttachEl.length) {
569
- allAttachEl.forEach((attachEl, index) => chosenItems.push(index) & attachEl.classList.add('chosen'));
589
+ allAttachEl.forEach((attachEl, index) => chosenItems.push(index) & attachEl.firstChild.classList.add('chosen'));
570
590
  }
571
591
  event.preventDefault();
572
592
  return false;
573
593
  } else if (/Arrow/.test(key)) {
574
594
  // Press Arrow key to select another item
575
595
  event.preventDefault();
576
- const itemsNode = Array.from(attachedRef.current.querySelectorAll('.attachment-row')).map(item => item.firstChild);
577
- const chosenItemsNode = Array.from(itemsNode).filter(el => el.classList.contains('chosen'));
596
+ const itemsNode = attachedRef.current.querySelectorAll('.attachment-row');
597
+ const chosenItemsNode = Array.from(itemsNode).filter(el => el.firstChild.classList.contains('chosen'));
578
598
  const length = itemsNode.length;
579
599
  let index;
580
600
  if (key === 'ArrowDown' || key === 'ArrowRight') {
581
601
  for (let id = length - 1; id >= 0; id--) {
582
- if (Array.from(itemsNode)[id].classList.contains('chosen')) {
602
+ if (Array.from(itemsNode)[id].firstChild.classList.contains('chosen')) {
583
603
  index = id;
584
604
  break;
585
605
  }
@@ -588,7 +608,7 @@ const Attachment = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
588
608
  if (chosenItemsNode.length !== 1 && !event.shiftKey) {
589
609
  chosenItemsNode.forEach((node, i) => {
590
610
  if (i !== index) {
591
- node.classList.remove('chosen');
611
+ node.firstChild.classList.remove('chosen');
592
612
  }
593
613
  });
594
614
  chosenItems.length = 0;
@@ -606,18 +626,18 @@ const Attachment = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
606
626
  });
607
627
  if (!event.shiftKey) {
608
628
  itemsNode.forEach(node => {
609
- node.classList.remove('chosen');
629
+ node.firstChild.classList.remove('chosen');
610
630
  });
611
631
  }
612
- itemsNode[index + 1].classList.add('chosen');
632
+ itemsNode[index + 1].firstChild.classList.add('chosen');
613
633
  chosenItems.push(index + 1);
614
634
  } else if (key === 'ArrowUp' || key === 'ArrowLeft') {
615
- index = Array.from(itemsNode).findIndex(el => el.classList.contains('chosen'));
635
+ index = Array.from(itemsNode).findIndex(el => el.firstChild.classList.contains('chosen'));
616
636
  if (index === 0) {
617
637
  if (chosenItemsNode.length !== 1 && !event.shiftKey) {
618
638
  chosenItemsNode.forEach((node, i) => {
619
639
  if (i !== index) {
620
- node.classList.remove('chosen');
640
+ node.firstChild.classList.remove('chosen');
621
641
  }
622
642
  });
623
643
  chosenItems.length = 0;
@@ -635,10 +655,10 @@ const Attachment = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
635
655
  });
636
656
  if (!event.shiftKey) {
637
657
  chosenItemsNode.forEach(node => {
638
- node.classList.remove('chosen');
658
+ node.firstChild.classList.remove('chosen');
639
659
  });
640
660
  }
641
- itemsNode[index - 1].classList.add('chosen');
661
+ itemsNode[index - 1].firstChild.classList.add('chosen');
642
662
  chosenItems.push(index - 1);
643
663
  }
644
664
  if (!event.shiftKey) {
@@ -718,23 +738,19 @@ const Attachment = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
718
738
  if (!isNaN(maxSizeProp)) {
719
739
  maxSize.current = maxSizeProp * 1024 * 1024;
720
740
  } else {
721
- const [numberSize = ''] = maxSizeProp.match(/\d+/) || [];
722
- const [unitMaxSize = ''] = maxSizeProp.match(/\D+/) || [];
741
+ const numberSize = maxSizeProp.match(/\d+/g);
742
+ const unitMaxSize = maxSizeProp.match(/\D+/g);
723
743
  maxSize.current = getBit(numberSize, unitMaxSize);
724
744
  }
725
745
  }
726
- return () => {
727
- maxSize.current = Infinity;
728
- };
729
- }, [maxSizeProp]);
730
- useEffect(() => {
731
- if (multiple && maxFile > 1) attachmentInputRef.current.multiple = multiple;
732
- }, [multiple, maxFile]);
733
- useEffect(() => {
746
+ attachmentInputRef.current.multiple = multiple;
734
747
  if (accept && typeof accept === 'string') {
735
748
  attachmentInputRef.current.accept = `${accept}/*`.replace('/*/*', '/*');
736
749
  }
737
- }, [accept]);
750
+ return () => {
751
+ maxSize.current = Infinity;
752
+ };
753
+ }, [maxFile, maxSizeProp, multiple, accept]);
738
754
  useEffect(() => {
739
755
  oldAttached.length = 0;
740
756
  // afterChangeFile((data?.length || 0) + (newDataState?.length || 0));
@@ -753,11 +769,11 @@ const Attachment = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
753
769
  }
754
770
  }
755
771
  setDataState(data);
756
- setTimeout(() => {
757
- setNewDataState([]);
758
- });
759
772
  }
760
773
  return () => {
774
+ // if (attachedRef.current) {
775
+ // attachedRef.current.innerHTML = null;
776
+ // }
761
777
  oldAttached.length = 0;
762
778
  attached.length = 0;
763
779
  chosenItems.length = 0;
@@ -767,6 +783,9 @@ const Attachment = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
767
783
  }
768
784
  };
769
785
  }, [data]);
786
+ useEffect(() => {
787
+ setNewDataState([]);
788
+ }, [dataState]);
770
789
  useEffect(() => {
771
790
  if (inputProps && Object.keys(inputProps).length) {
772
791
  Object.keys(inputProps).forEach(name => {
@@ -793,11 +812,10 @@ const Attachment = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
793
812
  attachmentInputRef.current.click();
794
813
  };
795
814
  const onDragFileStart = () => {
796
- attachmentInputRef.current.style.display = 'block';
815
+ attachmentInputRef.current.parentNode.style.display = 'block';
797
816
  };
798
- const onDropInput = e => {
799
- attachmentInputRef.current.style.display = 'none';
800
- e.target.value = null; // Fix not fire onChange when select same file
817
+ const onDropInput = () => {
818
+ attachmentInputRef.current.parentNode.style.display = null;
801
819
  };
802
820
  // End handler
803
821
 
@@ -856,7 +874,7 @@ const Attachment = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
856
874
  name: 'delete',
857
875
  onClick: onShowPopup
858
876
  }) : null), jsx("div", {
859
- css: isEmpty ? AttachmentImageEmptyCSS : mgr([isSpecialCase ? 0 : 2])
877
+ css: isEmpty ? AttachmentImageEmptyCSS : AttachmentImageCSS
860
878
  }, jsx("div", {
861
879
  css: [AttachmentImageCenterCSS, !isEnable && [parseHeight('calc(100% - 32px)'), justifyEnd]]
862
880
  }, isEnable ? jsx("div", {
@@ -876,7 +894,7 @@ const Attachment = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
876
894
  css: userSelectNone,
877
895
  type: 'p3',
878
896
  color: 'system/rest'
879
- }, getGlobal('noFileText')) : null)), allowSort && !isEmpty && !isSpecialCase ? jsx(Popover, {
897
+ }, getGlobal('noFileText')) : null)), allowSort && !isEmpty ? jsx(Popover, {
880
898
  ref: popoverRef,
881
899
  anchor: jsx(ButtonIcon, {
882
900
  viewType: 'ghost',
@@ -903,25 +921,19 @@ const Attachment = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
903
921
  onClick: e => onSortElement(e, 'datetime')
904
922
  }, jsx(ListItemText, null, getGlobal('byDate'))), jsx(ListItem, {
905
923
  onClick: e => onSortElement(e, 'username')
906
- }, jsx(ListItemText, null, getGlobal('byOwner'))))) : null, !isEmpty && !isSpecialCase ? jsx(ButtonIcon, {
924
+ }, jsx(ListItemText, null, getGlobal('byOwner'))))) : null, !isEmpty ? jsx(ButtonIcon, {
907
925
  viewType: 'ghost',
908
- name: viewTypeIconMap.get(viewTypeState),
909
- onClick: () => setViewTypeState(viewTypeSwitchMap.get(viewTypeState))
926
+ name: viewTypeState === 'detail' ? 'IconView' : 'ListView',
927
+ onClick: () => setViewTypeState(viewTypeState === 'icon' ? 'detail' : 'icon')
910
928
  }) : null));
911
929
  }, [allowSort, disabled, domain, error, hintText, label, readOnly, required, isEmpty, viewTypeState]);
912
930
  const AttachmentInputView = useMemo(() => {
913
- return jsx("input", {
914
- ref: attachmentInputRef,
931
+ return jsx("div", {
932
+ css: AttachmentInputCSS,
933
+ className: 'DGN-UI-Attachment-Input'
934
+ }, jsx("input", {
915
935
  type: "file",
916
- style: {
917
- display: 'none'
918
- },
919
- css: css`
920
- ${positionAbsolute};
921
- ${parseWidthHeight('100%')};
922
- opacity: 0;
923
- `,
924
- className: 'DGN-UI-Attachment-Input',
936
+ ref: attachmentInputRef,
925
937
  title: "",
926
938
  onDrop: onDropInput,
927
939
  onDragLeave: onDropInput,
@@ -929,214 +941,76 @@ const Attachment = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
929
941
  ,
930
942
  onChange: onChangeFiles,
931
943
  ...inputProps
932
- });
944
+ }));
933
945
  }, [accept, disabled, domain, inputProps, isStripDomain, maxFile, multiple, onChange, readOnly, uploadErrorInfo, newDataState]);
934
- const renderAttachmentItemDetail = (item, idx, isNew) => {
935
- const date = isNew ? new Date() : new Date(item.CreateDate);
936
- if (isNew) item.CreateDate = date.toISOString();
937
- const type = getType(item);
938
- const name = isNew ? item.name : item.FileName;
939
- const key = (item === null || item === void 0 ? void 0 : item.lastModified) + (item === null || item === void 0 ? void 0 : item.size);
940
- return (
941
- // <div key={idx} className={classNames('DGN-UI-Attachment-List-Attached-Row', 'attachment-row')}>
942
- jsx(Grid, {
943
- item: true,
944
- xs: 12,
945
- key: idx,
946
- onClick: e => onChooseItem(e, idx),
947
- onDoubleClick: e => onView(e.currentTarget, isNew ? null : item.AttachmentID),
948
- className: classNames('DGN-UI-Attachment-List-Attached-Row', 'attachment-row')
949
- }, jsx("div", {
950
- css: [AttachedItemCSS, AttachedItemDetailCSS]
951
- }, jsx("span", {
952
- css: AttachedItemInfoCSS
953
- }, jsx(Icon, {
954
- css: (item.lastModifiedDate || isNew) && DotNewFileDetailCSS,
955
- width: 16,
956
- height: 16,
957
- name: type === 'default' ? 'another' : type
958
- }), jsx("span", {
959
- css: displayNone,
960
- className: 'filetype'
961
- }, type), jsx(Typography, {
962
- className: 'filename',
963
- css: [mgl([3])],
964
- type: 'p1',
965
- lineClamp: 1
966
- }, name)), jsx("span", {
967
- css: AttachedItemOwnerCSS
968
- }, jsx("span", {
969
- css: DetailInfoCSS
970
- }, jsx(Typography, {
971
- className: 'username',
972
- type: 'p2',
973
- color: 'text/sub'
974
- }, (item === null || item === void 0 ? void 0 : item.UserName) || item.lastModifiedDate && ownerName || ''), jsx(Typography, {
975
- className: 'datetime',
976
- type: 'p2',
977
- color: 'text/sub'
978
- }, getDateTime(date)), jsx(Typography, {
979
- className: 'filesize',
980
- type: 'p2',
981
- color: 'text/sub'
982
- }, calculateSize(item.FileSize || item.size))), isNew ? jsx("span", {
983
- css: [AttachedLinearCSS, displayNone]
984
- }, jsx(LinearProgress, {
985
- className: `DGN-UI-LinearProgress-${key}`,
986
- determinate: true,
987
- percent: 0
988
- })) : null)))
989
- // </div>
990
- );
991
- };
992
-
993
- const renderAttachmentItemIcon = (item, idx, isNew) => {
994
- const date = isNew ? new Date() : new Date(item.CreateDate);
995
- if (isNew) item.CreateDate = date.toISOString();
996
- const type = getType(item);
997
- const name = isNew ? item.name : item.FileName;
998
- const key = (item === null || item === void 0 ? void 0 : item.lastModified) + (item === null || item === void 0 ? void 0 : item.size);
999
- return (
1000
- // <div key={idx} className={classNames('DGN-UI-Attachment-List-Attached-Row', 'attachment-row')}>
1001
- jsx(Grid, {
1002
- item: true,
1003
- xs: 'auto',
1004
- key: idx,
1005
- onClick: e => onChooseItem(e, idx),
1006
- onDoubleClick: e => onView(e.currentTarget, isNew ? null : item.AttachmentID),
1007
- className: classNames('DGN-UI-Attachment-List-Attached-Row', 'attachment-row')
1008
- }, jsx("div", {
1009
- css: AttachedItemCSS
1010
- }, jsx("span", {
1011
- css: AttachedItemIconInfoCSS
1012
- }, jsx(Icon, {
1013
- css: [(item.lastModifiedDate || isNew) && DotNewFileIconCSS],
1014
- width: 40,
1015
- height: 40,
1016
- name: type === 'default' ? 'another' : type
1017
- }), jsx(Typography, {
1018
- className: 'filename',
1019
- css: [textLeft, parseMaxWidth(64)],
1020
- type: 'p3',
1021
- lineClamp: 2
1022
- }, name), jsx("span", {
1023
- css: displayNone,
1024
- className: 'filetype'
1025
- }, type), jsx("span", {
1026
- css: displayNone,
1027
- className: 'username'
1028
- }, (item === null || item === void 0 ? void 0 : item.UserName) || item.lastModifiedDate && ownerName || ''), jsx("span", {
1029
- css: displayNone,
1030
- className: 'datetime'
1031
- }, getDateTime(date)), jsx("span", {
1032
- css: displayNone,
1033
- className: 'filesize'
1034
- }, calculateSize(item.FileSize || item.size))), isNew ? jsx("span", {
1035
- css: [AttachedLinearCSS, displayNone]
1036
- }, jsx(LinearProgress, {
1037
- className: `DGN-UI-LinearProgress-${key}`,
1038
- determinate: true,
1039
- percent: 0
1040
- })) : null))
1041
- // </div>
1042
- );
1043
- };
1044
-
1045
- const updateSize = () => {
1046
- if (timer.current) {
1047
- clearTimeout(timer.current);
1048
- }
1049
- timer.current = setTimeout(() => {
1050
- setSizeByHeight(ref.current.offsetHeight < ref.current.offsetWidth);
1051
- }, 300);
1052
- };
1053
- useLayoutEffect(() => {
1054
- window.addEventListener('resize', updateSize);
1055
- updateSize();
1056
- return () => window.removeEventListener('resize', updateSize);
1057
- }, []);
1058
- const renderAttachmentItemPicture = (item, idx, isNew) => {
946
+ const renderAttachmentItem = (item, idx, isNew = false) => {
947
+ const isViewTypeIcon = viewTypeState === 'icon';
1059
948
  const date = isNew ? new Date() : new Date(item.CreateDate);
1060
949
  if (isNew) item.CreateDate = date.toISOString();
1061
950
  const type = getType(item);
1062
951
  const name = isNew ? item.name : item.FileName;
1063
- const key = (item === null || item === void 0 ? void 0 : item.lastModified) + (item === null || item === void 0 ? void 0 : item.size);
1064
- const isTypeImage = type === 'image';
1065
- const isSpecialByHeight = sizeByHeight && isSpecialCase;
1066
- const specialBreakpointColumn = isSpecialByHeight ? 'auto' : 12;
1067
- return jsx(Grid, {
1068
- item: true,
1069
- xs: isSpecialCase ? specialBreakpointColumn : 6,
1070
- sm: isSpecialCase ? specialBreakpointColumn : 4,
1071
- md: isSpecialCase ? specialBreakpointColumn : 3,
1072
- lg: isSpecialCase ? specialBreakpointColumn : 2,
1073
- xl: isSpecialCase ? specialBreakpointColumn : 2,
952
+ return jsx("div", {
1074
953
  key: idx,
1075
- onClick: e => onChooseItem(e, idx),
1076
- onDoubleClick: e => onView(e.currentTarget, isNew ? null : item.AttachmentID),
1077
- className: classNames('DGN-UI-Attachment-List-Attached-Row', 'attachment-row')
954
+ className: 'attachment-row'
1078
955
  }, jsx("div", {
1079
- css: [AttachedItemPictureCSS, !isTypeImage && AttachedItemPictureImageCSS, isSpecialByHeight && parseWidthHeight(height - 56 - 8 - 2)]
1080
- }, isTypeImage ? jsx(Image, {
1081
- square: true,
1082
- src: item.URL,
1083
- width: isSpecialByHeight ? 'auto' : '100%',
1084
- height: isSpecialByHeight ? '100%' : 'auto'
1085
- }) : jsx(Icon, {
1086
- css: parseWidthHeight('100%'),
1087
- name: type === 'default' ? 'another' : type,
1088
- width: '50%',
1089
- height: '50%'
1090
- }), jsx(Typography, {
1091
- css: ItemPictureInfoCSS,
956
+ css: AttachedItemCSS,
957
+ onClick: e => onChooseItem(e),
958
+ onDoubleClick: e => onView(e.currentTarget.parentNode, isNew ? null : item.AttachmentID)
959
+ }, jsx("span", {
960
+ css: AttachedItemInfoCSS
961
+ }, jsx("span", {
962
+ css: AttachedItemInfoIconCSS,
963
+ className: classNames((item.lastModifiedDate || isNew) && 'new-file')
964
+ }, icons[type], jsx("span", {
965
+ className: 'filetype',
966
+ style: {
967
+ display: 'none'
968
+ }
969
+ }, type)), jsx(Typography, {
970
+ className: 'filename',
971
+ css: [isViewTypeIcon ? mg([0, 2]) : mgl([3])],
972
+ type: isViewTypeIcon ? 'p3' : 'p1',
973
+ lineClamp: isViewTypeIcon ? 2 : 1
974
+ }, name)), jsx("span", {
975
+ css: AttachedItemOwnerCSS
976
+ }, !isViewTypeIcon ? jsx("span", {
977
+ css: DetailInfoCSS,
978
+ className: 'detail-info'
979
+ }, jsx(Typography, {
980
+ className: 'username',
981
+ type: 'p2',
982
+ color: 'text/sub'
983
+ }, (item === null || item === void 0 ? void 0 : item.UserName) || item.lastModifiedDate && ownerName || ''), jsx(Typography, {
984
+ className: 'datetime',
1092
985
  type: 'p2',
1093
- color: 'text/tooltip',
1094
- lineClamp: 10,
1095
- className: 'DGN-UI-Attachment-Item-Picture-Info'
1096
- }, name), jsx("span", {
1097
- css: displayNone,
1098
- className: 'filetype'
1099
- }, type), jsx("span", {
1100
- css: displayNone,
1101
- className: 'filename'
1102
- }, name), jsx("span", {
1103
- css: displayNone,
1104
- className: 'username'
1105
- }, (item === null || item === void 0 ? void 0 : item.UserName) || item.lastModifiedDate && ownerName || ''), jsx("span", {
1106
- css: displayNone,
1107
- className: 'datetime'
1108
- }, getDateTime(date)), jsx("span", {
1109
- css: displayNone,
1110
- className: 'filesize'
1111
- }, calculateSize(item.FileSize || item.size)), isNew ? jsx("span", {
1112
- css: [AttachedLinearCSS, displayNone]
986
+ color: 'text/sub'
987
+ }, getDateTime(date)), jsx(Typography, {
988
+ className: 'filesize',
989
+ type: 'p2',
990
+ color: 'text/sub'
991
+ }, calculateSize(item.FileSize || item.size))) : null, isNew ? jsx("span", {
992
+ css: AttachedLinearCSS
1113
993
  }, jsx(LinearProgress, {
1114
- className: `DGN-UI-LinearProgress-${key}`,
994
+ className: `css-${AttachedLinearCSS.name}-attached`,
1115
995
  determinate: true,
1116
996
  percent: 0
1117
- })) : null));
1118
- };
1119
- const renderAttachmentItem = (item, idx, isNew = false) => {
1120
- const date = isNew ? new Date() : new Date(item.CreateDate);
1121
- if (isNew) item.CreateDate = date.toISOString();
1122
- return viewTypeState === 'detail' ? renderAttachmentItemDetail(item, idx, isNew) : viewTypeState === 'icon' ? renderAttachmentItemIcon(item, idx, isNew) : renderAttachmentItemPicture(item, idx, isNew);
997
+ })) : null)));
1123
998
  };
1124
999
  const AttachedView = useMemo(() => {
1000
+ const isViewTypeIcon = viewTypeState === 'icon';
1125
1001
  return jsx(ScrollBar, {
1126
1002
  css: AttachmentListCSS,
1127
1003
  className: 'DGN-UI-Attachment-List'
1128
- }, jsx(Grid, {
1129
- container: true,
1130
- css: isSpecialCase && justifyCenter,
1004
+ }, jsx("div", {
1005
+ css: AttachedCSS,
1131
1006
  ref: attachedRef,
1132
- className: classNames('DGN-UI-Attachment-List-Attached'),
1133
- spacing: 2
1007
+ className: classNames(isViewTypeIcon && 'icon-view')
1134
1008
  }, dataState.map((item, idx) => {
1135
1009
  return renderAttachmentItem(item, idx);
1136
1010
  }), newDataState.map((item, idx) => {
1137
1011
  return renderAttachmentItem(item, (data === null || data === void 0 ? void 0 : data.length) + idx, true);
1138
1012
  })));
1139
- }, [data, onViewProp, unitSize, dataState, newDataState, viewTypeState, sizeByHeight]);
1013
+ }, [data, onViewProp, unitSize, dataState, newDataState, viewTypeState]);
1140
1014
  const PopupView = useMemo(() => {
1141
1015
  return jsx(Popup, {
1142
1016
  open: showPopup,
@@ -1153,7 +1027,6 @@ const Attachment = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
1153
1027
  if (!chosenItems.length) return setShowModal(false);
1154
1028
  const index = chosenItems[0];
1155
1029
  const data = mountDomain(attached[index]);
1156
-
1157
1030
  // let data = oldAttached[index] || allNewAttached.getAll('files')[index-oldAttached.length];
1158
1031
  return jsx(ModalSample, {
1159
1032
  open: showModal,
@@ -1172,7 +1045,7 @@ const Attachment = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
1172
1045
  className: classNames('DGN-UI-Attachment', className),
1173
1046
  style: style,
1174
1047
  onDragEnter: onDragFileStart
1175
- }, AttachHeaderView, AttachedView, AttachmentInputView, PopupView, ModalView, jsx(Notify, {
1048
+ }, AttachHeaderView, AttachmentInputView, AttachedView, PopupView, ModalView, jsx(Notify, {
1176
1049
  ref: notifyRef,
1177
1050
  progressing: true,
1178
1051
  autoDisappear: true,
@@ -1183,7 +1056,7 @@ const AttachmentHandleIconCSS = css`
1183
1056
  ${displayNone};
1184
1057
  ${parseHeight(24)};
1185
1058
  ${mgr([2])};
1186
- ${borderRight(1, 'line/normal')};
1059
+ border-right: 1px solid ${lineNormal};
1187
1060
  button {
1188
1061
  ${mgr([2])};
1189
1062
  }
@@ -1204,6 +1077,18 @@ const AttachmentHeaderIconCSS = css`
1204
1077
  ${displayFlex};
1205
1078
  ${itemsCenter};
1206
1079
  `;
1080
+ const AttachmentInputCSS = css`
1081
+ ${displayNone};
1082
+ ${positionAbsolute};
1083
+ ${parseWidthHeight('100%')};
1084
+ ${top(0)};
1085
+ ${left(0)};
1086
+ input {
1087
+ ${positionRelative};
1088
+ ${parseWidthHeight('100%', 'calc(100% + 20px)')};
1089
+ opacity: 0;
1090
+ }
1091
+ `;
1207
1092
  const AttachmentImageCenterCSS = css`
1208
1093
  ${displayFlex};
1209
1094
  ${flexCol};
@@ -1212,10 +1097,12 @@ const AttachmentImageCenterCSS = css`
1212
1097
  ${parseWidthHeight('100%')};
1213
1098
  `;
1214
1099
  const ButtonAttachmentCSS = css`
1215
- ${border(1, 'line/normal')};
1216
- ${borderDashed};
1100
+ border: 1px dashed ${lineNormal} !important;
1217
1101
  ${mg([0, 'auto', 4])};
1218
1102
  `;
1103
+ const AttachmentImageCSS = css`
1104
+ ${mgr([2])};
1105
+ `;
1219
1106
  const AttachmentImageEmptyCSS = css`
1220
1107
  ${positionAbsolute};
1221
1108
  ${parseWidthHeight('100%')};
@@ -1225,30 +1112,26 @@ const AttachmentImageEmptyCSS = css`
1225
1112
  const AttachedItemInfoCSS = css`
1226
1113
  ${displayFlex};
1227
1114
  ${itemsCenter};
1115
+ ${borderRadius4px};
1228
1116
  ${userSelectNone};
1229
1117
  ${parseMinWidth('calc(50% - 10px)')};
1230
1118
  ${mgr([2])};
1231
1119
  `;
1232
- const DotNewFileDetailCSS = css`
1233
- :after {
1120
+ const AttachedItemInfoIconCSS = css`
1121
+ ${displayFlex};
1122
+ ${flexRow};
1123
+ ${positionRelative};
1124
+ ${boxContent};
1125
+ ${parseMaxWidthHeight(14, 16)};
1126
+ ${pd([1, 1.25])};
1127
+ &.new-file:after {
1234
1128
  content: '';
1235
1129
  ${positionAbsolute};
1236
1130
  ${borderRadius50};
1237
1131
  ${parseWidthHeight(4, 4)};
1238
1132
  ${bgColor('semantic/success')};
1239
- ${top(0)};
1240
- ${left(4)};
1241
- }
1242
- `;
1243
- const DotNewFileIconCSS = css`
1244
- :after {
1245
- content: '';
1246
- ${positionAbsolute};
1247
- ${borderRadius50};
1248
- ${parseWidthHeight(6, 6)};
1249
- ${bgColor('semantic/success')};
1250
- ${top(3)};
1251
- ${left(14)};
1133
+ ${top(4.5)};
1134
+ ${left(-2)};
1252
1135
  }
1253
1136
  `;
1254
1137
  const AttachedItemOwnerCSS = css`
@@ -1288,52 +1171,92 @@ const AttachedLinearCSS = css`
1288
1171
  ${top(0)};
1289
1172
  `;
1290
1173
  const AttachedItemCSS = css`
1174
+ ${displayFlex};
1175
+ ${justifyBetween};
1291
1176
  ${positionRelative};
1292
1177
  ${borderRadius4px};
1293
1178
  ${cursorPointer};
1179
+ ${parseHeight(24)};
1180
+ ${pd([0, 2])};
1294
1181
  transition: padding 0.5s ease;
1295
- &:hover {
1296
- ${bgColor('fill/hover')};
1182
+ `;
1183
+ const AttachedCSS = css`
1184
+ ${positionRelative};
1185
+ ${parseHeight('100%')};
1186
+ ${mgx([2])};
1187
+ overflow-y: visible;
1188
+ .attachment-row {
1189
+ ${displayBlock};
1190
+ ${mgb([2])};
1191
+ &:last-child {
1192
+ ${mgb(0)};
1193
+ }
1297
1194
  }
1298
- &:active {
1299
- ${bgColor('fill/pressed')};
1195
+ &.icon-view {
1196
+ ${displayFlex};
1197
+ ${flexWrap};
1198
+ ${justifyBetween};
1199
+ &::after {
1200
+ content: '';
1201
+ flex: auto;
1202
+ }
1203
+ ${parseMaxWidthHeight('calc(100% - 26px)', 200)};
1204
+ ${parseWidth('max-content')};
1205
+ ${mgl(0)};
1206
+ .attachment-row {
1207
+ ${positionRelative};
1208
+ ${mgl([4])};
1209
+ overflow-y: visible;
1210
+ }
1211
+ .css-${AttachedItemCSS.name} {
1212
+ ${displayBlock};
1213
+ ${parseWidthHeight(80)};
1214
+ ${pd(0)};
1215
+ .css-${AttachedItemInfoCSS.name} {
1216
+ ${displayBlock};
1217
+ ${positionRelative};
1218
+ ${textCenter};
1219
+ ${truncate};
1220
+ ${parseWidth('max-content')};
1221
+ ${parseMaxWidth(80)};
1222
+ ${parseMinWidth(70)};
1223
+ ${mgx(['auto'])};
1224
+ .css-${AttachedItemInfoIconCSS.name} {
1225
+ ${displayBlock};
1226
+ ${parseWidthHeight(40)};
1227
+ ${parseMaxWidthHeight(40)};
1228
+ ${mg([1, 'auto', 0.5])};
1229
+ ${pd(0)};
1230
+ &.new-file:after {
1231
+ ${parseWidthHeight(8)};
1232
+ ${top(-1)};
1233
+ ${left(-7)};
1234
+ }
1235
+ }
1236
+ }
1237
+ .css-${AttachedItemOwnerCSS.name} {
1238
+ ${parseHeight('auto')};
1239
+ position: inherit;
1240
+ .css-${AttachedLinearCSS.name} {
1241
+ ${parseHeight('auto')};
1242
+ ${bottom(0)};
1243
+ top: unset;
1244
+ background: none;
1245
+ }
1246
+ }
1247
+ }
1300
1248
  }
1301
- &.chosen {
1302
- ${bgColor('fill/focus')};
1249
+ &:not(.icon-view) {
1250
+ ${parseMinWidth(684)};
1303
1251
  }
1304
1252
  `;
1305
- const AttachedItemDetailCSS = css`
1306
- ${displayFlex};
1307
- ${justifyBetween};
1308
- ${itemsCenter};
1309
- ${parseMinHeight(24)};
1310
- ${pd([0, 2])};
1311
- `;
1312
- const AttachedItemIconInfoCSS = css`
1313
- ${displayFlex};
1314
- ${flexCol};
1315
- ${itemsCenter};
1316
- ${positionRelative};
1317
- ${textCenter};
1318
- ${pd([1, 2])};
1319
- `;
1320
-
1321
- // const AttachedCSS = css`
1322
- // ${displayFlex};
1323
- // ${positionRelative};
1324
- // ${parseHeight('100%')};
1325
- // ${gap([2])};
1326
- // ${flexWrap};
1327
- // overflow-y: visible;
1328
- // `;
1329
-
1330
1253
  const AttachmentListCSS = css`
1331
1254
  ${boxBorder};
1332
1255
  ${mgr([1.25])};
1333
- ${pd([0, 1, 2, 4])};
1334
- overflow-y: scroll;
1256
+ ${pd([0, 1.75, 0])};
1257
+ overflow-y: overlay;
1335
1258
  `;
1336
- const AttachmentRootCSS = (isEmpty, isEnable, height) => css`
1259
+ const AttachmentRootCSS = (isEmpty, isEnable) => css`
1337
1260
  ${displayFlex};
1338
1261
  ${flexCol};
1339
1262
  ${justifyStart};
@@ -1341,44 +1264,39 @@ const AttachmentRootCSS = (isEmpty, isEnable, height) => css`
1341
1264
  ${borderRadius4px};
1342
1265
  ${boxBorder};
1343
1266
  ${border(1, 'line/normal')};
1344
- ${parseMinHeight(isEmpty && !isEnable ? 120 : isEmpty ? 280 : null)};
1345
- ${parseHeight(height)};
1267
+ ${parseHeight(isEmpty && !isEnable ? 120 : 280)};
1346
1268
  ${bgColor('system/white')};
1347
- `;
1348
- const AttachedItemPictureCSS = css`
1349
- ${displayFlex};
1350
- ${positionRelative};
1351
- ${boxBorder};
1352
- ${borderRadius4px};
1353
- ${cursorPointer};
1354
- ${overflowHidden};
1355
- ${userSelectNone};
1356
- ${border(1, 'line/category')};
1357
- &:focus,
1358
- &:active,
1359
- &.chosen {
1360
- ${border(2, 'line/focus')};
1269
+ .css-${AttachedCSS.name} {
1270
+ .css-${AttachedItemCSS.name} {
1271
+ &:hover {
1272
+ ${bgColor('fill/hover')};
1273
+ .css-${AttachedLinearCSS.name} {
1274
+ ${bgColor('fill/hover')};
1275
+ }
1276
+ }
1277
+ &:active {
1278
+ ${bgColor('fill/pressed')};
1279
+ .css-${AttachedLinearCSS.name} {
1280
+ ${bgColor('fill/pressed')};
1281
+ }
1282
+ }
1283
+ &.chosen {
1284
+ ${bgColor('fill/focus')};
1285
+ .css-${AttachedItemInfoCSS.name}, .css-${AttachedItemOwnerCSS.name} {
1286
+ ${bgColor('fill/focus')};
1287
+ }
1288
+ }
1289
+ }
1361
1290
  }
1362
- &:not(:hover) {
1363
- .DGN-UI-Attachment-Item-Picture-Info {
1364
- ${displayNone};
1291
+ @media (max-width: 716px) {
1292
+ .css-${AttachedCSS.name}:not(.icon-view) {
1293
+ ${parseMinWidth(575)};
1294
+ }
1295
+ .css-${AttachedItemInfoCSS.name} {
1296
+ ${parseMaxWidth('calc(40% - 10px)')};
1365
1297
  }
1366
1298
  }
1367
1299
  `;
1368
- const AttachedItemPictureImageCSS = css`
1369
- ${itemsCenter};
1370
- ${justifyCenter};
1371
- ${aspectSquare};
1372
- `;
1373
- const ItemPictureInfoCSS = css`
1374
- ${positionAbsolute};
1375
- ${boxBorder};
1376
- ${bottom(0)};
1377
- ${left(0)};
1378
- ${pd([1, 2])};
1379
- ${bgColor('fill/tooltip')};
1380
- ${parseWidth('100%')};
1381
- `;
1382
1300
  Attachment.defaultProps = {
1383
1301
  deleteNotifyText: getGlobal('deleteNotifyText'),
1384
1302
  hintText: getGlobal('dropFileHere'),
@@ -1390,7 +1308,6 @@ Attachment.defaultProps = {
1390
1308
  fileType: getGlobal(['errorDefault', 'fileType']),
1391
1309
  existingFile: getGlobal(['errorDefault', 'existingFile'])
1392
1310
  },
1393
- height: 280,
1394
1311
  ...getGlobal(['components', 'attachment', 'defaultProps'])
1395
1312
  };
1396
1313
  Attachment.propTypes = {
@@ -1421,8 +1338,6 @@ Attachment.propTypes = {
1421
1338
  domain: PropTypes.string,
1422
1339
  /** Error of attachment. */
1423
1340
  error: PropTypes.string,
1424
- /** Height of the component. */
1425
- height: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
1426
1341
  /** Suggested passage attached. */
1427
1342
  hintText: PropTypes.string,
1428
1343
  /** [Attributes](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#attributes) applied to the input element. */
@@ -1466,6 +1381,6 @@ Attachment.propTypes = {
1466
1381
  /** Errors show up when the file upload is corrupted. */
1467
1382
  uploadErrorInfo: PropTypes.object,
1468
1383
  /** The view type of files. */
1469
- viewType: PropTypes.oneOf(['detail', 'icon', 'picture'])
1384
+ viewType: PropTypes.oneOf(['detail', 'icon'])
1470
1385
  };
1471
1386
  export default Attachment;