diginet-core-ui 1.3.96 → 1.3.97-beta.2

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.
Binary file
@@ -87,27 +87,24 @@ const Breadcrumb = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
87
87
  // <ButtonIcon key="ellipsis" name={'MoreHoriz'} width={24} height={16} onClick={handleClickExpand} />,
88
88
  ...allItems.slice(allItems.length - itemsAfterCollapse, allItems.length)];
89
89
  };
90
- const allItems = data !== null && data !== void 0 && data.length ? data.map((item, idx) => {
91
- var _item$onClick2;
92
- return jsx("li", {
93
- css: _BreadcrumbLiCSS,
94
- className: 'DGN-UI-Breadcrumb-li',
95
- key: `child-${idx}`
96
- }, item !== null && item !== void 0 && item.icon ? jsx(Icon, {
97
- className: 'DGN-UI-Breadcrumb-li-icon',
98
- name: item === null || item === void 0 ? void 0 : item.icon,
99
- color: color,
100
- width: sizeIcon,
101
- height: sizeIcon
102
- }) : null, jsx(Typography, {
103
- className: 'DGN-UI-Breadcrumb-li-label',
104
- type: (data === null || data === void 0 ? void 0 : data.length) === idx + 1 ? sizeTypographyH : sizeTypographyP,
105
- mapping: 'a',
106
- color: 'currentColor',
107
- href: item === null || item === void 0 ? void 0 : item.href,
108
- onClick: item === null || item === void 0 ? void 0 : (_item$onClick2 = item.onClick) === null || _item$onClick2 === void 0 ? void 0 : _item$onClick2.call(item)
109
- }, (item === null || item === void 0 ? void 0 : item.label) || (item === null || item === void 0 ? void 0 : item.name)), (data === null || data === void 0 ? void 0 : data.length) !== idx + 1 ? renderSeparator : null);
110
- }) : React.Children.toArray(children).filter(child => {
90
+ const allItems = data !== null && data !== void 0 && data.length ? data.map((item, idx) => jsx("li", {
91
+ css: _BreadcrumbLiCSS,
92
+ className: 'DGN-UI-Breadcrumb-li',
93
+ key: `child-${idx}`
94
+ }, item !== null && item !== void 0 && item.icon ? jsx(Icon, {
95
+ className: 'DGN-UI-Breadcrumb-li-icon',
96
+ name: item === null || item === void 0 ? void 0 : item.icon,
97
+ color: color,
98
+ width: sizeIcon,
99
+ height: sizeIcon
100
+ }) : null, jsx(Typography, {
101
+ className: 'DGN-UI-Breadcrumb-li-label',
102
+ type: (data === null || data === void 0 ? void 0 : data.length) === idx + 1 ? sizeTypographyH : sizeTypographyP,
103
+ mapping: 'a',
104
+ color: 'currentColor',
105
+ href: item === null || item === void 0 ? void 0 : item.href,
106
+ onClick: item === null || item === void 0 ? void 0 : item.onClick
107
+ }, (item === null || item === void 0 ? void 0 : item.label) || (item === null || item === void 0 ? void 0 : item.name)), (data === null || data === void 0 ? void 0 : data.length) !== idx + 1 ? renderSeparator : null)) : React.Children.toArray(children).filter(child => {
111
108
  return /*#__PURE__*/React.isValidElement(child);
112
109
  }).map((child, idx) => {
113
110
  var _React$Children$toArr;
@@ -184,6 +181,7 @@ Breadcrumb.propTypes = {
184
181
  /** Class for component. */
185
182
  data: PropTypes.arrayOf(PropTypes.shape({
186
183
  label: PropTypes.string,
184
+ icon: PropTypes.string,
187
185
  href: PropTypes.string,
188
186
  onClick: PropTypes.func
189
187
  })),
@@ -48,7 +48,7 @@ const icons = {
48
48
  };
49
49
  const oldAttached = [];
50
50
  const allNewAttached = new FormData();
51
- const attached = [];
51
+ const attached = []; // attached = [...dataState, ...newDataState]
52
52
  const chosenItems = [];
53
53
  const getType = data => {
54
54
  if (data.type !== undefined) {
@@ -155,10 +155,10 @@ const Attachment = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
155
155
  const [showModal, setShowModal] = useState(false);
156
156
  const [showPopup, setShowPopup] = useState(false);
157
157
  const [viewTypeState, setViewTypeState] = useState(viewType);
158
- const [isEmpty, setIsEmpty] = useState(null);
159
158
  const [newDataState, setNewDataState] = useState([]);
160
159
  const [dataState, setDataState] = useState([]);
161
160
  const isEnable = !readOnly && !disabled;
161
+ const isEmpty = !((dataState === null || dataState === void 0 ? void 0 : dataState.length) + (newDataState === null || newDataState === void 0 ? void 0 : newDataState.length));
162
162
  const _AttachmentRootCSS = AttachmentRootCSS(isEmpty, isEnable);
163
163
 
164
164
  // Start handler
@@ -222,9 +222,11 @@ const Attachment = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
222
222
  attachedRef.current.appendChild(el);
223
223
  });
224
224
  };
225
- const afterChangeFile = (length = 0) => {
226
- setIsEmpty(!length);
227
- };
225
+
226
+ // const afterChangeFile = (length = 0) => {
227
+ // setIsEmpty(!length);
228
+ // };
229
+
228
230
  const onChangeFiles = async e => {
229
231
  var _e$target, _e$target$files;
230
232
  if (!isEnable) return;
@@ -253,10 +255,10 @@ const Attachment = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
253
255
  }
254
256
  const length = files.length;
255
257
  if (!lengthAttached && !length) {
256
- afterChangeFile();
258
+ // afterChangeFile();
257
259
  return;
258
260
  }
259
- afterChangeFile(lengthAttached + length);
261
+ // afterChangeFile(lengthAttached + length);
260
262
  if (multiple || inputProps && inputProps.multiple) {
261
263
  for (let i = 0; i < length; i++) {
262
264
  files[i].FileName = files[i].name;
@@ -281,10 +283,12 @@ const Attachment = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
281
283
  newAttached: files,
282
284
  allNewAttached: allNewAttached.getAll('files')
283
285
  });
284
- } else if (!attached.length) {
285
- afterChangeFile();
286
286
  }
287
+ // else if (!attached.length) {
288
+ // afterChangeFile();
289
+ // }
287
290
  };
291
+
288
292
  const onProgressing = file => {
289
293
  return new Promise((resolve, reject) => {
290
294
  const reader = new FileReader();
@@ -357,28 +361,35 @@ const Attachment = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
357
361
  }
358
362
  };
359
363
  const onRemoveMultiple = () => {
364
+ const attachedItems = [...dataState, ...newDataState];
360
365
  const nodeList = attachedRef.current.querySelectorAll('.chosen');
361
366
  const recentRemovedAttached = [];
367
+ const tempDataState = [...dataState];
368
+ const tempNewDataState = [...newDataState];
362
369
  nodeList.forEach(itemEl => {
363
370
  const parent = itemEl.parentNode;
364
371
  const index = Array.from(attachedRef.current.children).indexOf(parent);
365
- const deletedFile = attached.splice(index, 1)[0];
372
+ const deletedFile = attachedItems[index];
366
373
  removedAttachedRef.current.push(deletedFile);
367
374
  recentRemovedAttached.push(deletedFile);
368
- if (Object.prototype.toString.call(deletedFile) === '[object File]' && newDataState !== null && newDataState !== void 0 && newDataState.length) {
369
- removeFileOutInputFiles(allNewAttached.getAll('files').findIndex(attach => attach.FileName === deletedFile.FileName && attach.CreateDate === deletedFile.CreateDate));
375
+ if (Object.prototype.toString.call(deletedFile) === '[object File]' && tempNewDataState !== null && tempNewDataState !== void 0 && tempNewDataState.length) {
376
+ removeFileOutInputFiles(tempNewDataState.findIndex(attach => (attach === null || attach === void 0 ? void 0 : attach.FileName) === (deletedFile === null || deletedFile === void 0 ? void 0 : deletedFile.FileName) && (attach === null || attach === void 0 ? void 0 : attach.CreateDate) === (deletedFile === null || deletedFile === void 0 ? void 0 : deletedFile.CreateDate)));
377
+ tempNewDataState.splice(tempNewDataState.findIndex(attach => (attach === null || attach === void 0 ? void 0 : attach.FileName) === (deletedFile === null || deletedFile === void 0 ? void 0 : deletedFile.FileName) && (attach === null || attach === void 0 ? void 0 : attach.CreateDate) === (deletedFile === null || deletedFile === void 0 ? void 0 : deletedFile.CreateDate)), 1);
378
+ setNewDataState(tempNewDataState);
370
379
  } else {
371
- oldAttached.splice(oldAttached.findIndex(attach => attach.FileName === deletedFile.FileName && attach.CreateDate === deletedFile.CreateDate), 1);
372
- setDataState(dataState.filter(attach => attach.FileName !== deletedFile.FileName && attach.CreateDate !== deletedFile.CreateDate));
380
+ oldAttached.splice(oldAttached.findIndex(attach => (attach === null || attach === void 0 ? void 0 : attach.FileName) === (deletedFile === null || deletedFile === void 0 ? void 0 : deletedFile.FileName) && (attach === null || attach === void 0 ? void 0 : attach.CreateDate) === (deletedFile === null || deletedFile === void 0 ? void 0 : deletedFile.CreateDate)), 1);
381
+ tempDataState.splice(tempDataState.findIndex(attach => (attach === null || attach === void 0 ? void 0 : attach.FileName) === (deletedFile === null || deletedFile === void 0 ? void 0 : deletedFile.FileName) && (attach === null || attach === void 0 ? void 0 : attach.CreateDate) === (deletedFile === null || deletedFile === void 0 ? void 0 : deletedFile.CreateDate)), 1);
382
+ setDataState(tempDataState);
373
383
  }
374
384
  });
375
- if (attached.length < 2) {
376
- afterChangeFile(attached.length);
377
- }
385
+ const tempAttachedItems = [...tempDataState, ...tempNewDataState];
386
+ // if (tempAttachedItems.length < 2) {
387
+ // afterChangeFile(tempAttachedItems?.length || 0);
388
+ // }
378
389
  stripDomain();
379
390
  if (onChange) onChange({
380
391
  element: nodeList,
381
- attached,
392
+ attached: tempAttachedItems,
382
393
  recentRemovedAttached,
383
394
  removedAttached: removedAttachedRef.current,
384
395
  oldAttached,
@@ -442,8 +453,9 @@ const Attachment = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
442
453
  allNewAttached.delete('files');
443
454
  files.forEach(file => allNewAttached.append('files', file));
444
455
  // newAttachedRef.current = files || [];
445
- setNewDataState(files || []);
456
+ // setNewDataState(files || []);
446
457
  }
458
+
447
459
  attachmentInputRef.current.files = dt.files;
448
460
  return dt.files;
449
461
  };
@@ -735,7 +747,7 @@ const Attachment = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
735
747
  }, [maxFile, maxSizeProp, multiple, accept]);
736
748
  useEffect(() => {
737
749
  oldAttached.length = 0;
738
- afterChangeFile(((data === null || data === void 0 ? void 0 : data.length) || 0) + ((newDataState === null || newDataState === void 0 ? void 0 : newDataState.length) || 0));
750
+ // afterChangeFile((data?.length || 0) + (newDataState?.length || 0));
739
751
  if (data) {
740
752
  // Load files data was uploaded
741
753
  const length = data.length;
@@ -830,7 +842,7 @@ const Attachment = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
830
842
  uppercase: true,
831
843
  required: required,
832
844
  type: 'h5',
833
- color: 'text.sub',
845
+ color: 'text/sub',
834
846
  ref: attachTextRef
835
847
  }, label), error ? jsx(HelperText, null, error) : null), jsx("div", {
836
848
  css: AttachmentHeaderIconCSS
@@ -868,11 +880,11 @@ const Attachment = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
868
880
  }), isEmpty ? jsx(Typography, {
869
881
  css: userSelectNone,
870
882
  type: 'p3',
871
- color: 'system.rest'
883
+ color: 'system/rest'
872
884
  }, hintText) : null) : isEmpty ? jsx(Typography, {
873
885
  css: userSelectNone,
874
886
  type: 'p3',
875
- color: 'system.rest'
887
+ color: 'system/rest'
876
888
  }, getGlobal('noFileText')) : null)), allowSort && !isEmpty ? jsx(Popover, {
877
889
  ref: popoverRef,
878
890
  anchor: jsx(ButtonIcon, {
@@ -958,15 +970,15 @@ const Attachment = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
958
970
  }, jsx(Typography, {
959
971
  className: 'username',
960
972
  type: 'p2',
961
- color: 'text.sub'
973
+ color: 'text/sub'
962
974
  }, (item === null || item === void 0 ? void 0 : item.UserName) || item.lastModifiedDate && ownerName || ''), jsx(Typography, {
963
975
  className: 'datetime',
964
976
  type: 'p2',
965
- color: 'text.sub'
977
+ color: 'text/sub'
966
978
  }, getDateTime(date)), jsx(Typography, {
967
979
  className: 'filesize',
968
980
  type: 'p2',
969
- color: 'text.sub'
981
+ color: 'text/sub'
970
982
  }, calculateSize(item.FileSize || item.size))) : null, isNew ? jsx("span", {
971
983
  css: AttachedLinearCSS
972
984
  }, jsx(LinearProgress, {
@@ -1108,9 +1120,9 @@ const AttachedItemInfoIconCSS = css`
1108
1120
  ${positionAbsolute};
1109
1121
  ${borderRadius50};
1110
1122
  ${parseWidthHeight(4, 4)};
1111
- ${bgColor('semantic.success')};
1123
+ ${bgColor('semantic/success')};
1112
1124
  ${top(4.5)};
1113
- ${left(-2)}
1125
+ ${left(-2)};
1114
1126
  }
1115
1127
  `;
1116
1128
  const AttachedItemOwnerCSS = css`
@@ -1119,7 +1131,7 @@ const AttachedItemOwnerCSS = css`
1119
1131
  ${itemsCenter};
1120
1132
  ${userSelectNone};
1121
1133
  ${parseHeight('100%')};
1122
- ${textColor('text.sub')};
1134
+ ${textColor('text/sub')};
1123
1135
  `;
1124
1136
  const DetailInfoCSS = css`
1125
1137
  ${displayFlex};
@@ -1145,7 +1157,7 @@ const AttachedLinearCSS = css`
1145
1157
  ${displayFlex};
1146
1158
  ${positionAbsolute};
1147
1159
  ${itemsCenter};
1148
- ${bgColor('system.white')};
1160
+ ${bgColor('system/white')};
1149
1161
  ${parseWidthHeight('100%')};
1150
1162
  ${top(0)};
1151
1163
  `;
@@ -1242,27 +1254,27 @@ const AttachmentRootCSS = (isEmpty, isEnable) => css`
1242
1254
  ${positionRelative};
1243
1255
  ${borderRadius4px};
1244
1256
  ${boxBorder};
1245
- ${border(1, 'line.normal')};
1257
+ ${border(1, 'line/normal')};
1246
1258
  ${parseHeight(isEmpty && !isEnable ? 120 : 280)};
1247
- ${bgColor('system.white')};
1259
+ ${bgColor('system/white')};
1248
1260
  .css-${AttachedCSS.name} {
1249
1261
  .css-${AttachedItemCSS.name} {
1250
1262
  &:hover {
1251
- ${bgColor('fill.hover')};
1263
+ ${bgColor('fill/hover')};
1252
1264
  .css-${AttachedLinearCSS.name} {
1253
- ${bgColor('fill.hover')};
1265
+ ${bgColor('fill/hover')};
1254
1266
  }
1255
1267
  }
1256
1268
  &:active {
1257
- ${bgColor('fill.pressed')};
1269
+ ${bgColor('fill/pressed')};
1258
1270
  .css-${AttachedLinearCSS.name} {
1259
- ${bgColor('fill.pressed')};
1271
+ ${bgColor('fill/pressed')};
1260
1272
  }
1261
1273
  }
1262
1274
  &.chosen {
1263
- ${bgColor('fill.focus')};
1275
+ ${bgColor('fill/focus')};
1264
1276
  .css-${AttachedItemInfoCSS.name}, .css-${AttachedItemOwnerCSS.name} {
1265
- ${bgColor('fill.focus')};
1277
+ ${bgColor('fill/focus')};
1266
1278
  }
1267
1279
  }
1268
1280
  }
@@ -1277,22 +1289,18 @@ const AttachmentRootCSS = (isEmpty, isEnable) => css`
1277
1289
  }
1278
1290
  `;
1279
1291
  Attachment.defaultProps = {
1280
- allowSort: true,
1281
- className: '',
1282
- data: [],
1283
1292
  deleteNotifyText: getGlobal('deleteNotifyText'),
1284
- disabled: false,
1285
1293
  hintText: getGlobal('dropFileHere'),
1286
1294
  label: getGlobal('attachText'),
1287
- maxFile: Infinity,
1288
- multiple: true,
1289
- style: {},
1295
+ maxSize: getGlobal('maxSizeUpload'),
1290
1296
  uploadErrorInfo: {
1291
1297
  maxFile: getGlobal(['errorDefault', 'maxFile']),
1292
1298
  maxSize: getGlobal(['errorDefault', 'maxSize']),
1293
1299
  fileType: getGlobal(['errorDefault', 'fileType']),
1294
1300
  existingFile: getGlobal(['errorDefault', 'existingFile'])
1295
- }
1301
+ },
1302
+ viewType: 'detail',
1303
+ ...getGlobal(['components', 'attachment', 'defaultProps'])
1296
1304
  };
1297
1305
  Attachment.propTypes = {
1298
1306
  /** File types that can be accepted. */
@@ -1333,7 +1341,7 @@ Attachment.propTypes = {
1333
1341
  /** Limit the number of uploaded files. */
1334
1342
  maxFile: PropTypes.number,
1335
1343
  /** Limit the size of uploaded files. */
1336
- maxSize: PropTypes.string,
1344
+ maxSize: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
1337
1345
  /** Allows to attach multiple files. */
1338
1346
  multiple: PropTypes.bool,
1339
1347
  /** Callback fired when the files attached is changed. */
@@ -7,7 +7,7 @@ import locale from "../../../locale";
7
7
  import PropTypes from 'prop-types';
8
8
  import { forwardRef, memo, useCallback, useEffect, useImperativeHandle, useRef, useState } from 'react';
9
9
  import { render } from 'react-dom';
10
- import { bgColor, borderRadius4px, cursorPointer, displayBlock, displayFlex, displayNone, flexCol, flexRow, invisible, justifyEnd, left, mg, parseHeight, parseMaxWidth, parseMinWidth, parseWidthHeight, pd, pointerEventsNone, positionFixed, textCenter, top, userSelectNone, whiteSpaceNoWrap, z } from "../../../styles/general";
10
+ import { bgColor, borderRadius4px, cursorPointer, displayBlock, displayFlex, displayNone, flexCol, flexRow, invisible, justifyEnd, left, mg, parseHeight, parseMaxWidth, parseMinWidth, pd, pointerEventsNone, positionFixed, textCenter, top, userSelectNone, whiteSpaceNoWrap, z } from "../../../styles/general";
11
11
  import { useTheme } from "../../../theme";
12
12
  import { capitalizeSentenceCase, classNames, date as moment, isEqual, randomString, updatePosition } from "../../../utils";
13
13
  import { generateCalendarCSS, onUpdateNavigator, renderHeader, renderNavigator } from "../calendar/function";
@@ -123,6 +123,7 @@ const DateRangePicker = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
123
123
  const [, setValueFr] = useState(Date.now());
124
124
  const [, setValueTo] = useState(Date.now());
125
125
  const [, setSelected] = useState(Date.now());
126
+ const [valueState, setValueState] = useState();
126
127
  const navigatorFromRefs = {
127
128
  doubleLeft: useRef(null),
128
129
  doubleRight: useRef(null),
@@ -332,7 +333,11 @@ const DateRangePicker = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
332
333
  const timeFr = new Date(times[0]);
333
334
  const timeTo = new Date(times[1]);
334
335
  const from = new Date(timeFr.getFullYear(), timeFr.getMonth());
335
- const to = new Date(timeTo.getFullYear(), +moment(timeTo).diff(timeFr, 'months') === 0 ? timeTo.getMonth() + 1 : timeTo.getMonth());
336
+ const to = new Date(timeTo.getFullYear(), timeTo.getMonth());
337
+ // const to = new Date(
338
+ // timeTo.getFullYear(),
339
+ // +moment(timeTo).diff(timeFr, 'months') === 0 ? timeTo.getMonth() + 1 : timeTo.getMonth()
340
+ // );
336
341
  updateValueFr(from);
337
342
  updateValueTo(to);
338
343
  };
@@ -365,8 +370,7 @@ const DateRangePicker = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
365
370
  const {
366
371
  left,
367
372
  height,
368
- top,
369
- width
373
+ top
370
374
  } = anchor instanceof Element ? anchor.getBoundingClientRect() : ref.current.getBoundingClientRect();
371
375
  const pickerHeight = innerWidth < 567 ? controls ? 550 : 495 : controls ? 310 : 256;
372
376
  let style = {};
@@ -388,7 +392,7 @@ const DateRangePicker = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
388
392
  style.left = (innerWidth - pickerWidth) / 2;
389
393
  }
390
394
  }
391
- return pickerCSS.picker(style, width).styles;
395
+ return pickerCSS.picker(style).styles;
392
396
  };
393
397
  const clearDayHovering = arr => {
394
398
  if (values.current.length !== 2) {
@@ -740,6 +744,7 @@ const DateRangePicker = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
740
744
  tempValue = formatValue(time, displayFormat);
741
745
  }
742
746
  el.value = capitalizeSentenceCase(tempValue);
747
+ setValueState(capitalizeSentenceCase(tempValue));
743
748
  clearAble && onSwap(false);
744
749
  };
745
750
  const onClear = () => {
@@ -932,7 +937,9 @@ const DateRangePicker = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
932
937
  startIconProps: {
933
938
  className: 'non-effect allow-disabled'
934
939
  },
935
- endIcon: endIcon
940
+ endIcon: endIcon,
941
+ value: valueState,
942
+ onClick: onInputFocus
936
943
  }), error ? jsx(HelperText, {
937
944
  ...helperTextProps,
938
945
  disabled: disabled
@@ -1062,10 +1069,10 @@ const pickerCSS = {
1062
1069
  }
1063
1070
  }
1064
1071
  `,
1065
- picker: (position, width) => css`
1072
+ picker: position => css`
1066
1073
  ${borderRadius4px};
1067
1074
  ${positionFixed};
1068
- ${parseWidthHeight(width, 'max-content')};
1075
+ ${parseHeight('max-content')};
1069
1076
  ${parseMinWidth(window.innerWidth <= 633 ? 300 : 633)};
1070
1077
  ${parseMaxWidth(805)};
1071
1078
  ${top(position.top)};