infinity-forge 0.62.2 → 0.63.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.
- package/dist/fonts.css +1 -1
- package/dist/infinity-forge.css +2 -3
- package/dist/reset.css +1 -1
- package/dist/ui/components/error-boundary/component.js +2 -2
- package/dist/ui/components/error-boundary/component.js.map +1 -1
- package/dist/ui/components/error-boundary/src/ErrorBoundary.d.ts +21 -0
- package/dist/ui/components/error-boundary/src/ErrorBoundary.js +112 -0
- package/dist/ui/components/error-boundary/src/ErrorBoundary.js.map +1 -0
- package/dist/ui/components/error-boundary/src/ErrorBoundaryContext.d.ts +7 -0
- package/dist/ui/components/error-boundary/src/ErrorBoundaryContext.js +6 -0
- package/dist/ui/components/error-boundary/src/ErrorBoundaryContext.js.map +1 -0
- package/dist/ui/components/error-boundary/src/assertErrorBoundaryContext.d.ts +2 -0
- package/dist/ui/components/error-boundary/src/assertErrorBoundaryContext.js +12 -0
- package/dist/ui/components/error-boundary/src/assertErrorBoundaryContext.js.map +1 -0
- package/dist/ui/components/error-boundary/src/env-conditions/development.d.ts +1 -0
- package/dist/ui/components/error-boundary/src/env-conditions/development.js +5 -0
- package/dist/ui/components/error-boundary/src/env-conditions/development.js.map +1 -0
- package/dist/ui/components/error-boundary/src/env-conditions/production.d.ts +1 -0
- package/dist/ui/components/error-boundary/src/env-conditions/production.js +5 -0
- package/dist/ui/components/error-boundary/src/env-conditions/production.js.map +1 -0
- package/dist/ui/components/error-boundary/src/index.d.ts +5 -0
- package/dist/ui/components/error-boundary/src/index.js +22 -0
- package/dist/ui/components/error-boundary/src/index.js.map +1 -0
- package/dist/ui/components/error-boundary/src/types.d.ts +35 -0
- package/dist/ui/components/error-boundary/src/types.js +3 -0
- package/dist/ui/components/error-boundary/src/types.js.map +1 -0
- package/dist/ui/components/error-boundary/src/useErrorBoundary.d.ts +5 -0
- package/dist/ui/components/error-boundary/src/useErrorBoundary.js +32 -0
- package/dist/ui/components/error-boundary/src/useErrorBoundary.js.map +1 -0
- package/dist/ui/components/error-boundary/src/withErrorBoundary.d.ts +3 -0
- package/dist/ui/components/error-boundary/src/withErrorBoundary.js +27 -0
- package/dist/ui/components/error-boundary/src/withErrorBoundary.js.map +1 -0
- package/dist/ui/components/form/index.d.ts +0 -1
- package/dist/ui/components/form/index.js +0 -1
- package/dist/ui/components/form/index.js.map +1 -1
- package/dist/ui/components/form/input-currency/components/CurrencyInput.d.ts +2 -0
- package/dist/ui/components/form/input-currency/components/CurrencyInput.js +247 -0
- package/dist/ui/components/form/input-currency/components/CurrencyInput.js.map +1 -0
- package/dist/ui/components/form/input-currency/components/CurrencyInputProps.d.ts +160 -0
- package/dist/ui/components/form/input-currency/components/CurrencyInputProps.js +3 -0
- package/dist/ui/components/form/input-currency/components/CurrencyInputProps.js.map +1 -0
- package/dist/ui/components/form/input-currency/components/index.d.ts +1 -0
- package/dist/ui/components/form/input-currency/components/index.js +18 -0
- package/dist/ui/components/form/input-currency/components/index.js.map +1 -0
- package/dist/ui/components/form/input-currency/components/utils/addSeparators.d.ts +4 -0
- package/dist/ui/components/form/input-currency/components/utils/addSeparators.js +12 -0
- package/dist/ui/components/form/input-currency/components/utils/addSeparators.js.map +1 -0
- package/dist/ui/components/form/input-currency/components/utils/cleanValue.d.ts +8 -0
- package/dist/ui/components/form/input-currency/components/utils/cleanValue.js +62 -0
- package/dist/ui/components/form/input-currency/components/utils/cleanValue.js.map +1 -0
- package/dist/ui/components/form/input-currency/components/utils/escapeRegExp.d.ts +6 -0
- package/dist/ui/components/form/input-currency/components/utils/escapeRegExp.js +13 -0
- package/dist/ui/components/form/input-currency/components/utils/escapeRegExp.js.map +1 -0
- package/dist/ui/components/form/input-currency/components/utils/fixedDecimalValue.d.ts +1 -0
- package/dist/ui/components/form/input-currency/components/utils/fixedDecimalValue.js +30 -0
- package/dist/ui/components/form/input-currency/components/utils/fixedDecimalValue.js.map +1 -0
- package/dist/ui/components/form/input-currency/components/utils/formatValue.d.ts +49 -0
- package/dist/ui/components/form/input-currency/components/utils/formatValue.js +132 -0
- package/dist/ui/components/form/input-currency/components/utils/formatValue.js.map +1 -0
- package/dist/ui/components/form/input-currency/components/utils/getLocaleConfig.d.ts +13 -0
- package/dist/ui/components/form/input-currency/components/utils/getLocaleConfig.js +49 -0
- package/dist/ui/components/form/input-currency/components/utils/getLocaleConfig.js.map +1 -0
- package/dist/ui/components/form/input-currency/components/utils/getSuffix.d.ts +6 -0
- package/dist/ui/components/form/input-currency/components/utils/getSuffix.js +12 -0
- package/dist/ui/components/form/input-currency/components/utils/getSuffix.js.map +1 -0
- package/dist/ui/components/form/input-currency/components/utils/index.d.ts +8 -0
- package/dist/ui/components/form/input-currency/components/utils/index.js +25 -0
- package/dist/ui/components/form/input-currency/components/utils/index.js.map +1 -0
- package/dist/ui/components/form/input-currency/components/utils/isNumber.d.ts +1 -0
- package/dist/ui/components/form/input-currency/components/utils/isNumber.js +6 -0
- package/dist/ui/components/form/input-currency/components/utils/isNumber.js.map +1 -0
- package/dist/ui/components/form/input-currency/components/utils/padTrimValue.d.ts +1 -0
- package/dist/ui/components/form/input-currency/components/utils/padTrimValue.js +28 -0
- package/dist/ui/components/form/input-currency/components/utils/padTrimValue.js.map +1 -0
- package/dist/ui/components/form/input-currency/components/utils/parseAbbrValue.d.ts +10 -0
- package/dist/ui/components/form/input-currency/components/utils/parseAbbrValue.js +40 -0
- package/dist/ui/components/form/input-currency/components/utils/parseAbbrValue.js.map +1 -0
- package/dist/ui/components/form/input-currency/components/utils/removeInvalidChars.d.ts +4 -0
- package/dist/ui/components/form/input-currency/components/utils/removeInvalidChars.js +14 -0
- package/dist/ui/components/form/input-currency/components/utils/removeInvalidChars.js.map +1 -0
- package/dist/ui/components/form/input-currency/components/utils/removeSeparators.d.ts +4 -0
- package/dist/ui/components/form/input-currency/components/utils/removeSeparators.js +14 -0
- package/dist/ui/components/form/input-currency/components/utils/removeSeparators.js.map +1 -0
- package/dist/ui/components/form/input-currency/components/utils/repositionCursor.d.ts +16 -0
- package/dist/ui/components/form/input-currency/components/utils/repositionCursor.js +30 -0
- package/dist/ui/components/form/input-currency/components/utils/repositionCursor.js.map +1 -0
- package/dist/ui/components/form/input-currency/index.js +3 -6
- package/dist/ui/components/form/input-currency/index.js.map +1 -1
- package/dist/ui/components/form/input-date-picker/index.d.ts +4 -5
- package/dist/ui/components/form/input-date-picker/index.js +106 -63
- package/dist/ui/components/form/input-date-picker/index.js.map +1 -1
- package/dist/ui/components/form/input-date-picker/styles.js +1 -1
- package/dist/ui/components/form/input-date-picker/styles.js.map +1 -1
- package/dist/ui/components/form/text-editor/index.js +16 -6
- package/dist/ui/components/form/text-editor/index.js.map +1 -1
- package/dist/ui/components/form/text-editor/styles.js +1 -1
- package/dist/ui/components/form/text-editor/styles.js.map +1 -1
- package/package.json +75 -88
- package/dist/react-tool-tip.css +0 -1
- package/dist/ui/components/form/input-date-picker/date_picket_lib_css.d.ts +0 -4
- package/dist/ui/components/form/input-date-picker/date_picket_lib_css.js +0 -14
- package/dist/ui/components/form/input-date-picker/date_picket_lib_css.js.map +0 -1
- package/dist/ui/components/form/input-date-range/index.d.ts +0 -2
- package/dist/ui/components/form/input-date-range/index.js +0 -37
- package/dist/ui/components/form/input-date-range/index.js.map +0 -1
- package/dist/ui/components/form/input-date-range/styles.d.ts +0 -4
- package/dist/ui/components/form/input-date-range/styles.js +0 -14
- package/dist/ui/components/form/input-date-range/styles.js.map +0 -1
- package/dist/ui/components/form/text-editor/configs.d.ts +0 -3
- package/dist/ui/components/form/text-editor/configs.js +0 -23
- package/dist/ui/components/form/text-editor/configs.js.map +0 -1
- package/dist/ui/styles/libs/react-tool-tip.css +0 -109
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { IntlConfig } from '../CurrencyInputProps.js';
|
|
2
|
+
export type FormatValueOptions = {
|
|
3
|
+
/**
|
|
4
|
+
* Value to format
|
|
5
|
+
*/
|
|
6
|
+
value: string | undefined;
|
|
7
|
+
/**
|
|
8
|
+
* Decimal separator
|
|
9
|
+
*
|
|
10
|
+
* Default = '.'
|
|
11
|
+
*/
|
|
12
|
+
decimalSeparator?: string;
|
|
13
|
+
/**
|
|
14
|
+
* Group separator
|
|
15
|
+
*
|
|
16
|
+
* Default = ','
|
|
17
|
+
*/
|
|
18
|
+
groupSeparator?: string;
|
|
19
|
+
/**
|
|
20
|
+
* Turn off separators
|
|
21
|
+
*
|
|
22
|
+
* This will override Group separators
|
|
23
|
+
*
|
|
24
|
+
* Default = false
|
|
25
|
+
*/
|
|
26
|
+
disableGroupSeparators?: boolean;
|
|
27
|
+
/**
|
|
28
|
+
* Intl locale currency config
|
|
29
|
+
*/
|
|
30
|
+
intlConfig?: IntlConfig;
|
|
31
|
+
/**
|
|
32
|
+
* Specify decimal scale for padding/trimming
|
|
33
|
+
*
|
|
34
|
+
* Eg. 1.5 -> 1.50 or 1.234 -> 1.23
|
|
35
|
+
*/
|
|
36
|
+
decimalScale?: number;
|
|
37
|
+
/**
|
|
38
|
+
* Prefix
|
|
39
|
+
*/
|
|
40
|
+
prefix?: string;
|
|
41
|
+
/**
|
|
42
|
+
* Suffix
|
|
43
|
+
*/
|
|
44
|
+
suffix?: string;
|
|
45
|
+
};
|
|
46
|
+
/**
|
|
47
|
+
* Format value with decimal separator, group separator and prefix
|
|
48
|
+
*/
|
|
49
|
+
export declare const formatValue: (options: FormatValueOptions) => string;
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
14
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
15
|
+
if (ar || !(i in from)) {
|
|
16
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
17
|
+
ar[i] = from[i];
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
21
|
+
};
|
|
22
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
23
|
+
exports.formatValue = void 0;
|
|
24
|
+
var escapeRegExp_1 = require("./escapeRegExp.js");
|
|
25
|
+
var getSuffix_1 = require("./getSuffix.js");
|
|
26
|
+
/**
|
|
27
|
+
* Format value with decimal separator, group separator and prefix
|
|
28
|
+
*/
|
|
29
|
+
var formatValue = function (options) {
|
|
30
|
+
var _value = options.value, decimalSeparator = options.decimalSeparator, intlConfig = options.intlConfig, decimalScale = options.decimalScale, _a = options.prefix, prefix = _a === void 0 ? '' : _a, _b = options.suffix, suffix = _b === void 0 ? '' : _b;
|
|
31
|
+
if (_value === '' || _value === undefined) {
|
|
32
|
+
return '';
|
|
33
|
+
}
|
|
34
|
+
if (_value === '-') {
|
|
35
|
+
return '-';
|
|
36
|
+
}
|
|
37
|
+
var isNegative = new RegExp("^\\d?-".concat(prefix ? "".concat((0, escapeRegExp_1.escapeRegExp)(prefix), "?") : '', "\\d")).test(_value);
|
|
38
|
+
var value = decimalSeparator !== '.'
|
|
39
|
+
? replaceDecimalSeparator(_value, decimalSeparator, isNegative)
|
|
40
|
+
: _value;
|
|
41
|
+
if (decimalSeparator && decimalSeparator !== '-' && value.startsWith(decimalSeparator)) {
|
|
42
|
+
value = '0' + value;
|
|
43
|
+
}
|
|
44
|
+
var defaultNumberFormatOptions = {
|
|
45
|
+
minimumFractionDigits: decimalScale || 0,
|
|
46
|
+
maximumFractionDigits: 20,
|
|
47
|
+
};
|
|
48
|
+
var numberFormatter = intlConfig
|
|
49
|
+
? new Intl.NumberFormat(intlConfig.locale, intlConfig.currency
|
|
50
|
+
? __assign(__assign({}, defaultNumberFormatOptions), { style: 'currency', currency: intlConfig.currency }) : defaultNumberFormatOptions)
|
|
51
|
+
: new Intl.NumberFormat(undefined, defaultNumberFormatOptions);
|
|
52
|
+
var parts = numberFormatter.formatToParts(Number(value));
|
|
53
|
+
var formatted = replaceParts(parts, options);
|
|
54
|
+
// Does intl formatting add a suffix?
|
|
55
|
+
var intlSuffix = (0, getSuffix_1.getSuffix)(formatted, __assign({}, options));
|
|
56
|
+
// Include decimal separator if user input ends with decimal separator
|
|
57
|
+
var includeDecimalSeparator = _value.slice(-1) === decimalSeparator ? decimalSeparator : '';
|
|
58
|
+
var _c = value.match(RegExp('\\d+\\.(\\d+)')) || [], decimals = _c[1];
|
|
59
|
+
// Keep original decimal padding if no decimalScale
|
|
60
|
+
if (decimalScale === undefined && decimals && decimalSeparator) {
|
|
61
|
+
if (formatted.includes(decimalSeparator)) {
|
|
62
|
+
formatted = formatted.replace(RegExp("(\\d+)(".concat((0, escapeRegExp_1.escapeRegExp)(decimalSeparator), ")(\\d+)"), 'g'), "$1$2".concat(decimals));
|
|
63
|
+
}
|
|
64
|
+
else {
|
|
65
|
+
if (intlSuffix && !suffix) {
|
|
66
|
+
formatted = formatted.replace(intlSuffix, "".concat(decimalSeparator).concat(decimals).concat(intlSuffix));
|
|
67
|
+
}
|
|
68
|
+
else {
|
|
69
|
+
formatted = "".concat(formatted).concat(decimalSeparator).concat(decimals);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
if (suffix && includeDecimalSeparator) {
|
|
74
|
+
return "".concat(formatted).concat(includeDecimalSeparator).concat(suffix);
|
|
75
|
+
}
|
|
76
|
+
if (intlSuffix && includeDecimalSeparator) {
|
|
77
|
+
return formatted.replace(intlSuffix, "".concat(includeDecimalSeparator).concat(intlSuffix));
|
|
78
|
+
}
|
|
79
|
+
if (intlSuffix && suffix) {
|
|
80
|
+
return formatted.replace(intlSuffix, "".concat(includeDecimalSeparator).concat(suffix));
|
|
81
|
+
}
|
|
82
|
+
return [formatted, includeDecimalSeparator, suffix].join('');
|
|
83
|
+
};
|
|
84
|
+
exports.formatValue = formatValue;
|
|
85
|
+
/**
|
|
86
|
+
* Before converting to Number, decimal separator has to be .
|
|
87
|
+
*/
|
|
88
|
+
var replaceDecimalSeparator = function (value, decimalSeparator, isNegative) {
|
|
89
|
+
var newValue = value;
|
|
90
|
+
if (decimalSeparator && decimalSeparator !== '.') {
|
|
91
|
+
newValue = newValue.replace(RegExp((0, escapeRegExp_1.escapeRegExp)(decimalSeparator), 'g'), '.');
|
|
92
|
+
if (isNegative && decimalSeparator === '-') {
|
|
93
|
+
newValue = "-".concat(newValue.slice(1));
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
return newValue;
|
|
97
|
+
};
|
|
98
|
+
var replaceParts = function (parts, _a) {
|
|
99
|
+
var prefix = _a.prefix, groupSeparator = _a.groupSeparator, decimalSeparator = _a.decimalSeparator, decimalScale = _a.decimalScale, _b = _a.disableGroupSeparators, disableGroupSeparators = _b === void 0 ? false : _b;
|
|
100
|
+
return parts
|
|
101
|
+
.reduce(function (prev, _a, i) {
|
|
102
|
+
var type = _a.type, value = _a.value;
|
|
103
|
+
if (i === 0 && prefix) {
|
|
104
|
+
if (type === 'minusSign') {
|
|
105
|
+
return [value, prefix];
|
|
106
|
+
}
|
|
107
|
+
if (type === 'currency') {
|
|
108
|
+
return __spreadArray(__spreadArray([], prev, true), [prefix], false);
|
|
109
|
+
}
|
|
110
|
+
return [prefix, value];
|
|
111
|
+
}
|
|
112
|
+
if (type === 'currency') {
|
|
113
|
+
return prefix ? prev : __spreadArray(__spreadArray([], prev, true), [value], false);
|
|
114
|
+
}
|
|
115
|
+
if (type === 'group') {
|
|
116
|
+
return !disableGroupSeparators
|
|
117
|
+
? __spreadArray(__spreadArray([], prev, true), [groupSeparator !== undefined ? groupSeparator : value], false) : prev;
|
|
118
|
+
}
|
|
119
|
+
if (type === 'decimal') {
|
|
120
|
+
if (decimalScale !== undefined && decimalScale === 0) {
|
|
121
|
+
return prev;
|
|
122
|
+
}
|
|
123
|
+
return __spreadArray(__spreadArray([], prev, true), [decimalSeparator !== undefined ? decimalSeparator : value], false);
|
|
124
|
+
}
|
|
125
|
+
if (type === 'fraction') {
|
|
126
|
+
return __spreadArray(__spreadArray([], prev, true), [decimalScale !== undefined ? value.slice(0, decimalScale) : value], false);
|
|
127
|
+
}
|
|
128
|
+
return __spreadArray(__spreadArray([], prev, true), [value], false);
|
|
129
|
+
}, [''])
|
|
130
|
+
.join('');
|
|
131
|
+
};
|
|
132
|
+
//# sourceMappingURL=formatValue.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"formatValue.js","sourceRoot":"","sources":["../../../../../../../src/ui/components/form/input-currency/components/utils/formatValue.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AACA,+CAA8C;AAC9C,yCAAwC;AAsDxC;;GAEG;AACI,IAAM,WAAW,GAAG,UAAC,OAA2B;IAEnD,IAAO,MAAM,GAMX,OAAO,MANI,EACb,gBAAgB,GAKd,OAAO,iBALO,EAChB,UAAU,GAIR,OAAO,WAJC,EACV,YAAY,GAGV,OAAO,aAHG,EACZ,KAEE,OAAO,OAFE,EAAX,MAAM,mBAAG,EAAE,KAAA,EACX,KACE,OAAO,OADE,EAAX,MAAM,mBAAG,EAAE,KAAA,CACD;IAEZ,IAAI,MAAM,KAAK,EAAE,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;QAC1C,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,IAAI,MAAM,KAAK,GAAG,EAAE,CAAC;QACnB,OAAO,GAAG,CAAC;IACb,CAAC;IAED,IAAM,UAAU,GAAG,IAAI,MAAM,CAAC,gBAAS,MAAM,CAAC,CAAC,CAAC,UAAG,IAAA,2BAAY,EAAC,MAAM,CAAC,MAAG,CAAC,CAAC,CAAC,EAAE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;QAC1C,CAAC;QAED,IAAI,IAAI,KAAK,OAAO,EAAE,CAAC;YACrB,OAAO,CAAC,sBAAsB;gBAC5B,CAAC,iCAAK,IAAI,UAAE,cAAc,KAAK,SAAS,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,KAAK,UACjE,CAAC,CAAC,IAAI,CAAC;QACX,CAAC;QAED,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;YACvB,IAAI,YAAY,KAAK,SAAS,IAAI,YAAY,KAAK,CAAC,EAAE,CAAC;gBACrD,OAAO,IAAI,CAAC;YACd,CAAC;YAED,uCAAW,IAAI,UAAE,gBAAgB,KAAK,SAAS,CAAC,CAAC,CAAC,gBAAgB,CAAC,CAAC,CAAC,KAAK,UAAE;QAC9E,CAAC;QAED,IAAI,IAAI,KAAK,UAAU,EAAE,CAAC;YACxB,uCAAW,IAAI,UAAE,YAAY,KAAK,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,YAAY,CAAC,CAAC,CAAC,CAAC,KAAK,UAAE;QACtF,CAAC;QAED,uCAAW,IAAI,UAAE,KAAK,UAAE;IAC1B,CAAC,EACD,CAAC,EAAE,CAAC,CACL;SACA,IAAI,CAAC,EAAE,CAAC,CAAC;AACd,CAAC,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { IntlConfig } from '../CurrencyInputProps.js';
|
|
2
|
+
type LocaleConfig = {
|
|
3
|
+
currencySymbol: string;
|
|
4
|
+
groupSeparator: string;
|
|
5
|
+
decimalSeparator: string;
|
|
6
|
+
prefix: string;
|
|
7
|
+
suffix: string;
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* Get locale config from input or default
|
|
11
|
+
*/
|
|
12
|
+
export declare const getLocaleConfig: (intlConfig?: IntlConfig) => LocaleConfig;
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
+
exports.getLocaleConfig = void 0;
|
|
15
|
+
var defaultConfig = {
|
|
16
|
+
currencySymbol: '',
|
|
17
|
+
groupSeparator: '',
|
|
18
|
+
decimalSeparator: '',
|
|
19
|
+
prefix: '',
|
|
20
|
+
suffix: '',
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* Get locale config from input or default
|
|
24
|
+
*/
|
|
25
|
+
var getLocaleConfig = function (intlConfig) {
|
|
26
|
+
var _a = intlConfig || {}, locale = _a.locale, currency = _a.currency;
|
|
27
|
+
var numberFormatter = locale
|
|
28
|
+
? new Intl.NumberFormat(locale, currency ? { currency: currency, style: 'currency' } : undefined)
|
|
29
|
+
: new Intl.NumberFormat();
|
|
30
|
+
return numberFormatter.formatToParts(1000.1).reduce(function (prev, curr, i) {
|
|
31
|
+
if (curr.type === 'currency') {
|
|
32
|
+
if (i === 0) {
|
|
33
|
+
return __assign(__assign({}, prev), { currencySymbol: curr.value, prefix: curr.value });
|
|
34
|
+
}
|
|
35
|
+
else {
|
|
36
|
+
return __assign(__assign({}, prev), { currencySymbol: curr.value, suffix: curr.value });
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
if (curr.type === 'group') {
|
|
40
|
+
return __assign(__assign({}, prev), { groupSeparator: curr.value });
|
|
41
|
+
}
|
|
42
|
+
if (curr.type === 'decimal') {
|
|
43
|
+
return __assign(__assign({}, prev), { decimalSeparator: curr.value });
|
|
44
|
+
}
|
|
45
|
+
return prev;
|
|
46
|
+
}, defaultConfig);
|
|
47
|
+
};
|
|
48
|
+
exports.getLocaleConfig = getLocaleConfig;
|
|
49
|
+
//# sourceMappingURL=getLocaleConfig.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getLocaleConfig.js","sourceRoot":"","sources":["../../../../../../../src/ui/components/form/input-currency/components/utils/getLocaleConfig.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAUA,IAAM,aAAa,GAAiB;IAClC,cAAc,EAAE,EAAE;IAClB,cAAc,EAAE,EAAE;IAClB,gBAAgB,EAAE,EAAE;IACpB,MAAM,EAAE,EAAE;IACV,MAAM,EAAE,EAAE;CACX,CAAC;AAEF;;GAEG;AACI,IAAM,eAAe,GAAG,UAAC,UAAuB;IAC/C,IAAA,KAAuB,UAAU,IAAI,EAAE,EAArC,MAAM,YAAA,EAAE,QAAQ,cAAqB,CAAC;IAC9C,IAAM,eAAe,GAAG,MAAM;QAC5B,CAAC,CAAC,IAAI,IAAI,CAAC,YAAY,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC,CAAC,EAAE,QAAQ,UAAA,EAAE,KAAK,EAAE,UAAU,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;QACvF,CAAC,CAAC,IAAI,IAAI,CAAC,YAAY,EAAE,CAAC;IAE5B,OAAO,eAAe,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,UAAC,IAAI,EAAE,IAAI,EAAE,CAAC;QAChE,IAAI,IAAI,CAAC,IAAI,KAAK,UAAU,EAAE,CAAC;YAC7B,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;gBACZ,6BAAY,IAAI,KAAE,cAAc,EAAE,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,CAAC,KAAK,IAAG;YACrE,CAAC;iBAAM,CAAC;gBACN,6BAAY,IAAI,KAAE,cAAc,EAAE,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,CAAC,KAAK,IAAG;YACrE,CAAC;QACH,CAAC;QACD,IAAI,IAAI,CAAC,IAAI,KAAK,OAAO,EAAE,CAAC;YAC1B,6BAAY,IAAI,KAAE,cAAc,EAAE,IAAI,CAAC,KAAK,IAAG;QACjD,CAAC;QACD,IAAI,IAAI,CAAC,IAAI,KAAK,SAAS,EAAE,CAAC;YAC5B,6BAAY,IAAI,KAAE,gBAAgB,EAAE,IAAI,CAAC,KAAK,IAAG;QACnD,CAAC;QAED,OAAO,IAAI,CAAC;IACd,CAAC,EAAE,aAAa,CAAC,CAAC;AACpB,CAAC,CAAC;AAvBW,QAAA,eAAe,mBAuB1B"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getSuffix = void 0;
|
|
4
|
+
var escapeRegExp_1 = require("./escapeRegExp.js");
|
|
5
|
+
var getSuffix = function (value, _a) {
|
|
6
|
+
var _b = _a.groupSeparator, groupSeparator = _b === void 0 ? ',' : _b, _c = _a.decimalSeparator, decimalSeparator = _c === void 0 ? '.' : _c;
|
|
7
|
+
var suffixReg = new RegExp("\\d([^".concat((0, escapeRegExp_1.escapeRegExp)(groupSeparator)).concat((0, escapeRegExp_1.escapeRegExp)(decimalSeparator), "0-9]+)"));
|
|
8
|
+
var suffixMatch = value.match(suffixReg);
|
|
9
|
+
return suffixMatch ? suffixMatch[1] : undefined;
|
|
10
|
+
};
|
|
11
|
+
exports.getSuffix = getSuffix;
|
|
12
|
+
//# sourceMappingURL=getSuffix.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getSuffix.js","sourceRoot":"","sources":["../../../../../../../src/ui/components/form/input-currency/components/utils/getSuffix.ts"],"names":[],"mappings":";;;AAAA,+CAA8C;AAMvC,IAAM,SAAS,GAAG,UACvB,KAAa,EACb,EAAyD;QAAvD,sBAAoB,EAApB,cAAc,mBAAG,GAAG,KAAA,EAAE,wBAAsB,EAAtB,gBAAgB,mBAAG,GAAG,KAAA;IAE9C,IAAM,SAAS,GAAG,IAAI,MAAM,CAC1B,gBAAS,IAAA,2BAAY,EAAC,cAAc,CAAC,SAAG,IAAA,2BAAY,EAAC,gBAAgB,CAAC,WAAQ,CAC/E,CAAC;IACF,IAAM,WAAW,GAAG,KAAK,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;IAC3C,OAAO,WAAW,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;AAClD,CAAC,CAAC;AATW,QAAA,SAAS,aASpB"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export * from './cleanValue.js';
|
|
2
|
+
export * from './fixedDecimalValue.js';
|
|
3
|
+
export * from './formatValue.js';
|
|
4
|
+
export * from './getLocaleConfig.js';
|
|
5
|
+
export * from './getSuffix.js';
|
|
6
|
+
export * from './isNumber.js';
|
|
7
|
+
export * from './padTrimValue.js';
|
|
8
|
+
export * from './repositionCursor.js';
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./cleanValue.js"), exports);
|
|
18
|
+
__exportStar(require("./fixedDecimalValue.js"), exports);
|
|
19
|
+
__exportStar(require("./formatValue.js"), exports);
|
|
20
|
+
__exportStar(require("./getLocaleConfig.js"), exports);
|
|
21
|
+
__exportStar(require("./getSuffix.js"), exports);
|
|
22
|
+
__exportStar(require("./isNumber.js"), exports);
|
|
23
|
+
__exportStar(require("./padTrimValue.js"), exports);
|
|
24
|
+
__exportStar(require("./repositionCursor.js"), exports);
|
|
25
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../src/ui/components/form/input-currency/components/utils/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,+CAA6B;AAC7B,sDAAoC;AACpC,gDAA8B;AAC9B,oDAAkC;AAClC,8CAA4B;AAC5B,6CAA2B;AAC3B,iDAA+B;AAC/B,qDAAmC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const isNumber: (input: string) => boolean;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"isNumber.js","sourceRoot":"","sources":["../../../../../../../src/ui/components/form/input-currency/components/utils/isNumber.ts"],"names":[],"mappings":";;;AAAO,IAAM,QAAQ,GAAG,UAAC,KAAa,IAAc,OAAA,MAAM,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,EAA9B,CAA8B,CAAC;AAAtE,QAAA,QAAQ,YAA8D"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const padTrimValue: (value: string, decimalSeparator?: string, decimalScale?: number) => string;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.padTrimValue = void 0;
|
|
4
|
+
var padTrimValue = function (value, decimalSeparator, decimalScale) {
|
|
5
|
+
if (decimalSeparator === void 0) { decimalSeparator = '.'; }
|
|
6
|
+
if (decimalScale === undefined || value === '' || value === undefined) {
|
|
7
|
+
return value;
|
|
8
|
+
}
|
|
9
|
+
if (!value.match(/\d/g)) {
|
|
10
|
+
return '';
|
|
11
|
+
}
|
|
12
|
+
var _a = value.split(decimalSeparator), int = _a[0], decimals = _a[1];
|
|
13
|
+
if (decimalScale === 0) {
|
|
14
|
+
return int;
|
|
15
|
+
}
|
|
16
|
+
var newValue = decimals || '';
|
|
17
|
+
if (newValue.length < decimalScale) {
|
|
18
|
+
while (newValue.length < decimalScale) {
|
|
19
|
+
newValue += '0';
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
else {
|
|
23
|
+
newValue = newValue.slice(0, decimalScale);
|
|
24
|
+
}
|
|
25
|
+
return "".concat(int).concat(decimalSeparator).concat(newValue);
|
|
26
|
+
};
|
|
27
|
+
exports.padTrimValue = padTrimValue;
|
|
28
|
+
//# sourceMappingURL=padTrimValue.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"padTrimValue.js","sourceRoot":"","sources":["../../../../../../../src/ui/components/form/input-currency/components/utils/padTrimValue.ts"],"names":[],"mappings":";;;AAAO,IAAM,YAAY,GAAG,UAC1B,KAAa,EACb,gBAAsB,EACtB,YAAqB;IADrB,iCAAA,EAAA,sBAAsB;IAGtB,IAAI,YAAY,KAAK,SAAS,IAAI,KAAK,KAAK,EAAE,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;QACtE,OAAO,KAAK,CAAC;IACf,CAAC;IAED,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE,CAAC;QACxB,OAAO,EAAE,CAAC;IACZ,CAAC;IAEK,IAAA,KAAkB,KAAK,CAAC,KAAK,CAAC,gBAAgB,CAAC,EAA9C,GAAG,QAAA,EAAE,QAAQ,QAAiC,CAAC;IAEtD,IAAI,YAAY,KAAK,CAAC,EAAE,CAAC;QACvB,OAAO,GAAG,CAAC;IACb,CAAC;IAED,IAAI,QAAQ,GAAG,QAAQ,IAAI,EAAE,CAAC;IAE9B,IAAI,QAAQ,CAAC,MAAM,GAAG,YAAY,EAAE,CAAC;QACnC,OAAO,QAAQ,CAAC,MAAM,GAAG,YAAY,EAAE,CAAC;YACtC,QAAQ,IAAI,GAAG,CAAC;QAClB,CAAC;IACH,CAAC;SAAM,CAAC;QACN,QAAQ,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC,EAAE,YAAY,CAAC,CAAC;IAC7C,CAAC;IAED,OAAO,UAAG,GAAG,SAAG,gBAAgB,SAAG,QAAQ,CAAE,CAAC;AAChD,CAAC,CAAC;AA9BW,QAAA,YAAY,gBA8BvB"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Abbreviate number eg. 1000 = 1k
|
|
3
|
+
*
|
|
4
|
+
* Source: https://stackoverflow.com/a/9345181
|
|
5
|
+
*/
|
|
6
|
+
export declare const abbrValue: (value: number, decimalSeparator?: string, _decimalPlaces?: number) => string;
|
|
7
|
+
/**
|
|
8
|
+
* Parse a value with abbreviation e.g 1k = 1000
|
|
9
|
+
*/
|
|
10
|
+
export declare const parseAbbrValue: (value: string, decimalSeparator?: string) => number | undefined;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.parseAbbrValue = exports.abbrValue = void 0;
|
|
4
|
+
var escapeRegExp_1 = require("./escapeRegExp.js");
|
|
5
|
+
/**
|
|
6
|
+
* Abbreviate number eg. 1000 = 1k
|
|
7
|
+
*
|
|
8
|
+
* Source: https://stackoverflow.com/a/9345181
|
|
9
|
+
*/
|
|
10
|
+
var abbrValue = function (value, decimalSeparator, _decimalPlaces) {
|
|
11
|
+
if (decimalSeparator === void 0) { decimalSeparator = '.'; }
|
|
12
|
+
if (_decimalPlaces === void 0) { _decimalPlaces = 10; }
|
|
13
|
+
if (value > 999) {
|
|
14
|
+
var valueLength = ('' + value).length;
|
|
15
|
+
var p = Math.pow;
|
|
16
|
+
var d = p(10, _decimalPlaces);
|
|
17
|
+
valueLength -= valueLength % 3;
|
|
18
|
+
var abbrValue_1 = Math.round((value * d) / p(10, valueLength)) / d + ' kMGTPE'[valueLength / 3];
|
|
19
|
+
return abbrValue_1.replace('.', decimalSeparator);
|
|
20
|
+
}
|
|
21
|
+
return String(value);
|
|
22
|
+
};
|
|
23
|
+
exports.abbrValue = abbrValue;
|
|
24
|
+
var abbrMap = { k: 1000, m: 1000000, b: 1000000000 };
|
|
25
|
+
/**
|
|
26
|
+
* Parse a value with abbreviation e.g 1k = 1000
|
|
27
|
+
*/
|
|
28
|
+
var parseAbbrValue = function (value, decimalSeparator) {
|
|
29
|
+
if (decimalSeparator === void 0) { decimalSeparator = '.'; }
|
|
30
|
+
var reg = new RegExp("(\\d+(".concat((0, escapeRegExp_1.escapeRegExp)(decimalSeparator), "\\d*)?)([kmb])$"), 'i');
|
|
31
|
+
var match = value.match(reg);
|
|
32
|
+
if (match) {
|
|
33
|
+
var digits = match[1], abbr = match[3];
|
|
34
|
+
var multiplier = abbrMap[abbr.toLowerCase()];
|
|
35
|
+
return Number(digits.replace(decimalSeparator, '.')) * multiplier;
|
|
36
|
+
}
|
|
37
|
+
return undefined;
|
|
38
|
+
};
|
|
39
|
+
exports.parseAbbrValue = parseAbbrValue;
|
|
40
|
+
//# sourceMappingURL=parseAbbrValue.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parseAbbrValue.js","sourceRoot":"","sources":["../../../../../../../src/ui/components/form/input-currency/components/utils/parseAbbrValue.ts"],"names":[],"mappings":";;;AAAA,+CAA8C;AAE9C;;;;GAIG;AACI,IAAM,SAAS,GAAG,UAAC,KAAa,EAAE,gBAAsB,EAAE,cAAmB;IAA3C,iCAAA,EAAA,sBAAsB;IAAE,+BAAA,EAAA,mBAAmB;IAClF,IAAI,KAAK,GAAG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C,CAAC,GAAG,UAAU,CAAC;IACpE,CAAC;IAED,OAAO,SAAS,CAAC;AACnB,CAAC,CAAC;AAZW,QAAA,cAAc,kBAYzB"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.removeInvalidChars = void 0;
|
|
4
|
+
var escapeRegExp_1 = require("./escapeRegExp.js");
|
|
5
|
+
/**
|
|
6
|
+
* Remove invalid characters
|
|
7
|
+
*/
|
|
8
|
+
var removeInvalidChars = function (value, validChars) {
|
|
9
|
+
var chars = (0, escapeRegExp_1.escapeRegExp)(validChars.join(''));
|
|
10
|
+
var reg = new RegExp("[^\\d".concat(chars, "]"), 'gi');
|
|
11
|
+
return value.replace(reg, '');
|
|
12
|
+
};
|
|
13
|
+
exports.removeInvalidChars = removeInvalidChars;
|
|
14
|
+
//# sourceMappingURL=removeInvalidChars.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"removeInvalidChars.js","sourceRoot":"","sources":["../../../../../../../src/ui/components/form/input-currency/components/utils/removeInvalidChars.ts"],"names":[],"mappings":";;;AAAA,+CAA8C;AAE9C;;GAEG;AACI,IAAM,kBAAkB,GAAG,UAAC,KAAa,EAAE,UAAiC;IACjF,IAAM,KAAK,GAAG,IAAA,2BAAY,EAAC,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC;IAChD,IAAM,GAAG,GAAG,IAAI,MAAM,CAAC,eAAQ,KAAK,MAAG,EAAE,IAAI,CAAC,CAAC;IAC/C,OAAO,KAAK,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;AAChC,CAAC,CAAC;AAJW,QAAA,kBAAkB,sBAI7B"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.removeSeparators = void 0;
|
|
4
|
+
var escapeRegExp_1 = require("./escapeRegExp.js");
|
|
5
|
+
/**
|
|
6
|
+
* Remove group separator from value eg. 1,000 > 1000
|
|
7
|
+
*/
|
|
8
|
+
var removeSeparators = function (value, separator) {
|
|
9
|
+
if (separator === void 0) { separator = ','; }
|
|
10
|
+
var reg = new RegExp((0, escapeRegExp_1.escapeRegExp)(separator), 'g');
|
|
11
|
+
return value.replace(reg, '');
|
|
12
|
+
};
|
|
13
|
+
exports.removeSeparators = removeSeparators;
|
|
14
|
+
//# sourceMappingURL=removeSeparators.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"removeSeparators.js","sourceRoot":"","sources":["../../../../../../../src/ui/components/form/input-currency/components/utils/removeSeparators.ts"],"names":[],"mappings":";;;AAAA,+CAA8C;AAE9C;;GAEG;AACI,IAAM,gBAAgB,GAAG,UAAC,KAAa,EAAE,SAAe;IAAf,0BAAA,EAAA,eAAe;IAC7D,IAAM,GAAG,GAAG,IAAI,MAAM,CAAC,IAAA,2BAAY,EAAC,SAAS,CAAC,EAAE,GAAG,CAAC,CAAC;IACrD,OAAO,KAAK,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;AAChC,CAAC,CAAC;AAHW,QAAA,gBAAgB,oBAG3B"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
type RepositionCursorProps = {
|
|
2
|
+
selectionStart?: number | null;
|
|
3
|
+
value: string;
|
|
4
|
+
lastKeyStroke: string | null;
|
|
5
|
+
stateValue?: string;
|
|
6
|
+
groupSeparator?: string;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* Based on the last key stroke and the cursor position, update the value
|
|
10
|
+
* and reposition the cursor to the right place
|
|
11
|
+
*/
|
|
12
|
+
export declare const repositionCursor: ({ selectionStart, value, lastKeyStroke, stateValue, groupSeparator, }: RepositionCursorProps) => {
|
|
13
|
+
modifiedValue: string;
|
|
14
|
+
cursorPosition: number | null | undefined;
|
|
15
|
+
};
|
|
16
|
+
export {};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.repositionCursor = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Based on the last key stroke and the cursor position, update the value
|
|
6
|
+
* and reposition the cursor to the right place
|
|
7
|
+
*/
|
|
8
|
+
var repositionCursor = function (_a) {
|
|
9
|
+
var selectionStart = _a.selectionStart, value = _a.value, lastKeyStroke = _a.lastKeyStroke, stateValue = _a.stateValue, groupSeparator = _a.groupSeparator;
|
|
10
|
+
var cursorPosition = selectionStart;
|
|
11
|
+
var modifiedValue = value;
|
|
12
|
+
if (stateValue && cursorPosition) {
|
|
13
|
+
var splitValue = value.split('');
|
|
14
|
+
// if cursor is to right of groupSeparator and backspace pressed, delete the character to the left of the separator and reposition the cursor
|
|
15
|
+
if (lastKeyStroke === 'Backspace' && stateValue[cursorPosition] === groupSeparator) {
|
|
16
|
+
splitValue.splice(cursorPosition - 1, 1);
|
|
17
|
+
cursorPosition -= 1;
|
|
18
|
+
}
|
|
19
|
+
// if cursor is to left of groupSeparator and delete pressed, delete the character to the right of the separator and reposition the cursor
|
|
20
|
+
if (lastKeyStroke === 'Delete' && stateValue[cursorPosition] === groupSeparator) {
|
|
21
|
+
splitValue.splice(cursorPosition, 1);
|
|
22
|
+
cursorPosition += 1;
|
|
23
|
+
}
|
|
24
|
+
modifiedValue = splitValue.join('');
|
|
25
|
+
return { modifiedValue: modifiedValue, cursorPosition: cursorPosition };
|
|
26
|
+
}
|
|
27
|
+
return { modifiedValue: modifiedValue, cursorPosition: selectionStart };
|
|
28
|
+
};
|
|
29
|
+
exports.repositionCursor = repositionCursor;
|
|
30
|
+
//# sourceMappingURL=repositionCursor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"repositionCursor.js","sourceRoot":"","sources":["../../../../../../../src/ui/components/form/input-currency/components/utils/repositionCursor.ts"],"names":[],"mappings":";;;AAQA;;;GAGG;AACI,IAAM,gBAAgB,GAAG,UAAC,EAMT;QALtB,cAAc,oBAAA,EACd,KAAK,WAAA,EACL,aAAa,mBAAA,EACb,UAAU,gBAAA,EACV,cAAc,oBAAA;IAKd,IAAI,cAAc,GAAG,cAAc,CAAC;IACpC,IAAI,aAAa,GAAG,KAAK,CAAC;IAC1B,IAAI,UAAU,IAAI,cAAc,EAAE,CAAC;QACjC,IAAM,UAAU,GAAG,KAAK,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;QACnC,6IAA6I;QAC7I,IAAI,aAAa,KAAK,WAAW,IAAI,UAAU,CAAC,cAAc,CAAC,KAAK,cAAc,EAAE,CAAC;YACnF,UAAU,CAAC,MAAM,CAAC,cAAc,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC;YACzC,cAAc,IAAI,CAAC,CAAC;QACtB,CAAC;QACD,0IAA0I;QAC1I,IAAI,aAAa,KAAK,QAAQ,IAAI,UAAU,CAAC,cAAc,CAAC,KAAK,cAAc,EAAE,CAAC;YAChF,UAAU,CAAC,MAAM,CAAC,cAAc,EAAE,CAAC,CAAC,CAAC;YACrC,cAAc,IAAI,CAAC,CAAC;QACtB,CAAC;QACD,aAAa,GAAG,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QACpC,OAAO,EAAE,aAAa,eAAA,EAAE,cAAc,gBAAA,EAAE,CAAC;IAC3C,CAAC;IAED,OAAO,EAAE,aAAa,eAAA,EAAE,cAAc,EAAE,cAAc,EAAE,CAAC;AAC3D,CAAC,CAAC;AA7BW,QAAA,gBAAgB,oBA6B3B"}
|
|
@@ -10,21 +10,18 @@ var __assign = (this && this.__assign) || function () {
|
|
|
10
10
|
};
|
|
11
11
|
return __assign.apply(this, arguments);
|
|
12
12
|
};
|
|
13
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
14
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
15
|
-
};
|
|
16
13
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
14
|
exports.InputCurrency = void 0;
|
|
18
15
|
var jsx_runtime_1 = require("react/jsx-runtime");
|
|
19
16
|
var react_1 = require("react");
|
|
20
17
|
var formik_1 = require("formik");
|
|
21
|
-
var react_currency_input_field_1 = __importDefault(require("react-currency-input-field"));
|
|
22
18
|
var input_control_1 = require("../input-control/index.js");
|
|
19
|
+
var components_1 = require("./components/index.js");
|
|
23
20
|
function InputCurrency(props) {
|
|
24
21
|
var _a = (0, formik_1.useField)({ name: props.name }), field = _a[0], state = _a[1], handlers = _a[2];
|
|
25
22
|
function handleChange(value) {
|
|
26
23
|
if (value) {
|
|
27
|
-
var numericValue = parseFloat(value.includes(
|
|
24
|
+
var numericValue = parseFloat((value === null || value === void 0 ? void 0 : value.includes(',')) ? value === null || value === void 0 ? void 0 : value.replace(/\./g, '').replace(',', '.') : value);
|
|
28
25
|
if (props.max && numericValue > Number(props.max || 0)) {
|
|
29
26
|
if (props.errorMessageMax) {
|
|
30
27
|
handlers.setError(props.errorMessageMax(value));
|
|
@@ -49,7 +46,7 @@ function InputCurrency(props) {
|
|
|
49
46
|
}
|
|
50
47
|
}, 500);
|
|
51
48
|
}, [state.initialValue]);
|
|
52
|
-
return ((0, jsx_runtime_1.jsx)(input_control_1.InputControl, __assign({}, props, { children: (0, jsx_runtime_1.jsx)(
|
|
49
|
+
return ((0, jsx_runtime_1.jsx)(input_control_1.InputControl, __assign({}, props, { children: (0, jsx_runtime_1.jsx)(components_1.CurrencyInput, { prefix: 'R$', decimalsLimit: 2, decimalSeparator: ',', groupSeparator: '.', value: field.value, onValueChange: handleChange, readOnly: props.readOnly, max: props.max }) })));
|
|
53
50
|
}
|
|
54
51
|
exports.InputCurrency = InputCurrency;
|
|
55
52
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/ui/components/form/input-currency/index.tsx"],"names":[],"mappings":"
|
|
1
|
+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AAC,SAAS,CAAC,CAAA;YAC5B,KAAK,CAAC,aAAa,IAAI,KAAK,CAAC,aAAa,CAAC,GAAG,CAAC,CAAA;QACjD,CAAC;IACH,CAAC;IAED,IAAA,iBAAS,EAAC;QACR,UAAU,CAAC;YACT,IAAI,KAAK,CAAC,YAAY,EAAE,CAAC;gBACvB,YAAY,CAAC,KAAK,CAAC,YAAY,CAAC,CAAA;YAClC,CAAC;QACH,CAAC,EAAE,GAAG,CAAC,CAAA;IACT,CAAC,EAAE,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC,CAAA;IAExB,OAAO,CACL,uBAAC,4BAAY,eAAK,KAAK,cACrB,uBAAC,0BAAa,IACZ,MAAM,EAAC,IAAI,EACX,aAAa,EAAE,CAAC,EAChB,gBAAgB,EAAC,GAAG,EACpB,cAAc,EAAC,GAAG,EAClB,KAAK,EAAE,KAAK,CAAC,KAAK,EAClB,aAAa,EAAE,YAAY,EAC3B,QAAQ,EAAE,KAAK,CAAC,QAAQ,EACxB,GAAG,EAAE,KAAK,CAAC,GAAG,GACd,IACW,CAChB,CAAA;AACH,CAAC;AA7CD,sCA6CC"}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { ReactDatePickerProps } from 'react-datepicker';
|
|
2
1
|
import { InputProps } from '../interfaces.js';
|
|
3
|
-
export declare
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
}
|
|
2
|
+
export declare const DatePicker: (props: InputProps & {
|
|
3
|
+
mode: "month" | "date";
|
|
4
|
+
language: "en" | "pt";
|
|
5
|
+
}) => import("react/jsx-runtime").JSX.Element;
|