@bento-core/query-bar 1.0.1-ins.5 → 1.1.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 CHANGED
@@ -58,6 +58,11 @@ const CONFIG = {
58
58
  * @var {number}
59
59
  */
60
60
  maxItems: 2,
61
+ /**
62
+ * overirdes maxItems to display all the active filter items
63
+ * @var {boolean}
64
+ */
65
+ displayAllActiveFilters: false,
61
66
  },
62
67
 
63
68
  /* Component Helper Functions */
@@ -16,20 +16,14 @@ var _default = _ref => {
16
16
  classes,
17
17
  maxItems,
18
18
  onSectionClick,
19
- onItemClick,
20
- displayAllActiveFilters
19
+ onItemClick
21
20
  } = _ref;
22
21
  const {
23
22
  items,
24
23
  section
25
24
  } = data;
26
- const [expand, setExpand] = (0, _react.useState)(false);
25
+ const [expand, setExpand] = (0, _react.useState)(true);
27
26
  const noOfItems = expand ? items.length : maxItems;
28
- (0, _react.useEffect)(() => {
29
- if (items.length <= maxItems && expand) {
30
- setExpand(!expand);
31
- }
32
- }, [items]);
33
27
  const clsName = function clsName() {
34
28
  let text = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
35
29
  let attr = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
@@ -48,10 +42,10 @@ var _default = _ref => {
48
42
  className: (0, _clsx.default)(classes.filterCheckboxes, classes[clsName(section)]),
49
43
  key: idx,
50
44
  onClick: () => onItemClick(data, d)
51
- }, d), idx === maxItems - 1 ? null : ' ')), items.length > maxItems && /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, displayAllActiveFilters ? /*#__PURE__*/_react.default.createElement("span", {
45
+ }, d), idx === maxItems - 1 ? null : ' ')), items.length > maxItems && !expand && /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement("span", {
52
46
  className: classes.expandBtn,
53
47
  onClick: () => setExpand(!expand)
54
- }, "...") : '...'), expand && items.length > maxItems && /*#__PURE__*/_react.default.createElement("span", {
48
+ }, "...")), expand && items.length > maxItems && /*#__PURE__*/_react.default.createElement("span", {
55
49
  className: classes.collapseBtn,
56
50
  onClick: () => setExpand(!expand)
57
51
  }, ' LESS'), items.length > 1 && /*#__PURE__*/_react.default.createElement("span", {
@@ -37,9 +37,6 @@ const QueryBarGenerator = function QueryBarGenerator() {
37
37
  } = _facetFilter.InputTypes;
38
38
  const styles = () => _objectSpread(_objectSpread({}, (0, _styles.default)()), customStyles);
39
39
  const maxItems = config && typeof config.maxItems === 'number' ? config.maxItems : _config.default.config.maxItems;
40
- const displayAllActiveFilters = config && typeof config.displayAllActiveFilters === 'boolean' ? config.displayAllActiveFilters : _config.default.config.displayAllActiveFilters;
41
- const group = config && typeof config.group === 'string' ? config.group : _config.default.config.group;
42
- const count = config && typeof config.count === 'string' ? config.count : _config.default.config.count;
43
40
  const clearAll = functions && typeof functions.clearAll === 'function' ? functions.clearAll : _config.default.functions.clearAll;
44
41
  const clearUpload = functions && typeof functions.clearUpload === 'function' ? functions.clearUpload : _config.default.functions.clearUpload;
45
42
  const clearAutocomplete = functions && typeof functions.clearAutocomplete === 'function' ? functions.clearAutocomplete : _config.default.functions.clearAutocomplete;
@@ -64,13 +61,8 @@ const QueryBarGenerator = function QueryBarGenerator() {
64
61
  autocomplete,
65
62
  upload
66
63
  } = localFind;
67
- const [expand, setExpand] = (0, _react.useState)(false);
64
+ const [expand, setExpand] = (0, _react.useState)(true);
68
65
  const noOfItems = expand ? autocomplete.length : maxItems;
69
- (0, _react.useEffect)(() => {
70
- if (autocomplete.length <= maxItems && expand) {
71
- setExpand(!expand);
72
- }
73
- }, [autocomplete]);
74
66
 
75
67
  // Remove any sections without checkboxes selected
76
68
  const mappedInputs = statusReducer.filter(facet => facet.section && facet.type).map(facet => {
@@ -78,37 +70,17 @@ const QueryBarGenerator = function QueryBarGenerator() {
78
70
  return facet;
79
71
  }
80
72
  const {
81
- data,
82
73
  items
83
74
  } = facet;
84
75
  const itemKeys = Object.keys(items);
85
76
  itemKeys.sort((a, b) => a.localeCompare(b));
86
77
 
87
- /* Find any SELECTED CHECKBOXES that do NOT have any data
88
- * and remove them from the list of selected checkboxes artificially */
89
- itemKeys.forEach(item => {
90
- if (data.findIndex(d => d.group === item) < 0) {
91
- itemKeys.splice(itemKeys.indexOf(item), 1);
92
- }
93
- });
94
- // return { ...facet, items: itemKeys };
95
78
  /**
96
- * Maintain consistant behavior with facet filter component
97
- * Display the active filter items based on the count value
98
- * Display active filter items in query bar only if count is greater than 0
99
- * behavior similar to filter component
79
+ * to display all the active filters in the query bar
80
+ * ICDC-3287
100
81
  */
101
- // const { group, count } = config;
102
- const displayItems = itemKeys.reduce((accumulator, item) => {
103
- const itemList = data.filter(d => d[group] === item && d[count] > 0) || [];
104
- if (itemList.length > 0) {
105
- const labels = itemList.map(filter => filter[group]);
106
- accumulator.push(labels);
107
- }
108
- return accumulator;
109
- }, []);
110
82
  return _objectSpread(_objectSpread({}, facet), {}, {
111
- items: displayItems
83
+ items: itemKeys
112
84
  });
113
85
  }).filter(facet => facet.items.length > 0);
114
86
  if ((mappedInputs.length || autocomplete.length || upload.length) <= 0) {
@@ -131,7 +103,7 @@ const QueryBarGenerator = function QueryBarGenerator() {
131
103
  }, "INPUT CASE SET") : null, autocomplete.length ? /*#__PURE__*/_react.default.createElement("span", null, ' ', /*#__PURE__*/_react.default.createElement("span", {
132
104
  className: (0, _clsx.default)(classes.filterName, classes.localFindBackground),
133
105
  onClick: clearAutocomplete
134
- }, "Program Name"), ' ', ' ', /*#__PURE__*/_react.default.createElement("span", {
106
+ }, "Case IDs"), ' ', ' ', /*#__PURE__*/_react.default.createElement("span", {
135
107
  className: classes.operators
136
108
  }, autocomplete.length === 1 && !upload.length ? 'IS ' : 'IN ')) : null, /*#__PURE__*/_react.default.createElement("span", null, (upload.length > 0 ? 1 : 0) + autocomplete.length > 1 ? /*#__PURE__*/_react.default.createElement("span", {
137
109
  className: classes.bracketsOpen
@@ -142,10 +114,10 @@ const QueryBarGenerator = function QueryBarGenerator() {
142
114
  className: (0, _clsx.default)(classes.filterCheckboxes, classes.facetSectionCases),
143
115
  key: idx,
144
116
  onClick: () => deleteAutocompleteItem(d.title)
145
- }, d.title), idx === noOfItems - 1 ? null : ' ')), autocomplete.length > maxItems && /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, displayAllActiveFilters ? /*#__PURE__*/_react.default.createElement("span", {
117
+ }, d.title), idx === noOfItems - 1 ? null : ' ')), autocomplete.length > maxItems && !expand && /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement("span", {
146
118
  className: classes.expandBtn,
147
119
  onClick: () => setExpand(!expand)
148
- }, "...") : '...'), expand && autocomplete.length > maxItems && /*#__PURE__*/_react.default.createElement("span", {
120
+ }, "...")), expand && autocomplete.length > maxItems && /*#__PURE__*/_react.default.createElement("span", {
149
121
  className: classes.collapseBtn,
150
122
  onClick: () => setExpand(!expand)
151
123
  }, ' LESS'), (upload.length > 0 ? 1 : 0) + autocomplete.length > 1 ? /*#__PURE__*/_react.default.createElement("span", {
@@ -159,7 +131,6 @@ const QueryBarGenerator = function QueryBarGenerator() {
159
131
  type: filter.type,
160
132
  data: filter,
161
133
  maxItems: maxItems,
162
- displayAllActiveFilters: displayAllActiveFilters,
163
134
  classes: classes,
164
135
  onSectionClick: filter.type === CHECKBOX ? resetFacetSection : resetFacetSlider,
165
136
  onItemClick: filter.type === CHECKBOX ? resetFacetCheckbox : resetFacetSlider
@@ -17,17 +17,7 @@ var _default = {
17
17
  * overirdes maxItems to display all the active filter items
18
18
  * @var {boolean}
19
19
  */
20
- displayAllActiveFilters: false,
21
- /**
22
- * key to access label text
23
- * @var {boolean}
24
- */
25
- group: 'group',
26
- /**
27
- * key to access count value
28
- * @var {boolean}
29
- */
30
- count: 'subjects'
20
+ displayAllActiveFilters: false
31
21
  },
32
22
  /* Component Helper Functions */
33
23
  functions: {
@@ -21,7 +21,7 @@ var _default = () => ({
21
21
  letterSpacing: '0.5px',
22
22
  fontFamily: 'Nunito',
23
23
  fontSize: '14px',
24
- color: '#10A075'
24
+ color: '#0e3151'
25
25
  },
26
26
  filterName: {
27
27
  textTransform: 'uppercase',
@@ -85,17 +85,17 @@ var _default = () => ({
85
85
  borderRight: '2px solid #969696',
86
86
  marginLeft: 7
87
87
  },
88
- /* Custom Styling by Programs */
88
+ /* Custom Styling by Project */
89
89
  localFind: {
90
90
  color: '#10A075'
91
91
  },
92
92
  localFindBackground: {
93
93
  backgroundColor: '#C0E9D7'
94
94
  },
95
- facetSectionPrograms: {
95
+ facetSectionCases: {
96
96
  color: '#10A075'
97
97
  },
98
- facetSectionProgramsBackground: {
98
+ facetSectionCasesBackground: {
99
99
  backgroundColor: '#C0E9D7'
100
100
  },
101
101
  facetSectionFiles: {
package/package.json CHANGED
@@ -1,17 +1,14 @@
1
1
  {
2
2
  "name": "@bento-core/query-bar",
3
- "version": "1.0.1-ins.5",
4
- "description": "This package provides the Query Bar component that displays the current Facet Search and Local Find filters on the Dashboard/Explore page. It also provides the direct ability to reset all or some of the filters with the click of a button. It is designed to be implemented directly with the:",
3
+ "version": "1.1.0",
4
+ "description": "",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
7
7
  "build": "npm run lint && cross-env-shell rm -rf dist && NODE_ENV=production BABEL_ENV=es babel src --out-dir dist --copy-files",
8
8
  "test": "echo \"Error: no test specified\" && exit 1",
9
9
  "lint": "eslint src"
10
10
  },
11
- "repository": {
12
- "type": "git",
13
- "url": "git+https://github.com/CBIIT/bento-frontend.git"
14
- },
11
+ "repository": "https://github.com/CBIIT/bento-frontend",
15
12
  "publishConfig": {
16
13
  "access": "public"
17
14
  },
@@ -23,14 +20,10 @@
23
20
  "react-redux": "^7.2.1"
24
21
  },
25
22
  "dependencies": {
26
- "@bento-core/facet-filter": "1.0.1-ins.1",
23
+ "@bento-core/facet-filter": "^1.0.0",
27
24
  "lodash": "^4.17.20"
28
25
  },
29
26
  "author": "CTOS Bento Team",
30
27
  "license": "ISC",
31
- "bugs": {
32
- "url": "https://github.com/CBIIT/bento-frontend/issues"
33
- },
34
- "homepage": "https://github.com/CBIIT/bento-frontend#readme",
35
- "devDependencies": {}
28
+ "gitHead": "a5d1f2134a214a75a4d119b47b4f7156361ca966"
36
29
  }
@@ -1,21 +1,14 @@
1
- import React, { useEffect, useState } from 'react';
1
+ import React, { useState } from 'react';
2
2
  import clsx from 'clsx';
3
3
 
4
4
  export default ({
5
5
  index, data, classes, maxItems,
6
6
  onSectionClick, onItemClick,
7
- displayAllActiveFilters,
8
7
  }) => {
9
8
  const { items, section } = data;
10
- const [expand, setExpand] = useState(false);
9
+ const [expand, setExpand] = useState(true);
11
10
  const noOfItems = expand ? items.length : maxItems;
12
11
 
13
- useEffect(() => {
14
- if (items.length <= maxItems && expand) {
15
- setExpand(!expand);
16
- }
17
- }, [items]);
18
-
19
12
  const clsName = (text = '', attr = '') => `facetSection${text.replace(/\s+/g, '')}${attr}`;
20
13
 
21
14
  return (
@@ -49,20 +42,14 @@ export default ({
49
42
  {idx === (maxItems - 1) ? null : ' '}
50
43
  </>
51
44
  ))}
52
- {items.length > maxItems && (
45
+ {(items.length > maxItems && !expand) && (
53
46
  <>
54
- {
55
- displayAllActiveFilters
56
- ? (
57
- <span
58
- className={classes.expandBtn}
59
- onClick={() => setExpand(!expand)}
60
- >
61
- ...
62
- </span>
63
- )
64
- : '...'
65
- }
47
+ <span
48
+ className={classes.expandBtn}
49
+ onClick={() => setExpand(!expand)}
50
+ >
51
+ ...
52
+ </span>
66
53
  </>
67
54
  )}
68
55
  {(expand && items.length > maxItems) && (
@@ -1,6 +1,5 @@
1
- import React, { useState, useEffect } from 'react';
1
+ import React, { useState } from 'react';
2
2
  import { withStyles, Button } from '@material-ui/core';
3
- // eslint-disable-next-line import/no-unresolved
4
3
  import { InputTypes } from '@bento-core/facet-filter';
5
4
  import clsx from 'clsx';
6
5
  import { Filter } from '../components/FilterMap';
@@ -24,16 +23,6 @@ export const QueryBarGenerator = (uiConfig = DEFAULT_CONFIG) => {
24
23
  ? config.maxItems
25
24
  : DEFAULT_CONFIG.config.maxItems;
26
25
 
27
- const displayAllActiveFilters = config && typeof config.displayAllActiveFilters === 'boolean'
28
- ? config.displayAllActiveFilters
29
- : DEFAULT_CONFIG.config.displayAllActiveFilters;
30
-
31
- const group = config && typeof config.group === 'string'
32
- ? config.group : DEFAULT_CONFIG.config.group;
33
-
34
- const count = config && typeof config.count === 'string'
35
- ? config.count : DEFAULT_CONFIG.config.count;
36
-
37
26
  const clearAll = functions && typeof functions.clearAll === 'function'
38
27
  ? functions.clearAll
39
28
  : DEFAULT_CONFIG.functions.clearAll;
@@ -70,49 +59,23 @@ export const QueryBarGenerator = (uiConfig = DEFAULT_CONFIG) => {
70
59
 
71
60
  const { autocomplete, upload } = localFind;
72
61
 
73
- const [expand, setExpand] = useState(false);
62
+ const [expand, setExpand] = useState(true);
74
63
  const noOfItems = expand ? autocomplete.length : maxItems;
75
64
 
76
- useEffect(() => {
77
- if (autocomplete.length <= maxItems && expand) {
78
- setExpand(!expand);
79
- }
80
- }, [autocomplete]);
81
-
82
65
  // Remove any sections without checkboxes selected
83
66
  const mappedInputs = statusReducer.filter((facet) => facet.section && facet.type)
84
67
  .map((facet) => {
85
68
  if (facet.type !== CHECKBOX) { return facet; }
86
69
 
87
- const { data, items } = facet;
70
+ const { items } = facet;
88
71
  const itemKeys = Object.keys(items);
89
72
  itemKeys.sort((a, b) => a.localeCompare(b));
90
73
 
91
- /* Find any SELECTED CHECKBOXES that do NOT have any data
92
- * and remove them from the list of selected checkboxes artificially */
93
- itemKeys.forEach((item) => {
94
- if (data.findIndex((d) => d.group === item) < 0) {
95
- itemKeys.splice(itemKeys.indexOf(item), 1);
96
- }
97
- });
98
- // return { ...facet, items: itemKeys };
99
74
  /**
100
- * Maintain consistant behavior with facet filter component
101
- * Display the active filter items based on the count value
102
- * Display active filter items in query bar only if count is greater than 0
103
- * behavior similar to filter component
75
+ * to display all the active filters in the query bar
76
+ * ICDC-3287
104
77
  */
105
- // const { group, count } = config;
106
- const displayItems = itemKeys.reduce((accumulator, item) => {
107
- const itemList = data.filter((d) => (d[group] === item && d[count] > 0)) || [];
108
- if (itemList.length > 0) {
109
- const labels = itemList.map((filter) => filter[group]);
110
- accumulator.push(labels);
111
- }
112
- return accumulator;
113
- }, []);
114
-
115
- return { ...facet, items: displayItems };
78
+ return { ...facet, items: itemKeys };
116
79
  })
117
80
  .filter((facet) => facet.items.length > 0);
118
81
 
@@ -154,7 +117,7 @@ export const QueryBarGenerator = (uiConfig = DEFAULT_CONFIG) => {
154
117
  className={clsx(classes.filterName, classes.localFindBackground)}
155
118
  onClick={clearAutocomplete}
156
119
  >
157
- Program Name
120
+ Case IDs
158
121
  </span>
159
122
  {' '}
160
123
  {' '}
@@ -191,20 +154,14 @@ export const QueryBarGenerator = (uiConfig = DEFAULT_CONFIG) => {
191
154
  {idx === (noOfItems - 1) ? null : ' '}
192
155
  </>
193
156
  ))}
194
- {autocomplete.length > maxItems && (
157
+ {(autocomplete.length > maxItems && !expand) && (
195
158
  <>
196
- {
197
- displayAllActiveFilters
198
- ? (
199
- <span
200
- className={classes.expandBtn}
201
- onClick={() => setExpand(!expand)}
202
- >
203
- ...
204
- </span>
205
- )
206
- : '...'
207
- }
159
+ <span
160
+ className={classes.expandBtn}
161
+ onClick={() => setExpand(!expand)}
162
+ >
163
+ ...
164
+ </span>
208
165
  </>
209
166
  )}
210
167
  {(expand && autocomplete.length > maxItems) && (
@@ -233,7 +190,6 @@ export const QueryBarGenerator = (uiConfig = DEFAULT_CONFIG) => {
233
190
  type={filter.type}
234
191
  data={filter}
235
192
  maxItems={maxItems}
236
- displayAllActiveFilters={displayAllActiveFilters}
237
193
  classes={classes}
238
194
  onSectionClick={filter.type === CHECKBOX
239
195
  ? resetFacetSection
@@ -12,16 +12,6 @@ export default {
12
12
  * @var {boolean}
13
13
  */
14
14
  displayAllActiveFilters: false,
15
- /**
16
- * key to access label text
17
- * @var {boolean}
18
- */
19
- group: 'group',
20
- /**
21
- * key to access count value
22
- * @var {boolean}
23
- */
24
- count: 'subjects',
25
15
  },
26
16
 
27
17
  /* Component Helper Functions */
@@ -15,7 +15,7 @@ export default () => ({
15
15
  letterSpacing: '0.5px',
16
16
  fontFamily: 'Nunito',
17
17
  fontSize: '14px',
18
- color: '#10A075',
18
+ color: '#0e3151',
19
19
  },
20
20
  filterName: {
21
21
  textTransform: 'uppercase',
@@ -79,17 +79,17 @@ export default () => ({
79
79
  borderRight: '2px solid #969696',
80
80
  marginLeft: 7,
81
81
  },
82
- /* Custom Styling by Programs */
82
+ /* Custom Styling by Project */
83
83
  localFind: {
84
84
  color: '#10A075',
85
85
  },
86
86
  localFindBackground: {
87
87
  backgroundColor: '#C0E9D7',
88
88
  },
89
- facetSectionPrograms: {
89
+ facetSectionCases: {
90
90
  color: '#10A075',
91
91
  },
92
- facetSectionProgramsBackground: {
92
+ facetSectionCasesBackground: {
93
93
  backgroundColor: '#C0E9D7',
94
94
  },
95
95
  facetSectionFiles: {