@designcrowd/fe-shared-lib 1.2.18-ml-currency → 1.2.18
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/package.json +1 -1
- package/public/css/tailwind-brandCrowd.css +30 -0
- package/public/css/tailwind-brandPage.css +30 -0
- package/public/css/tailwind-crazyDomains.css +30 -0
- package/public/css/tailwind-designCom.css +30 -0
- package/public/css/tailwind-designCrowd.css +30 -0
- package/src/atoms/components/Price/Price.fixtures.js +3 -63
- package/src/atoms/components/Price/Price.stories.js +5 -127
- package/src/atoms/components/Price/Price.vue +3 -24
- package/src/useSharedLibTranslate.js +0 -42
- package/dist/css/tailwind-brandCrowd.css +0 -2459
- package/dist/css/tailwind-brandPage.css +0 -2147
- package/dist/css/tailwind-crazyDomains.css +0 -2459
- package/dist/css/tailwind-designCom.css +0 -2459
- package/dist/css/tailwind-designCrowd.css +0 -2459
|
@@ -1,9 +1,5 @@
|
|
|
1
1
|
import Price from './Price.vue';
|
|
2
|
-
import { currencies
|
|
3
|
-
import { setSharedLibLocaleAsync } from "../../../useSharedLibTranslate";
|
|
4
|
-
import { defineComponent } from "vue";
|
|
5
|
-
|
|
6
|
-
await setSharedLibLocaleAsync();
|
|
2
|
+
import { currencies } from './Price.fixtures';
|
|
7
3
|
|
|
8
4
|
// noinspection JSUnusedGlobalSymbols
|
|
9
5
|
export default {
|
|
@@ -11,7 +7,6 @@ export default {
|
|
|
11
7
|
component: Price,
|
|
12
8
|
args: {
|
|
13
9
|
currencyName: currencies[0].name,
|
|
14
|
-
locale: locales[0]
|
|
15
10
|
},
|
|
16
11
|
argTypes: {
|
|
17
12
|
amount: {
|
|
@@ -21,10 +16,6 @@ export default {
|
|
|
21
16
|
control: { type: 'select' },
|
|
22
17
|
options: currencies.map((x) => x.name),
|
|
23
18
|
},
|
|
24
|
-
locale: {
|
|
25
|
-
control: { type: 'select' },
|
|
26
|
-
options: locales,
|
|
27
|
-
},
|
|
28
19
|
},
|
|
29
20
|
};
|
|
30
21
|
|
|
@@ -40,16 +31,12 @@ export const Sample = {
|
|
|
40
31
|
selectedCurrency() {
|
|
41
32
|
return currencies.find((x) => x.name === this.args.currencyName);
|
|
42
33
|
},
|
|
43
|
-
selectedLocale() {
|
|
44
|
-
return locales.find((x) => x === this.args.locale);
|
|
45
|
-
},
|
|
46
34
|
},
|
|
47
35
|
template: `
|
|
48
36
|
<span>
|
|
49
37
|
<price
|
|
50
38
|
v-bind="args"
|
|
51
39
|
:currency="selectedCurrency"
|
|
52
|
-
:locale="selectedLocale"
|
|
53
40
|
/>
|
|
54
41
|
</span>
|
|
55
42
|
`,
|
|
@@ -72,9 +59,6 @@ export const WithFraction = {
|
|
|
72
59
|
selectedCurrency() {
|
|
73
60
|
return currencies.find((x) => x.name === this.args.currencyName);
|
|
74
61
|
},
|
|
75
|
-
selectedLocale() {
|
|
76
|
-
return locales.find((x) => x === this.args.locale);
|
|
77
|
-
},
|
|
78
62
|
},
|
|
79
63
|
template: `
|
|
80
64
|
<span>
|
|
@@ -82,7 +66,7 @@ export const WithFraction = {
|
|
|
82
66
|
v-bind="args"
|
|
83
67
|
:currency="selectedCurrency"
|
|
84
68
|
fraction="2"
|
|
85
|
-
:
|
|
69
|
+
:show-abbreviation="true"
|
|
86
70
|
/>
|
|
87
71
|
</span>
|
|
88
72
|
`,
|
|
@@ -105,9 +89,6 @@ export const AlwaysShowFractionOn = {
|
|
|
105
89
|
selectedCurrency() {
|
|
106
90
|
return currencies.find((x) => x.name === this.args.currencyName);
|
|
107
91
|
},
|
|
108
|
-
selectedLocale() {
|
|
109
|
-
return locales.find((x) => x === this.args.locale);
|
|
110
|
-
},
|
|
111
92
|
},
|
|
112
93
|
template: `
|
|
113
94
|
<span>
|
|
@@ -116,7 +97,7 @@ export const AlwaysShowFractionOn = {
|
|
|
116
97
|
:always-show-fraction="true"
|
|
117
98
|
:currency="selectedCurrency"
|
|
118
99
|
fraction="2"
|
|
119
|
-
:
|
|
100
|
+
:show-abbreviation="true"
|
|
120
101
|
/>
|
|
121
102
|
</span>
|
|
122
103
|
`,
|
|
@@ -147,7 +128,7 @@ export const AlwaysShowFractionOff = {
|
|
|
147
128
|
:always-show-fraction="false"
|
|
148
129
|
:currency="selectedCurrency"
|
|
149
130
|
fraction="2"
|
|
150
|
-
:
|
|
131
|
+
:show-abbreviation="true"
|
|
151
132
|
/>
|
|
152
133
|
</span>
|
|
153
134
|
`,
|
|
@@ -170,9 +151,6 @@ export const WithSuffix = {
|
|
|
170
151
|
selectedCurrency() {
|
|
171
152
|
return currencies.find((x) => x.name === this.args.currencyName);
|
|
172
153
|
},
|
|
173
|
-
selectedLocale() {
|
|
174
|
-
return locales.find((x) => x === this.args.locale);
|
|
175
|
-
},
|
|
176
154
|
},
|
|
177
155
|
template: `
|
|
178
156
|
<span>
|
|
@@ -181,8 +159,8 @@ export const WithSuffix = {
|
|
|
181
159
|
:always-show-fraction="true"
|
|
182
160
|
:currency="selectedCurrency"
|
|
183
161
|
fraction="2"
|
|
162
|
+
:show-abbreviation="true"
|
|
184
163
|
:suffix="suffix"
|
|
185
|
-
:locale="selectedLocale"
|
|
186
164
|
/>
|
|
187
165
|
</span>
|
|
188
166
|
`,
|
|
@@ -193,103 +171,3 @@ export const WithSuffix = {
|
|
|
193
171
|
suffix: '/yr',
|
|
194
172
|
},
|
|
195
173
|
};
|
|
196
|
-
|
|
197
|
-
export const WithLocale = {
|
|
198
|
-
render: (args, { argTypes }) => {
|
|
199
|
-
return {
|
|
200
|
-
components: { Price },
|
|
201
|
-
props: Object.keys(argTypes),
|
|
202
|
-
setup() {
|
|
203
|
-
return { args };
|
|
204
|
-
},
|
|
205
|
-
computed: {
|
|
206
|
-
selectedCurrency() {
|
|
207
|
-
return currencies.find((x) => x.name === this.args.currencyName);
|
|
208
|
-
},
|
|
209
|
-
selectedLocale() {
|
|
210
|
-
return locales.find((x) => x === this.args.locale);
|
|
211
|
-
},
|
|
212
|
-
},
|
|
213
|
-
template: `
|
|
214
|
-
<span>
|
|
215
|
-
<price
|
|
216
|
-
v-bind="args"
|
|
217
|
-
:currency="selectedCurrency"
|
|
218
|
-
:locale="selectedLocale"
|
|
219
|
-
/>
|
|
220
|
-
</span>
|
|
221
|
-
`,
|
|
222
|
-
};
|
|
223
|
-
},
|
|
224
|
-
args: {
|
|
225
|
-
amount: 22.0,
|
|
226
|
-
},
|
|
227
|
-
};
|
|
228
|
-
|
|
229
|
-
export const AllLocalesAndCurrencies = (args, { argTypes }) => {
|
|
230
|
-
return {
|
|
231
|
-
components: {
|
|
232
|
-
StorybookPriceComponent,
|
|
233
|
-
},
|
|
234
|
-
props: Object.keys(argTypes),
|
|
235
|
-
data() {
|
|
236
|
-
const combos = new Array(locales.length).fill(0);
|
|
237
|
-
combos.forEach((item, index) => {
|
|
238
|
-
combos[index] = new Array(currencies.length).fill(0).map((item2, index2) => ({"locale": locales[index], "currency": currencies[index2]}))
|
|
239
|
-
})
|
|
240
|
-
currencies.forEach((item) => {
|
|
241
|
-
console.log(item.iso4127Code);
|
|
242
|
-
})
|
|
243
|
-
return {
|
|
244
|
-
variants: combos,
|
|
245
|
-
};
|
|
246
|
-
},
|
|
247
|
-
template: `
|
|
248
|
-
<StorybookPriceComponent
|
|
249
|
-
:variants="variants"/>
|
|
250
|
-
<StorybookPriceComponent
|
|
251
|
-
:variants="variants"
|
|
252
|
-
:show-abbreviation="true"
|
|
253
|
-
/>
|
|
254
|
-
`,
|
|
255
|
-
};
|
|
256
|
-
};
|
|
257
|
-
|
|
258
|
-
const StorybookPriceComponent = defineComponent({
|
|
259
|
-
components: {
|
|
260
|
-
Price,
|
|
261
|
-
},
|
|
262
|
-
props: {
|
|
263
|
-
variants: {
|
|
264
|
-
type: Array,
|
|
265
|
-
required: true,
|
|
266
|
-
},
|
|
267
|
-
showAbbreviation: {
|
|
268
|
-
type: Boolean,
|
|
269
|
-
default: false,
|
|
270
|
-
},
|
|
271
|
-
},
|
|
272
|
-
template: `
|
|
273
|
-
<table class="tw-w-full">
|
|
274
|
-
<thead>
|
|
275
|
-
<tr>
|
|
276
|
-
<th class="tw-text-left tw-p-4 tw-bg-grayscale-400 tw-font-sans">Price</th>
|
|
277
|
-
</tr>
|
|
278
|
-
</thead>
|
|
279
|
-
<tbody>
|
|
280
|
-
<tr v-for="locale in variants" class="tw-bg-grayscale-200">
|
|
281
|
-
<td>{{ locale[0].locale }}</td>
|
|
282
|
-
<td v-for="item in locale" class="tw-p-4">
|
|
283
|
-
<price
|
|
284
|
-
:amount=10.00
|
|
285
|
-
:currency="item.currency"
|
|
286
|
-
:locale="item.locale"
|
|
287
|
-
:show-abbreviation="showAbbreviation"
|
|
288
|
-
fraction="2"
|
|
289
|
-
/>
|
|
290
|
-
</td>
|
|
291
|
-
</tr>
|
|
292
|
-
</tbody>
|
|
293
|
-
</table>
|
|
294
|
-
`,
|
|
295
|
-
});
|
|
@@ -5,8 +5,7 @@
|
|
|
5
5
|
</span>
|
|
6
6
|
</template>
|
|
7
7
|
<script>
|
|
8
|
-
|
|
9
|
-
import { priceTr, formatCurrency } from "../../../useSharedLibTranslate";
|
|
8
|
+
import { priceTr } from '../../../useSharedLibTranslate';
|
|
10
9
|
|
|
11
10
|
export default {
|
|
12
11
|
props: {
|
|
@@ -25,11 +24,6 @@ export default {
|
|
|
25
24
|
required: false,
|
|
26
25
|
default: null,
|
|
27
26
|
},
|
|
28
|
-
locale: {
|
|
29
|
-
type: String,
|
|
30
|
-
required: false,
|
|
31
|
-
default: null,
|
|
32
|
-
},
|
|
33
27
|
fraction: {
|
|
34
28
|
type: [Number, String],
|
|
35
29
|
required: false,
|
|
@@ -72,21 +66,6 @@ export default {
|
|
|
72
66
|
return this.free;
|
|
73
67
|
}
|
|
74
68
|
|
|
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
|
-
|
|
90
69
|
const parsedAmount = Number.parseFloat(this.amount);
|
|
91
70
|
|
|
92
71
|
if (Number.isNaN(parsedAmount)) {
|
|
@@ -102,10 +81,10 @@ export default {
|
|
|
102
81
|
return parsedAmount.toFixed(this.fraction);
|
|
103
82
|
},
|
|
104
83
|
currencyAbbreviation() {
|
|
105
|
-
return this.showAbbreviation && this.amount
|
|
84
|
+
return this.showAbbreviation && this.amount > 0 ? this.currency?.abbreviation?.trim() : '';
|
|
106
85
|
},
|
|
107
86
|
currencySymbol() {
|
|
108
|
-
if (!this.amount || this.amount === 0
|
|
87
|
+
if (!this.amount || this.amount === 0) {
|
|
109
88
|
return '';
|
|
110
89
|
}
|
|
111
90
|
|
|
@@ -67,47 +67,6 @@ 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
|
-
const abbreviationTrimmed = currency.abbreviation.trim();
|
|
81
|
-
const symbolTrimmed = currency.symbol.trim();
|
|
82
|
-
|
|
83
|
-
// i18next always uses iso code for ZAR, prefer symbol over iso code
|
|
84
|
-
if (localeAmount.includes(currency.iso4127Code) && currency.iso4127Code === 'ZAR') {
|
|
85
|
-
return localeAmount.replace(currency.iso4127Code, symbolTrimmed);
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
// edge case
|
|
89
|
-
if (localeAmount.includes(currency.iso4127Code)) {
|
|
90
|
-
return localeAmount.replace(currency.iso4127Code, symbolTrimmed);
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
// show abbreviation locale logic
|
|
94
|
-
// note: showAbbreviation is only passed as true for symbol = "$"
|
|
95
|
-
if (currency.symbol.trim() !== '$') {
|
|
96
|
-
return localeAmount;
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
const altAudAbbreviation = 'AU';
|
|
100
|
-
if (showAbbreviation && !localeAmount.includes(abbreviationTrimmed)) {
|
|
101
|
-
return localeAmount.replace(symbolTrimmed,`${abbreviationTrimmed}${symbolTrimmed}`);
|
|
102
|
-
} else if (!showAbbreviation && localeAmount.includes(altAudAbbreviation)) {
|
|
103
|
-
return localeAmount.replace(altAudAbbreviation, '');
|
|
104
|
-
} else if (!showAbbreviation && localeAmount.includes(abbreviationTrimmed)) {
|
|
105
|
-
return localeAmount.replace(abbreviationTrimmed, '');
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
return localeAmount;
|
|
109
|
-
}
|
|
110
|
-
|
|
111
70
|
export {
|
|
112
71
|
setSharedLibLocaleAsync,
|
|
113
72
|
getCurrentLocale,
|
|
@@ -122,5 +81,4 @@ export {
|
|
|
122
81
|
uploadYourLogoTr,
|
|
123
82
|
sharedPaymentConfigTr,
|
|
124
83
|
priceTr,
|
|
125
|
-
formatCurrency,
|
|
126
84
|
};
|