@shopgate/engage 7.32.0-beta.13 → 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.
- package/admin-preview/constants/index.d.ts +9 -1
- package/admin-preview/constants/index.d.ts.map +1 -1
- package/admin-preview/constants/index.js +10 -2
- package/admin-preview/helpers/_internal/origins.d.ts +20 -0
- package/admin-preview/helpers/_internal/origins.d.ts.map +1 -0
- package/admin-preview/helpers/_internal/origins.js +72 -0
- package/admin-preview/helpers/index.d.ts +13 -0
- package/admin-preview/helpers/index.d.ts.map +1 -1
- package/admin-preview/helpers/index.js +17 -1
- package/admin-preview/hooks/index.d.ts +9 -7
- package/admin-preview/hooks/index.d.ts.map +1 -1
- package/admin-preview/hooks/index.js +21 -18
- package/admin-preview/initialization/awaitInitialFrontendSettings.d.ts +4 -3
- package/admin-preview/initialization/awaitInitialFrontendSettings.d.ts.map +1 -1
- package/admin-preview/initialization/awaitInitialFrontendSettings.js +13 -9
- package/filter/components/FilterItem/index.js +9 -2
- package/filter/components/FilterPageContent/components/ApplyButton/index.d.ts +21 -0
- package/filter/components/FilterPageContent/components/ApplyButton/index.d.ts.map +1 -0
- package/filter/components/FilterPageContent/components/ApplyButton/index.js +25 -52
- package/filter/components/FilterPageContent/components/FilterButtonBar/index.d.ts +8 -0
- package/filter/components/FilterPageContent/components/FilterButtonBar/index.d.ts.map +1 -0
- package/filter/components/FilterPageContent/components/FilterButtonBar/index.js +63 -0
- package/filter/components/FilterPageContent/components/ResetButton/index.d.ts +17 -0
- package/filter/components/FilterPageContent/components/ResetButton/index.d.ts.map +1 -0
- package/filter/components/FilterPageContent/components/ResetButton/index.js +24 -46
- package/filter/components/FilterPageContent/components/Selector/components/Selected/index.d.ts +19 -0
- package/filter/components/FilterPageContent/components/Selector/components/Selected/index.d.ts.map +1 -0
- package/filter/components/FilterPageContent/components/Selector/components/Selected/index.js +25 -46
- package/filter/components/FilterPageContent/components/Selector/components/Toggle/index.d.ts +14 -0
- package/filter/components/FilterPageContent/components/Selector/components/Toggle/index.d.ts.map +1 -0
- package/filter/components/FilterPageContent/components/Selector/components/Toggle/index.js +13 -46
- package/filter/components/FilterPageContent/components/Selector/components/ValueCheckbox/index.d.ts +25 -0
- package/filter/components/FilterPageContent/components/Selector/components/ValueCheckbox/index.d.ts.map +1 -0
- package/filter/components/FilterPageContent/components/Selector/components/ValueCheckbox/index.js +77 -0
- package/filter/components/FilterPageContent/components/Selector/index.d.ts +43 -0
- package/filter/components/FilterPageContent/components/Selector/index.d.ts.map +1 -0
- package/filter/components/FilterPageContent/components/Selector/index.js +52 -40
- package/filter/components/FilterPageContent/index.d.ts +16 -0
- package/filter/components/FilterPageContent/index.d.ts.map +1 -0
- package/filter/components/FilterPageContent/index.js +51 -57
- package/filter/components/PriceSlider/components/Label/index.js +69 -94
- package/filter/components/PriceSlider/index.js +43 -33
- package/filter/helpers/buildFilterParamsForFetchFiltersRequest.d.ts +8 -0
- package/filter/helpers/buildFilterParamsForFetchFiltersRequest.d.ts.map +1 -0
- package/filter/helpers/buildInitialFilters.d.ts +7 -0
- package/filter/helpers/buildInitialFilters.d.ts.map +1 -0
- package/filter/helpers/buildUpdatedFilters.d.ts +7 -0
- package/filter/helpers/buildUpdatedFilters.d.ts.map +1 -0
- package/filter/helpers/index.d.ts +5 -0
- package/filter/helpers/index.d.ts.map +1 -0
- package/filter/helpers/translateFilterLabel.d.ts +8 -0
- package/filter/helpers/translateFilterLabel.d.ts.map +1 -0
- package/filter/providers/FilterPageProvider.context.d.ts +157 -0
- package/filter/providers/FilterPageProvider.context.d.ts.map +1 -0
- package/filter/providers/FilterPageProvider.d.ts +24 -0
- package/filter/providers/FilterPageProvider.d.ts.map +1 -0
- package/filter/providers/FilterPageProvider.js +77 -132
- package/locations/components/GlobalLocationSwitcher/GlobalLocationSwitcherBar.js +4 -2
- package/package.json +7 -7
- package/page/components/Widgets/hooks.d.ts.map +1 -1
- package/page/components/Widgets/hooks.js +5 -1
- package/product/components/FilterBar/components/Content/components/FilterButton/index.js +38 -46
- package/product/components/FilterBar/components/Content/components/FilterChips/components/FilterChip/index.d.ts +38 -0
- package/product/components/FilterBar/components/Content/components/FilterChips/components/FilterChip/index.d.ts.map +1 -0
- package/product/components/FilterBar/components/Content/components/FilterChips/components/FilterChip/index.js +88 -0
- package/product/components/FilterBar/components/Content/components/FilterChips/index.js +54 -35
- package/product/components/FilterBar/components/Content/components/Sort/index.js +1 -1
- package/product/components/FilterBar/components/Content/index.js +7 -3
- package/product/components/FilterBar/index.js +11 -22
- package/product/components/ProductFilters/index.js +2 -6
- package/filter/components/FilterPageContent/components/Selector/components/ValueButton/index.js +0 -69
- package/product/components/FilterBar/components/Content/components/FilterChips/connector.js +0 -22
|
@@ -1,35 +1,28 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
3
|
import { makeStyles } from '@shopgate/engage/styles';
|
|
4
|
-
import {
|
|
4
|
+
import { i18n } from '@shopgate/engage/core/helpers';
|
|
5
|
+
import { Badge, I18n, FilterIcon, Typography } from '@shopgate/engage/components';
|
|
5
6
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
6
7
|
const useStyles = makeStyles()(theme => ({
|
|
7
8
|
button: {
|
|
9
|
+
display: 'flex',
|
|
10
|
+
alignItems: 'center',
|
|
11
|
+
gap: theme.spacing(0.75),
|
|
8
12
|
color: 'inherit',
|
|
9
|
-
fontSize: theme.components.icon.medium,
|
|
10
13
|
outline: 0,
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
overflow: 'hidden'
|
|
17
|
-
},
|
|
18
|
-
filterButton: {
|
|
19
|
-
display: 'flex'
|
|
14
|
+
flexShrink: 0,
|
|
15
|
+
margin: theme.spacing(0, 1.5),
|
|
16
|
+
padding: theme.spacing(0.25, 1),
|
|
17
|
+
border: `1px solid ${theme.components.border.medium}`,
|
|
18
|
+
borderRadius: theme.shape.borderRadius
|
|
20
19
|
},
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
paddingRight: theme.spacing(1)
|
|
20
|
+
buttonActive: {
|
|
21
|
+
borderColor: theme.components.badge.background
|
|
24
22
|
},
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
width: '100%',
|
|
29
|
-
justifyContent: 'center',
|
|
30
|
-
alignItems: 'center',
|
|
31
|
-
margin: 0,
|
|
32
|
-
padding: '6px 10px'
|
|
23
|
+
icon: {
|
|
24
|
+
fontSize: theme.components.icon.medium,
|
|
25
|
+
display: 'flex'
|
|
33
26
|
}
|
|
34
27
|
}));
|
|
35
28
|
|
|
@@ -39,39 +32,38 @@ const useStyles = makeStyles()(theme => ({
|
|
|
39
32
|
* @return {JSX}
|
|
40
33
|
*/
|
|
41
34
|
function FilterButton({
|
|
42
|
-
openFilters
|
|
35
|
+
openFilters,
|
|
36
|
+
filterCount
|
|
43
37
|
}) {
|
|
44
38
|
const {
|
|
45
39
|
classes,
|
|
46
40
|
cx
|
|
47
41
|
} = useStyles();
|
|
48
|
-
return /*#__PURE__*/
|
|
49
|
-
className: cx(classes.button,
|
|
42
|
+
return /*#__PURE__*/_jsxs("button", {
|
|
43
|
+
className: cx(classes.button, {
|
|
44
|
+
[classes.buttonActive]: filterCount > 0
|
|
45
|
+
}, 'theme__filter-bar__filter-button'),
|
|
50
46
|
onClick: openFilters,
|
|
51
47
|
"data-test-id": "filterButton",
|
|
48
|
+
"aria-label": i18n.text('titles.filter'),
|
|
52
49
|
type: "button",
|
|
53
|
-
children: /*#__PURE__*/_jsx(
|
|
54
|
-
className: classes.
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
children: /*#__PURE__*/_jsx(Typography, {
|
|
62
|
-
variant: "subtitle2",
|
|
63
|
-
component: "span",
|
|
64
|
-
className: classes.filterButtonLabel,
|
|
65
|
-
children: /*#__PURE__*/_jsx(I18n.Text, {
|
|
66
|
-
string: "titles.filter"
|
|
67
|
-
})
|
|
68
|
-
})
|
|
69
|
-
}), /*#__PURE__*/_jsx(Grid.Item, {
|
|
70
|
-
component: "div",
|
|
71
|
-
children: /*#__PURE__*/_jsx(FilterIcon, {})
|
|
72
|
-
})]
|
|
50
|
+
children: [/*#__PURE__*/_jsx("span", {
|
|
51
|
+
className: classes.icon,
|
|
52
|
+
children: /*#__PURE__*/_jsx(FilterIcon, {})
|
|
53
|
+
}), /*#__PURE__*/_jsx(Typography, {
|
|
54
|
+
variant: "subtitle2",
|
|
55
|
+
component: "span",
|
|
56
|
+
children: /*#__PURE__*/_jsx(I18n.Text, {
|
|
57
|
+
string: "titles.filter"
|
|
73
58
|
})
|
|
74
|
-
})
|
|
59
|
+
}), /*#__PURE__*/_jsx(Badge, {
|
|
60
|
+
count: filterCount,
|
|
61
|
+
max: 9,
|
|
62
|
+
"aria-hidden": true
|
|
63
|
+
})]
|
|
75
64
|
});
|
|
76
65
|
}
|
|
66
|
+
FilterButton.defaultProps = {
|
|
67
|
+
filterCount: 0
|
|
68
|
+
};
|
|
77
69
|
export default FilterButton;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
export interface FilterChipProps {
|
|
3
|
+
/**
|
|
4
|
+
* Id of the filter value. Used as the test id and passed back to `onRemove`.
|
|
5
|
+
*/
|
|
6
|
+
id: string;
|
|
7
|
+
/**
|
|
8
|
+
* The chip label.
|
|
9
|
+
*/
|
|
10
|
+
children: ReactNode;
|
|
11
|
+
/**
|
|
12
|
+
* Whether the chip renders a remove button (default `true`).
|
|
13
|
+
*/
|
|
14
|
+
removable?: boolean;
|
|
15
|
+
/**
|
|
16
|
+
* Aria label for the label button, which opens the filter page.
|
|
17
|
+
*/
|
|
18
|
+
editLabel?: string;
|
|
19
|
+
/**
|
|
20
|
+
* Aria label for the remove button.
|
|
21
|
+
*/
|
|
22
|
+
removeLabel?: string;
|
|
23
|
+
/**
|
|
24
|
+
* Invoked when the chip label is clicked.
|
|
25
|
+
*/
|
|
26
|
+
onClick?: () => void;
|
|
27
|
+
/**
|
|
28
|
+
* Invoked with the chip id when the remove button is clicked.
|
|
29
|
+
*/
|
|
30
|
+
onRemove?: (id: string) => void;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* A removable chip representing one active filter within the filter bar.
|
|
34
|
+
* @returns The rendered component.
|
|
35
|
+
*/
|
|
36
|
+
declare const FilterChip: ({ id, children, removable, editLabel, removeLabel, onClick, onRemove, }: FilterChipProps) => import("react").JSX.Element;
|
|
37
|
+
export default FilterChip;
|
|
38
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../../../../../product/components/FilterBar/components/Content/components/FilterChips/components/FilterChip/index.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAiB,SAAS,EAAE,MAAM,OAAO,CAAC;AAwDtD,MAAM,WAAW,eAAe;IAC9B;;OAEG;IACH,EAAE,EAAE,MAAM,CAAC;IACX;;OAEG;IACH,QAAQ,EAAE,SAAS,CAAC;IACpB;;OAEG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB;;OAEG;IACH,QAAQ,CAAC,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;CACjC;AAED;;;GAGG;AACH,QAAA,MAAM,UAAU,GAAI,yEAQjB,eAAe,gCAwBjB,CAAC;AAEF,eAAe,UAAU,CAAC"}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { useCallback } from 'react';
|
|
2
|
+
import noop from 'lodash/noop';
|
|
3
|
+
import Button from '@shopgate/pwa-common/components/Button';
|
|
4
|
+
import { CrossIcon } from '@shopgate/engage/components';
|
|
5
|
+
import { makeStyles } from '@shopgate/engage/styles';
|
|
6
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
7
|
+
const useStyles = makeStyles()((theme, {
|
|
8
|
+
removable
|
|
9
|
+
}) => ({
|
|
10
|
+
chip: {
|
|
11
|
+
display: 'flex',
|
|
12
|
+
alignItems: 'center',
|
|
13
|
+
minWidth: 0,
|
|
14
|
+
maxWidth: '72%',
|
|
15
|
+
height: 30,
|
|
16
|
+
borderRadius: theme.shape.borderRadius,
|
|
17
|
+
border: `1px solid ${theme.palette.secondary.main}`,
|
|
18
|
+
background: theme.palette.background.surface,
|
|
19
|
+
color: theme.palette.text.primary,
|
|
20
|
+
paddingLeft: removable ? theme.spacing(0.75) : theme.spacing(1.25),
|
|
21
|
+
paddingRight: theme.spacing(1.25),
|
|
22
|
+
outline: 0
|
|
23
|
+
},
|
|
24
|
+
name: {
|
|
25
|
+
...theme.typography.body2,
|
|
26
|
+
fontWeight: theme.typography.fontWeightMedium,
|
|
27
|
+
display: 'block',
|
|
28
|
+
color: 'inherit',
|
|
29
|
+
padding: 0,
|
|
30
|
+
paddingLeft: removable ? theme.spacing(0.5) : 0,
|
|
31
|
+
maxWidth: '100%',
|
|
32
|
+
overflow: 'hidden',
|
|
33
|
+
textOverflow: 'ellipsis',
|
|
34
|
+
whiteSpace: 'nowrap'
|
|
35
|
+
},
|
|
36
|
+
removeButton: {
|
|
37
|
+
display: 'flex',
|
|
38
|
+
flexShrink: 0,
|
|
39
|
+
padding: 0,
|
|
40
|
+
color: theme.palette.secondary.main
|
|
41
|
+
}
|
|
42
|
+
}));
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* `Button` is untyped JavaScript whose optional props read as required from TypeScript.
|
|
46
|
+
*/
|
|
47
|
+
const ChipButton = Button;
|
|
48
|
+
/**
|
|
49
|
+
* A removable chip representing one active filter within the filter bar.
|
|
50
|
+
* @returns The rendered component.
|
|
51
|
+
*/
|
|
52
|
+
const FilterChip = ({
|
|
53
|
+
id,
|
|
54
|
+
children,
|
|
55
|
+
removable = true,
|
|
56
|
+
editLabel,
|
|
57
|
+
removeLabel,
|
|
58
|
+
onClick = noop,
|
|
59
|
+
onRemove = noop
|
|
60
|
+
}) => {
|
|
61
|
+
const {
|
|
62
|
+
classes
|
|
63
|
+
} = useStyles({
|
|
64
|
+
removable
|
|
65
|
+
});
|
|
66
|
+
const handleRemove = useCallback(() => {
|
|
67
|
+
onRemove(id);
|
|
68
|
+
}, [onRemove, id]);
|
|
69
|
+
return /*#__PURE__*/_jsxs("div", {
|
|
70
|
+
className: classes.chip,
|
|
71
|
+
"data-test-id": id,
|
|
72
|
+
children: [removable && /*#__PURE__*/_jsx(ChipButton, {
|
|
73
|
+
className: classes.removeButton,
|
|
74
|
+
onClick: handleRemove,
|
|
75
|
+
testId: "removeFilter",
|
|
76
|
+
"aria-label": removeLabel,
|
|
77
|
+
children: /*#__PURE__*/_jsx(CrossIcon, {
|
|
78
|
+
size: 16
|
|
79
|
+
})
|
|
80
|
+
}), /*#__PURE__*/_jsx(ChipButton, {
|
|
81
|
+
className: classes.name,
|
|
82
|
+
onClick: onClick,
|
|
83
|
+
"aria-label": editLabel,
|
|
84
|
+
children: children
|
|
85
|
+
})]
|
|
86
|
+
});
|
|
87
|
+
};
|
|
88
|
+
export default FilterChip;
|
|
@@ -1,24 +1,41 @@
|
|
|
1
1
|
import React, { useCallback, useMemo, useEffect } from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
3
|
import noop from 'lodash/noop';
|
|
4
|
+
import { useDispatch } from 'react-redux';
|
|
4
5
|
import { router } from '@virtuous/conductor';
|
|
5
6
|
import appConfig from '@shopgate/pwa-common/helpers/config';
|
|
6
|
-
import {
|
|
7
|
+
import { updateFilters } from '@shopgate/pwa-common-commerce/filter/action-creators';
|
|
8
|
+
import { I18n } from '@shopgate/engage/components';
|
|
7
9
|
import { FILTER_TYPE_RANGE, FILTER_TYPE_MULTISELECT, translateFilterLabel } from '@shopgate/engage/filter';
|
|
8
10
|
import { i18n } from '@shopgate/engage/core/helpers';
|
|
9
11
|
import { makeStyles } from '@shopgate/engage/styles';
|
|
10
|
-
import
|
|
11
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
12
|
+
import FilterChip from "./components/FilterChip";
|
|
13
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
12
14
|
const useStyles = makeStyles()(theme => ({
|
|
13
15
|
container: {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
16
|
+
display: 'flex',
|
|
17
|
+
alignItems: 'center',
|
|
18
|
+
gap: theme.spacing(1),
|
|
19
|
+
overflowX: 'auto',
|
|
20
|
+
overflowY: 'hidden',
|
|
21
|
+
padding: theme.spacing(0.5, 1.5, 1.5),
|
|
22
|
+
width: '100%',
|
|
23
|
+
scrollbarWidth: 'none',
|
|
24
|
+
'&::-webkit-scrollbar': {
|
|
25
|
+
display: 'none'
|
|
26
|
+
},
|
|
27
|
+
'& > *': {
|
|
28
|
+
flexShrink: 0
|
|
29
|
+
}
|
|
17
30
|
},
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
31
|
+
clearAll: {
|
|
32
|
+
...theme.typography.body2,
|
|
33
|
+
color: theme.palette.text.primary,
|
|
34
|
+
outline: 0,
|
|
35
|
+
padding: theme.spacing(0.5, 1, 0.5, 0),
|
|
36
|
+
whiteSpace: 'nowrap',
|
|
37
|
+
textDecoration: 'underline',
|
|
38
|
+
textUnderlineOffset: 3
|
|
22
39
|
}
|
|
23
40
|
}));
|
|
24
41
|
|
|
@@ -29,16 +46,15 @@ const useStyles = makeStyles()(theme => ({
|
|
|
29
46
|
const FilterChips = ({
|
|
30
47
|
filters,
|
|
31
48
|
routeId,
|
|
32
|
-
updateFilters,
|
|
33
49
|
scrollTop,
|
|
34
50
|
openFilters,
|
|
35
|
-
currentPathname,
|
|
36
51
|
onChipCountUpdate
|
|
37
52
|
}) => {
|
|
38
53
|
const {
|
|
39
54
|
classes,
|
|
40
55
|
cx
|
|
41
56
|
} = useStyles();
|
|
57
|
+
const dispatch = useDispatch();
|
|
42
58
|
const handleRemove = useCallback((id, value) => {
|
|
43
59
|
const {
|
|
44
60
|
[id]: selected,
|
|
@@ -62,7 +78,7 @@ const FilterChips = ({
|
|
|
62
78
|
router.update(routeId, {
|
|
63
79
|
filters: newFilters
|
|
64
80
|
});
|
|
65
|
-
updateFilters(newFilters);
|
|
81
|
+
dispatch(updateFilters(newFilters));
|
|
66
82
|
scrollTop();
|
|
67
83
|
}, 0);
|
|
68
84
|
return;
|
|
@@ -72,9 +88,16 @@ const FilterChips = ({
|
|
|
72
88
|
router.update(routeId, {
|
|
73
89
|
filters: newFilters
|
|
74
90
|
});
|
|
75
|
-
updateFilters(newFilters);
|
|
91
|
+
dispatch(updateFilters(newFilters));
|
|
92
|
+
scrollTop();
|
|
93
|
+
}, [dispatch, filters, routeId, scrollTop]);
|
|
94
|
+
const handleClearAll = useCallback(() => {
|
|
95
|
+
router.update(routeId, {
|
|
96
|
+
filters: null
|
|
97
|
+
});
|
|
98
|
+
dispatch(updateFilters(null));
|
|
76
99
|
scrollTop();
|
|
77
|
-
}, [
|
|
100
|
+
}, [dispatch, routeId, scrollTop]);
|
|
78
101
|
const chips = useMemo(() => {
|
|
79
102
|
if (filters === null || !Object.keys(filters).length) {
|
|
80
103
|
return [];
|
|
@@ -108,16 +131,13 @@ const FilterChips = ({
|
|
|
108
131
|
const editLabel = i18n.text('filter.edit', {
|
|
109
132
|
filter: labelValue
|
|
110
133
|
});
|
|
111
|
-
entries.push(/*#__PURE__*/_jsx(
|
|
134
|
+
entries.push(/*#__PURE__*/_jsx(FilterChip, {
|
|
112
135
|
id: key,
|
|
113
136
|
onRemove: handleRemove,
|
|
114
137
|
onClick: openFilters,
|
|
115
138
|
removeLabel: removeLabel,
|
|
116
139
|
editLabel: editLabel,
|
|
117
|
-
children:
|
|
118
|
-
className: classes.label,
|
|
119
|
-
children: pricesFormatted
|
|
120
|
-
})
|
|
140
|
+
children: pricesFormatted
|
|
121
141
|
}, `filter-${key}`));
|
|
122
142
|
break;
|
|
123
143
|
}
|
|
@@ -133,43 +153,42 @@ const FilterChips = ({
|
|
|
133
153
|
const editLabel = i18n.text('filter.edit', {
|
|
134
154
|
filter: filterFormatted
|
|
135
155
|
});
|
|
136
|
-
entries.push(/*#__PURE__*/_jsx(
|
|
156
|
+
entries.push(/*#__PURE__*/_jsx(FilterChip, {
|
|
137
157
|
id: value.id,
|
|
138
158
|
onRemove: () => handleRemove(filter.id, value.id),
|
|
139
159
|
onClick: openFilters,
|
|
140
160
|
removeLabel: removeLabel,
|
|
141
161
|
editLabel: editLabel,
|
|
142
|
-
children:
|
|
143
|
-
className: classes.label,
|
|
144
|
-
children: filterFormatted
|
|
145
|
-
})
|
|
162
|
+
children: filterFormatted
|
|
146
163
|
}, `filter-${value.id}`));
|
|
147
164
|
});
|
|
148
165
|
break;
|
|
149
166
|
}
|
|
150
167
|
});
|
|
151
168
|
return entries;
|
|
152
|
-
}, [
|
|
169
|
+
}, [filters, handleRemove, openFilters]);
|
|
153
170
|
useEffect(() => {
|
|
154
171
|
onChipCountUpdate(chips.length);
|
|
155
172
|
}, [chips.length, onChipCountUpdate]);
|
|
156
173
|
if (chips.length === 0) {
|
|
157
174
|
return null;
|
|
158
175
|
}
|
|
159
|
-
return /*#__PURE__*/
|
|
176
|
+
return /*#__PURE__*/_jsxs("div", {
|
|
160
177
|
className: cx(classes.container, 'theme__filter-bar__filter-chips'),
|
|
161
|
-
children: /*#__PURE__*/_jsx(
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
178
|
+
children: [chips.length > 3 && /*#__PURE__*/_jsx("button", {
|
|
179
|
+
className: classes.clearAll,
|
|
180
|
+
onClick: handleClearAll,
|
|
181
|
+
"data-test-id": "clearAllFilters",
|
|
182
|
+
type: "button",
|
|
183
|
+
children: /*#__PURE__*/_jsx(I18n.Text, {
|
|
184
|
+
string: "filter.clear_all"
|
|
185
|
+
})
|
|
186
|
+
}), chips]
|
|
167
187
|
});
|
|
168
188
|
};
|
|
169
189
|
FilterChips.defaultProps = {
|
|
170
|
-
currentPathname: '',
|
|
171
190
|
filters: null,
|
|
172
191
|
scrollTop: noop,
|
|
173
192
|
onChipCountUpdate: noop
|
|
174
193
|
};
|
|
175
|
-
export default
|
|
194
|
+
export default FilterChips;
|
|
@@ -34,7 +34,7 @@ const useStyles = makeStyles()(theme => ({
|
|
|
34
34
|
zIndex: 2,
|
|
35
35
|
top: '100%',
|
|
36
36
|
left: 0,
|
|
37
|
-
background: theme.palette.background.
|
|
37
|
+
background: theme.palette.background.surface,
|
|
38
38
|
boxShadow: 'rgba(0, 0, 0, 0.16) 0 2px 2px',
|
|
39
39
|
[responsiveMediaQuery('>xs', {
|
|
40
40
|
webOnly: true
|
|
@@ -11,7 +11,8 @@ import FilterChips from "./components/FilterChips";
|
|
|
11
11
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
12
12
|
const useStyles = makeStyles()({
|
|
13
13
|
root: {
|
|
14
|
-
display: 'flex'
|
|
14
|
+
display: 'flex',
|
|
15
|
+
alignItems: 'center'
|
|
15
16
|
}
|
|
16
17
|
});
|
|
17
18
|
|
|
@@ -20,7 +21,8 @@ const useStyles = makeStyles()({
|
|
|
20
21
|
* @returns {JSX}
|
|
21
22
|
*/
|
|
22
23
|
function FilterBarContent({
|
|
23
|
-
onChipCountUpdate
|
|
24
|
+
onChipCountUpdate,
|
|
25
|
+
filterCount
|
|
24
26
|
}) {
|
|
25
27
|
const {
|
|
26
28
|
classes
|
|
@@ -42,7 +44,8 @@ function FilterBarContent({
|
|
|
42
44
|
children: [/*#__PURE__*/_jsxs("div", {
|
|
43
45
|
className: classes.root,
|
|
44
46
|
children: [/*#__PURE__*/_jsx(Sort, {}), /*#__PURE__*/_jsx(FilterButton, {
|
|
45
|
-
openFilters: openFilters
|
|
47
|
+
openFilters: openFilters,
|
|
48
|
+
filterCount: filterCount
|
|
46
49
|
})]
|
|
47
50
|
}), /*#__PURE__*/_jsx(FilterChips, {
|
|
48
51
|
openFilters: openFilters,
|
|
@@ -54,6 +57,7 @@ function FilterBarContent({
|
|
|
54
57
|
});
|
|
55
58
|
}
|
|
56
59
|
FilterBarContent.defaultProps = {
|
|
60
|
+
filterCount: 0,
|
|
57
61
|
onChipCountUpdate: noop
|
|
58
62
|
};
|
|
59
63
|
export default FilterBarContent;
|
|
@@ -1,18 +1,20 @@
|
|
|
1
|
-
import React, { useState, useMemo, memo
|
|
1
|
+
import React, { useState, useMemo, memo } from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
3
|
import { ResponsiveContainer } from '@shopgate/engage/components';
|
|
4
|
-
import { hasNewServices } from '@shopgate/engage/core/helpers';
|
|
5
4
|
import { SortProvider, SORT_SCOPE_CATEGORY, SORT_SCOPE_SEARCH } from '@shopgate/engage/filter';
|
|
6
|
-
import { makeStyles
|
|
5
|
+
import { makeStyles } from '@shopgate/engage/styles';
|
|
7
6
|
import Provider from "./FilterBarProvider";
|
|
8
7
|
import Content from "./components/Content";
|
|
9
8
|
import Modal from "./components/FilterModal";
|
|
10
9
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
11
|
-
const useStyles = makeStyles()({
|
|
10
|
+
const useStyles = makeStyles()(theme => ({
|
|
12
11
|
root: {
|
|
13
|
-
transition: 'transform 200ms cubic-bezier(0.25, 0.1, 0.25, 1)'
|
|
12
|
+
transition: 'transform 200ms cubic-bezier(0.25, 0.1, 0.25, 1)',
|
|
13
|
+
background: theme.palette.background.surface,
|
|
14
|
+
color: theme.palette.text.primary,
|
|
15
|
+
borderBottom: `1px solid ${theme.components.separatorLine.borderColor}`
|
|
14
16
|
}
|
|
15
|
-
});
|
|
17
|
+
}));
|
|
16
18
|
|
|
17
19
|
/**
|
|
18
20
|
* The FilterBar component.
|
|
@@ -20,35 +22,23 @@ const useStyles = makeStyles()({
|
|
|
20
22
|
* @returns {JSX}
|
|
21
23
|
*/
|
|
22
24
|
const FilterBar = ({
|
|
23
|
-
filters,
|
|
24
25
|
categoryId
|
|
25
26
|
}) => {
|
|
26
|
-
const theme = useTheme();
|
|
27
27
|
const {
|
|
28
28
|
classes,
|
|
29
29
|
cx
|
|
30
30
|
} = useStyles();
|
|
31
|
-
const [
|
|
32
|
-
const handleChipCountUpdate = useCallback(count => {
|
|
33
|
-
setActive(count > 0);
|
|
34
|
-
}, []);
|
|
35
|
-
const style = useMemo(() => hasNewServices() ? {
|
|
36
|
-
background: theme.palette.background.emphasized,
|
|
37
|
-
color: active ? theme.palette.primary.main : theme.palette.text.primary
|
|
38
|
-
} : {
|
|
39
|
-
background: active ? theme.palette.secondary.main : theme.palette.background.emphasized,
|
|
40
|
-
color: active ? theme.palette.secondary.contrastText : theme.palette.text.primary
|
|
41
|
-
}, [active, theme]);
|
|
31
|
+
const [filterCount, setFilterCount] = useState(0);
|
|
42
32
|
const sortScope = useMemo(() => categoryId ? SORT_SCOPE_CATEGORY : SORT_SCOPE_SEARCH, [categoryId]);
|
|
43
33
|
return /*#__PURE__*/_jsx("div", {
|
|
44
34
|
className: cx(classes.root, 'theme__filter-bar'),
|
|
45
35
|
"data-test-id": "filterBar",
|
|
46
|
-
style: style,
|
|
47
36
|
children: /*#__PURE__*/_jsx(SortProvider, {
|
|
48
37
|
scope: sortScope,
|
|
49
38
|
children: /*#__PURE__*/_jsxs(Provider, {
|
|
50
39
|
children: [/*#__PURE__*/_jsx(Content, {
|
|
51
|
-
onChipCountUpdate:
|
|
40
|
+
onChipCountUpdate: setFilterCount,
|
|
41
|
+
filterCount: filterCount
|
|
52
42
|
}), /*#__PURE__*/_jsx(ResponsiveContainer, {
|
|
53
43
|
breakpoint: ">xs",
|
|
54
44
|
webOnly: true,
|
|
@@ -59,7 +49,6 @@ const FilterBar = ({
|
|
|
59
49
|
});
|
|
60
50
|
};
|
|
61
51
|
FilterBar.defaultProps = {
|
|
62
|
-
filters: null,
|
|
63
52
|
categoryId: null
|
|
64
53
|
};
|
|
65
54
|
export default /*#__PURE__*/memo(FilterBar);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
|
-
import { useWidgetSettings,
|
|
3
|
+
import { useWidgetSettings, useResponsiveValue } from '@shopgate/engage/core/hooks';
|
|
4
4
|
import { applyScrollContainer } from '@shopgate/engage/core/helpers';
|
|
5
5
|
import { ResponsiveContainer, ScrollHeader, SurroundPortals } from '@shopgate/engage/components';
|
|
6
6
|
import { GlobalLocationSwitcher, FulfillmentSlotSwitcher } from '@shopgate/engage/locations/components';
|
|
@@ -62,9 +62,6 @@ const ProductFilters = ({
|
|
|
62
62
|
const {
|
|
63
63
|
hideOnScroll
|
|
64
64
|
} = useWidgetSettings('@shopgate/engage/components/FilterBar');
|
|
65
|
-
const {
|
|
66
|
-
state
|
|
67
|
-
} = useRoute();
|
|
68
65
|
|
|
69
66
|
// When the PWA is in website mode, we apply a higher offset value than usual because the AppBar
|
|
70
67
|
// is larger.
|
|
@@ -94,8 +91,7 @@ const ProductFilters = ({
|
|
|
94
91
|
renderBar: true
|
|
95
92
|
})]
|
|
96
93
|
}), showFilters && /*#__PURE__*/_jsx(FilterBar, {
|
|
97
|
-
categoryId: categoryId
|
|
98
|
-
filters: state.filters
|
|
94
|
+
categoryId: categoryId
|
|
99
95
|
})]
|
|
100
96
|
})
|
|
101
97
|
});
|
package/filter/components/FilterPageContent/components/Selector/components/ValueButton/index.js
DELETED
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
import React, { memo, useMemo } from 'react';
|
|
2
|
-
import PropTypes from 'prop-types';
|
|
3
|
-
import { makeStyles } from '@shopgate/engage/styles';
|
|
4
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
5
|
-
const useStyles = makeStyles()(theme => {
|
|
6
|
-
const inactive = {
|
|
7
|
-
border: `1px solid ${theme.components.border.medium}`,
|
|
8
|
-
borderRadius: 2,
|
|
9
|
-
color: 'inherit',
|
|
10
|
-
height: 42,
|
|
11
|
-
marginLeft: 8,
|
|
12
|
-
marginBottom: 8,
|
|
13
|
-
maxWidth: '100%',
|
|
14
|
-
minWidth: 42,
|
|
15
|
-
outline: 0,
|
|
16
|
-
overflow: 'hidden',
|
|
17
|
-
padding: '0 8px',
|
|
18
|
-
textOverflow: 'ellipsis',
|
|
19
|
-
whiteSpace: 'nowrap',
|
|
20
|
-
transition: 'color 100ms cubic-bezier(0.25, 0.1, 0.25, 1), border-color 100ms cubic-bezier(0.25, 0.1, 0.25, 1)',
|
|
21
|
-
willChange: 'color, border-color'
|
|
22
|
-
};
|
|
23
|
-
return {
|
|
24
|
-
inactive,
|
|
25
|
-
active: {
|
|
26
|
-
...inactive,
|
|
27
|
-
borderColor: theme.palette.secondary.main,
|
|
28
|
-
color: theme.palette.secondary.main
|
|
29
|
-
}
|
|
30
|
-
};
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* The value button component.
|
|
35
|
-
* @param {Object} props Props.
|
|
36
|
-
* @returns {JSX.Element}
|
|
37
|
-
*/
|
|
38
|
-
const ValueButton = ({
|
|
39
|
-
id,
|
|
40
|
-
isActive,
|
|
41
|
-
label,
|
|
42
|
-
onClick
|
|
43
|
-
}) => {
|
|
44
|
-
const {
|
|
45
|
-
classes,
|
|
46
|
-
cx
|
|
47
|
-
} = useStyles();
|
|
48
|
-
const buttonClassName = useMemo(() => cx({
|
|
49
|
-
[classes.inactive]: !isActive,
|
|
50
|
-
[classes.active]: isActive
|
|
51
|
-
}), [classes.active, classes.inactive, isActive, cx]);
|
|
52
|
-
return /*#__PURE__*/_jsx("button", {
|
|
53
|
-
className: buttonClassName,
|
|
54
|
-
value: id,
|
|
55
|
-
onClick: onClick,
|
|
56
|
-
"data-test-id": id,
|
|
57
|
-
type: "button",
|
|
58
|
-
role: "checkbox",
|
|
59
|
-
"aria-checked": isActive,
|
|
60
|
-
children: label
|
|
61
|
-
});
|
|
62
|
-
};
|
|
63
|
-
ValueButton.defaultProps = {
|
|
64
|
-
id: null,
|
|
65
|
-
label: null,
|
|
66
|
-
isActive: false,
|
|
67
|
-
onClick() {}
|
|
68
|
-
};
|
|
69
|
-
export default /*#__PURE__*/memo(ValueButton);
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { connect } from 'react-redux';
|
|
2
|
-
import { getCurrentPathname } from '@shopgate/engage/core';
|
|
3
|
-
import { updateFilters } from '@shopgate/pwa-common-commerce/filter/action-creators';
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Maps the contents of the state to the component props.
|
|
7
|
-
* @param {Object} state The current application state.
|
|
8
|
-
* @return {Object} The extended component props.
|
|
9
|
-
*/
|
|
10
|
-
const mapStateToProps = state => ({
|
|
11
|
-
currentPathname: getCurrentPathname(state)
|
|
12
|
-
});
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* @param {Function} dispatch The redux dispatch function.
|
|
16
|
-
* @param {Object} props The components props.
|
|
17
|
-
* @return {Object}
|
|
18
|
-
*/
|
|
19
|
-
const mapDispatchToProps = {
|
|
20
|
-
updateFilters
|
|
21
|
-
};
|
|
22
|
-
export default connect(mapStateToProps, mapDispatchToProps);
|