@firedesktop/react-base 1.45.0 → 1.46.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.
@@ -0,0 +1,3 @@
1
+ export default function CurrencyUtiles(): {
2
+ numberToCurrencyString: (value: string | number, locale?: string, currency?: string) => String;
3
+ };
@@ -0,0 +1,18 @@
1
+ export default function CurrencyUtiles() {
2
+ var numberToCurrencyString = function (value, locale, currency) {
3
+ if (locale === void 0) { locale = 'IT'; }
4
+ if (currency === void 0) { currency = 'EUR'; }
5
+ try {
6
+ var valueNumber = Number(value);
7
+ if (value === undefined || value === null || isNaN(valueNumber))
8
+ return '';
9
+ return new Intl.NumberFormat(locale, { style: 'currency', currency: currency }).format(valueNumber);
10
+ }
11
+ catch (err) { }
12
+ return '';
13
+ };
14
+ return {
15
+ numberToCurrencyString: numberToCurrencyString
16
+ };
17
+ }
18
+ //# sourceMappingURL=CurrencyUtiles.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CurrencyUtiles.js","sourceRoot":"","sources":["../../src/lib/utils/CurrencyUtiles.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,OAAO,UAAU,cAAc;IAUlC,IAAM,sBAAsB,GAAG,UAAC,KAAsB,EAAE,MAAqB,EAAE,QAAgB;QAAvC,uBAAA,EAAA,aAAqB;QAAE,yBAAA,EAAA,gBAAgB;QAC3F,IAAI;YACA,IAAM,WAAW,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;YAElC,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,CAAC,WAAW,CAAC;gBAC3D,OAAO,EAAE,CAAC;YAEd,OAAO,IAAI,IAAI,CAAC,YAAY,CAAC,MAAM,EAAE,EAAE,KAAK,EAAE,UAAU,EAAE,QAAQ,UAAA,EAAE,CAAC,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;SAC7F;QAAC,OAAO,GAAG,EAAE,GAAG;QAEjB,OAAO,EAAE,CAAC;IACd,CAAC,CAAC;IAGF,OAAO;QACH,sBAAsB,wBAAA;KACzB,CAAC;AACN,CAAC"}
package/package.json CHANGED
@@ -1,14 +1,14 @@
1
1
  {
2
2
  "name": "@firedesktop/react-base",
3
- "version": "1.45.0",
3
+ "version": "1.46.0",
4
4
  "license": "ISC",
5
5
  "main": "dist/index.js",
6
6
  "description": "This is the FireDesktop base package used to support every React Project in this Company.",
7
7
  "author": "alessandro.gambaro",
8
8
  "repository": "https://firedesktopDevOps@dev.azure.com/firedesktopDevOps/baseFEComponents/_git/baseFEComponents",
9
9
  "dependencies": {
10
- "@syncfusion/ej2-popups": "20.1.47",
11
- "@syncfusion/ej2-react-notifications": "20.1.47"
10
+ "@syncfusion/ej2-popups": "20.1.55",
11
+ "@syncfusion/ej2-react-notifications": "20.1.55"
12
12
  },
13
13
  "devDependencies": {
14
14
  "@babel/cli": "7.17.10",
@@ -18,14 +18,14 @@
18
18
  "@babel/preset-typescript": "7.16.7",
19
19
  "@testing-library/jest-dom": "5.16.4",
20
20
  "@testing-library/react": "13.2.0",
21
- "@testing-library/user-event": "14.1.1",
22
- "@types/jest": "27.5.0",
23
- "@types/node": "17.0.31",
24
- "@types/react": "18.0.8",
25
- "@types/react-dom": "18.0.3",
21
+ "@testing-library/user-event": "14.2.0",
22
+ "@types/jest": "27.5.1",
23
+ "@types/node": "17.0.33",
24
+ "@types/react": "18.0.9",
25
+ "@types/react-dom": "18.0.4",
26
26
  "@types/react-redux": "7.1.24",
27
27
  "babel-plugin-minify-builtins": "0.5.0",
28
- "babel-preset-minify": "0.5.1",
28
+ "babel-preset-minify": "0.5.2",
29
29
  "bootstrap": "4.6.0",
30
30
  "copyfiles": "2.4.1",
31
31
  "react": "18.1.0",
@@ -0,0 +1,28 @@
1
+ export default function CurrencyUtiles() {
2
+ /**
3
+ * Intl
4
+ * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat
5
+ *
6
+ * @param value
7
+ * @param locale 'en-US' or 'en' or 'US'...
8
+ * @param currency https://www.easymarkets.com/eu/learn-centre/discover-trading/currency-acronyms-and-abbreviations/, default EUR
9
+ * @returns
10
+ */
11
+ const numberToCurrencyString = (value: string | number, locale: string = 'IT', currency = 'EUR'): String => {
12
+ try {
13
+ const valueNumber = Number(value);
14
+
15
+ if (value === undefined || value === null || isNaN(valueNumber))
16
+ return '';
17
+
18
+ return new Intl.NumberFormat(locale, { style: 'currency', currency }).format(valueNumber);
19
+ } catch (err) { }
20
+
21
+ return '';
22
+ };
23
+
24
+
25
+ return {
26
+ numberToCurrencyString
27
+ };
28
+ }