@carbon/ibm-products 2.10.2 → 2.11.1
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +7 -0
- package/css/index-full-carbon.css +71 -26
- package/css/index-full-carbon.css.map +1 -1
- package/css/index-full-carbon.min.css +3 -3
- package/css/index-full-carbon.min.css.map +1 -1
- package/css/index-without-carbon-released-only.css +1 -0
- package/css/index-without-carbon-released-only.css.map +1 -1
- package/css/index-without-carbon-released-only.min.css.map +1 -1
- package/css/index-without-carbon.css +71 -26
- package/css/index-without-carbon.css.map +1 -1
- package/css/index-without-carbon.min.css +3 -3
- package/css/index-without-carbon.min.css.map +1 -1
- package/css/index.css +68 -25
- package/css/index.css.map +1 -1
- package/css/index.min.css +2 -2
- package/css/index.min.css.map +1 -1
- package/es/components/APIKeyModal/APIKeyModal.js +10 -3
- package/es/components/AboutModal/AboutModal.js +10 -3
- package/es/components/ButtonSetWithOverflow/ButtonSetWithOverflow.js +17 -5
- package/es/components/CreateModal/CreateModal.js +10 -3
- package/es/components/Datagrid/Datagrid/DatagridContent.js +9 -7
- package/es/components/Datagrid/Datagrid/DatagridEmptyBody.js +3 -2
- package/es/components/Datagrid/Datagrid/DatagridExpandedRow.js +26 -13
- package/es/components/Datagrid/Datagrid/DatagridRow.js +47 -40
- package/es/components/Datagrid/Datagrid/DatagridToolbar.js +30 -37
- package/es/components/Datagrid/Datagrid/DraggableElement.js +36 -132
- package/es/components/Datagrid/Datagrid/addons/CustomizeColumns/Columns.js +17 -49
- package/es/components/Datagrid/Datagrid/addons/CustomizeColumns/DraggableItemsList.js +125 -40
- package/es/components/Datagrid/Extensions/ExpandableRow/ExpandableRow.docs-page.js +1 -1
- package/es/components/Datagrid/useExpandedRow.js +1 -1
- package/es/components/Datagrid/useNestedRowExpander.js +22 -9
- package/es/components/Datagrid/useRowExpander.js +22 -9
- package/es/components/Datagrid/utils/DatagridActions.js +1 -1
- package/es/components/Datagrid/utils/DatagridPagination.js +1 -1
- package/es/components/Datagrid/utils/getArgTypes.js +12 -0
- package/es/components/EditTearsheet/EditTearsheet.js +47 -38
- package/es/components/EditTearsheet/EditTearsheetForm.js +6 -0
- package/es/components/EditTearsheet/preview-components/MultiFormEditTearsheet.js +6 -1
- package/es/components/EmptyStates/EmptyState.js +1 -1
- package/es/components/EmptyStates/ErrorEmptyState/ErrorEmptyState.js +1 -1
- package/es/components/EmptyStates/NoDataEmptyState/NoDataEmptyState.js +1 -1
- package/es/components/EmptyStates/NoTagsEmptyState/NoTagsEmptyState.js +1 -1
- package/es/components/EmptyStates/NotFoundEmptyState/NotFoundEmptyState.js +1 -1
- package/es/components/EmptyStates/NotificationsEmptyState/NotificationsEmptyState.js +1 -1
- package/es/components/EmptyStates/UnauthorizedEmptyState/UnauthorizedEmptyState.js +1 -1
- package/es/components/EmptyStates/assets/ErrorIllustration.js +6 -11
- package/es/components/EmptyStates/assets/NoDataIllustration.js +6 -11
- package/es/components/EmptyStates/assets/NoTagsIllustration.js +6 -12
- package/es/components/EmptyStates/assets/NotFoundIllustration.js +6 -12
- package/es/components/EmptyStates/assets/NotificationsIllustration.js +6 -12
- package/es/components/EmptyStates/assets/UnauthorizedIllustration.js +6 -12
- package/es/components/ExportModal/ExportModal.js +10 -3
- package/es/components/ImportModal/ImportModal.js +10 -3
- package/es/components/RemoveModal/RemoveModal.js +10 -3
- package/es/components/TagSet/TagSet.js +5 -21
- package/es/components/TagSet/TagSetModal.js +7 -3
- package/es/components/Tearsheet/Tearsheet.js +2 -2
- package/es/components/Tearsheet/TearsheetNarrow.js +2 -2
- package/es/components/Tearsheet/TearsheetShell.js +14 -28
- package/es/global/decorators/sidePanelDecorator.js +7 -0
- package/es/global/js/hooks/usePortalTarget.js +30 -0
- package/es/global/js/hooks/useRetrieveFormTitles.js +20 -0
- package/es/global/js/hooks/useWindowScroll.js +5 -0
- package/es/global/js/package-settings.js +0 -1
- package/es/global/js/utils/getNodeTextContent.js +47 -0
- package/flags.js +6 -0
- package/lib/components/APIKeyModal/APIKeyModal.js +10 -3
- package/lib/components/AboutModal/AboutModal.js +10 -3
- package/lib/components/ButtonSetWithOverflow/ButtonSetWithOverflow.js +17 -5
- package/lib/components/CreateModal/CreateModal.js +10 -3
- package/lib/components/Datagrid/Datagrid/DatagridContent.js +9 -7
- package/lib/components/Datagrid/Datagrid/DatagridEmptyBody.js +2 -1
- package/lib/components/Datagrid/Datagrid/DatagridExpandedRow.js +26 -13
- package/lib/components/Datagrid/Datagrid/DatagridRow.js +46 -41
- package/lib/components/Datagrid/Datagrid/DatagridToolbar.js +30 -37
- package/lib/components/Datagrid/Datagrid/DraggableElement.js +37 -137
- package/lib/components/Datagrid/Datagrid/addons/CustomizeColumns/Columns.js +20 -49
- package/lib/components/Datagrid/Datagrid/addons/CustomizeColumns/DraggableItemsList.js +130 -47
- package/lib/components/Datagrid/Extensions/ExpandableRow/ExpandableRow.docs-page.js +1 -1
- package/lib/components/Datagrid/useExpandedRow.js +1 -1
- package/lib/components/Datagrid/useNestedRowExpander.js +24 -9
- package/lib/components/Datagrid/useRowExpander.js +24 -9
- package/lib/components/Datagrid/utils/DatagridActions.js +1 -1
- package/lib/components/Datagrid/utils/DatagridPagination.js +1 -1
- package/lib/components/Datagrid/utils/getArgTypes.js +12 -0
- package/lib/components/EditTearsheet/EditTearsheet.js +47 -38
- package/lib/components/EditTearsheet/EditTearsheetForm.js +6 -0
- package/lib/components/EditTearsheet/preview-components/MultiFormEditTearsheet.js +6 -1
- package/lib/components/EmptyStates/EmptyState.js +1 -1
- package/lib/components/EmptyStates/ErrorEmptyState/ErrorEmptyState.js +1 -1
- package/lib/components/EmptyStates/NoDataEmptyState/NoDataEmptyState.js +1 -1
- package/lib/components/EmptyStates/NoTagsEmptyState/NoTagsEmptyState.js +1 -1
- package/lib/components/EmptyStates/NotFoundEmptyState/NotFoundEmptyState.js +1 -1
- package/lib/components/EmptyStates/NotificationsEmptyState/NotificationsEmptyState.js +1 -1
- package/lib/components/EmptyStates/UnauthorizedEmptyState/UnauthorizedEmptyState.js +1 -1
- package/lib/components/EmptyStates/assets/ErrorIllustration.js +6 -11
- package/lib/components/EmptyStates/assets/NoDataIllustration.js +6 -11
- package/lib/components/EmptyStates/assets/NoTagsIllustration.js +6 -12
- package/lib/components/EmptyStates/assets/NotFoundIllustration.js +6 -12
- package/lib/components/EmptyStates/assets/NotificationsIllustration.js +6 -12
- package/lib/components/EmptyStates/assets/UnauthorizedIllustration.js +6 -12
- package/lib/components/ExportModal/ExportModal.js +10 -3
- package/lib/components/ImportModal/ImportModal.js +10 -3
- package/lib/components/RemoveModal/RemoveModal.js +10 -3
- package/lib/components/TagSet/TagSet.js +5 -21
- package/lib/components/TagSet/TagSetModal.js +7 -3
- package/lib/components/Tearsheet/Tearsheet.js +2 -2
- package/lib/components/Tearsheet/TearsheetNarrow.js +2 -2
- package/lib/components/Tearsheet/TearsheetShell.js +14 -28
- package/lib/global/decorators/sidePanelDecorator.js +7 -0
- package/lib/global/js/hooks/usePortalTarget.js +38 -0
- package/lib/global/js/hooks/useRetrieveFormTitles.js +28 -0
- package/lib/global/js/hooks/useWindowScroll.js +6 -0
- package/lib/global/js/package-settings.js +0 -1
- package/lib/global/js/utils/getNodeTextContent.js +55 -0
- package/package.json +7 -3
- package/scss/components/ActionSet/_action-set.scss +2 -1
- package/scss/components/Datagrid/_datagrid.scss +9 -0
- package/scss/components/Datagrid/styles/_datagrid.scss +7 -6
- package/scss/components/Datagrid/styles/_draggableElement.scss +34 -16
- package/scss/components/Datagrid/styles/_useExpandedRow.scss +13 -0
- package/scss/components/Datagrid/styles/addons/_CustomizeColumnsTearsheet.scss +1 -1
- package/scss/components/Datagrid/styles/addons/_FilterFlyout.scss +23 -11
- package/scss/components/Datagrid/styles/addons/_FilterPanel.scss +7 -3
- package/scss/components/FilterSummary/_filter-summary.scss +3 -1
- package/scss/global/decorators/_side-panel-decorator.scss +7 -0
- package/scss/global/js/utils/_story-as-full-page.scss +0 -6
@@ -7,26 +7,15 @@ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
7
7
|
* LICENSE file in the root directory of this source tree.
|
8
8
|
*/
|
9
9
|
|
10
|
-
import React from 'react';
|
10
|
+
import React, { useRef } from 'react';
|
11
11
|
import PropTypes from 'prop-types';
|
12
|
-
// import { DndProvider } from 'react-dnd';
|
13
|
-
// import { HTML5Backend } from 'react-dnd-html5-backend';
|
14
12
|
import { Checkbox } from '@carbon/react';
|
15
|
-
|
13
|
+
import update from 'immutability-helper';
|
16
14
|
import { pkg } from '../../../../../settings';
|
17
15
|
import cx from 'classnames';
|
18
16
|
import { DraggableItemsList } from './DraggableItemsList';
|
17
|
+
import uuidv4 from '../../../../../global/js/utils/uuidv4';
|
19
18
|
var blockClass = "".concat(pkg.prefix, "--datagrid");
|
20
|
-
var getNextIndex = function getNextIndex(array, currentIndex, key) {
|
21
|
-
var newIndex = -1;
|
22
|
-
if (key === 'ArrowUp') {
|
23
|
-
newIndex = currentIndex - 1 >= 0 ? currentIndex - 1 : array.length - 1;
|
24
|
-
}
|
25
|
-
if (key === 'ArrowDown') {
|
26
|
-
newIndex = currentIndex + 1 < array.length ? currentIndex + 1 : 0;
|
27
|
-
}
|
28
|
-
return newIndex;
|
29
|
-
};
|
30
19
|
var Columns = function Columns(_ref) {
|
31
20
|
var getVisibleColumnsCount = _ref.getVisibleColumnsCount,
|
32
21
|
filterString = _ref.filterString,
|
@@ -36,43 +25,26 @@ var Columns = function Columns(_ref) {
|
|
36
25
|
assistiveTextInstructionsLabel = _ref.assistiveTextInstructionsLabel,
|
37
26
|
assistiveTextDisabledInstructionsLabel = _ref.assistiveTextDisabledInstructionsLabel,
|
38
27
|
selectAllLabel = _ref.selectAllLabel;
|
28
|
+
var listId = useRef(uuidv4()); // keep id between renders
|
29
|
+
var listRef = useRef(null);
|
39
30
|
var _React$useState = React.useState(''),
|
40
31
|
_React$useState2 = _slicedToArray(_React$useState, 2),
|
41
32
|
ariaRegionText = _React$useState2[0],
|
42
33
|
setAriaRegionText = _React$useState2[1];
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
// setColumnsObject(
|
51
|
-
// update(columns, {
|
52
|
-
// $splice: [
|
53
|
-
// [dragIndex, 1],
|
54
|
-
// [hoverIndex, 0, dragCard],
|
55
|
-
// ],
|
56
|
-
// })
|
57
|
-
// );
|
58
|
-
// },
|
59
|
-
// [columns, setColumnsObject]
|
60
|
-
// );
|
61
|
-
|
34
|
+
// after a drag/drop action set the columns
|
35
|
+
var moveElement = React.useCallback(function (from, to) {
|
36
|
+
var fromCol = columns[from];
|
37
|
+
setColumnsObject(update(columns, {
|
38
|
+
$splice: [[from, 1], [to, 0, fromCol]]
|
39
|
+
}));
|
40
|
+
}, [columns, setColumnsObject]);
|
62
41
|
return /*#__PURE__*/React.createElement("div", {
|
63
|
-
className: "".concat(blockClass, "__customize-columns-column-list")
|
42
|
+
className: "".concat(blockClass, "__customize-columns-column-list"),
|
43
|
+
ref: listRef
|
64
44
|
}, /*#__PURE__*/React.createElement("ol", {
|
65
45
|
className: "".concat(blockClass, "__customize-columns-column-list--focus"),
|
66
46
|
role: "listbox",
|
67
47
|
"aria-describedby": "".concat(blockClass, "__customize-columns--instructions"),
|
68
|
-
onKeyDown: function onKeyDown(e) {
|
69
|
-
var nextIndex = getNextIndex(columns, focusIndex, e.key);
|
70
|
-
if (nextIndex >= 0) {
|
71
|
-
setFocusIndex(nextIndex);
|
72
|
-
e.preventDefault();
|
73
|
-
e.stopPropagation();
|
74
|
-
}
|
75
|
-
},
|
76
48
|
tabIndex: 0
|
77
49
|
}, /*#__PURE__*/React.createElement("span", {
|
78
50
|
"aria-live": "assertive",
|
@@ -94,16 +66,12 @@ var Columns = function Columns(_ref) {
|
|
94
66
|
id: "".concat(blockClass, "__customization-column-select-all"),
|
95
67
|
labelText: selectAllLabel
|
96
68
|
})), /*#__PURE__*/React.createElement(DraggableItemsList, {
|
69
|
+
id: listId.current,
|
97
70
|
columns: columns,
|
98
71
|
filterString: filterString,
|
99
|
-
|
100
|
-
getNextIndex: getNextIndex
|
101
|
-
// moveElement={moveElement}
|
102
|
-
,
|
103
|
-
onSelectColumn: onSelectColumn,
|
72
|
+
moveElement: moveElement,
|
104
73
|
setAriaRegionText: setAriaRegionText,
|
105
|
-
|
106
|
-
setFocusIndex: setFocusIndex
|
74
|
+
onSelectColumn: onSelectColumn
|
107
75
|
})));
|
108
76
|
};
|
109
77
|
Columns.propTypes = {
|
@@ -1,3 +1,6 @@
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
2
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
3
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
1
4
|
/**
|
2
5
|
* Copyright IBM Corp. 2023, 2023
|
3
6
|
*
|
@@ -12,17 +15,21 @@ import { isColumnVisible } from './common';
|
|
12
15
|
import DraggableElement from '../../DraggableElement';
|
13
16
|
import { pkg } from '../../../../../settings';
|
14
17
|
import getColTitle from '../../../utils/getColTitle';
|
18
|
+
import { DndContext, KeyboardSensor, PointerSensor, closestCenter, useSensor, useSensors } from '@dnd-kit/core';
|
19
|
+
import { SortableContext, verticalListSortingStrategy } from '@dnd-kit/sortable';
|
15
20
|
var blockClass = "".concat(pkg.prefix, "--datagrid");
|
21
|
+
var matchedColsById = function matchedColsById(col1, col2) {
|
22
|
+
return col1 && col2 && col1.id === col2.id;
|
23
|
+
};
|
16
24
|
export var DraggableItemsList = function DraggableItemsList(_ref) {
|
17
25
|
var columns = _ref.columns,
|
18
26
|
filterString = _ref.filterString,
|
19
|
-
|
20
|
-
|
27
|
+
id = _ref.id,
|
28
|
+
moveElement = _ref.moveElement,
|
21
29
|
onSelectColumn = _ref.onSelectColumn,
|
22
|
-
setAriaRegionText = _ref.setAriaRegionText
|
23
|
-
|
24
|
-
|
25
|
-
return /*#__PURE__*/React.createElement(React.Fragment, null, columns
|
30
|
+
setAriaRegionText = _ref.setAriaRegionText;
|
31
|
+
var draggableClass = "".concat(blockClass, "__draggable-item");
|
32
|
+
var visibleCols = columns
|
26
33
|
// hide the columns without Header, e.g the sticky actions, spacer
|
27
34
|
.filter(function (colDef) {
|
28
35
|
return !!getColTitle(colDef);
|
@@ -31,7 +38,108 @@ export var DraggableItemsList = function DraggableItemsList(_ref) {
|
|
31
38
|
}).filter(function (colDef) {
|
32
39
|
var _getColTitle;
|
33
40
|
return filterString.length === 0 || ((_getColTitle = getColTitle(colDef)) === null || _getColTitle === void 0 ? void 0 : _getColTitle.toLowerCase().includes(filterString)) && colDef.id !== 'spacer';
|
34
|
-
})
|
41
|
+
});
|
42
|
+
|
43
|
+
// let localRefCopy;
|
44
|
+
var handleDragEnd = function handleDragEnd(event) {
|
45
|
+
var active = event.active,
|
46
|
+
over = event.over;
|
47
|
+
var fromVisibleIndex = columns.findIndex(function (col) {
|
48
|
+
return matchedColsById(col, active);
|
49
|
+
});
|
50
|
+
var toVisibleIndex = columns.findIndex(function (col) {
|
51
|
+
return matchedColsById(col, over);
|
52
|
+
});
|
53
|
+
var colTitle = getColTitle(visibleCols[fromVisibleIndex]);
|
54
|
+
setAriaRegionText("".concat(colTitle, " dropped. New position ").concat(toVisibleIndex + 1, " of ").concat(visibleCols.length, "."));
|
55
|
+
var fromIndex = columns.findIndex(function (col) {
|
56
|
+
return matchedColsById(col, active);
|
57
|
+
});
|
58
|
+
var toIndex = columns.findIndex(function (col) {
|
59
|
+
return matchedColsById(col, over);
|
60
|
+
});
|
61
|
+
moveElement(fromIndex, toIndex);
|
62
|
+
};
|
63
|
+
var handleDragStart = function handleDragStart(event) {
|
64
|
+
var active = event.active;
|
65
|
+
var fromIndex = visibleCols.findIndex(function (col) {
|
66
|
+
return matchedColsById(col, active);
|
67
|
+
});
|
68
|
+
var colTitle = getColTitle(visibleCols[fromIndex]);
|
69
|
+
setAriaRegionText("".concat(colTitle, " grabbed. Current position ").concat(fromIndex + 1, " of ").concat(visibleCols.length, "."));
|
70
|
+
};
|
71
|
+
var handleDragUpdate = function handleDragUpdate(event) {
|
72
|
+
var active = event.active,
|
73
|
+
over = event.over;
|
74
|
+
var fromIndex = visibleCols.findIndex(function (col) {
|
75
|
+
return matchedColsById(col, active);
|
76
|
+
});
|
77
|
+
var toIndex = visibleCols.findIndex(function (col) {
|
78
|
+
return matchedColsById(col, over);
|
79
|
+
});
|
80
|
+
var colTitle = getColTitle(visibleCols[fromIndex]);
|
81
|
+
setAriaRegionText("".concat(colTitle, " grabbed. Original position ").concat(fromIndex + 1, ", new position ").concat(toIndex + 1, " of ").concat(visibleCols.length, "."));
|
82
|
+
};
|
83
|
+
var pointerSensor = useSensor(PointerSensor, {
|
84
|
+
// Require the mouse to move by 10 pixels before activating
|
85
|
+
activationConstraint: {
|
86
|
+
distance: 4
|
87
|
+
}
|
88
|
+
});
|
89
|
+
var keyboardSensor = useSensor(KeyboardSensor, {
|
90
|
+
coordinateGetter: function coordinateGetter(event, args) {
|
91
|
+
var currentCoordinates = args.currentCoordinates;
|
92
|
+
var target = event.target;
|
93
|
+
while (target && !target.classList.contains(draggableClass)) {
|
94
|
+
target = target.parentNode;
|
95
|
+
}
|
96
|
+
var delta = target.offsetHeight;
|
97
|
+
switch (event.code) {
|
98
|
+
case 'ArrowRight':
|
99
|
+
case 'ArrowLeft':
|
100
|
+
// ignore right and left
|
101
|
+
return currentCoordinates;
|
102
|
+
case 'ArrowUp':
|
103
|
+
return _objectSpread(_objectSpread({}, currentCoordinates), {}, {
|
104
|
+
y: currentCoordinates.y - delta
|
105
|
+
});
|
106
|
+
case 'ArrowDown':
|
107
|
+
return _objectSpread(_objectSpread({}, currentCoordinates), {}, {
|
108
|
+
y: currentCoordinates.y + delta
|
109
|
+
});
|
110
|
+
case 'Space':
|
111
|
+
break;
|
112
|
+
}
|
113
|
+
}
|
114
|
+
});
|
115
|
+
var sensors = useSensors(pointerSensor, keyboardSensor);
|
116
|
+
var handleCheckboxKeydown = function handleCheckboxKeydown(event, colDef) {
|
117
|
+
if (event.code === 'Space') {
|
118
|
+
onSelectColumn(colDef, !isColumnVisible(colDef));
|
119
|
+
event.preventDefault();
|
120
|
+
event.stopPropagation();
|
121
|
+
return false;
|
122
|
+
}
|
123
|
+
};
|
124
|
+
return /*#__PURE__*/React.createElement(DndContext, {
|
125
|
+
collisionDetection: closestCenter,
|
126
|
+
onDragEnd: handleDragEnd,
|
127
|
+
onDragStart: handleDragStart,
|
128
|
+
onDragMove: handleDragUpdate,
|
129
|
+
sensors: sensors
|
130
|
+
}, /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
|
131
|
+
className: "".concat(blockClass, "__draggable-underlay"),
|
132
|
+
"aria-hidden": "true",
|
133
|
+
key: "draggable-underlay-".concat(id)
|
134
|
+
}, visibleCols.map(function (colDef) {
|
135
|
+
return /*#__PURE__*/React.createElement("div", {
|
136
|
+
className: "".concat(blockClass, "__draggable-underlay-item"),
|
137
|
+
key: colDef.id
|
138
|
+
});
|
139
|
+
})), /*#__PURE__*/React.createElement(SortableContext, {
|
140
|
+
items: visibleCols,
|
141
|
+
strategy: verticalListSortingStrategy
|
142
|
+
}, visibleCols.map(function (colDef) {
|
35
143
|
var colHeaderTitle = getColTitle(colDef);
|
36
144
|
var searchString = new RegExp('(' + filterString + ')');
|
37
145
|
var res = filterString.length ? colHeaderTitle.toLowerCase().split(searchString) : null;
|
@@ -39,7 +147,6 @@ export var DraggableItemsList = function DraggableItemsList(_ref) {
|
|
39
147
|
var highlightedText = res !== null ? res[0] === '' ? "<strong>".concat(firstWord, "</strong>") + res[2] : firstWord + "<strong>".concat(res[1], "</strong>") + res[2] : colHeaderTitle;
|
40
148
|
var isFrozenColumn = !!colDef.sticky;
|
41
149
|
var listContents = /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Checkbox, {
|
42
|
-
wrapperClassName: "".concat(blockClass, "__customize-columns-checkbox-wrapper"),
|
43
150
|
checked: isColumnVisible(colDef),
|
44
151
|
disabled: isFrozenColumn,
|
45
152
|
onChange: function onChange(_, _ref2) {
|
@@ -50,7 +157,10 @@ export var DraggableItemsList = function DraggableItemsList(_ref) {
|
|
50
157
|
labelText: colHeaderTitle,
|
51
158
|
title: colHeaderTitle,
|
52
159
|
className: "".concat(blockClass, "__customize-columns-checkbox"),
|
53
|
-
hideLabel: true
|
160
|
+
hideLabel: true,
|
161
|
+
onKeyDown: function onKeyDown(event) {
|
162
|
+
return handleCheckboxKeydown(event, colDef);
|
163
|
+
}
|
54
164
|
}), /*#__PURE__*/React.createElement("div", {
|
55
165
|
dangerouslySetInnerHTML: {
|
56
166
|
__html: highlightedText
|
@@ -58,46 +168,21 @@ export var DraggableItemsList = function DraggableItemsList(_ref) {
|
|
58
168
|
className: "".concat(blockClass, "__customize-columns-checkbox-visible-label")
|
59
169
|
}));
|
60
170
|
return /*#__PURE__*/React.createElement(DraggableElement, {
|
171
|
+
classList: draggableClass,
|
61
172
|
key: colDef.id,
|
62
|
-
|
63
|
-
listData: columns,
|
64
|
-
setListData: setColumnsObject,
|
65
|
-
id: "dnd-datagrid-columns-".concat(colDef.id),
|
66
|
-
type: "column-customization",
|
173
|
+
id: colDef.id,
|
67
174
|
disabled: filterString.length > 0 || isFrozenColumn,
|
68
175
|
ariaLabel: colHeaderTitle,
|
69
|
-
onGrab: setAriaRegionText,
|
70
|
-
isFocused: focusIndex === i
|
71
|
-
// moveElement={moveElement}
|
72
|
-
,
|
73
|
-
onArrowKeyDown: function onArrowKeyDown(e, isGrabbed, currentIndex) {
|
74
|
-
if (isGrabbed) {
|
75
|
-
var _columns$nextIndex;
|
76
|
-
var nextIndex = getNextIndex(columns, currentIndex, e.key);
|
77
|
-
e.preventDefault();
|
78
|
-
e.stopPropagation();
|
79
|
-
if (nextIndex >= 0 && !((_columns$nextIndex = columns[nextIndex]) !== null && _columns$nextIndex !== void 0 && _columns$nextIndex.sticky)) {
|
80
|
-
setFocusIndex(nextIndex);
|
81
|
-
// moveElement(currentIndex, nextIndex);
|
82
|
-
e.target.scrollIntoView({
|
83
|
-
block: 'center'
|
84
|
-
});
|
85
|
-
}
|
86
|
-
}
|
87
|
-
},
|
88
176
|
isSticky: isFrozenColumn,
|
89
177
|
selected: isColumnVisible(colDef)
|
90
178
|
}, listContents);
|
91
|
-
}));
|
179
|
+
}))));
|
92
180
|
};
|
93
181
|
DraggableItemsList.propTypes = {
|
94
182
|
columns: PropTypes.array.isRequired,
|
95
183
|
filterString: PropTypes.string.isRequired,
|
96
|
-
|
97
|
-
|
98
|
-
// moveElement: PropTypes.func.isRequired,
|
184
|
+
id: PropTypes.string.isRequired,
|
185
|
+
moveElement: PropTypes.func.isRequired,
|
99
186
|
onSelectColumn: PropTypes.func.isRequired,
|
100
|
-
setAriaRegionText: PropTypes.func.isRequired
|
101
|
-
setColumnsObject: PropTypes.func.isRequired,
|
102
|
-
setFocusIndex: PropTypes.func.isRequired
|
187
|
+
setAriaRegionText: PropTypes.func.isRequired
|
103
188
|
};
|
@@ -6,7 +6,7 @@ export var DocsPage = function DocsPage() {
|
|
6
6
|
description: "The `Datagrid` supports expandable rows with the use of the `useExpandedRow` hook.",
|
7
7
|
source: {
|
8
8
|
language: 'jsx',
|
9
|
-
code: "\nimport { Datagrid, useDatagrid, useExpandedRow } from '@carbon/ibm-products';\n\nconst App = () => {\n const columns = React.useMemo(() => defaultHeader, []); // These are the columns that will be used by the datagrid\n const [data] = useState(makeData(10)); // This is the data that will be rendered by the datagrid\n\n const expansionRenderer = ({ row }) => {\n return <div>Content for row index: {row.id}</div>;\n };\n\n const datagridState = useDatagrid(\n {\n columns,\n data,\n ExpandedRowContentComponent: expansionRenderer,\n },\n useExpandedRow\n );\n\n return <Datagrid datagridState={datagridState} />;\n};\n "
|
9
|
+
code: "\nimport { Datagrid, useDatagrid, useExpandedRow } from '@carbon/ibm-products';\n\nconst App = () => {\n const columns = React.useMemo(() => defaultHeader, []); // These are the columns that will be used by the datagrid\n const [data] = useState(makeData(10)); // This is the data that will be rendered by the datagrid\n\n const expansionRenderer = ({ row }) => {\n return <div>Content for row index: {row.id}</div>;\n };\n\n const datagridState = useDatagrid(\n {\n columns,\n data,\n ExpandedRowContentComponent: expansionRenderer,\n expanderButtonTitleExpanded: 'Collapse row',\n expanderButtonTitleCollapsed: 'Expand row', \n },\n useExpandedRow\n );\n\n return <Datagrid datagridState={datagridState} />;\n};\n "
|
10
10
|
}
|
11
11
|
}]
|
12
12
|
});
|
@@ -33,7 +33,7 @@ var useExpandedRow = function useExpandedRow(hooks) {
|
|
33
33
|
return _objectSpread(_objectSpread({}, row), {}, {
|
34
34
|
canExpand: row.original && !row.original.notExpandable,
|
35
35
|
expandedContentHeight: expandedRowsHeight[row.index] || expandedContentHeight,
|
36
|
-
|
36
|
+
RowExpansionRenderer: DatagridExpandedRow(ExpandedRowContentComponent)
|
37
37
|
});
|
38
38
|
});
|
39
39
|
Object.assign(instance, {
|
@@ -2,30 +2,42 @@ import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
2
2
|
import _extends from "@babel/runtime/helpers/extends";
|
3
3
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
4
4
|
/* eslint-disable react/prop-types */
|
5
|
-
|
6
|
-
*
|
7
|
-
*
|
8
|
-
*
|
9
|
-
*
|
10
|
-
* restricted by GSA ADP Schedule Contract with IBM Corp.
|
5
|
+
/**
|
6
|
+
* Copyright IBM Corp. 2020, 2023
|
7
|
+
*
|
8
|
+
* This source code is licensed under the Apache-2.0 license found in the
|
9
|
+
* LICENSE file in the root directory of this source tree.
|
11
10
|
*/
|
12
|
-
|
11
|
+
|
12
|
+
import React, { useRef } from 'react';
|
13
13
|
import { ChevronRight } from '@carbon/react/icons';
|
14
14
|
import cx from 'classnames';
|
15
15
|
import { pkg, carbon } from '../../settings';
|
16
16
|
var blockClass = "".concat(pkg.prefix, "--datagrid");
|
17
17
|
var useNestedRowExpander = function useNestedRowExpander(hooks) {
|
18
|
+
var tempState = useRef();
|
19
|
+
var useInstance = function useInstance(instance) {
|
20
|
+
tempState.current = instance;
|
21
|
+
};
|
18
22
|
var visibleColumns = function visibleColumns(columns) {
|
19
23
|
var expanderColumn = {
|
20
24
|
id: 'expander',
|
21
25
|
Cell: function Cell(_ref) {
|
22
26
|
var _cx;
|
23
27
|
var row = _ref.row;
|
28
|
+
var _ref2 = (tempState === null || tempState === void 0 ? void 0 : tempState.current) || {},
|
29
|
+
_ref2$expanderButtonT = _ref2.expanderButtonTitleExpanded,
|
30
|
+
expanderButtonTitleExpanded = _ref2$expanderButtonT === void 0 ? 'Collapse row' : _ref2$expanderButtonT,
|
31
|
+
_ref2$expanderButtonT2 = _ref2.expanderButtonTitleCollapsed,
|
32
|
+
expanderButtonTitleCollapsed = _ref2$expanderButtonT2 === void 0 ? 'Expand row' : _ref2$expanderButtonT2;
|
33
|
+
var expanderTitle = row.isExpanded ? expanderButtonTitleExpanded : expanderButtonTitleCollapsed;
|
24
34
|
return row.canExpand && /*#__PURE__*/React.createElement("button", _extends({
|
25
35
|
type: "button",
|
26
|
-
"aria-label":
|
36
|
+
"aria-label": expanderTitle,
|
27
37
|
className: cx("".concat(blockClass, "__row-expander"), "".concat(carbon.prefix, "--btn"), "".concat(carbon.prefix, "--btn--ghost"))
|
28
|
-
}, row.getToggleRowExpandedProps()
|
38
|
+
}, row.getToggleRowExpandedProps(), {
|
39
|
+
title: expanderTitle
|
40
|
+
}), /*#__PURE__*/React.createElement(ChevronRight, {
|
29
41
|
className: cx("".concat(blockClass, "__expander-icon"), (_cx = {}, _defineProperty(_cx, "".concat(blockClass, "__expander-icon--not-open"), !row.isExpanded), _defineProperty(_cx, "".concat(blockClass, "__expander-icon--open"), row.isExpanded), _cx))
|
30
42
|
}));
|
31
43
|
},
|
@@ -37,5 +49,6 @@ var useNestedRowExpander = function useNestedRowExpander(hooks) {
|
|
37
49
|
return [expanderColumn].concat(_toConsumableArray(columns));
|
38
50
|
};
|
39
51
|
hooks.visibleColumns.push(visibleColumns);
|
52
|
+
hooks.useInstance.push(useInstance);
|
40
53
|
};
|
41
54
|
export default useNestedRowExpander;
|
@@ -1,29 +1,41 @@
|
|
1
1
|
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
2
2
|
import _extends from "@babel/runtime/helpers/extends";
|
3
3
|
/* eslint-disable react/prop-types */
|
4
|
-
|
5
|
-
*
|
6
|
-
*
|
7
|
-
*
|
8
|
-
*
|
9
|
-
* restricted by GSA ADP Schedule Contract with IBM Corp.
|
4
|
+
/**
|
5
|
+
* Copyright IBM Corp. 2020, 2023
|
6
|
+
*
|
7
|
+
* This source code is licensed under the Apache-2.0 license found in the
|
8
|
+
* LICENSE file in the root directory of this source tree.
|
10
9
|
*/
|
11
|
-
|
10
|
+
|
11
|
+
import React, { useRef } from 'react';
|
12
12
|
import { ChevronDown, ChevronUp } from '@carbon/react/icons';
|
13
13
|
import { pkg, carbon } from '../../settings';
|
14
14
|
import cx from 'classnames';
|
15
15
|
var blockClass = "".concat(pkg.prefix, "--datagrid");
|
16
16
|
var useRowExpander = function useRowExpander(hooks) {
|
17
|
+
var tempState = useRef();
|
18
|
+
var useInstance = function useInstance(instance) {
|
19
|
+
tempState.current = instance;
|
20
|
+
};
|
17
21
|
var visibleColumns = function visibleColumns(columns) {
|
18
22
|
var expanderColumn = {
|
19
23
|
id: 'expander',
|
20
24
|
Cell: function Cell(_ref) {
|
21
25
|
var row = _ref.row;
|
26
|
+
var _ref2 = (tempState === null || tempState === void 0 ? void 0 : tempState.current) || {},
|
27
|
+
_ref2$expanderButtonT = _ref2.expanderButtonTitleExpanded,
|
28
|
+
expanderButtonTitleExpanded = _ref2$expanderButtonT === void 0 ? 'Collapse row' : _ref2$expanderButtonT,
|
29
|
+
_ref2$expanderButtonT2 = _ref2.expanderButtonTitleCollapsed,
|
30
|
+
expanderButtonTitleCollapsed = _ref2$expanderButtonT2 === void 0 ? 'Expand row' : _ref2$expanderButtonT2;
|
31
|
+
var expanderTitle = row.isExpanded ? expanderButtonTitleExpanded : expanderButtonTitleCollapsed;
|
22
32
|
return row.canExpand && /*#__PURE__*/React.createElement("button", _extends({
|
23
33
|
type: "button",
|
24
|
-
"aria-label":
|
34
|
+
"aria-label": expanderTitle,
|
25
35
|
className: cx("".concat(blockClass, "__row-expander"), "".concat(carbon.prefix, "--btn"), "".concat(carbon.prefix, "--btn--ghost"))
|
26
|
-
}, row.getToggleRowExpandedProps()
|
36
|
+
}, row.getToggleRowExpandedProps(), {
|
37
|
+
title: expanderTitle
|
38
|
+
}), row.isExpanded ? /*#__PURE__*/React.createElement(ChevronUp, {
|
27
39
|
className: "".concat(blockClass, "__row-expander--icon")
|
28
40
|
}) : /*#__PURE__*/React.createElement(ChevronDown, {
|
29
41
|
className: "".concat(blockClass, "__row-expander--icon")
|
@@ -37,5 +49,6 @@ var useRowExpander = function useRowExpander(hooks) {
|
|
37
49
|
return [expanderColumn].concat(_toConsumableArray(columns));
|
38
50
|
};
|
39
51
|
hooks.visibleColumns.push(visibleColumns);
|
52
|
+
hooks.useInstance.push(useInstance);
|
40
53
|
};
|
41
54
|
export default useRowExpander;
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
2
2
|
/**
|
3
|
-
* Copyright IBM Corp. 2020,
|
3
|
+
* Copyright IBM Corp. 2020, 2023
|
4
4
|
*
|
5
5
|
* This source code is licensed under the Apache-2.0 license found in the
|
6
6
|
* LICENSE file in the root directory of this source tree.
|
@@ -87,6 +87,18 @@ export var ARG_TYPES = {
|
|
87
87
|
},
|
88
88
|
description: 'This value controls the height of the expanded content area. _This value is set/passed inside of the `datagridState` object._'
|
89
89
|
},
|
90
|
+
expanderButtonTitleExpanded: {
|
91
|
+
control: {
|
92
|
+
type: 'text'
|
93
|
+
},
|
94
|
+
description: 'This value controls the expander title/aria-label when expanded. _This value is set/passed inside of the `datagridState` object._'
|
95
|
+
},
|
96
|
+
expanderButtonTitleCollapsed: {
|
97
|
+
control: {
|
98
|
+
type: 'text'
|
99
|
+
},
|
100
|
+
description: 'This value controls the expander title/aria-label when expanded. _This value is set/passed inside of the `datagridState` object._'
|
101
|
+
},
|
90
102
|
customizeColumnsProps: {
|
91
103
|
control: 'object',
|
92
104
|
description: 'This is an object containing all of the props used with the column customization extension. _This value is set/passed inside of the `datagridState` object._'
|
@@ -1,9 +1,9 @@
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
2
2
|
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
3
3
|
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
4
|
-
var _excluded = ["cancelButtonText", "children", "className", "description", "influencerWidth", "label", "onClose", "open", "submitButtonText", "title", "verticalPosition", "onHandleModalClick"];
|
4
|
+
var _excluded = ["cancelButtonText", "children", "className", "description", "influencerWidth", "label", "onClose", "open", "submitButtonText", "title", "verticalPosition", "onHandleModalClick", "onFormChange", "sideNavAriaLabel"];
|
5
5
|
/**
|
6
|
-
* Copyright IBM Corp. 2022,
|
6
|
+
* Copyright IBM Corp. 2022, 2023
|
7
7
|
*
|
8
8
|
* This source code is licensed under the Apache-2.0 license found in the
|
9
9
|
* LICENSE file in the root directory of this source tree.
|
@@ -31,7 +31,8 @@ export var FormNumberContext = /*#__PURE__*/createContext(0);
|
|
31
31
|
// Default values for props
|
32
32
|
var defaults = {
|
33
33
|
verticalPosition: 'normal',
|
34
|
-
influencerWidth: 'narrow'
|
34
|
+
influencerWidth: 'narrow',
|
35
|
+
sideNavAriaLabel: 'Side navigation'
|
35
36
|
};
|
36
37
|
|
37
38
|
/**
|
@@ -52,40 +53,43 @@ export var EditTearsheet = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
52
53
|
_ref$verticalPosition = _ref.verticalPosition,
|
53
54
|
verticalPosition = _ref$verticalPosition === void 0 ? defaults.verticalPosition : _ref$verticalPosition,
|
54
55
|
onHandleModalClick = _ref.onHandleModalClick,
|
56
|
+
onFormChange = _ref.onFormChange,
|
57
|
+
_ref$sideNavAriaLabel = _ref.sideNavAriaLabel,
|
58
|
+
sideNavAriaLabel = _ref$sideNavAriaLabel === void 0 ? defaults.sideNavAriaLabel : _ref$sideNavAriaLabel,
|
55
59
|
rest = _objectWithoutProperties(_ref, _excluded);
|
56
60
|
var _useState = useState(0),
|
57
61
|
_useState2 = _slicedToArray(_useState, 2),
|
58
62
|
currentForm = _useState2[0],
|
59
63
|
setCurrentForm = _useState2[1];
|
64
|
+
var _useState3 = useState([]),
|
65
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
66
|
+
formTitles = _useState4[0],
|
67
|
+
setFormTitles = _useState4[1];
|
60
68
|
var contentRef = useRef();
|
61
|
-
var handleCurrentForm = function handleCurrentForm(
|
62
|
-
setCurrentForm(
|
69
|
+
var handleCurrentForm = function handleCurrentForm(formIndex) {
|
70
|
+
setCurrentForm(formIndex);
|
71
|
+
if (onFormChange) {
|
72
|
+
onFormChange(formIndex);
|
73
|
+
}
|
63
74
|
};
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
key: index,
|
83
|
-
onClick: function onClick() {
|
84
|
-
return handleCurrentForm(index);
|
85
|
-
},
|
86
|
-
isActive: currentForm === index
|
87
|
-
}, item.label);
|
88
|
-
}))));
|
75
|
+
function defaultInfluencer() {
|
76
|
+
return /*#__PURE__*/React.createElement("div", {
|
77
|
+
className: "".concat(blockClass, "__side-nav-wrapper")
|
78
|
+
}, /*#__PURE__*/React.createElement(SideNav, {
|
79
|
+
"aria-label": sideNavAriaLabel,
|
80
|
+
className: "".concat(blockClass, "__side-nav"),
|
81
|
+
expanded: true,
|
82
|
+
isFixedNav: false
|
83
|
+
}, /*#__PURE__*/React.createElement(SideNavItems, null, formTitles.map(function (title, index) {
|
84
|
+
return /*#__PURE__*/React.createElement(SideNavMenuItem, {
|
85
|
+
key: index,
|
86
|
+
onClick: function onClick() {
|
87
|
+
return handleCurrentForm(index);
|
88
|
+
},
|
89
|
+
isActive: currentForm === index
|
90
|
+
}, title);
|
91
|
+
}))));
|
92
|
+
}
|
89
93
|
return /*#__PURE__*/React.createElement(TearsheetShell, _extends({}, rest, getDevtoolsProps(componentName), {
|
90
94
|
actions: [{
|
91
95
|
label: submitButtonText,
|
@@ -99,7 +103,7 @@ export var EditTearsheet = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
99
103
|
className: cx(blockClass, className),
|
100
104
|
description: description,
|
101
105
|
hasCloseIcon: false,
|
102
|
-
influencer:
|
106
|
+
influencer: defaultInfluencer(),
|
103
107
|
influencerPosition: "left",
|
104
108
|
influencerWidth: influencerWidth,
|
105
109
|
label: label,
|
@@ -115,7 +119,8 @@ export var EditTearsheet = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
115
119
|
role: "main"
|
116
120
|
}, /*#__PURE__*/React.createElement(Form, null, /*#__PURE__*/React.createElement(FormContext.Provider, {
|
117
121
|
value: {
|
118
|
-
currentForm: currentForm
|
122
|
+
currentForm: currentForm,
|
123
|
+
setFormTitles: setFormTitles
|
119
124
|
}
|
120
125
|
}, React.Children.map(children, function (child, index) {
|
121
126
|
return /*#__PURE__*/React.createElement(FormNumberContext.Provider, {
|
@@ -150,12 +155,6 @@ EditTearsheet.propTypes = {
|
|
150
155
|
* A description of the flow, displayed in the header area of the tearsheet.
|
151
156
|
*/
|
152
157
|
description: PropTypes.node,
|
153
|
-
/**
|
154
|
-
* The content for the influencer section of the tearsheet, displayed
|
155
|
-
* alongside the main content. This is typically a menu, or filter, or
|
156
|
-
* progress indicator, or similar.
|
157
|
-
*/
|
158
|
-
influencer: PropTypes.element,
|
159
158
|
/**
|
160
159
|
* Used to set the size of the influencer
|
161
160
|
*/
|
@@ -172,6 +171,12 @@ EditTearsheet.propTypes = {
|
|
172
171
|
* Returning `false` here prevents the modal from closing.
|
173
172
|
*/
|
174
173
|
onClose: PropTypes.func,
|
174
|
+
/**
|
175
|
+
* An optional handler that is called when a user changes forms via clicking
|
176
|
+
* an influencer nav item.
|
177
|
+
* Returns the index of the selected form.
|
178
|
+
*/
|
179
|
+
onFormChange: PropTypes.func,
|
175
180
|
/**
|
176
181
|
* Specifies whether the tearsheet is currently open.
|
177
182
|
*/
|
@@ -180,6 +185,10 @@ EditTearsheet.propTypes = {
|
|
180
185
|
* Specifies whether the tearsheet is currently open.
|
181
186
|
*/
|
182
187
|
open: PropTypes.bool,
|
188
|
+
/**
|
189
|
+
* Specifies the aria label for the SideNav from Carbon UIShell
|
190
|
+
*/
|
191
|
+
sideNavAriaLabel: PropTypes.string,
|
183
192
|
/**
|
184
193
|
* The submit button text
|
185
194
|
*/
|