diginet-core-ui 1.3.90-beta.6 → 1.3.91-beta.1

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.
@@ -6,28 +6,13 @@ import { getGlobal } from "../../../global";
6
6
  import { Another, Compressed, Image, Pdf, Presentation, Sheet, Word } from "../../../icons";
7
7
  import PropTypes from 'prop-types';
8
8
  import { forwardRef, memo, useEffect, useImperativeHandle, useMemo, useRef, useState } from 'react';
9
- import { bgColor, border, borderRadius4px, borderRadius50, boxBorder, boxContent, cursorPointer, displayBlock, displayFlex, displayInlineBlock, displayNone, flexCol, flexRow, flexWrap, floatRight, gap, itemsCenter, justifyBetween, justifyCenter, justifyEnd, justifyStart, mg, mgb, mgl, mgr, mgx, parseHeight, parseMaxWidth, parseMaxWidthHeight, parseMinWidth, parseWidth, parseWidthHeight, pd, positionAbsolute, positionRelative, textCenter, textRight, truncate, userSelectNone } from "../../../styles/general";
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
10
  import { useTheme } from "../../../theme";
11
11
  import { classNames, date as moment, getFileType } from "../../../utils";
12
12
  const {
13
13
  colors: {
14
- system: {
15
- rest: systemRest,
16
- white: systemWhite
17
- },
18
- semantic: {
19
- success: semanticSuccess
20
- },
21
- fill: {
22
- hover: fillHover,
23
- pressed: fillPressed,
24
- focus: fillFocus
25
- },
26
14
  line: {
27
15
  normal: lineNormal
28
- },
29
- text: {
30
- sub: textSub
31
16
  }
32
17
  }
33
18
  } = useTheme();
@@ -157,7 +142,7 @@ const Attachment = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
157
142
  const attachmentHandleIconRef = useRef(null);
158
143
  const attachmentInputRef = useRef(null);
159
144
  const attachedRef = useRef(null);
160
- const newAttachedRef = useRef([]);
145
+ // const newAttachedRef = useRef([]);
161
146
  const popupRef = useRef(null);
162
147
  const popoverRef = useRef(null);
163
148
  const isDeleteAll = useRef(false);
@@ -172,6 +157,7 @@ const Attachment = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
172
157
  const [viewTypeState, setViewTypeState] = useState(viewType);
173
158
  const [isEmpty, setIsEmpty] = useState(null);
174
159
  const [newDataState, setNewDataState] = useState([]);
160
+ const [dataState, setDataState] = useState([]);
175
161
  const isEnable = !readOnly && !disabled;
176
162
  const _AttachmentRootCSS = AttachmentRootCSS(isEmpty, isEnable);
177
163
 
@@ -377,14 +363,14 @@ const Attachment = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
377
363
  const parent = itemEl.parentNode;
378
364
  const index = Array.from(attachedRef.current.children).indexOf(parent);
379
365
  const deletedFile = attached.splice(index, 1)[0];
380
- if (Object.prototype.toString.call(deletedFile) === '[object File]') {
366
+ removedAttachedRef.current.push(deletedFile);
367
+ recentRemovedAttached.push(deletedFile);
368
+ if (Object.prototype.toString.call(deletedFile) === '[object File]' && newDataState !== null && newDataState !== void 0 && newDataState.length) {
381
369
  removeFileOutInputFiles(allNewAttached.getAll('files').findIndex(attach => attach.FileName === deletedFile.FileName && attach.CreateDate === deletedFile.CreateDate));
382
370
  } else {
383
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));
384
373
  }
385
- removedAttachedRef.current.push(deletedFile);
386
- recentRemovedAttached.push(deletedFile);
387
- parent.remove();
388
374
  });
389
375
  if (attached.length < 2) {
390
376
  afterChangeFile(attached.length);
@@ -455,21 +441,26 @@ const Attachment = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
455
441
  files.splice(index, 1);
456
442
  allNewAttached.delete('files');
457
443
  files.forEach(file => allNewAttached.append('files', file));
458
- newAttachedRef.current = files || [];
444
+ // newAttachedRef.current = files || [];
445
+ setNewDataState(files || []);
459
446
  }
460
447
  attachmentInputRef.current.files = dt.files;
461
448
  return dt.files;
462
449
  };
463
450
  const insertAttached = files => {
464
451
  if (multiple || inputProps && inputProps.multiple) {
452
+ let tempArr = [];
465
453
  for (let file of files) {
466
454
  allNewAttached.append('files', file);
467
- newAttachedRef.current.push(file);
455
+ // newAttachedRef.current.push(file);
456
+ tempArr.push(file);
468
457
  }
458
+ setNewDataState(tempArr);
469
459
  } else if (files[0]) {
470
460
  allNewAttached.delete('files');
471
461
  allNewAttached.append('files', files[0]);
472
- newAttachedRef.current = [files[0]];
462
+ // newAttachedRef.current = [files[0]];
463
+ setNewDataState([files[0]]);
473
464
  }
474
465
  // attachmentInputRef.current.files = allNewAttached.getAll('files');
475
466
  };
@@ -714,7 +705,7 @@ const Attachment = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
714
705
  }
715
706
  };
716
707
  useEffect(() => {
717
- if (attached.length) {
708
+ if (attached !== null && attached !== void 0 && attached.length) {
718
709
  attached.length = 0;
719
710
  }
720
711
  return () => {
@@ -743,16 +734,15 @@ const Attachment = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
743
734
  };
744
735
  }, [maxFile, maxSizeProp, multiple, accept]);
745
736
  useEffect(() => {
746
- var _newAttachedRef$curre;
747
737
  oldAttached.length = 0;
748
- 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));
738
+ afterChangeFile(((data === null || data === void 0 ? void 0 : data.length) || 0) + ((newDataState === null || newDataState === void 0 ? void 0 : newDataState.length) || 0));
749
739
  if (data) {
750
740
  // Load files data was uploaded
751
741
  const length = data.length;
752
742
  for (let i = 0; i < length; i++) {
753
743
  if (Object.prototype.toString.call(data[i]) === '[object File]') {
754
744
  allNewAttached.append('files', data[i]);
755
- newAttachedRef.current.push(data[i]);
745
+ // newAttachedRef.current.push(data[i]);
756
746
  attached.push(data[i]);
757
747
  } else {
758
748
  const item = mountDomain(data[i]);
@@ -760,12 +750,12 @@ const Attachment = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
760
750
  attached.push(item);
761
751
  }
762
752
  }
753
+ setDataState(data);
763
754
  }
764
755
  return () => {
765
756
  // if (attachedRef.current) {
766
757
  // attachedRef.current.innerHTML = null;
767
758
  // }
768
- setNewDataState([]);
769
759
  oldAttached.length = 0;
770
760
  attached.length = 0;
771
761
  chosenItems.length = 0;
@@ -840,7 +830,7 @@ const Attachment = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
840
830
  uppercase: true,
841
831
  required: required,
842
832
  type: 'h5',
843
- color: textSub,
833
+ color: 'text.sub',
844
834
  ref: attachTextRef
845
835
  }, label), error ? jsx(HelperText, null, error) : null), jsx("div", {
846
836
  css: AttachmentHeaderIconCSS
@@ -878,11 +868,11 @@ const Attachment = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
878
868
  }), isEmpty ? jsx(Typography, {
879
869
  css: userSelectNone,
880
870
  type: 'p3',
881
- color: systemRest
871
+ color: 'system.rest'
882
872
  }, hintText) : null) : isEmpty ? jsx(Typography, {
883
873
  css: userSelectNone,
884
874
  type: 'p3',
885
- color: systemRest
875
+ color: 'system.rest'
886
876
  }, getGlobal('noFileText')) : null)), allowSort && !isEmpty ? jsx(Popover, {
887
877
  ref: popoverRef,
888
878
  anchor: jsx(ButtonIcon, {
@@ -968,15 +958,15 @@ const Attachment = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
968
958
  }, jsx(Typography, {
969
959
  className: 'username',
970
960
  type: 'p2',
971
- color: textSub
961
+ color: 'text.sub'
972
962
  }, (item === null || item === void 0 ? void 0 : item.UserName) || item.lastModifiedDate && ownerName || ''), jsx(Typography, {
973
963
  className: 'datetime',
974
964
  type: 'p2',
975
- color: textSub
965
+ color: 'text.sub'
976
966
  }, getDateTime(date)), jsx(Typography, {
977
967
  className: 'filesize',
978
968
  type: 'p2',
979
- color: textSub
969
+ color: 'text.sub'
980
970
  }, calculateSize(item.FileSize || item.size))) : null, isNew ? jsx("span", {
981
971
  css: AttachedLinearCSS
982
972
  }, jsx(LinearProgress, {
@@ -994,12 +984,12 @@ const Attachment = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
994
984
  css: AttachedCSS,
995
985
  ref: attachedRef,
996
986
  className: classNames(isViewTypeIcon && 'icon-view')
997
- }, data.map((item, idx) => {
987
+ }, dataState.map((item, idx) => {
998
988
  return renderAttachmentItem(item, idx);
999
989
  }), newDataState.map((item, idx) => {
1000
990
  return renderAttachmentItem(item, (data === null || data === void 0 ? void 0 : data.length) + idx, true);
1001
991
  })));
1002
- }, [data, onViewProp, unitSize, newDataState, viewTypeState]);
992
+ }, [data, onViewProp, unitSize, dataState, newDataState, viewTypeState]);
1003
993
  const PopupView = useMemo(() => {
1004
994
  return jsx(Popup, {
1005
995
  open: showPopup,
@@ -1070,8 +1060,8 @@ const AttachmentInputCSS = css`
1070
1060
  ${displayNone};
1071
1061
  ${positionAbsolute};
1072
1062
  ${parseWidthHeight('100%')};
1073
- top: 0;
1074
- left: 0;
1063
+ ${top(0)};
1064
+ ${left(0)};
1075
1065
  input {
1076
1066
  ${positionRelative};
1077
1067
  ${parseWidthHeight('100%', 'calc(100% + 20px)')};
@@ -1095,8 +1085,8 @@ const AttachmentImageCSS = css`
1095
1085
  const AttachmentImageEmptyCSS = css`
1096
1086
  ${positionAbsolute};
1097
1087
  ${parseWidthHeight('100%')};
1098
- top: 0;
1099
- left: 0;
1088
+ ${top(0)};
1089
+ ${left(0)};
1100
1090
  `;
1101
1091
  const AttachedItemInfoCSS = css`
1102
1092
  ${displayFlex};
@@ -1107,6 +1097,7 @@ const AttachedItemInfoCSS = css`
1107
1097
  ${mgr([2])};
1108
1098
  `;
1109
1099
  const AttachedItemInfoIconCSS = css`
1100
+ ${displayFlex};
1110
1101
  ${flexRow};
1111
1102
  ${positionRelative};
1112
1103
  ${boxContent};
@@ -1117,9 +1108,9 @@ const AttachedItemInfoIconCSS = css`
1117
1108
  ${positionAbsolute};
1118
1109
  ${borderRadius50};
1119
1110
  ${parseWidthHeight(4, 4)};
1120
- ${bgColor(semanticSuccess)};
1121
- top: 4.5px;
1122
- left: -2px;
1111
+ ${bgColor('semantic.success')};
1112
+ ${top(4.5)};
1113
+ ${left(-2)}
1123
1114
  }
1124
1115
  `;
1125
1116
  const AttachedItemOwnerCSS = css`
@@ -1128,7 +1119,7 @@ const AttachedItemOwnerCSS = css`
1128
1119
  ${itemsCenter};
1129
1120
  ${userSelectNone};
1130
1121
  ${parseHeight('100%')};
1131
- color: ${textSub};
1122
+ ${textColor('text.sub')};
1132
1123
  `;
1133
1124
  const DetailInfoCSS = css`
1134
1125
  ${displayFlex};
@@ -1154,9 +1145,9 @@ const AttachedLinearCSS = css`
1154
1145
  ${displayFlex};
1155
1146
  ${positionAbsolute};
1156
1147
  ${itemsCenter};
1157
- ${bgColor(systemWhite)};
1148
+ ${bgColor('system.white')};
1158
1149
  ${parseWidthHeight('100%')};
1159
- top: 0;
1150
+ ${top(0)};
1160
1151
  `;
1161
1152
  const AttachedItemCSS = css`
1162
1153
  ${displayFlex};
@@ -1217,8 +1208,8 @@ const AttachedCSS = css`
1217
1208
  ${pd(0)};
1218
1209
  &.new-file:after {
1219
1210
  ${parseWidthHeight(8)};
1220
- top: -1px;
1221
- left: -7px;
1211
+ ${top(-1)};
1212
+ ${left(-7)};
1222
1213
  }
1223
1214
  }
1224
1215
  }
@@ -1227,7 +1218,7 @@ const AttachedCSS = css`
1227
1218
  position: inherit;
1228
1219
  .css-${AttachedLinearCSS.name} {
1229
1220
  ${parseHeight('auto')};
1230
- bottom: 0;
1221
+ ${bottom(0)};
1231
1222
  top: unset;
1232
1223
  background: none;
1233
1224
  }
@@ -1251,27 +1242,27 @@ const AttachmentRootCSS = (isEmpty, isEnable) => css`
1251
1242
  ${positionRelative};
1252
1243
  ${borderRadius4px};
1253
1244
  ${boxBorder};
1254
- ${border(1, lineNormal)};
1245
+ ${border(1, 'line.normal')};
1255
1246
  ${parseHeight(isEmpty && !isEnable ? 120 : 280)};
1256
- ${bgColor(systemWhite)};
1247
+ ${bgColor('system.white')};
1257
1248
  .css-${AttachedCSS.name} {
1258
1249
  .css-${AttachedItemCSS.name} {
1259
1250
  &:hover {
1260
- ${bgColor(fillHover)};
1251
+ ${bgColor('fill.hover')};
1261
1252
  .css-${AttachedLinearCSS.name} {
1262
- ${bgColor(fillHover)};
1253
+ ${bgColor('fill.hover')};
1263
1254
  }
1264
1255
  }
1265
1256
  &:active {
1266
- ${bgColor(fillPressed)};
1257
+ ${bgColor('fill.pressed')};
1267
1258
  .css-${AttachedLinearCSS.name} {
1268
- ${bgColor(fillPressed)};
1259
+ ${bgColor('fill.pressed')};
1269
1260
  }
1270
1261
  }
1271
1262
  &.chosen {
1272
- ${bgColor(fillFocus)};
1263
+ ${bgColor('fill.focus')};
1273
1264
  .css-${AttachedItemInfoCSS.name}, .css-${AttachedItemOwnerCSS.name} {
1274
- ${bgColor(fillFocus)};
1265
+ ${bgColor('fill.focus')};
1275
1266
  }
1276
1267
  }
1277
1268
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "diginet-core-ui",
3
- "version": "1.3.90-beta.6",
3
+ "version": "1.3.91-beta.1",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "license": "UNLICENSED",
package/readme.md CHANGED
@@ -38,6 +38,16 @@ npm test
38
38
  ```
39
39
 
40
40
  ## Changelog
41
+ ## 1.3.91
42
+ - \[Changed\]: TreeView – Optimize code
43
+ - \[Changed\]: Popup – Add defaultProps description
44
+ - \[Changed\]: Grid – Add sx prop handle responsive css display
45
+ - \[Changed\]: ButtonMore – Export component ButtonMore
46
+ - \[Changed\]: DateRangePicker – Add description for prop value
47
+ - \[Fixed\]: Avatar – Fix bug not clear avatar when src null
48
+ - \[Fixed\]: Typography – Add min-width to popover hover tooltip
49
+ - \[Fixed\]: DatePicker – Fix disabled button previous month in navigator
50
+
41
51
  ## 1.3.90
42
52
  - \[Added\]: Breadcrumb – Add component Breadcrumb
43
53
  - \[Added\]: Icon – Question, Pause, Cake, ChatAnswer
package/styles/general.js CHANGED
@@ -4,10 +4,10 @@ export const rootSpacing = 4;
4
4
  export let rootZIndex = 1500;
5
5
  export const typographyTypes = ['t1', 't2', 't3', 't4', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'p1', 'p2', 'p3', 'title1', 'title2', 'title3', 'title4', 'heading1', 'heading2', 'heading3', 'heading4', 'heading5', 'heading6', 'paragraph1', 'paragraph2', 'paragraph3'];
6
6
 
7
- /**
8
- * get value spacing with rootZIndex
9
- * @param number
10
- * @return {number}
7
+ /**
8
+ * get value spacing with rootZIndex
9
+ * @param number
10
+ * @return {number}
11
11
  */
12
12
  export const zIndex = number => {
13
13
  number = Number(number || 0);
@@ -15,10 +15,10 @@ export const zIndex = number => {
15
15
  return rootZIndex + number;
16
16
  };
17
17
 
18
- /**
19
- * get value spacing with rootSpacing
20
- * @param {(number|number[])} vl - default 1
21
- * @returns {(number|string)}
18
+ /**
19
+ * get value spacing with rootSpacing
20
+ * @param {(number|number[])} vl - default 1
21
+ * @returns {(number|string)}
22
22
  */
23
23
 
24
24
  export const getSpacing = (vl = 1) => {
@@ -28,9 +28,9 @@ export const getSpacing = (vl = 1) => {
28
28
  } else return vl;
29
29
  };
30
30
 
31
- /**
32
- * replace rootZIndex
33
- * @param number
31
+ /**
32
+ * replace rootZIndex
33
+ * @param number
34
34
  */
35
35
  export const setZIndex = number => {
36
36
  number = Number(number || 0);
@@ -413,6 +413,14 @@ const textLowercase = css`
413
413
  const textRight = css`
414
414
  text-align: right;
415
415
  `;
416
+ const textSentence = css`
417
+ & {
418
+ text-transform: lowercase;
419
+ }
420
+ &:first-letter {
421
+ text-transform: uppercase;
422
+ }
423
+ `;
416
424
  const textUnderline = css`
417
425
  text-decoration: underline;
418
426
  `;
@@ -445,4 +453,4 @@ const whiteSpacePreWrap = css`
445
453
  const z = vl => css`
446
454
  z-index: ${zIndex(vl)};
447
455
  `;
448
- export { bgColor, bgCurrent, bgTransparent, border, borderBottom, borderBottomColor, borderColor, borderNone, borderRadius, borderRadius100, borderRadius4px, borderRadius50, bottom, boxBorder, boxContent, breakAll, breakWord, cursorDefault, cursorInherit, cursorInitial, cursorMove, cursorNoDrop, cursorNotAllowed, cursorPointer, cursorText, displayBlock, displayFlex, displayInlineBlock, displayInlineFlex, displayNone, fill, flexCol, flexColReverse, flexNowrap, flexRow, flexRowReverse, flexShrink, flexShrink0, flexWrap, flexWrapReverse, floatLeft, floatNone, floatRight, gap, gapX, gapY, inset, insetX, insetY, invisible, italic, itemsCenter, itemsEnd, itemsStart, justifyAround, justifyBetween, justifyCenter, justifyEnd, justifyEvenly, justifyStart, left, mg, mgb, mgl, mgr, mgt, mgx, mgy, noBorder, noBoxShadow, noMargin, noPadding, objectContain, objectCover, objectFill, objectNone, order, outlineNone, overflowAuto, overflowHidden, parseHeight, parseMaxHeight, parseMaxWidth, parseMaxWidthHeight, parseMinHeight, parseMinWidth, parseMinWidthHeight, parseWidth, parseWidthHeight, pd, pdb, pdl, pdr, pdt, pdx, pdy, pointerEventsAuto, pointerEventsInherit, pointerEventsInitial, pointerEventsNone, positionAbsolute, positionFixed, positionRelative, positionSticky, right, scale, scaleX, scaleY, selfCenter, selfEnd, selfStart, shadowNone, textCapitalize, textCenter, textColor, textCurrent, textEllipsis, textLeft, textLineThrough, textLowercase, textRight, textUnderline, textUppercase, top, truncate, userSelectNone, visible, whiteSpaceBreakSpaces, whiteSpaceNoWrap, whiteSpacePreWrap, z };
456
+ export { bgColor, bgCurrent, bgTransparent, border, borderBottom, borderBottomColor, borderColor, borderNone, borderRadius, borderRadius100, borderRadius4px, borderRadius50, bottom, boxBorder, boxContent, breakAll, breakWord, cursorDefault, cursorInherit, cursorInitial, cursorMove, cursorNoDrop, cursorNotAllowed, cursorPointer, cursorText, displayBlock, displayFlex, displayInlineBlock, displayInlineFlex, displayNone, fill, flexCol, flexColReverse, flexNowrap, flexRow, flexRowReverse, flexShrink, flexShrink0, flexWrap, flexWrapReverse, floatLeft, floatNone, floatRight, gap, gapX, gapY, inset, insetX, insetY, invisible, italic, itemsCenter, itemsEnd, itemsStart, justifyAround, justifyBetween, justifyCenter, justifyEnd, justifyEvenly, justifyStart, left, mg, mgb, mgl, mgr, mgt, mgx, mgy, noBorder, noBoxShadow, noMargin, noPadding, objectContain, objectCover, objectFill, objectNone, order, outlineNone, overflowAuto, overflowHidden, parseHeight, parseMaxHeight, parseMaxWidth, parseMaxWidthHeight, parseMinHeight, parseMinWidth, parseMinWidthHeight, parseWidth, parseWidthHeight, pd, pdb, pdl, pdr, pdt, pdx, pdy, pointerEventsAuto, pointerEventsInherit, pointerEventsInitial, pointerEventsNone, positionAbsolute, positionFixed, positionRelative, positionSticky, right, scale, scaleX, scaleY, selfCenter, selfEnd, selfStart, shadowNone, textCapitalize, textCenter, textColor, textCurrent, textEllipsis, textLeft, textLineThrough, textLowercase, textRight, textSentence, textUnderline, textUppercase, top, truncate, userSelectNone, visible, whiteSpaceBreakSpaces, whiteSpaceNoWrap, whiteSpacePreWrap, z };