diginet-core-ui 1.4.6-beta.1 → 1.4.7-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.
|
@@ -144,7 +144,7 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
144
144
|
const _InputCSS = InputCSS(multiple, typeof renderSelectedItem === 'function');
|
|
145
145
|
const _DropdownInputCSS = DropdownInputCSS(viewType, multiple, placeholder, disabled, readOnly, multilineSelectedItem);
|
|
146
146
|
const _IconCSS = IconCSS(viewType);
|
|
147
|
-
const _DropdownFormCSS = DropdownFormCSS(viewType, multiple, disabled, placeholder, _DropdownInputCSS.name);
|
|
147
|
+
const _DropdownFormCSS = DropdownFormCSS(viewType, multiple, disabled, readOnly, placeholder, _DropdownInputCSS.name);
|
|
148
148
|
const _DropdownListCSS = DropdownListCSS(loadingState);
|
|
149
149
|
const _DropdownItemCSS = DropdownItemCSS(multiple, selectBox);
|
|
150
150
|
const _DropdownRootCSS = DropdownRootCSS(_DropdownFormCSS.name, _DropdownInputCSS.name);
|
|
@@ -360,7 +360,7 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
360
360
|
// convert {id} - {name} to {<data[id]>} - {<data[name]>}
|
|
361
361
|
if (!mask && regexBetween.test(displayExpr)) {
|
|
362
362
|
var _displayExpr;
|
|
363
|
-
mask = (_displayExpr = displayExpr) === null || _displayExpr === void 0 ? void 0 : _displayExpr.replace(regexBetween, _ => data[_]);
|
|
363
|
+
mask = (_displayExpr = displayExpr) === null || _displayExpr === void 0 ? void 0 : _displayExpr.replace(regexBetween, _ => (data === null || data === void 0 ? void 0 : data[_]) || '');
|
|
364
364
|
} else if (!mask) {
|
|
365
365
|
mask = typeof data !== 'object' ? data : '';
|
|
366
366
|
}
|
|
@@ -544,7 +544,7 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
544
544
|
};
|
|
545
545
|
// Nếu đối tượng đã được hiển thị ở trên rồi thì không hiển thị ra nữa
|
|
546
546
|
if (onLoadMore && i > notExistItem && currentObjectDefault[unique].some(valueObject => valueObject[valueExpr] === data[valueExpr])) continue;
|
|
547
|
-
let displayText = typeof data === 'object' ? keyArr ?
|
|
547
|
+
let displayText = typeof data === 'object' ? keyArr ? displayValue(data) : data[displayExpr] || data[valueExpr] : data;
|
|
548
548
|
if (pattern && !new RegExp(pattern).test(displayText.normalize())) continue;
|
|
549
549
|
const value = typeof data === 'object' ? data[valueExpr] : data;
|
|
550
550
|
const icon = getIconFromData(data);
|
|
@@ -599,18 +599,24 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
599
599
|
}
|
|
600
600
|
}
|
|
601
601
|
};
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
602
|
+
|
|
603
|
+
// const renderData = (data, keyArr) => {
|
|
604
|
+
// const pattern = keyArr.join('|').replace(/([{}])/g, '\\$1');
|
|
605
|
+
// const separatorArr = displayExpr.split(new RegExp(pattern));
|
|
606
|
+
// let str = '';
|
|
607
|
+
// let i = 0;
|
|
608
|
+
// for (i; i < keyArr.length; i++) {
|
|
609
|
+
// str +=
|
|
610
|
+
// separatorArr[i] +
|
|
611
|
+
// (data[keyArr[i].replace(/\W/g, '')] !== undefined
|
|
612
|
+
// ? data[keyArr[i].replace(/\W/g, '')]
|
|
613
|
+
// : keyArr[i]);
|
|
614
|
+
// }
|
|
615
|
+
// return str + separatorArr[i];
|
|
616
|
+
// };
|
|
617
|
+
|
|
612
618
|
const getIconFromData = (data, insideChip = false) => {
|
|
613
|
-
if (!iconExpr || iconExpr === 'none') return null;
|
|
619
|
+
if (!data || !iconExpr || iconExpr === 'none') return null;
|
|
614
620
|
let _src;
|
|
615
621
|
if (typeof iconExpr === 'string') _src = data[iconExpr];else {
|
|
616
622
|
let prefix = iconExpr.prefix || '';
|
|
@@ -1054,7 +1060,7 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
1054
1060
|
currentValue[unique].push(value);
|
|
1055
1061
|
};
|
|
1056
1062
|
const setSingleValueHandler = (data, keyArr) => {
|
|
1057
|
-
const text = keyArr ?
|
|
1063
|
+
const text = keyArr ? displayValue(data) : typeof renderSelectedItem === 'string' ? data[renderSelectedItem] : data[displayExpr] || data[valueExpr] || data;
|
|
1058
1064
|
const renderContent = content => jsx(Typography, {
|
|
1059
1065
|
type: 'p1',
|
|
1060
1066
|
lineClamp: multilineSelectedItem ? undefined : 1,
|
|
@@ -1314,43 +1320,28 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
1314
1320
|
}, valueMulti.map((vl, index) => {
|
|
1315
1321
|
let dataFilter = getData();
|
|
1316
1322
|
const data = dataFilter.find(v => v[valueExpr] === vl || v === vl);
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1323
|
+
if (data) {
|
|
1324
|
+
const displayText = displayValue(data);
|
|
1325
|
+
let item;
|
|
1326
|
+
if (typeof renderSelectedItem === 'function') {
|
|
1327
|
+
item = renderSelectedItem({
|
|
1328
|
+
data,
|
|
1329
|
+
index
|
|
1330
|
+
});
|
|
1331
|
+
} else {
|
|
1332
|
+
item = jsx(Chip, {
|
|
1333
|
+
css: [parseWidth('100%'), parseMaxWidth('max-content')],
|
|
1334
|
+
key: index,
|
|
1335
|
+
startIcon: getIconFromData(data, true),
|
|
1336
|
+
label: displayText,
|
|
1337
|
+
size: 'medium',
|
|
1338
|
+
disabled: disabled,
|
|
1339
|
+
clearAble: !readOnly && !disabled,
|
|
1340
|
+
onRemove: e => onRemove(e, vl)
|
|
1341
|
+
});
|
|
1332
1342
|
}
|
|
1333
|
-
|
|
1334
|
-
}
|
|
1335
|
-
let item;
|
|
1336
|
-
if (typeof renderSelectedItem === 'function') {
|
|
1337
|
-
item = renderSelectedItem({
|
|
1338
|
-
data,
|
|
1339
|
-
index
|
|
1340
|
-
});
|
|
1341
|
-
} else {
|
|
1342
|
-
item = jsx(Chip, {
|
|
1343
|
-
css: [parseWidth('100%'), parseMaxWidth('max-content')],
|
|
1344
|
-
key: index,
|
|
1345
|
-
startIcon: getIconFromData(data, true),
|
|
1346
|
-
label: text,
|
|
1347
|
-
size: 'medium',
|
|
1348
|
-
disabled: disabled,
|
|
1349
|
-
clearAble: !readOnly && !disabled,
|
|
1350
|
-
onRemove: e => onRemove(e, vl)
|
|
1351
|
-
});
|
|
1343
|
+
return item;
|
|
1352
1344
|
}
|
|
1353
|
-
return item;
|
|
1354
1345
|
})) : typeof renderSelectedItem === 'function' || iconExpr && iconExpr !== 'none' ? jsx("div", {
|
|
1355
1346
|
...inputProps,
|
|
1356
1347
|
style: inputStyle,
|
|
@@ -1491,7 +1482,7 @@ const IconCSS = viewType => css`
|
|
|
1491
1482
|
${mgl([2])};
|
|
1492
1483
|
${mgr([viewType !== 'outlined' ? 0 : 4])};
|
|
1493
1484
|
`;
|
|
1494
|
-
const DropdownFormCSS = (viewType, multiple, disabled, placeholder, DropdownInputCSSName) => viewType !== 'outlined' ? css`
|
|
1485
|
+
const DropdownFormCSS = (viewType, multiple, disabled, readOnly, placeholder, DropdownInputCSSName) => viewType !== 'outlined' ? css`
|
|
1495
1486
|
${displayFlex};
|
|
1496
1487
|
${flexRow};
|
|
1497
1488
|
${itemsCenter};
|
|
@@ -1499,7 +1490,7 @@ const DropdownFormCSS = (viewType, multiple, disabled, placeholder, DropdownInpu
|
|
|
1499
1490
|
${boxBorder};
|
|
1500
1491
|
${parseWidth('100%')};
|
|
1501
1492
|
${pdy([multiple ? 0.25 : 1])};
|
|
1502
|
-
${!disabled && css`
|
|
1493
|
+
${!disabled && !readOnly && css`
|
|
1503
1494
|
&:not(:focus-within):hover {
|
|
1504
1495
|
&::before {
|
|
1505
1496
|
${borderBottomColor('system/active')};
|
|
@@ -1559,7 +1550,7 @@ const DropdownFormCSS = (viewType, multiple, disabled, placeholder, DropdownInpu
|
|
|
1559
1550
|
${parseWidth('100%')};
|
|
1560
1551
|
${parseMinHeight(40)};
|
|
1561
1552
|
${mgt([0.5])};
|
|
1562
|
-
${!disabled && css`
|
|
1553
|
+
${!disabled && !readOnly && css`
|
|
1563
1554
|
&:not(:focus-within):hover {
|
|
1564
1555
|
${bgColor('fill/hover')};
|
|
1565
1556
|
${borderColor('system/active')};
|
|
@@ -82,13 +82,13 @@ const NumberInput = /*#__PURE__*/forwardRef(({
|
|
|
82
82
|
|
|
83
83
|
// if (valueProps || valueProps === 0) valueProps = clamp(valueProps, min, max);
|
|
84
84
|
|
|
85
|
-
/**
|
|
86
|
-
* Convert number to format money
|
|
87
|
-
* @param vl {number} - value
|
|
88
|
-
* @type {function}
|
|
89
|
-
* @return {string}
|
|
90
|
-
* @example 1200300.123 => 1,200,300.123
|
|
91
|
-
* @example 1200300,123 => 1.200.300,123
|
|
85
|
+
/**
|
|
86
|
+
* Convert number to format money
|
|
87
|
+
* @param vl {number} - value
|
|
88
|
+
* @type {function}
|
|
89
|
+
* @return {string}
|
|
90
|
+
* @example 1200300.123 => 1,200,300.123
|
|
91
|
+
* @example 1200300,123 => 1.200.300,123
|
|
92
92
|
*/
|
|
93
93
|
const parseNumberToMoney = useCallback((vl, isNumber) => {
|
|
94
94
|
var _number, _number2, _number$, _number3;
|
|
@@ -124,13 +124,13 @@ const NumberInput = /*#__PURE__*/forwardRef(({
|
|
|
124
124
|
return number;
|
|
125
125
|
}, [decimalSymbol, max, value]);
|
|
126
126
|
|
|
127
|
-
/**
|
|
128
|
-
* Convert money to format number
|
|
129
|
-
* @param vl {string} - value
|
|
130
|
-
* @type {function}
|
|
131
|
-
* @return {number}
|
|
132
|
-
* @example 1,200,300.123 => 1200300.123
|
|
133
|
-
* @example 1.200.300,123 => 1200300.123
|
|
127
|
+
/**
|
|
128
|
+
* Convert money to format number
|
|
129
|
+
* @param vl {string} - value
|
|
130
|
+
* @type {function}
|
|
131
|
+
* @return {number}
|
|
132
|
+
* @example 1,200,300.123 => 1200300.123
|
|
133
|
+
* @example 1.200.300,123 => 1200300.123
|
|
134
134
|
*/
|
|
135
135
|
const convertMoneyToNumber = useCallback((vl, isNumber) => {
|
|
136
136
|
var _number4, _number4$toString, _number4$toString$rep, _number4$toString$rep2, _number4$toString$rep3;
|
|
@@ -440,10 +440,10 @@ NumberInput.propTypes = {
|
|
|
440
440
|
style: PropTypes.object,
|
|
441
441
|
/** Thousand separator character. */
|
|
442
442
|
thousandSeparator: PropTypes.oneOfType([PropTypes.bool, PropTypes.oneOf(['.', ','])]),
|
|
443
|
-
/** Validation value, argument can:<br/>
|
|
444
|
-
* * string: the validation rule. Example required.<br/>
|
|
445
|
-
* * object: the validation rule insist name, property, message. Example {name: 'min', compareValue: 9, message: 'Error'} or {max: 99}<br/>
|
|
446
|
-
* * array: the validation rule list, insist object/string
|
|
443
|
+
/** Validation value, argument can:<br/>
|
|
444
|
+
* * string: the validation rule. Example required.<br/>
|
|
445
|
+
* * object: the validation rule insist name, property, message. Example {name: 'min', compareValue: 9, message: 'Error'} or {max: 99}<br/>
|
|
446
|
+
* * array: the validation rule list, insist object/string
|
|
447
447
|
*/
|
|
448
448
|
validates: PropTypes.oneOfType([PropTypes.string, PropTypes.object, PropTypes.array, PropTypes.func]),
|
|
449
449
|
/** The value of the input element, required for a controlled component. */
|
package/package.json
CHANGED