diginet-core-ui 1.3.68 → 1.3.69-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/button/index.js +13 -8
- package/components/chip/index.js +154 -185
- package/components/form-control/checkbox/index.js +1 -1
- package/components/form-control/date-picker/index.js +14 -4
- package/components/form-control/number-input/index2.js +18 -18
- package/components/form-control/phone-input/index.js +7 -7
- package/components/form-control/text-input/index.js +5 -41
- package/components/others/option-wrapper/index.js +2 -8
- package/components/paging/page-info.js +23 -23
- package/components/paging/page-selector2.js +23 -23
- package/components/popover/index.js +138 -88
- package/components/tab/tab-header.js +14 -7
- package/components/tab/tab.js +1 -1
- package/components/tooltip/index.js +75 -73
- package/package.json +59 -31
- package/readme.md +4 -0
- package/utils/index.js +1 -0
- package/utils/refType.js +5 -0
- package/utils/sb-teamplate.js +105 -0
|
@@ -12,6 +12,7 @@ import Ripple from './ripple-effect';
|
|
|
12
12
|
import CircularProgress from '../progress/circular';
|
|
13
13
|
import Icon from '../../icons';
|
|
14
14
|
import { flexRow, alignCenter, justifyCenter, positionRelative, borderRadius4px, borderBox, noPadding, noBorder, cursorPointer, overflowHidden, pointerEventsNone, outlineNone, userSelectNone, backgroundTransparent, inlineFlex, noMargin } from '../../styles/general';
|
|
15
|
+
import { classNames } from '../../utils';
|
|
15
16
|
import theme from '../../theme/settings';
|
|
16
17
|
const {
|
|
17
18
|
colors: {
|
|
@@ -33,7 +34,8 @@ const {
|
|
|
33
34
|
},
|
|
34
35
|
typography: {
|
|
35
36
|
uppercase
|
|
36
|
-
}
|
|
37
|
+
},
|
|
38
|
+
spacing
|
|
37
39
|
} = theme;
|
|
38
40
|
export const getRippleColor = (color, viewType, colors) => {
|
|
39
41
|
if (!isColor(color) && !isColorName(color)) {
|
|
@@ -83,12 +85,13 @@ export const getClassNameFromColor = color => {
|
|
|
83
85
|
return !isColor(color) && !isColorName(color) ? color : 'custom-color';
|
|
84
86
|
};
|
|
85
87
|
const colorMap = new Map([['primary', active], ['success', success], ['warning', warning], ['danger', danger], ['info', info]]);
|
|
86
|
-
const iconSizeMap = new Map([['tiny',
|
|
87
|
-
const paddingSizeMap = new Map([['tiny',
|
|
88
|
-
const outlinedPaddingSizeMap = new Map([['tiny',
|
|
88
|
+
const iconSizeMap = new Map([['tiny', spacing([4])], ['small', spacing([5])], ['medium', spacing([6])], ['large', spacing([8])], ['giant', spacing([10])]]);
|
|
89
|
+
const paddingSizeMap = new Map([['tiny', spacing([1, 2])], ['small', spacing([1.5, 3])], ['medium', spacing([2, 4])], ['large', spacing([2, 5])], ['giant', spacing([2, 6])]]);
|
|
90
|
+
const outlinedPaddingSizeMap = new Map([['tiny', spacing([0.75, 1.75])], ['small', spacing([1.25, 2.75])], ['medium', spacing([1.75, 3.75])], ['large', spacing([1.75, 4.75])], ['giant', spacing([1.75, 5.75])]]);
|
|
89
91
|
const iconMarginSizeMap = new Map([['tiny', '4px'], ['small', '4px'], ['medium', '4px'], ['large', '6px'], ['giant', '8px']]);
|
|
90
92
|
const typographySizeMap = new Map([['tiny', 'heading5'], ['small', 'heading5'], ['medium', 'heading4'], ['large', 'heading2'], ['giant', 'heading1']]);
|
|
91
93
|
const minHeightSizeMap = new Map([['tiny', '24px'], ['small', '32px'], ['medium', '40px'], ['large', '48px'], ['giant', '56px']]);
|
|
94
|
+
const minHeightSizeLinkMap = new Map([['tiny', '16px'], ['small', '20px'], ['medium', '24px'], ['large', '32px'], ['giant', '40px']]);
|
|
92
95
|
const alphaArr = {
|
|
93
96
|
hover: 0.1,
|
|
94
97
|
focus: 0.2,
|
|
@@ -121,10 +124,11 @@ const Button = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
121
124
|
const typographySize = typographySizeMap.get(size);
|
|
122
125
|
const iconMarginSize = iconMarginSizeMap.get(size);
|
|
123
126
|
const minHeightSize = minHeightSizeMap.get(size);
|
|
127
|
+
const minHeightSizeLink = minHeightSizeLinkMap.get(size);
|
|
124
128
|
|
|
125
129
|
const _ButtonText = ButtonText(loading, iconMarginSize);
|
|
126
130
|
|
|
127
|
-
const _ButtonRoot = ButtonRoot(viewType, size, paddingSize, minHeightSize, outlinedPaddingSize, endIcon, label, iconMarginSize, startIcon, iconSize, color);
|
|
131
|
+
const _ButtonRoot = ButtonRoot(viewType, size, paddingSize, minHeightSize, minHeightSizeLink, outlinedPaddingSize, endIcon, label, iconMarginSize, startIcon, iconSize, color);
|
|
128
132
|
|
|
129
133
|
useImperativeHandle(reference, () => ({
|
|
130
134
|
element: ref.current,
|
|
@@ -219,7 +223,7 @@ const Button = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
219
223
|
onClick: _onClick,
|
|
220
224
|
id: id,
|
|
221
225
|
type: type,
|
|
222
|
-
className:
|
|
226
|
+
className: classNames('DGN-UI-Button', viewType, getClassNameFromColor(color), size, loading && 'button--loading', disabled && 'button--disabled', className),
|
|
223
227
|
...props
|
|
224
228
|
}, start, jsx(Typography, {
|
|
225
229
|
css: _ButtonText,
|
|
@@ -228,7 +232,7 @@ const Button = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
228
232
|
}, children || label), end && end, !disabled && !loading && viewType !== 'link' && jsx(Ripple, {
|
|
229
233
|
color: getRippleColor(color, viewType, allColors)
|
|
230
234
|
}));
|
|
231
|
-
}, [
|
|
235
|
+
}, [children, className, color, disabled, endIcon, id, label, loading, onClick, size, startIcon, type, viewType]);
|
|
232
236
|
}));
|
|
233
237
|
const ButtonIcon = css`
|
|
234
238
|
${flexRow};
|
|
@@ -244,7 +248,7 @@ const ButtonText = (loading, iconMarginSize) => css`
|
|
|
244
248
|
margin: 0 ${loading ? iconMarginSize : 0};
|
|
245
249
|
`;
|
|
246
250
|
|
|
247
|
-
const ButtonRoot = (viewType, size, paddingSize, minHeightSize, outlinedPaddingSize, endIcon, label, iconMarginSize, startIcon, iconSize, color) => css`
|
|
251
|
+
const ButtonRoot = (viewType, size, paddingSize, minHeightSize, minHeightSizeLink, outlinedPaddingSize, endIcon, label, iconMarginSize, startIcon, iconSize, color) => css`
|
|
248
252
|
${inlineFlex};
|
|
249
253
|
${alignCenter};
|
|
250
254
|
${justifyCenter};
|
|
@@ -413,6 +417,7 @@ const ButtonRoot = (viewType, size, paddingSize, minHeightSize, outlinedPaddingS
|
|
|
413
417
|
}
|
|
414
418
|
}
|
|
415
419
|
&.link {
|
|
420
|
+
min-height: ${minHeightSizeLink};
|
|
416
421
|
${backgroundTransparent};
|
|
417
422
|
${noBorder};
|
|
418
423
|
${noPadding};
|
package/components/chip/index.js
CHANGED
|
@@ -6,34 +6,33 @@ import PropTypes from 'prop-types';
|
|
|
6
6
|
import { jsx, css } from '@emotion/core';
|
|
7
7
|
import { ButtonIcon, Typography } from '../';
|
|
8
8
|
import Icon from '../../icons';
|
|
9
|
-
import { alignCenter, border, borderBox, flexRow, inlineFlex, justifyCenter, positionRelative, userSelectNone, whiteSpaceNoWrap } from '../../styles/general';
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
9
|
+
import { alignCenter, border, borderBox, flexRow, inlineFlex, justifyCenter, positionRelative, userSelectNone, whiteSpaceNoWrap, cursorNotAllowed, positionAbsolute } from '../../styles/general';
|
|
10
|
+
import { hexToRGBA } from '../../styles/color-helper';
|
|
11
|
+
import { useTheme } from '../../theme';
|
|
12
12
|
const {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
line: {
|
|
26
|
-
normal,
|
|
27
|
-
disabled: lineDisabled
|
|
13
|
+
colors: {
|
|
14
|
+
danger,
|
|
15
|
+
info,
|
|
16
|
+
success,
|
|
17
|
+
warning,
|
|
18
|
+
system: {
|
|
19
|
+
active,
|
|
20
|
+
rest,
|
|
21
|
+
white,
|
|
22
|
+
disabled: disabledCl,
|
|
23
|
+
dark
|
|
24
|
+
}
|
|
28
25
|
},
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
const
|
|
26
|
+
spacing
|
|
27
|
+
} = useTheme();
|
|
28
|
+
const colorMap = new Map([['default', active], ['primary', active], ['success', success], ['warning', warning], ['danger', danger], ['info', info]]);
|
|
29
|
+
const iconSizeMap = new Map([['small', `${spacing(4)}px`], ['medium', `${spacing(5)}px`], ['large', `${spacing(6)}px`]]);
|
|
30
|
+
const typographySizeMap = new Map([['small', 'p3'], ['medium', 'p2'], ['large', 'p1']]);
|
|
31
|
+
const paddingSizeMap = new Map([['small', `0px ${spacing(1.5)}px`], ['medium', `0px ${spacing(2)}px`], ['large', `0px ${spacing(2.5)}px`]]);
|
|
32
|
+
const minHeightSizeMap = new Map([['small', `${spacing(5)}px`], ['medium', `${spacing(6)}px`], ['large', `${spacing(7)}px`]]);
|
|
34
33
|
const Chip = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
35
34
|
viewType,
|
|
36
|
-
color,
|
|
35
|
+
color: colorProps,
|
|
37
36
|
size,
|
|
38
37
|
label,
|
|
39
38
|
className,
|
|
@@ -41,21 +40,44 @@ const Chip = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
41
40
|
onClick,
|
|
42
41
|
onDbClick,
|
|
43
42
|
onDoubleClick,
|
|
44
|
-
maxLength,
|
|
45
43
|
startIcon,
|
|
46
44
|
endIcon,
|
|
47
45
|
clearAble,
|
|
48
46
|
disabled,
|
|
49
47
|
readOnly,
|
|
50
48
|
children,
|
|
51
|
-
style
|
|
49
|
+
style,
|
|
50
|
+
labelProps
|
|
52
51
|
}, reference) => {
|
|
53
52
|
const ref = useRef(null);
|
|
54
53
|
const IconRef = useRef(null);
|
|
55
54
|
if (!onDbClick && onDoubleClick) onDbClick = onDoubleClick;
|
|
55
|
+
const color = colorMap.get(colorProps) || colorProps;
|
|
56
|
+
const infoChip = {
|
|
57
|
+
color: colorMap.get(colorProps) || colorProps,
|
|
58
|
+
contentColor: viewType !== 'filled' ? color : white,
|
|
59
|
+
backgroundColor: viewType !== 'filled' ? white : color,
|
|
60
|
+
iconSize: iconSizeMap.get(size),
|
|
61
|
+
paddingSize: paddingSizeMap.get(size),
|
|
62
|
+
typographySize: typographySizeMap.get(size),
|
|
63
|
+
minHeightSize: minHeightSizeMap.get(size),
|
|
64
|
+
viewType
|
|
65
|
+
};
|
|
66
|
+
infoChip.border = viewType === 'ghost' ? 'transparent !important' : colorProps === 'default' ? rest : infoChip === null || infoChip === void 0 ? void 0 : infoChip.color;
|
|
67
|
+
infoChip.contentColor = colorProps === 'default' && viewType === 'outlined' ? rest : infoChip === null || infoChip === void 0 ? void 0 : infoChip.contentColor;
|
|
68
|
+
infoChip.backgroundColor = colorProps === 'default' && viewType === 'filled' ? rest : infoChip === null || infoChip === void 0 ? void 0 : infoChip.backgroundColor;
|
|
69
|
+
useImperativeHandle(reference, () => {
|
|
70
|
+
const currentRef = ref.current || {};
|
|
71
|
+
const _instance = {}; // methods
|
|
72
|
+
|
|
73
|
+
_instance.__proto__ = {}; // hidden methods
|
|
74
|
+
|
|
75
|
+
currentRef.instance = _instance;
|
|
76
|
+
return currentRef;
|
|
77
|
+
});
|
|
56
78
|
|
|
57
79
|
const onRemoveHandler = () => {
|
|
58
|
-
if (onRemove) onRemove(ref.current);
|
|
80
|
+
if (onRemove || disabled) onRemove(ref.current);
|
|
59
81
|
setTimeout(() => {
|
|
60
82
|
ref.current && ref.current.remove();
|
|
61
83
|
}, 0);
|
|
@@ -71,213 +93,158 @@ const Chip = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
71
93
|
onDbClick && event.stopPropagation();
|
|
72
94
|
if (disabled) return;
|
|
73
95
|
onDbClick && onDbClick(event);
|
|
74
|
-
};
|
|
96
|
+
}; // Start Icon
|
|
75
97
|
|
|
76
|
-
const renderLabel = () => {
|
|
77
|
-
if (maxLength && label && label.length > maxLength) {
|
|
78
|
-
label = label.slice(0, maxLength) + '...';
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
return label;
|
|
82
|
-
};
|
|
83
98
|
|
|
84
|
-
useImperativeHandle(reference, () => {
|
|
85
|
-
const currentRef = ref.current || {};
|
|
86
|
-
const _instance = {}; // methods
|
|
87
|
-
|
|
88
|
-
_instance.__proto__ = {}; // hidden methods
|
|
89
|
-
|
|
90
|
-
currentRef.instance = _instance;
|
|
91
|
-
return currentRef;
|
|
92
|
-
});
|
|
93
99
|
const startIconView = useMemo(() => {
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
height: iconSizeMap.get(size),
|
|
101
|
-
color: 'currentColor',
|
|
102
|
-
viewBox: false
|
|
100
|
+
if (typeof startIcon === 'string') {
|
|
101
|
+
return jsx(Icon, {
|
|
102
|
+
name: startIcon,
|
|
103
|
+
width: infoChip.iconSize,
|
|
104
|
+
height: infoChip.iconSize,
|
|
105
|
+
color: 'currentColor'
|
|
103
106
|
});
|
|
104
|
-
}
|
|
107
|
+
} else return jsx("div", {
|
|
108
|
+
css: ChipIconCSS(info)
|
|
109
|
+
}, startIcon);
|
|
110
|
+
}, [startIcon, size]); // Label
|
|
105
111
|
|
|
106
|
-
return startIcon && jsx("div", {
|
|
107
|
-
css: ChipIconCSS,
|
|
108
|
-
className: size
|
|
109
|
-
}, node);
|
|
110
|
-
}, [startIcon, size]);
|
|
111
112
|
const labelView = useMemo(() => {
|
|
112
|
-
return jsx(
|
|
113
|
-
css: ChipLabelCSS
|
|
114
|
-
|
|
115
|
-
}, jsx(Typography, {
|
|
116
|
-
type: size === 'small' ? 'p2' : 'p1',
|
|
113
|
+
return jsx(Typography, {
|
|
114
|
+
css: ChipLabelCSS,
|
|
115
|
+
type: infoChip.typographySize,
|
|
117
116
|
color: 'inherit',
|
|
118
|
-
lineClamp: 1
|
|
119
|
-
|
|
120
|
-
|
|
117
|
+
lineClamp: 1,
|
|
118
|
+
...labelProps
|
|
119
|
+
}, label);
|
|
120
|
+
}, [label, size, startIcon, endIcon, clearAble]); // End Icon
|
|
121
|
+
|
|
121
122
|
const endIconView = useMemo(() => {
|
|
122
123
|
let node = endIcon;
|
|
123
124
|
|
|
124
125
|
if (typeof node === 'string') {
|
|
125
|
-
|
|
126
|
+
return jsx(Icon, {
|
|
126
127
|
name: node,
|
|
127
|
-
width:
|
|
128
|
-
height:
|
|
129
|
-
color:
|
|
130
|
-
viewBox:
|
|
128
|
+
width: infoChip.iconSize,
|
|
129
|
+
height: infoChip.iconSize,
|
|
130
|
+
color: infoChip.contentColor,
|
|
131
|
+
viewBox: true
|
|
131
132
|
});
|
|
132
133
|
}
|
|
133
134
|
|
|
134
|
-
return clearAble ? jsx(
|
|
135
|
-
|
|
136
|
-
className: 'end-icon
|
|
137
|
-
ref: IconRef
|
|
138
|
-
}, jsx(ButtonIcon, {
|
|
135
|
+
return clearAble ? jsx(ButtonIcon, {
|
|
136
|
+
ref: IconRef,
|
|
137
|
+
className: 'end-icon',
|
|
139
138
|
viewType: 'ghost',
|
|
140
139
|
name: 'Close',
|
|
141
|
-
|
|
140
|
+
width: infoChip.iconSize,
|
|
141
|
+
height: infoChip.iconSize,
|
|
142
|
+
color: infoChip.contentColor,
|
|
142
143
|
disabled: disabled,
|
|
144
|
+
viewBox: true,
|
|
143
145
|
onClick: onRemoveHandler
|
|
144
|
-
})
|
|
145
|
-
css: ChipIconCSS,
|
|
146
|
+
}) : node && jsx("div", {
|
|
147
|
+
css: ChipIconCSS(size),
|
|
146
148
|
className: 'end-icon ' + size,
|
|
147
149
|
ref: IconRef
|
|
148
150
|
}, node);
|
|
149
151
|
}, [clearAble, viewType, color, endIcon, size, disabled]);
|
|
150
152
|
return jsx("div", {
|
|
151
|
-
css: ChipRootCSS(onClick, onDbClick,
|
|
153
|
+
css: ChipRootCSS(onClick, onDbClick, colorProps, infoChip),
|
|
152
154
|
ref: ref,
|
|
153
|
-
className: ['DGN-UI-Chip',
|
|
155
|
+
className: ['DGN-UI-Chip', className, disabled && 'chip--disabled', readOnly && 'chip--readOnly', viewType === 'filled' && 'chip--filled'].join(' '),
|
|
154
156
|
style: style,
|
|
155
157
|
onClick: _onClick,
|
|
156
158
|
onDoubleClick: _onDbClick
|
|
157
|
-
}, startIconView, labelView, endIconView, children);
|
|
159
|
+
}, !!startIcon && startIconView, !!label && labelView, (!!endIcon || !!clearAble) && endIconView, children);
|
|
158
160
|
}));
|
|
159
|
-
const
|
|
160
|
-
${flexRow};
|
|
161
|
-
${justifyCenter};
|
|
162
|
-
${alignCenter};
|
|
163
|
-
${positionRelative};
|
|
164
|
-
${borderBox};
|
|
165
|
-
padding: 0 2px;
|
|
166
|
-
color: inherit;
|
|
167
|
-
img {
|
|
168
|
-
border-radius: 50%;
|
|
169
|
-
}
|
|
170
|
-
&.small {
|
|
171
|
-
width: 24px;
|
|
172
|
-
height: 24px;
|
|
173
|
-
img {
|
|
174
|
-
width: 20px;
|
|
175
|
-
height: 20px;
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
|
-
&.medium {
|
|
179
|
-
max-width: 32px;
|
|
180
|
-
max-height: 32px;
|
|
181
|
-
img {
|
|
182
|
-
min-width: 24px;
|
|
183
|
-
min-height: 24px;
|
|
184
|
-
}
|
|
185
|
-
&:not(.end-icon) {
|
|
186
|
-
margin-right: 4px;
|
|
187
|
-
}
|
|
188
|
-
&.end-icon {
|
|
189
|
-
width: 32px;
|
|
190
|
-
height: 26px;
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
`;
|
|
194
|
-
|
|
195
|
-
const ChipLabelCSS = (startIcon, endIcon, clearAble) => css`
|
|
161
|
+
const ChipLabelCSS = css`
|
|
196
162
|
${flexRow};
|
|
197
163
|
${alignCenter};
|
|
198
164
|
${positionRelative};
|
|
199
165
|
${userSelectNone};
|
|
200
166
|
${whiteSpaceNoWrap};
|
|
201
|
-
padding-right: ${endIcon || clearAble ? 2 : 10}px;
|
|
202
|
-
padding-left: ${startIcon ? 2 : 10}px;
|
|
203
|
-
&.small {
|
|
204
|
-
max-height: 24px;
|
|
205
|
-
}
|
|
206
|
-
&.medium {
|
|
207
|
-
max-height: 32px;
|
|
208
|
-
}
|
|
209
167
|
`;
|
|
210
168
|
|
|
211
|
-
const ChipRootCSS = (onClick, onDbClick,
|
|
169
|
+
const ChipRootCSS = (onClick, onDbClick, colorProps, info) => css`
|
|
212
170
|
${inlineFlex};
|
|
213
171
|
${alignCenter};
|
|
214
172
|
${positionRelative};
|
|
215
173
|
${borderBox};
|
|
216
|
-
${border(
|
|
174
|
+
${border('1px', info.border)};
|
|
217
175
|
width: max-content;
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
border-radius: 20px;
|
|
176
|
+
padding: ${info === null || info === void 0 ? void 0 : info.paddingSize};
|
|
177
|
+
color: ${info === null || info === void 0 ? void 0 : info.contentColor};
|
|
178
|
+
background: ${info === null || info === void 0 ? void 0 : info.backgroundColor};
|
|
179
|
+
border-radius: ${spacing(4)}px;
|
|
223
180
|
cursor: ${onClick || onDbClick ? 'pointer' : 'unset'};
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
}
|
|
227
|
-
&.
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
181
|
+
height: ${info === null || info === void 0 ? void 0 : info.minHeightSize};
|
|
182
|
+
min-height: ${info === null || info === void 0 ? void 0 : info.minHeightSize};
|
|
183
|
+
gap: ${spacing()}px;
|
|
184
|
+
&.chip--filled {
|
|
185
|
+
&:not(.chip--disabled):not(.chip--readOnly) {
|
|
186
|
+
&::after {
|
|
187
|
+
border-radius: ${spacing(4)}px;
|
|
188
|
+
${positionAbsolute};
|
|
189
|
+
top: 0;
|
|
190
|
+
left: 0;
|
|
191
|
+
content: '';
|
|
192
|
+
width: 100%;
|
|
193
|
+
height: 100%;
|
|
194
|
+
}
|
|
195
|
+
&:hover::after,
|
|
196
|
+
&:focus::after {
|
|
197
|
+
background: ${hexToRGBA(dark, 0.15)};
|
|
198
|
+
}
|
|
199
|
+
&:active::after {
|
|
200
|
+
background: ${hexToRGBA(dark, 0.3)};
|
|
244
201
|
}
|
|
245
202
|
}
|
|
246
203
|
}
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
204
|
+
&:not(.chip--filled) {
|
|
205
|
+
&:not(.chip--disabled):not(.chip--readOnly):hover {
|
|
206
|
+
${border('1px', info === null || info === void 0 ? void 0 : info.color)};
|
|
207
|
+
background: ${hexToRGBA(info === null || info === void 0 ? void 0 : info.color, 0.1)};
|
|
208
|
+
color: ${info === null || info === void 0 ? void 0 : info.color};
|
|
251
209
|
}
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
color: ${
|
|
256
|
-
border-color: ${colors[color] || color};
|
|
210
|
+
&:not(.chip--disabled):not(.chip--readOnly):active {
|
|
211
|
+
${border('1px', info === null || info === void 0 ? void 0 : info.color)};
|
|
212
|
+
background: ${hexToRGBA(info === null || info === void 0 ? void 0 : info.color, 0.3)};
|
|
213
|
+
color: ${info === null || info === void 0 ? void 0 : info.color};
|
|
257
214
|
}
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
color: ${white};
|
|
263
|
-
&:hover {
|
|
264
|
-
color: ${danger};
|
|
265
|
-
}
|
|
266
|
-
}
|
|
267
|
-
&.${color} {
|
|
268
|
-
background-color: ${colors[color] || color};
|
|
269
|
-
border-color: ${darken(colors[color] || color, 0.22)};
|
|
215
|
+
&:not(.chip--disabled):not(.chip--readOnly):focus {
|
|
216
|
+
${border('1px', info === null || info === void 0 ? void 0 : info.color)};
|
|
217
|
+
background: ${hexToRGBA(info === null || info === void 0 ? void 0 : info.color, 0.2)};
|
|
218
|
+
color: ${info === null || info === void 0 ? void 0 : info.color};
|
|
270
219
|
}
|
|
271
220
|
}
|
|
221
|
+
&.chip--disabled {
|
|
222
|
+
color: ${disabledCl} !important;
|
|
223
|
+
background-color: ${white} !important;
|
|
224
|
+
${border('1px', disabledCl)};
|
|
225
|
+
}
|
|
226
|
+
&.chip--readOnly,
|
|
227
|
+
&.chip--disabled {
|
|
228
|
+
${cursorNotAllowed}
|
|
229
|
+
}
|
|
230
|
+
`;
|
|
231
|
+
|
|
232
|
+
const ChipIconCSS = info => css`
|
|
233
|
+
${flexRow};
|
|
234
|
+
${justifyCenter};
|
|
235
|
+
${alignCenter};
|
|
236
|
+
${positionRelative};
|
|
237
|
+
${borderBox};
|
|
238
|
+
width: ${info === null || info === void 0 ? void 0 : info.iconSize};
|
|
239
|
+
min-width: ${info === null || info === void 0 ? void 0 : info.iconSize};
|
|
240
|
+
height: ${info === null || info === void 0 ? void 0 : info.iconSize};
|
|
241
|
+
min-height: ${info === null || info === void 0 ? void 0 : info.iconSize};
|
|
272
242
|
`;
|
|
273
243
|
|
|
274
244
|
Chip.defaultProps = {
|
|
275
|
-
label: '',
|
|
276
|
-
className: '',
|
|
277
|
-
style: {},
|
|
278
245
|
viewType: 'outlined',
|
|
279
|
-
size: '
|
|
280
|
-
|
|
246
|
+
size: 'medium',
|
|
247
|
+
color: 'default'
|
|
281
248
|
};
|
|
282
249
|
Chip.propTypes = {
|
|
283
250
|
/** content to display in Chip */
|
|
@@ -290,7 +257,6 @@ Chip.propTypes = {
|
|
|
290
257
|
|
|
291
258
|
/** style inline of component */
|
|
292
259
|
style: PropTypes.object,
|
|
293
|
-
maxLength: PropTypes.number,
|
|
294
260
|
|
|
295
261
|
/** the icon display at head of Chip */
|
|
296
262
|
startIcon: PropTypes.any,
|
|
@@ -299,13 +265,13 @@ Chip.propTypes = {
|
|
|
299
265
|
endIcon: PropTypes.any,
|
|
300
266
|
|
|
301
267
|
/** type of chip */
|
|
302
|
-
viewType: PropTypes.oneOf(['outlined', 'filled']),
|
|
268
|
+
viewType: PropTypes.oneOf(['ghost', 'outlined', 'filled']),
|
|
303
269
|
|
|
304
270
|
/** color for text or background of Chip */
|
|
305
271
|
color: PropTypes.oneOf(['default', 'primary', 'info', 'success', 'warning', 'danger']),
|
|
306
272
|
|
|
307
273
|
/** size of Chip */
|
|
308
|
-
size: PropTypes.oneOf(['small', 'medium']),
|
|
274
|
+
size: PropTypes.oneOf(['small', 'medium', 'large']),
|
|
309
275
|
|
|
310
276
|
/** show clear icon if true */
|
|
311
277
|
clearAble: PropTypes.bool,
|
|
@@ -332,6 +298,9 @@ Chip.propTypes = {
|
|
|
332
298
|
onDoubleClick: PropTypes.func,
|
|
333
299
|
|
|
334
300
|
/** content to display on Chip (the same to label) */
|
|
335
|
-
children: PropTypes.node
|
|
301
|
+
children: PropTypes.node,
|
|
302
|
+
|
|
303
|
+
/** props for Typography of label */
|
|
304
|
+
labelProps: PropTypes.object
|
|
336
305
|
};
|
|
337
306
|
export default Chip;
|
|
@@ -55,7 +55,7 @@ const DatePicker = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
55
55
|
returnFormat,
|
|
56
56
|
style,
|
|
57
57
|
textAlign,
|
|
58
|
-
value,
|
|
58
|
+
value: valueProp,
|
|
59
59
|
viewType,
|
|
60
60
|
...props
|
|
61
61
|
}, reference) => {
|
|
@@ -86,6 +86,7 @@ const DatePicker = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
86
86
|
const focusedValue = useRef(null);
|
|
87
87
|
const [, setDisplayValue] = useState(Date.now());
|
|
88
88
|
const [, setFocusedValue] = useState(Date.now());
|
|
89
|
+
const [value, setValue] = useState(valueProp || defaultValue);
|
|
89
90
|
|
|
90
91
|
const _IconAreaCSS = IconAreaCSS(unique);
|
|
91
92
|
|
|
@@ -126,7 +127,12 @@ const DatePicker = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
126
127
|
};
|
|
127
128
|
|
|
128
129
|
const onChangeValue = e => {
|
|
129
|
-
|
|
130
|
+
if (valueProp) {
|
|
131
|
+
closePicker();
|
|
132
|
+
} else {
|
|
133
|
+
setValue(e.value);
|
|
134
|
+
}
|
|
135
|
+
|
|
130
136
|
!!onChange && onChange({
|
|
131
137
|
value: formatValue(e.value, returnFormat)
|
|
132
138
|
});
|
|
@@ -436,6 +442,9 @@ const DatePicker = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
436
442
|
closePicker();
|
|
437
443
|
}
|
|
438
444
|
}, [value]);
|
|
445
|
+
useEffect(() => {
|
|
446
|
+
setValue(valueProp);
|
|
447
|
+
}, [valueProp]);
|
|
439
448
|
useEffect(() => {
|
|
440
449
|
if (!readOnly) {
|
|
441
450
|
ipRef.current.addEventListener('focus', onInputFocus);
|
|
@@ -534,7 +543,6 @@ const DatePicker = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
534
543
|
}, jsx(InputBase, {
|
|
535
544
|
placeholder: placeholder,
|
|
536
545
|
...inputProps,
|
|
537
|
-
readOnly: true,
|
|
538
546
|
ref: ipConRef,
|
|
539
547
|
inputRef: ipRef,
|
|
540
548
|
disabled: disabled,
|
|
@@ -544,7 +552,9 @@ const DatePicker = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
544
552
|
...inputStyle
|
|
545
553
|
},
|
|
546
554
|
startIcon: startIcon,
|
|
547
|
-
endIcon: endIcon
|
|
555
|
+
endIcon: endIcon,
|
|
556
|
+
onKeyDown: e => e.preventDefault(),
|
|
557
|
+
readOnly: true
|
|
548
558
|
})), isError && jsx(HelperText, { ...errorProps,
|
|
549
559
|
style: {
|
|
550
560
|
minHeight: 16,
|
|
@@ -79,13 +79,13 @@ const NumberInput = /*#__PURE__*/forwardRef(({
|
|
|
79
79
|
const clamp = (num, min, max) => Math.min(Math.max(num, min), max);
|
|
80
80
|
|
|
81
81
|
if (valueProps || valueProps === 0) valueProps = clamp(valueProps, min, max);
|
|
82
|
-
/**
|
|
83
|
-
* Convert number to format money
|
|
84
|
-
* @param vl {number} - value
|
|
85
|
-
* @type {function(*): number}
|
|
86
|
-
* @return {string}
|
|
87
|
-
* @example 1200300.123 => 1,200,300.123
|
|
88
|
-
* @example 1200300,123 => 1.200.300,123
|
|
82
|
+
/**
|
|
83
|
+
* Convert number to format money
|
|
84
|
+
* @param vl {number} - value
|
|
85
|
+
* @type {function(*): number}
|
|
86
|
+
* @return {string}
|
|
87
|
+
* @example 1200300.123 => 1,200,300.123
|
|
88
|
+
* @example 1200300,123 => 1.200.300,123
|
|
89
89
|
*/
|
|
90
90
|
|
|
91
91
|
const parseNumberToMoney = useCallback((vl, isNumber) => {
|
|
@@ -119,13 +119,13 @@ const NumberInput = /*#__PURE__*/forwardRef(({
|
|
|
119
119
|
|
|
120
120
|
return number;
|
|
121
121
|
}, [decimalSymbol, max, value]);
|
|
122
|
-
/**
|
|
123
|
-
* Convert money to format number
|
|
124
|
-
* @param vl {string} - value
|
|
125
|
-
* @type {function(*): number}
|
|
126
|
-
* @return {number}
|
|
127
|
-
* @example 1,200,300.123 => 1200300.123
|
|
128
|
-
* @example 1.200.300,123 => 1200300.123
|
|
122
|
+
/**
|
|
123
|
+
* Convert money to format number
|
|
124
|
+
* @param vl {string} - value
|
|
125
|
+
* @type {function(*): number}
|
|
126
|
+
* @return {number}
|
|
127
|
+
* @example 1,200,300.123 => 1200300.123
|
|
128
|
+
* @example 1.200.300,123 => 1200300.123
|
|
129
129
|
*/
|
|
130
130
|
|
|
131
131
|
const convertMoneyToNumber = useCallback((vl, isNumber) => {
|
|
@@ -397,10 +397,10 @@ NumberInput.propTypes = {
|
|
|
397
397
|
/** style inline of input in NumberInput component */
|
|
398
398
|
inputStyle: PropTypes.object,
|
|
399
399
|
|
|
400
|
-
/** validation value, argument can:<br/>
|
|
401
|
-
* * string: the validation rule. Example required.<br/>
|
|
402
|
-
* * object: the validation rule insist name, property, message. Example {name: 'min', compareValue: 9, message: 'Error'} or {max: 99}<br/>
|
|
403
|
-
* * array: the validation rule list, insist object/string
|
|
400
|
+
/** validation value, argument can:<br/>
|
|
401
|
+
* * string: the validation rule. Example required.<br/>
|
|
402
|
+
* * object: the validation rule insist name, property, message. Example {name: 'min', compareValue: 9, message: 'Error'} or {max: 99}<br/>
|
|
403
|
+
* * array: the validation rule list, insist object/string
|
|
404
404
|
*/
|
|
405
405
|
validates: PropTypes.oneOfType([PropTypes.string, PropTypes.object, PropTypes.array, PropTypes.func]),
|
|
406
406
|
|