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

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.
@@ -87,24 +87,27 @@ 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) => 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 => {
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 => {
108
111
  return /*#__PURE__*/React.isValidElement(child);
109
112
  }).map((child, idx) => {
110
113
  var _React$Children$toArr;
@@ -181,7 +184,6 @@ Breadcrumb.propTypes = {
181
184
  /** Class for component. */
182
185
  data: PropTypes.arrayOf(PropTypes.shape({
183
186
  label: PropTypes.string,
184
- icon: PropTypes.string,
185
187
  href: PropTypes.string,
186
188
  onClick: PropTypes.func
187
189
  })),
@@ -1299,7 +1299,6 @@ Attachment.defaultProps = {
1299
1299
  fileType: getGlobal(['errorDefault', 'fileType']),
1300
1300
  existingFile: getGlobal(['errorDefault', 'existingFile'])
1301
1301
  },
1302
- viewType: 'detail',
1303
1302
  ...getGlobal(['components', 'attachment', 'defaultProps'])
1304
1303
  };
1305
1304
  Attachment.propTypes = {
@@ -306,10 +306,10 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
306
306
  // }
307
307
  // };
308
308
 
309
- /**
310
- * So sánh text đầu vào cáo map với txtSearch
311
- * @param text
312
- * @return {boolean}
309
+ /**
310
+ * So sánh text đầu vào cáo map với txtSearch
311
+ * @param text
312
+ * @return {boolean}
313
313
  */
314
314
  const handleRenderBySearch = (text = '') => {
315
315
  if (!txtSearch || typeof text !== 'string') return true;
@@ -320,10 +320,10 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
320
320
  } else return text.toLowerCase().includes(txtSearch.toLowerCase());
321
321
  };
322
322
 
323
- /**
324
- * Chuyển đổi data thành giá trị cần hiện thị dựa vào displayExpr [string, string object {field} - {field}], renderSelectedItem, displayExpr, valueExpr
325
- * @param data {object} rowData of dataSource
326
- * @return {string}
323
+ /**
324
+ * Chuyển đổi data thành giá trị cần hiện thị dựa vào displayExpr [string, string object {field} - {field}], renderSelectedItem, displayExpr, valueExpr
325
+ * @param data {object} rowData of dataSource
326
+ * @return {string}
327
327
  */
328
328
  const displayValue = data => {
329
329
  let text = '';
@@ -1634,9 +1634,9 @@ Dropdown.propTypes = {
1634
1634
  defaultValue: PropTypes.oneOfType([PropTypes.string, PropTypes.number, PropTypes.array]),
1635
1635
  /** If `true`, the component is disabled. */
1636
1636
  disabled: PropTypes.bool,
1637
- /** Field name used for text display in dropdown list.<br/>
1638
- * Example: 'name', '{id} - {name}', '{age} age(s)'<br/>
1639
- * Note: don't use 'id - name', return undefined
1637
+ /** Field name used for text display in dropdown list.<br/>
1638
+ * Example: 'name', '{id} - {name}', '{age} age(s)'<br/>
1639
+ * Note: don't use 'id - name', return undefined
1640
1640
  */
1641
1641
  displayExpr: PropTypes.oneOfType([PropTypes.string, PropTypes.number, PropTypes.array]),
1642
1642
  /** Style inline of dropdown items. */
@@ -1645,14 +1645,14 @@ Dropdown.propTypes = {
1645
1645
  error: PropTypes.oneOfType([PropTypes.bool, PropTypes.string]),
1646
1646
  /** Props applied to the [HelperText](https://core.diginet.com.vn/ui/?path=/story/form-control-text-helpertext) element. */
1647
1647
  helperTextProps: PropTypes.object,
1648
- /** Field name used for icon display.<br/>
1649
- * Example:<br/>
1650
- * &nbsp;&nbsp;string: 'icon'<br/>
1651
- * &nbsp;&nbsp;object: {<br/>
1652
- * &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;key: 'icon',<br/>
1653
- * &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;prefix: 'https://imglink.com',<br/>
1654
- * &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;suffix: '.jpg'<br/>
1655
- * &nbsp;&nbsp;}
1648
+ /** Field name used for icon display.<br/>
1649
+ * Example:<br/>
1650
+ * &nbsp;&nbsp;string: 'icon'<br/>
1651
+ * &nbsp;&nbsp;object: {<br/>
1652
+ * &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;key: 'icon',<br/>
1653
+ * &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;prefix: 'https://imglink.com',<br/>
1654
+ * &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;suffix: '.jpg'<br/>
1655
+ * &nbsp;&nbsp;}
1656
1656
  */
1657
1657
  iconExpr: PropTypes.oneOfType([PropTypes.string, PropTypes.shape({
1658
1658
  key: PropTypes.string,
@@ -1686,8 +1686,8 @@ Dropdown.propTypes = {
1686
1686
  onChange: PropTypes.func,
1687
1687
  /** Callback fired when dropdown closed. */
1688
1688
  onClosed: PropTypes.func,
1689
- /** Callback fired when the input value changes.<br/>
1690
- * if undefined: the filter function will run (default)
1689
+ /** Callback fired when the input value changes.<br/>
1690
+ * if undefined: the filter function will run (default)
1691
1691
  */
1692
1692
  onInput: PropTypes.func,
1693
1693
  /** Callback fired when key down input */
@@ -1698,21 +1698,21 @@ Dropdown.propTypes = {
1698
1698
  placeholder: PropTypes.string,
1699
1699
  /** If `true`, the component is read-only. */
1700
1700
  readOnly: PropTypes.bool,
1701
- /** Function displays items by custom.<br/>
1702
- * renderItem={(data, index) => data.name + ' - ' + data.role}<br/>
1703
- * --> such as: displayExpr={'name - role'}
1701
+ /** Function displays items by custom.<br/>
1702
+ * renderItem={(data, index) => data.name + ' - ' + data.role}<br/>
1703
+ * --> such as: displayExpr={'name - role'}
1704
1704
  */
1705
1705
  renderItem: PropTypes.func,
1706
- /** Function or field name used for display selected items, example:<br/>
1707
- * renderSelectedItem={(data, index) => index + ' - ' + data.name}<br/>
1706
+ /** Function or field name used for display selected items, example:<br/>
1707
+ * renderSelectedItem={(data, index) => index + ' - ' + data.name}<br/>
1708
1708
  */
1709
1709
  renderSelectedItem: PropTypes.oneOfType([PropTypes.func, PropTypes.string]),
1710
1710
  /** If `true`, the label will indicate that the input is required. */
1711
1711
  required: PropTypes.bool,
1712
- /**
1713
- * Duration wait enter search content on search.<br/>
1714
- * Example: 700 -> 700ms, '700ms' -> 700ms, '0.7s' -> 700ms, '1m' -> 60000ms
1715
- * If `true`, used default delayOnInput.
1712
+ /**
1713
+ * Duration wait enter search content on search.<br/>
1714
+ * Example: 700 -> 700ms, '700ms' -> 700ms, '0.7s' -> 700ms, '1m' -> 60000ms
1715
+ * If `true`, used default delayOnInput.
1716
1716
  */
1717
1717
  searchDelayTime: PropTypes.oneOfType([PropTypes.string, PropTypes.number, PropTypes.bool]),
1718
1718
  /** Specifies a data object's field name or an expression whose value is compared to the search string. */
@@ -1739,19 +1739,19 @@ Dropdown.propTypes = {
1739
1739
  valueObjectDefault: PropTypes.oneOfType([PropTypes.object, PropTypes.array]),
1740
1740
  /**The variant to use. */
1741
1741
  viewType: PropTypes.oneOf(['underlined', 'outlined', 'none'])
1742
- /**
1743
- * ref methods
1744
- *
1745
- * how to get component element? ref.current
1746
- *
1747
- * how to call method? ref.current.instance.{method}
1748
- *
1749
- * * showDropdown(): Show dropdown
1750
- * * closeDropdown(): Close dropdown
1751
- * * onClear(): Clear selected value
1752
- * * setPreviousValue(): Set value to previous value
1753
- * * setValue(value): Set value of dropdown
1754
- * * @param {value} - string || number || array
1742
+ /**
1743
+ * ref methods
1744
+ *
1745
+ * how to get component element? ref.current
1746
+ *
1747
+ * how to call method? ref.current.instance.{method}
1748
+ *
1749
+ * * showDropdown(): Show dropdown
1750
+ * * closeDropdown(): Close dropdown
1751
+ * * onClear(): Clear selected value
1752
+ * * setPreviousValue(): Set value to previous value
1753
+ * * setValue(value): Set value of dropdown
1754
+ * * @param {value} - string || number || array
1755
1755
  */
1756
1756
  };
1757
1757
 
@@ -1,11 +1,11 @@
1
1
  /** @jsxRuntime classic */
2
2
  /** @jsx jsx */
3
3
  import { css, jsx, keyframes } from '@emotion/core';
4
- import ImageDefault from "../../assets/image/default.jpg";
4
+ import AvatarDefault from "../../assets/avatar/default.svg";
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 { animation, borderRadius, displayInlineFlex, itemsCenter, objectCover, overflowHidden, parseWidthHeight, positionRelative } from "../../styles/general";
8
+ import { 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 = ImageDefault;
32
+ if (!defaultSrc) defaultSrc = AvatarDefault;
33
33
  const ref = useRef(null);
34
34
  const [srcState, setSrcState] = useState(src);
35
35
  const [isInView, setIsInView] = useState(false);
@@ -106,10 +106,7 @@ const ImageCSS = (width, height, circular) => css`
106
106
  ${circular && borderRadius('50%')};
107
107
  `;
108
108
  const blurAnimationCSS = css`
109
- ${animation({
110
- keyframes: blurKeyframe,
111
- duration: '1s'
112
- })}
109
+ animation: ${blurKeyframe} 1s ease;
113
110
  `;
114
111
  Image.defaultProps = {
115
112
  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 { makeStyles, useTheme } from "../../theme";
10
+ import { useTheme } from "../../theme";
11
11
  import { classNames, useDelayUnmount } from "../../utils";
12
12
  import ModalContext from "./context";
13
13
  const {
@@ -16,12 +16,6 @@ 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
- });
25
19
  const fadeInDown = animations.fadeInDown;
26
20
  const fadeOutUp = animations.fadeOutUp;
27
21
  const Modal = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
@@ -44,8 +38,7 @@ const Modal = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
44
38
  }, reference) => {
45
39
  if (!reference) reference = useRef(null);
46
40
  const ref = useRef(null);
47
-
48
- // const overflow = useRef(null);
41
+ const overflow = useRef(null);
49
42
  const modalBoxRef = useRef(null);
50
43
  const [openState, setOpenState] = useState(open);
51
44
  const showModal = useDelayUnmount(openState, 200);
@@ -55,6 +48,7 @@ const Modal = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
55
48
  setOpenState(true);
56
49
  };
57
50
  const onCloseModal = () => {
51
+ document.body.style.overflow = overflow.current; // reset overflow of <body /> before open modal
58
52
  onClose && onClose();
59
53
  setOpenState(false);
60
54
  };
@@ -115,34 +109,36 @@ const Modal = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
115
109
  modalBoxRef.current.style.left = newLeft + 'px';
116
110
  };
117
111
  };
112
+ useEffect(() => {
113
+ return () => {
114
+ document.body.style.overflow = overflow.current; // reset overflow of <body /> before open modal
115
+ };
116
+ }, []);
118
117
  useEffect(() => {
119
118
  setOpenState(open);
120
119
  }, [open]);
121
120
  useEffect(() => {
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();
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
+ }
131
132
  }
132
133
  }
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';
134
+ overflow.current = document.body.style.overflow; // overflow of <body /> before open modal
135
+ document.body.style.overflow = 'hidden';
139
136
  // Allow press ESC to close popup
140
137
  if (pressESCToClose) {
141
138
  document.addEventListener('keydown', pressESCHandler);
142
139
  }
143
140
  return () => {
144
- document.body.classList.remove(...noScrollClass);
145
- // document.body.style.overflow = overflow.current; // reset overflow of <body /> before open modal
141
+ document.body.style.overflow = overflow.current; // reset overflow of <body /> before open modal
146
142
  if (pressESCToClose) {
147
143
  document.removeEventListener('keydown', pressESCHandler);
148
144
  }
@@ -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 { makeStyles, useTheme } from "../../theme";
9
+ import { useTheme } from "../../theme";
10
10
  import { classNames, isMobile, refType as ref } from "../../utils";
11
11
  const {
12
12
  typography: {
@@ -15,12 +15,6 @@ 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
- });
24
18
  const eventMap = new Map([['click', ['click']], ['hover', ['mouseenter', 'mouseleave']], ['focus', ['focus', 'blur']]]);
25
19
  const getArrowPosition = (anchorOrigin, transformOrigin, translate) => {
26
20
  if (anchorOrigin.horizontal === 'right' && transformOrigin.horizontal === 'left') {
@@ -145,7 +139,7 @@ const Popover = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
145
139
  if (isMobile.any() && trigger === 'hover') trigger = 'click';
146
140
  const ref = useRef(null);
147
141
  const arrowRef = useRef(null);
148
- // const overflow = useRef(null);
142
+ const overflow = useRef(null);
149
143
  const anchorRef = useRef(anchor);
150
144
  const [openState, setOpenState] = useState(open);
151
145
  const [element, setElement] = useState(null);
@@ -412,14 +406,10 @@ const Popover = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
412
406
  }, [open]);
413
407
  useEffect(() => {
414
408
  if (openState && ref.current) {
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);
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
+ }
423
413
  // Position's anchor
424
414
  updatePositionPopover();
425
415
 
@@ -434,8 +424,7 @@ const Popover = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
434
424
  window.addEventListener('resize', updatePositionPopover);
435
425
  if (trigger === 'hover') ref.current.addEventListener('mouseleave', handleEventTrigger, false);
436
426
  return () => {
437
- document.body.classList.remove(...noScrollClass);
438
- // document.body.style.overflow = overflow.current; // reset overflow of <body /> before open
427
+ document.body.style.overflow = overflow.current; // reset overflow of <body /> before open
439
428
  if (pressESCToClose) {
440
429
  document.removeEventListener('keydown', pressESCHandler);
441
430
  }
@@ -443,10 +432,9 @@ const Popover = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
443
432
  window.removeEventListener('resize', updatePositionPopover);
444
433
  if (trigger === 'hover' && ref.current) ref.current.removeEventListener('mouseleave', handleEventTrigger, false);
445
434
  };
435
+ } else if (!openState) {
436
+ document.documentElement.style.overflow = overflow.current;
446
437
  }
447
- // else if (!openState) {
448
- // document.documentElement.style.overflow = overflow.current;
449
- // }
450
438
  }, [openState]);
451
439
  useEffect(() => {
452
440
  clickOutsideToClose ? document.addEventListener('click', onClickOutside) : document.removeEventListener('click', onClickOutside);
@@ -5,15 +5,24 @@ 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 { useTypography as typography } from "../../theme";
8
+ import { useTheme, useTypography as typography } from "../../theme";
9
9
  import { classNames, renderHTML } from "../../utils";
10
- const colorMap = new Map([['default', 'text/main']]);
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]]);
11
21
  const formatMap = new Map([['capitalize', textCapitalize], ['uppercase', textUppercase], ['lowercase', textLowercase], ['italic', italic], ['line-through', textLineThrough], ['underline', textUnderline], ['sentence', textSentence]]);
12
22
  const isTextClamped = elm => (elm === null || elm === void 0 ? void 0 : elm.scrollHeight) > (elm === null || elm === void 0 ? void 0 : elm.clientHeight);
13
23
  const Typography = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
14
24
  action = {},
15
25
  capitalize,
16
- // deprecated
17
26
  center,
18
27
  children,
19
28
  className,
@@ -28,20 +37,17 @@ const Typography = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
28
37
  tooltipDirection,
29
38
  type,
30
39
  uppercase,
31
- // deprecated
32
40
  ...props
33
41
  }, reference) => {
34
42
  var _ref$current;
35
43
  if (!reference) reference = useRef(null);
36
44
  const ref = useRef(null);
37
45
  const formatCSS = [];
38
- if (Array.isArray(format)) {
39
- format.forEach(item => {
40
- formatCSS.push(formatMap.get(item));
41
- });
42
- }
46
+ format.forEach(item => {
47
+ formatCSS.push(formatMap.get(item));
48
+ });
43
49
  const [openTooltip, setOpenTooltip] = useState(false);
44
- const _TextRootCSS = [TextRootCSS(color, type, lineClamp, onClick, hoverTooltip, center, fullWidth, uppercase, capitalize), ...formatCSS];
50
+ const _TextRootCSS = [TextRootCSS(color, type, lineClamp, onClick, hoverTooltip), ...formatCSS];
45
51
  const showTooltip = () => {
46
52
  if (!hoverTooltip) return;
47
53
  if (isTextClamped(ref.current)) {
@@ -64,26 +70,26 @@ const Typography = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
64
70
  currentRef.instance = _instance;
65
71
  return currentRef;
66
72
  });
67
- const classes = classNames('DGN-UI-Typography', `DGN-UI-Typography-${type}`, className);
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);
68
74
  const content = Array.isArray(children) && !children.some(node => node && String(node.$$typeof) === 'Symbol(react.element)') ? children.join('') : children;
69
75
  const renderTooltip = hoverTooltip ? jsx(Popover, {
70
- css: parseMinWidth(300),
76
+ css: [parseMinWidth(300)],
71
77
  open: openTooltip,
72
78
  pressESCToClose: false,
73
79
  fullScreen: false,
74
- bgColor: 'fill/tooltip',
80
+ bgColor: fillTooltip,
75
81
  anchor: ref,
76
82
  width: ((_ref$current = ref.current) === null || _ref$current === void 0 ? void 0 : _ref$current.clientWidth) || 'max-content',
77
83
  direction: tooltipDirection
78
84
  }, renderHTML(content, mapping, {
79
85
  css: [_TextRootCSS, PopoverContentCSS],
80
- className: classes
86
+ className: classes(true)
81
87
  })) : null;
82
88
  return useMemo(() => {
83
89
  return jsx(Fragment, null, renderHTML(content, mapping, {
84
90
  ref: ref,
85
- css: [_TextRootCSS, lineClamp && ClampCSS(lineClamp)],
86
- className: classes,
91
+ css: _TextRootCSS,
92
+ className: classes(),
87
93
  onMouseEnter: showTooltip,
88
94
  onMouseLeave: hideTooltip,
89
95
  onClick: onClick,
@@ -91,7 +97,7 @@ const Typography = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
91
97
  }), renderTooltip);
92
98
  }, [capitalize, center, children, className, color, format, fullWidth, hoverTooltip, italic, lineClamp, mapping, onClick, props, tooltipDirection, type, uppercase, openTooltip]);
93
99
  }));
94
- const TextRootCSS = (color, type, lineClamp, onClick, hoverTooltip, center, fullWidth, uppercase, capitalize) => css`
100
+ const TextRootCSS = (color, type, lineClamp, onClick, hoverTooltip) => css`
95
101
  ${displayInlineBlock};
96
102
  ${positionRelative};
97
103
  ${onClick && cursorPointer};
@@ -100,22 +106,28 @@ const TextRootCSS = (color, type, lineClamp, onClick, hoverTooltip, center, full
100
106
  ${textColor(colorMap.get(color) || color)};
101
107
  ${parseMaxWidth('max-content')};
102
108
  ${type !== 'inherit' && typography[type]};
103
- ${center && textCenter};
104
- ${uppercase && textUppercase};
105
- ${capitalize && textCapitalize};
106
- ${fullWidth && css`
109
+ &.DGN-Typography-center {
110
+ ${textCenter};
111
+ }
112
+ &.DGN-Typography-fullWidth {
107
113
  ${displayBlock};
108
114
  ${parseMaxWidth('initial')};
109
- `}
110
- `;
111
- const ClampCSS = lineClamp => css`
112
- ${overflowHidden};
113
- display: -webkit-box;
114
- -webkit-line-clamp: ${lineClamp};
115
- -webkit-box-orient: vertical;
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
+ }
116
128
  `;
117
129
  const PopoverContentCSS = css`
118
- ${textColor('text/tooltip')};
130
+ ${textColor('text.tooltip')};
119
131
  ${pd([1, 1.5])};
120
132
  ${parseHeight('fit-content')};
121
133
  `;