@carbon/ibm-products 1.60.0 → 1.61.0
Sign up to get free protection for your applications and to get access to all the features.
- package/css/index-full-carbon.css +57 -24
- package/css/index-full-carbon.css.map +1 -1
- package/css/index-full-carbon.min.css +4 -4
- package/css/index-full-carbon.min.css.map +1 -1
- package/css/index-without-carbon-released-only.css +9 -3
- 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 +47 -9
- package/css/index-without-carbon.css.map +1 -1
- package/css/index-without-carbon.min.css +2 -2
- package/css/index-without-carbon.min.css.map +1 -1
- package/css/index.css +47 -24
- package/css/index.css.map +1 -1
- package/css/index.min.css +3 -3
- package/css/index.min.css.map +1 -1
- package/es/components/Datagrid/Datagrid/DatagridContent.js +3 -1
- package/es/components/Datagrid/Datagrid/DatagridHeaderRow.js +2 -2
- package/es/components/Datagrid/Datagrid/addons/CustomizeColumns/DraggableItemsList.js +9 -8
- package/es/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditButton/InlineEditButton.js +6 -12
- package/es/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditCell/InlineEditCell.js +0 -5
- package/es/components/Datagrid/Datagrid/addons/RowSize/RowSizeDropdown.js +17 -5
- package/es/components/Datagrid/Datagrid/addons/RowSize/RowSizeRadioGroup.js +4 -3
- package/es/components/Datagrid/useInlineEdit.js +1 -6
- package/es/components/Datagrid/useSortableColumns.js +5 -4
- package/es/components/FilterSummary/FilterSummary.js +6 -2
- package/es/components/TagSet/TagSet.js +11 -3
- package/es/components/TagSet/TagSetOverflow.js +16 -5
- package/es/global/js/utils/getNodeTextContent.js +51 -0
- package/lib/components/Datagrid/Datagrid/DatagridContent.js +3 -1
- package/lib/components/Datagrid/Datagrid/DatagridHeaderRow.js +2 -2
- package/lib/components/Datagrid/Datagrid/addons/CustomizeColumns/DraggableItemsList.js +9 -8
- package/lib/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditButton/InlineEditButton.js +6 -12
- package/lib/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditCell/InlineEditCell.js +0 -5
- package/lib/components/Datagrid/Datagrid/addons/RowSize/RowSizeDropdown.js +15 -3
- package/lib/components/Datagrid/Datagrid/addons/RowSize/RowSizeRadioGroup.js +7 -3
- package/lib/components/Datagrid/useInlineEdit.js +1 -6
- package/lib/components/Datagrid/useSortableColumns.js +5 -4
- package/lib/components/FilterSummary/FilterSummary.js +6 -2
- package/lib/components/TagSet/TagSet.js +11 -3
- package/lib/components/TagSet/TagSetOverflow.js +16 -5
- package/lib/global/js/utils/getNodeTextContent.js +59 -0
- package/package.json +4 -4
- package/scss/components/Datagrid/_datagrid.scss +1 -0
- package/scss/components/Datagrid/styles/_useInlineEdit.scss +7 -11
- package/scss/components/Datagrid/styles/addons/_RowSizeDropdown.scss +42 -1
- package/scss/components/TagSet/_tag-set.scss +13 -3
- package/es/components/Datagrid/utils/getColTitle.js +0 -25
- package/lib/components/Datagrid/utils/getColTitle.js +0 -32
@@ -14,7 +14,7 @@ import { Checkbox } from 'carbon-components-react';
|
|
14
14
|
import { isColumnVisible } from './common';
|
15
15
|
import DraggableElement from '../../DraggableElement';
|
16
16
|
import { pkg } from '../../../../../settings';
|
17
|
-
import
|
17
|
+
import { getNodeTextContent } from '../../../../../global/js/utils/getNodeTextContent';
|
18
18
|
import { DndContext, KeyboardSensor, PointerSensor, closestCenter, useSensor, useSensors } from '@dnd-kit/core';
|
19
19
|
import { SortableContext, verticalListSortingStrategy } from '@dnd-kit/sortable';
|
20
20
|
var blockClass = "".concat(pkg.prefix, "--datagrid");
|
@@ -32,12 +32,13 @@ export var DraggableItemsList = function DraggableItemsList(_ref) {
|
|
32
32
|
var visibleCols = columns
|
33
33
|
// hide the columns without Header, e.g the sticky actions, spacer
|
34
34
|
.filter(function (colDef) {
|
35
|
-
return
|
35
|
+
return getNodeTextContent(colDef.Header).trim().length !== 0;
|
36
36
|
}).filter(Boolean).filter(function (colDef) {
|
37
37
|
return !colDef.isAction;
|
38
38
|
}).filter(function (colDef) {
|
39
|
-
|
40
|
-
|
39
|
+
return colDef.id !== 'spacer';
|
40
|
+
}).filter(function (colDef) {
|
41
|
+
return filterString.length === 0 || getNodeTextContent(colDef.Header).toLowerCase().includes(filterString);
|
41
42
|
});
|
42
43
|
|
43
44
|
// let localRefCopy;
|
@@ -50,7 +51,7 @@ export var DraggableItemsList = function DraggableItemsList(_ref) {
|
|
50
51
|
var toVisibleIndex = columns.findIndex(function (col) {
|
51
52
|
return matchedColsById(col, over);
|
52
53
|
});
|
53
|
-
var colTitle =
|
54
|
+
var colTitle = getNodeTextContent(visibleCols[fromVisibleIndex].Header);
|
54
55
|
setAriaRegionText("".concat(colTitle, " dropped. New position ").concat(toVisibleIndex + 1, " of ").concat(visibleCols.length, "."));
|
55
56
|
var fromIndex = columns.findIndex(function (col) {
|
56
57
|
return matchedColsById(col, active);
|
@@ -65,7 +66,7 @@ export var DraggableItemsList = function DraggableItemsList(_ref) {
|
|
65
66
|
var fromIndex = visibleCols.findIndex(function (col) {
|
66
67
|
return matchedColsById(col, active);
|
67
68
|
});
|
68
|
-
var colTitle =
|
69
|
+
var colTitle = getNodeTextContent(visibleCols[fromIndex].Header);
|
69
70
|
setAriaRegionText("".concat(colTitle, " grabbed. Current position ").concat(fromIndex + 1, " of ").concat(visibleCols.length, "."));
|
70
71
|
};
|
71
72
|
var handleDragUpdate = function handleDragUpdate(event) {
|
@@ -77,7 +78,7 @@ export var DraggableItemsList = function DraggableItemsList(_ref) {
|
|
77
78
|
var toIndex = visibleCols.findIndex(function (col) {
|
78
79
|
return matchedColsById(col, over);
|
79
80
|
});
|
80
|
-
var colTitle =
|
81
|
+
var colTitle = getNodeTextContent(visibleCols[fromIndex].Header);
|
81
82
|
setAriaRegionText("".concat(colTitle, " grabbed. Original position ").concat(fromIndex + 1, ", new position ").concat(toIndex + 1, " of ").concat(visibleCols.length, "."));
|
82
83
|
};
|
83
84
|
var pointerSensor = useSensor(PointerSensor, {
|
@@ -140,7 +141,7 @@ export var DraggableItemsList = function DraggableItemsList(_ref) {
|
|
140
141
|
items: visibleCols,
|
141
142
|
strategy: verticalListSortingStrategy
|
142
143
|
}, visibleCols.map(function (colDef) {
|
143
|
-
var colHeaderTitle =
|
144
|
+
var colHeaderTitle = getNodeTextContent(colDef.Header);
|
144
145
|
var searchString = new RegExp('(' + filterString + ')');
|
145
146
|
var res = filterString.length ? colHeaderTitle.toLowerCase().split(searchString) : null;
|
146
147
|
var firstWord = res !== null ? res[0] === '' ? res[1].charAt(0).toUpperCase() + res[1].substring(1) : res[0].charAt(0).toUpperCase() + res[0].substring(1) : null;
|
package/es/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditButton/InlineEditButton.js
CHANGED
@@ -1,10 +1,9 @@
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
2
|
-
|
3
|
-
*
|
4
|
-
*
|
5
|
-
*
|
6
|
-
*
|
7
|
-
* restricted by GSA ADP Schedule Contract with IBM Corp.
|
2
|
+
/**
|
3
|
+
* Copyright IBM Corp. 2022, 2023
|
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.
|
8
7
|
*/
|
9
8
|
|
10
9
|
import React from 'react';
|
@@ -22,12 +21,9 @@ export var InlineEditButton = function InlineEditButton(_ref) {
|
|
22
21
|
nonEditCell = _ref.nonEditCell,
|
23
22
|
isActiveCell = _ref.isActiveCell,
|
24
23
|
columnConfig = _ref.columnConfig,
|
25
|
-
totalInlineEditColumns = _ref.totalInlineEditColumns,
|
26
|
-
totalColumns = _ref.totalColumns,
|
27
24
|
type = _ref.type;
|
28
|
-
var inlineEditColsLessThanHalfOfTotal = totalInlineEditColumns < totalColumns / 2;
|
29
25
|
return /*#__PURE__*/React.createElement("div", {
|
30
|
-
className: cx("".concat(blockClass, "__inline-edit-button"), (_cx = {}, _defineProperty(_cx, "".concat(blockClass, "__inline-edit-button--disabled"), disabled || nonEditCell), _defineProperty(_cx, "".concat(blockClass, "__inline-edit-button--with-label-icon"), LabelIcon), _defineProperty(_cx, "".concat(blockClass, "__inline-edit-button--non-edit"), nonEditCell), _defineProperty(_cx, "".concat(blockClass, "__inline-edit-button--active"), isActiveCell), _defineProperty(_cx, "".concat(blockClass, "__inline-edit-button--
|
26
|
+
className: cx("".concat(blockClass, "__inline-edit-button"), (_cx = {}, _defineProperty(_cx, "".concat(blockClass, "__inline-edit-button--disabled"), disabled || nonEditCell), _defineProperty(_cx, "".concat(blockClass, "__inline-edit-button--with-label-icon"), LabelIcon), _defineProperty(_cx, "".concat(blockClass, "__inline-edit-button--non-edit"), nonEditCell), _defineProperty(_cx, "".concat(blockClass, "__inline-edit-button--active"), isActiveCell), _defineProperty(_cx, "".concat(blockClass, "__inline-edit-button--").concat(type), type === 'date' || type === 'selection'), _cx)),
|
31
27
|
tabIndex: isActiveCell ? 0 : -1,
|
32
28
|
"data-disabled": disabled || nonEditCell,
|
33
29
|
"aria-disabled": disabled || nonEditCell,
|
@@ -52,8 +48,6 @@ InlineEditButton.propTypes = {
|
|
52
48
|
nonEditCell: PropTypes.bool,
|
53
49
|
placeholder: PropTypes.string,
|
54
50
|
renderIcon: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
|
55
|
-
totalColumns: PropTypes.number,
|
56
|
-
totalInlineEditColumns: PropTypes.number,
|
57
51
|
type: PropTypes.oneOf(['text', 'number', 'selection', 'date']),
|
58
52
|
value: PropTypes.oneOfType([PropTypes.string, PropTypes.node])
|
59
53
|
};
|
@@ -32,14 +32,12 @@ export var InlineEditCell = function InlineEditCell(_ref) {
|
|
32
32
|
tabIndex = _ref.tabIndex,
|
33
33
|
value = _ref.value,
|
34
34
|
nonEditCell = _ref.nonEditCell,
|
35
|
-
totalInlineEditColumns = _ref.totalInlineEditColumns,
|
36
35
|
type = _ref.type;
|
37
36
|
var columnId = cell.column.id;
|
38
37
|
var columnIndex = instance.columns.findIndex(function (col) {
|
39
38
|
return col.id === columnId;
|
40
39
|
});
|
41
40
|
var cellId = "column-".concat(columnIndex, "-row-").concat(cell.row.index);
|
42
|
-
var totalColumns = instance.columns.length;
|
43
41
|
var _useContext = useContext(InlineEditContext),
|
44
42
|
state = _useContext.state,
|
45
43
|
dispatch = _useContext.dispatch;
|
@@ -442,8 +440,6 @@ export var InlineEditCell = function InlineEditCell(_ref) {
|
|
442
440
|
tabIndex: tabIndex,
|
443
441
|
nonEditCell: nonEditCell,
|
444
442
|
columnConfig: cell.column,
|
445
|
-
totalInlineEditColumns: totalInlineEditColumns,
|
446
|
-
totalColumns: totalColumns,
|
447
443
|
type: type
|
448
444
|
}), !nonEditCell && inEditMode && cellId === activeCellId && /*#__PURE__*/React.createElement(React.Fragment, null, type === 'text' && renderTextInput(), type === 'number' && renderNumberInput(), type === 'selection' && renderSelectCell(), type === 'date' && renderDateCell()))
|
449
445
|
);
|
@@ -461,7 +457,6 @@ InlineEditCell.propTypes = {
|
|
461
457
|
nonEditCell: PropTypes.bool,
|
462
458
|
placeholder: PropTypes.string,
|
463
459
|
tabIndex: PropTypes.number,
|
464
|
-
totalInlineEditColumns: PropTypes.number,
|
465
460
|
type: PropTypes.oneOf(['text', 'number', 'selection', 'date']),
|
466
461
|
value: PropTypes.oneOfType([PropTypes.string, PropTypes.node, PropTypes.object])
|
467
462
|
};
|
@@ -10,23 +10,31 @@ var _excluded = ["legendText"];
|
|
10
10
|
* LICENSE file in the root directory of this source tree.
|
11
11
|
*/
|
12
12
|
|
13
|
-
import React, { useRef, useState } from 'react';
|
13
|
+
import React, { useRef, useState, useEffect } from 'react';
|
14
14
|
import PropTypes from 'prop-types';
|
15
15
|
import { Settings16 } from '@carbon/icons-react';
|
16
16
|
import { Button } from 'carbon-components-react';
|
17
17
|
import cx from 'classnames';
|
18
18
|
import RowSizeRadioGroup from './RowSizeRadioGroup';
|
19
|
-
import { pkg } from '../../../../../settings';
|
19
|
+
import { pkg, carbon } from '../../../../../settings';
|
20
20
|
var blockClass = "".concat(pkg.prefix, "--datagrid__row-size");
|
21
21
|
var RowSizeDropdown = function RowSizeDropdown(_ref) {
|
22
22
|
var _ref$legendText = _ref.legendText,
|
23
|
-
legendText = _ref$legendText === void 0 ? 'Row
|
23
|
+
legendText = _ref$legendText === void 0 ? 'Row settings' : _ref$legendText,
|
24
24
|
props = _objectWithoutProperties(_ref, _excluded);
|
25
25
|
var buttonRef = useRef(null);
|
26
|
+
var radioGroupRef = useRef();
|
26
27
|
var _useState = useState(false),
|
27
28
|
_useState2 = _slicedToArray(_useState, 2),
|
28
29
|
isOpen = _useState2[0],
|
29
30
|
setIsOpen = _useState2[1];
|
31
|
+
useEffect(function () {
|
32
|
+
if (isOpen) {
|
33
|
+
var radioGroupParentElement = radioGroupRef === null || radioGroupRef === void 0 ? void 0 : radioGroupRef.current;
|
34
|
+
var checkedRadioChild = radioGroupParentElement === null || radioGroupParentElement === void 0 ? void 0 : radioGroupParentElement.querySelector(".".concat(carbon.prefix, "--radio-button:checked"));
|
35
|
+
checkedRadioChild === null || checkedRadioChild === void 0 ? void 0 : checkedRadioChild.focus();
|
36
|
+
}
|
37
|
+
}, [isOpen]);
|
30
38
|
var onCloseHandler = function onCloseHandler() {
|
31
39
|
setIsOpen(false);
|
32
40
|
};
|
@@ -36,7 +44,9 @@ var RowSizeDropdown = function RowSizeDropdown(_ref) {
|
|
36
44
|
}
|
37
45
|
};
|
38
46
|
var onClickHandler = function onClickHandler() {
|
39
|
-
setIsOpen(
|
47
|
+
setIsOpen(function (prev) {
|
48
|
+
return !prev;
|
49
|
+
});
|
40
50
|
};
|
41
51
|
var onKeyHandler = function onKeyHandler(e) {
|
42
52
|
if (e.key === 'Escape') {
|
@@ -59,7 +69,9 @@ var RowSizeDropdown = function RowSizeDropdown(_ref) {
|
|
59
69
|
iconDescription: legendText,
|
60
70
|
className: cx("".concat(blockClass, "-button"), _defineProperty({}, "".concat(blockClass, "-button--open"), isOpen)),
|
61
71
|
onClick: onClickHandler
|
62
|
-
}), isOpen && /*#__PURE__*/React.createElement(RowSizeRadioGroup, _extends({
|
72
|
+
}), isOpen && /*#__PURE__*/React.createElement(RowSizeRadioGroup, _extends({
|
73
|
+
ref: radioGroupRef
|
74
|
+
}, props, {
|
63
75
|
legendText: legendText,
|
64
76
|
buttonRef: buttonRef
|
65
77
|
})));
|
@@ -8,13 +8,13 @@
|
|
8
8
|
* restricted by GSA ADP Schedule Contract with IBM Corp.
|
9
9
|
*/
|
10
10
|
|
11
|
-
import React from 'react';
|
11
|
+
import React, { forwardRef } from 'react';
|
12
12
|
import PropTypes from 'prop-types';
|
13
13
|
import { RadioButtonGroup, RadioButton } from 'carbon-components-react';
|
14
14
|
import isArray from 'lodash/isArray';
|
15
15
|
import { pkg } from '../../../../../settings';
|
16
16
|
var blockClass = "".concat(pkg.prefix, "--datagrid");
|
17
|
-
var RowSizeRadioGroup = function
|
17
|
+
var RowSizeRadioGroup = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
18
18
|
var rowSizes = _ref.rowSizes,
|
19
19
|
selectedOption = _ref.selectedOption,
|
20
20
|
datagridName = _ref.datagridName,
|
@@ -29,6 +29,7 @@ var RowSizeRadioGroup = function RowSizeRadioGroup(_ref) {
|
|
29
29
|
xs: 'Extra small'
|
30
30
|
} : _ref$rowSizeLabels;
|
31
31
|
return /*#__PURE__*/React.createElement("div", {
|
32
|
+
ref: ref,
|
32
33
|
className: "".concat(blockClass, "__row-size-dropdown"),
|
33
34
|
role: "presentation"
|
34
35
|
}, /*#__PURE__*/React.createElement(RadioButtonGroup, {
|
@@ -51,7 +52,7 @@ var RowSizeRadioGroup = function RowSizeRadioGroup(_ref) {
|
|
51
52
|
id: "".concat(datagridName || 'datagrid', "--row-density--").concat(option.value)
|
52
53
|
});
|
53
54
|
})));
|
54
|
-
};
|
55
|
+
});
|
55
56
|
var getBackwardCompatibleRowSize = function getBackwardCompatibleRowSize(rowSize) {
|
56
57
|
// TODO: deprecate this function in next major release (v8) on carbon-components-react
|
57
58
|
var rowSizeMap = {
|
@@ -22,14 +22,11 @@ var useInlineEdit = function useInlineEdit(hooks, usingEditableCell) {
|
|
22
22
|
}
|
23
23
|
}, [usingEditableCell]);
|
24
24
|
var addInlineEdit = function addInlineEdit(props, _ref) {
|
25
|
-
var _cell$column, _cell$column$inlineEd
|
25
|
+
var _cell$column, _cell$column$inlineEd;
|
26
26
|
var cell = _ref.cell,
|
27
27
|
instance = _ref.instance;
|
28
28
|
var columnInlineEditConfig = cell.column.inlineEdit;
|
29
29
|
var inlineEditType = (_cell$column = cell.column) === null || _cell$column === void 0 ? void 0 : (_cell$column$inlineEd = _cell$column.inlineEdit) === null || _cell$column$inlineEd === void 0 ? void 0 : _cell$column$inlineEd.type;
|
30
|
-
var totalInlineEditColumns = (_instance$columns$fil = instance.columns.filter(function (item) {
|
31
|
-
return item.inlineEdit;
|
32
|
-
})) === null || _instance$columns$fil === void 0 ? void 0 : _instance$columns$fil.length;
|
33
30
|
var renderInlineEditComponent = function renderInlineEditComponent(type) {
|
34
31
|
return /*#__PURE__*/React.createElement(InlineEditCell, {
|
35
32
|
config: columnInlineEditConfig,
|
@@ -37,7 +34,6 @@ var useInlineEdit = function useInlineEdit(hooks, usingEditableCell) {
|
|
37
34
|
value: cell.value,
|
38
35
|
cell: cell,
|
39
36
|
instance: instance,
|
40
|
-
totalInlineEditColumns: totalInlineEditColumns,
|
41
37
|
type: type
|
42
38
|
});
|
43
39
|
};
|
@@ -57,7 +53,6 @@ var useInlineEdit = function useInlineEdit(hooks, usingEditableCell) {
|
|
57
53
|
instance: instance,
|
58
54
|
disabled: true,
|
59
55
|
nonEditCell: true,
|
60
|
-
totalInlineEditColumns: totalInlineEditColumns,
|
61
56
|
type: "text"
|
62
57
|
}))
|
63
58
|
}];
|
@@ -14,6 +14,7 @@ import cx from 'classnames';
|
|
14
14
|
import { pkg, carbon } from '../../settings';
|
15
15
|
import { Button } from 'carbon-components-react';
|
16
16
|
import { ArrowUp16, Arrows16 } from '@carbon/icons-react';
|
17
|
+
import { SelectAll } from './Datagrid/DatagridSelectAll';
|
17
18
|
var blockClass = "".concat(pkg.prefix, "--datagrid");
|
18
19
|
var ordering = {
|
19
20
|
ASC: 'ASC',
|
@@ -31,13 +32,13 @@ var getAriaSortValue = function getAriaSortValue(col, _ref) {
|
|
31
32
|
isSorted = _ref2.isSorted,
|
32
33
|
isSortedDesc = _ref2.isSortedDesc;
|
33
34
|
if (!isSorted) {
|
34
|
-
return defaultSortableLabelText
|
35
|
+
return defaultSortableLabelText;
|
35
36
|
}
|
36
37
|
if (isSorted && !isSortedDesc) {
|
37
|
-
return ascendingSortableLabelText
|
38
|
+
return ascendingSortableLabelText;
|
38
39
|
}
|
39
40
|
if (isSorted && isSortedDesc) {
|
40
|
-
return descendingSortableLabelText
|
41
|
+
return descendingSortableLabelText;
|
41
42
|
}
|
42
43
|
};
|
43
44
|
var useSortableColumns = function useSortableColumns(hooks) {
|
@@ -91,7 +92,7 @@ var useSortableColumns = function useSortableColumns(hooks) {
|
|
91
92
|
};
|
92
93
|
var Header = function Header(headerProp) {
|
93
94
|
var _cx;
|
94
|
-
return column.disableSortBy === true ? column.Header : /*#__PURE__*/React.createElement(Button, {
|
95
|
+
return column.disableSortBy === true || column.id === 'datagridSelection' ? column.disableSortBy ? column.Header : /*#__PURE__*/React.createElement(SelectAll, instance) : /*#__PURE__*/React.createElement(Button, {
|
95
96
|
"aria-sort": getAriaSortValue(headerProp === null || headerProp === void 0 ? void 0 : headerProp.column, {
|
96
97
|
ascendingSortableLabelText: ascendingSortableLabelText,
|
97
98
|
descendingSortableLabelText: descendingSortableLabelText,
|
@@ -26,7 +26,9 @@ var FilterSummary = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
26
26
|
_ref$filters = _ref.filters,
|
27
27
|
filters = _ref$filters === void 0 ? [] : _ref$filters,
|
28
28
|
_ref$renderLabel = _ref.renderLabel,
|
29
|
-
renderLabel = _ref$renderLabel === void 0 ? null : _ref$renderLabel
|
29
|
+
renderLabel = _ref$renderLabel === void 0 ? null : _ref$renderLabel,
|
30
|
+
_ref$overflowType = _ref.overflowType,
|
31
|
+
overflowType = _ref$overflowType === void 0 ? 'default' : _ref$overflowType;
|
30
32
|
var tagFilters = filters.map(function (_ref2) {
|
31
33
|
var _renderLabel;
|
32
34
|
var key = _ref2.key,
|
@@ -45,7 +47,8 @@ var FilterSummary = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
45
47
|
allTagsModalSearchPlaceholderText: "Search all tags",
|
46
48
|
allTagsModalTitle: "All tags",
|
47
49
|
showAllTagsLabel: "View all tags",
|
48
|
-
tags: tagFilters
|
50
|
+
tags: tagFilters,
|
51
|
+
overflowType: overflowType
|
49
52
|
}), /*#__PURE__*/React.createElement(Button, {
|
50
53
|
kind: "ghost",
|
51
54
|
size: "sm",
|
@@ -59,6 +62,7 @@ FilterSummary.propTypes = {
|
|
59
62
|
clearFilters: PropTypes.func.isRequired,
|
60
63
|
clearFiltersText: PropTypes.string,
|
61
64
|
filters: PropTypes.arrayOf(PropTypes.object).isRequired,
|
65
|
+
overflowType: PropTypes.oneOf(['default', 'tag']),
|
62
66
|
renderLabel: PropTypes.func
|
63
67
|
};
|
64
68
|
export default FilterSummary;
|
@@ -2,7 +2,7 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
2
|
import _extends from "@babel/runtime/helpers/extends";
|
3
3
|
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
4
4
|
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
5
|
-
var _excluded = ["align", "allTagsModalTarget", "className", "maxVisible", "multiline", "overflowAlign", "overflowClassName", "overflowDirection", "allTagsModalTitle", "allTagsModalSearchLabel", "allTagsModalSearchPlaceholderText", "showAllTagsLabel", "tags"],
|
5
|
+
var _excluded = ["align", "allTagsModalTarget", "className", "maxVisible", "multiline", "overflowAlign", "overflowClassName", "overflowType", "overflowDirection", "allTagsModalTitle", "allTagsModalSearchLabel", "allTagsModalSearchPlaceholderText", "showAllTagsLabel", "tags"],
|
6
6
|
_excluded2 = ["label", "id"],
|
7
7
|
_excluded3 = ["label"];
|
8
8
|
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; }
|
@@ -34,7 +34,8 @@ var defaults = {
|
|
34
34
|
align: 'start',
|
35
35
|
// allTagsModalTarget: document.body,
|
36
36
|
overflowAlign: 'center',
|
37
|
-
overflowDirection: 'bottom'
|
37
|
+
overflowDirection: 'bottom',
|
38
|
+
overflowType: 'default'
|
38
39
|
};
|
39
40
|
export var TagSet = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
40
41
|
var _ref$align = _ref.align,
|
@@ -46,6 +47,8 @@ export var TagSet = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
46
47
|
_ref$overflowAlign = _ref.overflowAlign,
|
47
48
|
overflowAlign = _ref$overflowAlign === void 0 ? defaults.overflowAlign : _ref$overflowAlign,
|
48
49
|
overflowClassName = _ref.overflowClassName,
|
50
|
+
_ref$overflowType = _ref.overflowType,
|
51
|
+
overflowType = _ref$overflowType === void 0 ? defaults.overflowType : _ref$overflowType,
|
49
52
|
_ref$overflowDirectio = _ref.overflowDirection,
|
50
53
|
overflowDirection = _ref$overflowDirectio === void 0 ? defaults.overflowDirection : _ref$overflowDirectio,
|
51
54
|
allTagsModalTitle = _ref.allTagsModalTitle,
|
@@ -141,13 +144,14 @@ export var TagSet = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
141
144
|
onShowAllClick: handleShowAllClick,
|
142
145
|
overflowTags: newOverflowTags,
|
143
146
|
overflowAlign: overflowAlign,
|
147
|
+
overflowType: overflowType,
|
144
148
|
overflowDirection: overflowDirection,
|
145
149
|
showAllTagsLabel: showAllTagsLabel,
|
146
150
|
key: "displayed-tag-overflow",
|
147
151
|
ref: overflowTag
|
148
152
|
}));
|
149
153
|
setDisplayedTags(newDisplayedTags);
|
150
|
-
}, [displayCount, overflowAlign, overflowClassName, overflowDirection, showAllTagsLabel, tags]);
|
154
|
+
}, [displayCount, overflowAlign, overflowType, overflowClassName, overflowDirection, showAllTagsLabel, tags]);
|
151
155
|
var checkFullyVisibleTags = useCallback(function () {
|
152
156
|
if (multiline) {
|
153
157
|
return setDisplayCount(maxVisible);
|
@@ -300,6 +304,10 @@ TagSet.propTypes = {
|
|
300
304
|
* overflowDirection from the standard tooltip
|
301
305
|
*/
|
302
306
|
overflowDirection: PropTypes.oneOf(['top', 'right', 'bottom', 'left']),
|
307
|
+
/**
|
308
|
+
* Type of rendering displayed inside of the tag overflow component
|
309
|
+
*/
|
310
|
+
overflowType: PropTypes.oneOf(['default', 'tag']),
|
303
311
|
/**
|
304
312
|
* label for the overflow show all tags link.
|
305
313
|
*
|
@@ -2,7 +2,7 @@ import _extends from "@babel/runtime/helpers/extends";
|
|
2
2
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
3
3
|
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
4
4
|
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
5
|
-
var _excluded = ["allTagsModalSearchThreshold", "className", "onShowAllClick", "overflowAlign", "overflowDirection", "overflowTags", "showAllTagsLabel"];
|
5
|
+
var _excluded = ["allTagsModalSearchThreshold", "className", "onShowAllClick", "overflowAlign", "overflowDirection", "overflowTags", "overflowType", "showAllTagsLabel"];
|
6
6
|
//
|
7
7
|
// Copyright IBM Corp. 2021, 2021
|
8
8
|
//
|
@@ -35,6 +35,7 @@ export var TagSetOverflow = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
35
35
|
_ref$overflowDirectio = _ref.overflowDirection,
|
36
36
|
overflowDirection = _ref$overflowDirectio === void 0 ? defaults.overflowDirection : _ref$overflowDirectio,
|
37
37
|
overflowTags = _ref.overflowTags,
|
38
|
+
overflowType = _ref.overflowType,
|
38
39
|
showAllTagsLabel = _ref.showAllTagsLabel,
|
39
40
|
rest = _objectWithoutProperties(_ref, _excluded);
|
40
41
|
var _useState = useState(false),
|
@@ -78,12 +79,18 @@ export var TagSetOverflow = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
78
79
|
}, overflowTags.filter(function (_, index) {
|
79
80
|
return overflowTags.length > allTagsModalSearchThreshold ? index < allTagsModalSearchThreshold : index <= allTagsModalSearchThreshold;
|
80
81
|
}).map(function (tag, index) {
|
82
|
+
var _cx2;
|
83
|
+
var tagProps = {};
|
84
|
+
if (overflowType === 'tag') {
|
85
|
+
tagProps.type = 'high-contrast';
|
86
|
+
}
|
87
|
+
if (overflowType === 'default') {
|
88
|
+
tagProps.filter = false;
|
89
|
+
}
|
81
90
|
return /*#__PURE__*/React.createElement("li", {
|
82
|
-
className: "".concat(blockClass, "__tag-item"),
|
91
|
+
className: cx("".concat(blockClass, "__tag-item"), (_cx2 = {}, _defineProperty(_cx2, "".concat(blockClass, "__tag-item--default"), overflowType === 'default'), _defineProperty(_cx2, "".concat(blockClass, "__tag-item--tag"), overflowType === 'tag'), _cx2)),
|
83
92
|
key: index
|
84
|
-
}, /*#__PURE__*/React.cloneElement(tag,
|
85
|
-
filter: false
|
86
|
-
}));
|
93
|
+
}, /*#__PURE__*/React.cloneElement(tag, tagProps));
|
87
94
|
})), overflowTags.length > allTagsModalSearchThreshold && /*#__PURE__*/React.createElement(Link, {
|
88
95
|
className: "".concat(blockClass, "__show-all-tags-link"),
|
89
96
|
href: "",
|
@@ -117,6 +124,10 @@ TagSetOverflow.propTypes = {
|
|
117
124
|
* tags shown in overflow
|
118
125
|
*/
|
119
126
|
overflowTags: PropTypes.arrayOf(PropTypes.object).isRequired,
|
127
|
+
/**
|
128
|
+
* Type of rendering displayed inside of the tag overflow component
|
129
|
+
*/
|
130
|
+
overflowType: PropTypes.oneOf(['default', 'tag']),
|
120
131
|
/**
|
121
132
|
* label for the overflow show all tags link
|
122
133
|
*/
|
@@ -0,0 +1,51 @@
|
|
1
|
+
import _typeof from "@babel/runtime/helpers/typeof";
|
2
|
+
/**
|
3
|
+
* Copyright IBM Corp. 2023, 2023
|
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
|
+
/**
|
10
|
+
* Returns a compiled string of all the text content of a React node and any of its child nodes.
|
11
|
+
* This is meant to be used in a limited fashion to convert a "styled" sentence into a single string:
|
12
|
+
* e.g. <p>Title <b>Page</b>.</p> --> "Title Page."
|
13
|
+
* This will likely not work for arrays of nodes due to the lack of word spacing:
|
14
|
+
* e.g. <ul>
|
15
|
+
* <li>Item 1</li>
|
16
|
+
* <li>Item 2</li>
|
17
|
+
* <li>Item 3</li>
|
18
|
+
* </ul>
|
19
|
+
* --> "Item 1Item 2Item 3"
|
20
|
+
* @param {Node} node A React node
|
21
|
+
* @returns {string}
|
22
|
+
*/
|
23
|
+
export var getNodeTextContent = function getNodeTextContent(node) {
|
24
|
+
if (node == null) {
|
25
|
+
return '';
|
26
|
+
}
|
27
|
+
switch (_typeof(node)) {
|
28
|
+
case 'string':
|
29
|
+
case 'number':
|
30
|
+
return node.toString();
|
31
|
+
case 'object':
|
32
|
+
{
|
33
|
+
if (node instanceof Array) {
|
34
|
+
return node.map(getNodeTextContent).join('');
|
35
|
+
}
|
36
|
+
if ('props' in node) {
|
37
|
+
return getNodeTextContent(node.props.children);
|
38
|
+
}
|
39
|
+
|
40
|
+
// Ignore any other JavaScript 'object' types.
|
41
|
+
return '';
|
42
|
+
}
|
43
|
+
case 'function':
|
44
|
+
{
|
45
|
+
return getNodeTextContent(node());
|
46
|
+
}
|
47
|
+
default:
|
48
|
+
// Ignore all other JavaScript types.
|
49
|
+
return '';
|
50
|
+
}
|
51
|
+
};
|
@@ -149,7 +149,9 @@ var DatagridContent = function DatagridContent(_ref) {
|
|
149
149
|
filters: filterTags,
|
150
150
|
clearFilters: function clearFilters() {
|
151
151
|
return EventEmitter.dispatch(_constants.CLEAR_FILTERS);
|
152
|
-
}
|
152
|
+
},
|
153
|
+
renderLabel: filterProps.renderLabel,
|
154
|
+
overflowType: "tag"
|
153
155
|
});
|
154
156
|
};
|
155
157
|
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(TableContainer, {
|
@@ -16,7 +16,7 @@ var _layout = require("@carbon/layout");
|
|
16
16
|
var _commonColumnIds = require("../common-column-ids");
|
17
17
|
var _settings = require("../../../settings");
|
18
18
|
var _stateReducer = require("./addons/stateReducer");
|
19
|
-
var
|
19
|
+
var _getNodeTextContent = require("../../../global/js/utils/getNodeTextContent");
|
20
20
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
21
21
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
22
22
|
/**
|
@@ -31,7 +31,7 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
|
|
31
31
|
var blockClass = "".concat(_settings.pkg.prefix, "--datagrid");
|
32
32
|
var getAccessibilityProps = function getAccessibilityProps(header) {
|
33
33
|
var props = {};
|
34
|
-
var title = (0,
|
34
|
+
var title = (0, _getNodeTextContent.getNodeTextContent)(header.Header);
|
35
35
|
if (title) {
|
36
36
|
props.title = title;
|
37
37
|
} else {
|
@@ -12,7 +12,7 @@ var _carbonComponentsReact = require("carbon-components-react");
|
|
12
12
|
var _common = require("./common");
|
13
13
|
var _DraggableElement = _interopRequireDefault(require("../../DraggableElement"));
|
14
14
|
var _settings = require("../../../../../settings");
|
15
|
-
var
|
15
|
+
var _getNodeTextContent = require("../../../../../global/js/utils/getNodeTextContent");
|
16
16
|
var _core = require("@dnd-kit/core");
|
17
17
|
var _sortable = require("@dnd-kit/sortable");
|
18
18
|
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; }
|
@@ -32,12 +32,13 @@ var DraggableItemsList = function DraggableItemsList(_ref) {
|
|
32
32
|
var visibleCols = columns
|
33
33
|
// hide the columns without Header, e.g the sticky actions, spacer
|
34
34
|
.filter(function (colDef) {
|
35
|
-
return
|
35
|
+
return (0, _getNodeTextContent.getNodeTextContent)(colDef.Header).trim().length !== 0;
|
36
36
|
}).filter(Boolean).filter(function (colDef) {
|
37
37
|
return !colDef.isAction;
|
38
38
|
}).filter(function (colDef) {
|
39
|
-
|
40
|
-
|
39
|
+
return colDef.id !== 'spacer';
|
40
|
+
}).filter(function (colDef) {
|
41
|
+
return filterString.length === 0 || (0, _getNodeTextContent.getNodeTextContent)(colDef.Header).toLowerCase().includes(filterString);
|
41
42
|
});
|
42
43
|
|
43
44
|
// let localRefCopy;
|
@@ -50,7 +51,7 @@ var DraggableItemsList = function DraggableItemsList(_ref) {
|
|
50
51
|
var toVisibleIndex = columns.findIndex(function (col) {
|
51
52
|
return matchedColsById(col, over);
|
52
53
|
});
|
53
|
-
var colTitle = (0,
|
54
|
+
var colTitle = (0, _getNodeTextContent.getNodeTextContent)(visibleCols[fromVisibleIndex].Header);
|
54
55
|
setAriaRegionText("".concat(colTitle, " dropped. New position ").concat(toVisibleIndex + 1, " of ").concat(visibleCols.length, "."));
|
55
56
|
var fromIndex = columns.findIndex(function (col) {
|
56
57
|
return matchedColsById(col, active);
|
@@ -65,7 +66,7 @@ var DraggableItemsList = function DraggableItemsList(_ref) {
|
|
65
66
|
var fromIndex = visibleCols.findIndex(function (col) {
|
66
67
|
return matchedColsById(col, active);
|
67
68
|
});
|
68
|
-
var colTitle = (0,
|
69
|
+
var colTitle = (0, _getNodeTextContent.getNodeTextContent)(visibleCols[fromIndex].Header);
|
69
70
|
setAriaRegionText("".concat(colTitle, " grabbed. Current position ").concat(fromIndex + 1, " of ").concat(visibleCols.length, "."));
|
70
71
|
};
|
71
72
|
var handleDragUpdate = function handleDragUpdate(event) {
|
@@ -77,7 +78,7 @@ var DraggableItemsList = function DraggableItemsList(_ref) {
|
|
77
78
|
var toIndex = visibleCols.findIndex(function (col) {
|
78
79
|
return matchedColsById(col, over);
|
79
80
|
});
|
80
|
-
var colTitle = (0,
|
81
|
+
var colTitle = (0, _getNodeTextContent.getNodeTextContent)(visibleCols[fromIndex].Header);
|
81
82
|
setAriaRegionText("".concat(colTitle, " grabbed. Original position ").concat(fromIndex + 1, ", new position ").concat(toIndex + 1, " of ").concat(visibleCols.length, "."));
|
82
83
|
};
|
83
84
|
var pointerSensor = (0, _core.useSensor)(_core.PointerSensor, {
|
@@ -140,7 +141,7 @@ var DraggableItemsList = function DraggableItemsList(_ref) {
|
|
140
141
|
items: visibleCols,
|
141
142
|
strategy: _sortable.verticalListSortingStrategy
|
142
143
|
}, visibleCols.map(function (colDef) {
|
143
|
-
var colHeaderTitle = (0,
|
144
|
+
var colHeaderTitle = (0, _getNodeTextContent.getNodeTextContent)(colDef.Header);
|
144
145
|
var searchString = new RegExp('(' + filterString + ')');
|
145
146
|
var res = filterString.length ? colHeaderTitle.toLowerCase().split(searchString) : null;
|
146
147
|
var firstWord = res !== null ? res[0] === '' ? res[1].charAt(0).toUpperCase() + res[1].substring(1) : res[0].charAt(0).toUpperCase() + res[0].substring(1) : null;
|
package/lib/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditButton/InlineEditButton.js
CHANGED
@@ -10,12 +10,11 @@ var _react = _interopRequireDefault(require("react"));
|
|
10
10
|
var _classnames = _interopRequireDefault(require("classnames"));
|
11
11
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
12
12
|
var _settings = require("../../../../../../settings");
|
13
|
-
|
14
|
-
*
|
15
|
-
*
|
16
|
-
*
|
17
|
-
*
|
18
|
-
* restricted by GSA ADP Schedule Contract with IBM Corp.
|
13
|
+
/**
|
14
|
+
* Copyright IBM Corp. 2022, 2023
|
15
|
+
*
|
16
|
+
* This source code is licensed under the Apache-2.0 license found in the
|
17
|
+
* LICENSE file in the root directory of this source tree.
|
19
18
|
*/
|
20
19
|
|
21
20
|
var blockClass = "".concat(_settings.pkg.prefix, "--datagrid");
|
@@ -29,12 +28,9 @@ var InlineEditButton = function InlineEditButton(_ref) {
|
|
29
28
|
nonEditCell = _ref.nonEditCell,
|
30
29
|
isActiveCell = _ref.isActiveCell,
|
31
30
|
columnConfig = _ref.columnConfig,
|
32
|
-
totalInlineEditColumns = _ref.totalInlineEditColumns,
|
33
|
-
totalColumns = _ref.totalColumns,
|
34
31
|
type = _ref.type;
|
35
|
-
var inlineEditColsLessThanHalfOfTotal = totalInlineEditColumns < totalColumns / 2;
|
36
32
|
return /*#__PURE__*/_react.default.createElement("div", {
|
37
|
-
className: (0, _classnames.default)("".concat(blockClass, "__inline-edit-button"), (_cx = {}, (0, _defineProperty2.default)(_cx, "".concat(blockClass, "__inline-edit-button--disabled"), disabled || nonEditCell), (0, _defineProperty2.default)(_cx, "".concat(blockClass, "__inline-edit-button--with-label-icon"), LabelIcon), (0, _defineProperty2.default)(_cx, "".concat(blockClass, "__inline-edit-button--non-edit"), nonEditCell), (0, _defineProperty2.default)(_cx, "".concat(blockClass, "__inline-edit-button--active"), isActiveCell), (0, _defineProperty2.default)(_cx, "".concat(blockClass, "__inline-edit-button--
|
33
|
+
className: (0, _classnames.default)("".concat(blockClass, "__inline-edit-button"), (_cx = {}, (0, _defineProperty2.default)(_cx, "".concat(blockClass, "__inline-edit-button--disabled"), disabled || nonEditCell), (0, _defineProperty2.default)(_cx, "".concat(blockClass, "__inline-edit-button--with-label-icon"), LabelIcon), (0, _defineProperty2.default)(_cx, "".concat(blockClass, "__inline-edit-button--non-edit"), nonEditCell), (0, _defineProperty2.default)(_cx, "".concat(blockClass, "__inline-edit-button--active"), isActiveCell), (0, _defineProperty2.default)(_cx, "".concat(blockClass, "__inline-edit-button--").concat(type), type === 'date' || type === 'selection'), _cx)),
|
38
34
|
tabIndex: isActiveCell ? 0 : -1,
|
39
35
|
"data-disabled": disabled || nonEditCell,
|
40
36
|
"aria-disabled": disabled || nonEditCell,
|
@@ -60,8 +56,6 @@ InlineEditButton.propTypes = {
|
|
60
56
|
nonEditCell: _propTypes.default.bool,
|
61
57
|
placeholder: _propTypes.default.string,
|
62
58
|
renderIcon: _propTypes.default.oneOfType([_propTypes.default.func, _propTypes.default.object]),
|
63
|
-
totalColumns: _propTypes.default.number,
|
64
|
-
totalInlineEditColumns: _propTypes.default.number,
|
65
59
|
type: _propTypes.default.oneOf(['text', 'number', 'selection', 'date']),
|
66
60
|
value: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.node])
|
67
61
|
};
|