@bento-core/facet-filter 1.0.1-icdc.5 → 1.0.1-icdc.7
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/dist/FacetFilterView.js +4 -2
- package/dist/components/facet/FacetStyle.js +1 -1
- package/dist/components/facet/FacetView.js +28 -5
- package/dist/components/facet/ReduxFacetView.js +1 -0
- package/dist/store/reducers/SideBarReducer.js +18 -4
- package/package.json +1 -1
- package/src/FacetFilterView.js +2 -0
- package/src/components/facet/FacetStyle.js +1 -1
- package/src/components/facet/FacetView.js +27 -4
- package/src/components/facet/ReduxFacetView.js +1 -0
- package/src/store/reducers/SideBarReducer.js +9 -2
package/dist/FacetFilterView.js
CHANGED
|
@@ -18,7 +18,8 @@ const BentoFacetFilter = _ref => {
|
|
|
18
18
|
sideBarSections,
|
|
19
19
|
CustomFacetSection,
|
|
20
20
|
CustomFacetView,
|
|
21
|
-
enableClearSection
|
|
21
|
+
enableClearSection,
|
|
22
|
+
enableFacetCollapse
|
|
22
23
|
} = _ref;
|
|
23
24
|
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, sideBarSections.map((section, index) => /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_core.Divider, {
|
|
24
25
|
variant: "middle",
|
|
@@ -29,7 +30,8 @@ const BentoFacetFilter = _ref => {
|
|
|
29
30
|
}, section.items.map(facet => /*#__PURE__*/_react.default.createElement(_ReduxFacetView.default, {
|
|
30
31
|
facet: facet,
|
|
31
32
|
CustomView: CustomFacetView,
|
|
32
|
-
enableClearSection: enableClearSection
|
|
33
|
+
enableClearSection: enableClearSection,
|
|
34
|
+
enableFacetCollapse: enableFacetCollapse
|
|
33
35
|
}))))));
|
|
34
36
|
};
|
|
35
37
|
var _default = (0, _core.withStyles)(_FacetFilterStyle.default)(BentoFacetFilter);
|
|
@@ -15,6 +15,7 @@ var _FacetStyle = _interopRequireDefault(require("./FacetStyle"));
|
|
|
15
15
|
var _FilterItems = _interopRequireDefault(require("../inputs/FilterItems"));
|
|
16
16
|
var _Sort = require("../../utils/Sort");
|
|
17
17
|
var _clearIcon = _interopRequireDefault(require("./assets/clearIcon.svg"));
|
|
18
|
+
var _ActionTypes = require("../../store/actions/ActionTypes");
|
|
18
19
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
19
20
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
20
21
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
@@ -32,10 +33,29 @@ const FacetView = _ref => {
|
|
|
32
33
|
onClearSliderSection,
|
|
33
34
|
CustomView,
|
|
34
35
|
autoComplete,
|
|
35
|
-
upload
|
|
36
|
+
upload,
|
|
37
|
+
filterState,
|
|
38
|
+
currentActionType = {},
|
|
39
|
+
enableFacetCollapse
|
|
36
40
|
} = _ref;
|
|
37
41
|
const [expand, setExpand] = (0, _react.useState)(false);
|
|
38
42
|
const onExpandFacet = () => setExpand(!expand);
|
|
43
|
+
const {
|
|
44
|
+
datafield
|
|
45
|
+
} = facet;
|
|
46
|
+
/**
|
|
47
|
+
* Collapse expanded facet or facets
|
|
48
|
+
* 1. on clear facet section
|
|
49
|
+
* 2. on clear all
|
|
50
|
+
*/
|
|
51
|
+
(0, _react.useEffect)(() => {
|
|
52
|
+
if (enableFacetCollapse) {
|
|
53
|
+
const actionType = currentActionType[datafield];
|
|
54
|
+
if (actionType && actionType === _ActionTypes.sideBarActionTypes.CLEAR_FACET_SECTION || currentActionType === _ActionTypes.sideBarActionTypes.CLEAR_ALL_FILTERS) {
|
|
55
|
+
setExpand(false);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}, [currentActionType]);
|
|
39
59
|
|
|
40
60
|
/**
|
|
41
61
|
* expand section incase of active local search
|
|
@@ -51,10 +71,13 @@ const FacetView = _ref => {
|
|
|
51
71
|
};
|
|
52
72
|
const onClearSection = () => {
|
|
53
73
|
setSortBy(null);
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
74
|
+
const activeFilterItems = filterState[datafield];
|
|
75
|
+
if (activeFilterItems && Object.keys(activeFilterItems).length > 0) {
|
|
76
|
+
if (facet.type === _Types.InputTypes.SLIDER) {
|
|
77
|
+
onClearSliderSection(facet);
|
|
78
|
+
} else {
|
|
79
|
+
onClearFacetSection(facet);
|
|
80
|
+
}
|
|
58
81
|
}
|
|
59
82
|
};
|
|
60
83
|
/**
|
|
@@ -14,6 +14,7 @@ const mapStateToProps = state => {
|
|
|
14
14
|
var _state$localFind, _state$localFind2;
|
|
15
15
|
return {
|
|
16
16
|
filterState: state.statusReducer.filterState,
|
|
17
|
+
currentActionType: state.statusReducer.currentActionType,
|
|
17
18
|
autoComplete: (state === null || state === void 0 ? void 0 : (_state$localFind = state.localFind) === null || _state$localFind === void 0 ? void 0 : _state$localFind.autocomplete) || [],
|
|
18
19
|
upload: (state === null || state === void 0 ? void 0 : (_state$localFind2 = state.localFind) === null || _state$localFind2 === void 0 ? void 0 : _state$localFind2.upload) || []
|
|
19
20
|
};
|
|
@@ -44,7 +44,10 @@ const onClearFacetSection = _ref2 => {
|
|
|
44
44
|
if (updatedState[datafield]) {
|
|
45
45
|
updatedState[datafield] = {};
|
|
46
46
|
}
|
|
47
|
-
return
|
|
47
|
+
return {
|
|
48
|
+
updatedState,
|
|
49
|
+
datafield
|
|
50
|
+
};
|
|
48
51
|
};
|
|
49
52
|
exports.onClearFacetSection = onClearFacetSection;
|
|
50
53
|
const onClearSliderSection = _ref3 => {
|
|
@@ -97,12 +100,21 @@ function sideBarReducerGenerator() {
|
|
|
97
100
|
});
|
|
98
101
|
case _ActionTypes.sideBarActionTypes.CLEAR_ALL_FILTERS:
|
|
99
102
|
return _objectSpread(_objectSpread({}, state), {}, {
|
|
100
|
-
filterState: {}
|
|
103
|
+
filterState: {},
|
|
104
|
+
currentActionType: _ActionTypes.sideBarActionTypes.CLEAR_ALL_FILTERS
|
|
101
105
|
});
|
|
102
106
|
case _ActionTypes.sideBarActionTypes.CLEAR_FACET_SECTION:
|
|
103
|
-
|
|
107
|
+
const {
|
|
108
|
+
updatedState: updtState,
|
|
109
|
+
datafield
|
|
110
|
+
} = onClearFacetSection(_objectSpread(_objectSpread({}, payload), state));
|
|
111
|
+
updateState = updtState;
|
|
112
|
+
const currentActionType = {
|
|
113
|
+
[datafield]: _ActionTypes.sideBarActionTypes.CLEAR_FACET_SECTION
|
|
114
|
+
};
|
|
104
115
|
return _objectSpread(_objectSpread({}, state), {}, {
|
|
105
|
-
filterState: _objectSpread({}, updateState)
|
|
116
|
+
filterState: _objectSpread({}, updateState),
|
|
117
|
+
currentActionType
|
|
106
118
|
});
|
|
107
119
|
case _ActionTypes.sideBarActionTypes.CLEAR_SLIDER_SECTION:
|
|
108
120
|
updateState = onClearSliderSection(_objectSpread(_objectSpread({}, payload), state));
|
|
@@ -113,6 +125,8 @@ function sideBarReducerGenerator() {
|
|
|
113
125
|
return {
|
|
114
126
|
filterState: payload
|
|
115
127
|
};
|
|
128
|
+
case _ActionTypes.sideBarActionTypes.CURR_FILTER_ACTION:
|
|
129
|
+
return _objectSpread(_objectSpread({}, state), payload);
|
|
116
130
|
default:
|
|
117
131
|
return state;
|
|
118
132
|
}
|
package/package.json
CHANGED
package/src/FacetFilterView.js
CHANGED
|
@@ -11,6 +11,7 @@ const BentoFacetFilter = ({
|
|
|
11
11
|
CustomFacetSection,
|
|
12
12
|
CustomFacetView,
|
|
13
13
|
enableClearSection,
|
|
14
|
+
enableFacetCollapse,
|
|
14
15
|
}) => {
|
|
15
16
|
return (
|
|
16
17
|
<>
|
|
@@ -26,6 +27,7 @@ const BentoFacetFilter = ({
|
|
|
26
27
|
facet={facet}
|
|
27
28
|
CustomView={CustomFacetView}
|
|
28
29
|
enableClearSection={enableClearSection}
|
|
30
|
+
enableFacetCollapse={enableFacetCollapse}
|
|
29
31
|
/>
|
|
30
32
|
))}
|
|
31
33
|
</FacetSectionView>
|
|
@@ -11,6 +11,7 @@ import styles from './FacetStyle';
|
|
|
11
11
|
import FilterItems from '../inputs/FilterItems';
|
|
12
12
|
import { sortType } from '../../utils/Sort';
|
|
13
13
|
import clearIcon from './assets/clearIcon.svg';
|
|
14
|
+
import { sideBarActionTypes } from '../../store/actions/ActionTypes';
|
|
14
15
|
|
|
15
16
|
const FacetView = ({
|
|
16
17
|
classes,
|
|
@@ -21,10 +22,29 @@ const FacetView = ({
|
|
|
21
22
|
CustomView,
|
|
22
23
|
autoComplete,
|
|
23
24
|
upload,
|
|
25
|
+
filterState,
|
|
26
|
+
currentActionType = {},
|
|
27
|
+
enableFacetCollapse,
|
|
24
28
|
}) => {
|
|
25
29
|
const [expand, setExpand] = useState(false);
|
|
26
30
|
const onExpandFacet = () => setExpand(!expand);
|
|
27
31
|
|
|
32
|
+
const { datafield } = facet;
|
|
33
|
+
/**
|
|
34
|
+
* Collapse expanded facet or facets
|
|
35
|
+
* 1. on clear facet section
|
|
36
|
+
* 2. on clear all
|
|
37
|
+
*/
|
|
38
|
+
useEffect(() => {
|
|
39
|
+
if (enableFacetCollapse) {
|
|
40
|
+
const actionType = currentActionType[datafield];
|
|
41
|
+
if ((actionType && actionType === sideBarActionTypes.CLEAR_FACET_SECTION)
|
|
42
|
+
|| currentActionType === sideBarActionTypes.CLEAR_ALL_FILTERS) {
|
|
43
|
+
setExpand(false);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}, [currentActionType]);
|
|
47
|
+
|
|
28
48
|
/**
|
|
29
49
|
* expand section incase of active local search
|
|
30
50
|
*/
|
|
@@ -44,10 +64,13 @@ const FacetView = ({
|
|
|
44
64
|
|
|
45
65
|
const onClearSection = () => {
|
|
46
66
|
setSortBy(null);
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
67
|
+
const activeFilterItems = filterState[datafield];
|
|
68
|
+
if (activeFilterItems && Object.keys(activeFilterItems).length > 0) {
|
|
69
|
+
if (facet.type === InputTypes.SLIDER) {
|
|
70
|
+
onClearSliderSection(facet);
|
|
71
|
+
} else {
|
|
72
|
+
onClearFacetSection(facet);
|
|
73
|
+
}
|
|
51
74
|
}
|
|
52
75
|
};
|
|
53
76
|
/**
|
|
@@ -11,6 +11,7 @@ const ReduxFacetView = (props) => <FacetView {...props} />;
|
|
|
11
11
|
|
|
12
12
|
const mapStateToProps = (state) => ({
|
|
13
13
|
filterState: state.statusReducer.filterState,
|
|
14
|
+
currentActionType: state.statusReducer.currentActionType,
|
|
14
15
|
autoComplete: state?.localFind?.autocomplete || [],
|
|
15
16
|
upload: state?.localFind?.upload || [],
|
|
16
17
|
});
|
|
@@ -30,7 +30,7 @@ export const onClearFacetSection = ({
|
|
|
30
30
|
if (updatedState[datafield]) {
|
|
31
31
|
updatedState[datafield] = {};
|
|
32
32
|
}
|
|
33
|
-
return updatedState;
|
|
33
|
+
return { updatedState, datafield };
|
|
34
34
|
};
|
|
35
35
|
|
|
36
36
|
export const onClearSliderSection = ({
|
|
@@ -78,12 +78,19 @@ export function sideBarReducerGenerator() {
|
|
|
78
78
|
return {
|
|
79
79
|
...state,
|
|
80
80
|
filterState: {},
|
|
81
|
+
currentActionType: sideBarActionTypes.CLEAR_ALL_FILTERS,
|
|
81
82
|
};
|
|
82
83
|
case sideBarActionTypes.CLEAR_FACET_SECTION:
|
|
83
|
-
|
|
84
|
+
const {
|
|
85
|
+
updatedState: updtState,
|
|
86
|
+
datafield,
|
|
87
|
+
} = onClearFacetSection({ ...payload, ...state });
|
|
88
|
+
updateState = updtState;
|
|
89
|
+
const currentActionType = { [datafield]: sideBarActionTypes.CLEAR_FACET_SECTION };
|
|
84
90
|
return {
|
|
85
91
|
...state,
|
|
86
92
|
filterState: { ...updateState },
|
|
93
|
+
currentActionType,
|
|
87
94
|
};
|
|
88
95
|
case sideBarActionTypes.CLEAR_SLIDER_SECTION:
|
|
89
96
|
updateState = onClearSliderSection({ ...payload, ...state });
|