diginet-core-ui 1.3.36 → 1.3.38
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/avatar/default.svg +3 -3
- package/assets/images/icons/wifi.svg +3 -3
- package/assets/images/menu/dhr/ALL.svg +6 -6
- package/assets/images/menu/dhr/D00.svg +12 -12
- package/assets/images/menu/dhr/D09.svg +8 -8
- package/assets/images/menu/dhr/D13.svg +10 -10
- package/assets/images/menu/dhr/D15.svg +10 -10
- package/assets/images/menu/dhr/D21.svg +10 -10
- package/assets/images/menu/dhr/D25.svg +11 -11
- package/assets/images/menu/dhr/D29.svg +11 -11
- package/assets/images/menu/dhr/D38.svg +6 -6
- package/assets/images/menu/dhr/D39.svg +10 -10
- package/assets/images/menu/dhr/D51.svg +12 -12
- package/assets/images/menu/dhr/D52.svg +16 -16
- package/assets/images/menu/dhr/D77.svg +16 -16
- package/assets/images/menu/dhr/D84.svg +12 -12
- package/assets/images/menu/dhr/D89.svg +8 -8
- package/assets/images/menu/dhr/Default.svg +13 -13
- package/assets/images/menu/dhr/MHRM00N0001.svg +14 -14
- package/assets/images/menu/dhr/MHRM09N0002.svg +3 -3
- package/assets/images/menu/dhr/MHRM09N0003.svg +25 -25
- package/assets/images/menu/dhr/MHRM09N0004.svg +14 -14
- package/assets/images/menu/dhr/MHRM09N0005.svg +7 -7
- package/assets/images/menu/dhr/MHRM13N0001.svg +16 -16
- package/assets/images/menu/dhr/MHRM25N0001.svg +26 -26
- package/assets/images/menu/dhr/MHRM29N0001.svg +30 -30
- package/assets/images/menu/dhr/MHRM29N0002.svg +13 -0
- package/assets/images/menu/dhr/MHRM29N0003.svg +17 -0
- package/assets/images/menu/dhr/MHRM29N0015.svg +63 -63
- package/assets/images/menu/dhr/MHRM39N0012.svg +43 -43
- package/assets/images/menu/dhr/MHRM39N0013.svg +24 -24
- package/assets/images/menu/dhr/MHRM39N0014.svg +14 -14
- package/assets/images/menu/dhr/MHRM39N0015.svg +36 -36
- package/assets/images/menu/dhr/MHRM39N0016.svg +23 -23
- package/assets/images/menu/dhr/MHRM77N0001.svg +28 -28
- package/assets/images/menu/dhr/MHRM84N0001.svg +27 -27
- package/assets/images/menu/dhr/MHRM84N0002.svg +24 -24
- package/assets/images/menu/dhr/MHRM89N0001.svg +16 -16
- package/assets/images/menu/dhr/MHRP00N0001.svg +10 -10
- package/assets/images/menu/dhr/MHRP09N0001.svg +22 -22
- package/assets/images/menu/dhr/MHRP09N0002.svg +19 -19
- package/assets/images/menu/dhr/MHRP09N0003.svg +12 -12
- package/assets/images/menu/dhr/MHRP09N0004.svg +6 -6
- package/assets/images/menu/dhr/MHRP09N0005.svg +10 -10
- package/assets/images/menu/dhr/MHRP09N0006.svg +17 -17
- package/assets/images/menu/dhr/MHRP09N0007.svg +15 -15
- package/assets/images/menu/dhr/MHRP09N0008.svg +8 -8
- package/assets/images/menu/dhr/MHRP09N0009.svg +10 -10
- package/assets/images/menu/dhr/MHRP09N0010.svg +12 -12
- package/assets/images/menu/dhr/MHRP09N0011.svg +16 -16
- package/assets/images/menu/dhr/MHRP09N0012.svg +6 -6
- package/assets/images/menu/dhr/MHRP09N0013.svg +8 -8
- package/assets/images/menu/dhr/MHRP09N0014.svg +11 -11
- package/assets/images/menu/dhr/MHRP09N0015.svg +12 -12
- package/assets/images/menu/dhr/MHRP09N0016.svg +18 -18
- package/assets/images/menu/dhr/MHRP09N0017.svg +18 -18
- package/assets/images/menu/dhr/MHRP09N0018.svg +12 -12
- package/assets/images/menu/dhr/MHRP09N0019.svg +13 -13
- package/assets/images/menu/dhr/MHRP09N0020.svg +17 -17
- package/assets/images/menu/dhr/MHRP09N0021.svg +10 -10
- package/assets/images/menu/dhr/MHRP09N0022.svg +16 -16
- package/assets/images/menu/dhr/MHRP09N0023.svg +8 -8
- package/assets/images/menu/dhr/MHRP09N0024.svg +15 -15
- package/assets/images/menu/dhr/MHRP09N0025.svg +16 -16
- package/assets/images/menu/dhr/MHRP09N0026.svg +13 -13
- package/assets/images/menu/dhr/MHRP09N0027.svg +10 -10
- package/assets/images/menu/dhr/MHRP09N0028.svg +6 -6
- package/assets/images/menu/dhr/MHRP09N0029.svg +14 -14
- package/assets/images/menu/dhr/MHRP09N0030.svg +4 -4
- package/assets/images/menu/dhr/MHRP09N0031.svg +5 -5
- package/assets/images/menu/dhr/MHRP09N0032.svg +7 -7
- package/assets/images/menu/dhr/MHRP13N0001.svg +9 -9
- package/assets/images/menu/dhr/MHRP21N0001.svg +12 -12
- package/assets/images/menu/dhr/MHRP21N0002.svg +13 -13
- package/assets/images/menu/dhr/MHRP25N0001.svg +13 -13
- package/assets/images/menu/dhr/MHRP25N0002.svg +16 -16
- package/assets/images/menu/dhr/MHRP25N0003.svg +38 -38
- package/assets/images/menu/dhr/MHRP25N0004.svg +17 -17
- package/assets/images/menu/dhr/MHRP25N0005.svg +20 -20
- package/assets/images/menu/dhr/MHRP29N0001.svg +18 -18
- package/assets/images/menu/dhr/MHRP29N0002.svg +15 -15
- package/assets/images/menu/dhr/MHRP29N0003.svg +20 -20
- package/assets/images/menu/dhr/MHRP29N0004.svg +21 -21
- package/assets/images/menu/dhr/MHRP29N0005.svg +21 -21
- package/assets/images/menu/dhr/MHRP29N0006.svg +14 -14
- package/assets/images/menu/dhr/MHRP29N0007.svg +19 -19
- package/assets/images/menu/dhr/MHRP29N0008.svg +20 -20
- package/assets/images/menu/dhr/MHRP29N0009.svg +11 -11
- package/assets/images/menu/dhr/MHRP29N0010.svg +11 -11
- package/assets/images/menu/dhr/MHRP29N0011.svg +12 -12
- package/assets/images/menu/dhr/MHRP29N0012.svg +7 -7
- package/assets/images/menu/dhr/MHRP29N0013.svg +27 -27
- package/assets/images/menu/dhr/MHRP29N0014.svg +32 -32
- package/assets/images/menu/dhr/MHRP29N0016.svg +54 -54
- package/assets/images/menu/dhr/MHRP29N0017.svg +24 -24
- package/assets/images/menu/dhr/MHRP29N0018.svg +44 -44
- package/assets/images/menu/dhr/MHRP29N0019.svg +17 -17
- package/assets/images/menu/dhr/MHRP29N0020.svg +11 -11
- package/assets/images/menu/dhr/MHRP29N0021.svg +8 -8
- package/assets/images/menu/dhr/MHRP29N0022.svg +9 -9
- package/assets/images/menu/dhr/MHRP29N0023.svg +22 -22
- package/assets/images/menu/dhr/MHRP38N0001.svg +13 -13
- package/assets/images/menu/dhr/MHRP38N0002.svg +14 -14
- package/assets/images/menu/dhr/MHRP39N0001.svg +15 -15
- package/assets/images/menu/dhr/MHRP39N0002.svg +13 -13
- package/assets/images/menu/dhr/MHRP39N0003.svg +16 -16
- package/assets/images/menu/dhr/MHRP39N0004.svg +22 -22
- package/assets/images/menu/dhr/MHRP39N0005.svg +16 -16
- package/assets/images/menu/dhr/MHRP39N0006.svg +17 -17
- package/assets/images/menu/dhr/MHRP39N0007.svg +13 -13
- package/assets/images/menu/dhr/MHRP39N0008.svg +3 -3
- package/assets/images/menu/dhr/MHRP39N0009.svg +3 -3
- package/assets/images/menu/dhr/MHRP39N0010.svg +7 -7
- package/assets/images/menu/dhr/MHRP39N0011.svg +14 -14
- package/assets/images/menu/dhr/MHRP39N0013.svg +10 -10
- package/assets/images/menu/dhr/MHRP39N0014.svg +11 -11
- package/assets/images/menu/dhr/MHRP39N0015.svg +5 -5
- package/assets/images/menu/dhr/MHRP39N0017.svg +11 -11
- package/assets/images/menu/dhr/MHRP39N0018.svg +11 -0
- package/assets/images/menu/dhr/MHRP39N1222.svg +12 -12
- package/assets/images/menu/dhr/MHRP51N0001.svg +9 -9
- package/assets/images/menu/dhr/MHRP51N0002.svg +13 -13
- package/assets/images/menu/dhr/MHRP52N0001.svg +21 -21
- package/assets/images/menu/dhr/MHRP52N0002.svg +21 -21
- package/assets/images/menu/dhr/MHRP52N0003.svg +16 -16
- package/assets/images/menu/dhr/MHRP75N0001.svg +19 -19
- package/assets/images/menu/dhr/MHRP75N0002.svg +25 -25
- package/assets/images/menu/dhr/MHRP75N0003.svg +3 -3
- package/assets/images/menu/dhr/MHRP75N0006.svg +14 -14
- package/assets/images/menu/dhr/MHRP75N0007.svg +19 -19
- package/assets/images/menu/dhr/MHRP75N0008.svg +19 -19
- package/assets/images/menu/dhr/MHRP77N0007.svg +28 -28
- package/assets/images/menu/dhr/MHRP77N0008.svg +17 -17
- package/assets/images/menu/dhr/MHRP77N0009.svg +19 -19
- package/assets/images/menu/dhr/MHRP77N0010.svg +20 -20
- package/assets/images/menu/dhr/MHRP89N1000.svg +6 -6
- package/assets/images/menu/dhr/MHRP89N1001.svg +6 -6
- package/assets/images/menu/dhr/TASK.svg +9 -9
- package/assets/images/menu/dhr/W00F0001.svg +3 -3
- package/assets/images/menu/dhr/W00F0002.svg +3 -3
- package/assets/images/menu/dhr/W00F0003.svg +3 -3
- package/assets/images/menu/dhr/W00F0004.svg +3 -3
- package/assets/images/menu/dhr/W09F2000-WEB5.svg +17 -17
- package/assets/images/menu/dhr/W09F2000.svg +6 -6
- package/assets/images/menu/dhr/W09F2002-WEB5.svg +21 -21
- package/assets/images/menu/dhr/W09F2005-WEB5.svg +13 -13
- package/assets/images/menu/dhr/W09F2020-WEB5.svg +16 -16
- package/assets/images/menu/dhr/W09F2022-WEB5.svg +20 -20
- package/assets/images/menu/dhr/W09F2150-WEB5.svg +16 -16
- package/assets/images/menu/dhr/W09F2152-WEB5.svg +20 -20
- package/assets/images/menu/dhr/W09F2160-WEB5.svg +14 -14
- package/assets/images/menu/dhr/W09F2162-WEB5.svg +18 -18
- package/assets/images/menu/dhr/W29F4006-WEB5.svg +19 -19
- package/assets/images/menu/dhr/W75F2260-WEB5.svg +15 -15
- package/assets/images/menu/dhr/W75F2261-WEB5.svg +19 -19
- package/assets/images/menu/dhr/W75F3005-WEB5.svg +13 -13
- package/assets/images/menu/dhr/W75F4070-WEB5.svg +21 -21
- package/assets/images/menu/dhr/W75F4071-WEB5.svg +17 -17
- package/assets/images/menu/dhr/W75F4100-WEB5.svg +14 -14
- package/assets/images/menu/dhr/W77F1011.svg +19 -19
- package/assets/images/menu/dhr/W77F1013.svg +22 -22
- package/assets/images/menu/erp/D05.svg +8 -8
- package/assets/images/menu/erp/D06.svg +4 -4
- package/assets/images/menu/erp/D90R.svg +9 -9
- package/assets/images/menu/erp/DBC.svg +9 -9
- package/assets/images/menu/erp/W00F0001.svg +3 -3
- package/assets/images/menu/erp/W00F0002.svg +3 -3
- package/assets/images/menu/erp/W00F0003.svg +3 -3
- package/assets/images/menu/erp/W00F0004.svg +3 -3
- package/assets/images/menu/erp/W05F0001.svg +16 -16
- package/assets/images/menu/erp/W05F0001N0000.svg +16 -16
- package/assets/images/menu/erp/W05F0004N0000.svg +6 -6
- package/assets/images/menu/erp/W05F0006N0000.svg +30 -30
- package/assets/images/menu/erp/W05F0007N0000.svg +6 -6
- package/assets/images/menu/erp/W05F0008N0000.svg +14 -14
- package/assets/images/menu/erp/W05F0011N0000.svg +20 -20
- package/assets/images/menu/erp/W05F0013N0000.svg +9 -9
- package/assets/images/menu/erp/W05F4000N0000.svg +9 -9
- package/assets/images/menu/erp/W06F0001.svg +17 -17
- package/assets/images/menu/erp/W06F0001N0000.svg +17 -17
- package/assets/images/menu/erp/W06F0004N0000.svg +22 -22
- package/assets/images/menu/erp/W06F0005N0000.svg +22 -22
- package/assets/images/menu/erp/W06F0006N0000.svg +55 -55
- package/assets/images/menu/erp/W06F0008N0000.svg +17 -17
- package/assets/images/menu/erp/W94F1000N0000.svg +9 -9
- package/assets/images/menu/erp/W94F1000N0001.svg +9 -9
- package/assets/images/menu/erp/WA3F1025.svg +5 -5
- package/assets/images/menu/erp/WA3F2100.svg +10 -10
- package/components/accordion/css.js +42 -35
- package/components/accordion/details.js +48 -42
- package/components/accordion/group.js +88 -82
- package/components/accordion/index.js +54 -48
- package/components/accordion/summary.js +52 -43
- package/components/alert/index.js +115 -103
- package/components/alert/notify.js +16 -18
- package/components/badge/index.js +5 -5
- package/components/button/icon.js +21 -21
- package/components/button/index.js +13 -13
- package/components/chart/Pie/Sector.js +2 -2
- package/components/chart/Pie-v2/Sector.js +2 -2
- package/components/chip/attach.js +5 -5
- package/components/chip/index.js +13 -10
- package/components/divider/index.js +17 -15
- package/components/form-control/attachment/index.js +1 -0
- package/components/form-control/calendar/function.js +295 -289
- package/components/form-control/calendar/index.js +16 -16
- package/components/form-control/checkbox/index.js +5 -5
- package/components/form-control/date-picker/index.js +7 -3
- package/components/form-control/date-range-picker/index.js +12 -8
- package/components/form-control/dropdown/index.js +139 -81
- package/components/form-control/input-base/index.js +32 -27
- package/components/form-control/money-input/index.js +17 -17
- package/components/form-control/number-input/index.js +11 -11
- package/components/form-control/number-input/index2.js +432 -0
- package/components/form-control/phone-input/index.js +7 -7
- package/components/form-control/radio/index.js +98 -146
- package/components/form-control/text-input/index.js +4 -4
- package/components/form-control/time-picker/index.js +305 -300
- package/components/form-control/toggle/index.js +92 -90
- package/components/index.js +1 -1
- package/components/modal/header.js +63 -65
- package/components/modal/modal.js +84 -130
- package/components/paging/page-selector.js +53 -49
- package/components/popup/index.js +5 -1
- package/components/popup/proposals_popup.js +5 -1
- package/components/popup/v2/index.js +12 -8
- package/components/progress/circular.js +12 -12
- package/components/rating/index.js +3 -3
- package/components/slider/slider-item.js +65 -25
- package/components/tab/tab-container.js +2 -2
- package/components/tab/tab-header.js +2 -2
- package/components/tab/tab-panel.js +2 -2
- package/components/tab/tab.js +2 -2
- package/components/transfer/index.js +3 -3
- package/components/tree-view/index.js +38 -38
- package/components/typography/index.js +10 -10
- package/icons/basic.js +75 -408
- package/icons/effect.js +15 -15
- package/package.json +45 -45
- package/readme.md +677 -654
- package/styles/color-helper.js +103 -103
- package/styles/colors.js +7 -7
- package/styles/general.js +40 -12
- package/styles/utils.js +5 -5
- package/theme/set-theme.js +3 -3
- package/theme/settings.js +3 -2
- package/utils/array/array.js +36 -36
- package/utils/date.js +56 -56
- package/utils/error/error.js +2 -2
- package/utils/error/errors.js +99 -99
- package/utils/number.js +6 -6
- package/utils/render-portal.js +5 -1
- package/utils/renderIcon.js +5 -5
- package/utils/useOnClickOutside.js +2 -2
- package/utils/usePortal.js +9 -9
- package/utils/validate.js +33 -33
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
/** @jsx jsx */
|
|
4
4
|
import { memo, useEffect, useRef, forwardRef, useImperativeHandle } from 'react';
|
|
5
|
+
import useInput from '../../../utils/useInput';
|
|
5
6
|
import PropTypes from 'prop-types';
|
|
6
7
|
import { jsx, css } from '@emotion/core';
|
|
7
8
|
import { renderIcon } from '../../../utils';
|
|
@@ -15,7 +16,7 @@ const InputBase = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
15
16
|
type,
|
|
16
17
|
viewType,
|
|
17
18
|
defaultValue,
|
|
18
|
-
value,
|
|
19
|
+
value: valueProp,
|
|
19
20
|
placeholder,
|
|
20
21
|
resize,
|
|
21
22
|
status,
|
|
@@ -31,7 +32,7 @@ const InputBase = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
31
32
|
endIcon,
|
|
32
33
|
startIconProps,
|
|
33
34
|
endIconProps,
|
|
34
|
-
inputRef,
|
|
35
|
+
inputRef: inputBaseRef,
|
|
35
36
|
inputProps,
|
|
36
37
|
iconStyle,
|
|
37
38
|
inputStyle,
|
|
@@ -43,10 +44,19 @@ const InputBase = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
43
44
|
onInput,
|
|
44
45
|
onKeyDown,
|
|
45
46
|
onKeyUp,
|
|
47
|
+
delayOnChange,
|
|
46
48
|
...props
|
|
47
49
|
}, reference) => {
|
|
50
|
+
const {
|
|
51
|
+
bind
|
|
52
|
+
} = useInput({
|
|
53
|
+
defaultValue,
|
|
54
|
+
valueProp,
|
|
55
|
+
onChange,
|
|
56
|
+
delayOnChange
|
|
57
|
+
});
|
|
58
|
+
if (!inputBaseRef) inputBaseRef = useRef(null);
|
|
48
59
|
const ref = useRef(null);
|
|
49
|
-
const inputBaseRef = useRef(null);
|
|
50
60
|
const valueArray = useRef([]);
|
|
51
61
|
/* Start styled */
|
|
52
62
|
|
|
@@ -479,9 +489,9 @@ const InputBase = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
479
489
|
useEffect(() => {
|
|
480
490
|
const defaultHeight = 24;
|
|
481
491
|
|
|
482
|
-
if (
|
|
483
|
-
valueArray.current.push(
|
|
484
|
-
inputBaseRef.current.value =
|
|
492
|
+
if (valueProp !== undefined) {
|
|
493
|
+
valueArray.current.push(valueProp);
|
|
494
|
+
inputBaseRef.current.value = valueProp;
|
|
485
495
|
|
|
486
496
|
if (multiline && !/\d+/.test(rows)) {
|
|
487
497
|
inputBaseRef.current.style.height = 0;
|
|
@@ -490,11 +500,11 @@ const InputBase = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
490
500
|
}
|
|
491
501
|
|
|
492
502
|
return () => {
|
|
493
|
-
if (
|
|
503
|
+
if (valueProp !== undefined && multiline && !/\d+/.test(rows) && inputBaseRef.current) {
|
|
494
504
|
inputBaseRef.current.style.height = defaultHeight + 'px';
|
|
495
505
|
}
|
|
496
506
|
};
|
|
497
|
-
}, [
|
|
507
|
+
}, [valueProp]);
|
|
498
508
|
useEffect(() => {
|
|
499
509
|
if (disabled) {
|
|
500
510
|
if (ref.current) {
|
|
@@ -532,9 +542,9 @@ const InputBase = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
532
542
|
onKeyDown: onKeyDown,
|
|
533
543
|
onKeyUp: onKeyUp,
|
|
534
544
|
onInput: onInputTextArea,
|
|
535
|
-
onChange: onChange,
|
|
536
545
|
onBlur: onBlur,
|
|
537
|
-
onFocus: onFocus
|
|
546
|
+
onFocus: onFocus,
|
|
547
|
+
...bind
|
|
538
548
|
}));
|
|
539
549
|
const InputComp = jsx("div", {
|
|
540
550
|
css: inputBaseRoot,
|
|
@@ -569,9 +579,9 @@ const InputBase = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
569
579
|
onKeyDown: onKeyDown,
|
|
570
580
|
onKeyUp: onKeyUp,
|
|
571
581
|
onInput: onInput,
|
|
572
|
-
onChange: onChange,
|
|
573
582
|
onBlur: onBlur,
|
|
574
|
-
onFocus: onFocus
|
|
583
|
+
onFocus: onFocus,
|
|
584
|
+
...bind
|
|
575
585
|
})), !!endIcon && jsx("div", {
|
|
576
586
|
css: inputBaseIconCSS,
|
|
577
587
|
...endIconProps,
|
|
@@ -587,22 +597,14 @@ const InputBase = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
587
597
|
const InputBaseComp = multiline ? MultipleInputComp : InputComp;
|
|
588
598
|
/* End component */
|
|
589
599
|
|
|
590
|
-
useImperativeHandle(reference, () =>
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
inputBaseRef.current.value = value;
|
|
594
|
-
return value;
|
|
595
|
-
};
|
|
600
|
+
useImperativeHandle(reference, () => {
|
|
601
|
+
const currentRef = inputBaseRef.current || {};
|
|
602
|
+
const _instance = {}; // methods
|
|
596
603
|
|
|
597
|
-
|
|
598
|
-
valueArray.current.pop();
|
|
599
|
-
const preValue = valueArray.current[valueArray.current.length - 1];
|
|
600
|
-
const previousValue = preValue || preValue === 0 ? preValue : defaultValue || '';
|
|
601
|
-
inputBaseRef.current.value = previousValue;
|
|
602
|
-
return previousValue;
|
|
603
|
-
};
|
|
604
|
+
_instance.__proto__ = {}; // hidden methods
|
|
604
605
|
|
|
605
|
-
|
|
606
|
+
currentRef.instance = _instance;
|
|
607
|
+
return currentRef;
|
|
606
608
|
});
|
|
607
609
|
return InputBaseComp;
|
|
608
610
|
}));
|
|
@@ -719,6 +721,9 @@ InputBase.propTypes = {
|
|
|
719
721
|
onFocus: PropTypes.func,
|
|
720
722
|
|
|
721
723
|
/** inputRef of InputBase component */
|
|
722
|
-
inputRef: PropTypes.any
|
|
724
|
+
inputRef: PropTypes.any,
|
|
725
|
+
|
|
726
|
+
/** delayOnChange of InputBase component */
|
|
727
|
+
delayOnChange: PropTypes.number
|
|
723
728
|
};
|
|
724
729
|
export default InputBase;
|
|
@@ -142,15 +142,15 @@ const MoneyInput = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
142
142
|
|
|
143
143
|
const separatorSymbol = typeof thousandSeparator === 'string' ? thousandSeparator : locale.get() === 'vi' ? '.' : ',';
|
|
144
144
|
const decimalSymbol = separatorSymbol === '.' ? ',' : '.';
|
|
145
|
-
const thousandSeparatorPattern = new RegExp(`[0-9]|Backspace|Delete|Arrow|Home|End|Tab${decimalDigit === 0 ? '' : '|\\' + decimalSymbol}${disabledNegative ? '' : '
|
|
145
|
+
const thousandSeparatorPattern = new RegExp(`[0-9]|Backspace|Delete|Arrow|Home|End|Tab${decimalDigit === 0 ? '' : '|\\' + decimalSymbol}${disabledNegative ? '' : '|-'}`);
|
|
146
146
|
const isError = !!error && !value && value !== 0;
|
|
147
147
|
/* Start styled */
|
|
148
148
|
|
|
149
149
|
const MoneyInputRoot = css`
|
|
150
|
-
|
|
151
|
-
|
|
150
|
+
${displayBlock}
|
|
151
|
+
${positionRelative}
|
|
152
152
|
margin-bottom: 20px;
|
|
153
|
-
|
|
153
|
+
`;
|
|
154
154
|
/* End styled */
|
|
155
155
|
|
|
156
156
|
/* Start handler */
|
|
@@ -277,8 +277,8 @@ const MoneyInput = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
277
277
|
const value = e.target.value;
|
|
278
278
|
|
|
279
279
|
if (/[a-z]/i.test(value)) {
|
|
280
|
-
const length = value.match(/[a-z]/
|
|
281
|
-
e.target.value = value.replace(/[a-z]/
|
|
280
|
+
const length = value.match(/[a-z]/gi).length;
|
|
281
|
+
e.target.value = value.replace(/[a-z]/gi, '');
|
|
282
282
|
|
|
283
283
|
if (length === 1) {
|
|
284
284
|
const index = value.match(/[a-z]/i).index;
|
|
@@ -552,10 +552,10 @@ MoneyInput.propTypes = {
|
|
|
552
552
|
/** The function to get ref of MoneyInput component */
|
|
553
553
|
refs: PropTypes.func,
|
|
554
554
|
|
|
555
|
-
/** validation value, argument can:<br/>
|
|
556
|
-
* * string: the validation rule. Example required.<br/>
|
|
557
|
-
* * object: the validation rule insist name, property, message. Example {name: 'min', compareValue: 9, message: 'Error'} or {max: 99}<br/>
|
|
558
|
-
* * array: the validation rule list, insist object/string
|
|
555
|
+
/** validation value, argument can:<br/>
|
|
556
|
+
* * string: the validation rule. Example required.<br/>
|
|
557
|
+
* * object: the validation rule insist name, property, message. Example {name: 'min', compareValue: 9, message: 'Error'} or {max: 99}<br/>
|
|
558
|
+
* * array: the validation rule list, insist object/string
|
|
559
559
|
*/
|
|
560
560
|
validates: PropTypes.oneOfType([PropTypes.string, PropTypes.object, PropTypes.array, PropTypes.func]),
|
|
561
561
|
|
|
@@ -568,13 +568,13 @@ MoneyInput.propTypes = {
|
|
|
568
568
|
/** on input function */
|
|
569
569
|
onInput: PropTypes.func,
|
|
570
570
|
|
|
571
|
-
/**
|
|
572
|
-
* on change function, return an object:<br/>
|
|
573
|
-
* {<br/>
|
|
574
|
-
* value: is a number or null value<br/>
|
|
575
|
-
* target.value: value of input<br/>
|
|
576
|
-
* ...element<br/>
|
|
577
|
-
* }
|
|
571
|
+
/**
|
|
572
|
+
* on change function, return an object:<br/>
|
|
573
|
+
* {<br/>
|
|
574
|
+
* value: is a number or null value<br/>
|
|
575
|
+
* target.value: value of input<br/>
|
|
576
|
+
* ...element<br/>
|
|
577
|
+
* }
|
|
578
578
|
*/
|
|
579
579
|
onChange: PropTypes.func,
|
|
580
580
|
|
|
@@ -591,23 +591,23 @@ NumberInput.propTypes = {
|
|
|
591
591
|
/** any props of error in NumberInput component */
|
|
592
592
|
errorProps: PropTypes.object,
|
|
593
593
|
|
|
594
|
-
/**
|
|
595
|
-
* the format to display value<br/>
|
|
596
|
-
* * function: value => function(value)<br/>
|
|
597
|
-
* * string: Example: '#.###', '# ###', '#.### 2%', '#.### %%'<br/>
|
|
598
|
-
* #: integer part digit<br/>
|
|
599
|
-
* . / '_': separator symbol<br/>
|
|
600
|
-
* %: decimal digit, '2%' === '%%'
|
|
594
|
+
/**
|
|
595
|
+
* the format to display value<br/>
|
|
596
|
+
* * function: value => function(value)<br/>
|
|
597
|
+
* * string: Example: '#.###', '# ###', '#.### 2%', '#.### %%'<br/>
|
|
598
|
+
* #: integer part digit<br/>
|
|
599
|
+
* . / '_': separator symbol<br/>
|
|
600
|
+
* %: decimal digit, '2%' === '%%'
|
|
601
601
|
*/
|
|
602
602
|
format: PropTypes.oneOfType([PropTypes.string, PropTypes.func]),
|
|
603
603
|
|
|
604
604
|
/** The function to get ref of NumberInput component */
|
|
605
605
|
refs: PropTypes.func,
|
|
606
606
|
|
|
607
|
-
/** validation value, argument can:<br/>
|
|
608
|
-
* * string: the validation rule. Example required.<br/>
|
|
609
|
-
* * object: the validation rule insist name, property, message. Example {name: 'min', compareValue: 9, message: 'Error'} or {max: 99}<br/>
|
|
610
|
-
* * array: the validation rule list, insist object/string
|
|
607
|
+
/** validation value, argument can:<br/>
|
|
608
|
+
* * string: the validation rule. Example required.<br/>
|
|
609
|
+
* * object: the validation rule insist name, property, message. Example {name: 'min', compareValue: 9, message: 'Error'} or {max: 99}<br/>
|
|
610
|
+
* * array: the validation rule list, insist object/string
|
|
611
611
|
*/
|
|
612
612
|
validates: PropTypes.oneOfType([PropTypes.string, PropTypes.object, PropTypes.array, PropTypes.func]),
|
|
613
613
|
|
|
@@ -0,0 +1,432 @@
|
|
|
1
|
+
/** @jsxRuntime classic */
|
|
2
|
+
|
|
3
|
+
/** @jsx jsx */
|
|
4
|
+
import { useState, useRef, forwardRef, useMemo, useCallback, useEffect, useImperativeHandle } from 'react';
|
|
5
|
+
import PropTypes from 'prop-types';
|
|
6
|
+
import { jsx, css } from '@emotion/core';
|
|
7
|
+
import locale from '../../../locale';
|
|
8
|
+
import { InputBase, Label, HelperText } from '../..';
|
|
9
|
+
import { onValidate } from '../../../utils';
|
|
10
|
+
import { getGlobal } from '../../../global';
|
|
11
|
+
/* Start styled */
|
|
12
|
+
|
|
13
|
+
const NumberInputRoot = css`
|
|
14
|
+
display: block;
|
|
15
|
+
position: relative;
|
|
16
|
+
margin-bottom: 20px;
|
|
17
|
+
`;
|
|
18
|
+
const regexValidNumber = /[^0-9.,-]/g;
|
|
19
|
+
const regexThousandNumber = /(\d)(?=(\d{3})+\b)/g;
|
|
20
|
+
const NumberInput = /*#__PURE__*/forwardRef(({
|
|
21
|
+
viewType,
|
|
22
|
+
required,
|
|
23
|
+
disabledNegative,
|
|
24
|
+
nonStyle,
|
|
25
|
+
decimalDigit,
|
|
26
|
+
decimalSymbol,
|
|
27
|
+
thousandSeparator: thousandSymbol,
|
|
28
|
+
label,
|
|
29
|
+
defaultValue,
|
|
30
|
+
value: valueProps,
|
|
31
|
+
min,
|
|
32
|
+
max,
|
|
33
|
+
step,
|
|
34
|
+
placeholder,
|
|
35
|
+
startIcon,
|
|
36
|
+
endIcon,
|
|
37
|
+
autoFocus,
|
|
38
|
+
disabled,
|
|
39
|
+
readOnly,
|
|
40
|
+
inputRef,
|
|
41
|
+
inputProps,
|
|
42
|
+
inputStyle,
|
|
43
|
+
error,
|
|
44
|
+
onChange,
|
|
45
|
+
onFocus,
|
|
46
|
+
onInput,
|
|
47
|
+
onKeyDown,
|
|
48
|
+
onKeyUp,
|
|
49
|
+
validates,
|
|
50
|
+
delayOnChange,
|
|
51
|
+
fixedDecimalDigit,
|
|
52
|
+
className
|
|
53
|
+
}, reference) => {
|
|
54
|
+
inputRef = inputRef || useRef(null);
|
|
55
|
+
const pos = useRef(null);
|
|
56
|
+
const ref = useRef(null);
|
|
57
|
+
const globalRef = useRef({});
|
|
58
|
+
const [value, setValue] = useState(defaultValue); // nếu không cho nhập số âm mà max là âm thì remove giá trị max
|
|
59
|
+
|
|
60
|
+
if (max < 0 && disabledNegative) max = null;
|
|
61
|
+
|
|
62
|
+
if (thousandSymbol) {
|
|
63
|
+
thousandSymbol = useMemo(() => {
|
|
64
|
+
return typeof thousandSymbol === 'string' ? thousandSymbol : decimalSymbol === ',' ? '.' : ',';
|
|
65
|
+
}, [decimalSymbol, thousandSymbol]);
|
|
66
|
+
decimalSymbol = useMemo(() => {
|
|
67
|
+
return thousandSymbol === ',' ? '.' : ',';
|
|
68
|
+
}, [decimalSymbol, decimalSymbol]);
|
|
69
|
+
} else {
|
|
70
|
+
thousandSymbol = '';
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
const validateResult = validates && onValidate(value, validates, true); // Clamp number between two values with the following line:
|
|
74
|
+
|
|
75
|
+
const clamp = (num, min, max) => Math.min(Math.max(num, min), max);
|
|
76
|
+
|
|
77
|
+
if (valueProps || valueProps === 0) valueProps = clamp(valueProps, min, max);
|
|
78
|
+
/**
|
|
79
|
+
* Convert number to format money
|
|
80
|
+
* @param vl {number} - value
|
|
81
|
+
* @type {function(*): number}
|
|
82
|
+
* @return {string}
|
|
83
|
+
* @example 1200300.123 => 1,200,300.123
|
|
84
|
+
* @example 1200300,123 => 1.200.300,123
|
|
85
|
+
*/
|
|
86
|
+
|
|
87
|
+
const parseNumberToMoney = useCallback((vl, isNumber) => {
|
|
88
|
+
var _number, _number2, _number$, _number3;
|
|
89
|
+
|
|
90
|
+
const {
|
|
91
|
+
current: {
|
|
92
|
+
selectionStart
|
|
93
|
+
}
|
|
94
|
+
} = inputRef;
|
|
95
|
+
let number = convertMoneyToNumber(vl, isNumber);
|
|
96
|
+
if (disabledNegative && Number(number || 0) < 0) number = clamp(number, min, max);
|
|
97
|
+
if (typeof max !== 'undefined' && Number(number) > max) number = Math.min(number, max); // number = Currency.format(number);
|
|
98
|
+
|
|
99
|
+
if (!number) return number;
|
|
100
|
+
number = (_number = number) === null || _number === void 0 ? void 0 : _number.toString().split('.');
|
|
101
|
+
|
|
102
|
+
if (number.length === 2 && !number[0]) {
|
|
103
|
+
number[0] = '0';
|
|
104
|
+
pos.current = 2;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
number[0] = (_number2 = number) === null || _number2 === void 0 ? void 0 : _number2[0].replace(regexThousandNumber, '$1' + thousandSymbol); // add thousand symbol to number
|
|
108
|
+
|
|
109
|
+
if (!decimalDigit) number.length = 1;else if (number[1]) number[1] = (_number$ = number[1]) === null || _number$ === void 0 ? void 0 : _number$.slice(0, decimalDigit || 0);
|
|
110
|
+
number = number.join(decimalSymbol); // keep focus position
|
|
111
|
+
|
|
112
|
+
if ((_number3 = number) !== null && _number3 !== void 0 && _number3.indexOf(thousandSymbol) && !pos.current) {
|
|
113
|
+
var _number4;
|
|
114
|
+
|
|
115
|
+
pos.current = selectionStart + (((_number4 = number) === null || _number4 === void 0 ? void 0 : _number4.toString().split(thousandSymbol).length) - (vl === null || vl === void 0 ? void 0 : vl.toString().split(thousandSymbol).length));
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
return number;
|
|
119
|
+
}, [decimalSymbol, max, value]);
|
|
120
|
+
/**
|
|
121
|
+
* Convert money to format number
|
|
122
|
+
* @param vl {string} - value
|
|
123
|
+
* @type {function(*): number}
|
|
124
|
+
* @return {number}
|
|
125
|
+
* @example 1,200,300.123 => 1200300.123
|
|
126
|
+
* @example 1.200.300,123 => 1200300.123
|
|
127
|
+
*/
|
|
128
|
+
|
|
129
|
+
const convertMoneyToNumber = useCallback((vl, isNumber) => {
|
|
130
|
+
var _number5, _number5$toString, _number5$toString$rep, _number5$toString$rep2, _number5$toString$rep3;
|
|
131
|
+
|
|
132
|
+
let number = vl === null || vl === void 0 ? void 0 : vl.toString().replace(regexValidNumber, ''); // allow number and , || . || -
|
|
133
|
+
// remove <thousandSymbol> and replace . to <decimalSymbol>
|
|
134
|
+
|
|
135
|
+
if (!isNumber) number = (_number5 = number) === null || _number5 === void 0 ? void 0 : (_number5$toString = _number5.toString()) === null || _number5$toString === void 0 ? void 0 : (_number5$toString$rep = _number5$toString.replaceAll) === null || _number5$toString$rep === void 0 ? void 0 : (_number5$toString$rep2 = (_number5$toString$rep3 = _number5$toString$rep.call(_number5$toString, thousandSymbol, '')).replaceAll) === null || _number5$toString$rep2 === void 0 ? void 0 : _number5$toString$rep2.call(_number5$toString$rep3, decimalSymbol, '.');
|
|
136
|
+
return number;
|
|
137
|
+
}, [decimalSymbol]);
|
|
138
|
+
|
|
139
|
+
const _onInput = e => {
|
|
140
|
+
var _e$target$value;
|
|
141
|
+
|
|
142
|
+
let valueT = (_e$target$value = e.target.value) !== null && _e$target$value !== void 0 ? _e$target$value : e.value;
|
|
143
|
+
if (disabledNegative && Number(valueT || 0) < 0) return;
|
|
144
|
+
valueT = parseNumberToMoney(valueT);
|
|
145
|
+
const returnValue = convertMoneyToNumber(valueT);
|
|
146
|
+
e.value = globalRef.current.value = !isNaN(parseFloat(returnValue)) ? parseFloat(returnValue) : null;
|
|
147
|
+
e.target.value = globalRef.current.valueString = valueT || '';
|
|
148
|
+
onInput === null || onInput === void 0 ? void 0 : onInput(e);
|
|
149
|
+
setValue(valueT);
|
|
150
|
+
};
|
|
151
|
+
|
|
152
|
+
const _onBlur = e => {
|
|
153
|
+
var _e$value;
|
|
154
|
+
|
|
155
|
+
let value = (_e$value = e.value) !== null && _e$value !== void 0 ? _e$value : e.target.value;
|
|
156
|
+
if (fixedDecimalDigit) value = Number(value).toFixed(decimalDigit);
|
|
157
|
+
|
|
158
|
+
if (value && (typeof min !== 'undefined' || typeof max !== 'undefined')) {
|
|
159
|
+
value = convertMoneyToNumber(value);
|
|
160
|
+
|
|
161
|
+
if (Number(value) < min || Number(value) > max) {
|
|
162
|
+
_onInput({ ...e,
|
|
163
|
+
target: { ...e.target,
|
|
164
|
+
value: clamp(value, min, max)
|
|
165
|
+
}
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
};
|
|
170
|
+
|
|
171
|
+
const _onKeyDown = e => {
|
|
172
|
+
var _value$split, _value$split$;
|
|
173
|
+
|
|
174
|
+
const {
|
|
175
|
+
keyCode,
|
|
176
|
+
ctrlKey,
|
|
177
|
+
metaKey,
|
|
178
|
+
shiftKey,
|
|
179
|
+
target: {
|
|
180
|
+
value,
|
|
181
|
+
selectionStart,
|
|
182
|
+
selectionEnd
|
|
183
|
+
}
|
|
184
|
+
} = e; // 0-9 only
|
|
185
|
+
|
|
186
|
+
const isNumber = keyCode >= 48 && keyCode <= 57 && shiftKey === false || keyCode >= 96 && keyCode <= 105; // character input type="number"
|
|
187
|
+
|
|
188
|
+
const allowKeyTypeNumber = isNumber || keyCode === 8 || // key backspace
|
|
189
|
+
keyCode > 34 && keyCode < 40 || keyCode === 190 || keyCode === 110 || // .
|
|
190
|
+
keyCode === 188 || // ,
|
|
191
|
+
(ctrlKey || metaKey) && (keyCode === 65 || keyCode === 67 || keyCode === 86) || // ctrl + A, ctrl + C, ctrl + V
|
|
192
|
+
keyCode === 46 || // key delete
|
|
193
|
+
keyCode === 189 || keyCode === 109 || // -
|
|
194
|
+
keyCode === 9; // tab
|
|
195
|
+
// The key is delete (|| remove) and focus after the thousand digit
|
|
196
|
+
|
|
197
|
+
const removeDot = keyCode === 8 && selectionEnd - selectionStart <= 1 && value.charAt(selectionEnd - 1) === thousandSymbol; // Decimal
|
|
198
|
+
// Do not allow the character decimal if decimalDigit is undefined
|
|
199
|
+
|
|
200
|
+
const isDecimalSymbol = decimalSymbol === '.' && (keyCode === 190 || keyCode === 110) || decimalSymbol === ',' && keyCode === 188;
|
|
201
|
+
const disabledDecimalSymbol = isDecimalSymbol && !decimalDigit; // Accepts only one decimal separator
|
|
202
|
+
|
|
203
|
+
const decimalExists = value.includes(decimalSymbol) && isDecimalSymbol; // Do not allow the character thousand
|
|
204
|
+
|
|
205
|
+
const isThousandSymbol = (!thousandSymbol || thousandSymbol === '.') && (keyCode === 190 || keyCode === 110) || thousandSymbol === ',' && keyCode === 188;
|
|
206
|
+
const disabledThousandSymbol = isThousandSymbol; // Disabled typing input when decimal digit to limit and focus is last
|
|
207
|
+
|
|
208
|
+
const disabledTypingDecimal = ((_value$split = value.split(decimalSymbol)) === null || _value$split === void 0 ? void 0 : (_value$split$ = _value$split[1]) === null || _value$split$ === void 0 ? void 0 : _value$split$.length) >= decimalDigit && // total number after decimal symbol > {decimalDigit}
|
|
209
|
+
selectionStart === value.length; // the focus is at the end of the string
|
|
210
|
+
// key arrow up
|
|
211
|
+
|
|
212
|
+
if (keyCode === 38) {
|
|
213
|
+
_onInput({ ...e,
|
|
214
|
+
target: { ...e.target,
|
|
215
|
+
value: Number(convertMoneyToNumber(value) || 0) + step
|
|
216
|
+
}
|
|
217
|
+
});
|
|
218
|
+
|
|
219
|
+
e.preventDefault();
|
|
220
|
+
} // key arrow down
|
|
221
|
+
else if (keyCode === 40) {
|
|
222
|
+
_onInput({ ...e,
|
|
223
|
+
target: { ...e.target,
|
|
224
|
+
value: Number(convertMoneyToNumber(value) || 0) - step
|
|
225
|
+
}
|
|
226
|
+
});
|
|
227
|
+
|
|
228
|
+
e.preventDefault();
|
|
229
|
+
} // disabled negative
|
|
230
|
+
|
|
231
|
+
|
|
232
|
+
const disabled180 = (keyCode === 189 || keyCode === 109) && (disabledNegative || value.includes('-')); // Block event if include conditions
|
|
233
|
+
|
|
234
|
+
if (decimalExists || disabledThousandSymbol || removeDot || isNumber && disabledTypingDecimal || disabledDecimalSymbol || !allowKeyTypeNumber || disabled180) {
|
|
235
|
+
e.preventDefault();
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
onKeyDown === null || onKeyDown === void 0 ? void 0 : onKeyDown(e);
|
|
239
|
+
};
|
|
240
|
+
|
|
241
|
+
useEffect(() => {
|
|
242
|
+
inputRef.current.value = value !== null && value !== void 0 ? value : null; // keep focus position
|
|
243
|
+
|
|
244
|
+
if (pos.current) {
|
|
245
|
+
inputRef.current.setSelectionRange(pos.current, pos.current);
|
|
246
|
+
pos.current = null;
|
|
247
|
+
}
|
|
248
|
+
}, [value]);
|
|
249
|
+
useEffect(() => {
|
|
250
|
+
var _valueProps;
|
|
251
|
+
|
|
252
|
+
if (typeof valueProps !== 'undefined') if (disabledNegative && Number(valueProps || 0) < 0) {
|
|
253
|
+
// nếu không cho nhập số âm mà value đầu vào là âm thì reset value về 0
|
|
254
|
+
valueProps = clamp(0, min, max);
|
|
255
|
+
}
|
|
256
|
+
setValue(parseNumberToMoney((_valueProps = valueProps) === null || _valueProps === void 0 ? void 0 : _valueProps.toString().replace(regexValidNumber, ''), true));
|
|
257
|
+
}, [valueProps]);
|
|
258
|
+
useImperativeHandle(reference, () => {
|
|
259
|
+
const currentRef = ref.current || {};
|
|
260
|
+
const _instance = {}; // methods
|
|
261
|
+
|
|
262
|
+
_instance.__proto__ = {}; // hidden methods
|
|
263
|
+
|
|
264
|
+
currentRef.instance = _instance;
|
|
265
|
+
return currentRef;
|
|
266
|
+
});
|
|
267
|
+
return jsx("div", {
|
|
268
|
+
ref: ref,
|
|
269
|
+
css: NumberInputRoot,
|
|
270
|
+
className: ['DGN-UI-NumberInput', className].join(' ').trim().replace(/\s+/g, ' ')
|
|
271
|
+
}, !!label && jsx(Label, {
|
|
272
|
+
required: required,
|
|
273
|
+
disabled: disabled
|
|
274
|
+
}, label), jsx(InputBase, {
|
|
275
|
+
inputRef: inputRef,
|
|
276
|
+
viewType: viewType,
|
|
277
|
+
defaultValue: defaultValue,
|
|
278
|
+
value: value,
|
|
279
|
+
placeholder: placeholder,
|
|
280
|
+
autoFocus: autoFocus,
|
|
281
|
+
disabled: disabled,
|
|
282
|
+
readOnly: readOnly,
|
|
283
|
+
status: !!error || validateResult ? 'danger' : 'default',
|
|
284
|
+
inputProps: inputProps,
|
|
285
|
+
inputStyle: inputStyle,
|
|
286
|
+
startIcon: startIcon,
|
|
287
|
+
endIcon: endIcon,
|
|
288
|
+
nonStyle: nonStyle,
|
|
289
|
+
onFocus: onFocus,
|
|
290
|
+
onInput: _onInput,
|
|
291
|
+
onKeyUp: onKeyUp,
|
|
292
|
+
delayOnChange: delayOnChange,
|
|
293
|
+
onKeyDown: _onKeyDown,
|
|
294
|
+
onChange: e => {
|
|
295
|
+
onChange({ ...e,
|
|
296
|
+
value: globalRef.current.value,
|
|
297
|
+
target: { ...e.target,
|
|
298
|
+
value: globalRef.current.valueString
|
|
299
|
+
}
|
|
300
|
+
});
|
|
301
|
+
},
|
|
302
|
+
onBlur: e => _onBlur(e)
|
|
303
|
+
}), !!error && jsx(HelperText, {
|
|
304
|
+
disabled: disabled
|
|
305
|
+
}, error), !error && validateResult && jsx(HelperText, {
|
|
306
|
+
disabled: disabled
|
|
307
|
+
}, validateResult));
|
|
308
|
+
});
|
|
309
|
+
NumberInput.defaultProps = {
|
|
310
|
+
viewType: 'underlined',
|
|
311
|
+
label: '',
|
|
312
|
+
placeholder: getGlobal('inputPlaceholder'),
|
|
313
|
+
error: '',
|
|
314
|
+
startIcon: '',
|
|
315
|
+
endIcon: '',
|
|
316
|
+
decimalSymbol: locale.get() === 'vi' ? ',' : '.',
|
|
317
|
+
required: false,
|
|
318
|
+
nonStyle: false,
|
|
319
|
+
autoFocus: false,
|
|
320
|
+
disabled: false,
|
|
321
|
+
readOnly: false,
|
|
322
|
+
disabledNegative: false,
|
|
323
|
+
fixedDecimalDigit: false,
|
|
324
|
+
step: 1,
|
|
325
|
+
decimalDigit: 0,
|
|
326
|
+
thousandSeparator: false,
|
|
327
|
+
min: -Infinity,
|
|
328
|
+
max: Infinity,
|
|
329
|
+
className: ''
|
|
330
|
+
};
|
|
331
|
+
NumberInput.propTypes = {
|
|
332
|
+
/** the type of border you want to display */
|
|
333
|
+
viewType: PropTypes.oneOf(['underlined', 'outlined']),
|
|
334
|
+
|
|
335
|
+
/** separator symbol */
|
|
336
|
+
decimalSymbol: PropTypes.oneOf([',', '.']),
|
|
337
|
+
|
|
338
|
+
/** default value is displayed for first render */
|
|
339
|
+
defaultValue: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
|
340
|
+
|
|
341
|
+
/** the displayed value for each change */
|
|
342
|
+
value: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
|
343
|
+
|
|
344
|
+
/** number of decimal places allowed */
|
|
345
|
+
decimalDigit: PropTypes.number,
|
|
346
|
+
|
|
347
|
+
/** min of value was allowed */
|
|
348
|
+
min: PropTypes.number,
|
|
349
|
+
|
|
350
|
+
/** max of value was allowed */
|
|
351
|
+
max: PropTypes.number,
|
|
352
|
+
|
|
353
|
+
/** step of input */
|
|
354
|
+
step: PropTypes.number,
|
|
355
|
+
|
|
356
|
+
/** label for input */
|
|
357
|
+
label: PropTypes.oneOfType([PropTypes.string, PropTypes.node]),
|
|
358
|
+
|
|
359
|
+
/** hints for input */
|
|
360
|
+
placeholder: PropTypes.string,
|
|
361
|
+
|
|
362
|
+
/** error for input */
|
|
363
|
+
error: PropTypes.oneOfType([PropTypes.bool, PropTypes.string]),
|
|
364
|
+
|
|
365
|
+
/** icon at start */
|
|
366
|
+
startIcon: PropTypes.any,
|
|
367
|
+
|
|
368
|
+
/** icon at end */
|
|
369
|
+
endIcon: PropTypes.any,
|
|
370
|
+
|
|
371
|
+
/** prevent all event if true, hide all icon */
|
|
372
|
+
disabled: PropTypes.bool,
|
|
373
|
+
|
|
374
|
+
/** transparent border color if true */
|
|
375
|
+
nonStyle: PropTypes.bool,
|
|
376
|
+
|
|
377
|
+
/** prevent all event if true */
|
|
378
|
+
readOnly: PropTypes.bool,
|
|
379
|
+
|
|
380
|
+
/** auto focus after first render */
|
|
381
|
+
autoFocus: PropTypes.bool,
|
|
382
|
+
|
|
383
|
+
/** negative numbers are not allowed if true */
|
|
384
|
+
disabledNegative: PropTypes.bool,
|
|
385
|
+
|
|
386
|
+
/** At least one character is required */
|
|
387
|
+
required: PropTypes.bool,
|
|
388
|
+
|
|
389
|
+
/** props of input in NumberInput component */
|
|
390
|
+
inputProps: PropTypes.object,
|
|
391
|
+
|
|
392
|
+
/** style inline of input in NumberInput component */
|
|
393
|
+
inputStyle: PropTypes.object,
|
|
394
|
+
|
|
395
|
+
/** validation value, argument can:<br/>
|
|
396
|
+
* * string: the validation rule. Example required.<br/>
|
|
397
|
+
* * object: the validation rule insist name, property, message. Example {name: 'min', compareValue: 9, message: 'Error'} or {max: 99}<br/>
|
|
398
|
+
* * array: the validation rule list, insist object/string
|
|
399
|
+
*/
|
|
400
|
+
validates: PropTypes.oneOfType([PropTypes.string, PropTypes.object, PropTypes.array, PropTypes.func]),
|
|
401
|
+
|
|
402
|
+
/** on key down function */
|
|
403
|
+
onKeyDown: PropTypes.func,
|
|
404
|
+
|
|
405
|
+
/** on key up function */
|
|
406
|
+
onKeyUp: PropTypes.func,
|
|
407
|
+
|
|
408
|
+
/** on input function */
|
|
409
|
+
onInput: PropTypes.func,
|
|
410
|
+
|
|
411
|
+
/** on change function */
|
|
412
|
+
onChange: PropTypes.func,
|
|
413
|
+
|
|
414
|
+
/** on focus function */
|
|
415
|
+
onFocus: PropTypes.func,
|
|
416
|
+
|
|
417
|
+
/** inputRef of NumberInput component */
|
|
418
|
+
inputRef: PropTypes.any,
|
|
419
|
+
|
|
420
|
+
/** inputRef of fixedDecimalDigit component */
|
|
421
|
+
fixedDecimalDigit: PropTypes.bool,
|
|
422
|
+
|
|
423
|
+
/** inputRef of delayOnChange component */
|
|
424
|
+
delayOnChange: PropTypes.number,
|
|
425
|
+
|
|
426
|
+
/** inputRef of delayOnChange component */
|
|
427
|
+
thousandSeparator: PropTypes.oneOfType([PropTypes.bool, PropTypes.oneOf(['.', ','])]),
|
|
428
|
+
|
|
429
|
+
/** className of component */
|
|
430
|
+
className: PropTypes.string
|
|
431
|
+
};
|
|
432
|
+
export default NumberInput;
|
|
@@ -410,13 +410,13 @@ PhoneInput.propTypes = {
|
|
|
410
410
|
/** on input function */
|
|
411
411
|
onInput: PropTypes.func,
|
|
412
412
|
|
|
413
|
-
/**
|
|
414
|
-
* on change function. Return a object, example:<br/>
|
|
415
|
-
* {<br/>
|
|
416
|
-
* target: {value: "(+84) 123 456 789", ...}<br/>
|
|
417
|
-
* value: 0123456789<br/>
|
|
418
|
-
* countryCode: 84<br/>
|
|
419
|
-
* }
|
|
413
|
+
/**
|
|
414
|
+
* on change function. Return a object, example:<br/>
|
|
415
|
+
* {<br/>
|
|
416
|
+
* target: {value: "(+84) 123 456 789", ...}<br/>
|
|
417
|
+
* value: 0123456789<br/>
|
|
418
|
+
* countryCode: 84<br/>
|
|
419
|
+
* }
|
|
420
420
|
*/
|
|
421
421
|
onChange: PropTypes.func,
|
|
422
422
|
|