@bento-core/query-bar 1.0.1-icdc.17 → 1.0.1-icdc.18

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
@@ -63,25 +63,6 @@ const CONFIG = {
63
63
  * @var {boolean}
64
64
  */
65
65
  displayAllActiveFilters: false,
66
- /**
67
- * key to access label text
68
- * @var {boolean}
69
- */
70
- group: 'group',
71
-
72
- /**
73
- * root path of bento app {window.location.href} or react PUBLIC_URL
74
- * PR (https://github.com/CBIIT/bento-icdc-frontend/pull/953)
75
- * @var {string}
76
- */
77
- rootPath: null,
78
- /**
79
- * display query URL
80
- * @var {boolean}
81
- * PR (https://github.com/CBIIT/bento-icdc-frontend/pull/953)
82
- */
83
- viewQueryURL: false,
84
-
85
66
  },
86
67
 
87
68
  /* Component Helper Functions */
@@ -139,7 +120,6 @@ const CONFIG = {
139
120
  * @returns {void}
140
121
  */
141
122
  resetFacetSlider: (section) => {},
142
-
143
123
  },
144
124
  };
145
125
  ```
@@ -164,4 +144,4 @@ This component, which is generated by the provided generator, accepts the follow
164
144
  />
165
145
  ```
166
146
 
167
- > **Warning**: The `statusReducer` prop requires the dashboard API data merged with the `facetsConfig` property. Please see the example in the demo implementation [here](https://github.com/CBIIT/bento-frontend/blob/7efd62cd3da0c29326e523055d30118244dc2f2f/packages/bento-frontend/src/pages/dashTemplate/filterQueryBar/QueryBarView.js#LL20C14-L20C14).
147
+ > **Warning**: The `statusReducer` prop requires the dashboard API data merged with the `facetsConfig` property. Please see the example in the demo implementation [here](https://github.com/CBIIT/bento-frontend/blob/7efd62cd3da0c29326e523055d30118244dc2f2f/packages/bento-frontend/src/pages/dashTemplate/filterQueryBar/QueryBarView.js#LL20C14-L20C14).
@@ -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 && /*#__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", {
@@ -40,11 +40,6 @@ const QueryBarGenerator = function QueryBarGenerator() {
40
40
  const maxItems = config && typeof config.maxItems === 'number' ? config.maxItems : _config.default.config.maxItems;
41
41
  const queryURLRootPath = config && typeof config.rootPath === 'string' ? config.rootPath : _config.default.config.rootPath;
42
42
  const viewQueryURL = config && typeof config.viewQueryURL === 'boolean' ? config.viewQueryURL : _config.default.config.viewQueryURL;
43
- const displayAllActiveFilters = config && typeof config.displayAllActiveFilters === 'boolean' ? config.displayAllActiveFilters : _config.default.config.displayAllActiveFilters;
44
-
45
- // const group = config && typeof config.group === 'string'
46
- // ? config.group : DEFAULT_CONFIG.config.group;
47
-
48
43
  const clearAll = functions && typeof functions.clearAll === 'function' ? functions.clearAll : _config.default.functions.clearAll;
49
44
  const clearUpload = functions && typeof functions.clearUpload === 'function' ? functions.clearUpload : _config.default.functions.clearUpload;
50
45
  const clearAutocomplete = functions && typeof functions.clearAutocomplete === 'function' ? functions.clearAutocomplete : _config.default.functions.clearAutocomplete;
@@ -69,7 +64,7 @@ const QueryBarGenerator = function QueryBarGenerator() {
69
64
  autocomplete,
70
65
  upload
71
66
  } = localFind;
72
- const [expand, setExpand] = (0, _react.useState)(false);
67
+ const [expand, setExpand] = (0, _react.useState)(true);
73
68
  const noOfItems = expand ? autocomplete.length : maxItems;
74
69
  (0, _react.useEffect)(() => {
75
70
  if (autocomplete.length <= maxItems && expand) {
@@ -88,16 +83,7 @@ const QueryBarGenerator = function QueryBarGenerator() {
88
83
  const itemKeys = Object.keys(items);
89
84
  itemKeys.sort((a, b) => a.localeCompare(b));
90
85
 
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
-
99
86
  /**
100
- * commenting out line 89-93
101
87
  * to display all the active filters in the query bar
102
88
  * ICDC-3287
103
89
  */
@@ -136,10 +122,10 @@ const QueryBarGenerator = function QueryBarGenerator() {
136
122
  className: (0, _clsx.default)(classes.filterCheckboxes, classes.facetSectionCases),
137
123
  key: idx,
138
124
  onClick: () => deleteAutocompleteItem(d.title)
139
- }, d.title), idx === noOfItems - 1 ? null : ' ')), autocomplete.length > maxItems && /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, displayAllActiveFilters ? /*#__PURE__*/_react.default.createElement("span", {
125
+ }, d.title), idx === noOfItems - 1 ? null : ' ')), autocomplete.length > maxItems && /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement("span", {
140
126
  className: classes.expandBtn,
141
127
  onClick: () => setExpand(!expand)
142
- }, "...") : '...'), expand && autocomplete.length > maxItems && /*#__PURE__*/_react.default.createElement("span", {
128
+ }, "...")), expand && autocomplete.length > maxItems && /*#__PURE__*/_react.default.createElement("span", {
143
129
  className: classes.collapseBtn,
144
130
  onClick: () => setExpand(!expand)
145
131
  }, ' LESS'), (upload.length > 0 ? 1 : 0) + autocomplete.length > 1 ? /*#__PURE__*/_react.default.createElement("span", {
@@ -153,7 +139,6 @@ const QueryBarGenerator = function QueryBarGenerator() {
153
139
  type: filter.type,
154
140
  data: filter,
155
141
  maxItems: maxItems,
156
- displayAllActiveFilters: displayAllActiveFilters,
157
142
  classes: classes,
158
143
  onSectionClick: filter.type === CHECKBOX ? resetFacetSection : resetFacetSlider,
159
144
  onItemClick: filter.type === CHECKBOX ? resetFacetCheckbox : resetFacetSlider
@@ -18,20 +18,6 @@ var _default = {
18
18
  * @var {boolean}
19
19
  */
20
20
  displayAllActiveFilters: false,
21
- /**
22
- * key to access label text
23
- * @var {boolean}
24
- */
25
- group: 'group',
26
- /**
27
- * root path of bento app
28
- * @var {boolean}
29
- */
30
- rootPath: null,
31
- /**
32
- * display query URL
33
- * @var {boolean}
34
- */
35
21
  viewQueryURL: false
36
22
  },
37
23
  /* Component Helper Functions */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bento-core/query-bar",
3
- "version": "1.0.1-icdc.17",
3
+ "version": "1.0.1-icdc.18",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
@@ -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 (
@@ -51,18 +44,12 @@ export default ({
51
44
  ))}
52
45
  {items.length > maxItems && (
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) && (
@@ -32,13 +32,6 @@ export const QueryBarGenerator = (uiConfig = DEFAULT_CONFIG) => {
32
32
  ? config.viewQueryURL
33
33
  : DEFAULT_CONFIG.config.viewQueryURL;
34
34
 
35
- const displayAllActiveFilters = config && typeof config.displayAllActiveFilters === 'boolean'
36
- ? config.displayAllActiveFilters
37
- : DEFAULT_CONFIG.config.displayAllActiveFilters;
38
-
39
- // const group = config && typeof config.group === 'string'
40
- // ? config.group : DEFAULT_CONFIG.config.group;
41
-
42
35
  const clearAll = functions && typeof functions.clearAll === 'function'
43
36
  ? functions.clearAll
44
37
  : DEFAULT_CONFIG.functions.clearAll;
@@ -75,7 +68,7 @@ export const QueryBarGenerator = (uiConfig = DEFAULT_CONFIG) => {
75
68
 
76
69
  const { autocomplete, upload } = localFind;
77
70
 
78
- const [expand, setExpand] = useState(false);
71
+ const [expand, setExpand] = useState(true);
79
72
  const noOfItems = expand ? autocomplete.length : maxItems;
80
73
 
81
74
  useEffect(() => {
@@ -93,16 +86,7 @@ export const QueryBarGenerator = (uiConfig = DEFAULT_CONFIG) => {
93
86
  const itemKeys = Object.keys(items);
94
87
  itemKeys.sort((a, b) => a.localeCompare(b));
95
88
 
96
- /* Find any SELECTED CHECKBOXES that do NOT have any data
97
- * and remove them from the list of selected checkboxes artificially */
98
- // itemKeys.forEach((item) => {
99
- // if (data.findIndex((d) => d.group === item) < 0) {
100
- // itemKeys.splice(itemKeys.indexOf(item), 1);
101
- // }
102
- // });
103
-
104
89
  /**
105
- * commenting out line 89-93
106
90
  * to display all the active filters in the query bar
107
91
  * ICDC-3287
108
92
  */
@@ -188,18 +172,12 @@ export const QueryBarGenerator = (uiConfig = DEFAULT_CONFIG) => {
188
172
  ))}
189
173
  {autocomplete.length > maxItems && (
190
174
  <>
191
- {
192
- displayAllActiveFilters
193
- ? (
194
- <span
195
- className={classes.expandBtn}
196
- onClick={() => setExpand(!expand)}
197
- >
198
- ...
199
- </span>
200
- )
201
- : '...'
202
- }
175
+ <span
176
+ className={classes.expandBtn}
177
+ onClick={() => setExpand(!expand)}
178
+ >
179
+ ...
180
+ </span>
203
181
  </>
204
182
  )}
205
183
  {(expand && autocomplete.length > maxItems) && (
@@ -228,7 +206,6 @@ export const QueryBarGenerator = (uiConfig = DEFAULT_CONFIG) => {
228
206
  type={filter.type}
229
207
  data={filter}
230
208
  maxItems={maxItems}
231
- displayAllActiveFilters={displayAllActiveFilters}
232
209
  classes={classes}
233
210
  onSectionClick={filter.type === CHECKBOX
234
211
  ? resetFacetSection
@@ -12,20 +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
- * root path of bento app
22
- * @var {boolean}
23
- */
24
- rootPath: null,
25
- /**
26
- * display query URL
27
- * @var {boolean}
28
- */
29
15
  viewQueryURL: false,
30
16
  },
31
17