diginet-core-ui 1.3.96-beta.1 → 1.3.96-beta.3

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
  })),
@@ -360,7 +360,7 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
360
360
  const length = currentObjectDefault[unique].length;
361
361
  let existItemQuantity = 0;
362
362
  for (let index = length - 1; index >= 0; index--) {
363
- if (!dataSourceUsable.some(data => data[valueExpr] === currentObjectDefault[unique][index][valueExpr])) {
363
+ if ((currentObjectDefault[unique][index][valueExpr] || currentObjectDefault[unique][index][valueExpr] === 0) && !dataSourceUsable.some(data => data[valueExpr] === currentObjectDefault[unique][index][valueExpr])) {
364
364
  dataSourceUsable.unshift(currentObjectDefault[unique][index]);
365
365
  } else {
366
366
  // Nếu số lượng phần tử của valueObjectDefault tồn tại trong dataSource nhiều hơn hoặc bằng limit thì không remove nữa
@@ -1,11 +1,11 @@
1
1
  /** @jsxRuntime classic */
2
2
  /** @jsx jsx */
3
3
  import { css, jsx, keyframes } from '@emotion/core';
4
- import AvatarDefault from "../../assets/avatar/default.svg";
4
+ import ImageDefault from "../../assets/image/default.jpg";
5
5
  import OptionWrapper from "../others/option-wrapper";
6
6
  import PropTypes from 'prop-types';
7
7
  import { forwardRef, Fragment, memo, useEffect, useImperativeHandle, useMemo, useRef, useState } from 'react';
8
- import { borderRadius, displayInlineFlex, itemsCenter, objectCover, overflowHidden, parseWidthHeight, positionRelative } from "../../styles/general";
8
+ import { animation, borderRadius, displayInlineFlex, itemsCenter, objectCover, overflowHidden, parseWidthHeight, positionRelative } from "../../styles/general";
9
9
  import { classNames, useIntersection } from "../../utils";
10
10
  const blurKeyframe = keyframes`
11
11
  0% { -webkit-filter: blur(4px);}
@@ -29,7 +29,7 @@ const Image = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
29
29
  width
30
30
  }, reference) => {
31
31
  if (!reference) reference = useRef(null);
32
- if (!defaultSrc) defaultSrc = AvatarDefault;
32
+ if (!defaultSrc) defaultSrc = ImageDefault;
33
33
  const ref = useRef(null);
34
34
  const [srcState, setSrcState] = useState(src);
35
35
  const [isInView, setIsInView] = useState(false);
@@ -106,7 +106,10 @@ const ImageCSS = (width, height, circular) => css`
106
106
  ${circular && borderRadius('50%')};
107
107
  `;
108
108
  const blurAnimationCSS = css`
109
- animation: ${blurKeyframe} 1s ease;
109
+ ${animation({
110
+ keyframes: blurKeyframe,
111
+ duration: '1s'
112
+ })}
110
113
  `;
111
114
  Image.defaultProps = {
112
115
  circular: false,
@@ -7,7 +7,7 @@ import { forwardRef, memo, useEffect, useImperativeHandle, useMemo, useRef, useS
7
7
  import { createPortal } from 'react-dom';
8
8
  import { animations } from "../../styles/animation";
9
9
  import { bgColor, borderRadius, boxBorder, cursorMove, displayFlex, flexCol, flexRow, justifyCenter, left, parseMaxWidthHeight, parseMinWidth, parseWidthHeight, pdt, positionAbsolute, positionRelative, top } from "../../styles/general";
10
- import { useTheme } from "../../theme";
10
+ import { makeStyles, useTheme } from "../../theme";
11
11
  import { classNames, useDelayUnmount } from "../../utils";
12
12
  import ModalContext from "./context";
13
13
  const {
@@ -16,6 +16,12 @@ const {
16
16
  },
17
17
  zIndex: zIndexCORE
18
18
  } = useTheme();
19
+ const useStyles = makeStyles({
20
+ noScroll: {
21
+ key: props => `DGN-Modal-${props}`,
22
+ overflow: 'hidden'
23
+ }
24
+ });
19
25
  const fadeInDown = animations.fadeInDown;
20
26
  const fadeOutUp = animations.fadeOutUp;
21
27
  const Modal = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
@@ -38,7 +44,8 @@ const Modal = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
38
44
  }, reference) => {
39
45
  if (!reference) reference = useRef(null);
40
46
  const ref = useRef(null);
41
- const overflow = useRef(null);
47
+
48
+ // const overflow = useRef(null);
42
49
  const modalBoxRef = useRef(null);
43
50
  const [openState, setOpenState] = useState(open);
44
51
  const showModal = useDelayUnmount(openState, 200);
@@ -48,7 +55,6 @@ const Modal = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
48
55
  setOpenState(true);
49
56
  };
50
57
  const onCloseModal = () => {
51
- document.body.style.overflow = overflow.current; // reset overflow of <body /> before open modal
52
58
  onClose && onClose();
53
59
  setOpenState(false);
54
60
  };
@@ -109,36 +115,34 @@ const Modal = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
109
115
  modalBoxRef.current.style.left = newLeft + 'px';
110
116
  };
111
117
  };
112
- useEffect(() => {
113
- return () => {
114
- document.body.style.overflow = overflow.current; // reset overflow of <body /> before open modal
115
- };
116
- }, []);
117
118
  useEffect(() => {
118
119
  setOpenState(open);
119
120
  }, [open]);
120
121
  useEffect(() => {
121
- if (openState) {
122
- if (ref.current) {
123
- const modals = document.querySelectorAll('.DGN-UI-Modal');
124
- if (!darkTheme && modals && modals.length > 1) {
125
- ref.current.style.backgroundColor = 'transparent';
126
- }
127
- if (autoFocus) {
128
- if (!ref.current.contains(document.activeElement)) {
129
- ref.current.tabIndex = -1;
130
- ref.current.focus();
131
- }
122
+ if (openState && ref.current) {
123
+ const modals = document.querySelectorAll('.DGN-UI-Modal');
124
+ if (!darkTheme && modals && modals.length > 1) {
125
+ ref.current.style.backgroundColor = 'transparent';
126
+ }
127
+ if (autoFocus) {
128
+ if (!ref.current.contains(document.activeElement)) {
129
+ ref.current.tabIndex = -1;
130
+ ref.current.focus();
132
131
  }
133
132
  }
134
- overflow.current = document.body.style.overflow; // overflow of <body /> before open modal
135
- document.body.style.overflow = 'hidden';
133
+ const timestamp = Date.now();
134
+ const classes = useStyles(timestamp);
135
+ const noScrollClass = classes.noScroll.split(' ');
136
+ document.body.classList.add(...noScrollClass);
137
+ // overflow.current = document.body.style.overflow; // overflow of <body /> before open modal
138
+ // document.body.style.overflow = 'hidden';
136
139
  // Allow press ESC to close popup
137
140
  if (pressESCToClose) {
138
141
  document.addEventListener('keydown', pressESCHandler);
139
142
  }
140
143
  return () => {
141
- document.body.style.overflow = overflow.current; // reset overflow of <body /> before open modal
144
+ document.body.classList.remove(...noScrollClass);
145
+ // document.body.style.overflow = overflow.current; // reset overflow of <body /> before open modal
142
146
  if (pressESCToClose) {
143
147
  document.removeEventListener('keydown', pressESCHandler);
144
148
  }
@@ -6,7 +6,7 @@ import PropTypes from 'prop-types';
6
6
  import React, { forwardRef, memo, useEffect, useImperativeHandle, useMemo, useRef, useState } from 'react';
7
7
  import { createPortal } from 'react-dom';
8
8
  import { bgColor, borderBottom, borderRadius4px, displayFlex, displayNone, flexCol, inset, justifyBetween, overflowAuto, parseMaxWidthHeight, parseMinWidthHeight, parseWidthHeight, pointerEventsInitial, pointerEventsNone, positionAbsolute, positionFixed, positionRelative } from "../../styles/general";
9
- import { useTheme } from "../../theme";
9
+ import { makeStyles, useTheme } from "../../theme";
10
10
  import { classNames, isMobile, refType as ref } from "../../utils";
11
11
  const {
12
12
  typography: {
@@ -15,6 +15,12 @@ const {
15
15
  spacing,
16
16
  zIndex: zIndexCORE
17
17
  } = useTheme();
18
+ const useStyles = makeStyles({
19
+ noScroll: {
20
+ key: props => `DGN-Popover-${props}`,
21
+ overflow: 'hidden'
22
+ }
23
+ });
18
24
  const eventMap = new Map([['click', ['click']], ['hover', ['mouseenter', 'mouseleave']], ['focus', ['focus', 'blur']]]);
19
25
  const getArrowPosition = (anchorOrigin, transformOrigin, translate) => {
20
26
  if (anchorOrigin.horizontal === 'right' && transformOrigin.horizontal === 'left') {
@@ -139,7 +145,7 @@ const Popover = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
139
145
  if (isMobile.any() && trigger === 'hover') trigger = 'click';
140
146
  const ref = useRef(null);
141
147
  const arrowRef = useRef(null);
142
- const overflow = useRef(null);
148
+ // const overflow = useRef(null);
143
149
  const anchorRef = useRef(anchor);
144
150
  const [openState, setOpenState] = useState(open);
145
151
  const [element, setElement] = useState(null);
@@ -406,10 +412,14 @@ const Popover = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
406
412
  }, [open]);
407
413
  useEffect(() => {
408
414
  if (openState && ref.current) {
409
- if (document.body.style.overflow !== 'hidden') {
410
- overflow.current = document.body.style.overflow; // store overflow of <body /> before open
411
- document.body.style.overflow = 'hidden';
412
- }
415
+ // if (document.body.style.overflow !== 'hidden') {
416
+ // overflow.current = document.body.style.overflow; // store overflow of <body /> before open
417
+ // document.body.style.overflow = 'hidden';
418
+ // }
419
+ const timestamp = Date.now();
420
+ const classes = useStyles(timestamp);
421
+ const noScrollClass = classes.noScroll.split(' ');
422
+ document.body.classList.add(...noScrollClass);
413
423
  // Position's anchor
414
424
  updatePositionPopover();
415
425
 
@@ -424,7 +434,8 @@ const Popover = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
424
434
  window.addEventListener('resize', updatePositionPopover);
425
435
  if (trigger === 'hover') ref.current.addEventListener('mouseleave', handleEventTrigger, false);
426
436
  return () => {
427
- document.body.style.overflow = overflow.current; // reset overflow of <body /> before open
437
+ document.body.classList.remove(...noScrollClass);
438
+ // document.body.style.overflow = overflow.current; // reset overflow of <body /> before open
428
439
  if (pressESCToClose) {
429
440
  document.removeEventListener('keydown', pressESCHandler);
430
441
  }
@@ -432,9 +443,10 @@ const Popover = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
432
443
  window.removeEventListener('resize', updatePositionPopover);
433
444
  if (trigger === 'hover' && ref.current) ref.current.removeEventListener('mouseleave', handleEventTrigger, false);
434
445
  };
435
- } else if (!openState) {
436
- document.documentElement.style.overflow = overflow.current;
437
446
  }
447
+ // else if (!openState) {
448
+ // document.documentElement.style.overflow = overflow.current;
449
+ // }
438
450
  }, [openState]);
439
451
  useEffect(() => {
440
452
  clickOutsideToClose ? document.addEventListener('click', onClickOutside) : document.removeEventListener('click', onClickOutside);
@@ -5,24 +5,15 @@ import { Popover } from "./..";
5
5
  import PropTypes from 'prop-types';
6
6
  import { forwardRef, Fragment, memo, useImperativeHandle, useMemo, useRef, useState } from 'react';
7
7
  import { breakAll, breakWord, cursorPointer, displayBlock, displayInlineBlock, italic, overflowHidden, parseHeight, parseMaxWidth, parseMinWidth, pd, positionRelative, textCapitalize, textCenter, textColor, textLineThrough, textLowercase, textSentence, textUnderline, textUppercase, whiteSpaceBreakSpaces } from "../../styles/general";
8
- import { useTheme, useTypography as typography } from "../../theme";
8
+ import { useTypography as typography } from "../../theme";
9
9
  import { classNames, renderHTML } from "../../utils";
10
- const {
11
- colors: {
12
- text: {
13
- main: textMain
14
- },
15
- fill: {
16
- tooltip: fillTooltip
17
- }
18
- }
19
- } = useTheme();
20
- const colorMap = new Map([['default', textMain]]);
10
+ const colorMap = new Map([['default', 'text/main']]);
21
11
  const formatMap = new Map([['capitalize', textCapitalize], ['uppercase', textUppercase], ['lowercase', textLowercase], ['italic', italic], ['line-through', textLineThrough], ['underline', textUnderline], ['sentence', textSentence]]);
22
12
  const isTextClamped = elm => (elm === null || elm === void 0 ? void 0 : elm.scrollHeight) > (elm === null || elm === void 0 ? void 0 : elm.clientHeight);
23
13
  const Typography = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
24
14
  action = {},
25
15
  capitalize,
16
+ // deprecated
26
17
  center,
27
18
  children,
28
19
  className,
@@ -37,17 +28,20 @@ const Typography = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
37
28
  tooltipDirection,
38
29
  type,
39
30
  uppercase,
31
+ // deprecated
40
32
  ...props
41
33
  }, reference) => {
42
34
  var _ref$current;
43
35
  if (!reference) reference = useRef(null);
44
36
  const ref = useRef(null);
45
37
  const formatCSS = [];
46
- format.forEach(item => {
47
- formatCSS.push(formatMap.get(item));
48
- });
38
+ if (Array.isArray(format)) {
39
+ format.forEach(item => {
40
+ formatCSS.push(formatMap.get(item));
41
+ });
42
+ }
49
43
  const [openTooltip, setOpenTooltip] = useState(false);
50
- const _TextRootCSS = [TextRootCSS(color, type, lineClamp, onClick, hoverTooltip), ...formatCSS];
44
+ const _TextRootCSS = [TextRootCSS(color, type, lineClamp, onClick, hoverTooltip, center, fullWidth, uppercase, capitalize), ...formatCSS];
51
45
  const showTooltip = () => {
52
46
  if (!hoverTooltip) return;
53
47
  if (isTextClamped(ref.current)) {
@@ -70,26 +64,26 @@ const Typography = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
70
64
  currentRef.instance = _instance;
71
65
  return currentRef;
72
66
  });
73
- const classes = (inTooltip = false) => classNames('DGN-UI-Typography', center && 'DGN-Typography-center', fullWidth && 'DGN-Typography-fullWidth', `DGN-Typography-${type}`, uppercase && `DGN-Typography-Uppercase`, capitalize && 'DGN-Typography-Capitalize', !inTooltip && lineClamp && 'DGN-Typography-Clamp', className);
67
+ const classes = classNames('DGN-UI-Typography', `DGN-UI-Typography-${type}`, className);
74
68
  const content = Array.isArray(children) && !children.some(node => node && String(node.$$typeof) === 'Symbol(react.element)') ? children.join('') : children;
75
69
  const renderTooltip = hoverTooltip ? jsx(Popover, {
76
- css: [parseMinWidth(300)],
70
+ css: parseMinWidth(300),
77
71
  open: openTooltip,
78
72
  pressESCToClose: false,
79
73
  fullScreen: false,
80
- bgColor: fillTooltip,
74
+ bgColor: 'fill/tooltip',
81
75
  anchor: ref,
82
76
  width: ((_ref$current = ref.current) === null || _ref$current === void 0 ? void 0 : _ref$current.clientWidth) || 'max-content',
83
77
  direction: tooltipDirection
84
78
  }, renderHTML(content, mapping, {
85
79
  css: [_TextRootCSS, PopoverContentCSS],
86
- className: classes(true)
80
+ className: classes
87
81
  })) : null;
88
82
  return useMemo(() => {
89
83
  return jsx(Fragment, null, renderHTML(content, mapping, {
90
84
  ref: ref,
91
- css: _TextRootCSS,
92
- className: classes(),
85
+ css: [_TextRootCSS, lineClamp && ClampCSS(lineClamp)],
86
+ className: classes,
93
87
  onMouseEnter: showTooltip,
94
88
  onMouseLeave: hideTooltip,
95
89
  onClick: onClick,
@@ -97,7 +91,7 @@ const Typography = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
97
91
  }), renderTooltip);
98
92
  }, [capitalize, center, children, className, color, format, fullWidth, hoverTooltip, italic, lineClamp, mapping, onClick, props, tooltipDirection, type, uppercase, openTooltip]);
99
93
  }));
100
- const TextRootCSS = (color, type, lineClamp, onClick, hoverTooltip) => css`
94
+ const TextRootCSS = (color, type, lineClamp, onClick, hoverTooltip, center, fullWidth, uppercase, capitalize) => css`
101
95
  ${displayInlineBlock};
102
96
  ${positionRelative};
103
97
  ${onClick && cursorPointer};
@@ -106,28 +100,22 @@ const TextRootCSS = (color, type, lineClamp, onClick, hoverTooltip) => css`
106
100
  ${textColor(colorMap.get(color) || color)};
107
101
  ${parseMaxWidth('max-content')};
108
102
  ${type !== 'inherit' && typography[type]};
109
- &.DGN-Typography-center {
110
- ${textCenter};
111
- }
112
- &.DGN-Typography-fullWidth {
103
+ ${center && textCenter};
104
+ ${uppercase && textUppercase};
105
+ ${capitalize && textCapitalize};
106
+ ${fullWidth && css`
113
107
  ${displayBlock};
114
108
  ${parseMaxWidth('initial')};
115
- }
116
- &.DGN-Typography-Uppercase {
117
- ${textUppercase};
118
- }
119
- &.DGN-Typography-Capitalize {
120
- ${textCapitalize};
121
- }
122
- &.DGN-Typography-Clamp {
123
- ${overflowHidden};
124
- display: -webkit-box;
125
- -webkit-line-clamp: ${lineClamp};
126
- -webkit-box-orient: vertical;
127
- }
109
+ `}
110
+ `;
111
+ const ClampCSS = lineClamp => css`
112
+ ${overflowHidden};
113
+ display: -webkit-box;
114
+ -webkit-line-clamp: ${lineClamp};
115
+ -webkit-box-orient: vertical;
128
116
  `;
129
117
  const PopoverContentCSS = css`
130
- ${textColor('text.tooltip')};
118
+ ${textColor('text/tooltip')};
131
119
  ${pd([1, 1.5])};
132
120
  ${parseHeight('fit-content')};
133
121
  `;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "diginet-core-ui",
3
- "version": "1.3.96-beta.1",
3
+ "version": "1.3.96-beta.3",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "license": "UNLICENSED",
@@ -11,7 +11,7 @@ const renderHTML = (text = null, TagName = 'div', options = {}) => {
11
11
  return jsx(TagName, {
12
12
  ...options,
13
13
  dangerouslySetInnerHTML: {
14
- __html: parseTextToHTML(String(text))
14
+ __html: parseTextToHTML(String(text !== null && text !== void 0 ? text : ''))
15
15
  }
16
16
  });
17
17
  };