diginet-core-ui 1.3.78 → 1.3.79
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/components/accordion/details.js +2 -6
- package/components/accordion/group.js +2 -9
- package/components/accordion/index.js +2 -15
- package/components/accordion/summary.js +4 -27
- package/components/alert/index.js +98 -137
- package/components/alert/notify.js +97 -166
- package/components/avatar/index.js +4 -63
- package/components/badge/index.js +7 -34
- package/components/button/icon.js +120 -186
- package/components/button/index.js +136 -205
- package/components/button/more.js +0 -12
- package/components/button/ripple-effect.js +46 -44
- package/components/card/body.js +2 -7
- package/components/card/extra.js +2 -7
- package/components/card/footer.js +2 -7
- package/components/card/header.js +2 -7
- package/components/card/index.js +2 -22
- package/components/chart/Pie/Circle.js +0 -1
- package/components/chart/Pie/Sector.js +0 -17
- package/components/chart/Pie/Sectors.js +0 -10
- package/components/chart/Pie/index.js +4 -36
- package/components/chart/Pie-v2/Circle.js +0 -1
- package/components/chart/Pie-v2/Sector.js +0 -13
- package/components/chart/Pie-v2/Sectors.js +0 -20
- package/components/chart/Pie-v2/index.js +11 -38
- package/components/chart/bar/Axis.js +0 -12
- package/components/chart/bar/Bar.js +13 -35
- package/components/chart/bar/Grid.js +0 -18
- package/components/chart/bar/Labels.js +0 -18
- package/components/chart/bar/Points.js +0 -17
- package/components/chart/bar/index.js +6 -26
- package/components/chart/bar-v2/Axis.js +0 -12
- package/components/chart/bar-v2/Bar.js +15 -36
- package/components/chart/bar-v2/Grid.js +0 -18
- package/components/chart/bar-v2/Labels.js +0 -18
- package/components/chart/bar-v2/Points.js +0 -17
- package/components/chart/bar-v2/index.js +6 -26
- package/components/chart/line/Axis.js +4 -16
- package/components/chart/line/Grid.js +2 -19
- package/components/chart/line/Labels.js +0 -18
- package/components/chart/line/Path.js +23 -33
- package/components/chart/line/Point.js +6 -40
- package/components/chart/line/Title.js +0 -3
- package/components/chart/line/index.js +12 -35
- package/components/chart/line-v2/Axis.js +0 -13
- package/components/chart/line-v2/Grid.js +0 -18
- package/components/chart/line-v2/Labels.js +0 -18
- package/components/chart/line-v2/Path.js +23 -33
- package/components/chart/line-v2/Point.js +6 -35
- package/components/chart/line-v2/Title.js +0 -3
- package/components/chart/line-v2/index.js +12 -30
- package/components/check-text/index.js +0 -8
- package/components/check-text/interview-confirmation.js +0 -7
- package/components/check-text/interview-status.js +0 -7
- package/components/chip/attach.js +4 -17
- package/components/chip/index.js +6 -33
- package/components/collapse/index.js +0 -13
- package/components/divider/index.js +0 -8
- package/components/form-control/attachment/index.js +24 -202
- package/components/form-control/calendar/function.js +40 -94
- package/components/form-control/calendar/index.js +5 -30
- package/components/form-control/calendar/range.js +11 -28
- package/components/form-control/checkbox/index.js +4 -37
- package/components/form-control/control/index.js +3 -13
- package/components/form-control/date-picker/index-old.js +18 -0
- package/components/form-control/date-picker/index.js +23 -99
- package/components/form-control/date-range-picker/index.js +86 -221
- package/components/form-control/dropdown/index.js +72 -289
- package/components/form-control/dropdown-box/index.js +6 -35
- package/components/form-control/form/index.js +0 -2
- package/components/form-control/form-group/index.js +1 -6
- package/components/form-control/helper-text/index.js +2 -9
- package/components/form-control/input-base/index.js +218 -399
- package/components/form-control/label/index.js +2 -12
- package/components/form-control/money-input/index.js +43 -132
- package/components/form-control/number-input/index.js +15 -113
- package/components/form-control/number-input/index2.js +78 -119
- package/components/form-control/phone-input/index.js +16 -78
- package/components/form-control/radio/index.js +4 -23
- package/components/form-control/text-input/index.js +33 -256
- package/components/form-control/time-picker/index.js +14 -71
- package/components/form-control/time-picker/swiper.js +21 -73
- package/components/form-control/toggle/index.js +4 -19
- package/components/form-view/helper-text.js +2 -2
- package/components/form-view/index.js +0 -14
- package/components/form-view/input.js +2 -13
- package/components/form-view/label.js +0 -2
- package/components/grid/Col.js +2 -15
- package/components/grid/Container.js +2 -21
- package/components/grid/Row.js +2 -21
- package/components/grid/index.js +2 -43
- package/components/image/index.js +2 -22
- package/components/index.js +62 -31
- package/components/list/list-item-action.js +0 -9
- package/components/list/list-item-icon.js +0 -9
- package/components/list/list-item-text.js +0 -5
- package/components/list/list-item.js +0 -11
- package/components/list/list.js +0 -13
- package/components/list/sub-header.js +0 -4
- package/components/modal/body.js +2 -6
- package/components/modal/footer.js +2 -11
- package/components/modal/header.js +2 -12
- package/components/modal/index.js +2 -10
- package/components/modal/modal.js +11 -52
- package/components/others/extra/index.js +3 -10
- package/components/others/import/index.js +0 -7
- package/components/others/option-wrapper/index.js +4 -7
- package/components/others/scrollbar/index.js +0 -3
- package/components/paging/page-info.js +39 -101
- package/components/paging/page-selector.js +7 -35
- package/components/paging/page-selector2.js +35 -74
- package/components/paper/index.js +0 -11
- package/components/popover/body.js +2 -6
- package/components/popover/footer.js +2 -11
- package/components/popover/header.js +2 -7
- package/components/popover/index.js +39 -123
- package/components/popup/danger_popup.js +0 -19
- package/components/popup/index.js +2 -48
- package/components/popup/proposals_popup.js +10 -49
- package/components/popup/v2/index.js +0 -31
- package/components/progress/circular.js +19 -81
- package/components/progress/linear.js +4 -20
- package/components/rating/index.js +0 -24
- package/components/slider/slider-container.js +3 -40
- package/components/slider/slider-item.js +10 -25
- package/components/status/index.js +2 -16
- package/components/tab/tab-container.js +2 -16
- package/components/tab/tab-header.js +4 -24
- package/components/tab/tab-panel.js +4 -16
- package/components/tab/tab.js +4 -28
- package/components/tooltip/index.js +12 -97
- package/components/tooltip/portal.js +0 -2
- package/components/transfer/index.js +22 -67
- package/components/tree-view/index.js +62 -202
- package/components/typography/index.js +3 -31
- package/global/index.js +0 -8
- package/icons/basic.js +0 -48
- package/icons/effect.js +17 -29
- package/icons/general/clock/clock.js +0 -2
- package/icons/general/color-handler/background.js +0 -2
- package/icons/general/color-handler/text.js +0 -2
- package/icons/general/emoji/emoji.js +0 -2
- package/icons/general/font-properties/bold.js +0 -2
- package/icons/general/font-properties/font-family.js +0 -2
- package/icons/general/font-properties/font-size.js +0 -2
- package/icons/general/font-properties/italic.js +0 -2
- package/icons/general/font-properties/underline.js +0 -2
- package/icons/general/hyperlink/hyperlink.js +0 -2
- package/icons/general/indent/decrease.js +0 -2
- package/icons/general/indent/increase.js +0 -2
- package/icons/general/list/bullets.js +0 -2
- package/icons/general/list/numbering.js +0 -2
- package/icons/general/picture/picture.js +0 -2
- package/icons/general/steps/redo.js +0 -2
- package/icons/general/steps/undo.js +0 -2
- package/icons/general/text-align/center.js +0 -2
- package/icons/general/text-align/justify.js +0 -2
- package/icons/general/text-align/left.js +0 -2
- package/icons/general/text-align/right.js +0 -2
- package/icons/menu/dhr.js +2 -1
- package/icons/menu/index.js +2 -2
- package/icons/menu/v2/index.js +0 -10
- package/package.json +1 -1
- package/readme.md +11 -1
- package/styles/animation.js +15 -58
- package/styles/color-helper.js +24 -54
- package/styles/colors.js +17 -9
- package/styles/general.js +6 -2
- package/styles/typography.js +4 -4
- package/styles/utils.js +2 -2
- package/theme/createBreakpoints.js +7 -18
- package/theme/make-styles.js +2 -5
- package/theme/set-theme.js +3 -6
- package/theme/settings.js +3 -2
- package/theme/theme-provider.js +0 -1
- package/utils/array/array.js +14 -23
- package/utils/classNames.js +0 -5
- package/utils/console.js +0 -6
- package/utils/date.js +13 -82
- package/utils/error/error.js +1 -9
- package/utils/error/errors.js +1 -48
- package/utils/getFileType.js +0 -9
- package/utils/handleBreakpoints.js +0 -5
- package/utils/intersectionObserver.js +0 -5
- package/utils/iterator.js +0 -9
- package/utils/map-parent.js +3 -10
- package/utils/object/extend.js +0 -10
- package/utils/object/object.js +12 -11
- package/utils/parseHTML.js +0 -1
- package/utils/promisify.js +0 -5
- package/utils/randomString.js +0 -7
- package/utils/remove-unicode.js +0 -1
- package/utils/render-portal.js +1 -9
- package/utils/renderHTML.js +4 -6
- package/utils/renderIcon.js +4 -14
- package/utils/sb-template.js +6 -5
- package/utils/string/capitalize.js +0 -1
- package/utils/string/capitalizeSentenceCase.js +0 -2
- package/utils/string/string.js +0 -13
- package/utils/type.js +0 -21
- package/utils/updatePosition.js +4 -5
- package/utils/useDelayUnmount.js +0 -4
- package/utils/useElementSize.js +9 -3
- package/utils/useEventListener.js +12 -6
- package/utils/useInput.js +0 -6
- package/utils/useMediaQuery.js +8 -10
- package/utils/useOnClickOutside.js +0 -2
- package/utils/usePortal.js +3 -10
- package/utils/validate.js +6 -20
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
/** @jsxRuntime classic */
|
|
2
|
-
|
|
3
2
|
/** @jsx jsx */
|
|
4
3
|
import { memo, forwardRef, useRef, useMemo, useImperativeHandle } from 'react';
|
|
5
4
|
import PropTypes from 'prop-types';
|
|
@@ -29,11 +28,10 @@ const AccordionDetails = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
29
28
|
useImperativeHandle(reference, () => {
|
|
30
29
|
const currentRef = ref.current || {};
|
|
31
30
|
currentRef.element = ref.current;
|
|
32
|
-
const _instance = {
|
|
31
|
+
const _instance = {
|
|
32
|
+
...action
|
|
33
33
|
}; // methods
|
|
34
|
-
|
|
35
34
|
_instance.__proto__ = {}; // hidden methods
|
|
36
|
-
|
|
37
35
|
currentRef.instance = _instance;
|
|
38
36
|
return currentRef;
|
|
39
37
|
});
|
|
@@ -74,10 +72,8 @@ AccordionDetails.defaultProps = {
|
|
|
74
72
|
AccordionDetails.propTypes = {
|
|
75
73
|
/** The content of the component. */
|
|
76
74
|
children: PropTypes.node,
|
|
77
|
-
|
|
78
75
|
/** Class for component. */
|
|
79
76
|
className: PropTypes.string,
|
|
80
|
-
|
|
81
77
|
/** Style inline of component. */
|
|
82
78
|
style: PropTypes.object
|
|
83
79
|
};
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
/** @jsxRuntime classic */
|
|
2
|
-
|
|
3
2
|
/** @jsx jsx */
|
|
4
3
|
import { memo, useRef, forwardRef, Children, cloneElement, useMemo, useImperativeHandle } from 'react';
|
|
5
4
|
import PropTypes from 'prop-types';
|
|
@@ -18,7 +17,6 @@ const AccordionGroup = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
18
17
|
style
|
|
19
18
|
}, reference) => {
|
|
20
19
|
const ref = useRef(null);
|
|
21
|
-
|
|
22
20
|
const onCollapseOther = (e, onExpand) => {
|
|
23
21
|
if (collapseOther) {
|
|
24
22
|
const accordions = ref.current.querySelectorAll('.DGN-UI-Accordion');
|
|
@@ -31,15 +29,13 @@ const AccordionGroup = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
31
29
|
!!onExpand && onExpand(e);
|
|
32
30
|
}
|
|
33
31
|
};
|
|
34
|
-
|
|
35
32
|
useImperativeHandle(reference, () => {
|
|
36
33
|
const currentRef = ref.current || {};
|
|
37
34
|
currentRef.element = ref.current;
|
|
38
|
-
const _instance = {
|
|
35
|
+
const _instance = {
|
|
36
|
+
...action
|
|
39
37
|
}; // methods
|
|
40
|
-
|
|
41
38
|
_instance.__proto__ = {}; // hidden methods
|
|
42
|
-
|
|
43
39
|
currentRef.instance = _instance;
|
|
44
40
|
return currentRef;
|
|
45
41
|
});
|
|
@@ -123,13 +119,10 @@ AccordionGroup.defaultProps = {
|
|
|
123
119
|
AccordionGroup.propTypes = {
|
|
124
120
|
/** The content of the component. */
|
|
125
121
|
children: PropTypes.node,
|
|
126
|
-
|
|
127
122
|
/** Class for component. */
|
|
128
123
|
className: PropTypes.string,
|
|
129
|
-
|
|
130
124
|
/** If `true`, collapse other when expand */
|
|
131
125
|
collapseOther: PropTypes.bool,
|
|
132
|
-
|
|
133
126
|
/** Style inline of component. */
|
|
134
127
|
style: PropTypes.object
|
|
135
128
|
};
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
/** @jsxRuntime classic */
|
|
2
|
-
|
|
3
2
|
/** @jsx jsx */
|
|
4
3
|
import { memo, useEffect, useRef, forwardRef, useState, useMemo, useImperativeHandle } from 'react';
|
|
5
4
|
import PropTypes from 'prop-types';
|
|
@@ -35,7 +34,6 @@ const Accordion = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
35
34
|
useEffect(() => {
|
|
36
35
|
if (ref.current) {
|
|
37
36
|
const previous = ref.current.previousElementSibling;
|
|
38
|
-
|
|
39
37
|
if (previous) {
|
|
40
38
|
expandState ? previous.classList.add('previousExpanding') : previous.classList.remove('previousExpanding');
|
|
41
39
|
}
|
|
@@ -44,21 +42,18 @@ const Accordion = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
44
42
|
useEffect(() => {
|
|
45
43
|
expanded !== undefined ? setExpandState(expanded) : setExpandState(expand);
|
|
46
44
|
}, [expand, expanded]);
|
|
47
|
-
|
|
48
45
|
const onClickAccordion = () => {
|
|
49
46
|
!!onClick && onClick({
|
|
50
47
|
target: ref.current
|
|
51
48
|
});
|
|
52
49
|
};
|
|
53
|
-
|
|
54
50
|
useImperativeHandle(reference, () => {
|
|
55
51
|
const currentRef = ref.current || {};
|
|
56
52
|
currentRef.element = ref.current;
|
|
57
|
-
const _instance = {
|
|
53
|
+
const _instance = {
|
|
54
|
+
...action
|
|
58
55
|
}; // methods
|
|
59
|
-
|
|
60
56
|
_instance.__proto__ = {}; // hidden methods
|
|
61
|
-
|
|
62
57
|
currentRef.instance = _instance;
|
|
63
58
|
return currentRef;
|
|
64
59
|
});
|
|
@@ -112,28 +107,20 @@ Accordion.defaultProps = {
|
|
|
112
107
|
Accordion.propTypes = {
|
|
113
108
|
/** The box-shadow of component. */
|
|
114
109
|
boxShadow: PropTypes.oneOfType([PropTypes.string, PropTypes.bool]),
|
|
115
|
-
|
|
116
110
|
/** The content of the component (insist <AccordionSummary />, <AccordionDetails />). */
|
|
117
111
|
children: PropTypes.node,
|
|
118
|
-
|
|
119
112
|
/** Class for component. */
|
|
120
113
|
className: PropTypes.string,
|
|
121
|
-
|
|
122
114
|
/** If `true`, the component is disabled. */
|
|
123
115
|
disabled: PropTypes.bool,
|
|
124
|
-
|
|
125
116
|
/** If `true`, expand immediate after render (shouldn't use this). */
|
|
126
117
|
expand: PropTypes.bool,
|
|
127
|
-
|
|
128
118
|
/** Expand state of accordion (should use this). */
|
|
129
119
|
expanded: PropTypes.bool,
|
|
130
|
-
|
|
131
120
|
/** Callback fired when Accordion is collapsed. */
|
|
132
121
|
onCollapse: PropTypes.func,
|
|
133
|
-
|
|
134
122
|
/** Callback fired when Accordion is expanded. */
|
|
135
123
|
onExpand: PropTypes.func,
|
|
136
|
-
|
|
137
124
|
/** Style inline of component. */
|
|
138
125
|
style: PropTypes.object
|
|
139
126
|
};
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
/** @jsxRuntime classic */
|
|
2
|
-
|
|
3
2
|
/** @jsx jsx */
|
|
4
3
|
import { memo, useEffect, useRef, useContext, forwardRef, useMemo, useImperativeHandle } from 'react';
|
|
5
4
|
import PropTypes from 'prop-types';
|
|
@@ -44,23 +43,18 @@ const AccordionSummary = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
44
43
|
const ref = useRef(null);
|
|
45
44
|
const expandIconRef = useRef(null);
|
|
46
45
|
const timer = useRef(null);
|
|
47
|
-
|
|
48
46
|
const _SummaryRootCSS = SummaryRootCSS(background);
|
|
49
|
-
|
|
50
47
|
const _onClick = e => {
|
|
51
48
|
if (disabled) return;
|
|
52
49
|
const target = e.target;
|
|
53
|
-
|
|
54
50
|
if (onClickAccordion) {
|
|
55
51
|
onClickAccordion();
|
|
56
52
|
return;
|
|
57
53
|
}
|
|
58
|
-
|
|
59
54
|
if (onClick && (!expandIconRef.current || !expandIconRef.current.contains(target))) {
|
|
60
55
|
onClick(e);
|
|
61
56
|
return;
|
|
62
57
|
}
|
|
63
|
-
|
|
64
58
|
if (expandState) {
|
|
65
59
|
if (expanded === undefined) setExpandState(false);
|
|
66
60
|
!!onCollapse && onCollapse(ref.current);
|
|
@@ -69,25 +63,20 @@ const AccordionSummary = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
69
63
|
!!onExpand && onExpand(ref.current);
|
|
70
64
|
}
|
|
71
65
|
};
|
|
72
|
-
|
|
73
66
|
const showHideDetailHandler = type => {
|
|
74
67
|
if (ref.current) {
|
|
75
68
|
const detailsEl = ref.current.nextElementSibling;
|
|
76
|
-
|
|
77
69
|
if (type === 'show') {
|
|
78
70
|
if (detailsEl) {
|
|
79
71
|
const scrollHeight = detailsEl.scrollHeight;
|
|
80
72
|
const duration = Math.max(Math.min(scrollHeight, 1500), 200);
|
|
81
73
|
detailsEl.style.height = scrollHeight + 'px';
|
|
82
|
-
|
|
83
74
|
if (!detailsEl.style.transitionDuration) {
|
|
84
75
|
detailsEl.style.transitionDuration = duration + 'ms';
|
|
85
76
|
}
|
|
86
|
-
|
|
87
77
|
if (timer.current) {
|
|
88
78
|
clearTimeout(timer.current);
|
|
89
79
|
}
|
|
90
|
-
|
|
91
80
|
timer.current = setTimeout(() => {
|
|
92
81
|
detailsEl.style.height = 'auto';
|
|
93
82
|
}, (detailsEl.firstChild.childNodes.length || 2.5) * 100);
|
|
@@ -95,11 +84,9 @@ const AccordionSummary = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
95
84
|
} else {
|
|
96
85
|
if (detailsEl && detailsEl.style.height) {
|
|
97
86
|
detailsEl.style.height = detailsEl.scrollHeight + 'px';
|
|
98
|
-
|
|
99
87
|
if (timer.current) {
|
|
100
88
|
clearTimeout(timer.current);
|
|
101
89
|
}
|
|
102
|
-
|
|
103
90
|
timer.current = setTimeout(() => {
|
|
104
91
|
detailsEl.style.height = null;
|
|
105
92
|
}, 10);
|
|
@@ -107,7 +94,6 @@ const AccordionSummary = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
107
94
|
}
|
|
108
95
|
}
|
|
109
96
|
};
|
|
110
|
-
|
|
111
97
|
useEffect(() => {
|
|
112
98
|
if (expandState) {
|
|
113
99
|
showHideDetailHandler('show');
|
|
@@ -118,11 +104,10 @@ const AccordionSummary = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
118
104
|
useImperativeHandle(reference, () => {
|
|
119
105
|
const currentRef = ref.current || {};
|
|
120
106
|
currentRef.element = ref.current;
|
|
121
|
-
const _instance = {
|
|
107
|
+
const _instance = {
|
|
108
|
+
...action
|
|
122
109
|
}; // methods
|
|
123
|
-
|
|
124
110
|
_instance.__proto__ = {}; // hidden methods
|
|
125
|
-
|
|
126
111
|
currentRef.instance = _instance;
|
|
127
112
|
return currentRef;
|
|
128
113
|
});
|
|
@@ -146,7 +131,8 @@ const AccordionSummary = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
146
131
|
}
|
|
147
132
|
}, title || ''), children), !!expandIcon && jsx("div", {
|
|
148
133
|
className: 'Accordion-Icon-Root'
|
|
149
|
-
}, jsx("div", {
|
|
134
|
+
}, jsx("div", {
|
|
135
|
+
...expandIconProps,
|
|
150
136
|
ref: expandIconRef,
|
|
151
137
|
className: classNames('Accordion-Icon', !collapseIcon && 'rotate-able', expandIconProps === null || expandIconProps === void 0 ? void 0 : expandIconProps.className)
|
|
152
138
|
}, typeof expandIcon === 'string' ? jsx(ButtonIcon, {
|
|
@@ -174,31 +160,22 @@ AccordionSummary.defaultProps = {
|
|
|
174
160
|
AccordionSummary.propTypes = {
|
|
175
161
|
/** Background for label summary. */
|
|
176
162
|
background: PropTypes.oneOfType([PropTypes.string, PropTypes.bool]),
|
|
177
|
-
|
|
178
163
|
/** The content of the component. */
|
|
179
164
|
children: PropTypes.node,
|
|
180
|
-
|
|
181
165
|
/** Class for component. */
|
|
182
166
|
className: PropTypes.string,
|
|
183
|
-
|
|
184
167
|
/** Icon display for collapse icon. */
|
|
185
168
|
collapseIcon: PropTypes.any,
|
|
186
|
-
|
|
187
169
|
/** Icon display for expand icon. */
|
|
188
170
|
expandIcon: PropTypes.any,
|
|
189
|
-
|
|
190
171
|
/** Position to render icon. */
|
|
191
172
|
expandIconAt: PropTypes.oneOf(['start', 'end']),
|
|
192
|
-
|
|
193
173
|
/** Other props of icons. */
|
|
194
174
|
expandIconProps: PropTypes.any,
|
|
195
|
-
|
|
196
175
|
/** Callback fired when the component is clicked. */
|
|
197
176
|
onClick: PropTypes.func,
|
|
198
|
-
|
|
199
177
|
/** Style inline of component. */
|
|
200
178
|
style: PropTypes.object,
|
|
201
|
-
|
|
202
179
|
/** The title of the component. */
|
|
203
180
|
title: PropTypes.oneOfType([PropTypes.string, PropTypes.node])
|
|
204
181
|
};
|
|
@@ -1,21 +1,20 @@
|
|
|
1
1
|
/** @jsxRuntime classic */
|
|
2
|
-
|
|
3
2
|
/** @jsx jsx */
|
|
4
|
-
import {
|
|
3
|
+
import { forwardRef, memo, useEffect, useImperativeHandle, useMemo, useRef, useState } from 'react';
|
|
5
4
|
import PropTypes from 'prop-types';
|
|
6
5
|
import { jsx, css } from '@emotion/core';
|
|
7
6
|
import LinearProgress from '../progress/linear';
|
|
8
|
-
import { color as colors } from '../../styles/colors';
|
|
9
7
|
import ButtonIcon from '../button/icon';
|
|
10
8
|
import Icon from '../../icons';
|
|
11
9
|
import { hexToRGBA } from '../../styles/color-helper';
|
|
10
|
+
import { animations } from '../../styles/animation';
|
|
11
|
+
import { classNames, useDelayUnmount } from '../../utils';
|
|
12
12
|
import { alignCenter, border, borderBox, borderRadius4px, breakWord, displayBlock, flexRow, justifyStart, positionRelative, userSelectNone } from '../../styles/general';
|
|
13
|
-
import
|
|
13
|
+
import { useTheme, useColor as colors } from '../../theme';
|
|
14
14
|
const {
|
|
15
15
|
colors: {
|
|
16
16
|
system: {
|
|
17
|
-
|
|
18
|
-
white
|
|
17
|
+
white: systemWhite
|
|
19
18
|
}
|
|
20
19
|
},
|
|
21
20
|
typography: {
|
|
@@ -28,89 +27,85 @@ const {
|
|
|
28
27
|
},
|
|
29
28
|
spacing,
|
|
30
29
|
zIndex: zIndexCORE
|
|
31
|
-
} =
|
|
30
|
+
} = useTheme();
|
|
32
31
|
const iconMap = new Map([['info', 'Info'], ['success', 'ApprovalFilled'], ['warning', 'Warning'], ['danger', 'CancelFilled']]);
|
|
33
32
|
const maxWidthMap = new Map([['tiny', 320], ['small', 400], ['medium', 480]]);
|
|
34
33
|
const primaryTypoMap = new Map([['tiny', heading5], ['small', heading4], ['medium', heading3]]);
|
|
35
34
|
const iconSizeMap = new Map([['tiny', 16], ['small', 20], ['medium', 24]]);
|
|
36
35
|
const linearProgressSizeMap = new Map([['tiny', 2], ['small', 3], ['medium', 4]]);
|
|
36
|
+
const transitionTime = 300;
|
|
37
37
|
const Alert = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
38
|
-
|
|
39
|
-
text,
|
|
40
|
-
secondary,
|
|
41
|
-
size,
|
|
42
|
-
className,
|
|
43
|
-
progressing,
|
|
38
|
+
action = {},
|
|
44
39
|
autoDisappear,
|
|
45
|
-
|
|
40
|
+
children,
|
|
41
|
+
className,
|
|
46
42
|
clearAble,
|
|
43
|
+
color,
|
|
44
|
+
duration,
|
|
47
45
|
onClose,
|
|
48
|
-
|
|
49
|
-
|
|
46
|
+
progressing,
|
|
47
|
+
secondary,
|
|
48
|
+
size,
|
|
49
|
+
text,
|
|
50
|
+
type
|
|
51
|
+
}, reference) => {
|
|
52
|
+
type = type || color;
|
|
53
|
+
const ref = useRef(null);
|
|
50
54
|
const clearIconRef = useRef(null);
|
|
51
55
|
const [percentState, setPercentState] = useState(100);
|
|
52
|
-
const
|
|
56
|
+
const [isClose, setIsClose] = useState(false);
|
|
57
|
+
const showAlert = useDelayUnmount(!isClose, transitionTime);
|
|
58
|
+
const mainColor = colors[type];
|
|
53
59
|
const opacityColor = hexToRGBA(mainColor, 0.15);
|
|
54
|
-
|
|
55
|
-
const
|
|
56
|
-
|
|
60
|
+
const iconName = iconMap.get(type);
|
|
61
|
+
const iconSize = iconSizeMap.get(size);
|
|
62
|
+
const _AlertContainerCSS = AlertContainerCSS(size);
|
|
57
63
|
const _AlertInfoCSS = AlertInfoCSS(mainColor, opacityColor);
|
|
58
|
-
|
|
59
64
|
const _AlertTextCSS = AlertTextCSS(clearAble);
|
|
60
|
-
|
|
61
65
|
const _AlertPrimaryCSS = AlertPrimaryCSS(secondary, size);
|
|
62
|
-
|
|
63
66
|
const _AlertSecondaryCSS = AlertSecondaryCSS(size);
|
|
64
|
-
|
|
65
67
|
const _linearProgressCSS = linearProgressCSS(size);
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
if (!el) return;
|
|
71
|
-
el.style.pointerEvent = 'none';
|
|
72
|
-
const alertNode = el === null || el === void 0 ? void 0 : (_el$parentNode = el.parentNode) === null || _el$parentNode === void 0 ? void 0 : _el$parentNode.parentNode;
|
|
73
|
-
|
|
74
|
-
if (alertNode) {
|
|
75
|
-
if (urgency) {
|
|
76
|
-
alertNode.style.transition = `opacity 1s ease`;
|
|
77
|
-
alertNode.style.opacity = 1;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
setTimeout(() => {
|
|
81
|
-
alertNode.style.opacity = 0;
|
|
82
|
-
}, 0);
|
|
83
|
-
setTimeout(() => {
|
|
84
|
-
if (onClose) onClose(alertNode);
|
|
85
|
-
alertNode.remove();
|
|
86
|
-
}, !urgency && progressing ? duration * 1000 + 300 : duration * 1000);
|
|
87
|
-
}
|
|
68
|
+
const _onClose = () => {
|
|
69
|
+
setIsClose(true);
|
|
70
|
+
onClose === null || onClose === void 0 ? void 0 : onClose();
|
|
88
71
|
};
|
|
89
|
-
|
|
72
|
+
useEffect(() => {
|
|
73
|
+
setTimeout(() => {
|
|
74
|
+
setPercentState(0);
|
|
75
|
+
}, 100);
|
|
76
|
+
}, []);
|
|
77
|
+
useEffect(() => {
|
|
78
|
+
if (ref.current && isClose) ref.current.style.opacity = 0;
|
|
79
|
+
}, [isClose]);
|
|
80
|
+
useEffect(() => {
|
|
81
|
+
setTimeout(() => {
|
|
82
|
+
if (autoDisappear) _onClose();
|
|
83
|
+
}, duration);
|
|
84
|
+
}, [autoDisappear]);
|
|
85
|
+
useImperativeHandle(reference, () => {
|
|
86
|
+
const currentRef = ref.current || {};
|
|
87
|
+
currentRef.element = ref.current;
|
|
88
|
+
const _instance = {
|
|
89
|
+
...action
|
|
90
|
+
}; // methods
|
|
91
|
+
_instance.__proto__ = {}; // hidden methods
|
|
92
|
+
currentRef.instance = _instance;
|
|
93
|
+
return currentRef;
|
|
94
|
+
});
|
|
90
95
|
const AlertView = useMemo(() => {
|
|
91
96
|
let node = children;
|
|
92
|
-
|
|
93
97
|
if (!node) {
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
color: 'currentColor',
|
|
102
|
-
viewBox: true
|
|
103
|
-
});
|
|
104
|
-
} else {
|
|
105
|
-
node = jsx("span", {
|
|
106
|
-
css: NotFoundIconCSS
|
|
107
|
-
});
|
|
108
|
-
}
|
|
98
|
+
node = jsx(Icon, {
|
|
99
|
+
name: iconName,
|
|
100
|
+
width: iconSize,
|
|
101
|
+
height: iconSize,
|
|
102
|
+
color: 'currentColor',
|
|
103
|
+
viewBox: true
|
|
104
|
+
});
|
|
109
105
|
}
|
|
110
|
-
|
|
111
106
|
return jsx("div", {
|
|
112
107
|
css: _AlertInfoCSS,
|
|
113
|
-
className:
|
|
108
|
+
className: classNames('DGN-UI-Alert', className)
|
|
114
109
|
}, jsx("span", {
|
|
115
110
|
css: AlertIconCSS,
|
|
116
111
|
className: 'DGN-UI-Alert-Icon'
|
|
@@ -125,17 +120,17 @@ const Alert = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
125
120
|
className: 'DGN-UI-Alert-Content-Secondary'
|
|
126
121
|
}, secondary)), jsx("span", {
|
|
127
122
|
css: AlertClearIconCSS,
|
|
128
|
-
onClick:
|
|
123
|
+
onClick: _onClose,
|
|
129
124
|
ref: clearIconRef,
|
|
130
125
|
className: 'DGN-UI-Alert-Clear'
|
|
131
126
|
}, clearAble ? jsx(ButtonIcon, {
|
|
132
127
|
circular: true,
|
|
133
128
|
viewType: 'text',
|
|
134
129
|
size: size,
|
|
135
|
-
color:
|
|
130
|
+
color: type,
|
|
136
131
|
name: 'Close'
|
|
137
132
|
}) : null));
|
|
138
|
-
}, [color, text, clearAble, secondary, size, children, className]);
|
|
133
|
+
}, [color, text, clearAble, secondary, size, children, className, type, onClose, mainColor, opacityColor, isClose]);
|
|
139
134
|
const LinearView = useMemo(() => {
|
|
140
135
|
return progressing ? jsx("span", {
|
|
141
136
|
css: _linearProgressCSS,
|
|
@@ -145,41 +140,30 @@ const Alert = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
145
140
|
background: 'transparent',
|
|
146
141
|
color: mainColor,
|
|
147
142
|
percent: percentState,
|
|
148
|
-
duration: duration,
|
|
143
|
+
duration: duration / 1000,
|
|
149
144
|
height: linearProgressSizeMap.get(size),
|
|
150
145
|
style: {
|
|
151
146
|
boxShadow: 'none'
|
|
152
147
|
}
|
|
153
148
|
})) : null;
|
|
154
|
-
}, [progressing, size, percentState]);
|
|
155
|
-
|
|
156
|
-
if (progressing) {
|
|
157
|
-
setTimeout(() => {
|
|
158
|
-
setPercentState(0);
|
|
159
|
-
}, 1);
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
if (autoDisappear) {
|
|
163
|
-
onClearAlert(clearIconRef.current);
|
|
164
|
-
}
|
|
165
|
-
}, []);
|
|
166
|
-
return jsx("div", {
|
|
149
|
+
}, [progressing, size, duration, percentState]);
|
|
150
|
+
return showAlert ? jsx("div", {
|
|
167
151
|
css: _AlertContainerCSS,
|
|
168
152
|
className: 'DGN-UI-Container-Alert',
|
|
169
153
|
ref: ref
|
|
170
|
-
}, AlertView, LinearView);
|
|
154
|
+
}, AlertView, LinearView) : null;
|
|
171
155
|
}));
|
|
172
|
-
|
|
173
|
-
const AlertContainerCSS =
|
|
156
|
+
const fadeIn = animations.fadeIn;
|
|
157
|
+
const AlertContainerCSS = size => css`
|
|
174
158
|
${positionRelative};
|
|
175
159
|
${displayBlock};
|
|
176
160
|
max-width: ${maxWidthMap.get(size)}px;
|
|
177
|
-
transition: opacity ${
|
|
161
|
+
transition: opacity ${transitionTime}ms ease;
|
|
178
162
|
margin-bottom: 1rem;
|
|
179
163
|
pointer-events: auto;
|
|
180
164
|
z-index: ${zIndexCORE(1)};
|
|
165
|
+
animation: ${fadeIn} ${transitionTime}ms ease;
|
|
181
166
|
`;
|
|
182
|
-
|
|
183
167
|
const AlertInfoCSS = (mainColor, opacityColor) => css`
|
|
184
168
|
${flexRow};
|
|
185
169
|
${positionRelative};
|
|
@@ -189,26 +173,23 @@ const AlertInfoCSS = (mainColor, opacityColor) => css`
|
|
|
189
173
|
${border(1, mainColor)};
|
|
190
174
|
color: ${mainColor};
|
|
191
175
|
background-image: linear-gradient(${opacityColor}, ${opacityColor});
|
|
192
|
-
background-color: ${
|
|
176
|
+
background-color: ${systemWhite};
|
|
193
177
|
width: 100%;
|
|
194
178
|
min-width: 320px;
|
|
195
179
|
padding: ${spacing([0, 1, 0, 4])};
|
|
196
180
|
opacity: 1;
|
|
197
181
|
`;
|
|
198
|
-
|
|
199
182
|
const AlertIconCSS = css`
|
|
200
183
|
display: inherit;
|
|
201
|
-
margin-right:
|
|
184
|
+
margin-right: ${spacing([2.5])};
|
|
202
185
|
padding: ${spacing([2, 0])};
|
|
203
186
|
`;
|
|
204
|
-
|
|
205
187
|
const AlertTextCSS = clearAble => css`
|
|
206
188
|
${displayBlock};
|
|
207
|
-
margin-right: ${clearAble ?
|
|
189
|
+
margin-right: ${spacing([clearAble ? 2.5 : 0])};
|
|
208
190
|
padding: ${spacing([2, 0])};
|
|
209
191
|
align-self: center;
|
|
210
192
|
`;
|
|
211
|
-
|
|
212
193
|
const AlertPrimaryCSS = (secondary, size) => css`
|
|
213
194
|
${flexRow};
|
|
214
195
|
${positionRelative};
|
|
@@ -217,71 +198,51 @@ const AlertPrimaryCSS = (secondary, size) => css`
|
|
|
217
198
|
${userSelectNone};
|
|
218
199
|
${secondary ? primaryTypoMap.get(size) : paragraph1};
|
|
219
200
|
`;
|
|
220
|
-
|
|
221
201
|
const AlertSecondaryCSS = size => css`
|
|
222
202
|
${displayBlock};
|
|
223
203
|
${userSelectNone};
|
|
224
204
|
${size === 'tiny' ? paragraph3 : paragraph2};
|
|
225
205
|
`;
|
|
226
|
-
|
|
227
206
|
const AlertClearIconCSS = css`
|
|
228
207
|
margin-left: auto;
|
|
229
208
|
`;
|
|
230
|
-
|
|
231
209
|
const linearProgressCSS = size => css`
|
|
232
210
|
${displayBlock};
|
|
233
211
|
${positionRelative};
|
|
234
|
-
margin-top: ${size === 'medium' ?
|
|
235
|
-
padding: 0
|
|
236
|
-
`;
|
|
237
|
-
|
|
238
|
-
const NotFoundIconCSS = css`
|
|
239
|
-
${displayBlock};
|
|
240
|
-
width: 70%;
|
|
241
|
-
height: 70%;
|
|
242
|
-
border: 1px dashed ${rest};
|
|
212
|
+
margin-top: ${spacing([size === 'medium' ? 1 : 0.5])};
|
|
213
|
+
padding: ${spacing([0, 1.25])};
|
|
243
214
|
`;
|
|
244
215
|
Alert.defaultProps = {
|
|
245
|
-
|
|
246
|
-
size: 'medium',
|
|
216
|
+
autoDisappear: false,
|
|
247
217
|
className: '',
|
|
248
218
|
clearAble: true,
|
|
219
|
+
color: 'info',
|
|
220
|
+
duration: 2000,
|
|
249
221
|
progressing: false,
|
|
250
|
-
|
|
251
|
-
duration: 5
|
|
222
|
+
size: 'medium'
|
|
252
223
|
};
|
|
253
224
|
Alert.propTypes = {
|
|
254
|
-
/**
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
225
|
+
/** Automatically remove the Alert component after the timer ends (milliseconds). */
|
|
226
|
+
autoDisappear: PropTypes.bool,
|
|
227
|
+
/** The element to display in alert like text props (priority). */
|
|
228
|
+
children: PropTypes.node,
|
|
229
|
+
/** Class for component. */
|
|
258
230
|
className: PropTypes.string,
|
|
259
|
-
|
|
260
|
-
/** The text to show in alert */
|
|
261
|
-
text: PropTypes.string,
|
|
262
|
-
|
|
263
|
-
/** The secondary text to show in alert (under primary) */
|
|
264
|
-
secondary: PropTypes.string,
|
|
265
|
-
|
|
266
|
-
/** size is a string, size of Alert */
|
|
267
|
-
size: PropTypes.oneOf(['tiny', 'small', 'medium']),
|
|
268
|
-
|
|
269
|
-
/** Display clear icon to close alert */
|
|
231
|
+
/** If `true`, show clear icon to close alert. */
|
|
270
232
|
clearAble: PropTypes.bool,
|
|
271
|
-
|
|
272
|
-
/** use to display linear progress in duration time show Alert */
|
|
273
|
-
progressing: PropTypes.bool,
|
|
274
|
-
|
|
275
|
-
/** Automatically remove the Alert component after the timer ends (duration) */
|
|
276
|
-
autoDisappear: PropTypes.bool,
|
|
277
|
-
|
|
278
|
-
/** The amount of time the alert is displayed. The unit is the second */
|
|
233
|
+
/** The amount of time the alert is displayed. The unit is the milliseconds. */
|
|
279
234
|
duration: PropTypes.number,
|
|
280
|
-
|
|
281
|
-
/** The function will run after remove an Alert component */
|
|
235
|
+
/** Callback fired when the component closed. */
|
|
282
236
|
onClose: PropTypes.func,
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
237
|
+
/** If `true`, show linear progress in duration time.*/
|
|
238
|
+
progressing: PropTypes.bool,
|
|
239
|
+
/** The secondary text to show in alert (under primary). */
|
|
240
|
+
secondary: PropTypes.string,
|
|
241
|
+
/** The size of the component. */
|
|
242
|
+
size: PropTypes.oneOf(['tiny', 'small', 'medium']),
|
|
243
|
+
/** The text to show in alert. */
|
|
244
|
+
text: PropTypes.string,
|
|
245
|
+
/** Type of the component. */
|
|
246
|
+
type: PropTypes.oneOf(['info', 'success', 'warning', 'danger'])
|
|
286
247
|
};
|
|
287
248
|
export default Alert;
|