@tecsinapse/cortex-react 1.9.9-beta.0 → 1.9.9
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.
|
@@ -5,9 +5,15 @@ var React = require('react');
|
|
|
5
5
|
require('@internationalized/date');
|
|
6
6
|
var extractors = require('../utils/extractors.js');
|
|
7
7
|
|
|
8
|
+
const DEFAULT_OPTIONS = {
|
|
9
|
+
symbol: "R$ ",
|
|
10
|
+
separator: ".",
|
|
11
|
+
decimal: ",",
|
|
12
|
+
precision: 2
|
|
13
|
+
};
|
|
8
14
|
const getRegex = (precision) => new RegExp(`\\B(?=(\\d{${precision}})(?!\\d))`, "g");
|
|
9
15
|
const getInternalNumberAndMask = (value, options) => {
|
|
10
|
-
const mergedOptions = { ...options };
|
|
16
|
+
const mergedOptions = { ...DEFAULT_OPTIONS, ...options };
|
|
11
17
|
const { precision = -1 } = mergedOptions;
|
|
12
18
|
let internalNumber;
|
|
13
19
|
if (typeof value === "number") {
|
|
@@ -48,7 +54,7 @@ const useNumberMask = (options, defaultValue) => {
|
|
|
48
54
|
);
|
|
49
55
|
return {
|
|
50
56
|
raw: internalNumber,
|
|
51
|
-
formatted: currency(internalNumber
|
|
57
|
+
formatted: currency(internalNumber).format(mergedOptions)
|
|
52
58
|
};
|
|
53
59
|
},
|
|
54
60
|
[options, getRegex]
|
|
@@ -3,9 +3,15 @@ import { useCallback, useState } from 'react';
|
|
|
3
3
|
import '@internationalized/date';
|
|
4
4
|
import { extractNumbersFromString } from '../utils/extractors.js';
|
|
5
5
|
|
|
6
|
+
const DEFAULT_OPTIONS = {
|
|
7
|
+
symbol: "R$ ",
|
|
8
|
+
separator: ".",
|
|
9
|
+
decimal: ",",
|
|
10
|
+
precision: 2
|
|
11
|
+
};
|
|
6
12
|
const getRegex = (precision) => new RegExp(`\\B(?=(\\d{${precision}})(?!\\d))`, "g");
|
|
7
13
|
const getInternalNumberAndMask = (value, options) => {
|
|
8
|
-
const mergedOptions = { ...options };
|
|
14
|
+
const mergedOptions = { ...DEFAULT_OPTIONS, ...options };
|
|
9
15
|
const { precision = -1 } = mergedOptions;
|
|
10
16
|
let internalNumber;
|
|
11
17
|
if (typeof value === "number") {
|
|
@@ -46,7 +52,7 @@ const useNumberMask = (options, defaultValue) => {
|
|
|
46
52
|
);
|
|
47
53
|
return {
|
|
48
54
|
raw: internalNumber,
|
|
49
|
-
formatted: currency(internalNumber
|
|
55
|
+
formatted: currency(internalNumber).format(mergedOptions)
|
|
50
56
|
};
|
|
51
57
|
},
|
|
52
58
|
[options, getRegex]
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tecsinapse/cortex-react",
|
|
3
|
-
"version": "1.9.9
|
|
3
|
+
"version": "1.9.9",
|
|
4
4
|
"description": "React components based in @tecsinapse/cortex-core",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "dist/esm/index.js",
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"dependencies": {
|
|
21
21
|
"@floating-ui/react": "^0.26.18",
|
|
22
22
|
"@internationalized/date": "*",
|
|
23
|
-
"@tecsinapse/cortex-core": "0.4.6
|
|
23
|
+
"@tecsinapse/cortex-core": "0.4.6",
|
|
24
24
|
"clsx": "*",
|
|
25
25
|
"currency.js": "~2.0.4",
|
|
26
26
|
"react-aria": "^3.33.1",
|
|
@@ -48,5 +48,5 @@
|
|
|
48
48
|
"react-dom": ">=18.0.0",
|
|
49
49
|
"tailwind": ">=3.3.0"
|
|
50
50
|
},
|
|
51
|
-
"gitHead": "
|
|
51
|
+
"gitHead": "b09eb691310bb40ea8e7481d2bdfece3c3b239ff"
|
|
52
52
|
}
|