@empathyco/x-components 3.0.0-alpha.364 → 3.0.0-alpha.366
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 +26 -0
- package/design-system/deprecated-full-theme.css +71 -71
- package/docs/API-reference/api/x-components.baseaddtocart.md +14 -11
- package/docs/API-reference/api/x-components.baseheadertogglepanel.animation.md +1 -1
- package/docs/API-reference/api/x-components.baseheadertogglepanel.md +1 -1
- package/docs/API-reference/api/x-components.basepricefilterlabel.md +46 -21
- package/docs/API-reference/api/x-components.baseratingfilterlabel.md +24 -11
- package/docs/API-reference/api/x-components.baseresultcurrentprice.md +20 -11
- package/docs/API-reference/api/x-components.baseresultimage.md +50 -13
- package/docs/API-reference/api/x-components.baseresultlink.md +15 -10
- package/docs/API-reference/api/x-components.baseresultpreviousprice.md +18 -11
- package/docs/API-reference/api/x-components.baseresultrating.md +20 -11
- package/docs/API-reference/api/x-components.basetogglepanel.md +24 -11
- package/docs/API-reference/api/x-components.md +9 -9
- package/js/components/filters/labels/base-price-filter-label.vue.js.map +1 -1
- package/js/components/filters/labels/base-price-filter-label.vue_rollup-plugin-vue_script.vue.js +79 -60
- package/js/components/filters/labels/base-price-filter-label.vue_rollup-plugin-vue_script.vue.js.map +1 -1
- package/js/components/filters/labels/base-rating-filter-label.vue.js.map +1 -1
- package/js/components/filters/labels/base-rating-filter-label.vue_rollup-plugin-vue_script.vue.js +41 -29
- package/js/components/filters/labels/base-rating-filter-label.vue_rollup-plugin-vue_script.vue.js.map +1 -1
- package/js/components/panels/base-header-toggle-panel.vue.js +1 -1
- package/js/components/panels/base-header-toggle-panel.vue.js.map +1 -1
- package/js/components/panels/base-header-toggle-panel.vue_rollup-plugin-vue_script.vue.js.map +1 -1
- package/js/components/panels/base-header-toggle-panel.vue_rollup-plugin-vue_styles.0.vue.js +1 -1
- package/js/components/panels/base-toggle-panel.vue.js.map +1 -1
- package/js/components/panels/base-toggle-panel.vue_rollup-plugin-vue_script.vue.js +25 -15
- package/js/components/panels/base-toggle-panel.vue_rollup-plugin-vue_script.vue.js.map +1 -1
- package/js/components/result/base-result-add-to-cart.vue.js.map +1 -1
- package/js/components/result/base-result-add-to-cart.vue_rollup-plugin-vue_script.vue.js +29 -23
- package/js/components/result/base-result-add-to-cart.vue_rollup-plugin-vue_script.vue.js.map +1 -1
- package/js/components/result/base-result-current-price.vue.js.map +1 -1
- package/js/components/result/base-result-current-price.vue_rollup-plugin-vue_script.vue.js +47 -26
- package/js/components/result/base-result-current-price.vue_rollup-plugin-vue_script.vue.js.map +1 -1
- package/js/components/result/base-result-image.vue.js +1 -1
- package/js/components/result/base-result-image.vue.js.map +1 -1
- package/js/components/result/base-result-image.vue_rollup-plugin-vue_script.vue.js +125 -96
- package/js/components/result/base-result-image.vue_rollup-plugin-vue_script.vue.js.map +1 -1
- package/js/components/result/base-result-image.vue_rollup-plugin-vue_styles.0.vue.js +1 -1
- package/js/components/result/base-result-link.vue.js +2 -1
- package/js/components/result/base-result-link.vue.js.map +1 -1
- package/js/components/result/base-result-link.vue_rollup-plugin-vue_script.vue.js +46 -27
- package/js/components/result/base-result-link.vue_rollup-plugin-vue_script.vue.js.map +1 -1
- package/js/components/result/base-result-link.vue_rollup-plugin-vue_styles.0.vue.js +1 -1
- package/js/components/result/base-result-previous-price.vue.js.map +1 -1
- package/js/components/result/base-result-previous-price.vue_rollup-plugin-vue_script.vue.js +34 -17
- package/js/components/result/base-result-previous-price.vue_rollup-plugin-vue_script.vue.js.map +1 -1
- package/js/components/result/base-result-rating.vue.js +2 -1
- package/js/components/result/base-result-rating.vue.js.map +1 -1
- package/js/components/result/base-result-rating.vue_rollup-plugin-vue_script.vue.js +44 -27
- package/js/components/result/base-result-rating.vue_rollup-plugin-vue_script.vue.js.map +1 -1
- package/js/components/result/base-result-rating.vue_rollup-plugin-vue_styles.0.vue.js +1 -1
- package/js/utils/options-api.js +4 -0
- package/js/utils/options-api.js.map +1 -0
- package/package.json +6 -6
- package/report/x-components.api.json +3107 -1695
- package/report/x-components.api.md +228 -82
- package/types/components/filters/labels/base-price-filter-label.vue.d.ts +59 -13
- package/types/components/filters/labels/base-price-filter-label.vue.d.ts.map +1 -1
- package/types/components/filters/labels/base-rating-filter-label.vue.d.ts +33 -11
- package/types/components/filters/labels/base-rating-filter-label.vue.d.ts.map +1 -1
- package/types/components/panels/base-header-toggle-panel.vue.d.ts +2 -1
- package/types/components/panels/base-header-toggle-panel.vue.d.ts.map +1 -1
- package/types/components/panels/base-toggle-panel.vue.d.ts +35 -5
- package/types/components/panels/base-toggle-panel.vue.d.ts.map +1 -1
- package/types/components/result/base-result-add-to-cart.vue.d.ts +16 -8
- package/types/components/result/base-result-add-to-cart.vue.d.ts.map +1 -1
- package/types/components/result/base-result-current-price.vue.d.ts +40 -10
- package/types/components/result/base-result-current-price.vue.d.ts.map +1 -1
- package/types/components/result/base-result-image.vue.d.ts +60 -70
- package/types/components/result/base-result-image.vue.d.ts.map +1 -1
- package/types/components/result/base-result-link.vue.d.ts +18 -23
- package/types/components/result/base-result-link.vue.d.ts.map +1 -1
- package/types/components/result/base-result-previous-price.vue.d.ts +40 -5
- package/types/components/result/base-result-previous-price.vue.d.ts.map +1 -1
- package/types/components/result/base-result-rating.vue.d.ts +28 -9
- package/types/components/result/base-result-rating.vue.d.ts.map +1 -1
- package/types/utils/options-api.d.ts +3 -0
- package/types/utils/options-api.d.ts.map +1 -0
- package/docs/API-reference/api/x-components.baseaddtocart.events.md +0 -13
- package/docs/API-reference/api/x-components.baseaddtocart.result.md +0 -13
- package/docs/API-reference/api/x-components.basepricefilterlabel.filter.md +0 -15
- package/docs/API-reference/api/x-components.basepricefilterlabel.format.md +0 -13
- package/docs/API-reference/api/x-components.basepricefilterlabel.from.md +0 -13
- package/docs/API-reference/api/x-components.basepricefilterlabel.fromto.md +0 -13
- package/docs/API-reference/api/x-components.basepricefilterlabel.label.md +0 -13
- package/docs/API-reference/api/x-components.basepricefilterlabel.lessthan.md +0 -13
- package/docs/API-reference/api/x-components.basepricefilterlabel.render.md +0 -22
- package/docs/API-reference/api/x-components.baseratingfilterlabel.filter.md +0 -13
- package/docs/API-reference/api/x-components.baseratingfilterlabel.max.md +0 -13
- package/docs/API-reference/api/x-components.baseresultcurrentprice.format.md +0 -18
- package/docs/API-reference/api/x-components.baseresultcurrentprice.result.md +0 -13
- package/docs/API-reference/api/x-components.baseresultimage.hoveranimation.md +0 -13
- package/docs/API-reference/api/x-components.baseresultimage.loadanimation.md +0 -13
- package/docs/API-reference/api/x-components.baseresultimage.result.md +0 -13
- package/docs/API-reference/api/x-components.baseresultimage.shownextimageonhover.md +0 -13
- package/docs/API-reference/api/x-components.baseresultlink.result.md +0 -13
- package/docs/API-reference/api/x-components.baseresultpreviousprice.format.md +0 -18
- package/docs/API-reference/api/x-components.baseresultpreviousprice.result.md +0 -13
- package/docs/API-reference/api/x-components.baseresultrating.link.md +0 -13
- package/docs/API-reference/api/x-components.baseresultrating.result.md +0 -13
- package/docs/API-reference/api/x-components.basetogglepanel.animation.md +0 -13
- package/docs/API-reference/api/x-components.basetogglepanel.open.md +0 -13
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import Vue from 'vue';
|
|
3
|
-
import { Prop, Component } from 'vue-property-decorator';
|
|
1
|
+
import { defineComponent, computed } from 'vue';
|
|
4
2
|
import __vue_component__ from '../base-event-button.vue.js';
|
|
5
3
|
|
|
6
4
|
/**
|
|
@@ -9,27 +7,35 @@ import __vue_component__ from '../base-event-button.vue.js';
|
|
|
9
7
|
*
|
|
10
8
|
* @public
|
|
11
9
|
*/
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
10
|
+
var script = defineComponent({
|
|
11
|
+
components: { BaseEventButton: __vue_component__ },
|
|
12
|
+
props: {
|
|
13
|
+
/**
|
|
14
|
+
* (Required) The {@link @empathyco/x-types#Result | result} information.
|
|
15
|
+
*
|
|
16
|
+
* @public
|
|
17
|
+
*/
|
|
18
|
+
result: {
|
|
19
|
+
type: Object,
|
|
20
|
+
required: true
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
setup(props) {
|
|
24
|
+
/**
|
|
25
|
+
* The events to be emitted by the button.
|
|
26
|
+
*
|
|
27
|
+
* @returns Events {@link XEventsTypes} to emit.
|
|
28
|
+
*
|
|
29
|
+
* @public
|
|
30
|
+
*/
|
|
31
|
+
const events = computed(() => ({
|
|
32
|
+
UserClickedResultAddToCart: props.result
|
|
33
|
+
}));
|
|
34
|
+
return {
|
|
35
|
+
events
|
|
36
|
+
};
|
|
22
37
|
}
|
|
23
|
-
};
|
|
24
|
-
__decorate([
|
|
25
|
-
Prop({ required: true })
|
|
26
|
-
], BaseResultAddToCart.prototype, "result", void 0);
|
|
27
|
-
BaseResultAddToCart = __decorate([
|
|
28
|
-
Component({
|
|
29
|
-
components: { BaseEventButton: __vue_component__ }
|
|
30
|
-
})
|
|
31
|
-
], BaseResultAddToCart);
|
|
32
|
-
var script = BaseResultAddToCart;
|
|
38
|
+
});
|
|
33
39
|
|
|
34
40
|
export { script as default };
|
|
35
41
|
//# sourceMappingURL=base-result-add-to-cart.vue_rollup-plugin-vue_script.vue.js.map
|
package/js/components/result/base-result-add-to-cart.vue_rollup-plugin-vue_script.vue.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base-result-add-to-cart.vue_rollup-plugin-vue_script.vue.js","sources":["../../../../src/components/result/base-result-add-to-cart.vue?rollup-plugin-vue=script.ts"],"sourcesContent":["\n\n\n\n\n\n\n\n\n\n\n\n\n import { Result } from '@empathyco/x-types';\n import
|
|
1
|
+
{"version":3,"file":"base-result-add-to-cart.vue_rollup-plugin-vue_script.vue.js","sources":["../../../../src/components/result/base-result-add-to-cart.vue?rollup-plugin-vue=script.ts"],"sourcesContent":["\n\n\n\n\n\n\n\n\n\n\n\n\n import { Result } from '@empathyco/x-types';\n import { computed, defineComponent, PropType } from 'vue';\n import { XEventsTypes } from '../../wiring/events.types';\n import BaseEventButton from '../base-event-button.vue';\n\n /**\n * Renders a button with a default slot. It receives the result with the data and emits\n * {@link XEventsTypes.UserClickedResultAddToCart} to the bus on click mouse event.\n *\n * @public\n */\n export default defineComponent({\n components: { BaseEventButton },\n props: {\n /**\n * (Required) The {@link @empathyco/x-types#Result | result} information.\n *\n * @public\n */\n result: {\n type: Object as PropType<Result>,\n required: true\n }\n },\n setup(props) {\n /**\n * The events to be emitted by the button.\n *\n * @returns Events {@link XEventsTypes} to emit.\n *\n * @public\n */\n const events = computed<Partial<XEventsTypes>>(() => ({\n UserClickedResultAddToCart: props.result\n }));\n\n return {\n events\n };\n }\n });\n"],"names":["BaseEventButton"],"mappings":";;;AAkBE;;;;;AAKG;AACH,aAAe,eAAe,CAAC;IAC7B,UAAU,EAAE,mBAAEA,iBAAe,EAAE;AAC/B,IAAA,KAAK,EAAE;AACL;;;;AAIG;AACH,QAAA,MAAM,EAAE;AACN,YAAA,IAAI,EAAE,MAA0B;AAChC,YAAA,QAAQ,EAAE,IAAI;AACf,SAAA;AACF,KAAA;AACD,IAAA,KAAK,CAAC,KAAK,EAAA;AACT;;;;;;AAMG;AACH,QAAA,MAAM,MAAM,GAAG,QAAQ,CAAwB,OAAO;YACpD,0BAA0B,EAAE,KAAK,CAAC,MAAM;AACzC,SAAA,CAAC,CAAC,CAAC;QAEJ,OAAO;YACL,MAAM;SACP,CAAC;KACH;AACF,CAAA,CAAC;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base-result-current-price.vue.js","sources":["../../../../src/components/result/base-result-current-price.vue"],"sourcesContent":["<template>\n <div :class=\"dynamicClasses\" class=\"x-result-current-price\" data-test=\"result-current-price\">\n <!--\n @slot Base currency item\n @binding {result} result - Result data\n -->\n <slot :result=\"result\">\n <BaseCurrency :value=\"result.price.value\" :format=\"format\" />\n </slot>\n </div>\n</template>\n\n<script lang=\"ts\">\n import { Result } from '@empathyco/x-types';\n import {
|
|
1
|
+
{"version":3,"file":"base-result-current-price.vue.js","sources":["../../../../src/components/result/base-result-current-price.vue"],"sourcesContent":["<template>\n <div :class=\"dynamicClasses\" class=\"x-result-current-price\" data-test=\"result-current-price\">\n <!--\n @slot Base currency item\n @binding {result} result - Result data\n -->\n <slot :result=\"result\">\n <BaseCurrency :value=\"result.price.value\" :format=\"format\" />\n </slot>\n </div>\n</template>\n\n<script lang=\"ts\">\n import { Result } from '@empathyco/x-types';\n import { computed, defineComponent, PropType } from 'vue';\n import { VueCSSClasses } from '../../utils/types';\n import BaseCurrency from '../currency/base-currency.vue';\n\n /**\n * Component that renders the {@link @empathyco/x-types#Result | result} current price\n * that may or may not be on sale.\n *\n * @public\n */\n export default defineComponent({\n components: { BaseCurrency },\n props: {\n /**\n * (Required) The {@link @empathyco/x-types#Result | result} information.\n *\n * @public\n */\n result: {\n type: Object as PropType<Result>,\n required: true\n },\n /**\n * Format or mask to be defined as string.\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 *\n * @remarks The number of 'd', which is the maximum decimal length, MUST match with the length\n * of decimals provided from the adapter. Otherwise, when the component truncate the decimal\n * part, delete significant digits.\n *\n * @public\n */\n format: {\n type: String\n }\n },\n setup(props) {\n /**\n * Dynamic CSS classes to add to the root element of this component.\n *\n * @returns A booleans dictionary where each key is the class name to add,\n * and the boolean value tells if it should be added or not.\n * @internal\n */\n const dynamicClasses = computed<VueCSSClasses>(() => ({\n 'x-result-current-price--on-sale': props.result.price?.hasDiscount ?? false\n }));\n\n return {\n dynamicClasses\n };\n }\n });\n</script>\n\n<docs lang=\"mdx\">\n## Examples\n\n### Basic example\n\nThis component shows the current price formatted. You can provide the `format` by property or let\nthe `BaseCurrency` component use an injected one.\n\n```vue\n<BaseResultCurrentPrice :value=\"result\" :format=\"'i.iii,ddd €'\" />\n```\n\n### Overriding default slot\n\n```vue\n<BaseResultCurrentPrice :result=\"result\">\n <span class=\"custom-base-result-current-price\">{{ result.price.value }}</span>\n</BaseResultCurrentPrice>\n```\n</docs>\n"],"names":[],"mappings":";;;;AAEA,MAAc,cAAA,GAAA,OAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { Prop, Component } from 'vue-property-decorator';
|
|
3
|
-
import Vue from 'vue';
|
|
1
|
+
import { defineComponent, computed } from 'vue';
|
|
4
2
|
import __vue_component__ from '../currency/base-currency.vue.js';
|
|
5
3
|
|
|
6
4
|
/**
|
|
@@ -9,32 +7,55 @@ import __vue_component__ from '../currency/base-currency.vue.js';
|
|
|
9
7
|
*
|
|
10
8
|
* @public
|
|
11
9
|
*/
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
10
|
+
var script = defineComponent({
|
|
11
|
+
components: { BaseCurrency: __vue_component__ },
|
|
12
|
+
props: {
|
|
13
|
+
/**
|
|
14
|
+
* (Required) The {@link @empathyco/x-types#Result | result} information.
|
|
15
|
+
*
|
|
16
|
+
* @public
|
|
17
|
+
*/
|
|
18
|
+
result: {
|
|
19
|
+
type: Object,
|
|
20
|
+
required: true
|
|
21
|
+
},
|
|
22
|
+
/**
|
|
23
|
+
* Format or mask to be defined as string.
|
|
24
|
+
* - Use 'i' to define integer numbers.
|
|
25
|
+
* - Use 'd' to define decimal numbers. You can define the length of the decimal part. If the
|
|
26
|
+
* doesn't include decimals, it is filled with zeros until reach the length defined with 'd's.
|
|
27
|
+
* - Integer separator must be defined between the 3rd and the 4th integer 'i' of a group.
|
|
28
|
+
* - Decimal separator must be defined between the last 'i' and the first 'd'. It can be more
|
|
29
|
+
* than one character.
|
|
30
|
+
* - Set whatever you need around the integers and decimals marks.
|
|
31
|
+
* - Default mask: 'i.iii,dd' which returns '1.345,67'.
|
|
32
|
+
*
|
|
33
|
+
* @remarks The number of 'd', which is the maximum decimal length, MUST match with the length
|
|
34
|
+
* of decimals provided from the adapter. Otherwise, when the component truncate the decimal
|
|
35
|
+
* part, delete significant digits.
|
|
36
|
+
*
|
|
37
|
+
* @public
|
|
38
|
+
*/
|
|
39
|
+
format: {
|
|
40
|
+
type: String
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
setup(props) {
|
|
44
|
+
/**
|
|
45
|
+
* Dynamic CSS classes to add to the root element of this component.
|
|
46
|
+
*
|
|
47
|
+
* @returns A booleans dictionary where each key is the class name to add,
|
|
48
|
+
* and the boolean value tells if it should be added or not.
|
|
49
|
+
* @internal
|
|
50
|
+
*/
|
|
51
|
+
const dynamicClasses = computed(() => ({
|
|
52
|
+
'x-result-current-price--on-sale': props.result.price?.hasDiscount ?? false
|
|
53
|
+
}));
|
|
21
54
|
return {
|
|
22
|
-
|
|
55
|
+
dynamicClasses
|
|
23
56
|
};
|
|
24
57
|
}
|
|
25
|
-
};
|
|
26
|
-
__decorate([
|
|
27
|
-
Prop({ required: true })
|
|
28
|
-
], BaseResultCurrentPrice.prototype, "result", void 0);
|
|
29
|
-
__decorate([
|
|
30
|
-
Prop()
|
|
31
|
-
], BaseResultCurrentPrice.prototype, "format", void 0);
|
|
32
|
-
BaseResultCurrentPrice = __decorate([
|
|
33
|
-
Component({
|
|
34
|
-
components: { BaseCurrency: __vue_component__ }
|
|
35
|
-
})
|
|
36
|
-
], BaseResultCurrentPrice);
|
|
37
|
-
var script = BaseResultCurrentPrice;
|
|
58
|
+
});
|
|
38
59
|
|
|
39
60
|
export { script as default };
|
|
40
61
|
//# sourceMappingURL=base-result-current-price.vue_rollup-plugin-vue_script.vue.js.map
|
package/js/components/result/base-result-current-price.vue_rollup-plugin-vue_script.vue.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base-result-current-price.vue_rollup-plugin-vue_script.vue.js","sources":["../../../../src/components/result/base-result-current-price.vue?rollup-plugin-vue=script.ts"],"sourcesContent":["\n\n\n\n\n\n\n\n\n\n\n\n\n import { Result } from '@empathyco/x-types';\n import {
|
|
1
|
+
{"version":3,"file":"base-result-current-price.vue_rollup-plugin-vue_script.vue.js","sources":["../../../../src/components/result/base-result-current-price.vue?rollup-plugin-vue=script.ts"],"sourcesContent":["\n\n\n\n\n\n\n\n\n\n\n\n\n import { Result } from '@empathyco/x-types';\n import { computed, defineComponent, PropType } from 'vue';\n import { VueCSSClasses } from '../../utils/types';\n import BaseCurrency from '../currency/base-currency.vue';\n\n /**\n * Component that renders the {@link @empathyco/x-types#Result | result} current price\n * that may or may not be on sale.\n *\n * @public\n */\n export default defineComponent({\n components: { BaseCurrency },\n props: {\n /**\n * (Required) The {@link @empathyco/x-types#Result | result} information.\n *\n * @public\n */\n result: {\n type: Object as PropType<Result>,\n required: true\n },\n /**\n * Format or mask to be defined as string.\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 *\n * @remarks The number of 'd', which is the maximum decimal length, MUST match with the length\n * of decimals provided from the adapter. Otherwise, when the component truncate the decimal\n * part, delete significant digits.\n *\n * @public\n */\n format: {\n type: String\n }\n },\n setup(props) {\n /**\n * Dynamic CSS classes to add to the root element of this component.\n *\n * @returns A booleans dictionary where each key is the class name to add,\n * and the boolean value tells if it should be added or not.\n * @internal\n */\n const dynamicClasses = computed<VueCSSClasses>(() => ({\n 'x-result-current-price--on-sale': props.result.price?.hasDiscount ?? false\n }));\n\n return {\n dynamicClasses\n };\n }\n });\n"],"names":["BaseCurrency"],"mappings":";;;AAkBE;;;;;AAKG;AACH,aAAe,eAAe,CAAC;IAC7B,UAAU,EAAE,gBAAEA,iBAAY,EAAE;AAC5B,IAAA,KAAK,EAAE;AACL;;;;AAIG;AACH,QAAA,MAAM,EAAE;AACN,YAAA,IAAI,EAAE,MAA0B;AAChC,YAAA,QAAQ,EAAE,IAAI;AACf,SAAA;AACD;;;;;;;;;;;;;;;;AAgBG;AACH,QAAA,MAAM,EAAE;AACN,YAAA,IAAI,EAAE,MAAM;AACb,SAAA;AACF,KAAA;AACD,IAAA,KAAK,CAAC,KAAK,EAAA;AACT;;;;;;AAMG;AACH,QAAA,MAAM,cAAc,GAAG,QAAQ,CAAgB,OAAO;YACpD,iCAAiC,EAAE,KAAK,CAAC,MAAM,CAAC,KAAK,EAAE,WAAW,IAAI,KAAK;AAC5E,SAAA,CAAC,CAAC,CAAC;QAEJ,OAAO;YACL,cAAc;SACf,CAAC;KACH;AACF,CAAA,CAAC;;;;"}
|
|
@@ -75,7 +75,7 @@ __vue_render__._withStripped = true;
|
|
|
75
75
|
/* style */
|
|
76
76
|
const __vue_inject_styles__ = undefined;
|
|
77
77
|
/* scoped */
|
|
78
|
-
const __vue_scope_id__ = "data-v-
|
|
78
|
+
const __vue_scope_id__ = "data-v-1ae01006";
|
|
79
79
|
/* module identifier */
|
|
80
80
|
const __vue_module_identifier__ = undefined;
|
|
81
81
|
/* functional template */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base-result-image.vue.js","sources":["../../../../src/components/result/base-result-image.vue"],"sourcesContent":["<template>\n <!-- This is a div because using a picture causes the onload event of the image to fire twice. -->\n <!-- eslint-disable-next-line vuejs-accessibility/mouse-events-have-key-events -->\n <div\n @mouseenter.once=\"userHasHoveredImage = true\"\n @mouseenter=\"isHovering = true\"\n @mouseleave=\"isHovering = false\"\n class=\"x-result-picture x-picture\"\n data-test=\"result-picture\"\n >\n <img\n v-if=\"shouldLoadNextImage\"\n @load=\"flagImageLoaded\"\n @error=\"flagImageAsFailed\"\n loading=\"lazy\"\n :src=\"pendingImages[0]\"\n :style=\"loaderStyles\"\n class=\"x-picture-image\"\n data-test=\"result-picture-loader\"\n alt=\"\"\n role=\"presentation\"\n />\n <component :is=\"animation\" class=\"x-picture-image\" :appear=\"false\">\n <!-- @slot Fallback image content. It will be rendered when all the images failed -->\n <slot v-if=\"!loadedImages.length && !pendingImages.length\" name=\"fallback\" />\n\n <!-- @slot Loading image content. It will be rendered while the real image is not loaded -->\n <slot v-else-if=\"!loadedImages.length\" name=\"placeholder\" />\n\n <img\n v-else\n :key=\"imageSrc\"\n :alt=\"result.name\"\n :src=\"imageSrc\"\n class=\"x-result-picture-image\"\n data-test=\"result-picture-image\"\n />\n </component>\n </div>\n</template>\n\n<script lang=\"ts\">\n import { Result } from '@empathyco/x-types';\n import
|
|
1
|
+
{"version":3,"file":"base-result-image.vue.js","sources":["../../../../src/components/result/base-result-image.vue"],"sourcesContent":["<template>\n <!-- This is a div because using a picture causes the onload event of the image to fire twice. -->\n <!-- eslint-disable-next-line vuejs-accessibility/mouse-events-have-key-events -->\n <div\n @mouseenter.once=\"userHasHoveredImage = true\"\n @mouseenter=\"isHovering = true\"\n @mouseleave=\"isHovering = false\"\n class=\"x-result-picture x-picture\"\n data-test=\"result-picture\"\n >\n <img\n v-if=\"shouldLoadNextImage\"\n @load=\"flagImageLoaded\"\n @error=\"flagImageAsFailed\"\n loading=\"lazy\"\n :src=\"pendingImages[0]\"\n :style=\"loaderStyles\"\n class=\"x-picture-image\"\n data-test=\"result-picture-loader\"\n alt=\"\"\n role=\"presentation\"\n />\n <component :is=\"animation\" class=\"x-picture-image\" :appear=\"false\">\n <!-- @slot Fallback image content. It will be rendered when all the images failed -->\n <slot v-if=\"!loadedImages.length && !pendingImages.length\" name=\"fallback\" />\n\n <!-- @slot Loading image content. It will be rendered while the real image is not loaded -->\n <slot v-else-if=\"!loadedImages.length\" name=\"placeholder\" />\n\n <img\n v-else\n :key=\"imageSrc\"\n :alt=\"result.name\"\n :src=\"imageSrc\"\n class=\"x-result-picture-image\"\n data-test=\"result-picture-image\"\n />\n </component>\n </div>\n</template>\n\n<script lang=\"ts\">\n import { Result } from '@empathyco/x-types';\n import {\n computed,\n DefineComponent,\n defineComponent,\n PropType,\n Ref,\n ref,\n toRef,\n watch\n } from 'vue';\n import { NoElement } from '../no-element';\n import { animationProp } from '../../utils/options-api';\n\n /**\n * Component to be reused that renders an `<img>`.\n *\n * @public\n */\n export default defineComponent({\n components: {\n NoElement\n },\n props: {\n /**\n * (Required) The {@link @empathyco/x-types#Result | result} information.\n *\n * @public\n */\n result: {\n type: Object as PropType<Result>,\n required: true\n },\n\n /**\n * Animation to use when switching between the placeholder, the loaded image, or the failed\n * image fallback.\n *\n * @public\n */\n loadAnimation: {\n type: animationProp,\n default: () => NoElement\n },\n\n /**\n * Animation to use when switching between the loaded image and the hover image.\n *\n * @public\n */\n hoverAnimation: {\n type: animationProp\n },\n\n /**\n * Indicates if the next valid image should be displayed on hover.\n *\n * @public\n */\n showNextImageOnHover: {\n type: Boolean,\n default: false\n }\n },\n\n setup(props) {\n /**\n * Copy of the images of the result.\n *\n * It is used as a queue of images to load, once an image loads/fails to load, it is removed\n * from this array.\n *\n * @internal\n */\n const pendingImages: Ref<string[]> = ref([]);\n\n /**\n * Contains the images that have been loaded successfully.\n *\n * @internal\n */\n const loadedImages: Ref<string[]> = ref([]);\n\n /**\n * Indicates if the user is hovering the image.\n *\n * @internal\n */\n const isHovering = ref(false);\n\n /**\n * Indicates if the user has hovered the image.\n *\n * @internal\n */\n const userHasHoveredImage = ref(false);\n\n /**.\n * Styles to use inline in the image loader, to prevent override from CSS\n *\n * @internal\n */\n const loaderStyles: Partial<CSSStyleDeclaration> = {\n position: 'absolute !important',\n top: '0 !important',\n left: '0 !important',\n width: '100% !important',\n height: '100% !important',\n pointerEvents: 'none !important',\n visibility: 'hidden !important'\n };\n\n const resultImages = toRef(props.result, 'images');\n\n /**\n * Initializes images state and resets when the result's images change.\n *\n * @internal\n */\n watch(\n resultImages,\n () => {\n pendingImages.value = [...(props.result.images ?? [])];\n loadedImages.value = pendingImages.value.filter(image =>\n loadedImages.value.includes(image)\n );\n },\n { immediate: true }\n );\n\n /**\n * Animation to be used.\n *\n * @returns The animation to be used, taking into account if the user has hovered the image.\n *\n * @internal\n */\n const animation = computed<DefineComponent | string>(() => {\n return userHasHoveredImage\n ? props.hoverAnimation ?? props.loadAnimation\n : props.loadAnimation;\n });\n\n /**\n * Gets the src from the result image.\n *\n * @returns The result image src.\n *\n * @internal\n */\n const imageSrc = computed<string>(() => {\n return loadedImages.value[\n !props.showNextImageOnHover || !isHovering ? 0 : loadedImages.value.length - 1\n ];\n });\n\n /**\n * Indicates if the loader should try to load the next image.\n *\n * @returns True if it should try to load the next image.\n *\n * @internal\n */\n const shouldLoadNextImage = computed<boolean>(() => {\n const numImagesToLoad = props.showNextImageOnHover && userHasHoveredImage ? 2 : 1;\n return !!pendingImages.value.length && loadedImages.value.length < numImagesToLoad;\n });\n\n /**\n * Sets an image as failed.\n *\n * @internal\n */\n const flagImageAsFailed = (): void => {\n pendingImages.value.shift();\n };\n\n /**\n * Sets an image as loaded.\n *\n * @internal\n */\n const flagImageLoaded = (): void => {\n const image = pendingImages.value.shift();\n if (image) {\n loadedImages.value.push(image);\n }\n };\n\n return {\n pendingImages,\n loadedImages,\n isHovering,\n userHasHoveredImage,\n loaderStyles,\n animation,\n imageSrc,\n shouldLoadNextImage,\n flagImageAsFailed,\n flagImageLoaded\n };\n }\n });\n</script>\n\n<style lang=\"scss\" scoped>\n .x-result-picture {\n position: relative;\n min-width: 1px;\n min-height: 1px;\n\n &-image {\n max-width: 100%;\n max-height: 100%;\n }\n }\n</style>\n\n<docs lang=\"mdx\">\n## Examples\n\n### Basic example\n\nThis component is for the result image. It may be part of the search result page, recommendations or\nother section which needs to include results.\n\nThe result prop is required. It will render a `<img/>` with the result image:\n\n```vue\n<BaseResultImage :result=\"result\" />\n```\n\n### Showing the next image on hover\n\nIf a result has multiple images, it can show the next one on hover.\n\n```vue\n<BaseResultImage :result=\"result\" showNextImageOnHover />\n```\n\n### Customizing slots content\n\nFallback and placeholder contents can be customized.\n\nThe fallback slot allows you to replace the content of the fallback image.\n\nThe other slot is called `placeholder`, and allows you to set the image that its going to be\ndisplayed while the real one is loaded.\n\n```vue\n<BaseResultImage :result=\"result\">\n <template #placeholder>\n <img alt=\"Placeholder image\" src=\"./placeholder-image.svg\"/>\n </template>\n <template #fallback>\n <img alt=\"Fallback image\" src=\"./fallback-image.svg\"/>\n </template>\n</BaseResultImage>\n```\n\n### Customizing the animations\n\nTwo animations can be used this component.\n\nThe `loadAnimation` is used to transition between the placeholder, the fallback and the image.\n\nThe `hoverAnimation` is used to transition between the image and the hover image, if the\n`showNextImageOnHover` prop is `true`.\n\n`hoverAnimation` will default to `loadAnimation` if it is not provided.\n\n```vue\n<template>\n <BaseResultImage\n :result=\"result\"\n :loadAnimation=\"loadAnimation\"\n :hoverAnimation=\"hoverAnimation\"\n showNextImageOnHover\n />\n</template>\n\n<script>\n import { BaseResultImage } from '@empathyco/x-components';\n import { CrossFade, CollapseHeight } from '@empathyco/x-components/animations';\n\n export default {\n name: 'BaseResultImageAnimations',\n components: {\n BaseResultImage\n },\n data() {\n return {\n loadAnimation: CrossFade,\n hoverAnimation: CollapseHeight,\n result: {\n name: 'jacket',\n images: ['https://some-image', 'https://some-image-2']\n }\n };\n }\n };\n</script>\n```\n</docs>\n"],"names":[],"mappings":";;;;;AAEA,MAAc,cAAA,GAAA,OAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -1,16 +1,55 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import Vue from 'vue';
|
|
3
|
-
import { Prop, Watch, Component } from 'vue-property-decorator';
|
|
1
|
+
import { defineComponent, ref, toRef, watch, computed } from 'vue';
|
|
4
2
|
import { NoElement } from '../no-element.js';
|
|
3
|
+
import { animationProp } from '../../utils/options-api.js';
|
|
5
4
|
|
|
6
5
|
/**
|
|
7
6
|
* Component to be reused that renders an `<img>`.
|
|
8
7
|
*
|
|
9
8
|
* @public
|
|
10
9
|
*/
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
10
|
+
var script = defineComponent({
|
|
11
|
+
components: {
|
|
12
|
+
NoElement
|
|
13
|
+
},
|
|
14
|
+
props: {
|
|
15
|
+
/**
|
|
16
|
+
* (Required) The {@link @empathyco/x-types#Result | result} information.
|
|
17
|
+
*
|
|
18
|
+
* @public
|
|
19
|
+
*/
|
|
20
|
+
result: {
|
|
21
|
+
type: Object,
|
|
22
|
+
required: true
|
|
23
|
+
},
|
|
24
|
+
/**
|
|
25
|
+
* Animation to use when switching between the placeholder, the loaded image, or the failed
|
|
26
|
+
* image fallback.
|
|
27
|
+
*
|
|
28
|
+
* @public
|
|
29
|
+
*/
|
|
30
|
+
loadAnimation: {
|
|
31
|
+
type: animationProp,
|
|
32
|
+
default: () => NoElement
|
|
33
|
+
},
|
|
34
|
+
/**
|
|
35
|
+
* Animation to use when switching between the loaded image and the hover image.
|
|
36
|
+
*
|
|
37
|
+
* @public
|
|
38
|
+
*/
|
|
39
|
+
hoverAnimation: {
|
|
40
|
+
type: animationProp
|
|
41
|
+
},
|
|
42
|
+
/**
|
|
43
|
+
* Indicates if the next valid image should be displayed on hover.
|
|
44
|
+
*
|
|
45
|
+
* @public
|
|
46
|
+
*/
|
|
47
|
+
showNextImageOnHover: {
|
|
48
|
+
type: Boolean,
|
|
49
|
+
default: false
|
|
50
|
+
}
|
|
51
|
+
},
|
|
52
|
+
setup(props) {
|
|
14
53
|
/**
|
|
15
54
|
* Copy of the images of the result.
|
|
16
55
|
*
|
|
@@ -19,31 +58,31 @@ let BaseResultImage = class BaseResultImage extends Vue {
|
|
|
19
58
|
*
|
|
20
59
|
* @internal
|
|
21
60
|
*/
|
|
22
|
-
|
|
61
|
+
const pendingImages = ref([]);
|
|
23
62
|
/**
|
|
24
63
|
* Contains the images that have been loaded successfully.
|
|
25
64
|
*
|
|
26
65
|
* @internal
|
|
27
66
|
*/
|
|
28
|
-
|
|
67
|
+
const loadedImages = ref([]);
|
|
29
68
|
/**
|
|
30
69
|
* Indicates if the user is hovering the image.
|
|
31
70
|
*
|
|
32
71
|
* @internal
|
|
33
72
|
*/
|
|
34
|
-
|
|
73
|
+
const isHovering = ref(false);
|
|
35
74
|
/**
|
|
36
75
|
* Indicates if the user has hovered the image.
|
|
37
76
|
*
|
|
38
77
|
* @internal
|
|
39
78
|
*/
|
|
40
|
-
|
|
79
|
+
const userHasHoveredImage = ref(false);
|
|
41
80
|
/**.
|
|
42
81
|
* Styles to use inline in the image loader, to prevent override from CSS
|
|
43
82
|
*
|
|
44
83
|
* @internal
|
|
45
84
|
*/
|
|
46
|
-
|
|
85
|
+
const loaderStyles = {
|
|
47
86
|
position: 'absolute !important',
|
|
48
87
|
top: '0 !important',
|
|
49
88
|
left: '0 !important',
|
|
@@ -52,92 +91,82 @@ let BaseResultImage = class BaseResultImage extends Vue {
|
|
|
52
91
|
pointerEvents: 'none !important',
|
|
53
92
|
visibility: 'hidden !important'
|
|
54
93
|
};
|
|
94
|
+
const resultImages = toRef(props.result, 'images');
|
|
95
|
+
/**
|
|
96
|
+
* Initializes images state and resets when the result's images change.
|
|
97
|
+
*
|
|
98
|
+
* @internal
|
|
99
|
+
*/
|
|
100
|
+
watch(resultImages, () => {
|
|
101
|
+
pendingImages.value = [...(props.result.images ?? [])];
|
|
102
|
+
loadedImages.value = pendingImages.value.filter(image => loadedImages.value.includes(image));
|
|
103
|
+
}, { immediate: true });
|
|
104
|
+
/**
|
|
105
|
+
* Animation to be used.
|
|
106
|
+
*
|
|
107
|
+
* @returns The animation to be used, taking into account if the user has hovered the image.
|
|
108
|
+
*
|
|
109
|
+
* @internal
|
|
110
|
+
*/
|
|
111
|
+
const animation = computed(() => {
|
|
112
|
+
return userHasHoveredImage
|
|
113
|
+
? props.hoverAnimation ?? props.loadAnimation
|
|
114
|
+
: props.loadAnimation;
|
|
115
|
+
});
|
|
116
|
+
/**
|
|
117
|
+
* Gets the src from the result image.
|
|
118
|
+
*
|
|
119
|
+
* @returns The result image src.
|
|
120
|
+
*
|
|
121
|
+
* @internal
|
|
122
|
+
*/
|
|
123
|
+
const imageSrc = computed(() => {
|
|
124
|
+
return loadedImages.value[!props.showNextImageOnHover || !isHovering ? 0 : loadedImages.value.length - 1];
|
|
125
|
+
});
|
|
126
|
+
/**
|
|
127
|
+
* Indicates if the loader should try to load the next image.
|
|
128
|
+
*
|
|
129
|
+
* @returns True if it should try to load the next image.
|
|
130
|
+
*
|
|
131
|
+
* @internal
|
|
132
|
+
*/
|
|
133
|
+
const shouldLoadNextImage = computed(() => {
|
|
134
|
+
const numImagesToLoad = props.showNextImageOnHover && userHasHoveredImage ? 2 : 1;
|
|
135
|
+
return !!pendingImages.value.length && loadedImages.value.length < numImagesToLoad;
|
|
136
|
+
});
|
|
137
|
+
/**
|
|
138
|
+
* Sets an image as failed.
|
|
139
|
+
*
|
|
140
|
+
* @internal
|
|
141
|
+
*/
|
|
142
|
+
const flagImageAsFailed = () => {
|
|
143
|
+
pendingImages.value.shift();
|
|
144
|
+
};
|
|
145
|
+
/**
|
|
146
|
+
* Sets an image as loaded.
|
|
147
|
+
*
|
|
148
|
+
* @internal
|
|
149
|
+
*/
|
|
150
|
+
const flagImageLoaded = () => {
|
|
151
|
+
const image = pendingImages.value.shift();
|
|
152
|
+
if (image) {
|
|
153
|
+
loadedImages.value.push(image);
|
|
154
|
+
}
|
|
155
|
+
};
|
|
156
|
+
return {
|
|
157
|
+
pendingImages,
|
|
158
|
+
loadedImages,
|
|
159
|
+
isHovering,
|
|
160
|
+
userHasHoveredImage,
|
|
161
|
+
loaderStyles,
|
|
162
|
+
animation,
|
|
163
|
+
imageSrc,
|
|
164
|
+
shouldLoadNextImage,
|
|
165
|
+
flagImageAsFailed,
|
|
166
|
+
flagImageLoaded
|
|
167
|
+
};
|
|
55
168
|
}
|
|
56
|
-
|
|
57
|
-
* Initializes images state and resets when the result's images change.
|
|
58
|
-
*
|
|
59
|
-
* @internal
|
|
60
|
-
*/
|
|
61
|
-
resetImagesState() {
|
|
62
|
-
this.pendingImages = [...(this.result.images ?? [])];
|
|
63
|
-
this.loadedImages = this.pendingImages.filter(image => this.loadedImages.includes(image));
|
|
64
|
-
}
|
|
65
|
-
/**
|
|
66
|
-
* Animation to be used.
|
|
67
|
-
*
|
|
68
|
-
* @returns The animation to be used, taking into account if the user has hovered the image.
|
|
69
|
-
*
|
|
70
|
-
* @internal
|
|
71
|
-
*/
|
|
72
|
-
get animation() {
|
|
73
|
-
return this.userHasHoveredImage
|
|
74
|
-
? this.hoverAnimation ?? this.loadAnimation
|
|
75
|
-
: this.loadAnimation;
|
|
76
|
-
}
|
|
77
|
-
/**
|
|
78
|
-
* Gets the src from the result image.
|
|
79
|
-
*
|
|
80
|
-
* @returns The result image src.
|
|
81
|
-
*
|
|
82
|
-
* @internal
|
|
83
|
-
*/
|
|
84
|
-
get imageSrc() {
|
|
85
|
-
return this.loadedImages[!this.showNextImageOnHover || !this.isHovering ? 0 : this.loadedImages.length - 1];
|
|
86
|
-
}
|
|
87
|
-
/**
|
|
88
|
-
* Indicates if the loader should try to load the next image.
|
|
89
|
-
*
|
|
90
|
-
* @returns True if it should try to load the next image.
|
|
91
|
-
*
|
|
92
|
-
* @internal
|
|
93
|
-
*/
|
|
94
|
-
get shouldLoadNextImage() {
|
|
95
|
-
const numImagesToLoad = this.showNextImageOnHover && this.userHasHoveredImage ? 2 : 1;
|
|
96
|
-
return !!this.pendingImages.length && this.loadedImages.length < numImagesToLoad;
|
|
97
|
-
}
|
|
98
|
-
/**
|
|
99
|
-
* Sets an image as failed.
|
|
100
|
-
*
|
|
101
|
-
* @internal
|
|
102
|
-
*/
|
|
103
|
-
flagImageAsFailed() {
|
|
104
|
-
this.pendingImages.shift();
|
|
105
|
-
}
|
|
106
|
-
/**
|
|
107
|
-
* Sets an image as loaded.
|
|
108
|
-
*
|
|
109
|
-
* @internal
|
|
110
|
-
*/
|
|
111
|
-
flagImageLoaded() {
|
|
112
|
-
const image = this.pendingImages.shift();
|
|
113
|
-
if (image) {
|
|
114
|
-
this.loadedImages.push(image);
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
};
|
|
118
|
-
__decorate([
|
|
119
|
-
Prop({ required: true })
|
|
120
|
-
], BaseResultImage.prototype, "result", void 0);
|
|
121
|
-
__decorate([
|
|
122
|
-
Prop({ default: () => NoElement })
|
|
123
|
-
], BaseResultImage.prototype, "loadAnimation", void 0);
|
|
124
|
-
__decorate([
|
|
125
|
-
Prop()
|
|
126
|
-
], BaseResultImage.prototype, "hoverAnimation", void 0);
|
|
127
|
-
__decorate([
|
|
128
|
-
Prop({ type: Boolean, default: false })
|
|
129
|
-
], BaseResultImage.prototype, "showNextImageOnHover", void 0);
|
|
130
|
-
__decorate([
|
|
131
|
-
Watch('result.images', { immediate: true })
|
|
132
|
-
], BaseResultImage.prototype, "resetImagesState", null);
|
|
133
|
-
BaseResultImage = __decorate([
|
|
134
|
-
Component({
|
|
135
|
-
components: {
|
|
136
|
-
NoElement
|
|
137
|
-
}
|
|
138
|
-
})
|
|
139
|
-
], BaseResultImage);
|
|
140
|
-
var script = BaseResultImage;
|
|
169
|
+
});
|
|
141
170
|
|
|
142
171
|
export { script as default };
|
|
143
172
|
//# sourceMappingURL=base-result-image.vue_rollup-plugin-vue_script.vue.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base-result-image.vue_rollup-plugin-vue_script.vue.js","sources":["../../../../src/components/result/base-result-image.vue?rollup-plugin-vue=script.ts"],"sourcesContent":["\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n import { Result } from '@empathyco/x-types';\n import
|
|
1
|
+
{"version":3,"file":"base-result-image.vue_rollup-plugin-vue_script.vue.js","sources":["../../../../src/components/result/base-result-image.vue?rollup-plugin-vue=script.ts"],"sourcesContent":["\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n import { Result } from '@empathyco/x-types';\n import {\n computed,\n DefineComponent,\n defineComponent,\n PropType,\n Ref,\n ref,\n toRef,\n watch\n } from 'vue';\n import { NoElement } from '../no-element';\n import { animationProp } from '../../utils/options-api';\n\n /**\n * Component to be reused that renders an `<img>`.\n *\n * @public\n */\n export default defineComponent({\n components: {\n NoElement\n },\n props: {\n /**\n * (Required) The {@link @empathyco/x-types#Result | result} information.\n *\n * @public\n */\n result: {\n type: Object as PropType<Result>,\n required: true\n },\n\n /**\n * Animation to use when switching between the placeholder, the loaded image, or the failed\n * image fallback.\n *\n * @public\n */\n loadAnimation: {\n type: animationProp,\n default: () => NoElement\n },\n\n /**\n * Animation to use when switching between the loaded image and the hover image.\n *\n * @public\n */\n hoverAnimation: {\n type: animationProp\n },\n\n /**\n * Indicates if the next valid image should be displayed on hover.\n *\n * @public\n */\n showNextImageOnHover: {\n type: Boolean,\n default: false\n }\n },\n\n setup(props) {\n /**\n * Copy of the images of the result.\n *\n * It is used as a queue of images to load, once an image loads/fails to load, it is removed\n * from this array.\n *\n * @internal\n */\n const pendingImages: Ref<string[]> = ref([]);\n\n /**\n * Contains the images that have been loaded successfully.\n *\n * @internal\n */\n const loadedImages: Ref<string[]> = ref([]);\n\n /**\n * Indicates if the user is hovering the image.\n *\n * @internal\n */\n const isHovering = ref(false);\n\n /**\n * Indicates if the user has hovered the image.\n *\n * @internal\n */\n const userHasHoveredImage = ref(false);\n\n /**.\n * Styles to use inline in the image loader, to prevent override from CSS\n *\n * @internal\n */\n const loaderStyles: Partial<CSSStyleDeclaration> = {\n position: 'absolute !important',\n top: '0 !important',\n left: '0 !important',\n width: '100% !important',\n height: '100% !important',\n pointerEvents: 'none !important',\n visibility: 'hidden !important'\n };\n\n const resultImages = toRef(props.result, 'images');\n\n /**\n * Initializes images state and resets when the result's images change.\n *\n * @internal\n */\n watch(\n resultImages,\n () => {\n pendingImages.value = [...(props.result.images ?? [])];\n loadedImages.value = pendingImages.value.filter(image =>\n loadedImages.value.includes(image)\n );\n },\n { immediate: true }\n );\n\n /**\n * Animation to be used.\n *\n * @returns The animation to be used, taking into account if the user has hovered the image.\n *\n * @internal\n */\n const animation = computed<DefineComponent | string>(() => {\n return userHasHoveredImage\n ? props.hoverAnimation ?? props.loadAnimation\n : props.loadAnimation;\n });\n\n /**\n * Gets the src from the result image.\n *\n * @returns The result image src.\n *\n * @internal\n */\n const imageSrc = computed<string>(() => {\n return loadedImages.value[\n !props.showNextImageOnHover || !isHovering ? 0 : loadedImages.value.length - 1\n ];\n });\n\n /**\n * Indicates if the loader should try to load the next image.\n *\n * @returns True if it should try to load the next image.\n *\n * @internal\n */\n const shouldLoadNextImage = computed<boolean>(() => {\n const numImagesToLoad = props.showNextImageOnHover && userHasHoveredImage ? 2 : 1;\n return !!pendingImages.value.length && loadedImages.value.length < numImagesToLoad;\n });\n\n /**\n * Sets an image as failed.\n *\n * @internal\n */\n const flagImageAsFailed = (): void => {\n pendingImages.value.shift();\n };\n\n /**\n * Sets an image as loaded.\n *\n * @internal\n */\n const flagImageLoaded = (): void => {\n const image = pendingImages.value.shift();\n if (image) {\n loadedImages.value.push(image);\n }\n };\n\n return {\n pendingImages,\n loadedImages,\n isHovering,\n userHasHoveredImage,\n loaderStyles,\n animation,\n imageSrc,\n shouldLoadNextImage,\n flagImageAsFailed,\n flagImageLoaded\n };\n }\n });\n"],"names":[],"mappings":"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"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createInjector, createInjectorSSR } from 'vue-runtime-helpers';
|
|
2
2
|
|
|
3
|
-
var css = ".x-result-picture[data-v-
|
|
3
|
+
var css = ".x-result-picture[data-v-1ae01006] {\n position: relative;\n min-width: 1px;\n min-height: 1px;\n}\n.x-result-picture-image[data-v-1ae01006] {\n max-width: 100%;\n max-height: 100%;\n}";
|
|
4
4
|
const isBrowser = /*#__PURE__*/ (function () {
|
|
5
5
|
return (
|
|
6
6
|
Object.prototype.toString.call(typeof process !== 'undefined' ? process : 0) !==
|
|
@@ -12,6 +12,7 @@ var __vue_render__ = function () {
|
|
|
12
12
|
return _c(
|
|
13
13
|
"a",
|
|
14
14
|
{
|
|
15
|
+
ref: "el",
|
|
15
16
|
staticClass: "x-result-link",
|
|
16
17
|
attrs: { href: _vm.result.url, "data-test": "result-link" },
|
|
17
18
|
on: {
|
|
@@ -37,7 +38,7 @@ __vue_render__._withStripped = true;
|
|
|
37
38
|
/* style */
|
|
38
39
|
const __vue_inject_styles__ = undefined;
|
|
39
40
|
/* scoped */
|
|
40
|
-
const __vue_scope_id__ = "data-v-
|
|
41
|
+
const __vue_scope_id__ = "data-v-5c0bb921";
|
|
41
42
|
/* module identifier */
|
|
42
43
|
const __vue_module_identifier__ = undefined;
|
|
43
44
|
/* functional template */
|