diginet-core-ui 1.3.92-beta.1 → 1.3.93-beta.1
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/breadcrumb/index.js +120 -53
- package/components/button/icon.js +21 -21
- package/components/button/index.js +42 -59
- package/components/button/more.js +20 -2
- package/components/form-control/attachment/index.js +1 -1
- package/components/form-control/number-input/index2.js +18 -18
- package/components/form-control/radio/index.js +5 -5
- package/components/form-control/toggle/index.js +4 -4
- package/components/rating/index.js +8 -8
- package/components/tab/tab-container.js +2 -2
- package/components/tab/tab-header.js +2 -2
- package/components/tab/tab-panel.js +2 -2
- package/components/tab/tab.js +2 -2
- package/components/transfer/index.js +3 -3
- package/components/typography/index.js +2 -2
- package/icons/effect.js +3 -2
- package/package.json +1 -1
- package/readme.md +6 -0
- package/styles/utils.js +15 -15
|
@@ -1,43 +1,42 @@
|
|
|
1
1
|
/** @jsxRuntime classic */
|
|
2
2
|
/** @jsx jsx */
|
|
3
3
|
import { css, jsx } from '@emotion/core';
|
|
4
|
-
import {
|
|
5
|
-
import { Icon } from "../../icons/effect";
|
|
4
|
+
import { ButtonMore, Typography } from "./..";
|
|
6
5
|
import OptionWrapper from "../others/option-wrapper";
|
|
6
|
+
import { Icon } from "../../icons/effect";
|
|
7
7
|
import PropTypes from 'prop-types';
|
|
8
8
|
import React, { forwardRef, memo, useImperativeHandle, useMemo, useRef } from 'react';
|
|
9
|
-
import {
|
|
9
|
+
import { hexToRGBA } from "../../styles/color-helper";
|
|
10
|
+
import { bgColor, borderRadius, cursorPointer, displayFlex, flexWrap, gap, itemsCenter, mg, pd, pdl, pdr, textColor, userSelectNone } from "../../styles/general";
|
|
11
|
+
import { useTypography as typography } from "../../theme";
|
|
10
12
|
import { classNames } from "../../utils";
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
acc = acc.concat(current, jsx("li", {
|
|
15
|
-
css: BreadcrumbSeparatorCSS,
|
|
16
|
-
"aria-hidden": true,
|
|
17
|
-
key: `separator-${index}`,
|
|
18
|
-
className: 'DGN-UI-Breadcrumb-separator'
|
|
19
|
-
}, separator));
|
|
20
|
-
} else {
|
|
21
|
-
acc.push(current);
|
|
22
|
-
}
|
|
23
|
-
return acc;
|
|
24
|
-
}, []);
|
|
25
|
-
};
|
|
13
|
+
const sizeIconMap = new Map([['tiny', 16], ['small', 18], ['medium', 20]]);
|
|
14
|
+
const sizeTypographyPMap = new Map([['tiny', 'p3'], ['small', 'p2'], ['medium', 'p1']]);
|
|
15
|
+
const sizeTypographyHMap = new Map([['tiny', 'h5'], ['small', 'h4'], ['medium', 'h3']]);
|
|
26
16
|
const Breadcrumb = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
27
17
|
action = {},
|
|
28
18
|
children,
|
|
29
19
|
className,
|
|
20
|
+
color,
|
|
30
21
|
data,
|
|
31
22
|
id,
|
|
32
23
|
itemsAfterCollapse,
|
|
33
24
|
itemsBeforeCollapse,
|
|
34
25
|
maxItems,
|
|
35
26
|
separator,
|
|
27
|
+
size,
|
|
36
28
|
style
|
|
37
29
|
}, reference) => {
|
|
38
30
|
if (!reference) reference = useRef(null);
|
|
31
|
+
if (color === 'default') color = 'system.rest';
|
|
39
32
|
const ref = useRef(null);
|
|
40
|
-
const
|
|
33
|
+
const sizeIcon = sizeIconMap.get(size);
|
|
34
|
+
const sizeTypographyP = sizeTypographyPMap.get(size);
|
|
35
|
+
const sizeTypographyH = sizeTypographyHMap.get(size);
|
|
36
|
+
|
|
37
|
+
// const [expanded, setExpanded] = React.useState(false);
|
|
38
|
+
|
|
39
|
+
const _BreadcrumbLiCSS = BreadcrumbLiCSS(color, sizeTypographyP, sizeTypographyH);
|
|
41
40
|
useImperativeHandle(reference, () => {
|
|
42
41
|
const currentRef = ref.current || {};
|
|
43
42
|
currentRef.element = ref.current;
|
|
@@ -48,39 +47,78 @@ const Breadcrumb = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
48
47
|
currentRef.instance = _instance;
|
|
49
48
|
return currentRef;
|
|
50
49
|
});
|
|
50
|
+
const renderSeparator = typeof separator === 'string' ? jsx(Icon, {
|
|
51
|
+
name: separator,
|
|
52
|
+
width: sizeIcon,
|
|
53
|
+
height: sizeIcon,
|
|
54
|
+
color: color,
|
|
55
|
+
viewBox: true
|
|
56
|
+
}) : separator;
|
|
51
57
|
const renderItemsBeforeAndAfter = allItems => {
|
|
52
|
-
const handleClickExpand = () => {
|
|
53
|
-
|
|
54
|
-
};
|
|
58
|
+
// const handleClickExpand = () => {
|
|
59
|
+
// setExpanded(true);
|
|
60
|
+
// };
|
|
61
|
+
|
|
55
62
|
if (itemsBeforeCollapse + itemsAfterCollapse >= allItems.length) {
|
|
56
63
|
return allItems;
|
|
57
64
|
}
|
|
58
|
-
|
|
65
|
+
let options = [];
|
|
66
|
+
data.slice(itemsBeforeCollapse, allItems.length - itemsAfterCollapse).map(item => {
|
|
67
|
+
var _item$onClick;
|
|
68
|
+
return options = [...options, {
|
|
69
|
+
label: (item === null || item === void 0 ? void 0 : item.label) || (item === null || item === void 0 ? void 0 : item.name),
|
|
70
|
+
icon: item === null || item === void 0 ? void 0 : item.icon,
|
|
71
|
+
action: item === null || item === void 0 ? void 0 : (_item$onClick = item.onClick) === null || _item$onClick === void 0 ? void 0 : _item$onClick.call(item)
|
|
72
|
+
}];
|
|
73
|
+
});
|
|
74
|
+
return [...allItems.slice(0, itemsBeforeCollapse), jsx(ButtonMore, {
|
|
59
75
|
key: "ellipsis",
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
76
|
+
options: options,
|
|
77
|
+
anchor: jsx("li", {
|
|
78
|
+
key: "ellipsis",
|
|
79
|
+
css: _BreadcrumbLiCSS
|
|
80
|
+
}, jsx(Icon, {
|
|
81
|
+
name: 'MoreHoriz',
|
|
82
|
+
width: sizeIcon,
|
|
83
|
+
height: sizeIcon,
|
|
84
|
+
color: color
|
|
85
|
+
}), renderSeparator)
|
|
86
|
+
}),
|
|
87
|
+
// <ButtonIcon key="ellipsis" name={'MoreHoriz'} width={24} height={16} onClick={handleClickExpand} />,
|
|
88
|
+
...allItems.slice(allItems.length - itemsAfterCollapse, allItems.length)];
|
|
65
89
|
};
|
|
66
90
|
const allItems = data !== null && data !== void 0 && data.length ? data.map((item, idx) => {
|
|
67
|
-
var
|
|
91
|
+
var _item$onClick2;
|
|
68
92
|
return jsx("li", {
|
|
93
|
+
css: _BreadcrumbLiCSS,
|
|
69
94
|
className: 'DGN-UI-Breadcrumb-li',
|
|
70
95
|
key: `child-${idx}`
|
|
71
|
-
}, jsx(
|
|
72
|
-
|
|
96
|
+
}, item !== null && item !== void 0 && item.icon ? jsx(Icon, {
|
|
97
|
+
className: 'DGN-UI-Breadcrumb-li-icon',
|
|
98
|
+
name: item === null || item === void 0 ? void 0 : item.icon,
|
|
99
|
+
color: color,
|
|
100
|
+
width: sizeIcon,
|
|
101
|
+
height: sizeIcon
|
|
102
|
+
}) : null, jsx(Typography, {
|
|
103
|
+
className: 'DGN-UI-Breadcrumb-li-label',
|
|
104
|
+
type: (data === null || data === void 0 ? void 0 : data.length) === idx + 1 ? sizeTypographyH : sizeTypographyP,
|
|
73
105
|
mapping: 'a',
|
|
74
|
-
color: '
|
|
75
|
-
href:
|
|
76
|
-
onClick:
|
|
77
|
-
}, item === null || item === void 0 ? void 0 : item.name));
|
|
106
|
+
color: 'currentColor',
|
|
107
|
+
href: item === null || item === void 0 ? void 0 : item.href,
|
|
108
|
+
onClick: item === null || item === void 0 ? void 0 : (_item$onClick2 = item.onClick) === null || _item$onClick2 === void 0 ? void 0 : _item$onClick2.call(item)
|
|
109
|
+
}, (item === null || item === void 0 ? void 0 : item.label) || (item === null || item === void 0 ? void 0 : item.name)), (data === null || data === void 0 ? void 0 : data.length) !== idx + 1 ? renderSeparator : null);
|
|
78
110
|
}) : React.Children.toArray(children).filter(child => {
|
|
79
111
|
return /*#__PURE__*/React.isValidElement(child);
|
|
80
|
-
}).map((child, idx) =>
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
112
|
+
}).map((child, idx) => {
|
|
113
|
+
var _React$Children$toArr;
|
|
114
|
+
return jsx("li", {
|
|
115
|
+
css: _BreadcrumbLiCSS,
|
|
116
|
+
className: 'DGN-UI-Breadcrumb-li',
|
|
117
|
+
key: `child-${idx}`
|
|
118
|
+
}, child, ((_React$Children$toArr = React.Children.toArray(children).filter(child => {
|
|
119
|
+
return /*#__PURE__*/React.isValidElement(child);
|
|
120
|
+
})) === null || _React$Children$toArr === void 0 ? void 0 : _React$Children$toArr.length) !== idx + 1 ? renderSeparator : null);
|
|
121
|
+
});
|
|
84
122
|
return useMemo(() => {
|
|
85
123
|
return jsx("nav", {
|
|
86
124
|
ref: ref,
|
|
@@ -88,34 +126,59 @@ const Breadcrumb = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
88
126
|
style: style,
|
|
89
127
|
className: classNames('DGN-UI-Breadcrumb', className)
|
|
90
128
|
}, jsx("ol", {
|
|
91
|
-
css: BreadcrumbOlCSS,
|
|
129
|
+
css: BreadcrumbOlCSS(color),
|
|
92
130
|
className: 'DGN-UI-Breadcrumb-ol'
|
|
93
|
-
},
|
|
94
|
-
|
|
131
|
+
},
|
|
132
|
+
// expanded ||
|
|
133
|
+
maxItems && allItems.length <= maxItems ? allItems : renderItemsBeforeAndAfter(allItems)));
|
|
134
|
+
}, [children, className, color, data, id, itemsAfterCollapse, itemsBeforeCollapse, maxItems, separator, size, style
|
|
135
|
+
// expanded,
|
|
136
|
+
]);
|
|
95
137
|
}));
|
|
96
|
-
|
|
138
|
+
|
|
139
|
+
const alphaArr = {
|
|
140
|
+
hover: 0.1,
|
|
141
|
+
focus: 0.2,
|
|
142
|
+
active: 0.3
|
|
143
|
+
};
|
|
144
|
+
const BreadcrumbOlCSS = color => css`
|
|
97
145
|
${displayFlex};
|
|
98
146
|
${flexWrap};
|
|
99
147
|
${itemsCenter};
|
|
100
148
|
${pd(0)};
|
|
101
149
|
${mg(0)};
|
|
102
150
|
list-style: none;
|
|
151
|
+
${textColor(color)};
|
|
103
152
|
`;
|
|
104
|
-
const
|
|
153
|
+
const BreadcrumbLiCSS = (color, sizeTypographyP, sizeTypographyH) => css`
|
|
154
|
+
${typography[sizeTypographyP]};
|
|
155
|
+
&:last-child {
|
|
156
|
+
${typography[sizeTypographyH]};
|
|
157
|
+
}
|
|
105
158
|
${displayFlex};
|
|
159
|
+
${itemsCenter};
|
|
160
|
+
${gap('4px')};
|
|
161
|
+
${pdl([1])};
|
|
162
|
+
${borderRadius(4)};
|
|
163
|
+
${cursorPointer};
|
|
106
164
|
${userSelectNone};
|
|
107
|
-
|
|
165
|
+
&:last-child {
|
|
166
|
+
${pdr([1])};
|
|
167
|
+
}
|
|
168
|
+
${Object.keys(alphaArr).map(key => css`
|
|
169
|
+
&: ${key} {
|
|
170
|
+
${bgColor(hexToRGBA(color, alphaArr[key]))};
|
|
171
|
+
}
|
|
172
|
+
`)}
|
|
108
173
|
`;
|
|
109
174
|
Breadcrumb.defaultProps = {
|
|
110
175
|
className: '',
|
|
111
|
-
|
|
176
|
+
color: 'default',
|
|
112
177
|
itemsAfterCollapse: 1,
|
|
178
|
+
itemsBeforeCollapse: 1,
|
|
113
179
|
maxItems: 8,
|
|
114
|
-
separator:
|
|
115
|
-
|
|
116
|
-
width: 16,
|
|
117
|
-
height: 16
|
|
118
|
-
}),
|
|
180
|
+
separator: 'ArrowRight',
|
|
181
|
+
size: 'medium',
|
|
119
182
|
style: {}
|
|
120
183
|
};
|
|
121
184
|
Breadcrumb.propTypes = {
|
|
@@ -123,9 +186,11 @@ Breadcrumb.propTypes = {
|
|
|
123
186
|
children: PropTypes.oneOfType([PropTypes.string, PropTypes.node]),
|
|
124
187
|
/** Class for component. */
|
|
125
188
|
className: PropTypes.string,
|
|
189
|
+
/** The color of the component. */
|
|
190
|
+
color: PropTypes.string,
|
|
126
191
|
/** Class for component. */
|
|
127
192
|
data: PropTypes.PropTypes.arrayOf(PropTypes.shape({
|
|
128
|
-
|
|
193
|
+
label: PropTypes.string,
|
|
129
194
|
href: PropTypes.string,
|
|
130
195
|
onClick: PropTypes.func
|
|
131
196
|
})),
|
|
@@ -136,7 +201,9 @@ Breadcrumb.propTypes = {
|
|
|
136
201
|
/** Class for component. */
|
|
137
202
|
maxItems: PropTypes.number,
|
|
138
203
|
/** Custom separator node. */
|
|
139
|
-
separator: PropTypes.node,
|
|
204
|
+
separator: PropTypes.oneOfType([PropTypes.string, PropTypes.node]),
|
|
205
|
+
/** The size of the component. */
|
|
206
|
+
size: PropTypes.oneOf(['tiny', 'small', 'medium']),
|
|
140
207
|
/** Style inline of component. */
|
|
141
208
|
style: PropTypes.object
|
|
142
209
|
};
|
|
@@ -321,14 +321,14 @@ ButtonIcon.propTypes = {
|
|
|
321
321
|
onClick: PropTypes.func,
|
|
322
322
|
/** Name of [icon](https://core.diginet.com.vn/ui/?path=/story/icon-basic). */
|
|
323
323
|
name: PropTypes.string,
|
|
324
|
-
/**
|
|
325
|
-
* The size of the component.
|
|
326
|
-
*
|
|
327
|
-
* * tiny (button 24px, icon 16px)
|
|
328
|
-
* * small (button 32px, icon 20px)
|
|
329
|
-
* * medium (button 40px, icon 24px)
|
|
330
|
-
* * large (button 48px, icon 32px)
|
|
331
|
-
* * giant (button 56px, icon 40px)
|
|
324
|
+
/**
|
|
325
|
+
* The size of the component.
|
|
326
|
+
*
|
|
327
|
+
* * tiny (button 24px, icon 16px)
|
|
328
|
+
* * small (button 32px, icon 20px)
|
|
329
|
+
* * medium (button 40px, icon 24px)
|
|
330
|
+
* * large (button 48px, icon 32px)
|
|
331
|
+
* * giant (button 56px, icon 40px)
|
|
332
332
|
* */
|
|
333
333
|
size: PropTypes.oneOf(['tiny', 'small', 'medium', 'large', 'giant', 'extraGiant']),
|
|
334
334
|
/** Style inline of component. */
|
|
@@ -339,19 +339,19 @@ ButtonIcon.propTypes = {
|
|
|
339
339
|
viewType: PropTypes.oneOf(['text', 'outlined', 'filled', 'ghost']),
|
|
340
340
|
/** Width of the component. */
|
|
341
341
|
width: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
342
|
-
/**
|
|
343
|
-
* ref methods (ref.current.instance.*method*)
|
|
344
|
-
*
|
|
345
|
-
* * option(): Gets all UI component properties
|
|
346
|
-
* * Returns value - object
|
|
347
|
-
* * option(optionName): Gets the value of a single property
|
|
348
|
-
* * @param {optionName} - string
|
|
349
|
-
* * Returns value - any
|
|
350
|
-
* * option(optionName, optionValue): Updates the value of a single property
|
|
351
|
-
* * @param {optionName} - string
|
|
352
|
-
* * @param {optionValue} - any
|
|
353
|
-
* * option(options): Updates the values of several properties
|
|
354
|
-
* * @param {options} - object
|
|
342
|
+
/**
|
|
343
|
+
* ref methods (ref.current.instance.*method*)
|
|
344
|
+
*
|
|
345
|
+
* * option(): Gets all UI component properties
|
|
346
|
+
* * Returns value - object
|
|
347
|
+
* * option(optionName): Gets the value of a single property
|
|
348
|
+
* * @param {optionName} - string
|
|
349
|
+
* * Returns value - any
|
|
350
|
+
* * option(optionName, optionValue): Updates the value of a single property
|
|
351
|
+
* * @param {optionName} - string
|
|
352
|
+
* * @param {optionValue} - any
|
|
353
|
+
* * option(options): Updates the values of several properties
|
|
354
|
+
* * @param {options} - object
|
|
355
355
|
*/
|
|
356
356
|
reference: ref
|
|
357
357
|
};
|
|
@@ -7,19 +7,11 @@ import PropTypes from 'prop-types';
|
|
|
7
7
|
import { forwardRef, memo, useEffect, useImperativeHandle, useMemo, useRef, useState } from 'react';
|
|
8
8
|
import { detectColor, fade, hexToRGBA, hslToRgb, isColor, isColorName, rgbaToHexA, rgbToHex } from "../../styles/color-helper";
|
|
9
9
|
import * as allColors from "../../styles/colors";
|
|
10
|
-
import { bgColor, bgTransparent, border, borderColor, borderNone, borderRadius4px, boxBorder, cursorPointer, displayFlex, displayInlineFlex, flexRow, itemsCenter, justifyCenter, mg, mgl, mgr, outlineNone, overflowHidden, parseHeight, parseMinWidth, parseMinWidthHeight, parseWidthHeight, pd, pointerEventsNone, positionRelative, textColor, userSelectNone, whiteSpaceNoWrap } from "../../styles/general";
|
|
10
|
+
import { bgColor, bgTransparent, border, borderColor, borderNone, borderRadius4px, boxBorder, cursorNotAllowed, cursorPointer, displayFlex, displayInlineFlex, flexRow, itemsCenter, justifyCenter, mg, mgl, mgr, outlineNone, overflowHidden, parseHeight, parseMinWidth, parseMinWidthHeight, parseWidthHeight, pd, pointerEventsNone, positionRelative, textColor, userSelectNone, whiteSpaceNoWrap } from "../../styles/general";
|
|
11
11
|
import { useColor as colors, useTheme } from "../../theme";
|
|
12
12
|
import { classNames, refType as ref } from "../../utils";
|
|
13
13
|
import Ripple from "./ripple-effect";
|
|
14
14
|
const {
|
|
15
|
-
colors: {
|
|
16
|
-
system: {
|
|
17
|
-
disabled: systemDisabled
|
|
18
|
-
},
|
|
19
|
-
fill: {
|
|
20
|
-
disabled: fillDisabled
|
|
21
|
-
}
|
|
22
|
-
},
|
|
23
15
|
spacing
|
|
24
16
|
} = useTheme();
|
|
25
17
|
export const getRippleColor = (color, viewType, colors) => {
|
|
@@ -204,13 +196,13 @@ const Button = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
204
196
|
if (!startIcon && !endIcon) start = IconLoading;
|
|
205
197
|
}
|
|
206
198
|
return jsx(TagName, {
|
|
207
|
-
css: [_ButtonRootCSS, _ButtonSizeCSS
|
|
199
|
+
css: [_ButtonRootCSS, _ButtonSizeCSS],
|
|
208
200
|
ref: ref,
|
|
209
201
|
onClick: _onClick,
|
|
210
202
|
id: id,
|
|
211
203
|
type: type,
|
|
212
204
|
disabled: disabled,
|
|
213
|
-
className: classNames('DGN-UI-Button', viewType, size,
|
|
205
|
+
className: classNames('DGN-UI-Button', viewType, size, className),
|
|
214
206
|
href: urlState || null,
|
|
215
207
|
...props
|
|
216
208
|
}, start, jsx(Typography, {
|
|
@@ -253,21 +245,6 @@ const ButtonLabelCSS = (loading, iconMarginSize) => css`
|
|
|
253
245
|
${textColor('inherit')};
|
|
254
246
|
${mgl(loading ? iconMarginSize : 0)};
|
|
255
247
|
`;
|
|
256
|
-
const ButtonDisabledCSS = css`
|
|
257
|
-
cursor: not-allowed !important;
|
|
258
|
-
color: ${systemDisabled} !important;
|
|
259
|
-
&.outlined {
|
|
260
|
-
border-color: ${systemDisabled} !important;
|
|
261
|
-
background-color: transparent !important;
|
|
262
|
-
}
|
|
263
|
-
&.filled {
|
|
264
|
-
background-color: ${fillDisabled} !important;
|
|
265
|
-
filter: brightness(1) !important;
|
|
266
|
-
}
|
|
267
|
-
&.text {
|
|
268
|
-
background-color: transparent !important;
|
|
269
|
-
}
|
|
270
|
-
`;
|
|
271
248
|
const ButtonSizeCSS = (paddingSize, minHeightSize) => css`
|
|
272
249
|
${pd(paddingSize)};
|
|
273
250
|
${parseMinWidthHeight('max-content', minHeightSize)};
|
|
@@ -288,12 +265,10 @@ const ButtonRootCSS = (color, isColorDefault, viewType, loading) => css`
|
|
|
288
265
|
transition: all 0.5s;
|
|
289
266
|
${loading && pointerEventsNone};
|
|
290
267
|
${viewType === 'outlined' && css`
|
|
291
|
-
${bgColor('transparent')};
|
|
292
|
-
${border(1, color)};
|
|
293
268
|
${textColor(color)};
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
}
|
|
269
|
+
${border(1, color)};
|
|
270
|
+
${bgColor('transparent')};
|
|
271
|
+
${loading && bgColor(hexToRGBA(color, alphaLoading))};
|
|
297
272
|
${Object.keys(alphaArr).map(key => css`
|
|
298
273
|
&: ${key} {
|
|
299
274
|
${bgColor(hexToRGBA(color, alphaArr[key]))};
|
|
@@ -302,29 +277,32 @@ const ButtonRootCSS = (color, isColorDefault, viewType, loading) => css`
|
|
|
302
277
|
${isColorDefault && css`
|
|
303
278
|
${border(1, 'system.rest')};
|
|
304
279
|
${textColor('system.rest')};
|
|
305
|
-
|
|
306
|
-
&:hover,
|
|
307
|
-
&:focus,
|
|
308
|
-
&:active {
|
|
280
|
+
${loading && css`
|
|
309
281
|
${textColor('system.active')};
|
|
310
282
|
${borderColor('system.active')};
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
${bgColor(hexToRGBA('system.active', alphaLoading))}
|
|
314
|
-
}
|
|
283
|
+
${bgColor(hexToRGBA('system.active', alphaLoading))};
|
|
284
|
+
`}
|
|
315
285
|
${Object.keys(alphaArr).map(key => css`
|
|
316
286
|
&: ${key} {
|
|
287
|
+
${textColor('system.active')};
|
|
288
|
+
${borderColor('system.active')};
|
|
317
289
|
${bgColor(hexToRGBA('system.active', alphaArr[key]))};
|
|
318
290
|
}
|
|
319
|
-
`)}// &:hover | &:focus | &:active
|
|
291
|
+
`)} // &:hover | &:focus | &:active
|
|
320
292
|
`}
|
|
293
|
+
:disabled {
|
|
294
|
+
${borderColor('system.disabled')};
|
|
295
|
+
${bgColor('transparent')};
|
|
296
|
+
}
|
|
321
297
|
`}
|
|
322
298
|
${viewType === 'filled' && css`
|
|
323
299
|
${borderNone};
|
|
324
300
|
${textColor('system.white')};
|
|
325
301
|
${bgColor(color)};
|
|
326
302
|
font-weight: bold;
|
|
327
|
-
|
|
303
|
+
${loading && css`
|
|
304
|
+
filter: brightness(0.85);
|
|
305
|
+
`}
|
|
328
306
|
&:hover,
|
|
329
307
|
&:focus {
|
|
330
308
|
filter: brightness(0.85);
|
|
@@ -334,23 +312,23 @@ const ButtonRootCSS = (color, isColorDefault, viewType, loading) => css`
|
|
|
334
312
|
}
|
|
335
313
|
${isColorDefault && css`
|
|
336
314
|
${bgColor('system.rest')};
|
|
337
|
-
|
|
338
|
-
${bgColor('system.active')};
|
|
339
|
-
}
|
|
315
|
+
${loading && bgColor('system.active')};
|
|
340
316
|
&:hover,
|
|
341
317
|
&:focus,
|
|
342
318
|
&:active {
|
|
343
319
|
${bgColor('system.active')};
|
|
344
320
|
}
|
|
345
321
|
`}
|
|
322
|
+
:disabled {
|
|
323
|
+
${bgColor('fill.disabled')};
|
|
324
|
+
filter: brightness(1);
|
|
325
|
+
}
|
|
346
326
|
`}
|
|
347
327
|
${viewType === 'text' && css`
|
|
348
328
|
${bgTransparent};
|
|
349
329
|
${borderNone};
|
|
350
330
|
${textColor(color)};
|
|
351
|
-
|
|
352
|
-
${bgColor(hexToRGBA(color, alphaLoading))};
|
|
353
|
-
}
|
|
331
|
+
${loading && bgColor(hexToRGBA(color, alphaLoading))};
|
|
354
332
|
${Object.keys(alphaArr).map(key => css`
|
|
355
333
|
&: ${key} {
|
|
356
334
|
${bgColor(hexToRGBA(color, alphaArr[key]))};
|
|
@@ -358,27 +336,28 @@ const ButtonRootCSS = (color, isColorDefault, viewType, loading) => css`
|
|
|
358
336
|
`)}
|
|
359
337
|
${isColorDefault && css`
|
|
360
338
|
${textColor('system.rest')};
|
|
361
|
-
|
|
362
|
-
&:focus,
|
|
363
|
-
&:active {
|
|
364
|
-
${textColor('system.active')};
|
|
365
|
-
}
|
|
366
|
-
&.button--loading {
|
|
339
|
+
${loading && css`
|
|
367
340
|
${textColor('system.active')};
|
|
368
341
|
${bgColor(hexToRGBA('system.active', alphaLoading))};
|
|
369
|
-
}
|
|
342
|
+
`}
|
|
370
343
|
${Object.keys(alphaArr).map(key => css`
|
|
371
344
|
&: ${key} {
|
|
345
|
+
${textColor('system.active')};
|
|
372
346
|
${bgColor(hexToRGBA('system.active', alphaArr[key]))};
|
|
373
347
|
}
|
|
374
348
|
`)}
|
|
375
349
|
`}
|
|
350
|
+
:disabled {
|
|
351
|
+
${bgColor('transparent')};
|
|
352
|
+
}
|
|
376
353
|
`}
|
|
377
354
|
${viewType === 'link' && css`
|
|
378
355
|
${borderNone};
|
|
379
|
-
${textColor(color)};
|
|
356
|
+
${textColor(isColorDefault ? 'semantic.info' : color)};
|
|
380
357
|
${bgColor('transparent')};
|
|
381
|
-
|
|
358
|
+
${loading && css`
|
|
359
|
+
filter: brightness(0.85);
|
|
360
|
+
`}
|
|
382
361
|
&:hover,
|
|
383
362
|
&:focus {
|
|
384
363
|
filter: brightness(0.85);
|
|
@@ -386,10 +365,14 @@ const ButtonRootCSS = (color, isColorDefault, viewType, loading) => css`
|
|
|
386
365
|
&:active {
|
|
387
366
|
filter: brightness(0.7);
|
|
388
367
|
}
|
|
389
|
-
|
|
390
|
-
|
|
368
|
+
:disabled {
|
|
369
|
+
filter: brightness(1);
|
|
391
370
|
}
|
|
392
371
|
`}
|
|
372
|
+
:disabled {
|
|
373
|
+
${cursorNotAllowed};
|
|
374
|
+
${textColor('system.disabled')};
|
|
375
|
+
}
|
|
393
376
|
`;
|
|
394
377
|
Button.defaultProps = {
|
|
395
378
|
className: '',
|
|
@@ -416,7 +399,7 @@ Button.propTypes = {
|
|
|
416
399
|
href: PropTypes.string,
|
|
417
400
|
/** The content of the component. */
|
|
418
401
|
label: PropTypes.string,
|
|
419
|
-
/** [Props](https://core.diginet.com.vn/ui/?path=/docs/typography--title) applied to the `Typography` label. */
|
|
402
|
+
/** [Props](https://core.diginet.com.vn/ui/?path=/docs/components-typography--title) applied to the `Typography` label. */
|
|
420
403
|
labelProps: PropTypes.object,
|
|
421
404
|
/** If `true`, the loading indicator is shown. */
|
|
422
405
|
loading: PropTypes.bool,
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
/** @jsx jsx */
|
|
3
3
|
import { css, jsx } from '@emotion/core';
|
|
4
4
|
import PropTypes from 'prop-types';
|
|
5
|
-
import { forwardRef, isValidElement, memo, useImperativeHandle, useMemo, useRef, useState } from 'react';
|
|
5
|
+
import React, { forwardRef, isValidElement, memo, useImperativeHandle, useMemo, useRef, useState } from 'react';
|
|
6
6
|
import { ButtonIcon, Icon, Popover, Typography } from "../";
|
|
7
7
|
import { itemsCenter, borderNone, cursorPointer, flexCol, flexRow, outlineNone, parseHeight } from "../../styles/general";
|
|
8
8
|
import { useTheme } from "../../theme";
|
|
@@ -23,6 +23,7 @@ const {
|
|
|
23
23
|
} = useTheme();
|
|
24
24
|
const ButtonMore = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
25
25
|
action = {},
|
|
26
|
+
anchor,
|
|
26
27
|
buttonProps,
|
|
27
28
|
className,
|
|
28
29
|
disabled,
|
|
@@ -90,6 +91,23 @@ const ButtonMore = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
90
91
|
}
|
|
91
92
|
});
|
|
92
93
|
};
|
|
94
|
+
const renderAnchor = () => {
|
|
95
|
+
var _anchor, _anchor2, _anchor2$props;
|
|
96
|
+
if (!((_anchor = anchor) !== null && _anchor !== void 0 && _anchor.type)) return null;
|
|
97
|
+
const AnchorTag = /*#__PURE__*/React.cloneElement(anchor, {
|
|
98
|
+
ref: ref => {
|
|
99
|
+
anchor = ref;
|
|
100
|
+
},
|
|
101
|
+
onClick: openPopover,
|
|
102
|
+
id: id,
|
|
103
|
+
style: {
|
|
104
|
+
...style,
|
|
105
|
+
...(((_anchor2 = anchor) === null || _anchor2 === void 0 ? void 0 : (_anchor2$props = _anchor2.props) === null || _anchor2$props === void 0 ? void 0 : _anchor2$props.style) || {})
|
|
106
|
+
},
|
|
107
|
+
className: classNames('DGN-UI-ButtonMore', className)
|
|
108
|
+
});
|
|
109
|
+
return AnchorTag;
|
|
110
|
+
};
|
|
93
111
|
return useMemo(() => {
|
|
94
112
|
return jsx(Popover, {
|
|
95
113
|
css: _PopoverCSS,
|
|
@@ -103,7 +121,7 @@ const ButtonMore = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
103
121
|
vertical: 'top',
|
|
104
122
|
horizontal: 'left'
|
|
105
123
|
},
|
|
106
|
-
anchor: jsx(ButtonIcon, {
|
|
124
|
+
anchor: anchor ? renderAnchor() : jsx(ButtonIcon, {
|
|
107
125
|
ref: ref,
|
|
108
126
|
circular: true,
|
|
109
127
|
name: 'more',
|
|
@@ -455,7 +455,7 @@ const Attachment = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
455
455
|
// newAttachedRef.current.push(file);
|
|
456
456
|
tempArr.push(file);
|
|
457
457
|
}
|
|
458
|
-
setNewDataState(tempArr);
|
|
458
|
+
setNewDataState([...newDataState, ...tempArr]);
|
|
459
459
|
} else if (files[0]) {
|
|
460
460
|
allNewAttached.delete('files');
|
|
461
461
|
allNewAttached.append('files', files[0]);
|
|
@@ -77,13 +77,13 @@ const NumberInput = /*#__PURE__*/forwardRef(({
|
|
|
77
77
|
}
|
|
78
78
|
if (valueProps || valueProps === 0) valueProps = clamp(valueProps, min, max);
|
|
79
79
|
|
|
80
|
-
/**
|
|
81
|
-
* Convert number to format money
|
|
82
|
-
* @param vl {number} - value
|
|
83
|
-
* @type {function}
|
|
84
|
-
* @return {string}
|
|
85
|
-
* @example 1200300.123 => 1,200,300.123
|
|
86
|
-
* @example 1200300,123 => 1.200.300,123
|
|
80
|
+
/**
|
|
81
|
+
* Convert number to format money
|
|
82
|
+
* @param vl {number} - value
|
|
83
|
+
* @type {function}
|
|
84
|
+
* @return {string}
|
|
85
|
+
* @example 1200300.123 => 1,200,300.123
|
|
86
|
+
* @example 1200300,123 => 1.200.300,123
|
|
87
87
|
*/
|
|
88
88
|
const parseNumberToMoney = useCallback((vl, isNumber) => {
|
|
89
89
|
var _number, _number2, _number$, _number3;
|
|
@@ -114,13 +114,13 @@ const NumberInput = /*#__PURE__*/forwardRef(({
|
|
|
114
114
|
return number;
|
|
115
115
|
}, [decimalSymbol, max, value]);
|
|
116
116
|
|
|
117
|
-
/**
|
|
118
|
-
* Convert money to format number
|
|
119
|
-
* @param vl {string} - value
|
|
120
|
-
* @type {function}
|
|
121
|
-
* @return {number}
|
|
122
|
-
* @example 1,200,300.123 => 1200300.123
|
|
123
|
-
* @example 1.200.300,123 => 1200300.123
|
|
117
|
+
/**
|
|
118
|
+
* Convert money to format number
|
|
119
|
+
* @param vl {string} - value
|
|
120
|
+
* @type {function}
|
|
121
|
+
* @return {number}
|
|
122
|
+
* @example 1,200,300.123 => 1200300.123
|
|
123
|
+
* @example 1.200.300,123 => 1200300.123
|
|
124
124
|
*/
|
|
125
125
|
const convertMoneyToNumber = useCallback((vl, isNumber) => {
|
|
126
126
|
var _number4, _number4$toString, _number4$toString$rep, _number4$toString$rep2, _number4$toString$rep3;
|
|
@@ -414,10 +414,10 @@ NumberInput.propTypes = {
|
|
|
414
414
|
style: PropTypes.object,
|
|
415
415
|
/** Thousand separator character. */
|
|
416
416
|
thousandSeparator: PropTypes.oneOfType([PropTypes.bool, PropTypes.oneOf(['.', ','])]),
|
|
417
|
-
/** Validation value, argument can:<br/>
|
|
418
|
-
* * string: the validation rule. Example required.<br/>
|
|
419
|
-
* * object: the validation rule insist name, property, message. Example {name: 'min', compareValue: 9, message: 'Error'} or {max: 99}<br/>
|
|
420
|
-
* * array: the validation rule list, insist object/string
|
|
417
|
+
/** Validation value, argument can:<br/>
|
|
418
|
+
* * string: the validation rule. Example required.<br/>
|
|
419
|
+
* * object: the validation rule insist name, property, message. Example {name: 'min', compareValue: 9, message: 'Error'} or {max: 99}<br/>
|
|
420
|
+
* * array: the validation rule list, insist object/string
|
|
421
421
|
*/
|
|
422
422
|
validates: PropTypes.oneOfType([PropTypes.string, PropTypes.object, PropTypes.array, PropTypes.func]),
|
|
423
423
|
/** The value of the input element, required for a controlled component. */
|
|
@@ -191,11 +191,11 @@ Radio.propTypes = {
|
|
|
191
191
|
className: PropTypes.string,
|
|
192
192
|
/** Props for input. */
|
|
193
193
|
inputProps: PropTypes.object,
|
|
194
|
-
/** Callback fired when the state is changed.
|
|
195
|
-
*
|
|
196
|
-
* @param {object} event The event source of the callback.
|
|
197
|
-
* You can pull out the new value by accessing `event.target.value` (string).
|
|
198
|
-
* You can pull out the new checked state by accessing `event.target.checked` (boolean).
|
|
194
|
+
/** Callback fired when the state is changed.
|
|
195
|
+
*
|
|
196
|
+
* @param {object} event The event source of the callback.
|
|
197
|
+
* You can pull out the new value by accessing `event.target.value` (string).
|
|
198
|
+
* You can pull out the new checked state by accessing `event.target.checked` (boolean).
|
|
199
199
|
* */
|
|
200
200
|
onChange: PropTypes.func,
|
|
201
201
|
/** Prevent all event if true. */
|
|
@@ -226,10 +226,10 @@ Toggle.propTypes = {
|
|
|
226
226
|
lineClamp: PropTypes.number,
|
|
227
227
|
/** Shows tooltip containing Label on hover */
|
|
228
228
|
hoverTooltip: PropTypes.bool,
|
|
229
|
-
/** * Callback fired when the state is changed.
|
|
230
|
-
*
|
|
231
|
-
* @param {object} event The event source of the callback.
|
|
232
|
-
* You can pull out the new checked state by accessing `event.target.checked` (boolean).
|
|
229
|
+
/** * Callback fired when the state is changed.
|
|
230
|
+
*
|
|
231
|
+
* @param {object} event The event source of the callback.
|
|
232
|
+
* You can pull out the new checked state by accessing `event.target.checked` (boolean).
|
|
233
233
|
*/
|
|
234
234
|
onChange: PropTypes.func,
|
|
235
235
|
/** If `true`, the label will indicate that the checkbox is required. */
|
|
@@ -243,14 +243,14 @@ Rating.propTypes = {
|
|
|
243
243
|
className: PropTypes.string,
|
|
244
244
|
/** Style inline of component. */
|
|
245
245
|
style: PropTypes.object,
|
|
246
|
-
/**
|
|
247
|
-
* Callback fired when the value changes.
|
|
248
|
-
*
|
|
249
|
-
|
|
250
|
-
*
|
|
251
|
-
* event: The event source of the callback.
|
|
252
|
-
*
|
|
253
|
-
* value: The new value.
|
|
246
|
+
/**
|
|
247
|
+
* Callback fired when the value changes.
|
|
248
|
+
*
|
|
249
|
+
function(event: React.SyntheticEvent, value: number) => void
|
|
250
|
+
*
|
|
251
|
+
* event: The event source of the callback.
|
|
252
|
+
*
|
|
253
|
+
* value: The new value.
|
|
254
254
|
*/
|
|
255
255
|
onRating: PropTypes.func
|
|
256
256
|
};
|
package/components/tab/tab.js
CHANGED
|
@@ -416,9 +416,9 @@ Transfer.propTypes = {
|
|
|
416
416
|
height: oneOfType([string, number]),
|
|
417
417
|
/** field name used for icon display */
|
|
418
418
|
iconExpr: string,
|
|
419
|
-
/** field name used for text display<br/>
|
|
420
|
-
* Example: 'name', '{id} - {name}', '{age} age(s)'<br/>
|
|
421
|
-
* Note: don't use 'id - name', return undefined
|
|
419
|
+
/** field name used for text display<br/>
|
|
420
|
+
* Example: 'name', '{id} - {name}', '{age} age(s)'<br/>
|
|
421
|
+
* Note: don't use 'id - name', return undefined
|
|
422
422
|
*/
|
|
423
423
|
displayExpr: oneOfType([string, array]),
|
|
424
424
|
/** display header to select all choices if true */
|
|
@@ -105,7 +105,7 @@ const TextRootCSS = (color, type, lineClamp, onClick, hoverTooltip) => css`
|
|
|
105
105
|
${whiteSpaceBreakSpaces};
|
|
106
106
|
${textColor(colorMap.get(color) || color)};
|
|
107
107
|
${parseMaxWidth('max-content')};
|
|
108
|
-
${typography[type]};
|
|
108
|
+
${type !== 'inherit' && typography[type]};
|
|
109
109
|
&.DGN-Typography-center {
|
|
110
110
|
${textCenter};
|
|
111
111
|
}
|
|
@@ -181,6 +181,6 @@ Typography.propTypes = {
|
|
|
181
181
|
/** Tooltip direction. */
|
|
182
182
|
tooltipDirection: PropTypes.oneOf(['top', 'bottom', 'left', 'right']),
|
|
183
183
|
/** Applies the theme typography styles. */
|
|
184
|
-
type: PropTypes.oneOf(arrTypeTypography)
|
|
184
|
+
type: PropTypes.oneOf([...arrTypeTypography, 'inherit'])
|
|
185
185
|
};
|
|
186
186
|
export default Typography;
|
package/icons/effect.js
CHANGED
|
@@ -5,7 +5,8 @@ import OptionWrapper from "../components/others/option-wrapper";
|
|
|
5
5
|
import PropTypes from 'prop-types';
|
|
6
6
|
import { forwardRef, memo, useImperativeHandle, useMemo, useRef } from 'react';
|
|
7
7
|
import { itemsCenter, boxBorder, flexRow, justifyCenter, outlineNone, parseMinWidthHeight, parseWidthHeight, userSelectNone } from "../styles/general";
|
|
8
|
-
import {
|
|
8
|
+
import { getColor } from "../styles/utils";
|
|
9
|
+
import { useTheme } from "../theme";
|
|
9
10
|
import { capitalize, classNames, refType as ref } from "../utils";
|
|
10
11
|
import * as Icons from "./basic";
|
|
11
12
|
const {
|
|
@@ -50,7 +51,7 @@ const Icon = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
50
51
|
node = jsx(IconComp, {
|
|
51
52
|
width: width,
|
|
52
53
|
height: height,
|
|
53
|
-
color:
|
|
54
|
+
color: getColor(color),
|
|
54
55
|
viewBox: viewBox
|
|
55
56
|
});
|
|
56
57
|
} else {
|
package/package.json
CHANGED
package/readme.md
CHANGED
|
@@ -38,6 +38,12 @@ npm test
|
|
|
38
38
|
```
|
|
39
39
|
|
|
40
40
|
## Changelog
|
|
41
|
+
## 1.3.93
|
|
42
|
+
- \[Changed\]: Dropdown – Apply multilineSelectedItem to renderSelectedItem
|
|
43
|
+
- \[Fixed\]: Checkbox – Fix bug still uncheck when not set state
|
|
44
|
+
- \[Fixed\]: Modal – Fix footer height
|
|
45
|
+
- \[Fixed\]: DateRangePicker – Fix UI hover, focus empty days between selected range
|
|
46
|
+
|
|
41
47
|
## 1.3.92
|
|
42
48
|
- \[Fixed\]: Dropdown – Fix override css selected item Typography
|
|
43
49
|
- \[Fixed\]: Attachment – Fix crash when remove attached item
|
package/styles/utils.js
CHANGED
|
@@ -1,31 +1,31 @@
|
|
|
1
1
|
import { color as colors } from "./colors";
|
|
2
2
|
|
|
3
|
-
/**
|
|
4
|
-
* Parse css value
|
|
5
|
-
*
|
|
6
|
-
* @param {string | number} vl
|
|
7
|
-
* @returns {string | number}
|
|
3
|
+
/**
|
|
4
|
+
* Parse css value
|
|
5
|
+
*
|
|
6
|
+
* @param {string | number} vl
|
|
7
|
+
* @returns {string | number}
|
|
8
8
|
*/
|
|
9
9
|
export const parseCSSValue = vl => {
|
|
10
10
|
return isNaN(vl) ? vl : vl + 'px';
|
|
11
11
|
};
|
|
12
12
|
|
|
13
|
-
/**
|
|
14
|
-
* Parse to pixel
|
|
15
|
-
*
|
|
16
|
-
* @param {number} vl
|
|
17
|
-
* @returns {string}
|
|
13
|
+
/**
|
|
14
|
+
* Parse to pixel
|
|
15
|
+
*
|
|
16
|
+
* @param {number} vl
|
|
17
|
+
* @returns {string}
|
|
18
18
|
*/
|
|
19
19
|
export const parseToPixel = vl => {
|
|
20
20
|
if (!vl) return '1px';
|
|
21
21
|
return typeof vl === 'string' ? vl : `${vl}px`;
|
|
22
22
|
};
|
|
23
23
|
|
|
24
|
-
/**
|
|
25
|
-
* Get color from CORE colors
|
|
26
|
-
*
|
|
27
|
-
* @param {string} cl
|
|
28
|
-
* @returns {string}
|
|
24
|
+
/**
|
|
25
|
+
* Get color from CORE colors
|
|
26
|
+
*
|
|
27
|
+
* @param {string} cl
|
|
28
|
+
* @returns {string}
|
|
29
29
|
*/
|
|
30
30
|
export const getColor = cl => {
|
|
31
31
|
if (typeof cl !== 'string') return;
|