@designcrowd/fe-shared-lib 1.2.17-free-label-fix → 1.2.17-ml-currency
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/Dockerfile +1 -1
- package/dist/css/tailwind-brandCrowd.css +3 -37
- package/dist/css/tailwind-brandPage.css +3 -33
- package/dist/css/tailwind-crazyDomains.css +3 -37
- package/dist/css/tailwind-designCom.css +3 -37
- package/dist/css/tailwind-designCrowd.css +3 -37
- package/package.json +1 -1
- package/public/css/tailwind-brandCrowd.css +2411 -0
- package/public/css/tailwind-brandPage.css +2095 -0
- package/public/css/tailwind-crazyDomains.css +2411 -0
- package/public/css/tailwind-designCom.css +2411 -0
- package/public/css/tailwind-designCrowd.css +2411 -0
- package/src/atoms/components/Price/Price.fixtures.js +62 -2
- package/src/atoms/components/Price/Price.stories.js +58 -5
- package/src/atoms/components/Price/Price.vue +31 -10
- package/src/useSharedLibTranslate.js +37 -0
- package/.claude/settings.local.json +0 -10
|
@@ -14,12 +14,72 @@ export const audCurrency = {
|
|
|
14
14
|
abbreviation: 'AU',
|
|
15
15
|
};
|
|
16
16
|
|
|
17
|
+
export const gbpCurrency = {
|
|
18
|
+
id: 3,
|
|
19
|
+
name: 'British Pound',
|
|
20
|
+
iso4127Code: 'GBP',
|
|
21
|
+
symbol: '£',
|
|
22
|
+
abbreviation: 'UK',
|
|
23
|
+
};
|
|
24
|
+
|
|
17
25
|
export const euroCurrency = {
|
|
18
|
-
id:
|
|
26
|
+
id: 4,
|
|
19
27
|
name: 'Euro',
|
|
20
28
|
iso4127Code: 'EUR',
|
|
21
29
|
symbol: '€',
|
|
22
30
|
abbreviation: 'EU',
|
|
23
31
|
};
|
|
24
32
|
|
|
25
|
-
export const
|
|
33
|
+
export const inrCurrency = {
|
|
34
|
+
id: 5,
|
|
35
|
+
name: 'Indian Rupee',
|
|
36
|
+
iso4127Code: 'INR',
|
|
37
|
+
symbol: '₹',
|
|
38
|
+
abbreviation: 'IN',
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
export const phpCurrency = {
|
|
42
|
+
id: 6,
|
|
43
|
+
name: 'Philippine Peso',
|
|
44
|
+
iso4127Code: 'PHP',
|
|
45
|
+
symbol: '₱',
|
|
46
|
+
abbreviation: 'PH',
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
export const brlCurrency = {
|
|
50
|
+
id: 7,
|
|
51
|
+
name: 'Brazilian Real',
|
|
52
|
+
iso4127Code: 'BRL',
|
|
53
|
+
symbol: 'R$',
|
|
54
|
+
abbreviation: 'R',
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
export const mxnCurrency = {
|
|
58
|
+
id: 8,
|
|
59
|
+
name: 'Mexican Peso',
|
|
60
|
+
iso4127Code: 'MXN',
|
|
61
|
+
symbol: 'MX$',
|
|
62
|
+
abbreviation: 'MX',
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
export const zarCurrency = {
|
|
66
|
+
id: 9,
|
|
67
|
+
name: 'South African Rand',
|
|
68
|
+
iso4127Code: 'ZAR',
|
|
69
|
+
symbol: 'R',
|
|
70
|
+
abbreviation: 'R',
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
export const currencies = [
|
|
74
|
+
usdCurrency,
|
|
75
|
+
audCurrency,
|
|
76
|
+
gbpCurrency,
|
|
77
|
+
euroCurrency,
|
|
78
|
+
inrCurrency,
|
|
79
|
+
phpCurrency,
|
|
80
|
+
brlCurrency,
|
|
81
|
+
mxnCurrency,
|
|
82
|
+
zarCurrency,
|
|
83
|
+
];
|
|
84
|
+
|
|
85
|
+
export const locales = [ 'en_US', 'fr_FR', 'es_ES', 'pt_PT', 'de-DE']
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import Price from './Price.vue';
|
|
2
|
-
import { currencies } from './Price.fixtures';
|
|
2
|
+
import { currencies, locales } from './Price.fixtures';
|
|
3
|
+
import {setSharedLibLocaleAsync} from "../../../useSharedLibTranslate";
|
|
4
|
+
|
|
5
|
+
await setSharedLibLocaleAsync();
|
|
3
6
|
|
|
4
7
|
// noinspection JSUnusedGlobalSymbols
|
|
5
8
|
export default {
|
|
@@ -7,6 +10,7 @@ export default {
|
|
|
7
10
|
component: Price,
|
|
8
11
|
args: {
|
|
9
12
|
currencyName: currencies[0].name,
|
|
13
|
+
locale: locales[0]
|
|
10
14
|
},
|
|
11
15
|
argTypes: {
|
|
12
16
|
amount: {
|
|
@@ -16,6 +20,10 @@ export default {
|
|
|
16
20
|
control: { type: 'select' },
|
|
17
21
|
options: currencies.map((x) => x.name),
|
|
18
22
|
},
|
|
23
|
+
locale: {
|
|
24
|
+
control: { type: 'select' },
|
|
25
|
+
options: locales,
|
|
26
|
+
},
|
|
19
27
|
},
|
|
20
28
|
};
|
|
21
29
|
|
|
@@ -31,12 +39,16 @@ export const Sample = {
|
|
|
31
39
|
selectedCurrency() {
|
|
32
40
|
return currencies.find((x) => x.name === this.args.currencyName);
|
|
33
41
|
},
|
|
42
|
+
selectedLocale() {
|
|
43
|
+
return locales.find((x) => x === this.args.locale);
|
|
44
|
+
},
|
|
34
45
|
},
|
|
35
46
|
template: `
|
|
36
47
|
<span>
|
|
37
48
|
<price
|
|
38
49
|
v-bind="args"
|
|
39
50
|
:currency="selectedCurrency"
|
|
51
|
+
:locale="selectedLocale"
|
|
40
52
|
/>
|
|
41
53
|
</span>
|
|
42
54
|
`,
|
|
@@ -59,6 +71,9 @@ export const WithFraction = {
|
|
|
59
71
|
selectedCurrency() {
|
|
60
72
|
return currencies.find((x) => x.name === this.args.currencyName);
|
|
61
73
|
},
|
|
74
|
+
selectedLocale() {
|
|
75
|
+
return locales.find((x) => x === this.args.locale);
|
|
76
|
+
},
|
|
62
77
|
},
|
|
63
78
|
template: `
|
|
64
79
|
<span>
|
|
@@ -66,7 +81,7 @@ export const WithFraction = {
|
|
|
66
81
|
v-bind="args"
|
|
67
82
|
:currency="selectedCurrency"
|
|
68
83
|
fraction="2"
|
|
69
|
-
:
|
|
84
|
+
:locale="selectedLocale"
|
|
70
85
|
/>
|
|
71
86
|
</span>
|
|
72
87
|
`,
|
|
@@ -89,6 +104,9 @@ export const AlwaysShowFractionOn = {
|
|
|
89
104
|
selectedCurrency() {
|
|
90
105
|
return currencies.find((x) => x.name === this.args.currencyName);
|
|
91
106
|
},
|
|
107
|
+
selectedLocale() {
|
|
108
|
+
return locales.find((x) => x === this.args.locale);
|
|
109
|
+
},
|
|
92
110
|
},
|
|
93
111
|
template: `
|
|
94
112
|
<span>
|
|
@@ -97,7 +115,7 @@ export const AlwaysShowFractionOn = {
|
|
|
97
115
|
:always-show-fraction="true"
|
|
98
116
|
:currency="selectedCurrency"
|
|
99
117
|
fraction="2"
|
|
100
|
-
:
|
|
118
|
+
:locale="selectedLocale"
|
|
101
119
|
/>
|
|
102
120
|
</span>
|
|
103
121
|
`,
|
|
@@ -128,7 +146,7 @@ export const AlwaysShowFractionOff = {
|
|
|
128
146
|
:always-show-fraction="false"
|
|
129
147
|
:currency="selectedCurrency"
|
|
130
148
|
fraction="2"
|
|
131
|
-
:
|
|
149
|
+
:locale="selectedLocale"
|
|
132
150
|
/>
|
|
133
151
|
</span>
|
|
134
152
|
`,
|
|
@@ -151,6 +169,9 @@ export const WithSuffix = {
|
|
|
151
169
|
selectedCurrency() {
|
|
152
170
|
return currencies.find((x) => x.name === this.args.currencyName);
|
|
153
171
|
},
|
|
172
|
+
selectedLocale() {
|
|
173
|
+
return locales.find((x) => x === this.args.locale);
|
|
174
|
+
},
|
|
154
175
|
},
|
|
155
176
|
template: `
|
|
156
177
|
<span>
|
|
@@ -159,8 +180,8 @@ export const WithSuffix = {
|
|
|
159
180
|
:always-show-fraction="true"
|
|
160
181
|
:currency="selectedCurrency"
|
|
161
182
|
fraction="2"
|
|
162
|
-
:show-abbreviation="true"
|
|
163
183
|
:suffix="suffix"
|
|
184
|
+
:locale="selectedLocale"
|
|
164
185
|
/>
|
|
165
186
|
</span>
|
|
166
187
|
`,
|
|
@@ -171,3 +192,35 @@ export const WithSuffix = {
|
|
|
171
192
|
suffix: '/yr',
|
|
172
193
|
},
|
|
173
194
|
};
|
|
195
|
+
|
|
196
|
+
export const WithLocale = {
|
|
197
|
+
render: (args, { argTypes }) => {
|
|
198
|
+
return {
|
|
199
|
+
components: { Price },
|
|
200
|
+
props: Object.keys(argTypes),
|
|
201
|
+
setup() {
|
|
202
|
+
return { args };
|
|
203
|
+
},
|
|
204
|
+
computed: {
|
|
205
|
+
selectedCurrency() {
|
|
206
|
+
return currencies.find((x) => x.name === this.args.currencyName);
|
|
207
|
+
},
|
|
208
|
+
selectedLocale() {
|
|
209
|
+
return locales.find((x) => x === this.args.locale);
|
|
210
|
+
},
|
|
211
|
+
},
|
|
212
|
+
template: `
|
|
213
|
+
<span>
|
|
214
|
+
<price
|
|
215
|
+
v-bind="args"
|
|
216
|
+
:currency="selectedCurrency"
|
|
217
|
+
:locale="selectedLocale"
|
|
218
|
+
/>
|
|
219
|
+
</span>
|
|
220
|
+
`,
|
|
221
|
+
};
|
|
222
|
+
},
|
|
223
|
+
args: {
|
|
224
|
+
amount: 22.0,
|
|
225
|
+
},
|
|
226
|
+
};
|
|
@@ -5,7 +5,8 @@
|
|
|
5
5
|
</span>
|
|
6
6
|
</template>
|
|
7
7
|
<script>
|
|
8
|
-
|
|
8
|
+
|
|
9
|
+
import { priceTr, formatCurrency } from "../../../useSharedLibTranslate";
|
|
9
10
|
|
|
10
11
|
export default {
|
|
11
12
|
props: {
|
|
@@ -24,6 +25,11 @@ export default {
|
|
|
24
25
|
required: false,
|
|
25
26
|
default: null,
|
|
26
27
|
},
|
|
28
|
+
locale: {
|
|
29
|
+
type: String,
|
|
30
|
+
required: false,
|
|
31
|
+
default: null,
|
|
32
|
+
},
|
|
27
33
|
fraction: {
|
|
28
34
|
type: [Number, String],
|
|
29
35
|
required: false,
|
|
@@ -36,7 +42,7 @@ export default {
|
|
|
36
42
|
},
|
|
37
43
|
wrapInParentheses: {
|
|
38
44
|
type: Boolean,
|
|
39
|
-
|
|
45
|
+
requred: false,
|
|
40
46
|
default: false,
|
|
41
47
|
},
|
|
42
48
|
suffix: {
|
|
@@ -50,13 +56,13 @@ export default {
|
|
|
50
56
|
default: false,
|
|
51
57
|
},
|
|
52
58
|
},
|
|
59
|
+
data() {
|
|
60
|
+
return {
|
|
61
|
+
domainCreditUsed: priceTr('domainCreditUsed') ?? 'Domain credit used',
|
|
62
|
+
free: priceTr('free') ?? 'Free',
|
|
63
|
+
};
|
|
64
|
+
},
|
|
53
65
|
computed: {
|
|
54
|
-
domainCreditUsed() {
|
|
55
|
-
return priceTr('domainCreditUsed') ?? 'Domain credit used';
|
|
56
|
-
},
|
|
57
|
-
free() {
|
|
58
|
-
return priceTr('free') ?? 'Free';
|
|
59
|
-
},
|
|
60
66
|
amountFormatted() {
|
|
61
67
|
if (this.isDomainCredit) {
|
|
62
68
|
return this.domainCreditUsed;
|
|
@@ -66,6 +72,21 @@ export default {
|
|
|
66
72
|
return this.free;
|
|
67
73
|
}
|
|
68
74
|
|
|
75
|
+
if (this.locale != null)
|
|
76
|
+
{
|
|
77
|
+
const formattedCurrency = formatCurrency(
|
|
78
|
+
this.amount,
|
|
79
|
+
this.locale,
|
|
80
|
+
this.currency,
|
|
81
|
+
this.fraction,
|
|
82
|
+
this.showAbbreviation
|
|
83
|
+
);
|
|
84
|
+
|
|
85
|
+
if (formattedCurrency) {
|
|
86
|
+
return formattedCurrency;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
69
90
|
const parsedAmount = Number.parseFloat(this.amount);
|
|
70
91
|
|
|
71
92
|
if (Number.isNaN(parsedAmount)) {
|
|
@@ -81,10 +102,10 @@ export default {
|
|
|
81
102
|
return parsedAmount.toFixed(this.fraction);
|
|
82
103
|
},
|
|
83
104
|
currencyAbbreviation() {
|
|
84
|
-
return this.showAbbreviation && this.amount > 0 ? this.currency?.abbreviation?.trim() : '';
|
|
105
|
+
return this.showAbbreviation && this.amount && !this.locale > 0 ? this.currency?.abbreviation?.trim() : '';
|
|
85
106
|
},
|
|
86
107
|
currencySymbol() {
|
|
87
|
-
if (!this.amount || this.amount === 0) {
|
|
108
|
+
if (!this.amount || this.amount === 0 || this.locale) {
|
|
88
109
|
return '';
|
|
89
110
|
}
|
|
90
111
|
|
|
@@ -67,6 +67,42 @@ const getCurrentLocale = () => {
|
|
|
67
67
|
return i18next.language || 'en-US';
|
|
68
68
|
};
|
|
69
69
|
|
|
70
|
+
const formatCurrency = (amount, locale, currency, fraction = 0, showAbbreviation = false) => {
|
|
71
|
+
let localeAmount = i18next.t('{{val, currency}}', {
|
|
72
|
+
ns: 'fe-shared-lib',
|
|
73
|
+
val: amount,
|
|
74
|
+
currency: currency.iso4127Code,
|
|
75
|
+
locale: locale,
|
|
76
|
+
maximumFractionDigits: fraction,
|
|
77
|
+
useGrouping: false,
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
// i18next always uses iso code for ZAR, prefer symbol over iso code
|
|
81
|
+
if (localeAmount.includes(currency.iso4127Code)) {
|
|
82
|
+
return localeAmount.replace(currency.iso4127Code, currency.symbol);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
// show abbreviation locale logic
|
|
86
|
+
// note: showAbbreviaton is only passed as true for symbol = "$"
|
|
87
|
+
if (currency.symbol != '$') {
|
|
88
|
+
return localeAmount;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
// AUD edge case for en_US
|
|
92
|
+
if (currency.iso4127Code == 'AUD') {
|
|
93
|
+
localeAmount = localeAmount.replace('A$', currency.symbol);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
if (showAbbreviation && !localeAmount.includes(currency.abbreviation)) {
|
|
97
|
+
return `${currency?.abbreviation}${localeAmount}`;
|
|
98
|
+
|
|
99
|
+
} else if (!showAbbreviation && localeAmount.includes(currency.abbreviation)) {
|
|
100
|
+
return localeAmount.replace(currency.abbreviation, '');
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
return localeAmount;
|
|
104
|
+
}
|
|
105
|
+
|
|
70
106
|
export {
|
|
71
107
|
setSharedLibLocaleAsync,
|
|
72
108
|
getCurrentLocale,
|
|
@@ -81,4 +117,5 @@ export {
|
|
|
81
117
|
uploadYourLogoTr,
|
|
82
118
|
sharedPaymentConfigTr,
|
|
83
119
|
priceTr,
|
|
120
|
+
formatCurrency,
|
|
84
121
|
};
|