@ancon/wildcat-utils 1.41.18 → 1.42.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.
|
@@ -1,3 +1,15 @@
|
|
|
1
|
+
declare type Options = {
|
|
2
|
+
/**
|
|
3
|
+
* Whether or not to format the currency postfix (ie SEK -> kr)
|
|
4
|
+
* @default true
|
|
5
|
+
*/
|
|
6
|
+
formatPostfix?: boolean;
|
|
7
|
+
/**
|
|
8
|
+
* Whether or not to trim trailing zeros
|
|
9
|
+
* @default true
|
|
10
|
+
*/
|
|
11
|
+
trimTrailingZeros?: boolean;
|
|
12
|
+
};
|
|
1
13
|
/**
|
|
2
14
|
* Formats the given monetary value
|
|
3
15
|
* @param {number} value - The numeric value
|
|
@@ -6,4 +18,12 @@
|
|
|
6
18
|
* @return {string} - Formatted monetary value
|
|
7
19
|
*/
|
|
8
20
|
declare function getFormattedCurrency(value?: number | null, currency?: string | null, formatPostfix?: boolean): string;
|
|
21
|
+
/**
|
|
22
|
+
* Formats the given monetary value
|
|
23
|
+
* @param {number} value - The numeric value
|
|
24
|
+
* @param {string} currency - The currency string
|
|
25
|
+
* @param {boolean} options - Options object
|
|
26
|
+
* @return {string} - Formatted monetary value
|
|
27
|
+
*/
|
|
28
|
+
declare function getFormattedCurrency(value: number | null | undefined, currency: string | null | undefined, options: Options): string;
|
|
9
29
|
export default getFormattedCurrency;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const
|
|
1
|
+
"use strict";const i=require("./getFormattedCurrencyPostfix.js");function N(r=0,c="SEK",e=!0){let u=0;const t=typeof e=="object"?{formatPostfix:(e==null?void 0:e.formatPostfix)??!0,trimTrailingZeros:(e==null?void 0:e.trimTrailingZeros)??!0}:{formatPostfix:e,trimTrailingZeros:!0};!r||Number.isNaN(Number(r))?u=0:t.trimTrailingZeros&&Number.isInteger(Number(r))?u=r:u=Number(r).toFixed(2);const g=t.formatPostfix?i.getFormattedCurrencyPostfix(c):c;return`${u} ${g}`}module.exports=N;
|
|
@@ -1,10 +1,17 @@
|
|
|
1
|
-
import { getFormattedCurrencyPostfix as
|
|
2
|
-
function
|
|
3
|
-
let
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
import { getFormattedCurrencyPostfix as c } from "./getFormattedCurrencyPostfix.mjs";
|
|
2
|
+
function d(r = 0, g = "SEK", e = !0) {
|
|
3
|
+
let u = 0;
|
|
4
|
+
const N = typeof e == "object" ? {
|
|
5
|
+
formatPostfix: (e == null ? void 0 : e.formatPostfix) ?? !0,
|
|
6
|
+
trimTrailingZeros: (e == null ? void 0 : e.trimTrailingZeros) ?? !0
|
|
7
|
+
} : {
|
|
8
|
+
formatPostfix: e,
|
|
9
|
+
trimTrailingZeros: !0
|
|
10
|
+
};
|
|
11
|
+
!r || Number.isNaN(Number(r)) ? u = 0 : N.trimTrailingZeros && Number.isInteger(Number(r)) ? u = r : u = Number(r).toFixed(2);
|
|
12
|
+
const b = N.formatPostfix ? c(g) : g;
|
|
13
|
+
return `${u} ${b}`;
|
|
7
14
|
}
|
|
8
15
|
export {
|
|
9
|
-
|
|
16
|
+
d as default
|
|
10
17
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const
|
|
1
|
+
"use strict";const r=require("moment"),e=require("@ancon/wildcat-types"),t=require("./types.js");function c(i,n,s=10){return(i&e.LicenseStatus.Terminated)===e.LicenseStatus.Terminated?t.LicenseUIState.Terminated:(i&e.LicenseStatus.Expired)===e.LicenseStatus.Expired?t.LicenseUIState.Expired:(i&e.LicenseStatus.Extended)===e.LicenseStatus.Extended?t.LicenseUIState.Extended:n&&r(n).diff(r(),"day")<=s?t.LicenseUIState.AboutToExpire:t.LicenseUIState.Valid}module.exports=c;
|
|
@@ -1,18 +1,9 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { LicenseStatus as
|
|
3
|
-
import { LicenseUIState as
|
|
4
|
-
function
|
|
5
|
-
|
|
6
|
-
case t.Expired:
|
|
7
|
-
return e.Expired;
|
|
8
|
-
case t.Extended:
|
|
9
|
-
return e.Extended;
|
|
10
|
-
case t.Terminated:
|
|
11
|
-
return e.Terminated;
|
|
12
|
-
default:
|
|
13
|
-
return r && i(r).diff(i(), "day") <= o ? e.AboutToExpire : e.Valid;
|
|
14
|
-
}
|
|
1
|
+
import n from "moment";
|
|
2
|
+
import { LicenseStatus as e } from "@ancon/wildcat-types";
|
|
3
|
+
import { LicenseUIState as r } from "./types.mjs";
|
|
4
|
+
function a(i, t, o = 10) {
|
|
5
|
+
return (i & e.Terminated) === e.Terminated ? r.Terminated : (i & e.Expired) === e.Expired ? r.Expired : (i & e.Extended) === e.Extended ? r.Extended : t && n(t).diff(n(), "day") <= o ? r.AboutToExpire : r.Valid;
|
|
15
6
|
}
|
|
16
7
|
export {
|
|
17
|
-
|
|
8
|
+
a as default
|
|
18
9
|
};
|