@empathyco/x-components 3.1.0-alpha.0 → 3.1.0-alpha.2

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 CHANGED
@@ -3,6 +3,24 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [3.1.0-alpha.2](https://github.com/empathyco/x/compare/@empathyco/x-components@3.1.0-alpha.1...@empathyco/x-components@3.1.0-alpha.2) (2023-11-13)
7
+
8
+
9
+ ### Documentation
10
+
11
+ * **integration:** how to track add2cart event (#1349) ([65509fd](https://github.com/empathyco/x/commit/65509fdfcbd89ce823bd2a36898c3bbf21b7b3ce))
12
+
13
+
14
+
15
+ ## [3.1.0-alpha.1](https://github.com/empathyco/x/compare/@empathyco/x-components@3.1.0-alpha.0...@empathyco/x-components@3.1.0-alpha.1) (2023-11-10)
16
+
17
+
18
+ ### Documentation
19
+
20
+ * fix `@empathyco/x-components import path in examples (#1353) ([071f12d](https://github.com/empathyco/x/commit/071f12dd96285a02f56c9ddc52c8fe6b802cefae))
21
+
22
+
23
+
6
24
  ## [3.1.0-alpha.0](https://github.com/empathyco/x/compare/@empathyco/x-components@3.0.1-alpha.4...@empathyco/x-components@3.1.0-alpha.0) (2023-11-06)
7
25
 
8
26
 
@@ -1,5 +1,4 @@
1
1
 
2
-
3
2
  .x-uppercase {
4
3
  text-transform: uppercase;
5
4
  }
@@ -15,6 +14,7 @@
15
14
  .x-normal-case {
16
15
  text-transform: none;
17
16
  }
17
+
18
18
  .x-underline {
19
19
  -webkit-text-decoration-line: underline;
20
20
  text-decoration-line: underline;
@@ -4895,9 +4895,6 @@
4895
4895
  :root {
4896
4896
  --x-size-border-radius-result-card: var(--x-size-border-radius-base-s);
4897
4897
  }
4898
- :root {
4899
- --x-size-border-radius-result-card: var(--x-size-border-radius-base-s);
4900
- }
4901
4898
 
4902
4899
  .x-result.x-result--card {
4903
4900
  overflow: hidden;
@@ -8845,4 +8842,7 @@
8845
8842
  --x-size-border-radius-base-m: var(--x-size-base-06);
8846
8843
  --x-size-border-radius-base-pill: 99999px;
8847
8844
  --x-size-border-width-base: 1px;
8845
+ }
8846
+ :root {
8847
+ --x-size-border-radius-result-card: var(--x-size-border-radius-base-s);
8848
8848
  }
@@ -46,7 +46,7 @@ It is required to send the columns prop.
46
46
  <BaseColumnPickerList :columns="columns" />
47
47
  </template>
48
48
  <script>
49
- import { BaseColumnPickerList } from '@empathyco/xcomponents';
49
+ import { BaseColumnPickerList } from '@empathyco/x-components';
50
50
 
51
51
  export default {
52
52
  components: {
@@ -69,7 +69,7 @@ updated if it changed the value or if the parent changes it.
69
69
  <BaseColumnPickerList :columns="columns" v-model="selectedColumns" />
70
70
  </template>
71
71
  <script>
72
- import { BaseColumnPickerList } from '@empathyco/xcomponents';
72
+ import { BaseColumnPickerList } from '@empathyco/x-components';
73
73
 
74
74
  export default {
75
75
  components: {
@@ -95,7 +95,7 @@ It is possible to override the column picker button content.
95
95
  </BaseColumnPickerList>
96
96
  </template>
97
97
  <script>
98
- import { BaseColumnPickerList } from '@empathyco/xcomponents';
98
+ import { BaseColumnPickerList } from '@empathyco/x-components';
99
99
 
100
100
  export default {
101
101
  components: {
@@ -120,7 +120,7 @@ It is also possible to add a divider element between the column picker buttons b
120
120
  </BaseColumnPickerList>
121
121
  </template>
122
122
  <script>
123
- import { BaseColumnPickerList, ChevronRightIcon } from '@empathyco/xcomponents';
123
+ import { BaseColumnPickerList, ChevronRightIcon } from '@empathyco/x-components';
124
124
 
125
125
  export default {
126
126
  components: {
@@ -143,7 +143,7 @@ The `buttonClass` prop can be used to add classes to the buttons.
143
143
  <BaseColumnPickerList :columns="columns" buttonClass="x-button--round" />
144
144
  </template>
145
145
  <script>
146
- import { BaseColumnPickerList } from '@empathyco/xcomponents';
146
+ import { BaseColumnPickerList } from '@empathyco/x-components';
147
147
 
148
148
  export default {
149
149
  components: {
@@ -213,6 +213,7 @@ out further information about:
213
213
  - **Functions supported by the [X&nbsp;API object](#x-api)** to initialize Interface&nbsp;X
214
214
  - Notes on how to set up [**the preview of query results**](#dynamic-query-results-preview) for
215
215
  determined queries at the pre-search stage
216
+ - [**Tracking options for add to cart events**](#tracking-events-for-add-to-cart-on-product-detail-pages) from product detail pages
216
217
 
217
218
  ### Snippet configuration
218
219
 
@@ -405,3 +406,64 @@ instance:
405
406
  });
406
407
  </script>
407
408
  ```
409
+
410
+ ### Tracking events for add to cart on product detail pages
411
+
412
+ Empathy Platform Interface X allows you to track shoppers' add-to-cart interactions from any product detail page (PDP) in your commerce store, regardless of whether your commerce store is running on a **single-page application or not**.
413
+
414
+ #### Tracking add-to-cart events on non-SPA webpages
415
+ To track your shoppers' add-to-cart interactions from any PDP based on a non-spa structured webpage, follow these steps:
416
+
417
+ 1. Add the `productId` parameter when initializing the script.
418
+
419
+ ```html
420
+ window.InterfaceX.init({
421
+ instance: "instanceName",
422
+ lang: "es",
423
+ documentDirection: "ltr",
424
+ scope: 'desktop',
425
+ currency: "EUR",
426
+ consent: true,
427
+ isSPA: false,
428
+ queriesPreview: []
429
+ {
430
+ query: 'coats',
431
+ title: 'Winter Coats'
432
+ }
433
+ ],
434
+ callbacks: {
435
+ UserClickedAResult: function(a, b, e, t) {}
436
+ },
437
+ productId: '11776347-ES' // Add this parameter
438
+ })
439
+ ```
440
+
441
+ 2. Call the `InterfaceX.addProductToCart('11776347-ES')` function to track the event when the add-to-cart button is clicked.
442
+
443
+ ```html
444
+ yourCommerceStoreEnvironment.addToCartButton.addEventListener('click', () =>
445
+ InterfaceX.addProductToCart('11776347-ES');
446
+ );
447
+ ```
448
+
449
+
450
+ #### Tracking add-to-cart events on SPA webpages
451
+ To track your shoppers' add-to-cart interactions from any PDP based on a SPA structured webpage, follow these steps:
452
+
453
+ 1. Call the `InterfaceX.bus.emit('PDPIsLoaded')` function any time a new PDP-type page is loaded.
454
+
455
+
456
+ ```html
457
+ if (yourCommerceStoreEnvironment.isPDP && window.initX.isSpa) {
458
+ InterfaceX.bus.emit('PDPIsLoaded')
459
+ }
460
+ ```
461
+
462
+ 2. Call the `InterfaceX.addProductToCart()` function to track the event when the add-to-cart button is clicked:
463
+
464
+
465
+ ```html
466
+ yourCommerceStoreEnvironment.addToCartButton.addEventListener('click', () =>
467
+ InterfaceX.addProductToCart();
468
+ );
469
+ ```
@@ -1 +1 @@
1
- {"version":3,"file":"base-column-picker-list.vue.js","sources":["../../../../src/components/column-picker/base-column-picker-list.vue"],"sourcesContent":["<template>\n <div class=\"x-column-picker-list x-button-group\" data-test=\"column-picker-list\" role=\"list\">\n <template v-for=\"({ column, cssClasses, events, isSelected }, index) in columnsWithCssClasses\">\n <BaseEventButton\n :key=\"column\"\n class=\"x-column-picker-list__button x-button\"\n :class=\"[buttonClass, cssClasses]\"\n data-test=\"column-picker-button\"\n :aria-pressed=\"isSelected\"\n :events=\"events\"\n :aria-label=\"`${column} columns`\"\n role=\"listitem\"\n >\n <!--\n @slot Customized Column Picker Button content. Specifying a slot with the column value\n will result in the column using that slot composition to render.\n @binding {number} column - Columns Number to pick.\n @binding {boolean} isSelected - True if the columns number are the chosen value.\n -->\n <slot v-bind=\"{ column, isSelected }\">\n {{ column }}\n </slot>\n </BaseEventButton>\n\n <!--\n @slot Customized Column Picker divider. Specify an element to act as divider for\n the items in the column picker. Empty by default.\n -->\n <slot v-if=\"index !== columnsWithCssClasses.length - 1\" name=\"divider\"></slot>\n </template>\n </div>\n</template>\n\n<script lang=\"ts\">\n import { mixins } from 'vue-class-component';\n import { Component } from 'vue-property-decorator';\n import { VueCSSClasses } from '../../utils/types';\n import { XEventsTypes } from '../../wiring';\n import BaseEventButton from '../base-event-button.vue';\n import { dynamicPropsMixin } from '../dynamic-props.mixin';\n import ColumnPickerMixin from './column-picker.mixin';\n\n interface ColumnPickerItem {\n column: number;\n cssClasses: VueCSSClasses;\n events: Partial<XEventsTypes>;\n isSelected: boolean;\n }\n\n /**\n * Column picker list component renders a list of buttons to choose the columns number.\n *\n * Additionally, this component exposes the following props to modify the classes of the\n * elements: `buttonClass`.\n *\n * @remarks It extends {@link ColumnPickerMixin}.\n *\n * @public\n */\n @Component({\n components: { BaseEventButton }\n })\n export default class BaseColumnPickerList extends mixins(\n ColumnPickerMixin,\n dynamicPropsMixin(['buttonClass'])\n ) {\n /**\n * Maps the column to an object containing: the `column` and `CSS classes`.\n *\n * @returns An array of objects containing the column number and CSS classes.\n *\n * @internal\n */\n protected get columnsWithCssClasses(): ColumnPickerItem[] {\n return this.columns.map(column => ({\n column,\n cssClasses: [\n `x-column-picker-list__button--${column}-cols`,\n {\n 'x-selected': this.selectedColumns === column\n }\n ],\n isSelected: this.selectedColumns === column,\n events: {\n UserClickedColumnPicker: column,\n ColumnsNumberProvided: column\n }\n }));\n }\n }\n</script>\n\n<docs lang=\"mdx\">\n## Examples\n\nThis component renders a list of elements in different slots depending on the columns prop. Each\nelement will emit the needed events to sync other instances of columns pickers, or grids with the\nnumber of columns that it is being selected when it is clicked.\n\n### Default usage\n\nIt is required to send the columns prop.\n\n```vue live\n<template>\n <BaseColumnPickerList :columns=\"columns\" />\n</template>\n<script>\n import { BaseColumnPickerList } from '@empathyco/xcomponents';\n\n export default {\n components: {\n BaseColumnPickerList\n },\n data() {\n return { columns: [2, 4, 6] };\n }\n };\n</script>\n```\n\n#### Using v-model\n\nIt is possible to do two way binding in order to synchronize the value with the parents. It will be\nupdated if it changed the value or if the parent changes it.\n\n```vue live\n<template>\n <BaseColumnPickerList :columns=\"columns\" v-model=\"selectedColumns\" />\n</template>\n<script>\n import { BaseColumnPickerList } from '@empathyco/xcomponents';\n\n export default {\n components: {\n BaseColumnPickerList\n },\n data() {\n return { columns: [2, 4, 6], selectedColumns: 4 };\n }\n };\n</script>\n```\n\n### Customized usage\n\n#### Overriding the slots\n\nIt is possible to override the column picker button content.\n\n```vue live\n<template>\n <BaseColumnPickerList :columns=\"columns\" #default=\"{ column, isSelected }\">\n <span>{{ column }} {{ isSelected ? '🟢' : '' }}</span>\n </BaseColumnPickerList>\n</template>\n<script>\n import { BaseColumnPickerList } from '@empathyco/xcomponents';\n\n export default {\n components: {\n BaseColumnPickerList\n },\n data() {\n return { columns: [2, 4, 6] };\n }\n };\n</script>\n```\n\nIt is also possible to add a divider element between the column picker buttons by overriding the\n`divider` slot.\n\n```vue live\n<template>\n <BaseColumnPickerList :columns=\"columns\">\n <template #divider>\n <ChevronRightIcon aria-hidden=\"true\" />\n </template>\n </BaseColumnPickerList>\n</template>\n<script>\n import { BaseColumnPickerList, ChevronRightIcon } from '@empathyco/xcomponents';\n\n export default {\n components: {\n BaseColumnPickerList,\n ChevronRightIcon\n },\n data() {\n return { columns: [2, 4, 6] };\n }\n };\n</script>\n```\n\n#### Customizing the buttons with classes\n\nThe `buttonClass` prop can be used to add classes to the buttons.\n\n```vue live\n<template>\n <BaseColumnPickerList :columns=\"columns\" buttonClass=\"x-button--round\" />\n</template>\n<script>\n import { BaseColumnPickerList } from '@empathyco/xcomponents';\n\n export default {\n components: {\n BaseColumnPickerList\n },\n data() {\n return { columns: [2, 4, 6] };\n }\n };\n</script>\n```\n\n## Events\n\nA list of events that the component will emit:\n\n- [`UserClickedColumnPicker`](https://github.com/empathyco/x/blob/main/packages/x-components/src/wiring/events.types.ts):\n the event is emitted after the user clicks an item. The event payload is the number of columns\n that the clicked item represents.\n- [`ColumnsNumberProvided`](https://github.com/empathyco/x/blob/main/packages/x-components/src/wiring/events.types.ts):\n the event is emitted on component mount. The event payload is the current `selectedColumns` value.\n</docs>\n"],"names":[],"mappings":";;;;AAEA,MAAc,cAAA,GAAA,OAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"base-column-picker-list.vue.js","sources":["../../../../src/components/column-picker/base-column-picker-list.vue"],"sourcesContent":["<template>\n <div class=\"x-column-picker-list x-button-group\" data-test=\"column-picker-list\" role=\"list\">\n <template v-for=\"({ column, cssClasses, events, isSelected }, index) in columnsWithCssClasses\">\n <BaseEventButton\n :key=\"column\"\n class=\"x-column-picker-list__button x-button\"\n :class=\"[buttonClass, cssClasses]\"\n data-test=\"column-picker-button\"\n :aria-pressed=\"isSelected\"\n :events=\"events\"\n :aria-label=\"`${column} columns`\"\n role=\"listitem\"\n >\n <!--\n @slot Customized Column Picker Button content. Specifying a slot with the column value\n will result in the column using that slot composition to render.\n @binding {number} column - Columns Number to pick.\n @binding {boolean} isSelected - True if the columns number are the chosen value.\n -->\n <slot v-bind=\"{ column, isSelected }\">\n {{ column }}\n </slot>\n </BaseEventButton>\n\n <!--\n @slot Customized Column Picker divider. Specify an element to act as divider for\n the items in the column picker. Empty by default.\n -->\n <slot v-if=\"index !== columnsWithCssClasses.length - 1\" name=\"divider\"></slot>\n </template>\n </div>\n</template>\n\n<script lang=\"ts\">\n import { mixins } from 'vue-class-component';\n import { Component } from 'vue-property-decorator';\n import { VueCSSClasses } from '../../utils/types';\n import { XEventsTypes } from '../../wiring';\n import BaseEventButton from '../base-event-button.vue';\n import { dynamicPropsMixin } from '../dynamic-props.mixin';\n import ColumnPickerMixin from './column-picker.mixin';\n\n interface ColumnPickerItem {\n column: number;\n cssClasses: VueCSSClasses;\n events: Partial<XEventsTypes>;\n isSelected: boolean;\n }\n\n /**\n * Column picker list component renders a list of buttons to choose the columns number.\n *\n * Additionally, this component exposes the following props to modify the classes of the\n * elements: `buttonClass`.\n *\n * @remarks It extends {@link ColumnPickerMixin}.\n *\n * @public\n */\n @Component({\n components: { BaseEventButton }\n })\n export default class BaseColumnPickerList extends mixins(\n ColumnPickerMixin,\n dynamicPropsMixin(['buttonClass'])\n ) {\n /**\n * Maps the column to an object containing: the `column` and `CSS classes`.\n *\n * @returns An array of objects containing the column number and CSS classes.\n *\n * @internal\n */\n protected get columnsWithCssClasses(): ColumnPickerItem[] {\n return this.columns.map(column => ({\n column,\n cssClasses: [\n `x-column-picker-list__button--${column}-cols`,\n {\n 'x-selected': this.selectedColumns === column\n }\n ],\n isSelected: this.selectedColumns === column,\n events: {\n UserClickedColumnPicker: column,\n ColumnsNumberProvided: column\n }\n }));\n }\n }\n</script>\n\n<docs lang=\"mdx\">\n## Examples\n\nThis component renders a list of elements in different slots depending on the columns prop. Each\nelement will emit the needed events to sync other instances of columns pickers, or grids with the\nnumber of columns that it is being selected when it is clicked.\n\n### Default usage\n\nIt is required to send the columns prop.\n\n```vue live\n<template>\n <BaseColumnPickerList :columns=\"columns\" />\n</template>\n<script>\n import { BaseColumnPickerList } from '@empathyco/x-components';\n\n export default {\n components: {\n BaseColumnPickerList\n },\n data() {\n return { columns: [2, 4, 6] };\n }\n };\n</script>\n```\n\n#### Using v-model\n\nIt is possible to do two way binding in order to synchronize the value with the parents. It will be\nupdated if it changed the value or if the parent changes it.\n\n```vue live\n<template>\n <BaseColumnPickerList :columns=\"columns\" v-model=\"selectedColumns\" />\n</template>\n<script>\n import { BaseColumnPickerList } from '@empathyco/x-components';\n\n export default {\n components: {\n BaseColumnPickerList\n },\n data() {\n return { columns: [2, 4, 6], selectedColumns: 4 };\n }\n };\n</script>\n```\n\n### Customized usage\n\n#### Overriding the slots\n\nIt is possible to override the column picker button content.\n\n```vue live\n<template>\n <BaseColumnPickerList :columns=\"columns\" #default=\"{ column, isSelected }\">\n <span>{{ column }} {{ isSelected ? '🟢' : '' }}</span>\n </BaseColumnPickerList>\n</template>\n<script>\n import { BaseColumnPickerList } from '@empathyco/x-components';\n\n export default {\n components: {\n BaseColumnPickerList\n },\n data() {\n return { columns: [2, 4, 6] };\n }\n };\n</script>\n```\n\nIt is also possible to add a divider element between the column picker buttons by overriding the\n`divider` slot.\n\n```vue live\n<template>\n <BaseColumnPickerList :columns=\"columns\">\n <template #divider>\n <ChevronRightIcon aria-hidden=\"true\" />\n </template>\n </BaseColumnPickerList>\n</template>\n<script>\n import { BaseColumnPickerList, ChevronRightIcon } from '@empathyco/x-components';\n\n export default {\n components: {\n BaseColumnPickerList,\n ChevronRightIcon\n },\n data() {\n return { columns: [2, 4, 6] };\n }\n };\n</script>\n```\n\n#### Customizing the buttons with classes\n\nThe `buttonClass` prop can be used to add classes to the buttons.\n\n```vue live\n<template>\n <BaseColumnPickerList :columns=\"columns\" buttonClass=\"x-button--round\" />\n</template>\n<script>\n import { BaseColumnPickerList } from '@empathyco/x-components';\n\n export default {\n components: {\n BaseColumnPickerList\n },\n data() {\n return { columns: [2, 4, 6] };\n }\n };\n</script>\n```\n\n## Events\n\nA list of events that the component will emit:\n\n- [`UserClickedColumnPicker`](https://github.com/empathyco/x/blob/main/packages/x-components/src/wiring/events.types.ts):\n the event is emitted after the user clicks an item. The event payload is the number of columns\n that the clicked item represents.\n- [`ColumnsNumberProvided`](https://github.com/empathyco/x/blob/main/packages/x-components/src/wiring/events.types.ts):\n the event is emitted on component mount. The event payload is the current `selectedColumns` value.\n</docs>\n"],"names":[],"mappings":";;;;AAEA,MAAc,cAAA,GAAA,OAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@empathyco/x-components",
3
- "version": "3.1.0-alpha.0",
3
+ "version": "3.1.0-alpha.2",
4
4
  "description": "Empathy X Components",
5
5
  "author": "Empathy Systems Corporation S.L.",
6
6
  "license": "Apache-2.0",
@@ -143,5 +143,5 @@
143
143
  "access": "public",
144
144
  "directory": "dist"
145
145
  },
146
- "gitHead": "6a38784650ffcae60dc0a58afc002c600d702da6"
146
+ "gitHead": "1096966c93eab5719555bb24779d94bf15a70570"
147
147
  }