diginet-core-ui 1.4.14-beta.2 → 1.4.14-beta.3
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 +36 -25
- package/components/accordion/group.js +33 -18
- package/components/accordion/index.js +42 -28
- package/components/accordion/summary.js +60 -52
- package/components/alert/index.js +84 -75
- package/components/alert/notify.js +53 -41
- package/components/avatar/index.js +97 -94
- package/components/badge/index.js +80 -78
- package/components/breadcrumb/index.js +62 -44
- package/components/button/icon.js +90 -70
- package/components/button/index.js +110 -88
- package/components/button/more.js +60 -39
- package/components/button/ripple-effect.js +1 -1
- package/components/card/body.js +38 -28
- package/components/card/extra.js +38 -28
- package/components/card/footer.js +38 -28
- package/components/card/header.js +39 -28
- package/components/card/index.js +79 -70
- package/components/chart/bar/Labels.js +14 -8
- package/components/chart/bar-v2/Labels.js +14 -8
- package/components/chart/line/Labels.js +14 -8
- package/components/chart/line/Path.js +3 -3
- package/components/chart/line/Point.js +12 -11
- package/components/chart/line-v2/Labels.js +14 -8
- package/components/check-text/index.js +21 -16
- package/components/check-text/interview-confirmation.js +21 -15
- package/components/check-text/interview-status.js +21 -15
- package/components/chip/attach.js +11 -7
- package/components/chip/index.js +83 -82
- package/components/collapse/index.js +1 -1
- package/components/dialogs/colors.js +13 -11
- package/components/divider/index.js +40 -22
- package/components/form-control/attachment/index.js +94 -57
- package/components/form-control/calendar/function.js +173 -169
- package/components/form-control/calendar/index.js +48 -36
- package/components/form-control/calendar/range.js +38 -22
- package/components/form-control/checkbox/index.js +87 -63
- package/components/form-control/control/index.js +9 -10
- package/components/form-control/date-picker/index.js +81 -64
- package/components/form-control/date-range-picker/index.js +98 -81
- package/components/form-control/dropdown/index.js +240 -215
- package/components/form-control/dropdown-box/index.js +56 -43
- package/components/form-control/form-group/index.js +7 -6
- package/components/form-control/helper-text/index.js +45 -41
- package/components/form-control/input-base/index.js +165 -133
- package/components/form-control/label/index.js +48 -41
- package/components/form-control/money-input/index.js +87 -79
- package/components/form-control/number-input/index.js +579 -521
- package/components/form-control/number-input/index2.js +107 -87
- package/components/form-control/password-input/index.js +71 -63
- package/components/form-control/radio/index.js +90 -74
- package/components/form-control/text-input/index.js +83 -74
- package/components/form-control/time-picker/index.js +79 -56
- package/components/form-control/time-picker/v2/index.js +90 -84
- package/components/form-control/toggle/index.js +144 -133
- package/components/form-view/helper-text.js +2 -2
- package/components/form-view/index.js +34 -31
- package/components/form-view/input.js +70 -69
- package/components/form-view/label.js +14 -9
- package/components/grid/Col.js +48 -39
- package/components/grid/Container.js +31 -38
- package/components/grid/Row.js +28 -32
- package/components/grid/index.js +66 -54
- package/components/image/index.js +37 -27
- package/components/list/list-item-action.js +36 -26
- package/components/list/list-item-icon.js +34 -29
- package/components/list/list-item-text.js +27 -22
- package/components/list/list-item.js +42 -36
- package/components/list/list.js +46 -38
- package/components/list/sub-header.js +33 -26
- package/components/modal/body.js +24 -14
- package/components/modal/footer.js +23 -13
- package/components/modal/header.js +39 -28
- package/components/modal/index.js +3 -3
- package/components/modal/modal.js +60 -49
- package/components/others/extra/index.js +31 -30
- package/components/others/import/index.js +2 -2
- package/components/others/scrollbar/index.js +32 -26
- package/components/paging/page-info.js +67 -68
- package/components/paging/page-selector.js +49 -49
- package/components/paper/index.js +32 -28
- package/components/popover/body.js +14 -8
- package/components/popover/footer.js +13 -8
- package/components/popover/header.js +17 -15
- package/components/popover/index.js +103 -92
- package/components/popup/danger_popup.js +17 -16
- package/components/popup/index.js +16 -17
- package/components/popup/v2/index.js +41 -54
- package/components/progress/circular.js +65 -80
- package/components/progress/linear.js +73 -58
- package/components/rating/index.js +49 -63
- package/components/slider/slider-container.js +49 -57
- package/components/slider/slider-item.js +30 -29
- package/components/status/index.js +23 -34
- package/components/tab/tab-header.js +20 -11
- package/components/tab/tab-panel.js +12 -7
- package/components/tab/tab.js +35 -22
- package/components/tooltip/index.js +24 -35
- package/components/transfer/index.js +105 -106
- package/components/tree-view/index.js +133 -115
- package/components/typography/index.js +72 -55
- package/global/index.js +2 -17
- package/icons/basic.js +975 -972
- package/icons/effect.js +21 -20
- package/package.json +3 -1
- package/styles/color-helper.js +105 -105
- package/styles/colors.js +168 -30
- package/styles/general.js +84 -16
- package/styles/sx/index.js +7 -4
- package/styles/utils.js +20 -19
- package/theme/createSpacing.js +10 -0
- package/theme/createTheme.js +26 -0
- package/theme/createZIndex.js +9 -0
- package/theme/index.js +13 -2
- package/theme/make-styles.js +2 -1
- package/theme/settings.js +699 -8
- package/theme/theme-provider.js +32 -15
- package/theme/theme.js +57 -56
- package/theme/use-classes.js +15 -0
- package/theme/utils/getThemeProps.js +12 -0
- package/theme/utils/resolveProps.js +17 -0
- package/theme/utils/useThemeProps.js +14 -0
- package/utils/handleBreakpoints.js +2 -2
- package/utils/hexToRGBA/index.js +7 -7
- package/utils/object/deepmerge.js +104 -0
- package/utils/object/object.js +7 -12
- package/utils/render-portal.js +4 -3
- package/theme/set-theme.js +0 -38
|
@@ -5,28 +5,15 @@ import { Icon } from "./..";
|
|
|
5
5
|
import OptionWrapper from "../others/option-wrapper";
|
|
6
6
|
import PropTypes from 'prop-types';
|
|
7
7
|
import { forwardRef, memo, useImperativeHandle, useMemo, useRef } from 'react';
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
system: {
|
|
14
|
-
rest: systemRest,
|
|
15
|
-
white: systemWhite
|
|
16
|
-
}
|
|
17
|
-
},
|
|
18
|
-
typography: {
|
|
19
|
-
paragraph1,
|
|
20
|
-
paragraph2,
|
|
21
|
-
paragraph3
|
|
22
|
-
},
|
|
23
|
-
spacing
|
|
24
|
-
} = useTheme();
|
|
25
|
-
const colorMap = new Map([['default', systemRest]]);
|
|
8
|
+
import { bgColor, borderRadius4px, boxBorder, displayInlineFlex, flexRow, flexWrap, itemsCenter, justifyCenter, parseMinWidthHeight, parseWidthHeight, pointerEventsNone, positionAbsolute, positionRelative, textColor } from "../../styles/general";
|
|
9
|
+
import { useTheme } from "../../theme";
|
|
10
|
+
import useThemeProps from "../../theme/utils/useThemeProps";
|
|
11
|
+
import { classNames, getProp } from "../../utils";
|
|
12
|
+
const colorMap = new Map([['default', 'system/rest']]);
|
|
26
13
|
const iconSizeMap = new Map([['medium', 24], ['large', 32], ['giant', 40]]);
|
|
27
14
|
const dotSizeMap = new Map([['medium', 8], ['large', 10], ['giant', 12]]);
|
|
28
15
|
const dotIndentMap = new Map([['medium', 4], ['large', 2]]);
|
|
29
|
-
const typographySizeMap = new Map([['medium', paragraph3], ['large', paragraph2], ['giant', paragraph1]]);
|
|
16
|
+
const typographySizeMap = new Map([['medium', 'paragraph3'], ['large', 'paragraph2'], ['giant', 'paragraph1']]);
|
|
30
17
|
const calDotPos = (anchorOrigin, contentDirection, dotSize, hasContent, size) => {
|
|
31
18
|
const halfDotSize = dotSize / 2;
|
|
32
19
|
const {
|
|
@@ -70,32 +57,45 @@ const calDotPos = (anchorOrigin, contentDirection, dotSize, hasContent, size) =>
|
|
|
70
57
|
}
|
|
71
58
|
}
|
|
72
59
|
};
|
|
73
|
-
const Badge = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
74
|
-
action = {},
|
|
75
|
-
anchorOrigin,
|
|
76
|
-
children,
|
|
77
|
-
className,
|
|
78
|
-
color,
|
|
79
|
-
content,
|
|
80
|
-
contentDirection,
|
|
81
|
-
iconProps,
|
|
82
|
-
id,
|
|
83
|
-
invisible,
|
|
84
|
-
max,
|
|
85
|
-
name,
|
|
86
|
-
showZero,
|
|
87
|
-
size,
|
|
88
|
-
style,
|
|
89
|
-
...props
|
|
90
|
-
}, reference) => {
|
|
60
|
+
const Badge = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, reference) => {
|
|
91
61
|
if (!reference) reference = useRef(null);
|
|
62
|
+
const theme = useTheme();
|
|
63
|
+
const {
|
|
64
|
+
colors,
|
|
65
|
+
typography
|
|
66
|
+
} = theme;
|
|
67
|
+
|
|
68
|
+
// props priority: `inProps` > `themeDefaultProps`
|
|
69
|
+
const props = useThemeProps({
|
|
70
|
+
props: inProps,
|
|
71
|
+
name: 'Badge'
|
|
72
|
+
});
|
|
73
|
+
const {
|
|
74
|
+
action = {},
|
|
75
|
+
anchorOrigin,
|
|
76
|
+
children,
|
|
77
|
+
className,
|
|
78
|
+
color,
|
|
79
|
+
content,
|
|
80
|
+
contentDirection,
|
|
81
|
+
iconProps,
|
|
82
|
+
id,
|
|
83
|
+
invisible,
|
|
84
|
+
max,
|
|
85
|
+
name,
|
|
86
|
+
showZero,
|
|
87
|
+
size,
|
|
88
|
+
style,
|
|
89
|
+
...other
|
|
90
|
+
} = props;
|
|
92
91
|
const ref = useRef(null);
|
|
93
|
-
const typographySize = typographySizeMap.get(size);
|
|
92
|
+
const typographySize = typography[typographySizeMap.get(size)];
|
|
94
93
|
const iconSize = iconSizeMap.get(size);
|
|
95
94
|
const dotSize = content || content === 0 && showZero ? dotSizeMap.get(size) + 8 : dotSizeMap.get(size);
|
|
96
|
-
|
|
95
|
+
let dotColor = colorMap.get(color) || color;
|
|
96
|
+
dotColor = getProp(colors, dotColor, dotColor);
|
|
97
97
|
const dotPos = calDotPos(anchorOrigin, !children && name ? 'right' : contentDirection, dotSize, content || content === 0, size);
|
|
98
|
-
const _BadgeNumberCSS = BadgeNumberCSS(typographySize, children, name, dotSize, dotColor);
|
|
98
|
+
const _BadgeNumberCSS = BadgeNumberCSS(typographySize, children, name, dotSize, dotColor, theme);
|
|
99
99
|
const _BadgeRootCSS = BadgeRootCSS(children, name, dotPos, _BadgeNumberCSS.name);
|
|
100
100
|
useImperativeHandle(reference, () => {
|
|
101
101
|
const currentRef = ref.current || {};
|
|
@@ -125,16 +125,19 @@ const Badge = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
125
125
|
id: id,
|
|
126
126
|
className: classNames('DGN-UI-Badge', className),
|
|
127
127
|
style: style,
|
|
128
|
-
...
|
|
128
|
+
...other
|
|
129
129
|
}, jsx("span", {
|
|
130
130
|
className: 'DGN-UI-Badge-Children'
|
|
131
131
|
}, node), content !== undefined && !invisible ? jsx("span", {
|
|
132
132
|
css: _BadgeNumberCSS,
|
|
133
133
|
className: 'DGN-UI-Badge-Dot'
|
|
134
134
|
}, max && content > max ? max + '+' : content === 0 && !showZero ? null : content) : null);
|
|
135
|
-
}, [anchorOrigin, children, className, color, content, contentDirection, iconProps, id, invisible, max, name, showZero, size, style,
|
|
135
|
+
}, [anchorOrigin, children, className, color, content, contentDirection, iconProps, id, invisible, max, name, other, showZero, size, style, theme]);
|
|
136
136
|
}));
|
|
137
|
-
const BadgeNumberCSS = (typographySize, children, name, dotSize, dotColor
|
|
137
|
+
const BadgeNumberCSS = (typographySize, children, name, dotSize, dotColor, {
|
|
138
|
+
colors,
|
|
139
|
+
spacing
|
|
140
|
+
}) => css`
|
|
138
141
|
${typographySize};
|
|
139
142
|
${flexRow};
|
|
140
143
|
${itemsCenter};
|
|
@@ -143,9 +146,9 @@ const BadgeNumberCSS = (typographySize, children, name, dotSize, dotColor) => cs
|
|
|
143
146
|
${boxBorder};
|
|
144
147
|
${pointerEventsNone};
|
|
145
148
|
${children || name ? positionAbsolute : positionRelative};
|
|
146
|
-
|
|
149
|
+
${textColor(getProp(colors, 'system/standard'))};
|
|
150
|
+
${bgColor(dotColor)};
|
|
147
151
|
${parseMinWidthHeight(dotSize)};
|
|
148
|
-
background-color: ${dotColor};
|
|
149
152
|
border-radius: ${dotSize / 2}px;
|
|
150
153
|
padding: ${spacing([0, 1])};
|
|
151
154
|
`;
|
|
@@ -162,21 +165,20 @@ const BadgeRootCSS = (children, name, dotPos, BadgeNumberCSSName) => css`
|
|
|
162
165
|
${(children || name) && dotPos};
|
|
163
166
|
}
|
|
164
167
|
`;
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
};
|
|
168
|
+
|
|
169
|
+
// Badge.defaultProps = {
|
|
170
|
+
// anchorOrigin: { vertical: 'top', horizontal: 'right' },
|
|
171
|
+
// className: '',
|
|
172
|
+
// color: 'default',
|
|
173
|
+
// content: null,
|
|
174
|
+
// contentDirection: 'left',
|
|
175
|
+
// invisible: false,
|
|
176
|
+
// max: 99,
|
|
177
|
+
// showZero: false,
|
|
178
|
+
// size: 'medium',
|
|
179
|
+
// style: {},
|
|
180
|
+
// };
|
|
181
|
+
|
|
180
182
|
Badge.propTypes = {
|
|
181
183
|
/** The anchor of the badge. */
|
|
182
184
|
anchorOrigin: PropTypes.shape({
|
|
@@ -201,28 +203,28 @@ Badge.propTypes = {
|
|
|
201
203
|
name: PropTypes.string,
|
|
202
204
|
/** Controls whether the badge is hidden when `content` is zero. */
|
|
203
205
|
showZero: PropTypes.bool,
|
|
204
|
-
/** Size of the components.
|
|
205
|
-
*
|
|
206
|
-
* * medium (dot 8px, typography p3)
|
|
207
|
-
* * large (button 10px, typography p2)
|
|
208
|
-
* * giant (button 12px, typography p1)
|
|
206
|
+
/** Size of the components.
|
|
207
|
+
*
|
|
208
|
+
* * medium (dot 8px, typography p3)
|
|
209
|
+
* * large (button 10px, typography p2)
|
|
210
|
+
* * giant (button 12px, typography p1)
|
|
209
211
|
* */
|
|
210
212
|
size: PropTypes.oneOf(['medium', 'large', 'giant']),
|
|
211
213
|
/** Style inline of component. */
|
|
212
214
|
style: PropTypes.object
|
|
213
|
-
/**
|
|
214
|
-
* ref methods (ref.current.instance.*method*)
|
|
215
|
-
*
|
|
216
|
-
* * option(): Gets all UI component properties
|
|
217
|
-
* * Returns value - object
|
|
218
|
-
* * option(optionName): Gets the value of a single property
|
|
219
|
-
* * @param {optionName} - string
|
|
220
|
-
* * Returns value - any
|
|
221
|
-
* * option(optionName, optionValue): Updates the value of a single property
|
|
222
|
-
* * @param {optionName} - string
|
|
223
|
-
* * @param {optionValue} - any
|
|
224
|
-
* * option(options): Updates the values of several properties
|
|
225
|
-
* * @param {options} - object
|
|
215
|
+
/**
|
|
216
|
+
* ref methods (ref.current.instance.*method*)
|
|
217
|
+
*
|
|
218
|
+
* * option(): Gets all UI component properties
|
|
219
|
+
* * Returns value - object
|
|
220
|
+
* * option(optionName): Gets the value of a single property
|
|
221
|
+
* * @param {optionName} - string
|
|
222
|
+
* * Returns value - any
|
|
223
|
+
* * option(optionName, optionValue): Updates the value of a single property
|
|
224
|
+
* * @param {optionName} - string
|
|
225
|
+
* * @param {optionValue} - any
|
|
226
|
+
* * option(options): Updates the values of several properties
|
|
227
|
+
* * @param {options} - object
|
|
226
228
|
*/
|
|
227
229
|
};
|
|
228
230
|
|
|
@@ -7,28 +7,41 @@ import { Icon } from "../../icons/effect";
|
|
|
7
7
|
import PropTypes from 'prop-types';
|
|
8
8
|
import React, { forwardRef, memo, useImperativeHandle, useMemo, useRef } from 'react';
|
|
9
9
|
import { hexToRGBA } from "../../styles/color-helper";
|
|
10
|
-
import { alphaPseudo, bgColor, borderRadius, cursorPointer, displayFlex, flexWrap,
|
|
11
|
-
import {
|
|
12
|
-
import
|
|
10
|
+
import { alphaPseudo, bgColor, borderRadius, cursorPointer, displayFlex, flexWrap, itemsCenter, listNone, textColor, userSelectNone } from "../../styles/general";
|
|
11
|
+
import { useTheme } from "../../theme";
|
|
12
|
+
import useThemeProps from "../../theme/utils/useThemeProps";
|
|
13
|
+
import { classNames, getProp } from "../../utils";
|
|
13
14
|
const sizeIconMap = new Map([['tiny', 16], ['small', 18], ['medium', 20]]);
|
|
14
15
|
const sizeTypographyPMap = new Map([['tiny', 'p3'], ['small', 'p2'], ['medium', 'p1']]);
|
|
15
16
|
const sizeTypographyHMap = new Map([['tiny', 'h5'], ['small', 'h4'], ['medium', 'h3']]);
|
|
16
|
-
const Breadcrumb = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
17
|
-
action = {},
|
|
18
|
-
children,
|
|
19
|
-
className,
|
|
20
|
-
color,
|
|
21
|
-
data,
|
|
22
|
-
id,
|
|
23
|
-
itemsAfterCollapse,
|
|
24
|
-
itemsBeforeCollapse,
|
|
25
|
-
maxItems,
|
|
26
|
-
separator,
|
|
27
|
-
size,
|
|
28
|
-
style
|
|
29
|
-
}, reference) => {
|
|
17
|
+
const Breadcrumb = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, reference) => {
|
|
30
18
|
if (!reference) reference = useRef(null);
|
|
31
|
-
|
|
19
|
+
const theme = useTheme();
|
|
20
|
+
const {
|
|
21
|
+
colors
|
|
22
|
+
} = theme;
|
|
23
|
+
|
|
24
|
+
// props priority: `inProps` > `themeDefaultProps`
|
|
25
|
+
const props = useThemeProps({
|
|
26
|
+
props: inProps,
|
|
27
|
+
name: 'Breadcrumb'
|
|
28
|
+
});
|
|
29
|
+
const {
|
|
30
|
+
action = {},
|
|
31
|
+
children,
|
|
32
|
+
className,
|
|
33
|
+
color: colorProp,
|
|
34
|
+
data,
|
|
35
|
+
id,
|
|
36
|
+
itemsAfterCollapse,
|
|
37
|
+
itemsBeforeCollapse,
|
|
38
|
+
maxItems,
|
|
39
|
+
separator,
|
|
40
|
+
size,
|
|
41
|
+
style
|
|
42
|
+
} = props;
|
|
43
|
+
const color = colorProp === 'default' ? 'system/rest' : colorProp;
|
|
44
|
+
const colorCode = getProp(colors, color, color);
|
|
32
45
|
const ref = useRef(null);
|
|
33
46
|
const sizeIcon = sizeIconMap.get(size);
|
|
34
47
|
const sizeTypographyP = sizeTypographyPMap.get(size);
|
|
@@ -36,7 +49,8 @@ const Breadcrumb = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
36
49
|
|
|
37
50
|
// const [expanded, setExpanded] = React.useState(false);
|
|
38
51
|
|
|
39
|
-
const
|
|
52
|
+
const _BreadcrumbOlCSS = BreadcrumbOlCSS(colorCode, theme);
|
|
53
|
+
const _BreadcrumbLiCSS = BreadcrumbLiCSS(colorCode, sizeTypographyP, sizeTypographyH, theme);
|
|
40
54
|
useImperativeHandle(reference, () => {
|
|
41
55
|
const currentRef = ref.current || {};
|
|
42
56
|
currentRef.element = ref.current;
|
|
@@ -51,7 +65,7 @@ const Breadcrumb = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
51
65
|
name: separator,
|
|
52
66
|
width: sizeIcon,
|
|
53
67
|
height: sizeIcon,
|
|
54
|
-
color:
|
|
68
|
+
color: colorCode,
|
|
55
69
|
viewBox: true
|
|
56
70
|
}) : separator;
|
|
57
71
|
const renderItemsBeforeAndAfter = allItems => {
|
|
@@ -81,7 +95,7 @@ const Breadcrumb = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
81
95
|
name: 'MoreHoriz',
|
|
82
96
|
width: sizeIcon,
|
|
83
97
|
height: sizeIcon,
|
|
84
|
-
color:
|
|
98
|
+
color: colorCode
|
|
85
99
|
}), renderSeparator)
|
|
86
100
|
}),
|
|
87
101
|
// <ButtonIcon key="ellipsis" name={'MoreHoriz'} width={24} height={16} onClick={handleClickExpand} />,
|
|
@@ -94,7 +108,7 @@ const Breadcrumb = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
94
108
|
}, item !== null && item !== void 0 && item.icon ? jsx(Icon, {
|
|
95
109
|
className: 'DGN-UI-Breadcrumb-li-icon',
|
|
96
110
|
name: item === null || item === void 0 ? void 0 : item.icon,
|
|
97
|
-
color:
|
|
111
|
+
color: colorCode,
|
|
98
112
|
width: sizeIcon,
|
|
99
113
|
height: sizeIcon
|
|
100
114
|
}) : null, jsx(Typography, {
|
|
@@ -123,36 +137,38 @@ const Breadcrumb = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
123
137
|
style: style,
|
|
124
138
|
className: classNames('DGN-UI-Breadcrumb', className)
|
|
125
139
|
}, jsx("ol", {
|
|
126
|
-
css:
|
|
140
|
+
css: _BreadcrumbOlCSS,
|
|
127
141
|
className: 'DGN-UI-Breadcrumb-ol'
|
|
128
142
|
},
|
|
129
143
|
// expanded ||
|
|
130
144
|
maxItems && allItems.length <= maxItems ? allItems : renderItemsBeforeAndAfter(allItems)));
|
|
131
|
-
}, [children, className,
|
|
132
|
-
// expanded,
|
|
133
|
-
]);
|
|
145
|
+
}, [children, className, colorProp, data, id, itemsAfterCollapse, itemsBeforeCollapse, maxItems, separator, size, style, theme]);
|
|
134
146
|
}));
|
|
135
|
-
|
|
136
|
-
|
|
147
|
+
const BreadcrumbOlCSS = (color, {
|
|
148
|
+
spacing
|
|
149
|
+
}) => css`
|
|
137
150
|
${displayFlex};
|
|
138
151
|
${flexWrap};
|
|
139
152
|
${itemsCenter};
|
|
140
|
-
${
|
|
141
|
-
${
|
|
153
|
+
padding: ${spacing([0])};
|
|
154
|
+
margin: ${spacing([0])};
|
|
142
155
|
${listNone};
|
|
143
156
|
${textColor(color)};
|
|
144
157
|
`;
|
|
145
|
-
const BreadcrumbLiCSS = (color, sizeTypographyP, sizeTypographyH
|
|
158
|
+
const BreadcrumbLiCSS = (color, sizeTypographyP, sizeTypographyH, {
|
|
159
|
+
spacing,
|
|
160
|
+
typography
|
|
161
|
+
}) => css`
|
|
146
162
|
${typography[sizeTypographyP]};
|
|
147
163
|
${displayFlex};
|
|
148
164
|
${itemsCenter};
|
|
149
|
-
${
|
|
150
|
-
${
|
|
165
|
+
gap: ${spacing([1])};
|
|
166
|
+
padding-left: ${spacing([1])};
|
|
151
167
|
${borderRadius(4)};
|
|
152
168
|
${cursorPointer};
|
|
153
169
|
${userSelectNone};
|
|
154
170
|
&:last-child {
|
|
155
|
-
${
|
|
171
|
+
padding-right: ${spacing([1])};
|
|
156
172
|
${typography[sizeTypographyH]};
|
|
157
173
|
}
|
|
158
174
|
${Object.keys(alphaPseudo).map(key => css`
|
|
@@ -161,16 +177,18 @@ const BreadcrumbLiCSS = (color, sizeTypographyP, sizeTypographyH) => css`
|
|
|
161
177
|
}
|
|
162
178
|
`)}
|
|
163
179
|
`;
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
}
|
|
180
|
+
|
|
181
|
+
// Breadcrumb.defaultProps = {
|
|
182
|
+
// className: '',
|
|
183
|
+
// color: 'default',
|
|
184
|
+
// itemsAfterCollapse: 1,
|
|
185
|
+
// itemsBeforeCollapse: 1,
|
|
186
|
+
// maxItems: 8,
|
|
187
|
+
// separator: 'ArrowRight',
|
|
188
|
+
// size: 'medium',
|
|
189
|
+
// style: {},
|
|
190
|
+
// };
|
|
191
|
+
|
|
174
192
|
Breadcrumb.propTypes = {
|
|
175
193
|
/** The content of the component. */
|
|
176
194
|
children: PropTypes.oneOfType([PropTypes.string, PropTypes.node]),
|
|
@@ -6,10 +6,11 @@ import OptionWrapper from "../others/option-wrapper";
|
|
|
6
6
|
import PropTypes from 'prop-types';
|
|
7
7
|
import { forwardRef, memo, useImperativeHandle, useMemo, useRef } from 'react';
|
|
8
8
|
import { hexToRGBA } from "../../styles/color-helper";
|
|
9
|
-
import
|
|
10
|
-
import { alphaPseudo, bgColor, border, borderColor, borderNone, borderRadius, boxBorder, cursorNotAllowed, cursorPointer, displayFlex, displayInlineFlex, flexRow, itemsCenter, justifyCenter, outlineNone, parseMinWidthHeight, parseWidthHeight, pd, pointerEventsNone, positionRelative, textColor, userSelectNone } from "../../styles/general";
|
|
9
|
+
import { alphaPseudo, bgColor, border, borderColor, borderNone, borderRadius, boxBorder, cursorNotAllowed, cursorPointer, displayFlex, displayInlineFlex, flexRow, itemsCenter, justifyCenter, outlineNone, parseMinWidthHeight, parseWidthHeight, pointerEventsNone, positionRelative, textColor, userSelectNone } from "../../styles/general";
|
|
11
10
|
import { getColor } from "../../styles/utils";
|
|
12
|
-
import {
|
|
11
|
+
import { useTheme } from "../../theme";
|
|
12
|
+
import useThemeProps from "../../theme/utils/useThemeProps";
|
|
13
|
+
import { capitalize, classNames, getProp } from "../../utils";
|
|
13
14
|
import { getRippleColor } from '.';
|
|
14
15
|
import Ripple from "./ripple-effect";
|
|
15
16
|
const sizeMap = new Map([['tiny', {
|
|
@@ -31,7 +32,7 @@ const sizeMap = new Map([['tiny', {
|
|
|
31
32
|
buttonSize: '96px',
|
|
32
33
|
iconSize: '56px'
|
|
33
34
|
}]]);
|
|
34
|
-
const iconColorMap = new Map([['Close', 'semantic
|
|
35
|
+
const iconColorMap = new Map([['Close', 'semantic/danger'], ['Cancel', 'semantic/danger'], ['Approval', 'semantic/success'], ['Delete', 'semantic/warning'], ['Trash', 'semantic/warning'], ['Edit', 'semantic/info'], ['EditV2', 'semantic/info'], ['View', 'semantic/info']]);
|
|
35
36
|
const alphaLoading = 0.2;
|
|
36
37
|
// customIconSize calculated based on design size
|
|
37
38
|
// Button size <= 24 => icon size = Button size - 8
|
|
@@ -47,33 +48,47 @@ const IconLoadingView = iconSize => {
|
|
|
47
48
|
width: parseInt(iconSize)
|
|
48
49
|
});
|
|
49
50
|
};
|
|
50
|
-
const ButtonIcon = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
51
|
-
action = {},
|
|
52
|
-
children,
|
|
53
|
-
circular,
|
|
54
|
-
className,
|
|
55
|
-
color: colorProp,
|
|
56
|
-
colorHover,
|
|
57
|
-
disabled,
|
|
58
|
-
height,
|
|
59
|
-
id,
|
|
60
|
-
loading,
|
|
61
|
-
name,
|
|
62
|
-
onClick,
|
|
63
|
-
size,
|
|
64
|
-
style,
|
|
65
|
-
viewBox,
|
|
66
|
-
viewType,
|
|
67
|
-
width
|
|
68
|
-
}, reference) => {
|
|
51
|
+
const ButtonIcon = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, reference) => {
|
|
69
52
|
var _sizeMap$get, _sizeMap$get2;
|
|
53
|
+
if (!reference) reference = useRef(null);
|
|
54
|
+
const theme = useTheme();
|
|
55
|
+
const {
|
|
56
|
+
colors
|
|
57
|
+
} = theme;
|
|
58
|
+
|
|
59
|
+
// props priority: `inProps` > `themeDefaultProps`
|
|
60
|
+
const props = useThemeProps({
|
|
61
|
+
props: inProps,
|
|
62
|
+
name: 'ButtonIcon'
|
|
63
|
+
});
|
|
64
|
+
const {
|
|
65
|
+
action = {},
|
|
66
|
+
children,
|
|
67
|
+
circular,
|
|
68
|
+
className,
|
|
69
|
+
color: colorProp,
|
|
70
|
+
colorHover,
|
|
71
|
+
disabled,
|
|
72
|
+
height,
|
|
73
|
+
id,
|
|
74
|
+
loading,
|
|
75
|
+
name,
|
|
76
|
+
onClick,
|
|
77
|
+
size,
|
|
78
|
+
style,
|
|
79
|
+
viewBox,
|
|
80
|
+
viewType,
|
|
81
|
+
width
|
|
82
|
+
} = props;
|
|
70
83
|
const ref = useRef(null);
|
|
71
84
|
const rippleRef = useRef(null);
|
|
72
85
|
const isColorDefault = colorProp === 'default';
|
|
73
86
|
const isViewTypeGhost = viewType === 'ghost';
|
|
74
87
|
const buttonSize = ((_sizeMap$get = sizeMap.get(size)) === null || _sizeMap$get === void 0 ? void 0 : _sizeMap$get.buttonSize) || '40px';
|
|
75
88
|
const iconSize = width ? isNaN(width) ? '60%' : customIconSize(parseInt(width)) + 'px' : ((_sizeMap$get2 = sizeMap.get(size)) === null || _sizeMap$get2 === void 0 ? void 0 : _sizeMap$get2.iconSize) || '24px';
|
|
76
|
-
const
|
|
89
|
+
const colorCss = getProp(colors, colorProp, colorProp);
|
|
90
|
+
const colorHoverCss = getProp(colors, colorHover, colorHover);
|
|
91
|
+
const _ButtonRootCSS = ButtonRootCSS(circular, colorHoverCss, colorCss, name, isColorDefault, viewType, loading, theme);
|
|
77
92
|
const _ButtonSizeCSS = ButtonSizeCSS(width, height, buttonSize, iconSize);
|
|
78
93
|
const _ButtonIconCSS = ButtonIconCSS(iconSize);
|
|
79
94
|
const _onClick = event => {
|
|
@@ -112,10 +127,10 @@ const ButtonIcon = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
112
127
|
viewBox: viewBox
|
|
113
128
|
})), !disabled && !loading && !isViewTypeGhost && jsx(Ripple, {
|
|
114
129
|
ref: rippleRef,
|
|
115
|
-
color: getRippleColor(colorProp, viewType,
|
|
130
|
+
color: getRippleColor(colorProp, viewType, colors),
|
|
116
131
|
circular: circular
|
|
117
132
|
}));
|
|
118
|
-
}, [children, circular, className, colorHover, colorProp, disabled, height, id, loading, name, onClick, size, style, viewBox, viewType, width]);
|
|
133
|
+
}, [children, circular, className, colorHover, colorProp, disabled, height, id, loading, name, onClick, size, style, viewBox, viewType, width, theme]);
|
|
119
134
|
}));
|
|
120
135
|
const ButtonIconCSS = iconSize => css`
|
|
121
136
|
${displayFlex};
|
|
@@ -135,7 +150,10 @@ const ButtonSizeCSS = (width, height, buttonSize, iconSize) => css`
|
|
|
135
150
|
${parseMinWidthHeight(width || iconSize, height || iconSize)};
|
|
136
151
|
}
|
|
137
152
|
`;
|
|
138
|
-
const ButtonRootCSS = (circular, colorHover, color, name, isColorDefault, viewType, loading
|
|
153
|
+
const ButtonRootCSS = (circular, colorHover, color, name, isColorDefault, viewType, loading, {
|
|
154
|
+
colors,
|
|
155
|
+
spacing
|
|
156
|
+
}) => css`
|
|
139
157
|
${displayInlineFlex};
|
|
140
158
|
${positionRelative};
|
|
141
159
|
${justifyCenter};
|
|
@@ -145,7 +163,7 @@ const ButtonRootCSS = (circular, colorHover, color, name, isColorDefault, viewTy
|
|
|
145
163
|
${cursorPointer};
|
|
146
164
|
${userSelectNone};
|
|
147
165
|
${borderRadius(circular ? '50%' : 4)};
|
|
148
|
-
${
|
|
166
|
+
padding: ${spacing([0])};
|
|
149
167
|
transition: background-color 0.5s, filter 0.5s;
|
|
150
168
|
${loading && pointerEventsNone};
|
|
151
169
|
${viewType === 'outlined' && css`
|
|
@@ -161,8 +179,8 @@ const ButtonRootCSS = (circular, colorHover, color, name, isColorDefault, viewTy
|
|
|
161
179
|
}
|
|
162
180
|
`)}
|
|
163
181
|
${isColorDefault && css`
|
|
164
|
-
${border(1, 'system/rest')};
|
|
165
|
-
${textColor('system/rest')};
|
|
182
|
+
${border(1, getProp(colors, 'system/rest'))};
|
|
183
|
+
${textColor(getProp(colors, 'system/rest'))};
|
|
166
184
|
${loading && css`
|
|
167
185
|
${textColor(colorHover)};
|
|
168
186
|
${borderColor(colorHover)};
|
|
@@ -181,13 +199,13 @@ const ButtonRootCSS = (circular, colorHover, color, name, isColorDefault, viewTy
|
|
|
181
199
|
`)}// &:hover | &:focus | &:active
|
|
182
200
|
`}
|
|
183
201
|
&.disabled {
|
|
184
|
-
${borderColor('system/disabled')};
|
|
202
|
+
${borderColor(getProp(colors, 'system/disabled'))};
|
|
185
203
|
${bgColor('transparent')};
|
|
186
204
|
}
|
|
187
205
|
`}
|
|
188
206
|
${viewType === 'filled' && css`
|
|
189
207
|
${borderNone};
|
|
190
|
-
${textColor(color === getColor('system
|
|
208
|
+
${textColor(color === getColor(getProp(colors, 'system/standard')) ? getProp(colors, 'system/rest') : getProp(colors, 'system/standard'))};
|
|
191
209
|
${bgColor(color)};
|
|
192
210
|
font-weight: bold;
|
|
193
211
|
${loading && css`
|
|
@@ -201,8 +219,8 @@ const ButtonRootCSS = (circular, colorHover, color, name, isColorDefault, viewTy
|
|
|
201
219
|
filter: brightness(0.7);
|
|
202
220
|
}
|
|
203
221
|
${isColorDefault && css`
|
|
204
|
-
${bgColor('system/rest')};
|
|
205
|
-
${loading && bgColor('system/active')};
|
|
222
|
+
${bgColor(getProp(colors, 'system/rest'))};
|
|
223
|
+
${loading && bgColor(getProp(colors, 'system/active'))};
|
|
206
224
|
&:hover,
|
|
207
225
|
&:focus,
|
|
208
226
|
&:active {
|
|
@@ -210,7 +228,7 @@ const ButtonRootCSS = (circular, colorHover, color, name, isColorDefault, viewTy
|
|
|
210
228
|
}
|
|
211
229
|
`}
|
|
212
230
|
&.disabled {
|
|
213
|
-
${bgColor('fill/disabled')};
|
|
231
|
+
${bgColor(getProp(colors, 'fill/disabled'))};
|
|
214
232
|
}
|
|
215
233
|
`}
|
|
216
234
|
${viewType === 'text' && css`
|
|
@@ -224,9 +242,9 @@ const ButtonRootCSS = (circular, colorHover, color, name, isColorDefault, viewTy
|
|
|
224
242
|
}
|
|
225
243
|
`)}
|
|
226
244
|
${isColorDefault && css`
|
|
227
|
-
${textColor('system/rest')};
|
|
245
|
+
${textColor(getProp(colors, 'system/rest'))};
|
|
228
246
|
${loading && css`
|
|
229
|
-
${textColor('system/active')};
|
|
247
|
+
${textColor(getProp(colors, 'system/active'))};
|
|
230
248
|
${bgColor(hexToRGBA(colorHover, alphaLoading))};
|
|
231
249
|
`}
|
|
232
250
|
${Object.keys(alphaPseudo).map(key => css`
|
|
@@ -255,7 +273,7 @@ const ButtonRootCSS = (circular, colorHover, color, name, isColorDefault, viewTy
|
|
|
255
273
|
filter: brightness(0.7);
|
|
256
274
|
}
|
|
257
275
|
${isColorDefault && css`
|
|
258
|
-
${textColor('system/rest')};
|
|
276
|
+
${textColor(getProp(colors, 'system/rest'))};
|
|
259
277
|
&:hover,
|
|
260
278
|
&:focus,
|
|
261
279
|
&:active {
|
|
@@ -265,20 +283,22 @@ const ButtonRootCSS = (circular, colorHover, color, name, isColorDefault, viewTy
|
|
|
265
283
|
`}
|
|
266
284
|
&.disabled {
|
|
267
285
|
${cursorNotAllowed};
|
|
268
|
-
${textColor('system/disabled')};
|
|
286
|
+
${textColor(getProp(colors, 'system/disabled'))};
|
|
269
287
|
filter: brightness(1);
|
|
270
288
|
}
|
|
271
289
|
`;
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
290
|
+
|
|
291
|
+
// ButtonIcon.defaultProps = {
|
|
292
|
+
// circular: false,
|
|
293
|
+
// className: '',
|
|
294
|
+
// color: 'default',
|
|
295
|
+
// colorHover: 'system/active',
|
|
296
|
+
// disabled: false,
|
|
297
|
+
// size: 'medium',
|
|
298
|
+
// viewBox: true,
|
|
299
|
+
// viewType: 'outlined',
|
|
300
|
+
// };
|
|
301
|
+
|
|
282
302
|
ButtonIcon.propTypes = {
|
|
283
303
|
/** The content of the component. */
|
|
284
304
|
children: PropTypes.node,
|
|
@@ -300,14 +320,14 @@ ButtonIcon.propTypes = {
|
|
|
300
320
|
onClick: PropTypes.func,
|
|
301
321
|
/** Name of [icon](https://core.diginet.com.vn/ui/?path=/story/icon-basic). */
|
|
302
322
|
name: PropTypes.string,
|
|
303
|
-
/**
|
|
304
|
-
* The size of the component.
|
|
305
|
-
*
|
|
306
|
-
* * tiny (button 24px, icon 16px)
|
|
307
|
-
* * small (button 32px, icon 20px)
|
|
308
|
-
* * medium (button 40px, icon 24px)
|
|
309
|
-
* * large (button 48px, icon 32px)
|
|
310
|
-
* * giant (button 56px, icon 40px)
|
|
323
|
+
/**
|
|
324
|
+
* The size of the component.
|
|
325
|
+
*
|
|
326
|
+
* * tiny (button 24px, icon 16px)
|
|
327
|
+
* * small (button 32px, icon 20px)
|
|
328
|
+
* * medium (button 40px, icon 24px)
|
|
329
|
+
* * large (button 48px, icon 32px)
|
|
330
|
+
* * giant (button 56px, icon 40px)
|
|
311
331
|
* */
|
|
312
332
|
size: PropTypes.oneOf(['tiny', 'small', 'medium', 'large', 'giant', 'extraGiant']),
|
|
313
333
|
/** Style inline of component. */
|
|
@@ -318,19 +338,19 @@ ButtonIcon.propTypes = {
|
|
|
318
338
|
viewType: PropTypes.oneOf(['text', 'outlined', 'filled', 'ghost']),
|
|
319
339
|
/** Width of the component. */
|
|
320
340
|
width: PropTypes.oneOfType([PropTypes.number, PropTypes.string])
|
|
321
|
-
/**
|
|
322
|
-
* ref methods (ref.current.instance.*method*)
|
|
323
|
-
*
|
|
324
|
-
* * option(): Gets all UI component properties
|
|
325
|
-
* * Returns value - object
|
|
326
|
-
* * option(optionName): Gets the value of a single property
|
|
327
|
-
* * @param {optionName} - string
|
|
328
|
-
* * Returns value - any
|
|
329
|
-
* * option(optionName, optionValue): Updates the value of a single property
|
|
330
|
-
* * @param {optionName} - string
|
|
331
|
-
* * @param {optionValue} - any
|
|
332
|
-
* * option(options): Updates the values of several properties
|
|
333
|
-
* * @param {options} - object
|
|
341
|
+
/**
|
|
342
|
+
* ref methods (ref.current.instance.*method*)
|
|
343
|
+
*
|
|
344
|
+
* * option(): Gets all UI component properties
|
|
345
|
+
* * Returns value - object
|
|
346
|
+
* * option(optionName): Gets the value of a single property
|
|
347
|
+
* * @param {optionName} - string
|
|
348
|
+
* * Returns value - any
|
|
349
|
+
* * option(optionName, optionValue): Updates the value of a single property
|
|
350
|
+
* * @param {optionName} - string
|
|
351
|
+
* * @param {optionValue} - any
|
|
352
|
+
* * option(options): Updates the values of several properties
|
|
353
|
+
* * @param {options} - object
|
|
334
354
|
*/
|
|
335
355
|
};
|
|
336
356
|
|