diginet-core-ui 1.3.35 → 1.3.36

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.
@@ -1,22 +1,38 @@
1
1
  /** @jsxRuntime classic */
2
2
 
3
3
  /** @jsx jsx */
4
+ import { forwardRef, memo, useEffect, useRef, useState, useMemo, useImperativeHandle } from 'react';
4
5
  import PropTypes from 'prop-types';
5
- import { forwardRef, memo, useEffect, useRef, useState } from 'react';
6
- import Portal from './portal';
6
+ import { createPortal } from 'react-dom';
7
7
  import { randomString } from '../../utils';
8
8
  import { jsx, css } from '@emotion/core';
9
9
  import { typography } from '../../styles/typography';
10
- const defaultColor = 'rgba(255, 255, 255, 0.9)';
11
- const defaultBg = 'rgba(21, 26, 48, 0.9)';
10
+ import { color as colors } from '../../styles/colors';
11
+ import { borderBox, borderRadius4px, displayInlineBlock, positionAbsolute, userSelectNone } from '../../styles/general';
12
+ const {
13
+ paragraph2,
14
+ paragraph3
15
+ } = typography;
16
+ const {
17
+ system: {
18
+ white
19
+ },
20
+ fill: {
21
+ tooltip: fillTooltip
22
+ }
23
+ } = colors;
12
24
  const defaultViewPadding = 4;
13
25
 
14
26
  const getScrollTop = () => {
15
- return window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop || 0;
27
+ var _ref, _ref2, _window$pageYOffset;
28
+
29
+ return (_ref = (_ref2 = (_window$pageYOffset = window.pageYOffset) !== null && _window$pageYOffset !== void 0 ? _window$pageYOffset : document.documentElement.scrollTop) !== null && _ref2 !== void 0 ? _ref2 : document.body.scrollTop) !== null && _ref !== void 0 ? _ref : 0;
16
30
  };
17
31
 
18
32
  const getScrollLeft = () => {
19
- return window.pageXOffset || document.documentElement.scrollLeft || document.body.scrollLeft || 0;
33
+ var _ref3, _ref4, _window$pageXOffset;
34
+
35
+ return (_ref3 = (_ref4 = (_window$pageXOffset = window.pageXOffset) !== null && _window$pageXOffset !== void 0 ? _window$pageXOffset : document.documentElement.scrollLeft) !== null && _ref4 !== void 0 ? _ref4 : document.body.scrollLeft) !== null && _ref3 !== void 0 ? _ref3 : 0;
20
36
  };
21
37
 
22
38
  const getArrowSpacing = (arrow, arrowSize, distance) => {
@@ -30,71 +46,44 @@ const parseAlignMode = alignMode => {
30
46
  }
31
47
 
32
48
  return 'middle';
33
- }; // const getScrollParent = (element) => {
34
- // const style = getComputedStyle(element);
35
- // let scrollParent = window;
36
- // if (style.position !== 'fixed') {
37
- // let parent = element.parentElement;
38
- // while (parent) {
39
- // const parentStyle = getComputedStyle(parent);
40
- // if (/(auto|scroll)/.test(parentStyle.overflow + parentStyle.overflowY + parentStyle.overflowX)) {
41
- // scrollParent = parent;
42
- // parent = undefined;
43
- // } else {
44
- // parent = parent.parentElement;
45
- // }
46
- // }
47
- // }
48
- // return scrollParent;
49
- // };
50
-
51
-
52
- const Tooltip = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((props, ref) => {
53
- const {
54
- alignMode,
55
- arrow,
56
- arrowSize,
57
- backgroundColor,
58
- children,
59
- color,
60
- direction,
61
- distance,
62
- size,
63
- forceDirection,
64
- hoverDelay,
65
- onToggle,
66
- padding,
67
- style,
68
- tagCreatedName: TagCreatedName,
69
- textAlign,
70
- title,
71
- tooltipMaxWidth,
72
- viewportPadding,
73
- ...other
74
- } = props;
49
+ };
50
+
51
+ const Tooltip = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
52
+ alignMode,
53
+ arrow,
54
+ arrowSize,
55
+ backgroundColor,
56
+ children,
57
+ color,
58
+ direction,
59
+ distance,
60
+ size,
61
+ forceDirection,
62
+ hoverDelay,
63
+ onToggle,
64
+ padding,
65
+ style,
66
+ tagCreatedName: TagCreatedName,
67
+ textAlign,
68
+ title,
69
+ tooltipMaxWidth,
70
+ viewportPadding,
71
+ className,
72
+ ...props
73
+ }, reference) => {
75
74
  const Id = randomString(length = 6, {
76
75
  allowSymbol: false
77
- }),
78
- IDs = {
79
- arrow: 'DCUI-tooltip-arrow-' + Id,
80
- container: 'DCUI-tooltip-container-' + Id,
81
- main: 'DCUI-tooltip-main-' + Id
82
- },
83
- arrowRef = useRef(null),
84
- containerRef = useRef(null),
85
- tooltipRef = useRef(null),
86
- containerProps = { ...other,
87
- ref: ref || containerRef,
88
- className: IDs.container,
89
- style: {
90
- boxSizing: 'border-box',
91
- height: 'max-content',
92
- position: 'relative',
93
- width: 'max-content',
94
- ...style
95
- }
96
- },
97
- hiddenPositions = {
76
+ });
77
+ const IDs = {
78
+ arrow: 'DGN-UI-tooltip-arrow-' + Id,
79
+ container: 'DGN-UI-tooltip-container-' + Id,
80
+ main: 'DGN-UI-tooltip-main-' + Id
81
+ };
82
+ const [open, setOpen] = useState(false);
83
+ const arrowRef = useRef(null);
84
+ const containerRef = useRef(null);
85
+ const tooltipRef = useRef(null);
86
+ const hiddenPositions = {
98
87
  tooltip: {
99
88
  left: '-10000000px',
100
89
  opacity: 0
@@ -105,36 +94,8 @@ const Tooltip = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((props, ref) => {
105
94
  opacity: 0,
106
95
  top: '-10000000px'
107
96
  }
108
- },
109
- [existed, setExisted] = useState(false);
110
- let calculateTimeout, hoverTimeout, tooltip;
111
- const styles = {
112
- arrow: css`
113
- height: 0;
114
- opacity: 0;
115
- position: absolute;
116
- transition: opacity 0.1s ease-in-out;
117
- user-select: none;
118
- width: 0;
119
- z-index: 9005;
120
- `,
121
- main: css`
122
- background-color: ${backgroundColor};
123
- border-radius: 3px;
124
- box-sizing: border-box;
125
- color: ${color};
126
- display: inline-block;
127
- ${size === 'small' ? typography.paragraph3 : typography.paragraph2};
128
- opacity: 0;
129
- padding: ${padding};
130
- position: absolute;
131
- text-align: ${textAlign};
132
- transition: opacity 0.1s ease-in-out;
133
- user-select: none;
134
- word-wrap: break-word;
135
- z-index: 9004;
136
- `
137
97
  };
98
+ let calculateTimeout, hoverTimeout;
138
99
 
139
100
  const checkHorizontal = (distance, el, parent) => {
140
101
  const {
@@ -254,11 +215,11 @@ const Tooltip = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((props, ref) => {
254
215
  const clientW = document.documentElement.clientWidth;
255
216
  const parentRect = parent.getBoundingClientRect();
256
217
  const arrowSpacing = getArrowSpacing(arrow, arrowSize, distance);
257
- const wrapperHight = el.offsetHeight + arrowSpacing + viewportPadding;
218
+ const wrapperHeight = el.offsetHeight + arrowSpacing + viewportPadding;
258
219
  const spaceBelow = window.innerHeight - parentRect.bottom;
259
220
  const spaceAbove = parentRect.top;
260
- const enoughBelow = spaceBelow >= wrapperHight;
261
- const enoughAbove = spaceAbove >= wrapperHight;
221
+ const enoughBelow = spaceBelow >= wrapperHeight;
222
+ const enoughAbove = spaceAbove >= wrapperHeight;
262
223
 
263
224
  switch (currentDirection) {
264
225
  case 'right':
@@ -425,7 +386,7 @@ const Tooltip = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((props, ref) => {
425
386
 
426
387
  if (el) {
427
388
  const space = el.style.width ? 0 : 5;
428
- width = Math.min(el.offsetWidth, maxWidth) + space + 'px';
389
+ width = Math.min(el.offsetWidth, parseInt(maxWidth)) + space + 'px';
429
390
  tooltipPosition = trueDirection === 'up' || trueDirection === 'down' ? getVertical(align, trueDirection, el, parent) : getHorizontal(align, trueDirection, el, parent);
430
391
  }
431
392
 
@@ -438,15 +399,6 @@ const Tooltip = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((props, ref) => {
438
399
  };
439
400
  };
440
401
 
441
- const onSettingTooltip = (arrow, parent) => {
442
- if (!existed) {
443
- setExisted(true);
444
- onShowTooltip(arrow, parent);
445
- } else {
446
- onShowTooltip(arrow, parent);
447
- }
448
- };
449
-
450
402
  const onShowTooltip = (arrow, parent) => {
451
403
  if (!tooltipRef.current || !arrowRef.current) return;
452
404
  const arrowEl = arrowRef.current,
@@ -483,56 +435,104 @@ const Tooltip = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((props, ref) => {
483
435
  Object.assign(el.style, hiddenPositions.tooltip);
484
436
  Object.assign(arrowEl.style, hiddenPositions.arrow);
485
437
  }, hoverDelay);
486
- }; // const handleEvent = (arrow, parent) => {
487
- // onHideTooltip();
488
- // onShowTooltip(arrow, parent);
489
- // };
490
-
491
-
492
- tooltip = existed && title ? jsx(Portal, {
493
- id: 'DGN-UI-Portal'
494
- }, jsx("span", {
495
- className: IDs.arrow,
496
- css: styles.arrow,
497
- ref: arrowRef,
498
- style: { ...hiddenPositions.arrow
499
- }
500
- }), jsx("span", {
501
- className: IDs.main,
502
- css: styles.main,
503
- ref: tooltipRef,
504
- style: { ...hiddenPositions.tooltip
505
- }
506
- }, title)) : null;
507
- useEffect(() => {
508
- const parent = containerProps.ref.current; // const scrollableParent = getScrollParent(parent);
509
-
510
- parent.addEventListener('mouseenter', () => onSettingTooltip(arrow, parent)); // parent.addEventListener('touchstart', () => onSettingTooltip(arrow, parent), { passive: true });
438
+ };
511
439
 
512
- parent.addEventListener('mouseleave', () => onHideTooltip()); // parent.addEventListener('touchend', () => onHideTooltip(), { passive: true });
513
- // window.addEventListener('resize', handleEvent(arrow, parent));
514
- // scrollableParent.addEventListener('scroll', handleEvent(arrow, parent));
440
+ const setOpenTrue = () => {
441
+ setOpen(true);
442
+ };
515
443
 
516
- return () => {
517
- parent.removeEventListener('mouseenter', () => onSettingTooltip(arrow, parent)); // parent.removeEventListener('touchstart', () => onSettingTooltip(arrow, parent), { passive: true });
444
+ const setOpenFalse = () => {
445
+ setOpen(false);
446
+ };
518
447
 
519
- parent.removeEventListener('mouseleave', () => onHideTooltip()); // parent.removeEventListener('touchend', () => onHideTooltip(), { passive: true });
520
- // window.removeEventListener('resize', handleEvent(arrow, parent));
521
- // scrollableParent.removeEventListener('scroll', handleEvent(arrow, parent));
448
+ useEffect(() => {
449
+ if (open) {
450
+ onShowTooltip(arrow, containerRef.current);
451
+ } else {
452
+ onHideTooltip();
453
+ }
454
+ }, [open]);
455
+ useImperativeHandle(reference, () => {
456
+ const currentRef = containerRef.current || {};
457
+ const _instance = {}; // methods
458
+
459
+ _instance.__proto__ = {}; // hidden methods
460
+
461
+ currentRef.instance = _instance;
462
+ return currentRef;
463
+ });
464
+ const renderTooltip = useMemo(() => {
465
+ if (open && title) {
466
+ const node = jsx("div", {
467
+ className: 'DGN-UI-Portal DGN-Tooltip'
468
+ }, jsx("span", {
469
+ className: IDs.arrow,
470
+ css: arrowCSS,
471
+ ref: arrowRef,
472
+ style: { ...hiddenPositions.arrow
473
+ }
474
+ }), jsx("span", {
475
+ className: [IDs.main, className].join(' ').trim().replace(/\s+/g, ' '),
476
+ css: mainCSS(backgroundColor, color, size, padding, textAlign),
477
+ ref: tooltipRef,
478
+ style: { ...hiddenPositions.tooltip
479
+ }
480
+ }, title));
481
+ return /*#__PURE__*/createPortal(node, document.body);
482
+ }
522
483
 
523
- clearTimeout(calculateTimeout);
524
- clearTimeout(hoverTimeout);
525
- };
526
- }, []);
527
- return jsx(TagCreatedName, { ...containerProps
528
- }, children, tooltip);
484
+ return null;
485
+ }, [open, title, backgroundColor, color, size, padding, textAlign]);
486
+ return jsx(TagCreatedName, {
487
+ ref: containerRef,
488
+ className: IDs.container,
489
+ style: {
490
+ boxSizing: 'border-box',
491
+ height: 'max-content',
492
+ width: 'max-content',
493
+ position: 'relative',
494
+ ...style
495
+ },
496
+ onMouseEnter: setOpenTrue,
497
+ onMouseLeave: setOpenFalse,
498
+ onFocus: setOpenTrue,
499
+ onBlur: setOpenFalse,
500
+ ...props
501
+ }, children, renderTooltip);
529
502
  }));
503
+ const arrowCSS = css`
504
+ ${positionAbsolute}
505
+ ${userSelectNone}
506
+ height: 0;
507
+ opacity: 0;
508
+ transition: opacity 0.1s ease-in-out;
509
+ width: 0;
510
+ z-index: 9005;
511
+ `;
512
+
513
+ const mainCSS = (backgroundColor, color, size, padding, textAlign) => css`
514
+ ${displayInlineBlock}
515
+ ${borderBox}
516
+ ${positionAbsolute}
517
+ ${userSelectNone}
518
+ ${borderRadius4px}
519
+ ${size === 'small' ? paragraph3 : paragraph2};
520
+ background-color: ${backgroundColor};
521
+ color: ${color};
522
+ padding: ${padding};
523
+ text-align: ${textAlign};
524
+ opacity: 0;
525
+ transition: opacity 0.1s ease-in-out;
526
+ word-wrap: break-word;
527
+ z-index: 9004;
528
+ `;
529
+
530
530
  Tooltip.defaultProps = {
531
531
  alignMode: 'middle',
532
532
  arrow: false,
533
533
  arrowSize: 6,
534
- backgroundColor: defaultBg,
535
- color: defaultColor,
534
+ backgroundColor: fillTooltip,
535
+ color: white,
536
536
  direction: 'down',
537
537
  size: 'medium',
538
538
  forceDirection: false,
@@ -540,7 +540,8 @@ Tooltip.defaultProps = {
540
540
  padding: '4px 6px',
541
541
  tagCreatedName: 'div',
542
542
  textAlign: 'center',
543
- viewportPadding: defaultViewPadding
543
+ viewportPadding: defaultViewPadding,
544
+ className: ''
544
545
  };
545
546
  Tooltip.propTypes = {
546
547
  /** alignMode use to set align-items of the tooltip*/
@@ -582,6 +583,9 @@ Tooltip.propTypes = {
582
583
  /** style is a object like style-inline, use to set the style for the element will be created to contain the children */
583
584
  style: PropTypes.object,
584
585
 
586
+ /** class of Tooltip-main */
587
+ className: PropTypes.string,
588
+
585
589
  /** tagName of the element will be created to contain the children */
586
590
  tagCreatedName: PropTypes.oneOf(['div', 'span']),
587
591
 
@@ -1,8 +1,11 @@
1
1
  /** @jsxRuntime classic */
2
- import { memo, useRef, forwardRef, useImperativeHandle } from 'react';
2
+
3
+ /** @jsx jsx */
4
+ import { memo, useRef, forwardRef, useImperativeHandle, Fragment, useMemo, useState } from 'react';
3
5
  import PropTypes from 'prop-types';
4
- import { css } from '@emotion/core';
6
+ import { jsx, css } from '@emotion/core';
5
7
  import { renderHTML } from '../../utils';
8
+ import { Popover } from '..';
6
9
  import { typography } from '../../styles/typography';
7
10
  import { breakWord, displayBlock, displayInlineBlock, overflowHidden, positionRelative, textCapitalize, textCenter, textUppercase } from '../../styles/general';
8
11
  import { color as colors } from '../../styles/colors';
@@ -34,10 +37,71 @@ const {
34
37
  },
35
38
  text: {
36
39
  main
40
+ },
41
+ fill: {
42
+ tooltip: fillTooltip
43
+ },
44
+ text: {
45
+ tooltip: textTooltip
37
46
  }
38
47
  } = colors;
39
48
  const typographyMap = new Map([['t1', title1], ['t2', title2], ['t3', title3], ['t4', title4], ['h1', heading1], ['h2', heading2], ['h3', heading3], ['h4', heading4], ['h5', heading5], ['h6', heading6], ['p1', paragraph1], ['p2', paragraph2], ['p3', paragraph3]]);
40
49
  const colorMap = new Map([['default', main], ['primary', active], ['secondary', rest], ['success', success], ['warning', warning], ['danger', danger], ['info', info]]);
50
+
51
+ const getDirectionPopover = direction => {
52
+ switch (direction) {
53
+ case 'top':
54
+ return {
55
+ anchorOrigin: {
56
+ vertical: 'top',
57
+ horizontal: 'center'
58
+ },
59
+ transformOrigin: {
60
+ vertical: 'bottom',
61
+ horizontal: 'center'
62
+ }
63
+ };
64
+
65
+ case 'left':
66
+ return {
67
+ anchorOrigin: {
68
+ vertical: 'center',
69
+ horizontal: 'left'
70
+ },
71
+ transformOrigin: {
72
+ vertical: 'center',
73
+ horizontal: 'right'
74
+ }
75
+ };
76
+
77
+ case 'right':
78
+ return {
79
+ anchorOrigin: {
80
+ vertical: 'center',
81
+ horizontal: 'right'
82
+ },
83
+ transformOrigin: {
84
+ vertical: 'center',
85
+ horizontal: 'left'
86
+ }
87
+ };
88
+
89
+ default:
90
+ return {
91
+ anchorOrigin: {
92
+ vertical: 'bottom',
93
+ horizontal: 'center'
94
+ },
95
+ transformOrigin: {
96
+ vertical: 'top',
97
+ horizontal: 'center'
98
+ }
99
+ };
100
+ }
101
+ };
102
+
103
+ const isTextClamped = elm => (elm === null || elm === void 0 ? void 0 : elm.scrollHeight) > (elm === null || elm === void 0 ? void 0 : elm.clientHeight);
104
+
41
105
  const Typography = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
42
106
  type,
43
107
  color,
@@ -49,42 +113,14 @@ const Typography = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
49
113
  className,
50
114
  lineClamp,
51
115
  children,
116
+ hoverTooltip,
117
+ tooltipDirection,
52
118
  ...props
53
119
  }, reference) => {
54
- const typographyRef = useRef(null);
55
- const TextRoot = css`
56
- ${displayInlineBlock}
57
- ${positionRelative}
58
- ${breakWord}
59
- ${paragraph1};
60
- white-space: normal;
61
- color: ${colorMap.get(color) || colors[color] || color};
62
- max-width: max-content;
63
- &.DGN-Typography-${type} {
64
- ${typographyMap.get(type.charAt(0) + type.slice(-1))}; //Get first and last character of type
65
- }
66
- &.DGN-Typography-center {
67
- ${textCenter}
68
- }
69
- &.DGN-Typography-fullWidth {
70
- ${displayBlock}
71
- max-width: initial;
72
- }
73
- &.DGN-Typography-Uppercase {
74
- ${textUppercase}
75
- }
76
- &.DGN-Typography-Capitalize {
77
- ${textCapitalize}
78
- }
79
- &.DGN-Typography-Clamp {
80
- ${overflowHidden}
81
- display: -webkit-box;
82
- -webkit-line-clamp: ${lineClamp};
83
- -webkit-box-orient: vertical;
84
- }
85
- `;
120
+ const ref = useRef(null);
121
+ const [openTooltip, setOpenTooltip] = useState(false);
86
122
  useImperativeHandle(reference, () => {
87
- const currentRef = typographyRef.current || {};
123
+ const currentRef = ref.current || {};
88
124
  const _instance = {}; // methods
89
125
 
90
126
  _instance.__proto__ = {}; // hidden methods
@@ -92,21 +128,92 @@ const Typography = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
92
128
  currentRef.instance = _instance;
93
129
  return currentRef;
94
130
  });
95
- const classNames = ['DGN-UI-Typography', center && 'DGN-Typography-center', fullWidth && 'DGN-Typography-fullWidth', `DGN-Typography-${type}`, uppercase && `DGN-Typography-Uppercase`, capitalize && 'DGN-Typography-Capitalize', lineClamp && 'DGN-Typography-Clamp', className].join(' ').trim().replace(/\s+/g, ' ');
96
- return renderHTML(Array.isArray(children) && !children.some(node => node && String(node.$$typeof) === 'Symbol(react.element)') ? children.join('') : children, mapping, {
97
- ref: typographyRef,
98
- css: TextRoot,
99
- className: classNames,
131
+
132
+ const classNames = inTooltip => ['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].join(' ').trim().replace(/\s+/g, ' ');
133
+
134
+ const setHoverTooltip = open => {
135
+ if (hoverTooltip && isTextClamped(ref.current)) {
136
+ setOpenTooltip(open);
137
+ }
138
+ };
139
+
140
+ const renderChildren = () => {
141
+ return Array.isArray(children) && !children.some(node => node && String(node.$$typeof) === 'Symbol(react.element)') ? children.join('') : children;
142
+ };
143
+
144
+ const renderTooltip = useMemo(() => jsx(Popover, {
145
+ open: openTooltip,
146
+ pressESCToClose: false,
147
+ bgColor: fillTooltip,
148
+ anchor: ref,
149
+ fullScreen: false,
150
+ width: 'max-content',
151
+ style: {
152
+ color: textTooltip
153
+ },
154
+ onMouseEnter: () => setHoverTooltip(true),
155
+ onMouseLeave: () => setHoverTooltip(false),
156
+ ...getDirectionPopover(tooltipDirection)
157
+ }, renderHTML(renderChildren(), mapping, {
158
+ css: TextRoot(color, type, lineClamp),
159
+ className: classNames(true),
160
+ style: {
161
+ color: textTooltip,
162
+ padding: '4px 6px'
163
+ }
164
+ })), [openTooltip, tooltipDirection, children, mapping, color, type, lineClamp]);
165
+ return jsx(Fragment, null, renderHTML(renderChildren(), mapping, {
166
+ ref: ref,
167
+ css: TextRoot(color, type, lineClamp),
168
+ className: classNames(false),
169
+ onMouseEnter: () => setHoverTooltip(true),
170
+ onMouseLeave: () => setHoverTooltip(false),
100
171
  ...props
101
- });
172
+ }), hoverTooltip && renderTooltip);
102
173
  }));
174
+
175
+ const TextRoot = (color, type, lineClamp) => css`
176
+ ${displayInlineBlock};
177
+ ${positionRelative};
178
+ ${breakWord};
179
+ ${paragraph1};
180
+ white-space: normal;
181
+ color: ${colorMap.get(color) || colors[color] || color};
182
+ max-width: max-content;
183
+ &.DGN-Typography-${type} {
184
+ ${typographyMap.get(type.charAt(0) + type.slice(-1))}; //Get first and last character of type
185
+ }
186
+ &.DGN-Typography-center {
187
+ ${textCenter}
188
+ }
189
+ &.DGN-Typography-fullWidth {
190
+ ${displayBlock}
191
+ max-width: initial;
192
+ }
193
+ &.DGN-Typography-Uppercase {
194
+ ${textUppercase}
195
+ }
196
+ &.DGN-Typography-Capitalize {
197
+ ${textCapitalize}
198
+ }
199
+ &.DGN-Typography-Clamp {
200
+ ${overflowHidden}
201
+ word-break: break-all;
202
+ display: -webkit-box;
203
+ -webkit-line-clamp: ${lineClamp};
204
+ -webkit-box-orient: vertical;
205
+ }
206
+ `;
207
+
103
208
  Typography.defaultProps = {
104
209
  type: 'p1',
105
210
  color: 'default',
106
211
  center: false,
107
212
  fullWidth: true,
108
213
  mapping: 'span',
109
- className: ''
214
+ className: '',
215
+ hoverTooltip: false,
216
+ tooltipDirection: 'down'
110
217
  };
111
218
  /** type of text<br/>
112
219
  * h1: Title <br/>
@@ -145,6 +252,12 @@ Typography.propTypes = {
145
252
  /** The line-clamp property truncates text at a specific number of lines. */
146
253
  lineClamp: PropTypes.number,
147
254
 
255
+ /** If true, hover will show tooltip when text clamped. */
256
+ hoverTooltip: PropTypes.bool,
257
+
258
+ /** Tooltip direction */
259
+ tooltipDirection: PropTypes.oneOf(['top', 'down', 'left', 'right']),
260
+
148
261
  /** allows maximum screen width if true */
149
262
  fullWidth: PropTypes.bool,
150
263
 
package/icons/effect.js CHANGED
@@ -96,8 +96,8 @@ Icon.propTypes = {
96
96
  /** name of icon in icons store */
97
97
  name: PropTypes.string.isRequired,
98
98
 
99
- /** color of icon<br />
100
- * default: #7F828E
99
+ /** color of icon<br />
100
+ * default: #7F828E
101
101
  */
102
102
  color: PropTypes.string,
103
103
 
@@ -119,19 +119,19 @@ Icon.propTypes = {
119
119
  /** have view box if true */
120
120
  onClick: PropTypes.func,
121
121
 
122
- /**
123
- * ref methods
124
- *
125
- * * option(): Gets all UI component properties
126
- * * Returns value - object
127
- * * option(optionName): Gets the value of a single property
128
- * * @param {optionName} - string
129
- * * Returns value - any
130
- * * option(optionName, optionValue): Updates the value of a single property
131
- * * @param {optionName} - string
132
- * * @param {optionValue} - any
133
- * * option(options): Updates the values of several properties
134
- * * @param {options} - object
122
+ /**
123
+ * ref methods
124
+ *
125
+ * * option(): Gets all UI component properties
126
+ * * Returns value - object
127
+ * * option(optionName): Gets the value of a single property
128
+ * * @param {optionName} - string
129
+ * * Returns value - any
130
+ * * option(optionName, optionValue): Updates the value of a single property
131
+ * * @param {optionName} - string
132
+ * * @param {optionValue} - any
133
+ * * option(options): Updates the values of several properties
134
+ * * @param {options} - object
135
135
  */
136
136
  reference: PropTypes.oneOfType([PropTypes.func, PropTypes.shape({
137
137
  current: PropTypes.instanceOf(Element)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "diginet-core-ui",
3
- "version": "1.3.35",
3
+ "version": "1.3.36",
4
4
  "description": "The DigiNet core ui",
5
5
  "homepage": "https://diginet.com.vn",
6
6
  "main": "index.js",