@empathyco/x-components 6.0.0-alpha.23 → 6.0.0-alpha.25
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 +18 -0
- package/design-system/deprecated-full-theme.css +1943 -1943
- package/docs/API-reference/api/x-components.installxoptions.installextraplugins.md +2 -2
- package/js/components/animations/fade-and-slide.vue.js +1 -2
- package/js/components/animations/fade-and-slide.vue.js.map +1 -1
- package/js/components/base-dropdown.vue.js +1 -3
- package/js/components/base-dropdown.vue.js.map +1 -1
- package/js/components/base-event-button.vue.js +1 -2
- package/js/components/base-event-button.vue.js.map +1 -1
- package/js/components/base-grid.vue.js +11 -18
- package/js/components/base-grid.vue.js.map +1 -1
- package/js/components/base-keyboard-navigation.vue.js +1 -2
- package/js/components/base-keyboard-navigation.vue.js.map +1 -1
- package/js/components/base-rating.vue.js +1 -3
- package/js/components/base-rating.vue.js.map +1 -1
- package/js/components/base-slider.vue.js +1 -2
- package/js/components/base-slider.vue.js.map +1 -1
- package/js/components/base-variable-column-grid.vue.js +1 -2
- package/js/components/base-variable-column-grid.vue.js.map +1 -1
- package/js/components/column-picker/base-column-picker-dropdown.vue.js +1 -3
- package/js/components/column-picker/base-column-picker-dropdown.vue.js.map +1 -1
- package/js/components/column-picker/base-column-picker-list.vue.js +1 -3
- package/js/components/column-picker/base-column-picker-list.vue.js.map +1 -1
- package/js/components/filters/labels/base-rating-filter-label.vue.js +1 -3
- package/js/components/filters/labels/base-rating-filter-label.vue.js.map +1 -1
- package/js/components/items-list.vue.js +1 -2
- package/js/components/items-list.vue.js.map +1 -1
- package/js/components/layouts/fixed-header-and-asides-layout.vue.js +1 -7
- package/js/components/layouts/fixed-header-and-asides-layout.vue.js.map +1 -1
- package/js/components/layouts/multi-column-max-width-layout.vue.js +1 -9
- package/js/components/layouts/multi-column-max-width-layout.vue.js.map +1 -1
- package/js/components/layouts/single-column-layout.vue.js +1 -9
- package/js/components/layouts/single-column-layout.vue.js.map +1 -1
- package/js/components/modals/base-events-modal-close.vue.js +1 -2
- package/js/components/modals/base-events-modal-close.vue.js.map +1 -1
- package/js/components/modals/base-events-modal-open.vue.js +1 -2
- package/js/components/modals/base-events-modal-open.vue.js.map +1 -1
- package/js/components/modals/base-id-modal-close.vue.js +1 -2
- package/js/components/modals/base-id-modal-close.vue.js.map +1 -1
- package/js/components/modals/base-id-modal-open.vue.js +1 -2
- package/js/components/modals/base-id-modal-open.vue.js.map +1 -1
- package/js/components/modals/base-modal.vue.js +1 -2
- package/js/components/modals/base-modal.vue.js.map +1 -1
- package/js/components/page-loader-button.vue.js +1 -4
- package/js/components/page-loader-button.vue.js.map +1 -1
- package/js/components/panels/base-header-toggle-panel.vue.js +1 -5
- package/js/components/panels/base-header-toggle-panel.vue.js.map +1 -1
- package/js/components/panels/base-id-toggle-panel-button.vue.js +1 -2
- package/js/components/panels/base-id-toggle-panel-button.vue.js.map +1 -1
- package/js/components/panels/base-id-toggle-panel.vue.js +1 -2
- package/js/components/panels/base-id-toggle-panel.vue.js.map +1 -1
- package/js/components/panels/base-tabs-panel.vue.js +1 -4
- package/js/components/panels/base-tabs-panel.vue.js.map +1 -1
- package/js/components/panels/base-toggle-panel.vue.js +1 -2
- package/js/components/panels/base-toggle-panel.vue.js.map +1 -1
- package/js/components/result/base-result-add-to-cart.vue.js +1 -2
- package/js/components/result/base-result-add-to-cart.vue.js.map +1 -1
- package/js/components/result/base-result-current-price.vue.js +1 -2
- package/js/components/result/base-result-current-price.vue.js.map +1 -1
- package/js/components/result/base-result-image.vue.js +39 -59
- package/js/components/result/base-result-image.vue.js.map +1 -1
- package/js/components/result/base-result-link.vue.js +1 -2
- package/js/components/result/base-result-link.vue.js.map +1 -1
- package/js/components/result/base-result-previous-price.vue.js +1 -2
- package/js/components/result/base-result-previous-price.vue.js.map +1 -1
- package/js/components/result/base-result-rating.vue.js +1 -4
- package/js/components/result/base-result-rating.vue.js.map +1 -1
- package/js/components/result/result-variant-selector.vue.js +1 -3
- package/js/components/result/result-variant-selector.vue.js.map +1 -1
- package/js/components/sliding-panel.vue.js +1 -4
- package/js/components/sliding-panel.vue.js.map +1 -1
- package/js/components/suggestions/base-suggestion.vue.js +1 -2
- package/js/components/suggestions/base-suggestion.vue.js.map +1 -1
- package/js/components/suggestions/base-suggestions.vue.js +1 -2
- package/js/components/suggestions/base-suggestions.vue.js.map +1 -1
- package/js/x-modules/empathize/components/empathize.vue.js +1 -2
- package/js/x-modules/empathize/components/empathize.vue.js.map +1 -1
- package/js/x-modules/facets/components/facets/facets.vue.js +20 -33
- package/js/x-modules/facets/components/facets/facets.vue.js.map +1 -1
- package/js/x-modules/facets/components/filters/all-filter.vue.js +1 -2
- package/js/x-modules/facets/components/filters/all-filter.vue.js.map +1 -1
- package/js/x-modules/facets/components/filters/editable-number-range-filter.vue.js +1 -6
- package/js/x-modules/facets/components/filters/editable-number-range-filter.vue.js.map +1 -1
- package/js/x-modules/facets/components/filters/hierarchical-filter.vue.js +1 -3
- package/js/x-modules/facets/components/filters/hierarchical-filter.vue.js.map +1 -1
- package/js/x-modules/facets/components/filters/number-range-filter.vue.js +1 -3
- package/js/x-modules/facets/components/filters/number-range-filter.vue.js.map +1 -1
- package/js/x-modules/facets/components/filters/simple-filter.vue.js +1 -3
- package/js/x-modules/facets/components/filters/simple-filter.vue.js.map +1 -1
- package/js/x-modules/facets/components/lists/filters-list.vue.js +1 -2
- package/js/x-modules/facets/components/lists/filters-list.vue.js.map +1 -1
- package/js/x-modules/facets/components/lists/filters-search.vue.js +1 -3
- package/js/x-modules/facets/components/lists/filters-search.vue.js.map +1 -1
- package/js/x-modules/facets/components/lists/selected-filters-list.vue.js +11 -18
- package/js/x-modules/facets/components/lists/selected-filters-list.vue.js.map +1 -1
- package/js/x-modules/facets/components/lists/sliced-filters.vue.js +1 -4
- package/js/x-modules/facets/components/lists/sliced-filters.vue.js.map +1 -1
- package/js/x-modules/history-queries/components/clear-history-queries.vue.js +1 -2
- package/js/x-modules/history-queries/components/clear-history-queries.vue.js.map +1 -1
- package/js/x-modules/history-queries/components/history-queries.vue.js +1 -10
- package/js/x-modules/history-queries/components/history-queries.vue.js.map +1 -1
- package/js/x-modules/history-queries/components/history-query.vue.js +1 -6
- package/js/x-modules/history-queries/components/history-query.vue.js.map +1 -1
- package/js/x-modules/history-queries/components/my-history.vue.js +1 -4
- package/js/x-modules/history-queries/components/my-history.vue.js.map +1 -1
- package/js/x-modules/history-queries/components/remove-history-query.vue.js +1 -2
- package/js/x-modules/history-queries/components/remove-history-query.vue.js.map +1 -1
- package/js/x-modules/identifier-results/components/identifier-results.vue.js +1 -2
- package/js/x-modules/identifier-results/components/identifier-results.vue.js.map +1 -1
- package/js/x-modules/next-queries/components/next-queries.vue.js +1 -7
- package/js/x-modules/next-queries/components/next-queries.vue.js.map +1 -1
- package/js/x-modules/next-queries/components/next-query-preview.vue.js +1 -3
- package/js/x-modules/next-queries/components/next-query-preview.vue.js.map +1 -1
- package/js/x-modules/next-queries/components/next-query.vue.js +1 -4
- package/js/x-modules/next-queries/components/next-query.vue.js.map +1 -1
- package/js/x-modules/popular-searches/components/popular-search.vue.js +1 -4
- package/js/x-modules/popular-searches/components/popular-search.vue.js.map +1 -1
- package/js/x-modules/popular-searches/components/popular-searches.vue.js +1 -7
- package/js/x-modules/popular-searches/components/popular-searches.vue.js.map +1 -1
- package/js/x-modules/queries-preview/components/query-preview-button.vue.js +1 -2
- package/js/x-modules/queries-preview/components/query-preview-button.vue.js.map +1 -1
- package/js/x-modules/queries-preview/components/query-preview.vue.js +1 -2
- package/js/x-modules/queries-preview/components/query-preview.vue.js.map +1 -1
- package/js/x-modules/query-suggestions/components/query-suggestion.vue.js +1 -4
- package/js/x-modules/query-suggestions/components/query-suggestion.vue.js.map +1 -1
- package/js/x-modules/query-suggestions/components/query-suggestions.vue.js +1 -7
- package/js/x-modules/query-suggestions/components/query-suggestions.vue.js.map +1 -1
- package/js/x-modules/recommendations/components/recommendations.vue.js +1 -2
- package/js/x-modules/recommendations/components/recommendations.vue.js.map +1 -1
- package/js/x-modules/related-tags/components/related-tag.vue.js +1 -2
- package/js/x-modules/related-tags/components/related-tag.vue.js.map +1 -1
- package/js/x-modules/related-tags/components/related-tags.vue.js +1 -4
- package/js/x-modules/related-tags/components/related-tags.vue.js.map +1 -1
- package/js/x-modules/scroll/components/scroll-to-top.vue.js +1 -2
- package/js/x-modules/scroll/components/scroll-to-top.vue.js.map +1 -1
- package/js/x-modules/search/components/partial-results-list.vue.js +1 -2
- package/js/x-modules/search/components/partial-results-list.vue.js.map +1 -1
- package/js/x-modules/search/components/sort-dropdown.vue.js +1 -3
- package/js/x-modules/search/components/sort-dropdown.vue.js.map +1 -1
- package/js/x-modules/search-box/components/clear-search-input.vue.js +1 -2
- package/js/x-modules/search-box/components/clear-search-input.vue.js.map +1 -1
- package/js/x-modules/search-box/components/search-button.vue.js +1 -2
- package/js/x-modules/search-box/components/search-button.vue.js.map +1 -1
- package/js/x-modules/semantic-queries/components/semantic-queries.vue.js +1 -3
- package/js/x-modules/semantic-queries/components/semantic-queries.vue.js.map +1 -1
- package/js/x-modules/semantic-queries/components/semantic-query.vue.js +1 -4
- package/js/x-modules/semantic-queries/components/semantic-query.vue.js.map +1 -1
- package/package.json +2 -2
- package/report/x-components.api.json +11 -2
- package/report/x-components.api.md +1 -1
- package/types/x-installer/x-installer/types.d.ts +1 -1
- package/types/x-installer/x-installer/types.d.ts.map +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import _sfc_main from './base-tabs-panel.vue2.js';
|
|
2
|
-
import { openBlock, createElementBlock, createBlock, resolveDynamicComponent, normalizeClass, withCtx,
|
|
2
|
+
import { openBlock, createElementBlock, createBlock, resolveDynamicComponent, normalizeClass, withCtx, Fragment, renderList, renderSlot, mergeProps, createTextVNode, toDisplayString, normalizeProps, guardReactiveProps, createCommentVNode } from 'vue';
|
|
3
3
|
import './base-tabs-panel.vue3.js';
|
|
4
4
|
import _export_sfc from '../../_virtual/_plugin-vue_export-helper.js';
|
|
5
5
|
|
|
@@ -18,7 +18,6 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
18
18
|
role: "tablist"
|
|
19
19
|
}, {
|
|
20
20
|
default: withCtx(() => [
|
|
21
|
-
createCommentVNode("\n @slot Slot used to replace the whole tab.\n @binding {string} tab - The tab name.\n @binding {boolean} isSelected - Indicates if the tab is selected.\n @binding {function} select - Function to select the tab.\n "),
|
|
22
21
|
(openBlock(true), createElementBlock(
|
|
23
22
|
Fragment,
|
|
24
23
|
null,
|
|
@@ -33,7 +32,6 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
33
32
|
"data-test": "base-tabs-panel-button",
|
|
34
33
|
role: "tab"
|
|
35
34
|
}, [
|
|
36
|
-
createCommentVNode("\n @slot Slot used to just pass the content.\n @binding {string} tab - The tab name.\n @binding {boolean} isSelected - Indicates if the tab is selected.\n "),
|
|
37
35
|
renderSlot(_ctx.$slots, "tab-content", mergeProps({ ref_for: true }, { tab, isSelected: _ctx.tabIsSelected(tab) }), () => [
|
|
38
36
|
createTextVNode(
|
|
39
37
|
toDisplayString(tab),
|
|
@@ -60,7 +58,6 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
60
58
|
"data-test": "base-tabs-panel-content",
|
|
61
59
|
role: "tabpanel"
|
|
62
60
|
}, [
|
|
63
|
-
createCommentVNode("\n @slot Slot used to display the selected tab content.\n @binding {string} tab - This content's tab name.\n @binding {function} selectTab - Function to select a tab.\n @binding {function} deselectTab - Function to deselect the tab.\n "),
|
|
64
61
|
renderSlot(_ctx.$slots, _ctx.selectedTab, normalizeProps(guardReactiveProps({ tab: _ctx.selectedTab, selectTab: _ctx.selectTab, deselectTab: () => _ctx.selectTab(_ctx.selectedTab) })), void 0, true)
|
|
65
62
|
], 10, _hoisted_3)) : createCommentVNode("v-if", true)
|
|
66
63
|
]),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base-tabs-panel.vue.js","sources":["../../../../src/components/panels/base-tabs-panel.vue"],"sourcesContent":["<template>\n <section v-if=\"getTabs().length > 0\" class=\"x-tabs-panel\" data-test=\"base-tabs-panel\">\n <component\n :is=\"tabsAnimation\"\n class=\"x-tabs-panel__items-list\"\n :class=\"tabsListClass\"\n data-test=\"base-tabs-panel-list\"\n role=\"tablist\"\n >\n <!--\n @slot Slot used to replace the whole tab.\n @binding {string} tab - The tab name.\n @binding {boolean} isSelected - Indicates if the tab is selected.\n @binding {function} select - Function to select the tab.\n -->\n <slot\n v-for=\"tab in getTabs()\"\n name=\"tab\"\n v-bind=\"{ tab, isSelected: tabIsSelected(tab), select: () => selectTab(tab) }\"\n >\n <button\n :key=\"tab\"\n @click=\"selectTab(tab)\"\n :id=\"`base-tabs-panel-${tab}`\"\n class=\"x-tabs-panel__list-item x-tabs-panel__button x-button\"\n :class=\"tabIsSelected(tab) ? activeTabClass : tabClass\"\n :aria-selected=\"tabIsSelected(tab).toString()\"\n data-test=\"base-tabs-panel-button\"\n role=\"tab\"\n >\n <!--\n @slot Slot used to just pass the content.\n @binding {string} tab - The tab name.\n @binding {boolean} isSelected - Indicates if the tab is selected.\n -->\n <slot name=\"tab-content\" v-bind=\"{ tab, isSelected: tabIsSelected(tab) }\">\n {{ tab }}\n </slot>\n </button>\n </slot>\n </component>\n\n <component :is=\"contentAnimation\">\n <div\n v-if=\"selectedTab && slots[selectedTab]\"\n :key=\"selectedTab\"\n :class=\"contentClass\"\n :aria-labelledby=\"`base-tabs-panel-${selectedTab}`\"\n data-test=\"base-tabs-panel-content\"\n role=\"tabpanel\"\n >\n <!--\n @slot Slot used to display the selected tab content.\n @binding {string} tab - This content's tab name.\n @binding {function} selectTab - Function to select a tab.\n @binding {function} deselectTab - Function to deselect the tab.\n -->\n <slot\n :name=\"selectedTab\"\n v-bind=\"{ tab: selectedTab, selectTab, deselectTab: () => selectTab(selectedTab) }\"\n />\n </div>\n </component>\n </section>\n</template>\n\n<script lang=\"ts\">\n import { defineComponent, ref } from 'vue';\n import { AnimationProp } from '../../types';\n import { NoAnimation } from '../animations';\n\n /**\n * Base Tabs Panel.\n *\n * @public\n */\n export default defineComponent({\n name: 'BaseTabsPanel',\n props: {\n /**\n * Animation component that will be used to animate the tabs list.\n *\n * @public\n */\n tabsAnimation: {\n type: AnimationProp,\n default: 'header'\n },\n /**\n * Animation component that will be used to animate the selected tab content.\n *\n * @public\n */\n contentAnimation: {\n type: AnimationProp,\n default: () => NoAnimation\n },\n /**\n * The tab to be initially selected.\n *\n * @public\n */\n initialTab: {\n type: String,\n default: ''\n },\n /**\n * Allows the tabs to be unselected.\n *\n * @public\n */\n allowTabDeselect: {\n type: Boolean,\n default: false\n },\n /** Class inherited by content element. */\n activeTabClass: String,\n /** Class inherited by content element. */\n contentClass: String,\n /** Class inherited by content element. */\n tabClass: String,\n /** Class inherited by content element. */\n tabsListClass: String\n },\n setup: function (props, { slots }) {\n /**\n * The currently selected tab.\n *\n * @internal\n */\n const selectedTab = ref(props.initialTab);\n\n /**\n * Extracts the tab from the slots.\n *\n * @returns The list of tabs.\n *\n * @internal\n */\n const getTabs = () =>\n Object.keys(slots).filter(slotName => !['tab', 'tab-content'].includes(slotName));\n\n /**\n * Changes the current selected tab. If the tab is already selected\n * and `allowTabDeselect` is `true`, the tab will be unselected.\n *\n * @param tab - The tab to be selected.\n *\n * @internal\n */\n const selectTab = (tab: string) => {\n if (props.allowTabDeselect && selectedTab.value === tab) {\n selectedTab.value = '';\n } else {\n selectedTab.value = tab;\n }\n };\n\n /**\n * Checks if a tab is selected.\n *\n * @param tab - Tab to check.\n * @returns True if the tab is selected, false otherwise.\n *\n * @internal\n */\n const tabIsSelected = (tab: string) => selectedTab.value === tab;\n\n return {\n selectedTab,\n slots,\n getTabs,\n selectTab,\n tabIsSelected\n };\n }\n });\n</script>\n\n<style lang=\"css\" scoped>\n .x-tabs-panel__items-list {\n display: flex;\n }\n</style>\n\n<docs lang=\"mdx\">\n## Events\n\nThis component emits no events.\n\n## Examples\n\nThis component renders a list of tabs based on the name of the slots passed on its template. By\ndefault, the name of each slot will be used as tab label. If an initial tab is passed by prop, the\ncontent of its correspondent slot will displayed in a panel. Otherwise, no content will be displayed\nuntil a tab is selected.\n\n### Basic example\n\nIt renders a list of tabs and, when a tab is clicked, a panel with its content will be displayed.\n\n```vue\n<template>\n <BaseTabsPanel>\n <template #summer>\n <div>Summer Top Sales</div>\n </template>\n\n <template #fall>\n <div>Fall Top Sales</div>\n </template>\n\n <template #outlet>\n <div>Outlet Top Sales</div>\n </template>\n </BaseTabsPanel>\n</template>\n\n<script>\n import { BaseTabsPanel } from '@empathyco/x-components';\n\n export default {\n name: 'BaseTabsPanelDemo',\n components: {\n BaseTabsPanel\n }\n };\n</script>\n```\n\n### Play with props\n\n#### Define the tab to be initially opened\n\nBy default, no tab is selected so any panel is displayed. The `initialTab` prop allows to indicate\nwhich tab should be opened at first.\n\n```vue\n<template>\n <BaseTabsPanel initialTab=\"summer\">\n <template #summer>\n <div>Summer Top Sales</div>\n </template>\n\n <template #fall>\n <div>Fall Top Sales</div>\n </template>\n\n <template #outlet>\n <div>Outlet Top Sales</div>\n </template>\n </BaseTabsPanel>\n</template>\n\n<script>\n import { BaseTabsPanel } from '@empathyco/x-components';\n\n export default {\n name: 'BaseTabsPanelDemo',\n components: {\n BaseTabsPanel\n }\n };\n</script>\n```\n\n#### Allowing tabs deselection\n\nThe prop `allowTabDeselect` allows the tabs to be deselected. When a tab that is already selected is\nclicked again, the tab will be deselected and no panel content will be displayed. By default, this\nbehavior is deactivated.\n\n```vue\n<template>\n <BaseTabsPanel initialTab=\"summer\" allowTabDeselect>\n <template #summer>\n <div>Summer Top Sales</div>\n </template>\n\n <template #fall>\n <div>Fall Top Sales</div>\n </template>\n\n <template #outlet>\n <div>Outlet Top Sales</div>\n </template>\n </BaseTabsPanel>\n</template>\n\n<script>\n import { BaseTabsPanel } from '@empathyco/x-components';\n\n export default {\n name: 'BaseTabsPanelDemo',\n components: {\n BaseTabsPanel\n }\n };\n</script>\n```\n\n#### Customizing the content with classes\n\n- The `activeTabClass` prop can be used to add classes to the active tab button.\n- The `contentClass` prop can be used to add classes to the content.\n- The `tabClass` prop can be used to add classes to the tab buttons.\n- The `tabsListClass` prop can be used to add classes to the tabs list.\n\n```vue\n<template>\n <BaseTabsPanel\n activeTabClass=\"x-button-auxiliary\"\n contentClass=\"x-p-12 x-bg-auxiliary-25\"\n tabClass=\"x-button-ghost\"\n tabListClass=\"x-flex-col\"\n >\n <template #summer>\n <div>Summer Top Sales</div>\n </template>\n\n <template #fall>\n <div>Fall Top Sales</div>\n </template>\n\n <template #outlet>\n <div>Outlet Top Sales</div>\n </template>\n </BaseTabsPanel>\n</template>\n\n<script>\n import { BaseTabsPanel } from '@empathyco/x-components';\n\n export default {\n name: 'BaseTabsPanelDemo',\n components: {\n BaseTabsPanel\n }\n };\n</script>\n```\n\n#### Play with the animations\n\n- The `tabsAnimation` prop can be used to animate the tabs list.\n- The `contentAnimation` prop can be used to animate the selected tab content.\n\n```vue\n<template>\n <BaseTabsPanel :tabsAnimation=\"staggeredFadeAndSlide\" :contentAnimation=\"staggeredFadeAndSlide\">\n <template #summer>\n <div>Summer Top Sales</div>\n </template>\n\n <template #fall>\n <div>Fall Top Sales</div>\n </template>\n </BaseTabsPanel>\n</template>\n\n<script>\n import { BaseTabsPanel, StaggeredFadeAndSlide } from '@empathyco/x-components';\n\n export default {\n name: 'BaseTabsPanelDemo',\n components: {\n BaseTabsPanel\n },\n data() {\n return {\n staggeredFadeAndSlide: StaggeredFadeAndSlide\n };\n }\n };\n</script>\n```\n\n### Overriding the slots\n\n#### Customizing the tab button\n\nBy default, the component is rendering a button for each tab to be displayed. This button can be\nreplaced entirely through the `tab` slot.\n\n```vue\n<template>\n <BaseTabsPanel>\n <template #tab=\"{ tab, isSelected, select }\">\n <CheckIcon v-if=\"isSelected\" />\n This is the {{ tab }} tab.\n <button @click=\"select\">Open tab</button>\n </template>\n\n <template #summer>\n <div>Summer Top Sales</div>\n </template>\n\n <template #fall>\n <div>Fall Top Sales</div>\n </template>\n\n <template #outlet>\n <div>Outlet Top Sales</div>\n </template>\n </BaseTabsPanel>\n</template>\n\n<script>\n import { BaseTabsPanel, CheckIcon } from '@empathyco/x-components';\n\n export default {\n name: 'BaseTabsPanelDemo',\n components: {\n BaseTabsPanel,\n CheckIcon\n }\n };\n</script>\n```\n\n#### Customizing the tab button content\n\nAlternatively to the previous example, instead of changing the whole tab button, the slot\n`tab-content` offers the possibility of changing just its contents.\n\n```vue\n<template>\n <BaseTabsPanel>\n <template #tab-content=\"{ tab, isSelected }\">\n <CheckIcon v-if=\"isSelected\" />\n {{ tab }}\n </template>\n\n <template #summer>\n <div>Summer Top Sales</div>\n </template>\n\n <template #fall>\n <div>Fall Top Sales</div>\n </template>\n\n <template #outlet>\n <div>Outlet Top Sales</div>\n </template>\n </BaseTabsPanel>\n</template>\n\n<script>\n import { BaseTabsPanel, CheckIcon } from '@empathyco/x-components';\n\n export default {\n name: 'BaseTabsPanelDemo',\n components: {\n BaseTabsPanel,\n CheckIcon\n }\n };\n</script>\n```\n\n#### Customizing the tab panel content\n\nThe displayed tab name and a method to select a tab are exposed to the tab panel content slot.\n\n```vue\n<template>\n <BaseTabsPanel>\n <template #summer=\"{ tab, selectTab, deselectTab }\">\n <h1>{{ tab }}</h1>\n <button @click=\"() => selectTab('fall')\">Open Fall</button>\n <button @click=\"deselectTab\">Close tab</button>\n </template>\n\n <template #fall>\n <div>Fall Top Sales</div>\n </template>\n </BaseTabsPanel>\n</template>\n\n<script>\n import { BaseTabsPanel } from '@empathyco/x-components';\n\n export default {\n name: 'BaseTabsPanelDemo',\n components: {\n BaseTabsPanel\n }\n };\n</script>\n```\n</docs>\n"],"names":["_openBlock","tabsListClass","_createBlock","_resolveDynamicComponent","_normalizeClass","_withCtx","_createCommentVNode","_createElementBlock","_Fragment","_renderList","_renderSlot","_mergeProps","selectTab","tabIsSelected","_toDisplayString","slots","selected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,CAAA,gBAAA,EAAA,IAAA,CAAA,WAAA,CAAA,CAAA;AAAA,UAAA,WAAA,EAAA,yBAAA;AAEf,UAAA,IAAA,EAAA,UAAA;AAAA,SAMA,EAAA;AAAA,UAzDRX,kBAAA,CAAA,8RAAA,CAAA;AAAA,UAAAI,UAAA,CAAA,IAAA,CAAA,MAAA,EAAA,IAAA,CAAA,WAAA,EAAAQ,cAAA,CAAAC,kBAAA,CAAA,EAAA,GAAA,EAAA,IAAA,CAAA,WAAA,EAAA,SAAA,EAAA,IAAA,CAAA,SAAA,EAAA,WAAA,EAAA,MAAA,IAAA,CAAA,SAAA,CAAA,IAAA,CAAA,WAAA,CAAA,EAAA,CAAA,CAAA,EAAA,KAAA,CAAA,EAAA,IAAA,CAAA;AAAA,SAAA,EAAA,EAAA,EAAA,UAAA,CAAA,IAAAb,kBAAA,CAAA,MAAA,EAAA,IAAA,CAAA;AAAA,OAAA,CAAA;;;AAAA,KAAA,CAAA;AAAA,GAAA,CAAA,IAAAA,kBAAA,CAAA,MAAA,EAAA,IAAA,CAAA,CAAA;;;;;;"}
|
|
1
|
+
{"version":3,"file":"base-tabs-panel.vue.js","sources":["../../../../src/components/panels/base-tabs-panel.vue"],"sourcesContent":["<template>\n <section v-if=\"getTabs().length > 0\" class=\"x-tabs-panel\" data-test=\"base-tabs-panel\">\n <component\n :is=\"tabsAnimation\"\n class=\"x-tabs-panel__items-list\"\n :class=\"tabsListClass\"\n data-test=\"base-tabs-panel-list\"\n role=\"tablist\"\n >\n <!--\n @slot Slot used to replace the whole tab.\n @binding {string} tab - The tab name.\n @binding {boolean} isSelected - Indicates if the tab is selected.\n @binding {function} select - Function to select the tab.\n -->\n <slot\n v-for=\"tab in getTabs()\"\n name=\"tab\"\n v-bind=\"{ tab, isSelected: tabIsSelected(tab), select: () => selectTab(tab) }\"\n >\n <button\n :key=\"tab\"\n @click=\"selectTab(tab)\"\n :id=\"`base-tabs-panel-${tab}`\"\n class=\"x-tabs-panel__list-item x-tabs-panel__button x-button\"\n :class=\"tabIsSelected(tab) ? activeTabClass : tabClass\"\n :aria-selected=\"tabIsSelected(tab).toString()\"\n data-test=\"base-tabs-panel-button\"\n role=\"tab\"\n >\n <!--\n @slot Slot used to just pass the content.\n @binding {string} tab - The tab name.\n @binding {boolean} isSelected - Indicates if the tab is selected.\n -->\n <slot name=\"tab-content\" v-bind=\"{ tab, isSelected: tabIsSelected(tab) }\">\n {{ tab }}\n </slot>\n </button>\n </slot>\n </component>\n\n <component :is=\"contentAnimation\">\n <div\n v-if=\"selectedTab && slots[selectedTab]\"\n :key=\"selectedTab\"\n :class=\"contentClass\"\n :aria-labelledby=\"`base-tabs-panel-${selectedTab}`\"\n data-test=\"base-tabs-panel-content\"\n role=\"tabpanel\"\n >\n <!--\n @slot Slot used to display the selected tab content.\n @binding {string} tab - This content's tab name.\n @binding {function} selectTab - Function to select a tab.\n @binding {function} deselectTab - Function to deselect the tab.\n -->\n <slot\n :name=\"selectedTab\"\n v-bind=\"{ tab: selectedTab, selectTab, deselectTab: () => selectTab(selectedTab) }\"\n />\n </div>\n </component>\n </section>\n</template>\n\n<script lang=\"ts\">\n import { defineComponent, ref } from 'vue';\n import { AnimationProp } from '../../types';\n import { NoAnimation } from '../animations';\n\n /**\n * Base Tabs Panel.\n *\n * @public\n */\n export default defineComponent({\n name: 'BaseTabsPanel',\n props: {\n /**\n * Animation component that will be used to animate the tabs list.\n *\n * @public\n */\n tabsAnimation: {\n type: AnimationProp,\n default: 'header'\n },\n /**\n * Animation component that will be used to animate the selected tab content.\n *\n * @public\n */\n contentAnimation: {\n type: AnimationProp,\n default: () => NoAnimation\n },\n /**\n * The tab to be initially selected.\n *\n * @public\n */\n initialTab: {\n type: String,\n default: ''\n },\n /**\n * Allows the tabs to be unselected.\n *\n * @public\n */\n allowTabDeselect: {\n type: Boolean,\n default: false\n },\n /** Class inherited by content element. */\n activeTabClass: String,\n /** Class inherited by content element. */\n contentClass: String,\n /** Class inherited by content element. */\n tabClass: String,\n /** Class inherited by content element. */\n tabsListClass: String\n },\n setup: function (props, { slots }) {\n /**\n * The currently selected tab.\n *\n * @internal\n */\n const selectedTab = ref(props.initialTab);\n\n /**\n * Extracts the tab from the slots.\n *\n * @returns The list of tabs.\n *\n * @internal\n */\n const getTabs = () =>\n Object.keys(slots).filter(slotName => !['tab', 'tab-content'].includes(slotName));\n\n /**\n * Changes the current selected tab. If the tab is already selected\n * and `allowTabDeselect` is `true`, the tab will be unselected.\n *\n * @param tab - The tab to be selected.\n *\n * @internal\n */\n const selectTab = (tab: string) => {\n if (props.allowTabDeselect && selectedTab.value === tab) {\n selectedTab.value = '';\n } else {\n selectedTab.value = tab;\n }\n };\n\n /**\n * Checks if a tab is selected.\n *\n * @param tab - Tab to check.\n * @returns True if the tab is selected, false otherwise.\n *\n * @internal\n */\n const tabIsSelected = (tab: string) => selectedTab.value === tab;\n\n return {\n selectedTab,\n slots,\n getTabs,\n selectTab,\n tabIsSelected\n };\n }\n });\n</script>\n\n<style lang=\"css\" scoped>\n .x-tabs-panel__items-list {\n display: flex;\n }\n</style>\n\n<docs lang=\"mdx\">\n## Events\n\nThis component emits no events.\n\n## Examples\n\nThis component renders a list of tabs based on the name of the slots passed on its template. By\ndefault, the name of each slot will be used as tab label. If an initial tab is passed by prop, the\ncontent of its correspondent slot will displayed in a panel. Otherwise, no content will be displayed\nuntil a tab is selected.\n\n### Basic example\n\nIt renders a list of tabs and, when a tab is clicked, a panel with its content will be displayed.\n\n```vue\n<template>\n <BaseTabsPanel>\n <template #summer>\n <div>Summer Top Sales</div>\n </template>\n\n <template #fall>\n <div>Fall Top Sales</div>\n </template>\n\n <template #outlet>\n <div>Outlet Top Sales</div>\n </template>\n </BaseTabsPanel>\n</template>\n\n<script>\n import { BaseTabsPanel } from '@empathyco/x-components';\n\n export default {\n name: 'BaseTabsPanelDemo',\n components: {\n BaseTabsPanel\n }\n };\n</script>\n```\n\n### Play with props\n\n#### Define the tab to be initially opened\n\nBy default, no tab is selected so any panel is displayed. The `initialTab` prop allows to indicate\nwhich tab should be opened at first.\n\n```vue\n<template>\n <BaseTabsPanel initialTab=\"summer\">\n <template #summer>\n <div>Summer Top Sales</div>\n </template>\n\n <template #fall>\n <div>Fall Top Sales</div>\n </template>\n\n <template #outlet>\n <div>Outlet Top Sales</div>\n </template>\n </BaseTabsPanel>\n</template>\n\n<script>\n import { BaseTabsPanel } from '@empathyco/x-components';\n\n export default {\n name: 'BaseTabsPanelDemo',\n components: {\n BaseTabsPanel\n }\n };\n</script>\n```\n\n#### Allowing tabs deselection\n\nThe prop `allowTabDeselect` allows the tabs to be deselected. When a tab that is already selected is\nclicked again, the tab will be deselected and no panel content will be displayed. By default, this\nbehavior is deactivated.\n\n```vue\n<template>\n <BaseTabsPanel initialTab=\"summer\" allowTabDeselect>\n <template #summer>\n <div>Summer Top Sales</div>\n </template>\n\n <template #fall>\n <div>Fall Top Sales</div>\n </template>\n\n <template #outlet>\n <div>Outlet Top Sales</div>\n </template>\n </BaseTabsPanel>\n</template>\n\n<script>\n import { BaseTabsPanel } from '@empathyco/x-components';\n\n export default {\n name: 'BaseTabsPanelDemo',\n components: {\n BaseTabsPanel\n }\n };\n</script>\n```\n\n#### Customizing the content with classes\n\n- The `activeTabClass` prop can be used to add classes to the active tab button.\n- The `contentClass` prop can be used to add classes to the content.\n- The `tabClass` prop can be used to add classes to the tab buttons.\n- The `tabsListClass` prop can be used to add classes to the tabs list.\n\n```vue\n<template>\n <BaseTabsPanel\n activeTabClass=\"x-button-auxiliary\"\n contentClass=\"x-p-12 x-bg-auxiliary-25\"\n tabClass=\"x-button-ghost\"\n tabListClass=\"x-flex-col\"\n >\n <template #summer>\n <div>Summer Top Sales</div>\n </template>\n\n <template #fall>\n <div>Fall Top Sales</div>\n </template>\n\n <template #outlet>\n <div>Outlet Top Sales</div>\n </template>\n </BaseTabsPanel>\n</template>\n\n<script>\n import { BaseTabsPanel } from '@empathyco/x-components';\n\n export default {\n name: 'BaseTabsPanelDemo',\n components: {\n BaseTabsPanel\n }\n };\n</script>\n```\n\n#### Play with the animations\n\n- The `tabsAnimation` prop can be used to animate the tabs list.\n- The `contentAnimation` prop can be used to animate the selected tab content.\n\n```vue\n<template>\n <BaseTabsPanel :tabsAnimation=\"staggeredFadeAndSlide\" :contentAnimation=\"staggeredFadeAndSlide\">\n <template #summer>\n <div>Summer Top Sales</div>\n </template>\n\n <template #fall>\n <div>Fall Top Sales</div>\n </template>\n </BaseTabsPanel>\n</template>\n\n<script>\n import { BaseTabsPanel, StaggeredFadeAndSlide } from '@empathyco/x-components';\n\n export default {\n name: 'BaseTabsPanelDemo',\n components: {\n BaseTabsPanel\n },\n data() {\n return {\n staggeredFadeAndSlide: StaggeredFadeAndSlide\n };\n }\n };\n</script>\n```\n\n### Overriding the slots\n\n#### Customizing the tab button\n\nBy default, the component is rendering a button for each tab to be displayed. This button can be\nreplaced entirely through the `tab` slot.\n\n```vue\n<template>\n <BaseTabsPanel>\n <template #tab=\"{ tab, isSelected, select }\">\n <CheckIcon v-if=\"isSelected\" />\n This is the {{ tab }} tab.\n <button @click=\"select\">Open tab</button>\n </template>\n\n <template #summer>\n <div>Summer Top Sales</div>\n </template>\n\n <template #fall>\n <div>Fall Top Sales</div>\n </template>\n\n <template #outlet>\n <div>Outlet Top Sales</div>\n </template>\n </BaseTabsPanel>\n</template>\n\n<script>\n import { BaseTabsPanel, CheckIcon } from '@empathyco/x-components';\n\n export default {\n name: 'BaseTabsPanelDemo',\n components: {\n BaseTabsPanel,\n CheckIcon\n }\n };\n</script>\n```\n\n#### Customizing the tab button content\n\nAlternatively to the previous example, instead of changing the whole tab button, the slot\n`tab-content` offers the possibility of changing just its contents.\n\n```vue\n<template>\n <BaseTabsPanel>\n <template #tab-content=\"{ tab, isSelected }\">\n <CheckIcon v-if=\"isSelected\" />\n {{ tab }}\n </template>\n\n <template #summer>\n <div>Summer Top Sales</div>\n </template>\n\n <template #fall>\n <div>Fall Top Sales</div>\n </template>\n\n <template #outlet>\n <div>Outlet Top Sales</div>\n </template>\n </BaseTabsPanel>\n</template>\n\n<script>\n import { BaseTabsPanel, CheckIcon } from '@empathyco/x-components';\n\n export default {\n name: 'BaseTabsPanelDemo',\n components: {\n BaseTabsPanel,\n CheckIcon\n }\n };\n</script>\n```\n\n#### Customizing the tab panel content\n\nThe displayed tab name and a method to select a tab are exposed to the tab panel content slot.\n\n```vue\n<template>\n <BaseTabsPanel>\n <template #summer=\"{ tab, selectTab, deselectTab }\">\n <h1>{{ tab }}</h1>\n <button @click=\"() => selectTab('fall')\">Open Fall</button>\n <button @click=\"deselectTab\">Close tab</button>\n </template>\n\n <template #fall>\n <div>Fall Top Sales</div>\n </template>\n </BaseTabsPanel>\n</template>\n\n<script>\n import { BaseTabsPanel } from '@empathyco/x-components';\n\n export default {\n name: 'BaseTabsPanelDemo',\n components: {\n BaseTabsPanel\n }\n };\n</script>\n```\n</docs>\n"],"names":["_openBlock","tabsListClass","_createBlock","_resolveDynamicComponent","_normalizeClass","_createElementBlock","_Fragment","_renderList","_renderSlot","_mergeProps","selectTab","tabIsSelected","_toDisplayString","slots","_withCtx","selectedTab","contentClass","_normalizeProps","_guardReactiveProps","_createCommentVNode"],"mappings":";;;;;MACuC,UAAM,GAAA;AAAA,EAAe,GAAA,EAAA,CAAA;AAAA,EAAA,KAAA,EAAA,cAAA;;;;;AAA1D,SAAA,WAAA,CAAA,IAAA,EAAA,MAAA,EAAA,MAAA,EA8DU,eA9DV,QA8DU,EAAA;AA7DR,EAAA,OAAA,IAAA,CAAA,OAAA,EAAA,CAAA,MAAA,GAAA,CAAA,IAAAA,SAAA,uBAEQ,SACEC,EAAAA,UAAAA,EAAAA;AAAAA,KAAAA,SAAAA,IACEC,WAAsB,CAAAC,uBAAA,CAAA,IAAA,CAAA,aAAA,CAAA,EAAA;AAAA,MAChC,OAAKC,cAAS,CAAA,CAAA,0BAAA,EAAA,IAAA,CAAA,aAAA,CAAA,CAAA;AAAA,MAAA,WAAA,EAAA,sBAAA;AAPpB,MAAA,I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AZ,SAAA,gBAjBiBa,uBAAiB,CAAA,IAAA,CAAA,gBAAA,CAAA,EAAA,IAAA,EAAA;AAAA,MADxC,OAAA,EAAAC,OAAA,CAAA,MAAA;AAAA,QAAA,IAAA,CAEG,WAAKC,IAAAA,IAAAA,CAAAA,KAAAA,CAAW,IA7CzB,CAAA,WAAA,CAAA,IAAAf,SAAA,EAAA,EAAAK,kBAAA,CA8CgBW,KAAY,EAAA;AAAA,UACnB,GAAA,EAAA,IAAA,CAAA,WAAA;AAAA,UACD,sBAAU,IAAyB,CAAA,YAAA,CAAA;AAAA,UACnC,iBAAe,EAAA,CAAA,gBAAA,EAAA,IAAA,CAAA,WAAA,CAAA,CAAA;AAAA,UAAA,WAAA,EAAA,yBAAA;AAQf,UAAA,IAAA,EAAA,UAAA;AAAA,SAAA,EAAA;AAzDR,UAAAR,UAAA,CAAA,IAAA,CAAA,MAAA,EAAA,IAAA,CAAA,WAAA,EAAAS,cAAA,CAAAC,kBAAA,CAAA,EAAA,GAAA,EAAA,IAAA,CAAA,WAAA,EAAA,SAAA,EAAA,IAAA,CAAA,SAAA,EAAA,WAAA,EAAA,MAAA,IAAA,CAAA,SAAA,CAAA,IAAA,CAAA,WAAA,CAAA,EAAA,CAAA,CAAA,EAAA,KAAA,CAAA,EAAA,IAAA,CAAA;AAAA,SAAA,EAAA,EAAA,EAAA,UAAA,CAAA,IAAAC,kBAAA,CAAA,MAAA,EAAA,IAAA,CAAA;AAAA,OAAA,CAAA;;;AAAA,KAAA,CAAA;AAAA,GAAA,CAAA,IAAAA,kBAAA,CAAA,MAAA,EAAA,IAAA,CAAA,CAAA;;;;;;"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import _sfc_main from './base-toggle-panel.vue2.js';
|
|
2
|
-
import { openBlock, createBlock, resolveDynamicComponent, withCtx, createElementBlock,
|
|
2
|
+
import { openBlock, createBlock, resolveDynamicComponent, withCtx, createElementBlock, renderSlot, createCommentVNode } from 'vue';
|
|
3
3
|
import _export_sfc from '../../_virtual/_plugin-vue_export-helper.js';
|
|
4
4
|
|
|
5
5
|
const _hoisted_1 = {
|
|
@@ -11,7 +11,6 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
11
11
|
return openBlock(), createBlock(resolveDynamicComponent(_ctx.animation), null, {
|
|
12
12
|
default: withCtx(() => [
|
|
13
13
|
_ctx.open ? (openBlock(), createElementBlock("div", _hoisted_1, [
|
|
14
|
-
createCommentVNode(" @slot (Required) Default content "),
|
|
15
14
|
renderSlot(_ctx.$slots, "default")
|
|
16
15
|
])) : createCommentVNode("v-if", true)
|
|
17
16
|
]),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base-toggle-panel.vue.js","sources":["../../../../src/components/panels/base-toggle-panel.vue"],"sourcesContent":["<template>\n <component :is=\"animation\">\n <div v-if=\"open\" class=\"x-toggle-panel\" data-test=\"base-toggle-panel\">\n <!-- @slot (Required) Default content -->\n <slot />\n </div>\n </component>\n</template>\n\n<script lang=\"ts\">\n import { defineComponent } from 'vue';\n import { AnimationProp } from '../../types/animation-prop';\n\n /**\n * Simple panel that receives its open state via prop, which is responsible of rendering\n * default slot inside a configurable transition.\n *\n * @public\n */\n export default defineComponent({\n props: {\n /**\n * Handles if the panel is rendered. It is used with v-if instead of v-show to get better\n * performance.\n *\n * @public\n */\n open: {\n type: Boolean,\n required: true\n },\n /**\n * Animation component that will be used to animate the panel content.\n *\n * @public\n */\n animation: {\n type: AnimationProp,\n default: 'div'\n }\n }\n });\n</script>\n\n<docs lang=\"mdx\">\n## Examples\n\nSimple panel that receives its open state via prop, which is responsible of rendering default slot\ninside a configurable transition.\n\n### Basic usage\n\nUsing default slot:\n\n```vue\n<BaseTogglePanel :open=\"true\" :animation=\"collapseFromTop\">\n <Filters :filters=\"filters\">\n <template #default=\"{ filter }\">\n <p>{{ filter.label }}</p>\n </template>\n </Filters>\n</BaseTogglePanel>\n```\n</docs>\n"],"names":["open","_createBlock","_resolveDynamicComponent","_withCtx","
|
|
1
|
+
{"version":3,"file":"base-toggle-panel.vue.js","sources":["../../../../src/components/panels/base-toggle-panel.vue"],"sourcesContent":["<template>\n <component :is=\"animation\">\n <div v-if=\"open\" class=\"x-toggle-panel\" data-test=\"base-toggle-panel\">\n <!-- @slot (Required) Default content -->\n <slot />\n </div>\n </component>\n</template>\n\n<script lang=\"ts\">\n import { defineComponent } from 'vue';\n import { AnimationProp } from '../../types/animation-prop';\n\n /**\n * Simple panel that receives its open state via prop, which is responsible of rendering\n * default slot inside a configurable transition.\n *\n * @public\n */\n export default defineComponent({\n props: {\n /**\n * Handles if the panel is rendered. It is used with v-if instead of v-show to get better\n * performance.\n *\n * @public\n */\n open: {\n type: Boolean,\n required: true\n },\n /**\n * Animation component that will be used to animate the panel content.\n *\n * @public\n */\n animation: {\n type: AnimationProp,\n default: 'div'\n }\n }\n });\n</script>\n\n<docs lang=\"mdx\">\n## Examples\n\nSimple panel that receives its open state via prop, which is responsible of rendering default slot\ninside a configurable transition.\n\n### Basic usage\n\nUsing default slot:\n\n```vue\n<BaseTogglePanel :open=\"true\" :animation=\"collapseFromTop\">\n <Filters :filters=\"filters\">\n <template #default=\"{ filter }\">\n <p>{{ filter.label }}</p>\n </template>\n </Filters>\n</BaseTogglePanel>\n```\n</docs>\n"],"names":["open","_createBlock","_resolveDynamicComponent","_withCtx","_openBlock","_createElementBlock","_renderSlot","_createCommentVNode"],"mappings":";;;;MAEqB,UAAM,GAAA;AAAA,EAAiB,GAAA,EAAA,CAAA;AAAA,EAAA,KAAA,EAAA,gBAAA;;;SAF5C,WAKU,CAAA,IAAA,EAAA,MAAA,EAAA,MAAA,EAAA,MAAA,EAAA,KAAA,EAAA,QAAA,EAAA;SAHKA,SAAI,EAAA,EAAAC,WAAA,CAAAC,uBAAA,CAAA,IAAA,CAAA,SAAA,CAAA,EAAA,IAAA,EAAA;AAAA,IAAf,OAAA,EAAAC,OAAA,CAAA,MAAA;AAAA,MAEE,IAAA,CAAA,IAAA,IAAAC,SAAA,EAAA,EAAAC,kBAAA,CAAA,KAAA,EAAA,UAAA,EAAA;AAJN,QAAAC,UAAA,CAAA,IAAA,CAAA,MAAA,EAAA,SAAA,CAAA;AAAA,OAAA,CAAA,IAAAC,kBAAA,CAAA,MAAA,EAAA,IAAA,CAAA;AAAA,KAAA,CAAA;;;;;;;;;"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import _sfc_main from './base-result-add-to-cart.vue2.js';
|
|
2
|
-
import { resolveComponent, openBlock, createBlock, withCtx,
|
|
2
|
+
import { resolveComponent, openBlock, createBlock, withCtx, renderSlot } from 'vue';
|
|
3
3
|
import _export_sfc from '../../_virtual/_plugin-vue_export-helper.js';
|
|
4
4
|
|
|
5
5
|
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
@@ -10,7 +10,6 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
10
10
|
"data-test": "result-add-to-cart"
|
|
11
11
|
}, {
|
|
12
12
|
default: withCtx(() => [
|
|
13
|
-
createCommentVNode(" @slot (Required) Button content with a text, an icon or both "),
|
|
14
13
|
renderSlot(_ctx.$slots, "default")
|
|
15
14
|
]),
|
|
16
15
|
_: 3
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base-result-add-to-cart.vue.js","sources":["../../../../src/components/result/base-result-add-to-cart.vue"],"sourcesContent":["<template>\n <BaseEventButton\n :events=\"events\"\n class=\"x-result-add-to-cart x-button\"\n data-test=\"result-add-to-cart\"\n >\n <!-- @slot (Required) Button content with a text, an icon or both -->\n <slot />\n </BaseEventButton>\n</template>\n\n<script lang=\"ts\">\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} 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</script>\n\n<docs lang=\"mdx\">\n## Events\n\nA list of events that the component will emit:\n\n- [`UserClickedResultAddToCart`](https://github.com/empathyco/x/blob/main/packages/x-components/src/wiring/events.types.ts):\n the event is emitted after the user clicks the button. The event payload is the result data.\n\n## Examples\n\nRenders a button with a default slot. It receives the result with the data and emits an event\n`UserClickedResultAddToCart` to the bus on click mouse event.\n\n### Basic example\n\nThis component is a button to emit `UserClickedResultAddToCart` whe clicked by the user\n\n```vue\n<BaseResultAddToCart :result=\"result\">\n <img src=\"./add-to-cart.svg\" />\n <span>Add to cart</span>\n</BaseResultAddToCart>\n```\n</docs>\n"],"names":["_resolveComponent","_openBlock","_createBlock","
|
|
1
|
+
{"version":3,"file":"base-result-add-to-cart.vue.js","sources":["../../../../src/components/result/base-result-add-to-cart.vue"],"sourcesContent":["<template>\n <BaseEventButton\n :events=\"events\"\n class=\"x-result-add-to-cart x-button\"\n data-test=\"result-add-to-cart\"\n >\n <!-- @slot (Required) Button content with a text, an icon or both -->\n <slot />\n </BaseEventButton>\n</template>\n\n<script lang=\"ts\">\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} 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</script>\n\n<docs lang=\"mdx\">\n## Events\n\nA list of events that the component will emit:\n\n- [`UserClickedResultAddToCart`](https://github.com/empathyco/x/blob/main/packages/x-components/src/wiring/events.types.ts):\n the event is emitted after the user clicks the button. The event payload is the result data.\n\n## Examples\n\nRenders a button with a default slot. It receives the result with the data and emits an event\n`UserClickedResultAddToCart` to the bus on click mouse event.\n\n### Basic example\n\nThis component is a button to emit `UserClickedResultAddToCart` whe clicked by the user\n\n```vue\n<BaseResultAddToCart :result=\"result\">\n <img src=\"./add-to-cart.svg\" />\n <span>Add to cart</span>\n</BaseResultAddToCart>\n```\n</docs>\n"],"names":["_resolveComponent","_openBlock","_createBlock","_renderSlot"],"mappings":";;;;;AAQoB,EAAA,MAAA,0BAAA,GAAAA,gBAAA,CAAA,iBAAA,CAAA,CAAA;AALX,EAAA,OAAAC,SAAA,EAAgC,EAAAC,WAAA,CAAA,0BAAA,EAAA;AAAA,IACrC,MAAU,EAAA,IAAA,CAAA,MAAA;AAAA,IAAA,KAAA,EAAA,+BAAA;AAJd,IAAA,WAAA,EAAA,oBAAA;AAAA,GAAA,EAAA;;AAAA,MAAAC,UAAA,CAAA,IAAA,CAAA,MAAA,EAAA,SAAA,CAAA;AAAA,KAAA,CAAA;;;;;;;;;"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import _sfc_main from './base-result-current-price.vue2.js';
|
|
2
|
-
import { resolveComponent, openBlock, createElementBlock, normalizeClass,
|
|
2
|
+
import { resolveComponent, openBlock, createElementBlock, normalizeClass, renderSlot, createVNode } from 'vue';
|
|
3
3
|
import _export_sfc from '../../_virtual/_plugin-vue_export-helper.js';
|
|
4
4
|
|
|
5
5
|
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
@@ -11,7 +11,6 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
11
11
|
"data-test": "result-current-price"
|
|
12
12
|
},
|
|
13
13
|
[
|
|
14
|
-
createCommentVNode("\n @slot Base currency item\n @binding {result} result - Result data\n "),
|
|
15
14
|
renderSlot(_ctx.$slots, "default", { result: _ctx.result }, () => [
|
|
16
15
|
createVNode(_component_BaseCurrency, {
|
|
17
16
|
value: _ctx.result.price.value,
|
|
@@ -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 { 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} 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} 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":["_resolveComponent","_openBlock","_createElementBlock","_normalizeClass","
|
|
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} 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} 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":["_resolveComponent","_openBlock","_createElementBlock","_normalizeClass","result","_createVNode","format"],"mappings":";;;;;kCACEA,gBAQM,CAAA,cAAA,CAAA,CAAA;SARsDC,SAAU,EAAA,EAAAC,kBAAA;AAAA,IAAsB,KAAA;AAAA,IAAA;AAAA,MAAA,KAAA,EAAAC,cAAA,CAAA,CAAA,IAAA,CAAA,cAAA,EAAA,wBAAA,CAAA,CAAA;MAK1F,WAEO,EAAA,sBAAA;AAAA,KAAA;;AADiBC,MAAAA,UAAAA,CAAAA,IAAAA,CAAAA,MAAAA,EAAO,SAAW,EAAA,EAAA,MAAA,EAAA,IAAA,CAAA,MAAA,EAAA,EAAA,MAAA;AAAA,QAAAC,WAAA,CAAWC,uBAAM,EAAA;AAAA,UAAA,KAAA,EAAA,IAAA,CAAA,MAAA,CAAA,KAAA,CAAA,KAAA;;;;;;;;;;;;;"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import _sfc_main from './base-result-image.vue2.js';
|
|
2
|
-
import { openBlock, createElementBlock,
|
|
2
|
+
import { openBlock, createElementBlock, normalizeStyle, createCommentVNode, createBlock, resolveDynamicComponent, withCtx, renderSlot } from 'vue';
|
|
3
3
|
import './base-result-image.vue3.js';
|
|
4
4
|
import _export_sfc from '../../_virtual/_plugin-vue_export-helper.js';
|
|
5
5
|
|
|
@@ -7,66 +7,46 @@ const _hoisted_1 = ["src"];
|
|
|
7
7
|
const _hoisted_2 = ["alt", "src"];
|
|
8
8
|
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
9
9
|
return openBlock(), createElementBlock(
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
"div",
|
|
11
|
+
{
|
|
12
|
+
onMouseenterOnce: _cache[2] || (_cache[2] = ($event) => _ctx.userHasHoveredImage = true),
|
|
13
|
+
onMouseenter: _cache[3] || (_cache[3] = ($event) => _ctx.isHovering = true),
|
|
14
|
+
onMouseleave: _cache[4] || (_cache[4] = ($event) => _ctx.isHovering = false),
|
|
15
|
+
class: "x-result-picture x-picture",
|
|
16
|
+
"data-test": "result-picture"
|
|
17
|
+
},
|
|
12
18
|
[
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
}, null,
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
default: withCtx(() => [
|
|
42
|
-
createCommentVNode(" @slot Fallback image content. It will be rendered when all the images failed "),
|
|
43
|
-
!_ctx.loadedImages.length && !_ctx.pendingImages.length ? renderSlot(_ctx.$slots, "fallback", { key: 0 }, void 0, true) : !_ctx.loadedImages.length ? (openBlock(), createElementBlock(
|
|
44
|
-
Fragment,
|
|
45
|
-
{ key: 1 },
|
|
46
|
-
[
|
|
47
|
-
createCommentVNode(" @slot Loading image content. It will be rendered while the real image is not loaded "),
|
|
48
|
-
renderSlot(_ctx.$slots, "placeholder", {}, void 0, true)
|
|
49
|
-
],
|
|
50
|
-
2112
|
|
51
|
-
/* STABLE_FRAGMENT, DEV_ROOT_FRAGMENT */
|
|
52
|
-
)) : (openBlock(), createElementBlock("img", {
|
|
53
|
-
key: _ctx.imageSrc,
|
|
54
|
-
alt: _ctx.result.name,
|
|
55
|
-
src: _ctx.imageSrc,
|
|
56
|
-
class: "x-result-picture-image",
|
|
57
|
-
"data-test": "result-picture-image"
|
|
58
|
-
}, null, 8, _hoisted_2))
|
|
59
|
-
]),
|
|
60
|
-
_: 3
|
|
61
|
-
/* FORWARDED */
|
|
62
|
-
}))
|
|
63
|
-
],
|
|
64
|
-
32
|
|
65
|
-
/* NEED_HYDRATION */
|
|
66
|
-
)
|
|
19
|
+
_ctx.shouldLoadNextImage ? (openBlock(), createElementBlock("img", {
|
|
20
|
+
key: 0,
|
|
21
|
+
onLoad: _cache[0] || (_cache[0] = (...args) => _ctx.flagImageLoaded && _ctx.flagImageLoaded(...args)),
|
|
22
|
+
onError: _cache[1] || (_cache[1] = (...args) => _ctx.flagImageAsFailed && _ctx.flagImageAsFailed(...args)),
|
|
23
|
+
loading: "lazy",
|
|
24
|
+
src: _ctx.pendingImages[0],
|
|
25
|
+
style: normalizeStyle(_ctx.loaderStyles),
|
|
26
|
+
class: "x-picture-image",
|
|
27
|
+
"data-test": "result-picture-loader",
|
|
28
|
+
alt: "",
|
|
29
|
+
role: "presentation"
|
|
30
|
+
}, null, 44, _hoisted_1)) : createCommentVNode("v-if", true),
|
|
31
|
+
(openBlock(), createBlock(resolveDynamicComponent(_ctx.animation), {
|
|
32
|
+
class: "x-picture-image",
|
|
33
|
+
appear: false
|
|
34
|
+
}, {
|
|
35
|
+
default: withCtx(() => [
|
|
36
|
+
!_ctx.loadedImages.length && !_ctx.pendingImages.length ? renderSlot(_ctx.$slots, "fallback", { key: 0 }, void 0, true) : !_ctx.loadedImages.length ? renderSlot(_ctx.$slots, "placeholder", { key: 1 }, void 0, true) : (openBlock(), createElementBlock("img", {
|
|
37
|
+
key: _ctx.imageSrc,
|
|
38
|
+
alt: _ctx.result.name,
|
|
39
|
+
src: _ctx.imageSrc,
|
|
40
|
+
class: "x-result-picture-image",
|
|
41
|
+
"data-test": "result-picture-image"
|
|
42
|
+
}, null, 8, _hoisted_2))
|
|
43
|
+
]),
|
|
44
|
+
_: 3
|
|
45
|
+
/* FORWARDED */
|
|
46
|
+
}))
|
|
67
47
|
],
|
|
68
|
-
|
|
69
|
-
/*
|
|
48
|
+
32
|
|
49
|
+
/* NEED_HYDRATION */
|
|
70
50
|
);
|
|
71
51
|
}
|
|
72
52
|
var baseResultImage = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render], ["__scopeId", "data-v-17531567"]]);
|
|
@@ -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 { computed, defineComponent, PropType, Ref, ref, watch } from 'vue';\n import { NoAnimation } from '../animations';\n import { AnimationProp } from '../../types';\n\n /**\n * Component to be reused that renders an `<img>`.\n *\n * @public\n */\n export default defineComponent({\n name: 'BaseResultImage',\n props: {\n /** (Required) The {@link @empathyco/x-types#Result} information. */\n result: {\n type: Object as PropType<Result>,\n required: true\n },\n /**\n * Animation to use when switching between the placeholder, the loaded image, or the failed\n * image fallback.\n */\n loadAnimation: {\n type: AnimationProp,\n default: () => NoAnimation\n },\n /** Animation to use when switching between the loaded image and the hover image. */\n hoverAnimation: {\n type: AnimationProp\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 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 /**\n * Initializes images state and resets when the result's images change.\n *\n * @internal\n */\n watch(\n () => props.result.images,\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(() => {\n return userHasHoveredImage.value\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(() => {\n return loadedImages.value[\n !props.showNextImageOnHover || !isHovering.value ? 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(() => {\n const numImagesToLoad = props.showNextImageOnHover && userHasHoveredImage.value ? 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 = () => {\n pendingImages.value.shift();\n };\n\n /**\n * Sets an image as loaded.\n *\n * @internal\n */\n const flagImageLoaded = () => {\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=\"css\" scoped>\n .x-result-picture {\n position: relative;\n min-width: 1px;\n min-height: 1px;\n }\n\n .x-result-picture-image {\n max-width: 100%;\n max-height: 100%;\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":["_openBlock","_createElementBlock","_Fragment","_createCommentVNode","_createElementVNode","isHovering","shouldLoadNextImage","pendingImages","animation","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AAA,CAAA,IAAA;AAAA,gBACN,GAAA,EAAA,IAAA,CAAA,QAAA;AAAA,gBAAA,KAAA,EAAA,wBAAA;;AAnCR,eAAA,EAAA,IAAA,EAAA,CAAA,EAAA,UAAA,CAAA,CAAA;AAAA,aAAA,CAAA;;;;;;;;;;;;;;;;;"}
|
|
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 { computed, defineComponent, PropType, Ref, ref, watch } from 'vue';\n import { NoAnimation } from '../animations';\n import { AnimationProp } from '../../types';\n\n /**\n * Component to be reused that renders an `<img>`.\n *\n * @public\n */\n export default defineComponent({\n name: 'BaseResultImage',\n props: {\n /** (Required) The {@link @empathyco/x-types#Result} information. */\n result: {\n type: Object as PropType<Result>,\n required: true\n },\n /**\n * Animation to use when switching between the placeholder, the loaded image, or the failed\n * image fallback.\n */\n loadAnimation: {\n type: AnimationProp,\n default: () => NoAnimation\n },\n /** Animation to use when switching between the loaded image and the hover image. */\n hoverAnimation: {\n type: AnimationProp\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 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 /**\n * Initializes images state and resets when the result's images change.\n *\n * @internal\n */\n watch(\n () => props.result.images,\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(() => {\n return userHasHoveredImage.value\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(() => {\n return loadedImages.value[\n !props.showNextImageOnHover || !isHovering.value ? 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(() => {\n const numImagesToLoad = props.showNextImageOnHover && userHasHoveredImage.value ? 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 = () => {\n pendingImages.value.shift();\n };\n\n /**\n * Sets an image as loaded.\n *\n * @internal\n */\n const flagImageLoaded = () => {\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=\"css\" scoped>\n .x-result-picture {\n position: relative;\n min-width: 1px;\n min-height: 1px;\n }\n\n .x-result-picture-image {\n max-width: 100%;\n max-height: 100%;\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":["userHasHoveredImage","_openBlock","_createElementBlock","isHovering","shouldLoadNextImage","pendingImages","animation","_createCommentVNode","_createBlock","_resolveDynamicComponent","_withCtx","loadedImages","imageSrc"],"mappings":";;;;;;;SAAA,WAIsBA,CAAAA,IAAAA,EAAAA,MAAAA,EAAAA,MAAAA,EAAAA,MAAAA,EAAAA,KAAAA,EAAAA,QAAAA,EAAAA;SACjBC,SAAU,EAAA,EAAAC,kBAAA;AAAA,IAAA,KAAA;AAAA,IAAA;AAAA,MACV,gBAAA,EAAU,sCAAEC,IAAU,CAAA,mBAAA,GAAA,IAAA,CAAA;AAAA,MACvB,cAAM,MAA4B,CAAA,CAAA,CAAA,KAAA,MAAA,CAAA,CAAA,CAAA,GAAA,CAAA,MAAA,KAAA,IAAA,CAAA,UAAA,GAAA,IAAA,CAAA;AAAA,MAClC,cAAU,MAAgB,CAAA,CAAA,CAAA,KAAA,MAAA,CAAA,CAAA,CAAA,GAAA,CAAA,MAAA,KAAA,IAAA,CAAA,UAAA,GAAA,KAAA,CAAA;AAAA,MAAA,KAAA,EAAA,4BAAA;AAGlBC,MAAAA,WAAAA,EAAAA,gBAAAA;AAAAA,KAAAA;;WAXZ,mBAYW,IAAAH,SAAA,EAAA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A,IAAAA,CAAAA,QAAAA;AAAAA,YACN,KAAK,IAAC,CAAA,MAAA,CAAA,IAAA;AAAA,YACN,GAAA,EAAA,IAAA,CAAA,QAAA;AAAA,YAAA,KAAA,EAAA,wBAAA;;AAnCR,WAAA,EAAA,IAAA,EAAA,CAAA,EAAA,UAAA,CAAA,CAAA;AAAA,SAAA,CAAA;;;;;;;;;;;;;"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import _sfc_main from './base-result-link.vue2.js';
|
|
2
|
-
import { openBlock, createElementBlock, withModifiers,
|
|
2
|
+
import { openBlock, createElementBlock, withModifiers, renderSlot } from 'vue';
|
|
3
3
|
import './base-result-link.vue3.js';
|
|
4
4
|
import _export_sfc from '../../_virtual/_plugin-vue_export-helper.js';
|
|
5
5
|
|
|
@@ -14,7 +14,6 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
14
14
|
class: "x-result-link",
|
|
15
15
|
"data-test": "result-link"
|
|
16
16
|
}, [
|
|
17
|
-
createCommentVNode("\n @slot (Required) Link content with a text, an image, another component or both\n @binding {Result} result - Result data\n "),
|
|
18
17
|
renderSlot(_ctx.$slots, "default", { result: _ctx.result }, void 0, true)
|
|
19
18
|
], 40, _hoisted_1);
|
|
20
19
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base-result-link.vue.js","sources":["../../../../src/components/result/base-result-link.vue"],"sourcesContent":["<template>\n <a\n ref=\"el\"\n @click=\"emitUserClickedAResult\"\n @click.right=\"emitUserClickedAResult\"\n @click.middle=\"emitUserClickedAResult\"\n :href=\"result.url\"\n class=\"x-result-link\"\n data-test=\"result-link\"\n >\n <!--\n @slot (Required) Link content with a text, an image, another component or both\n @binding {Result} result - Result data\n -->\n <slot :result=\"result\" />\n </a>\n</template>\n\n<script lang=\"ts\">\n import { Result } from '@empathyco/x-types';\n import { defineComponent, inject, PropType, ref } from 'vue';\n import { PropsWithType } from '../../utils/types';\n import { XEventsTypes } from '../../wiring/events.types';\n import { use$x } from '../../composables/index';\n import { WireMetadata } from '../../wiring';\n\n /**\n * Component to be reused that renders an `<a>` wrapping the result contents.\n *\n * @remarks\n * It has the logic to emit {@link XEventsTypes.UserClickedAResult} to the bus on click mouse\n * events. Additionally, this component may be injected other events to be emitted on click\n * event, so, depending on where it's used its father component may provide this events.\n *\n * @public\n */\n export default defineComponent({\n props: {\n /**\n * (Required) The {@link @empathyco/x-types#Result} information.\n *\n * @public\n */\n result: {\n type: Object as PropType<Result>,\n required: true\n }\n },\n setup(props) {\n const $x = use$x();\n\n /**\n * The rendered DOM element.\n *\n * @internal\n */\n const el = ref<HTMLElement | null>();\n\n /**\n * The list of additional events to be emitted by the component when user clicks the link.\n *\n * @internal\n */\n const resultClickExtraEvents = inject<PropsWithType<XEventsTypes, Result>[]>(\n 'resultClickExtraEvents',\n []\n );\n\n /**\n * The metadata to be injected in the events emitted by the component. This component can emit\n * have extra events so this record pairs each event to its metadata.\n */\n const resultLinkMetadataPerEvent = inject<\n // TODO: Refactor this inject key to the constants when doing EMP-909\n Partial<\n Record<\n PropsWithType<XEventsTypes, Result>,\n Omit<WireMetadata, 'moduleName' | 'origin' | 'location'>\n >\n >\n >('resultLinkMetadataPerEvent', {});\n\n /**\n * Emits the {@link XEventsTypes.UserClickedAResult} when user clicks on the result, and also\n * additional events if have been injected in the component.\n *\n * @internal\n */\n const emitUserClickedAResult = (): void => {\n $x.emit('UserClickedAResult', props.result, {\n target: el.value!,\n ...resultLinkMetadataPerEvent['UserClickedAResult']\n });\n resultClickExtraEvents.forEach(event => {\n $x.emit(event, props.result, { target: el.value!, ...resultLinkMetadataPerEvent[event] });\n });\n };\n\n return {\n emitUserClickedAResult\n };\n }\n });\n</script>\n\n<style lang=\"css\" scoped>\n .x-result-link {\n text-decoration: none;\n }\n</style>\n\n<docs lang=\"mdx\">\n## Events\n\nThis component emits the following event:\n\n- [`UserClickedAResult`](https://github.com/empathyco/x/blob/main/packages/x-components/src/wiring/events.types.ts)\n\nThe component can emit more events on click using the `resultClickExtraEvents` prop.\n\n## See it in action\n\nThis component is a wrapper for the result contents (images, name, price...) It may be part of the\nsearch result page, recommendations or other section which needs to include results.\n\nAdditionally, this component may be injected other events to be emitted on click event, so,\ndepending where it's used its father component may provide this events.\n\nThe result prop is required. It will render a `<a></a>` with the href to the result URL:\n\n```vue\n<BaseResultLink :result=\"result\">\n <template #default=\"{ result }\">\n <img :src=\"result.images[0]\"/>\n <span>{{ result.name }}</span>\n </template>\n</BaseResultLink>\n```\n</docs>\n"],"names":["_openBlock","_createElementBlock","result","_withModifiers"
|
|
1
|
+
{"version":3,"file":"base-result-link.vue.js","sources":["../../../../src/components/result/base-result-link.vue"],"sourcesContent":["<template>\n <a\n ref=\"el\"\n @click=\"emitUserClickedAResult\"\n @click.right=\"emitUserClickedAResult\"\n @click.middle=\"emitUserClickedAResult\"\n :href=\"result.url\"\n class=\"x-result-link\"\n data-test=\"result-link\"\n >\n <!--\n @slot (Required) Link content with a text, an image, another component or both\n @binding {Result} result - Result data\n -->\n <slot :result=\"result\" />\n </a>\n</template>\n\n<script lang=\"ts\">\n import { Result } from '@empathyco/x-types';\n import { defineComponent, inject, PropType, ref } from 'vue';\n import { PropsWithType } from '../../utils/types';\n import { XEventsTypes } from '../../wiring/events.types';\n import { use$x } from '../../composables/index';\n import { WireMetadata } from '../../wiring';\n\n /**\n * Component to be reused that renders an `<a>` wrapping the result contents.\n *\n * @remarks\n * It has the logic to emit {@link XEventsTypes.UserClickedAResult} to the bus on click mouse\n * events. Additionally, this component may be injected other events to be emitted on click\n * event, so, depending on where it's used its father component may provide this events.\n *\n * @public\n */\n export default defineComponent({\n props: {\n /**\n * (Required) The {@link @empathyco/x-types#Result} information.\n *\n * @public\n */\n result: {\n type: Object as PropType<Result>,\n required: true\n }\n },\n setup(props) {\n const $x = use$x();\n\n /**\n * The rendered DOM element.\n *\n * @internal\n */\n const el = ref<HTMLElement | null>();\n\n /**\n * The list of additional events to be emitted by the component when user clicks the link.\n *\n * @internal\n */\n const resultClickExtraEvents = inject<PropsWithType<XEventsTypes, Result>[]>(\n 'resultClickExtraEvents',\n []\n );\n\n /**\n * The metadata to be injected in the events emitted by the component. This component can emit\n * have extra events so this record pairs each event to its metadata.\n */\n const resultLinkMetadataPerEvent = inject<\n // TODO: Refactor this inject key to the constants when doing EMP-909\n Partial<\n Record<\n PropsWithType<XEventsTypes, Result>,\n Omit<WireMetadata, 'moduleName' | 'origin' | 'location'>\n >\n >\n >('resultLinkMetadataPerEvent', {});\n\n /**\n * Emits the {@link XEventsTypes.UserClickedAResult} when user clicks on the result, and also\n * additional events if have been injected in the component.\n *\n * @internal\n */\n const emitUserClickedAResult = (): void => {\n $x.emit('UserClickedAResult', props.result, {\n target: el.value!,\n ...resultLinkMetadataPerEvent['UserClickedAResult']\n });\n resultClickExtraEvents.forEach(event => {\n $x.emit(event, props.result, { target: el.value!, ...resultLinkMetadataPerEvent[event] });\n });\n };\n\n return {\n emitUserClickedAResult\n };\n }\n });\n</script>\n\n<style lang=\"css\" scoped>\n .x-result-link {\n text-decoration: none;\n }\n</style>\n\n<docs lang=\"mdx\">\n## Events\n\nThis component emits the following event:\n\n- [`UserClickedAResult`](https://github.com/empathyco/x/blob/main/packages/x-components/src/wiring/events.types.ts)\n\nThe component can emit more events on click using the `resultClickExtraEvents` prop.\n\n## See it in action\n\nThis component is a wrapper for the result contents (images, name, price...) It may be part of the\nsearch result page, recommendations or other section which needs to include results.\n\nAdditionally, this component may be injected other events to be emitted on click event, so,\ndepending where it's used its father component may provide this events.\n\nThe result prop is required. It will render a `<a></a>` with the href to the result URL:\n\n```vue\n<BaseResultLink :result=\"result\">\n <template #default=\"{ result }\">\n <img :src=\"result.images[0]\"/>\n <span>{{ result.name }}</span>\n </template>\n</BaseResultLink>\n```\n</docs>\n"],"names":["_openBlock","_createElementBlock","result","_withModifiers"],"mappings":";;;;;;SAEQ,WAAI,CAAA,IAAA,EAAA,MAAA,EAAA,MAAA,EAAA,MAAA,EAAA,KAAA,EAAA,QAAA,EAAA;SACPA,SAAK,EAAA,EAAAC,kBAAA,CAAA,GAAA,EAAA;AAAA,IAHV,GAAA,EAAA,IAAA;AAAA,IAKmB,OAAA,EAAA,MAAA,CAAA,CAAA,CAAA,KAAA,MAAA,CAAA,CAAA,CAAA,GAAA,CAAA,GAAA,IAAA,KAAA,IAAA,CAAA,sBAAA,IAAA,IAAA,CAAA,sBAAA,CAAA,GAAA,IAAA,CAAA,CAAA;AAAA,IACd,eAAMC,MAAU,CAAA,CAAA,CAAA,KAAA,MAAA,CAAA,CAAA,CAAA,GAAAC,aAAA,CAAA,CAAA,GAAA,IAAA,KAAA,IAAA,CAAA,sBAAA,IAAA,IAAA,CAAA,sBAAA,CAAA,GAAA,IAAA,CAAA,EAAA,CAAA,OAAA,CAAA,CAAA,CAAA;AAAA,IACjB,WAAM,MAAe,CAAA,CAAA,CAAA,KAAA,MAAA,CAAA,CAAA,CAAA,GAAAA,aAAA,CAAA,CAAA,GAAA,IAAA,KAAA,IAAA,CAAA,sBAAA,IAAA,IAAA,CAAA,sBAAA,CAAA,GAAA,IAAA,CAAA,EAAA,CAAA,QAAA,CAAA,CAAA,CAAA;AAAA,IACrB,WAAS,MAAC,CAAA,GAAA;AAAA,IAAA,KAAA,EAAA,eAAA;IAMV,WAAyB,EAAA,aAAA;AAAA,GAAA,EAAA;;;;;;;;"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import _sfc_main from './base-result-previous-price.vue2.js';
|
|
2
|
-
import { resolveComponent, openBlock, createElementBlock,
|
|
2
|
+
import { resolveComponent, openBlock, createElementBlock, renderSlot, createVNode, createCommentVNode } from 'vue';
|
|
3
3
|
import _export_sfc from '../../_virtual/_plugin-vue_export-helper.js';
|
|
4
4
|
|
|
5
5
|
const _hoisted_1 = {
|
|
@@ -10,7 +10,6 @@ const _hoisted_1 = {
|
|
|
10
10
|
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
11
11
|
const _component_BaseCurrency = resolveComponent("BaseCurrency");
|
|
12
12
|
return _ctx.result.price.hasDiscount ? (openBlock(), createElementBlock("div", _hoisted_1, [
|
|
13
|
-
createCommentVNode("\n @slot Base currency item\n @binding {result} result - Result data\n "),
|
|
14
13
|
renderSlot(_ctx.$slots, "default", { result: _ctx.result }, () => [
|
|
15
14
|
createVNode(_component_BaseCurrency, {
|
|
16
15
|
value: _ctx.result.price.originalValue,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base-result-previous-price.vue.js","sources":["../../../../src/components/result/base-result-previous-price.vue"],"sourcesContent":["<template>\n <div\n v-if=\"result.price.hasDiscount\"\n class=\"x-result-previous-price\"\n data-test=\"result-previous-price\"\n >\n <!--\n @slot Base currency item\n @binding {result} result - Result data\n -->\n <slot :result=\"result\">\n <BaseCurrency :value=\"result.price.originalValue\" :format=\"format\" />\n </slot>\n </div>\n</template>\n\n<script lang=\"ts\">\n import { Result } from '@empathyco/x-types';\n import { defineComponent, PropType } from 'vue';\n import BaseCurrency from '../currency/base-currency.vue';\n\n /**\n * Component that renders the {@link @empathyco/x-types#Result} previous price.\n *\n * @public\n */\n export default defineComponent({\n components: { BaseCurrency },\n props: {\n /**\n * (Required) The {@link @empathyco/x-types#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 *\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 });\n</script>\n\n<docs lang=\"mdx\">\n## Examples\n\n### Basic example\n\nThis component shows the previous price formatted if it has discount. The component has two optional\nprops. `format` to select the currency format to be applied.\n\n```vue\n<template>\n <BaseResultPreviousPrice :result=\"result\" :format=\"'i.iii,ddd €'\" />\n</template>\n\n<script>\n import { BaseResultPreviousPrice } from '@empathyco/x-components';\n\n export default {\n name: 'BaseResultPreviousPriceDemo',\n components: {\n BaseResultPreviousPrice\n }\n };\n</script>\n```\n\n### Overriding default slot\n\n```vue\n<template>\n <BaseResultPreviousPrice :result=\"result\">\n <span class=\"custom-base-result-previous-price\">{{ result.price.originalValue }}</span>\n </BaseResultPreviousPrice>\n</template>\n\n<script>\n import { BaseResultPreviousPrice } from '@empathyco/x-components';\n\n export default {\n name: 'BaseResultPreviousPriceDemo',\n components: {\n BaseResultPreviousPrice\n }\n };\n</script>\n```\n</docs>\n"],"names":["_resolveComponent","
|
|
1
|
+
{"version":3,"file":"base-result-previous-price.vue.js","sources":["../../../../src/components/result/base-result-previous-price.vue"],"sourcesContent":["<template>\n <div\n v-if=\"result.price.hasDiscount\"\n class=\"x-result-previous-price\"\n data-test=\"result-previous-price\"\n >\n <!--\n @slot Base currency item\n @binding {result} result - Result data\n -->\n <slot :result=\"result\">\n <BaseCurrency :value=\"result.price.originalValue\" :format=\"format\" />\n </slot>\n </div>\n</template>\n\n<script lang=\"ts\">\n import { Result } from '@empathyco/x-types';\n import { defineComponent, PropType } from 'vue';\n import BaseCurrency from '../currency/base-currency.vue';\n\n /**\n * Component that renders the {@link @empathyco/x-types#Result} previous price.\n *\n * @public\n */\n export default defineComponent({\n components: { BaseCurrency },\n props: {\n /**\n * (Required) The {@link @empathyco/x-types#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 *\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 });\n</script>\n\n<docs lang=\"mdx\">\n## Examples\n\n### Basic example\n\nThis component shows the previous price formatted if it has discount. The component has two optional\nprops. `format` to select the currency format to be applied.\n\n```vue\n<template>\n <BaseResultPreviousPrice :result=\"result\" :format=\"'i.iii,ddd €'\" />\n</template>\n\n<script>\n import { BaseResultPreviousPrice } from '@empathyco/x-components';\n\n export default {\n name: 'BaseResultPreviousPriceDemo',\n components: {\n BaseResultPreviousPrice\n }\n };\n</script>\n```\n\n### Overriding default slot\n\n```vue\n<template>\n <BaseResultPreviousPrice :result=\"result\">\n <span class=\"custom-base-result-previous-price\">{{ result.price.originalValue }}</span>\n </BaseResultPreviousPrice>\n</template>\n\n<script>\n import { BaseResultPreviousPrice } from '@empathyco/x-components';\n\n export default {\n name: 'BaseResultPreviousPriceDemo',\n components: {\n BaseResultPreviousPrice\n }\n };\n</script>\n```\n</docs>\n"],"names":["_resolveComponent","_createElementBlock","result","_createVNode","format","_createCommentVNode"],"mappings":";;;;MAGI,UAAM,GAAA;AAAA,EACN,GAAA,EAAA,CAAA;AAAA,EAAA,KAAA,EAAA,yBAAA;;;;kCAFmBA,gBAAW,CAAA,cAAA,CAAA,CAAA;AAQ9B,EAAA,OAAA,IAAA,CAAA,MAAA,CAEO,gCADgE,EAAAC,kBAAA,CAAA,KAAA,EAAA,UAAA,EAAA;AAAA,IAA/CC,UAAAA,CAAAA,IAAAA,CAAAA,MAAAA,EAAO,WAAM,EAAa,MAAA,EAAA,IAAA,CAAA,MAAA,EAAA,EAAA,MAAA;AAAA,MAAAC,WAAA,CAAWC,uBAAM,EAAA;AAAA,QAAA,KAAA,EAAA,IAAA,CAAA,MAAA,CAAA,KAAA,CAAA,aAAA;;;AAXvE,KAAA,CAAA;AAAA,GAAA,CAAA,IAAAC,kBAAA,CAAA,MAAA,EAAA,IAAA,CAAA,CAAA;;;;;;"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import _sfc_main from './base-result-rating.vue2.js';
|
|
2
|
-
import { resolveComponent, openBlock, createBlock, resolveDynamicComponent, withCtx,
|
|
2
|
+
import { resolveComponent, openBlock, createBlock, resolveDynamicComponent, withCtx, renderSlot, createVNode, mergeProps, createCommentVNode } from 'vue';
|
|
3
3
|
import './base-result-rating.vue3.js';
|
|
4
4
|
import _export_sfc from '../../_virtual/_plugin-vue_export-helper.js';
|
|
5
5
|
|
|
@@ -14,7 +14,6 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
14
14
|
"data-test": "result-rating"
|
|
15
15
|
}, {
|
|
16
16
|
default: withCtx(() => [
|
|
17
|
-
createCommentVNode("\n @slot To override the whole content\n "),
|
|
18
17
|
renderSlot(_ctx.$slots, "default", {
|
|
19
18
|
rating: _ctx.result.rating.value,
|
|
20
19
|
result: _ctx.result
|
|
@@ -23,11 +22,9 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
23
22
|
value: _ctx.result.rating.value
|
|
24
23
|
}, _ctx.$attrs), {
|
|
25
24
|
"empty-icon": withCtx(() => [
|
|
26
|
-
createCommentVNode("\n @slot The content to render as empty icon\n "),
|
|
27
25
|
renderSlot(_ctx.$slots, "empty-icon", {}, void 0, true)
|
|
28
26
|
]),
|
|
29
27
|
"filled-icon": withCtx(() => [
|
|
30
|
-
createCommentVNode("\n @slot The content to render as filled icon\n "),
|
|
31
28
|
renderSlot(_ctx.$slots, "filled-icon", {}, void 0, true)
|
|
32
29
|
]),
|
|
33
30
|
_: 3
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base-result-rating.vue.js","sources":["../../../../src/components/result/base-result-rating.vue"],"sourcesContent":["<template>\n <component\n :is=\"link ? 'a' : 'div'\"\n v-if=\"result.rating && result.rating.value\"\n ref=\"el\"\n @click=\"emitClickedEvent\"\n :href=\"link\"\n class=\"x-result-rating\"\n data-test=\"result-rating\"\n >\n <!--\n @slot To override the whole content\n -->\n <slot :rating=\"result.rating.value\" :result=\"result\">\n <BaseRating :value=\"result.rating.value\" v-bind=\"$attrs\">\n <template #empty-icon>\n <!--\n @slot The content to render as empty icon\n -->\n <slot name=\"empty-icon\" />\n </template>\n\n <template #filled-icon>\n <!--\n @slot The content to render as filled icon\n -->\n <slot name=\"filled-icon\" />\n </template>\n </BaseRating>\n </slot>\n </component>\n</template>\n\n<script lang=\"ts\">\n import { defineComponent, PropType, ref } from 'vue';\n import { Result } from '@empathyco/x-types';\n import BaseRating from '../base-rating.vue';\n import { use$x } from '../../composables/index';\n\n /**\n * This component renders a {@link BaseRating} for a result passed as prop.\n *\n * @public\n */\n export default defineComponent({\n components: {\n BaseRating\n },\n inheritAttrs: false,\n props: {\n /**\n * The {@link @empathyco/x-types#Result} to render its rating.\n *\n * @public\n */\n result: {\n type: Object as PropType<Result>,\n required: true\n },\n\n /**\n * A link to redirect when rating is clicked.\n *\n * @public\n */\n link: {\n type: String\n }\n },\n setup(props) {\n const $x = use$x();\n\n /**\n * Emits the `UserClickedAResultRating` event when user clicks this component, with the\n * {@link @empathyco/x-types#Result} as payload.\n *\n * @internal\n */\n const emitClickedEvent = (): void => {\n const el = ref<HTMLElement | null>(null);\n $x.emit('UserClickedAResultRating', props.result, {\n target: el.value!\n });\n };\n\n return {\n emitClickedEvent\n };\n }\n });\n</script>\n\n<style lang=\"css\" scoped>\n .x-result-rating {\n color: inherit;\n text-decoration: none;\n }\n</style>\n\n<docs lang=\"mdx\">\n## Events\n\nThis component emits the following events:\n\n- [`UserClickedAResultRating`](https://github.com/empathyco/x/blob/main/packages/x-components/src/wiring/events.types.ts)\n\n## See it in action\n\nHere you have a basic example of how the result rating is rendered.\n\n```vue\n<template>\n <BaseResultRating :result=\"result\" />\n</template>\n\n<script>\n import { BaseResultRating } from '@empathyco/x-components';\n\n export default {\n name: 'ResultRatingDemo',\n components: {\n BaseResultRating\n },\n data() {\n return {\n result: {\n id: 1,\n name: 'Result with rating',\n rating: { value: 3 }\n }\n };\n }\n };\n</script>\n```\n\n### Play with props\n\nIn this example, the result rating has been configured to 6 as maximum value using the prop `max`.\n\n```vue\n<template>\n <BaseResultRating :result=\"result\" :max=\"6\" />\n</template>\n\n<script>\n import { BaseResultRating } from '@empathyco/x-components';\n\n export default {\n name: 'ResultRatingDemo',\n components: {\n BaseResultRating\n },\n data() {\n return {\n result: {\n id: 1,\n name: 'Result with rating',\n rating: { value: 3 }\n }\n };\n }\n };\n</script>\n```\n\nIn this example, the result rating has been configured with a link to redirect when is clicked.\n\n```vue\n<template>\n <BaseResultRating :result=\"result\" link=\"https://empathy.co/\" />\n</template>\n\n<script>\n import { BaseResultRating } from '@empathyco/x-components';\n\n export default {\n name: 'ResultRatingDemo',\n components: {\n BaseResultRating\n },\n data() {\n return {\n result: {\n id: 1,\n name: 'Result with rating',\n rating: { value: 3 }\n }\n };\n }\n };\n</script>\n```\n\n### Play with events\n\nIn this example, a message has been added to be shown when the result rating is clicked.\n\n```vue\n<template>\n <BaseResultRating :result=\"result\" @UserClickedAResultRating=\"logUserClickedRating\" />\n</template>\n\n<script>\n import { BaseResultRating } from '@empathyco/x-components';\n\n export default {\n name: 'ResultRatingDemo',\n components: {\n BaseResultRating\n },\n data() {\n return {\n result: {\n id: 1,\n name: 'Result with rating',\n rating: { value: 3 }\n }\n };\n },\n methods: {\n logUserClickedRating(result) {\n console.log('User clickedRating of this result:', result);\n }\n }\n };\n</script>\n```\n\n## Extending the component\n\nThe rendered icons for rating can be configured through slots. Keep in mind that the icons for both\nstates (filled and empty), must have the same size make component work properly.\n\n```vue\n<template>\n <BaseResultRating :result=\"result\">\n <template #filled-icon>❤️</template>\n <template #empty-icon>🤍</template>\n </BaseResultRating>\n</template>\n\n<script>\n import { BaseResultRating } from '@empathyco/x-components';\n\n export default {\n name: 'ResultRatingDemo',\n components: {\n BaseResultRating\n },\n data() {\n return {\n result: {\n id: 1,\n name: 'Result with rating',\n rating: { value: 3 }\n }\n };\n }\n };\n</script>\n```\n\nIt is possible to override all the content of the component to show your own rating but keeping the\nlink and event behaviour:\n\n```vue\n<template>\n <BaseResultRating :result=\"result\" #default=\"{ rating, result }\">\n <span v-for=\"star in rating\">⭐️</span>\n <span>{{ result.name }}</span>\n </BaseResultRating>\n</template>\n\n<script>\n import { BaseResultRating } from '@empathyco/x-components';\n\n export default {\n name: 'ResultRatingDemo',\n components: {\n BaseResultRating\n },\n data() {\n return {\n result: {\n id: 1,\n name: 'Result with rating',\n rating: { value: 3 }\n }\n };\n }\n };\n</script>\n```\n\nEven it is possible to reuse our rating component:\n\n```vue\n<template>\n <BaseResultRating :result=\"result\" #default=\"{ rating, result }\">\n <BaseRating :value=\"rating\" />\n <span>{{ result.name }}</span>\n </BaseResultRating>\n</template>\n\n<script>\n import { BaseResultRating, BaseRating } from '@empathyco/x-components';\n\n export default {\n name: 'ResultRatingDemo',\n components: {\n BaseResultRating,\n BaseRating\n },\n data() {\n return {\n result: {\n id: 1,\n name: 'Result with rating',\n rating: { value: 3 }\n }\n };\n }\n };\n</script>\n```\n</docs>\n"],"names":["result","_openBlock","_createBlock","_resolveDynamicComponent","_withCtx","
|
|
1
|
+
{"version":3,"file":"base-result-rating.vue.js","sources":["../../../../src/components/result/base-result-rating.vue"],"sourcesContent":["<template>\n <component\n :is=\"link ? 'a' : 'div'\"\n v-if=\"result.rating && result.rating.value\"\n ref=\"el\"\n @click=\"emitClickedEvent\"\n :href=\"link\"\n class=\"x-result-rating\"\n data-test=\"result-rating\"\n >\n <!--\n @slot To override the whole content\n -->\n <slot :rating=\"result.rating.value\" :result=\"result\">\n <BaseRating :value=\"result.rating.value\" v-bind=\"$attrs\">\n <template #empty-icon>\n <!--\n @slot The content to render as empty icon\n -->\n <slot name=\"empty-icon\" />\n </template>\n\n <template #filled-icon>\n <!--\n @slot The content to render as filled icon\n -->\n <slot name=\"filled-icon\" />\n </template>\n </BaseRating>\n </slot>\n </component>\n</template>\n\n<script lang=\"ts\">\n import { defineComponent, PropType, ref } from 'vue';\n import { Result } from '@empathyco/x-types';\n import BaseRating from '../base-rating.vue';\n import { use$x } from '../../composables/index';\n\n /**\n * This component renders a {@link BaseRating} for a result passed as prop.\n *\n * @public\n */\n export default defineComponent({\n components: {\n BaseRating\n },\n inheritAttrs: false,\n props: {\n /**\n * The {@link @empathyco/x-types#Result} to render its rating.\n *\n * @public\n */\n result: {\n type: Object as PropType<Result>,\n required: true\n },\n\n /**\n * A link to redirect when rating is clicked.\n *\n * @public\n */\n link: {\n type: String\n }\n },\n setup(props) {\n const $x = use$x();\n\n /**\n * Emits the `UserClickedAResultRating` event when user clicks this component, with the\n * {@link @empathyco/x-types#Result} as payload.\n *\n * @internal\n */\n const emitClickedEvent = (): void => {\n const el = ref<HTMLElement | null>(null);\n $x.emit('UserClickedAResultRating', props.result, {\n target: el.value!\n });\n };\n\n return {\n emitClickedEvent\n };\n }\n });\n</script>\n\n<style lang=\"css\" scoped>\n .x-result-rating {\n color: inherit;\n text-decoration: none;\n }\n</style>\n\n<docs lang=\"mdx\">\n## Events\n\nThis component emits the following events:\n\n- [`UserClickedAResultRating`](https://github.com/empathyco/x/blob/main/packages/x-components/src/wiring/events.types.ts)\n\n## See it in action\n\nHere you have a basic example of how the result rating is rendered.\n\n```vue\n<template>\n <BaseResultRating :result=\"result\" />\n</template>\n\n<script>\n import { BaseResultRating } from '@empathyco/x-components';\n\n export default {\n name: 'ResultRatingDemo',\n components: {\n BaseResultRating\n },\n data() {\n return {\n result: {\n id: 1,\n name: 'Result with rating',\n rating: { value: 3 }\n }\n };\n }\n };\n</script>\n```\n\n### Play with props\n\nIn this example, the result rating has been configured to 6 as maximum value using the prop `max`.\n\n```vue\n<template>\n <BaseResultRating :result=\"result\" :max=\"6\" />\n</template>\n\n<script>\n import { BaseResultRating } from '@empathyco/x-components';\n\n export default {\n name: 'ResultRatingDemo',\n components: {\n BaseResultRating\n },\n data() {\n return {\n result: {\n id: 1,\n name: 'Result with rating',\n rating: { value: 3 }\n }\n };\n }\n };\n</script>\n```\n\nIn this example, the result rating has been configured with a link to redirect when is clicked.\n\n```vue\n<template>\n <BaseResultRating :result=\"result\" link=\"https://empathy.co/\" />\n</template>\n\n<script>\n import { BaseResultRating } from '@empathyco/x-components';\n\n export default {\n name: 'ResultRatingDemo',\n components: {\n BaseResultRating\n },\n data() {\n return {\n result: {\n id: 1,\n name: 'Result with rating',\n rating: { value: 3 }\n }\n };\n }\n };\n</script>\n```\n\n### Play with events\n\nIn this example, a message has been added to be shown when the result rating is clicked.\n\n```vue\n<template>\n <BaseResultRating :result=\"result\" @UserClickedAResultRating=\"logUserClickedRating\" />\n</template>\n\n<script>\n import { BaseResultRating } from '@empathyco/x-components';\n\n export default {\n name: 'ResultRatingDemo',\n components: {\n BaseResultRating\n },\n data() {\n return {\n result: {\n id: 1,\n name: 'Result with rating',\n rating: { value: 3 }\n }\n };\n },\n methods: {\n logUserClickedRating(result) {\n console.log('User clickedRating of this result:', result);\n }\n }\n };\n</script>\n```\n\n## Extending the component\n\nThe rendered icons for rating can be configured through slots. Keep in mind that the icons for both\nstates (filled and empty), must have the same size make component work properly.\n\n```vue\n<template>\n <BaseResultRating :result=\"result\">\n <template #filled-icon>❤️</template>\n <template #empty-icon>🤍</template>\n </BaseResultRating>\n</template>\n\n<script>\n import { BaseResultRating } from '@empathyco/x-components';\n\n export default {\n name: 'ResultRatingDemo',\n components: {\n BaseResultRating\n },\n data() {\n return {\n result: {\n id: 1,\n name: 'Result with rating',\n rating: { value: 3 }\n }\n };\n }\n };\n</script>\n```\n\nIt is possible to override all the content of the component to show your own rating but keeping the\nlink and event behaviour:\n\n```vue\n<template>\n <BaseResultRating :result=\"result\" #default=\"{ rating, result }\">\n <span v-for=\"star in rating\">⭐️</span>\n <span>{{ result.name }}</span>\n </BaseResultRating>\n</template>\n\n<script>\n import { BaseResultRating } from '@empathyco/x-components';\n\n export default {\n name: 'ResultRatingDemo',\n components: {\n BaseResultRating\n },\n data() {\n return {\n result: {\n id: 1,\n name: 'Result with rating',\n rating: { value: 3 }\n }\n };\n }\n };\n</script>\n```\n\nEven it is possible to reuse our rating component:\n\n```vue\n<template>\n <BaseResultRating :result=\"result\" #default=\"{ rating, result }\">\n <BaseRating :value=\"rating\" />\n <span>{{ result.name }}</span>\n </BaseResultRating>\n</template>\n\n<script>\n import { BaseResultRating, BaseRating } from '@empathyco/x-components';\n\n export default {\n name: 'ResultRatingDemo',\n components: {\n BaseResultRating,\n BaseRating\n },\n data() {\n return {\n result: {\n id: 1,\n name: 'Result with rating',\n rating: { value: 3 }\n }\n };\n }\n };\n</script>\n```\n</docs>\n"],"names":["result","_openBlock","_createBlock","_resolveDynamicComponent","_withCtx","_renderSlot","_createVNode","$attrs","_mergeProps","_createCommentVNode"],"mappings":";;;;;;AAG2BA,EAAAA,MAAAA,qBAAAA,GAAAA,gBAAAA,CAAa,YAAM,CAAA,CAAA;SAH9C,IAIY,CAAA,MAAA,CAAA,MAAA,IAAA,IAAA,CAAA,MAAA,CAAA,MAAA,CAAA,KAAA,IAAAC,SAAA,EAAA,EAAAC,WAAA,CAAAC,uBAAA,CAAA,IAAA,CAAA,IAAA,GAAA,GAAA,GAAA,KAAA,CAAA,EAAA;AAAA,IACP,GAAA,EAAA,CAAA;AAAA,IACA,GAAI,EAAA,IAAA;AAAA,IACL,OAAM,EAAA,IAAA,CAAA,gBAAA;AAAA,IACN,IAAS,EAAA,IAAA,CAAA,IAAA;AAAA,IAAA,KAAA,EAAA,iBAAA;AARb,IAAA,WAAA,EAAA,eAAA;AAAA,GAAA,EAAA;AAaW,IAAA,OAAA,EAAAC,OAAA,CAAQJ,MAAO;AAAA,MAAAK,UAAA,CAAuBL,IAAM,CAAA,MAAA,EAAA,SAAA,EAAA;AAAA,QAgB5C,MAAA,EAAA,IAAA,CAAA,MAAA,CAAA,MAAA,CAAA,KAAA;AAAA,QAfL,MAca,EAAA,IAAA,CAAA,MAAA;AAAA,OAdK,EAAA,MAAA;AAAA,QAAAM,WAAA,CAA+BC,qBAAM,EAAAC,UAAA,CAAA;AAAA,UAC1C,YAAU,MAIO,CAAA,MAAA,CAAA,KAAA;AAAA,SAAA,EAAA,IAAA,CAA1B,MAA0B,CAAA,EAAA;AAAA,UAAA,YAAA,EAAAJ,OAAA,CAAA,MAAA;AAGjB,YAAAC,UAAA,CAAW,IAIO,CAAA,MAAA,EAAA,YAAA,EAAA,EAAA,EAAA,KAAA,CAAA,EAAA,IAAA,CAAA;AAAA,WAAA,CAAA;;AA1BrC,YAAAA,UAAA,CAAA,IAAA,CAAA,MAAA,EAAA,aAAA,EAAA,EAAA,EAAA,KAAA,CAAA,EAAA,IAAA,CAAA;AAAA,WAAA,CAAA;;;;AAAA,OAAA,EAAA,IAAA,CAAA;AAAA,KAAA,CAAA;AAAA,IAAA,CAAA,EAAA,CAAA;AAAA;AAAA,GAAA,EAAA,CAAA,EAAA,CAAA,SAAA,EAAA,MAAA,CAAA,CAAA,IAAAI,kBAAA,CAAA,MAAA,EAAA,IAAA,CAAA,CAAA;;;;;;"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import _sfc_main from './result-variant-selector.vue2.js';
|
|
2
|
-
import { openBlock, createElementBlock, Fragment, renderList, normalizeClass,
|
|
2
|
+
import { openBlock, createElementBlock, Fragment, renderList, normalizeClass, renderSlot, createElementVNode, createTextVNode, toDisplayString, createCommentVNode } from 'vue';
|
|
3
3
|
import './result-variant-selector.vue3.js';
|
|
4
4
|
import _export_sfc from '../../_virtual/_plugin-vue_export-helper.js';
|
|
5
5
|
|
|
@@ -23,7 +23,6 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
23
23
|
"data-test": "variant-item"
|
|
24
24
|
},
|
|
25
25
|
[
|
|
26
|
-
createCommentVNode("\n @slot Variant item\n @binding {ResultVariant} variant - The variant item\n @binding {boolean} isSelected - Indicates if the variant is selected\n @binding {() => void} selectVariant - Callback to select the variant\n "),
|
|
27
26
|
renderSlot(_ctx.$slots, "variant", {
|
|
28
27
|
variant,
|
|
29
28
|
isSelected: _ctx.variantIsSelected(variant),
|
|
@@ -34,7 +33,6 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
34
33
|
"data-test": "variant-button",
|
|
35
34
|
class: "x-button"
|
|
36
35
|
}, [
|
|
37
|
-
createCommentVNode("\n @slot Variant content\n @binding {ResultVariant} variant - The variant item\n @binding {boolean} isSelected - Indicates if the variant is selected\n "),
|
|
38
36
|
renderSlot(_ctx.$slots, "variant-content", {
|
|
39
37
|
variant,
|
|
40
38
|
isSelected: _ctx.variantIsSelected(variant)
|