diginet-core-ui 1.3.49-beta.2 → 1.3.51
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/alert/index.js +1 -1
- package/components/chip/index.js +2 -1
- package/components/form-control/checkbox/index.js +1 -1
- package/components/form-control/dropdown/index.js +55 -62
- package/components/form-control/input-base/index.js +28 -20
- package/components/modal/modal.js +4 -4
- package/package.json +31 -54
- package/readme.md +8 -0
- package/styles/general.js +1 -1
- package/utils/useDelayUnmount.js +19 -0
|
@@ -10,8 +10,8 @@ import ButtonIcon from '../button/icon';
|
|
|
10
10
|
import Icon from '../../icons';
|
|
11
11
|
import { hexToRGBA } from '../../styles/color-helper';
|
|
12
12
|
import { typography } from '../../styles/typography';
|
|
13
|
-
import { useTheme } from '../../theme';
|
|
14
13
|
import { alignCenter, border, borderBox, borderRadius4px, breakWord, displayBlock, flexRow, justifyStart, positionRelative, userSelectNone } from '../../styles/general';
|
|
14
|
+
import { useTheme } from '../../theme';
|
|
15
15
|
const {
|
|
16
16
|
heading3,
|
|
17
17
|
heading4,
|
package/components/chip/index.js
CHANGED
|
@@ -114,7 +114,8 @@ const Chip = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
114
114
|
className: size
|
|
115
115
|
}, jsx(Typography, {
|
|
116
116
|
type: size === 'small' ? 'p2' : 'p1',
|
|
117
|
-
color: 'inherit'
|
|
117
|
+
color: 'inherit',
|
|
118
|
+
lineClamp: 1
|
|
118
119
|
}, renderLabel()));
|
|
119
120
|
}, [label, size, startIcon, endIcon, clearAble]);
|
|
120
121
|
const endIconView = useMemo(() => {
|
|
@@ -157,11 +157,9 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
157
157
|
if (!boxRef.current) {
|
|
158
158
|
if (!multiple || !Array.from(inputRef.current.querySelectorAll('.DGN-UI-Chip')).some(item => item.contains(e.target))) {
|
|
159
159
|
if ((renderSelectedItem || iconExpr && iconExpr !== 'none') && !multiple) {
|
|
160
|
-
var _inputRef$current$chi;
|
|
161
|
-
|
|
162
160
|
inputRef.current.innerHTML = inputRef.current.textContent.trim();
|
|
163
161
|
inputRef.current.contentEditable = 'plaintext-only';
|
|
164
|
-
const caret =
|
|
162
|
+
const caret = inputRef.current.childNodes.length ? 1 : 0;
|
|
165
163
|
const range = document.createRange();
|
|
166
164
|
range.setStart(inputRef.current, caret);
|
|
167
165
|
range.setEnd(inputRef.current, caret);
|
|
@@ -283,6 +281,7 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
283
281
|
window.addEventListener('resize', customizeWidthDropdown);
|
|
284
282
|
document.addEventListener('wheel', onWheelHandler);
|
|
285
283
|
document.addEventListener('mousedown', onClickOutsideOfInput);
|
|
284
|
+
document.addEventListener('keydown', preventScroll);
|
|
286
285
|
boxRef.current && boxRef.current.addEventListener('keydown', moveOnItem);
|
|
287
286
|
|
|
288
287
|
if (onLoadMore && dataSource.length < total) {
|
|
@@ -307,6 +306,15 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
307
306
|
}
|
|
308
307
|
};
|
|
309
308
|
|
|
309
|
+
const preventScroll = e => {
|
|
310
|
+
if (/Arrow(Up|Down)/.test(e.key)) {
|
|
311
|
+
e.preventDefault();
|
|
312
|
+
return false;
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
return true;
|
|
316
|
+
};
|
|
317
|
+
|
|
310
318
|
const pressESCHandler = event => {
|
|
311
319
|
if (event.key === 'Escape' || event.key === 'Tab') {
|
|
312
320
|
closeDropdown();
|
|
@@ -331,9 +339,11 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
331
339
|
};
|
|
332
340
|
|
|
333
341
|
const closeDropdown = () => {
|
|
334
|
-
const node = document.querySelector(`.DGN-Dropdown-${unique}`);
|
|
335
|
-
|
|
336
|
-
|
|
342
|
+
const node = document.querySelector(`.DGN-Dropdown-${unique}`);
|
|
343
|
+
|
|
344
|
+
if ((renderSelectedItem || iconExpr && iconExpr !== 'none') && !multiple && inputRef.current) {
|
|
345
|
+
inputRef.current.contentEditable = true;
|
|
346
|
+
}
|
|
337
347
|
|
|
338
348
|
if (node) {
|
|
339
349
|
node.style.pointerEvents = `none`;
|
|
@@ -349,6 +359,7 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
349
359
|
document.removeEventListener('mousedown', onClickOutsideOfInput);
|
|
350
360
|
window.removeEventListener('resize', customizeWidthDropdown);
|
|
351
361
|
document.removeEventListener('wheel', onWheelHandler);
|
|
362
|
+
document.removeEventListener('keydown', preventScroll);
|
|
352
363
|
|
|
353
364
|
if (onLoadMore && boxRef.current) {
|
|
354
365
|
boxRef.current.removeEventListener('scroll', onLoadMoreHandler);
|
|
@@ -389,14 +400,12 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
389
400
|
};
|
|
390
401
|
|
|
391
402
|
const mapDropdown = (pattern, keyArr) => {
|
|
392
|
-
var _currentObjectDefault;
|
|
393
|
-
|
|
394
403
|
const items = [];
|
|
395
404
|
const dataSourceUsable = [...dataSource];
|
|
396
405
|
|
|
397
406
|
const _DropdownItemCSS = DropdownItemCSS(multiple, selectBox);
|
|
398
407
|
|
|
399
|
-
if (currentObjectDefault[unique] &&
|
|
408
|
+
if (currentObjectDefault[unique] && currentObjectDefault[unique].length) {
|
|
400
409
|
const length = currentObjectDefault[unique].length;
|
|
401
410
|
let existItemQuantity = 0;
|
|
402
411
|
|
|
@@ -446,13 +455,15 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
446
455
|
items.push(jsx("div", {
|
|
447
456
|
key: index,
|
|
448
457
|
css: !itemDisabled ? _DropdownItemCSS : [DisabledCSS, _DropdownItemCSS],
|
|
449
|
-
onClick:
|
|
450
|
-
if (itemDisabled) return;
|
|
451
|
-
|
|
458
|
+
onClick: () => {
|
|
459
|
+
if (itemDisabled) return; // onChangeValueWithCheckbox(e) & onChangeValue(displayText, value, icon, data, index);
|
|
460
|
+
|
|
461
|
+
onChangeValue(displayText, value, icon, data, index);
|
|
452
462
|
},
|
|
453
463
|
onKeyPress: e => {
|
|
454
|
-
if (itemDisabled) return;
|
|
455
|
-
|
|
464
|
+
if (itemDisabled) return; // if (e.key === 'Enter') e.currentTarget.firstChild.click();
|
|
465
|
+
|
|
466
|
+
if (e.key === 'Enter') onChangeValue(displayText, value, icon, data, index);
|
|
456
467
|
},
|
|
457
468
|
tabIndex: -1
|
|
458
469
|
}, jsx(Checkbox, {
|
|
@@ -463,7 +474,8 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
463
474
|
padding: '0 16px'
|
|
464
475
|
},
|
|
465
476
|
value: value,
|
|
466
|
-
disabled: itemDisabled
|
|
477
|
+
disabled: itemDisabled,
|
|
478
|
+
onChange: () => onChangeValue(displayText, value, icon, data, index)
|
|
467
479
|
}, icon && jsx("div", {
|
|
468
480
|
css: DropdownIconCSS
|
|
469
481
|
}, icon), jsx("div", {
|
|
@@ -535,13 +547,13 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
535
547
|
};
|
|
536
548
|
|
|
537
549
|
const loadMoreItemsDropdown = (i = 0, pattern) => {
|
|
538
|
-
var
|
|
550
|
+
var _displayExpr3;
|
|
539
551
|
|
|
540
552
|
const dataSourceUsable = [...dataSource]; // Nếu có load more thì đẩy đội tượng mặc định lên đầu
|
|
541
553
|
|
|
542
554
|
let notExistItem = 0;
|
|
543
555
|
|
|
544
|
-
if (onLoadMore &&
|
|
556
|
+
if (onLoadMore && currentObjectDefault[unique].length) {
|
|
545
557
|
const length = currentObjectDefault[unique].length;
|
|
546
558
|
|
|
547
559
|
for (let index = length - 1; index >= 0; index--) {
|
|
@@ -732,9 +744,7 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
732
744
|
const _DropdownItemCSS = DropdownItemCSS(multiple, selectBox);
|
|
733
745
|
|
|
734
746
|
if (scrollHeight === Math.ceil(scrollTop) + offsetHeight && boxRef.current) {
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
const length = (_boxRef$current$query = boxRef.current.querySelectorAll(`.css-${_DropdownItemCSS.name}`)) === null || _boxRef$current$query === void 0 ? void 0 : _boxRef$current$query.length;
|
|
747
|
+
const length = boxRef.current.querySelectorAll(`.css-${_DropdownItemCSS.name}`).length;
|
|
738
748
|
boxRef.current.removeEventListener('scroll', onLoadMoreHandler);
|
|
739
749
|
!!onLoadMore && onLoadMore({
|
|
740
750
|
skip: length,
|
|
@@ -884,15 +894,13 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
884
894
|
if (closeAfterSelect === true || closeAfterSelect === undefined && !multiple) {
|
|
885
895
|
closeDropdown();
|
|
886
896
|
}
|
|
887
|
-
};
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
897
|
+
}; // const onChangeValueWithCheckbox = e => {
|
|
898
|
+
// const firstChild = e.currentTarget.firstChild;
|
|
899
|
+
// if (!firstChild.contains(e.target)) {
|
|
900
|
+
// firstChild.click();
|
|
901
|
+
// }
|
|
902
|
+
// };
|
|
891
903
|
|
|
892
|
-
if (!firstChild.contains(e.target)) {
|
|
893
|
-
firstChild.click();
|
|
894
|
-
}
|
|
895
|
-
};
|
|
896
904
|
|
|
897
905
|
const onRemove = (e, value) => {
|
|
898
906
|
const index = currentValue[unique].findIndex(v => JSON.stringify(v) === JSON.stringify(value));
|
|
@@ -918,7 +926,7 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
918
926
|
};
|
|
919
927
|
|
|
920
928
|
const onClear = e => {
|
|
921
|
-
if (disabled || readOnly || loading
|
|
929
|
+
if (disabled || readOnly || loading) return;
|
|
922
930
|
currentValue[unique] = multiple ? [] : '';
|
|
923
931
|
|
|
924
932
|
if (inputRef.current.tagName.toLowerCase() === 'div') {
|
|
@@ -932,7 +940,6 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
932
940
|
} // onChangeValue('', '');
|
|
933
941
|
|
|
934
942
|
|
|
935
|
-
setShowClear(false);
|
|
936
943
|
e && e.target && e.target.blur();
|
|
937
944
|
updatePositionDropdown();
|
|
938
945
|
onInput === null || onInput === void 0 ? void 0 : onInput({ ...(inputRef === null || inputRef === void 0 ? void 0 : inputRef.current),
|
|
@@ -969,7 +976,7 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
969
976
|
}
|
|
970
977
|
|
|
971
978
|
const length = dataSource.length;
|
|
972
|
-
const displayKey = displayExpr;
|
|
979
|
+
const displayKey = keyExpr || displayExpr;
|
|
973
980
|
|
|
974
981
|
if (displayKey && Array.isArray(displayKey)) {
|
|
975
982
|
displayExpr = displayExpr.join(' - ');
|
|
@@ -988,8 +995,6 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
988
995
|
currentValue[unique] = [];
|
|
989
996
|
inputRef.current.innerHTML = '';
|
|
990
997
|
valueArr.forEach(v => {
|
|
991
|
-
var _currentObjectDefault3;
|
|
992
|
-
|
|
993
998
|
for (let i = 0; i < length; i++) {
|
|
994
999
|
if (typeof dataSource[i] === 'object' && dataSource[i][valueExpr] === v || dataSource[i] === v) {
|
|
995
1000
|
setMultipleValueHandler(dataSource[i], v, keyArr, i);
|
|
@@ -997,7 +1002,7 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
997
1002
|
}
|
|
998
1003
|
}
|
|
999
1004
|
|
|
1000
|
-
if (
|
|
1005
|
+
if (currentObjectDefault[unique].length) {
|
|
1001
1006
|
const itemOfValue = currentObjectDefault[unique].find(valueObject => valueObject[valueExpr] === v || valueObject === v);
|
|
1002
1007
|
|
|
1003
1008
|
if (itemOfValue) {
|
|
@@ -1006,8 +1011,6 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
1006
1011
|
}
|
|
1007
1012
|
});
|
|
1008
1013
|
} else {
|
|
1009
|
-
var _currentObjectDefault4;
|
|
1010
|
-
|
|
1011
1014
|
currentValue[unique] = source;
|
|
1012
1015
|
|
|
1013
1016
|
for (let i = 0; i < length; i++) {
|
|
@@ -1017,7 +1020,7 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
1017
1020
|
}
|
|
1018
1021
|
}
|
|
1019
1022
|
|
|
1020
|
-
if (
|
|
1023
|
+
if (currentObjectDefault[unique].length) {
|
|
1021
1024
|
const itemOfValue = currentObjectDefault[unique].find(valueObject => valueObject[valueExpr] === source || valueObject === source);
|
|
1022
1025
|
|
|
1023
1026
|
if (itemOfValue) {
|
|
@@ -1042,7 +1045,7 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
1042
1045
|
});
|
|
1043
1046
|
} else {
|
|
1044
1047
|
const icon = getIconFromData(data);
|
|
1045
|
-
const text = keyArr ? renderData(data, keyArr) : data[displayExpr];
|
|
1048
|
+
const text = keyArr ? renderData(data, keyArr) : data[keyExpr || displayExpr];
|
|
1046
1049
|
item = jsx(Chip, {
|
|
1047
1050
|
startIcon: icon,
|
|
1048
1051
|
label: text,
|
|
@@ -1065,7 +1068,7 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
1065
1068
|
};
|
|
1066
1069
|
|
|
1067
1070
|
const setSingleValueHandler = (data, keyArr) => {
|
|
1068
|
-
const text = keyArr ? renderData(data, keyArr) : data[
|
|
1071
|
+
const text = keyArr ? renderData(data, keyArr) : data[keyExpr || displayExpr] || data[valueExpr] || data;
|
|
1069
1072
|
|
|
1070
1073
|
if (renderSelectedItem && typeof renderSelectedItem === 'function') {
|
|
1071
1074
|
inputRef.current.innerHTML = '';
|
|
@@ -1283,17 +1286,15 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
1283
1286
|
}
|
|
1284
1287
|
|
|
1285
1288
|
if (boxRef.current) {
|
|
1286
|
-
var _boxRef$current$query2, _currentObjectDefault5;
|
|
1287
|
-
|
|
1288
1289
|
if (!disabled && !readOnly) {
|
|
1289
1290
|
inputRef.current.addEventListener('input', onChangeInput);
|
|
1290
1291
|
}
|
|
1291
1292
|
|
|
1292
1293
|
const _DropdownItemCSS = DropdownItemCSS(multiple, selectBox);
|
|
1293
1294
|
|
|
1294
|
-
const length =
|
|
1295
|
+
const length = boxRef.current.querySelectorAll(`.css-${_DropdownItemCSS.name}`).length;
|
|
1295
1296
|
|
|
1296
|
-
if (length < dataSource.length +
|
|
1297
|
+
if (length < dataSource.length + currentObjectDefault[unique].length && !isSearch[unique]) {
|
|
1297
1298
|
loadMoreItemsDropdown(length);
|
|
1298
1299
|
!!onLoadMore && dataSource.length < total && boxRef.current.addEventListener('scroll', onLoadMoreHandler);
|
|
1299
1300
|
} else {
|
|
@@ -1328,7 +1329,7 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
1328
1329
|
|
|
1329
1330
|
const _DropdownFormCSS = DropdownFormCSS(viewType, multiple, placeholder, itemMultipleSize, renderSelectedItem, disabled);
|
|
1330
1331
|
|
|
1331
|
-
const _DropdownInputCSS = DropdownInputCSS(viewType, multiple, placeholder, itemMultipleSize, renderSelectedItem
|
|
1332
|
+
const _DropdownInputCSS = DropdownInputCSS(viewType, multiple, placeholder, itemMultipleSize, renderSelectedItem);
|
|
1332
1333
|
|
|
1333
1334
|
return jsx("div", {
|
|
1334
1335
|
css: _DropdownFormCSS,
|
|
@@ -1352,7 +1353,7 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
1352
1353
|
return false;
|
|
1353
1354
|
}
|
|
1354
1355
|
}) : renderSelectedItem || iconExpr && iconExpr !== 'none' ? jsx("div", { ...inputProps,
|
|
1355
|
-
contentEditable:
|
|
1356
|
+
contentEditable: true,
|
|
1356
1357
|
style: inputStyle,
|
|
1357
1358
|
ref: inputRef,
|
|
1358
1359
|
css: _DropdownInputCSS,
|
|
@@ -1446,7 +1447,7 @@ const DropdownIconCSS = css`
|
|
|
1446
1447
|
}
|
|
1447
1448
|
`;
|
|
1448
1449
|
|
|
1449
|
-
const DropdownInputCSS = (viewType, multiple, placeholder, itemMultipleSize, renderSelectedItem
|
|
1450
|
+
const DropdownInputCSS = (viewType, multiple, placeholder, itemMultipleSize, renderSelectedItem) => css`
|
|
1450
1451
|
${flexRow};
|
|
1451
1452
|
${alignCenter};
|
|
1452
1453
|
${outlineNone};
|
|
@@ -1454,7 +1455,7 @@ const DropdownInputCSS = (viewType, multiple, placeholder, itemMultipleSize, ren
|
|
|
1454
1455
|
${borderNone};
|
|
1455
1456
|
${paragraph1};
|
|
1456
1457
|
width: 100%;
|
|
1457
|
-
color: ${
|
|
1458
|
+
color: ${main};
|
|
1458
1459
|
padding-top: 0;
|
|
1459
1460
|
padding-bottom: ${viewType !== 'outlined' ? 0 : 'inherit'};
|
|
1460
1461
|
padding-left: ${viewType !== 'outlined' ? 0 : '16px'};
|
|
@@ -1488,19 +1489,7 @@ const DropdownInputCSS = (viewType, multiple, placeholder, itemMultipleSize, ren
|
|
|
1488
1489
|
padding: ${itemMultipleSize === 'medium' ? 2 : 1}px;
|
|
1489
1490
|
}
|
|
1490
1491
|
}
|
|
1491
|
-
.DGN-UI-Typography {
|
|
1492
|
-
${disabled && `
|
|
1493
|
-
color: ${systemDisabled}
|
|
1494
|
-
`}
|
|
1495
|
-
}
|
|
1496
1492
|
.css-${DropdownIconCSS.name} {
|
|
1497
|
-
${disabled && `
|
|
1498
|
-
svg {
|
|
1499
|
-
path {
|
|
1500
|
-
fill: ${systemDisabled};
|
|
1501
|
-
}
|
|
1502
|
-
}
|
|
1503
|
-
`}
|
|
1504
1493
|
${renderSelectedItem ? `
|
|
1505
1494
|
min-height: 24px;
|
|
1506
1495
|
min-width: 24px;
|
|
@@ -1549,9 +1538,10 @@ const DropdownFormCSS = (viewType, multiple, placeholder, itemMultipleSize, rend
|
|
|
1549
1538
|
}
|
|
1550
1539
|
.css-${DropdownInputCSS(viewType, multiple, placeholder, itemMultipleSize, renderSelectedItem).name} {
|
|
1551
1540
|
color: ${active};
|
|
1552
|
-
}
|
|
1553
1541
|
}
|
|
1542
|
+
}
|
|
1554
1543
|
`}
|
|
1544
|
+
|
|
1555
1545
|
&:focus-within {
|
|
1556
1546
|
border-bottom-color: ${focus};
|
|
1557
1547
|
&::after {
|
|
@@ -1576,7 +1566,7 @@ const DropdownFormCSS = (viewType, multiple, placeholder, itemMultipleSize, rend
|
|
|
1576
1566
|
left: 0;
|
|
1577
1567
|
right: 0;
|
|
1578
1568
|
bottom: 0;
|
|
1579
|
-
border-bottom: 1px solid ${
|
|
1569
|
+
border-bottom: 1px solid ${rest};
|
|
1580
1570
|
}
|
|
1581
1571
|
&::after {
|
|
1582
1572
|
${positionAbsolute};
|
|
@@ -1595,7 +1585,7 @@ const DropdownFormCSS = (viewType, multiple, placeholder, itemMultipleSize, rend
|
|
|
1595
1585
|
${positionRelative};
|
|
1596
1586
|
${borderRadius4px};
|
|
1597
1587
|
${borderBox};
|
|
1598
|
-
${border(1,
|
|
1588
|
+
${border(1, rest)};
|
|
1599
1589
|
width: 100%;
|
|
1600
1590
|
min-height: 40px;
|
|
1601
1591
|
${!disabled && `
|
|
@@ -1831,6 +1821,9 @@ Dropdown.propTypes = {
|
|
|
1831
1821
|
/** the displayed value for each change */
|
|
1832
1822
|
value: PropTypes.oneOfType([PropTypes.string, PropTypes.number, PropTypes.array]),
|
|
1833
1823
|
|
|
1824
|
+
/** field name used for text display in input */
|
|
1825
|
+
keyExpr: PropTypes.oneOfType([PropTypes.string, PropTypes.number, PropTypes.array]),
|
|
1826
|
+
|
|
1834
1827
|
/** field name used for text display<br/>
|
|
1835
1828
|
* Example: 'name', '{id} - {name}', '{age} age(s)'<br/>
|
|
1836
1829
|
* Note: don't use 'id - name', return undefined
|
|
@@ -86,7 +86,7 @@ const InputBase = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
86
86
|
padding-top: 4px;
|
|
87
87
|
&:not(:focus-within):hover {
|
|
88
88
|
&::before {
|
|
89
|
-
border-bottom-color: ${colors.brand};
|
|
89
|
+
${!readOnly && `border-bottom-color: ${colors.brand}`};
|
|
90
90
|
}
|
|
91
91
|
}
|
|
92
92
|
&:focus-within {
|
|
@@ -125,11 +125,13 @@ const InputBase = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
125
125
|
box-sizing: border-box;
|
|
126
126
|
background-color: ${colors.white};
|
|
127
127
|
&:not(:focus-within):hover {
|
|
128
|
-
|
|
129
|
-
border-color: ${colors.brand};
|
|
130
|
-
input {
|
|
128
|
+
${!readOnly && `
|
|
131
129
|
background-color: ${colors.hover};
|
|
132
|
-
|
|
130
|
+
border-color: ${colors.brand};
|
|
131
|
+
input {
|
|
132
|
+
background-color: ${colors.hover};
|
|
133
|
+
}
|
|
134
|
+
`};
|
|
133
135
|
}
|
|
134
136
|
&:focus-within {
|
|
135
137
|
${!readOnly && `
|
|
@@ -280,11 +282,13 @@ const InputBase = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
280
282
|
color: ${colors.disabled};
|
|
281
283
|
} */
|
|
282
284
|
&:hover:not(:focus-within) {
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
::placeholder {
|
|
285
|
+
${!readOnly && `
|
|
286
|
+
border-color: ${colors.brand};
|
|
286
287
|
color: ${colors.primary};
|
|
287
|
-
|
|
288
|
+
::placeholder {
|
|
289
|
+
color: ${colors.primary};
|
|
290
|
+
}
|
|
291
|
+
`};
|
|
288
292
|
}
|
|
289
293
|
&:focus-within {
|
|
290
294
|
color: ${colors.primary};
|
|
@@ -316,11 +320,13 @@ const InputBase = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
316
320
|
height: 24px;
|
|
317
321
|
}
|
|
318
322
|
&:not(:focus-within):hover {
|
|
319
|
-
|
|
320
|
-
border-color: ${colors.brand};
|
|
321
|
-
input {
|
|
323
|
+
${!readOnly && `
|
|
322
324
|
background-color: ${colors.hover};
|
|
323
|
-
|
|
325
|
+
border-color: ${colors.brand};
|
|
326
|
+
input {
|
|
327
|
+
background-color: ${colors.hover};
|
|
328
|
+
}
|
|
329
|
+
`};
|
|
324
330
|
}
|
|
325
331
|
&:focus-within {
|
|
326
332
|
${!readOnly && `
|
|
@@ -351,17 +357,19 @@ const InputBase = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
351
357
|
height: 24px;
|
|
352
358
|
}
|
|
353
359
|
&:not(:focus-within):hover {
|
|
354
|
-
|
|
360
|
+
${!readOnly && `
|
|
361
|
+
&::before {
|
|
355
362
|
border-bottom-color: ${colors.brand};
|
|
356
|
-
|
|
363
|
+
}
|
|
364
|
+
`};
|
|
357
365
|
}
|
|
358
366
|
&:focus-within {
|
|
359
367
|
${!readOnly && `
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
368
|
+
&::after {
|
|
369
|
+
border-bottom-color: ${colors.info5};
|
|
370
|
+
transform: scaleX(1);
|
|
371
|
+
}
|
|
372
|
+
`}
|
|
365
373
|
}
|
|
366
374
|
&::before {
|
|
367
375
|
content: '';
|
|
@@ -8,10 +8,6 @@ import { jsx, css } from '@emotion/core';
|
|
|
8
8
|
import ModalContext from './context';
|
|
9
9
|
import { animations } from '../../styles/animation';
|
|
10
10
|
import { typography } from '../../styles/typography';
|
|
11
|
-
import { useTheme } from '../../theme';
|
|
12
|
-
const {
|
|
13
|
-
zIndex: zIndexCORE
|
|
14
|
-
} = useTheme();
|
|
15
11
|
import { borderBox, borderRadius4px, flexCol, flexRow, justifyCenter, parseWidth, positionFixed, positionRelative } from '../../styles/general';
|
|
16
12
|
import { color as colors } from '../../styles/colors';
|
|
17
13
|
const {
|
|
@@ -23,6 +19,10 @@ const {
|
|
|
23
19
|
}
|
|
24
20
|
} = colors;
|
|
25
21
|
const fadeInDown = animations.fadeInDown;
|
|
22
|
+
import { useTheme } from '../../theme';
|
|
23
|
+
const {
|
|
24
|
+
zIndex: zIndexCORE
|
|
25
|
+
} = useTheme();
|
|
26
26
|
const Modal = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
27
27
|
open,
|
|
28
28
|
moveable,
|
package/package.json
CHANGED
|
@@ -1,65 +1,42 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "diginet-core-ui",
|
|
3
|
-
"version": "1.3.
|
|
4
|
-
"description": "",
|
|
3
|
+
"version": "1.3.51",
|
|
4
|
+
"description": "The DigiNet core ui",
|
|
5
|
+
"homepage": "https://diginet.com.vn",
|
|
5
6
|
"main": "index.js",
|
|
6
|
-
"license": "UNLICENSED",
|
|
7
7
|
"scripts": {
|
|
8
|
-
"start": "
|
|
9
|
-
"start
|
|
10
|
-
"build
|
|
11
|
-
"
|
|
12
|
-
"
|
|
13
|
-
"build:darwin:linux:default": "rm -rf dist && npm run compile && sass --style=compressed src/scss:dist/css && cp -rf src/assets dist/assets",
|
|
14
|
-
"compile": "babel src --out-dir dist --ignore **/*.stories.js",
|
|
15
|
-
"pack": "npm run build && cp *.md dist/ && npm run version:bump --silent && npm run version:add --silent && cd dist && npm pack",
|
|
16
|
-
"production-keep-version": "npm run build && cp *.md dist/ && cp package.json dist/ && cd dist && npm publish",
|
|
17
|
-
"beta": "npm run build && cp *.md dist/ && cp package.json dist/ && cd dist && npm publish --tag beta",
|
|
18
|
-
"production": "npm run build && cp *.md dist/ && npm run version:bump --silent && npm run version:add --silent && cd dist && npm publish",
|
|
19
|
-
"version:add": "run-script-os",
|
|
20
|
-
"version:add:windows": "cat package.json.tmp | sed \"s/0.0.0/%npm_package_version%/g\" > dist/package.json",
|
|
21
|
-
"version:add:darwin:linux:default": "VERSION=$(npm run version:extract --silent) && cat package.json.tmp | sed \"s/0.0.0/${VERSION}/g\" > dist/package.json",
|
|
22
|
-
"version:bump": "npm version patch --no-git-tag-version --silent",
|
|
23
|
-
"version:extract": "cat package.json | grep version | head -1 | awk -F: '{ print $2 }' | sed 's/[\",]//g' | tr -d '[[:space:]]'",
|
|
24
|
-
"test": "echo \"Error: no test specified\" && exit 1",
|
|
25
|
-
"lint": "eslint --fix --config .eslintrc.js \"**/*.js\"",
|
|
26
|
-
"eslint-test": "onchange \"src/**/*.{js,jsx,json}\" -- eslint . --fix"
|
|
8
|
+
"start-js": "react-scripts start --max_old_space_size=4096",
|
|
9
|
+
"start": "npx npm-run-all -p start-js",
|
|
10
|
+
"build": "GENERATE_SOURCEMAP=false && react-scripts build --env=production --max_old_space_size=8192",
|
|
11
|
+
"eject": "react-scripts eject",
|
|
12
|
+
"test": "echo \"Error: no test specified\" && exit 1"
|
|
27
13
|
},
|
|
28
14
|
"dependencies": {
|
|
29
15
|
"@emotion/core": "^10.0.35",
|
|
30
16
|
"prop-types": "^15.7.2"
|
|
31
17
|
},
|
|
32
|
-
"
|
|
33
|
-
"
|
|
34
|
-
|
|
35
|
-
"git add"
|
|
36
|
-
]
|
|
18
|
+
"repository": {
|
|
19
|
+
"type": "git",
|
|
20
|
+
"url": "git+https://diginetvn@bitbucket.org/diginetvn/diginet-core-ui.git"
|
|
37
21
|
},
|
|
38
|
-
"
|
|
39
|
-
"
|
|
40
|
-
"
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
"react": "^17.0.1",
|
|
59
|
-
"react-dom": "^17.0.1",
|
|
60
|
-
"rimraf": "^3.0.2",
|
|
61
|
-
"run-script-os": "^1.1.6",
|
|
62
|
-
"sass": "^1.37.0",
|
|
63
|
-
"onchange": "^7.1.0"
|
|
64
|
-
}
|
|
22
|
+
"keywords": [
|
|
23
|
+
"core ui",
|
|
24
|
+
"diginet"
|
|
25
|
+
],
|
|
26
|
+
"author": "rocachien",
|
|
27
|
+
"contributors": [
|
|
28
|
+
{
|
|
29
|
+
"name": "Chien Do",
|
|
30
|
+
"email": "rocachien@gmail.com"
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
"name": "Nhat Tran",
|
|
34
|
+
"email": "tranminhnhat1005@gmail.com"
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
"name": "Thuan Nguyen",
|
|
38
|
+
"email": "nt.thuan.hutech@gmail.com"
|
|
39
|
+
}
|
|
40
|
+
],
|
|
41
|
+
"license": "MIT"
|
|
65
42
|
}
|
package/readme.md
CHANGED
|
@@ -38,6 +38,14 @@ npm test
|
|
|
38
38
|
```
|
|
39
39
|
|
|
40
40
|
## Changelog
|
|
41
|
+
## 1.3.51
|
|
42
|
+
- \[Fixed\]: THEME – Fix bug makeStyles add duplicate style tag into head tag
|
|
43
|
+
- \[Fixed\]: Accordion – Change css AccordionSummary; Fix when children of AccordionGroup null
|
|
44
|
+
- \[Fixed\]: InputBase – Fix disabled css
|
|
45
|
+
|
|
46
|
+
## 1.3.50
|
|
47
|
+
- \[Fixed\]: Dropdown – Fix dropdown onInput search
|
|
48
|
+
|
|
41
49
|
## 1.3.49
|
|
42
50
|
- \[Added\]: MenuIcon – WA3F0100, WA3F1025, WA3F2000, WA3F2020, WA3F2030, WA3F2040, WA3F2100
|
|
43
51
|
- \[Changed\]: Grid – Phát triển component Grid
|
package/styles/general.js
CHANGED
|
@@ -177,7 +177,7 @@ export const parseWidth = width => css`
|
|
|
177
177
|
export const parseHeight = height => css`
|
|
178
178
|
height: ${isNaN(height) ? height : height + 'px'};
|
|
179
179
|
`;
|
|
180
|
-
export const parseWidthHeight = (width, height) => css`
|
|
180
|
+
export const parseWidthHeight = (width, height = width) => css`
|
|
181
181
|
width: ${isNaN(width) ? width : width + 'px'};
|
|
182
182
|
height: ${isNaN(height) ? height : height + 'px'};
|
|
183
183
|
`;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { useState, useEffect } from 'react';
|
|
2
|
+
|
|
3
|
+
const useDelayUnmount = (isMounted, delayTime) => {
|
|
4
|
+
const [show, setShow] = useState(false);
|
|
5
|
+
useEffect(() => {
|
|
6
|
+
let timeoutId;
|
|
7
|
+
|
|
8
|
+
if (isMounted && !show) {
|
|
9
|
+
setShow(true);
|
|
10
|
+
} else if (!isMounted && show) {
|
|
11
|
+
timeoutId = setTimeout(() => setShow(false), delayTime);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
return () => clearTimeout(timeoutId);
|
|
15
|
+
}, [isMounted, delayTime, show]);
|
|
16
|
+
return show;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export default useDelayUnmount;
|