diginet-core-ui 1.3.80-beta.5 → 1.3.80-beta.7

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.
@@ -7,7 +7,7 @@ import PropTypes from 'prop-types';
7
7
  import { forwardRef, memo, useImperativeHandle, useMemo, useRef } from 'react';
8
8
  import { alignCenter, borderBox, borderRadius4px, flexRow, flexWrap, inlineFlex, justifyCenter, parseMinWidthHeight, parseWidthHeight, pointerEventsNone, positionAbsolute, positionRelative } from "../../styles/general";
9
9
  import { useColor as colors, useTheme } from "../../theme";
10
- import { classNames } from "../../utils";
10
+ import { classNames, refType as ref } from "../../utils";
11
11
  const {
12
12
  colors: {
13
13
  system: {
@@ -79,6 +79,7 @@ const Badge = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
79
79
  content,
80
80
  contentDirection,
81
81
  iconProps,
82
+ id,
82
83
  invisible,
83
84
  max,
84
85
  name,
@@ -110,16 +111,18 @@ const Badge = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
110
111
  let node = children;
111
112
  if (!node && name) {
112
113
  node = jsx(Icon, {
114
+ viewBox: true,
113
115
  name: name,
114
116
  width: iconSize,
115
117
  height: iconSize,
116
- viewBox: true,
118
+ color: 'currentColor',
117
119
  ...iconProps
118
120
  });
119
121
  }
120
122
  return jsx("div", {
121
123
  css: _BadgeRootCSS,
122
124
  ref: ref,
125
+ id: id,
123
126
  className: classNames('DGN-UI-Badge', className),
124
127
  style: style,
125
128
  ...props
@@ -129,7 +132,7 @@ const Badge = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
129
132
  css: _BadgeNumberCSS,
130
133
  className: 'DGN-UI-Badge-Dot'
131
134
  }, max && content > max ? max + '+' : content === 0 && !showZero ? null : content) : null);
132
- }, [anchorOrigin, children, className, color, content, contentDirection, iconProps, invisible, max, name, showZero, size, style]);
135
+ }, [anchorOrigin, children, className, color, content, contentDirection, iconProps, id, invisible, max, name, showZero, size, style, props]);
133
136
  }));
134
137
  const BadgeNumberCSS = (typographySize, children, name, dotSize, dotColor) => css`
135
138
  ${typographySize};
@@ -153,11 +156,10 @@ const BadgeRootCSS = (children, name, dotPos, BadgeNumberCSSName) => css`
153
156
  ${positionRelative};
154
157
  ${borderBox};
155
158
  ${borderRadius4px};
156
- color: ${systemWhite};
157
159
  ${parseWidthHeight('max-content')};
158
160
  ${parseMinWidthHeight('max-content')};
159
161
  .css-${BadgeNumberCSSName} {
160
- ${(children || name) && dotPos}
162
+ ${(children || name) && dotPos};
161
163
  }
162
164
  `;
163
165
  Badge.defaultProps = {
@@ -176,39 +178,53 @@ Badge.defaultProps = {
176
178
  style: {}
177
179
  };
178
180
  Badge.propTypes = {
181
+ /** The anchor of the badge. */
179
182
  anchorOrigin: PropTypes.shape({
180
183
  horizontal: PropTypes.oneOf(['left', 'right']),
181
184
  vertical: PropTypes.oneOf(['top', 'bottom'])
182
185
  }),
183
- /** the quantity is shown on the badge */
186
+ /** The badge will be added relative to this node. */
187
+ children: PropTypes.node,
188
+ /** Class for component. */
189
+ className: PropTypes.string,
190
+ /** The color of the component. */
191
+ color: PropTypes.oneOfType([PropTypes.oneOf(['default', 'primary', 'info', 'success', 'warning', 'danger']), PropTypes.string]),
192
+ /** The content rendered within the badge. */
184
193
  content: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
185
- /** the largest number is displayed on the badge */
186
- max: PropTypes.number,
187
- /** used to fill background for button */
194
+ /** Direction of content within the badge */
188
195
  contentDirection: PropTypes.oneOf(['left', 'right']),
189
- /** background color of badge */
190
- color: PropTypes.oneOfType([PropTypes.oneOf(['default', 'primary', 'info', 'success', 'warning', 'danger']), PropTypes.string]),
191
- /** use name will replace children with ButtonIcon */
196
+ /** If `true`, the badge is invisible */
197
+ invisible: PropTypes.bool,
198
+ /** Max count to show. */
199
+ max: PropTypes.number,
200
+ /** Prop name of [ButtonIcon](https://core.diginet.com.vn/ui/?path=/docs/buttonicon) components. */
192
201
  name: PropTypes.string,
193
- /** other icon props when use prop name */
194
- iconProps: PropTypes.object,
195
- /** size of Badge
202
+ /** Controls whether the badge is hidden when `content` is zero. */
203
+ showZero: PropTypes.bool,
204
+ /** Size of the components.
196
205
  *
197
206
  * * medium (dot 8px, typography p3)
198
207
  * * large (button 10px, typography p2)
199
208
  * * giant (button 12px, typography p1)
200
209
  * */
201
210
  size: PropTypes.oneOf(['medium', 'large', 'giant']),
202
- /** Controls whether the badge is hidden when content is zero */
203
- showZero: PropTypes.bool,
204
- /** If true, the badge is invisible */
205
- invisible: PropTypes.bool,
206
- /** className of component */
207
- className: PropTypes.string,
208
- /** style inline of component */
211
+ /** Style inline of component. */
209
212
  style: PropTypes.object,
210
- /** the content displayed under the number of the badge */
211
- children: PropTypes.node
213
+ /**
214
+ * ref methods (ref.current.instance.*method*)
215
+ *
216
+ * * option(): Gets all UI component properties
217
+ * * Returns value - object
218
+ * * option(optionName): Gets the value of a single property
219
+ * * @param {optionName} - string
220
+ * * Returns value - any
221
+ * * option(optionName, optionValue): Updates the value of a single property
222
+ * * @param {optionName} - string
223
+ * * @param {optionValue} - any
224
+ * * option(options): Updates the values of several properties
225
+ * * @param {options} - object
226
+ */
227
+ reference: ref
212
228
  };
213
229
  export { Badge };
214
230
  export default OptionWrapper(Badge);
@@ -7,7 +7,7 @@ import PropTypes from 'prop-types';
7
7
  import { forwardRef, memo, useEffect, useImperativeHandle, useMemo, useRef, useState } from 'react';
8
8
  import { detectColor, fade, hexToRGBA, hslToRgb, isColor, isColorName, rgbaToHexA, rgbToHex } from "../../styles/color-helper";
9
9
  import * as allColors from "../../styles/colors";
10
- import { alignCenter, backgroundTransparent, border, borderBox, borderNone, borderRadius4px, cursorPointer, flexRow, inlineFlex, justifyCenter, noBorder, noMargin, noPadding, outlineNone, overflowHidden, parseHeight, parseMinHeight, parseMinWidth, parseMinWidthHeight, parseWidthHeight, pointerEventsNone, positionRelative, userSelectNone } from "../../styles/general";
10
+ import { alignCenter, backgroundTransparent, border, borderBox, borderNone, borderRadius4px, cursorPointer, flexRow, inlineFlex, justifyCenter, outlineNone, overflowHidden, parseHeight, parseMinHeight, parseMinWidth, parseMinWidthHeight, parseWidthHeight, pointerEventsNone, positionRelative, userSelectNone } from "../../styles/general";
11
11
  import { useColor as colors, useTheme } from "../../theme";
12
12
  import { classNames, refType as ref } from "../../utils";
13
13
  import Ripple from "./ripple-effect";
@@ -279,7 +279,7 @@ const ButtonSizeCSS = (paddingSize, minHeightSize, minHeightSizeLink, outlinedPa
279
279
  ${parseMinHeight(minHeightSizeLink)};
280
280
  }
281
281
  .no-icon {
282
- ${noMargin};
282
+ margin: 0;
283
283
  ${parseHeight(iconSize)};
284
284
  ${parseMinWidth(0)};
285
285
  }
@@ -357,7 +357,7 @@ const ButtonRootCSS = color => css`
357
357
  }
358
358
  &.text {
359
359
  ${backgroundTransparent};
360
- ${noBorder};
360
+ ${borderNone};
361
361
  color: ${color};
362
362
  &.button--loading {
363
363
  background-color: ${hexToRGBA(color, alphaLoading)};
@@ -383,8 +383,8 @@ const ButtonRootCSS = color => css`
383
383
  }
384
384
  &.link {
385
385
  ${backgroundTransparent};
386
- ${noBorder};
387
- ${noPadding};
386
+ ${borderNone};
387
+ padding: 0;
388
388
  color: ${color};
389
389
  &.button--loading,
390
390
  &:hover,
@@ -73,10 +73,6 @@ const oldAttached = [];
73
73
  const allNewAttached = new FormData();
74
74
  const attached = [];
75
75
  const chosenItems = [];
76
- let prevent = false;
77
- let existClickOutOfItem = false;
78
- let maxSize = Infinity;
79
- let divideSize = null;
80
76
  const getType = data => {
81
77
  if (data.type !== undefined) {
82
78
  var _type$match;
@@ -168,8 +164,12 @@ const Attachment = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
168
164
  const popupRef = useRef(null);
169
165
  const popoverRef = useRef(null);
170
166
  const isDeleteAll = useRef(false);
171
- const PushNotify = useRef(null);
167
+ const notifyRef = useRef(null);
172
168
  const removedAttachedRef = useRef([]);
169
+ const prevent = useRef(null);
170
+ const existClickOutOfItem = useRef(null);
171
+ const divideSize = useRef(null);
172
+ const maxSize = useRef(Infinity);
173
173
  const timer = useRef(null);
174
174
  const [showModal, setShowModal] = useState(false);
175
175
  const [showPopup, setShowPopup] = useState(false);
@@ -246,19 +246,19 @@ const Attachment = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
246
246
  let files = e.target.files;
247
247
  const lengthAttached = attached.length;
248
248
  for (let i = 0; i < files.length; i++) {
249
- if (i + 1 > maxFile - lengthAttached || files[i].size > maxSize || checkExistingFile(files[i]) || !checkAcceptFileType(files[i])) {
249
+ if (i + 1 > maxFile - lengthAttached || files[i].size > maxSize.current || checkExistingFile(files[i]) || !checkAcceptFileType(files[i])) {
250
250
  if (i + 1 > maxFile - lengthAttached) {
251
251
  var _files$i;
252
- PushNotify.current(`${(_files$i = files[i]) === null || _files$i === void 0 ? void 0 : _files$i.name} - ${uploadErrorInfo['maxFile']}`);
253
- } else if (files[i].size > maxSize) {
252
+ notifyRef.current.instance.show(`${(_files$i = files[i]) === null || _files$i === void 0 ? void 0 : _files$i.name} - ${uploadErrorInfo['maxFile']}`);
253
+ } else if (files[i].size > maxSize.current) {
254
254
  var _files$i2;
255
- PushNotify.current(`${(_files$i2 = files[i]) === null || _files$i2 === void 0 ? void 0 : _files$i2.name} - ${uploadErrorInfo['maxSize']}`);
255
+ notifyRef.current.instance.show(`${(_files$i2 = files[i]) === null || _files$i2 === void 0 ? void 0 : _files$i2.name} - ${uploadErrorInfo['maxSize']}`);
256
256
  } else if (!checkAcceptFileType(files[i])) {
257
257
  var _files$i3;
258
- PushNotify.current(`${(_files$i3 = files[i]) === null || _files$i3 === void 0 ? void 0 : _files$i3.name} - ${uploadErrorInfo['fileType']}`);
258
+ notifyRef.current.instance.show(`${(_files$i3 = files[i]) === null || _files$i3 === void 0 ? void 0 : _files$i3.name} - ${uploadErrorInfo['fileType']}`);
259
259
  } else {
260
260
  var _files$i4;
261
- PushNotify.current(`${(_files$i4 = files[i]) === null || _files$i4 === void 0 ? void 0 : _files$i4.name} - ${uploadErrorInfo['existingFile']}`);
261
+ notifyRef.current.instance.show(`${(_files$i4 = files[i]) === null || _files$i4 === void 0 ? void 0 : _files$i4.name} - ${uploadErrorInfo['existingFile']}`);
262
262
  }
263
263
  files = removeFileOutInputFiles(i, true);
264
264
  i--;
@@ -410,8 +410,8 @@ const Attachment = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
410
410
  if (!size && size !== 0) return 'unknown';
411
411
  let totalSize;
412
412
  let unitSizeName;
413
- if (divideSize) {
414
- totalSize = size / divideSize;
413
+ if (divideSize.current) {
414
+ totalSize = size / divideSize.current;
415
415
  unitSizeName = unitSize.toUpperCase();
416
416
  while (totalSize < 0.01 && unitSizeName !== 'B') {
417
417
  [unitSizeName, totalSize] = getNewUnitSize(unitSizeName, totalSize, 1);
@@ -500,22 +500,15 @@ const Attachment = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
500
500
  };
501
501
  const onView = (node, AttachmentID) => {
502
502
  if (timer.current) {
503
- prevent = true;
503
+ prevent.current = true;
504
504
  clearTimeout(timer.current);
505
- // if (existClickOutOfItem) {
506
- // removeAllChosenItems();
507
- // attachedRef.current.querySelectorAll('.chosen').forEach(itemEl => {
508
- // itemEl.classList.remove('chosen');
509
- // })
510
- // }
511
505
  }
512
-
513
506
  const index = Array.from(attachedRef.current.children).indexOf(node);
514
507
  if (onViewProp) onViewProp(AttachmentID, index);else {
515
508
  setShowModal(true);
516
509
  }
517
510
  setTimeout(() => {
518
- prevent = false;
511
+ prevent.current = false;
519
512
  }, 110);
520
513
  };
521
514
  const onDownload = (url, name) => {
@@ -621,7 +614,7 @@ const Attachment = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
621
614
  const shiftKey = e.shiftKey;
622
615
  const itemEl = e.currentTarget;
623
616
  timer.current = setTimeout(() => {
624
- if (!prevent) {
617
+ if (!prevent.current) {
625
618
  const index = Array.from(attachedRef.current.children).indexOf(itemEl.parentNode);
626
619
  if (shiftKey && !ctrlKey) {
627
620
  let startIndex = chosenItems[chosenItems.length - 1] || 0;
@@ -663,15 +656,15 @@ const Attachment = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
663
656
  itemEl.classList.add('chosen');
664
657
  }
665
658
  // Add event listener click out of item
666
- if (!existClickOutOfItem) {
667
- existClickOutOfItem = true;
659
+ if (!existClickOutOfItem.current) {
660
+ existClickOutOfItem.current = true;
668
661
  attachmentHandleIconRef.current.style.display = 'block';
669
662
  document.addEventListener('keydown', onKeyDown);
670
663
  document.addEventListener('click', clickOutOfItem);
671
664
  }
672
665
  checkChosenMultiple();
673
666
  }
674
- prevent = false;
667
+ prevent.current = false;
675
668
  }, 100);
676
669
  };
677
670
  const removeActiveChosenItem = () => {
@@ -796,7 +789,7 @@ const Attachment = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
796
789
  };
797
790
  const removeAllChosenItems = () => {
798
791
  chosenItems.length = 0;
799
- existClickOutOfItem = false;
792
+ existClickOutOfItem.current = false;
800
793
  attachmentHandleIconRef.current.style.display = null;
801
794
  document.removeEventListener('keydown', onKeyDown);
802
795
  document.removeEventListener('click', clickOutOfItem);
@@ -847,7 +840,7 @@ const Attachment = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
847
840
  attached.length = 0;
848
841
  }
849
842
  return () => {
850
- existClickOutOfItem = false;
843
+ existClickOutOfItem.current = false;
851
844
  };
852
845
  }, []);
853
846
  useEffect(() => {
@@ -862,22 +855,22 @@ const Attachment = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
862
855
  useEffect(() => {
863
856
  switch (true) {
864
857
  case /^B$/i.test(unitSize):
865
- divideSize = 1;
858
+ divideSize.current = 1;
866
859
  break;
867
860
  case /KB/i.test(unitSize):
868
- divideSize = 1024;
861
+ divideSize.current = 1024;
869
862
  break;
870
863
  case /MB/i.test(unitSize):
871
- divideSize = 1024 ** 2;
864
+ divideSize.current = 1024 ** 2;
872
865
  break;
873
866
  case /GB/i.test(unitSize):
874
- divideSize = 1024 ** 3;
867
+ divideSize.current = 1024 ** 3;
875
868
  break;
876
869
  case /TB/i.test(unitSize):
877
- divideSize = 1024 ** 4;
870
+ divideSize.current = 1024 ** 4;
878
871
  break;
879
872
  default:
880
- divideSize = null;
873
+ divideSize.current = null;
881
874
  break;
882
875
  }
883
876
  attachmentInputRef.current.addEventListener('change', onChangeFiles);
@@ -888,11 +881,11 @@ const Attachment = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
888
881
  useEffect(() => {
889
882
  if (maxSizeProp) {
890
883
  if (!isNaN(maxSizeProp)) {
891
- maxSize = maxSizeProp * 1024 * 1024;
884
+ maxSize.current = maxSizeProp * 1024 * 1024;
892
885
  } else {
893
886
  const numberSize = maxSizeProp.match(/\d+/g);
894
887
  const unitMaxSize = maxSizeProp.match(/\D+/g);
895
- maxSize = getBit(numberSize, unitMaxSize);
888
+ maxSize.current = getBit(numberSize, unitMaxSize);
896
889
  }
897
890
  }
898
891
  attachmentInputRef.current.multiple = multiple;
@@ -905,7 +898,7 @@ const Attachment = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
905
898
  attachmentInputRef.current.removeEventListener('change', onChangeFiles);
906
899
  attachmentInputRef.current.accept = null;
907
900
  }
908
- maxSize = Infinity;
901
+ maxSize.current = Infinity;
909
902
  };
910
903
  }, [maxFile, maxSizeProp, multiple, accept]);
911
904
  useEffect(() => {
@@ -1148,13 +1141,9 @@ const Attachment = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
1148
1141
  style: style,
1149
1142
  onDragEnter: onDragFileStart
1150
1143
  }, AttachHeaderView, AttachmentInputView, AttachedView, PopupView, ModalView, jsx(Notify, {
1151
- getAddNotify: func => PushNotify.current = func,
1144
+ ref: notifyRef,
1152
1145
  progressing: true,
1153
1146
  autoDisappear: true,
1154
- position: {
1155
- vertical: 'bottom',
1156
- horizontal: 'center'
1157
- },
1158
1147
  color: 'danger'
1159
1148
  }));
1160
1149
  }));
@@ -1193,8 +1182,6 @@ const AttachmentInputCSS = css`
1193
1182
  ${positionRelative};
1194
1183
  ${parseWidthHeight('100%', 'calc(100% + 20px)')};
1195
1184
  opacity: 0;
1196
- top: ${spacing([-5])};
1197
- font-size: 0px;
1198
1185
  }
1199
1186
  `;
1200
1187
  const AttachmentImageCenterCSS = css`
@@ -1258,17 +1245,17 @@ const AttachedItemOwnerCSS = css`
1258
1245
  color: ${textSub};
1259
1246
  .detail-info {
1260
1247
  ${flexRow};
1261
- min-width: 333px;
1248
+ ${parseMinWidth(333)};
1262
1249
  .username {
1263
1250
  ${displayInlineBlock};
1264
1251
  ${ellipsis};
1265
- min-width: 120px;
1266
- max-width: 120px;
1252
+ ${parseMinWidth(120)};
1253
+ ${parseMaxWidth(120)};
1267
1254
  }
1268
1255
  .datetime {
1269
1256
  ${displayInlineBlock};
1270
- min-width: max-content;
1271
- max-width: max-content;
1257
+ ${parseMinWidth('max-content')};
1258
+ ${parseMaxWidth('max-content')};
1272
1259
  }
1273
1260
  .filesize {
1274
1261
  float: right;
@@ -94,7 +94,7 @@ const InputBase = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
94
94
  const widthInit = useRef(null);
95
95
  const isEnabled = !readOnly && !disabled;
96
96
  const _InputBaseCSS = InputBaseCSS(readOnly, status);
97
- const _SingleLineCSS = SingleLineCSS(autoWidth);
97
+ const _SingleLineCSS = SingleLineCSS(autoWidth, readOnly);
98
98
  const _InputCSS = InputCSS(autoWidth, isEnabled, hoverTooltip);
99
99
  const _TypoCSS = TypoCSS(disabled);
100
100
  const _TextAreaCSS = TextAreaCSS(resize, readOnly);
@@ -410,16 +410,18 @@ const InputBaseCSS = (readOnly, status) => css`
410
410
  top: 100%;
411
411
  }
412
412
  `;
413
- const SingleLineCSS = autoWidth => css`
413
+ const SingleLineCSS = (autoWidth, readOnly) => css`
414
414
  ${parseWidthHeight(autoWidth ? 'max-content' : 'auto', 'max-content')}
415
415
  ${alignCenter};
416
416
  flex: 1 1 auto;
417
417
  &:focus-within {
418
- border-bottom-color: ${semanticInfo};
419
- &::after {
420
- border-bottom-color: inherit;
421
- transform: scaleX(1);
422
- }
418
+ ${!readOnly && `
419
+ border-bottom-color: ${semanticInfo};
420
+ &::after {
421
+ border-bottom-color: inherit;
422
+ transform: scaleX(1);
423
+ }
424
+ `}
423
425
  }
424
426
  &.outlined {
425
427
  ${parseHeight(40)};
@@ -254,7 +254,7 @@ const CircleMainCSS = color => css`
254
254
  const CircleMainDeterminateCSS = (circumference, percent, directionAngle, duration) => css`
255
255
  stroke-dasharray: ${`${circumference} ${circumference}`};
256
256
  stroke-dashoffset: ${circumference - validatePercent(percent) / 100 * circumference};
257
- transform: rotate(${directionAngle}deg);
257
+ // transform: rotate(${directionAngle}deg);
258
258
  transform-origin: center;
259
259
  transition: stroke-dashoffset ${duration}s cubic-bezier(0.77, 0, 0.175, 1); /* easeInOutQuart */
260
260
  `;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "diginet-core-ui",
3
- "version": "1.3.80-beta.5",
3
+ "version": "1.3.80-beta.7",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "license": "UNLICENSED",