@bolttech/form-engine-core 1.0.1-beta.2 → 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 +6 -1
- 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
|
};
|
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;
|