@carbon/ibm-products 1.70.0 → 1.72.0
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +8 -4
- package/css/index-full-carbon.css +1 -8
- package/css/index-full-carbon.css.map +1 -1
- package/css/index-full-carbon.min.css +1 -1
- package/css/index-full-carbon.min.css.map +1 -1
- package/css/index-without-carbon-released-only.css +1 -8
- package/css/index-without-carbon-released-only.css.map +1 -1
- package/css/index-without-carbon-released-only.min.css +1 -1
- package/css/index-without-carbon-released-only.min.css.map +1 -1
- package/css/index-without-carbon.css +1 -8
- package/css/index-without-carbon.css.map +1 -1
- package/css/index-without-carbon.min.css +1 -1
- package/css/index-without-carbon.min.css.map +1 -1
- package/css/index.css +1 -8
- package/css/index.css.map +1 -1
- package/css/index.min.css +1 -1
- package/css/index.min.css.map +1 -1
- package/es/components/CoachmarkStack/CoachmarkStack.js +11 -11
- package/es/components/CreateTearsheet/preview-components/MultiStepWithIntro.js +6 -3
- package/es/components/Datagrid/Datagrid/Datagrid.js +10 -3
- package/es/components/Datagrid/Datagrid/DatagridContent.js +6 -2
- package/es/components/Datagrid/Datagrid/DatagridEmptyBody.js +1 -1
- package/es/components/Datagrid/Datagrid/DatagridHeaderRow.js +10 -3
- package/es/components/Datagrid/Datagrid/DatagridRefBody.js +1 -1
- package/es/components/Datagrid/Datagrid/DatagridRow.js +2 -2
- package/es/components/Datagrid/Datagrid/DatagridSelectAll.js +5 -3
- package/es/components/Datagrid/Datagrid/DatagridSimpleBody.js +1 -1
- package/es/components/Datagrid/Datagrid/DatagridToolbar.js +26 -7
- package/es/components/Datagrid/Datagrid/DatagridVirtualBody.js +1 -1
- package/es/components/Datagrid/Datagrid/addons/Filtering/FilterFlyout.js +4 -0
- package/es/components/Datagrid/Datagrid/addons/Filtering/FilterPanel.js +0 -1
- package/es/components/Datagrid/Datagrid/addons/Filtering/FilterProvider.js +41 -17
- package/es/components/Datagrid/Datagrid/addons/Filtering/constants.js +7 -2
- package/es/components/Datagrid/Datagrid/addons/Filtering/hooks/useFilterContext.js +7 -0
- package/es/components/Datagrid/Datagrid/addons/Filtering/hooks/useFilters.js +103 -5
- package/es/components/Datagrid/Datagrid/addons/Filtering/hooks/useShouldDisableButtons.js +1 -0
- package/es/components/Datagrid/Datagrid/addons/Filtering/hooks/useSubscribeToEventEmitter.js +1 -0
- package/es/components/Datagrid/Datagrid/addons/Filtering/index.js +1 -0
- package/es/components/Datagrid/Datagrid/addons/Filtering/utils.js +12 -1
- package/es/components/Datagrid/Datagrid/addons/stateReducer.js +4 -7
- package/es/components/Datagrid/useDisableSelectRows.js +1 -1
- package/es/components/Datagrid/useFiltering.js +49 -52
- package/es/components/Datagrid/useInfiniteScroll.js +7 -3
- package/es/components/Datagrid/useInitialColumnSort.js +39 -0
- package/es/components/Datagrid/useSelectAllToggle.js +11 -10
- package/es/components/Datagrid/useSelectRows.js +4 -4
- package/es/components/Datagrid/useSortableColumns.js +16 -16
- package/es/components/Tearsheet/TearsheetShell.js +6 -4
- package/es/global/js/hooks/index.js +3 -2
- package/es/global/js/hooks/useFocus.js +72 -0
- package/es/global/js/hooks/useIsomorphicEffect.js +12 -0
- package/es/global/js/package-settings.js +0 -1
- package/lib/components/CoachmarkStack/CoachmarkStack.js +11 -11
- package/lib/components/CreateTearsheet/preview-components/MultiStepWithIntro.js +6 -3
- package/lib/components/Datagrid/Datagrid/Datagrid.js +10 -3
- package/lib/components/Datagrid/Datagrid/DatagridContent.js +6 -2
- package/lib/components/Datagrid/Datagrid/DatagridEmptyBody.js +1 -1
- package/lib/components/Datagrid/Datagrid/DatagridHeaderRow.js +10 -3
- package/lib/components/Datagrid/Datagrid/DatagridRefBody.js +1 -1
- package/lib/components/Datagrid/Datagrid/DatagridRow.js +2 -2
- package/lib/components/Datagrid/Datagrid/DatagridSelectAll.js +4 -2
- package/lib/components/Datagrid/Datagrid/DatagridSimpleBody.js +1 -1
- package/lib/components/Datagrid/Datagrid/DatagridToolbar.js +26 -14
- package/lib/components/Datagrid/Datagrid/DatagridVirtualBody.js +1 -1
- package/lib/components/Datagrid/Datagrid/addons/Filtering/FilterFlyout.js +4 -0
- package/lib/components/Datagrid/Datagrid/addons/Filtering/FilterPanel.js +0 -1
- package/lib/components/Datagrid/Datagrid/addons/Filtering/FilterProvider.js +37 -14
- package/lib/components/Datagrid/Datagrid/addons/Filtering/constants.js +11 -4
- package/lib/components/Datagrid/Datagrid/addons/Filtering/hooks/useFilterContext.js +7 -0
- package/lib/components/Datagrid/Datagrid/addons/Filtering/hooks/useFilters.js +99 -2
- package/lib/components/Datagrid/Datagrid/addons/Filtering/hooks/useShouldDisableButtons.js +1 -0
- package/lib/components/Datagrid/Datagrid/addons/Filtering/utils.js +11 -0
- package/lib/components/Datagrid/Datagrid/addons/stateReducer.js +4 -7
- package/lib/components/Datagrid/useDisableSelectRows.js +1 -1
- package/lib/components/Datagrid/useFiltering.js +47 -50
- package/lib/components/Datagrid/useInfiniteScroll.js +7 -3
- package/lib/components/Datagrid/useInitialColumnSort.js +47 -0
- package/lib/components/Datagrid/useSelectAllToggle.js +9 -9
- package/lib/components/Datagrid/useSelectRows.js +3 -3
- package/lib/components/Datagrid/useSortableColumns.js +18 -17
- package/lib/components/Tearsheet/TearsheetShell.js +6 -4
- package/lib/global/js/hooks/index.js +8 -1
- package/lib/global/js/hooks/useFocus.js +79 -0
- package/lib/global/js/hooks/useIsomorphicEffect.js +18 -0
- package/lib/global/js/package-settings.js +0 -1
- package/package.json +9 -8
- package/scss/components/Datagrid/styles/addons/_FilterPanel.scss +7 -8
- package/telemetry.yml +816 -0
@@ -4,6 +4,7 @@
|
|
4
4
|
* This source code is licensed under the Apache-2.0 license found in the
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
6
6
|
*/
|
7
|
+
|
7
8
|
export { default as FilterFlyout } from './FilterFlyout';
|
8
9
|
export { default as FilterPanel } from './FilterPanel';
|
9
10
|
export { FilterProvider, FilterContext } from './FilterProvider';
|
@@ -5,7 +5,7 @@
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
6
6
|
*/
|
7
7
|
|
8
|
-
import { CHECKBOX, DATE, DROPDOWN, FLYOUT, NUMBER, PANEL, RADIO } from './constants';
|
8
|
+
import { CHECKBOX, DATE, DROPDOWN, FLYOUT, MULTISELECT, NUMBER, PANEL, RADIO } from './constants';
|
9
9
|
var applyInitialFilters = function applyInitialFilters(filterState, initialFilters) {
|
10
10
|
Object.keys(filterState).forEach(function (key) {
|
11
11
|
var hasInitialFilter = initialFilters.find(function (filter) {
|
@@ -59,6 +59,17 @@ export var getInitialStateFromFilters = function getInitialStateFromFilters(filt
|
|
59
59
|
value: '',
|
60
60
|
type: type
|
61
61
|
};
|
62
|
+
} else if (type === MULTISELECT) {
|
63
|
+
initialFilterState[column] = {
|
64
|
+
value: props.MultiSelect.items.map(function (item) {
|
65
|
+
return {
|
66
|
+
id: typeof item === 'string' ? item : item.id,
|
67
|
+
value: typeof item === 'string' ? item : item.text,
|
68
|
+
selected: false
|
69
|
+
};
|
70
|
+
}),
|
71
|
+
type: type
|
72
|
+
};
|
62
73
|
}
|
63
74
|
};
|
64
75
|
if (variation === FLYOUT) {
|
@@ -92,7 +92,7 @@ export var stateReducer = function stateReducer(newState, action) {
|
|
92
92
|
if (rows) {
|
93
93
|
var newSelectedRowData = {};
|
94
94
|
rows.forEach(function (row) {
|
95
|
-
newSelectedRowData[getRowId(row, row.index)] = row;
|
95
|
+
newSelectedRowData[getRowId(row.original, row.index)] = row.original;
|
96
96
|
});
|
97
97
|
return _objectSpread(_objectSpread({}, newState), {}, {
|
98
98
|
selectedRowData: indeterminate || !isChecked ? {} : newSelectedRowData
|
@@ -111,7 +111,7 @@ export var stateReducer = function stateReducer(newState, action) {
|
|
111
111
|
}
|
112
112
|
if (_isChecked) {
|
113
113
|
return _objectSpread(_objectSpread({}, newState), {}, {
|
114
|
-
selectedRowData: _objectSpread(_objectSpread({}, newState.selectedRowData), {}, _defineProperty({}, _getRowId(rowData, rowData.index), rowData))
|
114
|
+
selectedRowData: _objectSpread(_objectSpread({}, newState.selectedRowData), {}, _defineProperty({}, _getRowId(rowData.original, rowData.index), rowData.original))
|
115
115
|
});
|
116
116
|
}
|
117
117
|
if (rowData && !_isChecked) {
|
@@ -119,7 +119,7 @@ export var stateReducer = function stateReducer(newState, action) {
|
|
119
119
|
var dataWithRemovedRow = Object.fromEntries(Object.entries(newData).filter(function (_ref5) {
|
120
120
|
var _ref6 = _slicedToArray(_ref5, 1),
|
121
121
|
key = _ref6[0];
|
122
|
-
return parseInt(key) !== parseInt(rowData.index);
|
122
|
+
return parseInt(key) !== parseInt(_getRowId(rowData.original, rowData.index));
|
123
123
|
}));
|
124
124
|
return _objectSpread(_objectSpread({}, newState), {}, {
|
125
125
|
selectedRowData: dataWithRemovedRow
|
@@ -177,10 +177,7 @@ export var stateReducer = function stateReducer(newState, action) {
|
|
177
177
|
var currentColumn = {};
|
178
178
|
currentColumn[_headerId2] = newState.columnResizing.columnWidths[_headerId2];
|
179
179
|
var allChangedColumns = newState.columnResizing.columnWidths;
|
180
|
-
|
181
|
-
if (isResizing) {
|
182
|
-
onColResizeEnd === null || onColResizeEnd === void 0 ? void 0 : onColResizeEnd(currentColumn, allChangedColumns);
|
183
|
-
}
|
180
|
+
onColResizeEnd === null || onColResizeEnd === void 0 ? void 0 : onColResizeEnd(currentColumn, allChangedColumns);
|
184
181
|
if (!isKeyEvent) {
|
185
182
|
if (typeof isKeyEvent === 'undefined') {
|
186
183
|
// Blur resizer input if it has focus and is not from a key event resize
|
@@ -13,7 +13,7 @@ var useDisableSelectRows = function useDisableSelectRows(hooks) {
|
|
13
13
|
var row = _ref.row,
|
14
14
|
instance = _ref.instance;
|
15
15
|
return [props, {
|
16
|
-
|
16
|
+
disabled: instance.shouldDisableSelectRow && instance.shouldDisableSelectRow(row)
|
17
17
|
}];
|
18
18
|
};
|
19
19
|
hooks.getRowProps.push(getRowProps);
|
@@ -10,64 +10,61 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
|
|
10
10
|
* LICENSE file in the root directory of this source tree.
|
11
11
|
*/
|
12
12
|
|
13
|
-
import { useMemo
|
14
|
-
import { pkg } from '../../settings';
|
13
|
+
import { useMemo } from 'react';
|
15
14
|
import { FilterFlyout } from './Datagrid/addons/Filtering';
|
16
|
-
import { BATCH } from './Datagrid/addons/Filtering/constants';
|
17
|
-
var
|
18
|
-
|
19
|
-
|
20
|
-
|
15
|
+
import { BATCH, CHECKBOX, DATE, MULTISELECT, NUMBER } from './Datagrid/addons/Filtering/constants';
|
16
|
+
var handleMultiFilter = function handleMultiFilter(rows, id, value) {
|
17
|
+
// gets all the items that are selected and returns their value
|
18
|
+
var selectedItems = value.filter(function (item) {
|
19
|
+
return item.selected;
|
20
|
+
}).map(function (item) {
|
21
|
+
return item.value;
|
22
|
+
});
|
21
23
|
|
24
|
+
// if the user removed all checkboxes then display all rows
|
25
|
+
if (selectedItems.length === 0) {
|
26
|
+
return rows;
|
27
|
+
}
|
28
|
+
return rows.filter(function (row) {
|
29
|
+
var rowValue = row.values[id];
|
30
|
+
return selectedItems.includes(rowValue);
|
31
|
+
});
|
32
|
+
};
|
33
|
+
var useFiltering = function useFiltering(hooks) {
|
22
34
|
/* istanbul ignore next */
|
23
35
|
var filterTypes = useMemo(function () {
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
}
|
41
|
-
});
|
42
|
-
},
|
43
|
-
number: function number(rows, id, value) {
|
44
|
-
if (value === '') {
|
45
|
-
return rows;
|
36
|
+
var _ref3;
|
37
|
+
return _ref3 = {}, _defineProperty(_ref3, DATE, function (rows, id, _ref) {
|
38
|
+
var _ref2 = _slicedToArray(_ref, 2),
|
39
|
+
startDate = _ref2[0],
|
40
|
+
endDate = _ref2[1];
|
41
|
+
return rows.filter(function (row) {
|
42
|
+
var rowValue = row.values[id];
|
43
|
+
var startDateObj = _typeof(startDate) === 'object' ? startDate : new Date(startDate);
|
44
|
+
var endDateObj = _typeof(endDate) === 'object' ? endDate : new Date(endDate);
|
45
|
+
var rowValueDateObj = _typeof(rowValue) === 'object' ? rowValue : new Date(rowValue);
|
46
|
+
if (rowValueDateObj.getTime() <= endDateObj.getTime() && rowValueDateObj.getTime() >= startDateObj.getTime()) {
|
47
|
+
// In date range
|
48
|
+
return true;
|
49
|
+
} else {
|
50
|
+
// Not in date range
|
51
|
+
return false;
|
46
52
|
}
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
});
|
52
|
-
},
|
53
|
-
checkbox: function checkbox(rows, id, value) {
|
54
|
-
// gets all the items that are selected and returns their value
|
55
|
-
var selectedItems = value.filter(function (item) {
|
56
|
-
return item.selected;
|
57
|
-
}).map(function (item) {
|
58
|
-
return item.value;
|
59
|
-
});
|
60
|
-
|
61
|
-
// if the user removed all checkboxes then display all rows
|
62
|
-
if (selectedItems.length === 0) {
|
63
|
-
return rows;
|
64
|
-
}
|
65
|
-
return rows.filter(function (row) {
|
66
|
-
var rowValue = row.values[id];
|
67
|
-
return selectedItems.includes(rowValue);
|
68
|
-
});
|
53
|
+
});
|
54
|
+
}), _defineProperty(_ref3, NUMBER, function (rows, id, value) {
|
55
|
+
if (value === '') {
|
56
|
+
return rows;
|
69
57
|
}
|
70
|
-
|
58
|
+
var parsedValue = parseInt(value);
|
59
|
+
return rows.filter(function (row) {
|
60
|
+
var rowValue = row.values[id];
|
61
|
+
return rowValue === parsedValue;
|
62
|
+
});
|
63
|
+
}), _defineProperty(_ref3, CHECKBOX, function (rows, id, value) {
|
64
|
+
return handleMultiFilter(rows, id, value);
|
65
|
+
}), _defineProperty(_ref3, MULTISELECT, function (rows, id, value) {
|
66
|
+
return handleMultiFilter(rows, id, value);
|
67
|
+
}), _ref3;
|
71
68
|
}, []);
|
72
69
|
hooks.useInstance.push(function (instance) {
|
73
70
|
var filterProps = instance.filterProps,
|
@@ -1,5 +1,5 @@
|
|
1
1
|
/**
|
2
|
-
* Copyright IBM Corp. 2020,
|
2
|
+
* Copyright IBM Corp. 2020, 2024
|
3
3
|
*
|
4
4
|
* This source code is licensed under the Apache-2.0 license found in the
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
@@ -13,14 +13,18 @@ var useInfiniteScroll = function useInfiniteScroll(hooks) {
|
|
13
13
|
useParentDimensions(hooks);
|
14
14
|
useResizeTable(hooks);
|
15
15
|
var useInstance = function useInstance(instance) {
|
16
|
+
var _tableElement;
|
16
17
|
var isFetching = instance.isFetching,
|
17
18
|
tableHeight = instance.tableHeight,
|
18
19
|
innerListRef = instance.innerListRef,
|
19
20
|
fetchMoreData = instance.fetchMoreData,
|
20
21
|
tableId = instance.tableId,
|
21
22
|
loadMoreThreshold = instance.loadMoreThreshold;
|
22
|
-
var tableElement
|
23
|
-
|
23
|
+
var tableElement;
|
24
|
+
if (typeof document !== 'undefined') {
|
25
|
+
tableElement = document.querySelector("#".concat(tableId));
|
26
|
+
}
|
27
|
+
var totalTableHeight = tableHeight || ((_tableElement = tableElement) === null || _tableElement === void 0 ? void 0 : _tableElement.clientHeight);
|
24
28
|
var loadMoreThresholdValue = typeof loadMoreThreshold === 'number' ? loadMoreThreshold : 200;
|
25
29
|
var emptyFetchData = function emptyFetchData() {};
|
26
30
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
@@ -0,0 +1,39 @@
|
|
1
|
+
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
2
|
+
/**
|
3
|
+
* Copyright IBM Corp. 2024, 2024
|
4
|
+
*
|
5
|
+
* This source code is licensed under the Apache-2.0 license found in the
|
6
|
+
* LICENSE file in the root directory of this source tree.
|
7
|
+
*/
|
8
|
+
|
9
|
+
import { useEffect, useState } from 'react';
|
10
|
+
import { getNewSortOrder } from './useSortableColumns';
|
11
|
+
export var useInitialColumnSort = function useInitialColumnSort(instance) {
|
12
|
+
var _useState = useState(false),
|
13
|
+
_useState2 = _slicedToArray(_useState, 2),
|
14
|
+
hasInitialSort = _useState2[0],
|
15
|
+
setHasInitialSort = _useState2[1];
|
16
|
+
useEffect(function () {
|
17
|
+
var initialState = instance.initialState,
|
18
|
+
headers = instance.headers,
|
19
|
+
onSort = instance.onSort,
|
20
|
+
isTableSortable = instance.isTableSortable;
|
21
|
+
var sortableColumn = initialState.sortableColumn;
|
22
|
+
var foundSortedCol = headers.some(function (h) {
|
23
|
+
return h.isSorted;
|
24
|
+
});
|
25
|
+
if (foundSortedCol || hasInitialSort || !isTableSortable) {
|
26
|
+
return;
|
27
|
+
}
|
28
|
+
if (sortableColumn) {
|
29
|
+
var columnId = sortableColumn.id,
|
30
|
+
order = sortableColumn.order;
|
31
|
+
var _getNewSortOrder = getNewSortOrder(order),
|
32
|
+
newSortDesc = _getNewSortOrder.newSortDesc,
|
33
|
+
newOrder = _getNewSortOrder.newOrder;
|
34
|
+
onSort === null || onSort === void 0 ? void 0 : onSort(columnId, newOrder);
|
35
|
+
instance.toggleSortBy(columnId, newSortDesc, false);
|
36
|
+
setHasInitialSort(true);
|
37
|
+
}
|
38
|
+
}, [instance, hasInitialSort]);
|
39
|
+
};
|
@@ -1,18 +1,18 @@
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
2
2
|
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
3
|
-
|
4
|
-
*
|
5
|
-
*
|
6
|
-
*
|
7
|
-
*
|
8
|
-
* restricted by GSA ADP Schedule Contract with IBM Corp.
|
3
|
+
/**
|
4
|
+
* Copyright IBM Corp. 2021, 2024
|
5
|
+
*
|
6
|
+
* This source code is licensed under the Apache-2.0 license found in the
|
7
|
+
* LICENSE file in the root directory of this source tree.
|
9
8
|
*/
|
10
|
-
|
11
|
-
import React, {
|
9
|
+
|
10
|
+
import React, { useState } from 'react';
|
12
11
|
import cx from 'classnames';
|
13
12
|
import { selectionColumnId } from './common-column-ids';
|
14
13
|
import SelectAllWithToggle from './Datagrid/DatagridSelectAllWithToggle';
|
15
14
|
import { pkg } from '../../settings';
|
15
|
+
import { useIsomorphicEffect } from '../../global/js/hooks';
|
16
16
|
var blockClass = "".concat(pkg.prefix, "--datagrid__select-all");
|
17
17
|
var useSelectAllToggle = function useSelectAllToggle(hooks) {
|
18
18
|
useSelectAllWithToggleComponent(hooks);
|
@@ -37,11 +37,12 @@ var useSelectAllWithToggleComponent = function useSelectAllWithToggleComponent(h
|
|
37
37
|
hooks.useInstance.push(useInstance);
|
38
38
|
};
|
39
39
|
var useAddClassNameToSelectRow = function useAddClassNameToSelectRow(hooks) {
|
40
|
-
var _useState = useState(
|
40
|
+
var _useState = useState(0),
|
41
41
|
_useState2 = _slicedToArray(_useState, 2),
|
42
42
|
windowSize = _useState2[0],
|
43
43
|
setWindowSize = _useState2[1];
|
44
|
-
|
44
|
+
useIsomorphicEffect(function () {
|
45
|
+
setWindowSize(window.innerWidth);
|
45
46
|
function updateSize() {
|
46
47
|
setWindowSize(window.innerWidth);
|
47
48
|
}
|
@@ -7,7 +7,7 @@ var _excluded = ["onChange", "title"];
|
|
7
7
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
8
8
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
9
9
|
/**
|
10
|
-
* Copyright IBM Corp. 2020,
|
10
|
+
* Copyright IBM Corp. 2020, 2024
|
11
11
|
*
|
12
12
|
* This source code is licensed under the Apache-2.0 license found in the
|
13
13
|
* LICENSE file in the root directory of this source tree.
|
@@ -87,7 +87,7 @@ var SelectRow = function SelectRow(datagridState) {
|
|
87
87
|
withStickyColumn = datagridState.withStickyColumn,
|
88
88
|
dispatch = datagridState.dispatch,
|
89
89
|
getRowId = datagridState.getRowId;
|
90
|
-
var _useState = useState(window.innerWidth),
|
90
|
+
var _useState = useState(typeof window !== 'undefined' ? window.innerWidth : ''),
|
91
91
|
_useState2 = _slicedToArray(_useState, 2),
|
92
92
|
windowSize = _useState2[0],
|
93
93
|
setWindowSize = _useState2[1];
|
@@ -100,7 +100,7 @@ var SelectRow = function SelectRow(datagridState) {
|
|
100
100
|
return window.removeEventListener('resize', updateSize);
|
101
101
|
};
|
102
102
|
}, []);
|
103
|
-
var selectDisabled = isFetching || row.getRowProps().
|
103
|
+
var selectDisabled = isFetching || row.getRowProps().disabled;
|
104
104
|
var _row$getToggleRowSele2 = row.getToggleRowSelectedProps(),
|
105
105
|
onChange = _row$getToggleRowSele2.onChange,
|
106
106
|
title = _row$getToggleRowSele2.title,
|
@@ -124,7 +124,7 @@ var SelectRow = function SelectRow(datagridState) {
|
|
124
124
|
getRowId: getRowId
|
125
125
|
});
|
126
126
|
};
|
127
|
-
var rowId = "".concat(tableId, "-").concat(row.index);
|
127
|
+
var rowId = "".concat(tableId, "-").concat(row.id, "-").concat(row.index);
|
128
128
|
return /*#__PURE__*/React.createElement(TableSelectRow, _extends({}, cellProps, selectProps, {
|
129
129
|
radio: radio,
|
130
130
|
onSelect: onSelectHandler,
|
@@ -21,6 +21,21 @@ var ordering = {
|
|
21
21
|
DESC: 'DESC',
|
22
22
|
NONE: 'NONE'
|
23
23
|
};
|
24
|
+
export var getNewSortOrder = function getNewSortOrder(sortOrder) {
|
25
|
+
var order = {
|
26
|
+
newSortDesc: undefined,
|
27
|
+
newOrder: ordering.NONE
|
28
|
+
};
|
29
|
+
if (sortOrder === false) {
|
30
|
+
order.newOrder = ordering.DESC;
|
31
|
+
order.newSortDesc = true;
|
32
|
+
}
|
33
|
+
if (sortOrder === undefined) {
|
34
|
+
order.newOrder = ordering.ASC;
|
35
|
+
order.newSortDesc = false;
|
36
|
+
}
|
37
|
+
return order;
|
38
|
+
};
|
24
39
|
var getAriaSortValue = function getAriaSortValue(col, _ref) {
|
25
40
|
var ascendingSortableLabelText = _ref.ascendingSortableLabelText,
|
26
41
|
descendingSortableLabelText = _ref.descendingSortableLabelText,
|
@@ -91,7 +106,7 @@ var useSortableColumns = function useSortableColumns(hooks) {
|
|
91
106
|
};
|
92
107
|
var Header = function Header(headerProp) {
|
93
108
|
var _cx;
|
94
|
-
return column.disableSortBy === true || column.id === 'datagridSelection' ? column.disableSortBy ? column.Header : /*#__PURE__*/React.createElement(SelectAll, instance) : /*#__PURE__*/React.createElement(Button, {
|
109
|
+
return column.disableSortBy === true || column.id === 'datagridSelection' || column.isAction ? column.disableSortBy || column.isAction ? column.Header : /*#__PURE__*/React.createElement(SelectAll, instance) : /*#__PURE__*/React.createElement(Button, {
|
95
110
|
"aria-sort": getAriaSortValue(headerProp === null || headerProp === void 0 ? void 0 : headerProp.column, {
|
96
111
|
ascendingSortableLabelText: ascendingSortableLabelText,
|
97
112
|
descendingSortableLabelText: descendingSortableLabelText,
|
@@ -119,21 +134,6 @@ var useSortableColumns = function useSortableColumns(hooks) {
|
|
119
134
|
isTableSortable: true
|
120
135
|
});
|
121
136
|
};
|
122
|
-
var getNewSortOrder = function getNewSortOrder(sortOrder) {
|
123
|
-
var order = {
|
124
|
-
newSortDesc: undefined,
|
125
|
-
newOrder: ordering.NONE
|
126
|
-
};
|
127
|
-
if (sortOrder === false) {
|
128
|
-
order.newOrder = ordering.DESC;
|
129
|
-
order.newSortDesc = true;
|
130
|
-
}
|
131
|
-
if (sortOrder === undefined) {
|
132
|
-
order.newOrder = ordering.ASC;
|
133
|
-
order.newSortDesc = false;
|
134
|
-
}
|
135
|
-
return order;
|
136
|
-
};
|
137
137
|
hooks.visibleColumns.push(sortableVisibleColumns);
|
138
138
|
hooks.useInstance.push(sortInstanceProps);
|
139
139
|
};
|
@@ -27,6 +27,7 @@ import pconsole from '../../global/js/utils/pconsole';
|
|
27
27
|
import { Button, ComposedModal, ModalHeader, ModalBody } from 'carbon-components-react';
|
28
28
|
import { ActionSet } from '../ActionSet';
|
29
29
|
import { Wrap } from '../../global/js/utils/Wrap';
|
30
|
+
import { useFocus } from '../../global/js/hooks/useFocus';
|
30
31
|
|
31
32
|
// The block part of our conventional BEM class names (bc__E--M).
|
32
33
|
var bc = "".concat(pkg.prefix, "--tearsheet");
|
@@ -97,6 +98,9 @@ export var TearsheetShell = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
97
98
|
var modalRef = ref || localRef;
|
98
99
|
var _useResizeObserver = useResizeObserver(resizer),
|
99
100
|
width = _useResizeObserver.width;
|
101
|
+
var _useFocus = useFocus(modalRef),
|
102
|
+
firstElement = _useFocus.firstElement,
|
103
|
+
keyDownListener = _useFocus.keyDownListener;
|
100
104
|
|
101
105
|
// Keep track of the stack depth and our position in it (1-based, 0=closed)
|
102
106
|
var _useState3 = useState(0),
|
@@ -133,10 +137,7 @@ export var TearsheetShell = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
133
137
|
|
134
138
|
// Callback to give the tearsheet the opportunity to claim focus
|
135
139
|
handleStackChange.claimFocus = function () {
|
136
|
-
|
137
|
-
setTimeout(function () {
|
138
|
-
return element.focus();
|
139
|
-
}, 1);
|
140
|
+
firstElement === null || firstElement === void 0 ? void 0 : firstElement.focus();
|
140
141
|
};
|
141
142
|
useEffect(function () {
|
142
143
|
var notify = function notify() {
|
@@ -204,6 +205,7 @@ export var TearsheetShell = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
204
205
|
open: open,
|
205
206
|
selectorPrimaryFocus: selectorPrimaryFocus,
|
206
207
|
onFocus: handleFocus,
|
208
|
+
onKeyDown: keyDownListener,
|
207
209
|
preventCloseOnClickOutside: !isPassive,
|
208
210
|
ref: modalRef,
|
209
211
|
selectorsFloatingMenus: [".".concat(carbon.prefix, "--overflow-menu-options"), ".".concat(carbon.prefix, "--tooltip"), '.flatpickr-calendar', ".".concat(bc, "__container")],
|
@@ -1,5 +1,5 @@
|
|
1
1
|
/**
|
2
|
-
* Copyright IBM Corp. 2020,
|
2
|
+
* Copyright IBM Corp. 2020, 2024
|
3
3
|
*
|
4
4
|
* This source code is licensed under the Apache-2.0 license found in the
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
@@ -16,4 +16,5 @@ export { useResetCreateComponent } from './useResetCreateComponent';
|
|
16
16
|
export { useRetrieveStepData } from './useRetrieveStepData';
|
17
17
|
export { useValidCreateStepCount } from './useValidCreateStepCount';
|
18
18
|
export { useControllableState } from './useControllableState';
|
19
|
-
export { usePrefix } from './usePrefix';
|
19
|
+
export { usePrefix } from './usePrefix';
|
20
|
+
export { useIsomorphicEffect } from './useIsomorphicEffect';
|
@@ -0,0 +1,72 @@
|
|
1
|
+
/**
|
2
|
+
* Copyright IBM Corp. 2024, 2024
|
3
|
+
*
|
4
|
+
* This source code is licensed under the Apache-2.0 license found in the
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
6
|
+
*/
|
7
|
+
|
8
|
+
import { pkg, carbon } from '../../../settings';
|
9
|
+
import { useCallback, useEffect } from 'react';
|
10
|
+
export var useFocus = function useFocus(modalRef) {
|
11
|
+
var tearsheetBaseClass = "".concat(pkg.prefix, "--tearsheet");
|
12
|
+
// Querying focusable element in the modal
|
13
|
+
// Query to exclude hidden elements in the modal from querySelectorAll() method
|
14
|
+
// feel free to include more if needed :)
|
15
|
+
var notQuery = ":not(.".concat(carbon.prefix, "--visually-hidden,.").concat(tearsheetBaseClass, "__header--no-close-icon,.").concat(carbon.prefix, "--btn--disabled,[aria-hidden=\"true\"],[tabindex=\"-1\"])");
|
16
|
+
// Queries to include element types button, input, select, textarea
|
17
|
+
var queryButton = "button".concat(notQuery);
|
18
|
+
var queryInput = "input".concat(notQuery);
|
19
|
+
var querySelect = "select".concat(notQuery);
|
20
|
+
var queryTextarea = "textarea".concat(notQuery);
|
21
|
+
var queryLink = "[href]".concat(notQuery);
|
22
|
+
// Final query
|
23
|
+
var query = "".concat(queryButton, ",").concat(queryLink, ",").concat(queryInput, ",").concat(querySelect, ",").concat(queryTextarea);
|
24
|
+
var getFocusable = useCallback(function () {
|
25
|
+
var _modalRef$current, _modalRef$current$inn, _modalRef$current$inn2;
|
26
|
+
// Selecting all focusable elements based on the above conditions
|
27
|
+
var focusableElements = modalRef === null || modalRef === void 0 ? void 0 : (_modalRef$current = modalRef.current) === null || _modalRef$current === void 0 ? void 0 : (_modalRef$current$inn = _modalRef$current.innerModal) === null || _modalRef$current$inn === void 0 ? void 0 : (_modalRef$current$inn2 = _modalRef$current$inn.current) === null || _modalRef$current$inn2 === void 0 ? void 0 : _modalRef$current$inn2.querySelectorAll("".concat(query));
|
28
|
+
var first = focusableElements === null || focusableElements === void 0 ? void 0 : focusableElements[0];
|
29
|
+
var last = focusableElements === null || focusableElements === void 0 ? void 0 : focusableElements[(focusableElements === null || focusableElements === void 0 ? void 0 : focusableElements.length) - 1];
|
30
|
+
var all = focusableElements;
|
31
|
+
return {
|
32
|
+
first: first,
|
33
|
+
last: last,
|
34
|
+
all: all
|
35
|
+
};
|
36
|
+
}, [modalRef, query]);
|
37
|
+
useEffect(function () {
|
38
|
+
getFocusable();
|
39
|
+
}, [getFocusable]);
|
40
|
+
var handleKeyDown = function handleKeyDown(event) {
|
41
|
+
// Checking whether the key is tab or not
|
42
|
+
if (event.key === 'Tab') {
|
43
|
+
// updating the focusable elements list
|
44
|
+
var _getFocusable = getFocusable(),
|
45
|
+
first = _getFocusable.first,
|
46
|
+
last = _getFocusable.last,
|
47
|
+
all = _getFocusable.all;
|
48
|
+
event.persist();
|
49
|
+
setTimeout(function () {
|
50
|
+
var _document, _document2;
|
51
|
+
if (event.shiftKey && !Array.prototype.includes.call(all, (_document = document) === null || _document === void 0 ? void 0 : _document.activeElement)) {
|
52
|
+
// Prevents the default "Tab" behavior
|
53
|
+
event.preventDefault();
|
54
|
+
// if the user press shift+tab and the current element not in focusable items
|
55
|
+
last === null || last === void 0 ? void 0 : last.focus();
|
56
|
+
} else if (!Array.prototype.includes.call(all, (_document2 = document) === null || _document2 === void 0 ? void 0 : _document2.activeElement)) {
|
57
|
+
event.preventDefault();
|
58
|
+
// user pressing tab key only then
|
59
|
+
// focusing the first element if the current element is not in focusable items
|
60
|
+
first === null || first === void 0 ? void 0 : first.focus();
|
61
|
+
}
|
62
|
+
}, 0);
|
63
|
+
}
|
64
|
+
};
|
65
|
+
return {
|
66
|
+
firstElement: getFocusable().first,
|
67
|
+
lastElement: getFocusable().last,
|
68
|
+
allElements: getFocusable().all,
|
69
|
+
keyDownListener: handleKeyDown,
|
70
|
+
getFocusable: getFocusable
|
71
|
+
};
|
72
|
+
};
|
@@ -0,0 +1,12 @@
|
|
1
|
+
/**
|
2
|
+
* Copyright IBM Corp. 2024, 2024
|
3
|
+
*
|
4
|
+
* This source code is licensed under the Apache-2.0 license found in the
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
6
|
+
*/
|
7
|
+
|
8
|
+
import { useEffect, useLayoutEffect } from 'react';
|
9
|
+
|
10
|
+
// Originally from `@carbon/react`, https://github.com/carbon-design-system/carbon/blob/main/packages/react/src/internal/useIsomorphicEffect.js
|
11
|
+
// useLayoutEffect on the client, useEffect on the server
|
12
|
+
export var useIsomorphicEffect = typeof window !== 'undefined' ? useLayoutEffect : useEffect;
|
@@ -101,7 +101,6 @@ var defaults = {
|
|
101
101
|
'a-new-feature': false,
|
102
102
|
'default-portal-target-body': true,
|
103
103
|
'Datagrid.useInlineEdit': false,
|
104
|
-
'Datagrid.useFiltering': false,
|
105
104
|
'Datagrid.useCustomizeColumns': false,
|
106
105
|
'ExampleComponent.secondaryIcon': false,
|
107
106
|
'ExampleComponent.useExample': false
|
@@ -91,17 +91,6 @@ var CoachmarkStack = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref)
|
|
91
91
|
var handleClickNavItem = function handleClickNavItem(itemNumber) {
|
92
92
|
setSelectedItemNumber(itemNumber);
|
93
93
|
};
|
94
|
-
var escFunction = (0, _react.useCallback)(function (event) {
|
95
|
-
if (event.key === 'Escape') {
|
96
|
-
selectedItemNumber === 0 ? handleClose(true) : handleClose(false);
|
97
|
-
}
|
98
|
-
}, [handleClose, selectedItemNumber]);
|
99
|
-
(0, _react.useEffect)(function () {
|
100
|
-
document.addEventListener('keydown', escFunction, false);
|
101
|
-
return function () {
|
102
|
-
document.removeEventListener('keydown', escFunction, false);
|
103
|
-
};
|
104
|
-
}, [escFunction]);
|
105
94
|
var handleClose = (0, _react.useCallback)(function (isParentCloseButton) {
|
106
95
|
if (isParentCloseButton) {
|
107
96
|
// Trigger slide-out animation
|
@@ -120,6 +109,17 @@ var CoachmarkStack = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref)
|
|
120
109
|
setSelectedItemNumber(0);
|
121
110
|
}
|
122
111
|
}, [onClose]);
|
112
|
+
var escFunction = (0, _react.useCallback)(function (event) {
|
113
|
+
if (event.key === 'Escape') {
|
114
|
+
selectedItemNumber === 0 ? handleClose(true) : handleClose(false);
|
115
|
+
}
|
116
|
+
}, [handleClose, selectedItemNumber]);
|
117
|
+
(0, _react.useEffect)(function () {
|
118
|
+
document.addEventListener('keydown', escFunction, false);
|
119
|
+
return function () {
|
120
|
+
document.removeEventListener('keydown', escFunction, false);
|
121
|
+
};
|
122
|
+
}, [escFunction]);
|
123
123
|
var contextValue = {
|
124
124
|
buttonProps: {
|
125
125
|
tabIndex: 0,
|
@@ -129,7 +129,8 @@ var MultiStepWithIntro = function MultiStepWithIntro(_ref) {
|
|
129
129
|
}, /*#__PURE__*/_react.default.createElement(_carbonComponentsReact.RadioTile, {
|
130
130
|
className: "".concat(_settings.pkg.prefix, "--tearsheet-create-multi-step--custom-tile"),
|
131
131
|
value: "standard",
|
132
|
-
id: "tile-1"
|
132
|
+
id: "tile-1",
|
133
|
+
tabIndex: selectedCategory === 'standard' ? 0 : -1
|
133
134
|
}, /*#__PURE__*/_react.default.createElement(_NoDataIllustration.NoDataIllustration, {
|
134
135
|
size: "lg"
|
135
136
|
}), /*#__PURE__*/_react.default.createElement("span", {
|
@@ -137,7 +138,8 @@ var MultiStepWithIntro = function MultiStepWithIntro(_ref) {
|
|
137
138
|
}, "Standard")), /*#__PURE__*/_react.default.createElement(_carbonComponentsReact.RadioTile, {
|
138
139
|
className: "".concat(_settings.pkg.prefix, "--tearsheet-create-multi-step--custom-tile"),
|
139
140
|
value: "premium",
|
140
|
-
id: "tile-2"
|
141
|
+
id: "tile-2",
|
142
|
+
tabIndex: selectedCategory === 'premium' ? 0 : -1
|
141
143
|
}, /*#__PURE__*/_react.default.createElement(_NoDataIllustration.NoDataIllustration, {
|
142
144
|
size: "lg"
|
143
145
|
}), /*#__PURE__*/_react.default.createElement("span", {
|
@@ -145,7 +147,8 @@ var MultiStepWithIntro = function MultiStepWithIntro(_ref) {
|
|
145
147
|
}, "Premium")), /*#__PURE__*/_react.default.createElement(_carbonComponentsReact.RadioTile, {
|
146
148
|
className: "".concat(_settings.pkg.prefix, "--tearsheet-create-multi-step--custom-tile"),
|
147
149
|
value: "plus",
|
148
|
-
id: "tile-3"
|
150
|
+
id: "tile-3",
|
151
|
+
tabIndex: selectedCategory === 'plus' ? 0 : -1
|
149
152
|
}, /*#__PURE__*/_react.default.createElement(_NoDataIllustration.NoDataIllustration, {
|
150
153
|
size: "lg"
|
151
154
|
}), /*#__PURE__*/_react.default.createElement("span", {
|