@constructor-io/constructorio-ui-plp 1.9.0 → 1.10.0

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.
@@ -16,6 +16,7 @@ exports.cnstrcDataAttrs = {
16
16
  zeroResults: 'data-cnstrc-zero-result',
17
17
  slCampaignId: 'data-cnstrc-sl-campaign-id',
18
18
  slCampaignOwner: 'data-cnstrc-sl-campaign-owner',
19
+ resultPage: 'data-cnstrc-result-page',
19
20
  },
20
21
  search: {
21
22
  searchContainer: 'data-cnstrc-search',
@@ -53,18 +54,20 @@ function getProductCardCnstrcDataAttributes(productInfo, options) {
53
54
  }
54
55
  exports.getProductCardCnstrcDataAttributes = getProductCardCnstrcDataAttributes;
55
56
  function getPlpContainerCnstrcDataAttributes(data, requestConfigs, isLoading = false) {
56
- var _a, _b;
57
+ var _a, _b, _c;
57
58
  if (!data || (!(0, typeHelpers_1.isPlpSearchDataResults)(data) && !(0, typeHelpers_1.isPlpBrowseDataResults)(data)))
58
59
  return {};
59
60
  const { filterName, filterValue } = requestConfigs;
60
61
  const pageType = (0, requestConfigsHelpers_1.getPageType)(requestConfigs);
61
62
  const isZeroResults = data.response.totalNumResults === 0;
63
+ const resultPage = ((_a = data === null || data === void 0 ? void 0 : data.request) === null || _a === void 0 ? void 0 : _a.page) || requestConfigs.page || 1;
62
64
  let dataCnstrc = {};
63
65
  switch (pageType) {
64
66
  case 'browse':
65
67
  dataCnstrc = {
66
68
  [exports.cnstrcDataAttrs.browse.browseContainer]: true,
67
69
  [exports.cnstrcDataAttrs.common.numResults]: data.response.totalNumResults,
70
+ [exports.cnstrcDataAttrs.common.resultPage]: resultPage,
68
71
  [exports.cnstrcDataAttrs.common.resultId]: data.resultId,
69
72
  [exports.cnstrcDataAttrs.browse.filterName]: filterName,
70
73
  [exports.cnstrcDataAttrs.browse.filterValue]: filterValue,
@@ -75,9 +78,10 @@ function getPlpContainerCnstrcDataAttributes(data, requestConfigs, isLoading = f
75
78
  [exports.cnstrcDataAttrs.search.searchContainer]: true,
76
79
  [exports.cnstrcDataAttrs.common.resultId]: data.resultId,
77
80
  [exports.cnstrcDataAttrs.common.numResults]: data.response.totalNumResults,
81
+ [exports.cnstrcDataAttrs.common.resultPage]: resultPage,
78
82
  };
79
83
  // Add search term
80
- if ((_a = data.request) === null || _a === void 0 ? void 0 : _a.term) {
84
+ if ((_b = data.request) === null || _b === void 0 ? void 0 : _b.term) {
81
85
  dataCnstrc[exports.cnstrcDataAttrs.search.searchTerm] = data.request.term;
82
86
  }
83
87
  break;
@@ -94,7 +98,7 @@ function getPlpContainerCnstrcDataAttributes(data, requestConfigs, isLoading = f
94
98
  dataCnstrc[exports.cnstrcDataAttrs.common.zeroResults] = true;
95
99
  }
96
100
  // Add section if it's not "Products"
97
- if (((_b = data.request) === null || _b === void 0 ? void 0 : _b.section) && data.request.section !== 'Products') {
101
+ if (((_c = data.request) === null || _c === void 0 ? void 0 : _c.section) && data.request.section !== 'Products') {
98
102
  dataCnstrc[exports.cnstrcDataAttrs.common.section] = data.request.section;
99
103
  }
100
104
  }
@@ -111,6 +111,10 @@ function getUrlFromState(state, url) {
111
111
  if (exports.defaultQueryStringMap[key] === undefined) {
112
112
  return;
113
113
  }
114
+ // Don't append page=1 to URL since it's the default and affects SEO
115
+ if (key === 'page' && val === 1) {
116
+ return;
117
+ }
114
118
  let encodedVal = '';
115
119
  if (key === 'filters' && state.filters) {
116
120
  getFilterParamsFromState(params, state.filters);
@@ -1,3 +1,3 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.default = '1.9.0';
3
+ exports.default = '1.10.0';
@@ -13,6 +13,7 @@ export const cnstrcDataAttrs = {
13
13
  zeroResults: 'data-cnstrc-zero-result',
14
14
  slCampaignId: 'data-cnstrc-sl-campaign-id',
15
15
  slCampaignOwner: 'data-cnstrc-sl-campaign-owner',
16
+ resultPage: 'data-cnstrc-result-page',
16
17
  },
17
18
  search: {
18
19
  searchContainer: 'data-cnstrc-search',
@@ -53,12 +54,14 @@ export function getPlpContainerCnstrcDataAttributes(data, requestConfigs, isLoad
53
54
  const { filterName, filterValue } = requestConfigs;
54
55
  const pageType = getPageType(requestConfigs);
55
56
  const isZeroResults = data.response.totalNumResults === 0;
57
+ const resultPage = data?.request?.page || requestConfigs.page || 1;
56
58
  let dataCnstrc = {};
57
59
  switch (pageType) {
58
60
  case 'browse':
59
61
  dataCnstrc = {
60
62
  [cnstrcDataAttrs.browse.browseContainer]: true,
61
63
  [cnstrcDataAttrs.common.numResults]: data.response.totalNumResults,
64
+ [cnstrcDataAttrs.common.resultPage]: resultPage,
62
65
  [cnstrcDataAttrs.common.resultId]: data.resultId,
63
66
  [cnstrcDataAttrs.browse.filterName]: filterName,
64
67
  [cnstrcDataAttrs.browse.filterValue]: filterValue,
@@ -69,6 +72,7 @@ export function getPlpContainerCnstrcDataAttributes(data, requestConfigs, isLoad
69
72
  [cnstrcDataAttrs.search.searchContainer]: true,
70
73
  [cnstrcDataAttrs.common.resultId]: data.resultId,
71
74
  [cnstrcDataAttrs.common.numResults]: data.response.totalNumResults,
75
+ [cnstrcDataAttrs.common.resultPage]: resultPage,
72
76
  };
73
77
  // Add search term
74
78
  if (data.request?.term) {
@@ -99,6 +99,10 @@ export function getUrlFromState(state, url) {
99
99
  if (defaultQueryStringMap[key] === undefined) {
100
100
  return;
101
101
  }
102
+ // Don't append page=1 to URL since it's the default and affects SEO
103
+ if (key === 'page' && val === 1) {
104
+ return;
105
+ }
102
106
  let encodedVal = '';
103
107
  if (key === 'filters' && state.filters) {
104
108
  getFilterParamsFromState(params, state.filters);
@@ -1 +1 @@
1
- export default '1.9.0';
1
+ export default '1.10.0';
@@ -18,6 +18,7 @@ export declare const cnstrcDataAttrs: {
18
18
  zeroResults: string;
19
19
  slCampaignId: string;
20
20
  slCampaignOwner: string;
21
+ resultPage: string;
21
22
  };
22
23
  search: {
23
24
  searchContainer: string;
@@ -1,2 +1,2 @@
1
- declare const _default: "1.9.0";
1
+ declare const _default: "1.10.0";
2
2
  export default _default;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@constructor-io/constructorio-ui-plp",
3
- "version": "1.9.0",
3
+ "version": "1.10.0",
4
4
  "description": "Constructor PLP UI library for web applications",
5
5
  "author": "Constructor.io Corporation",
6
6
  "license": "MIT",