diginet-core-ui 1.3.66 → 1.3.68
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/assets/storybook/avatar01.svg +9 -0
- package/assets/storybook/cover01.svg +9 -0
- package/components/accordion/css.js +6 -6
- package/components/accordion/details.js +13 -18
- package/components/accordion/group.js +16 -17
- package/components/accordion/index.js +17 -22
- package/components/accordion/summary.js +55 -32
- package/components/avatar/index.js +4 -9
- package/components/badge/index.js +4 -9
- package/components/button/icon.js +4 -9
- package/components/button/index.js +287 -292
- package/components/card/body.js +47 -0
- package/components/card/extra.js +47 -0
- package/components/card/footer.js +47 -0
- package/components/card/header.js +50 -0
- package/components/card/index.js +175 -37
- package/components/chart/Pie-v2/Sector.js +2 -2
- package/components/chip/attach.js +5 -5
- package/components/form-control/attachment/index.js +5 -3
- package/components/form-control/calendar/function.js +20 -10
- package/components/form-control/calendar/index.js +16 -16
- package/components/form-control/dropdown/index.js +71 -10
- package/components/form-control/helper-text/index.js +8 -3
- package/components/form-control/input-base/index.js +47 -10
- package/components/form-control/money-input/index.js +6 -2
- package/components/form-control/number-input/index.js +11 -11
- package/components/form-control/number-input/index2.js +13 -4
- package/components/form-control/phone-input/index.js +13 -9
- package/components/form-control/text-input/index.js +13 -3
- package/components/grid/Container.js +110 -0
- package/components/grid/Row.js +1 -1
- package/components/grid/index.js +35 -5
- package/components/index.js +7 -2
- package/components/others/option-wrapper/index.js +21 -27
- package/components/paging/page-info.js +263 -88
- package/components/paging/page-selector2.js +95 -56
- package/components/popover/index.js +8 -6
- package/components/progress/circular.js +12 -12
- package/components/transfer/index.js +3 -3
- package/components/tree-view/index.js +10 -6
- package/icons/basic.js +120 -0
- package/icons/effect.js +19 -24
- package/package.json +1 -1
- package/readme.md +20 -0
- package/styles/color-helper.js +103 -103
- package/styles/utils.js +14 -2
- package/utils/classNames.js +30 -0
- package/utils/error/error.js +2 -2
- package/utils/index.js +1 -0
- package/utils/renderIcon.js +5 -5
- package/utils/useInput.js +1 -8
- package/components/card/body-card.js +0 -65
- package/components/card/card.js +0 -125
- package/components/card/context.js +0 -6
|
@@ -101,9 +101,12 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
101
101
|
labelProps,
|
|
102
102
|
errorStyle,
|
|
103
103
|
children,
|
|
104
|
-
dropdownItemStyle
|
|
104
|
+
dropdownItemStyle,
|
|
105
|
+
searchExpr,
|
|
106
|
+
searchMode
|
|
105
107
|
}, reference) => {
|
|
106
108
|
if (multiple && selectBox === undefined) selectBox = true;
|
|
109
|
+
if (typeof searchExpr === 'string') searchExpr = [searchExpr];
|
|
107
110
|
const ref = useRef(null);
|
|
108
111
|
const dropdownRef = useRef(null);
|
|
109
112
|
const loadingProgressRef = useRef(null);
|
|
@@ -122,6 +125,7 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
122
125
|
}));
|
|
123
126
|
const [openState, setOpenState] = useState(false);
|
|
124
127
|
const [showClear, setShowClear] = useState(false);
|
|
128
|
+
const [textValue, setTextValue] = useState('');
|
|
125
129
|
|
|
126
130
|
const _isMobile = isMobile.any();
|
|
127
131
|
|
|
@@ -169,6 +173,8 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
169
173
|
};
|
|
170
174
|
|
|
171
175
|
const onClickInput = e => {
|
|
176
|
+
if (disabled || readOnly || loading) return;
|
|
177
|
+
|
|
172
178
|
if (!dropdownListRef.current) {
|
|
173
179
|
if (!multiple || !Array.from(inputRef.current.querySelectorAll('.DGN-UI-Chip')).some(item => item.contains(e === null || e === void 0 ? void 0 : e.target))) {
|
|
174
180
|
if ((typeof renderSelectedItem === 'function' || iconExpr && iconExpr !== 'none') && !multiple) {
|
|
@@ -231,7 +237,7 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
231
237
|
const dropdownHeight = Math.min(Math.max(1, (itemMode === 'normal' ? dropdown.props.children : mapParent(dataSource, treeViewID, treeViewParentID)).length || 1), 7) * 40 + (multiple ? 43 : 0);
|
|
232
238
|
let positionTop = top + height + 4;
|
|
233
239
|
|
|
234
|
-
if (top + height + 4 + dropdownHeight > innerHeight) {
|
|
240
|
+
if (top + height + 4 + dropdownHeight + (allowSearch ? 40 : 0) > innerHeight) {
|
|
235
241
|
if (top - dropdownHeight > 0) {
|
|
236
242
|
positionTop = top - dropdownHeight;
|
|
237
243
|
} else {
|
|
@@ -387,6 +393,29 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
387
393
|
}
|
|
388
394
|
};
|
|
389
395
|
|
|
396
|
+
const handleRenderBySearch = (data, searchValue) => {
|
|
397
|
+
let existExpr = [];
|
|
398
|
+
typeof data === 'object' ? existExpr = searchExpr.filter(value => Object.keys(data).includes(value)) : existExpr = [data];
|
|
399
|
+
return existExpr.every(key => {
|
|
400
|
+
// return searchByMode(data?.[key] || key.toString(), searchValue);
|
|
401
|
+
const _data = (data === null || data === void 0 ? void 0 : data[key]) || key.toString();
|
|
402
|
+
|
|
403
|
+
if (searchMode === 'contains') {
|
|
404
|
+
if (_data.indexOf(searchValue) !== -1) return false;
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
if (searchMode === 'startswith') {
|
|
408
|
+
if (_data.lastIndexOf(searchValue) === 0) return false;
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
if (searchMode === 'equals') {
|
|
412
|
+
if (_data == searchValue) return false;
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
return true;
|
|
416
|
+
});
|
|
417
|
+
};
|
|
418
|
+
|
|
390
419
|
const mapDropdown = (pattern, keyArr) => {
|
|
391
420
|
var _currentObjectDefault;
|
|
392
421
|
|
|
@@ -414,9 +443,16 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
414
443
|
const length = dataSourceUsable.length;
|
|
415
444
|
|
|
416
445
|
for (let index = 0; index < length; index++) {
|
|
446
|
+
var _searchExpr;
|
|
447
|
+
|
|
417
448
|
const data = dataSourceUsable[index];
|
|
449
|
+
const itemHidden = typeof data === 'object' ? data['hidden'] : false;
|
|
450
|
+
if (itemHidden) continue;
|
|
418
451
|
let displayText = typeof data === 'object' ? keyArr ? renderData(data, keyArr) : data[displayExpr] || data[valueExpr] : data;
|
|
419
|
-
|
|
452
|
+
|
|
453
|
+
if (((_searchExpr = searchExpr) === null || _searchExpr === void 0 ? void 0 : _searchExpr.length) > 0 && pattern) {
|
|
454
|
+
if (handleRenderBySearch(data, pattern)) continue;
|
|
455
|
+
} else if (pattern && !new RegExp(pattern).test(displayText.normalize())) continue;
|
|
420
456
|
|
|
421
457
|
if (renderItem && typeof renderItem === 'function') {
|
|
422
458
|
displayText = renderItem({
|
|
@@ -785,11 +821,13 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
785
821
|
|
|
786
822
|
if (timing[unique]) clearTimeout(timing[unique]);
|
|
787
823
|
timing[unique] = setTimeout(() => {
|
|
824
|
+
var _searchExpr2;
|
|
825
|
+
|
|
788
826
|
// if (timerRef.current) {
|
|
789
827
|
// clearTimeout(timerRef.current);
|
|
790
828
|
// timerRef.current = null;
|
|
791
829
|
// }
|
|
792
|
-
renderDropdown(new RegExp(value.normalize(), 'gim'));
|
|
830
|
+
renderDropdown(((_searchExpr2 = searchExpr) === null || _searchExpr2 === void 0 ? void 0 : _searchExpr2.length) > 0 ? value.normalize() : new RegExp(value.normalize(), 'gim'));
|
|
793
831
|
}, timeout.current || searchDelayTime);
|
|
794
832
|
};
|
|
795
833
|
|
|
@@ -931,6 +969,7 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
931
969
|
}
|
|
932
970
|
} else {
|
|
933
971
|
inputRef.current.value = '';
|
|
972
|
+
setTextValue('');
|
|
934
973
|
} // onChangeValue('', '');
|
|
935
974
|
|
|
936
975
|
|
|
@@ -962,6 +1001,7 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
962
1001
|
inputRef.current.innerHTML = '';
|
|
963
1002
|
} else if (!isSearch[unique]) {
|
|
964
1003
|
inputRef.current.value = '';
|
|
1004
|
+
setTextValue('');
|
|
965
1005
|
}
|
|
966
1006
|
|
|
967
1007
|
currentValue[unique] = '';
|
|
@@ -1093,6 +1133,7 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
1093
1133
|
ReactDOM.render(valueWithIcon, inputRef.current.appendChild(el));
|
|
1094
1134
|
} else {
|
|
1095
1135
|
inputRef.current.value = text;
|
|
1136
|
+
setTextValue(text);
|
|
1096
1137
|
}
|
|
1097
1138
|
};
|
|
1098
1139
|
|
|
@@ -1325,14 +1366,26 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
1325
1366
|
return false;
|
|
1326
1367
|
}
|
|
1327
1368
|
}
|
|
1328
|
-
}) : jsx("input", { ...inputProps,
|
|
1329
|
-
style: inputStyle,
|
|
1369
|
+
}) : jsx(Fragment, null, jsx("input", { ...inputProps,
|
|
1370
|
+
style: openState || !textValue ? inputStyle : { ...inputStyle,
|
|
1371
|
+
visibility: 'hidden'
|
|
1372
|
+
},
|
|
1330
1373
|
ref: inputRef,
|
|
1331
1374
|
css: _DropdownInputCSS,
|
|
1332
1375
|
type: "text",
|
|
1333
1376
|
placeholder: placeholder,
|
|
1334
|
-
disabled: disabled ||
|
|
1335
|
-
})
|
|
1377
|
+
disabled: disabled || allowSearch
|
|
1378
|
+
}), !openState && textValue && jsx(Typography, {
|
|
1379
|
+
hoverTooltip: true,
|
|
1380
|
+
lineClamp: 1,
|
|
1381
|
+
type: 'p1',
|
|
1382
|
+
css: _DropdownInputCSS,
|
|
1383
|
+
style: {
|
|
1384
|
+
position: 'absolute',
|
|
1385
|
+
lineHeight: '24px'
|
|
1386
|
+
},
|
|
1387
|
+
onClick: onClickInput
|
|
1388
|
+
}, textValue))), jsx("div", {
|
|
1336
1389
|
ref: iconRef,
|
|
1337
1390
|
css: _IconCSS,
|
|
1338
1391
|
className: 'DGN-UI-Dropdown-Icon'
|
|
@@ -1356,7 +1409,7 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
1356
1409
|
},
|
|
1357
1410
|
disabled: disabled || readOnly
|
|
1358
1411
|
})));
|
|
1359
|
-
}, [viewType, inputProps, inputStyle, multiple, clearAble, onChange, disabled, readOnly, loading, renderSelectedItem, placeholder, itemMultipleSize, openState, showClear]);
|
|
1412
|
+
}, [viewType, inputProps, inputStyle, multiple, clearAble, onChange, disabled, readOnly, loading, renderSelectedItem, placeholder, itemMultipleSize, openState, showClear, textValue]);
|
|
1360
1413
|
const ErrorView = useMemo(() => error && jsx(HelperText, {
|
|
1361
1414
|
disabled: disabled,
|
|
1362
1415
|
style: {
|
|
@@ -1382,6 +1435,7 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
1382
1435
|
|
|
1383
1436
|
const InputCSS = (multiple, renderSelectedItem) => css`
|
|
1384
1437
|
${flexRow};
|
|
1438
|
+
${positionRelative};
|
|
1385
1439
|
width: 100%;
|
|
1386
1440
|
${!multiple && renderSelectedItem ? `width: calc(100% - 34px)` : ''}
|
|
1387
1441
|
`;
|
|
@@ -1757,7 +1811,8 @@ Dropdown.defaultProps = {
|
|
|
1757
1811
|
inputProps: {},
|
|
1758
1812
|
formStyle: {},
|
|
1759
1813
|
dataSource: [],
|
|
1760
|
-
onInput: null
|
|
1814
|
+
onInput: null,
|
|
1815
|
+
searchMode: 'contains'
|
|
1761
1816
|
};
|
|
1762
1817
|
Dropdown.propTypes = {
|
|
1763
1818
|
/**The variant to use. */
|
|
@@ -1928,6 +1983,12 @@ Dropdown.propTypes = {
|
|
|
1928
1983
|
/** The contents in Dropdown box (Exp: TreeView). */
|
|
1929
1984
|
children: PropTypes.node,
|
|
1930
1985
|
|
|
1986
|
+
/** Specifies a data object's field name or an expression whose value is compared to the search string. */
|
|
1987
|
+
searchExpr: PropTypes.oneOfType([PropTypes.array, PropTypes.string]),
|
|
1988
|
+
|
|
1989
|
+
/** Specifies a comparison operation used to search items. */
|
|
1990
|
+
searchMode: PropTypes.oneOf(['contains', 'startswith', 'equals']),
|
|
1991
|
+
|
|
1931
1992
|
/**
|
|
1932
1993
|
* ref methods
|
|
1933
1994
|
*
|
|
@@ -28,7 +28,8 @@ const HelperText = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
28
28
|
className,
|
|
29
29
|
style,
|
|
30
30
|
children,
|
|
31
|
-
id
|
|
31
|
+
id,
|
|
32
|
+
...props
|
|
32
33
|
}, ref) => {
|
|
33
34
|
const color = colorMap.get(status);
|
|
34
35
|
return jsx(Typography, {
|
|
@@ -40,7 +41,8 @@ const HelperText = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
40
41
|
css: HelperTextRootCSS,
|
|
41
42
|
className: ['DGN-UI-HelperText', className].join(' ').trim().replace(/\s+/g, ' '),
|
|
42
43
|
style: style,
|
|
43
|
-
lineClamp: 1
|
|
44
|
+
lineClamp: 1,
|
|
45
|
+
...props
|
|
44
46
|
}, typeof children === 'boolean' ? getGlobal('thisFieldIsRequired') : children);
|
|
45
47
|
}));
|
|
46
48
|
const HelperTextRootCSS = css`
|
|
@@ -67,6 +69,9 @@ HelperText.propTypes = {
|
|
|
67
69
|
style: PropTypes.object,
|
|
68
70
|
|
|
69
71
|
/** Content to display in component. */
|
|
70
|
-
children: PropTypes.oneOfType([PropTypes.string, PropTypes.bool])
|
|
72
|
+
children: PropTypes.oneOfType([PropTypes.string, PropTypes.bool]),
|
|
73
|
+
|
|
74
|
+
/** [Props](https://core.diginet.com.vn/ui/?path=/docs/typography) of Typography */
|
|
75
|
+
props: PropTypes.any
|
|
71
76
|
};
|
|
72
77
|
export default HelperText;
|
|
@@ -45,20 +45,24 @@ const InputBase = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
45
45
|
onKeyDown,
|
|
46
46
|
onKeyUp,
|
|
47
47
|
delayOnChange,
|
|
48
|
+
autoWidth,
|
|
48
49
|
...props
|
|
49
50
|
}, reference) => {
|
|
51
|
+
const _onChange = e => {
|
|
52
|
+
onChange && onChange(e);
|
|
53
|
+
dynamicWidth(e);
|
|
54
|
+
};
|
|
55
|
+
|
|
50
56
|
const {
|
|
51
57
|
bind
|
|
52
|
-
} = useInput(
|
|
53
|
-
|
|
54
|
-
valueProp,
|
|
55
|
-
onChange,
|
|
56
|
-
onInput,
|
|
57
|
-
delayOnChange
|
|
58
|
-
});
|
|
58
|
+
} = useInput(defaultValue, valueProp, _onChange, onInput, delayOnChange);
|
|
59
|
+
if (!autoWidth && inputProps !== null && inputProps !== void 0 && inputProps.autoWidth) autoWidth = inputProps.autoWidth;
|
|
59
60
|
if (!inputBaseRef) inputBaseRef = useRef(null);
|
|
60
61
|
const ref = useRef(null);
|
|
61
62
|
const valueArray = useRef([]);
|
|
63
|
+
const canvas = document.createElement('canvas');
|
|
64
|
+
const styleInputBase = useRef(null);
|
|
65
|
+
const widthInit = useRef(null);
|
|
62
66
|
const isEnabled = !readOnly && !disabled;
|
|
63
67
|
/* Start styled */
|
|
64
68
|
|
|
@@ -68,6 +72,7 @@ const InputBase = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
68
72
|
align-items: center;
|
|
69
73
|
position: relative;
|
|
70
74
|
height: max-content;
|
|
75
|
+
width: ${autoWidth ? 'max-content' : 'auto'};
|
|
71
76
|
&:hover,
|
|
72
77
|
&:focus-within {
|
|
73
78
|
.start-icon:not(.non-effect) {
|
|
@@ -231,9 +236,10 @@ const InputBase = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
231
236
|
flex: 1 1 auto;
|
|
232
237
|
`;
|
|
233
238
|
const inputCSS = css`
|
|
234
|
-
width: 100
|
|
239
|
+
width: ${autoWidth ? '10px' : '100%'};
|
|
235
240
|
border: none;
|
|
236
241
|
outline: none;
|
|
242
|
+
transition: all 0.1s;
|
|
237
243
|
color: ${colors.input};
|
|
238
244
|
background-color: transparent;
|
|
239
245
|
padding-top: 0;
|
|
@@ -507,6 +513,12 @@ const InputBase = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
507
513
|
if (multiline && !/\d+/.test(rows)) {
|
|
508
514
|
inputBaseRef.current.style.height = 0;
|
|
509
515
|
inputBaseRef.current.style.height = Math.max(defaultHeight, inputBaseRef.current.scrollHeight) + 'px';
|
|
516
|
+
} else {
|
|
517
|
+
dynamicWidth({
|
|
518
|
+
target: {
|
|
519
|
+
value: valueProp
|
|
520
|
+
}
|
|
521
|
+
});
|
|
510
522
|
}
|
|
511
523
|
}
|
|
512
524
|
|
|
@@ -532,8 +544,27 @@ const InputBase = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
532
544
|
}, [disabled]);
|
|
533
545
|
/* End handler */
|
|
534
546
|
|
|
547
|
+
const saveInitInfo = refs => {
|
|
548
|
+
inputBaseRef.current = refs;
|
|
549
|
+
if (!autoWidth) return;
|
|
550
|
+
const style = window.getComputedStyle(refs) || refs.currentStyle;
|
|
551
|
+
if (!widthInit.current) widthInit.current = parseInt(style.width);
|
|
552
|
+
styleInputBase.current = style;
|
|
553
|
+
};
|
|
554
|
+
|
|
555
|
+
const dynamicWidth = e => {
|
|
556
|
+
if (!autoWidth || !inputBaseRef.current) return;
|
|
557
|
+
if (!canvas || !styleInputBase.current || !inputBaseRef.current) return;
|
|
558
|
+
const context = canvas.getContext('2d');
|
|
559
|
+
context.font = styleInputBase.current.font;
|
|
560
|
+
const {
|
|
561
|
+
width
|
|
562
|
+
} = context.measureText(e.target.value);
|
|
563
|
+
inputBaseRef.current.style.width = `${Math.max(width, widthInit.current)}px`;
|
|
564
|
+
};
|
|
535
565
|
/* Start component */
|
|
536
566
|
|
|
567
|
+
|
|
537
568
|
const newClass = (viewType === 'outlined' ? 'outlined' : 'underlined') + (nonStyle ? ' non-style' : '');
|
|
538
569
|
const MultipleInputComp = jsx("div", {
|
|
539
570
|
css: multilineCSS,
|
|
@@ -605,7 +636,10 @@ const InputBase = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
605
636
|
readOnly: readOnly,
|
|
606
637
|
style: inputStyle || (inputProps === null || inputProps === void 0 ? void 0 : inputProps.style),
|
|
607
638
|
className: [newClass, inputProps === null || inputProps === void 0 ? void 0 : inputProps.className].join(' '),
|
|
608
|
-
ref:
|
|
639
|
+
ref: refs => {
|
|
640
|
+
if (!refs) return;
|
|
641
|
+
saveInitInfo(refs);
|
|
642
|
+
},
|
|
609
643
|
css: inputCSS,
|
|
610
644
|
onKeyDown: onKeyDown,
|
|
611
645
|
onKeyUp: onKeyUp,
|
|
@@ -744,6 +778,9 @@ InputBase.propTypes = {
|
|
|
744
778
|
inputRef: PropTypes.any,
|
|
745
779
|
|
|
746
780
|
/** delayOnChange of InputBase component */
|
|
747
|
-
delayOnChange: PropTypes.number
|
|
781
|
+
delayOnChange: PropTypes.number,
|
|
782
|
+
|
|
783
|
+
/** autoWidth of TextInput component, don't run with multiline = true */
|
|
784
|
+
autoWidth: PropTypes.bool
|
|
748
785
|
};
|
|
749
786
|
export default InputBase;
|
|
@@ -123,6 +123,7 @@ const MoneyInput = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
123
123
|
convertToWords,
|
|
124
124
|
prefix,
|
|
125
125
|
suffix,
|
|
126
|
+
labelProps,
|
|
126
127
|
...props
|
|
127
128
|
}, reference) => {
|
|
128
129
|
const ref = useRef(null);
|
|
@@ -418,7 +419,7 @@ const MoneyInput = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
418
419
|
css: MoneyInputRoot,
|
|
419
420
|
className: ['DGN-UI-Money-Input', className].join(' ').trim().replace(/\s+/g, ' '),
|
|
420
421
|
...props
|
|
421
|
-
}, !!label && jsx(Label, {
|
|
422
|
+
}, !!label && jsx(Label, { ...labelProps,
|
|
422
423
|
required: required,
|
|
423
424
|
disabled: disabled
|
|
424
425
|
}, label), jsx(InputBase, {
|
|
@@ -581,6 +582,9 @@ MoneyInput.propTypes = {
|
|
|
581
582
|
onFocus: PropTypes.func,
|
|
582
583
|
|
|
583
584
|
/** inputRef of MoneyInput component */
|
|
584
|
-
inputRef: PropTypes.any
|
|
585
|
+
inputRef: PropTypes.any,
|
|
586
|
+
|
|
587
|
+
/** [Props](https://core.diginet.com.vn/ui/?path=/docs/form-control-text-label) of label. */
|
|
588
|
+
labelProps: PropTypes.object
|
|
585
589
|
};
|
|
586
590
|
export default MoneyInput;
|
|
@@ -578,23 +578,23 @@ NumberInput.propTypes = {
|
|
|
578
578
|
/** style inline of input in NumberInput component */
|
|
579
579
|
inputStyle: PropTypes.object,
|
|
580
580
|
|
|
581
|
-
/**
|
|
582
|
-
* the format to display value<br/>
|
|
583
|
-
* * function: value => function(value)<br/>
|
|
584
|
-
* * string: Example: '#.###', '# ###', '#.### 2%', '#.### %%'<br/>
|
|
585
|
-
* #: integer part digit<br/>
|
|
586
|
-
* . / '_': separator symbol<br/>
|
|
587
|
-
* %: decimal digit, '2%' === '%%'
|
|
581
|
+
/**
|
|
582
|
+
* the format to display value<br/>
|
|
583
|
+
* * function: value => function(value)<br/>
|
|
584
|
+
* * string: Example: '#.###', '# ###', '#.### 2%', '#.### %%'<br/>
|
|
585
|
+
* #: integer part digit<br/>
|
|
586
|
+
* . / '_': separator symbol<br/>
|
|
587
|
+
* %: decimal digit, '2%' === '%%'
|
|
588
588
|
*/
|
|
589
589
|
format: PropTypes.oneOfType([PropTypes.string, PropTypes.func]),
|
|
590
590
|
|
|
591
591
|
/** The function to get ref of NumberInput component */
|
|
592
592
|
refs: PropTypes.func,
|
|
593
593
|
|
|
594
|
-
/** validation value, argument can:<br/>
|
|
595
|
-
* * string: the validation rule. Example required.<br/>
|
|
596
|
-
* * object: the validation rule insist name, property, message. Example {name: 'min', compareValue: 9, message: 'Error'} or {max: 99}<br/>
|
|
597
|
-
* * array: the validation rule list, insist object/string
|
|
594
|
+
/** validation value, argument can:<br/>
|
|
595
|
+
* * string: the validation rule. Example required.<br/>
|
|
596
|
+
* * object: the validation rule insist name, property, message. Example {name: 'min', compareValue: 9, message: 'Error'} or {max: 99}<br/>
|
|
597
|
+
* * array: the validation rule list, insist object/string
|
|
598
598
|
*/
|
|
599
599
|
validates: PropTypes.oneOfType([PropTypes.string, PropTypes.object, PropTypes.array, PropTypes.func]),
|
|
600
600
|
|
|
@@ -51,7 +51,9 @@ const NumberInput = /*#__PURE__*/forwardRef(({
|
|
|
51
51
|
delayOnChange,
|
|
52
52
|
fixedDecimalDigit,
|
|
53
53
|
className,
|
|
54
|
-
maxDigit
|
|
54
|
+
maxDigit,
|
|
55
|
+
autoWidth,
|
|
56
|
+
labelProps
|
|
55
57
|
}, reference) => {
|
|
56
58
|
inputRef = inputRef || useRef(null);
|
|
57
59
|
const pos = useRef(null);
|
|
@@ -156,7 +158,7 @@ const NumberInput = /*#__PURE__*/forwardRef(({
|
|
|
156
158
|
let value = (_e$value = e.value) !== null && _e$value !== void 0 ? _e$value : e.target.value;
|
|
157
159
|
if (fixedDecimalDigit) value = Number(value).toFixed(decimalDigit);
|
|
158
160
|
|
|
159
|
-
if (value && (typeof min !== 'undefined' || typeof max !== 'undefined')) {
|
|
161
|
+
if ((value || value === '' && typeof min !== 'undefined') && (typeof min !== 'undefined' || typeof max !== 'undefined')) {
|
|
160
162
|
value = convertMoneyToNumber(value);
|
|
161
163
|
|
|
162
164
|
if (Number(value) < min || Number(value) > max) {
|
|
@@ -269,7 +271,7 @@ const NumberInput = /*#__PURE__*/forwardRef(({
|
|
|
269
271
|
ref: ref,
|
|
270
272
|
css: NumberInputRoot,
|
|
271
273
|
className: ['DGN-UI-NumberInput', className].join(' ').trim().replace(/\s+/g, ' ')
|
|
272
|
-
}, !!label && jsx(Label, {
|
|
274
|
+
}, !!label && jsx(Label, { ...labelProps,
|
|
273
275
|
required: required,
|
|
274
276
|
disabled: disabled
|
|
275
277
|
}, label), jsx(InputBase, {
|
|
@@ -283,6 +285,7 @@ const NumberInput = /*#__PURE__*/forwardRef(({
|
|
|
283
285
|
readOnly: readOnly,
|
|
284
286
|
status: !!error || validateResult ? 'danger' : 'default',
|
|
285
287
|
inputProps: inputProps,
|
|
288
|
+
autoWidth: autoWidth,
|
|
286
289
|
inputStyle: inputStyle,
|
|
287
290
|
startIcon: startIcon,
|
|
288
291
|
endIcon: endIcon,
|
|
@@ -435,6 +438,12 @@ NumberInput.propTypes = {
|
|
|
435
438
|
className: PropTypes.string,
|
|
436
439
|
|
|
437
440
|
/** max character is number of NumberInput component */
|
|
438
|
-
maxDigit: PropTypes.number
|
|
441
|
+
maxDigit: PropTypes.number,
|
|
442
|
+
|
|
443
|
+
/** autoWidth of TextInput component, don't run with multiline = true */
|
|
444
|
+
autoWidth: PropTypes.bool,
|
|
445
|
+
|
|
446
|
+
/** [Props](https://core.diginet.com.vn/ui/?path=/docs/form-control-text-label) of label. */
|
|
447
|
+
labelProps: PropTypes.object
|
|
439
448
|
};
|
|
440
449
|
export default NumberInput;
|
|
@@ -42,6 +42,7 @@ const PhoneInput = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
42
42
|
onInput,
|
|
43
43
|
onKeyDown,
|
|
44
44
|
onKeyUp,
|
|
45
|
+
labelProps,
|
|
45
46
|
...props
|
|
46
47
|
}, reference) => {
|
|
47
48
|
const ref = useRef(null);
|
|
@@ -295,7 +296,7 @@ const PhoneInput = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
295
296
|
marginBottom: '20px'
|
|
296
297
|
},
|
|
297
298
|
...props
|
|
298
|
-
}, jsx(Label, {
|
|
299
|
+
}, jsx(Label, { ...labelProps,
|
|
299
300
|
required: required,
|
|
300
301
|
disabled: disabled
|
|
301
302
|
}, label), jsx(InputBase, {
|
|
@@ -396,13 +397,13 @@ PhoneInput.propTypes = {
|
|
|
396
397
|
/** on input function */
|
|
397
398
|
onInput: PropTypes.func,
|
|
398
399
|
|
|
399
|
-
/**
|
|
400
|
-
* on change function. Return a object, example:<br/>
|
|
401
|
-
* {<br/>
|
|
402
|
-
* target: {value: "(+84) 123 456 789", ...}<br/>
|
|
403
|
-
* value: 0123456789<br/>
|
|
404
|
-
* countryCode: 84<br/>
|
|
405
|
-
* }
|
|
400
|
+
/**
|
|
401
|
+
* on change function. Return a object, example:<br/>
|
|
402
|
+
* {<br/>
|
|
403
|
+
* target: {value: "(+84) 123 456 789", ...}<br/>
|
|
404
|
+
* value: 0123456789<br/>
|
|
405
|
+
* countryCode: 84<br/>
|
|
406
|
+
* }
|
|
406
407
|
*/
|
|
407
408
|
onChange: PropTypes.func,
|
|
408
409
|
|
|
@@ -413,6 +414,9 @@ PhoneInput.propTypes = {
|
|
|
413
414
|
onFocus: PropTypes.func,
|
|
414
415
|
|
|
415
416
|
/** inputRef of PhoneInput component */
|
|
416
|
-
inputRef: PropTypes.any
|
|
417
|
+
inputRef: PropTypes.any,
|
|
418
|
+
|
|
419
|
+
/** [Props](https://core.diginet.com.vn/ui/?path=/docs/form-control-text-label) of label. */
|
|
420
|
+
labelProps: PropTypes.object
|
|
417
421
|
};
|
|
418
422
|
export default PhoneInput;
|
|
@@ -66,6 +66,7 @@ const TextInput = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
66
66
|
onKeyUp,
|
|
67
67
|
onPaste,
|
|
68
68
|
validates,
|
|
69
|
+
autoWidth,
|
|
69
70
|
...props
|
|
70
71
|
}, reference) => {
|
|
71
72
|
const ref = useRef(null);
|
|
@@ -244,11 +245,12 @@ const TextInput = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
244
245
|
}
|
|
245
246
|
}, [error, value]);
|
|
246
247
|
useEffect(() => {
|
|
247
|
-
if (placeholder !== undefined) {
|
|
248
|
+
if (placeholder !== undefined && inputRef.current) {
|
|
248
249
|
inputRef.current.placeholder = placeholder;
|
|
249
250
|
}
|
|
250
251
|
}, [placeholder]);
|
|
251
252
|
useEffect(() => {
|
|
253
|
+
if (!inputRef.current) return;
|
|
252
254
|
inputRef.current.readOnly = !!readOnly;
|
|
253
255
|
|
|
254
256
|
if (/^(quick)?Edit/i.test(type) && !multiline && readOnly) {
|
|
@@ -347,6 +349,7 @@ const TextInput = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
347
349
|
disabled: disabled,
|
|
348
350
|
readOnly: readOnly,
|
|
349
351
|
multiline: multiline,
|
|
352
|
+
autoWidth: autoWidth,
|
|
350
353
|
rows: rows,
|
|
351
354
|
maxRows: maxRows,
|
|
352
355
|
status: isError || validateResult ? 'danger' : 'default',
|
|
@@ -387,7 +390,8 @@ TextInput.defaultProps = {
|
|
|
387
390
|
disabled: false,
|
|
388
391
|
readOnly: false,
|
|
389
392
|
multiline: false,
|
|
390
|
-
iconStyle: {}
|
|
393
|
+
iconStyle: {},
|
|
394
|
+
autoWidth: false
|
|
391
395
|
};
|
|
392
396
|
TextInput.propTypes = {
|
|
393
397
|
/** type of input */
|
|
@@ -500,6 +504,12 @@ TextInput.propTypes = {
|
|
|
500
504
|
validates: PropTypes.oneOfType([PropTypes.string, PropTypes.object, PropTypes.array, PropTypes.func]),
|
|
501
505
|
|
|
502
506
|
/** inputRef of TextInput component */
|
|
503
|
-
inputRef: PropTypes.any
|
|
507
|
+
inputRef: PropTypes.any,
|
|
508
|
+
|
|
509
|
+
/** autoWidth of TextInput component, don't run with multiline = true */
|
|
510
|
+
autoWidth: PropTypes.bool,
|
|
511
|
+
|
|
512
|
+
/** If `true`, a textarea element is rendered. */
|
|
513
|
+
multiline: PropTypes.bool
|
|
504
514
|
};
|
|
505
515
|
export default TextInput;
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
/** @jsxRuntime classic */
|
|
2
|
+
|
|
3
|
+
/** @jsx jsx */
|
|
4
|
+
import PropTypes from 'prop-types';
|
|
5
|
+
import { jsx } from '@emotion/core';
|
|
6
|
+
import Grid from '.';
|
|
7
|
+
|
|
8
|
+
const checkChildren = children => {
|
|
9
|
+
if (!children) return false;
|
|
10
|
+
|
|
11
|
+
if (Array.isArray(children)) {
|
|
12
|
+
return !children.every(v => v === false);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
return true;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
const Container = props => {
|
|
19
|
+
const {
|
|
20
|
+
className,
|
|
21
|
+
children
|
|
22
|
+
} = props;
|
|
23
|
+
return checkChildren(children) ? jsx(Grid, { ...props,
|
|
24
|
+
className: ['DGN-UI-Container', className].join(' ').trim().replace(/\s+/g, ' '),
|
|
25
|
+
container: true
|
|
26
|
+
}) : null;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
Container.defaultProps = {
|
|
30
|
+
style: {},
|
|
31
|
+
className: '',
|
|
32
|
+
columns: 12,
|
|
33
|
+
lg: false,
|
|
34
|
+
md: false,
|
|
35
|
+
sm: false,
|
|
36
|
+
xl: false,
|
|
37
|
+
xs: false,
|
|
38
|
+
zeroMinWidth: false,
|
|
39
|
+
spacing: 0,
|
|
40
|
+
direction: 'row',
|
|
41
|
+
wrap: 'wrap',
|
|
42
|
+
columnSpacing: {
|
|
43
|
+
xs: 4,
|
|
44
|
+
sm: 4,
|
|
45
|
+
md: 4,
|
|
46
|
+
lg: 4,
|
|
47
|
+
xl: 6
|
|
48
|
+
},
|
|
49
|
+
rowSpacing: {
|
|
50
|
+
xs: 4,
|
|
51
|
+
sm: 4,
|
|
52
|
+
md: 4,
|
|
53
|
+
lg: 4,
|
|
54
|
+
xl: 4
|
|
55
|
+
},
|
|
56
|
+
topSpacing: {
|
|
57
|
+
xs: 2,
|
|
58
|
+
sm: 2,
|
|
59
|
+
md: 2,
|
|
60
|
+
lg: 2,
|
|
61
|
+
xl: 2
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
Container.propTypes = {
|
|
65
|
+
/** The content of the component. */
|
|
66
|
+
children: PropTypes.node,
|
|
67
|
+
|
|
68
|
+
/** Style inline of component. */
|
|
69
|
+
style: PropTypes.object,
|
|
70
|
+
|
|
71
|
+
/** Class for component. */
|
|
72
|
+
className: PropTypes.string,
|
|
73
|
+
|
|
74
|
+
/** The number of columns. */
|
|
75
|
+
columns: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.number), PropTypes.number, PropTypes.object]),
|
|
76
|
+
|
|
77
|
+
/** Defines the horizontal space between the type `Col` components. It overrides the value of the `spacing` prop. */
|
|
78
|
+
columnSpacing: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.number, PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.string]),
|
|
79
|
+
|
|
80
|
+
/** Defines the `flex-direction` style property. It is applied for all screen sizes. */
|
|
81
|
+
direction: PropTypes.oneOfType([PropTypes.oneOf(['column-reverse', 'column', 'row-reverse', 'row']), PropTypes.arrayOf(PropTypes.oneOf(['column-reverse', 'column', 'row-reverse', 'row'])), PropTypes.object]),
|
|
82
|
+
|
|
83
|
+
/** If a number, it sets the number of columns the grid item uses. It can't be greater than the total number of columns of the container (12 by default). If 'auto', the grid item's width matches its content. If false, the prop is ignored. If true, the grid item's width grows to use the space available in the grid container. The value is applied for the `lg` breakpoint and wider screens if not overridden. */
|
|
84
|
+
lg: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number, PropTypes.bool]),
|
|
85
|
+
|
|
86
|
+
/** If a number, it sets the number of columns the grid item uses. It can't be greater than the total number of columns of the container (12 by default). If 'auto', the grid item's width matches its content. If false, the prop is ignored. If true, the grid item's width grows to use the space available in the grid container. The value is applied for the `md` breakpoint and wider screens if not overridden. */
|
|
87
|
+
md: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number, PropTypes.bool]),
|
|
88
|
+
|
|
89
|
+
/** Defines the vertical space between the type `Col` components. It overrides the value of the `spacing` prop. */
|
|
90
|
+
rowSpacing: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.number, PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.string]),
|
|
91
|
+
|
|
92
|
+
/** If a number, it sets the number of columns the grid item uses. It can't be greater than the total number of columns of the container (12 by default). If 'auto', the grid item's width matches its content. If false, the prop is ignored. If true, the grid item's width grows to use the space available in the grid container. The value is applied for the `sm` breakpoint and wider screens if not overridden. */
|
|
93
|
+
sm: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number, PropTypes.bool]),
|
|
94
|
+
|
|
95
|
+
/** Defines the space between the type `Col` components */
|
|
96
|
+
spacing: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.number, PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.string]),
|
|
97
|
+
|
|
98
|
+
/** Defines the flex-wrap style property. It's applied for all screen sizes. */
|
|
99
|
+
wrap: PropTypes.oneOf(['nowrap', 'wrap-reverse', 'wrap']),
|
|
100
|
+
|
|
101
|
+
/** If a number, it sets the number of columns the grid item uses. It can't be greater than the total number of columns of the container (12 by default). If 'auto', the grid item's width matches its content. If false, the prop is ignored. If true, the grid item's width grows to use the space available in the grid container. The value is applied for the `xl` breakpoint and wider screens if not overridden. */
|
|
102
|
+
xl: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number, PropTypes.bool]),
|
|
103
|
+
|
|
104
|
+
/** If a number, it sets the number of columns the grid item uses. It can't be greater than the total number of columns of the container (12 by default). If 'auto', the grid item's width matches its content. If false, the prop is ignored. If true, the grid item's width grows to use the space available in the grid container. The value is applied for all the screen sizes with the lowest priority. */
|
|
105
|
+
xs: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number, PropTypes.bool]),
|
|
106
|
+
|
|
107
|
+
/** If `true`, it sets `min-width: 0` on the item. Refer to the limitations section of the documentation to better understand the use case. */
|
|
108
|
+
zeroMinWidth: PropTypes.bool
|
|
109
|
+
};
|
|
110
|
+
export default Container;
|