diginet-core-ui 1.3.78 → 1.3.79

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.
Files changed (209) hide show
  1. package/components/accordion/details.js +2 -6
  2. package/components/accordion/group.js +2 -9
  3. package/components/accordion/index.js +2 -15
  4. package/components/accordion/summary.js +4 -27
  5. package/components/alert/index.js +98 -137
  6. package/components/alert/notify.js +97 -166
  7. package/components/avatar/index.js +4 -63
  8. package/components/badge/index.js +7 -34
  9. package/components/button/icon.js +120 -186
  10. package/components/button/index.js +136 -205
  11. package/components/button/more.js +0 -12
  12. package/components/button/ripple-effect.js +46 -44
  13. package/components/card/body.js +2 -7
  14. package/components/card/extra.js +2 -7
  15. package/components/card/footer.js +2 -7
  16. package/components/card/header.js +2 -7
  17. package/components/card/index.js +2 -22
  18. package/components/chart/Pie/Circle.js +0 -1
  19. package/components/chart/Pie/Sector.js +0 -17
  20. package/components/chart/Pie/Sectors.js +0 -10
  21. package/components/chart/Pie/index.js +4 -36
  22. package/components/chart/Pie-v2/Circle.js +0 -1
  23. package/components/chart/Pie-v2/Sector.js +0 -13
  24. package/components/chart/Pie-v2/Sectors.js +0 -20
  25. package/components/chart/Pie-v2/index.js +11 -38
  26. package/components/chart/bar/Axis.js +0 -12
  27. package/components/chart/bar/Bar.js +13 -35
  28. package/components/chart/bar/Grid.js +0 -18
  29. package/components/chart/bar/Labels.js +0 -18
  30. package/components/chart/bar/Points.js +0 -17
  31. package/components/chart/bar/index.js +6 -26
  32. package/components/chart/bar-v2/Axis.js +0 -12
  33. package/components/chart/bar-v2/Bar.js +15 -36
  34. package/components/chart/bar-v2/Grid.js +0 -18
  35. package/components/chart/bar-v2/Labels.js +0 -18
  36. package/components/chart/bar-v2/Points.js +0 -17
  37. package/components/chart/bar-v2/index.js +6 -26
  38. package/components/chart/line/Axis.js +4 -16
  39. package/components/chart/line/Grid.js +2 -19
  40. package/components/chart/line/Labels.js +0 -18
  41. package/components/chart/line/Path.js +23 -33
  42. package/components/chart/line/Point.js +6 -40
  43. package/components/chart/line/Title.js +0 -3
  44. package/components/chart/line/index.js +12 -35
  45. package/components/chart/line-v2/Axis.js +0 -13
  46. package/components/chart/line-v2/Grid.js +0 -18
  47. package/components/chart/line-v2/Labels.js +0 -18
  48. package/components/chart/line-v2/Path.js +23 -33
  49. package/components/chart/line-v2/Point.js +6 -35
  50. package/components/chart/line-v2/Title.js +0 -3
  51. package/components/chart/line-v2/index.js +12 -30
  52. package/components/check-text/index.js +0 -8
  53. package/components/check-text/interview-confirmation.js +0 -7
  54. package/components/check-text/interview-status.js +0 -7
  55. package/components/chip/attach.js +4 -17
  56. package/components/chip/index.js +6 -33
  57. package/components/collapse/index.js +0 -13
  58. package/components/divider/index.js +0 -8
  59. package/components/form-control/attachment/index.js +24 -202
  60. package/components/form-control/calendar/function.js +40 -94
  61. package/components/form-control/calendar/index.js +5 -30
  62. package/components/form-control/calendar/range.js +11 -28
  63. package/components/form-control/checkbox/index.js +4 -37
  64. package/components/form-control/control/index.js +3 -13
  65. package/components/form-control/date-picker/index-old.js +18 -0
  66. package/components/form-control/date-picker/index.js +23 -99
  67. package/components/form-control/date-range-picker/index.js +86 -221
  68. package/components/form-control/dropdown/index.js +72 -289
  69. package/components/form-control/dropdown-box/index.js +6 -35
  70. package/components/form-control/form/index.js +0 -2
  71. package/components/form-control/form-group/index.js +1 -6
  72. package/components/form-control/helper-text/index.js +2 -9
  73. package/components/form-control/input-base/index.js +218 -399
  74. package/components/form-control/label/index.js +2 -12
  75. package/components/form-control/money-input/index.js +43 -132
  76. package/components/form-control/number-input/index.js +15 -113
  77. package/components/form-control/number-input/index2.js +78 -119
  78. package/components/form-control/phone-input/index.js +16 -78
  79. package/components/form-control/radio/index.js +4 -23
  80. package/components/form-control/text-input/index.js +33 -256
  81. package/components/form-control/time-picker/index.js +14 -71
  82. package/components/form-control/time-picker/swiper.js +21 -73
  83. package/components/form-control/toggle/index.js +4 -19
  84. package/components/form-view/helper-text.js +2 -2
  85. package/components/form-view/index.js +0 -14
  86. package/components/form-view/input.js +2 -13
  87. package/components/form-view/label.js +0 -2
  88. package/components/grid/Col.js +2 -15
  89. package/components/grid/Container.js +2 -21
  90. package/components/grid/Row.js +2 -21
  91. package/components/grid/index.js +2 -43
  92. package/components/image/index.js +2 -22
  93. package/components/index.js +62 -31
  94. package/components/list/list-item-action.js +0 -9
  95. package/components/list/list-item-icon.js +0 -9
  96. package/components/list/list-item-text.js +0 -5
  97. package/components/list/list-item.js +0 -11
  98. package/components/list/list.js +0 -13
  99. package/components/list/sub-header.js +0 -4
  100. package/components/modal/body.js +2 -6
  101. package/components/modal/footer.js +2 -11
  102. package/components/modal/header.js +2 -12
  103. package/components/modal/index.js +2 -10
  104. package/components/modal/modal.js +11 -52
  105. package/components/others/extra/index.js +3 -10
  106. package/components/others/import/index.js +0 -7
  107. package/components/others/option-wrapper/index.js +4 -7
  108. package/components/others/scrollbar/index.js +0 -3
  109. package/components/paging/page-info.js +39 -101
  110. package/components/paging/page-selector.js +7 -35
  111. package/components/paging/page-selector2.js +35 -74
  112. package/components/paper/index.js +0 -11
  113. package/components/popover/body.js +2 -6
  114. package/components/popover/footer.js +2 -11
  115. package/components/popover/header.js +2 -7
  116. package/components/popover/index.js +39 -123
  117. package/components/popup/danger_popup.js +0 -19
  118. package/components/popup/index.js +2 -48
  119. package/components/popup/proposals_popup.js +10 -49
  120. package/components/popup/v2/index.js +0 -31
  121. package/components/progress/circular.js +19 -81
  122. package/components/progress/linear.js +4 -20
  123. package/components/rating/index.js +0 -24
  124. package/components/slider/slider-container.js +3 -40
  125. package/components/slider/slider-item.js +10 -25
  126. package/components/status/index.js +2 -16
  127. package/components/tab/tab-container.js +2 -16
  128. package/components/tab/tab-header.js +4 -24
  129. package/components/tab/tab-panel.js +4 -16
  130. package/components/tab/tab.js +4 -28
  131. package/components/tooltip/index.js +12 -97
  132. package/components/tooltip/portal.js +0 -2
  133. package/components/transfer/index.js +22 -67
  134. package/components/tree-view/index.js +62 -202
  135. package/components/typography/index.js +3 -31
  136. package/global/index.js +0 -8
  137. package/icons/basic.js +0 -48
  138. package/icons/effect.js +17 -29
  139. package/icons/general/clock/clock.js +0 -2
  140. package/icons/general/color-handler/background.js +0 -2
  141. package/icons/general/color-handler/text.js +0 -2
  142. package/icons/general/emoji/emoji.js +0 -2
  143. package/icons/general/font-properties/bold.js +0 -2
  144. package/icons/general/font-properties/font-family.js +0 -2
  145. package/icons/general/font-properties/font-size.js +0 -2
  146. package/icons/general/font-properties/italic.js +0 -2
  147. package/icons/general/font-properties/underline.js +0 -2
  148. package/icons/general/hyperlink/hyperlink.js +0 -2
  149. package/icons/general/indent/decrease.js +0 -2
  150. package/icons/general/indent/increase.js +0 -2
  151. package/icons/general/list/bullets.js +0 -2
  152. package/icons/general/list/numbering.js +0 -2
  153. package/icons/general/picture/picture.js +0 -2
  154. package/icons/general/steps/redo.js +0 -2
  155. package/icons/general/steps/undo.js +0 -2
  156. package/icons/general/text-align/center.js +0 -2
  157. package/icons/general/text-align/justify.js +0 -2
  158. package/icons/general/text-align/left.js +0 -2
  159. package/icons/general/text-align/right.js +0 -2
  160. package/icons/menu/dhr.js +2 -1
  161. package/icons/menu/index.js +2 -2
  162. package/icons/menu/v2/index.js +0 -10
  163. package/package.json +1 -1
  164. package/readme.md +11 -1
  165. package/styles/animation.js +15 -58
  166. package/styles/color-helper.js +24 -54
  167. package/styles/colors.js +17 -9
  168. package/styles/general.js +6 -2
  169. package/styles/typography.js +4 -4
  170. package/styles/utils.js +2 -2
  171. package/theme/createBreakpoints.js +7 -18
  172. package/theme/make-styles.js +2 -5
  173. package/theme/set-theme.js +3 -6
  174. package/theme/settings.js +3 -2
  175. package/theme/theme-provider.js +0 -1
  176. package/utils/array/array.js +14 -23
  177. package/utils/classNames.js +0 -5
  178. package/utils/console.js +0 -6
  179. package/utils/date.js +13 -82
  180. package/utils/error/error.js +1 -9
  181. package/utils/error/errors.js +1 -48
  182. package/utils/getFileType.js +0 -9
  183. package/utils/handleBreakpoints.js +0 -5
  184. package/utils/intersectionObserver.js +0 -5
  185. package/utils/iterator.js +0 -9
  186. package/utils/map-parent.js +3 -10
  187. package/utils/object/extend.js +0 -10
  188. package/utils/object/object.js +12 -11
  189. package/utils/parseHTML.js +0 -1
  190. package/utils/promisify.js +0 -5
  191. package/utils/randomString.js +0 -7
  192. package/utils/remove-unicode.js +0 -1
  193. package/utils/render-portal.js +1 -9
  194. package/utils/renderHTML.js +4 -6
  195. package/utils/renderIcon.js +4 -14
  196. package/utils/sb-template.js +6 -5
  197. package/utils/string/capitalize.js +0 -1
  198. package/utils/string/capitalizeSentenceCase.js +0 -2
  199. package/utils/string/string.js +0 -13
  200. package/utils/type.js +0 -21
  201. package/utils/updatePosition.js +4 -5
  202. package/utils/useDelayUnmount.js +0 -4
  203. package/utils/useElementSize.js +9 -3
  204. package/utils/useEventListener.js +12 -6
  205. package/utils/useInput.js +0 -6
  206. package/utils/useMediaQuery.js +8 -10
  207. package/utils/useOnClickOutside.js +0 -2
  208. package/utils/usePortal.js +3 -10
  209. package/utils/validate.js +6 -20
@@ -1,5 +1,4 @@
1
1
  /** @jsxRuntime classic */
2
-
3
2
  /** @jsx jsx */
4
3
  import { useState, useRef, forwardRef, useMemo, useCallback, useEffect, useImperativeHandle } from 'react';
5
4
  import PropTypes from 'prop-types';
@@ -14,10 +13,10 @@ const {
14
13
  } = theme;
15
14
  const regexValidNumber = /[^0-9.,-]/g;
16
15
  const regexNumber = /[^0-9]/g;
17
- const regexThousandNumber = /(\d)(?=(\d{3})+\b)/g; // Clamp number between two values with the following line:
16
+ const regexThousandNumber = /(\d)(?=(\d{3})+\b)/g;
18
17
 
18
+ // Clamp number between two values with the following line:
19
19
  const clamp = (num, min, max) => Math.min(Math.max(num, min), max);
20
-
21
20
  const NumberInput = /*#__PURE__*/forwardRef(({
22
21
  autoFocus,
23
22
  autoWidth,
@@ -61,10 +60,10 @@ const NumberInput = /*#__PURE__*/forwardRef(({
61
60
  const pos = useRef(null);
62
61
  const ref = useRef(null);
63
62
  const globalRef = useRef({});
64
- const [value, setValue] = useState(defaultValue); // nếu không cho nhập số âm mà max là âm thì remove giá trị max
63
+ const [value, setValue] = useState(defaultValue);
65
64
 
65
+ // nếu không cho nhập số âm mà max là âm thì remove giá trị max
66
66
  if (max < 0 && disabledNegative) max = null;
67
-
68
67
  if (thousandSymbol) {
69
68
  thousandSymbol = useMemo(() => {
70
69
  return typeof thousandSymbol === 'string' ? thousandSymbol : decimalSymbol === ',' ? '.' : ',';
@@ -75,21 +74,19 @@ const NumberInput = /*#__PURE__*/forwardRef(({
75
74
  } else {
76
75
  thousandSymbol = '';
77
76
  }
78
-
79
77
  const validateResult = validates && onValidate(value, validates, true);
80
78
  if (valueProps || valueProps === 0) valueProps = clamp(valueProps, min, max);
81
- /**
82
- * Convert number to format money
83
- * @param vl {number} - value
84
- * @type {function}
85
- * @return {string}
86
- * @example 1200300.123 => 1,200,300.123
87
- * @example 1200300,123 => 1.200.300,123
88
- */
89
79
 
80
+ /**
81
+ * Convert number to format money
82
+ * @param vl {number} - value
83
+ * @type {function}
84
+ * @return {string}
85
+ * @example 1200300.123 => 1,200,300.123
86
+ * @example 1200300,123 => 1.200.300,123
87
+ */
90
88
  const parseNumberToMoney = useCallback((vl, isNumber) => {
91
89
  var _number, _number2, _number$, _number3;
92
-
93
90
  const {
94
91
  current: {
95
92
  selectionStart
@@ -97,49 +94,44 @@ const NumberInput = /*#__PURE__*/forwardRef(({
97
94
  } = inputRef;
98
95
  let number = convertMoneyToNumber(vl, isNumber);
99
96
  if (disabledNegative && Number(number || 0) < 0) number = clamp(number, min, max);
100
- if (typeof max !== 'undefined' && Number(number) > max) number = Math.min(number, max); // number = Currency.format(number);
97
+ if (typeof max !== 'undefined' && Number(number) > max) number = Math.min(number, max);
101
98
 
99
+ // number = Currency.format(number);
102
100
  if (!number) return number;
103
101
  number = (_number = number) === null || _number === void 0 ? void 0 : _number.toString().split('.');
104
-
105
102
  if (number.length === 2 && !number[0]) {
106
103
  number[0] = '0';
107
104
  pos.current = 2;
108
105
  }
109
-
110
106
  number[0] = (_number2 = number) === null || _number2 === void 0 ? void 0 : _number2[0].replace(regexThousandNumber, '$1' + thousandSymbol); // add a thousand symbol to number
111
107
 
112
108
  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);
113
- number = number.join(decimalSymbol); // keep focus position
114
-
109
+ number = number.join(decimalSymbol);
110
+ // keep focus position
115
111
  if (((_number3 = number) === null || _number3 === void 0 ? void 0 : _number3.indexOf(thousandSymbol)) > -1 && selectionStart !== number.length + 1) {
116
112
  pos.current = selectionStart + (number.toString().length - 1 === vl.toString().length ? 1 : 0);
117
113
  }
118
-
119
114
  return number;
120
115
  }, [decimalSymbol, max, value]);
121
- /**
122
- * Convert money to format number
123
- * @param vl {string} - value
124
- * @type {function}
125
- * @return {number}
126
- * @example 1,200,300.123 => 1200300.123
127
- * @example 1.200.300,123 => 1200300.123
128
- */
129
116
 
117
+ /**
118
+ * Convert money to format number
119
+ * @param vl {string} - value
120
+ * @type {function}
121
+ * @return {number}
122
+ * @example 1,200,300.123 => 1200300.123
123
+ * @example 1.200.300,123 => 1200300.123
124
+ */
130
125
  const convertMoneyToNumber = useCallback((vl, isNumber) => {
131
126
  var _number4, _number4$toString, _number4$toString$rep, _number4$toString$rep2, _number4$toString$rep3;
132
-
133
127
  let number = vl === null || vl === void 0 ? void 0 : vl.toString().replace(regexValidNumber, ''); // allow number and , || . || -
134
- // remove <thousandSymbol> and replace . to <decimalSymbol>
135
128
 
129
+ // remove <thousandSymbol> and replace . to <decimalSymbol>
136
130
  if (!isNumber) number = (_number4 = number) === null || _number4 === void 0 ? void 0 : (_number4$toString = _number4.toString()) === null || _number4$toString === void 0 ? void 0 : (_number4$toString$rep = _number4$toString.replaceAll) === null || _number4$toString$rep === void 0 ? void 0 : (_number4$toString$rep2 = (_number4$toString$rep3 = _number4$toString$rep.call(_number4$toString, thousandSymbol, '')).replaceAll) === null || _number4$toString$rep2 === void 0 ? void 0 : _number4$toString$rep2.call(_number4$toString$rep3, decimalSymbol, '.');
137
131
  return number;
138
132
  }, [decimalSymbol]);
139
-
140
133
  const _onInput = e => {
141
134
  var _e$target$value;
142
-
143
135
  let valueT = (_e$target$value = e.target.value) !== null && _e$target$value !== void 0 ? _e$target$value : e.value;
144
136
  if (disabledNegative && Number(valueT || 0) < 0) return;
145
137
  valueT = parseNumberToMoney(valueT);
@@ -150,32 +142,25 @@ const NumberInput = /*#__PURE__*/forwardRef(({
150
142
  onInput === null || onInput === void 0 ? void 0 : onInput(e);
151
143
  setValue(valueT);
152
144
  };
153
-
154
145
  const _onBlur = e => {
155
146
  var _e$value;
156
-
157
147
  let value = (_e$value = e.value) !== null && _e$value !== void 0 ? _e$value : e.target.value;
158
148
  if (fixedDecimalDigit) value = Number(value).toFixed(decimalDigit);
159
-
160
149
  if ((value || value === '' && typeof min !== 'undefined') && (typeof min !== 'undefined' || typeof max !== 'undefined')) {
161
150
  value = convertMoneyToNumber(value);
162
-
163
151
  if (Number(value) < min || Number(value) > max) {
164
152
  const target = e.target;
165
153
  target.value = clamp(value, min, max);
166
-
167
- _onInput({ ...e,
154
+ _onInput({
155
+ ...e,
168
156
  target
169
157
  });
170
158
  }
171
159
  }
172
-
173
160
  onBlur && onBlur(e);
174
161
  };
175
-
176
162
  const _onKeyDown = e => {
177
163
  var _value$split, _value$split$;
178
-
179
164
  const {
180
165
  key,
181
166
  keyCode,
@@ -187,64 +172,73 @@ const NumberInput = /*#__PURE__*/forwardRef(({
187
172
  selectionStart,
188
173
  selectionEnd
189
174
  }
190
- } = e; // 0-9 only
191
-
192
- const isNumber = keyCode >= 48 && keyCode <= 57 && shiftKey === false || keyCode >= 96 && keyCode <= 105 || keyCode === 231 && key >= '0' && key <= '9'; // character input type="number"
193
-
194
- let allowKeyTypeNumber = isNumber || keyCode === 8 || // key backspace
195
- keyCode > 34 && keyCode < 40 || key === thousandSymbol || key === decimalSymbol || (ctrlKey || metaKey) && (keyCode === 65 || keyCode === 67 || keyCode === 86) || // ctrl + A, ctrl + C, ctrl + V
196
- keyCode === 46 || // key delete
197
- keyCode === 189 || keyCode === 109 || // -
175
+ } = e;
176
+
177
+ // 0-9 only
178
+ const isNumber = keyCode >= 48 && keyCode <= 57 && shiftKey === false || keyCode >= 96 && keyCode <= 105 || keyCode === 231 && key >= '0' && key <= '9';
179
+
180
+ // character input type="number"
181
+ let allowKeyTypeNumber = isNumber || keyCode === 8 ||
182
+ // key backspace
183
+ keyCode > 34 && keyCode < 40 || key === thousandSymbol || key === decimalSymbol || (ctrlKey || metaKey) && (keyCode === 65 || keyCode === 67 || keyCode === 86) ||
184
+ // ctrl + A, ctrl + C, ctrl + V
185
+ keyCode === 46 ||
186
+ // key delete
187
+ keyCode === 189 || keyCode === 109 ||
188
+ // -
198
189
  keyCode === 9; // tab
190
+
199
191
  // The key is delete (|| remove) and focus after the thousand digit
192
+ const removeDot = keyCode === 8 && selectionEnd - selectionStart <= 1 && value.charAt(selectionEnd - 1) === thousandSymbol;
200
193
 
201
- const removeDot = keyCode === 8 && selectionEnd - selectionStart <= 1 && value.charAt(selectionEnd - 1) === thousandSymbol; // Decimal
194
+ // Decimal
202
195
  // Do not allow the character decimal if decimalDigit is undefined
203
-
204
196
  const isDecimalSymbol = decimalSymbol === key;
205
- const disabledDecimalSymbol = isDecimalSymbol && !decimalDigit; // Accepts only one decimal separator
197
+ const disabledDecimalSymbol = isDecimalSymbol && !decimalDigit;
206
198
 
207
- const decimalExists = value.includes(decimalSymbol) && isDecimalSymbol; // Disabled typing input when decimal digit to limit and focus is last
199
+ // Accepts only one decimal separator
200
+ const decimalExists = value.includes(decimalSymbol) && isDecimalSymbol;
208
201
 
209
- 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}
202
+ // Disabled typing input when decimal digit to limit and focus is last
203
+ 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 &&
204
+ // total number after decimal symbol > {decimalDigit}
210
205
  selectionStart === value.length; // the focus is at the end of the string
211
-
212
- const target = e.target; // key arrow up
213
-
206
+ const target = e.target;
207
+ // key arrow up
214
208
  if (keyCode === 38) {
215
209
  target.value = Number(convertMoneyToNumber(value) || 0) + step;
216
-
217
- _onInput({ ...e,
210
+ _onInput({
211
+ ...e,
218
212
  target
219
213
  });
220
-
221
214
  e.preventDefault();
222
- } // key arrow down
215
+ }
216
+ // key arrow down
223
217
  else if (keyCode === 40) {
224
218
  target.value = Number(convertMoneyToNumber(value) || 0) - step;
225
-
226
- _onInput({ ...e,
219
+ _onInput({
220
+ ...e,
227
221
  target
228
222
  });
229
-
230
223
  e.preventDefault();
231
- } // disabled negative
232
-
224
+ }
233
225
 
234
- const disabled180 = (keyCode === 189 || keyCode === 109) && (disabledNegative || value.includes('-')); // disabled max digit
226
+ // disabled negative
227
+ const disabled180 = (keyCode === 189 || keyCode === 109) && (disabledNegative || value.includes('-'));
235
228
 
236
- const isMaxDigit = maxDigit && (value === null || value === void 0 ? void 0 : value.replace(regexNumber, '').length) === maxDigit && (isNumber || key === thousandSymbol || key === decimalSymbol) && selectionStart === selectionEnd; // Block event if include conditions
229
+ // disabled max digit
230
+ const isMaxDigit = maxDigit && (value === null || value === void 0 ? void 0 : value.replace(regexNumber, '').length) === maxDigit && (isNumber || key === thousandSymbol || key === decimalSymbol) && selectionStart === selectionEnd;
237
231
 
232
+ // Block event if include conditions
238
233
  if (decimalExists || removeDot || isNumber && disabledTypingDecimal || disabledDecimalSymbol || !allowKeyTypeNumber || disabled180 || isMaxDigit) {
239
234
  e.preventDefault();
240
235
  }
241
-
242
236
  onKeyDown === null || onKeyDown === void 0 ? void 0 : onKeyDown(e);
243
237
  };
244
-
245
238
  useEffect(() => {
246
- inputRef.current.value = value !== null && value !== void 0 ? value : null; // keep focus position
239
+ inputRef.current.value = value !== null && value !== void 0 ? value : null;
247
240
 
241
+ // keep focus position
248
242
  if (pos.current) {
249
243
  inputRef.current.setSelectionRange(pos.current, pos.current);
250
244
  pos.current = null;
@@ -252,7 +246,6 @@ const NumberInput = /*#__PURE__*/forwardRef(({
252
246
  }, [value]);
253
247
  useEffect(() => {
254
248
  var _valueProps;
255
-
256
249
  if (typeof valueProps !== 'undefined') if (disabledNegative && Number(valueProps || 0) < 0) {
257
250
  // nếu không cho nhập số âm mà value đầu vào là âm thì reset value về 0
258
251
  valueProps = clamp(0, min, max);
@@ -263,9 +256,7 @@ const NumberInput = /*#__PURE__*/forwardRef(({
263
256
  const currentRef = ref.current || {};
264
257
  currentRef.element = ref.current;
265
258
  const _instance = {}; // methods
266
-
267
259
  _instance.__proto__ = {}; // hidden methods
268
-
269
260
  currentRef.instance = _instance;
270
261
  return currentRef;
271
262
  });
@@ -273,7 +264,8 @@ const NumberInput = /*#__PURE__*/forwardRef(({
273
264
  ref: ref,
274
265
  css: NumberInputRoot,
275
266
  className: classNames('DGN-UI-NumberInput', className)
276
- }, !!label && jsx(Label, { ...labelProps,
267
+ }, !!label && jsx(Label, {
268
+ ...labelProps,
277
269
  required: required,
278
270
  disabled: disabled
279
271
  }, label), jsx(InputBase, {
@@ -301,15 +293,18 @@ const NumberInput = /*#__PURE__*/forwardRef(({
301
293
  const target = e.target;
302
294
  target.value = globalRef.current.valueString;
303
295
  target.valueString = globalRef.current.returnValue;
304
- onChange({ ...e,
296
+ onChange({
297
+ ...e,
305
298
  value: globalRef.current.value,
306
299
  target
307
300
  });
308
301
  },
309
302
  onBlur: e => _onBlur(e)
310
- }), !!error && jsx(HelperText, { ...helperTextProps,
303
+ }), !!error && jsx(HelperText, {
304
+ ...helperTextProps,
311
305
  disabled: disabled
312
- }, error), !error && validateResult && jsx(HelperText, { ...helperTextProps,
306
+ }, error), !error && validateResult && jsx(HelperText, {
307
+ ...helperTextProps,
313
308
  disabled: disabled
314
309
  }, validateResult));
315
310
  });
@@ -342,116 +337,80 @@ NumberInput.defaultProps = {
342
337
  NumberInput.propTypes = {
343
338
  /** If `true`, the `input` element is focused during the first mount. */
344
339
  autoFocus: PropTypes.bool,
345
-
346
340
  /** If `true`, width of input will resize according to content. */
347
341
  autoWidth: PropTypes.bool,
348
-
349
342
  /** Class for component. */
350
343
  className: PropTypes.string,
351
-
352
344
  /** Number of decimal places allowed. */
353
345
  decimalDigit: PropTypes.number,
354
-
355
346
  /** Separator symbol. */
356
347
  decimalSymbol: PropTypes.oneOf([',', '.']),
357
-
358
348
  /** Default value of the component. */
359
349
  defaultValue: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
360
-
361
350
  /** The number of milliseconds to wait before call onChange. */
362
351
  delayOnChange: PropTypes.number,
363
-
364
352
  /** If `true`, the component is disabled. */
365
353
  disabled: PropTypes.bool,
366
-
367
354
  /** If `true`, negative numbers are not allowed. */
368
355
  disabledNegative: PropTypes.bool,
369
-
370
356
  /** [Icon](https://core.diginet.com.vn/ui/?path=/story/icon-basic--basic) or element placed to the right of input. */
371
357
  endIcon: PropTypes.oneOfType([PropTypes.string, PropTypes.node]),
372
-
373
358
  /** Error displayed below input. */
374
359
  error: PropTypes.oneOfType([PropTypes.bool, PropTypes.string]),
375
-
376
360
  /** fixedDecimalDigit. */
377
361
  fixedDecimalDigit: PropTypes.bool,
378
-
379
362
  /** Props applied to the [HelperText](https://core.diginet.com.vn/ui/?path=/story/form-control-text-helpertext) element. */
380
363
  helperTextProps: PropTypes.object,
381
-
382
364
  /** [Attributes](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#attributes) applied to the input element. */
383
365
  inputProps: PropTypes.object,
384
-
385
366
  /** Pass a ref to the input element. */
386
367
  inputRef: ref,
387
-
388
368
  /** Style inline of input element. */
389
369
  inputStyle: PropTypes.object,
390
-
391
370
  /** The label of the component. */
392
371
  label: PropTypes.oneOfType([PropTypes.string, PropTypes.node]),
393
-
394
372
  /** Props applied to the [Label](https://core.diginet.com.vn/ui/?path=/docs/form-control-text-label) element. */
395
373
  labelProps: PropTypes.object,
396
-
397
374
  /** Maximum possible value. */
398
375
  max: PropTypes.number,
399
-
400
376
  /** Maximum value character (not including separator). */
401
377
  maxDigit: PropTypes.number,
402
-
403
378
  /** Minimal possible value. */
404
379
  min: PropTypes.number,
405
-
406
380
  /** If `true`, component will have no style */
407
381
  nonStyle: PropTypes.bool,
408
-
409
382
  /** Callback fired when the input is blurred. */
410
383
  onBlur: PropTypes.func,
411
-
412
384
  /** Callback fired when the value is changed. */
413
385
  onChange: PropTypes.func,
414
-
415
386
  /** Callback fired when the input is focused. */
416
387
  onFocus: PropTypes.func,
417
-
418
388
  /** Callback fired when input. */
419
389
  onInput: PropTypes.func,
420
-
421
390
  /** Callback fired when pressing a key. */
422
391
  onKeyDown: PropTypes.func,
423
-
424
392
  /** Callback fired when releases a key. */
425
393
  onKeyUp: PropTypes.func,
426
-
427
394
  /** The short hint displayed in the input before the user enters a value. */
428
395
  placeholder: PropTypes.string,
429
-
430
396
  /** If `true`, the component is readOnly. */
431
397
  readOnly: PropTypes.bool,
432
-
433
398
  /** If `true`, the input element is required. */
434
399
  required: PropTypes.bool,
435
-
436
400
  /** [Icon](https://core.diginet.com.vn/ui/?path=/story/icon-basic--basic) or element placed to the left of input. */
437
401
  startIcon: PropTypes.any,
438
-
439
402
  /** Specify how much the values should increase/decrease upon clicking on up/down button. */
440
403
  step: PropTypes.number,
441
-
442
404
  /** Thousand separator character. */
443
405
  thousandSeparator: PropTypes.oneOfType([PropTypes.bool, PropTypes.oneOf(['.', ','])]),
444
-
445
- /** Validation value, argument can:<br/>
446
- * * string: the validation rule. Example required.<br/>
447
- * * object: the validation rule insist name, property, message. Example {name: 'min', compareValue: 9, message: 'Error'} or {max: 99}<br/>
448
- * * array: the validation rule list, insist object/string
406
+ /** Validation value, argument can:<br/>
407
+ * * string: the validation rule. Example required.<br/>
408
+ * * object: the validation rule insist name, property, message. Example {name: 'min', compareValue: 9, message: 'Error'} or {max: 99}<br/>
409
+ * * array: the validation rule list, insist object/string
449
410
  */
450
411
  validates: PropTypes.oneOfType([PropTypes.string, PropTypes.object, PropTypes.array, PropTypes.func]),
451
-
452
412
  /** The value of the input element, required for a controlled component. */
453
413
  value: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
454
-
455
414
  /** The variant to use. */
456
415
  viewType: PropTypes.oneOf(['underlined', 'outlined'])
457
416
  };