@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.
- package/CHANGELOG.md +19 -0
- package/core/index.js +0 -1
- package/core/index.js.map +1 -1
- package/docs/API-reference/api/x-adapter-platform.platformnextquery.md +1 -1
- package/docs/API-reference/api/x-adapter-platform.platformnextquery.source.md +1 -1
- package/docs/API-reference/api/x-adapter-platform.platformrelatedtag.md +1 -1
- package/docs/API-reference/api/x-adapter-platform.platformrelatedtag.source.md +1 -1
- package/docs/API-reference/api/x-components.basecurrency.md +10 -25
- package/docs/API-reference/api/x-components.basepricefilterlabel.md +4 -6
- package/docs/API-reference/api/x-components.baseresultcurrentprice.md +9 -3
- package/docs/API-reference/api/x-components.baseresultpreviousprice.md +9 -3
- package/docs/API-reference/api/x-components.md +0 -15
- package/docs/API-reference/components/common/currency/x-components.base-currency.md +47 -140
- package/docs/API-reference/components/common/filters/labels/x-components.base-price-filter-label.md +43 -8
- package/docs/API-reference/components/common/result/x-components.base-result-current-price.md +30 -7
- package/docs/API-reference/components/common/result/x-components.base-result-previous-price.md +33 -7
- package/js/components/currency/base-currency.vue.js +5 -8
- package/js/components/currency/base-currency.vue.js.map +1 -1
- package/js/components/currency/base-currency.vue2.js +21 -63
- package/js/components/currency/base-currency.vue2.js.map +1 -1
- package/js/components/filters/labels/base-price-filter-label.vue.js +15 -4
- package/js/components/filters/labels/base-price-filter-label.vue.js.map +1 -1
- package/js/components/result/base-result-current-price.vue.js +2 -1
- package/js/components/result/base-result-current-price.vue.js.map +1 -1
- package/js/components/result/base-result-current-price.vue2.js +9 -13
- package/js/components/result/base-result-current-price.vue2.js.map +1 -1
- package/js/components/result/base-result-previous-price.vue.js +2 -1
- package/js/components/result/base-result-previous-price.vue.js.map +1 -1
- package/js/components/result/base-result-previous-price.vue2.js +9 -12
- package/js/components/result/base-result-previous-price.vue2.js.map +1 -1
- package/js/index.js +0 -1
- package/js/index.js.map +1 -1
- package/package.json +3 -3
- package/report/x-adapter-platform.api.json +2 -2
- package/report/x-components.api.json +294 -85
- package/report/x-components.api.md +33 -20
- package/types/src/components/currency/base-currency.vue.d.ts +27 -43
- package/types/src/components/currency/base-currency.vue.d.ts.map +1 -1
- package/types/src/components/filters/labels/base-price-filter-label.vue.d.ts +26 -8
- package/types/src/components/filters/labels/base-price-filter-label.vue.d.ts.map +1 -1
- package/types/src/components/result/base-result-current-price.vue.d.ts +21 -27
- package/types/src/components/result/base-result-current-price.vue.d.ts.map +1 -1
- package/types/src/components/result/base-result-previous-price.vue.d.ts +21 -25
- package/types/src/components/result/base-result-previous-price.vue.d.ts.map +1 -1
- package/types/src/utils/index.d.ts +0 -1
- package/types/src/utils/index.d.ts.map +1 -1
- package/docs/API-reference/api/x-components.currencyformatter.md +0 -76
- package/js/utils/currency-formatter.js +0 -121
- package/js/utils/currency-formatter.js.map +0 -1
- package/types/src/utils/currency-formatter.d.ts +0 -30
- package/types/src/utils/currency-formatter.d.ts.map +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"currency-formatter.js","sources":["../../../src/utils/currency-formatter.ts"],"sourcesContent":["/**\n * Regex to detect the format.\n */\nconst FORMAT_REGEX = /(i([^id]+))?i+(([^id?]+)(d+)(\\?)?)?/\n\n/**\n * Configuration for format currency.\n */\ninterface CurrencyConfig {\n /** The character between a group of three integer 'i's and the following one. */\n integerSeparator: string\n /**\n * The character between a group of three integer 'i's and the following one. It also\n * supports more than one single character.\n */\n decimalSeparator: string\n /** Length of decimals numbers. It counts the number of 'd's after the integer part. */\n decimalsNumber: number\n /** Boolean value to hide or show the decimal part when it has 0. */\n hideIntegerDecimals: boolean\n}\n\n/**\n * Parts of number: integer and decimal.\n */\ninterface NumberParts {\n /** Integer part of the number as string. */\n integer: string\n /** Decimal part of the number as string. */\n decimal: string\n}\n\n/**\n * Format a value with a given format.\n *\n * @param value - Numeric value to be formatted.\n * @param format - Format or mask to be defined as string.\n *\n * @remarks\n * Format:\n * - Use 'i' to define integer numbers.\n * - Use 'd' to define decimal numbers. You can define the length of the decimal part. If the\n * doesn't include decimals, it is filled with zeros until reach the length defined with 'd's.\n * - Integer separator must be defined between the 3rd and the 4th integer 'i' of a group.\n * - Decimal separator must be defined between the last 'i' and the first 'd'. It can be more\n * than one character.\n * - Set whatever you need around the integers and decimals marks.\n * - Default mask: 'i.iii,dd' which returns '1.345,67'.\n * - If you want to hide the decimal part if it's zero (non significant), you can add the `?` symbol\n * after the decimal characters (e.g. 'i.iii,dd?', for `1234` you would get `1.234` instead of\n * `1.234,00`). It defines the value of `hideIntegerDecimals`:\n * - If true (exists) and the value is an integer without decimals, the decimal non significant\n * zeroes are hidden.\n * - If false, the default behaviour will fill with zeros the remaining length until getting\n * the one defined with the 'd's.\n *\n * @returns Formatted number.\n *\n * @public\n */\nexport function currencyFormatter(value: number, format = 'i.iii,dd'): string {\n const { integer, decimal } = numberParts(value)\n const { decimalSeparator, decimalsNumber, integerSeparator, hideIntegerDecimals } =\n currencyConfig(format)\n\n const formattedInteger = formatInteger(integer, integerSeparator)\n const formattedDecimal = formatDecimal(decimal, {\n decimalsNumber,\n hideIntegerDecimals,\n decimalSeparator,\n })\n return format.replace(FORMAT_REGEX, `${formattedInteger}${formattedDecimal}`)\n}\n\n/**\n * Returns the formatted integer part. This computed returns:\n * - integer part with the integer separator added.\n *\n * @param integer - Integer value as a string.\n * @param integerSeparator - Separator to apply in the integer side.\n *\n * The regexp adds the integer separator for each thousand group (each 3 numbers).\n *\n * @returns Formatted integer.\n *\n * @internal\n */\nfunction formatInteger(integer: string, integerSeparator: string): string {\n return integer.replace(/\\B(?=(\\d{3})+(?!\\d))/g, integerSeparator)\n}\n\n/**\n * Returns the formatted decimal. This computed returns:\n * - decimal part filled with zeros until complete remaining slots defined with the decimal\n * length in the format.\n * - decimal part truncated. The decimal numbers length, defined with the number of 'd's in the\n * format prop. This must MATCH with the number of decimals provided from the adapter.\n *\n * @param decimal - Decimal part as a string.\n * @param CurrencyConfig - From which the `decimalsNumber`, `decimalsSeparator` and\n * `hideIntegerDecimals` are obtained.\n * @param CurrencyConfig.decimalsNumber - decimalsNumber currency config.\n * @param CurrencyConfig.decimalSeparator - decimalSeparator currency config.\n * @param CurrencyConfig.hideIntegerDecimals - hideIntegerDecimals currency config.\n *\n * @returns Formatted integer.\n *\n * @internal\n */\nfunction formatDecimal(\n decimal: string,\n {\n decimalsNumber,\n decimalSeparator,\n hideIntegerDecimals,\n }: Omit<CurrencyConfig, 'integerSeparator'>,\n): string {\n return hideIntegerDecimals && !+decimal\n ? ''\n : `${decimalSeparator}${decimal.padEnd(decimalsNumber, '0').substring(0, decimalsNumber)}`\n}\n\n/**\n * Function that divide fhe format passed as value for get integerSeparator, decimalSeparator\n * and decimalsNumber.\n *\n * @param format - Format or mask to apply to the value.\n *\n * @returns Object with properties of the currency config.\n *\n * @internal\n */\nfunction currencyConfig(format: string): CurrencyConfig {\n const [\n ,\n ,\n integerSeparator = '',\n ,\n decimalSeparator = '',\n decimals = '',\n hideIntegerDecimals = '',\n ] = FORMAT_REGEX.exec(format) ?? []\n return {\n integerSeparator,\n decimalSeparator,\n decimalsNumber: decimals.length,\n hideIntegerDecimals: !!hideIntegerDecimals,\n }\n}\n\n/**\n * Divide the number in two parts by separator '.', one of them is the integer number and other\n * the decimals numbers.\n *\n * @param value - Numeric value to be formatted.\n *\n * @returns Parts of number.\n *\n * @internal\n */\nfunction numberParts(value: number): NumberParts {\n const [integer, decimal = ''] = `${value}`.split('.')\n return {\n integer,\n decimal,\n }\n}\n"],"names":[],"mappings":"AAAA;;AAEG;AACH,MAAM,YAAY,GAAG,qCAAqC;AA6B1D;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2BG;SACa,iBAAiB,CAAC,KAAa,EAAE,MAAM,GAAG,UAAU,EAAA;IAClE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG,WAAW,CAAC,KAAK,CAAC;AAC/C,IAAA,MAAM,E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;AASG;AACH,SAAS,WAAW,CAAC,KAAa,EAAA;AAChC,IAAA,MAAM,CAAC,OAAO,EAAE,OAAO,GAAG,EAAE,CAAC,GAAG,CAAA,EAAG,KAAK,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC;IACrD,OAAO;QACL,OAAO;QACP,OAAO;KACR;AACH;;;;"}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Format a value with a given format.
|
|
3
|
-
*
|
|
4
|
-
* @param value - Numeric value to be formatted.
|
|
5
|
-
* @param format - Format or mask to be defined as string.
|
|
6
|
-
*
|
|
7
|
-
* @remarks
|
|
8
|
-
* Format:
|
|
9
|
-
* - Use 'i' to define integer numbers.
|
|
10
|
-
* - Use 'd' to define decimal numbers. You can define the length of the decimal part. If the
|
|
11
|
-
* doesn't include decimals, it is filled with zeros until reach the length defined with 'd's.
|
|
12
|
-
* - Integer separator must be defined between the 3rd and the 4th integer 'i' of a group.
|
|
13
|
-
* - Decimal separator must be defined between the last 'i' and the first 'd'. It can be more
|
|
14
|
-
* than one character.
|
|
15
|
-
* - Set whatever you need around the integers and decimals marks.
|
|
16
|
-
* - Default mask: 'i.iii,dd' which returns '1.345,67'.
|
|
17
|
-
* - If you want to hide the decimal part if it's zero (non significant), you can add the `?` symbol
|
|
18
|
-
* after the decimal characters (e.g. 'i.iii,dd?', for `1234` you would get `1.234` instead of
|
|
19
|
-
* `1.234,00`). It defines the value of `hideIntegerDecimals`:
|
|
20
|
-
* - If true (exists) and the value is an integer without decimals, the decimal non significant
|
|
21
|
-
* zeroes are hidden.
|
|
22
|
-
* - If false, the default behaviour will fill with zeros the remaining length until getting
|
|
23
|
-
* the one defined with the 'd's.
|
|
24
|
-
*
|
|
25
|
-
* @returns Formatted number.
|
|
26
|
-
*
|
|
27
|
-
* @public
|
|
28
|
-
*/
|
|
29
|
-
export declare function currencyFormatter(value: number, format?: string): string;
|
|
30
|
-
//# sourceMappingURL=currency-formatter.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"currency-formatter.d.ts","sourceRoot":"","sources":["../../../../src/utils/currency-formatter.ts"],"names":[],"mappings":"AAgCA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,SAAa,GAAG,MAAM,CAY5E"}
|