@shopgate/engage 7.32.0-beta.14 → 7.32.0-beta.15

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.
Files changed (55) hide show
  1. package/filter/components/FilterItem/index.js +9 -2
  2. package/filter/components/FilterPageContent/components/ApplyButton/index.d.ts +21 -0
  3. package/filter/components/FilterPageContent/components/ApplyButton/index.d.ts.map +1 -0
  4. package/filter/components/FilterPageContent/components/ApplyButton/index.js +25 -52
  5. package/filter/components/FilterPageContent/components/FilterButtonBar/index.d.ts +8 -0
  6. package/filter/components/FilterPageContent/components/FilterButtonBar/index.d.ts.map +1 -0
  7. package/filter/components/FilterPageContent/components/FilterButtonBar/index.js +63 -0
  8. package/filter/components/FilterPageContent/components/ResetButton/index.d.ts +17 -0
  9. package/filter/components/FilterPageContent/components/ResetButton/index.d.ts.map +1 -0
  10. package/filter/components/FilterPageContent/components/ResetButton/index.js +24 -46
  11. package/filter/components/FilterPageContent/components/Selector/components/Selected/index.d.ts +19 -0
  12. package/filter/components/FilterPageContent/components/Selector/components/Selected/index.d.ts.map +1 -0
  13. package/filter/components/FilterPageContent/components/Selector/components/Selected/index.js +25 -46
  14. package/filter/components/FilterPageContent/components/Selector/components/Toggle/index.d.ts +14 -0
  15. package/filter/components/FilterPageContent/components/Selector/components/Toggle/index.d.ts.map +1 -0
  16. package/filter/components/FilterPageContent/components/Selector/components/Toggle/index.js +13 -46
  17. package/filter/components/FilterPageContent/components/Selector/components/ValueCheckbox/index.d.ts +25 -0
  18. package/filter/components/FilterPageContent/components/Selector/components/ValueCheckbox/index.d.ts.map +1 -0
  19. package/filter/components/FilterPageContent/components/Selector/components/ValueCheckbox/index.js +77 -0
  20. package/filter/components/FilterPageContent/components/Selector/index.d.ts +43 -0
  21. package/filter/components/FilterPageContent/components/Selector/index.d.ts.map +1 -0
  22. package/filter/components/FilterPageContent/components/Selector/index.js +52 -40
  23. package/filter/components/FilterPageContent/index.d.ts +16 -0
  24. package/filter/components/FilterPageContent/index.d.ts.map +1 -0
  25. package/filter/components/FilterPageContent/index.js +51 -57
  26. package/filter/components/PriceSlider/components/Label/index.js +69 -94
  27. package/filter/components/PriceSlider/index.js +43 -33
  28. package/filter/helpers/buildFilterParamsForFetchFiltersRequest.d.ts +8 -0
  29. package/filter/helpers/buildFilterParamsForFetchFiltersRequest.d.ts.map +1 -0
  30. package/filter/helpers/buildInitialFilters.d.ts +7 -0
  31. package/filter/helpers/buildInitialFilters.d.ts.map +1 -0
  32. package/filter/helpers/buildUpdatedFilters.d.ts +7 -0
  33. package/filter/helpers/buildUpdatedFilters.d.ts.map +1 -0
  34. package/filter/helpers/index.d.ts +5 -0
  35. package/filter/helpers/index.d.ts.map +1 -0
  36. package/filter/helpers/translateFilterLabel.d.ts +8 -0
  37. package/filter/helpers/translateFilterLabel.d.ts.map +1 -0
  38. package/filter/providers/FilterPageProvider.context.d.ts +157 -0
  39. package/filter/providers/FilterPageProvider.context.d.ts.map +1 -0
  40. package/filter/providers/FilterPageProvider.d.ts +24 -0
  41. package/filter/providers/FilterPageProvider.d.ts.map +1 -0
  42. package/filter/providers/FilterPageProvider.js +77 -132
  43. package/locations/components/GlobalLocationSwitcher/GlobalLocationSwitcherBar.js +4 -2
  44. package/package.json +7 -7
  45. package/product/components/FilterBar/components/Content/components/FilterButton/index.js +38 -46
  46. package/product/components/FilterBar/components/Content/components/FilterChips/components/FilterChip/index.d.ts +38 -0
  47. package/product/components/FilterBar/components/Content/components/FilterChips/components/FilterChip/index.d.ts.map +1 -0
  48. package/product/components/FilterBar/components/Content/components/FilterChips/components/FilterChip/index.js +88 -0
  49. package/product/components/FilterBar/components/Content/components/FilterChips/index.js +54 -35
  50. package/product/components/FilterBar/components/Content/components/Sort/index.js +1 -1
  51. package/product/components/FilterBar/components/Content/index.js +7 -3
  52. package/product/components/FilterBar/index.js +11 -22
  53. package/product/components/ProductFilters/index.js +2 -6
  54. package/filter/components/FilterPageContent/components/Selector/components/ValueButton/index.js +0 -69
  55. package/product/components/FilterBar/components/Content/components/FilterChips/connector.js +0 -22
@@ -2,13 +2,14 @@ import React, { useState, useEffect, useCallback, useRef, memo } from 'react';
2
2
  import PropTypes from 'prop-types';
3
3
  import isEqual from 'lodash/isEqual';
4
4
  import { makeStyles } from '@shopgate/engage/styles';
5
- import { RangeSlider } from '@shopgate/engage/components';
5
+ import { Accordion, RangeSlider } from '@shopgate/engage/components';
6
+ import { i18n } from '@shopgate/engage/core/helpers';
6
7
  import { FilterItem } from '@shopgate/engage/filter';
7
8
  import Label from "./components/Label";
8
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
9
+ import { jsx as _jsx } from "react/jsx-runtime";
9
10
  const useStyles = makeStyles()(theme => ({
10
- wrapper: {
11
- padding: theme.spacing(1.5, 2)
11
+ accordionContent: {
12
+ padding: theme.spacing(0, 2, 1)
12
13
  },
13
14
  rangeSliderContainer: {
14
15
  paddingTop: theme.spacing(2),
@@ -27,18 +28,18 @@ const useStyles = makeStyles()(theme => ({
27
28
  marginRight: theme.spacing(1)
28
29
  },
29
30
  rangeSliderHandleInner: {
30
- background: theme.palette.common.white,
31
- border: `1px solid ${theme.components.border.light}`,
32
- boxShadow: theme.shadows[2],
31
+ background: theme.palette.grey.light,
32
+ boxShadow: '0 0 8px rgba(0, 0, 0, .32)',
33
33
  ...theme.applyStyles('dark', {
34
- boxShadow: 'none',
35
- border: 'none'
34
+ background: '#F2F2F2'
36
35
  }),
37
36
  borderRadius: '50%',
38
37
  width: theme.spacing(3),
39
38
  height: theme.spacing(3)
40
39
  },
41
- rangeSliderHandleOuter: {}
40
+ rangeSliderHandleOuter: {
41
+ padding: theme.spacing(1)
42
+ }
42
43
  }));
43
44
 
44
45
  /**
@@ -79,31 +80,40 @@ const PriceSlider = ({
79
80
  }, [id, onChange]);
80
81
  const priceMin = Math.floor(value[0] / 100);
81
82
  const priceMax = Math.ceil(value[1] / 100);
82
- const priceLength = `${(max / 100).toString().length + 2}ch`;
83
+ const priceLength = (max / 100).toString().length;
84
+ const renderLabel = useCallback(() => /*#__PURE__*/_jsx(Label, {
85
+ priceLength: priceLength,
86
+ priceMax: priceMax,
87
+ priceMin: priceMin,
88
+ onChange: handleChange
89
+ }), [handleChange, priceLength, priceMax, priceMin]);
83
90
  return /*#__PURE__*/_jsx(FilterItem, {
84
- children: /*#__PURE__*/_jsxs("div", {
85
- className: classes.wrapper,
91
+ children: /*#__PURE__*/_jsx("div", {
86
92
  "data-test-id": "priceRangeSlider",
87
- children: [/*#__PURE__*/_jsx(Label, {
88
- priceLength: priceLength,
89
- priceMax: priceMax,
90
- priceMin: priceMin,
91
- onChange: handleChange
92
- }), /*#__PURE__*/_jsx(RangeSlider, {
93
- classNames: {
94
- container: classes.rangeSliderContainer,
95
- outerRange: classes.rangeSliderOuterRange,
96
- range: classes.rangeSliderRange,
97
- handleInner: classes.rangeSliderHandleInner,
98
- handleOuter: classes.rangeSliderHandleOuter
99
- },
100
- easing: useLinearEasing ? 'linear' : 'exponential',
101
- factor: 3,
102
- max: max,
103
- min: min,
104
- onChange: handleChange,
105
- value: value
106
- })]
93
+ children: /*#__PURE__*/_jsx(Accordion, {
94
+ openWithChevron: true,
95
+ startOpened: true,
96
+ renderLabel: renderLabel,
97
+ contentClassName: classes.accordionContent,
98
+ handleLabel: i18n.text('filter.filter_by', {
99
+ label: i18n.text('filter.label.price')
100
+ }),
101
+ children: /*#__PURE__*/_jsx(RangeSlider, {
102
+ classNames: {
103
+ container: classes.rangeSliderContainer,
104
+ outerRange: classes.rangeSliderOuterRange,
105
+ range: classes.rangeSliderRange,
106
+ handleInner: classes.rangeSliderHandleInner,
107
+ handleOuter: classes.rangeSliderHandleOuter
108
+ },
109
+ easing: useLinearEasing ? 'linear' : 'exponential',
110
+ factor: 3,
111
+ max: max,
112
+ min: min,
113
+ onChange: handleChange,
114
+ value: value
115
+ })
116
+ })
107
117
  })
108
118
  });
109
119
  };
@@ -0,0 +1,8 @@
1
+ export default buildFilterParamsForFetchFiltersRequest;
2
+ /**
3
+ * Creates the filter params to be used with a fetchFilters request.
4
+ * @param {Object} filters All configured filters
5
+ * @return {Object}
6
+ */
7
+ declare function buildFilterParamsForFetchFiltersRequest(filters?: Object): Object;
8
+ //# sourceMappingURL=buildFilterParamsForFetchFiltersRequest.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"buildFilterParamsForFetchFiltersRequest.d.ts","sourceRoot":"","sources":["../../../filter/helpers/buildFilterParamsForFetchFiltersRequest.js"],"names":[],"mappings":";AAEA;;;;GAIG;AACH,mEAHW,MAAM,GACL,MAAM,CAuCjB"}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * @param {Object} filters The available filters.
3
+ * @param {Object} activeFilters The selected filters.
4
+ * @returns {Object}
5
+ */
6
+ export default function buildInitialFilters(filters: Object, activeFilters: Object): Object;
7
+ //# sourceMappingURL=buildInitialFilters.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"buildInitialFilters.d.ts","sourceRoot":"","sources":["../../../filter/helpers/buildInitialFilters.js"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,qDAJW,MAAM,iBACN,MAAM,GACJ,MAAM,CAwBlB"}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * @param {Object} initialFilters The filters before they where modified.
3
+ * @param {Object} updatedFilters The filters after they where modified.
4
+ * @return {Object}
5
+ */
6
+ export default function buildUpdatedFilters(initialFilters: Object, updatedFilters: Object): Object;
7
+ //# sourceMappingURL=buildUpdatedFilters.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"buildUpdatedFilters.d.ts","sourceRoot":"","sources":["../../../filter/helpers/buildUpdatedFilters.js"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,4DAJW,MAAM,kBACN,MAAM,GACL,MAAM,CAgCjB"}
@@ -0,0 +1,5 @@
1
+ export { default as buildInitialFilters } from "./buildInitialFilters";
2
+ export { default as buildUpdatedFilters } from "./buildUpdatedFilters";
3
+ export { default as buildFilterParamsForFetchFiltersRequest } from "./buildFilterParamsForFetchFiltersRequest";
4
+ export { translateFilterLabel } from "./translateFilterLabel";
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../filter/helpers/index.js"],"names":[],"mappings":""}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Translate filter label
3
+ * @param {string} id filter id.
4
+ * @param {string} label filter label.
5
+ * @returns {string}
6
+ */
7
+ export function translateFilterLabel(id: string, label: string): string;
8
+ //# sourceMappingURL=translateFilterLabel.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"translateFilterLabel.d.ts","sourceRoot":"","sources":["../../../filter/helpers/translateFilterLabel.js"],"names":[],"mappings":"AAEA;;;;;GAKG;AACH,yCAJW,MAAM,SACN,MAAM,GACJ,MAAM,CAIlB"}
@@ -0,0 +1,157 @@
1
+ export default context;
2
+ export type APIFilterValue = {
3
+ /**
4
+ * Filter value id
5
+ */
6
+ id: string;
7
+ /**
8
+ * Filter value label
9
+ */
10
+ label: string;
11
+ /**
12
+ * Number of hits for the filter value
13
+ */
14
+ hits: number;
15
+ };
16
+ export type APIFilter = {
17
+ /**
18
+ * Filter id
19
+ */
20
+ id: string;
21
+ /**
22
+ * Filter label
23
+ */
24
+ label: string;
25
+ /**
26
+ * Filter type
27
+ */
28
+ type: "range" | "multiselect" | "single_select";
29
+ /**
30
+ * Filter source
31
+ */
32
+ source?: string | undefined;
33
+ /**
34
+ * Minimum value for a range filter
35
+ */
36
+ minimum?: number | undefined;
37
+ /**
38
+ * Maximum value for a range filter
39
+ */
40
+ maximum?: number | undefined;
41
+ values: APIFilterValue[];
42
+ };
43
+ export type RouteFilterValue = {
44
+ /**
45
+ * Filter value id
46
+ */
47
+ id: string;
48
+ /**
49
+ * Filter value label
50
+ */
51
+ label: string;
52
+ };
53
+ export type RouteFilter = {
54
+ /**
55
+ * Filter id
56
+ */
57
+ id: string;
58
+ /**
59
+ * Filter label
60
+ */
61
+ label: string;
62
+ /**
63
+ * Filter source
64
+ */
65
+ source: string;
66
+ /**
67
+ * Filter type
68
+ */
69
+ type: "range" | "multiselect" | "single_select";
70
+ /**
71
+ * Selected values for the filter
72
+ */
73
+ values: RouteFilterValue[];
74
+ };
75
+ /**
76
+ * Object with the active filters for a route with filtered product list
77
+ */
78
+ export type RouteFilters = {
79
+ [x: string]: RouteFilter;
80
+ };
81
+ export type GetSelectedFilterValuesFn = (filterId: string) => any;
82
+ export type UpdateSelectedFilterValuesFn = (filterId: string, selectedValues: string[]) => void;
83
+ export type FilterPageContext = {
84
+ /**
85
+ * Whether the filter selection has changed since the filters page
86
+ * was opened
87
+ */
88
+ hasChanged: boolean;
89
+ /**
90
+ * Whether a reset of the active filters is possible
91
+ */
92
+ resetPossible: boolean;
93
+ /**
94
+ * List of available filters from the API
95
+ */
96
+ apiFilters: APIFilter[];
97
+ /**
98
+ * Object that represents the current state of all filters
99
+ */
100
+ filters: RouteFilters;
101
+ /**
102
+ * Resets all filters which have been changed by the
103
+ * user
104
+ */
105
+ resetAllFilters: () => void;
106
+ /**
107
+ * Resets all filters which have been changed by the
108
+ * user since the filters page was opened
109
+ */
110
+ resetChangedFilters: () => void;
111
+ /**
112
+ * Applies the current filter selection to the parent route
113
+ * with a product list to be filtered
114
+ */
115
+ applyFilters: () => void;
116
+ /**
117
+ * Retrieves a list of currently
118
+ * selected values for a filter
119
+ */
120
+ getSelectedFilterValues: GetSelectedFilterValuesFn;
121
+ /**
122
+ * Updates the selection for a
123
+ * filter
124
+ */
125
+ updateSelectedFilterValues: UpdateSelectedFilterValuesFn;
126
+ };
127
+ /**
128
+ * @callback GetSelectedFilterValuesFn
129
+ * @param {string} filterId The id of the filter
130
+ */
131
+ /**
132
+ * @callback UpdateSelectedFilterValuesFn
133
+ * @param {string} filterId The id of the filter to be updated
134
+ * @param {string[]} selectedValues The updated selected values
135
+ * @returns {void}
136
+ */
137
+ /**
138
+ * @typedef {Object} FilterPageContext
139
+ * @property {boolean} hasChanged Whether the filter selection has changed since the filters page
140
+ * was opened
141
+ * @property {boolean} resetPossible Whether a reset of the active filters is possible
142
+ * @property {APIFilter[]} apiFilters List of available filters from the API
143
+ * @property {RouteFilters} filters Object that represents the current state of all filters
144
+ * @property {function():void} resetAllFilters Resets all filters which have been changed by the
145
+ * user
146
+ * @property {function():void} resetChangedFilters Resets all filters which have been changed by the
147
+ * user since the filters page was opened
148
+ * @property {function():void} applyFilters Applies the current filter selection to the parent route
149
+ * with a product list to be filtered
150
+ * @property {GetSelectedFilterValuesFn} getSelectedFilterValues Retrieves a list of currently
151
+ * selected values for a filter
152
+ * @property {UpdateSelectedFilterValuesFn} updateSelectedFilterValues Updates the selection for a
153
+ * filter
154
+ */
155
+ /** @type {import('react').Context<FilterPageContext>} */
156
+ declare const context: import("react").Context<FilterPageContext>;
157
+ //# sourceMappingURL=FilterPageProvider.context.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FilterPageProvider.context.d.ts","sourceRoot":"","sources":["../../../filter/providers/FilterPageProvider.context.js"],"names":[],"mappings":";;;;;QAKc,MAAM;;;;WACN,MAAM;;;;UACN,MAAM;;;;;;QAMN,MAAM;;;;WACN,MAAM;;;;UACN,OAAO,GAAC,aAAa,GAAC,eAAe;;;;;;;;;;;;;YAIrC,cAAc,EAAE;;;;;;QAMhB,MAAM;;;;WACN,MAAM;;;;;;QAKN,MAAM;;;;WACN,MAAM;;;;YACN,MAAM;;;;UACN,OAAO,GAAC,aAAa,GAAC,eAAe;;;;YACrC,gBAAgB,EAAE;;;;;;;;mDAWrB,MAAM;sDAKN,MAAM,kBACN,MAAM,EAAE,KACN,IAAI;;;;;;gBAIH,OAAO;;;;mBAEP,OAAO;;;;gBACP,SAAS,EAAE;;;;aACX,YAAY;;;;;qBACZ,MAAW,IAAI;;;;;yBAEf,MAAW,IAAI;;;;;kBAEf,MAAW,IAAI;;;;;6BAEf,yBAAyB;;;;;gCAEzB,4BAA4B;;AA1B1C;;;GAGG;AAEH;;;;;GAKG;AACH;;;;;;;;;;;;;;;;;GAiBG;AAEH,yDAAyD;AACzD,uBADW,OAAO,OAAO,EAAE,OAAO,CAAC,iBAAiB,CAAC,CAWlD"}
@@ -0,0 +1,24 @@
1
+ import type { ReactNode } from 'react';
2
+ import type { APIFilter, RouteFilters } from './FilterPageProvider.context';
3
+ interface FilterPageProviderProps {
4
+ /** Array of available filters, injected from Redux. */
5
+ filters?: APIFilter[] | null;
6
+ /** Object with the active filters for a filtered product list. */
7
+ activeFilters?: RouteFilters | null;
8
+ /** Id of the route with the product list that's supposed to be filtered. */
9
+ parentRouteId?: string | null;
10
+ /** Callback invoked when users pressed the apply button. */
11
+ onApply?: (filters: RouteFilters | null) => void;
12
+ /** Provider children. */
13
+ children?: ReactNode;
14
+ }
15
+ declare const _default: import("react-redux").ConnectedComponent<({ filters: filtersProp, activeFilters: activeFiltersProp, parentRouteId, onApply, children, }: FilterPageProviderProps) => import("react").JSX.Element, {
16
+ children?: ReactNode;
17
+ activeFilters?: (RouteFilters | null) | undefined;
18
+ parentRouteId?: string | null | undefined;
19
+ onApply?: ((filters: RouteFilters | null) => void) | undefined;
20
+ context?: import("react-redux/es/components/Context").ReactReduxContextInstance | undefined;
21
+ store?: import("redux").Store | undefined;
22
+ }>;
23
+ export default _default;
24
+ //# sourceMappingURL=FilterPageProvider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FilterPageProvider.d.ts","sourceRoot":"","sources":["../../../filter/providers/FilterPageProvider.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAkB,SAAS,EAAE,MAAM,OAAO,CAAC;AASvD,OAAO,KAAK,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAyC5E,UAAU,uBAAuB;IAC/B,uDAAuD;IACvD,OAAO,CAAC,EAAE,SAAS,EAAE,GAAG,IAAI,CAAC;IAC7B,kEAAkE;IAClE,aAAa,CAAC,EAAE,YAAY,GAAG,IAAI,CAAC;IACpC,4EAA4E;IAC5E,aAAa,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,4DAA4D;IAC5D,OAAO,CAAC,EAAE,CAAC,OAAO,EAAE,YAAY,GAAG,IAAI,KAAK,IAAI,CAAC;IACjD,yBAAyB;IACzB,QAAQ,CAAC,EAAE,SAAS,CAAC;CACtB;iKAoCE,uBAAuB;;qBA3CR,YAAY,GAAG,IAAI;oBAEnB,MAAM,GAAG,IAAI;eAEnB,CAAC,OAAO,EAAE,YAAY,GAAG,IAAI,KAAK,IAAI;;;;AAiQlD,wBAKsB"}