@sankhyalabs/core 1.0.42 → 1.0.45
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/.eslintignore +1 -1
- package/.eslintrc.cjs +34 -34
- package/README.md +54 -54
- package/dist/dataunit/DataUnit.d.ts +87 -82
- package/dist/dataunit/DataUnit.js +290 -278
- package/dist/dataunit/DataUnit.js.map +1 -1
- package/dist/dataunit/metadata/DataType.d.ts +9 -9
- package/dist/dataunit/metadata/DataType.js +36 -36
- package/dist/dataunit/metadata/UnitMetadata.d.ts +71 -71
- package/dist/dataunit/metadata/UnitMetadata.js +31 -31
- package/dist/dataunit/state/HistReducer.d.ts +10 -10
- package/dist/dataunit/state/HistReducer.js +27 -27
- package/dist/dataunit/state/StateManager.d.ts +57 -57
- package/dist/dataunit/state/StateManager.js +96 -96
- package/dist/dataunit/state/action/DataUnitAction.d.ts +29 -28
- package/dist/dataunit/state/action/DataUnitAction.js +34 -33
- package/dist/dataunit/state/action/DataUnitAction.js.map +1 -1
- package/dist/dataunit/state/slice/AddedRecordsSlice.d.ts +11 -11
- package/dist/dataunit/state/slice/AddedRecordsSlice.js +25 -25
- package/dist/dataunit/state/slice/ChangesSlice.d.ts +12 -12
- package/dist/dataunit/state/slice/ChangesSlice.js +76 -72
- package/dist/dataunit/state/slice/ChangesSlice.js.map +1 -1
- package/dist/dataunit/state/slice/CurrentRecordsSlice.d.ts +11 -11
- package/dist/dataunit/state/slice/CurrentRecordsSlice.js +45 -45
- package/dist/dataunit/state/slice/RecordsSlice.d.ts +10 -10
- package/dist/dataunit/state/slice/RecordsSlice.js +43 -43
- package/dist/dataunit/state/slice/RemovedRecordsSlice.d.ts +9 -9
- package/dist/dataunit/state/slice/RemovedRecordsSlice.js +24 -24
- package/dist/dataunit/state/slice/SelectionSlice.d.ts +11 -11
- package/dist/dataunit/state/slice/SelectionSlice.js +111 -111
- package/dist/dataunit/state/slice/UnitMetadataSlice.d.ts +11 -11
- package/dist/dataunit/state/slice/UnitMetadataSlice.js +20 -20
- package/dist/dataunit/state/slice/WaitingChangesSlice.d.ts +9 -0
- package/dist/dataunit/state/slice/WaitingChangesSlice.js +32 -0
- package/dist/dataunit/state/slice/WaitingChangesSlice.js.map +1 -0
- package/dist/http/AuthorizedServiceCaller.d.ts +11 -11
- package/dist/http/AuthorizedServiceCaller.js +53 -53
- package/dist/http/HttpProvider.d.ts +25 -25
- package/dist/http/HttpProvider.js +73 -73
- package/dist/http/RequestMetadata.d.ts +30 -30
- package/dist/http/RequestMetadata.js +24 -24
- package/dist/http/SkwHttpProvider.d.ts +9 -9
- package/dist/http/SkwHttpProvider.js +66 -66
- package/dist/index.d.ts +16 -16
- package/dist/index.js +17 -17
- package/dist/index.js.map +1 -1
- package/dist/ui/FloatingManager.d.ts +25 -24
- package/dist/ui/FloatingManager.js +124 -122
- package/dist/ui/FloatingManager.js.map +1 -1
- package/dist/utils/ApplicationContext.d.ts +5 -5
- package/dist/utils/ApplicationContext.js +16 -16
- package/dist/utils/CriteriaModel.d.ts +109 -109
- package/dist/utils/CriteriaModel.js +173 -173
- package/dist/utils/CriteriaParameter.d.ts +69 -69
- package/dist/utils/CriteriaParameter.js +82 -82
- package/dist/utils/DateUtils.d.ts +5 -5
- package/dist/utils/DateUtils.js +42 -42
- package/dist/utils/MaskFormatter.d.ts +126 -126
- package/dist/utils/MaskFormatter.js +275 -275
- package/dist/utils/NumberUtils.d.ts +53 -53
- package/dist/utils/NumberUtils.js +141 -141
- package/dist/utils/StringUtils.d.ts +18 -18
- package/dist/utils/StringUtils.js +53 -53
- package/dist/utils/TimeFormatter.d.ts +33 -33
- package/dist/utils/TimeFormatter.js +97 -97
- package/jest.config.ts +16 -16
- package/mock/http/XMLHttpRequest-mock.js +25 -25
- package/package.json +38 -37
- package/scripts/runlink.bat +1 -0
- package/src/dataunit/DataUnit.ts +374 -356
- package/src/dataunit/metadata/DataType.ts +37 -37
- package/src/dataunit/metadata/UnitMetadata.ts +82 -82
- package/src/dataunit/state/HistReducer.ts +33 -33
- package/src/dataunit/state/StateManager.ts +141 -141
- package/src/dataunit/state/action/DataUnitAction.ts +52 -50
- package/src/dataunit/state/slice/AddedRecordsSlice.ts +32 -32
- package/src/dataunit/state/slice/ChangesSlice.ts +95 -90
- package/src/dataunit/state/slice/CurrentRecordsSlice.ts +53 -53
- package/src/dataunit/state/slice/RecordsSlice.ts +56 -56
- package/src/dataunit/state/slice/RemovedRecordsSlice.ts +29 -29
- package/src/dataunit/state/slice/SelectionSlice.ts +130 -130
- package/src/dataunit/state/slice/UnitMetadataSlice.ts +29 -29
- package/src/dataunit/state/slice/WaitingChangesSlice.ts +44 -0
- package/src/http/AuthorizedServiceCaller.ts +58 -58
- package/src/http/HttpProvider.ts +93 -93
- package/src/http/RequestMetadata.ts +41 -41
- package/src/http/SkwHttpProvider.ts +77 -77
- package/src/index.ts +45 -44
- package/src/ui/FloatingManager.ts +167 -165
- package/src/utils/ApplicationContext.ts +18 -18
- package/src/utils/CriteriaModel.ts +207 -207
- package/src/utils/CriteriaParameter.ts +107 -107
- package/src/utils/DateUtils.ts +52 -52
- package/src/utils/MaskFormatter.ts +322 -322
- package/src/utils/NumberUtils.ts +174 -174
- package/src/utils/StringUtils.ts +60 -60
- package/src/utils/TimeFormatter.ts +97 -97
- package/test/http/HttpProvider.spec.ts +34 -34
- package/test/http/SkwHttpProvider.ts.spec.ts +33 -33
- package/test/util/CriteriaModel.spec.ts +231 -231
- package/test/util/CriteriaParameter.spec.ts +51 -51
- package/test/util/MaskFormatter.spec.ts +138 -138
- package/test/util/NumberUtils.spec.ts +156 -156
- package/test/util/StringUtils.spec.ts +43 -43
- package/test/util/TimeFormatter.spec.ts +25 -25
- package/tsconfig.json +15 -15
- package/dist/application/Application.d.ts +0 -8
- package/dist/application/Application.js +0 -19
- package/dist/application/Application.js.map +0 -1
- package/dist/http/data-fetcher/HttpFetcher.d.ts +0 -14
- package/dist/http/data-fetcher/HttpFetcher.js +0 -164
- package/dist/http/data-fetcher/HttpFetcher.js.map +0 -1
- package/dist/http/data-fetcher/default/DefaultGraphQL.d.ts +0 -3
- package/dist/http/data-fetcher/default/DefaultGraphQL.js +0 -18
- package/dist/http/data-fetcher/default/DefaultGraphQL.js.map +0 -1
- package/dist/http/data-fetcher/default/application-config-fetcher.d.ts +0 -6
- package/dist/http/data-fetcher/default/application-config-fetcher.js +0 -21
- package/dist/http/data-fetcher/default/application-config-fetcher.js.map +0 -1
- package/dist/http/data-fetcher/default/data-unit-graphql.d.ts +0 -3
- package/dist/http/data-fetcher/default/data-unit-graphql.js +0 -18
- package/dist/http/data-fetcher/default/data-unit-graphql.js.map +0 -1
- package/dist/http/data-fetcher/default/dataunit-executor.d.ts +0 -10
- package/dist/http/data-fetcher/default/dataunit-executor.js +0 -56
- package/dist/http/data-fetcher/default/dataunit-executor.js.map +0 -1
- package/dist/http/data-fetcher/default/dataunit-fetcher.d.ts +0 -9
- package/dist/http/data-fetcher/default/dataunit-fetcher.js +0 -69
- package/dist/http/data-fetcher/default/dataunit-fetcher.js.map +0 -1
- package/dist/http/data-fetcher/default/form-config-fetcher.d.ts +0 -2
- package/dist/http/data-fetcher/default/form-config-fetcher.js +0 -3
- package/dist/http/data-fetcher/default/form-config-fetcher.js.map +0 -1
- package/dist/http/data-fetcher/default/grid-config-fetcher.d.ts +0 -2
- package/dist/http/data-fetcher/default/grid-config-fetcher.js +0 -3
- package/dist/http/data-fetcher/default/grid-config-fetcher.js.map +0 -1
- package/dist/http/data-fetcher/default/index.d.ts +0 -0
- package/dist/http/data-fetcher/default/index.js +0 -2
- package/dist/http/data-fetcher/default/index.js.map +0 -1
- package/dist/http/data-fetcher/default/sankhya-graphql.d.ts +0 -3
- package/dist/http/data-fetcher/default/sankhya-graphql.js +0 -8
- package/dist/http/data-fetcher/default/sankhya-graphql.js.map +0 -1
- package/dist/http/data-fetcher/graphql/DefaultGraphQl.d.ts +0 -3
- package/dist/http/data-fetcher/graphql/DefaultGraphQl.js +0 -18
- package/dist/http/data-fetcher/graphql/DefaultGraphQl.js.map +0 -1
- package/dist/http/data-fetcher/state/LoadStateManager.d.ts +0 -23
- package/dist/http/data-fetcher/state/LoadStateManager.js +0 -78
- package/dist/http/data-fetcher/state/LoadStateManager.js.map +0 -1
|
@@ -1,142 +1,142 @@
|
|
|
1
|
-
const NUMBERINPUTS_REGEX_SCIENTIFIC_PARTS = /^([+-])?(\d+).?(\d*)[eE]([-+]?\d+)$/;
|
|
2
|
-
/**
|
|
3
|
-
* `NumberUtils` é uma biblioteca para manipulação de números
|
|
4
|
-
*
|
|
5
|
-
* `Métodos`:
|
|
6
|
-
*
|
|
7
|
-
* @stringToNumber: converte um número em formato de string em um valor numérico nativo do javascript
|
|
8
|
-
* @format: arredonda um número em formato de string baseado nos parâmetros "presision" e "prettyPrecision";
|
|
9
|
-
*/
|
|
10
|
-
export class NumberUtils {
|
|
11
|
-
}
|
|
12
|
-
/**
|
|
13
|
-
* @stringToNumber: converte um numero em formato de string em numero
|
|
14
|
-
*
|
|
15
|
-
* @param value numero em formato de string a ser convertido (Importante: formato PT-BR ou já em formato numérico: ######.##)
|
|
16
|
-
*
|
|
17
|
-
* @returns string based number
|
|
18
|
-
*
|
|
19
|
-
* @Exemples
|
|
20
|
-
* @"100,12" | 100.12
|
|
21
|
-
* @"100.12" | 100.12
|
|
22
|
-
* @"-100,12" | -100.12
|
|
23
|
-
* @"R$100,12" | 100.12
|
|
24
|
-
* @"-R$100,12" | -100.12
|
|
25
|
-
* @"string" | NaN
|
|
26
|
-
*/
|
|
27
|
-
NumberUtils.stringToNumber = (value) => {
|
|
28
|
-
if (value === '' || value === null || value === undefined) {
|
|
29
|
-
return NaN;
|
|
30
|
-
}
|
|
31
|
-
if (value) {
|
|
32
|
-
value = value.toString();
|
|
33
|
-
const negative = (value.charAt(0) === '-');
|
|
34
|
-
if (!NUMBERINPUTS_REGEX_SCIENTIFIC_PARTS.test(value)) {
|
|
35
|
-
value = value.replace(/[^\d.,]/g, '');
|
|
36
|
-
}
|
|
37
|
-
else {
|
|
38
|
-
value = value.replace(/^-/g, '');
|
|
39
|
-
}
|
|
40
|
-
//In case of simple string such as: "@@@@@@@"
|
|
41
|
-
if (value === '') {
|
|
42
|
-
return Number(NaN);
|
|
43
|
-
}
|
|
44
|
-
const indexV = value.indexOf(',');
|
|
45
|
-
const indexP = value.indexOf('.');
|
|
46
|
-
if (indexP > indexV) {
|
|
47
|
-
value = value.replace(',', '');
|
|
48
|
-
}
|
|
49
|
-
else if (indexP < indexV) {
|
|
50
|
-
value = value.replace(/\./g, '@').replace(',', '.').replace(/@/g, '');
|
|
51
|
-
}
|
|
52
|
-
if (negative) {
|
|
53
|
-
value = '-' + value;
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
return Number(value);
|
|
57
|
-
};
|
|
58
|
-
/**
|
|
59
|
-
* @format: converte um numero em formato de string em um numero em formato de string formatado de acordo com os parametros de "precision" e "prettyPrecision"
|
|
60
|
-
*
|
|
61
|
-
* @param value numero em formato de string a ser convertido (Importante: formato PT-BR ou já em formato numérico<sem separadors de milhares>: ######.##)
|
|
62
|
-
* @param precision (numero de decimais)
|
|
63
|
-
* @param prettyPrecision (numero de zeros nos decimais)
|
|
64
|
-
*
|
|
65
|
-
* @returns numero em formato de string formatado em PT-BR
|
|
66
|
-
*/
|
|
67
|
-
NumberUtils.format = (value, precision, prettyPrecision = NaN) => {
|
|
68
|
-
if (value === '' || value === undefined || value === "NaN") {
|
|
69
|
-
return NaN.toString();
|
|
70
|
-
}
|
|
71
|
-
const newValue = NumberUtils.stringToNumber(value);
|
|
72
|
-
if (isNaN(newValue)) {
|
|
73
|
-
return NaN.toString();
|
|
74
|
-
}
|
|
75
|
-
//Validation "precision":
|
|
76
|
-
// Case1: precision < 0 => does not use precision
|
|
77
|
-
// Case2: presicion not int => does not use precision
|
|
78
|
-
if (precision < 0 || Math.abs(Math.round(precision * 1) / 1) !== precision) {
|
|
79
|
-
//Once stringToNumber returns number format, we need to change to pt-br
|
|
80
|
-
return NumberUtils.changeFormat(newValue.toString());
|
|
81
|
-
}
|
|
82
|
-
//Validation "prettyPrecision"
|
|
83
|
-
let prettyPrecisionInternal = 0;
|
|
84
|
-
// Case1: prettyPrecision < 0 => prettyPrecision does not change de format that means: prettyPrecisionInternal = precision;
|
|
85
|
-
// Case2: prettyPrecision not int => prettyPrecision does not change de format that means: prettyPrecisionInternal = precision;
|
|
86
|
-
if (isNaN(prettyPrecision) || Math.abs(Math.round(prettyPrecision * 1) / 1) !== prettyPrecision) {
|
|
87
|
-
prettyPrecisionInternal = precision;
|
|
88
|
-
}
|
|
89
|
-
else {
|
|
90
|
-
prettyPrecisionInternal = prettyPrecision;
|
|
91
|
-
}
|
|
92
|
-
let newValueStr;
|
|
93
|
-
newValueStr = (Math.round(newValue * Math.pow(10, precision)) / Math.pow(10, precision)).toLocaleString('pt-br', { minimumFractionDigits: precision });
|
|
94
|
-
//prettyPrecision
|
|
95
|
-
const varSettingPP = precision - prettyPrecisionInternal;
|
|
96
|
-
if (varSettingPP > 0) {
|
|
97
|
-
for (let i = 0; i < varSettingPP; i++) {
|
|
98
|
-
if (newValueStr.substring(newValueStr.length - 1) == "0" && precision > 0) {
|
|
99
|
-
newValueStr = newValueStr.substring(0, newValueStr.length - 1);
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
//in Case "." or "," in the end of the string
|
|
104
|
-
if (newValueStr.substring(newValueStr.length - 1) == "." || newValueStr.substring(newValueStr.length - 1) == ",") {
|
|
105
|
-
newValueStr = newValueStr.substring(0, newValueStr.length - 1);
|
|
106
|
-
}
|
|
107
|
-
return newValueStr;
|
|
108
|
-
};
|
|
109
|
-
/**
|
|
110
|
-
* @keepOnlyDecimalSeparator: retira os separadores de milhar de um número em formato de string
|
|
111
|
-
*
|
|
112
|
-
* @param value numero em formato de string a ser convertido
|
|
113
|
-
* @param formatnumber (formatação de ENTRADA e SAÍDA do utilitário: pt-BR="###.###,##" en-US="###,###.##"; Default: "pt-BR")
|
|
114
|
-
*
|
|
115
|
-
* @returns numero em formato de string formatado apenas com separador decimal
|
|
116
|
-
*/
|
|
117
|
-
NumberUtils.keepOnlyDecimalSeparator = (value, formatnumber = 'pt-BR') => {
|
|
118
|
-
//Formatting formatnumber to be able to get lowercases
|
|
119
|
-
formatnumber = formatnumber.toUpperCase();
|
|
120
|
-
//Formatting value following formatnumber parameter
|
|
121
|
-
//keep only decimal character in order to correct format the string
|
|
122
|
-
//This transformation is due the "stringtoNumber" method is a general method that tries to convert all formated strings
|
|
123
|
-
if (formatnumber === 'EN-US') {
|
|
124
|
-
value = value.replace(/\,/g, '');
|
|
125
|
-
}
|
|
126
|
-
else {
|
|
127
|
-
value = value.replace(/\./g, '');
|
|
128
|
-
}
|
|
129
|
-
return value;
|
|
130
|
-
};
|
|
131
|
-
/**
|
|
132
|
-
* @changeFormat: troca o formato do numero string de "PT-BR" para "EN-US" e vice-versa
|
|
133
|
-
*
|
|
134
|
-
* @param value numero em formato de string a ser convertido
|
|
135
|
-
*
|
|
136
|
-
* @returns numero em formato de string formatado de "PT-BR" para "EN-US" e vice-versa
|
|
137
|
-
*/
|
|
138
|
-
NumberUtils.changeFormat = (value) => {
|
|
139
|
-
//Formatting output following formatnumber
|
|
140
|
-
return value.replace(/\./g, '_').replace(/\,/g, '.').replace(/\_/g, ',');
|
|
141
|
-
};
|
|
1
|
+
const NUMBERINPUTS_REGEX_SCIENTIFIC_PARTS = /^([+-])?(\d+).?(\d*)[eE]([-+]?\d+)$/;
|
|
2
|
+
/**
|
|
3
|
+
* `NumberUtils` é uma biblioteca para manipulação de números
|
|
4
|
+
*
|
|
5
|
+
* `Métodos`:
|
|
6
|
+
*
|
|
7
|
+
* @stringToNumber: converte um número em formato de string em um valor numérico nativo do javascript
|
|
8
|
+
* @format: arredonda um número em formato de string baseado nos parâmetros "presision" e "prettyPrecision";
|
|
9
|
+
*/
|
|
10
|
+
export class NumberUtils {
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* @stringToNumber: converte um numero em formato de string em numero
|
|
14
|
+
*
|
|
15
|
+
* @param value numero em formato de string a ser convertido (Importante: formato PT-BR ou já em formato numérico: ######.##)
|
|
16
|
+
*
|
|
17
|
+
* @returns string based number
|
|
18
|
+
*
|
|
19
|
+
* @Exemples
|
|
20
|
+
* @"100,12" | 100.12
|
|
21
|
+
* @"100.12" | 100.12
|
|
22
|
+
* @"-100,12" | -100.12
|
|
23
|
+
* @"R$100,12" | 100.12
|
|
24
|
+
* @"-R$100,12" | -100.12
|
|
25
|
+
* @"string" | NaN
|
|
26
|
+
*/
|
|
27
|
+
NumberUtils.stringToNumber = (value) => {
|
|
28
|
+
if (value === '' || value === null || value === undefined) {
|
|
29
|
+
return NaN;
|
|
30
|
+
}
|
|
31
|
+
if (value) {
|
|
32
|
+
value = value.toString();
|
|
33
|
+
const negative = (value.charAt(0) === '-');
|
|
34
|
+
if (!NUMBERINPUTS_REGEX_SCIENTIFIC_PARTS.test(value)) {
|
|
35
|
+
value = value.replace(/[^\d.,]/g, '');
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
value = value.replace(/^-/g, '');
|
|
39
|
+
}
|
|
40
|
+
//In case of simple string such as: "@@@@@@@"
|
|
41
|
+
if (value === '') {
|
|
42
|
+
return Number(NaN);
|
|
43
|
+
}
|
|
44
|
+
const indexV = value.indexOf(',');
|
|
45
|
+
const indexP = value.indexOf('.');
|
|
46
|
+
if (indexP > indexV) {
|
|
47
|
+
value = value.replace(',', '');
|
|
48
|
+
}
|
|
49
|
+
else if (indexP < indexV) {
|
|
50
|
+
value = value.replace(/\./g, '@').replace(',', '.').replace(/@/g, '');
|
|
51
|
+
}
|
|
52
|
+
if (negative) {
|
|
53
|
+
value = '-' + value;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
return Number(value);
|
|
57
|
+
};
|
|
58
|
+
/**
|
|
59
|
+
* @format: converte um numero em formato de string em um numero em formato de string formatado de acordo com os parametros de "precision" e "prettyPrecision"
|
|
60
|
+
*
|
|
61
|
+
* @param value numero em formato de string a ser convertido (Importante: formato PT-BR ou já em formato numérico<sem separadors de milhares>: ######.##)
|
|
62
|
+
* @param precision (numero de decimais)
|
|
63
|
+
* @param prettyPrecision (numero de zeros nos decimais)
|
|
64
|
+
*
|
|
65
|
+
* @returns numero em formato de string formatado em PT-BR
|
|
66
|
+
*/
|
|
67
|
+
NumberUtils.format = (value, precision, prettyPrecision = NaN) => {
|
|
68
|
+
if (value === '' || value === undefined || value === "NaN") {
|
|
69
|
+
return NaN.toString();
|
|
70
|
+
}
|
|
71
|
+
const newValue = NumberUtils.stringToNumber(value);
|
|
72
|
+
if (isNaN(newValue)) {
|
|
73
|
+
return NaN.toString();
|
|
74
|
+
}
|
|
75
|
+
//Validation "precision":
|
|
76
|
+
// Case1: precision < 0 => does not use precision
|
|
77
|
+
// Case2: presicion not int => does not use precision
|
|
78
|
+
if (precision < 0 || Math.abs(Math.round(precision * 1) / 1) !== precision) {
|
|
79
|
+
//Once stringToNumber returns number format, we need to change to pt-br
|
|
80
|
+
return NumberUtils.changeFormat(newValue.toString());
|
|
81
|
+
}
|
|
82
|
+
//Validation "prettyPrecision"
|
|
83
|
+
let prettyPrecisionInternal = 0;
|
|
84
|
+
// Case1: prettyPrecision < 0 => prettyPrecision does not change de format that means: prettyPrecisionInternal = precision;
|
|
85
|
+
// Case2: prettyPrecision not int => prettyPrecision does not change de format that means: prettyPrecisionInternal = precision;
|
|
86
|
+
if (isNaN(prettyPrecision) || Math.abs(Math.round(prettyPrecision * 1) / 1) !== prettyPrecision) {
|
|
87
|
+
prettyPrecisionInternal = precision;
|
|
88
|
+
}
|
|
89
|
+
else {
|
|
90
|
+
prettyPrecisionInternal = prettyPrecision;
|
|
91
|
+
}
|
|
92
|
+
let newValueStr;
|
|
93
|
+
newValueStr = (Math.round(newValue * Math.pow(10, precision)) / Math.pow(10, precision)).toLocaleString('pt-br', { minimumFractionDigits: precision });
|
|
94
|
+
//prettyPrecision
|
|
95
|
+
const varSettingPP = precision - prettyPrecisionInternal;
|
|
96
|
+
if (varSettingPP > 0) {
|
|
97
|
+
for (let i = 0; i < varSettingPP; i++) {
|
|
98
|
+
if (newValueStr.substring(newValueStr.length - 1) == "0" && precision > 0) {
|
|
99
|
+
newValueStr = newValueStr.substring(0, newValueStr.length - 1);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
//in Case "." or "," in the end of the string
|
|
104
|
+
if (newValueStr.substring(newValueStr.length - 1) == "." || newValueStr.substring(newValueStr.length - 1) == ",") {
|
|
105
|
+
newValueStr = newValueStr.substring(0, newValueStr.length - 1);
|
|
106
|
+
}
|
|
107
|
+
return newValueStr;
|
|
108
|
+
};
|
|
109
|
+
/**
|
|
110
|
+
* @keepOnlyDecimalSeparator: retira os separadores de milhar de um número em formato de string
|
|
111
|
+
*
|
|
112
|
+
* @param value numero em formato de string a ser convertido
|
|
113
|
+
* @param formatnumber (formatação de ENTRADA e SAÍDA do utilitário: pt-BR="###.###,##" en-US="###,###.##"; Default: "pt-BR")
|
|
114
|
+
*
|
|
115
|
+
* @returns numero em formato de string formatado apenas com separador decimal
|
|
116
|
+
*/
|
|
117
|
+
NumberUtils.keepOnlyDecimalSeparator = (value, formatnumber = 'pt-BR') => {
|
|
118
|
+
//Formatting formatnumber to be able to get lowercases
|
|
119
|
+
formatnumber = formatnumber.toUpperCase();
|
|
120
|
+
//Formatting value following formatnumber parameter
|
|
121
|
+
//keep only decimal character in order to correct format the string
|
|
122
|
+
//This transformation is due the "stringtoNumber" method is a general method that tries to convert all formated strings
|
|
123
|
+
if (formatnumber === 'EN-US') {
|
|
124
|
+
value = value.replace(/\,/g, '');
|
|
125
|
+
}
|
|
126
|
+
else {
|
|
127
|
+
value = value.replace(/\./g, '');
|
|
128
|
+
}
|
|
129
|
+
return value;
|
|
130
|
+
};
|
|
131
|
+
/**
|
|
132
|
+
* @changeFormat: troca o formato do numero string de "PT-BR" para "EN-US" e vice-versa
|
|
133
|
+
*
|
|
134
|
+
* @param value numero em formato de string a ser convertido
|
|
135
|
+
*
|
|
136
|
+
* @returns numero em formato de string formatado de "PT-BR" para "EN-US" e vice-versa
|
|
137
|
+
*/
|
|
138
|
+
NumberUtils.changeFormat = (value) => {
|
|
139
|
+
//Formatting output following formatnumber
|
|
140
|
+
return value.replace(/\./g, '_').replace(/\,/g, '.').replace(/\_/g, ',');
|
|
141
|
+
};
|
|
142
142
|
//# sourceMappingURL=NumberUtils.js.map
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Classe com utiliários comuns para Strings.
|
|
3
|
-
*/
|
|
4
|
-
export declare class StringUtils {
|
|
5
|
-
/**
|
|
6
|
-
* Verifica se a string está vazia.
|
|
7
|
-
* Valores null e undefined são considerados como vazio.
|
|
8
|
-
*
|
|
9
|
-
* @param value String para ser validada.
|
|
10
|
-
*/
|
|
11
|
-
static isEmpty(value: any): Boolean;
|
|
12
|
-
/**
|
|
13
|
-
* Remove acentos de vogais, substitui Ç por c e retorna a string em caixa alta.
|
|
14
|
-
*
|
|
15
|
-
* @param value String para ser transformada.
|
|
16
|
-
*/
|
|
17
|
-
static replaceAccentuatedChars(text: string): string;
|
|
18
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* Classe com utiliários comuns para Strings.
|
|
3
|
+
*/
|
|
4
|
+
export declare class StringUtils {
|
|
5
|
+
/**
|
|
6
|
+
* Verifica se a string está vazia.
|
|
7
|
+
* Valores null e undefined são considerados como vazio.
|
|
8
|
+
*
|
|
9
|
+
* @param value String para ser validada.
|
|
10
|
+
*/
|
|
11
|
+
static isEmpty(value: any): Boolean;
|
|
12
|
+
/**
|
|
13
|
+
* Remove acentos de vogais, substitui Ç por c e retorna a string em caixa alta.
|
|
14
|
+
*
|
|
15
|
+
* @param value String para ser transformada.
|
|
16
|
+
*/
|
|
17
|
+
static replaceAccentuatedChars(text: string): string;
|
|
18
|
+
}
|
|
@@ -1,54 +1,54 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Classe com utiliários comuns para Strings.
|
|
3
|
-
*/
|
|
4
|
-
export class StringUtils {
|
|
5
|
-
/**
|
|
6
|
-
* Verifica se a string está vazia.
|
|
7
|
-
* Valores null e undefined são considerados como vazio.
|
|
8
|
-
*
|
|
9
|
-
* @param value String para ser validada.
|
|
10
|
-
*/
|
|
11
|
-
static isEmpty(value) {
|
|
12
|
-
if (value == undefined || value === null) {
|
|
13
|
-
return true;
|
|
14
|
-
}
|
|
15
|
-
value = value.toString();
|
|
16
|
-
value = value.trim();
|
|
17
|
-
if (value.length === 0) {
|
|
18
|
-
return true;
|
|
19
|
-
}
|
|
20
|
-
return false;
|
|
21
|
-
}
|
|
22
|
-
/**
|
|
23
|
-
* Remove acentos de vogais, substitui Ç por c e retorna a string em caixa alta.
|
|
24
|
-
*
|
|
25
|
-
* @param value String para ser transformada.
|
|
26
|
-
*/
|
|
27
|
-
static replaceAccentuatedChars(text) {
|
|
28
|
-
text = text.toUpperCase();
|
|
29
|
-
text = text.replace(/[À]/, "A");
|
|
30
|
-
text = text.replace(/[Á]/, "A");
|
|
31
|
-
text = text.replace(/[Â]/, "A");
|
|
32
|
-
text = text.replace(/[Ã]/, "A");
|
|
33
|
-
text = text.replace(/[Ä]/, "A");
|
|
34
|
-
text = text.replace(/[È]/, "E");
|
|
35
|
-
text = text.replace(/[É]/, "E");
|
|
36
|
-
text = text.replace(/[Ê]/, "E");
|
|
37
|
-
text = text.replace(/[Ë]/, "E");
|
|
38
|
-
text = text.replace(/[Ì]/, "I");
|
|
39
|
-
text = text.replace(/[Í]/, "I");
|
|
40
|
-
text = text.replace(/[Î]/, "I");
|
|
41
|
-
text = text.replace(/[Ï]/, "I");
|
|
42
|
-
text = text.replace(/[Ò]/, "O");
|
|
43
|
-
text = text.replace(/[Ó]/, "O");
|
|
44
|
-
text = text.replace(/[Ô]/, "O");
|
|
45
|
-
text = text.replace(/[Ö]/, "O");
|
|
46
|
-
text = text.replace(/[Ù]/, "U");
|
|
47
|
-
text = text.replace(/[Ú]/, "U");
|
|
48
|
-
text = text.replace(/[Û]/, "U");
|
|
49
|
-
text = text.replace(/[Ü]/, "U");
|
|
50
|
-
text = text.replace(/[Ç]/, "C");
|
|
51
|
-
return text.replace(/[^a-z0-9]/gi, '');
|
|
52
|
-
}
|
|
53
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* Classe com utiliários comuns para Strings.
|
|
3
|
+
*/
|
|
4
|
+
export class StringUtils {
|
|
5
|
+
/**
|
|
6
|
+
* Verifica se a string está vazia.
|
|
7
|
+
* Valores null e undefined são considerados como vazio.
|
|
8
|
+
*
|
|
9
|
+
* @param value String para ser validada.
|
|
10
|
+
*/
|
|
11
|
+
static isEmpty(value) {
|
|
12
|
+
if (value == undefined || value === null) {
|
|
13
|
+
return true;
|
|
14
|
+
}
|
|
15
|
+
value = value.toString();
|
|
16
|
+
value = value.trim();
|
|
17
|
+
if (value.length === 0) {
|
|
18
|
+
return true;
|
|
19
|
+
}
|
|
20
|
+
return false;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Remove acentos de vogais, substitui Ç por c e retorna a string em caixa alta.
|
|
24
|
+
*
|
|
25
|
+
* @param value String para ser transformada.
|
|
26
|
+
*/
|
|
27
|
+
static replaceAccentuatedChars(text) {
|
|
28
|
+
text = text.toUpperCase();
|
|
29
|
+
text = text.replace(/[À]/, "A");
|
|
30
|
+
text = text.replace(/[Á]/, "A");
|
|
31
|
+
text = text.replace(/[Â]/, "A");
|
|
32
|
+
text = text.replace(/[Ã]/, "A");
|
|
33
|
+
text = text.replace(/[Ä]/, "A");
|
|
34
|
+
text = text.replace(/[È]/, "E");
|
|
35
|
+
text = text.replace(/[É]/, "E");
|
|
36
|
+
text = text.replace(/[Ê]/, "E");
|
|
37
|
+
text = text.replace(/[Ë]/, "E");
|
|
38
|
+
text = text.replace(/[Ì]/, "I");
|
|
39
|
+
text = text.replace(/[Í]/, "I");
|
|
40
|
+
text = text.replace(/[Î]/, "I");
|
|
41
|
+
text = text.replace(/[Ï]/, "I");
|
|
42
|
+
text = text.replace(/[Ò]/, "O");
|
|
43
|
+
text = text.replace(/[Ó]/, "O");
|
|
44
|
+
text = text.replace(/[Ô]/, "O");
|
|
45
|
+
text = text.replace(/[Ö]/, "O");
|
|
46
|
+
text = text.replace(/[Ù]/, "U");
|
|
47
|
+
text = text.replace(/[Ú]/, "U");
|
|
48
|
+
text = text.replace(/[Û]/, "U");
|
|
49
|
+
text = text.replace(/[Ü]/, "U");
|
|
50
|
+
text = text.replace(/[Ç]/, "C");
|
|
51
|
+
return text.replace(/[^a-z0-9]/gi, '');
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
54
|
//# sourceMappingURL=StringUtils.js.map
|
|
@@ -1,33 +1,33 @@
|
|
|
1
|
-
import { MaskFormatter } from "./MaskFormatter.js";
|
|
2
|
-
/**
|
|
3
|
-
* `TimeFormatter` é um utilitário para formatação de strings desformatadas em strings válidas de horários
|
|
4
|
-
*/
|
|
5
|
-
export declare class TimeFormatter {
|
|
6
|
-
static _maskFormatter: MaskFormatter;
|
|
7
|
-
/**
|
|
8
|
-
* @prepareValue: converts an unformated time string into a formatted time.
|
|
9
|
-
*
|
|
10
|
-
* @param value unformated time string to convert
|
|
11
|
-
*
|
|
12
|
-
* @returns formatted time string
|
|
13
|
-
*
|
|
14
|
-
* @Exemples
|
|
15
|
-
* @"1012" | "10:12"
|
|
16
|
-
* @"10:12" | "10:12:00"
|
|
17
|
-
* @"100112" | "10:01:12"
|
|
18
|
-
*/
|
|
19
|
-
static prepareValue(value: string, showSeconds: boolean): string;
|
|
20
|
-
/**
|
|
21
|
-
* @validateTime: validates if an input string has the corect time format.
|
|
22
|
-
*
|
|
23
|
-
* @param value input string to validate
|
|
24
|
-
*
|
|
25
|
-
* @returns true or false
|
|
26
|
-
*
|
|
27
|
-
* @Exemples
|
|
28
|
-
* @"1012" | true
|
|
29
|
-
* @"14e4" | false
|
|
30
|
-
* @"2624" | false
|
|
31
|
-
*/
|
|
32
|
-
static validateTime(value: string, showSeconds: boolean): boolean;
|
|
33
|
-
}
|
|
1
|
+
import { MaskFormatter } from "./MaskFormatter.js";
|
|
2
|
+
/**
|
|
3
|
+
* `TimeFormatter` é um utilitário para formatação de strings desformatadas em strings válidas de horários
|
|
4
|
+
*/
|
|
5
|
+
export declare class TimeFormatter {
|
|
6
|
+
static _maskFormatter: MaskFormatter;
|
|
7
|
+
/**
|
|
8
|
+
* @prepareValue: converts an unformated time string into a formatted time.
|
|
9
|
+
*
|
|
10
|
+
* @param value unformated time string to convert
|
|
11
|
+
*
|
|
12
|
+
* @returns formatted time string
|
|
13
|
+
*
|
|
14
|
+
* @Exemples
|
|
15
|
+
* @"1012" | "10:12"
|
|
16
|
+
* @"10:12" | "10:12:00"
|
|
17
|
+
* @"100112" | "10:01:12"
|
|
18
|
+
*/
|
|
19
|
+
static prepareValue(value: string, showSeconds: boolean): string;
|
|
20
|
+
/**
|
|
21
|
+
* @validateTime: validates if an input string has the corect time format.
|
|
22
|
+
*
|
|
23
|
+
* @param value input string to validate
|
|
24
|
+
*
|
|
25
|
+
* @returns true or false
|
|
26
|
+
*
|
|
27
|
+
* @Exemples
|
|
28
|
+
* @"1012" | true
|
|
29
|
+
* @"14e4" | false
|
|
30
|
+
* @"2624" | false
|
|
31
|
+
*/
|
|
32
|
+
static validateTime(value: string, showSeconds: boolean): boolean;
|
|
33
|
+
}
|