@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.
- 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/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
|
@@ -5,8 +5,15 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
5
5
|
const useStyles = makeStyles()(theme => ({
|
|
6
6
|
item: {
|
|
7
7
|
background: theme.palette.background.surface,
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
position: 'relative',
|
|
9
|
+
'&::before': {
|
|
10
|
+
content: '""',
|
|
11
|
+
position: 'absolute',
|
|
12
|
+
top: 0,
|
|
13
|
+
left: theme.spacing(2),
|
|
14
|
+
right: theme.spacing(2),
|
|
15
|
+
borderTop: `1px solid ${theme.components.separatorLine.borderColor}`
|
|
16
|
+
}
|
|
10
17
|
}
|
|
11
18
|
}));
|
|
12
19
|
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export interface FilterApplyButtonProps {
|
|
2
|
+
/**
|
|
3
|
+
* Click handler for the button.
|
|
4
|
+
*/
|
|
5
|
+
onClick: () => void;
|
|
6
|
+
/**
|
|
7
|
+
* Widget settings injected by `withWidgetSettings`, forwarded to the portal.
|
|
8
|
+
*/
|
|
9
|
+
widgetSettings?: Record<string, unknown>;
|
|
10
|
+
/**
|
|
11
|
+
* Class name for the button.
|
|
12
|
+
*/
|
|
13
|
+
className?: string;
|
|
14
|
+
/**
|
|
15
|
+
* Whether the button is disabled.
|
|
16
|
+
*/
|
|
17
|
+
disabled?: boolean;
|
|
18
|
+
}
|
|
19
|
+
declare const _default: JSX;
|
|
20
|
+
export default _default;
|
|
21
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../filter/components/FilterPageContent/components/ApplyButton/index.tsx"],"names":[],"mappings":"AAMA,MAAM,WAAW,sBAAsB;IACrC;;OAEG;IACH,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB;;OAEG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACzC;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;OAEG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;;AAgCD,wBAAiG"}
|
|
@@ -1,64 +1,37 @@
|
|
|
1
|
-
import
|
|
2
|
-
import PropTypes from 'prop-types';
|
|
1
|
+
import { memo } from 'react';
|
|
3
2
|
import { I18n, SurroundPortals } from '@shopgate/engage/components';
|
|
4
3
|
import { Button } from '@shopgate/engage/components/v2';
|
|
5
|
-
import { makeStyles } from '@shopgate/engage/styles';
|
|
6
4
|
import { PORTAL_FILTER_APPLY_BUTTON } from '@shopgate/engage/filter/constants';
|
|
7
5
|
import { withWidgetSettings } from '@shopgate/engage/core';
|
|
8
6
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
9
|
-
const useStyles = makeStyles()(theme => ({
|
|
10
|
-
wrapper: {
|
|
11
|
-
display: 'flex',
|
|
12
|
-
marginRight: theme.spacing(2)
|
|
13
|
-
}
|
|
14
|
-
}));
|
|
15
|
-
|
|
16
7
|
/**
|
|
17
|
-
* The filter apply button
|
|
18
|
-
* @
|
|
19
|
-
* @param {boolean} props.disabled Whether the button is disabled
|
|
20
|
-
* @param {Function} props.onClick Click handler for the button
|
|
21
|
-
* @returns {JSX.Element}
|
|
8
|
+
* The filter apply button, rendered as "View Results" in the filter button bar.
|
|
9
|
+
* @returns The rendered component.
|
|
22
10
|
*/
|
|
23
11
|
const FilterApplyButton = ({
|
|
24
|
-
disabled,
|
|
12
|
+
disabled = false,
|
|
25
13
|
onClick,
|
|
14
|
+
className,
|
|
26
15
|
widgetSettings
|
|
27
|
-
}) => {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
children: /*#__PURE__*/_jsx(
|
|
44
|
-
|
|
45
|
-
children: /*#__PURE__*/_jsx(Button, {
|
|
46
|
-
variant: "link",
|
|
47
|
-
color: "secondary",
|
|
48
|
-
onClick: onClick,
|
|
49
|
-
disabled: disabled,
|
|
50
|
-
testId: "applyFilterButton",
|
|
51
|
-
children: /*#__PURE__*/_jsx(I18n.Text, {
|
|
52
|
-
string: "filter.apply",
|
|
53
|
-
style: {
|
|
54
|
-
color: buttonColor
|
|
55
|
-
}
|
|
56
|
-
})
|
|
57
|
-
})
|
|
16
|
+
}) => /*#__PURE__*/_jsx(SurroundPortals, {
|
|
17
|
+
portalName: PORTAL_FILTER_APPLY_BUTTON,
|
|
18
|
+
portalProps: {
|
|
19
|
+
disabled,
|
|
20
|
+
onClick,
|
|
21
|
+
widgetSettings
|
|
22
|
+
},
|
|
23
|
+
children: /*#__PURE__*/_jsx(Button, {
|
|
24
|
+
className: className,
|
|
25
|
+
variant: "contained",
|
|
26
|
+
color: "primary",
|
|
27
|
+
onClick: onClick,
|
|
28
|
+
disabled: disabled,
|
|
29
|
+
fullWidth: true,
|
|
30
|
+
size: "small",
|
|
31
|
+
testId: "applyFilterButton",
|
|
32
|
+
children: /*#__PURE__*/_jsx(I18n.Text, {
|
|
33
|
+
string: "filter.view_results"
|
|
58
34
|
})
|
|
59
|
-
})
|
|
60
|
-
};
|
|
61
|
-
FilterApplyButton.defaultProps = {
|
|
62
|
-
disabled: false
|
|
63
|
-
};
|
|
35
|
+
})
|
|
36
|
+
});
|
|
64
37
|
export default withWidgetSettings(/*#__PURE__*/memo(FilterApplyButton), '@shopgate/engage/components/AppBar');
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The filter button bar renders the "View Results" and "Clear all" buttons in a sticky bar at the
|
|
3
|
+
* bottom of the screen. It's rendered into the app footer via a portal.
|
|
4
|
+
* @returns The rendered component, or `null` when the app footer is not available.
|
|
5
|
+
*/
|
|
6
|
+
declare const FilterButtonBar: () => import("react").ReactPortal | null;
|
|
7
|
+
export default FilterButtonBar;
|
|
8
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../filter/components/FilterPageContent/components/FilterButtonBar/index.tsx"],"names":[],"mappings":"AA0BA;;;;GAIG;AACH,QAAA,MAAM,eAAe,0CAkCpB,CAAC;AAEF,eAAe,eAAe,CAAC"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { createPortal } from 'react-dom';
|
|
2
|
+
import { ResponsiveContainer } from '@shopgate/engage/components';
|
|
3
|
+
import { makeStyles } from '@shopgate/engage/styles';
|
|
4
|
+
import { useFilterPage } from '@shopgate/engage/filter/hooks';
|
|
5
|
+
import ApplyButton from "../ApplyButton";
|
|
6
|
+
import ResetButton from "../ResetButton";
|
|
7
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
8
|
+
const useStyles = makeStyles()(theme => ({
|
|
9
|
+
bar: {
|
|
10
|
+
display: 'flex',
|
|
11
|
+
gap: theme.spacing(1.5),
|
|
12
|
+
padding: theme.spacing(1.5, 2),
|
|
13
|
+
background: theme.palette.background.surface,
|
|
14
|
+
boxShadow: '0 -4px 5px -2px rgba(0, 0, 0, 0.1)',
|
|
15
|
+
position: 'relative',
|
|
16
|
+
zIndex: 2,
|
|
17
|
+
paddingBottom: `calc(${theme.spacing(1.5)}px + ${theme.layout.safeArea.bottom})`
|
|
18
|
+
},
|
|
19
|
+
apply: {
|
|
20
|
+
flex: 2
|
|
21
|
+
},
|
|
22
|
+
reset: {
|
|
23
|
+
flex: 1
|
|
24
|
+
}
|
|
25
|
+
}));
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* The filter button bar renders the "View Results" and "Clear all" buttons in a sticky bar at the
|
|
29
|
+
* bottom of the screen. It's rendered into the app footer via a portal.
|
|
30
|
+
* @returns The rendered component, or `null` when the app footer is not available.
|
|
31
|
+
*/
|
|
32
|
+
const FilterButtonBar = () => {
|
|
33
|
+
const {
|
|
34
|
+
classes
|
|
35
|
+
} = useStyles();
|
|
36
|
+
const {
|
|
37
|
+
hasChanged,
|
|
38
|
+
resetPossible,
|
|
39
|
+
applyFilters,
|
|
40
|
+
resetAllFilters
|
|
41
|
+
} = useFilterPage();
|
|
42
|
+
const domElement = typeof document !== 'undefined' ? document.getElementById('AppFooter') : null;
|
|
43
|
+
if (!domElement) {
|
|
44
|
+
return null;
|
|
45
|
+
}
|
|
46
|
+
return /*#__PURE__*/createPortal(/*#__PURE__*/_jsx(ResponsiveContainer, {
|
|
47
|
+
appAlways: true,
|
|
48
|
+
breakpoint: "<sm",
|
|
49
|
+
children: /*#__PURE__*/_jsxs("div", {
|
|
50
|
+
className: classes.bar,
|
|
51
|
+
children: [/*#__PURE__*/_jsx(ApplyButton, {
|
|
52
|
+
className: classes.apply,
|
|
53
|
+
disabled: !hasChanged,
|
|
54
|
+
onClick: applyFilters
|
|
55
|
+
}), /*#__PURE__*/_jsx(ResetButton, {
|
|
56
|
+
className: classes.reset,
|
|
57
|
+
disabled: !resetPossible,
|
|
58
|
+
onClick: resetAllFilters
|
|
59
|
+
})]
|
|
60
|
+
})
|
|
61
|
+
}), domElement);
|
|
62
|
+
};
|
|
63
|
+
export default FilterButtonBar;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export interface FilterResetButtonProps {
|
|
2
|
+
/**
|
|
3
|
+
* Click handler for the button.
|
|
4
|
+
*/
|
|
5
|
+
onClick: () => void;
|
|
6
|
+
/**
|
|
7
|
+
* Class name for the button.
|
|
8
|
+
*/
|
|
9
|
+
className?: string;
|
|
10
|
+
/**
|
|
11
|
+
* Whether the button is disabled.
|
|
12
|
+
*/
|
|
13
|
+
disabled?: boolean;
|
|
14
|
+
}
|
|
15
|
+
declare const _default: import("react").MemoExoticComponent<({ disabled, onClick, className }: FilterResetButtonProps) => import("react").JSX.Element>;
|
|
16
|
+
export default _default;
|
|
17
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../filter/components/FilterPageContent/components/ResetButton/index.tsx"],"names":[],"mappings":"AAKA,MAAM,WAAW,sBAAsB;IACrC;;OAEG;IACH,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;OAEG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;+FAMoE,sBAAsB;AAsB3F,wBAAuC"}
|
|
@@ -1,55 +1,33 @@
|
|
|
1
|
-
import
|
|
2
|
-
import PropTypes from 'prop-types';
|
|
1
|
+
import { memo } from 'react';
|
|
3
2
|
import { I18n, SurroundPortals } from '@shopgate/engage/components';
|
|
4
3
|
import { Button } from '@shopgate/engage/components/v2';
|
|
5
|
-
import { makeStyles } from '@shopgate/engage/styles';
|
|
6
4
|
import { PORTAL_FILTER_RESET_BUTTON } from '@shopgate/engage/filter/constants';
|
|
7
5
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
8
|
-
const useStyles = makeStyles()(theme => ({
|
|
9
|
-
buttonContainer: {
|
|
10
|
-
marginTop: theme.spacing(0.5),
|
|
11
|
-
marginRight: theme.spacing(2),
|
|
12
|
-
marginBottom: 40,
|
|
13
|
-
textAlign: 'right'
|
|
14
|
-
}
|
|
15
|
-
}));
|
|
16
|
-
|
|
17
6
|
/**
|
|
18
|
-
* The filter reset button
|
|
19
|
-
* @
|
|
20
|
-
* @param {boolean} props.disabled Whether the button is disabled
|
|
21
|
-
* @param {Function} props.onClick Click handler for the button
|
|
22
|
-
* @returns {JSX.Element}
|
|
7
|
+
* The filter reset button, rendered as "Clear all" in the filter button bar.
|
|
8
|
+
* @returns The rendered component.
|
|
23
9
|
*/
|
|
24
10
|
const FilterResetButton = ({
|
|
25
|
-
disabled,
|
|
26
|
-
onClick
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
testId: "clearAllButton",
|
|
45
|
-
children: /*#__PURE__*/_jsx(I18n.Text, {
|
|
46
|
-
string: "filter.reset"
|
|
47
|
-
})
|
|
48
|
-
})
|
|
11
|
+
disabled = false,
|
|
12
|
+
onClick,
|
|
13
|
+
className
|
|
14
|
+
}) => /*#__PURE__*/_jsx(SurroundPortals, {
|
|
15
|
+
portalName: PORTAL_FILTER_RESET_BUTTON,
|
|
16
|
+
portalProps: {
|
|
17
|
+
disabled,
|
|
18
|
+
onClick
|
|
19
|
+
},
|
|
20
|
+
children: /*#__PURE__*/_jsx(Button, {
|
|
21
|
+
className: className,
|
|
22
|
+
variant: "outlined",
|
|
23
|
+
onClick: onClick,
|
|
24
|
+
disabled: disabled,
|
|
25
|
+
fullWidth: true,
|
|
26
|
+
size: "small",
|
|
27
|
+
testId: "clearAllButton",
|
|
28
|
+
children: /*#__PURE__*/_jsx(I18n.Text, {
|
|
29
|
+
string: "filter.clear_all"
|
|
49
30
|
})
|
|
50
|
-
})
|
|
51
|
-
};
|
|
52
|
-
FilterResetButton.defaultProps = {
|
|
53
|
-
disabled: false
|
|
54
|
-
};
|
|
31
|
+
})
|
|
32
|
+
});
|
|
55
33
|
export default /*#__PURE__*/memo(FilterResetButton);
|
package/filter/components/FilterPageContent/components/Selector/components/Selected/index.d.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export interface SelectedValue {
|
|
2
|
+
/**
|
|
3
|
+
* Id of the filter value.
|
|
4
|
+
*/
|
|
5
|
+
id: string;
|
|
6
|
+
/**
|
|
7
|
+
* Display label of the filter value.
|
|
8
|
+
*/
|
|
9
|
+
label: string;
|
|
10
|
+
}
|
|
11
|
+
export interface SelectedProps {
|
|
12
|
+
/**
|
|
13
|
+
* The selected filter values, already ordered for display.
|
|
14
|
+
*/
|
|
15
|
+
values: SelectedValue[];
|
|
16
|
+
}
|
|
17
|
+
declare const _default: import("react").MemoExoticComponent<({ values }: SelectedProps) => import("react").JSX.Element | null>;
|
|
18
|
+
export default _default;
|
|
19
|
+
//# sourceMappingURL=index.d.ts.map
|
package/filter/components/FilterPageContent/components/Selector/components/Selected/index.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../../../filter/components/FilterPageContent/components/Selector/components/Selected/index.tsx"],"names":[],"mappings":"AAkBA,MAAM,WAAW,aAAa;IAC5B;;OAEG;IACH,EAAE,EAAE,MAAM,CAAC;IACX;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,aAAa;IAC5B;;OAEG;IACH,MAAM,EAAE,aAAa,EAAE,CAAC;CACzB;yEAM6B,aAAa;AAgB3C,wBAA8B"}
|
package/filter/components/FilterPageContent/components/Selector/components/Selected/index.js
CHANGED
|
@@ -1,63 +1,42 @@
|
|
|
1
|
-
import
|
|
2
|
-
import "core-js/modules/es.array.reduce.js";
|
|
3
|
-
import React, { Fragment, memo, useMemo } from 'react';
|
|
4
|
-
import PropTypes from 'prop-types';
|
|
1
|
+
import { memo } from 'react';
|
|
5
2
|
import { makeStyles } from '@shopgate/engage/styles';
|
|
6
|
-
import { jsx as _jsx
|
|
7
|
-
const useStyles = makeStyles()(
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
textOverflow: 'ellipsis',
|
|
13
|
-
whiteSpace: 'nowrap'
|
|
3
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
4
|
+
const useStyles = makeStyles()(theme => ({
|
|
5
|
+
chips: {
|
|
6
|
+
display: 'flex',
|
|
7
|
+
flexWrap: 'wrap',
|
|
8
|
+
gap: theme.spacing(0.5)
|
|
14
9
|
},
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
10
|
+
chip: {
|
|
11
|
+
...theme.typography.body2,
|
|
12
|
+
padding: theme.spacing(0.25, 1.25),
|
|
13
|
+
borderRadius: theme.shape.borderRadius,
|
|
14
|
+
border: `1px solid ${theme.palette.secondary.main}`,
|
|
15
|
+
overflowWrap: 'anywhere'
|
|
19
16
|
}
|
|
20
17
|
}));
|
|
21
|
-
|
|
22
18
|
/**
|
|
23
|
-
*
|
|
24
|
-
* @
|
|
25
|
-
* @returns {JSX.Element|null}
|
|
19
|
+
* Renders the selected filter values as chips in the accordion header.
|
|
20
|
+
* @returns The rendered component.
|
|
26
21
|
*/
|
|
27
22
|
const Selected = ({
|
|
28
|
-
selected,
|
|
29
23
|
values
|
|
30
24
|
}) => {
|
|
31
25
|
const {
|
|
32
26
|
classes
|
|
33
27
|
} = useStyles();
|
|
34
|
-
|
|
35
|
-
if (!selected || selected.length === 0) {
|
|
36
|
-
return [];
|
|
37
|
-
}
|
|
38
|
-
return values.reduce((prevValues, value) => {
|
|
39
|
-
if (selected.includes(value.id)) {
|
|
40
|
-
prevValues.push(value.label);
|
|
41
|
-
}
|
|
42
|
-
return prevValues;
|
|
43
|
-
}, []);
|
|
44
|
-
}, [selected, values]);
|
|
45
|
-
if (!selected || selected.length === 0) {
|
|
28
|
+
if (values.length === 0) {
|
|
46
29
|
return null;
|
|
47
30
|
}
|
|
48
|
-
return /*#__PURE__*/_jsx(
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
}, item))
|
|
31
|
+
return /*#__PURE__*/_jsx("div", {
|
|
32
|
+
className: classes.chips,
|
|
33
|
+
children: values.map(({
|
|
34
|
+
id,
|
|
35
|
+
label
|
|
36
|
+
}) => /*#__PURE__*/_jsx("span", {
|
|
37
|
+
className: classes.chip,
|
|
38
|
+
children: label
|
|
39
|
+
}, id))
|
|
58
40
|
});
|
|
59
41
|
};
|
|
60
|
-
Selected.defaultProps = {
|
|
61
|
-
selected: null
|
|
62
|
-
};
|
|
63
42
|
export default /*#__PURE__*/memo(Selected);
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
export interface ToggleProps {
|
|
3
|
+
/**
|
|
4
|
+
* The filter label.
|
|
5
|
+
*/
|
|
6
|
+
label: ReactNode;
|
|
7
|
+
/**
|
|
8
|
+
* The selected values element rendered below the label.
|
|
9
|
+
*/
|
|
10
|
+
selected?: ReactNode;
|
|
11
|
+
}
|
|
12
|
+
declare const _default: import("react").MemoExoticComponent<({ label, selected }: ToggleProps) => import("react").JSX.Element>;
|
|
13
|
+
export default _default;
|
|
14
|
+
//# sourceMappingURL=index.d.ts.map
|
package/filter/components/FilterPageContent/components/Selector/components/Toggle/index.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../../../filter/components/FilterPageContent/components/Selector/components/Toggle/index.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAkBvC,MAAM,WAAW,WAAW;IAC1B;;OAEG;IACH,KAAK,EAAE,SAAS,CAAC;IACjB;;OAEG;IACH,QAAQ,CAAC,EAAE,SAAS,CAAC;CACtB;kFAM2C,WAAW;AAavD,wBAA4B"}
|
|
@@ -1,71 +1,38 @@
|
|
|
1
|
-
import
|
|
2
|
-
import PropTypes from 'prop-types';
|
|
1
|
+
import { memo } from 'react';
|
|
3
2
|
import { makeStyles } from '@shopgate/engage/styles';
|
|
4
3
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
5
4
|
const useStyles = makeStyles()(theme => ({
|
|
6
5
|
toggle: {
|
|
7
6
|
display: 'flex',
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
7
|
+
flexDirection: 'column',
|
|
8
|
+
alignItems: 'flex-start',
|
|
9
|
+
gap: theme.spacing(1),
|
|
10
|
+
flex: 1,
|
|
11
|
+
minWidth: 0
|
|
11
12
|
},
|
|
12
13
|
label: {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
flexGrow: 1,
|
|
16
|
-
textAlign: 'left',
|
|
17
|
-
maxWidth: '50%',
|
|
18
|
-
minWidth: '35%',
|
|
19
|
-
paddingRight: '16px'
|
|
20
|
-
},
|
|
21
|
-
selected: {
|
|
22
|
-
display: 'flex',
|
|
23
|
-
flexFlow: 'row wrap',
|
|
24
|
-
flexGrow: 1,
|
|
25
|
-
justifyContent: 'flex-end',
|
|
26
|
-
minWidth: '50%',
|
|
27
|
-
maxWidth: '65%'
|
|
28
|
-
},
|
|
29
|
-
closed: {
|
|
30
|
-
fontWeight: theme.typography.fontWeightRegular
|
|
31
|
-
},
|
|
32
|
-
open: {
|
|
33
|
-
fontWeight: theme.typography.fontWeightBold
|
|
14
|
+
...theme.typography.body1,
|
|
15
|
+
textAlign: 'left'
|
|
34
16
|
}
|
|
35
17
|
}));
|
|
36
|
-
|
|
37
18
|
/**
|
|
38
|
-
*
|
|
39
|
-
* @
|
|
40
|
-
* @returns {JSX.Element}
|
|
19
|
+
* Renders the filter label and its selected values in the accordion header.
|
|
20
|
+
* @returns The rendered component.
|
|
41
21
|
*/
|
|
42
22
|
const Toggle = ({
|
|
43
23
|
label,
|
|
44
|
-
|
|
45
|
-
selected
|
|
24
|
+
selected = null
|
|
46
25
|
}) => {
|
|
47
26
|
const {
|
|
48
27
|
classes,
|
|
49
28
|
cx
|
|
50
29
|
} = useStyles();
|
|
51
|
-
const labelClassName = useMemo(() => cx({
|
|
52
|
-
[classes.label]: true,
|
|
53
|
-
[classes.open]: open,
|
|
54
|
-
[classes.closed]: !open
|
|
55
|
-
}), [classes.closed, classes.label, classes.open, open, cx]);
|
|
56
30
|
return /*#__PURE__*/_jsxs("div", {
|
|
57
31
|
className: classes.toggle,
|
|
58
32
|
children: [/*#__PURE__*/_jsx("span", {
|
|
59
|
-
className:
|
|
33
|
+
className: cx(classes.label, 'filter-selector-toggle-label'),
|
|
60
34
|
children: label
|
|
61
|
-
}), selected
|
|
62
|
-
className: classes.selected,
|
|
63
|
-
children: selected
|
|
64
|
-
})]
|
|
35
|
+
}), selected]
|
|
65
36
|
});
|
|
66
37
|
};
|
|
67
|
-
Toggle.defaultProps = {
|
|
68
|
-
open: false,
|
|
69
|
-
selected: null
|
|
70
|
-
};
|
|
71
38
|
export default /*#__PURE__*/memo(Toggle);
|
package/filter/components/FilterPageContent/components/Selector/components/ValueCheckbox/index.d.ts
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export interface ValueCheckboxProps {
|
|
2
|
+
/**
|
|
3
|
+
* Id of the filter value. Also used as the form element name and test id.
|
|
4
|
+
*/
|
|
5
|
+
id: string;
|
|
6
|
+
/**
|
|
7
|
+
* Display label of the filter value. Rendered as is — never translated.
|
|
8
|
+
*/
|
|
9
|
+
label: string;
|
|
10
|
+
/**
|
|
11
|
+
* Number of products that are available for the filter value.
|
|
12
|
+
*/
|
|
13
|
+
hits?: number;
|
|
14
|
+
/**
|
|
15
|
+
* Whether the value is currently selected.
|
|
16
|
+
*/
|
|
17
|
+
isActive?: boolean;
|
|
18
|
+
/**
|
|
19
|
+
* Invoked with the value id whenever the checkbox is toggled.
|
|
20
|
+
*/
|
|
21
|
+
onToggle?: (id: string) => void;
|
|
22
|
+
}
|
|
23
|
+
declare const _default: import("react").MemoExoticComponent<({ id, label, hits, isActive, onToggle, }: ValueCheckboxProps) => import("react").JSX.Element>;
|
|
24
|
+
export default _default;
|
|
25
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../../../filter/components/FilterPageContent/components/Selector/components/ValueCheckbox/index.tsx"],"names":[],"mappings":"AA6CA,MAAM,WAAW,kBAAkB;IACjC;;OAEG;IACH,EAAE,EAAE,MAAM,CAAC;IACX;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;IACd;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;;OAEG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;OAEG;IACH,QAAQ,CAAC,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;CACjC;uGAYE,kBAAkB;AAkCrB,wBAAmC"}
|
package/filter/components/FilterPageContent/components/Selector/components/ValueCheckbox/index.js
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { memo, useCallback } from 'react';
|
|
2
|
+
import noop from 'lodash/noop';
|
|
3
|
+
import { Checkbox } from '@shopgate/engage/components';
|
|
4
|
+
import { i18n } from '@shopgate/engage/core/helpers';
|
|
5
|
+
import { makeStyles } from '@shopgate/engage/styles';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* `Checkbox` is untyped JavaScript whose optional props read as required from TypeScript.
|
|
9
|
+
*/
|
|
10
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
11
|
+
const CheckboxField = Checkbox;
|
|
12
|
+
const useStyles = makeStyles()(theme => ({
|
|
13
|
+
root: {
|
|
14
|
+
paddingBottom: 0,
|
|
15
|
+
marginLeft: 0
|
|
16
|
+
},
|
|
17
|
+
checkbox: {
|
|
18
|
+
display: 'flex',
|
|
19
|
+
alignItems: 'flex-start',
|
|
20
|
+
padding: theme.spacing(0.75, 0),
|
|
21
|
+
'& .checkedIcon': {
|
|
22
|
+
color: theme.palette.secondary.main
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
label: {
|
|
26
|
+
width: '100%',
|
|
27
|
+
display: 'flex',
|
|
28
|
+
justifyContent: 'space-between',
|
|
29
|
+
gap: theme.spacing(1),
|
|
30
|
+
paddingLeft: theme.spacing(1),
|
|
31
|
+
[theme.breakpoints.up('md')]: {
|
|
32
|
+
width: 'max-content',
|
|
33
|
+
maxWidth: '100%'
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}));
|
|
37
|
+
/**
|
|
38
|
+
* A single selectable value of a filter on the filter page.
|
|
39
|
+
* @returns The rendered component.
|
|
40
|
+
*/
|
|
41
|
+
const ValueCheckbox = ({
|
|
42
|
+
id,
|
|
43
|
+
label,
|
|
44
|
+
hits,
|
|
45
|
+
isActive = false,
|
|
46
|
+
onToggle = noop
|
|
47
|
+
}) => {
|
|
48
|
+
const {
|
|
49
|
+
classes
|
|
50
|
+
} = useStyles();
|
|
51
|
+
const handleChange = useCallback(() => {
|
|
52
|
+
onToggle(id);
|
|
53
|
+
}, [id, onToggle]);
|
|
54
|
+
return /*#__PURE__*/_jsx("div", {
|
|
55
|
+
"data-test-id": id,
|
|
56
|
+
children: /*#__PURE__*/_jsx(CheckboxField, {
|
|
57
|
+
className: classes.root,
|
|
58
|
+
checkboxClassName: classes.checkbox,
|
|
59
|
+
name: id,
|
|
60
|
+
checked: isActive,
|
|
61
|
+
onChange: handleChange,
|
|
62
|
+
label: /*#__PURE__*/_jsxs("div", {
|
|
63
|
+
className: classes.label,
|
|
64
|
+
"aria-label": hits === undefined ? label : i18n.text('filter.hits', {
|
|
65
|
+
label,
|
|
66
|
+
count: hits
|
|
67
|
+
}),
|
|
68
|
+
children: [/*#__PURE__*/_jsx("span", {
|
|
69
|
+
children: label
|
|
70
|
+
}), hits !== undefined && /*#__PURE__*/_jsx("span", {
|
|
71
|
+
children: `(${hits})`
|
|
72
|
+
})]
|
|
73
|
+
})
|
|
74
|
+
})
|
|
75
|
+
});
|
|
76
|
+
};
|
|
77
|
+
export default /*#__PURE__*/memo(ValueCheckbox);
|