carbon-addons-iot-react 5.6.4 → 5.6.5
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.
|
@@ -7,13 +7,17 @@ import isNil from '../../../node_modules/lodash-es/isNil.js';
|
|
|
7
7
|
import 'core-js/modules/es.symbol.js';
|
|
8
8
|
import 'core-js/modules/es.array.concat.js';
|
|
9
9
|
import 'core-js/modules/es.array.filter.js';
|
|
10
|
+
import 'core-js/modules/es.array.includes.js';
|
|
10
11
|
import 'core-js/modules/es.array.map.js';
|
|
12
|
+
import 'core-js/modules/es.array.slice.js';
|
|
11
13
|
import 'core-js/modules/es.function.name.js';
|
|
12
14
|
import 'core-js/modules/es.object.get-own-property-descriptor.js';
|
|
13
15
|
import 'core-js/modules/es.object.get-own-property-descriptors.js';
|
|
14
16
|
import 'core-js/modules/es.object.keys.js';
|
|
15
17
|
import 'core-js/modules/es.object.to-string.js';
|
|
18
|
+
import 'core-js/modules/es.promise.js';
|
|
16
19
|
import 'core-js/modules/es.regexp.exec.js';
|
|
20
|
+
import 'core-js/modules/es.string.includes.js';
|
|
17
21
|
import 'core-js/modules/es.string.search.js';
|
|
18
22
|
import 'core-js/modules/web.dom-collections.for-each.js';
|
|
19
23
|
import React__default, { useMemo } from 'react';
|
|
@@ -250,6 +254,72 @@ var TableToolbar = function TableToolbar(_ref) {
|
|
|
250
254
|
var visibleToolbarActions = actions.filter(function (action) {
|
|
251
255
|
return !action.isOverflow && action.hidden !== true;
|
|
252
256
|
});
|
|
257
|
+
|
|
258
|
+
// Extract TableViewDropdown from customToolbarContent
|
|
259
|
+
var _useMemo = useMemo(function () {
|
|
260
|
+
var _customToolbarContent;
|
|
261
|
+
if (!customToolbarContent) {
|
|
262
|
+
return {
|
|
263
|
+
tableViewDropdown: null,
|
|
264
|
+
otherToolbarContent: null
|
|
265
|
+
};
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
// Helper function to check if a child is TableViewDropdown
|
|
269
|
+
var isTableViewDropdown = function isTableViewDropdown(child) {
|
|
270
|
+
if (!child) return false;
|
|
271
|
+
|
|
272
|
+
// Check by key (most reliable for wrapped components)
|
|
273
|
+
if (child.key && typeof child.key === 'string' && child.key.includes('table-view-dropdown')) {
|
|
274
|
+
return true;
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
// Check by type properties
|
|
278
|
+
if (child.type) {
|
|
279
|
+
// Check by displayName
|
|
280
|
+
if (child.type.displayName === 'TableViewDropdown') return true;
|
|
281
|
+
|
|
282
|
+
// Check by function name
|
|
283
|
+
if (child.type.name === 'TableViewDropdown') return true;
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
// Check by props (TableViewDropdown has specific props like 'views', 'selectedViewId')
|
|
287
|
+
if (child.props && (child.props.views !== undefined || child.props.selectedViewId !== undefined || child.props.selectedViewEdited !== undefined)) {
|
|
288
|
+
return true;
|
|
289
|
+
}
|
|
290
|
+
return false;
|
|
291
|
+
};
|
|
292
|
+
|
|
293
|
+
// Extract children from Fragment if present
|
|
294
|
+
var contentToProcess = customToolbarContent;
|
|
295
|
+
|
|
296
|
+
// Check if it's a Fragment (React.Fragment has type as Symbol or Fragment)
|
|
297
|
+
if (customToolbarContent.type === React__default.Fragment && (_customToolbarContent = customToolbarContent.props) !== null && _customToolbarContent !== void 0 && _customToolbarContent.children) {
|
|
298
|
+
contentToProcess = customToolbarContent.props.children;
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
// Convert to array (handles both single element and multiple children)
|
|
302
|
+
var contentArray = React__default.Children.toArray(contentToProcess);
|
|
303
|
+
|
|
304
|
+
// Always check the first element
|
|
305
|
+
var firstElement = contentArray[0];
|
|
306
|
+
if (isTableViewDropdown(firstElement)) {
|
|
307
|
+
// First element is TableViewDropdown - extract it, rest is other content
|
|
308
|
+
var remainingContent = contentArray.slice(1);
|
|
309
|
+
return {
|
|
310
|
+
tableViewDropdown: firstElement,
|
|
311
|
+
otherToolbarContent: remainingContent.length > 0 ? remainingContent : null
|
|
312
|
+
};
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
// First element is not TableViewDropdown - all content is other content
|
|
316
|
+
return {
|
|
317
|
+
tableViewDropdown: null,
|
|
318
|
+
otherToolbarContent: contentArray.length > 0 ? contentArray : null
|
|
319
|
+
};
|
|
320
|
+
}, [customToolbarContent]),
|
|
321
|
+
tableViewDropdown = _useMemo.tableViewDropdown,
|
|
322
|
+
otherToolbarContent = _useMemo.otherToolbarContent;
|
|
253
323
|
var visibleBatchActions = batchActions.filter(function (action) {
|
|
254
324
|
return !action.isOverflow && action.hidden !== true;
|
|
255
325
|
});
|
|
@@ -389,7 +459,7 @@ var TableToolbar = function TableToolbar(_ref) {
|
|
|
389
459
|
, {
|
|
390
460
|
"data-testid": "".concat(testID || testId, "-content"),
|
|
391
461
|
className: "".concat(iotPrefix, "--table-toolbar-content")
|
|
392
|
-
}, hasSearch ? /*#__PURE__*/React__default.createElement(TableToolbarSearch, {
|
|
462
|
+
}, tableViewDropdown || null, hasSearch ? /*#__PURE__*/React__default.createElement(TableToolbarSearch, {
|
|
393
463
|
tableId: tableId,
|
|
394
464
|
i18n: i18n,
|
|
395
465
|
options: {
|
|
@@ -532,8 +602,8 @@ var TableToolbar = function TableToolbar(_ref) {
|
|
|
532
602
|
itemText: "",
|
|
533
603
|
disabled: true
|
|
534
604
|
})) : null,
|
|
535
|
-
//
|
|
536
|
-
|
|
605
|
+
// Render other custom toolbar content
|
|
606
|
+
otherToolbarContent || null));
|
|
537
607
|
};
|
|
538
608
|
TableToolbar.propTypes = propTypes;
|
|
539
609
|
TableToolbar.defaultProps = defaultProps;
|
|
@@ -9,13 +9,17 @@ var isNil = require('../../../node_modules/lodash-es/isNil.js');
|
|
|
9
9
|
require('core-js/modules/es.symbol.js');
|
|
10
10
|
require('core-js/modules/es.array.concat.js');
|
|
11
11
|
require('core-js/modules/es.array.filter.js');
|
|
12
|
+
require('core-js/modules/es.array.includes.js');
|
|
12
13
|
require('core-js/modules/es.array.map.js');
|
|
14
|
+
require('core-js/modules/es.array.slice.js');
|
|
13
15
|
require('core-js/modules/es.function.name.js');
|
|
14
16
|
require('core-js/modules/es.object.get-own-property-descriptor.js');
|
|
15
17
|
require('core-js/modules/es.object.get-own-property-descriptors.js');
|
|
16
18
|
require('core-js/modules/es.object.keys.js');
|
|
17
19
|
require('core-js/modules/es.object.to-string.js');
|
|
20
|
+
require('core-js/modules/es.promise.js');
|
|
18
21
|
require('core-js/modules/es.regexp.exec.js');
|
|
22
|
+
require('core-js/modules/es.string.includes.js');
|
|
19
23
|
require('core-js/modules/es.string.search.js');
|
|
20
24
|
require('core-js/modules/web.dom-collections.for-each.js');
|
|
21
25
|
var React = require('react');
|
|
@@ -262,6 +266,72 @@ var TableToolbar = function TableToolbar(_ref) {
|
|
|
262
266
|
var visibleToolbarActions = actions.filter(function (action) {
|
|
263
267
|
return !action.isOverflow && action.hidden !== true;
|
|
264
268
|
});
|
|
269
|
+
|
|
270
|
+
// Extract TableViewDropdown from customToolbarContent
|
|
271
|
+
var _useMemo = React.useMemo(function () {
|
|
272
|
+
var _customToolbarContent;
|
|
273
|
+
if (!customToolbarContent) {
|
|
274
|
+
return {
|
|
275
|
+
tableViewDropdown: null,
|
|
276
|
+
otherToolbarContent: null
|
|
277
|
+
};
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
// Helper function to check if a child is TableViewDropdown
|
|
281
|
+
var isTableViewDropdown = function isTableViewDropdown(child) {
|
|
282
|
+
if (!child) return false;
|
|
283
|
+
|
|
284
|
+
// Check by key (most reliable for wrapped components)
|
|
285
|
+
if (child.key && typeof child.key === 'string' && child.key.includes('table-view-dropdown')) {
|
|
286
|
+
return true;
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
// Check by type properties
|
|
290
|
+
if (child.type) {
|
|
291
|
+
// Check by displayName
|
|
292
|
+
if (child.type.displayName === 'TableViewDropdown') return true;
|
|
293
|
+
|
|
294
|
+
// Check by function name
|
|
295
|
+
if (child.type.name === 'TableViewDropdown') return true;
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
// Check by props (TableViewDropdown has specific props like 'views', 'selectedViewId')
|
|
299
|
+
if (child.props && (child.props.views !== undefined || child.props.selectedViewId !== undefined || child.props.selectedViewEdited !== undefined)) {
|
|
300
|
+
return true;
|
|
301
|
+
}
|
|
302
|
+
return false;
|
|
303
|
+
};
|
|
304
|
+
|
|
305
|
+
// Extract children from Fragment if present
|
|
306
|
+
var contentToProcess = customToolbarContent;
|
|
307
|
+
|
|
308
|
+
// Check if it's a Fragment (React.Fragment has type as Symbol or Fragment)
|
|
309
|
+
if (customToolbarContent.type === React__default.default.Fragment && (_customToolbarContent = customToolbarContent.props) !== null && _customToolbarContent !== void 0 && _customToolbarContent.children) {
|
|
310
|
+
contentToProcess = customToolbarContent.props.children;
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
// Convert to array (handles both single element and multiple children)
|
|
314
|
+
var contentArray = React__default.default.Children.toArray(contentToProcess);
|
|
315
|
+
|
|
316
|
+
// Always check the first element
|
|
317
|
+
var firstElement = contentArray[0];
|
|
318
|
+
if (isTableViewDropdown(firstElement)) {
|
|
319
|
+
// First element is TableViewDropdown - extract it, rest is other content
|
|
320
|
+
var remainingContent = contentArray.slice(1);
|
|
321
|
+
return {
|
|
322
|
+
tableViewDropdown: firstElement,
|
|
323
|
+
otherToolbarContent: remainingContent.length > 0 ? remainingContent : null
|
|
324
|
+
};
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
// First element is not TableViewDropdown - all content is other content
|
|
328
|
+
return {
|
|
329
|
+
tableViewDropdown: null,
|
|
330
|
+
otherToolbarContent: contentArray.length > 0 ? contentArray : null
|
|
331
|
+
};
|
|
332
|
+
}, [customToolbarContent]),
|
|
333
|
+
tableViewDropdown = _useMemo.tableViewDropdown,
|
|
334
|
+
otherToolbarContent = _useMemo.otherToolbarContent;
|
|
265
335
|
var visibleBatchActions = batchActions.filter(function (action) {
|
|
266
336
|
return !action.isOverflow && action.hidden !== true;
|
|
267
337
|
});
|
|
@@ -401,7 +471,7 @@ var TableToolbar = function TableToolbar(_ref) {
|
|
|
401
471
|
, {
|
|
402
472
|
"data-testid": "".concat(testID || testId, "-content"),
|
|
403
473
|
className: "".concat(iotPrefix, "--table-toolbar-content")
|
|
404
|
-
}, hasSearch ? /*#__PURE__*/React__default.default.createElement(TableToolbarSearch, {
|
|
474
|
+
}, tableViewDropdown || null, hasSearch ? /*#__PURE__*/React__default.default.createElement(TableToolbarSearch, {
|
|
405
475
|
tableId: tableId,
|
|
406
476
|
i18n: i18n,
|
|
407
477
|
options: {
|
|
@@ -544,8 +614,8 @@ var TableToolbar = function TableToolbar(_ref) {
|
|
|
544
614
|
itemText: "",
|
|
545
615
|
disabled: true
|
|
546
616
|
})) : null,
|
|
547
|
-
//
|
|
548
|
-
|
|
617
|
+
// Render other custom toolbar content
|
|
618
|
+
otherToolbarContent || null));
|
|
549
619
|
};
|
|
550
620
|
TableToolbar.propTypes = propTypes;
|
|
551
621
|
TableToolbar.defaultProps = defaultProps;
|