@bento-core/query-bar 1.0.1-ins.6 → 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,7 +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
40
  const clearAll = functions && typeof functions.clearAll === 'function' ? functions.clearAll : _config.default.functions.clearAll;
42
41
  const clearUpload = functions && typeof functions.clearUpload === 'function' ? functions.clearUpload : _config.default.functions.clearUpload;
43
42
  const clearAutocomplete = functions && typeof functions.clearAutocomplete === 'function' ? functions.clearAutocomplete : _config.default.functions.clearAutocomplete;
@@ -62,13 +61,8 @@ const QueryBarGenerator = function QueryBarGenerator() {
62
61
  autocomplete,
63
62
  upload
64
63
  } = localFind;
65
- const [expand, setExpand] = (0, _react.useState)(false);
64
+ const [expand, setExpand] = (0, _react.useState)(true);
66
65
  const noOfItems = expand ? autocomplete.length : maxItems;
67
- (0, _react.useEffect)(() => {
68
- if (autocomplete.length <= maxItems && expand) {
69
- setExpand(!expand);
70
- }
71
- }, [autocomplete]);
72
66
 
73
67
  // Remove any sections without checkboxes selected
74
68
  const mappedInputs = statusReducer.filter(facet => facet.section && facet.type).map(facet => {
@@ -81,30 +75,10 @@ const QueryBarGenerator = function QueryBarGenerator() {
81
75
  const itemKeys = Object.keys(items);
82
76
  itemKeys.sort((a, b) => a.localeCompare(b));
83
77
 
84
- /* Find any SELECTED CHECKBOXES that do NOT have any data
85
- * and remove them from the list of selected checkboxes artificially */
86
- // itemKeys.forEach((item) => {
87
- // if (data.findIndex((d) => d.group === item) < 0) {
88
- // itemKeys.splice(itemKeys.indexOf(item), 1);
89
- // }
90
- // });
91
- // return { ...facet, items: itemKeys };
92
78
  /**
93
- * Maintain consistant behavior with facet filter component
94
- * Display the active filter items based on the count value
95
- * Display active filter items in query bar only if count is greater than 0
96
- * behavior similar to filter component
79
+ * to display all the active filters in the query bar
80
+ * ICDC-3287
97
81
  */
98
- // const { group, count } = config;
99
- // const displayItems = itemKeys.reduce((accumulator, item) => {
100
- // const itemList = data.filter((d) => (d[group] === item && d[count] > 0)) || [];
101
- // if (itemList.length > 0) {
102
- // const labels = itemList.map((filter) => filter[group]);
103
- // accumulator.push(labels);
104
- // }
105
- // return accumulator;
106
- // }, []);
107
-
108
82
  return _objectSpread(_objectSpread({}, facet), {}, {
109
83
  items: itemKeys
110
84
  });
@@ -129,7 +103,7 @@ const QueryBarGenerator = function QueryBarGenerator() {
129
103
  }, "INPUT CASE SET") : null, autocomplete.length ? /*#__PURE__*/_react.default.createElement("span", null, ' ', /*#__PURE__*/_react.default.createElement("span", {
130
104
  className: (0, _clsx.default)(classes.filterName, classes.localFindBackground),
131
105
  onClick: clearAutocomplete
132
- }, "Program Name"), ' ', ' ', /*#__PURE__*/_react.default.createElement("span", {
106
+ }, "Case IDs"), ' ', ' ', /*#__PURE__*/_react.default.createElement("span", {
133
107
  className: classes.operators
134
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", {
135
109
  className: classes.bracketsOpen
@@ -140,10 +114,10 @@ const QueryBarGenerator = function QueryBarGenerator() {
140
114
  className: (0, _clsx.default)(classes.filterCheckboxes, classes.facetSectionCases),
141
115
  key: idx,
142
116
  onClick: () => deleteAutocompleteItem(d.title)
143
- }, 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", {
144
118
  className: classes.expandBtn,
145
119
  onClick: () => setExpand(!expand)
146
- }, "...") : '...'), expand && autocomplete.length > maxItems && /*#__PURE__*/_react.default.createElement("span", {
120
+ }, "...")), expand && autocomplete.length > maxItems && /*#__PURE__*/_react.default.createElement("span", {
147
121
  className: classes.collapseBtn,
148
122
  onClick: () => setExpand(!expand)
149
123
  }, ' LESS'), (upload.length > 0 ? 1 : 0) + autocomplete.length > 1 ? /*#__PURE__*/_react.default.createElement("span", {
@@ -157,7 +131,6 @@ const QueryBarGenerator = function QueryBarGenerator() {
157
131
  type: filter.type,
158
132
  data: filter,
159
133
  maxItems: maxItems,
160
- displayAllActiveFilters: displayAllActiveFilters,
161
134
  classes: classes,
162
135
  onSectionClick: filter.type === CHECKBOX ? resetFacetSection : resetFacetSlider,
163
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.6",
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.2",
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,10 +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
26
  const clearAll = functions && typeof functions.clearAll === 'function'
32
27
  ? functions.clearAll
33
28
  : DEFAULT_CONFIG.functions.clearAll;
@@ -64,15 +59,9 @@ export const QueryBarGenerator = (uiConfig = DEFAULT_CONFIG) => {
64
59
 
65
60
  const { autocomplete, upload } = localFind;
66
61
 
67
- const [expand, setExpand] = useState(false);
62
+ const [expand, setExpand] = useState(true);
68
63
  const noOfItems = expand ? autocomplete.length : maxItems;
69
64
 
70
- useEffect(() => {
71
- if (autocomplete.length <= maxItems && expand) {
72
- setExpand(!expand);
73
- }
74
- }, [autocomplete]);
75
-
76
65
  // Remove any sections without checkboxes selected
77
66
  const mappedInputs = statusReducer.filter((facet) => facet.section && facet.type)
78
67
  .map((facet) => {
@@ -82,30 +71,10 @@ export const QueryBarGenerator = (uiConfig = DEFAULT_CONFIG) => {
82
71
  const itemKeys = Object.keys(items);
83
72
  itemKeys.sort((a, b) => a.localeCompare(b));
84
73
 
85
- /* Find any SELECTED CHECKBOXES that do NOT have any data
86
- * and remove them from the list of selected checkboxes artificially */
87
- // itemKeys.forEach((item) => {
88
- // if (data.findIndex((d) => d.group === item) < 0) {
89
- // itemKeys.splice(itemKeys.indexOf(item), 1);
90
- // }
91
- // });
92
- // return { ...facet, items: itemKeys };
93
74
  /**
94
- * Maintain consistant behavior with facet filter component
95
- * Display the active filter items based on the count value
96
- * Display active filter items in query bar only if count is greater than 0
97
- * behavior similar to filter component
75
+ * to display all the active filters in the query bar
76
+ * ICDC-3287
98
77
  */
99
- // const { group, count } = config;
100
- // const displayItems = itemKeys.reduce((accumulator, item) => {
101
- // const itemList = data.filter((d) => (d[group] === item && d[count] > 0)) || [];
102
- // if (itemList.length > 0) {
103
- // const labels = itemList.map((filter) => filter[group]);
104
- // accumulator.push(labels);
105
- // }
106
- // return accumulator;
107
- // }, []);
108
-
109
78
  return { ...facet, items: itemKeys };
110
79
  })
111
80
  .filter((facet) => facet.items.length > 0);
@@ -148,7 +117,7 @@ export const QueryBarGenerator = (uiConfig = DEFAULT_CONFIG) => {
148
117
  className={clsx(classes.filterName, classes.localFindBackground)}
149
118
  onClick={clearAutocomplete}
150
119
  >
151
- Program Name
120
+ Case IDs
152
121
  </span>
153
122
  {' '}
154
123
  {' '}
@@ -185,20 +154,14 @@ export const QueryBarGenerator = (uiConfig = DEFAULT_CONFIG) => {
185
154
  {idx === (noOfItems - 1) ? null : ' '}
186
155
  </>
187
156
  ))}
188
- {autocomplete.length > maxItems && (
157
+ {(autocomplete.length > maxItems && !expand) && (
189
158
  <>
190
- {
191
- displayAllActiveFilters
192
- ? (
193
- <span
194
- className={classes.expandBtn}
195
- onClick={() => setExpand(!expand)}
196
- >
197
- ...
198
- </span>
199
- )
200
- : '...'
201
- }
159
+ <span
160
+ className={classes.expandBtn}
161
+ onClick={() => setExpand(!expand)}
162
+ >
163
+ ...
164
+ </span>
202
165
  </>
203
166
  )}
204
167
  {(expand && autocomplete.length > maxItems) && (
@@ -227,7 +190,6 @@ export const QueryBarGenerator = (uiConfig = DEFAULT_CONFIG) => {
227
190
  type={filter.type}
228
191
  data={filter}
229
192
  maxItems={maxItems}
230
- displayAllActiveFilters={displayAllActiveFilters}
231
193
  classes={classes}
232
194
  onSectionClick={filter.type === CHECKBOX
233
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: {