diginet-core-ui 1.3.78 → 1.3.79

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.
Files changed (209) hide show
  1. package/components/accordion/details.js +2 -6
  2. package/components/accordion/group.js +2 -9
  3. package/components/accordion/index.js +2 -15
  4. package/components/accordion/summary.js +4 -27
  5. package/components/alert/index.js +98 -137
  6. package/components/alert/notify.js +97 -166
  7. package/components/avatar/index.js +4 -63
  8. package/components/badge/index.js +7 -34
  9. package/components/button/icon.js +120 -186
  10. package/components/button/index.js +136 -205
  11. package/components/button/more.js +0 -12
  12. package/components/button/ripple-effect.js +46 -44
  13. package/components/card/body.js +2 -7
  14. package/components/card/extra.js +2 -7
  15. package/components/card/footer.js +2 -7
  16. package/components/card/header.js +2 -7
  17. package/components/card/index.js +2 -22
  18. package/components/chart/Pie/Circle.js +0 -1
  19. package/components/chart/Pie/Sector.js +0 -17
  20. package/components/chart/Pie/Sectors.js +0 -10
  21. package/components/chart/Pie/index.js +4 -36
  22. package/components/chart/Pie-v2/Circle.js +0 -1
  23. package/components/chart/Pie-v2/Sector.js +0 -13
  24. package/components/chart/Pie-v2/Sectors.js +0 -20
  25. package/components/chart/Pie-v2/index.js +11 -38
  26. package/components/chart/bar/Axis.js +0 -12
  27. package/components/chart/bar/Bar.js +13 -35
  28. package/components/chart/bar/Grid.js +0 -18
  29. package/components/chart/bar/Labels.js +0 -18
  30. package/components/chart/bar/Points.js +0 -17
  31. package/components/chart/bar/index.js +6 -26
  32. package/components/chart/bar-v2/Axis.js +0 -12
  33. package/components/chart/bar-v2/Bar.js +15 -36
  34. package/components/chart/bar-v2/Grid.js +0 -18
  35. package/components/chart/bar-v2/Labels.js +0 -18
  36. package/components/chart/bar-v2/Points.js +0 -17
  37. package/components/chart/bar-v2/index.js +6 -26
  38. package/components/chart/line/Axis.js +4 -16
  39. package/components/chart/line/Grid.js +2 -19
  40. package/components/chart/line/Labels.js +0 -18
  41. package/components/chart/line/Path.js +23 -33
  42. package/components/chart/line/Point.js +6 -40
  43. package/components/chart/line/Title.js +0 -3
  44. package/components/chart/line/index.js +12 -35
  45. package/components/chart/line-v2/Axis.js +0 -13
  46. package/components/chart/line-v2/Grid.js +0 -18
  47. package/components/chart/line-v2/Labels.js +0 -18
  48. package/components/chart/line-v2/Path.js +23 -33
  49. package/components/chart/line-v2/Point.js +6 -35
  50. package/components/chart/line-v2/Title.js +0 -3
  51. package/components/chart/line-v2/index.js +12 -30
  52. package/components/check-text/index.js +0 -8
  53. package/components/check-text/interview-confirmation.js +0 -7
  54. package/components/check-text/interview-status.js +0 -7
  55. package/components/chip/attach.js +4 -17
  56. package/components/chip/index.js +6 -33
  57. package/components/collapse/index.js +0 -13
  58. package/components/divider/index.js +0 -8
  59. package/components/form-control/attachment/index.js +24 -202
  60. package/components/form-control/calendar/function.js +40 -94
  61. package/components/form-control/calendar/index.js +5 -30
  62. package/components/form-control/calendar/range.js +11 -28
  63. package/components/form-control/checkbox/index.js +4 -37
  64. package/components/form-control/control/index.js +3 -13
  65. package/components/form-control/date-picker/index-old.js +18 -0
  66. package/components/form-control/date-picker/index.js +23 -99
  67. package/components/form-control/date-range-picker/index.js +86 -221
  68. package/components/form-control/dropdown/index.js +72 -289
  69. package/components/form-control/dropdown-box/index.js +6 -35
  70. package/components/form-control/form/index.js +0 -2
  71. package/components/form-control/form-group/index.js +1 -6
  72. package/components/form-control/helper-text/index.js +2 -9
  73. package/components/form-control/input-base/index.js +218 -399
  74. package/components/form-control/label/index.js +2 -12
  75. package/components/form-control/money-input/index.js +43 -132
  76. package/components/form-control/number-input/index.js +15 -113
  77. package/components/form-control/number-input/index2.js +78 -119
  78. package/components/form-control/phone-input/index.js +16 -78
  79. package/components/form-control/radio/index.js +4 -23
  80. package/components/form-control/text-input/index.js +33 -256
  81. package/components/form-control/time-picker/index.js +14 -71
  82. package/components/form-control/time-picker/swiper.js +21 -73
  83. package/components/form-control/toggle/index.js +4 -19
  84. package/components/form-view/helper-text.js +2 -2
  85. package/components/form-view/index.js +0 -14
  86. package/components/form-view/input.js +2 -13
  87. package/components/form-view/label.js +0 -2
  88. package/components/grid/Col.js +2 -15
  89. package/components/grid/Container.js +2 -21
  90. package/components/grid/Row.js +2 -21
  91. package/components/grid/index.js +2 -43
  92. package/components/image/index.js +2 -22
  93. package/components/index.js +62 -31
  94. package/components/list/list-item-action.js +0 -9
  95. package/components/list/list-item-icon.js +0 -9
  96. package/components/list/list-item-text.js +0 -5
  97. package/components/list/list-item.js +0 -11
  98. package/components/list/list.js +0 -13
  99. package/components/list/sub-header.js +0 -4
  100. package/components/modal/body.js +2 -6
  101. package/components/modal/footer.js +2 -11
  102. package/components/modal/header.js +2 -12
  103. package/components/modal/index.js +2 -10
  104. package/components/modal/modal.js +11 -52
  105. package/components/others/extra/index.js +3 -10
  106. package/components/others/import/index.js +0 -7
  107. package/components/others/option-wrapper/index.js +4 -7
  108. package/components/others/scrollbar/index.js +0 -3
  109. package/components/paging/page-info.js +39 -101
  110. package/components/paging/page-selector.js +7 -35
  111. package/components/paging/page-selector2.js +35 -74
  112. package/components/paper/index.js +0 -11
  113. package/components/popover/body.js +2 -6
  114. package/components/popover/footer.js +2 -11
  115. package/components/popover/header.js +2 -7
  116. package/components/popover/index.js +39 -123
  117. package/components/popup/danger_popup.js +0 -19
  118. package/components/popup/index.js +2 -48
  119. package/components/popup/proposals_popup.js +10 -49
  120. package/components/popup/v2/index.js +0 -31
  121. package/components/progress/circular.js +19 -81
  122. package/components/progress/linear.js +4 -20
  123. package/components/rating/index.js +0 -24
  124. package/components/slider/slider-container.js +3 -40
  125. package/components/slider/slider-item.js +10 -25
  126. package/components/status/index.js +2 -16
  127. package/components/tab/tab-container.js +2 -16
  128. package/components/tab/tab-header.js +4 -24
  129. package/components/tab/tab-panel.js +4 -16
  130. package/components/tab/tab.js +4 -28
  131. package/components/tooltip/index.js +12 -97
  132. package/components/tooltip/portal.js +0 -2
  133. package/components/transfer/index.js +22 -67
  134. package/components/tree-view/index.js +62 -202
  135. package/components/typography/index.js +3 -31
  136. package/global/index.js +0 -8
  137. package/icons/basic.js +0 -48
  138. package/icons/effect.js +17 -29
  139. package/icons/general/clock/clock.js +0 -2
  140. package/icons/general/color-handler/background.js +0 -2
  141. package/icons/general/color-handler/text.js +0 -2
  142. package/icons/general/emoji/emoji.js +0 -2
  143. package/icons/general/font-properties/bold.js +0 -2
  144. package/icons/general/font-properties/font-family.js +0 -2
  145. package/icons/general/font-properties/font-size.js +0 -2
  146. package/icons/general/font-properties/italic.js +0 -2
  147. package/icons/general/font-properties/underline.js +0 -2
  148. package/icons/general/hyperlink/hyperlink.js +0 -2
  149. package/icons/general/indent/decrease.js +0 -2
  150. package/icons/general/indent/increase.js +0 -2
  151. package/icons/general/list/bullets.js +0 -2
  152. package/icons/general/list/numbering.js +0 -2
  153. package/icons/general/picture/picture.js +0 -2
  154. package/icons/general/steps/redo.js +0 -2
  155. package/icons/general/steps/undo.js +0 -2
  156. package/icons/general/text-align/center.js +0 -2
  157. package/icons/general/text-align/justify.js +0 -2
  158. package/icons/general/text-align/left.js +0 -2
  159. package/icons/general/text-align/right.js +0 -2
  160. package/icons/menu/dhr.js +2 -1
  161. package/icons/menu/index.js +2 -2
  162. package/icons/menu/v2/index.js +0 -10
  163. package/package.json +1 -1
  164. package/readme.md +11 -1
  165. package/styles/animation.js +15 -58
  166. package/styles/color-helper.js +24 -54
  167. package/styles/colors.js +17 -9
  168. package/styles/general.js +6 -2
  169. package/styles/typography.js +4 -4
  170. package/styles/utils.js +2 -2
  171. package/theme/createBreakpoints.js +7 -18
  172. package/theme/make-styles.js +2 -5
  173. package/theme/set-theme.js +3 -6
  174. package/theme/settings.js +3 -2
  175. package/theme/theme-provider.js +0 -1
  176. package/utils/array/array.js +14 -23
  177. package/utils/classNames.js +0 -5
  178. package/utils/console.js +0 -6
  179. package/utils/date.js +13 -82
  180. package/utils/error/error.js +1 -9
  181. package/utils/error/errors.js +1 -48
  182. package/utils/getFileType.js +0 -9
  183. package/utils/handleBreakpoints.js +0 -5
  184. package/utils/intersectionObserver.js +0 -5
  185. package/utils/iterator.js +0 -9
  186. package/utils/map-parent.js +3 -10
  187. package/utils/object/extend.js +0 -10
  188. package/utils/object/object.js +12 -11
  189. package/utils/parseHTML.js +0 -1
  190. package/utils/promisify.js +0 -5
  191. package/utils/randomString.js +0 -7
  192. package/utils/remove-unicode.js +0 -1
  193. package/utils/render-portal.js +1 -9
  194. package/utils/renderHTML.js +4 -6
  195. package/utils/renderIcon.js +4 -14
  196. package/utils/sb-template.js +6 -5
  197. package/utils/string/capitalize.js +0 -1
  198. package/utils/string/capitalizeSentenceCase.js +0 -2
  199. package/utils/string/string.js +0 -13
  200. package/utils/type.js +0 -21
  201. package/utils/updatePosition.js +4 -5
  202. package/utils/useDelayUnmount.js +0 -4
  203. package/utils/useElementSize.js +9 -3
  204. package/utils/useEventListener.js +12 -6
  205. package/utils/useInput.js +0 -6
  206. package/utils/useMediaQuery.js +8 -10
  207. package/utils/useOnClickOutside.js +0 -2
  208. package/utils/usePortal.js +3 -10
  209. package/utils/validate.js +6 -20
@@ -1,5 +1,4 @@
1
1
  /** @jsxRuntime classic */
2
-
3
2
  /** @jsx jsx */
4
3
  import { memo, useMemo, useEffect, useState, useRef, forwardRef, useImperativeHandle, Fragment } from 'react';
5
4
  import PropTypes from 'prop-types';
@@ -112,73 +111,59 @@ let prevent = false;
112
111
  let existClickOutOfItem = false;
113
112
  let maxSize = Infinity;
114
113
  let divideSize = null;
115
-
116
114
  const getType = data => {
117
115
  if (data.type !== undefined) {
118
116
  var _type$match;
119
-
120
117
  const pattern = /word|sheet|presentation|pdf|image|compressed/i;
121
118
  let type = data.type;
122
-
123
119
  if (!type) {
124
120
  if (/rar/.test(data.name)) {
125
121
  type = 'compressed';
126
122
  }
127
123
  }
128
-
129
124
  return ((_type$match = type.match(pattern)) === null || _type$match === void 0 ? void 0 : _type$match[0]) || 'default';
130
125
  } else {
131
126
  var _data$FileName;
132
-
133
127
  const FileExt = (_data$FileName = data.FileName) === null || _data$FileName === void 0 ? void 0 : _data$FileName.slice(data.FileName.lastIndexOf('.'));
134
128
  return getFileType(FileExt, 'default');
135
129
  }
136
130
  };
137
-
138
131
  const getDateTime = date => {
139
- if (String(date) === 'Invalid Date') return 'unknown'; // const d = ('0' + date.getDate()).slice(-2);
132
+ if (String(date) === 'Invalid Date') return 'unknown';
133
+ // const d = ('0' + date.getDate()).slice(-2);
140
134
  // const m = ('0' + (date.getMonth() + 1)).slice(-2);
141
135
  // const y = date.getFullYear();
142
136
  // const t = date.toTimeString().slice(0, 8);
143
-
144
137
  return jsx(Fragment, null, moment(date).format('DD/MM/YYYY, HH:mm:ss'), ' ', jsx("span", {
145
138
  style: {
146
139
  display: 'none'
147
140
  }
148
141
  }, date.getMilliseconds()));
149
142
  };
150
-
151
143
  const getNewUnitSize = (sizeName, totalSize, num) => {
152
144
  if (sizeName === 'B' && num === 1 || sizeName === 'TB' && num === -1) return [sizeName, totalSize];
153
145
  const arraySize = ['TB', 'GB', 'MB', 'KB', 'B'];
154
146
  const index = arraySize.indexOf(sizeName);
155
- const newTotalSize = totalSize * Math.pow(1024, num); // newTotalSize = Math.round(newTotalSize*100)/100;
156
-
147
+ const newTotalSize = totalSize * Math.pow(1024, num);
148
+ // newTotalSize = Math.round(newTotalSize*100)/100;
157
149
  return [arraySize[index + num], newTotalSize];
158
150
  };
159
-
160
151
  const getBit = (size, unit) => {
161
152
  switch (true) {
162
153
  case /^B$/i.test(unit):
163
154
  return size * 1;
164
-
165
155
  case /KB/i.test(unit):
166
156
  return size * 1024;
167
-
168
157
  case /MB/i.test(unit):
169
158
  return size * 1024 ** 2;
170
-
171
159
  case /GB/i.test(unit):
172
160
  return size * 1024 ** 3;
173
-
174
161
  case /TB/i.test(unit):
175
162
  return size * 1024 ** 4;
176
-
177
163
  default:
178
164
  return size * 1024 * 1024;
179
165
  }
180
166
  };
181
-
182
167
  const Attachment = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
183
168
  accept,
184
169
  allowSort,
@@ -226,16 +211,15 @@ const Attachment = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
226
211
  const popoverRef = useRef(null);
227
212
  const isDeleteAll = useRef(false);
228
213
  const PushNotify = useRef(null);
229
- const removedAttachedRef = useRef([]); // Start handler
214
+ const removedAttachedRef = useRef([]);
230
215
 
216
+ // Start handler
231
217
  const onShowSortPopover = () => {
232
218
  setPopover(true);
233
219
  };
234
-
235
220
  const onSortElement = (e, type) => {
236
221
  let multi = 1;
237
222
  const currentActive = popoverRef.current.querySelector('.DGN-Active');
238
-
239
223
  if (currentActive) {
240
224
  if (e.currentTarget.classList.contains('DGN-Active')) {
241
225
  if (e.currentTarget.classList.contains('DGN-Decrease')) {
@@ -249,13 +233,11 @@ const Attachment = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
249
233
  currentActive.classList.remove('DGN-Active');
250
234
  }
251
235
  }
252
-
253
236
  e.currentTarget.classList.add('DGN-Active');
254
237
  const attachedList = Array.from(attachedRef.current.querySelectorAll('.attachment-row'));
255
238
  attachedList.sort((a, b) => {
256
239
  let textA = a.querySelector('.' + (type === 'filesize' ? 'filename' : type)).textContent;
257
240
  let textB = b.querySelector('.' + (type === 'filesize' ? 'filename' : type)).textContent;
258
-
259
241
  if (type === 'datetime') {
260
242
  textA = textA.replace(/.{10}/, text => moment(text, 'DD/MM/YYYY').format('YYYY/MM/DD'));
261
243
  textB = textB.replace(/.{10}/, text => moment(text, 'DD/MM/YYYY').format('YYYY/MM/DD'));
@@ -265,14 +247,12 @@ const Attachment = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
265
247
  textA = (objA.size || objA.FileSize).toString();
266
248
  textB = (objB.size || objB.FileSize).toString();
267
249
  }
268
-
269
250
  return multi * textA.localeCompare(textB, 'en', {
270
251
  numeric: type === 'filesize'
271
252
  });
272
253
  });
273
254
  attached.sort((a, b) => {
274
255
  let valueA, valueB;
275
-
276
256
  if (type === 'filesize' || type === 'datetime') {
277
257
  if (type === 'filesize') {
278
258
  valueA = a.size || a.FileSize;
@@ -289,7 +269,6 @@ const Attachment = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
289
269
  valueA = a[type === 'filename' ? 'FileName' : 'UserName'] || ownerName;
290
270
  valueB = b[type === 'filename' ? 'FileName' : 'UserName'] || ownerName;
291
271
  }
292
-
293
272
  return multi * valueA.toString().localeCompare(valueB.toString(), 'en', {
294
273
  numeric: type === 'filesize' || type === 'datetime'
295
274
  });
@@ -299,10 +278,8 @@ const Attachment = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
299
278
  });
300
279
  setPopover(false);
301
280
  };
302
-
303
281
  const afterChangeFile = (length = 0) => {
304
282
  var _sortIconRef$current;
305
-
306
283
  if (!length) {
307
284
  if (!attachmentImageRef.current.classList.contains('hint-center')) {
308
285
  attachmentImageRef.current.classList.add('hint-center');
@@ -310,7 +287,6 @@ const Attachment = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
310
287
  } else {
311
288
  attachmentImageRef.current.classList.remove('hint-center');
312
289
  }
313
-
314
290
  if ((_sortIconRef$current = sortIconRef.current) !== null && _sortIconRef$current !== void 0 && _sortIconRef$current.element) {
315
291
  if (length > 1) {
316
292
  sortIconRef.current.element.style.display = null;
@@ -319,54 +295,41 @@ const Attachment = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
319
295
  }
320
296
  }
321
297
  };
322
-
323
298
  const onChangeFiles = async e => {
324
299
  if (readOnly || disabled) return;
325
-
326
300
  if (e.target && e.target.files && e.target.files.length) {
327
301
  let files = e.target.files;
328
302
  const lengthAttached = attached.length;
329
-
330
303
  for (let i = 0; i < files.length; i++) {
331
304
  if (i + 1 > maxFile - lengthAttached || files[i].size > maxSize || checkExistingFile(files[i]) || !checkAcceptFileType(files[i])) {
332
305
  if (i + 1 > maxFile - lengthAttached) {
333
306
  var _files$i;
334
-
335
307
  PushNotify.current(`${(_files$i = files[i]) === null || _files$i === void 0 ? void 0 : _files$i.name} - ${uploadErrorInfo['maxFile']}`);
336
308
  } else if (files[i].size > maxSize) {
337
309
  var _files$i2;
338
-
339
310
  PushNotify.current(`${(_files$i2 = files[i]) === null || _files$i2 === void 0 ? void 0 : _files$i2.name} - ${uploadErrorInfo['maxSize']}`);
340
311
  } else if (!checkAcceptFileType(files[i])) {
341
312
  var _files$i3;
342
-
343
313
  PushNotify.current(`${(_files$i3 = files[i]) === null || _files$i3 === void 0 ? void 0 : _files$i3.name} - ${uploadErrorInfo['fileType']}`);
344
314
  } else {
345
315
  var _files$i4;
346
-
347
316
  PushNotify.current(`${(_files$i4 = files[i]) === null || _files$i4 === void 0 ? void 0 : _files$i4.name} - ${uploadErrorInfo['existingFile']}`);
348
317
  }
349
-
350
318
  files = removeFileOutInputFiles(i, true);
351
319
  i--;
352
320
  }
353
321
  }
354
-
355
322
  const length = files.length;
356
-
357
323
  if (!lengthAttached && !length) {
358
324
  afterChangeFile();
359
325
  return;
360
326
  }
361
-
362
327
  afterChangeFile(lengthAttached + length);
363
-
364
328
  if (multiple || inputProps && inputProps.multiple) {
365
329
  for (let i = 0; i < length; i++) {
366
330
  // if (files[i].size > maxSize) continue;
367
331
  addNewElement(files[i], lengthAttached);
368
332
  }
369
-
370
333
  for (let i = 0; i < length; i++) {
371
334
  // if (files[i].size > maxSize) continue;
372
335
  files[i].URL = await onProgressing(files[i]);
@@ -378,7 +341,6 @@ const Attachment = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
378
341
  addNewElement(files[0], lengthAttached);
379
342
  files[0].URL = await onProgressing(files[0]);
380
343
  }
381
-
382
344
  insertAttached(files);
383
345
  stripDomain();
384
346
  if (onChange) onChange({
@@ -392,40 +354,33 @@ const Attachment = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
392
354
  afterChangeFile();
393
355
  }
394
356
  };
395
-
396
357
  const onProgressing = file => {
397
358
  return new Promise((resolve, reject) => {
398
359
  const reader = new FileReader();
399
360
  let url;
400
361
  reader.readAsDataURL(file);
401
-
402
362
  reader.onload = e => {
403
363
  url = e.target.result;
404
364
  };
405
-
406
365
  reader.onloadstart = () => {
407
366
  // console.log(attachedRef.current.querySelector(`.css-${AttachedLinear.name}-attached`).parentNode.parentNode.querySelector('.filesize').offsetWidth);
408
367
  attachedRef.current.querySelector(`.css-${AttachedLinearCSS.name}-attached`).childNodes[0].style.width = '0%';
409
368
  };
410
-
411
369
  reader.onprogress = e => {
412
370
  attachedRef.current.querySelector(`.css-${AttachedLinearCSS.name}-attached`).childNodes[0].style.width = e.loaded / e.total * 100 + '%';
413
371
  };
414
-
415
372
  reader.onloadend = () => {
416
373
  setTimeout(() => {
417
374
  attachedRef.current.querySelector(`.css-${AttachedLinearCSS.name}-attached`).parentNode.remove();
418
375
  resolve(url);
419
376
  }, 200);
420
377
  };
421
-
422
378
  reader.onerror = () => {
423
379
  console.log('Upload file fail');
424
380
  reject(false);
425
381
  };
426
382
  });
427
383
  };
428
-
429
384
  const addNewElement = (file, lengthAttached) => {
430
385
  const newAttach = getItemDetailHTML(file, lengthAttached + 1);
431
386
  attached.push(file);
@@ -433,7 +388,6 @@ const Attachment = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
433
388
  newElement.className = 'attachment-row';
434
389
  ReactDOM.render(newAttach, attachedRef.current.appendChild(newElement));
435
390
  };
436
-
437
391
  const getItemDetailHTML = (data, i) => {
438
392
  const date = new Date();
439
393
  data.CreateDate = date.toISOString();
@@ -474,7 +428,6 @@ const Attachment = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
474
428
  percent: 0
475
429
  }))));
476
430
  };
477
-
478
431
  const getItemHTMLFromData = (data, i) => {
479
432
  const date = new Date(data.CreateDate);
480
433
  const type = getType(data);
@@ -508,55 +461,44 @@ const Attachment = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
508
461
  className: 'filesize'
509
462
  }, calculateSize(data.FileSize || data.size)))));
510
463
  };
511
-
512
464
  const calculateSize = size => {
513
465
  if (!size && size !== 0) return 'unknown';
514
466
  let totalSize;
515
467
  let unitSizeName;
516
-
517
468
  if (divideSize) {
518
469
  totalSize = size / divideSize;
519
470
  unitSizeName = unitSize.toUpperCase();
520
-
521
471
  while (totalSize < 0.01 && unitSizeName !== 'B') {
522
472
  [unitSizeName, totalSize] = getNewUnitSize(unitSizeName, totalSize, 1);
523
473
  }
524
474
  } else {
525
475
  totalSize = size;
526
476
  unitSizeName = 'B';
527
-
528
477
  while (totalSize > 1024 && unitSizeName !== 'TB') {
529
478
  [unitSizeName, totalSize] = getNewUnitSize(unitSizeName, totalSize, -1);
530
479
  }
531
480
  }
532
-
533
481
  if (totalSize < 1000) {
534
482
  totalSize = Math.round(totalSize * 100) / 100;
535
483
  } else {
536
484
  totalSize = Math.round(totalSize);
537
485
  }
538
-
539
486
  return totalSize + ' ' + unitSizeName;
540
487
  };
541
-
542
488
  const onShowPopup = () => {
543
489
  setPopup(true);
544
490
  };
545
-
546
491
  const onClosePopup = () => {
547
492
  setPopup(false);
548
-
549
493
  if (isDeleteAll.current) {
550
494
  isDeleteAll.current = false;
551
495
  chosenItems.length = 0;
552
496
  removeActiveChosenItem();
553
497
  }
554
498
  };
555
-
556
499
  const onDownloadMultiple = () => {
557
500
  const index = chosenItems[0];
558
501
  let file;
559
-
560
502
  if (index < oldAttached.length) {
561
503
  file = mountDomain(oldAttached[index]);
562
504
  onDownload(file.URL, file.FileName);
@@ -566,7 +508,6 @@ const Attachment = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
566
508
  onDownload(file.URL, file.name);
567
509
  }
568
510
  };
569
-
570
511
  const onRemoveMultiple = () => {
571
512
  const nodeList = attachedRef.current.querySelectorAll('.chosen');
572
513
  const recentRemovedAttached = [];
@@ -574,22 +515,18 @@ const Attachment = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
574
515
  const parent = itemEl.parentNode;
575
516
  const index = Array.from(attachedRef.current.children).indexOf(parent);
576
517
  const deletedFile = attached.splice(index, 1)[0];
577
-
578
518
  if (Object.prototype.toString.call(deletedFile) === '[object File]') {
579
519
  removeFileOutInputFiles(allNewAttached.getAll('files').findIndex(attach => attach.FileName === deletedFile.FileName && attach.CreateDate === deletedFile.CreateDate));
580
520
  } else {
581
521
  oldAttached.splice(oldAttached.findIndex(attach => attach.FileName === deletedFile.FileName && attach.CreateDate === deletedFile.CreateDate), 1);
582
522
  }
583
-
584
523
  removedAttachedRef.current.push(deletedFile);
585
524
  recentRemovedAttached.push(deletedFile);
586
525
  parent.remove();
587
526
  });
588
-
589
527
  if (attached.length < 2) {
590
528
  afterChangeFile(attached.length);
591
529
  }
592
-
593
530
  stripDomain();
594
531
  if (onChange) onChange({
595
532
  element: nodeList,
@@ -602,28 +539,25 @@ const Attachment = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
602
539
  !!onRemoveProp && onRemoveProp(recentRemovedAttached);
603
540
  onClosePopup();
604
541
  };
605
-
606
542
  const clearAllAttached = (confirmPopup = false) => {
607
543
  const allAttachEl = attachedRef.current.querySelectorAll('.attachment-row');
608
-
609
544
  if (allAttachEl && allAttachEl.length) {
610
545
  allAttachEl.forEach(attachEl => attachEl.firstChild.classList.add('chosen'));
611
546
  isDeleteAll.current = true;
612
547
  confirmPopup ? onShowPopup() : onRemoveMultiple();
613
548
  }
614
549
  };
615
-
616
550
  const onGetViewItem = (i = 0) => {
617
551
  const index = chosenItems[i];
618
552
  const node = attachedRef.current.childNodes[index];
619
553
  const AttachmentID = attached[index].AttachmentID;
620
554
  onView(node, AttachmentID);
621
555
  };
622
-
623
556
  const onView = (node, AttachmentID) => {
624
557
  if (timer) {
625
558
  prevent = true;
626
- clearTimeout(timer); // if (existClickOutOfItem) {
559
+ clearTimeout(timer);
560
+ // if (existClickOutOfItem) {
627
561
  // removeAllChosenItems();
628
562
  // attachedRef.current.querySelectorAll('.chosen').forEach(itemEl => {
629
563
  // itemEl.classList.remove('chosen');
@@ -639,22 +573,23 @@ const Attachment = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
639
573
  prevent = false;
640
574
  }, 110);
641
575
  };
642
-
643
576
  const onDownload = (url, name) => {
644
577
  if (!url) return;
645
578
  fetch(url).then(resp => resp.blob()).then(blob => {
646
579
  const url = window.URL.createObjectURL(blob);
647
580
  const a = document.createElement('a');
648
581
  a.style.display = 'none';
649
- a.href = url; // the filename you want
650
-
582
+ a.href = url;
583
+ // the filename you want
651
584
  a.download = name;
652
585
  document.body.appendChild(a);
653
586
  a.click();
654
587
  window.URL.revokeObjectURL(url);
655
588
  }).catch(() => alert('File not found'));
656
589
  if (onDownloadProp) onDownloadProp(url);
657
- }; // const onRemove = (e, AttachmentID='') => {
590
+ };
591
+
592
+ // const onRemove = (e, AttachmentID='') => {
658
593
  // const parent = e.currentTarget.parentNode.parentNode.parentNode;
659
594
  // const index = Array.from(attachedRef.current.children).indexOf(parent);
660
595
  // attached.splice(index, 1);
@@ -670,16 +605,13 @@ const Attachment = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
670
605
  // if (onRemoveItem) onRemoveItem({index, element: parent, oldAttached, allNewAttached: allNewAttached.getAll('files'), AttachmentID});
671
606
  // }
672
607
 
673
-
674
608
  const removeFileOutInputFiles = (index, keeping) => {
675
609
  const dt = new DataTransfer();
676
-
677
610
  for (let file of attachmentInputRef.current.files) {
678
611
  if (file !== attachmentInputRef.current.files[index]) {
679
612
  dt.items.add(file);
680
613
  }
681
614
  }
682
-
683
615
  if (!keeping) {
684
616
  const files = allNewAttached.getAll('files');
685
617
  files.splice(index, 1);
@@ -687,11 +619,9 @@ const Attachment = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
687
619
  files.forEach(file => allNewAttached.append('files', file));
688
620
  newAttachedRef.current = files || [];
689
621
  }
690
-
691
622
  attachmentInputRef.current.files = dt.files;
692
623
  return dt.files;
693
624
  };
694
-
695
625
  const insertAttached = files => {
696
626
  if (multiple || inputProps && inputProps.multiple) {
697
627
  for (let file of files) {
@@ -702,51 +632,40 @@ const Attachment = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
702
632
  allNewAttached.delete('files');
703
633
  allNewAttached.append('files', files[0]);
704
634
  newAttachedRef.current = [files[0]];
705
- } // attachmentInputRef.current.files = allNewAttached.getAll('files');
706
-
635
+ }
636
+ // attachmentInputRef.current.files = allNewAttached.getAll('files');
707
637
  };
708
638
 
709
639
  const checkExistingFile = newFile => {
710
640
  const files = allNewAttached.getAll('files');
711
-
712
641
  if (files && files.length) {
713
642
  const length = files.length;
714
-
715
643
  for (let i = 0; i < length; i++) {
716
644
  if (parseStringify(newFile) === parseStringify(files[i])) return true;
717
645
  }
718
646
  }
719
-
720
647
  return false;
721
648
  };
722
-
723
649
  const checkExistingFileInData = newFile => {
724
650
  const files = data;
725
-
726
651
  if (files && files.length) {
727
652
  const length = files.length;
728
-
729
653
  for (let i = 0; i < length; i++) {
730
654
  if (parseStringify2(newFile) === parseStringify2(files[i], true)) return true;
731
655
  }
732
656
  }
733
-
734
657
  return false;
735
658
  };
736
-
737
659
  const checkAcceptFileType = newFile => {
738
660
  if (!accept || !accept.length) return true;
739
661
  const type = typeof accept === 'string' ? accept : accept.join('-');
740
-
741
662
  if (typeof accept === 'string') {
742
663
  const acceptType = type.replace('/*', '');
743
664
  return newFile.type.includes(acceptType);
744
665
  }
745
-
746
666
  const extFile = newFile.name.slice(newFile.name.lastIndexOf('.') + 1);
747
667
  return accept.join('-').includes(extFile);
748
668
  };
749
-
750
669
  const onChooseItem = e => {
751
670
  const ctrlKey = e.ctrlKey;
752
671
  const shiftKey = e.shiftKey;
@@ -754,29 +673,24 @@ const Attachment = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
754
673
  timer = setTimeout(() => {
755
674
  if (!prevent) {
756
675
  const index = Array.from(attachedRef.current.children).indexOf(itemEl.parentNode);
757
-
758
676
  if (shiftKey && !ctrlKey) {
759
677
  let startIndex = chosenItems[chosenItems.length - 1] || 0;
760
678
  let endIndex = index;
761
-
762
679
  if (startIndex > endIndex) {
763
680
  endIndex = startIndex;
764
681
  startIndex = index;
765
682
  }
766
-
767
683
  chosenItems.length = 0;
768
684
  attachedRef.current.querySelectorAll(`.css-${AttachedItemCSS.name}`).forEach((itemEl, indexEl) => {
769
685
  if (startIndex <= indexEl && indexEl <= endIndex) {
770
686
  if (!itemEl.classList.contains('chosen')) {
771
687
  itemEl.classList.add('chosen');
772
688
  }
773
-
774
689
  chosenItems.push(indexEl);
775
690
  } else if (itemEl.classList.contains('chosen')) {
776
691
  itemEl.classList.remove('chosen');
777
692
  }
778
693
  });
779
-
780
694
  if (chosenItems[chosenItems.length - 1] !== index) {
781
695
  chosenItems.shift();
782
696
  chosenItems.push(index);
@@ -789,7 +703,6 @@ const Attachment = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
789
703
  } else if (itemEl.classList.contains('chosen')) {
790
704
  chosenItems.splice(chosenItems.indexOf(index));
791
705
  itemEl.classList.remove('chosen');
792
-
793
706
  if (!chosenItems.length) {
794
707
  setTimeout(() => {
795
708
  removeAllChosenItems();
@@ -798,32 +711,26 @@ const Attachment = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
798
711
  } else {
799
712
  chosenItems.push(index);
800
713
  itemEl.classList.add('chosen');
801
- } // Add event listener click out of item
802
-
803
-
714
+ }
715
+ // Add event listener click out of item
804
716
  if (!existClickOutOfItem) {
805
717
  existClickOutOfItem = true;
806
718
  attachmentHandleIconRef.current.style.display = 'block';
807
719
  document.addEventListener('keydown', onKeyDown);
808
720
  document.addEventListener('click', clickOutOfItem);
809
721
  }
810
-
811
722
  checkChosenMultiple();
812
723
  }
813
-
814
724
  prevent = false;
815
725
  }, 100);
816
726
  };
817
-
818
727
  const removeActiveChosenItem = () => {
819
728
  attachedRef.current.querySelectorAll('.chosen').forEach(itemEl => {
820
729
  itemEl.classList.remove('chosen');
821
730
  });
822
731
  };
823
-
824
732
  const checkChosenMultiple = () => {
825
733
  const actionIcons = attachmentHandleIconRef.current.childNodes;
826
-
827
734
  if (chosenItems.length > 1 && actionIcons[0].style.display !== 'none') {
828
735
  actionIcons[0].style.display = 'none';
829
736
  actionIcons[1].style.display = 'none';
@@ -832,10 +739,8 @@ const Attachment = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
832
739
  actionIcons[1].style.display = null;
833
740
  }
834
741
  };
835
-
836
742
  const onKeyDown = event => {
837
743
  const key = event.key;
838
-
839
744
  if (key === 'Delete') {
840
745
  // Press Delete key to delete item(s)
841
746
  onShowPopup();
@@ -846,11 +751,9 @@ const Attachment = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
846
751
  } else if (/a/i.test(key) && event.ctrlKey) {
847
752
  chosenItems.length = 0;
848
753
  const allAttachEl = attachedRef.current.querySelectorAll('.attachment-row');
849
-
850
754
  if (allAttachEl && allAttachEl.length) {
851
755
  allAttachEl.forEach((attachEl, index) => chosenItems.push(index) & attachEl.firstChild.classList.add('chosen'));
852
756
  }
853
-
854
757
  event.preventDefault();
855
758
  return false;
856
759
  } else if (/Arrow/.test(key)) {
@@ -860,7 +763,6 @@ const Attachment = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
860
763
  const chosenItemsNode = Array.from(itemsNode).filter(el => el.firstChild.classList.contains('chosen'));
861
764
  const length = itemsNode.length;
862
765
  let index;
863
-
864
766
  if (key === 'ArrowDown' || key === 'ArrowRight') {
865
767
  for (let id = length - 1; id >= 0; id--) {
866
768
  if (Array.from(itemsNode)[id].firstChild.classList.contains('chosen')) {
@@ -868,7 +770,6 @@ const Attachment = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
868
770
  break;
869
771
  }
870
772
  }
871
-
872
773
  if (index === length - 1) {
873
774
  if (chosenItemsNode.length !== 1 && !event.shiftKey) {
874
775
  chosenItemsNode.forEach((node, i) => {
@@ -883,26 +784,21 @@ const Attachment = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
883
784
  behavior: 'smooth'
884
785
  });
885
786
  }
886
-
887
787
  return;
888
788
  }
889
-
890
789
  Array.from(itemsNode)[index + 1].scrollIntoView({
891
790
  block: 'center',
892
791
  behavior: 'smooth'
893
792
  });
894
-
895
793
  if (!event.shiftKey) {
896
794
  itemsNode.forEach(node => {
897
795
  node.firstChild.classList.remove('chosen');
898
796
  });
899
797
  }
900
-
901
798
  itemsNode[index + 1].firstChild.classList.add('chosen');
902
799
  chosenItems.push(index + 1);
903
800
  } else if (key === 'ArrowUp' || key === 'ArrowLeft') {
904
801
  index = Array.from(itemsNode).findIndex(el => el.firstChild.classList.contains('chosen'));
905
-
906
802
  if (index === 0) {
907
803
  if (chosenItemsNode.length !== 1 && !event.shiftKey) {
908
804
  chosenItemsNode.forEach((node, i) => {
@@ -917,46 +813,37 @@ const Attachment = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
917
813
  behavior: 'smooth'
918
814
  });
919
815
  }
920
-
921
816
  return;
922
817
  }
923
-
924
818
  Array.from(itemsNode)[index - 1].scrollIntoView({
925
819
  block: 'center',
926
820
  behavior: 'smooth'
927
821
  });
928
-
929
822
  if (!event.shiftKey) {
930
823
  chosenItemsNode.forEach(node => {
931
824
  node.firstChild.classList.remove('chosen');
932
825
  });
933
826
  }
934
-
935
827
  itemsNode[index - 1].firstChild.classList.add('chosen');
936
828
  chosenItems.push(index - 1);
937
829
  }
938
-
939
830
  if (!event.shiftKey) {
940
831
  chosenItems.length = 1;
941
832
  }
942
833
  }
943
834
  };
944
-
945
835
  const clickOutOfItem = e => {
946
836
  var _popupRef$current, _popupRef$current$sty;
947
-
948
837
  if (!attachedRef || !attachedRef.current) {
949
838
  document.removeEventListener('keydown', onKeyDown);
950
839
  document.removeEventListener('click', clickOutOfItem);
951
840
  return;
952
841
  }
953
-
954
842
  if (!(attachedRef.current.contains(e.target) && attachedRef.current !== e.target) && !attachmentHandleIconRef.current.contains(e.target) && !isDeleteAll.current && (((_popupRef$current = popupRef.current) === null || _popupRef$current === void 0 ? void 0 : (_popupRef$current$sty = _popupRef$current.style) === null || _popupRef$current$sty === void 0 ? void 0 : _popupRef$current$sty.display) !== 'flex' || popupRef.current.querySelector('button.filled.info').contains(e.target))) {
955
843
  removeAllChosenItems();
956
844
  removeActiveChosenItem();
957
845
  }
958
846
  };
959
-
960
847
  const removeAllChosenItems = () => {
961
848
  chosenItems.length = 0;
962
849
  existClickOutOfItem = false;
@@ -964,7 +851,6 @@ const Attachment = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
964
851
  document.removeEventListener('keydown', onKeyDown);
965
852
  document.removeEventListener('click', clickOutOfItem);
966
853
  };
967
-
968
854
  const parseStringify = fileInfo => JSON.stringify({
969
855
  lastModified: fileInfo.lastModified,
970
856
  lastModifiedDate: fileInfo.lastModifiedDate,
@@ -973,57 +859,46 @@ const Attachment = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
973
859
  type: fileInfo.type,
974
860
  webkitRelativePath: fileInfo.webkitRelativePath
975
861
  });
976
-
977
862
  const parseStringify2 = (fileInfo, inData) => JSON.stringify({
978
863
  name: fileInfo === null || fileInfo === void 0 ? void 0 : fileInfo[inData ? 'FileName' : 'name'],
979
864
  size: fileInfo === null || fileInfo === void 0 ? void 0 : fileInfo[inData ? 'FileSize' : 'size']
980
865
  });
981
-
982
866
  const mountDomain = item => {
983
867
  if (!item) return item;
984
868
  const cloneItem = JSON.parse(JSON.stringify(item));
985
-
986
869
  if (domain) {
987
870
  if (!/\/$/.test(domain)) {
988
871
  domain = domain + '/';
989
872
  }
990
-
991
873
  if (cloneItem !== null && cloneItem !== void 0 && cloneItem.URL) {
992
874
  cloneItem.URL = cloneItem.URL.indexOf('http') < 0 ? domain + cloneItem.URL : cloneItem.URL;
993
875
  }
994
876
  }
995
-
996
877
  return cloneItem;
997
878
  };
998
-
999
879
  const stripDomain = () => {
1000
880
  if (isStripDomain && domain) {
1001
881
  const re = new RegExp(domain + '/?');
1002
882
  attached.forEach(item => {
1003
883
  var _item$URL;
1004
-
1005
884
  item.URL = (item === null || item === void 0 ? void 0 : (_item$URL = item.URL) === null || _item$URL === void 0 ? void 0 : _item$URL.replace(re, '')) || '';
1006
885
  });
1007
886
  oldAttached.forEach(item => {
1008
887
  var _item$URL2;
1009
-
1010
888
  item.URL = (item === null || item === void 0 ? void 0 : (_item$URL2 = item.URL) === null || _item$URL2 === void 0 ? void 0 : _item$URL2.replace(re, '')) || '';
1011
889
  });
1012
890
  }
1013
891
  };
1014
-
1015
892
  useEffect(() => {
1016
893
  if (attached.length) {
1017
894
  attached.length = 0;
1018
895
  }
1019
-
1020
896
  return () => {
1021
897
  existClickOutOfItem = false;
1022
898
  };
1023
899
  }, []);
1024
900
  useEffect(() => {
1025
901
  let el = null;
1026
-
1027
902
  if (error) {
1028
903
  attachTextRef.current.style.color = danger;
1029
904
  ref.current.style.borderColor = danger;
@@ -1032,13 +907,11 @@ const Attachment = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
1032
907
  el.innerHTML = error;
1033
908
  attachTextRef.current.parentNode.insertAdjacentElement('afterend', el);
1034
909
  }
1035
-
1036
910
  return () => {
1037
911
  if (attachTextRef.current && ref.current) {
1038
912
  attachTextRef.current.style.color = null;
1039
913
  ref.current.style.borderColor = null;
1040
914
  }
1041
-
1042
915
  if (el) {
1043
916
  el.remove();
1044
917
  }
@@ -1058,28 +931,22 @@ const Attachment = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
1058
931
  case /^B$/i.test(unitSize):
1059
932
  divideSize = 1;
1060
933
  break;
1061
-
1062
934
  case /KB/i.test(unitSize):
1063
935
  divideSize = 1024;
1064
936
  break;
1065
-
1066
937
  case /MB/i.test(unitSize):
1067
938
  divideSize = 1024 ** 2;
1068
939
  break;
1069
-
1070
940
  case /GB/i.test(unitSize):
1071
941
  divideSize = 1024 ** 3;
1072
942
  break;
1073
-
1074
943
  case /TB/i.test(unitSize):
1075
944
  divideSize = 1024 ** 4;
1076
945
  break;
1077
-
1078
946
  default:
1079
947
  divideSize = null;
1080
948
  break;
1081
949
  }
1082
-
1083
950
  attachmentInputRef.current.addEventListener('change', onChangeFiles);
1084
951
  return () => {
1085
952
  attachmentInputRef.current && attachmentInputRef.current.removeEventListener('change', onChangeFiles);
@@ -1095,57 +962,45 @@ const Attachment = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
1095
962
  maxSize = getBit(numberSize, unitMaxSize);
1096
963
  }
1097
964
  }
1098
-
1099
965
  attachmentInputRef.current.multiple = multiple;
1100
-
1101
966
  if (accept && typeof accept === 'string') {
1102
967
  attachmentInputRef.current.accept = `${accept}/*`.replace('/*/*', '/*');
1103
968
  }
1104
-
1105
969
  attachmentInputRef.current.addEventListener('change', onChangeFiles);
1106
970
  return () => {
1107
971
  if (attachmentInputRef.current) {
1108
972
  attachmentInputRef.current.removeEventListener('change', onChangeFiles);
1109
973
  attachmentInputRef.current.accept = null;
1110
974
  }
1111
-
1112
975
  maxSize = Infinity;
1113
976
  };
1114
977
  }, [maxFile, maxSizeProp, multiple, accept]);
1115
978
  useEffect(() => {
1116
979
  var _newAttachedRef$curre;
1117
-
1118
980
  oldAttached.length = 0;
1119
981
  afterChangeFile(((data === null || data === void 0 ? void 0 : data.length) || 0) + (((_newAttachedRef$curre = newAttachedRef.current) === null || _newAttachedRef$curre === void 0 ? void 0 : _newAttachedRef$curre.length) || 0));
1120
-
1121
982
  if (data) {
1122
983
  // Load files data was uploaded
1123
984
  const length = data.length;
1124
-
1125
985
  for (let i = 0; i < length; i++) {
1126
986
  const item = mountDomain(data[i]);
1127
987
  const newAttach = getItemHTMLFromData(item, i);
1128
-
1129
988
  if (Object.prototype.toString.call(item) === '[object File]') {
1130
989
  allNewAttached.append('files', item);
1131
990
  newAttachedRef.current.push(item);
1132
991
  } else {
1133
992
  oldAttached.push(item);
1134
993
  }
1135
-
1136
994
  attached.push(item);
1137
995
  const newElement = document.createElement('div');
1138
996
  newElement.className = 'attachment-row';
1139
997
  ReactDOM.render(newAttach, attachedRef.current.appendChild(newElement));
1140
998
  }
1141
999
  }
1142
-
1143
1000
  if (newAttachedRef.current) {
1144
1001
  const length = newAttachedRef.current.length;
1145
-
1146
1002
  for (let i = length - 1; i >= 0; i--) {
1147
1003
  const item = newAttachedRef.current[i];
1148
-
1149
1004
  if (checkExistingFileInData(item)) {
1150
1005
  newAttachedRef.current.splice(i, 1);
1151
1006
  } else {
@@ -1158,17 +1013,14 @@ const Attachment = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
1158
1013
  }
1159
1014
  }
1160
1015
  }
1161
-
1162
1016
  return () => {
1163
1017
  if (attachedRef.current) {
1164
1018
  attachedRef.current.innerHTML = null;
1165
1019
  }
1166
-
1167
1020
  oldAttached.length = 0;
1168
1021
  attached.length = 0;
1169
1022
  chosenItems.length = 0;
1170
1023
  allNewAttached.delete('files');
1171
-
1172
1024
  if (attachmentInputRef.current) {
1173
1025
  attachmentInputRef.current.value = '';
1174
1026
  }
@@ -1196,21 +1048,18 @@ const Attachment = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
1196
1048
  };
1197
1049
  }
1198
1050
  }, [inputProps]);
1199
-
1200
1051
  const triggerClickInput = () => {
1201
1052
  attachmentInputRef.current.click();
1202
1053
  };
1203
-
1204
1054
  const onDragFileStart = () => {
1205
1055
  attachmentInputRef.current.parentNode.style.display = 'block';
1206
1056
  };
1207
-
1208
1057
  const onDropInput = () => {
1209
1058
  attachmentInputRef.current.parentNode.style.display = null;
1210
- }; // End handler
1211
- // Start view
1212
-
1059
+ };
1060
+ // End handler
1213
1061
 
1062
+ // Start view
1214
1063
  const AttachHeaderView = useMemo(() => jsx("div", {
1215
1064
  css: AttachmentHeaderCSS,
1216
1065
  className: 'DGN-UI-Attachment-Header'
@@ -1355,8 +1204,8 @@ const Attachment = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
1355
1204
  const ModalView = useMemo(() => {
1356
1205
  if (!chosenItems.length) return setOpen(false);
1357
1206
  const index = chosenItems[0];
1358
- const data = mountDomain(attached[index]); // let data = oldAttached[index] || allNewAttached.getAll('files')[index-oldAttached.length];
1359
-
1207
+ const data = mountDomain(attached[index]);
1208
+ // let data = oldAttached[index] || allNewAttached.getAll('files')[index-oldAttached.length];
1360
1209
  return jsx(ModalSample, {
1361
1210
  open: open,
1362
1211
  title: data.FileName,
@@ -1364,7 +1213,8 @@ const Attachment = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
1364
1213
  }, jsx(Slider, null, jsx(SliderItem, {
1365
1214
  url: data.URL
1366
1215
  })));
1367
- }, [domain, open]); // End view
1216
+ }, [domain, open]);
1217
+ // End view
1368
1218
 
1369
1219
  useImperativeHandle(reference, () => {
1370
1220
  stripDomain();
@@ -1377,16 +1227,12 @@ const Attachment = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
1377
1227
  clear: confirmPopup => clearAllAttached(confirmPopup),
1378
1228
  openFileDialog: triggerClickInput
1379
1229
  }; // methods
1380
-
1381
1230
  _instance.__proto__ = {}; // hidden methods
1382
-
1383
1231
  currentRef.instance = _instance;
1384
1232
  currentRef.oldAttached = oldAttached;
1385
1233
  currentRef.allNewAttached = allNewAttached;
1386
1234
  currentRef.attached = attached;
1387
-
1388
1235
  currentRef.clear = confirmPopup => clearAllAttached(confirmPopup);
1389
-
1390
1236
  currentRef.openFileDialog = triggerClickInput;
1391
1237
  return currentRef;
1392
1238
  });
@@ -1784,13 +1630,10 @@ Attachment.defaultProps = {
1784
1630
  Attachment.propTypes = {
1785
1631
  /** File types that can be accepted. */
1786
1632
  accept: PropTypes.oneOfType([PropTypes.string, PropTypes.array]),
1787
-
1788
1633
  /** If `true`, allow sort. */
1789
1634
  allowSort: PropTypes.bool,
1790
-
1791
1635
  /** Class for component. */
1792
1636
  className: PropTypes.string,
1793
-
1794
1637
  /** List attachment:<br />
1795
1638
  * [{<br />
1796
1639
  * &nbsp;&nbsp;&nbsp;&nbsp;"AttachmentID": "ATT2U8O7YPTF1KSNCW3X",<br />
@@ -1804,46 +1647,32 @@ Attachment.propTypes = {
1804
1647
  * }, ...]
1805
1648
  */
1806
1649
  data: PropTypes.array,
1807
-
1808
1650
  /** The message to display when deleting files. */
1809
1651
  deleteNotifyText: PropTypes.string,
1810
-
1811
1652
  /** If `true`, the component is disabled. */
1812
1653
  disabled: PropTypes.bool,
1813
-
1814
1654
  /** Domain of attachments. */
1815
1655
  domain: PropTypes.string,
1816
-
1817
1656
  /** Error of attachment. */
1818
1657
  error: PropTypes.string,
1819
-
1820
1658
  /** Suggested passage attached. */
1821
1659
  hintText: PropTypes.string,
1822
-
1823
1660
  /** [Attributes](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#attributes) applied to the input element. */
1824
1661
  inputProps: PropTypes.object,
1825
-
1826
1662
  /** If `true`, strip domain of attachments. */
1827
1663
  isStripDomain: PropTypes.bool,
1828
-
1829
1664
  /** Label of the component. */
1830
1665
  label: PropTypes.string,
1831
-
1832
1666
  /** Limit the number of uploaded files. */
1833
1667
  maxFile: PropTypes.number,
1834
-
1835
1668
  /** Limit the size of uploaded files. */
1836
1669
  maxSize: PropTypes.string,
1837
-
1838
1670
  /** Allows to attach multiple files. */
1839
1671
  multiple: PropTypes.bool,
1840
-
1841
1672
  /** Callback fired when the files attached is changed. */
1842
1673
  onChange: PropTypes.func,
1843
-
1844
1674
  /** Download attached event, if not it will use default. */
1845
1675
  onDownload: PropTypes.func,
1846
-
1847
1676
  /**
1848
1677
  * event when removed file(s)
1849
1678
  *
@@ -1856,25 +1685,18 @@ Attachment.propTypes = {
1856
1685
  * }
1857
1686
  */
1858
1687
  onRemove: PropTypes.func,
1859
-
1860
1688
  /** View attached event, if not it will use default. */
1861
1689
  onView: PropTypes.func,
1862
-
1863
1690
  /** Name of the person who attached the file when uploading the file. */
1864
1691
  ownerName: PropTypes.string,
1865
-
1866
1692
  /** If `true`, the component is readOnly. */
1867
1693
  readOnly: PropTypes.bool,
1868
-
1869
1694
  /** At least one attachment is required. */
1870
1695
  required: PropTypes.bool,
1871
-
1872
1696
  /** Style inline of component. */
1873
1697
  style: PropTypes.object,
1874
-
1875
1698
  /** Errors show up when the file upload is corrupted. */
1876
1699
  uploadErrorInfo: PropTypes.object,
1877
-
1878
1700
  /** The view type of files. */
1879
1701
  viewType: PropTypes.oneOf(['detail', 'icon'])
1880
1702
  };