@bento-core/facet-filter 1.0.1-icdc.6 → 1.0.1-icdc.8
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/FacetView.js +30 -5
- package/dist/components/facet/ReduxFacetView.js +1 -0
- package/dist/store/reducers/SideBarReducer.js +24 -8
- package/package.json +1 -1
- package/src/FacetFilterView.js +2 -0
- package/src/components/facet/FacetView.js +29 -4
- package/src/components/facet/ReduxFacetView.js +1 -0
- package/src/store/reducers/SideBarReducer.js +13 -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,31 @@ 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
|
+
console.log(currentActionType);
|
|
55
|
+
if (actionType && actionType === _ActionTypes.sideBarActionTypes.CLEAR_FACET_SECTION || currentActionType === _ActionTypes.sideBarActionTypes.CLEAR_ALL_FILTERS) {
|
|
56
|
+
console.log('set to false');
|
|
57
|
+
setExpand(false);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}, [filterState]);
|
|
39
61
|
|
|
40
62
|
/**
|
|
41
63
|
* expand section incase of active local search
|
|
@@ -51,10 +73,13 @@ const FacetView = _ref => {
|
|
|
51
73
|
};
|
|
52
74
|
const onClearSection = () => {
|
|
53
75
|
setSortBy(null);
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
76
|
+
const activeFilterItems = filterState[datafield];
|
|
77
|
+
if (activeFilterItems && Object.keys(activeFilterItems).length > 0) {
|
|
78
|
+
if (facet.type === _Types.InputTypes.SLIDER) {
|
|
79
|
+
onClearSliderSection(facet);
|
|
80
|
+
} else {
|
|
81
|
+
onClearFacetSection(facet);
|
|
82
|
+
}
|
|
58
83
|
}
|
|
59
84
|
};
|
|
60
85
|
/**
|
|
@@ -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 => {
|
|
@@ -88,30 +91,43 @@ function sideBarReducerGenerator() {
|
|
|
88
91
|
case _ActionTypes.sideBarActionTypes.FACET_VALUE_CHANGED:
|
|
89
92
|
updateState = onToggleStateUpdate(_objectSpread(_objectSpread({}, state), payload));
|
|
90
93
|
return _objectSpread(_objectSpread({}, state), {}, {
|
|
91
|
-
filterState: _objectSpread({}, updateState)
|
|
94
|
+
filterState: _objectSpread({}, updateState),
|
|
95
|
+
currentActionType: _ActionTypes.sideBarActionTypes.FACET_VALUE_CHANGED
|
|
92
96
|
});
|
|
93
97
|
case _ActionTypes.sideBarActionTypes.ON_TOGGLE_SLIDER:
|
|
94
98
|
updateState = updateSiderValue(_objectSpread(_objectSpread({}, state), payload));
|
|
95
99
|
return _objectSpread(_objectSpread({}, state), {}, {
|
|
96
|
-
filterState: _objectSpread({}, updateState)
|
|
100
|
+
filterState: _objectSpread({}, updateState),
|
|
101
|
+
currentActionType: _ActionTypes.sideBarActionTypes.ON_TOGGLE_SLIDER
|
|
97
102
|
});
|
|
98
103
|
case _ActionTypes.sideBarActionTypes.CLEAR_ALL_FILTERS:
|
|
99
104
|
return _objectSpread(_objectSpread({}, state), {}, {
|
|
100
|
-
filterState: {}
|
|
105
|
+
filterState: {},
|
|
106
|
+
currentActionType: _ActionTypes.sideBarActionTypes.CLEAR_ALL_FILTERS
|
|
101
107
|
});
|
|
102
108
|
case _ActionTypes.sideBarActionTypes.CLEAR_FACET_SECTION:
|
|
103
|
-
|
|
109
|
+
const {
|
|
110
|
+
updatedState: updtState,
|
|
111
|
+
datafield
|
|
112
|
+
} = onClearFacetSection(_objectSpread(_objectSpread({}, payload), state));
|
|
113
|
+
updateState = updtState;
|
|
114
|
+
const currentActionType = {
|
|
115
|
+
[datafield]: _ActionTypes.sideBarActionTypes.CLEAR_FACET_SECTION
|
|
116
|
+
};
|
|
104
117
|
return _objectSpread(_objectSpread({}, state), {}, {
|
|
105
|
-
filterState: _objectSpread({}, updateState)
|
|
118
|
+
filterState: _objectSpread({}, updateState),
|
|
119
|
+
currentActionType
|
|
106
120
|
});
|
|
107
121
|
case _ActionTypes.sideBarActionTypes.CLEAR_SLIDER_SECTION:
|
|
108
122
|
updateState = onClearSliderSection(_objectSpread(_objectSpread({}, payload), state));
|
|
109
123
|
return _objectSpread(_objectSpread({}, state), {}, {
|
|
110
|
-
filterState: _objectSpread({}, updateState)
|
|
124
|
+
filterState: _objectSpread({}, updateState),
|
|
125
|
+
currentActionType: _ActionTypes.sideBarActionTypes.CLEAR_SLIDER_SECTION
|
|
111
126
|
});
|
|
112
127
|
case _ActionTypes.sideBarActionTypes.CLEAR_AND_SELECT_FACET_VALUE:
|
|
113
128
|
return {
|
|
114
|
-
filterState: payload
|
|
129
|
+
filterState: payload,
|
|
130
|
+
currentActionType: _ActionTypes.sideBarActionTypes.CLEAR_AND_SELECT_FACET_VALUE
|
|
115
131
|
};
|
|
116
132
|
default:
|
|
117
133
|
return state;
|
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,31 @@ 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
|
+
console.log(currentActionType);
|
|
42
|
+
if ((actionType && actionType === sideBarActionTypes.CLEAR_FACET_SECTION)
|
|
43
|
+
|| currentActionType === sideBarActionTypes.CLEAR_ALL_FILTERS) {
|
|
44
|
+
console.log('set to false');
|
|
45
|
+
setExpand(false);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}, [filterState]);
|
|
49
|
+
|
|
28
50
|
/**
|
|
29
51
|
* expand section incase of active local search
|
|
30
52
|
*/
|
|
@@ -44,10 +66,13 @@ const FacetView = ({
|
|
|
44
66
|
|
|
45
67
|
const onClearSection = () => {
|
|
46
68
|
setSortBy(null);
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
69
|
+
const activeFilterItems = filterState[datafield];
|
|
70
|
+
if (activeFilterItems && Object.keys(activeFilterItems).length > 0) {
|
|
71
|
+
if (facet.type === InputTypes.SLIDER) {
|
|
72
|
+
onClearSliderSection(facet);
|
|
73
|
+
} else {
|
|
74
|
+
onClearFacetSection(facet);
|
|
75
|
+
}
|
|
51
76
|
}
|
|
52
77
|
};
|
|
53
78
|
/**
|
|
@@ -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 = ({
|
|
@@ -67,33 +67,44 @@ export function sideBarReducerGenerator() {
|
|
|
67
67
|
return {
|
|
68
68
|
...state,
|
|
69
69
|
filterState: { ...updateState },
|
|
70
|
+
currentActionType: sideBarActionTypes.FACET_VALUE_CHANGED,
|
|
70
71
|
};
|
|
71
72
|
case sideBarActionTypes.ON_TOGGLE_SLIDER:
|
|
72
73
|
updateState = updateSiderValue({ ...state, ...payload });
|
|
73
74
|
return {
|
|
74
75
|
...state,
|
|
75
76
|
filterState: { ...updateState },
|
|
77
|
+
currentActionType: sideBarActionTypes.ON_TOGGLE_SLIDER,
|
|
76
78
|
};
|
|
77
79
|
case sideBarActionTypes.CLEAR_ALL_FILTERS:
|
|
78
80
|
return {
|
|
79
81
|
...state,
|
|
80
82
|
filterState: {},
|
|
83
|
+
currentActionType: sideBarActionTypes.CLEAR_ALL_FILTERS,
|
|
81
84
|
};
|
|
82
85
|
case sideBarActionTypes.CLEAR_FACET_SECTION:
|
|
83
|
-
|
|
86
|
+
const {
|
|
87
|
+
updatedState: updtState,
|
|
88
|
+
datafield,
|
|
89
|
+
} = onClearFacetSection({ ...payload, ...state });
|
|
90
|
+
updateState = updtState;
|
|
91
|
+
const currentActionType = { [datafield]: sideBarActionTypes.CLEAR_FACET_SECTION };
|
|
84
92
|
return {
|
|
85
93
|
...state,
|
|
86
94
|
filterState: { ...updateState },
|
|
95
|
+
currentActionType,
|
|
87
96
|
};
|
|
88
97
|
case sideBarActionTypes.CLEAR_SLIDER_SECTION:
|
|
89
98
|
updateState = onClearSliderSection({ ...payload, ...state });
|
|
90
99
|
return {
|
|
91
100
|
...state,
|
|
92
101
|
filterState: { ...updateState },
|
|
102
|
+
currentActionType: sideBarActionTypes.CLEAR_SLIDER_SECTION,
|
|
93
103
|
};
|
|
94
104
|
case sideBarActionTypes.CLEAR_AND_SELECT_FACET_VALUE:
|
|
95
105
|
return {
|
|
96
106
|
filterState: payload,
|
|
107
|
+
currentActionType: sideBarActionTypes.CLEAR_AND_SELECT_FACET_VALUE,
|
|
97
108
|
};
|
|
98
109
|
default:
|
|
99
110
|
return state;
|