@neovici/cosmoz-utils 6.4.0 → 6.6.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/index.d.ts +3 -1
- package/dist/index.js +3 -1
- package/dist/money.d.ts +6 -3
- package/dist/money.js +11 -7
- package/dist/sheet.d.ts +1 -0
- package/dist/sheet.js +5 -0
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -23,4 +23,6 @@ import * as Template from './template';
|
|
|
23
23
|
import * as DateUtils from './date';
|
|
24
24
|
import * as Money from './money';
|
|
25
25
|
export { hauntedPolymer, Template, DateUtils, mixin, Money, DateUtils as Date };
|
|
26
|
-
|
|
26
|
+
import { tagged } from './tagged';
|
|
27
|
+
export { tagged, tagged as css };
|
|
28
|
+
export * from './sheet';
|
package/dist/index.js
CHANGED
|
@@ -31,4 +31,6 @@ import * as DateUtils from './date';
|
|
|
31
31
|
import * as Money from './money';
|
|
32
32
|
// TODO remove deprecated Date export [issue #34]
|
|
33
33
|
export { hauntedPolymer, Template, DateUtils, mixin, Money, DateUtils as Date };
|
|
34
|
-
|
|
34
|
+
import { tagged } from './tagged';
|
|
35
|
+
export { tagged, tagged as css };
|
|
36
|
+
export * from './sheet';
|
package/dist/money.d.ts
CHANGED
|
@@ -13,22 +13,25 @@ isAmount: (potentialAmount: unknown) => potentialAmount is Amount,
|
|
|
13
13
|
* Render an amount with decimal separator and currency symbol.
|
|
14
14
|
* @param {object} money Money with amount property and optionally currency property.
|
|
15
15
|
* @param {void|string} locale Locale to format the amount in.
|
|
16
|
+
* @param {number} maximumFractionDigits Maximum number of decimals to display.
|
|
16
17
|
* @return {string} Formatted amount.
|
|
17
18
|
*/
|
|
18
|
-
renderAmount: (money: Amount | null, locale?: string) => string | undefined,
|
|
19
|
+
renderAmount: (money: Amount | null, locale?: string, maximumFractionDigits?: number) => string | undefined,
|
|
19
20
|
/**
|
|
20
21
|
* Alias for renderAmount(money). Render an amount with decimal separator and currency symbol.
|
|
21
22
|
* @param {object} money Money with amount property and optionally currency property.
|
|
22
23
|
* @return {string} Formatted amount.
|
|
23
24
|
*/
|
|
24
|
-
renderMoney: (money: Amount | null, locale?: string) => string | undefined,
|
|
25
|
+
renderMoney: (money: Amount | null, locale?: string, maximumFractionDigits?: number) => string | undefined,
|
|
25
26
|
/**
|
|
26
27
|
* Render an amount with decimal separator but without currency symbol.
|
|
27
28
|
* @param {object} money Money with amount property and optionally currency property.
|
|
28
29
|
* @param {void|string} locale Locale to format the amount in.
|
|
30
|
+
* @param {number} minimumFractionDigits Minimum number of decimals to display.
|
|
31
|
+
* @param {number} maximumFractionDigits Maximum number of decimals to display.
|
|
29
32
|
* @return {string} Formatted number.
|
|
30
33
|
*/
|
|
31
|
-
renderNumberAmount: (money: Amount, locale?: string) => string,
|
|
34
|
+
renderNumberAmount: (money: Amount, locale?: string, minimumFractionDigits?: number, maximumFractionDigits?: number) => string,
|
|
32
35
|
/**
|
|
33
36
|
* Round a number to a given precision.
|
|
34
37
|
* @param {string} number Number with decimals to round.
|
package/dist/money.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const CURRENCY_FORMATTERS = {}, NUMBER_FORMATTERS = {}, _getCurrencyFormatter = function (currency, locale,
|
|
1
|
+
const CURRENCY_FORMATTERS = {}, NUMBER_FORMATTERS = {}, _getCurrencyFormatter = function (currency, locale, maximumFractionDigits = 2) {
|
|
2
2
|
if (currency == null) {
|
|
3
3
|
return;
|
|
4
4
|
}
|
|
@@ -8,7 +8,8 @@ const CURRENCY_FORMATTERS = {}, NUMBER_FORMATTERS = {}, _getCurrencyFormatter =
|
|
|
8
8
|
CURRENCY_FORMATTERS[key] = new Intl.NumberFormat(locale, {
|
|
9
9
|
style: 'currency',
|
|
10
10
|
currency,
|
|
11
|
-
currencyDisplay,
|
|
11
|
+
currencyDisplay: 'code',
|
|
12
|
+
maximumFractionDigits,
|
|
12
13
|
});
|
|
13
14
|
}
|
|
14
15
|
catch (e) {
|
|
@@ -33,13 +34,14 @@ isAmount = (potentialAmount) => potentialAmount != null &&
|
|
|
33
34
|
* Render an amount with decimal separator and currency symbol.
|
|
34
35
|
* @param {object} money Money with amount property and optionally currency property.
|
|
35
36
|
* @param {void|string} locale Locale to format the amount in.
|
|
37
|
+
* @param {number} maximumFractionDigits Maximum number of decimals to display.
|
|
36
38
|
* @return {string} Formatted amount.
|
|
37
39
|
*/
|
|
38
|
-
renderAmount = (money, locale) => {
|
|
40
|
+
renderAmount = (money, locale, maximumFractionDigits) => {
|
|
39
41
|
if (money?.amount == null) {
|
|
40
42
|
return;
|
|
41
43
|
}
|
|
42
|
-
const formatter = _getCurrencyFormatter(money.currency, locale);
|
|
44
|
+
const formatter = _getCurrencyFormatter(money.currency, locale, maximumFractionDigits);
|
|
43
45
|
if (formatter == null) {
|
|
44
46
|
return;
|
|
45
47
|
}
|
|
@@ -55,14 +57,16 @@ renderMoney = renderAmount,
|
|
|
55
57
|
* Render an amount with decimal separator but without currency symbol.
|
|
56
58
|
* @param {object} money Money with amount property and optionally currency property.
|
|
57
59
|
* @param {void|string} locale Locale to format the amount in.
|
|
60
|
+
* @param {number} minimumFractionDigits Minimum number of decimals to display.
|
|
61
|
+
* @param {number} maximumFractionDigits Maximum number of decimals to display.
|
|
58
62
|
* @return {string} Formatted number.
|
|
59
63
|
*/
|
|
60
|
-
renderNumberAmount = (money, locale) => {
|
|
64
|
+
renderNumberAmount = (money, locale, minimumFractionDigits = 2, maximumFractionDigits = 2) => {
|
|
61
65
|
const key = locale || '0';
|
|
62
66
|
if (NUMBER_FORMATTERS[key] == null) {
|
|
63
67
|
NUMBER_FORMATTERS[key] = new Intl.NumberFormat(locale, {
|
|
64
|
-
minimumFractionDigits
|
|
65
|
-
maximumFractionDigits
|
|
68
|
+
minimumFractionDigits,
|
|
69
|
+
maximumFractionDigits,
|
|
66
70
|
});
|
|
67
71
|
}
|
|
68
72
|
return NUMBER_FORMATTERS[key].format(money.amount);
|
package/dist/sheet.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const sheet: (...styles: string[]) => CSSStyleSheet;
|
package/dist/sheet.js
ADDED