@bento-core/facet-filter 1.0.1-icdc.2 → 1.0.1-icdc.4

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.
@@ -17,7 +17,8 @@ const BentoFacetFilter = _ref => {
17
17
  let {
18
18
  sideBarSections,
19
19
  CustomFacetSection,
20
- CustomFacetView
20
+ CustomFacetView,
21
+ enableClearSection
21
22
  } = _ref;
22
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, {
23
24
  variant: "middle",
@@ -27,7 +28,8 @@ const BentoFacetFilter = _ref => {
27
28
  CustomSection: CustomFacetSection
28
29
  }, section.items.map(facet => /*#__PURE__*/_react.default.createElement(_ReduxFacetView.default, {
29
30
  facet: facet,
30
- CustomView: CustomFacetView
31
+ CustomView: CustomFacetView,
32
+ enableClearSection: enableClearSection
31
33
  }))))));
32
34
  };
33
35
  var _default = (0, _core.withStyles)(_FacetFilterStyle.default)(BentoFacetFilter);
@@ -20,6 +20,13 @@ var _default = () => ({
20
20
  position: 'initial'
21
21
  }
22
22
  },
23
+ subSectionSummaryTextWrapper: {
24
+ display: 'flex',
25
+ alignItems: 'center',
26
+ justifyContent: 'space-between',
27
+ width: '100%',
28
+ paddingRight: '15px'
29
+ },
23
30
  subSectionSummaryText: {
24
31
  marginLeft: '10px',
25
32
  lineHeight: 0,
@@ -7,6 +7,8 @@ exports.default = void 0;
7
7
  var _react = _interopRequireWildcard(require("react"));
8
8
  var _core = require("@material-ui/core");
9
9
  var _clsx = _interopRequireDefault(require("clsx"));
10
+ var _Refresh = _interopRequireDefault(require("@material-ui/icons/Refresh"));
11
+ var _IconButton = _interopRequireDefault(require("@material-ui/core/IconButton"));
10
12
  var _AccordionSummaryView = _interopRequireDefault(require("../summary/AccordionSummaryView"));
11
13
  var _Types = require("../inputs/Types");
12
14
  var _FacetStyle = _interopRequireDefault(require("./FacetStyle"));
@@ -25,6 +27,7 @@ const FacetView = _ref => {
25
27
  let {
26
28
  classes,
27
29
  facet,
30
+ enableClearSection,
28
31
  onClearFacetSection,
29
32
  onClearSliderSection,
30
33
  CustomView,
@@ -35,8 +38,8 @@ const FacetView = _ref => {
35
38
  const onExpandFacet = () => setExpand(!expand);
36
39
 
37
40
  /**
38
- * expand section incase of active local search
39
- */
41
+ * expand section incase of active local search
42
+ */
40
43
  (0, _react.useEffect)(() => {
41
44
  if (autoComplete && autoComplete.length > 0 || upload && upload.length > 0) {
42
45
  setExpand(true);
@@ -75,14 +78,25 @@ const FacetView = _ref => {
75
78
  },
76
79
  id: facet.section
77
80
  }, CustomView ? /*#__PURE__*/_react.default.createElement(CustomView, {
81
+ clearFacetSectionValues: onClearSection,
82
+ hasSelections: selectedItems.length,
78
83
  facet: facet,
79
84
  facetClasses: isActiveFacet ? "activeFacet".concat(facet.section) : "inactiveFacet".concat(facet.section)
80
- }) : /*#__PURE__*/_react.default.createElement(_AccordionSummaryView.default, null, /*#__PURE__*/_react.default.createElement("div", {
85
+ }) : /*#__PURE__*/_react.default.createElement(_AccordionSummaryView.default, null, !enableClearSection ? /*#__PURE__*/_react.default.createElement("div", {
86
+ id: "filterGroup_ ".concat(facet.datafield, "\n ").concat(facet.label),
87
+ className: (0, _clsx.default)(classes.subSectionSummaryText, {
88
+ ["activeFacet".concat(facet.section)]: isActiveFacet
89
+ })
90
+ }, facet.label) : /*#__PURE__*/_react.default.createElement("div", {
91
+ className: classes.subSectionSummaryTextWrapper
92
+ }, /*#__PURE__*/_react.default.createElement("div", {
81
93
  id: "filterGroup_ ".concat(facet.datafield, "\n ").concat(facet.label),
82
94
  className: (0, _clsx.default)(classes.subSectionSummaryText, {
83
95
  ["activeFacet".concat(facet.section)]: isActiveFacet
84
96
  })
85
- }, facet.label)), (facet.type === _Types.InputTypes.SLIDER || facetValues.length === 0) && /*#__PURE__*/_react.default.createElement("div", {
97
+ }, facet.label), selectedItems.length ? /*#__PURE__*/_react.default.createElement(_IconButton.default, {
98
+ onClick: onClearSection
99
+ }, /*#__PURE__*/_react.default.createElement(_Refresh.default, null)) : null)), (facet.type === _Types.InputTypes.SLIDER || facetValues.length === 0) && /*#__PURE__*/_react.default.createElement("div", {
86
100
  className: classes.NonSortGroup
87
101
  }, /*#__PURE__*/_react.default.createElement("span", {
88
102
  className: classes.NonSortGroupItem
@@ -19,6 +19,7 @@ const mapStateToProps = state => {
19
19
  };
20
20
  };
21
21
  const mapDispatchToProps = dispatch => ({
22
+ onToggle: facet => dispatch((0, _Actions.toggleCheckBox)(facet)),
22
23
  onClearFacetSection: facet => {
23
24
  dispatch((0, _Actions.clearFacetSection)(facet));
24
25
  },
@@ -119,7 +119,6 @@ var _default = () => ({
119
119
  },
120
120
  lowerUpperBound: {
121
121
  height: '15px'
122
- },
123
- minMaxInputs: {}
122
+ }
124
123
  });
125
124
  exports.default = _default;
@@ -11,6 +11,7 @@ var _AccordionSummaryStyle = _interopRequireDefault(require("./AccordionSummaryS
11
11
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
12
12
  const Summary = (0, _core.withStyles)({
13
13
  root: {
14
+ width: '307px',
14
15
  marginBottom: -1,
15
16
  minHeight: 48,
16
17
  paddingLeft: 14,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bento-core/facet-filter",
3
- "version": "1.0.1-icdc.2",
3
+ "version": "1.0.1-icdc.4",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
@@ -1,10 +1,7 @@
1
1
  /* eslint-disable arrow-body-style */
2
2
  /* eslint-disable padded-blocks */
3
3
  import React from 'react';
4
- import {
5
- Divider,
6
- withStyles,
7
- } from '@material-ui/core';
4
+ import { Divider, withStyles } from '@material-ui/core';
8
5
  import styles from './FacetFilterStyle';
9
6
  import FacetSectionView from './components/section/FacetSectionView';
10
7
  import FacetView from './components/facet/ReduxFacetView';
@@ -13,30 +10,27 @@ const BentoFacetFilter = ({
13
10
  sideBarSections,
14
11
  CustomFacetSection,
15
12
  CustomFacetView,
13
+ enableClearSection,
16
14
  }) => {
17
15
  return (
18
16
  <>
19
- {
20
- sideBarSections.map((section, index) => (
21
- <>
22
- <Divider
23
- variant="middle"
24
- className={`divider${index}`}
25
- />
26
- <FacetSectionView
27
- section={section}
28
- CustomSection={CustomFacetSection}
29
- >
30
- {section.items.map((facet) => (
31
- <FacetView
32
- facet={facet}
33
- CustomView={CustomFacetView}
34
- />
35
- ))}
36
- </FacetSectionView>
37
- </>
38
- ))
39
- }
17
+ {sideBarSections.map((section, index) => (
18
+ <>
19
+ <Divider variant="middle" className={`divider${index}`} />
20
+ <FacetSectionView
21
+ section={section}
22
+ CustomSection={CustomFacetSection}
23
+ >
24
+ {section.items.map((facet) => (
25
+ <FacetView
26
+ facet={facet}
27
+ CustomView={CustomFacetView}
28
+ enableClearSection={enableClearSection}
29
+ />
30
+ ))}
31
+ </FacetSectionView>
32
+ </>
33
+ ))}
40
34
  </>
41
35
  );
42
36
  };
@@ -14,6 +14,13 @@ export default () => ({
14
14
  position: 'initial',
15
15
  },
16
16
  },
17
+ subSectionSummaryTextWrapper: {
18
+ display: 'flex',
19
+ alignItems: 'center',
20
+ justifyContent: 'space-between',
21
+ width: '100%',
22
+ paddingRight: '15px',
23
+ },
17
24
  subSectionSummaryText: {
18
25
  marginLeft: '10px',
19
26
  lineHeight: 0,
@@ -1,11 +1,10 @@
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';
6
+ import RefreshIcon from '@material-ui/icons/Refresh';
7
+ import IconButton from '@material-ui/core/IconButton';
9
8
  import CustomAccordionSummary from '../summary/AccordionSummaryView';
10
9
  import { InputTypes } from '../inputs/Types';
11
10
  import styles from './FacetStyle';
@@ -16,6 +15,7 @@ import clearIcon from './assets/clearIcon.svg';
16
15
  const FacetView = ({
17
16
  classes,
18
17
  facet,
18
+ enableClearSection,
19
19
  onClearFacetSection,
20
20
  onClearSliderSection,
21
21
  CustomView,
@@ -26,11 +26,13 @@ const FacetView = ({
26
26
  const onExpandFacet = () => setExpand(!expand);
27
27
 
28
28
  /**
29
- * expand section incase of active local search
30
- */
29
+ * expand section incase of active local search
30
+ */
31
31
  useEffect(() => {
32
- if ((autoComplete && autoComplete.length > 0)
33
- || (upload && upload.length > 0)) {
32
+ if (
33
+ (autoComplete && autoComplete.length > 0)
34
+ || (upload && upload.length > 0)
35
+ ) {
34
36
  setExpand(true);
35
37
  }
36
38
  }, [autoComplete, upload]);
@@ -57,6 +59,7 @@ const FacetView = ({
57
59
  displayFacet.facetValues = selectedItems;
58
60
  const isActiveFacet = [...selectedItems].length > 0;
59
61
  const limitCheckBoxCount = facet?.showCheckboxCount || 5;
62
+
60
63
  return (
61
64
  <>
62
65
  <Accordion
@@ -68,119 +71,103 @@ const FacetView = ({
68
71
  }}
69
72
  id={facet.section}
70
73
  >
71
- { CustomView ? (
74
+ {CustomView ? (
72
75
  <CustomView
76
+ clearFacetSectionValues={onClearSection}
77
+ hasSelections={selectedItems.length}
73
78
  facet={facet}
74
79
  facetClasses={
75
- isActiveFacet ? `activeFacet${facet.section}`
76
- : `inactiveFacet${facet.section}`
80
+ isActiveFacet
81
+ ? `activeFacet${facet.section}`
82
+ : `inactiveFacet${facet.section}`
77
83
  }
78
84
  />
79
85
  ) : (
80
86
  <CustomAccordionSummary>
81
- <div
82
- id={
83
- `filterGroup_ ${facet.datafield}
84
- ${facet.label}`
85
- }
86
- className={clsx(classes.subSectionSummaryText, {
87
- [`activeFacet${facet.section}`]: isActiveFacet,
88
- })}
89
- >
90
- {facet.label}
91
- </div>
87
+ {!enableClearSection ? (
88
+ <div
89
+ id={`filterGroup_ ${facet.datafield}
90
+ ${facet.label}`}
91
+ className={clsx(classes.subSectionSummaryText, {
92
+ [`activeFacet${facet.section}`]: isActiveFacet,
93
+ })}
94
+ >
95
+ {facet.label}
96
+ </div>
97
+ ) : (
98
+ <div className={classes.subSectionSummaryTextWrapper}>
99
+ <div
100
+ id={`filterGroup_ ${facet.datafield}
101
+ ${facet.label}`}
102
+ className={clsx(classes.subSectionSummaryText, {
103
+ [`activeFacet${facet.section}`]: isActiveFacet,
104
+ })}
105
+ >
106
+ {facet.label}
107
+ </div>
108
+ {selectedItems.length ? (
109
+ <IconButton onClick={onClearSection}>
110
+ <RefreshIcon />
111
+ </IconButton>
112
+ ) : null}
113
+ </div>
114
+ )}
92
115
  </CustomAccordionSummary>
93
116
  )}
94
- {
95
- (facet.type === InputTypes.SLIDER || facetValues.length === 0)
96
- && (
117
+ {(facet.type === InputTypes.SLIDER || facetValues.length === 0) && (
97
118
  <div className={classes.NonSortGroup}>
98
- <span
99
- className={classes.NonSortGroupItem}
100
- >
119
+ <span className={classes.NonSortGroupItem}>
101
120
  No data for this field
102
121
  </span>
103
122
  </div>
104
- )
105
- }
106
- {
107
- (facet.type === InputTypes.SLIDER || facetValues.length > 0)
108
- && (
123
+ )}
124
+ {(facet.type === InputTypes.SLIDER || facetValues.length > 0) && (
109
125
  <div className={classes.sortGroup}>
110
126
  <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
- />
127
+ <Icon style={{ fontSize: 10 }} onClick={onClearSection}>
128
+ <img src={clearIcon} height={12} width={12} alt="clear-icon" />
121
129
  </Icon>
122
130
  </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
- )}
131
+ {facet.type === InputTypes.CHECKBOX && facetValues.length > 0 && (
132
+ <>
133
+ <span
134
+ className={clsx(classes.sortGroupItem, {
135
+ [classes.highlight]: sortBy === sortType.ALPHABET,
136
+ })}
137
+ onClick={() => {
138
+ onSortFacet(sortType.ALPHABET);
139
+ }}
140
+ >
141
+ Sort alphabetically
142
+ </span>
143
+ <span
144
+ className={clsx(classes.sortGroupItemCounts, {
145
+ [classes.highlight]: sortBy === sortType.NUMERIC,
146
+ })}
147
+ onClick={() => {
148
+ onSortFacet(sortType.NUMERIC);
149
+ }}
150
+ >
151
+ Sort by count
152
+ </span>
153
+ </>
154
+ )}
152
155
  </div>
153
- )
154
- }
155
- {(expand)
156
- && (
157
- <FilterItems
158
- facet={facet}
159
- sortBy={sortBy}
160
- />
161
- )}
156
+ )}
157
+ {expand && <FilterItems facet={facet} sortBy={sortBy} />}
162
158
  </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
- }
159
+ {!expand && type === InputTypes.CHECKBOX && selectedItems.length > 0 && (
160
+ <>
161
+ <List id="filter_Items">
162
+ <FilterItems facet={displayFacet} />
163
+ </List>
164
+ </>
165
+ )}
166
+ {!expand && selectedItems.length > limitCheckBoxCount && (
167
+ <div className={classes.showMore} onClick={onExpandFacet}>
168
+ ...expand to see all selections
169
+ </div>
170
+ )}
184
171
  </>
185
172
  );
186
173
  };
@@ -1,9 +1,13 @@
1
1
  import React from 'react';
2
2
  import { connect } from 'react-redux';
3
- import { clearFacetSection, clearSliderSection } from '../../store/actions/Actions';
3
+ import {
4
+ clearFacetSection,
5
+ clearSliderSection,
6
+ toggleCheckBox,
7
+ } from '../../store/actions/Actions';
4
8
  import FacetView from './FacetView';
5
9
 
6
- const ReduxFacetView = ((props) => <FacetView {...props} />);
10
+ const ReduxFacetView = (props) => <FacetView {...props} />;
7
11
 
8
12
  const mapStateToProps = (state) => ({
9
13
  filterState: state.statusReducer.filterState,
@@ -12,8 +16,13 @@ const mapStateToProps = (state) => ({
12
16
  });
13
17
 
14
18
  const mapDispatchToProps = (dispatch) => ({
15
- onClearFacetSection: (facet) => { dispatch(clearFacetSection(facet)); },
16
- onClearSliderSection: (facet) => { dispatch(clearSliderSection(facet)); },
19
+ onToggle: (facet) => dispatch(toggleCheckBox(facet)),
20
+ onClearFacetSection: (facet) => {
21
+ dispatch(clearFacetSection(facet));
22
+ },
23
+ onClearSliderSection: (facet) => {
24
+ dispatch(clearSliderSection(facet));
25
+ },
17
26
  });
18
27
 
19
28
  export default connect(mapStateToProps, mapDispatchToProps)(ReduxFacetView);
@@ -20,7 +20,8 @@ import {
20
20
  } from '@material-ui/core';
21
21
  import clsx from 'clsx';
22
22
  import {
23
- CheckBox as CheckBoxIcon, CheckBoxOutlineBlank as CheckBoxBlankIcon,
23
+ CheckBox as CheckBoxIcon,
24
+ CheckBoxOutlineBlank as CheckBoxBlankIcon,
24
25
  } from '@material-ui/icons';
25
26
  import styles from './CheckboxStyle';
26
27
 
@@ -31,12 +32,7 @@ const CheckBoxView = ({
31
32
  onToggle,
32
33
  facet,
33
34
  }) => {
34
- const {
35
- isChecked = false,
36
- index,
37
- section,
38
- tooltip,
39
- } = checkboxItem;
35
+ const { isChecked = false, index, section, tooltip } = checkboxItem;
40
36
  const {
41
37
  field = 'group',
42
38
  count = 'subjects',
@@ -65,9 +61,7 @@ const CheckBoxView = ({
65
61
  [`${checkedSection}NameChecked`]: isChecked,
66
62
  })}
67
63
  >
68
- <Typography className={classes.checkboxName}>
69
- {name}
70
- </Typography>
64
+ <Typography className={classes.checkboxName}>{name}</Typography>
71
65
  </Box>
72
66
  );
73
67
 
@@ -79,7 +73,9 @@ const CheckBoxView = ({
79
73
  alignItems="flex-start"
80
74
  onClick={handleToggle}
81
75
  classes={{ gutters: classes.listItemGutters }}
82
- className={clsx({ [`${checkedSection}Checked${indexType}`]: isChecked })}
76
+ className={clsx({
77
+ [`${checkedSection}Checked${indexType}`]: isChecked,
78
+ })}
83
79
  >
84
80
  <Checkbox
85
81
  id={`checkbox_${facet.label}_${name}`}
@@ -91,23 +87,21 @@ const CheckBoxView = ({
91
87
  }
92
88
  onClick={handleToggle}
93
89
  checked={isChecked}
94
- checkedIcon={(
90
+ checkedIcon={
95
91
  <CheckBoxIcon
96
92
  style={{
97
93
  fontSize: 18,
98
94
  }}
99
95
  className={`${checkedSection}CheckedIcon`}
100
96
  />
101
- )}
97
+ }
102
98
  disableRipple
103
99
  color="secondary"
104
100
  classes={{ root: classes.checkboxRoot }}
105
101
  />
106
- { tooltip ? (
102
+ {tooltip ? (
107
103
  <Tooltip id={datafield} title={tooltip}>
108
- <div className={datafield}>
109
- {name}
110
- </div>
104
+ <div className={datafield}>{name}</div>
111
105
  </Tooltip>
112
106
  ) : (
113
107
  <LabelComponent />
@@ -3,7 +3,7 @@ import { connect } from 'react-redux';
3
3
  import { toggleCheckBox } from '../../../store/actions/Actions';
4
4
  import CheckboxView from './CheckboxView';
5
5
 
6
- const ReduxCheckbox = ((props) => <CheckboxView {...props} />);
6
+ const ReduxCheckbox = (props) => <CheckboxView {...props} />;
7
7
 
8
8
  const mapStateToProps = (state) => ({
9
9
  filterState: state.statusReducer.filterState,
@@ -114,6 +114,4 @@ export default () => ({
114
114
  lowerUpperBound: {
115
115
  height: '15px',
116
116
  },
117
- minMaxInputs: {
118
- },
119
117
  });
@@ -1,15 +1,11 @@
1
1
  import React from 'react';
2
- import {
3
- AccordionSummary,
4
- withStyles,
5
- } from '@material-ui/core';
6
- import {
7
- ExpandMore as ExpandMoreIcon,
8
- } from '@material-ui/icons';
2
+ import { AccordionSummary, withStyles } from '@material-ui/core';
3
+ import { ExpandMore as ExpandMoreIcon } from '@material-ui/icons';
9
4
  import style from './AccordionSummaryStyle';
10
5
 
11
6
  const Summary = withStyles({
12
7
  root: {
8
+ width: '307px',
13
9
  marginBottom: -1,
14
10
  minHeight: 48,
15
11
  paddingLeft: 14,
@@ -27,10 +23,7 @@ const Summary = withStyles({
27
23
  expanded: {},
28
24
  })(AccordionSummary);
29
25
 
30
- const CustomAccordionSummary = ({
31
- children,
32
- classes,
33
- }) => (
26
+ const CustomAccordionSummary = ({ children, classes }) => (
34
27
  <Summary
35
28
  expandIcon={(
36
29
  <ExpandMoreIcon