@bento-core/facet-filter 1.0.1-popsci.1 → 1.0.1-popsci.3

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 CHANGED
@@ -95,8 +95,6 @@ export const facetsConfig = [{
95
95
  minLowerBound: 0,
96
96
  maxUpperBound: 100,
97
97
  quantifier: 'Years',
98
- CustomLowerUpperBound: CustomLowerUpperBound, // Custom component for displaying lower and upper bounds
99
- CustomSliderValue: CustomSliderValue, // Custom component for displaying slider value
100
98
  ].
101
99
  ```
102
100
  1. **apiForFiltering** refers to object key for retrieving name and subjects count from query response (DASHBOARD_QUERY)
@@ -246,66 +244,12 @@ className={clsx(classes.sectionSummaryText, classes[facetClasses])}
246
244
  ## 10 CLearAllFilterButton Component
247
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).
248
246
  ```
249
- import { ClearAllFiltersBtn, FacetFilter } from '@bento-core/facet-filter';
250
- import { getFilters } from '@bento-core/facet-filter';
247
+ import { generateClearAllFilterBtn } from 'bento-core';
251
248
 
252
249
  const CustomClearAllFiltersBtn = ({ onClearAllFilters, disable }) => {
253
250
  //...custom component 1. bind onClearFilters fn
254
251
  // 2. disable flag to disable button
255
- }
256
- // get filter data
257
- // filterState: state.statusReducer.filterState, (from reducer)
258
- // const activeFilters = getFilters(filterState) // formating
259
-
260
- <ClearAllFiltersBtn
261
- Component={CustomClearAllFiltersBtn}
262
- activeFilters={activeFilters}
263
- />
264
- ```
265
-
266
- ## 11 Facet Value Component
267
- ```
268
- // response
269
- // filterCaseCountByProgram: [{group: "COP", subjects: 301}]
270
- const {
271
- name,
272
- customName,
273
- subjects,
274
- customSubjects,
275
- tooltip,
276
- } = checkboxItem;
277
-
278
- // 1. by default facet value component display group ("COP")
279
- // 2. set customName to display customize value
280
- // 3. by default facet value component display subjects (301)
281
- // 4. set customSubjects to display customize value or adjust correct field for subject count
282
- // 5. tooltip - provide text value to tooltip text
283
-
284
- /**
285
- * Add Bento frontend filter count/subjects
286
- * Add tootip text
287
- */
288
- const filterData = facetsConfig.reduce((acc, item) => {
289
- const facetValues = searchData[item.apiPath];
290
- if (!facetValues) {
291
- return acc;
292
- }
293
- const subjectCounts = [...facetValues].map((checkbox) => {
294
- const text = tooltipText[item.tooltipKey];
295
- return {
296
- ...checkbox,
297
- customSubjects: checkbox.count,
298
- tooltip: text ? text[checkbox.group] : undefined,
299
- };
300
- });
301
- return { ...acc, [item.apiPath]: [...subjectCounts] };
302
- }, {});
252
+ }
303
253
 
304
- <FacetFilter
305
- data={filterData}
306
- facetSectionConfig={facetSectionVariables}
307
- facetsConfig={facetsConfig}
308
- CustomFacetSection={CustomFacetSection}
309
- CustomFacetView={CustomFacetView}
310
- />
254
+ const ClearAllFiltersButton = () => generateClearAllFilterBtn(CustomClearAllFiltersBtn);
311
255
  ```
@@ -12,13 +12,13 @@ var _FacetFilterView = _interopRequireDefault(require("./FacetFilterView"));
12
12
  const _excluded = ["section"];
13
13
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
14
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 _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; }
16
- 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; }
17
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; }
18
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; }
19
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; }
20
18
  function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
21
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
22
  const FacetFilterController = props => {
23
23
  /**
24
24
  * update checkbox state
@@ -29,8 +29,7 @@ const FacetFilterController = props => {
29
29
  filterState,
30
30
  data,
31
31
  facetsConfig,
32
- facetSectionConfig,
33
- tooltipText = {}
32
+ facetSectionConfig
34
33
  } = props;
35
34
  const updateFacetState = filterSections => {
36
35
  const updateSections = [...filterSections];
@@ -38,16 +37,9 @@ const FacetFilterController = props => {
38
37
  for (const [key, value] of Object.entries(filterState)) {
39
38
  updateSections.forEach(sideBar => {
40
39
  if (sideBar.type === _Types.InputTypes.CHECKBOX && sideBar.datafield === key) {
41
- const {
42
- facetValues = []
43
- } = sideBar;
44
- const updateFacetVals = facetValues.map(item => {
45
- const facetVal = item[sideBar.field];
46
- return _objectSpread(_objectSpread({}, item), {}, {
47
- isChecked: value[facetVal] ? value[facetVal] : false
48
- });
40
+ sideBar.facetValues.forEach(item => {
41
+ item.isChecked = value[item.name] ? value[item.name] : false;
49
42
  });
50
- sideBar.facetValues = updateFacetVals;
51
43
  }
52
44
  if (sideBar.type === _Types.InputTypes.SLIDER && sideBar.datafield === key) {
53
45
  sideBar.facetValues = value;
@@ -57,13 +49,9 @@ const FacetFilterController = props => {
57
49
  } else {
58
50
  updateSections.forEach(sideBar => {
59
51
  if (sideBar.type === _Types.InputTypes.CHECKBOX) {
60
- const {
61
- facetValues = []
62
- } = sideBar;
63
- const updateFacetVals = facetValues.map(item => _objectSpread(_objectSpread({}, item), {}, {
64
- isChecked: false
65
- }));
66
- sideBar.facetValues = updateFacetVals;
52
+ sideBar.facetValues.forEach(item => {
53
+ item.isChecked = false;
54
+ });
67
55
  }
68
56
  /**
69
57
  * set default value for slider - on clear all filter
@@ -108,7 +96,6 @@ const FacetFilterController = props => {
108
96
  * Construct filter object
109
97
  * 1. add facet values to facets
110
98
  * 2. add 'name' key to each facet value
111
- * 3. add '
112
99
  */
113
100
  const addFacetValues = facets => {
114
101
  const updateFacets = [];
@@ -118,13 +105,19 @@ const FacetFilterController = props => {
118
105
  facetValues: []
119
106
  });
120
107
  const {
108
+ field,
121
109
  ApiLowerBoundName,
122
110
  ApiUpperBoundName,
123
111
  apiForFiltering
124
112
  } = updateFacet;
125
113
  if (data[apiForFiltering]) {
126
114
  if (Array.isArray(data[apiForFiltering])) {
127
- updateFacet.facetValues = data[apiForFiltering];
115
+ const updateField = data[apiForFiltering].map(item => {
116
+ const addField = _objectSpread({}, item);
117
+ addField.name = item[field];
118
+ return addField;
119
+ });
120
+ updateFacet.facetValues = updateField;
128
121
  }
129
122
  /**
130
123
  * add object to facet values
@@ -147,7 +140,7 @@ const FacetFilterController = props => {
147
140
  * Generate facet sections state
148
141
  *
149
142
  */
150
- const displayFacets = facetsConfig.filter(facet => facet.show);
143
+ const displayFacets = facetsConfig.filter(facet => facet.show).slice(0, 16);
151
144
  const facetStates = addFacetValues(displayFacets);
152
145
  const updateState = updateFacetState(facetStates);
153
146
  const facetSections = arrangeBySections(updateState);
@@ -25,7 +25,7 @@ var _default = () => ({
25
25
  sortGroupItem: {
26
26
  cursor: 'pointer',
27
27
  fontFamily: 'Nunito',
28
- fontSize: '10px',
28
+ fontSize: '11px',
29
29
  marginRight: '32px'
30
30
  }
31
31
  });
@@ -9,6 +9,7 @@ var _core = require("@material-ui/core");
9
9
  var _FacetFilterStyle = _interopRequireDefault(require("./FacetFilterStyle"));
10
10
  var _FacetSectionView = _interopRequireDefault(require("./components/section/FacetSectionView"));
11
11
  var _ReduxFacetView = _interopRequireDefault(require("./components/facet/ReduxFacetView"));
12
+ var _FilterItems = _interopRequireDefault(require("./components/inputs/FilterItems"));
12
13
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
14
  /* eslint-disable arrow-body-style */
14
15
  /* eslint-disable padded-blocks */
@@ -28,7 +29,11 @@ const BentoFacetFilter = _ref => {
28
29
  }, section.items.map(facet => /*#__PURE__*/_react.default.createElement(_ReduxFacetView.default, {
29
30
  facet: facet,
30
31
  CustomView: CustomFacetView
31
- }))))));
32
+ }, /*#__PURE__*/_react.default.createElement(_core.List, {
33
+ className: "List_".concat(facet.label)
34
+ }, /*#__PURE__*/_react.default.createElement(_FilterItems.default, {
35
+ facet: facet
36
+ }))))))));
32
37
  };
33
38
  var _default = (0, _core.withStyles)(_FacetFilterStyle.default)(BentoFacetFilter);
34
39
  exports.default = _default;
@@ -46,7 +46,7 @@ var _default = () => ({
46
46
  sortGroupItem: {
47
47
  cursor: 'pointer',
48
48
  fontFamily: 'Nunito',
49
- fontSize: '10px',
49
+ fontSize: '11px',
50
50
  marginRight: '32px'
51
51
  },
52
52
  NonSortGroup: {
@@ -57,25 +57,25 @@ var _default = () => ({
57
57
  },
58
58
  NonSortGroupItem: {
59
59
  fontFamily: 'Nunito',
60
- fontSize: '10px',
60
+ fontSize: '11px',
61
61
  marginRight: '32px'
62
62
  },
63
63
  sortGroupItemCounts: {
64
64
  cursor: 'pointer',
65
65
  fontFamily: 'Nunito',
66
- fontSize: '10px',
66
+ fontSize: '11px',
67
67
  float: 'right',
68
68
  marginRight: '10px',
69
69
  marginTop: '5px'
70
70
  },
71
71
  highlight: {
72
- color: '#b2c6d6'
72
+ color: '#537A9D'
73
73
  },
74
74
  showMore: {
75
75
  textAlign: 'right',
76
76
  paddingRight: '5px',
77
77
  cursor: 'pointer',
78
- fontSize: '10px',
78
+ fontSize: '11px',
79
79
  width: '100%'
80
80
  }
81
81
  });
@@ -35,8 +35,8 @@ const FacetView = _ref => {
35
35
  const onExpandFacet = () => setExpand(!expand);
36
36
 
37
37
  /**
38
- * expand section incase of active local search
39
- */
38
+ * Expand section incase of active local search
39
+ */
40
40
  (0, _react.useEffect)(() => {
41
41
  if (autoComplete && autoComplete.length > 0 || upload && upload.length > 0) {
42
42
  setExpand(true);
@@ -82,11 +82,11 @@ const FacetView = _ref => {
82
82
  className: (0, _clsx.default)(classes.subSectionSummaryText, {
83
83
  ["activeFacet".concat(facet.section)]: isActiveFacet
84
84
  })
85
- }, facet.label)), (facet.type === _Types.InputTypes.SLIDER || facetValues.length === 0) && /*#__PURE__*/_react.default.createElement("div", {
85
+ }, facet.label)), facetValues.length === 0 && /*#__PURE__*/_react.default.createElement("div", {
86
86
  className: classes.NonSortGroup
87
87
  }, /*#__PURE__*/_react.default.createElement("span", {
88
88
  className: classes.NonSortGroupItem
89
- }, "No data for this field")), (facet.type === _Types.InputTypes.SLIDER || facetValues.length > 0) && /*#__PURE__*/_react.default.createElement("div", {
89
+ }, "No data for this field")), facetValues.length > 0 && /*#__PURE__*/_react.default.createElement("div", {
90
90
  className: classes.sortGroup
91
91
  }, /*#__PURE__*/_react.default.createElement("span", {
92
92
  className: classes.sortGroupIcon
@@ -8,6 +8,12 @@ var _default = () => ({
8
8
  listItemGutters: {
9
9
  padding: '10px 20px 10px 0px'
10
10
  },
11
+ listItemRoot: {
12
+ cursor: 'pointer',
13
+ '&:hover': {
14
+ backgroundColor: 'rgba(0, 0, 0, 0.04)'
15
+ }
16
+ },
11
17
  checkboxRoot: {
12
18
  marginLeft: '5px',
13
19
  height: 12
@@ -4,13 +4,16 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
- var _react = _interopRequireDefault(require("react"));
7
+ var _react = _interopRequireWildcard(require("react"));
8
8
  var _styles = require("@material-ui/core/styles");
9
9
  var _core = require("@material-ui/core");
10
+ var _TouchRipple = _interopRequireDefault(require("@material-ui/core/ButtonBase/TouchRipple"));
10
11
  var _clsx = _interopRequireDefault(require("clsx"));
11
12
  var _icons = require("@material-ui/icons");
12
13
  var _CheckboxStyle = _interopRequireDefault(require("./CheckboxStyle"));
13
14
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15
+ 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); }
16
+ 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; }
14
17
  /* eslint-disable no-unused-vars */
15
18
  /* eslint-disable no-unused-vars */
16
19
  /* eslint-disable react/jsx-wrap-multilines */
@@ -29,23 +32,31 @@ const CheckBoxView = _ref => {
29
32
  facet
30
33
  } = _ref;
31
34
  const {
35
+ name,
36
+ subjects,
32
37
  isChecked = false,
33
38
  index,
34
39
  section,
35
- tooltip
40
+ tooltip,
41
+ label
36
42
  } = checkboxItem;
37
- const {
38
- field = 'group',
39
- count = 'subjects',
40
- customCount = text => "(".concat(text, ")"),
41
- defaultValue = ''
42
- } = facet;
43
43
  const indexType = index % 2 === 0 ? 'Even' : 'Odd';
44
- const checkedSection = "".concat(section).toLowerCase().replace(/\ /g, '_');
45
- const name = checkboxItem[field] || defaultValue || 'N/A';
44
+ const checkedSection = "".concat(section).toLowerCase().replace(' ', '_');
45
+ const checkboxId = "checkbox_".concat(facet.label, "_").concat(name);
46
+ const rippleRef = (0, _react.useRef)(null);
47
+ const handleRippleStart = event => {
48
+ if (rippleRef.current) {
49
+ rippleRef.current.start(event);
50
+ }
51
+ };
52
+ const handleRippleStop = event => {
53
+ if (rippleRef.current) {
54
+ rippleRef.current.stop(event);
55
+ }
56
+ };
46
57
  const handleToggle = () => {
47
58
  const toggleCheckBoxItem = {
48
- name: checkboxItem[field],
59
+ name: name,
49
60
  datafield: datafield,
50
61
  isChecked: !isChecked
51
62
  };
@@ -57,29 +68,39 @@ const CheckBoxView = _ref => {
57
68
  ["".concat(checkedSection, "NameUnChecked")]: !isChecked,
58
69
  ["".concat(checkedSection, "NameChecked")]: isChecked
59
70
  })
60
- }, /*#__PURE__*/_react.default.createElement(_core.Typography, {
71
+ }, label ? /*#__PURE__*/_react.default.createElement(_core.Typography, {
72
+ className: classes.checkboxLabel
73
+ }, label) : /*#__PURE__*/_react.default.createElement(_core.Typography, {
61
74
  className: classes.checkboxName
62
75
  }, name));
63
76
  return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_core.ListItem, {
77
+ component: "div",
64
78
  width: 1,
65
- button: true,
66
79
  alignItems: "flex-start",
67
80
  onClick: handleToggle,
81
+ onMouseDown: handleRippleStart,
82
+ onMouseUp: handleRippleStop,
83
+ onMouseLeave: handleRippleStop,
68
84
  classes: {
69
- gutters: classes.listItemGutters
85
+ gutters: classes.listItemGutters,
86
+ root: classes.listItemRoot
70
87
  },
71
88
  className: (0, _clsx.default)({
72
89
  ["".concat(checkedSection, "Checked").concat(indexType)]: isChecked
73
90
  })
74
91
  }, /*#__PURE__*/_react.default.createElement(_core.Checkbox, {
75
- id: "checkbox_".concat(facet.label, "_").concat(name),
92
+ id: checkboxId,
76
93
  icon: /*#__PURE__*/_react.default.createElement(_icons.CheckBoxOutlineBlank, {
77
94
  style: {
78
95
  fontSize: 18
79
96
  },
80
97
  className: checkedSection
81
98
  }),
82
- onClick: handleToggle,
99
+ inputProps: {
100
+ 'aria-label': 'checkbox',
101
+ tabIndex: -1,
102
+ 'aria-hidden': true
103
+ },
83
104
  checked: isChecked,
84
105
  checkedIcon: /*#__PURE__*/_react.default.createElement(_icons.CheckBox, {
85
106
  style: {
@@ -92,22 +113,25 @@ const CheckBoxView = _ref => {
92
113
  classes: {
93
114
  root: classes.checkboxRoot
94
115
  },
95
- inputProps: {
96
- 'aria-label': 'Select'
116
+ style: {
117
+ pointerEvents: 'none'
97
118
  }
98
119
  }), tooltip ? /*#__PURE__*/_react.default.createElement(_core.Tooltip, {
99
120
  id: datafield,
100
121
  title: tooltip
101
122
  }, /*#__PURE__*/_react.default.createElement("div", {
102
123
  className: datafield
103
- }, name)) : /*#__PURE__*/_react.default.createElement(LabelComponent, null), /*#__PURE__*/_react.default.createElement(_core.ListItemText, {
124
+ }, /*#__PURE__*/_react.default.createElement(LabelComponent, null))) : /*#__PURE__*/_react.default.createElement(LabelComponent, null), /*#__PURE__*/_react.default.createElement(_core.ListItemText, {
104
125
  className: "".concat(checkedSection, "_md_space")
105
126
  }), /*#__PURE__*/_react.default.createElement(_core.Typography, {
106
127
  className: (0, _clsx.default)("".concat(checkedSection, "Subjects"), {
107
128
  ["".concat(checkedSection, "SubjectUnChecked")]: !isChecked,
108
129
  ["".concat(checkedSection, "SubjectChecked")]: isChecked
109
130
  })
110
- }, customCount(checkboxItem[count] || 0))), /*#__PURE__*/_react.default.createElement(_core.Divider, {
131
+ }, "(".concat(subjects, ")")), /*#__PURE__*/_react.default.createElement(_TouchRipple.default, {
132
+ ref: rippleRef,
133
+ center: true
134
+ })), /*#__PURE__*/_react.default.createElement(_core.Divider, {
111
135
  style: {
112
136
  backgroundColor: isChecked ? '#FFFFFF' : '#b1b1b1',
113
137
  margin: '0px',
@@ -29,9 +29,7 @@ const SliderView = _ref => {
29
29
  maxUpperBound,
30
30
  quantifier,
31
31
  datafield,
32
- facetValues,
33
- CustomLowerUpperBound,
34
- CustomSliderValue
32
+ facetValues
35
33
  } = facet;
36
34
  const lowerBoundValue = facetValues[0];
37
35
  const upperBoundValue = facetValues[1];
@@ -104,24 +102,13 @@ const SliderView = _ref => {
104
102
  thumb: isValid() ? classes.thumb : classes.invalidThumb,
105
103
  track: isValid() ? classes.track : classes.invalidTrack
106
104
  }
107
- })), typeof CustomLowerUpperBound === 'function' ? CustomLowerUpperBound({
108
- minLowerBound,
109
- maxUpperBound,
110
- classes
111
- }) : /*#__PURE__*/_react.default.createElement(_core.Box, {
105
+ })), /*#__PURE__*/_react.default.createElement(_core.Box, {
112
106
  className: classes.lowerUpperBound
113
107
  }, /*#__PURE__*/_react.default.createElement(_core.Typography, {
114
108
  className: classes.lowerBound
115
109
  }, minLowerBound), /*#__PURE__*/_react.default.createElement(_core.Typography, {
116
110
  className: classes.upperBound
117
- }, maxUpperBound))), typeof CustomSliderValue === 'function' ? CustomSliderValue({
118
- sliderValue,
119
- minLowerBound,
120
- maxUpperBound,
121
- isValid,
122
- quantifier,
123
- classes
124
- }) : (sliderValue[0] > minLowerBound || sliderValue[1] < maxUpperBound) && /*#__PURE__*/_react.default.createElement(_core.Typography, {
111
+ }, maxUpperBound))), (sliderValue[0] > minLowerBound || sliderValue[1] < maxUpperBound) && /*#__PURE__*/_react.default.createElement(_core.Typography, {
125
112
  className: isValid() ? classes.sliderText : classes.invalidSliderText
126
113
  }, sliderValue[0], ' - ', sliderValue[1], "\xA0", quantifier));
127
114
  };
@@ -46,30 +46,28 @@ const sortBySection = _ref => {
46
46
  let {
47
47
  facetValues,
48
48
  sort_type,
49
- sortBy,
50
- field,
51
- count = 'subjects'
49
+ sortBy
52
50
  } = _ref;
53
51
  const sortfacetValues = [...facetValues];
54
52
  if (!sortfacetValues) {
55
53
  return facetValues;
56
54
  }
57
55
  if (sortBy === sortType.NUMERIC) {
58
- sortfacetValues.sort((a, b) => b[count] - a[count]);
56
+ sortfacetValues.sort((a, b) => b.subjects - a.subjects);
59
57
  } else {
60
- sortfacetValues.sort((a, b) => lowerCaseString(a[field]) > lowerCaseString(b[field]) || -(lowerCaseString(a[field]) < lowerCaseString(b[field])));
58
+ sortfacetValues.sort((a, b) => lowerCaseString(a.name) > lowerCaseString(b.name) || -(lowerCaseString(a.name) < lowerCaseString(b.name)));
61
59
  }
62
60
  if (sort_type === sortType.CUSTOM_NUMBER && sortBy !== sortType.NUMERIC) {
63
61
  sortfacetValues.sort((a, b) => {
64
- const aNumbs = getNumberArray(a[field]);
65
- const bNumbs = getNumberArray(b[field]);
62
+ const aNumbs = getNumberArray(a.name);
63
+ const bNumbs = getNumberArray(b.name);
66
64
  const aNumb = Number(aNumbs[0]);
67
65
  const bNumb = Number(bNumbs[0]);
68
66
  return aNumbs.length === bNumbs.length ? aNumb > bNumb : -(aNumb <= bNumb);
69
67
  });
70
68
  }
71
69
  if (sort_type === sortType.RANGE && sortBy !== sortType.NUMERIC) {
72
- sortfacetValues.sort((a, b) => startIndex(a[field]) > startIndex(b[field]) || -(startIndex(a[field]) < startIndex(b[field])));
70
+ sortfacetValues.sort((a, b) => startIndex(a.name) > startIndex(b.name) || -(startIndex(a.name) < startIndex(b.name)));
73
71
  }
74
72
  /**
75
73
  * Display checked item always on top
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bento-core/facet-filter",
3
- "version": "1.0.1-popsci.1",
3
+ "version": "1.0.1-popsci.3",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
@@ -24,5 +24,6 @@
24
24
  "react-redux": "^7.2.1"
25
25
  },
26
26
  "author": "CTOS Bento Team",
27
- "license": "ISC"
27
+ "license": "ISC",
28
+ "gitHead": "01a57a616fd8d9cc6ffca70907b17b16a1dc369f"
28
29
  }
@@ -25,7 +25,6 @@ const FacetFilterController = (props) => {
25
25
  data,
26
26
  facetsConfig,
27
27
  facetSectionConfig,
28
- tooltipText = {},
29
28
  } = props;
30
29
 
31
30
  const updateFacetState = (filterSections) => {
@@ -34,15 +33,9 @@ const FacetFilterController = (props) => {
34
33
  for (const [key, value] of Object.entries(filterState)) {
35
34
  updateSections.forEach((sideBar) => {
36
35
  if (sideBar.type === InputTypes.CHECKBOX && sideBar.datafield === key) {
37
- const { facetValues = [] } = sideBar;
38
- const updateFacetVals = facetValues.map((item) => {
39
- const facetVal = item[sideBar.field];
40
- return {
41
- ...item,
42
- isChecked: value[facetVal] ? value[facetVal] : false,
43
- };
36
+ sideBar.facetValues.forEach((item) => {
37
+ item.isChecked = value[item.name] ? value[item.name] : false;
44
38
  });
45
- sideBar.facetValues = updateFacetVals;
46
39
  }
47
40
  if (sideBar.type === InputTypes.SLIDER && sideBar.datafield === key) {
48
41
  sideBar.facetValues = value;
@@ -52,12 +45,9 @@ const FacetFilterController = (props) => {
52
45
  } else {
53
46
  updateSections.forEach((sideBar) => {
54
47
  if (sideBar.type === InputTypes.CHECKBOX) {
55
- const { facetValues = [] } = sideBar;
56
- const updateFacetVals = facetValues.map((item) => ({
57
- ...item,
58
- isChecked: false,
59
- }));
60
- sideBar.facetValues = updateFacetVals;
48
+ sideBar.facetValues.forEach((item) => {
49
+ item.isChecked = false;
50
+ });
61
51
  }
62
52
  /**
63
53
  * set default value for slider - on clear all filter
@@ -93,7 +83,6 @@ const FacetFilterController = (props) => {
93
83
  * Construct filter object
94
84
  * 1. add facet values to facets
95
85
  * 2. add 'name' key to each facet value
96
- * 3. add '
97
86
  */
98
87
  const addFacetValues = (facets) => {
99
88
  const updateFacets = [];
@@ -101,13 +90,19 @@ const FacetFilterController = (props) => {
101
90
  facets.forEach((facet) => {
102
91
  const updateFacet = { ...facet, facetValues: [] };
103
92
  const {
93
+ field,
104
94
  ApiLowerBoundName,
105
95
  ApiUpperBoundName,
106
96
  apiForFiltering,
107
97
  } = updateFacet;
108
98
  if (data[apiForFiltering]) {
109
99
  if (Array.isArray(data[apiForFiltering])) {
110
- updateFacet.facetValues = data[apiForFiltering];
100
+ const updateField = data[apiForFiltering].map((item) => {
101
+ const addField = { ...item };
102
+ addField.name = item[field];
103
+ return addField;
104
+ });
105
+ updateFacet.facetValues = updateField;
111
106
  }
112
107
  /**
113
108
  * add object to facet values
@@ -130,7 +125,7 @@ const FacetFilterController = (props) => {
130
125
  * Generate facet sections state
131
126
  *
132
127
  */
133
- const displayFacets = facetsConfig.filter((facet) => facet.show);
128
+ const displayFacets = facetsConfig.filter((facet) => facet.show).slice(0, 16);
134
129
  const facetStates = addFacetValues(displayFacets);
135
130
  const updateState = updateFacetState(facetStates);
136
131
  const facetSections = arrangeBySections(updateState);
@@ -19,7 +19,7 @@ export default () => ({
19
19
  sortGroupItem: {
20
20
  cursor: 'pointer',
21
21
  fontFamily: 'Nunito',
22
- fontSize: '10px',
22
+ fontSize: '11px',
23
23
  marginRight: '32px',
24
24
  },
25
25
  });
@@ -3,11 +3,13 @@
3
3
  import React from 'react';
4
4
  import {
5
5
  Divider,
6
+ List,
6
7
  withStyles,
7
8
  } from '@material-ui/core';
8
9
  import styles from './FacetFilterStyle';
9
10
  import FacetSectionView from './components/section/FacetSectionView';
10
11
  import FacetView from './components/facet/ReduxFacetView';
12
+ import FilterItems from './components/inputs/FilterItems';
11
13
 
12
14
  const BentoFacetFilter = ({
13
15
  sideBarSections,
@@ -31,7 +33,13 @@ const BentoFacetFilter = ({
31
33
  <FacetView
32
34
  facet={facet}
33
35
  CustomView={CustomFacetView}
34
- />
36
+ >
37
+ <List className={`List_${facet.label}`}>
38
+ <FilterItems
39
+ facet={facet}
40
+ />
41
+ </List>
42
+ </FacetView>
35
43
  ))}
36
44
  </FacetSectionView>
37
45
  </>
@@ -40,7 +40,7 @@ export default () => ({
40
40
  sortGroupItem: {
41
41
  cursor: 'pointer',
42
42
  fontFamily: 'Nunito',
43
- fontSize: '10px',
43
+ fontSize: '11px',
44
44
  marginRight: '32px',
45
45
  },
46
46
  NonSortGroup: {
@@ -51,25 +51,25 @@ export default () => ({
51
51
  },
52
52
  NonSortGroupItem: {
53
53
  fontFamily: 'Nunito',
54
- fontSize: '10px',
54
+ fontSize: '11px',
55
55
  marginRight: '32px',
56
56
  },
57
57
  sortGroupItemCounts: {
58
58
  cursor: 'pointer',
59
59
  fontFamily: 'Nunito',
60
- fontSize: '10px',
60
+ fontSize: '11px',
61
61
  float: 'right',
62
62
  marginRight: '10px',
63
63
  marginTop: '5px',
64
64
  },
65
65
  highlight: {
66
- color: '#b2c6d6',
66
+ color: '#537A9D',
67
67
  },
68
68
  showMore: {
69
69
  textAlign: 'right',
70
70
  paddingRight: '5px',
71
71
  cursor: 'pointer',
72
- fontSize: '10px',
72
+ fontSize: '11px',
73
73
  width: '100%',
74
74
  },
75
75
  });
@@ -1,9 +1,6 @@
1
1
  import React, { useEffect, useState } from 'react';
2
2
  import {
3
- Accordion,
4
- List,
5
- withStyles,
6
- Icon,
3
+ Accordion, List, withStyles, Icon,
7
4
  } from '@material-ui/core';
8
5
  import clsx from 'clsx';
9
6
  import CustomAccordionSummary from '../summary/AccordionSummaryView';
@@ -26,11 +23,13 @@ const FacetView = ({
26
23
  const onExpandFacet = () => setExpand(!expand);
27
24
 
28
25
  /**
29
- * expand section incase of active local search
30
- */
26
+ * Expand section incase of active local search
27
+ */
31
28
  useEffect(() => {
32
- if ((autoComplete && autoComplete.length > 0)
33
- || (upload && upload.length > 0)) {
29
+ if (
30
+ (autoComplete && autoComplete.length > 0)
31
+ || (upload && upload.length > 0)
32
+ ) {
34
33
  setExpand(true);
35
34
  }
36
35
  }, [autoComplete, upload]);
@@ -68,21 +67,20 @@ const FacetView = ({
68
67
  }}
69
68
  id={facet.section}
70
69
  >
71
- { CustomView ? (
70
+ {CustomView ? (
72
71
  <CustomView
73
72
  facet={facet}
74
73
  facetClasses={
75
- isActiveFacet ? `activeFacet${facet.section}`
76
- : `inactiveFacet${facet.section}`
74
+ isActiveFacet
75
+ ? `activeFacet${facet.section}`
76
+ : `inactiveFacet${facet.section}`
77
77
  }
78
78
  />
79
79
  ) : (
80
80
  <CustomAccordionSummary>
81
81
  <div
82
- id={
83
- `filterGroup_ ${facet.datafield}
84
- ${facet.label}`
85
- }
82
+ id={`filterGroup_ ${facet.datafield}
83
+ ${facet.label}`}
86
84
  className={clsx(classes.subSectionSummaryText, {
87
85
  [`activeFacet${facet.section}`]: isActiveFacet,
88
86
  })}
@@ -91,96 +89,60 @@ const FacetView = ({
91
89
  </div>
92
90
  </CustomAccordionSummary>
93
91
  )}
94
- {
95
- (facet.type === InputTypes.SLIDER || facetValues.length === 0)
96
- && (
92
+ {facetValues.length === 0 && (
97
93
  <div className={classes.NonSortGroup}>
98
- <span
99
- className={classes.NonSortGroupItem}
100
- >
94
+ <span className={classes.NonSortGroupItem}>
101
95
  No data for this field
102
96
  </span>
103
97
  </div>
104
- )
105
- }
106
- {
107
- (facet.type === InputTypes.SLIDER || facetValues.length > 0)
108
- && (
98
+ )}
99
+ {facetValues.length > 0 && (
109
100
  <div className={classes.sortGroup}>
110
101
  <span className={classes.sortGroupIcon}>
111
- <Icon
112
- style={{ fontSize: 10 }}
113
- onClick={onClearSection}
114
- >
115
- <img
116
- src={clearIcon}
117
- height={12}
118
- width={12}
119
- alt="clear-icon"
120
- />
102
+ <Icon style={{ fontSize: 10 }} onClick={onClearSection}>
103
+ <img src={clearIcon} height={12} width={12} alt="clear-icon" />
121
104
  </Icon>
122
105
  </span>
123
- { (facet.type === InputTypes.CHECKBOX && facetValues.length > 0)
124
- && (
125
- <>
126
- <span
127
- className={
128
- clsx(classes.sortGroupItem, {
129
- [classes.highlight]: sortBy === sortType.ALPHABET,
130
- })
131
- }
132
- onClick={() => {
133
- onSortFacet(sortType.ALPHABET);
134
- }}
135
- >
136
- Sort alphabetically
137
- </span>
138
- <span
139
- className={
140
- clsx(classes.sortGroupItemCounts, {
141
- [classes.highlight]: sortBy === sortType.NUMERIC,
142
- })
143
- }
144
- onClick={() => {
145
- onSortFacet(sortType.NUMERIC);
146
- }}
147
- >
148
- Sort by count
149
- </span>
150
- </>
151
- )}
106
+ {facet.type === InputTypes.CHECKBOX && facetValues.length > 0 && (
107
+ <>
108
+ <span
109
+ className={clsx(classes.sortGroupItem, {
110
+ [classes.highlight]: sortBy === sortType.ALPHABET,
111
+ })}
112
+ onClick={() => {
113
+ onSortFacet(sortType.ALPHABET);
114
+ }}
115
+ >
116
+ Sort alphabetically
117
+ </span>
118
+ <span
119
+ className={clsx(classes.sortGroupItemCounts, {
120
+ [classes.highlight]: sortBy === sortType.NUMERIC,
121
+ })}
122
+ onClick={() => {
123
+ onSortFacet(sortType.NUMERIC);
124
+ }}
125
+ >
126
+ Sort by count
127
+ </span>
128
+ </>
129
+ )}
152
130
  </div>
153
- )
154
- }
155
- {(expand)
156
- && (
157
- <FilterItems
158
- facet={facet}
159
- sortBy={sortBy}
160
- />
161
- )}
131
+ )}
132
+ {expand && <FilterItems facet={facet} sortBy={sortBy} />}
162
133
  </Accordion>
163
- {
164
- (!expand && type === InputTypes.CHECKBOX && selectedItems.length > 0) && (
165
- <>
166
- <List id="filter_Items">
167
- <FilterItems
168
- facet={displayFacet}
169
- />
170
- </List>
171
- </>
172
- )
173
- }
174
- {
175
- (!expand && selectedItems.length > limitCheckBoxCount) && (
176
- <div
177
- className={classes.showMore}
178
- onClick={onExpandFacet}
179
- >
180
- ...expand to see all selections
181
- </div>
182
- )
183
- }
134
+ {!expand && type === InputTypes.CHECKBOX && selectedItems.length > 0 && (
135
+ <>
136
+ <List id="filter_Items">
137
+ <FilterItems facet={displayFacet} />
138
+ </List>
139
+ </>
140
+ )}
141
+ {!expand && selectedItems.length > limitCheckBoxCount && (
142
+ <div className={classes.showMore} onClick={onExpandFacet}>
143
+ ...expand to see all selections
144
+ </div>
145
+ )}
184
146
  </>
185
147
  );
186
148
  };
@@ -2,6 +2,12 @@ export default () => ({
2
2
  listItemGutters: {
3
3
  padding: '10px 20px 10px 0px',
4
4
  },
5
+ listItemRoot: {
6
+ cursor: 'pointer',
7
+ '&:hover': {
8
+ backgroundColor: 'rgba(0, 0, 0, 0.04)',
9
+ },
10
+ },
5
11
  checkboxRoot: {
6
12
  marginLeft: '5px',
7
13
  height: 12,
@@ -7,7 +7,7 @@
7
7
  /* eslint-disable react/jsx-one-expression-per-line */
8
8
  /* eslint-disable no-useless-escape */
9
9
 
10
- import React from 'react';
10
+ import React, { useRef } from 'react';
11
11
  import { withStyles } from '@material-ui/core/styles';
12
12
  import {
13
13
  Checkbox,
@@ -17,7 +17,9 @@ import {
17
17
  Tooltip,
18
18
  Box,
19
19
  Typography,
20
+ ButtonBase,
20
21
  } from '@material-ui/core';
22
+ import TouchRipple from '@material-ui/core/ButtonBase/TouchRipple';
21
23
  import clsx from 'clsx';
22
24
  import {
23
25
  CheckBox as CheckBoxIcon, CheckBoxOutlineBlank as CheckBoxBlankIcon,
@@ -32,26 +34,34 @@ const CheckBoxView = ({
32
34
  facet,
33
35
  }) => {
34
36
  const {
37
+ name,
38
+ subjects,
35
39
  isChecked = false,
36
40
  index,
37
41
  section,
38
42
  tooltip,
43
+ label,
39
44
  } = checkboxItem;
40
- const {
41
- field = 'group',
42
- count = 'subjects',
43
- customCount = (text) => `(${text})`,
44
- defaultValue = '',
45
- } = facet;
46
-
47
45
  const indexType = index % 2 === 0 ? 'Even' : 'Odd';
48
- const checkedSection = `${section}`.toLowerCase().replace(/\ /g, '_');
46
+ const checkedSection = `${section}`.toLowerCase().replace(' ', '_');
47
+ const checkboxId = `checkbox_${facet.label}_${name}`;
48
+ const rippleRef = useRef(null);
49
49
 
50
- const name = checkboxItem[field] || defaultValue || 'N/A';
50
+ const handleRippleStart = (event) => {
51
+ if (rippleRef.current) {
52
+ rippleRef.current.start(event);
53
+ }
54
+ };
55
+
56
+ const handleRippleStop = (event) => {
57
+ if (rippleRef.current) {
58
+ rippleRef.current.stop(event);
59
+ }
60
+ };
51
61
 
52
62
  const handleToggle = () => {
53
63
  const toggleCheckBoxItem = {
54
- name: checkboxItem[field],
64
+ name: name,
55
65
  datafield: datafield,
56
66
  isChecked: !isChecked,
57
67
  };
@@ -66,71 +76,71 @@ const CheckBoxView = ({
66
76
  [`${checkedSection}NameChecked`]: isChecked,
67
77
  })}
68
78
  >
69
- <Typography className={classes.checkboxName}>
70
- {name}
71
- </Typography>
79
+ {label ? (
80
+ <Typography className={classes.checkboxLabel}>{label}</Typography>
81
+ ) : (<Typography className={classes.checkboxName}>{name}</Typography>)}
72
82
  </Box>
73
83
  );
74
84
 
75
85
  return (
76
86
  <>
77
- <ListItem
78
- width={1}
79
- button
80
- alignItems="flex-start"
81
- onClick={handleToggle}
82
- classes={{ gutters: classes.listItemGutters }}
83
- className={clsx({ [`${checkedSection}Checked${indexType}`]: isChecked })}
84
- >
85
- <Checkbox
86
- id={`checkbox_${facet.label}_${name}`}
87
- icon={
88
- <CheckBoxBlankIcon
89
- style={{ fontSize: 18 }}
90
- className={checkedSection}
91
- />
92
- }
87
+ <ListItem
88
+ component="div"
89
+ width={1}
90
+ alignItems="flex-start"
93
91
  onClick={handleToggle}
94
- checked={isChecked}
95
- checkedIcon={(
96
- <CheckBoxIcon
97
- style={{
98
- fontSize: 18,
99
- }}
100
- className={`${checkedSection}CheckedIcon`}
101
- />
92
+ onMouseDown={handleRippleStart}
93
+ onMouseUp={handleRippleStop}
94
+ onMouseLeave={handleRippleStop}
95
+ classes={{ gutters: classes.listItemGutters, root: classes.listItemRoot }}
96
+ className={clsx({ [`${checkedSection}Checked${indexType}`]: isChecked })}
97
+ >
98
+ <Checkbox
99
+ id={checkboxId}
100
+ icon={(<CheckBoxBlankIcon style={{ fontSize: 18 }} className={checkedSection} />
101
+ )}
102
+ inputProps={{ 'aria-label': 'checkbox', tabIndex: -1, 'aria-hidden': true }}
103
+ checked={isChecked}
104
+ checkedIcon={(
105
+ <CheckBoxIcon
106
+ style={{
107
+ fontSize: 18,
108
+ }}
109
+ className={`${checkedSection}CheckedIcon`}
110
+ />
111
+ )}
112
+ disableRipple
113
+ color="secondary"
114
+ classes={{ root: classes.checkboxRoot }}
115
+ style={{ pointerEvents: 'none' }}
116
+ />
117
+ { tooltip ? (
118
+ <Tooltip id={datafield} title={tooltip}>
119
+ <div className={datafield}>
120
+ <LabelComponent />
121
+ </div>
122
+ </Tooltip>
123
+ ) : (
124
+ <LabelComponent />
102
125
  )}
103
- disableRipple
104
- color="secondary"
105
- classes={{ root: classes.checkboxRoot }}
106
- inputProps={{ 'aria-label': 'Select' }}
126
+ <ListItemText className={`${checkedSection}_md_space`} />
127
+ <Typography
128
+ className={clsx(`${checkedSection}Subjects`, {
129
+ [`${checkedSection}SubjectUnChecked`]: !isChecked,
130
+ [`${checkedSection}SubjectChecked`]: isChecked,
131
+ })}
132
+ >
133
+ {`(${subjects})`}
134
+ </Typography>
135
+ <TouchRipple ref={rippleRef} center />
136
+ </ListItem>
137
+ <Divider
138
+ style={{
139
+ backgroundColor: isChecked ? '#FFFFFF' : '#b1b1b1',
140
+ margin: '0px',
141
+ height: isChecked ? '2px' : '1px',
142
+ }}
107
143
  />
108
- { tooltip ? (
109
- <Tooltip id={datafield} title={tooltip}>
110
- <div className={datafield}>
111
- {name}
112
- </div>
113
- </Tooltip>
114
- ) : (
115
- <LabelComponent />
116
- )}
117
- <ListItemText className={`${checkedSection}_md_space`} />
118
- <Typography
119
- className={clsx(`${checkedSection}Subjects`, {
120
- [`${checkedSection}SubjectUnChecked`]: !isChecked,
121
- [`${checkedSection}SubjectChecked`]: isChecked,
122
- })}
123
- >
124
- {customCount(checkboxItem[count] || 0)}
125
- </Typography>
126
- </ListItem>
127
- <Divider
128
- style={{
129
- backgroundColor: isChecked ? '#FFFFFF' : '#b1b1b1',
130
- margin: '0px',
131
- height: isChecked ? '2px' : '1px',
132
- }}
133
- />
134
144
  </>
135
145
  );
136
146
  };
@@ -14,15 +14,7 @@ const SliderView = ({
14
14
  onSliderToggle,
15
15
  filterState,
16
16
  }) => {
17
- const {
18
- minLowerBound,
19
- maxUpperBound,
20
- quantifier,
21
- datafield,
22
- facetValues,
23
- CustomLowerUpperBound,
24
- CustomSliderValue,
25
- } = facet;
17
+ const { minLowerBound, maxUpperBound, quantifier, datafield, facetValues } = facet;
26
18
  const lowerBoundValue = facetValues[0];
27
19
  const upperBoundValue = facetValues[1];
28
20
 
@@ -107,26 +99,24 @@ const SliderView = ({
107
99
  }}
108
100
  />
109
101
  </div>
110
- {typeof CustomLowerUpperBound === 'function' ? (
111
- CustomLowerUpperBound({ minLowerBound, maxUpperBound, classes })
112
- ) : (
113
- <Box className={classes.lowerUpperBound}>
114
- <Typography className={classes.lowerBound}>
115
- {minLowerBound}
116
- </Typography>
117
- <Typography className={classes.upperBound}>
118
- {maxUpperBound}
119
- </Typography>
120
- </Box>
121
- )}
102
+ <Box className={classes.lowerUpperBound}>
103
+ <Typography className={classes.lowerBound}>
104
+ {minLowerBound}
105
+ </Typography>
106
+ <Typography className={classes.upperBound}>
107
+ {maxUpperBound}
108
+ </Typography>
109
+ </Box>
122
110
  </div>
123
111
  {/* Change to red if invalid range */}
124
- {typeof CustomSliderValue === 'function' ? (
125
- CustomSliderValue({
126
- sliderValue, minLowerBound, maxUpperBound, isValid, quantifier, classes })
127
- ) : (
128
- (sliderValue[0] > minLowerBound || sliderValue[1] < maxUpperBound) && (
129
- <Typography className={isValid() ? classes.sliderText : classes.invalidSliderText}>
112
+ {
113
+ (sliderValue[0] > minLowerBound || sliderValue[1] < maxUpperBound)
114
+ && (
115
+ <Typography
116
+ className={isValid()
117
+ ? classes.sliderText
118
+ : classes.invalidSliderText}
119
+ >
130
120
  {sliderValue[0]}
131
121
  {' - '}
132
122
  {sliderValue[1]}
@@ -134,7 +124,7 @@ const SliderView = ({
134
124
  {quantifier}
135
125
  </Typography>
136
126
  )
137
- )}
127
+ }
138
128
  </>
139
129
  );
140
130
  };
package/src/utils/Sort.js CHANGED
@@ -37,28 +37,22 @@ export const getNumberArray = (range) => {
37
37
  * @param {array} checkboxData
38
38
  * @return {array}
39
39
  */
40
- export const sortBySection = ({
41
- facetValues,
42
- sort_type,
43
- sortBy,
44
- field,
45
- count = 'subjects',
46
- }) => {
40
+ export const sortBySection = ({ facetValues, sort_type, sortBy }) => {
47
41
  const sortfacetValues = [...facetValues];
48
42
  if (!sortfacetValues) {
49
43
  return facetValues;
50
44
  }
51
45
  if (sortBy === sortType.NUMERIC) {
52
- sortfacetValues.sort((a, b) => b[count] - a[count]);
46
+ sortfacetValues.sort((a, b) => b.subjects - a.subjects);
53
47
  } else {
54
- sortfacetValues.sort(((a, b) => (lowerCaseString(a[field]) > lowerCaseString(b[field])
55
- || -(lowerCaseString(a[field]) < lowerCaseString(b[field])))));
48
+ sortfacetValues.sort(((a, b) => (lowerCaseString(a.name) > lowerCaseString(b.name)
49
+ || -(lowerCaseString(a.name) < lowerCaseString(b.name)))));
56
50
  }
57
51
 
58
52
  if (sort_type === sortType.CUSTOM_NUMBER && sortBy !== sortType.NUMERIC) {
59
53
  sortfacetValues.sort((a, b) => {
60
- const aNumbs = getNumberArray(a[field]);
61
- const bNumbs = getNumberArray(b[field]);
54
+ const aNumbs = getNumberArray(a.name);
55
+ const bNumbs = getNumberArray(b.name);
62
56
  const aNumb = Number(aNumbs[0]);
63
57
  const bNumb = Number(bNumbs[0]);
64
58
  return (aNumbs.length === bNumbs.length) ? aNumb > bNumb : -(aNumb <= bNumb);
@@ -66,8 +60,8 @@ export const sortBySection = ({
66
60
  }
67
61
 
68
62
  if (sort_type === sortType.RANGE && sortBy !== sortType.NUMERIC) {
69
- sortfacetValues.sort(((a, b) => (startIndex(a[field]) > startIndex(b[field])
70
- || -(startIndex(a[field]) < startIndex(b[field])))));
63
+ sortfacetValues.sort(((a, b) => (startIndex(a.name) > startIndex(b.name)
64
+ || -(startIndex(a.name) < startIndex(b.name)))));
71
65
  }
72
66
  /**
73
67
  * Display checked item always on top