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,32 +1,28 @@
|
|
|
1
1
|
/** @jsxRuntime classic */
|
|
2
|
-
|
|
3
2
|
/** @jsx jsx */
|
|
4
|
-
import {
|
|
3
|
+
import { css, jsx } from '@emotion/core';
|
|
5
4
|
import PropTypes from 'prop-types';
|
|
6
|
-
import {
|
|
7
|
-
import OptionWrapper from '../others/option-wrapper';
|
|
8
|
-
import * as allColors from '../../styles/colors';
|
|
5
|
+
import { forwardRef, memo, useImperativeHandle, useMemo, useRef } from 'react';
|
|
9
6
|
import { Typography } from '../';
|
|
10
|
-
import { detectColor, fade, hslToRgb, isColor, isColorName, rgbaToHexA, rgbToHex, hexToRGBA } from '../../styles/color-helper';
|
|
11
|
-
import Ripple from './ripple-effect';
|
|
12
|
-
import CircularProgress from '../progress/circular';
|
|
13
7
|
import Icon from '../../icons';
|
|
14
|
-
import {
|
|
15
|
-
import
|
|
16
|
-
import
|
|
8
|
+
import { detectColor, fade, hexToRGBA, hslToRgb, isColor, isColorName, rgbaToHexA, rgbToHex } from '../../styles/color-helper';
|
|
9
|
+
import * as allColors from '../../styles/colors';
|
|
10
|
+
import { alignCenter, backgroundTransparent, border, borderBox, borderNone, borderRadius4px, cursorPointer, flexRow, inlineFlex, justifyCenter, noBorder, noMargin, noPadding, outlineNone, overflowHidden, parseHeight, parseMinHeight, parseMinWidth, parseMinWidthHeight, parseWidthHeight, pointerEventsNone, positionRelative, userSelectNone } from '../../styles/general';
|
|
11
|
+
import { useColor as colors, useTheme } from '../../theme';
|
|
12
|
+
import { classNames, refType as ref } from '../../utils';
|
|
13
|
+
import OptionWrapper from '../others/option-wrapper';
|
|
14
|
+
import CircularProgress from '../progress/circular';
|
|
15
|
+
import Ripple from './ripple-effect';
|
|
17
16
|
const {
|
|
18
17
|
colors: {
|
|
19
18
|
system: {
|
|
20
|
-
active,
|
|
19
|
+
active: systemActive,
|
|
21
20
|
disabled: systemDisabled,
|
|
22
|
-
rest,
|
|
23
|
-
white
|
|
21
|
+
rest: systemRest,
|
|
22
|
+
white: systemWhite
|
|
24
23
|
},
|
|
25
24
|
semantic: {
|
|
26
|
-
|
|
27
|
-
warning,
|
|
28
|
-
danger,
|
|
29
|
-
info
|
|
25
|
+
info: semanticInfo
|
|
30
26
|
},
|
|
31
27
|
fill: {
|
|
32
28
|
disabled: fillDisabled
|
|
@@ -36,47 +32,36 @@ const {
|
|
|
36
32
|
uppercase
|
|
37
33
|
},
|
|
38
34
|
spacing
|
|
39
|
-
} =
|
|
35
|
+
} = useTheme();
|
|
40
36
|
export const getRippleColor = (color, viewType, colors) => {
|
|
41
37
|
if (!isColor(color) && !isColorName(color)) {
|
|
42
38
|
let level = 3;
|
|
43
39
|
let name = color;
|
|
44
|
-
|
|
45
40
|
if (name === 'primary') {
|
|
46
41
|
name = 'formal';
|
|
47
42
|
}
|
|
48
|
-
|
|
49
43
|
const isSystemColor = colors[name + level];
|
|
50
|
-
|
|
51
44
|
if (isSystemColor) {
|
|
52
45
|
if (viewType === 'filled') {
|
|
53
46
|
level = 7;
|
|
54
47
|
}
|
|
55
|
-
|
|
56
48
|
return colors[name + level];
|
|
57
49
|
}
|
|
58
50
|
}
|
|
59
|
-
|
|
60
51
|
if (isColorName(color)) {
|
|
61
52
|
return fade(isColorName(color), 0.5);
|
|
62
53
|
}
|
|
63
|
-
|
|
64
54
|
const colorType = detectColor(color);
|
|
65
|
-
|
|
66
55
|
switch (colorType) {
|
|
67
56
|
case 'hex':
|
|
68
57
|
case 'hexa':
|
|
69
58
|
return rgbaToHexA(fade(color, 0.5));
|
|
70
|
-
|
|
71
59
|
case 'rgb':
|
|
72
60
|
return rgbToHex(fade(color, 0.5));
|
|
73
|
-
|
|
74
61
|
case 'rgba':
|
|
75
62
|
return rgbaToHexA(fade(color, 0.5));
|
|
76
|
-
|
|
77
63
|
case 'hsl':
|
|
78
64
|
return rgbToHex(hslToRgb(fade(color, 0.5)));
|
|
79
|
-
|
|
80
65
|
case 'hsla':
|
|
81
66
|
return rgbaToHexA(hslToRgb(fade(color, 0.5)));
|
|
82
67
|
}
|
|
@@ -84,11 +69,10 @@ export const getRippleColor = (color, viewType, colors) => {
|
|
|
84
69
|
export const getClassNameFromColor = color => {
|
|
85
70
|
return !isColor(color) && !isColorName(color) ? color : 'custom-color';
|
|
86
71
|
};
|
|
87
|
-
const colorMap = new Map([['primary', active], ['success', success], ['warning', warning], ['danger', danger], ['info', info]]);
|
|
88
72
|
const iconSizeMap = new Map([['tiny', spacing([4])], ['small', spacing([5])], ['medium', spacing([6])], ['large', spacing([8])], ['giant', spacing([10])]]);
|
|
89
73
|
const paddingSizeMap = new Map([['tiny', spacing([1, 2])], ['small', spacing([1.5, 3])], ['medium', spacing([2, 4])], ['large', spacing([2, 5])], ['giant', spacing([2, 6])]]);
|
|
90
74
|
const outlinedPaddingSizeMap = new Map([['tiny', spacing([0.75, 1.75])], ['small', spacing([1.25, 2.75])], ['medium', spacing([1.75, 3.75])], ['large', spacing([1.75, 4.75])], ['giant', spacing([1.75, 5.75])]]);
|
|
91
|
-
const iconMarginSizeMap = new Map([['tiny',
|
|
75
|
+
const iconMarginSizeMap = new Map([['tiny', spacing([1])], ['small', spacing([1])], ['medium', spacing([1])], ['large', spacing([1.5])], ['giant', spacing([2])]]);
|
|
92
76
|
const typographySizeMap = new Map([['tiny', 'heading5'], ['small', 'heading5'], ['medium', 'heading4'], ['large', 'heading2'], ['giant', 'heading1']]);
|
|
93
77
|
const minHeightSizeMap = new Map([['tiny', '24px'], ['small', '32px'], ['medium', '40px'], ['large', '48px'], ['giant', '56px']]);
|
|
94
78
|
const minHeightSizeLinkMap = new Map([['tiny', '16px'], ['small', '20px'], ['medium', '24px'], ['large', '32px'], ['giant', '40px']]);
|
|
@@ -102,11 +86,12 @@ const Button = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
102
86
|
action = {},
|
|
103
87
|
children,
|
|
104
88
|
className,
|
|
105
|
-
color,
|
|
89
|
+
color: colorProp,
|
|
106
90
|
disabled,
|
|
107
91
|
endIcon,
|
|
108
92
|
id,
|
|
109
93
|
label,
|
|
94
|
+
labelProps,
|
|
110
95
|
loading,
|
|
111
96
|
onClick,
|
|
112
97
|
size,
|
|
@@ -117,8 +102,9 @@ const Button = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
117
102
|
viewType,
|
|
118
103
|
...props
|
|
119
104
|
}, reference) => {
|
|
120
|
-
const ref = useRef(null);
|
|
121
105
|
label = label || text || '';
|
|
106
|
+
const ref = useRef(null);
|
|
107
|
+
const rippleRef = useRef(null);
|
|
122
108
|
const iconSize = iconSizeMap.get(size);
|
|
123
109
|
const paddingSize = paddingSizeMap.get(size);
|
|
124
110
|
const outlinedPaddingSize = outlinedPaddingSizeMap.get(size);
|
|
@@ -126,25 +112,24 @@ const Button = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
126
112
|
const iconMarginSize = iconMarginSizeMap.get(size);
|
|
127
113
|
const minHeightSize = minHeightSizeMap.get(size);
|
|
128
114
|
const minHeightSizeLink = minHeightSizeLinkMap.get(size);
|
|
129
|
-
|
|
130
|
-
const
|
|
131
|
-
|
|
132
|
-
const
|
|
133
|
-
|
|
115
|
+
const color = colors[colorProp] || colorProp;
|
|
116
|
+
const isViewTypeLink = viewType === 'link';
|
|
117
|
+
const _ButtonRootCSS = ButtonRootCSS(color);
|
|
118
|
+
const _ButtonIcon = ButtonIconCSS(endIcon, label, startIcon, iconMarginSize, iconSize);
|
|
119
|
+
const _ButtonTextCSS = ButtonTextCSS(loading, iconMarginSize);
|
|
120
|
+
const _ButtonSizeCSS = ButtonSizeCSS(paddingSize, minHeightSize, minHeightSizeLink, outlinedPaddingSize, iconSize);
|
|
134
121
|
useImperativeHandle(reference, () => {
|
|
135
122
|
const currentRef = ref.current || {};
|
|
136
123
|
currentRef.element = ref.current;
|
|
137
|
-
const _instance = {
|
|
124
|
+
const _instance = {
|
|
125
|
+
...action
|
|
138
126
|
}; // methods
|
|
139
|
-
|
|
140
127
|
_instance.__proto__ = {}; // hidden methods
|
|
141
|
-
|
|
142
128
|
currentRef.instance = _instance;
|
|
143
129
|
return currentRef;
|
|
144
130
|
});
|
|
145
131
|
const StartIcon = useMemo(() => {
|
|
146
132
|
let node = startIcon;
|
|
147
|
-
|
|
148
133
|
if (typeof node === 'string') {
|
|
149
134
|
node = jsx(Icon, {
|
|
150
135
|
name: node,
|
|
@@ -154,19 +139,17 @@ const Button = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
154
139
|
viewBox: true
|
|
155
140
|
});
|
|
156
141
|
return jsx("span", {
|
|
157
|
-
css:
|
|
142
|
+
css: _ButtonIcon,
|
|
158
143
|
className: 'DGN-UI-Button-Start-Icon'
|
|
159
144
|
}, node);
|
|
160
145
|
}
|
|
161
|
-
|
|
162
146
|
return jsx("span", {
|
|
163
|
-
css:
|
|
147
|
+
css: _ButtonIcon,
|
|
164
148
|
className: 'DGN-UI-Button-Custom-Start-Icon'
|
|
165
149
|
}, node);
|
|
166
150
|
}, [startIcon, size]);
|
|
167
151
|
const EndIcon = useMemo(() => {
|
|
168
152
|
let node = endIcon;
|
|
169
|
-
|
|
170
153
|
if (typeof node === 'string') {
|
|
171
154
|
node = jsx(Icon, {
|
|
172
155
|
name: node,
|
|
@@ -176,19 +159,18 @@ const Button = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
176
159
|
viewBox: true
|
|
177
160
|
});
|
|
178
161
|
return jsx("span", {
|
|
179
|
-
css:
|
|
162
|
+
css: _ButtonIcon,
|
|
180
163
|
className: 'DGN-UI-Button-End-Icon'
|
|
181
164
|
}, node);
|
|
182
165
|
}
|
|
183
|
-
|
|
184
166
|
return jsx("span", {
|
|
185
|
-
css:
|
|
167
|
+
css: _ButtonIcon,
|
|
186
168
|
className: 'DGN-UI-Button-Custom-End-Icon'
|
|
187
169
|
}, node);
|
|
188
170
|
}, [endIcon, size]);
|
|
189
|
-
|
|
190
171
|
const iconLoading = () => {
|
|
191
172
|
return jsx(CircularProgress, {
|
|
173
|
+
className: 'DGN-UI-Button-Loading',
|
|
192
174
|
size: 'extraSmall',
|
|
193
175
|
background: 'transparent',
|
|
194
176
|
color: 'currentColor',
|
|
@@ -196,67 +178,104 @@ const Button = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
196
178
|
width: parseInt(iconSize)
|
|
197
179
|
});
|
|
198
180
|
};
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
onClick && stopPropagation && event.stopPropagation();
|
|
181
|
+
const _onClick = e => {
|
|
182
|
+
onClick && stopPropagation && e.stopPropagation();
|
|
202
183
|
if (disabled || loading) return;
|
|
203
|
-
|
|
184
|
+
if (!isViewTypeLink) rippleRef.current.start(e);
|
|
185
|
+
onClick && onClick(e);
|
|
204
186
|
};
|
|
205
|
-
|
|
206
187
|
return useMemo(() => {
|
|
207
188
|
// 1. Có StartIcon => thay StartIcon
|
|
208
189
|
// 2. Có EndIcon => thay EndIcon
|
|
209
190
|
// 3. Có StartIcon + EndIcon => thay StartIcon
|
|
210
191
|
// 4. Không có Icon => hiện thêm icon loading ở đầu
|
|
192
|
+
|
|
211
193
|
let start = startIcon ? StartIcon : jsx("span", {
|
|
212
194
|
className: 'no-icon'
|
|
213
195
|
});
|
|
214
196
|
let end = endIcon ? EndIcon : null;
|
|
215
|
-
|
|
216
197
|
if (loading) {
|
|
217
198
|
if (startIcon) start = iconLoading();
|
|
218
199
|
if (endIcon) end = iconLoading();
|
|
219
|
-
|
|
220
200
|
if (startIcon && endIcon) {
|
|
221
201
|
start = iconLoading();
|
|
222
202
|
end = EndIcon;
|
|
223
203
|
}
|
|
224
|
-
|
|
225
204
|
if (!startIcon && !endIcon) start = iconLoading();
|
|
226
205
|
}
|
|
227
|
-
|
|
228
206
|
return jsx("button", {
|
|
229
|
-
css:
|
|
207
|
+
css: [_ButtonRootCSS, _ButtonSizeCSS, disabled && ButtonDisabledCSS],
|
|
230
208
|
ref: ref,
|
|
231
209
|
onClick: _onClick,
|
|
232
210
|
id: id,
|
|
233
211
|
type: type,
|
|
234
|
-
|
|
212
|
+
disabled: disabled,
|
|
213
|
+
className: classNames('DGN-UI-Button', viewType, getClassNameFromColor(colorProp), size, loading && 'button--loading', className),
|
|
235
214
|
...props
|
|
236
215
|
}, start, jsx(Typography, {
|
|
237
|
-
css:
|
|
216
|
+
css: _ButtonTextCSS,
|
|
238
217
|
type: typographySize,
|
|
239
|
-
className: 'button-text'
|
|
240
|
-
|
|
241
|
-
|
|
218
|
+
className: classNames('DGN-UI-Button-Label', 'button-text'),
|
|
219
|
+
...labelProps
|
|
220
|
+
}, children || label), end && end, !disabled && !loading && !isViewTypeLink && jsx(Ripple, {
|
|
221
|
+
ref: rippleRef,
|
|
222
|
+
color: getRippleColor(colorProp, viewType, allColors)
|
|
242
223
|
}));
|
|
243
|
-
}, [children, className,
|
|
224
|
+
}, [children, className, colorProp, disabled, endIcon, id, label, loading, onClick, size, startIcon, stopPropagation, type, viewType]);
|
|
244
225
|
}));
|
|
245
|
-
const
|
|
226
|
+
const ButtonIconCSS = (endIcon, label, startIcon, iconMarginSize, iconSize) => css`
|
|
246
227
|
${flexRow};
|
|
247
228
|
${alignCenter};
|
|
248
229
|
${justifyCenter};
|
|
249
230
|
${positionRelative};
|
|
250
231
|
${borderBox};
|
|
232
|
+
margin-right: ${endIcon || label ? iconMarginSize : 0};
|
|
233
|
+
&.DGN-UI-Button-End-Icon,
|
|
234
|
+
&.DGN-UI-Button-Custom-End-Icon {
|
|
235
|
+
margin-right: unset;
|
|
236
|
+
margin-left: ${startIcon || label ? iconMarginSize : 0};
|
|
237
|
+
}
|
|
238
|
+
&.DGN-UI-Button-Start-Icon,
|
|
239
|
+
&.DGN-UI-Button-End-Icon {
|
|
240
|
+
${parseWidthHeight(iconSize)};
|
|
241
|
+
}
|
|
251
242
|
`;
|
|
252
|
-
|
|
253
|
-
const ButtonText = (loading, iconMarginSize) => css`
|
|
243
|
+
const ButtonTextCSS = (loading, iconMarginSize) => css`
|
|
254
244
|
white-space: nowrap;
|
|
255
245
|
color: inherit;
|
|
256
246
|
margin: 0 ${loading ? iconMarginSize : 0};
|
|
257
247
|
`;
|
|
258
|
-
|
|
259
|
-
|
|
248
|
+
const ButtonDisabledCSS = css`
|
|
249
|
+
cursor: not-allowed !important;
|
|
250
|
+
color: ${systemDisabled} !important;
|
|
251
|
+
&.outlined {
|
|
252
|
+
border-color: ${systemDisabled} !important;
|
|
253
|
+
background-color: transparent !important;
|
|
254
|
+
}
|
|
255
|
+
&.filled {
|
|
256
|
+
background-color: ${fillDisabled} !important;
|
|
257
|
+
filter: brightness(1) !important;
|
|
258
|
+
}
|
|
259
|
+
&.text {
|
|
260
|
+
background-color: transparent !important;
|
|
261
|
+
}
|
|
262
|
+
`;
|
|
263
|
+
const ButtonSizeCSS = (paddingSize, minHeightSize, minHeightSizeLink, outlinedPaddingSize, iconSize) => css`
|
|
264
|
+
padding: ${paddingSize};
|
|
265
|
+
${parseMinWidthHeight('max-content', minHeightSize)};
|
|
266
|
+
&.outlined {
|
|
267
|
+
padding: ${outlinedPaddingSize};
|
|
268
|
+
}
|
|
269
|
+
&.link {
|
|
270
|
+
${parseMinHeight(minHeightSizeLink)};
|
|
271
|
+
}
|
|
272
|
+
.no-icon {
|
|
273
|
+
${noMargin};
|
|
274
|
+
${parseHeight(iconSize)};
|
|
275
|
+
${parseMinWidth(0)};
|
|
276
|
+
}
|
|
277
|
+
`;
|
|
278
|
+
const ButtonRootCSS = color => css`
|
|
260
279
|
${inlineFlex};
|
|
261
280
|
${alignCenter};
|
|
262
281
|
${justifyCenter};
|
|
@@ -268,99 +287,44 @@ const ButtonRoot = (viewType, size, paddingSize, minHeightSize, minHeightSizeLin
|
|
|
268
287
|
${overflowHidden};
|
|
269
288
|
${outlineNone};
|
|
270
289
|
${userSelectNone};
|
|
271
|
-
|
|
290
|
+
${parseHeight('max-content')};
|
|
272
291
|
transition: all 0.5s;
|
|
273
|
-
&.button--disabled {
|
|
274
|
-
cursor: not-allowed !important;
|
|
275
|
-
color: ${systemDisabled} !important;
|
|
276
|
-
&.outlined {
|
|
277
|
-
border-color: ${systemDisabled} !important;
|
|
278
|
-
background-color: transparent !important;
|
|
279
|
-
}
|
|
280
|
-
&.filled {
|
|
281
|
-
background-color: ${fillDisabled} !important;
|
|
282
|
-
filter: brightness(1) !important;
|
|
283
|
-
}
|
|
284
|
-
&.text {
|
|
285
|
-
background-color: transparent !important;
|
|
286
|
-
}
|
|
287
|
-
}
|
|
288
|
-
/* &:not(:disabled):focus {
|
|
289
|
-
box-shadow: ${viewType === 'outlined' ? '0 0 0 2px ' + hexToRGBA(active, 0.13) : 'none'};
|
|
290
|
-
} */
|
|
291
292
|
&.button--loading {
|
|
292
293
|
${pointerEventsNone};
|
|
293
294
|
}
|
|
294
|
-
&.${size} {
|
|
295
|
-
padding: ${paddingSize};
|
|
296
|
-
min-height: ${minHeightSize};
|
|
297
|
-
min-width: max-content;
|
|
298
|
-
&.outlined {
|
|
299
|
-
padding: ${outlinedPaddingSize};
|
|
300
|
-
}
|
|
301
|
-
.css-${ButtonIcon.name} {
|
|
302
|
-
margin-right: ${endIcon || label ? iconMarginSize : 0};
|
|
303
|
-
&.DGN-UI-Button-End-Icon,
|
|
304
|
-
&.DGN-UI-Button-Custom-End-Icon {
|
|
305
|
-
margin-right: unset;
|
|
306
|
-
margin-left: ${startIcon || label ? iconMarginSize : 0};
|
|
307
|
-
}
|
|
308
|
-
&.DGN-UI-Button-Start-Icon,
|
|
309
|
-
&.DGN-UI-Button-End-Icon {
|
|
310
|
-
height: ${iconSize};
|
|
311
|
-
width: ${iconSize};
|
|
312
|
-
}
|
|
313
|
-
}
|
|
314
|
-
.no-icon {
|
|
315
|
-
${noMargin};
|
|
316
|
-
height: ${iconSize};
|
|
317
|
-
min-width: 0;
|
|
318
|
-
}
|
|
319
|
-
}
|
|
320
295
|
&.outlined {
|
|
321
|
-
${backgroundTransparent}
|
|
296
|
+
${backgroundTransparent};
|
|
297
|
+
${border(1, color)};
|
|
298
|
+
color: ${color};
|
|
299
|
+
&.button--loading {
|
|
300
|
+
background-color: ${hexToRGBA(color, alphaLoading)};
|
|
301
|
+
}
|
|
302
|
+
${Object.keys(alphaArr).map(key => `&:${key} {
|
|
303
|
+
background-color: ${hexToRGBA(color, alphaArr[key])};
|
|
304
|
+
}`)}
|
|
322
305
|
&.default {
|
|
323
|
-
border
|
|
324
|
-
color: ${
|
|
306
|
+
${border(1, systemRest)};
|
|
307
|
+
color: ${systemRest};
|
|
325
308
|
&.button--loading,
|
|
326
309
|
&:hover,
|
|
327
310
|
&:focus,
|
|
328
311
|
&:active {
|
|
329
|
-
color: ${
|
|
330
|
-
border-color: ${
|
|
312
|
+
color: ${systemActive};
|
|
313
|
+
border-color: ${systemActive};
|
|
331
314
|
}
|
|
332
315
|
&.button--loading {
|
|
333
|
-
background-color: ${hexToRGBA(
|
|
316
|
+
background-color: ${hexToRGBA(systemActive, alphaLoading)};
|
|
334
317
|
}
|
|
335
318
|
${Object.keys(alphaArr).map(key => `&:${key} {
|
|
336
|
-
background-color: ${hexToRGBA(
|
|
319
|
+
background-color: ${hexToRGBA(systemActive, alphaArr[key])};
|
|
337
320
|
}`)}// &:hover | &:focus | &:active
|
|
338
321
|
}
|
|
339
|
-
&.${color} {
|
|
340
|
-
border: 1px solid ${colorMap.get(color)};
|
|
341
|
-
color: ${colorMap.get(color)};
|
|
342
|
-
&.button--loading {
|
|
343
|
-
background-color: ${hexToRGBA(colorMap.get(color), alphaLoading)};
|
|
344
|
-
}
|
|
345
|
-
${Object.keys(alphaArr).map(key => `&:${key} {
|
|
346
|
-
background-color: ${hexToRGBA(colorMap.get(color), alphaArr[key])};
|
|
347
|
-
}`)}
|
|
348
|
-
}
|
|
349
|
-
&.custom-color {
|
|
350
|
-
border: 1px solid ${color};
|
|
351
|
-
color: ${color};
|
|
352
|
-
&.button--loading {
|
|
353
|
-
background-color: ${hexToRGBA(color, alphaLoading)};
|
|
354
|
-
}
|
|
355
|
-
${Object.keys(alphaArr).map(key => `&:${key} {
|
|
356
|
-
background-color: ${hexToRGBA(color, alphaArr[key])};
|
|
357
|
-
}`)}
|
|
358
|
-
}
|
|
359
322
|
}
|
|
360
323
|
&.filled {
|
|
361
|
-
|
|
362
|
-
color: ${
|
|
324
|
+
${borderNone};
|
|
325
|
+
color: ${systemWhite};
|
|
363
326
|
font-weight: bold;
|
|
327
|
+
background-color: ${color};
|
|
364
328
|
&.button--loading,
|
|
365
329
|
&:hover,
|
|
366
330
|
&:focus {
|
|
@@ -370,66 +334,48 @@ const ButtonRoot = (viewType, size, paddingSize, minHeightSize, minHeightSizeLin
|
|
|
370
334
|
filter: brightness(0.7);
|
|
371
335
|
}
|
|
372
336
|
&.default {
|
|
373
|
-
background-color: ${
|
|
337
|
+
background-color: ${systemRest};
|
|
374
338
|
&.button--loading {
|
|
375
|
-
background-color: ${
|
|
339
|
+
background-color: ${systemActive};
|
|
376
340
|
}
|
|
377
341
|
&:hover,
|
|
378
342
|
&:focus,
|
|
379
343
|
&:active {
|
|
380
|
-
background-color: ${
|
|
344
|
+
background-color: ${systemActive};
|
|
381
345
|
}
|
|
382
346
|
}
|
|
383
|
-
&.${color} {
|
|
384
|
-
background-color: ${colorMap.get(color)};
|
|
385
|
-
}
|
|
386
|
-
&.custom-color {
|
|
387
|
-
background-color: ${color};
|
|
388
|
-
}
|
|
389
347
|
}
|
|
390
348
|
&.text {
|
|
391
349
|
${backgroundTransparent};
|
|
392
350
|
${noBorder};
|
|
351
|
+
color: ${color};
|
|
352
|
+
&.button--loading {
|
|
353
|
+
background-color: ${hexToRGBA(color, alphaLoading)};
|
|
354
|
+
}
|
|
355
|
+
${Object.keys(alphaArr).map(key => `&:${key} {
|
|
356
|
+
background-color: ${hexToRGBA(color, alphaArr[key])};
|
|
357
|
+
}`)}
|
|
393
358
|
&.default {
|
|
394
|
-
color: ${
|
|
359
|
+
color: ${systemRest};
|
|
395
360
|
&:hover,
|
|
396
361
|
&:focus,
|
|
397
362
|
&:active {
|
|
398
|
-
color: ${
|
|
363
|
+
color: ${systemActive};
|
|
399
364
|
}
|
|
400
365
|
&.button--loading {
|
|
401
|
-
color: ${
|
|
402
|
-
background-color: ${hexToRGBA(
|
|
366
|
+
color: ${systemActive};
|
|
367
|
+
background-color: ${hexToRGBA(systemActive, alphaLoading)};
|
|
403
368
|
}
|
|
404
369
|
${Object.keys(alphaArr).map(key => `&:${key} {
|
|
405
|
-
background-color: ${hexToRGBA(
|
|
406
|
-
}`)}
|
|
407
|
-
}
|
|
408
|
-
&.${color} {
|
|
409
|
-
color: ${colorMap.get(color)};
|
|
410
|
-
&.button--loading {
|
|
411
|
-
background-color: ${hexToRGBA(colorMap.get(color), alphaLoading)};
|
|
412
|
-
}
|
|
413
|
-
${Object.keys(alphaArr).map(key => `&:${key} {
|
|
414
|
-
background-color: ${hexToRGBA(colorMap.get(color), alphaArr[key])};
|
|
415
|
-
}`)}
|
|
416
|
-
}
|
|
417
|
-
&.custom-color {
|
|
418
|
-
color: ${color};
|
|
419
|
-
&.button--loading {
|
|
420
|
-
background-color: ${hexToRGBA(color, alphaLoading)};
|
|
421
|
-
}
|
|
422
|
-
${Object.keys(alphaArr).map(key => `&:${key} {
|
|
423
|
-
background-color: ${hexToRGBA(color, alphaArr[key])};
|
|
370
|
+
background-color: ${hexToRGBA(systemActive, alphaArr[key])};
|
|
424
371
|
}`)}
|
|
425
372
|
}
|
|
426
373
|
}
|
|
427
374
|
&.link {
|
|
428
|
-
min-height: ${minHeightSizeLink};
|
|
429
375
|
${backgroundTransparent};
|
|
430
376
|
${noBorder};
|
|
431
377
|
${noPadding};
|
|
432
|
-
color: ${
|
|
378
|
+
color: ${color};
|
|
433
379
|
&.button--loading,
|
|
434
380
|
&:hover,
|
|
435
381
|
&:focus {
|
|
@@ -438,59 +384,46 @@ const ButtonRoot = (viewType, size, paddingSize, minHeightSize, minHeightSizeLin
|
|
|
438
384
|
&:active {
|
|
439
385
|
filter: brightness(0.7);
|
|
440
386
|
}
|
|
441
|
-
|
|
442
|
-
color: ${
|
|
443
|
-
}
|
|
444
|
-
&.custom-color {
|
|
445
|
-
color: ${color};
|
|
387
|
+
&.default {
|
|
388
|
+
color: ${semanticInfo};
|
|
446
389
|
}
|
|
447
390
|
}
|
|
448
391
|
`;
|
|
449
|
-
|
|
450
392
|
Button.defaultProps = {
|
|
451
|
-
viewType: 'text',
|
|
452
|
-
color: 'default',
|
|
453
|
-
size: 'medium',
|
|
454
|
-
label: '',
|
|
455
393
|
className: '',
|
|
394
|
+
color: 'default',
|
|
456
395
|
disabled: false,
|
|
396
|
+
label: '',
|
|
457
397
|
loading: false,
|
|
458
|
-
|
|
398
|
+
size: 'medium',
|
|
399
|
+
stopPropagation: true,
|
|
400
|
+
viewType: 'text'
|
|
459
401
|
};
|
|
460
402
|
Button.propTypes = {
|
|
461
403
|
/** The content of the component. */
|
|
462
404
|
children: PropTypes.node,
|
|
463
|
-
|
|
464
405
|
/** Class for component. */
|
|
465
406
|
className: PropTypes.string,
|
|
466
|
-
|
|
467
407
|
/** The color of the component. */
|
|
468
408
|
color: PropTypes.string,
|
|
469
|
-
|
|
470
409
|
/** If `true`, the component is disabled. */
|
|
471
410
|
disabled: PropTypes.bool,
|
|
472
|
-
|
|
473
411
|
/** [Icon](https://core.diginet.com.vn/ui/?path=/story/icon-basic--basic) or element placed after the children. */
|
|
474
412
|
endIcon: PropTypes.oneOfType([PropTypes.string, PropTypes.node]),
|
|
475
|
-
|
|
476
413
|
/** The content of the component. */
|
|
477
414
|
label: PropTypes.string,
|
|
478
|
-
|
|
415
|
+
/** [Props](https://core.diginet.com.vn/ui/?path=/docs/typography--title) applied to the `Typography` label. */
|
|
416
|
+
labelProps: PropTypes.object,
|
|
479
417
|
/** If `true`, the loading indicator is shown. */
|
|
480
418
|
loading: PropTypes.bool,
|
|
481
|
-
|
|
482
419
|
/** Callback fired when the component is clicked. */
|
|
483
420
|
onClick: PropTypes.func,
|
|
484
|
-
|
|
485
421
|
/** The size of the component. */
|
|
486
422
|
size: PropTypes.oneOf(['tiny', 'small', 'medium', 'large', 'giant']),
|
|
487
|
-
|
|
488
423
|
/** [Icon](https://core.diginet.com.vn/ui/?path=/story/icon-basic--basic) or element placed before the children. */
|
|
489
424
|
startIcon: PropTypes.oneOfType([PropTypes.string, PropTypes.node]),
|
|
490
|
-
|
|
491
425
|
/** The variant to use. */
|
|
492
426
|
viewType: PropTypes.oneOf(['text', 'outlined', 'filled', 'link']),
|
|
493
|
-
|
|
494
427
|
/**
|
|
495
428
|
* ref methods (ref.current.instance.*method*)
|
|
496
429
|
*
|
|
@@ -505,9 +438,7 @@ Button.propTypes = {
|
|
|
505
438
|
* * option(options): Updates the values of several properties
|
|
506
439
|
* * @param {options} - object
|
|
507
440
|
*/
|
|
508
|
-
reference:
|
|
509
|
-
current: PropTypes.instanceOf(Element)
|
|
510
|
-
})])
|
|
441
|
+
reference: ref
|
|
511
442
|
};
|
|
512
443
|
export { Button };
|
|
513
444
|
export default OptionWrapper(Button);
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
/** @jsxRuntime classic */
|
|
2
|
-
|
|
3
2
|
/** @jsx jsx */
|
|
4
3
|
import { memo, useRef, useState, useEffect, forwardRef } from 'react';
|
|
5
4
|
import PropTypes from 'prop-types';
|
|
@@ -20,7 +19,6 @@ const ButtonMore = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
20
19
|
if (!ref) {
|
|
21
20
|
ref = useRef(null);
|
|
22
21
|
}
|
|
23
|
-
|
|
24
22
|
const [open, setOpen] = useState(false);
|
|
25
23
|
const ButtonMoreStyle = css`
|
|
26
24
|
display: inline-flex;
|
|
@@ -40,22 +38,18 @@ const ButtonMore = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
40
38
|
display: none;
|
|
41
39
|
}
|
|
42
40
|
`;
|
|
43
|
-
|
|
44
41
|
const showMoreOption = () => {
|
|
45
42
|
if (!open) {
|
|
46
43
|
setOpen(true);
|
|
47
44
|
}
|
|
48
45
|
};
|
|
49
|
-
|
|
50
46
|
useEffect(() => {
|
|
51
47
|
const iconCloseEl = ref.current.querySelector('.more-icon-close');
|
|
52
48
|
const iconDownEl = ref.current.querySelector('.more-icon-down');
|
|
53
|
-
|
|
54
49
|
if (open) {
|
|
55
50
|
iconCloseEl.style.display = 'block';
|
|
56
51
|
iconDownEl.style.display = 'none';
|
|
57
52
|
}
|
|
58
|
-
|
|
59
53
|
return () => {
|
|
60
54
|
if (open) {
|
|
61
55
|
iconCloseEl.style.display = null;
|
|
@@ -112,22 +106,16 @@ ButtonMore.defaultProps = {
|
|
|
112
106
|
ButtonMore.propTypes = {
|
|
113
107
|
/** used to fill background for button */
|
|
114
108
|
viewType: PropTypes.oneOf(['text', 'outlined', 'filled']),
|
|
115
|
-
|
|
116
109
|
/** color for button */
|
|
117
110
|
color: PropTypes.string,
|
|
118
|
-
|
|
119
111
|
/** size button */
|
|
120
112
|
size: PropTypes.oneOf(['tiny', 'small', 'medium', 'large', 'giant']),
|
|
121
|
-
|
|
122
113
|
/** prevent all event if true */
|
|
123
114
|
disabled: PropTypes.bool,
|
|
124
|
-
|
|
125
115
|
/** more options element to display */
|
|
126
116
|
children: PropTypes.node,
|
|
127
|
-
|
|
128
117
|
/** any props else for Button component */
|
|
129
118
|
props: PropTypes.any,
|
|
130
|
-
|
|
131
119
|
/** status loading of button */
|
|
132
120
|
loading: PropTypes.bool
|
|
133
121
|
};
|