@bolttech/form-engine-core 1.0.1-beta.1 → 1.0.1-beta.3
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/index.esm.js +16 -7
- package/package.json +1 -1
- package/src/masks/string.d.ts +2 -0
package/index.esm.js
CHANGED
|
@@ -673,12 +673,14 @@ const replaceAll = (value, masks) => {
|
|
|
673
673
|
*
|
|
674
674
|
* const formattedValue = currency(config.value, config.masks);
|
|
675
675
|
* console.log(formattedValue); // Output: '9.876,54 €'
|
|
676
|
+
*
|
|
677
|
+
* PS: To unCurrency this value, usage onlyFloatNumber formatter
|
|
676
678
|
* ```
|
|
677
679
|
*/
|
|
678
680
|
const currency = (value, masks) => {
|
|
679
681
|
if (!(masks === null || masks === void 0 ? void 0 : masks.currency)) return value;
|
|
680
682
|
const {
|
|
681
|
-
align = '
|
|
683
|
+
align = '',
|
|
682
684
|
decimal = '.',
|
|
683
685
|
precision = 2,
|
|
684
686
|
prefix = 'BBD',
|
|
@@ -702,6 +704,9 @@ const currency = (value, masks) => {
|
|
|
702
704
|
decimalPart = '0'.repeat(precision - decimalPart.length) + decimalPart;
|
|
703
705
|
newRawValue += decimal + decimalPart;
|
|
704
706
|
}
|
|
707
|
+
if (!align) {
|
|
708
|
+
return newRawValue;
|
|
709
|
+
}
|
|
705
710
|
const symbol = getCurrencySymbol(prefix);
|
|
706
711
|
return align === 'left' ? `${symbol} ${newRawValue}` : `${newRawValue} ${symbol}`;
|
|
707
712
|
};
|
|
@@ -735,18 +740,21 @@ const custom = (value, masks) => {
|
|
|
735
740
|
let mask = '';
|
|
736
741
|
let index = 0;
|
|
737
742
|
const convertedValue = value.replace(/[^\w\s]/gi, '');
|
|
738
|
-
for (
|
|
739
|
-
if (
|
|
743
|
+
for (const char of masks.custom) {
|
|
744
|
+
if (char === '#') {
|
|
740
745
|
if (index < convertedValue.length) {
|
|
741
746
|
mask += convertedValue[index];
|
|
742
747
|
index++;
|
|
743
748
|
} else {
|
|
744
749
|
break;
|
|
745
750
|
}
|
|
746
|
-
} else {
|
|
747
|
-
mask +=
|
|
751
|
+
} else if (index <= convertedValue.length) {
|
|
752
|
+
mask += char;
|
|
748
753
|
}
|
|
749
754
|
}
|
|
755
|
+
if (value.length < mask.length) {
|
|
756
|
+
mask = mask.replace(/[^\w]+$/, '');
|
|
757
|
+
}
|
|
750
758
|
return mask;
|
|
751
759
|
};
|
|
752
760
|
|
|
@@ -4350,8 +4358,9 @@ class FormGroup {
|
|
|
4350
4358
|
formIndex
|
|
4351
4359
|
}) => ids.includes(formIndex)), groupBy(({
|
|
4352
4360
|
event,
|
|
4353
|
-
formIndex
|
|
4354
|
-
|
|
4361
|
+
formIndex,
|
|
4362
|
+
fieldIndex
|
|
4363
|
+
}) => `${event}.${formIndex}.${fieldIndex}`), mergeMap(group$ => group$.pipe(debounceTime(this.config.defaultStateRefreshTimeMS))), map(({
|
|
4355
4364
|
fieldIndex,
|
|
4356
4365
|
formIndex
|
|
4357
4366
|
}) => ids.reduce((acc, curr) => {
|
package/package.json
CHANGED
package/src/masks/string.d.ts
CHANGED
|
@@ -66,6 +66,8 @@ export declare const replaceAll: (value: string | number, masks: TMasks) => unkn
|
|
|
66
66
|
*
|
|
67
67
|
* const formattedValue = currency(config.value, config.masks);
|
|
68
68
|
* console.log(formattedValue); // Output: '9.876,54 €'
|
|
69
|
+
*
|
|
70
|
+
* PS: To unCurrency this value, usage onlyFloatNumber formatter
|
|
69
71
|
* ```
|
|
70
72
|
*/
|
|
71
73
|
export declare const currency: (value: string | number, masks: TMasks) => unknown;
|