@empathyco/x-components 6.3.2 → 7.0.1

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.
Files changed (51) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/core/index.js +0 -1
  3. package/core/index.js.map +1 -1
  4. package/docs/API-reference/api/x-adapter-platform.platformnextquery.md +1 -1
  5. package/docs/API-reference/api/x-adapter-platform.platformnextquery.source.md +1 -1
  6. package/docs/API-reference/api/x-adapter-platform.platformrelatedtag.md +1 -1
  7. package/docs/API-reference/api/x-adapter-platform.platformrelatedtag.source.md +1 -1
  8. package/docs/API-reference/api/x-components.basecurrency.md +10 -25
  9. package/docs/API-reference/api/x-components.basepricefilterlabel.md +4 -6
  10. package/docs/API-reference/api/x-components.baseresultcurrentprice.md +9 -3
  11. package/docs/API-reference/api/x-components.baseresultpreviousprice.md +9 -3
  12. package/docs/API-reference/api/x-components.md +0 -15
  13. package/docs/API-reference/components/common/currency/x-components.base-currency.md +47 -140
  14. package/docs/API-reference/components/common/filters/labels/x-components.base-price-filter-label.md +43 -8
  15. package/docs/API-reference/components/common/result/x-components.base-result-current-price.md +30 -7
  16. package/docs/API-reference/components/common/result/x-components.base-result-previous-price.md +33 -7
  17. package/js/components/currency/base-currency.vue.js +5 -8
  18. package/js/components/currency/base-currency.vue.js.map +1 -1
  19. package/js/components/currency/base-currency.vue2.js +21 -63
  20. package/js/components/currency/base-currency.vue2.js.map +1 -1
  21. package/js/components/filters/labels/base-price-filter-label.vue.js +15 -4
  22. package/js/components/filters/labels/base-price-filter-label.vue.js.map +1 -1
  23. package/js/components/result/base-result-current-price.vue.js +2 -1
  24. package/js/components/result/base-result-current-price.vue.js.map +1 -1
  25. package/js/components/result/base-result-current-price.vue2.js +9 -13
  26. package/js/components/result/base-result-current-price.vue2.js.map +1 -1
  27. package/js/components/result/base-result-previous-price.vue.js +2 -1
  28. package/js/components/result/base-result-previous-price.vue.js.map +1 -1
  29. package/js/components/result/base-result-previous-price.vue2.js +9 -12
  30. package/js/components/result/base-result-previous-price.vue2.js.map +1 -1
  31. package/js/index.js +0 -1
  32. package/js/index.js.map +1 -1
  33. package/package.json +3 -3
  34. package/report/x-adapter-platform.api.json +2 -2
  35. package/report/x-components.api.json +294 -85
  36. package/report/x-components.api.md +33 -20
  37. package/types/src/components/currency/base-currency.vue.d.ts +27 -43
  38. package/types/src/components/currency/base-currency.vue.d.ts.map +1 -1
  39. package/types/src/components/filters/labels/base-price-filter-label.vue.d.ts +26 -8
  40. package/types/src/components/filters/labels/base-price-filter-label.vue.d.ts.map +1 -1
  41. package/types/src/components/result/base-result-current-price.vue.d.ts +21 -27
  42. package/types/src/components/result/base-result-current-price.vue.d.ts.map +1 -1
  43. package/types/src/components/result/base-result-previous-price.vue.d.ts +21 -25
  44. package/types/src/components/result/base-result-previous-price.vue.d.ts.map +1 -1
  45. package/types/src/utils/index.d.ts +0 -1
  46. package/types/src/utils/index.d.ts.map +1 -1
  47. package/docs/API-reference/api/x-components.currencyformatter.md +0 -76
  48. package/js/utils/currency-formatter.js +0 -121
  49. package/js/utils/currency-formatter.js.map +0 -1
  50. package/types/src/utils/currency-formatter.d.ts +0 -30
  51. package/types/src/utils/currency-formatter.d.ts.map +0 -1
package/CHANGELOG.md CHANGED
@@ -3,6 +3,25 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [7.0.1](https://github.com/empathyco/x/compare/@empathyco/x-components@7.0.0...@empathyco/x-components@7.0.1) (2026-05-29)
7
+
8
+ **Note:** Version bump only for package @empathyco/x-components
9
+
10
+
11
+
12
+
13
+
14
+ ## [7.0.0](https://github.com/empathyco/x/compare/@empathyco/x-components@6.3.2...@empathyco/x-components@7.0.0) (2026-05-25)
15
+
16
+ ### ⚠ BREAKING CHANGES
17
+
18
+ * **currency:** Currency components props and simplified usage by default.
19
+
20
+ ### Code Refactoring
21
+
22
+ * **currency:** remove currency-formatter utils, tests, and related format props in components (#2109)
23
+
24
+
6
25
  ## [6.3.2](https://github.com/empathyco/x/compare/@empathyco/x-components@6.3.1...@empathyco/x-components@6.3.2) (2026-05-25)
7
26
 
8
27
  **Note:** Version bump only for package @empathyco/x-components
package/core/index.js CHANGED
@@ -175,7 +175,6 @@ export { AnimationProp } from '../js/types/animation-prop.js';
175
175
  export { arrayToObject, createEmitterArrayFilter, deepFilter, deepFlat, groupItemsBy, isArrayEmpty } from '../js/utils/array.js';
176
176
  export { CancelSymbol, cancellablePromise } from '../js/utils/cancellable-promise.js';
177
177
  export { clone } from '../js/utils/clone.js';
178
- export { currencyFormatter } from '../js/utils/currency-formatter.js';
179
178
  export { debounce as debounceFunction } from '../js/utils/debounce.js';
180
179
  export { areFiltersDifferent, createRawFilters } from '../js/utils/filters.js';
181
180
  export { FOCUSABLE_SELECTORS } from '../js/utils/focus.js';
package/core/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -79,7 +79,7 @@ string
79
79
 
80
80
  </td><td>
81
81
 
82
- 'ORGANIC' \| 'CURATED'
82
+ 'ORGANIC' \| 'CURATED' \| 'SYNTHETIC'
83
83
 
84
84
 
85
85
  </td><td>
@@ -7,5 +7,5 @@
7
7
  **Signature:**
8
8
 
9
9
  ```typescript
10
- source: 'ORGANIC' | 'CURATED';
10
+ source: 'ORGANIC' | 'CURATED' | 'SYNTHETIC';
11
11
  ```
@@ -79,7 +79,7 @@ string
79
79
 
80
80
  </td><td>
81
81
 
82
- 'ORGANIC' \| 'CURATED'
82
+ 'ORGANIC' \| 'CURATED' \| 'SYNTHETIC'
83
83
 
84
84
 
85
85
  </td><td>
@@ -7,5 +7,5 @@
7
7
  **Signature:**
8
8
 
9
9
  ```typescript
10
- source: 'ORGANIC' | 'CURATED';
10
+ source: 'ORGANIC' | 'CURATED' | 'SYNTHETIC';
11
11
  ```
@@ -4,10 +4,6 @@
4
4
 
5
5
  ## BaseCurrency variable
6
6
 
7
- Renders the value received as a property which always must be a JavaScript number, with the proper format provided as a string property or by injection. The rendered tag is a span in order to render a default inline HTML element.
8
-
9
- Regarding the format or mask to be defined as string: - Use 'i' to define integer numbers. - Use 'd' to define decimal numbers. You can define the length of the decimal part. If the format doesn't include decimals, it is filled with zeros until reach the length defined with 'd's. - Integer separator must be defined between the 3rd and the 4th integer 'i' of a group. - Decimal separator must be defined between the last 'i' and the first 'd'. It can be more than one character. - If you want to hide the decimal part if it's zero, you can add the `?` symbol after the decimal characters (e.g. 'i.iii,dd?', for `1234` you would get `1.234` instead of `1.234,00`<!-- -->). - Set whatever you need around the integers and decimals marks. - Default mask: 'i.iii,dd' which returns '1.345,67'.
10
-
11
7
  **Signature:**
12
8
 
13
9
  ```typescript
@@ -16,35 +12,24 @@ _default: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
16
12
  type: NumberConstructor;
17
13
  required: true;
18
14
  };
15
+ currency: StringConstructor;
19
16
  format: {
20
- type: StringConstructor;
17
+ type: PropType<Omit<Intl.NumberFormatOptions, "currency" | "style">>;
18
+ default: () => {};
21
19
  };
22
20
  }>, {
23
- currency: import("vue").ComputedRef<string>;
21
+ currencyText: import("vue").ComputedRef<string>;
24
22
  }, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
25
23
  value: {
26
24
  type: NumberConstructor;
27
25
  required: true;
28
26
  };
27
+ currency: StringConstructor;
29
28
  format: {
30
- type: StringConstructor;
29
+ type: PropType<Omit<Intl.NumberFormatOptions, "currency" | "style">>;
30
+ default: () => {};
31
31
  };
32
- }>> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>
32
+ }>> & Readonly<{}>, {
33
+ format: Omit<Intl.NumberFormatOptions, "currency" | "style">;
34
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>
33
35
  ```
34
-
35
- ## Remarks
36
-
37
- The number of 'd', which is the maximum decimal length, MUST matches with the length of decimals provided from the adapter. Otherwise, when the component truncate the decimal part, it deletes significant digits.
38
-
39
- Basic example:
40
-
41
- ```vue
42
- <BaseCurrency
43
- :value="123456.789"
44
- format="i.iiii,dddd €"
45
- />
46
- ```
47
- It will render: `123.456,7890 €`<!-- -->.
48
-
49
- See docs below for more examples.
50
-
@@ -16,9 +16,8 @@ _default: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
16
16
  }>;
17
17
  required: true;
18
18
  };
19
- format: {
20
- type: StringConstructor;
21
- };
19
+ currency: StringConstructor;
20
+ format: PropType<Omit<Intl.NumberFormatOptions, "currency" | "style">>;
22
21
  lessThan: {
23
22
  type: StringConstructor;
24
23
  required: true;
@@ -40,9 +39,8 @@ _default: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
40
39
  }>;
41
40
  required: true;
42
41
  };
43
- format: {
44
- type: StringConstructor;
45
- };
42
+ currency: StringConstructor;
43
+ format: PropType<Omit<Intl.NumberFormatOptions, "currency" | "style">>;
46
44
  lessThan: {
47
45
  type: StringConstructor;
48
46
  required: true;
@@ -14,8 +14,10 @@ _default: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
14
14
  type: PropType<Result>;
15
15
  required: true;
16
16
  };
17
+ currency: StringConstructor;
17
18
  format: {
18
- type: StringConstructor;
19
+ type: PropType<Omit<Intl.NumberFormatOptions, "currency" | "style">>;
20
+ default: () => {};
19
21
  };
20
22
  }>, {
21
23
  dynamicClasses: import("vue").ComputedRef<VueCSSClasses>;
@@ -24,10 +26,14 @@ _default: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
24
26
  type: PropType<Result>;
25
27
  required: true;
26
28
  };
29
+ currency: StringConstructor;
27
30
  format: {
28
- type: StringConstructor;
31
+ type: PropType<Omit<Intl.NumberFormatOptions, "currency" | "style">>;
32
+ default: () => {};
29
33
  };
30
- }>> & Readonly<{}>, {}, {}, {
34
+ }>> & Readonly<{}>, {
35
+ format: Omit<Intl.NumberFormatOptions, "currency" | "style">;
36
+ }, {}, {
31
37
  BaseCurrency: import("vue").DefineComponent<{}, {}, any>;
32
38
  }, {}, string, import("vue").ComponentProvideOptions, true, {}, any>
33
39
  ```
@@ -14,18 +14,24 @@ _default: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
14
14
  type: PropType<Result>;
15
15
  required: true;
16
16
  };
17
+ currency: StringConstructor;
17
18
  format: {
18
- type: StringConstructor;
19
+ type: PropType<Omit<Intl.NumberFormatOptions, "currency" | "style">>;
20
+ default: () => {};
19
21
  };
20
22
  }>, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
21
23
  result: {
22
24
  type: PropType<Result>;
23
25
  required: true;
24
26
  };
27
+ currency: StringConstructor;
25
28
  format: {
26
- type: StringConstructor;
29
+ type: PropType<Omit<Intl.NumberFormatOptions, "currency" | "style">>;
30
+ default: () => {};
27
31
  };
28
- }>> & Readonly<{}>, {}, {}, {
32
+ }>> & Readonly<{}>, {
33
+ format: Omit<Intl.NumberFormatOptions, "currency" | "style">;
34
+ }, {}, {
29
35
  BaseCurrency: import("vue").DefineComponent<{}, {}, any>;
30
36
  }, {}, string, import("vue").ComponentProvideOptions, true, {}, any>
31
37
  ```
@@ -534,17 +534,6 @@ Creates a wire that executes the function passed. This function will receive a [
534
534
  Util function to generate type-safe wiring. If TypeScript ever accepts the PR about generic type inference this function can be removed.
535
535
 
536
536
 
537
- </td></tr>
538
- <tr><td>
539
-
540
- [currencyFormatter(value, format)](./x-components.currencyformatter.md)
541
-
542
-
543
- </td><td>
544
-
545
- Format a value with a given format.
546
-
547
-
548
537
  </td></tr>
549
538
  <tr><td>
550
539
 
@@ -3774,10 +3763,6 @@ Additionally, this component exposes the following props to modify the classes o
3774
3763
 
3775
3764
  </td><td>
3776
3765
 
3777
- Renders the value received as a property which always must be a JavaScript number, with the proper format provided as a string property or by injection. The rendered tag is a span in order to render a default inline HTML element.
3778
-
3779
- Regarding the format or mask to be defined as string: - Use 'i' to define integer numbers. - Use 'd' to define decimal numbers. You can define the length of the decimal part. If the format doesn't include decimals, it is filled with zeros until reach the length defined with 'd's. - Integer separator must be defined between the 3rd and the 4th integer 'i' of a group. - Decimal separator must be defined between the last 'i' and the first 'd'. It can be more than one character. - If you want to hide the decimal part if it's zero, you can add the `?` symbol after the decimal characters (e.g. 'i.iii,dd?', for `1234` you would get `1.234` instead of `1.234,00`<!-- -->). - Set whatever you need around the integers and decimals marks. - Default mask: 'i.iii,dd' which returns '1.345,67'.
3780
-
3781
3766
 
3782
3767
  </td></tr>
3783
3768
  <tr><td>
@@ -6,43 +6,26 @@ title: BaseCurrency
6
6
 
7
7
  # BaseCurrency
8
8
 
9
- Renders the value received as a property which always must be a JavaScript number, with the
10
- proper format provided as a string property or by injection. The rendered tag is a span in
11
- order to render a default inline HTML element.
12
-
13
- Regarding the format or mask to be defined as string:
14
-
15
- - Use 'i' to define integer numbers.
16
- - Use 'd' to define decimal numbers. You can define the length of the decimal part. If the
17
- format doesn't include decimals, it is filled with zeros until reach the length defined with
18
- 'd's.
19
- - Integer separator must be defined between the 3rd and the 4th integer 'i' of a group.
20
- - Decimal separator must be defined between the last 'i' and the first 'd'. It can be more
21
- than one character.
22
- - If you want to hide the decimal part if it's zero, you can add the `?` symbol after the
23
- decimal characters (e.g. 'i.iii,dd?', for `1234` you would get `1.234` instead of `1.234,00`).
24
- - Set whatever you need around the integers and decimals marks.
25
- - Default mask: 'i.iii,dd' which returns '1.345,67'.
26
-
27
9
  ## Props
28
10
 
29
- | Name | Description | Type | Default |
30
- | ------------------- | ------------------------------ | ------------------- | ------------- |
31
- | <code>value</code> | Numeric value to be formatted. | <code>number</code> | <code></code> |
32
- | <code>format</code> | The format as string. | <code>string</code> | <code></code> |
11
+ | Name | Description | Type | Default |
12
+ | --------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------ | ----------------------- |
13
+ | <code>value</code> | Numeric value to be formatted. | <code>number</code> | <code></code> |
14
+ | <code>currency</code> | The ISO 4217 currency value. If not specified we use snippetConfig.currency | <code>string</code> | <code></code> |
15
+ | <code>format</code> | The currency format possibilities from Intl.NumberFormatOptions.<br />Allows customization of decimal places, grouping, etc.<br />Note: 'currency' and 'style' options are managed internally. | <code>Omit<Intl.NumberFormatOptions, 'currency' \| 'style'></code> | <code>() => ({})</code> |
33
16
 
34
17
  ## Example
35
18
 
36
- Renders the value received as a property, which always must be a JavaScript number, with the proper
37
- format provided as string property. The rendered tag is a span in order to render a default inline
38
- HTML element.
19
+ Renders the value received as a property, which always must be a JavaScript number, formatted
20
+ using the Intl.NumberFormat API with ISO 4217 currency codes. The rendered tag is a span in order
21
+ to render a default inline HTML element.
39
22
 
40
23
  ### Basic usage
41
24
 
42
25
  ```vue
43
26
  <template>
44
- <BaseCurrency :value="12345678.87654321" />
45
- <!-- output: '12.345.678,87' -->
27
+ <BaseCurrency :value="12345678.87654321" currency="EUR" />
28
+ <!-- output depends on locale, e.g., '12.345.678,88 €' for es-ES -->
46
29
  </template>
47
30
 
48
31
  <script setup>
@@ -50,21 +33,16 @@ import BaseCurrency from "@empathyco/x-components/js/components/currency/base-cu
50
33
  </script>
51
34
  ```
52
35
 
53
- ```vue
54
- <template>
55
- <BaseCurrency :value="12345678.87654321" format="i.iii,ddd? €" />
56
- <!-- output: '12.345.678,876 €' -->
57
- </template>
58
-
59
- <script setup>
60
- import BaseCurrency from "@empathyco/x-components/js/components/currency/base-currency.vue";
61
- </script>
62
- ```
36
+ ### Customizing decimal places
63
37
 
64
38
  ```vue
65
39
  <template>
66
- <BaseCurrency :value="12345678" format="i.iii,ddd? €" />
67
- <!-- output: '12.345.678 €' -->
40
+ <BaseCurrency
41
+ :value="12345678.87654321"
42
+ currency="USD"
43
+ :format="{ minimumFractionDigits: 3, maximumFractionDigits: 3 }"
44
+ />
45
+ <!-- output: '$12,345,678.877' for en-US locale -->
68
46
  </template>
69
47
 
70
48
  <script setup>
@@ -72,21 +50,16 @@ import BaseCurrency from "@empathyco/x-components/js/components/currency/base-cu
72
50
  </script>
73
51
  ```
74
52
 
75
- ```vue
76
- <template>
77
- <BaseCurrency :value="12345678.87654321" format="$ i.iii,dd" />
78
- <!-- output: '$ 12.345.678,87' -->
79
- </template>
80
-
81
- <script setup>
82
- import BaseCurrency from "@empathyco/x-components/js/components/currency/base-currency.vue";
83
- </script>
84
- ```
53
+ ### No decimal places
85
54
 
86
55
  ```vue
87
56
  <template>
88
- <BaseCurrency :value="12345678.87654321" format="$i.iii,dd" />
89
- <!-- output: '$12.345.678,87' -->
57
+ <BaseCurrency
58
+ :value="12345678.87"
59
+ currency="EUR"
60
+ :format="{ minimumFractionDigits: 0, maximumFractionDigits: 0 }"
61
+ />
62
+ <!-- output: '12.345.679 €' for es-ES locale (rounds up) -->
90
63
  </template>
91
64
 
92
65
  <script setup>
@@ -94,21 +67,20 @@ import BaseCurrency from "@empathyco/x-components/js/components/currency/base-cu
94
67
  </script>
95
68
  ```
96
69
 
97
- ```vue
98
- <template>
99
- <BaseCurrency :value="12345678.87654321" format="i.iii,dd €" />
100
- <!-- output: '12.345.678,87 €' -->
101
- </template>
102
-
103
- <script setup>
104
- import BaseCurrency from "@empathyco/x-components/js/components/currency/base-currency.vue";
105
- </script>
106
- ```
70
+ ### Using different currencies
107
71
 
108
72
  ```vue
109
73
  <template>
110
- <BaseCurrency :value="12345678.87654321" format="i.iii,dd€" />
111
- <!-- output: '12.345.678,87€' -->
74
+ <div>
75
+ <BaseCurrency :value="1234.56" currency="USD" />
76
+ <!-- output: '$1,234.56' for en-US -->
77
+ <BaseCurrency :value="1234.56" currency="EUR" />
78
+ <!-- output: '1.234,56 €' for es-ES -->
79
+ <BaseCurrency :value="1234.56" currency="GBP" />
80
+ <!-- output: '£1,234.56' for en-GB -->
81
+ <BaseCurrency :value="1234.56" currency="JPY" />
82
+ <!-- output: '¥1,235' for ja-JP -->
83
+ </div>
112
84
  </template>
113
85
 
114
86
  <script setup>
@@ -116,90 +88,25 @@ import BaseCurrency from "@empathyco/x-components/js/components/currency/base-cu
116
88
  </script>
117
89
  ```
118
90
 
119
- ```vue
120
- <template>
121
- <BaseCurrency :value="12345678.87654321" format="i,iii.dd €" />
122
- <!-- output: '12,345,678.87 €' -->
123
- </template>
91
+ ### Advanced formatting options
124
92
 
125
- <script setup>
126
- import BaseCurrency from "@empathyco/x-components/js/components/currency/base-currency.vue";
127
- </script>
128
- ```
93
+ You can pass any valid Intl.NumberFormatOptions (except 'currency' and 'style' which are managed
94
+ internally):
129
95
 
130
96
  ```vue
131
97
  <template>
132
- <BaseCurrency :value="12345678.87654321" format="i iii.dd €" />
133
- <!-- output: '12 345 678.87 €' -->
98
+ <BaseCurrency
99
+ :value="1234567.89"
100
+ currency="EUR"
101
+ :format="{
102
+ minimumFractionDigits: 2,
103
+ maximumFractionDigits: 4,
104
+ useGrouping: true,
105
+ }"
106
+ />
134
107
  </template>
135
108
 
136
109
  <script setup>
137
110
  import BaseCurrency from "@empathyco/x-components/js/components/currency/base-currency.vue";
138
111
  </script>
139
112
  ```
140
-
141
- ```vue
142
- <template>
143
- <BaseCurrency :value="12345678.87654321" format="i iii - dd €" />
144
- <!-- output: '12 345 678 - 87 €' -->
145
- </template>
146
-
147
- <script setup>
148
- import BaseCurrency from "@empathyco/x-components/js/components/currency/base-currency.vue";
149
- </script>
150
- ```
151
-
152
- ```vue
153
- <template>
154
- <BaseCurrency :value="12345678.87654321" format="i.iii,dddddd €" />
155
- <!-- output: '12.345.678,876543 €' -->
156
- </template>
157
-
158
- <script setup>
159
- import BaseCurrency from "@empathyco/x-components/js/components/currency/base-currency.vue";
160
- </script>
161
- ```
162
-
163
- ```vue
164
- <template>
165
- <BaseCurrency :value="12345678.87" format="i.iii,dddddd €" />
166
- <!-- output: '12.345.678,870000 €' -->
167
- </template>
168
-
169
- <script setup>
170
- import BaseCurrency from "@empathyco/x-components/js/components/currency/base-currency.vue";
171
- </script>
172
- ```
173
-
174
- ```vue
175
- <template>
176
- <BaseCurrency :value="12345678" format="i.iii,dddddd €" />
177
- <!-- output: '12.345.678,000000 €' -->
178
- </template>
179
-
180
- <script setup>
181
- import BaseCurrency from "@empathyco/x-components/js/components/currency/base-currency.vue";
182
- </script>
183
- ```
184
-
185
- ```vue
186
- <template>
187
- <BaseCurrency :value="12345678.87654321" format="i.iii,dd €" />
188
- <!-- output: '12.345.678,87 €' -->
189
- </template>
190
-
191
- <script setup>
192
- import BaseCurrency from "@empathyco/x-components/js/components/currency/base-currency.vue";
193
- </script>
194
- ```
195
-
196
- ```vue
197
- <template>
198
- <BaseCurrency :value="12345678.87654321" format="i.iii €" />
199
- <!-- output: '12.345.678 €' -->
200
- </template>
201
-
202
- <script setup>
203
- import { BaseCurrency } from "@empathyco/x-components/js/components/currency/base-currency.vue";
204
- </script>
205
- ```
@@ -11,13 +11,14 @@ value of the filter.
11
11
 
12
12
  ## Props
13
13
 
14
- | Name | Description | Type | Default |
15
- | --------------------- | ---------------------------------------------------------------------- | ---------------------------------- | ------------- |
16
- | <code>filter</code> | The filter data for get min and max value. | <code>{ range: RangeValue }</code> | <code></code> |
17
- | <code>format</code> | Configuration for show the label. | <code>string</code> | <code></code> |
18
- | <code>lessThan</code> | Message shown when the filter hasn't got the min value defined. | <code>string</code> | <code></code> |
19
- | <code>fromTo</code> | Message shown when the filter has both the min and max values defined. | <code>string</code> | <code></code> |
20
- | <code>from</code> | Message shown when the filter hasn't got max value defined. | <code>string</code> | <code></code> |
14
+ | Name | Description | Type | Default |
15
+ | --------------------- | ---------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------ | ------------- |
16
+ | <code>filter</code> | The filter data for get min and max value. | <code>{ range: RangeValue }</code> | <code></code> |
17
+ | <code>currency</code> | An ISO 4217 currency value. | <code>string</code> | <code></code> |
18
+ | <code>format</code> | The currency format possibilities from Intl.NumberFormatOptions.<br />Allows customization of decimal places, grouping, etc. | <code>Omit<Intl.NumberFormatOptions, 'currency' \| 'style'></code> | <code></code> |
19
+ | <code>lessThan</code> | Message shown when the filter hasn't got the min value defined. | <code>string</code> | <code></code> |
20
+ | <code>fromTo</code> | Message shown when the filter has both the min and max values defined. | <code>string</code> | <code></code> |
21
+ | <code>from</code> | Message shown when the filter hasn't got max value defined. | <code>string</code> | <code></code> |
21
22
 
22
23
  ## Example
23
24
 
@@ -44,7 +45,41 @@ how the price should look like.
44
45
  <NumberRangeFilter :filter="filter" v-slot="{ filter }">
45
46
  <BasePriceFilterLabel
46
47
  :filter="filter"
47
- format="$i"
48
+ currency="USD"
49
+ lessThan="Less than {max}"
50
+ fromTo="From {min} to {max}"
51
+ from="More than {min}"
52
+ />
53
+ </NumberRangeFilter>
54
+ </Filters>
55
+ </template>
56
+ </Facets>
57
+ </template>
58
+
59
+ <script setup>
60
+ import BasePriceFilterLabel from "@empathyco/x-components/js/components/filters/labels/base-price-filter-label.vue";
61
+ import {
62
+ Filters,
63
+ Facets,
64
+ NumberRangeFilter,
65
+ } from "@empathyco/x-components/facets";
66
+ </script>
67
+ ```
68
+
69
+ ### Customizing format
70
+
71
+ You can customize the number formatting using the `format` prop with `Intl.NumberFormatOptions`:
72
+
73
+ ```vue
74
+ <template>
75
+ <Facets>
76
+ <template #price="{ facet }">
77
+ <Filters v-slot="{ filter }" :filters="facet.filters">
78
+ <NumberRangeFilter :filter="filter" v-slot="{ filter }">
79
+ <BasePriceFilterLabel
80
+ :filter="filter"
81
+ currency="EUR"
82
+ :format="{ minimumFractionDigits: 0, maximumFractionDigits: 0 }"
48
83
  lessThan="Less than {max}"
49
84
  fromTo="From {min} to {max}"
50
85
  from="More than {min}"
@@ -11,10 +11,11 @@ that may or may not be on sale.
11
11
 
12
12
  ## Props
13
13
 
14
- | Name | Description | Type | Default |
15
- | ------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------- | ------------- |
16
- | <code>result</code> | (Required) The @empathyco/x-types#Result information. | <code>Result</code> | <code></code> |
17
- | <code>format</code> | Format or mask to be defined as string.<br />- Use 'i' to define integer numbers.<br />- Use 'd' to define decimal numbers. You can define the length of the decimal part. If the<br />doesn't include decimals, it is filled with zeros until reach the length defined with 'd's.<br />- Integer separator must be defined between the 3rd and the 4th integer 'i' of a group.<br />- Decimal separator must be defined between the last 'i' and the first 'd'. It can be more<br />than one character.<br />- Set whatever you need around the integers and decimals marks.<br />- Default mask: 'i.iii,dd' which returns '1.345,67'. | <code>string</code> | <code></code> |
14
+ | Name | Description | Type | Default |
15
+ | --------------------- | ---------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------ | ----------------------- |
16
+ | <code>result</code> | (Required) The @empathyco/x-types#Result information. | <code>Result</code> | <code></code> |
17
+ | <code>currency</code> | Optional value coming from https://en.wikipedia.org/wiki/ISO_4217#List_of_ISO_4217_currency_codes. | <code>string</code> | <code></code> |
18
+ | <code>format</code> | The currency format possibilities from Intl.NumberFormatOptions.<br />Allows customization of decimal places, grouping, etc. | <code>Omit<Intl.NumberFormatOptions, 'currency' \| 'style'></code> | <code>() => ({})</code> |
18
19
 
19
20
  ## Slots
20
21
 
@@ -26,12 +27,12 @@ that may or may not be on sale.
26
27
 
27
28
  ### Basic example
28
29
 
29
- This component shows the current price formatted. You can provide the `format` by property or let
30
- the `BaseCurrency` component use an injected one.
30
+ This component shows the current price formatted. You can provide the `currency` and `format`
31
+ properties to customize the display.
31
32
 
32
33
  ```vue
33
34
  <template>
34
- <BaseResultCurrentPrice :result="result" :format="'i.iii,ddd €'" />
35
+ <BaseResultCurrentPrice :result="result" currency="USD" />
35
36
  </template>
36
37
 
37
38
  <script setup>
@@ -43,6 +44,28 @@ const result = {
43
44
  </script>
44
45
  ```
45
46
 
47
+ ### Customizing format
48
+
49
+ You can customize the number formatting using the `format` prop with `Intl.NumberFormatOptions`:
50
+
51
+ ```vue
52
+ <template>
53
+ <BaseResultCurrentPrice
54
+ :result="result"
55
+ currency="EUR"
56
+ :format="{ minimumFractionDigits: 2, maximumFractionDigits: 2 }"
57
+ />
58
+ </template>
59
+
60
+ <script setup>
61
+ import { BaseResultCurrentPrice } from "@empathyco/x-components";
62
+ const result = {
63
+ price: { value: 123.456, hasDiscount: false },
64
+ // ...other result properties
65
+ };
66
+ </script>
67
+ ```
68
+
46
69
  ### Overriding default slot
47
70
 
48
71
  ```vue