@bento-core/facet-filter 0.2.0
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/README.md +255 -0
- package/babel.config.json +20 -0
- package/dist/FacetFilterController.js +152 -0
- package/dist/FacetFilterStyle.js +32 -0
- package/dist/FacetFilterView.js +39 -0
- package/dist/components/facet/FacetStyle.js +82 -0
- package/dist/components/facet/FacetView.js +130 -0
- package/dist/components/facet/ReduxFacetView.js +30 -0
- package/dist/components/facet/assets/clearIcon.svg +14 -0
- package/dist/components/inputs/FilterItemStyle.js +37 -0
- package/dist/components/inputs/FilterItems.js +53 -0
- package/dist/components/inputs/Types.js +17 -0
- package/dist/components/inputs/checkbox/CheckboxStyle.js +39 -0
- package/dist/components/inputs/checkbox/CheckboxView.js +108 -0
- package/dist/components/inputs/checkbox/ReduxCheckbox.js +20 -0
- package/dist/components/inputs/slider/InputMinMaxStyle.js +10 -0
- package/dist/components/inputs/slider/InputMinMaxView.js +47 -0
- package/dist/components/inputs/slider/ReduxSlider.js +20 -0
- package/dist/components/inputs/slider/SliderStyle.js +124 -0
- package/dist/components/inputs/slider/SliderView.js +110 -0
- package/dist/components/reset/ReduxClearAllBtn.js +58 -0
- package/dist/components/section/FacetSectionStyle.js +42 -0
- package/dist/components/section/FacetSectionView.js +46 -0
- package/dist/components/summary/AccordionSummaryStyle.js +18 -0
- package/dist/components/summary/AccordionSummaryView.js +50 -0
- package/dist/generator/component.js +37 -0
- package/dist/index.js +133 -0
- package/dist/store/actions/ActionTypes.js +17 -0
- package/dist/store/actions/Actions.js +40 -0
- package/dist/store/reducers/SideBarReducer.js +121 -0
- package/dist/utils/Sort.js +78 -0
- package/dist/utils/filter.js +30 -0
- package/package.json +25 -0
- package/src/FacetFilterController.js +145 -0
- package/src/FacetFilterStyle.js +25 -0
- package/src/FacetFilterView.js +52 -0
- package/src/components/facet/FacetStyle.js +75 -0
- package/src/components/facet/FacetView.js +183 -0
- package/src/components/facet/ReduxFacetView.js +19 -0
- package/src/components/facet/assets/clearIcon.svg +14 -0
- package/src/components/inputs/FilterItemStyle.js +30 -0
- package/src/components/inputs/FilterItems.js +40 -0
- package/src/components/inputs/Types.js +10 -0
- package/src/components/inputs/checkbox/CheckboxStyle.js +32 -0
- package/src/components/inputs/checkbox/CheckboxView.js +124 -0
- package/src/components/inputs/checkbox/ReduxCheckbox.js +16 -0
- package/src/components/inputs/slider/InputMinMaxStyle.js +4 -0
- package/src/components/inputs/slider/InputMinMaxView.js +45 -0
- package/src/components/inputs/slider/ReduxSlider.js +16 -0
- package/src/components/inputs/slider/SliderStyle.js +117 -0
- package/src/components/inputs/slider/SliderView.js +122 -0
- package/src/components/reset/ReduxClearAllBtn.js +53 -0
- package/src/components/section/FacetSectionStyle.js +35 -0
- package/src/components/section/FacetSectionView.js +52 -0
- package/src/components/summary/AccordionSummaryStyle.js +11 -0
- package/src/components/summary/AccordionSummaryView.js +49 -0
- package/src/generator/component.js +32 -0
- package/src/index.js +30 -0
- package/src/store/actions/ActionTypes.js +10 -0
- package/src/store/actions/Actions.js +32 -0
- package/src/store/reducers/SideBarReducer.js +103 -0
- package/src/utils/Sort.js +71 -0
- package/src/utils/filter.js +24 -0
package/README.md
ADDED
|
@@ -0,0 +1,255 @@
|
|
|
1
|
+
# SIDEBAR COMPONENT DESIGN
|
|
2
|
+
|
|
3
|
+
### Bento core sidebar design:
|
|
4
|
+
|
|
5
|
+
* Use of local state for all the click events
|
|
6
|
+
* Use of global redux limited to store active filters
|
|
7
|
+
* Limit use of props drilling
|
|
8
|
+
* Core layout defined by Bento Core Sidebar component
|
|
9
|
+
* Use of generator function to create and configure components (generator funtion is not used for configuring all the sidebar components due to local state issue)
|
|
10
|
+
* Simple configuration to maximize the customization of sideBar component
|
|
11
|
+
* Apply SOLID principles in react (https://konstantinlebedev.com/solid-in-react/)
|
|
12
|
+
|
|
13
|
+
## 1 Redux stores active filters value and configuration
|
|
14
|
+
|
|
15
|
+
### Generate and integrate redux dispatch actions
|
|
16
|
+
```
|
|
17
|
+
import { sideBarReducerGenerator } from 'bento-core';
|
|
18
|
+
const { statusReducer } = sideBarReducerGenerator();
|
|
19
|
+
|
|
20
|
+
const reducers = { statusReducer, ..., otherReducers };
|
|
21
|
+
const loggerMiddleware = createLogger();
|
|
22
|
+
const store = createStore(
|
|
23
|
+
combineReducers(reducers),
|
|
24
|
+
composeWithDevTools (applyMiddleware(ReduxThunk, loggerMiddleware)),
|
|
25
|
+
);
|
|
26
|
+
```
|
|
27
|
+
### Check Global redux store for all active filters
|
|
28
|
+
```
|
|
29
|
+
// active filter json structure
|
|
30
|
+
statusReducer:
|
|
31
|
+
filterState:
|
|
32
|
+
pr_status:
|
|
33
|
+
{
|
|
34
|
+
Not Reported: true
|
|
35
|
+
},
|
|
36
|
+
rc_scores: {
|
|
37
|
+
11-15: true,
|
|
38
|
+
21-25: true
|
|
39
|
+
}
|
|
40
|
+
tumor_grades: {}
|
|
41
|
+
tumor_sizes: {(1,2]: true}
|
|
42
|
+
```
|
|
43
|
+
#### (Note: Bento core sideBar provides method to override the redux filter events/ actions.)
|
|
44
|
+
|
|
45
|
+
## 2 Importing Component and Configuration
|
|
46
|
+
```
|
|
47
|
+
import FacetFilter from 'bento-core';
|
|
48
|
+
|
|
49
|
+
<FacetFilterThemeProvider>
|
|
50
|
+
<OtherComponent />
|
|
51
|
+
<FacetFilter
|
|
52
|
+
data={searchData}
|
|
53
|
+
facetSectionConfig={facetSectionVariables}
|
|
54
|
+
facetsConfig={facetsConfig}
|
|
55
|
+
CustomFacetSection={CustomFacetSection}
|
|
56
|
+
CustomFacetView={CustomFacetView}
|
|
57
|
+
/>
|
|
58
|
+
</FacetFilterThemeProvider>
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
## 3 Dashboard Data
|
|
62
|
+
***searchData*** Pass Dashboard Data. (DASHBOARD_QUERY response)
|
|
63
|
+
```
|
|
64
|
+
<FacetFilter
|
|
65
|
+
data={searchData}
|
|
66
|
+
...
|
|
67
|
+
/>
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
## 4 FacetsConfigs
|
|
71
|
+
|
|
72
|
+
```
|
|
73
|
+
import { InputTypes } from 'bento-core';
|
|
74
|
+
|
|
75
|
+
export const facetsConfig = [{
|
|
76
|
+
section: CASES,
|
|
77
|
+
label: 'Program',
|
|
78
|
+
apiForFiltering: 'filterSubjectCountByProgram',
|
|
79
|
+
datafield: 'programs',
|
|
80
|
+
field: GROUP,
|
|
81
|
+
type: InputTypes.CHECKBOX,
|
|
82
|
+
sort_type: sortType.ALPHABET,
|
|
83
|
+
show: true,
|
|
84
|
+
}, {
|
|
85
|
+
section: CASES,
|
|
86
|
+
label: 'Age',
|
|
87
|
+
apiForFiltering: 'filterSubjectCountByAge',
|
|
88
|
+
datafield: 'age_at_index',
|
|
89
|
+
ApiLowerBoundName: 'lowerBound',
|
|
90
|
+
ApiUpperBoundName: 'upperBound',
|
|
91
|
+
show: true,
|
|
92
|
+
slider: true,
|
|
93
|
+
type: InputTypes.SLIDER,
|
|
94
|
+
sort_type: 'none',
|
|
95
|
+
minLowerBound: 0,
|
|
96
|
+
maxUpperBound: 100,
|
|
97
|
+
quantifier: 'Years',
|
|
98
|
+
].
|
|
99
|
+
```
|
|
100
|
+
1. **apiForFiltering** refers to object key for retrieving name and subjects count from query response (DASHBOARD_QUERY)
|
|
101
|
+
2. **dataField** field for global redux store to track active filter item
|
|
102
|
+
3. **Type** indicates the type of input (checkbox or slider)
|
|
103
|
+
4. **sort_type** attribute used by Bento core sidebar local state to sorting of facet values
|
|
104
|
+
5. **section** refers to name of the facet section
|
|
105
|
+
6. **show** attribute must to be true to display facet on the Bento core Side bar component
|
|
106
|
+
|
|
107
|
+
Configuration varies based on the input types like checkbox or slider
|
|
108
|
+
|
|
109
|
+
#### (NOTE - SLIDER requires additional attributes)
|
|
110
|
+
|
|
111
|
+
## 5 facetSectionConfig
|
|
112
|
+
```
|
|
113
|
+
export const facetSectionVariables = {
|
|
114
|
+
Cases: {
|
|
115
|
+
isExpanded: true,
|
|
116
|
+
},
|
|
117
|
+
Samples: {
|
|
118
|
+
isExpanded: true,
|
|
119
|
+
},
|
|
120
|
+
Files: {
|
|
121
|
+
isExpanded: true,
|
|
122
|
+
}};
|
|
123
|
+
```
|
|
124
|
+
Facet section defines the number of sections that will be displayed on Bento core sidebar component. **isExpanded** attribute set default state for the section i.e if true then facet section expand if false facet section collapse.
|
|
125
|
+
|
|
126
|
+
## 6 CustomFacetSection
|
|
127
|
+
Bento Core sidebar component provides view customization to some component like FacetSection and Face component.
|
|
128
|
+
```
|
|
129
|
+
const CustomFacetSection = ({ section }) => {
|
|
130
|
+
return (
|
|
131
|
+
<>
|
|
132
|
+
<CustomExpansionPanelSummary>
|
|
133
|
+
<div className={classes.sectionSummaryTextContainer}>
|
|
134
|
+
{section.name}
|
|
135
|
+
</div>
|
|
136
|
+
</CustomExpansionPanelSummary>
|
|
137
|
+
</> );
|
|
138
|
+
};
|
|
139
|
+
|
|
140
|
+
// provide as props
|
|
141
|
+
<FacetFilter
|
|
142
|
+
data={searchData}
|
|
143
|
+
facetSectionConfig={facetSectionVariables}
|
|
144
|
+
facetsConfig={facetsConfig}
|
|
145
|
+
CustomFacetSection={CustomFacetSection}
|
|
146
|
+
CustomFacetView={CustomFacetView}
|
|
147
|
+
/>
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
## 7 CustomFacetView
|
|
151
|
+
```
|
|
152
|
+
const CustomFacetView = ({ facet, facetClasses }) => {
|
|
153
|
+
return (
|
|
154
|
+
<>
|
|
155
|
+
<CustomExpansionPanelSummary>
|
|
156
|
+
<div
|
|
157
|
+
className={clsx(classes.sectionSummaryText, classes[facetClasses])}
|
|
158
|
+
>
|
|
159
|
+
{facet.label}
|
|
160
|
+
</div>
|
|
161
|
+
</CustomExpansionPanelSummary>
|
|
162
|
+
</>
|
|
163
|
+
)};
|
|
164
|
+
|
|
165
|
+
// provide as props
|
|
166
|
+
<FacetFilter
|
|
167
|
+
data={searchData}
|
|
168
|
+
facetSectionConfig={facetSectionVariables}
|
|
169
|
+
facetsConfig={facetsConfig}
|
|
170
|
+
CustomFacetSection={CustomFacetSection}
|
|
171
|
+
CustomFacetView={CustomFacetView}
|
|
172
|
+
/>
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
## 8 FacetFilterThemeProvider
|
|
176
|
+
Bento Core Sidebar assigns classes dynamically to its components ***(Mui component)*** based on local state of the component, **FacetsConfigs** and **facetSectionConfig**. Bento Core sidebar uses Mui Components widely so ***ThemeProvider*** can be used to override styles for each of the components in Bento Core Sidebar. This approach is similar to react ***useContext***, to prevent props drilling.
|
|
177
|
+
|
|
178
|
+
```
|
|
179
|
+
const theme = {
|
|
180
|
+
overrides: {
|
|
181
|
+
MuiListItem:
|
|
182
|
+
root: {
|
|
183
|
+
'&.casesCheckedEven': {
|
|
184
|
+
//refer to class name table
|
|
185
|
+
..//styles
|
|
186
|
+
}
|
|
187
|
+
'&.casesCheckedOdd' :{
|
|
188
|
+
//refer to class name table
|
|
189
|
+
..//styles
|
|
190
|
+
},
|
|
191
|
+
'&.samplesCheckedEven': {
|
|
192
|
+
//refer to class name table
|
|
193
|
+
..//styles
|
|
194
|
+
}
|
|
195
|
+
'&.samplesCheckedOdd' :{
|
|
196
|
+
..//styles
|
|
197
|
+
},
|
|
198
|
+
MuiSvgIcon: {
|
|
199
|
+
root: {
|
|
200
|
+
'&.casesCheckedIcon': {
|
|
201
|
+
//refer to class name table
|
|
202
|
+
..//styles
|
|
203
|
+
}
|
|
204
|
+
'&.samplesCheckedIcon': {
|
|
205
|
+
..//styles
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
import FacetFilter from 'bento-core';
|
|
210
|
+
<ThemeProvider theme={computedTheme}>
|
|
211
|
+
<FacetFilter />
|
|
212
|
+
</ThemeProvider>
|
|
213
|
+
```
|
|
214
|
+
**NOTE: These are example class name and it is based on the configuration so for different configuration this classes may not apply)**
|
|
215
|
+
|
|
216
|
+
**CheckBox Component CLASS NAMES TABLE**
|
|
217
|
+
| Sidebar Component | Child Component | Mui | ClassName | Condition |
|
|
218
|
+
| :--- | :----: | :----: | :----: | ----: |
|
|
219
|
+
| Facet Value | Check box Button | ListItem | {***checkedSection***}Checked{***indexType***} | active |
|
|
220
|
+
| Facet Value | Checkbox Input | CheckboxIcon | {***checkedSection***}CheckedIcon | active |
|
|
221
|
+
| Facet Value | Name | Typography | {***checkedSection***}NameUnChecked | inactive |
|
|
222
|
+
| Facet Value | Name | Typography | {***checkedSection***}NameChecked | active |
|
|
223
|
+
| Facet Value | Subject | Typography | {***checkedSection***}SubjectUnChecked | active |
|
|
224
|
+
| Facet Value | Subject | Typography | {***checkedSection***}SubjectChecked | inactive |
|
|
225
|
+
|
|
226
|
+
Follows in order of parent to child components <br>
|
|
227
|
+
**bold** text indicates variables <br>
|
|
228
|
+
active - when input type is checked <br>
|
|
229
|
+
**{indexType}** = 'Even' /'Odd' based on index of the facet values <br>
|
|
230
|
+
**{checkedSection}** = section name (attribute of facetsConfig) (like Cases, Sample, Files)
|
|
231
|
+
|
|
232
|
+
**Slider Component** <br>
|
|
233
|
+
**{type}** -min or max (slider input type)
|
|
234
|
+
| Sidebar Component | Child Component | Mui | ClassName | Condition |
|
|
235
|
+
| :--- | :----: | :----: | :----: | ----: |
|
|
236
|
+
| Facet Value | Input Min/Max | Input | slider_{***type***} | active |
|
|
237
|
+
|
|
238
|
+
## 9. Styling Non Mui Custom Components
|
|
239
|
+
Classes provided by Bento Core Sidebar can be applied to the Custom elements.
|
|
240
|
+
```
|
|
241
|
+
className={clsx(classes.sectionSummaryText, classes[facetClasses])}
|
|
242
|
+
```
|
|
243
|
+
|
|
244
|
+
## 10 CLearAllFilterButton Component
|
|
245
|
+
Bento Core provides 1. function to clear all active filters, 2. disable flag (true incase of no active filters). Client is responsible for defining view (custom html).
|
|
246
|
+
```
|
|
247
|
+
import { generateClearAllFilterBtn } from 'bento-core';
|
|
248
|
+
|
|
249
|
+
const CustomClearAllFiltersBtn = ({ onClearAllFilters, disable }) => {
|
|
250
|
+
//...custom component 1. bind onClearFilters fn
|
|
251
|
+
// 2. disable flag to disable button
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
const ClearAllFiltersButton = () => generateClearAllFilterBtn(CustomClearAllFiltersBtn);
|
|
255
|
+
```
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
{
|
|
2
|
+
"presets": [
|
|
3
|
+
[
|
|
4
|
+
"@babel/env",
|
|
5
|
+
{
|
|
6
|
+
"targets": {
|
|
7
|
+
"edge": "17",
|
|
8
|
+
"firefox": "60",
|
|
9
|
+
"chrome": "67",
|
|
10
|
+
"safari": "11.1"
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
],
|
|
14
|
+
"@babel/preset-react"
|
|
15
|
+
],
|
|
16
|
+
"plugins": [
|
|
17
|
+
"@babel/plugin-transform-react-jsx",
|
|
18
|
+
"@babel/plugin-proposal-class-properties"
|
|
19
|
+
]
|
|
20
|
+
}
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _lodash = _interopRequireDefault(require("lodash"));
|
|
8
|
+
var _react = _interopRequireDefault(require("react"));
|
|
9
|
+
var _reactRedux = require("react-redux");
|
|
10
|
+
var _Types = require("./components/inputs/Types");
|
|
11
|
+
var _FacetFilterView = _interopRequireDefault(require("./FacetFilterView"));
|
|
12
|
+
const _excluded = ["section"];
|
|
13
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
14
|
+
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
15
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
16
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
17
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
18
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
19
|
+
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
20
|
+
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
21
|
+
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
22
|
+
const FacetFilterController = props => {
|
|
23
|
+
/**
|
|
24
|
+
* update checkbox state
|
|
25
|
+
* 1. checkbox state
|
|
26
|
+
* 2. subject state
|
|
27
|
+
*/
|
|
28
|
+
const {
|
|
29
|
+
filterState,
|
|
30
|
+
data,
|
|
31
|
+
facetsConfig,
|
|
32
|
+
facetSectionConfig
|
|
33
|
+
} = props;
|
|
34
|
+
const updateFacetState = filterSections => {
|
|
35
|
+
const updateSections = [...filterSections];
|
|
36
|
+
if (!_lodash.default.isEmpty(filterState)) {
|
|
37
|
+
for (const [key, value] of Object.entries(filterState)) {
|
|
38
|
+
updateSections.forEach(sideBar => {
|
|
39
|
+
if (sideBar.type === _Types.InputTypes.CHECKBOX && sideBar.datafield === key) {
|
|
40
|
+
sideBar.facetValues.forEach(item => {
|
|
41
|
+
item.isChecked = value[item.name] ? value[item.name] : false;
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
if (sideBar.type === _Types.InputTypes.SLIDER && sideBar.datafield === key) {
|
|
45
|
+
sideBar.facetValues = value;
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
} else {
|
|
50
|
+
updateSections.forEach(sideBar => {
|
|
51
|
+
if (sideBar.type === _Types.InputTypes.CHECKBOX) {
|
|
52
|
+
sideBar.facetValues.forEach(item => {
|
|
53
|
+
item.isChecked = false;
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* set default value for slider - on clear all filter
|
|
58
|
+
*/
|
|
59
|
+
if (sideBar.type === _Types.InputTypes.SLIDER) {
|
|
60
|
+
const {
|
|
61
|
+
minLowerBound,
|
|
62
|
+
maxUpperBound
|
|
63
|
+
} = sideBar;
|
|
64
|
+
sideBar.facetValues = [minLowerBound, maxUpperBound];
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
return updateSections;
|
|
69
|
+
};
|
|
70
|
+
const arrangeBySections = arr => {
|
|
71
|
+
const sideBar = {};
|
|
72
|
+
arr.forEach(_ref => {
|
|
73
|
+
let {
|
|
74
|
+
section
|
|
75
|
+
} = _ref,
|
|
76
|
+
item = _objectWithoutProperties(_ref, _excluded);
|
|
77
|
+
if (!sideBar[section]) {
|
|
78
|
+
sideBar[section] = {
|
|
79
|
+
name: section,
|
|
80
|
+
sectionName: section,
|
|
81
|
+
expandSection: facetSectionConfig[section].isExpanded,
|
|
82
|
+
items: []
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
sideBar[section].items.push(_objectSpread({
|
|
86
|
+
section
|
|
87
|
+
}, item));
|
|
88
|
+
});
|
|
89
|
+
return Object.values(sideBar);
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Construct filter object
|
|
94
|
+
* 1. add facet values to facets
|
|
95
|
+
* 2. add 'name' key to each facet value
|
|
96
|
+
*/
|
|
97
|
+
const addFacetValues = facets => {
|
|
98
|
+
const updateFacets = [];
|
|
99
|
+
if (facets) {
|
|
100
|
+
facets.forEach(facet => {
|
|
101
|
+
const updateFacet = _objectSpread(_objectSpread({}, facet), {}, {
|
|
102
|
+
facetValues: []
|
|
103
|
+
});
|
|
104
|
+
const {
|
|
105
|
+
field,
|
|
106
|
+
ApiLowerBoundName,
|
|
107
|
+
ApiUpperBoundName,
|
|
108
|
+
apiForFiltering
|
|
109
|
+
} = updateFacet;
|
|
110
|
+
if (data[apiForFiltering]) {
|
|
111
|
+
if (Array.isArray(data[apiForFiltering])) {
|
|
112
|
+
const updateField = data[apiForFiltering].map(item => {
|
|
113
|
+
const addField = _objectSpread({}, item);
|
|
114
|
+
addField.name = item[field];
|
|
115
|
+
return addField;
|
|
116
|
+
});
|
|
117
|
+
updateFacet.facetValues = updateField;
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* add object to facet values
|
|
121
|
+
*/
|
|
122
|
+
if (facet.type === _Types.InputTypes.SLIDER) {
|
|
123
|
+
const lowerBound = data[apiForFiltering][ApiLowerBoundName];
|
|
124
|
+
const upperBound = data[apiForFiltering][ApiUpperBoundName];
|
|
125
|
+
updateFacet.minLowerBound = lowerBound;
|
|
126
|
+
updateFacet.maxUpperBound = upperBound;
|
|
127
|
+
updateFacet.facetValues = [lowerBound, upperBound];
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
updateFacets.push(updateFacet);
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
return updateFacets;
|
|
134
|
+
};
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* Generate facet sections state
|
|
138
|
+
*
|
|
139
|
+
*/
|
|
140
|
+
const displayFacets = facetsConfig.filter(facet => facet.show).slice(0, 16);
|
|
141
|
+
const facetStates = addFacetValues(displayFacets);
|
|
142
|
+
const updateState = updateFacetState(facetStates);
|
|
143
|
+
const facetSections = arrangeBySections(updateState);
|
|
144
|
+
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_FacetFilterView.default, _extends({}, props, {
|
|
145
|
+
sideBarSections: facetSections
|
|
146
|
+
})));
|
|
147
|
+
};
|
|
148
|
+
const mapStateToProps = state => ({
|
|
149
|
+
filterState: state.statusReducer.filterState
|
|
150
|
+
});
|
|
151
|
+
var _default = (0, _reactRedux.connect)(mapStateToProps, null)(FacetFilterController);
|
|
152
|
+
exports.default = _default;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _default = () => ({
|
|
8
|
+
sectionSummaryText: {
|
|
9
|
+
color: '#323232',
|
|
10
|
+
fontFamily: 'Raleway',
|
|
11
|
+
fontSize: '15px',
|
|
12
|
+
fontWeight: 'bold',
|
|
13
|
+
letterSpacing: '0.25px',
|
|
14
|
+
marginLeft: '15px',
|
|
15
|
+
lineHeight: '26px'
|
|
16
|
+
},
|
|
17
|
+
sortGroup: {
|
|
18
|
+
paddingTop: '10px',
|
|
19
|
+
paddingBottom: '5px',
|
|
20
|
+
borderTop: '1px solid #B1B1B1',
|
|
21
|
+
textAlign: 'left',
|
|
22
|
+
marginLeft: '-5px',
|
|
23
|
+
boxShadow: 'inset -10px 2px 10px -7px rgb(50 50 50 / 25%)'
|
|
24
|
+
},
|
|
25
|
+
sortGroupItem: {
|
|
26
|
+
cursor: 'pointer',
|
|
27
|
+
fontFamily: 'Nunito',
|
|
28
|
+
fontSize: '10px',
|
|
29
|
+
marginRight: '32px'
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
exports.default = _default;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _react = _interopRequireDefault(require("react"));
|
|
8
|
+
var _core = require("@material-ui/core");
|
|
9
|
+
var _FacetFilterStyle = _interopRequireDefault(require("./FacetFilterStyle"));
|
|
10
|
+
var _FacetSectionView = _interopRequireDefault(require("./components/section/FacetSectionView"));
|
|
11
|
+
var _ReduxFacetView = _interopRequireDefault(require("./components/facet/ReduxFacetView"));
|
|
12
|
+
var _FilterItems = _interopRequireDefault(require("./components/inputs/FilterItems"));
|
|
13
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
14
|
+
/* eslint-disable arrow-body-style */
|
|
15
|
+
/* eslint-disable padded-blocks */
|
|
16
|
+
|
|
17
|
+
const BentoFacetFilter = _ref => {
|
|
18
|
+
let {
|
|
19
|
+
sideBarSections,
|
|
20
|
+
CustomFacetSection,
|
|
21
|
+
CustomFacetView
|
|
22
|
+
} = _ref;
|
|
23
|
+
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
|
+
variant: "middle",
|
|
25
|
+
className: "divider".concat(index)
|
|
26
|
+
}), /*#__PURE__*/_react.default.createElement(_FacetSectionView.default, {
|
|
27
|
+
section: section,
|
|
28
|
+
CustomSection: CustomFacetSection
|
|
29
|
+
}, section.items.map(facet => /*#__PURE__*/_react.default.createElement(_ReduxFacetView.default, {
|
|
30
|
+
facet: facet,
|
|
31
|
+
CustomView: CustomFacetView
|
|
32
|
+
}, /*#__PURE__*/_react.default.createElement(_core.List, {
|
|
33
|
+
className: "List_".concat(facet.label)
|
|
34
|
+
}, /*#__PURE__*/_react.default.createElement(_FilterItems.default, {
|
|
35
|
+
facet: facet
|
|
36
|
+
}))))))));
|
|
37
|
+
};
|
|
38
|
+
var _default = (0, _core.withStyles)(_FacetFilterStyle.default)(BentoFacetFilter);
|
|
39
|
+
exports.default = _default;
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _default = () => ({
|
|
8
|
+
expansionPanelDetailsRoot: {
|
|
9
|
+
display: 'block'
|
|
10
|
+
},
|
|
11
|
+
expansionPanelsideBarItem: {
|
|
12
|
+
boxShadow: 'none',
|
|
13
|
+
borderTop: '1px solid #D2D2D2',
|
|
14
|
+
'&:last-child': {
|
|
15
|
+
borderBottom: '1px solid #D2D2D2'
|
|
16
|
+
},
|
|
17
|
+
margin: 'auto',
|
|
18
|
+
position: 'initial',
|
|
19
|
+
'&:before': {
|
|
20
|
+
position: 'initial'
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
subSectionSummaryText: {
|
|
24
|
+
marginLeft: '10px',
|
|
25
|
+
lineHeight: 0,
|
|
26
|
+
color: '#323232',
|
|
27
|
+
fontFamily: 'Raleway',
|
|
28
|
+
fontSize: '13px',
|
|
29
|
+
fontWeight: 'bold',
|
|
30
|
+
letterSpacing: '0.25px'
|
|
31
|
+
},
|
|
32
|
+
sortGroup: {
|
|
33
|
+
paddingTop: '10px',
|
|
34
|
+
marginBottom: '5px',
|
|
35
|
+
borderTop: '1px solid #B1B1B1',
|
|
36
|
+
textAlign: 'left',
|
|
37
|
+
marginLeft: '-5px'
|
|
38
|
+
},
|
|
39
|
+
sortGroupIcon: {
|
|
40
|
+
cursor: 'pointer',
|
|
41
|
+
fontFamily: 'Nunito',
|
|
42
|
+
fontSize: '10px',
|
|
43
|
+
marginRight: '12px',
|
|
44
|
+
marginLeft: '16px'
|
|
45
|
+
},
|
|
46
|
+
sortGroupItem: {
|
|
47
|
+
cursor: 'pointer',
|
|
48
|
+
fontFamily: 'Nunito',
|
|
49
|
+
fontSize: '10px',
|
|
50
|
+
marginRight: '32px'
|
|
51
|
+
},
|
|
52
|
+
NonSortGroup: {
|
|
53
|
+
marginBottom: '5px',
|
|
54
|
+
borderTop: '1px solid #B1B1B1',
|
|
55
|
+
textAlign: 'left',
|
|
56
|
+
paddingLeft: '10px'
|
|
57
|
+
},
|
|
58
|
+
NonSortGroupItem: {
|
|
59
|
+
fontFamily: 'Nunito',
|
|
60
|
+
fontSize: '10px',
|
|
61
|
+
marginRight: '32px'
|
|
62
|
+
},
|
|
63
|
+
sortGroupItemCounts: {
|
|
64
|
+
cursor: 'pointer',
|
|
65
|
+
fontFamily: 'Nunito',
|
|
66
|
+
fontSize: '10px',
|
|
67
|
+
float: 'right',
|
|
68
|
+
marginRight: '10px',
|
|
69
|
+
marginTop: '5px'
|
|
70
|
+
},
|
|
71
|
+
highlight: {
|
|
72
|
+
color: '#b2c6d6'
|
|
73
|
+
},
|
|
74
|
+
showMore: {
|
|
75
|
+
textAlign: 'right',
|
|
76
|
+
paddingRight: '5px',
|
|
77
|
+
cursor: 'pointer',
|
|
78
|
+
fontSize: '10px',
|
|
79
|
+
width: '100%'
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
exports.default = _default;
|