diginet-core-ui 1.4.12-beta.2 → 1.4.12-beta.4

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.
@@ -403,9 +403,10 @@ const Attachment = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
403
403
  }
404
404
  };
405
405
  const onGetViewItem = (i = 0) => {
406
+ var _attached$index;
406
407
  const index = chosenItems[i];
407
408
  const node = attachedRef.current.childNodes[index];
408
- const AttachmentID = attached[index].AttachmentID;
409
+ const AttachmentID = ((_attached$index = attached[index]) === null || _attached$index === void 0 ? void 0 : _attached$index.AttachmentID) || null;
409
410
  onView(node, AttachmentID);
410
411
  };
411
412
  const onView = (node, AttachmentID) => {
@@ -463,7 +464,7 @@ const Attachment = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
463
464
  // newAttachedRef.current = [files[0]];
464
465
  if (isSpecialCase) setDataState([]);
465
466
  setTimeout(() => {
466
- setNewDataState([files[0]]);
467
+ setNewDataState(files[0] ? [files[0]] : []);
467
468
  });
468
469
  }
469
470
  // attachmentInputRef.current.files = allNewAttached.getAll('files');
@@ -1130,6 +1131,7 @@ const Attachment = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
1130
1131
  })) : null));
1131
1132
  };
1132
1133
  const renderAttachmentItem = (item, idx, isNew = false) => {
1134
+ if (!item) return;
1133
1135
  const date = isNew ? new Date() : new Date(item.CreateDate);
1134
1136
  if (isNew) item.CreateDate = date.toISOString();
1135
1137
  return viewTypeState === 'detail' ? renderAttachmentItemDetail(item, idx, isNew) : viewTypeState === 'icon' ? renderAttachmentItemIcon(item, idx, isNew) : renderAttachmentItemPicture(item, idx, isNew);
@@ -1145,11 +1147,11 @@ const Attachment = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
1145
1147
  className: classNames('DGN-UI-Attachment-List-Attached'),
1146
1148
  spacing: 2
1147
1149
  }, dataState.map((item, idx) => {
1148
- return renderAttachmentItem(item, idx);
1150
+ return renderAttachmentItem(mountDomain(item), idx);
1149
1151
  }), newDataState.map((item, idx) => {
1150
- return renderAttachmentItem(item, (data === null || data === void 0 ? void 0 : data.length) + idx, true);
1152
+ return renderAttachmentItem(mountDomain(item), (dataState === null || dataState === void 0 ? void 0 : dataState.length) + idx, true);
1151
1153
  })));
1152
- }, [data, onViewProp, unitSize, dataState, newDataState, viewTypeState, sizeByHeight, colors]);
1154
+ }, [data, domain, onViewProp, unitSize, dataState, newDataState, viewTypeState, sizeByHeight, colors]);
1153
1155
  const PopupView = useMemo(() => {
1154
1156
  return jsx(Popup, {
1155
1157
  open: showPopup,
@@ -1165,15 +1167,15 @@ const Attachment = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
1165
1167
  const ModalView = useMemo(() => {
1166
1168
  if (!chosenItems.length) return setShowModal(false);
1167
1169
  const index = chosenItems[0];
1168
- const data = mountDomain(attached[index]);
1170
+ const data = mountDomain([...dataState, ...newDataState][index]);
1169
1171
 
1170
1172
  // let data = oldAttached[index] || allNewAttached.getAll('files')[index-oldAttached.length];
1171
1173
  return jsx(ModalSample, {
1172
1174
  open: showModal,
1173
- title: data.FileName,
1175
+ title: data === null || data === void 0 ? void 0 : data.FileName,
1174
1176
  onClose: () => setShowModal(false)
1175
1177
  }, jsx(Slider, null, jsx(SliderItem, {
1176
- url: data.URL
1178
+ url: data === null || data === void 0 ? void 0 : data.URL
1177
1179
  })));
1178
1180
  }, [domain, showModal]);
1179
1181
  // End view
@@ -1413,17 +1415,17 @@ Attachment.propTypes = {
1413
1415
  allowSort: PropTypes.bool,
1414
1416
  /** Class for component. */
1415
1417
  className: PropTypes.string,
1416
- /** List attachment:<br />
1417
- * [{<br />
1418
- * &nbsp;&nbsp;&nbsp;&nbsp;"AttachmentID": "ATT2U8O7YPTF1KSNCW3X",<br />
1419
- * &nbsp;&nbsp;&nbsp;&nbsp;"URL": "https://apricot.diginet.com.vn/cdn-dev/file/8a07bee1eeff17a14eee.jpg?path=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJmaWxlUGF0aCI6Ii8yMDIwLzA4LzQ0YjNhYjQ4LTMwNGQtNDQ3NC05ZDk0LWNkNGVlMDQwOGNlMy5qcGciLCJmaWxlTmFtZSI6IjhhMDdiZWUxZWVmZjE3YTE0ZWVlLmpwZyIsImZpbGVTaXplIjoyNDg4MzcsImZpbGVUeXBlIjoiaW1hZ2UvanBlZyIsImlhdCI6MTU5ODI0NDMwMiwiZXhwIjo4Nzk5ODI0NDMwMn0.fow6O5fp2z3vieA9gom5RRwQ7xxwBx9_7X2Fe8T2YI0",<br />
1420
- * &nbsp;&nbsp;&nbsp;&nbsp;"FileName": "8a07bee1eeff17a14eee.jpg",<br />
1421
- * &nbsp;&nbsp;&nbsp;&nbsp;"FileSize": 248837,<br />
1422
- * &nbsp;&nbsp;&nbsp;&nbsp;"KeyID": "W39OAD3YGLCWAQKV1D6PGEKNW4RLGVTZTUWLYEVFQ2QG8AOCXW",<br />
1423
- * &nbsp;&nbsp;&nbsp;&nbsp;"CreateUserID": "LEMONADMIN",<br />
1424
- * &nbsp;&nbsp;&nbsp;&nbsp;"CreateDate": "2020-08-24T11:54:04.307Z",<br />
1425
- * &nbsp;&nbsp;&nbsp;&nbsp;"UserName": "Quản trị hệ thống"<br />
1426
- * }, ...]
1418
+ /** List attachment:<br />
1419
+ * [{<br />
1420
+ * &nbsp;&nbsp;&nbsp;&nbsp;"AttachmentID": "ATT2U8O7YPTF1KSNCW3X",<br />
1421
+ * &nbsp;&nbsp;&nbsp;&nbsp;"URL": "https://apricot.diginet.com.vn/cdn-dev/file/8a07bee1eeff17a14eee.jpg?path=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJmaWxlUGF0aCI6Ii8yMDIwLzA4LzQ0YjNhYjQ4LTMwNGQtNDQ3NC05ZDk0LWNkNGVlMDQwOGNlMy5qcGciLCJmaWxlTmFtZSI6IjhhMDdiZWUxZWVmZjE3YTE0ZWVlLmpwZyIsImZpbGVTaXplIjoyNDg4MzcsImZpbGVUeXBlIjoiaW1hZ2UvanBlZyIsImlhdCI6MTU5ODI0NDMwMiwiZXhwIjo4Nzk5ODI0NDMwMn0.fow6O5fp2z3vieA9gom5RRwQ7xxwBx9_7X2Fe8T2YI0",<br />
1422
+ * &nbsp;&nbsp;&nbsp;&nbsp;"FileName": "8a07bee1eeff17a14eee.jpg",<br />
1423
+ * &nbsp;&nbsp;&nbsp;&nbsp;"FileSize": 248837,<br />
1424
+ * &nbsp;&nbsp;&nbsp;&nbsp;"KeyID": "W39OAD3YGLCWAQKV1D6PGEKNW4RLGVTZTUWLYEVFQ2QG8AOCXW",<br />
1425
+ * &nbsp;&nbsp;&nbsp;&nbsp;"CreateUserID": "LEMONADMIN",<br />
1426
+ * &nbsp;&nbsp;&nbsp;&nbsp;"CreateDate": "2020-08-24T11:54:04.307Z",<br />
1427
+ * &nbsp;&nbsp;&nbsp;&nbsp;"UserName": "Quản trị hệ thống"<br />
1428
+ * }, ...]
1427
1429
  */
1428
1430
  data: PropTypes.array,
1429
1431
  /** The message to display when deleting files. */
@@ -1454,16 +1456,16 @@ Attachment.propTypes = {
1454
1456
  onChange: PropTypes.func,
1455
1457
  /** Download attached event, if not it will use default. */
1456
1458
  onDownload: PropTypes.func,
1457
- /**
1458
- * event when removed file(s)
1459
- *
1460
- * return data: {<br/>
1461
- * &nbsp;&nbsp;&nbsp;&nbsp;attached: [Files] (insist old and all new files )<br/>
1462
- * &nbsp;&nbsp;&nbsp;&nbsp;allNewAttached: [Files]<br/>
1463
- * &nbsp;&nbsp;&nbsp;&nbsp;oldAttached: [Files]<br/>
1464
- * &nbsp;&nbsp;&nbsp;&nbsp;removedAttached: [Files]<br/>
1465
- * &nbsp;&nbsp;&nbsp;&nbsp;element: [NodeList (just removed)]<br/>
1466
- * }
1459
+ /**
1460
+ * event when removed file(s)
1461
+ *
1462
+ * return data: {<br/>
1463
+ * &nbsp;&nbsp;&nbsp;&nbsp;attached: [Files] (insist old and all new files )<br/>
1464
+ * &nbsp;&nbsp;&nbsp;&nbsp;allNewAttached: [Files]<br/>
1465
+ * &nbsp;&nbsp;&nbsp;&nbsp;oldAttached: [Files]<br/>
1466
+ * &nbsp;&nbsp;&nbsp;&nbsp;removedAttached: [Files]<br/>
1467
+ * &nbsp;&nbsp;&nbsp;&nbsp;element: [NodeList (just removed)]<br/>
1468
+ * }
1467
1469
  */
1468
1470
  onRemove: PropTypes.func,
1469
1471
  /** View attached event, if not it will use default. */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "diginet-core-ui",
3
- "version": "1.4.12-beta.2",
3
+ "version": "1.4.12-beta.4",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "license": "UNLICENSED",