@zonos/amino 5.1.65 → 5.1.66
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/all.d.ts
CHANGED
|
@@ -711,6 +711,7 @@ import './utils/changeDeepProperty';
|
|
|
711
711
|
import './utils/changeDeepPropertyAtIndex';
|
|
712
712
|
import './utils/countryPhoneCodes';
|
|
713
713
|
import './utils/flattenRow';
|
|
714
|
+
import './utils/formatCurrency';
|
|
714
715
|
import './utils/getAminoColor';
|
|
715
716
|
import './utils/getCountryCodeByName';
|
|
716
717
|
import './utils/getFuzzySearch';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var e=require("react/jsx-runtime"),r=require("clsx"),t=require("../text/Text.js"),s=require("../../style-inject.es-d4ddeae4.js");function
|
|
1
|
+
"use strict";var e=require("react/jsx-runtime"),r=require("clsx"),t=require("../text/Text.js"),s=require("../../utils/formatCurrency.js"),n=require("../../style-inject.es-d4ddeae4.js");function u(e){return e&&e.__esModule?e:{default:e}}require("../../_tslib-ccfac372.js"),require("styled-components"),require("../../styles/constants/theme.js");var a=u(r),l="Amino_Currency-module__styledCurrency--vgT8x";n.styleInject('.Amino_Currency-module__styledCurrency--vgT8x{-webkit-font-feature-settings:"tnum" 1;font-feature-settings:"tnum" 1;display:flex;gap:var(--amino-space-4);white-space:nowrap}');exports.Currency=function(r){var n=r.amount,u=r.className,c=r.code,i=r.style,o=s.formatCurrency({code:c,value:n}),y=n<0;return e.jsxs("span",{className:a.default(l,u),style:i,children:[e.jsx(t.Text,{color:y?"red600":"gray1200",type:"label",children:o}),e.jsx(t.Text,{color:y?"red400":"gray700",children:c.toUpperCase()})]})};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var r=require("../../_tslib-ccfac372.js"),e=require("react/jsx-runtime"),n=require("clsx"),a=require("./Currency.js"),i=require("../../icons/ArrowSwapIcon.js"),u=require("../../style-inject.es-d4ddeae4.js");function t(r){return r&&r.__esModule?r:{default:r}}require("../text/Text.js"),require("styled-components"),require("../../styles/constants/theme.js"),require("react"),require("../../icons/icon-base/_IconBase.js");var c=t(n),s="Amino_DualCurrency-module__dualCurrencyWrapper--3BrVC";u.styleInject(".Amino_DualCurrency-module__dualCurrencyWrapper--3BrVC{grid-column-gap:var(--amino-space-8);-webkit-font-feature-settings:var(--amino-dual-currency-font-variant-numeric);font-feature-settings:var(--amino-dual-currency-font-variant-numeric);align-items:center;display:var(--amino-dual-currency-display);font-variant-numeric:var(--amino-dual-currency-font-variant-numeric);grid-template-columns:var(--amino-dual-currency-grid-template-columns);justify-items:right;width:var(--amino-dual-currency-width)}");exports.DualCurrency=function(n){var u=n.className,t=n.conversionRate,o=n.foreignCode,l=void 0===o?"USD":o,d=n.isTabular,m=void 0===d||d,y=n.localeCode,v=void 0===y?"USD":y,f=n.showForeign,
|
|
1
|
+
"use strict";var r=require("../../_tslib-ccfac372.js"),e=require("react/jsx-runtime"),n=require("clsx"),a=require("./Currency.js"),i=require("../../icons/ArrowSwapIcon.js"),u=require("../../style-inject.es-d4ddeae4.js");function t(r){return r&&r.__esModule?r:{default:r}}require("../text/Text.js"),require("styled-components"),require("../../styles/constants/theme.js"),require("../../utils/formatCurrency.js"),require("react"),require("../../icons/icon-base/_IconBase.js");var c=t(n),s="Amino_DualCurrency-module__dualCurrencyWrapper--3BrVC";u.styleInject(".Amino_DualCurrency-module__dualCurrencyWrapper--3BrVC{grid-column-gap:var(--amino-space-8);-webkit-font-feature-settings:var(--amino-dual-currency-font-variant-numeric);font-feature-settings:var(--amino-dual-currency-font-variant-numeric);align-items:center;display:var(--amino-dual-currency-display);font-variant-numeric:var(--amino-dual-currency-font-variant-numeric);grid-template-columns:var(--amino-dual-currency-grid-template-columns);justify-items:right;width:var(--amino-dual-currency-width)}");exports.DualCurrency=function(n){var u=n.className,t=n.conversionRate,o=n.foreignCode,l=void 0===o?"USD":o,d=n.isTabular,m=void 0===d||d,y=n.localeCode,v=void 0===y?"USD":y,f=n.showForeign,j=void 0===f||f,p=n.showLocale,g=void 0===p||p,_=n.style,C=n.value,q=n.width,w=function(r){return e.jsx(a.Currency,{amount:C,className:r,code:v})},x=t?C*t:C,h=function(r){return e.jsx(a.Currency,{amount:x,className:r,code:l})},b=v&&g,D=l&&j&&t,S=v===l;return D&&b&&!S?e.jsxs("div",{className:c.default(s,u),style:r.__assign(r.__assign({},_),{"--amino-dual-currency-display":m?"grid":"flex","--amino-dual-currency-font-variant-numberic":m?"tabular-nums":"","--amino-dual-currency-grid-template-columns":m?"1.25fr 0fr 1.25fr":"","--amino-dual-currency-width":(null==q?void 0:q.toString())||""}),children:[w(),e.jsx(i.ArrowSwapIcon,{size:12}),h()]}):S||b?w(u):D?h(u):null};
|
package/package.json
CHANGED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
type FormatCurrencyParams = {
|
|
2
|
+
code: string;
|
|
3
|
+
/**
|
|
4
|
+
* Keep the currency symbol and separators. Defualt is to remove them.
|
|
5
|
+
* @default false
|
|
6
|
+
*/
|
|
7
|
+
keepDecorators?: boolean;
|
|
8
|
+
/**
|
|
9
|
+
* If you don't want thousands separators, set useGrouping to false.
|
|
10
|
+
*/
|
|
11
|
+
options?: Intl.NumberFormatOptions;
|
|
12
|
+
value: number;
|
|
13
|
+
};
|
|
14
|
+
export declare const formatCurrency: ({ code, options, value, }: FormatCurrencyParams) => string;
|
|
15
|
+
type DualCurrencyParams = {
|
|
16
|
+
conversionRate: number | null;
|
|
17
|
+
foreignCode: string | null;
|
|
18
|
+
localCode: string;
|
|
19
|
+
value: number;
|
|
20
|
+
};
|
|
21
|
+
type DualCurrency = {
|
|
22
|
+
foreign: {
|
|
23
|
+
code: string;
|
|
24
|
+
value: string;
|
|
25
|
+
} | null;
|
|
26
|
+
local: {
|
|
27
|
+
code: string;
|
|
28
|
+
value: string;
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
/**
|
|
32
|
+
* Just returns values, presentation is up to implementation
|
|
33
|
+
*/
|
|
34
|
+
export declare const getDualCurrency: ({ conversionRate, foreignCode, localCode, value, }: DualCurrencyParams) => DualCurrency;
|
|
35
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var e=require("../_tslib-ccfac372.js"),r=function(r){var o=r.code,a=r.options,n=r.value;return new Intl.NumberFormat(navigator.language,e.__assign({currency:o,style:"currency"},a)).format(n).replace(/[^0-9.\-,]+/g,"")};exports.formatCurrency=r,exports.getDualCurrency=function(e){var o=e.conversionRate,a=e.foreignCode,n=e.localCode,u=e.value,c=o?u*o:u,l={code:n,value:r({code:n,value:u})};return{foreign:a?{code:a,value:r({code:a,value:c})}:null,local:l}};
|