diginet-core-ui 1.3.44 → 1.3.46
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.
- package/assets/images/menu/dhr/MHRM00N0005.svg +11 -0
- package/assets/images/menu/dhr/{MHRP09N0033.svg → MHRM09N1010.svg} +0 -0
- package/assets/images/menu/dhr/MHRM09N1015.svg +18 -0
- package/assets/images/menu/dhr/MHRM09N1020.svg +13 -0
- package/assets/images/menu/dhr/MHRM09N1025.svg +12 -0
- package/assets/images/menu/dhr/MHRM09N1400.svg +11 -0
- package/assets/images/menu/dhr/MHRP25L0101.svg +15 -0
- package/assets/images/menu/dhr/MHRP25L0501.svg +14 -0
- package/components/avatar/index.js +138 -187
- package/components/chart/line/Axis.js +11 -10
- package/components/chart/line/Grid.js +4 -3
- package/components/chart/line/Path.js +11 -10
- package/components/chart/line/Point.js +107 -80
- package/components/chart/line/index.js +36 -17
- package/components/form-control/dropdown/index.js +56 -52
- package/components/form-control/helper-text/index.js +35 -33
- package/components/form-control/number-input/index2.js +7 -7
- package/components/form-control/radio/index.js +126 -113
- package/components/form-control/time-picker/index.js +10 -19
- package/components/tree-view/css.js +17 -16
- package/components/tree-view/index.js +41 -23
- package/components/typography/index.js +18 -74
- package/package.json +1 -1
- package/readme.md +18 -0
|
@@ -3,8 +3,9 @@
|
|
|
3
3
|
/** @jsx jsx */
|
|
4
4
|
import { jsx, css } from '@emotion/core';
|
|
5
5
|
import PropTypes from 'prop-types';
|
|
6
|
-
import React, { forwardRef, memo, useEffect,
|
|
6
|
+
import React, { forwardRef, memo, useEffect, useMemo, useRef } from 'react';
|
|
7
7
|
import { Cancel as CancelIcon, Clock as ClockIcon } from '../../../icons';
|
|
8
|
+
import HelperText from '../helper-text';
|
|
8
9
|
import { randomString, useOnClickOutside } from '../../../utils';
|
|
9
10
|
import theme from '../../../theme/settings';
|
|
10
11
|
import Swiper from './swiper';
|
|
@@ -432,21 +433,10 @@ const TimePicker = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
432
433
|
}
|
|
433
434
|
`
|
|
434
435
|
},
|
|
435
|
-
error:
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
margin-top: 8px;
|
|
440
|
-
pointer-events: none;
|
|
441
|
-
`,
|
|
442
|
-
underlined: css`
|
|
443
|
-
color: ${theme.colors.danger};
|
|
444
|
-
${typography.paragraph3};
|
|
445
|
-
bottom: -20px;
|
|
446
|
-
position: absolute;
|
|
447
|
-
pointer-events: none;
|
|
448
|
-
`
|
|
449
|
-
},
|
|
436
|
+
error: css`
|
|
437
|
+
position: absolute;
|
|
438
|
+
top: 100%;
|
|
439
|
+
`,
|
|
450
440
|
clock: {
|
|
451
441
|
container: css`
|
|
452
442
|
background-color: white;
|
|
@@ -762,9 +752,10 @@ const TimePicker = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
762
752
|
onChange: selected => setInputSecond(selected),
|
|
763
753
|
parentNode: swiperWrapperSecondsRef
|
|
764
754
|
})) : null), [activeHeight, activeWidth, allowSeconds, defaultValue, disabled, error, value, viewType]);
|
|
765
|
-
const ErrorMemo = useMemo(() => error && jsx(
|
|
766
|
-
css: styles.error
|
|
767
|
-
|
|
755
|
+
const ErrorMemo = useMemo(() => error && jsx(HelperText, {
|
|
756
|
+
css: styles.error,
|
|
757
|
+
disabled: disabled
|
|
758
|
+
}, error), [error, disabled]);
|
|
768
759
|
const MainMemo = useMemo(() => jsx("div", {
|
|
769
760
|
className: IDs.main,
|
|
770
761
|
css: styles.main[viewType],
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { css } from '@emotion/core';
|
|
2
|
+
import { alignCenter, borderBox, cursorPointer, displayBlock, displayInlineBlock, flexRow, positionRelative } from '../../styles/general';
|
|
2
3
|
import theme from '../../theme/settings';
|
|
3
|
-
export const
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
export const TreeViewRootCSS = css`
|
|
5
|
+
${displayBlock};
|
|
6
|
+
${positionRelative};
|
|
6
7
|
.DGN-UI-Accordion {
|
|
7
8
|
box-shadow: none !important;
|
|
8
9
|
.DGN-UI-Accordion-Summary {
|
|
@@ -10,20 +11,19 @@ export const TreeViewRoot = css`
|
|
|
10
11
|
padding: 0;
|
|
11
12
|
border-radius: 0;
|
|
12
13
|
&.focus {
|
|
13
|
-
|
|
14
|
+
background-color: ${theme.colors.focus};
|
|
14
15
|
}
|
|
15
16
|
.Accordion-Icon-Root {
|
|
16
|
-
|
|
17
|
+
${flexRow};
|
|
17
18
|
margin-right: 4px;
|
|
18
19
|
}
|
|
19
20
|
}
|
|
20
21
|
.DGN-UI-Accordion-Details-Content {
|
|
21
22
|
padding: 0;
|
|
22
|
-
margin-left: 16px;
|
|
23
23
|
border-radius: 0;
|
|
24
24
|
}
|
|
25
25
|
.Accordion-Icon-Root {
|
|
26
|
-
|
|
26
|
+
${flexRow};
|
|
27
27
|
transition: opacity 0.2s ease-out;
|
|
28
28
|
opacity: 1;
|
|
29
29
|
&.DGN-Invisible {
|
|
@@ -36,29 +36,30 @@ export const TreeViewRoot = css`
|
|
|
36
36
|
}
|
|
37
37
|
.TreeView-All,
|
|
38
38
|
.TreeView-Content {
|
|
39
|
-
|
|
40
|
-
|
|
39
|
+
${displayBlock};
|
|
40
|
+
${positionRelative};
|
|
41
41
|
.DGN-UI-Accordion {
|
|
42
42
|
margin-bottom: 0;
|
|
43
43
|
}
|
|
44
44
|
}
|
|
45
45
|
.TreeView-Item-Checkbox {
|
|
46
|
-
|
|
47
|
-
|
|
46
|
+
${displayInlineBlock};
|
|
47
|
+
${positionRelative};
|
|
48
48
|
height: 100%;
|
|
49
49
|
margin-right: 8px;
|
|
50
50
|
}
|
|
51
51
|
.TreeView-Item {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
52
|
+
${flexRow};
|
|
53
|
+
${positionRelative};
|
|
54
|
+
${alignCenter};
|
|
55
|
+
${borderBox};
|
|
55
56
|
min-height: 40px;
|
|
56
57
|
text-align: left;
|
|
57
58
|
color: ${theme.colors.text.main};
|
|
58
|
-
|
|
59
|
+
width: 100%;
|
|
59
60
|
&.non-child {
|
|
61
|
+
${cursorPointer};
|
|
60
62
|
transition: background-color 300ms ease;
|
|
61
|
-
cursor: pointer;
|
|
62
63
|
&.disabled {
|
|
63
64
|
color: ${theme.colors.disabled};
|
|
64
65
|
cursor: no-drop;
|
|
@@ -5,7 +5,7 @@ import { memo, useMemo, useState, useEffect, useRef, forwardRef, Fragment, useIm
|
|
|
5
5
|
import { render } from 'react-dom';
|
|
6
6
|
import PropTypes from 'prop-types';
|
|
7
7
|
import { jsx } from '@emotion/core';
|
|
8
|
-
import {
|
|
8
|
+
import { TreeViewRootCSS } from './css';
|
|
9
9
|
import { Accordion, AccordionSummary, AccordionDetails, Typography, Checkbox, Divider, InputBase, ButtonIcon } from '..';
|
|
10
10
|
import { mapParent, randomString, removeUnicode } from '../../utils';
|
|
11
11
|
import { getGlobal } from '../../global';
|
|
@@ -63,7 +63,8 @@ const TreeView = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
63
63
|
input.nextElementSibling.classList[determinate ? 'add' : 'remove']('determinate');
|
|
64
64
|
input.nextElementSibling.classList[determinate ? 'remove' : 'add']('indeterminate');
|
|
65
65
|
}
|
|
66
|
-
};
|
|
66
|
+
}; // eslint-disable-next-line no-unused-vars
|
|
67
|
+
|
|
67
68
|
|
|
68
69
|
const triggerCheckboxRecursion = (nodes, isChecked) => {
|
|
69
70
|
nodes.forEach(el => {
|
|
@@ -77,7 +78,7 @@ const TreeView = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
77
78
|
};
|
|
78
79
|
|
|
79
80
|
const checkedParentFollowValue = nodes => {
|
|
80
|
-
if (nodes && nodes.length) {
|
|
81
|
+
if (nodes && nodes !== null && nodes !== void 0 && nodes.length) {
|
|
81
82
|
nodes.forEach(node => {
|
|
82
83
|
if (!node.classList.contains('non-child')) {
|
|
83
84
|
const input = node.firstChild.querySelector('input');
|
|
@@ -147,7 +148,7 @@ const TreeView = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
147
148
|
} else {
|
|
148
149
|
input.checked = true;
|
|
149
150
|
|
|
150
|
-
if (checkedQuantity === childNodes.length && checkedQuantity === determinateQuantity) {
|
|
151
|
+
if (checkedQuantity === (childNodes === null || childNodes === void 0 ? void 0 : childNodes.length) && checkedQuantity === determinateQuantity) {
|
|
151
152
|
if (!input.classList.contains('determinate')) {
|
|
152
153
|
determinateCheckbox(input, true);
|
|
153
154
|
}
|
|
@@ -238,10 +239,12 @@ const TreeView = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
238
239
|
node = node.parentNode;
|
|
239
240
|
|
|
240
241
|
if (node.classList.contains('DGN-UI-Accordion') && node.firstChild.classList.contains('DGN-UI-Accordion-Summary')) {
|
|
242
|
+
var _node$querySelectorAl;
|
|
243
|
+
|
|
241
244
|
const checkbox = node.firstChild.firstChild.firstChild.firstChild.firstChild.firstChild; // Trường hợp phải set về false để xét các input đã check không bao gồm node này
|
|
242
245
|
|
|
243
246
|
checkbox.firstChild.checked = isChecked;
|
|
244
|
-
const mustDisabled = !!node.querySelectorAll('input:checked').length; // Nếu có ít nhất một input con được check thì phải checked cho input này
|
|
247
|
+
const mustDisabled = !!((_node$querySelectorAl = node.querySelectorAll('input:checked')) !== null && _node$querySelectorAl !== void 0 && _node$querySelectorAl.length); // Nếu có ít nhất một input con được check thì phải checked cho input này
|
|
245
248
|
|
|
246
249
|
checkbox.firstChild.checked = mustDisabled;
|
|
247
250
|
determinateCheckbox(checkbox.firstChild, !mustDisabled);
|
|
@@ -261,9 +264,11 @@ const TreeView = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
261
264
|
|
|
262
265
|
const setValue = (data, isChecked) => {
|
|
263
266
|
if (multiple && multipleValueMode !== 'single') {
|
|
267
|
+
var _data$childItems;
|
|
268
|
+
|
|
264
269
|
currentValue[unique][typeof data === 'object' ? data[valueExpr] : data] = isChecked;
|
|
265
270
|
|
|
266
|
-
if (data.childItems && data.childItems.length) {
|
|
271
|
+
if (data.childItems && (_data$childItems = data.childItems) !== null && _data$childItems !== void 0 && _data$childItems.length) {
|
|
267
272
|
data.childItems.forEach(d => {
|
|
268
273
|
setValue(d, isChecked);
|
|
269
274
|
});
|
|
@@ -287,7 +292,7 @@ const TreeView = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
287
292
|
};
|
|
288
293
|
|
|
289
294
|
const setValueIntoInput = data => {
|
|
290
|
-
if (!data || !data.length) {
|
|
295
|
+
if (!data || !(data !== null && data !== void 0 && data.length)) {
|
|
291
296
|
inputValueRef.current.value = '';
|
|
292
297
|
clearIconRef.current.style.opacity = 0;
|
|
293
298
|
return;
|
|
@@ -334,6 +339,8 @@ const TreeView = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
334
339
|
const checkBoxEl = currentTarget.querySelector('.TreeView-Item-Checkbox');
|
|
335
340
|
|
|
336
341
|
if (multiple) {
|
|
342
|
+
var _value;
|
|
343
|
+
|
|
337
344
|
let checked = false;
|
|
338
345
|
let inputEl = null; // Click on text (not checkbox)
|
|
339
346
|
|
|
@@ -378,7 +385,7 @@ const TreeView = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
378
385
|
result.push(...Object.keys(currentValue[unique]).filter(v => currentValue[unique][v]));
|
|
379
386
|
value = result;
|
|
380
387
|
|
|
381
|
-
if (value.length) {
|
|
388
|
+
if ((_value = value) !== null && _value !== void 0 && _value.length) {
|
|
382
389
|
data = dataSource.filter(obj => value.includes(typeof obj === 'object' ? obj[valueExpr] : obj));
|
|
383
390
|
} else {
|
|
384
391
|
data = [];
|
|
@@ -529,7 +536,7 @@ const TreeView = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
529
536
|
if (entry.classList.contains('TreeView-Item-contain-children-active')) {
|
|
530
537
|
const hiddenEls = entry.querySelectorAll('.DGN-Hidden, .DGN-Invisible');
|
|
531
538
|
|
|
532
|
-
if (hiddenEls && hiddenEls.length) {
|
|
539
|
+
if (hiddenEls && hiddenEls !== null && hiddenEls !== void 0 && hiddenEls.length) {
|
|
533
540
|
hiddenEls.forEach(hiddenEl => hiddenEl.classList.remove('DGN-Hidden', 'DGN-Invisible'));
|
|
534
541
|
}
|
|
535
542
|
}
|
|
@@ -545,7 +552,7 @@ const TreeView = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
545
552
|
});
|
|
546
553
|
const activeEls = ref.current.querySelectorAll('.TreeView-Item-active');
|
|
547
554
|
|
|
548
|
-
if (!disabledBoldResult && activeEls && activeEls.length) {
|
|
555
|
+
if (!disabledBoldResult && activeEls && activeEls !== null && activeEls !== void 0 && activeEls.length) {
|
|
549
556
|
activeEls.forEach(activeEl => {
|
|
550
557
|
activeEl.classList.remove('TreeView-Item-active', 'TreeView-Item-contain-children-active');
|
|
551
558
|
});
|
|
@@ -580,12 +587,12 @@ const TreeView = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
580
587
|
};
|
|
581
588
|
|
|
582
589
|
const renderData = (data, keyArr) => {
|
|
583
|
-
const pattern = keyArr.join('|').replace(/([
|
|
590
|
+
const pattern = keyArr.join('|').replace(/([{}])/g, '\\$1');
|
|
584
591
|
const separatorArr = displayExpr.split(new RegExp(pattern));
|
|
585
592
|
let str = '';
|
|
586
593
|
let i = 0;
|
|
587
594
|
|
|
588
|
-
for (i; i < keyArr.length; i++) {
|
|
595
|
+
for (i; i < (keyArr === null || keyArr === void 0 ? void 0 : keyArr.length); i++) {
|
|
589
596
|
str += separatorArr[i] + (data[keyArr[i].replace(/\W/g, '')] !== undefined ? data[keyArr[i].replace(/\W/g, '')] : keyArr[i]);
|
|
590
597
|
}
|
|
591
598
|
|
|
@@ -630,7 +637,7 @@ const TreeView = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
630
637
|
const focusClass = isTrue && !selectBox && !multiple ? 'focus' : '';
|
|
631
638
|
const childItems = data.childItems; // is Summary
|
|
632
639
|
|
|
633
|
-
if (childItems && childItems.length) {
|
|
640
|
+
if (childItems && childItems !== null && childItems !== void 0 && childItems.length) {
|
|
634
641
|
const id = randomString(6, {
|
|
635
642
|
allowSymbol: false,
|
|
636
643
|
allowNumber: false
|
|
@@ -647,7 +654,10 @@ const TreeView = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
647
654
|
className: 'TreeView'
|
|
648
655
|
},
|
|
649
656
|
className: focusClass,
|
|
650
|
-
onClick: multiple || selectBox || onChange ? e => onClickHandler(e, data) : undefined
|
|
657
|
+
onClick: multiple || selectBox || onChange ? e => onClickHandler(e, data) : undefined,
|
|
658
|
+
style: {
|
|
659
|
+
paddingLeft: 16 * level
|
|
660
|
+
}
|
|
651
661
|
}, jsx("div", {
|
|
652
662
|
className: 'TreeView-Item'
|
|
653
663
|
}, (selectBox || multiple) && jsx("span", {
|
|
@@ -665,6 +675,9 @@ const TreeView = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
665
675
|
|
|
666
676
|
return jsx("div", {
|
|
667
677
|
className: 'TreeView-Item non-child ' + focusClass,
|
|
678
|
+
style: {
|
|
679
|
+
paddingLeft: 34 + 16 * level
|
|
680
|
+
},
|
|
668
681
|
onClick: multiple || selectBox || onChange ? e => onClickHandler(e, data) : undefined,
|
|
669
682
|
key: index,
|
|
670
683
|
tabIndex: "-1"
|
|
@@ -701,11 +714,13 @@ const TreeView = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
701
714
|
}
|
|
702
715
|
}, [searchDelayTime]);
|
|
703
716
|
useEffect(() => {
|
|
717
|
+
var _value2;
|
|
718
|
+
|
|
704
719
|
dataSource.forEach(data => {
|
|
705
720
|
currentValue[unique][typeof data === 'object' ? data[valueExpr] : data] = false;
|
|
706
721
|
});
|
|
707
722
|
|
|
708
|
-
if (value && value.length) {
|
|
723
|
+
if (value && (_value2 = value) !== null && _value2 !== void 0 && _value2.length) {
|
|
709
724
|
value.forEach(v => {
|
|
710
725
|
currentValue[unique][v] = true;
|
|
711
726
|
});
|
|
@@ -720,7 +735,7 @@ const TreeView = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
720
735
|
if (multipleValueMode !== 'single') {
|
|
721
736
|
const childNodes = Array.from(ref.current.childNodes);
|
|
722
737
|
|
|
723
|
-
if (childNodes && childNodes.length) {
|
|
738
|
+
if (childNodes && childNodes !== null && childNodes !== void 0 && childNodes.length) {
|
|
724
739
|
checkedParentFollowValue(childNodes);
|
|
725
740
|
}
|
|
726
741
|
|
|
@@ -780,7 +795,9 @@ const TreeView = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
780
795
|
}
|
|
781
796
|
}, [disabled]);
|
|
782
797
|
useEffect(() => {
|
|
783
|
-
|
|
798
|
+
var _Object$keys;
|
|
799
|
+
|
|
800
|
+
if ((_Object$keys = Object.keys(itemsRenderAsync[unique])) !== null && _Object$keys !== void 0 && _Object$keys.length) {
|
|
784
801
|
Object.keys(itemsRenderAsync[unique]).forEach(async key => {
|
|
785
802
|
await renderDataAsync(key, itemsRenderAsync[unique][key]);
|
|
786
803
|
});
|
|
@@ -798,19 +815,21 @@ const TreeView = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
798
815
|
handleCheckbox,
|
|
799
816
|
get: () => ref.current
|
|
800
817
|
}));
|
|
801
|
-
|
|
818
|
+
return useMemo(() => {
|
|
819
|
+
var _value3;
|
|
820
|
+
|
|
802
821
|
if (typeof value === 'string') {
|
|
803
822
|
value = [value];
|
|
804
823
|
}
|
|
805
824
|
|
|
806
|
-
if (!multiple && value.length > 1) {
|
|
825
|
+
if (!multiple && ((_value3 = value) === null || _value3 === void 0 ? void 0 : _value3.length) > 1) {
|
|
807
826
|
value.length = 1;
|
|
808
827
|
}
|
|
809
828
|
|
|
810
829
|
itemsRenderAsync[unique] = {};
|
|
811
|
-
const sync = dataSource.length > renderAsyncWithLength;
|
|
830
|
+
const sync = (dataSource === null || dataSource === void 0 ? void 0 : dataSource.length) > renderAsyncWithLength;
|
|
812
831
|
return jsx("div", {
|
|
813
|
-
css:
|
|
832
|
+
css: TreeViewRootCSS,
|
|
814
833
|
className: 'DGN-UI-TreeView' + (disabled ? ' disabled' : '')
|
|
815
834
|
}, showSelectedItems && jsx(InputBase, {
|
|
816
835
|
inputRef: inputValueRef,
|
|
@@ -845,10 +864,9 @@ const TreeView = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
845
864
|
})), jsx(Divider, null)), jsx("div", {
|
|
846
865
|
ref: ref,
|
|
847
866
|
...props,
|
|
848
|
-
className: ['TreeView-Content', disabled ? 'disabled' : '', className].join(' ').trim()
|
|
867
|
+
className: ['TreeView-Content', disabled ? 'disabled' : '', className].join(' ').trim().replace(/\s+/g, ' ')
|
|
849
868
|
}, disabledMap ? dataSource : mapParent(dataSource, id, parentID, true).map((data, index) => renderTreeView(data, index.toString(), 0, sync))));
|
|
850
869
|
}, [dataSource, value, multiple, selectBox, disabledBoldResult, autoExpandToResult, showChildrenOfResult, searchMode, onChange, searchProps]);
|
|
851
|
-
return TreeViewComp;
|
|
852
870
|
}));
|
|
853
871
|
TreeView.defaultProps = {
|
|
854
872
|
expand: false,
|
|
@@ -26,79 +26,18 @@ const {
|
|
|
26
26
|
} = typography;
|
|
27
27
|
const {
|
|
28
28
|
system: {
|
|
29
|
-
active,
|
|
30
29
|
rest
|
|
31
30
|
},
|
|
32
|
-
semantic: {
|
|
33
|
-
success,
|
|
34
|
-
warning,
|
|
35
|
-
danger,
|
|
36
|
-
info
|
|
37
|
-
},
|
|
38
31
|
text: {
|
|
39
|
-
main
|
|
32
|
+
main,
|
|
33
|
+
tooltip: textTooltip
|
|
40
34
|
},
|
|
41
35
|
fill: {
|
|
42
36
|
tooltip: fillTooltip
|
|
43
|
-
},
|
|
44
|
-
text: {
|
|
45
|
-
tooltip: textTooltip
|
|
46
37
|
}
|
|
47
38
|
} = colors;
|
|
48
39
|
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]]);
|
|
49
|
-
const colorMap = new Map([['default', main], ['
|
|
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
|
-
};
|
|
40
|
+
const colorMap = new Map([['default', main], ['secondary', rest]]);
|
|
102
41
|
|
|
103
42
|
const isTextClamped = elm => (elm === null || elm === void 0 ? void 0 : elm.scrollHeight) > (elm === null || elm === void 0 ? void 0 : elm.clientHeight);
|
|
104
43
|
|
|
@@ -119,6 +58,9 @@ const Typography = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
119
58
|
}, reference) => {
|
|
120
59
|
const ref = useRef(null);
|
|
121
60
|
const [openTooltip, setOpenTooltip] = useState(false);
|
|
61
|
+
|
|
62
|
+
const _TextRootCSS = TextRootCSS(color, type, lineClamp);
|
|
63
|
+
|
|
122
64
|
useImperativeHandle(reference, () => {
|
|
123
65
|
const currentRef = ref.current || {};
|
|
124
66
|
const _instance = {}; // methods
|
|
@@ -131,7 +73,9 @@ const Typography = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
131
73
|
|
|
132
74
|
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
75
|
|
|
134
|
-
const setHoverTooltip = open => {
|
|
76
|
+
const setHoverTooltip = (open, isTooltip) => {
|
|
77
|
+
!isTooltip && setOpenTooltip(false);
|
|
78
|
+
|
|
135
79
|
if (hoverTooltip && isTextClamped(ref.current)) {
|
|
136
80
|
setOpenTooltip(open);
|
|
137
81
|
}
|
|
@@ -151,11 +95,11 @@ const Typography = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
151
95
|
style: {
|
|
152
96
|
color: textTooltip
|
|
153
97
|
},
|
|
154
|
-
onMouseEnter: () => setHoverTooltip(true),
|
|
155
|
-
onMouseLeave: () => setHoverTooltip(false),
|
|
156
|
-
|
|
98
|
+
onMouseEnter: () => setHoverTooltip(true, true),
|
|
99
|
+
onMouseLeave: () => setHoverTooltip(false, true),
|
|
100
|
+
direction: tooltipDirection
|
|
157
101
|
}, renderHTML(renderChildren(), mapping, {
|
|
158
|
-
css:
|
|
102
|
+
css: _TextRootCSS,
|
|
159
103
|
className: classNames(true),
|
|
160
104
|
style: {
|
|
161
105
|
color: textTooltip,
|
|
@@ -164,7 +108,7 @@ const Typography = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
164
108
|
})), [openTooltip, tooltipDirection, children, mapping, color, type, lineClamp]);
|
|
165
109
|
return jsx(Fragment, null, renderHTML(renderChildren(), mapping, {
|
|
166
110
|
ref: ref,
|
|
167
|
-
css:
|
|
111
|
+
css: _TextRootCSS,
|
|
168
112
|
className: classNames(false),
|
|
169
113
|
onMouseEnter: () => setHoverTooltip(true),
|
|
170
114
|
onMouseLeave: () => setHoverTooltip(false),
|
|
@@ -172,7 +116,7 @@ const Typography = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
172
116
|
}), hoverTooltip && renderTooltip);
|
|
173
117
|
}));
|
|
174
118
|
|
|
175
|
-
const
|
|
119
|
+
const TextRootCSS = (color, type, lineClamp) => css`
|
|
176
120
|
${displayInlineBlock};
|
|
177
121
|
${positionRelative};
|
|
178
122
|
${breakWord};
|
|
@@ -213,7 +157,7 @@ Typography.defaultProps = {
|
|
|
213
157
|
mapping: 'span',
|
|
214
158
|
className: '',
|
|
215
159
|
hoverTooltip: false,
|
|
216
|
-
tooltipDirection: '
|
|
160
|
+
tooltipDirection: 'bottom'
|
|
217
161
|
};
|
|
218
162
|
/** type of text<br/>
|
|
219
163
|
* h1: Title <br/>
|
|
@@ -246,7 +190,7 @@ Typography.propTypes = {
|
|
|
246
190
|
/** text-transform is uppercase if true */
|
|
247
191
|
uppercase: PropTypes.bool,
|
|
248
192
|
|
|
249
|
-
/** text-transform is
|
|
193
|
+
/** text-transform is capitalized if true (and uppercase is false) */
|
|
250
194
|
capitalize: PropTypes.bool,
|
|
251
195
|
|
|
252
196
|
/** The line-clamp property truncates text at a specific number of lines. */
|
|
@@ -256,7 +200,7 @@ Typography.propTypes = {
|
|
|
256
200
|
hoverTooltip: PropTypes.bool,
|
|
257
201
|
|
|
258
202
|
/** Tooltip direction */
|
|
259
|
-
tooltipDirection: PropTypes.oneOf(['top', '
|
|
203
|
+
tooltipDirection: PropTypes.oneOf(['top', 'bottom', 'left', 'right']),
|
|
260
204
|
|
|
261
205
|
/** allows maximum screen width if true */
|
|
262
206
|
fullWidth: PropTypes.bool,
|
package/package.json
CHANGED
package/readme.md
CHANGED
|
@@ -38,6 +38,24 @@ npm test
|
|
|
38
38
|
```
|
|
39
39
|
|
|
40
40
|
## Changelog
|
|
41
|
+
## 1.3.46
|
|
42
|
+
- \[Added\]: MenuIcon – MHRM09N1025
|
|
43
|
+
- \[Changed\]: Dropdown – Ref set value not in dataSource
|
|
44
|
+
- \[Changed\]: Dropdown – Add logic if multiple then selectBox is true
|
|
45
|
+
- \[Fixed\]: Typography – Fix bug tooltip show wrong when hover
|
|
46
|
+
- \[Fixed\]: Avatar – Fix bug flickering
|
|
47
|
+
- \[Fixed\]: Radio – Fix cursor pointer:none when readonly - Fix event onchange - Fix warning
|
|
48
|
+
- \[Fixed\]: Dropdown – Bug not reload dataSource when onClear
|
|
49
|
+
- \[Fixed\]: Dropdown – Fix bug scroll to top after load more
|
|
50
|
+
|
|
51
|
+
## 1.3.45
|
|
52
|
+
- \[Added\]: MenuIcon – MHRM00N0005, MHRM09N1015, MHRM09N1400, MHRP25L0101, MHRP25L0501, MHRM09N1020
|
|
53
|
+
- \[Changed\]: LineChart – Allow pointsColor, pathColor use CORE colors; Add prop className, style, pointHoverAlignment
|
|
54
|
+
- \[Changed\]: HelperText – Add truncates text 1 line
|
|
55
|
+
- \[Fixed\]: TreeView – Fix css
|
|
56
|
+
- \[Fixed\]: Dropdown – Fix bug when multiple or selectBox value not array
|
|
57
|
+
- \[Fixed\]: Dropdown – Fix bug closeAfterSelect when multiple is true
|
|
58
|
+
|
|
41
59
|
## 1.3.44
|
|
42
60
|
- \[Added\]: MenuIcon – MHRP09N0033
|
|
43
61
|
- \[Changed\]: Modal – Add prop className
|