aloha-vue 2.63.0 → 2.64.0

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.
@@ -10,6 +10,7 @@ import {
10
10
  export default function UtilsAPI(props) {
11
11
  const decimalDivider = toRef(props, "decimalDivider");
12
12
  const decimalPartLength = toRef(props, "decimalPartLength");
13
+ const modelType = toRef(props, "modelType");
13
14
  const thousandDivider = toRef(props, "thousandDivider");
14
15
 
15
16
  const getCleanIntValue = ({ value, thousandDivider }) => {
@@ -21,15 +22,26 @@ export default function UtilsAPI(props) {
21
22
  .split("").reverse().join("");
22
23
  };
23
24
 
25
+ const normalizeValueFromModel = value => {
26
+ const valueString = `${ value }`;
27
+ const isNumberStringWithDot = modelType.value === "number" &&
28
+ decimalDivider.value !== "." &&
29
+ /^-?\d+\.\d+$/.test(valueString);
30
+
31
+ if (typeof value === "number" || isNumberStringWithDot) {
32
+ return valueString.replace(".", decimalDivider.value);
33
+ }
34
+
35
+ return valueString;
36
+ };
37
+
24
38
  const adjustFloatPartAndDivider = val => {
25
39
  if (isNil(val)) {
26
40
  return "";
27
41
  }
28
42
 
29
43
  if (decimalDivider.value) {
30
- const splitVal = typeof val === "number"
31
- ? val.toString().split(".")
32
- : val.toString().split(decimalDivider.value);
44
+ const splitVal = normalizeValueFromModel(val).split(decimalDivider.value);
33
45
  const intPart = splitVal[0];
34
46
  const setMinusSymbol = intPart[0] === "-" ? "-" : "";
35
47
  const intPartWithoutMinus = setMinusSymbol ? intPart.slice(1) : intPart;
@@ -50,5 +62,6 @@ export default function UtilsAPI(props) {
50
62
  return {
51
63
  adjustFloatPartAndDivider,
52
64
  getCleanIntValue,
65
+ normalizeValueFromModel,
53
66
  };
54
67
  }