diginet-core-ui 1.3.24 → 1.3.29
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/fonts/SF-Pro-Display-Bold.otf +0 -0
- package/assets/fonts/SF-Pro-Display-Medium.otf +0 -0
- package/assets/fonts/SF-Pro-Display-Regular.otf +0 -0
- package/assets/images/icons/wifi.svg +3 -0
- package/assets/images/menu/dhr/MHRM09N0004.svg +14 -0
- package/assets/images/menu/dhr/MHRP09N0028.svg +6 -0
- package/assets/images/menu/dhr/MHRP09N0029.svg +14 -0
- package/assets/images/menu/dhr/MHRP09N0030.svg +4 -0
- package/assets/images/menu/dhr/MHRP09N0031.svg +5 -0
- package/assets/images/menu/dhr/MHRP29N0012.svg +7 -0
- package/assets/images/menu/dhr/MHRP29N0021.svg +8 -0
- package/assets/images/menu/dhr/MHRP29N0022.svg +9 -0
- package/assets/images/menu/dhr/MHRP29N0023.svg +22 -0
- package/assets/images/menu/dhr/MHRP39N0015.svg +5 -0
- package/assets/images/menu/dhr/TASK.svg +9 -0
- package/assets/images/menu/erp/D05.svg +8 -0
- package/assets/images/menu/erp/D06.svg +4 -0
- package/assets/images/menu/erp/D90R.svg +9 -0
- package/assets/images/menu/erp/DBC.svg +9 -0
- package/assets/images/menu/erp/{W05F0006.svg → W05F0006N0000.svg} +0 -0
- package/assets/images/menu/erp/{W05F0008.svg → W05F0008N0000.svg} +0 -0
- package/assets/images/menu/erp/{W05F4000.svg → W05F4000N0000.svg} +0 -0
- package/assets/images/menu/erp/{W06F0005.svg → W06F0005N0000.svg} +0 -0
- package/assets/images/menu/erp/{W06F0006.svg → W06F0006N0000.svg} +0 -0
- package/assets/images/menu/erp/{W06F0008.svg → W06F0008N0000.svg} +0 -0
- package/assets/images/menu/erp/W94F1000N0000.svg +9 -0
- package/assets/images/menu/erp/W94F1000N0001.svg +9 -0
- package/components/accordion/css.js +42 -33
- package/components/accordion/details.js +29 -17
- package/components/accordion/group.js +23 -23
- package/components/accordion/index.js +36 -27
- package/components/accordion/summary.js +10 -11
- package/components/alert/index.js +97 -91
- package/components/alert/notify.js +10 -8
- package/components/avatar/index.js +19 -17
- package/components/badge/index.js +122 -139
- package/components/button/icon.js +242 -334
- package/components/button/index.js +272 -427
- package/components/button/more.js +4 -5
- package/components/button/ripple-effect.js +4 -6
- package/components/card/body-card.js +4 -6
- package/components/card/card.js +4 -8
- package/components/card/index.js +4 -5
- package/components/chart/Pie/Sector.js +4 -5
- package/components/chart/Pie/Sectors.js +5 -5
- package/components/chart/Pie/index.js +8 -9
- package/components/chart/Pie-v2/Sector.js +4 -5
- package/components/chart/Pie-v2/Sectors.js +7 -8
- package/components/chart/Pie-v2/index.js +11 -16
- package/components/chart/bar/Bar.js +2 -3
- package/components/chart/bar/Labels.js +9 -11
- package/components/chart/bar/index.js +17 -9
- package/components/chart/bar-v2/Bar.js +2 -3
- package/components/chart/bar-v2/Labels.js +9 -11
- package/components/chart/bar-v2/index.js +17 -9
- package/components/chart/line/Labels.js +8 -10
- package/components/chart/line/Point.js +2 -3
- package/components/chart/line/index.js +17 -9
- package/components/chart/line-v2/Labels.js +8 -10
- package/components/chart/line-v2/Point.js +2 -3
- package/components/chart/line-v2/index.js +17 -9
- package/components/chip/attach.js +12 -16
- package/components/chip/index.js +8 -11
- package/components/collapse/index.js +4 -5
- package/components/divider/index.js +27 -14
- package/components/form-control/attachment/index.js +143 -87
- package/components/form-control/calendar/function.js +24 -23
- package/components/form-control/calendar/index.js +2 -4
- package/components/form-control/calendar/range.js +3 -4
- package/components/form-control/checkbox/index.js +85 -71
- package/components/form-control/control/index.js +4 -6
- package/components/form-control/date-picker/index-old.js +0 -2
- package/components/form-control/date-picker/index.js +39 -43
- package/components/form-control/date-range-picker/index.js +26 -28
- package/components/form-control/dropdown/index.js +173 -202
- package/components/form-control/dropdown-box/index.js +72 -49
- package/components/form-control/form-group/index.js +4 -5
- package/components/form-control/helper-text/index.js +4 -5
- package/components/form-control/input-base/index.js +28 -38
- package/components/form-control/label/index.js +23 -13
- package/components/form-control/money-input/index.js +6 -6
- package/components/form-control/number-input/index.js +12 -14
- package/components/form-control/phone-input/index.js +4 -5
- package/components/form-control/radio/index.js +7 -15
- package/components/form-control/text-input/index.js +14 -24
- package/components/form-control/time-picker/index.js +15 -26
- package/components/form-control/time-picker/swiper.js +2 -4
- package/components/form-control/toggle/index.js +22 -18
- package/components/form-view/helper-text.js +4 -5
- package/components/form-view/index.js +4 -5
- package/components/form-view/input.js +5 -7
- package/components/form-view/label.js +2 -6
- package/components/list/list-item-action.js +7 -8
- package/components/list/list-item-icon.js +4 -5
- package/components/list/list-item-text.js +4 -5
- package/components/list/list-item.js +4 -5
- package/components/list/list.js +4 -5
- package/components/list/sub-header.js +4 -5
- package/components/modal/body.js +4 -6
- package/components/modal/footer.js +4 -6
- package/components/modal/header.js +8 -14
- package/components/modal/index.js +4 -5
- package/components/modal/modal.js +6 -13
- package/components/others/extra/index.js +4 -8
- package/components/others/option-wrapper/index.js +57 -0
- package/components/others/scrollbar/index.js +4 -5
- package/components/paging/page-info.js +282 -231
- package/components/paging/page-selector.js +4 -7
- package/components/popover/index.js +6 -7
- package/components/popup/danger_popup.js +8 -18
- package/components/popup/index.js +26 -34
- package/components/popup/proposals_popup.js +9 -16
- package/components/popup/v2/danger-popup.js +4 -6
- package/components/popup/v2/index.js +116 -98
- package/components/popup/v2/info-popup.js +4 -6
- package/components/popup/v2/success-popup.js +4 -6
- package/components/popup/v2/warning-popup.js +4 -6
- package/components/popup/v2/yes-no-popup.js +4 -6
- package/components/progress/circular.js +17 -26
- package/components/progress/linear.js +11 -13
- package/components/rating/index.js +114 -233
- package/components/slider/slider-container.js +15 -10
- package/components/slider/slider-item.js +10 -12
- package/components/status/index.js +63 -57
- package/components/tab/tab-container.js +26 -24
- package/components/tab/tab-header.js +36 -27
- package/components/tab/tab-panel.js +32 -15
- package/components/tab/tab.js +79 -80
- package/components/tooltip/index.js +4 -4
- package/components/transfer/index.js +10 -11
- package/components/tree-view/css.js +2 -0
- package/components/tree-view/index.js +14 -13
- package/components/typography/index.js +6 -112
- package/css/styles.css +1 -1
- package/css/styles.css.map +1 -1
- package/global/index.js +2 -0
- package/icons/basic.js +1648 -959
- package/icons/effect.js +45 -103
- package/package.json +1 -1
- package/readme.md +66 -0
- package/styles/color-helper.js +7 -146
- package/styles/colors.js +6 -2
- package/styles/font.js +9 -0
- package/styles/general.js +100 -7
- package/styles/typography.js +25 -26
- package/theme/settings.js +9 -2
- package/theme/theme-provider.js +15 -7
- package/theme/with-styles.js +2 -4
- package/theme/with-theme.js +2 -4
- package/utils/isMobile.js +21 -0
- package/utils/renderHTML.js +4 -5
- package/utils/renderIcon.js +15 -11
- package/utils/updatePosition.js +2 -2
|
@@ -1,19 +1,43 @@
|
|
|
1
|
-
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
2
|
-
|
|
3
1
|
/** @jsxRuntime classic */
|
|
4
2
|
|
|
5
3
|
/** @jsx jsx */
|
|
6
|
-
import { memo, useRef,
|
|
4
|
+
import { memo, useRef, useMemo, forwardRef, useImperativeHandle } from 'react';
|
|
7
5
|
import PropTypes from 'prop-types';
|
|
8
6
|
import { jsx, css } from '@emotion/core';
|
|
9
|
-
import
|
|
7
|
+
import OptionWrapper from '../others/option-wrapper';
|
|
8
|
+
import * as allColors from '../../styles/colors';
|
|
9
|
+
import { color as colors } from '../../styles/colors';
|
|
10
10
|
import { Typography } from '../';
|
|
11
|
-
import { detectColor, fade,
|
|
12
|
-
import { capitalize } from '../../utils';
|
|
13
|
-
import * as Icons from '../../icons';
|
|
11
|
+
import { detectColor, fade, hslToRgb, isColor, isColorName, rgbaToHexA, rgbToHex, hexToRGBA } from '../../styles/color-helper';
|
|
14
12
|
import Ripple from './ripple-effect';
|
|
15
|
-
import
|
|
16
|
-
import
|
|
13
|
+
import CircularProgress from '../progress/circular';
|
|
14
|
+
import Icon from '../../icons';
|
|
15
|
+
import { flexRow, alignCenter, justifyCenter, positionRelative, borderRadius4px, borderBox, noPadding, noBorder, cursorPointer, overflowHidden, pointerEventsNone, outlineNone, userSelectNone, backgroundTransparent, inlineFlex, noMargin } from '../../styles/general';
|
|
16
|
+
import { typography } from '../../styles/typography';
|
|
17
|
+
const {
|
|
18
|
+
heading1,
|
|
19
|
+
heading2,
|
|
20
|
+
heading4,
|
|
21
|
+
heading5,
|
|
22
|
+
uppercase
|
|
23
|
+
} = typography;
|
|
24
|
+
const {
|
|
25
|
+
system: {
|
|
26
|
+
active,
|
|
27
|
+
disabled: systemDisabled,
|
|
28
|
+
rest,
|
|
29
|
+
white
|
|
30
|
+
},
|
|
31
|
+
semantic: {
|
|
32
|
+
success,
|
|
33
|
+
warning,
|
|
34
|
+
danger,
|
|
35
|
+
info
|
|
36
|
+
},
|
|
37
|
+
fill: {
|
|
38
|
+
disabled: fillDisabled
|
|
39
|
+
}
|
|
40
|
+
} = colors;
|
|
17
41
|
export const getRippleColor = (color, viewType, colors) => {
|
|
18
42
|
if (!isColor(color) && !isColorName(color)) {
|
|
19
43
|
let level = 3;
|
|
@@ -59,12 +83,21 @@ export const getRippleColor = (color, viewType, colors) => {
|
|
|
59
83
|
}
|
|
60
84
|
};
|
|
61
85
|
export const getClassNameFromColor = color => {
|
|
62
|
-
|
|
63
|
-
return color;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
return 'custom-color';
|
|
86
|
+
return !isColor(color) && !isColorName(color) ? color : 'custom-color';
|
|
67
87
|
};
|
|
88
|
+
const colorMap = new Map([['primary', active], ['success', success], ['warning', warning], ['danger', danger], ['info', info]]);
|
|
89
|
+
const iconSizeMap = new Map([['tiny', '16px'], ['small', '20px'], ['medium', '24px'], ['large', '32px'], ['giant', '40px']]);
|
|
90
|
+
const paddingSizeMap = new Map([['tiny', '4px 8px'], ['small', '6px 12px'], ['medium', '8px 16px'], ['large', '8px 20px'], ['giant', '8px 24px']]);
|
|
91
|
+
const outlinedPaddingSizeMap = new Map([['tiny', '3px 7px'], ['small', '5px 11px'], ['medium', '7px 15px'], ['large', '7px 19px'], ['giant', '7px 23px']]);
|
|
92
|
+
const iconMarginSizeMap = new Map([['tiny', '4px'], ['small', '4px'], ['medium', '4px'], ['large', '6px'], ['giant', '8px']]);
|
|
93
|
+
const typographySizeMap = new Map([['tiny', heading5], ['small', heading5], ['medium', heading4], ['large', heading2], ['giant', heading1]]);
|
|
94
|
+
const minHeightSizeMap = new Map([['tiny', '24px'], ['small', '32px'], ['medium', '40px'], ['large', '48px'], ['giant', '56px']]);
|
|
95
|
+
const alphaArr = {
|
|
96
|
+
hover: 0.1,
|
|
97
|
+
focus: 0.2,
|
|
98
|
+
active: 0.3
|
|
99
|
+
};
|
|
100
|
+
const alphaLoading = 0.2;
|
|
68
101
|
const Button = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
69
102
|
type,
|
|
70
103
|
viewType,
|
|
@@ -81,470 +114,280 @@ const Button = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
81
114
|
refs,
|
|
82
115
|
loading,
|
|
83
116
|
...props
|
|
84
|
-
},
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
117
|
+
}, reference) => {
|
|
118
|
+
const ref = useRef(null);
|
|
119
|
+
label = label || text || '';
|
|
120
|
+
const iconSize = iconSizeMap.get(size);
|
|
121
|
+
const paddingSize = paddingSizeMap.get(size);
|
|
122
|
+
const outlinedPaddingSize = outlinedPaddingSizeMap.get(size);
|
|
123
|
+
const typographySize = typographySizeMap.get(size);
|
|
124
|
+
const iconMarginSize = iconMarginSizeMap.get(size);
|
|
125
|
+
const minHeightSize = minHeightSizeMap.get(size);
|
|
89
126
|
const ButtonIcon = css`
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
127
|
+
${flexRow}
|
|
128
|
+
${alignCenter}
|
|
129
|
+
${justifyCenter}
|
|
130
|
+
${positionRelative}
|
|
131
|
+
${borderBox}
|
|
95
132
|
`;
|
|
96
133
|
const ButtonText = css`
|
|
134
|
+
white-space: nowrap;
|
|
97
135
|
color: inherit;
|
|
98
|
-
|
|
99
|
-
margin: 0 ${loading ? '5px' : 0};
|
|
136
|
+
margin: 0 ${loading ? iconMarginSize : 0};
|
|
100
137
|
`;
|
|
101
138
|
const ButtonRoot = css`
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
139
|
+
${inlineFlex}
|
|
140
|
+
${alignCenter}
|
|
141
|
+
${justifyCenter}
|
|
142
|
+
${positionRelative}
|
|
143
|
+
${borderRadius4px}
|
|
144
|
+
${borderBox}
|
|
145
|
+
${uppercase}
|
|
146
|
+
${cursorPointer}
|
|
147
|
+
${overflowHidden}
|
|
148
|
+
${outlineNone}
|
|
149
|
+
${userSelectNone}
|
|
106
150
|
height: max-content;
|
|
107
|
-
outline: none;
|
|
108
|
-
margin: 2px;
|
|
109
|
-
box-sizing: border-box;
|
|
110
|
-
border-radius: 4px;
|
|
111
151
|
transition: all 0.5s;
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
border : none !important;
|
|
119
|
-
&.default {
|
|
120
|
-
color : ${theme.colors.secondary};
|
|
121
|
-
&:hover {
|
|
122
|
-
background-color: ${lighten(theme.colors.secondary, 0.9)};
|
|
123
|
-
}
|
|
124
|
-
&:focus {
|
|
125
|
-
background-color: ${lighten(theme.colors.secondary, 0.8)};
|
|
126
|
-
}
|
|
127
|
-
&:active {
|
|
128
|
-
background-color: ${lighten(theme.colors.secondary, 0.7)};
|
|
129
|
-
}
|
|
152
|
+
&.disabled {
|
|
153
|
+
cursor: not-allowed !important;
|
|
154
|
+
color: ${systemDisabled} !important;
|
|
155
|
+
&.outlined {
|
|
156
|
+
border-color: ${systemDisabled} !important;
|
|
157
|
+
background-color: transparent !important;
|
|
130
158
|
}
|
|
131
|
-
&.
|
|
132
|
-
color
|
|
133
|
-
|
|
134
|
-
background-color: ${lighten(theme.colors.primary, 0.9)};
|
|
135
|
-
}
|
|
136
|
-
&:focus {
|
|
137
|
-
background-color: ${lighten(theme.colors.primary, 0.8)};
|
|
138
|
-
}
|
|
139
|
-
&:active {
|
|
140
|
-
background-color: ${lighten(theme.colors.primary, 0.7)};
|
|
141
|
-
}
|
|
159
|
+
&.filled {
|
|
160
|
+
background-color: ${fillDisabled} !important;
|
|
161
|
+
filter: brightness(1) !important;
|
|
142
162
|
}
|
|
143
|
-
&.
|
|
144
|
-
color
|
|
145
|
-
&:hover {
|
|
146
|
-
background-color: ${lighten(theme.colors.success, 0.9)};
|
|
147
|
-
}
|
|
148
|
-
&:focus {
|
|
149
|
-
background-color: ${lighten(theme.colors.success, 0.8)};
|
|
150
|
-
}
|
|
151
|
-
&:active {
|
|
152
|
-
background-color: ${lighten(theme.colors.success, 0.7)};
|
|
153
|
-
}
|
|
163
|
+
&.text {
|
|
164
|
+
background-color: transparent !important;
|
|
154
165
|
}
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
+
}
|
|
167
|
+
/* &:not(:disabled):focus {
|
|
168
|
+
box-shadow: ${viewType === 'outlined' ? '0 0 0 2px ' + hexToRGBA(active, 0.13) : 'none'};
|
|
169
|
+
} */
|
|
170
|
+
&.loading {
|
|
171
|
+
${pointerEventsNone}
|
|
172
|
+
}
|
|
173
|
+
&.${size} {
|
|
174
|
+
padding: ${paddingSize};
|
|
175
|
+
min-height: ${minHeightSize};
|
|
176
|
+
min-width: max-content;
|
|
177
|
+
&.outlined {
|
|
178
|
+
padding: ${outlinedPaddingSize};
|
|
166
179
|
}
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
&:hover {
|
|
170
|
-
background-color: ${lighten(theme.colors.danger, 0.9)};
|
|
171
|
-
}
|
|
172
|
-
&:focus {
|
|
173
|
-
background-color: ${lighten(theme.colors.danger, 0.8)};
|
|
174
|
-
}
|
|
175
|
-
&:active {
|
|
176
|
-
background-color: ${lighten(theme.colors.danger, 0.7)};
|
|
177
|
-
}
|
|
180
|
+
.css-${ButtonText.name} {
|
|
181
|
+
${typographySize};
|
|
178
182
|
}
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
background-color: ${lighten(theme.colors.info, 0.8)};
|
|
183
|
+
.css-${ButtonIcon.name} {
|
|
184
|
+
margin-right: ${endIcon || label ? iconMarginSize : 0};
|
|
185
|
+
&.DGN-UI-Button-End-Icon,
|
|
186
|
+
&.DGN-UI-Button-Custom-End-Icon {
|
|
187
|
+
margin-right: unset;
|
|
188
|
+
margin-left: ${startIcon || label ? iconMarginSize : 0};
|
|
186
189
|
}
|
|
187
|
-
|
|
188
|
-
|
|
190
|
+
&.DGN-UI-Button-Start-Icon,
|
|
191
|
+
&.DGN-UI-Button-End-Icon {
|
|
192
|
+
height: ${iconSize};
|
|
193
|
+
width: ${iconSize};
|
|
189
194
|
}
|
|
190
195
|
}
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
&:focus {
|
|
197
|
-
background-color: ${lighten(color, 0.8)};
|
|
198
|
-
}
|
|
199
|
-
&:active {
|
|
200
|
-
background-color: ${lighten(color, 0.7)};
|
|
201
|
-
}
|
|
202
|
-
}`}
|
|
203
|
-
${isColorName(color) && `&.custom-color {
|
|
204
|
-
color : ${isColorName(color)};
|
|
205
|
-
&:hover {
|
|
206
|
-
background-color: ${lighten(isColorName(color), 0.9)};
|
|
207
|
-
}
|
|
208
|
-
&:focus {
|
|
209
|
-
background-color: ${lighten(isColorName(color), 0.8)};
|
|
210
|
-
}
|
|
211
|
-
&:active {
|
|
212
|
-
background-color: ${lighten(isColorName(color), 0.7)};
|
|
213
|
-
}
|
|
214
|
-
}`}
|
|
196
|
+
.no-icon {
|
|
197
|
+
${noMargin}
|
|
198
|
+
height: ${iconSize};
|
|
199
|
+
min-width: 0;
|
|
200
|
+
}
|
|
215
201
|
}
|
|
216
202
|
&.outlined {
|
|
217
|
-
|
|
218
|
-
background-color: ${theme.colors.white};
|
|
203
|
+
${backgroundTransparent}
|
|
219
204
|
&.default {
|
|
220
|
-
border: 1px solid ${
|
|
221
|
-
color
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
&:focus {
|
|
226
|
-
background-color: ${lighten(theme.colors.default, 0.8)};
|
|
227
|
-
}
|
|
205
|
+
border: 1px solid ${rest};
|
|
206
|
+
color: ${rest};
|
|
207
|
+
&.loading,
|
|
208
|
+
&:hover,
|
|
209
|
+
&:focus,
|
|
228
210
|
&:active {
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
}
|
|
232
|
-
&.primary {
|
|
233
|
-
border: 1px solid ${theme.colors.primary};
|
|
234
|
-
color : ${theme.colors.primary};
|
|
235
|
-
&:hover {
|
|
236
|
-
background-color: ${lighten(theme.colors.primary, 0.9)};
|
|
211
|
+
color: ${active};
|
|
212
|
+
border-color: ${active};
|
|
237
213
|
}
|
|
238
|
-
|
|
239
|
-
background-color: ${
|
|
240
|
-
}
|
|
241
|
-
&:active {
|
|
242
|
-
background-color: ${lighten(theme.colors.primary, 0.7)};
|
|
243
|
-
}
|
|
244
|
-
}
|
|
245
|
-
&.success {
|
|
246
|
-
border: 1px solid ${theme.colors.success};
|
|
247
|
-
color : ${theme.colors.success};
|
|
248
|
-
&:hover {
|
|
249
|
-
background-color: ${lighten(theme.colors.success, 0.9)};
|
|
250
|
-
}
|
|
251
|
-
&:focus {
|
|
252
|
-
background-color: ${lighten(theme.colors.success, 0.8)};
|
|
253
|
-
}
|
|
254
|
-
&:active {
|
|
255
|
-
background-color: ${lighten(theme.colors.success, 0.7)};
|
|
256
|
-
}
|
|
257
|
-
}
|
|
258
|
-
&.warning {
|
|
259
|
-
border: 1px solid ${theme.colors.warning};
|
|
260
|
-
color : ${theme.colors.warning};
|
|
261
|
-
&:hover {
|
|
262
|
-
background-color: ${lighten(theme.colors.warning, 0.9)};
|
|
263
|
-
}
|
|
264
|
-
&:focus {
|
|
265
|
-
background-color: ${lighten(theme.colors.warning, 0.8)};
|
|
266
|
-
}
|
|
267
|
-
&:active {
|
|
268
|
-
background-color: ${lighten(theme.colors.warning, 0.7)};
|
|
214
|
+
&.loading {
|
|
215
|
+
background-color: ${hexToRGBA(active, alphaLoading)};
|
|
269
216
|
}
|
|
217
|
+
${Object.keys(alphaArr).map(key => `&:${key} {
|
|
218
|
+
background-color: ${hexToRGBA(active, alphaArr[key])};
|
|
219
|
+
}`)}// &:hover | &:focus | &:active
|
|
270
220
|
}
|
|
271
|
-
|
|
272
|
-
border: 1px solid ${
|
|
273
|
-
color
|
|
274
|
-
|
|
275
|
-
background-color: ${
|
|
276
|
-
}
|
|
277
|
-
&:focus {
|
|
278
|
-
background-color: ${lighten(theme.colors.danger, 0.8)};
|
|
279
|
-
}
|
|
280
|
-
&:active {
|
|
281
|
-
background-color: ${lighten(theme.colors.danger, 0.7)};
|
|
221
|
+
&.${color} {
|
|
222
|
+
border: 1px solid ${colorMap.get(color)};
|
|
223
|
+
color: ${colorMap.get(color)};
|
|
224
|
+
&.loading {
|
|
225
|
+
background-color: ${hexToRGBA(colorMap.get(color), alphaLoading)};
|
|
282
226
|
}
|
|
227
|
+
${Object.keys(alphaArr).map(key => `&:${key} {
|
|
228
|
+
background-color: ${hexToRGBA(colorMap.get(color), alphaArr[key])};
|
|
229
|
+
}`)}
|
|
283
230
|
}
|
|
284
|
-
&.
|
|
285
|
-
border: 1px solid ${theme.colors.info};
|
|
286
|
-
color : ${theme.colors.info};
|
|
287
|
-
&:hover {
|
|
288
|
-
background-color: ${lighten(theme.colors.info, 0.9)};
|
|
289
|
-
}
|
|
290
|
-
&:focus {
|
|
291
|
-
background-color: ${lighten(theme.colors.info, 0.8)};
|
|
292
|
-
}
|
|
293
|
-
&:active {
|
|
294
|
-
background-color: ${lighten(theme.colors.info, 0.7)};
|
|
295
|
-
}
|
|
296
|
-
}
|
|
297
|
-
${isColor(color) && `&.custom-color {
|
|
231
|
+
&.custom-color {
|
|
298
232
|
border: 1px solid ${color};
|
|
299
|
-
color
|
|
300
|
-
|
|
301
|
-
background-color: ${
|
|
302
|
-
}
|
|
303
|
-
&:focus {
|
|
304
|
-
background-color: ${lighten(color, 0.8)};
|
|
305
|
-
}
|
|
306
|
-
&:active {
|
|
307
|
-
background-color: ${lighten(color, 0.7)};
|
|
233
|
+
color: ${color};
|
|
234
|
+
&.loading {
|
|
235
|
+
background-color: ${hexToRGBA(color, alphaLoading)};
|
|
308
236
|
}
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
&:hover {
|
|
314
|
-
background-color: ${lighten(isColorName(color), 0.9)};
|
|
315
|
-
}
|
|
316
|
-
&:focus {
|
|
317
|
-
background-color: ${lighten(isColorName(color), 0.8)};
|
|
318
|
-
}
|
|
319
|
-
&:active {
|
|
320
|
-
background-color: ${lighten(isColorName(color), 0.7)};
|
|
321
|
-
}
|
|
322
|
-
}`}
|
|
237
|
+
${Object.keys(alphaArr).map(key => `&:${key} {
|
|
238
|
+
background-color: ${hexToRGBA(color, alphaArr[key])};
|
|
239
|
+
}`)}
|
|
240
|
+
}
|
|
323
241
|
}
|
|
324
242
|
&.filled {
|
|
325
|
-
border
|
|
326
|
-
color
|
|
243
|
+
border: none;
|
|
244
|
+
color: ${white};
|
|
327
245
|
font-weight: bold;
|
|
328
|
-
|
|
246
|
+
&.loading,
|
|
247
|
+
&:hover,
|
|
248
|
+
&:focus {
|
|
329
249
|
filter: brightness(0.85);
|
|
330
250
|
}
|
|
331
251
|
&:active {
|
|
332
252
|
filter: brightness(0.7);
|
|
333
253
|
}
|
|
334
254
|
&.default {
|
|
335
|
-
background-color: ${
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
background-color: ${theme.colors.warning};
|
|
345
|
-
}
|
|
346
|
-
&.danger {
|
|
347
|
-
background-color: ${theme.colors.danger};
|
|
255
|
+
background-color: ${rest};
|
|
256
|
+
&.loading {
|
|
257
|
+
background-color: ${active};
|
|
258
|
+
}
|
|
259
|
+
&:hover,
|
|
260
|
+
&:focus,
|
|
261
|
+
&:active {
|
|
262
|
+
background-color: ${active};
|
|
263
|
+
}
|
|
348
264
|
}
|
|
349
|
-
|
|
350
|
-
background-color: ${
|
|
265
|
+
&.${color} {
|
|
266
|
+
background-color: ${colorMap.get(color)};
|
|
351
267
|
}
|
|
352
|
-
|
|
268
|
+
&.custom-color {
|
|
353
269
|
background-color: ${color};
|
|
354
|
-
}`}
|
|
355
|
-
${isColorName(color) && `&.custom-color {
|
|
356
|
-
background-color: ${isColorName(color)};
|
|
357
|
-
}`}
|
|
358
|
-
}
|
|
359
|
-
&.tiny {
|
|
360
|
-
padding: 4px 8px;
|
|
361
|
-
&.outlined {
|
|
362
|
-
padding: 3px 7px;
|
|
363
|
-
}
|
|
364
|
-
.css-${ButtonText.name} {
|
|
365
|
-
font-size: 10px;
|
|
366
|
-
line-height: 16px;
|
|
367
|
-
}
|
|
368
|
-
.css-${ButtonIcon.name} {
|
|
369
|
-
max-height: 16px;
|
|
370
|
-
min-width: 16px;
|
|
371
|
-
max-width: 16px;
|
|
372
|
-
margin-right: 4px;
|
|
373
|
-
&.end-icon {
|
|
374
|
-
margin-right: unset;
|
|
375
|
-
margin-left: 4px;
|
|
376
|
-
}
|
|
377
270
|
}
|
|
378
271
|
}
|
|
379
|
-
&.
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
.css-${ButtonIcon.name} {
|
|
389
|
-
max-height: 20px;
|
|
390
|
-
min-width: 20px;
|
|
391
|
-
max-width: 20px;
|
|
392
|
-
margin-right: 6px;
|
|
393
|
-
&.end-icon {
|
|
394
|
-
margin-right: unset;
|
|
395
|
-
margin-left: 6px;
|
|
272
|
+
&.text {
|
|
273
|
+
${backgroundTransparent}
|
|
274
|
+
${noBorder}
|
|
275
|
+
&.default {
|
|
276
|
+
color: ${rest};
|
|
277
|
+
&:hover,
|
|
278
|
+
&:focus,
|
|
279
|
+
&:active {
|
|
280
|
+
color: ${active};
|
|
396
281
|
}
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
padding: 8px 16px;
|
|
401
|
-
&.outlined {
|
|
402
|
-
padding: 7px 15px;
|
|
403
|
-
}
|
|
404
|
-
.css-${ButtonText.name} {
|
|
405
|
-
font-size: 14px;
|
|
406
|
-
line-height: 24px;
|
|
407
|
-
}
|
|
408
|
-
.css-${ButtonIcon.name} {
|
|
409
|
-
max-height: 24px;
|
|
410
|
-
min-width: 24px;
|
|
411
|
-
max-width: 24px;
|
|
412
|
-
margin-right: 8px;
|
|
413
|
-
&.end-icon {
|
|
414
|
-
margin-right: unset;
|
|
415
|
-
margin-left: 8px;
|
|
282
|
+
&.loading {
|
|
283
|
+
color: ${active};
|
|
284
|
+
background-color: ${hexToRGBA(active, alphaLoading)};
|
|
416
285
|
}
|
|
286
|
+
${Object.keys(alphaArr).map(key => `&:${key} {
|
|
287
|
+
background-color: ${hexToRGBA(active, alphaArr[key])};
|
|
288
|
+
}`)}
|
|
417
289
|
}
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
padding: 7px 19px;
|
|
423
|
-
}
|
|
424
|
-
.css-${ButtonText.name} {
|
|
425
|
-
font-size: 16px;
|
|
426
|
-
line-height: 32px;
|
|
427
|
-
}
|
|
428
|
-
.css-${ButtonIcon.name} {
|
|
429
|
-
max-height: 32px;
|
|
430
|
-
min-width: 32px;
|
|
431
|
-
max-width: 32px;
|
|
432
|
-
margin-right: 8px;
|
|
433
|
-
&.end-icon {
|
|
434
|
-
margin-right: unset;
|
|
435
|
-
margin-left: 8px;
|
|
290
|
+
&.${color} {
|
|
291
|
+
color: ${colorMap.get(color)};
|
|
292
|
+
&.loading {
|
|
293
|
+
background-color: ${hexToRGBA(colorMap.get(color), alphaLoading)};
|
|
436
294
|
}
|
|
295
|
+
${Object.keys(alphaArr).map(key => `&:${key} {
|
|
296
|
+
background-color: ${hexToRGBA(colorMap.get(color), alphaArr[key])};
|
|
297
|
+
}`)}
|
|
437
298
|
}
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
padding: 7px 23px;
|
|
443
|
-
}
|
|
444
|
-
.css-${ButtonText.name} {
|
|
445
|
-
font-size: 20px;
|
|
446
|
-
line-height: 40px;
|
|
447
|
-
}
|
|
448
|
-
.css-${ButtonIcon.name} {
|
|
449
|
-
max-height: 40px;
|
|
450
|
-
min-width: 40px;
|
|
451
|
-
max-width: 40px;
|
|
452
|
-
margin-right: 8px;
|
|
453
|
-
&.end-icon {
|
|
454
|
-
margin-right: unset;
|
|
455
|
-
margin-left: 8px;
|
|
299
|
+
&.custom-color {
|
|
300
|
+
color: ${color};
|
|
301
|
+
&.loading {
|
|
302
|
+
background-color: ${hexToRGBA(color, alphaLoading)};
|
|
456
303
|
}
|
|
304
|
+
${Object.keys(alphaArr).map(key => `&:${key} {
|
|
305
|
+
background-color: ${hexToRGBA(color, alphaArr[key])};
|
|
306
|
+
}`)}
|
|
457
307
|
}
|
|
458
308
|
}
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
309
|
+
&.link {
|
|
310
|
+
${backgroundTransparent}
|
|
311
|
+
${noBorder}
|
|
312
|
+
${noPadding}
|
|
313
|
+
color: ${info};
|
|
314
|
+
&.loading,
|
|
315
|
+
&:hover,
|
|
316
|
+
&:focus {
|
|
317
|
+
filter: brightness(0.85);
|
|
465
318
|
}
|
|
466
|
-
|
|
467
|
-
|
|
319
|
+
&:active {
|
|
320
|
+
filter: brightness(0.7);
|
|
468
321
|
}
|
|
469
|
-
|
|
470
|
-
|
|
322
|
+
&.${color} {
|
|
323
|
+
color: ${colorMap.get(color)};
|
|
471
324
|
}
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
content: '';
|
|
475
|
-
position: absolute;
|
|
476
|
-
cursor: no-drop;
|
|
477
|
-
inset: 0;
|
|
478
|
-
pointer-events: auto;
|
|
479
|
-
z-index: 1;
|
|
325
|
+
&.custom-color {
|
|
326
|
+
color: ${color};
|
|
480
327
|
}
|
|
481
328
|
}
|
|
482
|
-
&:not(:disabled):focus {
|
|
483
|
-
box-shadow: ${viewType !== 'text' ? '0 0 0 2px ' + hexToRgb(colors.brand + '20') : 'none'};
|
|
484
|
-
}
|
|
485
329
|
`;
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
}
|
|
496
|
-
};
|
|
497
|
-
}
|
|
498
|
-
}, [label, text]);
|
|
330
|
+
useImperativeHandle(reference, () => {
|
|
331
|
+
const currentRef = ref.current || {};
|
|
332
|
+
const _instance = {}; // methods
|
|
333
|
+
|
|
334
|
+
_instance.__proto__ = {}; // hidden methods
|
|
335
|
+
|
|
336
|
+
currentRef.instance = _instance;
|
|
337
|
+
return currentRef;
|
|
338
|
+
});
|
|
499
339
|
const StartIcon = useMemo(() => {
|
|
500
340
|
let node = startIcon;
|
|
501
341
|
|
|
502
342
|
if (typeof node === 'string') {
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
343
|
+
node = jsx(Icon, {
|
|
344
|
+
name: node,
|
|
345
|
+
width: iconSize,
|
|
346
|
+
height: iconSize,
|
|
347
|
+
color: 'currentColor',
|
|
348
|
+
viewBox: true
|
|
349
|
+
});
|
|
350
|
+
return jsx("span", {
|
|
351
|
+
css: ButtonIcon,
|
|
352
|
+
className: 'DGN-UI-Button-Start-Icon'
|
|
353
|
+
}, node);
|
|
513
354
|
}
|
|
514
355
|
|
|
515
356
|
return jsx("span", {
|
|
516
|
-
css: ButtonIcon
|
|
357
|
+
css: ButtonIcon,
|
|
358
|
+
className: 'DGN-UI-Button-Custom-Start-Icon'
|
|
517
359
|
}, node);
|
|
518
|
-
}, [startIcon]);
|
|
360
|
+
}, [startIcon, size]);
|
|
519
361
|
const EndIcon = useMemo(() => {
|
|
520
362
|
let node = endIcon;
|
|
521
363
|
|
|
522
364
|
if (typeof node === 'string') {
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
365
|
+
node = jsx(Icon, {
|
|
366
|
+
name: node,
|
|
367
|
+
width: iconSize,
|
|
368
|
+
height: iconSize,
|
|
369
|
+
color: 'currentColor',
|
|
370
|
+
viewBox: true
|
|
371
|
+
});
|
|
372
|
+
return jsx("span", {
|
|
373
|
+
css: ButtonIcon,
|
|
374
|
+
className: 'DGN-UI-Button-End-Icon'
|
|
375
|
+
}, node);
|
|
533
376
|
}
|
|
534
377
|
|
|
535
378
|
return jsx("span", {
|
|
536
379
|
css: ButtonIcon,
|
|
537
|
-
className: '
|
|
380
|
+
className: 'DGN-UI-Button-Custom-End-Icon'
|
|
538
381
|
}, node);
|
|
539
|
-
}, [endIcon]);
|
|
382
|
+
}, [endIcon, size]);
|
|
540
383
|
|
|
541
384
|
const iconLoading = () => {
|
|
542
385
|
return jsx(CircularProgress, {
|
|
543
|
-
size:
|
|
544
|
-
background:
|
|
386
|
+
size: 'extraSmall',
|
|
387
|
+
background: 'transparent',
|
|
545
388
|
color: 'currentColor',
|
|
546
389
|
strokeWidth: 3,
|
|
547
|
-
width:
|
|
390
|
+
width: parseInt(iconSize)
|
|
548
391
|
});
|
|
549
392
|
};
|
|
550
393
|
|
|
@@ -553,12 +396,14 @@ const Button = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
553
396
|
onClick && onClick(event);
|
|
554
397
|
};
|
|
555
398
|
|
|
556
|
-
|
|
399
|
+
return useMemo(() => {
|
|
557
400
|
// 1. Có StartIcon => thay StartIcon
|
|
558
401
|
// 2. Có EndIcon => thay EndIcon
|
|
559
402
|
// 3. Có StartIcon + EndIcon => thay StartIcon
|
|
560
403
|
// 4. Không có Icon => hiện thêm icon loading ở đầu
|
|
561
|
-
let start = startIcon ? StartIcon :
|
|
404
|
+
let start = startIcon ? StartIcon : jsx("span", {
|
|
405
|
+
className: 'no-icon'
|
|
406
|
+
});
|
|
562
407
|
let end = endIcon ? EndIcon : null;
|
|
563
408
|
|
|
564
409
|
if (loading) {
|
|
@@ -573,35 +418,26 @@ const Button = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
573
418
|
if (!startIcon && !endIcon) start = iconLoading();
|
|
574
419
|
}
|
|
575
420
|
|
|
576
|
-
return jsx("button",
|
|
421
|
+
return jsx("button", {
|
|
577
422
|
css: ButtonRoot,
|
|
578
423
|
onClick: _onClick,
|
|
579
424
|
ref: ref,
|
|
580
|
-
disabled: disabled,
|
|
581
425
|
type: type,
|
|
582
|
-
className: ['DGN-UI-Button', viewType, getClassNameFromColor(color), size, className].join(' ').trim().replace(/\s+/g, ' ')
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
426
|
+
className: ['DGN-UI-Button', viewType, getClassNameFromColor(color), size, loading && 'loading', disabled && 'disabled', className].join(' ').trim().replace(/\s+/g, ' '),
|
|
427
|
+
...props
|
|
428
|
+
}, start, jsx(Typography, {
|
|
429
|
+
css: ButtonText,
|
|
586
430
|
type: 'h4',
|
|
587
|
-
className: 'button-text'
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
fontSize: 'inherit',
|
|
591
|
-
lineHeight: 'inherit',
|
|
592
|
-
textTransform: 'inherit'
|
|
593
|
-
}
|
|
594
|
-
}, children || label || text)), end && end, jsx(Ripple, {
|
|
595
|
-
color: getRippleColor(color, viewType, colors)
|
|
431
|
+
className: 'button-text'
|
|
432
|
+
}, children || label), end && end, !disabled && !loading && viewType !== 'link' && jsx(Ripple, {
|
|
433
|
+
color: getRippleColor(color, viewType, allColors)
|
|
596
434
|
}));
|
|
597
|
-
}, [size, viewType, color, disabled, onClick, loading, startIcon, endIcon]);
|
|
598
|
-
return ButtonView;
|
|
435
|
+
}, [size, viewType, color, disabled, onClick, loading, startIcon, endIcon, label]);
|
|
599
436
|
}));
|
|
600
437
|
Button.defaultProps = {
|
|
601
438
|
viewType: 'text',
|
|
602
439
|
color: 'default',
|
|
603
440
|
size: 'medium',
|
|
604
|
-
text: '',
|
|
605
441
|
label: '',
|
|
606
442
|
className: '',
|
|
607
443
|
disabled: false,
|
|
@@ -612,7 +448,7 @@ Button.propTypes = {
|
|
|
612
448
|
type: PropTypes.oneOf(['button', 'submit', 'reset']),
|
|
613
449
|
|
|
614
450
|
/** used to fill background for button */
|
|
615
|
-
viewType: PropTypes.oneOf(['text', 'outlined', 'filled']),
|
|
451
|
+
viewType: PropTypes.oneOf(['text', 'outlined', 'filled', 'link']),
|
|
616
452
|
|
|
617
453
|
/** color for button */
|
|
618
454
|
color: PropTypes.string,
|
|
@@ -620,9 +456,6 @@ Button.propTypes = {
|
|
|
620
456
|
/** size button */
|
|
621
457
|
size: PropTypes.oneOf(['tiny', 'small', 'medium', 'large', 'giant']),
|
|
622
458
|
|
|
623
|
-
/** text to display in button */
|
|
624
|
-
text: PropTypes.string,
|
|
625
|
-
|
|
626
459
|
/** the content to display in button (like text prop) */
|
|
627
460
|
label: PropTypes.string,
|
|
628
461
|
|
|
@@ -648,6 +481,18 @@ Button.propTypes = {
|
|
|
648
481
|
props: PropTypes.any,
|
|
649
482
|
|
|
650
483
|
/** status loading of button */
|
|
651
|
-
loading: PropTypes.bool
|
|
484
|
+
loading: PropTypes.bool,
|
|
485
|
+
|
|
486
|
+
/**
|
|
487
|
+
* ref methods
|
|
488
|
+
*
|
|
489
|
+
* * onClick(): Call onClick function
|
|
490
|
+
* * option(): Gets all UI component properties
|
|
491
|
+
* * option(optionName): Gets the value of a single property.
|
|
492
|
+
* * option(optionName, optionValue): Updates the value of a single property
|
|
493
|
+
* * option(options): Updates the values of several properties
|
|
494
|
+
*/
|
|
495
|
+
ref: PropTypes.any
|
|
652
496
|
};
|
|
653
|
-
export
|
|
497
|
+
export { Button };
|
|
498
|
+
export default OptionWrapper(Button);
|