carbon-addons-iot-react 2.149.1-next.2 → 2.150.0-next.2

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/CHANGELOG.md CHANGED
@@ -3,6 +3,41 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ # [2.150.0-next.2](https://github.com/carbon-design-system/carbon-addons-iot-react/compare/v2.150.0-next.1...v2.150.0-next.2) (2022-06-03)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * **piechartcard:** removed testID proptype that is in cardproptypes ([9f642a0](https://github.com/carbon-design-system/carbon-addons-iot-react/commit/9f642a089a303a94e8b0e9d3167b2d8792c26788))
12
+ * **tablehead:** update default value for tableID to prevent warning ([0d61ca0](https://github.com/carbon-design-system/carbon-addons-iot-react/commit/0d61ca01ab5fe8b3419cc7c483c65b08ea415b28))
13
+
14
+
15
+
16
+
17
+
18
+ # [2.150.0-next.1](https://github.com/carbon-design-system/carbon-addons-iot-react/compare/v2.150.0-next.0...v2.150.0-next.1) (2022-06-03)
19
+
20
+
21
+ ### Features
22
+
23
+ * **tableheader:** hide toolbar if no bactch actions and supply count ([039feb3](https://github.com/carbon-design-system/carbon-addons-iot-react/commit/039feb3156675b934d560bf0d36af6a83af79f9e))
24
+ * **tabletoolbar:** change check to be prop based for backwards compat ([69cf408](https://github.com/carbon-design-system/carbon-addons-iot-react/commit/69cf4081fd1c36e590f3747622ad5eb8196f7968))
25
+
26
+
27
+
28
+
29
+
30
+ # [2.150.0-next.0](https://github.com/carbon-design-system/carbon-addons-iot-react/compare/v2.149.1-next.2...v2.150.0-next.0) (2022-06-02)
31
+
32
+
33
+ ### Features
34
+
35
+ * **SuiteHeader:** Including workspaceId in the `GET /uiresources` API call to make sure that the app data returned by the api matches the selected workspace. ([d1e2d3b](https://github.com/carbon-design-system/carbon-addons-iot-react/commit/d1e2d3bc60f0878f8364c3292804689bc56565e3))
36
+
37
+
38
+
39
+
40
+
6
41
  ## [2.149.1-next.2](https://github.com/carbon-design-system/carbon-addons-iot-react/compare/v2.149.1-next.1...v2.149.1-next.2) (2022-05-31)
7
42
 
8
43
 
@@ -10,6 +10,8 @@ var useUiResources = function useUiResources(_ref) {
10
10
  lang = _ref$lang === void 0 ? 'en' : _ref$lang,
11
11
  _ref$surveyId = _ref.surveyId,
12
12
  surveyId = _ref$surveyId === void 0 ? null : _ref$surveyId,
13
+ _ref$workspaceId = _ref.workspaceId,
14
+ workspaceId = _ref$workspaceId === void 0 ? null : _ref$workspaceId,
13
15
  _ref$fetchApi = _ref.fetchApi,
14
16
  fetchApi = _ref$fetchApi === void 0 ? defaultFetchApi : _ref$fetchApi,
15
17
  _ref$isTest = _ref.isTest,
@@ -51,6 +53,7 @@ var useUiResources = function useUiResources(_ref) {
51
53
  baseApiUrl: baseApiUrl,
52
54
  lang: lang,
53
55
  surveyId: surveyId,
56
+ workspaceId: workspaceId,
54
57
  fetchApi: fetchApi,
55
58
  isTest: isTest
56
59
  });
@@ -77,7 +80,7 @@ var useUiResources = function useUiResources(_ref) {
77
80
  }
78
81
  }
79
82
  }, _callee, null, [[0, 8, 11, 14]]);
80
- })), [baseApiUrl, lang, surveyId, isTest, setIsLoading]); // eslint-disable-line react-hooks/exhaustive-deps
83
+ })), [baseApiUrl, lang, surveyId, workspaceId, isTest, setIsLoading]); // eslint-disable-line react-hooks/exhaustive-deps
81
84
 
82
85
  useEffect(function () {
83
86
  // load actual data
@@ -46,13 +46,13 @@ var defaultFetchApi = /*#__PURE__*/function () {
46
46
 
47
47
  var getUiResourcesData = /*#__PURE__*/function () {
48
48
  var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(_ref2) {
49
- var baseApiUrl, _ref2$lang, lang, _ref2$surveyId, surveyId, _ref2$fetchApi, fetchApi, _ref2$isTest, isTest, api, langParam, surveyIdParam;
49
+ var baseApiUrl, _ref2$lang, lang, _ref2$surveyId, surveyId, _ref2$workspaceId, workspaceId, _ref2$fetchApi, fetchApi, _ref2$isTest, isTest, api, langParam, surveyIdParam, workspaceIdParam;
50
50
 
51
51
  return _regeneratorRuntime.wrap(function _callee2$(_context2) {
52
52
  while (1) {
53
53
  switch (_context2.prev = _context2.next) {
54
54
  case 0:
55
- baseApiUrl = _ref2.baseApiUrl, _ref2$lang = _ref2.lang, lang = _ref2$lang === void 0 ? 'en' : _ref2$lang, _ref2$surveyId = _ref2.surveyId, surveyId = _ref2$surveyId === void 0 ? null : _ref2$surveyId, _ref2$fetchApi = _ref2.fetchApi, fetchApi = _ref2$fetchApi === void 0 ? defaultFetchApi : _ref2$fetchApi, _ref2$isTest = _ref2.isTest, isTest = _ref2$isTest === void 0 ? false : _ref2$isTest;
55
+ baseApiUrl = _ref2.baseApiUrl, _ref2$lang = _ref2.lang, lang = _ref2$lang === void 0 ? 'en' : _ref2$lang, _ref2$surveyId = _ref2.surveyId, surveyId = _ref2$surveyId === void 0 ? null : _ref2$surveyId, _ref2$workspaceId = _ref2.workspaceId, workspaceId = _ref2$workspaceId === void 0 ? null : _ref2$workspaceId, _ref2$fetchApi = _ref2.fetchApi, fetchApi = _ref2$fetchApi === void 0 ? defaultFetchApi : _ref2$fetchApi, _ref2$isTest = _ref2.isTest, isTest = _ref2$isTest === void 0 ? false : _ref2$isTest;
56
56
 
57
57
  api = function api(method, path, body, headers) {
58
58
  return fetchApi(method, "".concat(baseApiUrl).concat(path), body, headers, isTest ? fixture[path.split('?')[0]] : null);
@@ -60,9 +60,10 @@ var getUiResourcesData = /*#__PURE__*/function () {
60
60
 
61
61
  langParam = "&lang=".concat(lang);
62
62
  surveyIdParam = surveyId ? "&surveyId=".concat(surveyId) : '';
63
- return _context2.abrupt("return", api('GET', "/uiresources?id=masthead".concat(langParam).concat(surveyIdParam)));
63
+ workspaceIdParam = workspaceId ? "&workspaceId=".concat(workspaceId) : '';
64
+ return _context2.abrupt("return", api('GET', "/uiresources?id=masthead".concat(langParam).concat(surveyIdParam).concat(workspaceIdParam)));
64
65
 
65
- case 5:
66
+ case 6:
66
67
  case "end":
67
68
  return _context2.stop();
68
69
  }
@@ -96,6 +96,11 @@ var propTypes = {
96
96
  hasPagination: PropTypes.bool,
97
97
  hasRowSelection: PropTypes.oneOf(['multi', 'single', false]),
98
98
 
99
+ /** @TODO: Remove in major release and just show action bar when no actions are defined */
100
+
101
+ /* option to hide batch action toolbar */
102
+ hasBatchActionToolbar: PropTypes.bool,
103
+
99
104
  /** True if the rows should be expandable */
100
105
  hasRowExpansion: PropTypes.oneOfType([PropTypes.bool, PropTypes.shape({
101
106
  /** True if any previously expanded rows should be collapsed when a new row is expanded */
@@ -418,6 +423,7 @@ var defaultProps = function defaultProps(baseProps) {
418
423
  hasPagination: false,
419
424
  hasRowSelection: false,
420
425
  hasRowExpansion: false,
426
+ hasBatchActionToolbar: true,
421
427
  hasRowActions: false,
422
428
  hasRowNesting: false,
423
429
  hasRowEdit: false,
@@ -874,7 +880,7 @@ var Table = function Table(props) {
874
880
  }
875
881
  }
876
882
  }),
877
- options: _objectSpread(_objectSpread({}, pick(options, 'hasAggregations', 'hasColumnSelection', 'hasFastSearch', 'hasSearch', 'hasRowSelection', 'hasRowCountInHeader', 'hasRowEdit', 'hasUserViewManagement')), {}, {
883
+ options: _objectSpread(_objectSpread({}, pick(options, 'hasAggregations', 'hasColumnSelection', 'hasFastSearch', 'hasSearch', 'hasRowSelection', 'hasRowCountInHeader', 'hasRowEdit', 'hasUserViewManagement', 'hasBatchActionToolbar')), {}, {
878
884
  hasFilter: Boolean(options === null || options === void 0 ? void 0 : options.hasFilter),
879
885
  hasAdvancedFilter: Boolean(options === null || options === void 0 ? void 0 : options.hasAdvancedFilter)
880
886
  }),
@@ -1174,6 +1180,11 @@ Table.__docgenInfo = {
1174
1180
  }],
1175
1181
  "required": false
1176
1182
  },
1183
+ "hasBatchActionToolbar": {
1184
+ "name": "bool",
1185
+ "description": "@TODO: Remove in major release and just show action bar when no actions are defined",
1186
+ "required": false
1187
+ },
1177
1188
  "hasRowExpansion": {
1178
1189
  "name": "union",
1179
1190
  "value": [{
@@ -150,7 +150,6 @@ var defaultProps = {
150
150
  closeMenuText: 'Close menu',
151
151
  i18n: _objectSpread({}, defaultI18NPropTypes),
152
152
  hasFastFilter: true,
153
- testID: '',
154
153
  testId: '',
155
154
  showExpanderColumn: false,
156
155
  size: undefined
@@ -837,18 +836,6 @@ TableHead.__docgenInfo = {
837
836
  "required": false,
838
837
  "description": "should we filter on each keypress"
839
838
  },
840
- "testID": {
841
- "defaultValue": {
842
- "value": "''",
843
- "computed": false
844
- },
845
- "type": {
846
- "name": "custom",
847
- "raw": "deprecate(\n PropTypes.string,\n `The 'testID' prop has been deprecated. Please use 'testId' instead.`\n)"
848
- },
849
- "required": false,
850
- "description": ""
851
- },
852
839
  "testId": {
853
840
  "defaultValue": {
854
841
  "value": "''",
@@ -1020,6 +1007,14 @@ TableHead.__docgenInfo = {
1020
1007
  },
1021
1008
  "required": true,
1022
1009
  "description": ""
1010
+ },
1011
+ "testID": {
1012
+ "type": {
1013
+ "name": "custom",
1014
+ "raw": "deprecate(\n PropTypes.string,\n `The 'testID' prop has been deprecated. Please use 'testId' instead.`\n)"
1015
+ },
1016
+ "required": false,
1017
+ "description": ""
1023
1018
  }
1024
1019
  }
1025
1020
  };
@@ -48,6 +48,9 @@ var propTypes = {
48
48
  hasAdvancedFilter: PropTypes.bool,
49
49
  hasAggregations: PropTypes.bool,
50
50
 
51
+ /* option to hide batch action toolbar */
52
+ hasBatchActionToolbar: PropTypes.bool,
53
+
51
54
  /** If true, search is applied as typed. If false, only after 'Enter' is pressed */
52
55
  hasFastSearch: PropTypes.bool,
53
56
  hasFilter: PropTypes.bool,
@@ -195,6 +198,7 @@ var TableToolbar = function TableToolbar(_ref) {
195
198
  hasRowCountInHeader = _ref$options.hasRowCountInHeader,
196
199
  hasRowEdit = _ref$options.hasRowEdit,
197
200
  hasUserViewManagement = _ref$options.hasUserViewManagement,
201
+ hasBatchActionToolbar = _ref$options.hasBatchActionToolbar,
198
202
  _ref$actions = _ref.actions,
199
203
  onCancelBatchAction = _ref$actions.onCancelBatchAction,
200
204
  onApplyBatchAction = _ref$actions.onApplyBatchAction,
@@ -266,13 +270,30 @@ var TableToolbar = function TableToolbar(_ref) {
266
270
  var visibleOverflowBatchActions = batchActions.filter(function (action) {
267
271
  return action.isOverflow && action.hidden !== true;
268
272
  });
273
+ var hasVisibleBatchActions = visibleBatchActions.length > 0;
269
274
  var hasVisibleOverflowBatchActions = visibleOverflowBatchActions.length > 0;
275
+ var totalSelectedText = useMemo(function () {
276
+ if (totalSelected > 1) {
277
+ if (typeof i18n.itemsSelected === 'function') {
278
+ return i18n.itemsSelected(totalSelected);
279
+ }
280
+
281
+ return "".concat(totalSelected, " ").concat(i18n.itemsSelected);
282
+ }
283
+
284
+ if (typeof i18n.itemSelected === 'function') {
285
+ return i18n.itemSelected(totalSelected);
286
+ }
287
+
288
+ return "".concat(totalSelected, " ").concat(i18n.itemSelected);
289
+ /* eslint-disable-next-line react-hooks/exhaustive-deps */
290
+ }, [i18n.itemSelected, i18n.itemsSelected, totalSelected]);
270
291
  return /*#__PURE__*/React__default.createElement(TableToolbar$1 // TODO: remove deprecated 'testID' in v3
271
292
  , {
272
293
  "data-testid": testID || testId,
273
294
  className: classnames("".concat(iotPrefix, "--table-toolbar"), className),
274
295
  "aria-label": i18n.toolbarLabelAria
275
- }, /*#__PURE__*/React__default.createElement(TableBatchActions // TODO: remove deprecated 'testID' in v3
296
+ }, hasBatchActionToolbar ? /*#__PURE__*/React__default.createElement(TableBatchActions // TODO: remove deprecated 'testID' in v3
276
297
  , {
277
298
  "data-testid": "".concat(testID || testId, "-batch-actions"),
278
299
  className: "".concat(iotPrefix, "--table-batch-actions"),
@@ -286,7 +307,7 @@ var TableToolbar = function TableToolbar(_ref) {
286
307
 
287
308
  return tableTranslateWithId.apply(void 0, [i18n].concat(args));
288
309
  }
289
- }, visibleBatchActions.map(function (_ref3) {
310
+ }, hasVisibleBatchActions && visibleBatchActions.map(function (_ref3) {
290
311
  var id = _ref3.id,
291
312
  labelText = _ref3.labelText,
292
313
  disabled = _ref3.disabled,
@@ -339,12 +360,17 @@ var TableToolbar = function TableToolbar(_ref) {
339
360
  isDelete: isDelete,
340
361
  "aria-label": labelText
341
362
  });
342
- })) : null), secondaryTitle ?
363
+ })) : null) : null, secondaryTitle ?
343
364
  /*#__PURE__*/
344
365
  // eslint-disable-next-line jsx-a11y/label-has-associated-control, jsx-a11y/label-has-for
345
366
  React__default.createElement("label", {
346
367
  className: "".concat(iotPrefix, "--table-toolbar-secondary-title")
347
- }, secondaryTitle) : null, // Deprecated in favor of secondaryTitle for a more general use-case
368
+ }, secondaryTitle) : !hasBatchActionToolbar && shouldShowBatchActions ?
369
+ /*#__PURE__*/
370
+ // eslint-disable-next-line jsx-a11y/label-has-associated-control, jsx-a11y/label-has-for
371
+ React__default.createElement("label", {
372
+ className: "".concat(iotPrefix, "--table-toolbar-secondary-title")
373
+ }, totalSelectedText) : null, // Deprecated in favor of secondaryTitle for a more general use-case
348
374
  hasRowCountInHeader ?
349
375
  /*#__PURE__*/
350
376
  // eslint-disable-next-line jsx-a11y/label-has-associated-control, jsx-a11y/label-has-for
@@ -671,6 +697,10 @@ TableToolbar.__docgenInfo = {
671
697
  "name": "bool",
672
698
  "required": false
673
699
  },
700
+ "hasBatchActionToolbar": {
701
+ "name": "bool",
702
+ "required": false
703
+ },
674
704
  "hasFastSearch": {
675
705
  "name": "bool",
676
706
  "description": "If true, search is applied as typed. If false, only after 'Enter' is pressed",
@@ -378,7 +378,6 @@ var PieCardPropTypes = {
378
378
  pieChart: OverridePropTypes,
379
379
  table: OverridePropTypes
380
380
  }),
381
- testID: PropTypes.string,
382
381
 
383
382
  /**
384
383
  * array of data objects from the backend for instance [{group: 'Group A', value: 50}, {group: 'Group B', value: 50}, ...]
@@ -18,6 +18,8 @@ var useUiResources = function useUiResources(_ref) {
18
18
  lang = _ref$lang === void 0 ? 'en' : _ref$lang,
19
19
  _ref$surveyId = _ref.surveyId,
20
20
  surveyId = _ref$surveyId === void 0 ? null : _ref$surveyId,
21
+ _ref$workspaceId = _ref.workspaceId,
22
+ workspaceId = _ref$workspaceId === void 0 ? null : _ref$workspaceId,
21
23
  _ref$fetchApi = _ref.fetchApi,
22
24
  fetchApi = _ref$fetchApi === void 0 ? uiresources.defaultFetchApi : _ref$fetchApi,
23
25
  _ref$isTest = _ref.isTest,
@@ -59,6 +61,7 @@ var useUiResources = function useUiResources(_ref) {
59
61
  baseApiUrl: baseApiUrl,
60
62
  lang: lang,
61
63
  surveyId: surveyId,
64
+ workspaceId: workspaceId,
62
65
  fetchApi: fetchApi,
63
66
  isTest: isTest
64
67
  });
@@ -85,7 +88,7 @@ var useUiResources = function useUiResources(_ref) {
85
88
  }
86
89
  }
87
90
  }, _callee, null, [[0, 8, 11, 14]]);
88
- })), [baseApiUrl, lang, surveyId, isTest, setIsLoading]); // eslint-disable-line react-hooks/exhaustive-deps
91
+ })), [baseApiUrl, lang, surveyId, workspaceId, isTest, setIsLoading]); // eslint-disable-line react-hooks/exhaustive-deps
89
92
 
90
93
  React.useEffect(function () {
91
94
  // load actual data
@@ -55,13 +55,13 @@ var defaultFetchApi = /*#__PURE__*/function () {
55
55
 
56
56
  var getUiResourcesData = /*#__PURE__*/function () {
57
57
  var _ref3 = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee2(_ref2) {
58
- var baseApiUrl, _ref2$lang, lang, _ref2$surveyId, surveyId, _ref2$fetchApi, fetchApi, _ref2$isTest, isTest, api, langParam, surveyIdParam;
58
+ var baseApiUrl, _ref2$lang, lang, _ref2$surveyId, surveyId, _ref2$workspaceId, workspaceId, _ref2$fetchApi, fetchApi, _ref2$isTest, isTest, api, langParam, surveyIdParam, workspaceIdParam;
59
59
 
60
60
  return _regeneratorRuntime__default['default'].wrap(function _callee2$(_context2) {
61
61
  while (1) {
62
62
  switch (_context2.prev = _context2.next) {
63
63
  case 0:
64
- baseApiUrl = _ref2.baseApiUrl, _ref2$lang = _ref2.lang, lang = _ref2$lang === void 0 ? 'en' : _ref2$lang, _ref2$surveyId = _ref2.surveyId, surveyId = _ref2$surveyId === void 0 ? null : _ref2$surveyId, _ref2$fetchApi = _ref2.fetchApi, fetchApi = _ref2$fetchApi === void 0 ? defaultFetchApi : _ref2$fetchApi, _ref2$isTest = _ref2.isTest, isTest = _ref2$isTest === void 0 ? false : _ref2$isTest;
64
+ baseApiUrl = _ref2.baseApiUrl, _ref2$lang = _ref2.lang, lang = _ref2$lang === void 0 ? 'en' : _ref2$lang, _ref2$surveyId = _ref2.surveyId, surveyId = _ref2$surveyId === void 0 ? null : _ref2$surveyId, _ref2$workspaceId = _ref2.workspaceId, workspaceId = _ref2$workspaceId === void 0 ? null : _ref2$workspaceId, _ref2$fetchApi = _ref2.fetchApi, fetchApi = _ref2$fetchApi === void 0 ? defaultFetchApi : _ref2$fetchApi, _ref2$isTest = _ref2.isTest, isTest = _ref2$isTest === void 0 ? false : _ref2$isTest;
65
65
 
66
66
  api = function api(method, path, body, headers) {
67
67
  return fetchApi(method, "".concat(baseApiUrl).concat(path), body, headers, isTest ? uiresources_fixture[path.split('?')[0]] : null);
@@ -69,9 +69,10 @@ var getUiResourcesData = /*#__PURE__*/function () {
69
69
 
70
70
  langParam = "&lang=".concat(lang);
71
71
  surveyIdParam = surveyId ? "&surveyId=".concat(surveyId) : '';
72
- return _context2.abrupt("return", api('GET', "/uiresources?id=masthead".concat(langParam).concat(surveyIdParam)));
72
+ workspaceIdParam = workspaceId ? "&workspaceId=".concat(workspaceId) : '';
73
+ return _context2.abrupt("return", api('GET', "/uiresources?id=masthead".concat(langParam).concat(surveyIdParam).concat(workspaceIdParam)));
73
74
 
74
- case 5:
75
+ case 6:
75
76
  case "end":
76
77
  return _context2.stop();
77
78
  }
@@ -113,6 +113,11 @@ var propTypes = {
113
113
  hasPagination: PropTypes__default['default'].bool,
114
114
  hasRowSelection: PropTypes__default['default'].oneOf(['multi', 'single', false]),
115
115
 
116
+ /** @TODO: Remove in major release and just show action bar when no actions are defined */
117
+
118
+ /* option to hide batch action toolbar */
119
+ hasBatchActionToolbar: PropTypes__default['default'].bool,
120
+
116
121
  /** True if the rows should be expandable */
117
122
  hasRowExpansion: PropTypes__default['default'].oneOfType([PropTypes__default['default'].bool, PropTypes__default['default'].shape({
118
123
  /** True if any previously expanded rows should be collapsed when a new row is expanded */
@@ -435,6 +440,7 @@ var defaultProps = function defaultProps(baseProps) {
435
440
  hasPagination: false,
436
441
  hasRowSelection: false,
437
442
  hasRowExpansion: false,
443
+ hasBatchActionToolbar: true,
438
444
  hasRowActions: false,
439
445
  hasRowNesting: false,
440
446
  hasRowEdit: false,
@@ -891,7 +897,7 @@ var Table = function Table(props) {
891
897
  }
892
898
  }
893
899
  }),
894
- options: _objectSpread(_objectSpread({}, pick(options, 'hasAggregations', 'hasColumnSelection', 'hasFastSearch', 'hasSearch', 'hasRowSelection', 'hasRowCountInHeader', 'hasRowEdit', 'hasUserViewManagement')), {}, {
900
+ options: _objectSpread(_objectSpread({}, pick(options, 'hasAggregations', 'hasColumnSelection', 'hasFastSearch', 'hasSearch', 'hasRowSelection', 'hasRowCountInHeader', 'hasRowEdit', 'hasUserViewManagement', 'hasBatchActionToolbar')), {}, {
895
901
  hasFilter: Boolean(options === null || options === void 0 ? void 0 : options.hasFilter),
896
902
  hasAdvancedFilter: Boolean(options === null || options === void 0 ? void 0 : options.hasAdvancedFilter)
897
903
  }),
@@ -1191,6 +1197,11 @@ Table.__docgenInfo = {
1191
1197
  }],
1192
1198
  "required": false
1193
1199
  },
1200
+ "hasBatchActionToolbar": {
1201
+ "name": "bool",
1202
+ "description": "@TODO: Remove in major release and just show action bar when no actions are defined",
1203
+ "required": false
1204
+ },
1194
1205
  "hasRowExpansion": {
1195
1206
  "name": "union",
1196
1207
  "value": [{
@@ -161,7 +161,6 @@ var defaultProps = {
161
161
  closeMenuText: 'Close menu',
162
162
  i18n: _objectSpread({}, TablePropTypes.defaultI18NPropTypes),
163
163
  hasFastFilter: true,
164
- testID: '',
165
164
  testId: '',
166
165
  showExpanderColumn: false,
167
166
  size: undefined
@@ -848,18 +847,6 @@ TableHead.__docgenInfo = {
848
847
  "required": false,
849
848
  "description": "should we filter on each keypress"
850
849
  },
851
- "testID": {
852
- "defaultValue": {
853
- "value": "''",
854
- "computed": false
855
- },
856
- "type": {
857
- "name": "custom",
858
- "raw": "deprecate(\n PropTypes.string,\n `The 'testID' prop has been deprecated. Please use 'testId' instead.`\n)"
859
- },
860
- "required": false,
861
- "description": ""
862
- },
863
850
  "testId": {
864
851
  "defaultValue": {
865
852
  "value": "''",
@@ -1031,6 +1018,14 @@ TableHead.__docgenInfo = {
1031
1018
  },
1032
1019
  "required": true,
1033
1020
  "description": ""
1021
+ },
1022
+ "testID": {
1023
+ "type": {
1024
+ "name": "custom",
1025
+ "raw": "deprecate(\n PropTypes.string,\n `The 'testID' prop has been deprecated. Please use 'testId' instead.`\n)"
1026
+ },
1027
+ "required": false,
1028
+ "description": ""
1034
1029
  }
1035
1030
  }
1036
1031
  };
@@ -60,6 +60,9 @@ var propTypes = {
60
60
  hasAdvancedFilter: PropTypes__default['default'].bool,
61
61
  hasAggregations: PropTypes__default['default'].bool,
62
62
 
63
+ /* option to hide batch action toolbar */
64
+ hasBatchActionToolbar: PropTypes__default['default'].bool,
65
+
63
66
  /** If true, search is applied as typed. If false, only after 'Enter' is pressed */
64
67
  hasFastSearch: PropTypes__default['default'].bool,
65
68
  hasFilter: PropTypes__default['default'].bool,
@@ -207,6 +210,7 @@ var TableToolbar = function TableToolbar(_ref) {
207
210
  hasRowCountInHeader = _ref$options.hasRowCountInHeader,
208
211
  hasRowEdit = _ref$options.hasRowEdit,
209
212
  hasUserViewManagement = _ref$options.hasUserViewManagement,
213
+ hasBatchActionToolbar = _ref$options.hasBatchActionToolbar,
210
214
  _ref$actions = _ref.actions,
211
215
  onCancelBatchAction = _ref$actions.onCancelBatchAction,
212
216
  onApplyBatchAction = _ref$actions.onApplyBatchAction,
@@ -278,13 +282,30 @@ var TableToolbar = function TableToolbar(_ref) {
278
282
  var visibleOverflowBatchActions = batchActions.filter(function (action) {
279
283
  return action.isOverflow && action.hidden !== true;
280
284
  });
285
+ var hasVisibleBatchActions = visibleBatchActions.length > 0;
281
286
  var hasVisibleOverflowBatchActions = visibleOverflowBatchActions.length > 0;
287
+ var totalSelectedText = React.useMemo(function () {
288
+ if (totalSelected > 1) {
289
+ if (typeof i18n.itemsSelected === 'function') {
290
+ return i18n.itemsSelected(totalSelected);
291
+ }
292
+
293
+ return "".concat(totalSelected, " ").concat(i18n.itemsSelected);
294
+ }
295
+
296
+ if (typeof i18n.itemSelected === 'function') {
297
+ return i18n.itemSelected(totalSelected);
298
+ }
299
+
300
+ return "".concat(totalSelected, " ").concat(i18n.itemSelected);
301
+ /* eslint-disable-next-line react-hooks/exhaustive-deps */
302
+ }, [i18n.itemSelected, i18n.itemsSelected, totalSelected]);
282
303
  return /*#__PURE__*/React__default['default'].createElement(carbonComponentsReact.TableToolbar // TODO: remove deprecated 'testID' in v3
283
304
  , {
284
305
  "data-testid": testID || testId,
285
306
  className: classnames__default['default']("".concat(iotPrefix, "--table-toolbar"), className),
286
307
  "aria-label": i18n.toolbarLabelAria
287
- }, /*#__PURE__*/React__default['default'].createElement(carbonComponentsReact.TableBatchActions // TODO: remove deprecated 'testID' in v3
308
+ }, hasBatchActionToolbar ? /*#__PURE__*/React__default['default'].createElement(carbonComponentsReact.TableBatchActions // TODO: remove deprecated 'testID' in v3
288
309
  , {
289
310
  "data-testid": "".concat(testID || testId, "-batch-actions"),
290
311
  className: "".concat(iotPrefix, "--table-batch-actions"),
@@ -298,7 +319,7 @@ var TableToolbar = function TableToolbar(_ref) {
298
319
 
299
320
  return componentUtilityFunctions.tableTranslateWithId.apply(void 0, [i18n].concat(args));
300
321
  }
301
- }, visibleBatchActions.map(function (_ref3) {
322
+ }, hasVisibleBatchActions && visibleBatchActions.map(function (_ref3) {
302
323
  var id = _ref3.id,
303
324
  labelText = _ref3.labelText,
304
325
  disabled = _ref3.disabled,
@@ -351,12 +372,17 @@ var TableToolbar = function TableToolbar(_ref) {
351
372
  isDelete: isDelete,
352
373
  "aria-label": labelText
353
374
  });
354
- })) : null), secondaryTitle ?
375
+ })) : null) : null, secondaryTitle ?
355
376
  /*#__PURE__*/
356
377
  // eslint-disable-next-line jsx-a11y/label-has-associated-control, jsx-a11y/label-has-for
357
378
  React__default['default'].createElement("label", {
358
379
  className: "".concat(iotPrefix, "--table-toolbar-secondary-title")
359
- }, secondaryTitle) : null, // Deprecated in favor of secondaryTitle for a more general use-case
380
+ }, secondaryTitle) : !hasBatchActionToolbar && shouldShowBatchActions ?
381
+ /*#__PURE__*/
382
+ // eslint-disable-next-line jsx-a11y/label-has-associated-control, jsx-a11y/label-has-for
383
+ React__default['default'].createElement("label", {
384
+ className: "".concat(iotPrefix, "--table-toolbar-secondary-title")
385
+ }, totalSelectedText) : null, // Deprecated in favor of secondaryTitle for a more general use-case
360
386
  hasRowCountInHeader ?
361
387
  /*#__PURE__*/
362
388
  // eslint-disable-next-line jsx-a11y/label-has-associated-control, jsx-a11y/label-has-for
@@ -683,6 +709,10 @@ TableToolbar.__docgenInfo = {
683
709
  "name": "bool",
684
710
  "required": false
685
711
  },
712
+ "hasBatchActionToolbar": {
713
+ "name": "bool",
714
+ "required": false
715
+ },
686
716
  "hasFastSearch": {
687
717
  "name": "bool",
688
718
  "description": "If true, search is applied as typed. If false, only after 'Enter' is pressed",
@@ -387,7 +387,6 @@ var PieCardPropTypes = {
387
387
  pieChart: SharedPropTypes.OverridePropTypes,
388
388
  table: SharedPropTypes.OverridePropTypes
389
389
  }),
390
- testID: PropTypes__default['default'].string,
391
390
 
392
391
  /**
393
392
  * array of data objects from the backend for instance [{group: 'Group A', value: 50}, {group: 'Group B', value: 50}, ...]
package/package.json CHANGED
@@ -340,10 +340,10 @@
340
340
  "whatwg-fetch": "^3.0.0"
341
341
  },
342
342
  "sideEffects": false,
343
- "version": "2.149.1-next.2",
343
+ "version": "2.150.0-next.2",
344
344
  "resolutions": {
345
345
  "chokidar": "3.3.1",
346
346
  "react-grid-layout": "1.2.2"
347
347
  },
348
- "gitHead": "6373f5a17b3eeb8a1ac8e69e74bbddd6955f6c0a"
348
+ "gitHead": "8d88ec637eb1ac95a37b0395e5b8a13a9830ffa7"
349
349
  }
@@ -33525,7 +33525,6 @@
33525
33525
  closeMenuText: 'Close menu',
33526
33526
  i18n: _objectSpread$1Z({}, defaultI18NPropTypes),
33527
33527
  hasFastFilter: true,
33528
- testID: '',
33529
33528
  testId: '',
33530
33529
  showExpanderColumn: false,
33531
33530
  size: undefined
@@ -34212,18 +34211,6 @@
34212
34211
  "required": false,
34213
34212
  "description": "should we filter on each keypress"
34214
34213
  },
34215
- "testID": {
34216
- "defaultValue": {
34217
- "value": "''",
34218
- "computed": false
34219
- },
34220
- "type": {
34221
- "name": "custom",
34222
- "raw": "deprecate(\n PropTypes.string,\n `The 'testID' prop has been deprecated. Please use 'testId' instead.`\n)"
34223
- },
34224
- "required": false,
34225
- "description": ""
34226
- },
34227
34214
  "testId": {
34228
34215
  "defaultValue": {
34229
34216
  "value": "''",
@@ -34395,6 +34382,14 @@
34395
34382
  },
34396
34383
  "required": true,
34397
34384
  "description": ""
34385
+ },
34386
+ "testID": {
34387
+ "type": {
34388
+ "name": "custom",
34389
+ "raw": "deprecate(\n PropTypes.string,\n `The 'testID' prop has been deprecated. Please use 'testId' instead.`\n)"
34390
+ },
34391
+ "required": false,
34392
+ "description": ""
34398
34393
  }
34399
34394
  }
34400
34395
  };
@@ -36363,6 +36358,9 @@
36363
36358
  hasAdvancedFilter: PropTypes__default['default'].bool,
36364
36359
  hasAggregations: PropTypes__default['default'].bool,
36365
36360
 
36361
+ /* option to hide batch action toolbar */
36362
+ hasBatchActionToolbar: PropTypes__default['default'].bool,
36363
+
36366
36364
  /** If true, search is applied as typed. If false, only after 'Enter' is pressed */
36367
36365
  hasFastSearch: PropTypes__default['default'].bool,
36368
36366
  hasFilter: PropTypes__default['default'].bool,
@@ -36510,6 +36508,7 @@
36510
36508
  hasRowCountInHeader = _ref$options.hasRowCountInHeader,
36511
36509
  hasRowEdit = _ref$options.hasRowEdit,
36512
36510
  hasUserViewManagement = _ref$options.hasUserViewManagement,
36511
+ hasBatchActionToolbar = _ref$options.hasBatchActionToolbar,
36513
36512
  _ref$actions = _ref.actions,
36514
36513
  onCancelBatchAction = _ref$actions.onCancelBatchAction,
36515
36514
  onApplyBatchAction = _ref$actions.onApplyBatchAction,
@@ -36581,13 +36580,30 @@
36581
36580
  var visibleOverflowBatchActions = batchActions.filter(function (action) {
36582
36581
  return action.isOverflow && action.hidden !== true;
36583
36582
  });
36583
+ var hasVisibleBatchActions = visibleBatchActions.length > 0;
36584
36584
  var hasVisibleOverflowBatchActions = visibleOverflowBatchActions.length > 0;
36585
+ var totalSelectedText = React$1.useMemo(function () {
36586
+ if (totalSelected > 1) {
36587
+ if (typeof i18n.itemsSelected === 'function') {
36588
+ return i18n.itemsSelected(totalSelected);
36589
+ }
36590
+
36591
+ return "".concat(totalSelected, " ").concat(i18n.itemsSelected);
36592
+ }
36593
+
36594
+ if (typeof i18n.itemSelected === 'function') {
36595
+ return i18n.itemSelected(totalSelected);
36596
+ }
36597
+
36598
+ return "".concat(totalSelected, " ").concat(i18n.itemSelected);
36599
+ /* eslint-disable-next-line react-hooks/exhaustive-deps */
36600
+ }, [i18n.itemSelected, i18n.itemsSelected, totalSelected]);
36585
36601
  return /*#__PURE__*/React__default['default'].createElement(carbonComponentsReact.TableToolbar // TODO: remove deprecated 'testID' in v3
36586
36602
  , {
36587
36603
  "data-testid": testID || testId,
36588
36604
  className: classnames$1("".concat(iotPrefix$20, "--table-toolbar"), className),
36589
36605
  "aria-label": i18n.toolbarLabelAria
36590
- }, /*#__PURE__*/React__default['default'].createElement(carbonComponentsReact.TableBatchActions // TODO: remove deprecated 'testID' in v3
36606
+ }, hasBatchActionToolbar ? /*#__PURE__*/React__default['default'].createElement(carbonComponentsReact.TableBatchActions // TODO: remove deprecated 'testID' in v3
36591
36607
  , {
36592
36608
  "data-testid": "".concat(testID || testId, "-batch-actions"),
36593
36609
  className: "".concat(iotPrefix$20, "--table-batch-actions"),
@@ -36601,7 +36617,7 @@
36601
36617
 
36602
36618
  return tableTranslateWithId.apply(void 0, [i18n].concat(args));
36603
36619
  }
36604
- }, visibleBatchActions.map(function (_ref3) {
36620
+ }, hasVisibleBatchActions && visibleBatchActions.map(function (_ref3) {
36605
36621
  var id = _ref3.id,
36606
36622
  labelText = _ref3.labelText,
36607
36623
  disabled = _ref3.disabled,
@@ -36654,12 +36670,17 @@
36654
36670
  isDelete: isDelete,
36655
36671
  "aria-label": labelText
36656
36672
  });
36657
- })) : null), secondaryTitle ?
36673
+ })) : null) : null, secondaryTitle ?
36674
+ /*#__PURE__*/
36675
+ // eslint-disable-next-line jsx-a11y/label-has-associated-control, jsx-a11y/label-has-for
36676
+ React__default['default'].createElement("label", {
36677
+ className: "".concat(iotPrefix$20, "--table-toolbar-secondary-title")
36678
+ }, secondaryTitle) : !hasBatchActionToolbar && shouldShowBatchActions ?
36658
36679
  /*#__PURE__*/
36659
36680
  // eslint-disable-next-line jsx-a11y/label-has-associated-control, jsx-a11y/label-has-for
36660
36681
  React__default['default'].createElement("label", {
36661
36682
  className: "".concat(iotPrefix$20, "--table-toolbar-secondary-title")
36662
- }, secondaryTitle) : null, // Deprecated in favor of secondaryTitle for a more general use-case
36683
+ }, totalSelectedText) : null, // Deprecated in favor of secondaryTitle for a more general use-case
36663
36684
  hasRowCountInHeader ?
36664
36685
  /*#__PURE__*/
36665
36686
  // eslint-disable-next-line jsx-a11y/label-has-associated-control, jsx-a11y/label-has-for
@@ -36986,6 +37007,10 @@
36986
37007
  "name": "bool",
36987
37008
  "required": false
36988
37009
  },
37010
+ "hasBatchActionToolbar": {
37011
+ "name": "bool",
37012
+ "required": false
37013
+ },
36989
37014
  "hasFastSearch": {
36990
37015
  "name": "bool",
36991
37016
  "description": "If true, search is applied as typed. If false, only after 'Enter' is pressed",
@@ -43668,6 +43693,11 @@
43668
43693
  hasPagination: PropTypes__default['default'].bool,
43669
43694
  hasRowSelection: PropTypes__default['default'].oneOf(['multi', 'single', false]),
43670
43695
 
43696
+ /** @TODO: Remove in major release and just show action bar when no actions are defined */
43697
+
43698
+ /* option to hide batch action toolbar */
43699
+ hasBatchActionToolbar: PropTypes__default['default'].bool,
43700
+
43671
43701
  /** True if the rows should be expandable */
43672
43702
  hasRowExpansion: PropTypes__default['default'].oneOfType([PropTypes__default['default'].bool, PropTypes__default['default'].shape({
43673
43703
  /** True if any previously expanded rows should be collapsed when a new row is expanded */
@@ -43990,6 +44020,7 @@
43990
44020
  hasPagination: false,
43991
44021
  hasRowSelection: false,
43992
44022
  hasRowExpansion: false,
44023
+ hasBatchActionToolbar: true,
43993
44024
  hasRowActions: false,
43994
44025
  hasRowNesting: false,
43995
44026
  hasRowEdit: false,
@@ -44446,7 +44477,7 @@
44446
44477
  }
44447
44478
  }
44448
44479
  }),
44449
- options: _objectSpread$1R(_objectSpread$1R({}, pick(options, 'hasAggregations', 'hasColumnSelection', 'hasFastSearch', 'hasSearch', 'hasRowSelection', 'hasRowCountInHeader', 'hasRowEdit', 'hasUserViewManagement')), {}, {
44480
+ options: _objectSpread$1R(_objectSpread$1R({}, pick(options, 'hasAggregations', 'hasColumnSelection', 'hasFastSearch', 'hasSearch', 'hasRowSelection', 'hasRowCountInHeader', 'hasRowEdit', 'hasUserViewManagement', 'hasBatchActionToolbar')), {}, {
44450
44481
  hasFilter: Boolean(options === null || options === void 0 ? void 0 : options.hasFilter),
44451
44482
  hasAdvancedFilter: Boolean(options === null || options === void 0 ? void 0 : options.hasAdvancedFilter)
44452
44483
  }),
@@ -44746,6 +44777,11 @@
44746
44777
  }],
44747
44778
  "required": false
44748
44779
  },
44780
+ "hasBatchActionToolbar": {
44781
+ "name": "bool",
44782
+ "description": "@TODO: Remove in major release and just show action bar when no actions are defined",
44783
+ "required": false
44784
+ },
44749
44785
  "hasRowExpansion": {
44750
44786
  "name": "union",
44751
44787
  "value": [{
@@ -103093,7 +103129,6 @@
103093
103129
  pieChart: OverridePropTypes,
103094
103130
  table: OverridePropTypes
103095
103131
  }),
103096
- testID: PropTypes__default['default'].string,
103097
103132
 
103098
103133
  /**
103099
103134
  * array of data objects from the backend for instance [{group: 'Group A', value: 50}, {group: 'Group B', value: 50}, ...]
@@ -122058,13 +122093,13 @@
122058
122093
 
122059
122094
  var getUiResourcesData = /*#__PURE__*/function () {
122060
122095
  var _ref3 = asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee2(_ref2) {
122061
- var baseApiUrl, _ref2$lang, lang, _ref2$surveyId, surveyId, _ref2$fetchApi, fetchApi, _ref2$isTest, isTest, api, langParam, surveyIdParam;
122096
+ var baseApiUrl, _ref2$lang, lang, _ref2$surveyId, surveyId, _ref2$workspaceId, workspaceId, _ref2$fetchApi, fetchApi, _ref2$isTest, isTest, api, langParam, surveyIdParam, workspaceIdParam;
122062
122097
 
122063
122098
  return regenerator.wrap(function _callee2$(_context2) {
122064
122099
  while (1) {
122065
122100
  switch (_context2.prev = _context2.next) {
122066
122101
  case 0:
122067
- baseApiUrl = _ref2.baseApiUrl, _ref2$lang = _ref2.lang, lang = _ref2$lang === void 0 ? 'en' : _ref2$lang, _ref2$surveyId = _ref2.surveyId, surveyId = _ref2$surveyId === void 0 ? null : _ref2$surveyId, _ref2$fetchApi = _ref2.fetchApi, fetchApi = _ref2$fetchApi === void 0 ? defaultFetchApi : _ref2$fetchApi, _ref2$isTest = _ref2.isTest, isTest = _ref2$isTest === void 0 ? false : _ref2$isTest;
122102
+ baseApiUrl = _ref2.baseApiUrl, _ref2$lang = _ref2.lang, lang = _ref2$lang === void 0 ? 'en' : _ref2$lang, _ref2$surveyId = _ref2.surveyId, surveyId = _ref2$surveyId === void 0 ? null : _ref2$surveyId, _ref2$workspaceId = _ref2.workspaceId, workspaceId = _ref2$workspaceId === void 0 ? null : _ref2$workspaceId, _ref2$fetchApi = _ref2.fetchApi, fetchApi = _ref2$fetchApi === void 0 ? defaultFetchApi : _ref2$fetchApi, _ref2$isTest = _ref2.isTest, isTest = _ref2$isTest === void 0 ? false : _ref2$isTest;
122068
122103
 
122069
122104
  api = function api(method, path, body, headers) {
122070
122105
  return fetchApi(method, "".concat(baseApiUrl).concat(path), body, headers, isTest ? fixture[path.split('?')[0]] : null);
@@ -122072,9 +122107,10 @@
122072
122107
 
122073
122108
  langParam = "&lang=".concat(lang);
122074
122109
  surveyIdParam = surveyId ? "&surveyId=".concat(surveyId) : '';
122075
- return _context2.abrupt("return", api('GET', "/uiresources?id=masthead".concat(langParam).concat(surveyIdParam)));
122110
+ workspaceIdParam = workspaceId ? "&workspaceId=".concat(workspaceId) : '';
122111
+ return _context2.abrupt("return", api('GET', "/uiresources?id=masthead".concat(langParam).concat(surveyIdParam).concat(workspaceIdParam)));
122076
122112
 
122077
- case 5:
122113
+ case 6:
122078
122114
  case "end":
122079
122115
  return _context2.stop();
122080
122116
  }
@@ -122093,6 +122129,8 @@
122093
122129
  lang = _ref$lang === void 0 ? 'en' : _ref$lang,
122094
122130
  _ref$surveyId = _ref.surveyId,
122095
122131
  surveyId = _ref$surveyId === void 0 ? null : _ref$surveyId,
122132
+ _ref$workspaceId = _ref.workspaceId,
122133
+ workspaceId = _ref$workspaceId === void 0 ? null : _ref$workspaceId,
122096
122134
  _ref$fetchApi = _ref.fetchApi,
122097
122135
  fetchApi = _ref$fetchApi === void 0 ? defaultFetchApi : _ref$fetchApi,
122098
122136
  _ref$isTest = _ref.isTest,
@@ -122134,6 +122172,7 @@
122134
122172
  baseApiUrl: baseApiUrl,
122135
122173
  lang: lang,
122136
122174
  surveyId: surveyId,
122175
+ workspaceId: workspaceId,
122137
122176
  fetchApi: fetchApi,
122138
122177
  isTest: isTest
122139
122178
  });
@@ -122160,7 +122199,7 @@
122160
122199
  }
122161
122200
  }
122162
122201
  }, _callee, null, [[0, 8, 11, 14]]);
122163
- })), [baseApiUrl, lang, surveyId, isTest, setIsLoading]); // eslint-disable-line react-hooks/exhaustive-deps
122202
+ })), [baseApiUrl, lang, surveyId, workspaceId, isTest, setIsLoading]); // eslint-disable-line react-hooks/exhaustive-deps
122164
122203
 
122165
122204
  React$1.useEffect(function () {
122166
122205
  // load actual data