@carbon/ibm-products 2.0.0-rc.18 → 2.0.0-rc.19

Sign up to get free protection for your applications and to get access to all the features.
Files changed (62) hide show
  1. package/css/index-full-carbon.css +135 -20
  2. package/css/index-full-carbon.css.map +1 -1
  3. package/css/index-full-carbon.min.css +3 -3
  4. package/css/index-full-carbon.min.css.map +1 -1
  5. package/css/index-without-carbon.css +135 -20
  6. package/css/index-without-carbon.css.map +1 -1
  7. package/css/index-without-carbon.min.css +3 -3
  8. package/css/index-without-carbon.min.css.map +1 -1
  9. package/css/index.css +134 -20
  10. package/css/index.css.map +1 -1
  11. package/css/index.min.css +2 -2
  12. package/css/index.min.css.map +1 -1
  13. package/es/components/Datagrid/Datagrid/Datagrid.js +4 -4
  14. package/es/components/Datagrid/Datagrid/DatagridContent.js +46 -16
  15. package/es/components/Datagrid/Datagrid/DatagridToolbar.js +3 -21
  16. package/es/components/Datagrid/Datagrid/addons/Filtering/FilterFlyout.js +120 -60
  17. package/es/components/Datagrid/Datagrid/addons/Filtering/FilterPanel.js +514 -0
  18. package/es/components/Datagrid/Datagrid/addons/Filtering/FilterProvider.js +10 -2
  19. package/es/components/Datagrid/Datagrid/addons/Filtering/constants.js +9 -1
  20. package/es/components/Datagrid/Datagrid/addons/Filtering/hooks/index.js +9 -0
  21. package/es/components/Datagrid/Datagrid/addons/Filtering/hooks/useInitialStateFromFilters.js +4 -1
  22. package/es/components/Datagrid/Datagrid/addons/Filtering/hooks/useShouldDisableButtons.js +38 -0
  23. package/es/components/Datagrid/Datagrid/addons/Filtering/hooks/useSubscribeToEventEmitter.js +25 -0
  24. package/es/components/Datagrid/Datagrid/addons/Filtering/index.js +3 -1
  25. package/es/components/Datagrid/Datagrid/addons/Filtering/motion/variants.js +55 -0
  26. package/es/components/Datagrid/Datagrid/addons/Filtering/utils.js +53 -19
  27. package/es/components/Datagrid/Datagrid.stories/index.js +0 -1
  28. package/es/components/Datagrid/useFiltering.js +11 -4
  29. package/es/components/Datagrid/utils/DatagridActions.js +41 -13
  30. package/es/components/OptionsTile/OptionsTile.js +3 -3
  31. package/es/components/Tearsheet/Tearsheet.js +5 -0
  32. package/es/components/Tearsheet/TearsheetNarrow.js +5 -0
  33. package/es/components/Tearsheet/TearsheetShell.js +1 -1
  34. package/lib/components/Datagrid/Datagrid/Datagrid.js +4 -4
  35. package/lib/components/Datagrid/Datagrid/DatagridContent.js +48 -15
  36. package/lib/components/Datagrid/Datagrid/DatagridToolbar.js +2 -23
  37. package/lib/components/Datagrid/Datagrid/addons/Filtering/FilterFlyout.js +113 -51
  38. package/lib/components/Datagrid/Datagrid/addons/Filtering/FilterPanel.js +538 -0
  39. package/lib/components/Datagrid/Datagrid/addons/Filtering/FilterProvider.js +9 -1
  40. package/lib/components/Datagrid/Datagrid/addons/Filtering/constants.js +15 -3
  41. package/lib/components/Datagrid/Datagrid/addons/Filtering/hooks/index.js +31 -0
  42. package/lib/components/Datagrid/Datagrid/addons/Filtering/hooks/useInitialStateFromFilters.js +5 -1
  43. package/lib/components/Datagrid/Datagrid/addons/Filtering/hooks/useShouldDisableButtons.js +50 -0
  44. package/lib/components/Datagrid/Datagrid/addons/Filtering/hooks/useSubscribeToEventEmitter.js +35 -0
  45. package/lib/components/Datagrid/Datagrid/addons/Filtering/index.js +23 -1
  46. package/lib/components/Datagrid/Datagrid/addons/Filtering/motion/variants.js +67 -0
  47. package/lib/components/Datagrid/Datagrid/addons/Filtering/utils.js +53 -18
  48. package/lib/components/Datagrid/Datagrid.stories/index.js +0 -8
  49. package/lib/components/Datagrid/useFiltering.js +11 -3
  50. package/lib/components/Datagrid/utils/DatagridActions.js +41 -11
  51. package/lib/components/OptionsTile/OptionsTile.js +2 -2
  52. package/lib/components/Tearsheet/Tearsheet.js +5 -0
  53. package/lib/components/Tearsheet/TearsheetNarrow.js +5 -0
  54. package/lib/components/Tearsheet/TearsheetShell.js +1 -1
  55. package/package.json +2 -2
  56. package/scss/components/Datagrid/styles/_datagrid.scss +16 -17
  57. package/scss/components/Datagrid/styles/_index.scss +1 -0
  58. package/scss/components/Datagrid/styles/addons/_FilterPanel.scss +129 -0
  59. package/scss/components/Datagrid/styles/addons/_RowSizeDropdown.scss +3 -3
  60. package/scss/components/FilterSummary/_filter-summary.scss +1 -0
  61. package/es/components/Datagrid/Datagrid.stories/LeftPanelStory.js +0 -6
  62. package/lib/components/Datagrid/Datagrid.stories/LeftPanelStory.js +0 -13
@@ -7,16 +7,13 @@ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
7
7
  * This source code is licensed under the Apache-2.0 license found in the
8
8
  * LICENSE file in the root directory of this source tree.
9
9
  */
10
- import React, { useEffect, useState, useContext } from 'react';
10
+ import React, { useEffect, useState } from 'react';
11
11
  import { Add, OverflowMenuVertical } from '@carbon/react/icons';
12
12
  import { TableToolbar, TableBatchActions, TableBatchAction } from '@carbon/react';
13
13
  import { useResizeDetector } from 'react-resize-detector';
14
14
  import { ButtonMenu, ButtonMenuItem } from '../../ButtonMenu';
15
15
  import { pkg, carbon } from '../../../settings';
16
16
  import cx from 'classnames';
17
- import { FilterSummary } from '../../FilterSummary';
18
- import { FilterContext } from './addons/Filtering/FilterProvider';
19
- import { CLEAR_FILTERS } from './addons/Filtering/constants';
20
17
  var blockClass = "".concat(pkg.prefix, "--datagrid");
21
18
 
22
19
  var DatagridBatchActionsToolbar = function DatagridBatchActionsToolbar(datagridState, width, ref) {
@@ -144,29 +141,14 @@ var DatagridToolbar = function DatagridToolbar(datagridState) {
144
141
  var DatagridActions = datagridState.DatagridActions,
145
142
  DatagridBatchActions = datagridState.DatagridBatchActions,
146
143
  batchActions = datagridState.batchActions,
147
- state = datagridState.state,
148
144
  rowSize = datagridState.rowSize;
149
-
150
- var _useContext = useContext(FilterContext),
151
- filterTags = _useContext.filterTags,
152
- EventEmitter = _useContext.EventEmitter;
153
-
154
- var renderFilterSummary = function renderFilterSummary() {
155
- return state.filters.length > 0 && /*#__PURE__*/React.createElement(FilterSummary, {
156
- filters: filterTags,
157
- clearFilters: function clearFilters() {
158
- return EventEmitter.dispatch(CLEAR_FILTERS);
159
- }
160
- });
161
- };
162
-
163
145
  var getRowHeight = rowSize ? rowSize : 'lg';
164
146
  return batchActions && DatagridActions ? /*#__PURE__*/React.createElement("div", {
165
147
  ref: ref,
166
148
  className: cx("".concat(blockClass, "__table-toolbar"), "".concat(blockClass, "__table-toolbar--").concat(getRowHeight))
167
- }, /*#__PURE__*/React.createElement(TableToolbar, null, DatagridActions && DatagridActions(datagridState), DatagridBatchActionsToolbar && DatagridBatchActionsToolbar(datagridState, width, ref)), renderFilterSummary()) : DatagridActions ? /*#__PURE__*/React.createElement("div", {
149
+ }, /*#__PURE__*/React.createElement(TableToolbar, null, DatagridActions && DatagridActions(datagridState), DatagridBatchActionsToolbar && DatagridBatchActionsToolbar(datagridState, width, ref))) : DatagridActions ? /*#__PURE__*/React.createElement("div", {
168
150
  className: "".concat(blockClass, "__table-toolbar")
169
- }, /*#__PURE__*/React.createElement(TableToolbar, null, DatagridActions && DatagridActions(datagridState), DatagridBatchActions && DatagridBatchActions(datagridState)), renderFilterSummary()) : null;
151
+ }, /*#__PURE__*/React.createElement(TableToolbar, null, DatagridActions && DatagridActions(datagridState), DatagridBatchActions && DatagridBatchActions(datagridState))) : null;
170
152
  };
171
153
 
172
154
  export default DatagridToolbar;
@@ -9,26 +9,22 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
9
9
 
10
10
  // @flow
11
11
 
12
- /*
13
- * Licensed Materials - Property of IBM
14
- * 5724-Q36
15
- * (c) Copyright IBM Corp. 2022
16
- * US Government Users Restricted Rights - Use, duplication or disclosure
17
- * restricted by GSA ADP Schedule Contract with IBM Corp.
12
+ /**
13
+ * Copyright IBM Corp. 2022, 2023
14
+ *
15
+ * This source code is licensed under the Apache-2.0 license found in the
16
+ * LICENSE file in the root directory of this source tree.
18
17
  */
19
18
  import { Filter } from '@carbon/react/icons';
20
- import { Button, Checkbox, DatePicker, DatePickerInput, Dropdown, FormGroup, NumberInput, RadioButton, RadioButtonGroup } from '@carbon/react';
19
+ import { Button, Checkbox, DatePicker, DatePickerInput, Dropdown, FormGroup, NumberInput, RadioButton, RadioButtonGroup, usePrefix } from '@carbon/react';
21
20
  import cx from 'classnames';
22
21
  import PropTypes from 'prop-types';
23
22
  import React, { useCallback, useRef, useState } from 'react';
24
- import { useEffect } from 'react';
25
- import { useContext } from 'react';
26
23
  import { useClickOutside } from '../../../../../global/js/hooks';
27
24
  import { pkg } from '../../../../../settings';
28
25
  import { ActionSet } from '../../../../ActionSet';
29
- import { BATCH, CHECKBOX, CLEAR_FILTERS, DATE, DROPDOWN, INSTANT, NUMBER, RADIO } from './constants';
30
- import { FilterContext } from './FilterProvider';
31
- import useInitialStateFromFilters from './hooks/useInitialStateFromFilters';
26
+ import { BATCH, CHECKBOX, CLEAR_FILTERS, DATE, DROPDOWN, FLYOUT, INSTANT, NUMBER, RADIO } from './constants';
27
+ import { useInitialStateFromFilters, useSubscribeToEventEmitter, useShouldDisableButtons } from './hooks';
32
28
  import { getInitialStateFromFilters } from './utils';
33
29
  var blockClass = "".concat(pkg.prefix, "--datagrid");
34
30
  var componentClass = "".concat(blockClass, "-filter-flyout");
@@ -56,20 +52,17 @@ var FilterFlyout = function FilterFlyout(_ref) {
56
52
  onCancel = _ref$onCancel === void 0 ? function () {} : _ref$onCancel,
57
53
  _ref$secondaryActionL = _ref.secondaryActionLabel,
58
54
  secondaryActionLabel = _ref$secondaryActionL === void 0 ? 'Cancel' : _ref$secondaryActionL,
59
- setAllFilters = _ref.setAllFilters;
55
+ setAllFilters = _ref.setAllFilters,
56
+ _ref$data = _ref.data,
57
+ data = _ref$data === void 0 ? [] : _ref$data;
60
58
 
61
- /** Context state and methods */
62
- var _useContext = useContext(FilterContext),
63
- EventEmitter = _useContext.EventEmitter;
64
59
  /** State */
65
-
66
-
67
60
  var _useState = useState(false),
68
61
  _useState2 = _slicedToArray(_useState, 2),
69
62
  open = _useState2[0],
70
63
  setOpen = _useState2[1];
71
64
 
72
- var _useInitialStateFromF = useInitialStateFromFilters(filters),
65
+ var _useInitialStateFromF = useInitialStateFromFilters(filters, FLYOUT),
73
66
  _useInitialStateFromF2 = _slicedToArray(_useInitialStateFromF, 2),
74
67
  filtersState = _useInitialStateFromF2[0],
75
68
  setFiltersState = _useInitialStateFromF2[1];
@@ -85,9 +78,21 @@ var FilterFlyout = function FilterFlyout(_ref) {
85
78
 
86
79
  var prevFiltersRef = useRef(JSON.stringify(filtersState));
87
80
  var prevFiltersObjectArrayRef = useRef(JSON.stringify(filtersObjectArray));
81
+ /** State from hooks */
82
+
83
+ var _useShouldDisableButt = useShouldDisableButtons({
84
+ initialValue: true,
85
+ filtersState: filtersState,
86
+ prevFiltersRef: prevFiltersRef
87
+ }),
88
+ _useShouldDisableButt2 = _slicedToArray(_useShouldDisableButt, 2),
89
+ shouldDisableButtons = _useShouldDisableButt2[0],
90
+ setShouldDisableButtons = _useShouldDisableButt2[1];
88
91
  /** Memos */
89
92
 
93
+
90
94
  var showActionSet = updateMethod === BATCH;
95
+ var carbonPrefix = usePrefix();
91
96
  /** Methods */
92
97
 
93
98
  var openFlyout = function openFlyout() {
@@ -102,8 +107,11 @@ var FilterFlyout = function FilterFlyout(_ref) {
102
107
 
103
108
  var apply = function apply() {
104
109
  setAllFilters(filtersObjectArray);
105
- closeFlyout();
106
- onApply(); // updates the ref so next time the flyout opens we have records of the previous filters
110
+ closeFlyout(); // From the user
111
+
112
+ onApply(); // When the user clicks apply, the action set buttons should be disabled again
113
+
114
+ setShouldDisableButtons(true); // updates the ref so next time the flyout opens we have records of the previous filters
107
115
 
108
116
  prevFiltersRef.current = JSON.stringify(filtersState);
109
117
  prevFiltersObjectArrayRef.current = JSON.stringify(filtersObjectArray);
@@ -121,7 +129,7 @@ var FilterFlyout = function FilterFlyout(_ref) {
121
129
 
122
130
  var reset = function reset() {
123
131
  // Get the initial values for the filters
124
- var initialFiltersState = getInitialStateFromFilters(filters);
132
+ var initialFiltersState = getInitialStateFromFilters(filters, FLYOUT);
125
133
  var initialFiltersObjectArray = []; // Set the state to the initial values
126
134
 
127
135
  setFiltersState(initialFiltersState);
@@ -166,6 +174,37 @@ var FilterFlyout = function FilterFlyout(_ref) {
166
174
  });
167
175
  }
168
176
 
177
+ if (type === CHECKBOX) {
178
+ /**
179
+ When all checkboxes of a group are all unselected the value still exists in the filtersObjectArray
180
+ This checks if all the checkboxes are selected = false and removes it from the array
181
+ */
182
+ var index = filtersObjectArrayCopy.findIndex(function (filter) {
183
+ return filter.id === column;
184
+ }); // If all the selected state is false remove from array
185
+
186
+ var shouldRemoveFromArray = filtersObjectArrayCopy[index].value.every(function (val) {
187
+ return val.selected === false;
188
+ });
189
+
190
+ if (shouldRemoveFromArray) {
191
+ filtersObjectArrayCopy.splice(index, 1);
192
+ }
193
+ } else if (type === DROPDOWN || type === RADIO) {
194
+ if (value === 'Any') {
195
+ /**
196
+ Checks to see if the selected value is 'Any', that means the user wants
197
+ to reset specific filter
198
+ */
199
+ var _index = filtersObjectArrayCopy.findIndex(function (filter) {
200
+ return filter.id === column;
201
+ }); // Remove it from the filters array
202
+
203
+
204
+ filtersObjectArrayCopy.splice(_index, 1);
205
+ }
206
+ }
207
+
169
208
  setFiltersObjectArray(filtersObjectArrayCopy); // Automatically apply the filters if the updateMethod is instant
170
209
 
171
210
  if (updateMethod === INSTANT) {
@@ -176,33 +215,31 @@ var FilterFlyout = function FilterFlyout(_ref) {
176
215
 
177
216
  useClickOutside(filterFlyoutRef, function (target) {
178
217
  var hasClickedOnDatePicker = target.closest('.flatpickr-calendar');
218
+ var hasClickedOnDropdown = target.className === "".concat(carbonPrefix, "--list-box__menu-item__option");
179
219
 
180
- if (!open || hasClickedOnDatePicker) {
220
+ if (!open || hasClickedOnDatePicker || hasClickedOnDropdown) {
181
221
  return;
182
222
  }
183
223
 
184
224
  cancel();
185
225
  });
186
- useEffect(function subscribeToEmitter() {
187
- // This event is emitted from the DatagridToolbar component when clearFilters is clicked in FilterSummary
188
- EventEmitter.subscribe(CLEAR_FILTERS, reset);
189
- });
226
+ useSubscribeToEventEmitter(CLEAR_FILTERS, reset);
190
227
  /** Render the individual filter component */
191
228
 
192
- var renderFilter = useCallback(function (_ref3) {
229
+ var renderFilter = function renderFilter(_ref3) {
193
230
  var type = _ref3.type,
194
231
  column = _ref3.column,
195
232
  components = _ref3.props;
196
- var key = "".concat(type, "-").concat(column, "-").concat(Math.random());
197
233
 
198
234
  if (type === DATE) {
199
- return /*#__PURE__*/React.createElement(DatePicker, _extends({
200
- key: key
201
- }, components.DatePicker, {
235
+ return /*#__PURE__*/React.createElement(DatePicker, _extends({}, components.DatePicker, {
202
236
  onChange: function onChange(value) {
203
237
  var _components$DatePicke, _components$DatePicke2;
204
238
 
205
- setFiltersState(_objectSpread(_objectSpread({}, filtersState), {}, _defineProperty({}, column, value)));
239
+ setFiltersState(_objectSpread(_objectSpread({}, filtersState), {}, _defineProperty({}, column, {
240
+ value: value,
241
+ type: type
242
+ })));
206
243
  applyFilters({
207
244
  column: column,
208
245
  value: value,
@@ -210,7 +247,7 @@ var FilterFlyout = function FilterFlyout(_ref) {
210
247
  });
211
248
  (_components$DatePicke = (_components$DatePicke2 = components.DatePicker).onChange) === null || _components$DatePicke === void 0 ? void 0 : _components$DatePicke.call(_components$DatePicke2, value);
212
249
  },
213
- value: filtersState[column],
250
+ value: filtersState[column].value,
214
251
  datePickerType: "range"
215
252
  }), /*#__PURE__*/React.createElement(DatePickerInput, _extends({
216
253
  placeholder: "mm/dd/yyyy",
@@ -221,7 +258,6 @@ var FilterFlyout = function FilterFlyout(_ref) {
221
258
  }, components.DatePickerInput.end)));
222
259
  } else if (type === NUMBER) {
223
260
  return /*#__PURE__*/React.createElement(NumberInput, _extends({
224
- key: key,
225
261
  step: 1,
226
262
  allowEmpty: true,
227
263
  hideSteppers: true
@@ -229,7 +265,10 @@ var FilterFlyout = function FilterFlyout(_ref) {
229
265
  onChange: function onChange(event) {
230
266
  var _components$NumberInp, _components$NumberInp2;
231
267
 
232
- setFiltersState(_objectSpread(_objectSpread({}, filtersState), {}, _defineProperty({}, column, event.target.value)));
268
+ setFiltersState(_objectSpread(_objectSpread({}, filtersState), {}, _defineProperty({}, column, {
269
+ value: event.target.value,
270
+ type: type
271
+ })));
233
272
  applyFilters({
234
273
  column: column,
235
274
  value: event.target.value,
@@ -237,44 +276,48 @@ var FilterFlyout = function FilterFlyout(_ref) {
237
276
  });
238
277
  (_components$NumberInp = (_components$NumberInp2 = components.NumberInput).onChange) === null || _components$NumberInp === void 0 ? void 0 : _components$NumberInp.call(_components$NumberInp2, event);
239
278
  },
240
- value: filtersState[column]
279
+ value: filtersState[column].value
241
280
  }));
242
281
  } else if (type === CHECKBOX) {
243
- return /*#__PURE__*/React.createElement(FormGroup, _extends({
244
- key: key
245
- }, components.FormGroup), filtersState[column].map(function (option) {
282
+ return /*#__PURE__*/React.createElement(FormGroup, components.FormGroup, filtersState[column].value.map(function (option) {
246
283
  return /*#__PURE__*/React.createElement(Checkbox, _extends({
247
284
  key: option.labelText
248
285
  }, option, {
249
286
  onChange: function onChange(_, _ref4) {
250
287
  var _option$onChange;
251
288
 
252
- var checked = _ref4.checked;
253
- var checkboxCopy = filtersState[column];
289
+ var isSelected = _ref4.checked;
290
+ var checkboxCopy = filtersState[column].value;
254
291
  var foundCheckbox = checkboxCopy.find(function (checkbox) {
255
292
  return checkbox.value === option.value;
256
293
  });
257
- foundCheckbox.selected = checked;
258
- setFiltersState(_objectSpread(_objectSpread({}, filtersState), {}, _defineProperty({}, column, checkboxCopy)));
294
+ foundCheckbox.selected = isSelected;
295
+ setFiltersState(_objectSpread(_objectSpread({}, filtersState), {}, _defineProperty({}, column, {
296
+ value: checkboxCopy,
297
+ type: type
298
+ })));
259
299
  applyFilters({
260
300
  column: column,
261
- value: _toConsumableArray(filtersState[column]),
301
+ value: _toConsumableArray(filtersState[column].value),
262
302
  type: type
263
303
  });
264
- (_option$onChange = option.onChange) === null || _option$onChange === void 0 ? void 0 : _option$onChange.call(option, checked);
304
+ (_option$onChange = option.onChange) === null || _option$onChange === void 0 ? void 0 : _option$onChange.call(option, isSelected);
265
305
  },
266
306
  checked: option.selected
267
307
  }));
268
308
  }));
269
309
  } else if (type === RADIO) {
270
- return /*#__PURE__*/React.createElement(FormGroup, _extends({
271
- key: key
272
- }, components.FormGroup), /*#__PURE__*/React.createElement(RadioButtonGroup, _extends({}, components.RadioButtonGroup, {
273
- valueSelected: filtersState[column],
310
+ var _filtersState$column, _filtersState$column2;
311
+
312
+ return /*#__PURE__*/React.createElement(FormGroup, components.FormGroup, /*#__PURE__*/React.createElement(RadioButtonGroup, _extends({}, components.RadioButtonGroup, {
313
+ valueSelected: ((_filtersState$column = filtersState[column]) === null || _filtersState$column === void 0 ? void 0 : _filtersState$column.value) === '' ? 'Any' : (_filtersState$column2 = filtersState[column]) === null || _filtersState$column2 === void 0 ? void 0 : _filtersState$column2.value,
274
314
  onChange: function onChange(selected) {
275
315
  var _components$RadioButt, _components$RadioButt2;
276
316
 
277
- setFiltersState(_objectSpread(_objectSpread({}, filtersState), {}, _defineProperty({}, column, selected)));
317
+ setFiltersState(_objectSpread(_objectSpread({}, filtersState), {}, _defineProperty({}, column, {
318
+ value: selected,
319
+ type: type
320
+ })));
278
321
  applyFilters({
279
322
  column: column,
280
323
  value: selected,
@@ -282,6 +325,10 @@ var FilterFlyout = function FilterFlyout(_ref) {
282
325
  });
283
326
  (_components$RadioButt = (_components$RadioButt2 = components.RadioButtonGroup).onChange) === null || _components$RadioButt === void 0 ? void 0 : _components$RadioButt.call(_components$RadioButt2, selected);
284
327
  }
328
+ }), /*#__PURE__*/React.createElement(RadioButton, {
329
+ id: "any",
330
+ labelText: "Any",
331
+ value: "Any"
285
332
  }), components.RadioButton.map(function (radio) {
286
333
  var _ref5, _radio$id;
287
334
 
@@ -290,15 +337,19 @@ var FilterFlyout = function FilterFlyout(_ref) {
290
337
  }, radio));
291
338
  })));
292
339
  } else if (type === DROPDOWN) {
293
- return /*#__PURE__*/React.createElement(Dropdown, _extends({
294
- key: key
295
- }, components.Dropdown, {
296
- selectedItem: filtersState[column],
340
+ var _filtersState$column3, _filtersState$column4;
341
+
342
+ return /*#__PURE__*/React.createElement(Dropdown, _extends({}, components.Dropdown, {
343
+ selectedItem: ((_filtersState$column3 = filtersState[column]) === null || _filtersState$column3 === void 0 ? void 0 : _filtersState$column3.value) === '' ? 'Any' : (_filtersState$column4 = filtersState[column]) === null || _filtersState$column4 === void 0 ? void 0 : _filtersState$column4.value,
344
+ items: ['Any'].concat(_toConsumableArray(components.Dropdown.items)),
297
345
  onChange: function onChange(_ref6) {
298
346
  var _components$Dropdown$, _components$Dropdown;
299
347
 
300
348
  var selectedItem = _ref6.selectedItem;
301
- setFiltersState(_objectSpread(_objectSpread({}, filtersState), {}, _defineProperty({}, column, selectedItem)));
349
+ setFiltersState(_objectSpread(_objectSpread({}, filtersState), {}, _defineProperty({}, column, {
350
+ value: selectedItem,
351
+ type: type
352
+ })));
302
353
  applyFilters({
303
354
  column: column,
304
355
  value: selectedItem,
@@ -308,9 +359,10 @@ var FilterFlyout = function FilterFlyout(_ref) {
308
359
  }
309
360
  }));
310
361
  }
311
- }, [filtersState, applyFilters, setFiltersState]);
362
+ };
312
363
  /** Renders all filters */
313
364
 
365
+
314
366
  var renderFilters = function renderFilters() {
315
367
  return filters.map(renderFilter);
316
368
  };
@@ -322,13 +374,15 @@ var FilterFlyout = function FilterFlyout(_ref) {
322
374
  kind: 'primary',
323
375
  label: primaryActionLabel,
324
376
  onClick: apply,
325
- isExpressive: false
377
+ isExpressive: false,
378
+ disabled: shouldDisableButtons
326
379
  }, {
327
380
  key: 3,
328
381
  kind: 'secondary',
329
382
  label: secondaryActionLabel,
330
383
  onClick: cancel,
331
- isExpressive: false
384
+ isExpressive: false,
385
+ disabled: shouldDisableButtons
332
386
  }],
333
387
  size: "md",
334
388
  buttonSize: "md"
@@ -348,7 +402,8 @@ var FilterFlyout = function FilterFlyout(_ref) {
348
402
  },
349
403
  iconDescription: flyoutIconDescription,
350
404
  onClick: open ? closeFlyout : openFlyout,
351
- className: cx("".concat(componentClass, "__trigger"), _defineProperty({}, "".concat(componentClass, "__trigger--open"), open))
405
+ className: cx("".concat(componentClass, "__trigger"), _defineProperty({}, "".concat(componentClass, "__trigger--open"), open)),
406
+ disabled: data.length === 0
352
407
  }), /*#__PURE__*/React.createElement("div", {
353
408
  ref: filterFlyoutRef,
354
409
  className: cx(componentClass, (_cx2 = {}, _defineProperty(_cx2, "".concat(componentClass, "--open"), open), _defineProperty(_cx2, "".concat(componentClass, "--batch"), showActionSet), _defineProperty(_cx2, "".concat(componentClass, "--instant"), !showActionSet), _cx2))
@@ -362,6 +417,11 @@ var FilterFlyout = function FilterFlyout(_ref) {
362
417
  };
363
418
 
364
419
  FilterFlyout.propTypes = {
420
+ /**
421
+ * All data rows in the table
422
+ */
423
+ data: PropTypes.array.isRequired,
424
+
365
425
  /**
366
426
  * Array of filters to render
367
427
  */