diginet-core-ui 1.3.70 → 1.3.71
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/avatar/index.js +99 -84
- package/components/button/index.js +13 -8
- package/components/card/body.js +2 -1
- package/components/card/extra.js +2 -1
- package/components/card/footer.js +2 -1
- package/components/card/header.js +2 -1
- package/components/card/index.js +11 -8
- package/components/chip/index.js +158 -189
- package/components/form-control/checkbox/index.js +2 -2
- package/components/form-control/dropdown/index.js +199 -218
- package/components/form-control/radio/index.js +2 -2
- package/components/form-control/text-input/index.js +139 -212
- package/components/form-control/toggle/index.js +2 -2
- package/components/grid/index.js +2 -2
- package/components/others/import/index.js +78 -0
- package/components/tooltip/index.js +8 -2
- package/global/index.js +5 -5
- package/package.json +1 -1
- package/readme.md +10 -0
- package/utils/index.js +2 -0
- package/utils/{sb-teamplate.js → sb-template.js} +20 -12
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
/** @jsx jsx */
|
|
4
4
|
import { css, jsx } from '@emotion/core';
|
|
5
5
|
import PropTypes from 'prop-types';
|
|
6
|
-
import
|
|
6
|
+
import { forwardRef, memo, useState, useRef, useEffect, useMemo, Fragment } from 'react';
|
|
7
7
|
import theme from '../../../theme/settings';
|
|
8
8
|
import { randomString } from '../../../utils';
|
|
9
9
|
import Typography from './../../typography';
|
|
@@ -98,7 +98,7 @@ const Radio = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
98
98
|
color: disabled ? clDisabled : '',
|
|
99
99
|
type: 'p1',
|
|
100
100
|
...labelProps
|
|
101
|
-
}, jsx(
|
|
101
|
+
}, jsx(Fragment, null, label !== null && label !== void 0 ? label : value, required && jsx("span", {
|
|
102
102
|
style: {
|
|
103
103
|
color: disabled ? clDisabled : clDanger
|
|
104
104
|
}
|
|
@@ -5,69 +5,49 @@ import { memo, useEffect, useRef, forwardRef, useState, useImperativeHandle } fr
|
|
|
5
5
|
import PropTypes from 'prop-types';
|
|
6
6
|
import { jsx, css } from '@emotion/core';
|
|
7
7
|
import { ButtonIcon, CircularProgress as Circular, HelperText, InputBase, Label } from '../../';
|
|
8
|
-
import { renderIcon, onValidate } from '../../../utils';
|
|
8
|
+
import { renderIcon, onValidate, refType as ref } from '../../../utils';
|
|
9
9
|
import { cursorNotAllowed, displayBlock, flexRow, positionRelative } from '../../../styles/general';
|
|
10
|
-
const icons = {
|
|
11
|
-
default: `<svg width="20" height="19" viewBox="0 0 20 19" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
12
|
-
<path fillRule="evenodd" clipRule="evenodd" d="M15.5616 19.0007C15.4036 19.0007 15.2446 18.9637 15.0986 18.8877L9.99962 16.2237L4.90162 18.8877C4.56362 19.0627 4.15562 19.0327 3.84962 18.8087C3.54162 18.5847 3.38862 18.2057 3.45362 17.8307L4.42462 12.2027L0.304623 8.21765C0.030623 7.95265 -0.068377 7.55465 0.048623 7.19065C0.165623 6.82865 0.478623 6.56365 0.856623 6.50965L6.55662 5.68165L9.10462 0.555654C9.44262 -0.124346 10.5576 -0.124346 10.8956 0.555654L13.4436 5.68165L19.1436 6.50965C19.5216 6.56365 19.8346 6.82865 19.9516 7.19065C20.0686 7.55465 19.9696 7.95265 19.6956 8.21765L15.5756 12.2027L16.5466 17.8307C16.6116 18.2057 16.4576 18.5847 16.1506 18.8087C15.9766 18.9367 15.7696 19.0007 15.5616 19.0007Z" fill="#7F828E"/>
|
|
13
|
-
</svg>`,
|
|
14
|
-
success: `<svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
15
|
-
<path fillRule="evenodd" clipRule="evenodd" d="M18.997 8.974H19C19.551 8.974 19.999 9.42 20 9.971C20.008 12.642 18.975 15.157 17.091 17.051C15.208 18.945 12.7 19.992 10.029 20H10C7.33905 20 4.83605 18.968 2.94905 17.091C1.05505 15.208 0.00804612 12.7 4.61203e-05 10.029C-0.00795388 7.357 1.02505 4.843 2.90905 2.949C4.79205 1.055 7.30005 0.008 9.97105 0C10.766 0.012 11.576 0.092 12.352 0.278C12.888 0.408 13.219 0.948 13.089 1.485C12.96 2.021 12.417 2.351 11.883 2.223C11.262 2.073 10.603 2.01 9.97705 2C7.84005 2.006 5.83305 2.844 4.32705 4.359C2.82005 5.874 1.99405 7.886 2.00005 10.023C2.00605 12.16 2.84405 14.166 4.35905 15.673C5.86905 17.174 7.87105 18 10 18H10.023C12.16 17.994 14.167 17.156 15.673 15.641C17.18 14.125 18.006 12.114 18 9.977C17.999 9.425 18.445 8.975 18.997 8.974ZM6.29305 9.2929C6.68405 8.9019 7.31605 8.9019 7.70705 9.2929L9.95105 11.5369L16.248 4.3409C16.612 3.9279 17.243 3.8839 17.659 4.2479C18.074 4.6109 18.116 5.2429 17.752 5.6589L10.752 13.6589C10.57 13.8669 10.31 13.9899 10.033 13.9999H10C9.73505 13.9999 9.48105 13.8949 9.29305 13.7069L6.29305 10.7069C5.90205 10.3159 5.90205 9.6839 6.29305 9.2929Z" fill="#00C875"/>
|
|
16
|
-
</svg>`,
|
|
17
|
-
warning: `<svg width="20" height="21" viewBox="0 0 20 21" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
18
|
-
<path fillRule="evenodd" clipRule="evenodd" d="M14.7736 2.56003C14.4236 3.00003 14.5036 3.63003 14.9336 3.97003C16.6136 5.29003 17.6836 7.18003 17.9336 9.31003C18.1936 11.43 17.6036 13.53 16.2836 15.21L16.2736 15.23C14.9536 16.9 13.0636 17.96 10.9536 18.21C8.83361 18.46 6.73361 17.88 5.05361 16.56C3.37361 15.24 2.30361 13.34 2.05361 11.22C1.79361 9.09003 2.38361 7.00003 3.70361 5.32003C4.10361 4.84003 4.55361 4.36003 5.06361 3.96003C5.49361 3.62003 5.57361 2.99003 5.23361 2.56003C4.89361 2.13003 4.26361 2.05003 3.83361 2.39003C3.19361 2.88003 2.63361 3.47003 2.13361 4.08003C0.48361 6.18003 -0.246391 8.80003 0.0736095 11.45C0.393609 14.1 1.72361 16.47 3.82361 18.12C5.92361 19.77 8.54361 20.5 11.1936 20.18C13.8336 19.86 16.1936 18.54 17.8436 16.45L17.8636 16.43C19.5136 14.33 20.2436 11.71 19.9236 9.06003C19.6036 6.41003 18.2736 4.04003 16.1736 2.39003C15.7436 2.05003 15.1136 2.13003 14.7736 2.56003Z" fill="#FFAA00"/>
|
|
19
|
-
<path d="M12.0835 15.01C12.0535 16.17 11.0935 17.08 9.9335 17.05C8.8235 17.02 7.9235 16.13 7.8935 15.01V14.96C7.9235 13.8 8.8835 12.89 10.0435 12.92C11.1535 12.95 12.0535 13.84 12.0835 14.96V15.01ZM12.1335 1.23L11.0935 10.27C11.0935 10.88 10.6035 11.37 9.9935 11.37C9.3835 11.37 8.8935 10.88 8.8935 10.27L7.8535 1.23C7.7235 0.69 8.0535 0.16 8.5935 0.03C8.6735 0.01 8.7435 0 8.8135 0H11.1635C11.7235 0.01 12.1635 0.47 12.1535 1.02C12.1635 1.09 12.1535 1.16 12.1335 1.23Z" fill="#FFAA00"/>
|
|
20
|
-
</svg>`,
|
|
21
|
-
none: `<svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
22
|
-
<path fillRule="evenodd" clipRule="evenodd" d="M2 10C2 8.154 2.635 6.458 3.688 5.103L14.897 16.312C13.542 17.366 11.846 18 10 18C5.589 18 2 14.411 2 10ZM18 10C18 11.846 17.365 13.542 16.312 14.897L5.103 3.688C6.458 2.634 8.154 2 10 2C14.411 2 18 5.589 18 10ZM10 0C4.486 0 0 4.486 0 10C0 15.514 4.486 20 10 20C15.514 20 20 15.514 20 10C20 4.486 15.514 0 10 0Z" fill="#FF3D71"/>
|
|
23
|
-
</svg>`,
|
|
24
|
-
danger: `<svg width="16" height="22" style="max-height:20px" viewBox="0 0 16 22" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
25
|
-
<path fillRule="evenodd" clipRule="evenodd" d="M7.11087 22.0002C6.99687 22.0002 6.88187 21.9802 6.76887 21.9392C6.33687 21.7822 6.06687 21.3502 6.11687 20.8932L6.88487 13.8002H0.999871C0.630871 13.8002 0.291871 13.5972 0.117871 13.2712C-0.056129 12.9452 -0.036129 12.5512 0.168871 12.2442L8.05687 0.444182C8.31287 0.0611818 8.79687 -0.0978183 9.22987 0.0611817C9.66287 0.218182 9.93187 0.650182 9.88187 1.10718L9.11387 8.20018H14.9999C15.3689 8.20018 15.7079 8.40318 15.8819 8.72918C16.0549 9.05518 16.0359 9.44918 15.8309 9.75618L7.94187 21.5562C7.75287 21.8402 7.43687 22.0002 7.11087 22.0002Z" fill="#FF3D71"/>
|
|
26
|
-
</svg>`
|
|
27
|
-
};
|
|
28
10
|
const TextInput = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
loading,
|
|
33
|
-
autoIncreaseBot,
|
|
11
|
+
autoComplete,
|
|
12
|
+
autoFocus,
|
|
13
|
+
autoWidth,
|
|
34
14
|
className,
|
|
35
|
-
label,
|
|
36
15
|
defaultValue,
|
|
37
|
-
|
|
38
|
-
placeholder,
|
|
39
|
-
startIcon,
|
|
16
|
+
disabled,
|
|
40
17
|
endIcon,
|
|
41
|
-
startIconProps,
|
|
42
18
|
endIconProps,
|
|
43
|
-
|
|
19
|
+
error,
|
|
20
|
+
helperTextProps,
|
|
44
21
|
icon,
|
|
45
|
-
autoComplete,
|
|
46
|
-
autoFocus,
|
|
47
|
-
disabled,
|
|
48
|
-
readOnly,
|
|
49
|
-
multiline,
|
|
50
|
-
onConfirm,
|
|
51
|
-
refs,
|
|
52
|
-
rows,
|
|
53
|
-
maxRows,
|
|
54
|
-
style,
|
|
55
22
|
iconStyle,
|
|
56
|
-
inputRef,
|
|
57
23
|
inputProps,
|
|
24
|
+
inputRef,
|
|
58
25
|
inputStyle,
|
|
26
|
+
label,
|
|
59
27
|
labelProps,
|
|
60
|
-
|
|
61
|
-
|
|
28
|
+
loading,
|
|
29
|
+
maxRows,
|
|
30
|
+
multiline,
|
|
62
31
|
onBlur,
|
|
32
|
+
onChange,
|
|
33
|
+
onConfirm,
|
|
63
34
|
onFocus,
|
|
64
35
|
onInput,
|
|
65
36
|
onKeyDown,
|
|
66
37
|
onKeyUp,
|
|
67
38
|
onPaste,
|
|
39
|
+
placeholder,
|
|
40
|
+
readOnly,
|
|
41
|
+
required,
|
|
42
|
+
rows,
|
|
43
|
+
startIcon,
|
|
44
|
+
startIconProps,
|
|
45
|
+
status,
|
|
46
|
+
style,
|
|
47
|
+
type,
|
|
68
48
|
validates,
|
|
69
|
-
|
|
70
|
-
|
|
49
|
+
value: valueProp,
|
|
50
|
+
viewType,
|
|
71
51
|
...props
|
|
72
52
|
}, reference) => {
|
|
73
53
|
const ref = useRef(null);
|
|
@@ -80,39 +60,9 @@ const TextInput = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
80
60
|
let currentValue = '';
|
|
81
61
|
const [value, setValue] = useState(valueProp || defaultValue);
|
|
82
62
|
const isError = !!error;
|
|
83
|
-
/* Start styled */
|
|
84
|
-
|
|
85
|
-
const TextInputRoot = css`
|
|
86
|
-
${displayBlock};
|
|
87
|
-
${positionRelative};
|
|
88
|
-
margin-bottom: 20px;
|
|
89
|
-
&.disabled {
|
|
90
|
-
${cursorNotAllowed};
|
|
91
|
-
}
|
|
92
|
-
`;
|
|
93
|
-
const TextInputIcon = css`
|
|
94
|
-
${flexRow};
|
|
95
|
-
color: inherit;
|
|
96
|
-
.edit-icon-pen {
|
|
97
|
-
${flexRow};
|
|
98
|
-
}
|
|
99
|
-
.edit-icon-confirm {
|
|
100
|
-
display: none;
|
|
101
|
-
}
|
|
102
|
-
.edit-icon-clear {
|
|
103
|
-
display: none;
|
|
104
|
-
margin-left: 12px;
|
|
105
|
-
}
|
|
106
|
-
.circular {
|
|
107
|
-
display: none;
|
|
108
|
-
}
|
|
109
|
-
`;
|
|
110
|
-
/* End styled */
|
|
111
|
-
|
|
112
63
|
/* Start handler */
|
|
113
64
|
|
|
114
65
|
const onMouseDownHandler = () => {
|
|
115
|
-
// ref.current.querySelector(`.css-${TextInputBox.name}`).style.backgroundColor = 'transparent';
|
|
116
66
|
inputRef.current.style.backgroundColor = 'transparent';
|
|
117
67
|
};
|
|
118
68
|
|
|
@@ -185,7 +135,6 @@ const TextInput = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
185
135
|
setValue(valueProp);
|
|
186
136
|
}, [valueProp]);
|
|
187
137
|
useEffect(() => {
|
|
188
|
-
!!refs && refs(ref);
|
|
189
138
|
currentValue = defaultValue || '';
|
|
190
139
|
}, []);
|
|
191
140
|
useEffect(() => {
|
|
@@ -207,49 +156,6 @@ const TextInput = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
207
156
|
}
|
|
208
157
|
};
|
|
209
158
|
}, [type, multiline]);
|
|
210
|
-
useEffect(() => {
|
|
211
|
-
if (/inform/i.test(type) && !multiline) {
|
|
212
|
-
const regexp = /(success)|(warning)|(danger)/gi;
|
|
213
|
-
const existedClass = ref.current.classList.value.match(regexp);
|
|
214
|
-
|
|
215
|
-
if (existedClass) {
|
|
216
|
-
ref.current.classList.remove(existedClass[0]);
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
ref.current.classList.add(status);
|
|
220
|
-
|
|
221
|
-
if (!icon) {
|
|
222
|
-
iconRef.current.innerHTML = icons[status];
|
|
223
|
-
}
|
|
224
|
-
}
|
|
225
|
-
}, [status]);
|
|
226
|
-
useEffect(() => {
|
|
227
|
-
if (error && !value && value !== 0) {
|
|
228
|
-
ref.current.classList.add('danger');
|
|
229
|
-
|
|
230
|
-
if (autoIncreaseBot) {
|
|
231
|
-
const helperTextNode = ref.current.querySelector('.DGN-UI-HelperText');
|
|
232
|
-
|
|
233
|
-
if (helperTextNode) {
|
|
234
|
-
if (helperTextNode.offsetHeight > 20) {
|
|
235
|
-
ref.current.style.marginBottom = helperTextNode.offsetHeight + 4 + 'px';
|
|
236
|
-
}
|
|
237
|
-
}
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
return () => {
|
|
241
|
-
if (ref.current) {
|
|
242
|
-
ref.current.classList.remove('danger');
|
|
243
|
-
ref.current.style.marginBottom = null;
|
|
244
|
-
}
|
|
245
|
-
};
|
|
246
|
-
}
|
|
247
|
-
}, [error, value]);
|
|
248
|
-
useEffect(() => {
|
|
249
|
-
if (placeholder !== undefined && inputRef.current) {
|
|
250
|
-
inputRef.current.placeholder = placeholder;
|
|
251
|
-
}
|
|
252
|
-
}, [placeholder]);
|
|
253
159
|
useEffect(() => {
|
|
254
160
|
if (!inputRef.current) return;
|
|
255
161
|
inputRef.current.readOnly = !!readOnly;
|
|
@@ -290,7 +196,10 @@ const TextInput = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
290
196
|
}, [loading]);
|
|
291
197
|
/* End handler */
|
|
292
198
|
|
|
293
|
-
useImperativeHandle(reference, () =>
|
|
199
|
+
useImperativeHandle(reference, () => ({
|
|
200
|
+
element: ref.current,
|
|
201
|
+
instance: {}
|
|
202
|
+
}));
|
|
294
203
|
const validateResult = validates && onValidate(value, validates, true);
|
|
295
204
|
const startIconCustom = icon && type !== 'inform' ? icon : startIcon;
|
|
296
205
|
const endIconCustom = /^inform$/i.test(type) ? jsx("div", {
|
|
@@ -353,7 +262,7 @@ const TextInput = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
353
262
|
autoWidth: autoWidth,
|
|
354
263
|
rows: rows,
|
|
355
264
|
maxRows: maxRows,
|
|
356
|
-
status: isError || validateResult ? 'danger' :
|
|
265
|
+
status: isError || validateResult ? 'danger' : status,
|
|
357
266
|
inputProps: inputProps,
|
|
358
267
|
inputStyle: inputStyle,
|
|
359
268
|
startIcon: startIconCustom,
|
|
@@ -375,145 +284,163 @@ const TextInput = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
375
284
|
disabled: disabled
|
|
376
285
|
}, validateResult));
|
|
377
286
|
}));
|
|
287
|
+
const TextInputRoot = css`
|
|
288
|
+
${displayBlock};
|
|
289
|
+
${positionRelative};
|
|
290
|
+
margin-bottom: 20px;
|
|
291
|
+
&.disabled {
|
|
292
|
+
${cursorNotAllowed};
|
|
293
|
+
}
|
|
294
|
+
`;
|
|
295
|
+
const TextInputIcon = css`
|
|
296
|
+
${flexRow};
|
|
297
|
+
color: inherit;
|
|
298
|
+
.edit-icon-pen {
|
|
299
|
+
${flexRow};
|
|
300
|
+
}
|
|
301
|
+
.edit-icon-confirm {
|
|
302
|
+
display: none;
|
|
303
|
+
}
|
|
304
|
+
.edit-icon-clear {
|
|
305
|
+
display: none;
|
|
306
|
+
margin-left: 12px;
|
|
307
|
+
}
|
|
308
|
+
.circular {
|
|
309
|
+
display: none;
|
|
310
|
+
}
|
|
311
|
+
`;
|
|
378
312
|
TextInput.defaultProps = {
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
313
|
+
autoComplete: 'off',
|
|
314
|
+
autoFocus: false,
|
|
315
|
+
autoWidth: false,
|
|
382
316
|
className: '',
|
|
383
317
|
defaultValue: '',
|
|
384
|
-
|
|
318
|
+
disabled: false,
|
|
385
319
|
error: '',
|
|
386
|
-
|
|
387
|
-
|
|
320
|
+
iconStyle: {},
|
|
321
|
+
label: '',
|
|
388
322
|
loading: false,
|
|
389
|
-
autoFocus: false,
|
|
390
|
-
autoIncreaseBot: false,
|
|
391
|
-
disabled: false,
|
|
392
|
-
readOnly: false,
|
|
393
323
|
multiline: false,
|
|
394
|
-
|
|
395
|
-
|
|
324
|
+
readOnly: false,
|
|
325
|
+
required: false,
|
|
326
|
+
status: 'default',
|
|
327
|
+
type: 'text',
|
|
328
|
+
viewType: 'underlined'
|
|
396
329
|
};
|
|
397
330
|
TextInput.propTypes = {
|
|
398
|
-
/**
|
|
399
|
-
|
|
331
|
+
/** This prop helps users to fill forms faster, especially on mobile devices. The name can be confusing, as it's more like an autofill. You can learn more about it [following the specification](https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#autofill). */
|
|
332
|
+
autoComplete: PropTypes.string,
|
|
400
333
|
|
|
401
|
-
/** the
|
|
402
|
-
|
|
334
|
+
/** If `true`, the input element is focused during the first mount. */
|
|
335
|
+
autoFocus: PropTypes.bool,
|
|
403
336
|
|
|
404
|
-
/**
|
|
405
|
-
|
|
337
|
+
/** If `true`, the width of the component will automatically be set according to the contents inside the input, don't run with multiline = true */
|
|
338
|
+
autoWidth: PropTypes.bool,
|
|
406
339
|
|
|
407
|
-
/**
|
|
340
|
+
/** Class for component. */
|
|
408
341
|
className: PropTypes.string,
|
|
409
342
|
|
|
410
|
-
/** default value
|
|
343
|
+
/** The default value. Use when the component is not controlled. */
|
|
411
344
|
defaultValue: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
412
345
|
|
|
413
|
-
/**
|
|
414
|
-
|
|
346
|
+
/** If `true`, the component is disabled.*/
|
|
347
|
+
disabled: PropTypes.bool,
|
|
415
348
|
|
|
416
|
-
/**
|
|
417
|
-
|
|
349
|
+
/** [Icon](https://core.diginet.com.vn/ui/?path=/story/icon-basic--basic) or element placed to the right of input. */
|
|
350
|
+
endIcon: PropTypes.any,
|
|
418
351
|
|
|
419
|
-
/**
|
|
420
|
-
|
|
352
|
+
/** Props of end icon in InputBase component. */
|
|
353
|
+
endIconProps: PropTypes.object,
|
|
421
354
|
|
|
422
|
-
/**
|
|
355
|
+
/** Error displayed below input. */
|
|
423
356
|
error: PropTypes.oneOfType([PropTypes.bool, PropTypes.string]),
|
|
424
357
|
|
|
425
|
-
/**
|
|
426
|
-
|
|
358
|
+
/** [Props](https://core.diginet.com.vn/ui/?path=/story/form-control-text-helpertext) of helper text. */
|
|
359
|
+
helperTextProps: PropTypes.object,
|
|
427
360
|
|
|
428
|
-
/** the
|
|
429
|
-
|
|
361
|
+
/** Icon element display in the end of input (only use for type is inform, if not, use startIcon instead). */
|
|
362
|
+
icon: PropTypes.any,
|
|
430
363
|
|
|
431
|
-
/**
|
|
432
|
-
|
|
364
|
+
/** Style inline of icon. */
|
|
365
|
+
iconStyle: PropTypes.object,
|
|
433
366
|
|
|
434
|
-
/**
|
|
435
|
-
|
|
367
|
+
/** [Attributes](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#attributes) applied to the input element. */
|
|
368
|
+
inputProps: PropTypes.object,
|
|
436
369
|
|
|
437
|
-
/**
|
|
438
|
-
|
|
370
|
+
/** Pass a ref to the input element. */
|
|
371
|
+
inputRef: ref,
|
|
439
372
|
|
|
440
|
-
/**
|
|
441
|
-
|
|
373
|
+
/** Style inline of input element. */
|
|
374
|
+
inputStyle: PropTypes.object,
|
|
442
375
|
|
|
443
|
-
/**
|
|
444
|
-
|
|
376
|
+
/** The label of the component. */
|
|
377
|
+
label: PropTypes.oneOfType([PropTypes.string, PropTypes.node]),
|
|
445
378
|
|
|
446
|
-
/**
|
|
447
|
-
|
|
379
|
+
/** [Props](https://core.diginet.com.vn/ui/?path=/docs/form-control-text-label--simple) of label. */
|
|
380
|
+
labelProps: PropTypes.object,
|
|
448
381
|
|
|
449
|
-
/**
|
|
450
|
-
|
|
382
|
+
/** Maximum number of rows to display when multiline option is set to true. */
|
|
383
|
+
maxRows: PropTypes.number,
|
|
451
384
|
|
|
452
|
-
/**
|
|
453
|
-
|
|
385
|
+
/** If `true`, a textarea element is rendered. */
|
|
386
|
+
multiline: PropTypes.bool,
|
|
454
387
|
|
|
455
|
-
/**
|
|
456
|
-
|
|
388
|
+
/** Callback fired when the input is blurred. */
|
|
389
|
+
onBlur: PropTypes.func,
|
|
457
390
|
|
|
458
|
-
/**
|
|
459
|
-
|
|
391
|
+
/** Callback fired when the value is changed. */
|
|
392
|
+
onChange: PropTypes.func,
|
|
460
393
|
|
|
461
|
-
/**
|
|
462
|
-
|
|
394
|
+
/** Callback fired when the input is focused. */
|
|
395
|
+
onFocus: PropTypes.func,
|
|
463
396
|
|
|
464
|
-
/**
|
|
465
|
-
|
|
397
|
+
/** Callback fired when input. */
|
|
398
|
+
onInput: PropTypes.func,
|
|
466
399
|
|
|
467
|
-
/**
|
|
468
|
-
|
|
400
|
+
/** Callback fired when pressing a key. */
|
|
401
|
+
onKeyDown: PropTypes.func,
|
|
469
402
|
|
|
470
|
-
/**
|
|
471
|
-
|
|
403
|
+
/** Callback fired when releases a key. */
|
|
404
|
+
onKeyUp: PropTypes.func,
|
|
472
405
|
|
|
473
|
-
/**
|
|
474
|
-
|
|
406
|
+
/** The short hint displayed in the input before the user enters a value. */
|
|
407
|
+
placeholder: PropTypes.string,
|
|
475
408
|
|
|
476
|
-
/**
|
|
477
|
-
|
|
409
|
+
/** If `true`, the component is readOnly. */
|
|
410
|
+
readOnly: PropTypes.bool,
|
|
478
411
|
|
|
479
|
-
/**
|
|
480
|
-
|
|
412
|
+
/** If `true`, the input element is required. */
|
|
413
|
+
required: PropTypes.bool,
|
|
481
414
|
|
|
482
|
-
/**
|
|
483
|
-
|
|
415
|
+
/** Number of rows to display when multiline option is set to true. */
|
|
416
|
+
rows: PropTypes.number,
|
|
484
417
|
|
|
485
|
-
/**
|
|
486
|
-
|
|
418
|
+
/** [Icon](https://core.diginet.com.vn/ui/?path=/story/icon-basic--basic) or element placed to the left of input. */
|
|
419
|
+
startIcon: PropTypes.oneOfType([PropTypes.string, PropTypes.node]),
|
|
487
420
|
|
|
488
|
-
/**
|
|
489
|
-
|
|
421
|
+
/** Props of start icon in InputBase component. */
|
|
422
|
+
startIconProps: PropTypes.object,
|
|
490
423
|
|
|
491
|
-
/**
|
|
492
|
-
|
|
424
|
+
/** Status type to display color for input. */
|
|
425
|
+
status: PropTypes.oneOf(['default', 'warning', 'success', 'danger']),
|
|
493
426
|
|
|
494
|
-
/**
|
|
495
|
-
|
|
427
|
+
/** Style inline of component. */
|
|
428
|
+
style: PropTypes.object,
|
|
496
429
|
|
|
497
|
-
/**
|
|
498
|
-
|
|
430
|
+
/** Type of the input element. It should be [a valid HTML5 input type](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#Form_%3Cinput%3E_types). */
|
|
431
|
+
type: PropTypes.oneOf(['inform', 'edit', 'quickEdit', 'text', 'number', 'password']),
|
|
499
432
|
|
|
500
|
-
/**
|
|
501
|
-
* * string: the validation rule. Example required.<br/>
|
|
502
|
-
* * object: the validation rule insist name, property, message. Example {name: 'min', compareValue: 9, message: 'Error'} or {max: 99}<br/>
|
|
503
|
-
* * array: the validation rule list, insist object/string
|
|
433
|
+
/** Validation value, argument can:<br/>
|
|
434
|
+
* * string: the validation rule. Example required.<br/>
|
|
435
|
+
* * object: the validation rule insist name, property, message. Example {name: 'min', compareValue: 9, message: 'Error'} or {max: 99}<br/>
|
|
436
|
+
* * array: the validation rule list, insist object/string
|
|
504
437
|
*/
|
|
505
438
|
validates: PropTypes.oneOfType([PropTypes.string, PropTypes.object, PropTypes.array, PropTypes.func]),
|
|
506
439
|
|
|
507
|
-
/**
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
/** autoWidth of TextInput component, don't run with multiline = true */
|
|
511
|
-
autoWidth: PropTypes.bool,
|
|
512
|
-
|
|
513
|
-
/** If `true`, a textarea element is rendered. */
|
|
514
|
-
multiline: PropTypes.bool,
|
|
440
|
+
/** The value of the input element, required for a controlled component. */
|
|
441
|
+
value: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
515
442
|
|
|
516
|
-
/**
|
|
517
|
-
|
|
443
|
+
/** The variant to use. */
|
|
444
|
+
viewType: PropTypes.oneOf(['underlined', 'outlined'])
|
|
518
445
|
};
|
|
519
446
|
export default TextInput;
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
/** @jsx jsx */
|
|
4
4
|
import { css, jsx } from '@emotion/core';
|
|
5
5
|
import PropTypes from 'prop-types';
|
|
6
|
-
import
|
|
6
|
+
import { forwardRef, memo, useEffect, useMemo, useRef, useState, Fragment } from 'react';
|
|
7
7
|
import theme from '../../../theme/settings';
|
|
8
8
|
import generateRandom from '../../../utils/randomString';
|
|
9
9
|
import Typography from '../../typography';
|
|
@@ -184,7 +184,7 @@ const Toggle = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
184
184
|
hoverTooltip: hoverTooltip,
|
|
185
185
|
lineClamp: lineClamp || null,
|
|
186
186
|
mapping: 'label'
|
|
187
|
-
}, jsx(
|
|
187
|
+
}, jsx(Fragment, null, label, required && jsx("span", {
|
|
188
188
|
style: {
|
|
189
189
|
color: disabled ? clDisabled : clDanger
|
|
190
190
|
}
|
package/components/grid/index.js
CHANGED
|
@@ -38,8 +38,8 @@ const Grid = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
38
38
|
const rowSpacing = rowSpacingProp || spacing;
|
|
39
39
|
const columnSpacing = columnSpacingProp || spacing;
|
|
40
40
|
const columns = container ? columnsProp : columnsContext;
|
|
41
|
-
const topSpacing = topSpacingProp
|
|
42
|
-
const leftSpacing = leftSpacingProp
|
|
41
|
+
const topSpacing = topSpacingProp !== null && topSpacingProp !== void 0 ? topSpacingProp : rowSpacing;
|
|
42
|
+
const leftSpacing = leftSpacingProp !== null && leftSpacingProp !== void 0 ? leftSpacingProp : columnSpacing;
|
|
43
43
|
const ref = useRef(null);
|
|
44
44
|
|
|
45
45
|
const _GridCSS = GridCSS(direction, zeroMinWidth, container, item, wrap);
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Button, Typography, Notify as AlertNotify } from '../..';
|
|
3
|
+
import PropTypes from 'prop-types';
|
|
4
|
+
|
|
5
|
+
const ImportComp = ({
|
|
6
|
+
components,
|
|
7
|
+
from = 'components',
|
|
8
|
+
importDefault = false
|
|
9
|
+
}) => {
|
|
10
|
+
let text = Array.isArray(components) ? components.join(', ') : components;
|
|
11
|
+
|
|
12
|
+
if (!importDefault) {
|
|
13
|
+
text = `{ ${text} }`;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const importText = `import ${text} from 'diginet-core-ui/${from}';`;
|
|
17
|
+
let Notify = null;
|
|
18
|
+
|
|
19
|
+
const onCopyImport = () => {
|
|
20
|
+
if (!components) {
|
|
21
|
+
Notify(`Không có components để copy`, {
|
|
22
|
+
color: 'warning'
|
|
23
|
+
});
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const el = document.createElement('input');
|
|
28
|
+
el.value = importText;
|
|
29
|
+
document.body.appendChild(el);
|
|
30
|
+
el.select();
|
|
31
|
+
document.execCommand('copy');
|
|
32
|
+
document.body.removeChild(el);
|
|
33
|
+
Notify(`Đã copy ${text} from ${from}`);
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
return components ? /*#__PURE__*/React.createElement("div", {
|
|
37
|
+
style: {
|
|
38
|
+
display: 'flex',
|
|
39
|
+
position: 'sticky',
|
|
40
|
+
justifyContent: 'flex-end',
|
|
41
|
+
alignItems: 'center',
|
|
42
|
+
top: 0,
|
|
43
|
+
textAlign: 'right'
|
|
44
|
+
}
|
|
45
|
+
}, /*#__PURE__*/React.createElement(Typography, {
|
|
46
|
+
type: 'h3',
|
|
47
|
+
color: 'primary',
|
|
48
|
+
style: {
|
|
49
|
+
fontSize: 14
|
|
50
|
+
}
|
|
51
|
+
}, importText), /*#__PURE__*/React.createElement(Button, {
|
|
52
|
+
onClick: onCopyImport,
|
|
53
|
+
text: 'Copy',
|
|
54
|
+
viewType: 'filled',
|
|
55
|
+
color: 'info',
|
|
56
|
+
size: 'tiny'
|
|
57
|
+
}), /*#__PURE__*/React.createElement(AlertNotify, {
|
|
58
|
+
getAddNotify: func => Notify = func,
|
|
59
|
+
progressing: true,
|
|
60
|
+
autoDisappear: true,
|
|
61
|
+
maxWidth: '500px',
|
|
62
|
+
color: 'success'
|
|
63
|
+
})) : /*#__PURE__*/React.createElement(Typography, {
|
|
64
|
+
type: 'h1',
|
|
65
|
+
color: 'danger',
|
|
66
|
+
center: true
|
|
67
|
+
}, "DEVELOPING", ' ', /*#__PURE__*/React.createElement(Typography, {
|
|
68
|
+
type: 'h3',
|
|
69
|
+
color: 'warning'
|
|
70
|
+
}, "(Khoan h\u1EB5n d\xF9ng)"));
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
ImportComp.propTypes = {
|
|
74
|
+
components: PropTypes.string,
|
|
75
|
+
from: PropTypes.string,
|
|
76
|
+
importDefault: PropTypes.bool
|
|
77
|
+
};
|
|
78
|
+
export default ImportComp;
|
|
@@ -57,6 +57,7 @@ const Tooltip = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
57
57
|
backgroundColor,
|
|
58
58
|
children,
|
|
59
59
|
color,
|
|
60
|
+
disableInteractive,
|
|
60
61
|
direction,
|
|
61
62
|
distance,
|
|
62
63
|
size,
|
|
@@ -462,7 +463,8 @@ const Tooltip = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
462
463
|
const renderTooltip = useMemo(() => {
|
|
463
464
|
if (open && title) {
|
|
464
465
|
const node = jsx("div", {
|
|
465
|
-
className: 'DGN-UI-Portal DGN-Tooltip'
|
|
466
|
+
className: 'DGN-UI-Portal DGN-Tooltip',
|
|
467
|
+
onMouseEnter: () => disableInteractive ? onHideTooltip() : null
|
|
466
468
|
}, jsx("span", {
|
|
467
469
|
className: IDs.arrow,
|
|
468
470
|
css: ArrowCSS,
|
|
@@ -480,7 +482,7 @@ const Tooltip = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
480
482
|
}
|
|
481
483
|
|
|
482
484
|
return null;
|
|
483
|
-
}, [open, title, backgroundColor, color, size, padding, textAlign]);
|
|
485
|
+
}, [open, title, backgroundColor, color, size, padding, textAlign, disableInteractive]);
|
|
484
486
|
return jsx(TagCreatedName, {
|
|
485
487
|
ref: ref,
|
|
486
488
|
css: ContainerCSS,
|
|
@@ -533,6 +535,7 @@ Tooltip.defaultProps = {
|
|
|
533
535
|
arrowSize: 6,
|
|
534
536
|
backgroundColor: fillTooltip,
|
|
535
537
|
color: white,
|
|
538
|
+
disableInteractive: false,
|
|
536
539
|
direction: 'down',
|
|
537
540
|
size: 'medium',
|
|
538
541
|
forceDirection: false,
|
|
@@ -573,6 +576,9 @@ Tooltip.propTypes = {
|
|
|
573
576
|
/** If `true`, the component is disabled. */
|
|
574
577
|
disabled: PropTypes.bool,
|
|
575
578
|
|
|
579
|
+
/** If `true`, makes a tooltip not interactive, i.e. it will close when the user hovers over the tooltip. */
|
|
580
|
+
disableInteractive: PropTypes.bool,
|
|
581
|
+
|
|
576
582
|
/** Distance between the tooltip and the children. */
|
|
577
583
|
distance: PropTypes.number,
|
|
578
584
|
|