diginet-core-ui 1.4.55-beta.8.5 → 1.4.56-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.
|
@@ -11,6 +11,7 @@ import { animation, bgColor, border, borderBottom, borderBottomColor, borderColo
|
|
|
11
11
|
import { useTheme } from "../../../theme";
|
|
12
12
|
import useThemeProps from "../../../theme/utils/useThemeProps";
|
|
13
13
|
import { classNames, getProp, isMobile, randomString } from "../../../utils";
|
|
14
|
+
import { isEmpty, typeOf } from "../../../utils/type";
|
|
14
15
|
const currentValue = {},
|
|
15
16
|
isSearch = {},
|
|
16
17
|
allValue = {};
|
|
@@ -135,6 +136,7 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, reference)
|
|
|
135
136
|
const loadMoreTimer = useRef(null);
|
|
136
137
|
const dataChosen = useRef([]);
|
|
137
138
|
const popupRef = useRef(null);
|
|
139
|
+
const valueObjectDefaultInit = useRef({});
|
|
138
140
|
const filter = useRef({
|
|
139
141
|
skip: skip || 0,
|
|
140
142
|
limit: limit || 50
|
|
@@ -297,10 +299,10 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, reference)
|
|
|
297
299
|
});
|
|
298
300
|
};
|
|
299
301
|
|
|
300
|
-
/**
|
|
301
|
-
* So sánh text đầu vào cáo map với txtSearch
|
|
302
|
-
* @param text
|
|
303
|
-
* @return {boolean}
|
|
302
|
+
/**
|
|
303
|
+
* So sánh text đầu vào cáo map với txtSearch
|
|
304
|
+
* @param text
|
|
305
|
+
* @return {boolean}
|
|
304
306
|
*/
|
|
305
307
|
const handleRenderBySearch = (text = '') => {
|
|
306
308
|
if (text === null || text === undefined) text = '';
|
|
@@ -313,17 +315,18 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, reference)
|
|
|
313
315
|
} else return text.toLowerCase().includes(txtSearch.toLowerCase());
|
|
314
316
|
};
|
|
315
317
|
|
|
316
|
-
/**
|
|
317
|
-
* Chuyển đổi data thành giá trị cần hiện thị dựa vào displayExpr [string, string object {field} - {field}], renderSelectedItem, displayExpr, valueExpr
|
|
318
|
-
* @param data {object} rowData of dataSource
|
|
319
|
-
* @return {string}
|
|
318
|
+
/**
|
|
319
|
+
* Chuyển đổi data thành giá trị cần hiện thị dựa vào displayExpr [string, string object {field} - {field}], renderSelectedItem, displayExpr, valueExpr
|
|
320
|
+
* @param data {object} rowData of dataSource
|
|
321
|
+
* @return {string}
|
|
320
322
|
*/
|
|
321
323
|
const displayValue = data => {
|
|
322
324
|
let text = '';
|
|
323
325
|
let isReplace = true;
|
|
324
326
|
if (data || data === 0) {
|
|
327
|
+
var _data$displayExpr;
|
|
325
328
|
displayExpr = displayExpr || valueExpr;
|
|
326
|
-
let mask = data === null || data === void 0 ? void 0 : data[displayExpr];
|
|
329
|
+
let mask = typeOf(data === null || data === void 0 ? void 0 : data[displayExpr], 'array') ? ((_data$displayExpr = data[displayExpr]) === null || _data$displayExpr === void 0 ? void 0 : _data$displayExpr[0]) || '' : data === null || data === void 0 ? void 0 : data[displayExpr];
|
|
327
330
|
// convert {id} - {name} to {<data[id]>} - {<data[name]>}
|
|
328
331
|
if (selectAll && (data === null || data === void 0 ? void 0 : data[valueExpr]) === 'all') {
|
|
329
332
|
isReplace = false;
|
|
@@ -342,6 +345,43 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, reference)
|
|
|
342
345
|
var _dataSourceUsable2;
|
|
343
346
|
const items = [];
|
|
344
347
|
let dataSourceUsable = [...dataSourceState];
|
|
348
|
+
if (vlObjDefaultState && (vlObjDefaultState === null || vlObjDefaultState === void 0 ? void 0 : vlObjDefaultState.length) > 0 && isEmpty(txtSearch)) {
|
|
349
|
+
// Sẽ Xem Lại
|
|
350
|
+
// if (vlObjDefaultState && vlObjDefaultState?.length > 0) {
|
|
351
|
+
const length = vlObjDefaultState === null || vlObjDefaultState === void 0 ? void 0 : vlObjDefaultState.length;
|
|
352
|
+
let existItemQuantity = 0;
|
|
353
|
+
for (let index = length - 1; index >= 0; index--) {
|
|
354
|
+
if ((vlObjDefaultState[index][valueExpr] || vlObjDefaultState[index][valueExpr] === 0) && !dataSourceUsable.some(data => data[valueExpr] === vlObjDefaultState[index][valueExpr])) {
|
|
355
|
+
if (isMultipleVal(vlObjDefaultState[index])) {
|
|
356
|
+
if (isEmpty(valueObjectDefaultInit.current)) {
|
|
357
|
+
let dataCloneDeep = {};
|
|
358
|
+
for (const name in vlObjDefaultState[index]) {
|
|
359
|
+
var _vlObjDefaultState$in;
|
|
360
|
+
if (name) dataCloneDeep[name] = (((_vlObjDefaultState$in = vlObjDefaultState[index]) === null || _vlObjDefaultState$in === void 0 ? void 0 : _vlObjDefaultState$in[name]) || []).map(item => item);
|
|
361
|
+
}
|
|
362
|
+
if (!isEmpty(dataCloneDeep)) valueObjectDefaultInit.current = dataCloneDeep;
|
|
363
|
+
const valueObjectDefaultOrigin = {
|
|
364
|
+
...valueObjectDefaultInit.current
|
|
365
|
+
} || {};
|
|
366
|
+
const arr = (valueObjectDefaultOrigin === null || valueObjectDefaultOrigin === void 0 ? void 0 : valueObjectDefaultOrigin[valueExpr]) || [];
|
|
367
|
+
for (let i = 0; i < arr.length; i++) {
|
|
368
|
+
let objData = {};
|
|
369
|
+
for (const name in valueObjectDefaultOrigin) {
|
|
370
|
+
var _valueObjectDefaultOr;
|
|
371
|
+
if (name) objData[name] = (valueObjectDefaultOrigin === null || valueObjectDefaultOrigin === void 0 ? void 0 : (_valueObjectDefaultOr = valueObjectDefaultOrigin[name]) === null || _valueObjectDefaultOr === void 0 ? void 0 : _valueObjectDefaultOr[i]) || '';
|
|
372
|
+
}
|
|
373
|
+
dataSourceUsable.unshift(objData);
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
} else dataSourceUsable.unshift(vlObjDefaultState[index]);
|
|
377
|
+
} else {
|
|
378
|
+
// Nếu số lượng phần tử của valueObjectDefault tồn tại trong dataSource nhiều hơn hoặc bằng limit thì không remove nữa
|
|
379
|
+
if (++existItemQuantity > limit) {
|
|
380
|
+
continue;
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
}
|
|
345
385
|
|
|
346
386
|
// search dataSource dựa trên txtSearch
|
|
347
387
|
if (!onInput) {
|
|
@@ -358,20 +398,6 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, reference)
|
|
|
358
398
|
});
|
|
359
399
|
}
|
|
360
400
|
}
|
|
361
|
-
if (vlObjDefaultState && (vlObjDefaultState === null || vlObjDefaultState === void 0 ? void 0 : vlObjDefaultState.length) > 0) {
|
|
362
|
-
const length = vlObjDefaultState === null || vlObjDefaultState === void 0 ? void 0 : vlObjDefaultState.length;
|
|
363
|
-
let existItemQuantity = 0;
|
|
364
|
-
for (let index = length - 1; index >= 0; index--) {
|
|
365
|
-
if ((vlObjDefaultState[index][valueExpr] || vlObjDefaultState[index][valueExpr] === 0) && !dataSourceUsable.some(data => data[valueExpr] === vlObjDefaultState[index][valueExpr])) {
|
|
366
|
-
dataSourceUsable.unshift(vlObjDefaultState[index]);
|
|
367
|
-
} else {
|
|
368
|
-
// Nếu số lượng phần tử của valueObjectDefault tồn tại trong dataSource nhiều hơn hoặc bằng limit thì không remove nữa
|
|
369
|
-
if (++existItemQuantity > limit) {
|
|
370
|
-
continue;
|
|
371
|
-
}
|
|
372
|
-
}
|
|
373
|
-
}
|
|
374
|
-
}
|
|
375
401
|
const length = (_dataSourceUsable2 = dataSourceUsable) === null || _dataSourceUsable2 === void 0 ? void 0 : _dataSourceUsable2.length;
|
|
376
402
|
for (let index = 0; index < length; index++) {
|
|
377
403
|
const data = dataSourceUsable[index];
|
|
@@ -399,10 +425,11 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, reference)
|
|
|
399
425
|
data,
|
|
400
426
|
index
|
|
401
427
|
}) : jsx(Typography, {
|
|
428
|
+
lineClamp: 1,
|
|
402
429
|
type: 'p1'
|
|
403
430
|
}, displayText);
|
|
404
431
|
if (multiple && selectBox) {
|
|
405
|
-
let checked = valueMulti.includes(value);
|
|
432
|
+
let checked = typeOf(value, 'array') ? valueMulti.some(item => value.includes(item)) : valueMulti.includes(value);
|
|
406
433
|
if (selectAll && value === 'all') checked = selectAll && value === 'all' && valueMulti.length > 0;
|
|
407
434
|
const isMaximumSelection = maximumSelectionLength === (valueMulti === null || valueMulti === void 0 ? void 0 : valueMulti.length);
|
|
408
435
|
itemDisabled = itemDisabled || isMaximumSelection && !checked;
|
|
@@ -423,7 +450,12 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, reference)
|
|
|
423
450
|
value: value,
|
|
424
451
|
disabled: itemDisabled,
|
|
425
452
|
onChange: e => onChangeValue(e, displayText, value, icon, data, index)
|
|
426
|
-
},
|
|
453
|
+
}, jsx("div", {
|
|
454
|
+
style: {
|
|
455
|
+
display: 'flex',
|
|
456
|
+
alignItems: 'center'
|
|
457
|
+
}
|
|
458
|
+
}, icon, text))));
|
|
427
459
|
} else {
|
|
428
460
|
items.push(jsx("div", {
|
|
429
461
|
key: index,
|
|
@@ -486,7 +518,9 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, reference)
|
|
|
486
518
|
const dataSourceUsable = [...dataSourceState];
|
|
487
519
|
// Nếu có load more thì đẩy đội tượng mặc định lên đầu
|
|
488
520
|
let notExistItem = 0;
|
|
489
|
-
if (onLoadMore && vlObjDefaultState !== null && vlObjDefaultState !== void 0 && vlObjDefaultState.length) {
|
|
521
|
+
if (onLoadMore && vlObjDefaultState !== null && vlObjDefaultState !== void 0 && vlObjDefaultState.length && isEmpty(txtSearch)) {
|
|
522
|
+
// Sẽ Xem Lại
|
|
523
|
+
// if (onLoadMore && vlObjDefaultState?.length) {
|
|
490
524
|
const length = vlObjDefaultState.length;
|
|
491
525
|
for (let index = length - 1; index >= 0; index--) {
|
|
492
526
|
if (!dataSourceUsable.some(data => data[valueExpr] === vlObjDefaultState[index][valueExpr])) {
|
|
@@ -550,7 +584,7 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, reference)
|
|
|
550
584
|
} else {
|
|
551
585
|
item = jsx(Fragment, null, icon, text);
|
|
552
586
|
}
|
|
553
|
-
if (!dropdownListRef.current) {
|
|
587
|
+
if (!dropdownListRef.current || isEmpty(txtSearch)) {
|
|
554
588
|
return;
|
|
555
589
|
}
|
|
556
590
|
ReactDOM.render(item, dropdownListRef.current.appendChild(dropdownItem));
|
|
@@ -997,7 +1031,7 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, reference)
|
|
|
997
1031
|
if (valueProp !== undefined && (!dropdownListRef.current || children || JSON.stringify(valueProp) !== JSON.stringify(currentValue[unique]))) {
|
|
998
1032
|
setValueIntoInput(valueProp);
|
|
999
1033
|
if (oneLiner && multiple) {
|
|
1000
|
-
const valueArray = sortMultiple(valueProp);
|
|
1034
|
+
const valueArray = sortMultiple(valueProp, true);
|
|
1001
1035
|
setValueMultiDisplay(valueArray === null || valueArray === void 0 ? void 0 : valueArray.display);
|
|
1002
1036
|
setValueMultiOverflow(valueArray === null || valueArray === void 0 ? void 0 : valueArray.overflow);
|
|
1003
1037
|
if ((valueArray === null || valueArray === void 0 ? void 0 : valueArray.overflow.length) === 0 && openMultipleOverflow) {
|
|
@@ -1098,9 +1132,34 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, reference)
|
|
|
1098
1132
|
disabled: disabled,
|
|
1099
1133
|
...labelProps
|
|
1100
1134
|
}, label) : null, [label, required, disabled, labelProps]);
|
|
1135
|
+
const isMultipleVal = (objData = {}) => {
|
|
1136
|
+
let status = false;
|
|
1137
|
+
if (typeOf(objData === null || objData === void 0 ? void 0 : objData[valueExpr], 'array') && !isEmpty(objData === null || objData === void 0 ? void 0 : objData[valueExpr]) || typeOf(objData === null || objData === void 0 ? void 0 : objData[displayExpr], 'array') && !isEmpty(objData === null || objData === void 0 ? void 0 : objData[displayExpr])) {
|
|
1138
|
+
status = true;
|
|
1139
|
+
}
|
|
1140
|
+
return status;
|
|
1141
|
+
};
|
|
1101
1142
|
const getData = () => {
|
|
1143
|
+
var _valObjDefault;
|
|
1102
1144
|
let dataFilter = JSON.parse(JSON.stringify(dataSourceState));
|
|
1103
|
-
|
|
1145
|
+
let valObjDefault = vlObjDefaultState;
|
|
1146
|
+
if (isMultipleVal((_valObjDefault = valObjDefault) === null || _valObjDefault === void 0 ? void 0 : _valObjDefault[0])) {
|
|
1147
|
+
var _vlObjDefaultState$;
|
|
1148
|
+
valObjDefault = [];
|
|
1149
|
+
const arr = (vlObjDefaultState === null || vlObjDefaultState === void 0 ? void 0 : (_vlObjDefaultState$ = vlObjDefaultState[0]) === null || _vlObjDefaultState$ === void 0 ? void 0 : _vlObjDefaultState$[valueExpr]) || [];
|
|
1150
|
+
for (let i = 0; i < arr.length; i++) {
|
|
1151
|
+
let objData = {};
|
|
1152
|
+
for (const name in vlObjDefaultState[0]) {
|
|
1153
|
+
var _vlObjDefaultState$2;
|
|
1154
|
+
if (name) objData[name] = (_vlObjDefaultState$2 = vlObjDefaultState[0]) === null || _vlObjDefaultState$2 === void 0 ? void 0 : _vlObjDefaultState$2[name][i];
|
|
1155
|
+
}
|
|
1156
|
+
if (!isEmpty(objData)) valObjDefault.push(objData);
|
|
1157
|
+
}
|
|
1158
|
+
}
|
|
1159
|
+
dataFilter = uniqBy([...valObjDefault, ...dataFilter], data => {
|
|
1160
|
+
let result = data === null || data === void 0 ? void 0 : data[valueExpr];
|
|
1161
|
+
return result;
|
|
1162
|
+
});
|
|
1104
1163
|
return dataFilter;
|
|
1105
1164
|
};
|
|
1106
1165
|
const getTextWidth = text => {
|
|
@@ -1127,8 +1186,8 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, reference)
|
|
|
1127
1186
|
const inputWidth = inputElement === null || inputElement === void 0 ? void 0 : inputElement.clientWidth;
|
|
1128
1187
|
const items = [];
|
|
1129
1188
|
if ((valueMulti === null || valueMulti === void 0 ? void 0 : valueMulti.length) > 0) {
|
|
1189
|
+
const dataFilter = getData();
|
|
1130
1190
|
value.map((vl, index) => {
|
|
1131
|
-
const dataFilter = getData();
|
|
1132
1191
|
const data = dataFilter.find(v => v[valueExpr] === vl || v === vl);
|
|
1133
1192
|
if (data) {
|
|
1134
1193
|
const displayText = displayValue(data);
|
|
@@ -1181,8 +1240,8 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, reference)
|
|
|
1181
1240
|
const renderMultipleItem = value => {
|
|
1182
1241
|
const items = [];
|
|
1183
1242
|
if ((valueMulti === null || valueMulti === void 0 ? void 0 : valueMulti.length) > 0) {
|
|
1243
|
+
const dataFilter = getData();
|
|
1184
1244
|
value.map((vl, index) => {
|
|
1185
|
-
const dataFilter = getData();
|
|
1186
1245
|
const data = dataFilter.find(v => v[valueExpr] === vl || v === vl);
|
|
1187
1246
|
if (data) {
|
|
1188
1247
|
const displayText = displayValue(data);
|
|
@@ -1251,8 +1310,8 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, reference)
|
|
|
1251
1310
|
const renderOverflowPopover = value => {
|
|
1252
1311
|
const items = [];
|
|
1253
1312
|
if ((valueMulti === null || valueMulti === void 0 ? void 0 : valueMulti.length) > 0) {
|
|
1313
|
+
const dataFilter = getData();
|
|
1254
1314
|
value.map((vl, index) => {
|
|
1255
|
-
const dataFilter = getData();
|
|
1256
1315
|
const data = dataFilter.find(v => v[valueExpr] === vl || v === vl);
|
|
1257
1316
|
if (data) {
|
|
1258
1317
|
const displayText = displayValue(data);
|
|
@@ -1743,9 +1802,9 @@ Dropdown.propTypes = {
|
|
|
1743
1802
|
defaultValue: PropTypes.oneOfType([PropTypes.string, PropTypes.number, PropTypes.array]),
|
|
1744
1803
|
/** If `true`, the component is disabled. */
|
|
1745
1804
|
disabled: PropTypes.bool,
|
|
1746
|
-
/** The field name used for displaying text in the dropdown list.<br/>
|
|
1747
|
-
* Examples: 'name', '{id} - {name}', '{age} age(s)'<br/>
|
|
1748
|
-
* Note: Do not use 'id - name', as it will return undefined.
|
|
1805
|
+
/** The field name used for displaying text in the dropdown list.<br/>
|
|
1806
|
+
* Examples: 'name', '{id} - {name}', '{age} age(s)'<br/>
|
|
1807
|
+
* Note: Do not use 'id - name', as it will return undefined.
|
|
1749
1808
|
*/
|
|
1750
1809
|
displayExpr: PropTypes.oneOfType([PropTypes.string, PropTypes.number, PropTypes.array]),
|
|
1751
1810
|
/** Inline style for dropdown items. */
|
|
@@ -1754,14 +1813,14 @@ Dropdown.propTypes = {
|
|
|
1754
1813
|
error: PropTypes.oneOfType([PropTypes.bool, PropTypes.string]),
|
|
1755
1814
|
/** Props applied to the [HelperText](https://core.diginet.com.vn/ui/?path=/story/form-control-text-helpertext) element. */
|
|
1756
1815
|
helperTextProps: PropTypes.object,
|
|
1757
|
-
/** The field name used for displaying icons.<br/>
|
|
1758
|
-
* Example:<br/>
|
|
1759
|
-
* string: 'icon'<br/>
|
|
1760
|
-
* object: {<br/>
|
|
1761
|
-
* key: 'icon',<br/>
|
|
1762
|
-
* prefix: 'https://imglink.com',<br/>
|
|
1763
|
-
* suffix: '.jpg'<br/>
|
|
1764
|
-
* }
|
|
1816
|
+
/** The field name used for displaying icons.<br/>
|
|
1817
|
+
* Example:<br/>
|
|
1818
|
+
* string: 'icon'<br/>
|
|
1819
|
+
* object: {<br/>
|
|
1820
|
+
* key: 'icon',<br/>
|
|
1821
|
+
* prefix: 'https://imglink.com',<br/>
|
|
1822
|
+
* suffix: '.jpg'<br/>
|
|
1823
|
+
* }
|
|
1765
1824
|
*/
|
|
1766
1825
|
iconExpr: PropTypes.oneOfType([PropTypes.string, PropTypes.shape({
|
|
1767
1826
|
key: PropTypes.string,
|
|
@@ -1795,8 +1854,8 @@ Dropdown.propTypes = {
|
|
|
1795
1854
|
onChange: PropTypes.func,
|
|
1796
1855
|
/** Callback function fired when the dropdown is closed. */
|
|
1797
1856
|
onClosed: PropTypes.func,
|
|
1798
|
-
/** Callback function fired when the input value changes.<br/>
|
|
1799
|
-
* If undefined, the filter function will run (default behavior).
|
|
1857
|
+
/** Callback function fired when the input value changes.<br/>
|
|
1858
|
+
* If undefined, the filter function will run (default behavior).
|
|
1800
1859
|
*/
|
|
1801
1860
|
onInput: PropTypes.func,
|
|
1802
1861
|
/** Callback function fired when a key is pressed down in the input. */
|
|
@@ -1809,21 +1868,21 @@ Dropdown.propTypes = {
|
|
|
1809
1868
|
placeholder: PropTypes.string,
|
|
1810
1869
|
/** If `true`, the component is read-only. */
|
|
1811
1870
|
readOnly: PropTypes.bool,
|
|
1812
|
-
/** Function used for custom rendering of items.<br/>
|
|
1813
|
-
* Example: `(data, index) => data.name + ' - ' + data.role`<br/>
|
|
1814
|
-
* This can be used as an alternative to `displayExpr`
|
|
1871
|
+
/** Function used for custom rendering of items.<br/>
|
|
1872
|
+
* Example: `(data, index) => data.name + ' - ' + data.role`<br/>
|
|
1873
|
+
* This can be used as an alternative to `displayExpr`
|
|
1815
1874
|
*/
|
|
1816
1875
|
renderItem: PropTypes.func,
|
|
1817
|
-
/** Function or field name used to display selected items.<br/>
|
|
1818
|
-
* Example: `(data, index) => index + ' - ' + data.name`<br/>
|
|
1876
|
+
/** Function or field name used to display selected items.<br/>
|
|
1877
|
+
* Example: `(data, index) => index + ' - ' + data.name`<br/>
|
|
1819
1878
|
*/
|
|
1820
1879
|
renderSelectedItem: PropTypes.oneOfType([PropTypes.func, PropTypes.string]),
|
|
1821
1880
|
/** If `true`, the label will indicate that the input is required. */
|
|
1822
1881
|
required: PropTypes.bool,
|
|
1823
|
-
/**
|
|
1824
|
-
* Duration to wait after entering search content before triggering a search.<br/>
|
|
1825
|
-
* Example: 700 -> 700ms, '700ms' -> 700ms, '0.7s' -> 700ms, '1m' -> 60000ms
|
|
1826
|
-
* If `true`, the default delayOnInput will be used.
|
|
1882
|
+
/**
|
|
1883
|
+
* Duration to wait after entering search content before triggering a search.<br/>
|
|
1884
|
+
* Example: 700 -> 700ms, '700ms' -> 700ms, '0.7s' -> 700ms, '1m' -> 60000ms
|
|
1885
|
+
* If `true`, the default delayOnInput will be used.
|
|
1827
1886
|
*/
|
|
1828
1887
|
searchDelayTime: PropTypes.oneOfType([PropTypes.string, PropTypes.number, PropTypes.bool]),
|
|
1829
1888
|
/** Specifies the field name or expression used to compare values with the search string. */
|
|
@@ -1854,19 +1913,19 @@ Dropdown.propTypes = {
|
|
|
1854
1913
|
valueObjectDefault: PropTypes.oneOfType([PropTypes.object, PropTypes.array]),
|
|
1855
1914
|
/** The variant to use. */
|
|
1856
1915
|
viewType: PropTypes.oneOf(['underlined', 'outlined', 'none'])
|
|
1857
|
-
/**
|
|
1858
|
-
* ref methods
|
|
1859
|
-
*
|
|
1860
|
-
* how to get component element? ref.current
|
|
1861
|
-
*
|
|
1862
|
-
* how to call method? ref.current.instance.{method}
|
|
1863
|
-
*
|
|
1864
|
-
* * showDropdown(): Show dropdown
|
|
1865
|
-
* * closeDropdown(): Close dropdown
|
|
1866
|
-
* * onClear(): Clear selected value
|
|
1867
|
-
* * setPreviousValue(): Set value to previous value
|
|
1868
|
-
* * setValue(value): Set value of dropdown
|
|
1869
|
-
* * @param {value} - string || number || array
|
|
1916
|
+
/**
|
|
1917
|
+
* ref methods
|
|
1918
|
+
*
|
|
1919
|
+
* how to get component element? ref.current
|
|
1920
|
+
*
|
|
1921
|
+
* how to call method? ref.current.instance.{method}
|
|
1922
|
+
*
|
|
1923
|
+
* * showDropdown(): Show dropdown
|
|
1924
|
+
* * closeDropdown(): Close dropdown
|
|
1925
|
+
* * onClear(): Clear selected value
|
|
1926
|
+
* * setPreviousValue(): Set value to previous value
|
|
1927
|
+
* * setValue(value): Set value of dropdown
|
|
1928
|
+
* * @param {value} - string || number || array
|
|
1870
1929
|
*/
|
|
1871
1930
|
};
|
|
1872
1931
|
export default Dropdown;
|
|
@@ -98,13 +98,13 @@ const NumberInput = /*#__PURE__*/forwardRef((inProps, reference) => {
|
|
|
98
98
|
|
|
99
99
|
// if (valueProps || valueProps === 0) valueProps = clamp(valueProps, min, max);
|
|
100
100
|
|
|
101
|
-
/**
|
|
102
|
-
* Convert number to format money
|
|
103
|
-
* @param vl {number} - value
|
|
104
|
-
* @type {function}
|
|
105
|
-
* @return {string}
|
|
106
|
-
* @example 1200300.123 => 1,200,300.123
|
|
107
|
-
* @example 1200300,123 => 1.200.300,123
|
|
101
|
+
/**
|
|
102
|
+
* Convert number to format money
|
|
103
|
+
* @param vl {number} - value
|
|
104
|
+
* @type {function}
|
|
105
|
+
* @return {string}
|
|
106
|
+
* @example 1200300.123 => 1,200,300.123
|
|
107
|
+
* @example 1200300,123 => 1.200.300,123
|
|
108
108
|
*/
|
|
109
109
|
const parseNumberToMoney = useCallback((vl, isNumber) => {
|
|
110
110
|
var _number, _number2, _number$, _number3;
|
|
@@ -152,13 +152,13 @@ const NumberInput = /*#__PURE__*/forwardRef((inProps, reference) => {
|
|
|
152
152
|
return number;
|
|
153
153
|
}, [decimalSymbol, max, value, decimalDigit, fixedDecimalDigit]);
|
|
154
154
|
|
|
155
|
-
/**
|
|
156
|
-
* Convert money to format number
|
|
157
|
-
* @param vl {string} - value
|
|
158
|
-
* @type {function}
|
|
159
|
-
* @return {number}
|
|
160
|
-
* @example 1,200,300.123 => 1200300.123
|
|
161
|
-
* @example 1.200.300,123 => 1200300.123
|
|
155
|
+
/**
|
|
156
|
+
* Convert money to format number
|
|
157
|
+
* @param vl {string} - value
|
|
158
|
+
* @type {function}
|
|
159
|
+
* @return {number}
|
|
160
|
+
* @example 1,200,300.123 => 1200300.123
|
|
161
|
+
* @example 1.200.300,123 => 1200300.123
|
|
162
162
|
*/
|
|
163
163
|
const convertMoneyToNumber = useCallback((vl, isNumber) => {
|
|
164
164
|
var _number4, _number4$toString, _number4$toString$rep, _number4$toString$rep2, _number4$toString$rep3;
|
|
@@ -171,9 +171,9 @@ const NumberInput = /*#__PURE__*/forwardRef((inProps, reference) => {
|
|
|
171
171
|
const _onInput = useCallback((e, flag) => {
|
|
172
172
|
var _e$target$value;
|
|
173
173
|
let valueT = (_e$target$value = e.target.value) !== null && _e$target$value !== void 0 ? _e$target$value : e.value;
|
|
174
|
-
if (disabledNegative &&
|
|
175
|
-
if ((min || min === 0) &&
|
|
176
|
-
if ((max || max === 0) &&
|
|
174
|
+
if (disabledNegative && eval(valueT || 0) <= 0 || valueT.includes('-')) valueT = 0;
|
|
175
|
+
if ((min || min === 0) && eval(valueT) <= min || min === 0 && valueT.includes('-')) valueT = min;
|
|
176
|
+
if ((max || max === 0) && eval(valueT) >= max) valueT = max;
|
|
177
177
|
valueT = parseNumberToMoney(valueT);
|
|
178
178
|
const returnValue = convertMoneyToNumber(valueT);
|
|
179
179
|
e.value = globalRef.current.value = !isNaN(parseFloat(returnValue)) ? parseFloat(returnValue) : null;
|
|
@@ -496,10 +496,10 @@ NumberInput.propTypes = {
|
|
|
496
496
|
style: PropTypes.object,
|
|
497
497
|
/** Thousand separator character. */
|
|
498
498
|
thousandSeparator: PropTypes.oneOfType([PropTypes.bool, PropTypes.oneOf(['.', ','])]),
|
|
499
|
-
/** Validation value, argument can:<br/>
|
|
500
|
-
* * string: the validation rule. Example required.<br/>
|
|
501
|
-
* * object: the validation rule insist name, property, message. Example {name: 'min', compareValue: 9, message: 'Error'} or {max: 99}<br/>
|
|
502
|
-
* * array: the validation rule list, insist object/string
|
|
499
|
+
/** Validation value, argument can:<br/>
|
|
500
|
+
* * string: the validation rule. Example required.<br/>
|
|
501
|
+
* * object: the validation rule insist name, property, message. Example {name: 'min', compareValue: 9, message: 'Error'} or {max: 99}<br/>
|
|
502
|
+
* * array: the validation rule list, insist object/string
|
|
503
503
|
*/
|
|
504
504
|
validates: PropTypes.oneOfType([PropTypes.string, PropTypes.object, PropTypes.array, PropTypes.func]),
|
|
505
505
|
/** The value of the input element, required for a controlled component. */
|
package/package.json
CHANGED
package/readme.md
CHANGED
|
@@ -42,6 +42,13 @@ npm test
|
|
|
42
42
|
|
|
43
43
|
## Changelog
|
|
44
44
|
|
|
45
|
+
## 1.4.56
|
|
46
|
+
- \[Added\]: Icon – Add IconMenu MHRP29N0033, MHRP29N0034
|
|
47
|
+
- \[Added\]: Icon – Add Icon CelebrationColor
|
|
48
|
+
- \[Fixed\]: Dropdown - Fix valueObjectDefault bug in Dropdown.
|
|
49
|
+
- \[Fixed\]: NumberInput – Fix issue where NumberInput allowed pasting negative values even when disabledNegative prop was enabled.
|
|
50
|
+
- \[Added\]: DateRangePicker – Add a new mode to change the UI of DateRangePicker
|
|
51
|
+
|
|
45
52
|
## 1.4.55
|
|
46
53
|
- \[Added\]: Icon – Add IconMenu MHRM09N1401, MHRM09N1402
|
|
47
54
|
- \[Added\]: Icon – Add Icon Book
|
package/utils/type.js
CHANGED
|
@@ -33,6 +33,34 @@ const isNumeric = object => {
|
|
|
33
33
|
const isObject = object => {
|
|
34
34
|
return type(object) === 'object';
|
|
35
35
|
};
|
|
36
|
+
const typeOf = (value, type) => {
|
|
37
|
+
const result = Object.prototype.toString.call(value).slice(8, -1).toLowerCase();
|
|
38
|
+
return type ? result === String(type).toLowerCase() : result;
|
|
39
|
+
};
|
|
40
|
+
const isEmpty = (value, escapeZero = false) => {
|
|
41
|
+
switch (typeOf(value)) {
|
|
42
|
+
case 'object':
|
|
43
|
+
{
|
|
44
|
+
return value && Object.keys(value).length <= 0 || !value;
|
|
45
|
+
}
|
|
46
|
+
case 'array':
|
|
47
|
+
{
|
|
48
|
+
return value.length <= 0;
|
|
49
|
+
}
|
|
50
|
+
case 'string':
|
|
51
|
+
{
|
|
52
|
+
return !value;
|
|
53
|
+
}
|
|
54
|
+
case 'number':
|
|
55
|
+
{
|
|
56
|
+
if (!escapeZero) return value === 0 ? false : !value;else return !value;
|
|
57
|
+
}
|
|
58
|
+
default:
|
|
59
|
+
{
|
|
60
|
+
return !value;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
};
|
|
36
64
|
const isEmptyObject = object => {
|
|
37
65
|
let property;
|
|
38
66
|
for (property in object) {
|
|
@@ -66,4 +94,4 @@ const isDeferred = object => {
|
|
|
66
94
|
const isEvent = object => {
|
|
67
95
|
return !!(object && object.preventDefault);
|
|
68
96
|
};
|
|
69
|
-
export { isBoolean, isExponential, isDate, isDefined, isFunction, isString, isNumeric, isObject, isEmptyObject, isPlainObject, isPrimitive, isWindow, isRenderer, isPromise, isDeferred, type, isEvent };
|
|
97
|
+
export { isBoolean, isExponential, isDate, isDefined, isFunction, isString, isNumeric, isObject, isEmptyObject, isPlainObject, isPrimitive, isWindow, isRenderer, isPromise, isDeferred, type, isEvent, isEmpty, typeOf };
|