@carbon/ibm-products 2.43.2-canary.3 → 2.43.2-canary.31
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/css/index-full-carbon.css +35 -3
- 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.map +1 -1
- package/css/index-without-carbon-released-only.min.css.map +1 -1
- package/css/index-without-carbon.css +35 -3
- 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 +35 -3
- 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/ConditionBuilder/ConditionBlock/ConditionBlock.js +23 -21
- package/es/components/ConditionBuilder/ConditionBuilder.js +67 -20
- package/es/components/ConditionBuilder/ConditionBuilderActions/ConditionBuilderActions.d.ts +15 -0
- package/es/components/ConditionBuilder/ConditionBuilderActions/ConditionBuilderActions.js +129 -0
- package/es/components/ConditionBuilder/ConditionBuilderAdd/ConditionBuilderAdd.js +6 -4
- package/es/components/ConditionBuilder/ConditionBuilderButton/ConditionBuilderButton.d.ts +5 -1
- package/es/components/ConditionBuilder/ConditionBuilderButton/ConditionBuilderButton.js +16 -4
- package/es/components/ConditionBuilder/ConditionBuilderConnector/ConditionConnector.js +2 -2
- package/es/components/ConditionBuilder/ConditionBuilderConnector/GroupConnector.js +2 -2
- package/es/components/ConditionBuilder/ConditionBuilderContent/ConditionBuilderContent.d.ts +9 -11
- package/es/components/ConditionBuilder/ConditionBuilderContent/ConditionBuilderContent.js +36 -32
- package/es/components/ConditionBuilder/ConditionBuilderContext/ConditionBuilderProvider.d.ts +0 -1
- package/es/components/ConditionBuilder/ConditionBuilderContext/ConditionBuilderProvider.js +7 -2
- package/es/components/ConditionBuilder/ConditionBuilderContext/DataConfigs.d.ts +6 -1
- package/es/components/ConditionBuilder/ConditionBuilderContext/DataConfigs.js +18 -10
- package/es/components/ConditionBuilder/ConditionBuilderContext/translationObject.d.ts +39 -36
- package/es/components/ConditionBuilder/ConditionBuilderContext/translationObject.js +12 -10
- package/es/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItem.d.ts +1 -1
- package/es/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItem.js +24 -16
- package/es/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItemNumber/ConditionBuilderItemNumber.js +19 -4
- package/es/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItemOption/ItemOption.d.ts +13 -0
- package/es/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItemOption/ItemOption.js +109 -0
- package/es/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItemOption/{ConditionBuilderItemOption.d.ts → ItemOptionForValueField.d.ts} +2 -2
- package/es/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItemOption/{ConditionBuilderItemOption.js → ItemOptionForValueField.js} +58 -33
- package/es/components/ConditionBuilder/ConditionGroupBuilder/ConditionGroupBuilder.js +4 -6
- package/es/components/ConditionBuilder/ConditionPreview/ConditionPreview.js +14 -5
- package/es/components/ConditionBuilder/utils/handleKeyboardEvents.js +1 -2
- package/es/components/ConditionBuilder/utils/util.d.ts +1 -0
- package/es/components/ConditionBuilder/utils/util.js +16 -1
- package/es/components/DataSpreadsheet/DataSpreadsheet.js +29 -16
- package/es/components/DataSpreadsheet/DataSpreadsheetBody.d.ts +9 -1
- package/es/components/DataSpreadsheet/DataSpreadsheetBody.js +18 -2
- package/es/components/DataSpreadsheet/DataSpreadsheetHeader.d.ts +8 -0
- package/es/components/DataSpreadsheet/DataSpreadsheetHeader.js +17 -6
- package/es/components/DataSpreadsheet/hooks/useSpreadsheetMouseMove.js +4 -1
- package/es/components/DataSpreadsheet/hooks/useSpreadsheetMouseUp.d.ts +3 -1
- package/es/components/DataSpreadsheet/hooks/useSpreadsheetMouseUp.js +15 -3
- package/es/components/DataSpreadsheet/types/index.d.ts +1 -1
- package/es/components/DataSpreadsheet/utils/moveColumnIndicatorLine.js +34 -2
- package/es/components/Datagrid/Datagrid/Datagrid.js +2 -1
- package/es/components/Datagrid/Datagrid/DatagridContent.js +1 -1
- package/es/components/Datagrid/Datagrid/DatagridHeaderRow.js +11 -1
- package/es/components/Datagrid/Datagrid/DatagridRow.js +13 -2
- package/es/components/Datagrid/Datagrid/addons/Filtering/FilterFlyout.js +6 -1
- package/es/components/Datagrid/Datagrid/addons/Filtering/FilterPanel.js +6 -1
- package/es/components/Datagrid/Datagrid/addons/Filtering/FilterProvider.d.ts +3 -1
- package/es/components/Datagrid/Datagrid/addons/Filtering/FilterProvider.js +6 -3
- package/es/components/Datagrid/Datagrid/addons/Filtering/hooks/useFilters.d.ts +1 -1
- package/es/components/Datagrid/Datagrid/addons/Filtering/hooks/useFilters.js +21 -16
- package/es/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditCell/InlineEditCell.js +21 -3
- package/es/components/Datagrid/types/index.d.ts +18 -4
- package/es/components/Datagrid/useActionsColumn.d.ts +8 -1
- package/es/components/Datagrid/useActionsColumn.js +7 -6
- package/es/components/Datagrid/useColumnRightAlign.d.ts +8 -1
- package/es/components/Datagrid/useColumnRightAlign.js +4 -3
- package/es/components/Datagrid/useInlineEdit.js +12 -2
- package/es/components/Datagrid/useNestedRows.js +32 -13
- package/es/components/Decorator/Decorator.js +2 -1
- package/es/components/DecoratorBase/DecoratorBase.js +3 -5
- package/es/components/DecoratorDualButton/DecoratorDualButton.js +2 -1
- package/es/components/DecoratorLink/DecoratorLink.js +2 -1
- package/es/components/DecoratorSingleButton/DecoratorSingleButton.js +2 -1
- package/es/components/HTTPErrors/HTTPError403/HTTPError403.js +6 -0
- package/es/components/HTTPErrors/HTTPError404/HTTPError404.js +6 -0
- package/es/components/HTTPErrors/HTTPErrorOther/HTTPErrorOther.js +6 -0
- package/es/components/RemoveModal/RemoveModal.d.ts +4 -0
- package/es/components/RemoveModal/RemoveModal.js +7 -1
- package/es/components/StatusIndicator/StatusIndicatorStep.js +87 -0
- package/es/components/Tearsheet/Tearsheet.d.ts +8 -1
- package/es/components/Tearsheet/Tearsheet.js +9 -1
- package/es/components/Tearsheet/TearsheetNarrow.d.ts +11 -0
- package/es/components/Tearsheet/TearsheetNarrow.js +12 -0
- package/es/components/Tearsheet/TearsheetShell.d.ts +10 -0
- package/es/components/Tearsheet/TearsheetShell.js +17 -3
- package/es/components/index.d.ts +1 -1
- package/es/index.js +1 -0
- package/lib/components/ConditionBuilder/ConditionBlock/ConditionBlock.js +23 -21
- package/lib/components/ConditionBuilder/ConditionBuilder.js +67 -20
- package/lib/components/ConditionBuilder/ConditionBuilderActions/ConditionBuilderActions.d.ts +15 -0
- package/lib/components/ConditionBuilder/ConditionBuilderActions/ConditionBuilderActions.js +137 -0
- package/lib/components/ConditionBuilder/ConditionBuilderAdd/ConditionBuilderAdd.js +6 -3
- package/lib/components/ConditionBuilder/ConditionBuilderButton/ConditionBuilderButton.d.ts +5 -1
- package/lib/components/ConditionBuilder/ConditionBuilderButton/ConditionBuilderButton.js +16 -4
- package/lib/components/ConditionBuilder/ConditionBuilderConnector/ConditionConnector.js +2 -2
- package/lib/components/ConditionBuilder/ConditionBuilderConnector/GroupConnector.js +2 -2
- package/lib/components/ConditionBuilder/ConditionBuilderContent/ConditionBuilderContent.d.ts +9 -11
- package/lib/components/ConditionBuilder/ConditionBuilderContent/ConditionBuilderContent.js +36 -32
- package/lib/components/ConditionBuilder/ConditionBuilderContext/ConditionBuilderProvider.d.ts +0 -1
- package/lib/components/ConditionBuilder/ConditionBuilderContext/ConditionBuilderProvider.js +7 -2
- package/lib/components/ConditionBuilder/ConditionBuilderContext/DataConfigs.d.ts +6 -1
- package/lib/components/ConditionBuilder/ConditionBuilderContext/DataConfigs.js +18 -10
- package/lib/components/ConditionBuilder/ConditionBuilderContext/translationObject.d.ts +39 -36
- package/lib/components/ConditionBuilder/ConditionBuilderContext/translationObject.js +12 -10
- package/lib/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItem.d.ts +1 -1
- package/lib/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItem.js +23 -15
- package/lib/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItemNumber/ConditionBuilderItemNumber.js +20 -5
- package/lib/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItemOption/ItemOption.d.ts +13 -0
- package/lib/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItemOption/ItemOption.js +117 -0
- package/lib/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItemOption/{ConditionBuilderItemOption.d.ts → ItemOptionForValueField.d.ts} +2 -2
- package/lib/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItemOption/{ConditionBuilderItemOption.js → ItemOptionForValueField.js} +56 -31
- package/lib/components/ConditionBuilder/ConditionGroupBuilder/ConditionGroupBuilder.js +4 -6
- package/lib/components/ConditionBuilder/ConditionPreview/ConditionPreview.js +14 -4
- package/lib/components/ConditionBuilder/utils/handleKeyboardEvents.js +1 -2
- package/lib/components/ConditionBuilder/utils/util.d.ts +1 -0
- package/lib/components/ConditionBuilder/utils/util.js +17 -0
- package/lib/components/DataSpreadsheet/DataSpreadsheet.js +29 -16
- package/lib/components/DataSpreadsheet/DataSpreadsheetBody.d.ts +9 -1
- package/lib/components/DataSpreadsheet/DataSpreadsheetBody.js +18 -2
- package/lib/components/DataSpreadsheet/DataSpreadsheetHeader.d.ts +8 -0
- package/lib/components/DataSpreadsheet/DataSpreadsheetHeader.js +17 -6
- package/lib/components/DataSpreadsheet/hooks/useSpreadsheetMouseMove.js +4 -1
- package/lib/components/DataSpreadsheet/hooks/useSpreadsheetMouseUp.d.ts +3 -1
- package/lib/components/DataSpreadsheet/hooks/useSpreadsheetMouseUp.js +15 -3
- package/lib/components/DataSpreadsheet/types/index.d.ts +1 -1
- package/lib/components/DataSpreadsheet/utils/moveColumnIndicatorLine.js +34 -2
- package/lib/components/Datagrid/Datagrid/Datagrid.js +2 -1
- package/lib/components/Datagrid/Datagrid/DatagridContent.js +1 -1
- package/lib/components/Datagrid/Datagrid/DatagridHeaderRow.js +11 -1
- package/lib/components/Datagrid/Datagrid/DatagridRow.js +13 -2
- package/lib/components/Datagrid/Datagrid/addons/Filtering/FilterFlyout.js +6 -1
- package/lib/components/Datagrid/Datagrid/addons/Filtering/FilterPanel.js +6 -1
- package/lib/components/Datagrid/Datagrid/addons/Filtering/FilterProvider.d.ts +3 -1
- package/lib/components/Datagrid/Datagrid/addons/Filtering/FilterProvider.js +6 -3
- package/lib/components/Datagrid/Datagrid/addons/Filtering/hooks/useFilters.d.ts +1 -1
- package/lib/components/Datagrid/Datagrid/addons/Filtering/hooks/useFilters.js +21 -16
- package/lib/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditCell/InlineEditCell.js +21 -3
- package/lib/components/Datagrid/types/index.d.ts +18 -4
- package/lib/components/Datagrid/useActionsColumn.d.ts +8 -1
- package/lib/components/Datagrid/useActionsColumn.js +7 -6
- package/lib/components/Datagrid/useColumnRightAlign.d.ts +8 -1
- package/lib/components/Datagrid/useColumnRightAlign.js +4 -3
- package/lib/components/Datagrid/useInlineEdit.js +12 -2
- package/lib/components/Datagrid/useNestedRows.js +32 -13
- package/lib/components/Decorator/Decorator.js +2 -1
- package/lib/components/DecoratorBase/DecoratorBase.js +3 -5
- package/lib/components/DecoratorDualButton/DecoratorDualButton.js +2 -1
- package/lib/components/DecoratorLink/DecoratorLink.js +2 -1
- package/lib/components/DecoratorSingleButton/DecoratorSingleButton.js +2 -1
- package/lib/components/HTTPErrors/HTTPError403/HTTPError403.js +6 -0
- package/lib/components/HTTPErrors/HTTPError404/HTTPError404.js +6 -0
- package/lib/components/HTTPErrors/HTTPErrorOther/HTTPErrorOther.js +6 -0
- package/lib/components/RemoveModal/RemoveModal.d.ts +4 -0
- package/lib/components/RemoveModal/RemoveModal.js +7 -1
- package/lib/components/StatusIndicator/StatusIndicatorStep.js +94 -0
- package/lib/components/Tearsheet/Tearsheet.d.ts +8 -1
- package/lib/components/Tearsheet/Tearsheet.js +9 -1
- package/lib/components/Tearsheet/TearsheetNarrow.d.ts +11 -0
- package/lib/components/Tearsheet/TearsheetNarrow.js +12 -0
- package/lib/components/Tearsheet/TearsheetShell.d.ts +10 -0
- package/lib/components/Tearsheet/TearsheetShell.js +16 -2
- package/lib/components/index.d.ts +1 -1
- package/lib/index.js +5 -0
- package/package.json +3 -3
- package/scss/components/ConditionBuilder/styles/_conditionBuilderCondition.scss +9 -1
- package/scss/components/ConditionBuilder/styles/_conditionBuilderItem.scss +26 -1
- package/scss/components/DataSpreadsheet/_data-spreadsheet.scss +1 -0
- package/scss/components/StatusIcon/_status-icon.scss +4 -4
- package/scss/components/StringFormatter/_string-formatter.scss +2 -2
- package/scss/components/UserProfileImage/_user-profile-image.scss +6 -2
- package/telemetry.yml +1 -0
- package/es/components/ConditionBuilder/utils/checkForHoldingKey.d.ts +0 -1
- package/es/components/ConditionBuilder/utils/checkForHoldingKey.js +0 -16
- package/lib/components/ConditionBuilder/utils/checkForHoldingKey.d.ts +0 -1
- package/lib/components/ConditionBuilder/utils/checkForHoldingKey.js +0 -20
@@ -31,6 +31,8 @@ var DataSpreadsheetHeader = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
31
31
|
headerGroups = _ref.headerGroups,
|
32
32
|
scrollBarSize = _ref.scrollBarSize,
|
33
33
|
selectionAreas = _ref.selectionAreas,
|
34
|
+
selectedHeaderReorderActive = _ref.selectedHeaderReorderActive,
|
35
|
+
setSelectedHeaderReorderActive = _ref.setSelectedHeaderReorderActive,
|
34
36
|
setActiveCellCoordinates = _ref.setActiveCellCoordinates,
|
35
37
|
setCurrentMatcher = _ref.setCurrentMatcher,
|
36
38
|
setSelectionAreas = _ref.setSelectionAreas,
|
@@ -46,10 +48,6 @@ var DataSpreadsheetHeader = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
46
48
|
_useState2 = _slicedToArray(_useState, 2),
|
47
49
|
scrollBarSizeValue = _useState2[0],
|
48
50
|
setScrollBarSizeValue = _useState2[1];
|
49
|
-
var _useState3 = useState(false),
|
50
|
-
_useState4 = _slicedToArray(_useState3, 2),
|
51
|
-
selectedHeaderReorderActive = _useState4[0],
|
52
|
-
setSelectedHeaderReorderActive = _useState4[1];
|
53
51
|
var previousState = usePreviousValue({
|
54
52
|
cellSize: cellSize
|
55
53
|
}) || {};
|
@@ -107,11 +105,16 @@ var DataSpreadsheetHeader = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
107
105
|
// Remove columns, need to call handleHeaderCellSelection
|
108
106
|
return;
|
109
107
|
}
|
110
|
-
setSelectedHeaderReorderActive(true);
|
111
108
|
var selectionAreaToClone = selectionAreas === null || selectionAreas === void 0 ? void 0 : selectionAreas.filter(function (item) {
|
112
109
|
return (item === null || item === void 0 ? void 0 : item.matcher) === currentMatcher;
|
113
110
|
});
|
114
111
|
var selectionAreaElement = ref.current.querySelector("[data-matcher-id=\"".concat(selectionAreaToClone === null || selectionAreaToClone === void 0 || (_selectionAreaToClone = selectionAreaToClone[0]) === null || _selectionAreaToClone === void 0 ? void 0 : _selectionAreaToClone.matcher, "\"]"));
|
112
|
+
if (selectionAreaElement) {
|
113
|
+
selectionAreaElement.classList.add("".concat(blockClass, "__selection-area--element"));
|
114
|
+
}
|
115
|
+
if (typeof setSelectedHeaderReorderActive === 'function') {
|
116
|
+
setSelectedHeaderReorderActive(true);
|
117
|
+
}
|
115
118
|
var clickXPosition = event.clientX;
|
116
119
|
var headerButtonCoords = event.target.getBoundingClientRect();
|
117
120
|
var headerIndex = event.target.getAttribute('data-column-index');
|
@@ -189,7 +192,7 @@ var DataSpreadsheetHeader = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
189
192
|
"data-column-index": index,
|
190
193
|
tabIndex: -1,
|
191
194
|
onMouseDown: selectedHeader ? handleHeaderMouseDown(index) : undefined,
|
192
|
-
onMouseUp: selectedHeader ? function () {
|
195
|
+
onMouseUp: selectedHeader && typeof setSelectedHeaderReorderActive === 'function' ? function () {
|
193
196
|
return setSelectedHeaderReorderActive(false);
|
194
197
|
} : undefined,
|
195
198
|
onClick: !selectedHeader ? handleColumnHeaderClick(index) : undefined,
|
@@ -254,6 +257,10 @@ DataSpreadsheetHeader.propTypes = {
|
|
254
257
|
* The aria label applied to the Select all button
|
255
258
|
*/
|
256
259
|
selectAllAriaLabel: PropTypes.string.isRequired,
|
260
|
+
/**
|
261
|
+
* Header reordering is active
|
262
|
+
*/
|
263
|
+
selectedHeaderReorderActive: PropTypes.bool,
|
257
264
|
/**
|
258
265
|
* All of the cell selection area items
|
259
266
|
*/
|
@@ -271,6 +278,10 @@ DataSpreadsheetHeader.propTypes = {
|
|
271
278
|
* Setter fn for header cell hold active value
|
272
279
|
*/
|
273
280
|
setHeaderCellHoldActive: PropTypes.func,
|
281
|
+
/**
|
282
|
+
* Set header reordering active or not
|
283
|
+
*/
|
284
|
+
setSelectedHeaderReorderActive: PropTypes.func,
|
274
285
|
/**
|
275
286
|
* Setter fn for selectionAreaData state value
|
276
287
|
*/
|
@@ -40,9 +40,12 @@ var useSpreadsheetMouseMove = function useSpreadsheetMouseMove(_ref) {
|
|
40
40
|
var totalSpreadsheetScrollingWidth = listContainer.scrollWidth;
|
41
41
|
var clonedSelectionWidth = clonedSelectionElement.offsetWidth;
|
42
42
|
var clonePlacement = Math.max(xPositionRelativeToSpreadsheet - offsetXValue, defaultColumn === null || defaultColumn === void 0 ? void 0 : defaultColumn.rowHeaderWidth);
|
43
|
+
var leftPosition = totalSpreadsheetScrollingWidth - clonedSelectionWidth >= clonePlacement ? clonePlacement + scrollAmount : totalSpreadsheetScrollingWidth - clonedSelectionWidth;
|
43
44
|
// Moves the position of the cloned selection area to follow mouse, and
|
44
45
|
// add the amount horizontally scrolled
|
45
|
-
|
46
|
+
if (leftPosition < spreadsheetCoords.right - 40) {
|
47
|
+
clonedSelectionElement.style.left = px(leftPosition);
|
48
|
+
}
|
46
49
|
};
|
47
50
|
if (headerCellHoldActive) {
|
48
51
|
ref.current.addEventListener('mousemove', handleMouseMove);
|
@@ -1,6 +1,8 @@
|
|
1
|
-
export function useSpreadsheetMouseUp({ currentMatcher, setSelectionAreas, setClickAndHoldActive, setValidStartingPoint, validStartingPoint, blockClass, ref, setHeaderCellHoldActive, setColumnOrder, visibleColumns, setActiveCellCoordinates, activeCellCoordinates, rows, defaultColumn, selectionAreas, }: {
|
1
|
+
export function useSpreadsheetMouseUp({ currentMatcher, setSelectionAreas, selectedHeaderReorderActive, setSelectedHeaderReorderActive, setClickAndHoldActive, setValidStartingPoint, validStartingPoint, blockClass, ref, setHeaderCellHoldActive, setColumnOrder, visibleColumns, setActiveCellCoordinates, activeCellCoordinates, rows, defaultColumn, selectionAreas, }: {
|
2
2
|
currentMatcher: any;
|
3
3
|
setSelectionAreas: any;
|
4
|
+
selectedHeaderReorderActive: any;
|
5
|
+
setSelectedHeaderReorderActive: any;
|
4
6
|
setClickAndHoldActive: any;
|
5
7
|
setValidStartingPoint: any;
|
6
8
|
validStartingPoint: any;
|
@@ -14,6 +14,8 @@ import { deepCloneObject } from '../../../global/js/utils/deepCloneObject.js';
|
|
14
14
|
var useSpreadsheetMouseUp = function useSpreadsheetMouseUp(_ref) {
|
15
15
|
var currentMatcher = _ref.currentMatcher,
|
16
16
|
setSelectionAreas = _ref.setSelectionAreas,
|
17
|
+
selectedHeaderReorderActive = _ref.selectedHeaderReorderActive,
|
18
|
+
setSelectedHeaderReorderActive = _ref.setSelectedHeaderReorderActive,
|
17
19
|
setClickAndHoldActive = _ref.setClickAndHoldActive,
|
18
20
|
setValidStartingPoint = _ref.setValidStartingPoint,
|
19
21
|
validStartingPoint = _ref.validStartingPoint,
|
@@ -30,15 +32,22 @@ var useSpreadsheetMouseUp = function useSpreadsheetMouseUp(_ref) {
|
|
30
32
|
selectionAreas = _ref.selectionAreas;
|
31
33
|
useEffect(function () {
|
32
34
|
var handleMouseUp = function handleMouseUp(event) {
|
35
|
+
var _selectionAreas$;
|
36
|
+
var isHoldingColumn = false;
|
37
|
+
if (selectionAreas !== null && selectionAreas !== void 0 && (_selectionAreas$ = selectionAreas[0]) !== null && _selectionAreas$ !== void 0 && _selectionAreas$.header && selectionAreas[0].header.type === 'column') {
|
38
|
+
isHoldingColumn = true;
|
39
|
+
}
|
33
40
|
// Remove the cloned selection area on mouse up
|
34
|
-
if (!validStartingPoint) {
|
41
|
+
if (!validStartingPoint && isHoldingColumn) {
|
35
42
|
setHeaderCellHoldActive(false);
|
43
|
+
var selectionAreaElement = ref.current.querySelector(".".concat(blockClass, "__selection-area--element"));
|
36
44
|
var selectionAreaCloneElement = ref.current.querySelector(".".concat(blockClass, "__selection-area--element-cloned"));
|
37
45
|
if (!selectionAreaCloneElement) {
|
38
46
|
return;
|
39
47
|
}
|
40
48
|
// Mouse up while a cloned selection area exists/a column is being reordered
|
41
49
|
if (selectionAreaCloneElement) {
|
50
|
+
var _selectionAreaElement;
|
42
51
|
var closestCell = event.target.closest(".".concat(blockClass, "--interactive-cell-element"));
|
43
52
|
var newColumnIndex = parseInt === null || parseInt === void 0 ? void 0 : parseInt(closestCell === null || closestCell === void 0 ? void 0 : closestCell.getAttribute('data-column-index'));
|
44
53
|
var originalColumnIndex = parseInt === null || parseInt === void 0 ? void 0 : parseInt(selectionAreaCloneElement === null || selectionAreaCloneElement === void 0 ? void 0 : selectionAreaCloneElement.getAttribute('data-column-index-original'));
|
@@ -81,6 +90,7 @@ var useSpreadsheetMouseUp = function useSpreadsheetMouseUp(_ref) {
|
|
81
90
|
selectionAreaClone[indexOfItemToUpdate].point1.column = Math.min.apply(Math, _toConsumableArray(newIndexArray));
|
82
91
|
selectionAreaClone[indexOfItemToUpdate].point2.column = Math.max.apply(Math, _toConsumableArray(newIndexArray));
|
83
92
|
}
|
93
|
+
selectionAreaClone[indexOfItemToUpdate].areaCreated = false;
|
84
94
|
return selectionAreaClone;
|
85
95
|
});
|
86
96
|
// Only reorder columns if the new index is _not_ part of the
|
@@ -125,11 +135,13 @@ var useSpreadsheetMouseUp = function useSpreadsheetMouseUp(_ref) {
|
|
125
135
|
var indicatorLineElement = ref.current.querySelector(".".concat(blockClass, "__reorder-indicator-line"));
|
126
136
|
indicatorLineElement === null || indicatorLineElement === void 0 || indicatorLineElement.remove();
|
127
137
|
selectionAreaCloneElement === null || selectionAreaCloneElement === void 0 || selectionAreaCloneElement.remove();
|
138
|
+
selectionAreaElement === null || selectionAreaElement === void 0 || (_selectionAreaElement = selectionAreaElement.classList) === null || _selectionAreaElement === void 0 || _selectionAreaElement.remove("".concat(blockClass, "__selection-area--element"));
|
139
|
+
setSelectedHeaderReorderActive(false);
|
128
140
|
}
|
129
141
|
}
|
130
142
|
// Mouse up was on a spreadsheet body cell which is a valid
|
131
143
|
// start/end point for creating a selection area
|
132
|
-
if (validStartingPoint) {
|
144
|
+
if (validStartingPoint || event.type === 'mouseup') {
|
133
145
|
setClickAndHoldActive(false);
|
134
146
|
setValidStartingPoint(false);
|
135
147
|
var cellButton = event.target.closest(".".concat(blockClass, "__body--td"));
|
@@ -158,7 +170,7 @@ var useSpreadsheetMouseUp = function useSpreadsheetMouseUp(_ref) {
|
|
158
170
|
return function () {
|
159
171
|
document.removeEventListener('mouseup', handleMouseUp);
|
160
172
|
};
|
161
|
-
}, [blockClass, currentMatcher, setSelectionAreas, setClickAndHoldActive, setValidStartingPoint, validStartingPoint, ref, setHeaderCellHoldActive, setColumnOrder, visibleColumns, setActiveCellCoordinates, activeCellCoordinates, rows, defaultColumn, selectionAreas]);
|
173
|
+
}, [blockClass, currentMatcher, setSelectionAreas, setClickAndHoldActive, setValidStartingPoint, validStartingPoint, selectedHeaderReorderActive, setSelectedHeaderReorderActive, ref, setHeaderCellHoldActive, setColumnOrder, visibleColumns, setActiveCellCoordinates, activeCellCoordinates, rows, defaultColumn, selectionAreas]);
|
162
174
|
};
|
163
175
|
|
164
176
|
export { useSpreadsheetMouseUp };
|
@@ -13,7 +13,7 @@ export interface PrevState {
|
|
13
13
|
cellEditorValue?: string;
|
14
14
|
activeCellCoordinates?: ActiveCellCoordinates;
|
15
15
|
isEditing?: boolean;
|
16
|
-
selectionAreaData?:
|
16
|
+
selectionAreaData?: any[];
|
17
17
|
clickAndHoldActive?: boolean;
|
18
18
|
rowHeight?: number;
|
19
19
|
cellSize?: Size;
|
@@ -22,11 +22,43 @@ var moveColumnIndicatorLine = function moveColumnIndicatorLine(_ref) {
|
|
22
22
|
var indicatorLineElement = ref.current.querySelector(".".concat(blockClass, "__reorder-indicator-line"));
|
23
23
|
var matcherId = clonedSelectionElement === null || clonedSelectionElement === void 0 ? void 0 : clonedSelectionElement.getAttribute('data-matcher-id');
|
24
24
|
var selectionAreaOrigin = ref.current.querySelector("[data-matcher-id=\"".concat(matcherId, "\"]"));
|
25
|
+
var listContainer = ref.current.querySelector(".".concat(blockClass, "__list--container"));
|
26
|
+
var scrollSpeed = 10; // Scrolling speed
|
27
|
+
var leftEdgeThreshold = 120; // Distance from the left edge to start scrolling
|
28
|
+
var rightEdgeThreshold = 100; // Distance from the right edge to start scrolling
|
29
|
+
|
30
|
+
var _event = event,
|
31
|
+
clientX = _event.clientX;
|
32
|
+
var _listContainer$getBou = listContainer.getBoundingClientRect(),
|
33
|
+
left = _listContainer$getBou.left,
|
34
|
+
right = _listContainer$getBou.right;
|
35
|
+
|
36
|
+
// Is near left side of viewport
|
37
|
+
if (clientX < leftEdgeThreshold) {
|
38
|
+
window.scrollBy(-scrollSpeed, 0);
|
39
|
+
}
|
40
|
+
|
41
|
+
// Is near right side of viewport
|
42
|
+
if (clientX > window.innerWidth - rightEdgeThreshold) {
|
43
|
+
window.scrollBy(scrollSpeed, 0);
|
44
|
+
}
|
45
|
+
|
46
|
+
// Is near left edge of table
|
47
|
+
if (clientX > left && clientX < left + leftEdgeThreshold) {
|
48
|
+
listContainer.scrollBy(-scrollSpeed, 0);
|
49
|
+
}
|
50
|
+
|
51
|
+
// Is near right edge of table
|
52
|
+
if (clientX < right && clientX > right - rightEdgeThreshold) {
|
53
|
+
listContainer.scrollBy(scrollSpeed, 0);
|
54
|
+
}
|
25
55
|
if (Number(newColumnIndex) > Number(originalColumnIndex)) {
|
26
|
-
|
56
|
+
var leftPosition = closestCellCoords.left - spreadsheetCoords.left + closestCell.offsetWidth - 2 + leftScrollAmount;
|
57
|
+
indicatorLineElement.style.left = px(leftPosition);
|
27
58
|
}
|
28
59
|
if (Number(newColumnIndex) < Number(originalColumnIndex)) {
|
29
|
-
|
60
|
+
var _leftPosition = closestCellCoords.left - spreadsheetCoords.left + leftScrollAmount;
|
61
|
+
indicatorLineElement.style.left = px(_leftPosition);
|
30
62
|
}
|
31
63
|
if (Number(newColumnIndex) === Number(originalColumnIndex)) {
|
32
64
|
indicatorLineElement.style.left = selectionAreaOrigin.style.left;
|
@@ -46,7 +46,8 @@ var Datagrid = /*#__PURE__*/React__default.forwardRef(function (_ref, ref) {
|
|
46
46
|
};
|
47
47
|
return /*#__PURE__*/React__default.createElement(FilterProvider, {
|
48
48
|
filters: state === null || state === void 0 ? void 0 : state.filters,
|
49
|
-
filterProps: filterProps
|
49
|
+
filterProps: filterProps,
|
50
|
+
tableId: tableId
|
50
51
|
}, /*#__PURE__*/React__default.createElement(InlineEditProvider, null, /*#__PURE__*/React__default.createElement("div", _extends({}, rest, {
|
51
52
|
id: tableId,
|
52
53
|
ref: ref,
|
@@ -158,7 +158,7 @@ var DatagridContent = function DatagridContent(_ref) {
|
|
158
158
|
className: "".concat(blockClass, "__filter-summary"),
|
159
159
|
filters: filterTags,
|
160
160
|
clearFilters: function clearFilters() {
|
161
|
-
return EventEmitter.dispatch(CLEAR_FILTERS);
|
161
|
+
return EventEmitter.dispatch(CLEAR_FILTERS, tableId);
|
162
162
|
},
|
163
163
|
renderLabel: filterProps === null || filterProps === void 0 ? void 0 : filterProps.renderLabel,
|
164
164
|
overflowType: "tag"
|
@@ -90,7 +90,8 @@ var HeaderRow = function HeaderRow(datagridState, headRef, headerGroup) {
|
|
90
90
|
var resizerAriaLabel = datagridState.resizerAriaLabel,
|
91
91
|
isTableSortable = datagridState.isTableSortable,
|
92
92
|
rows = datagridState.rows,
|
93
|
-
isFetching = datagridState.isFetching
|
93
|
+
isFetching = datagridState.isFetching,
|
94
|
+
headers = datagridState.headers;
|
94
95
|
useInitialColumnSort(datagridState);
|
95
96
|
// Used to measure the height of the table and uses that value
|
96
97
|
// to display a vertical line to indicate the column you are resizing
|
@@ -152,6 +153,9 @@ var HeaderRow = function HeaderRow(datagridState, headRef, headerGroup) {
|
|
152
153
|
});
|
153
154
|
var key = headerGroupProps.key,
|
154
155
|
rowProps = _objectWithoutProperties(headerGroupProps, _excluded2);
|
156
|
+
var withActionsColumn = headers ? !!headers.filter(function (header) {
|
157
|
+
return header.isAction;
|
158
|
+
}).length : false;
|
155
159
|
return /*#__PURE__*/React__default.createElement(TableRow, _extends({
|
156
160
|
key: key
|
157
161
|
}, rowProps, {
|
@@ -184,6 +188,12 @@ var HeaderRow = function HeaderRow(datagridState, headRef, headerGroup) {
|
|
184
188
|
var _header$getHeaderProp = header.getHeaderProps(),
|
185
189
|
headerProps = _extends({}, (_objectDestructuringEmpty(_header$getHeaderProp), _header$getHeaderProp));
|
186
190
|
var resizerProps = header === null || header === void 0 || (_header$getResizerPro = header.getResizerProps) === null || _header$getResizerPro === void 0 ? void 0 : _header$getResizerPro.call(header);
|
191
|
+
var headerStyle = headerProps === null || headerProps === void 0 ? void 0 : headerProps.style;
|
192
|
+
var lastVisibleIndex = withActionsColumn ? 2 : 1;
|
193
|
+
var lastVisibleFlexStyle = index === visibleColumns.length - lastVisibleIndex ? '1 1 0' : '0 0 auto';
|
194
|
+
if (headerStyle) {
|
195
|
+
headerStyle.flex = lastVisibleFlexStyle;
|
196
|
+
}
|
187
197
|
return /*#__PURE__*/React__default.createElement(TableHeader, _extends({}, headerProps, {
|
188
198
|
className: cx(header === null || header === void 0 ? void 0 : header.className, _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty({}, "".concat(blockClass, "__resizableColumn"), resizerProps), "".concat(blockClass, "__isResizing"), header === null || header === void 0 ? void 0 : header.isResizing), "".concat(blockClass, "__sortableColumn"), datagridState.isTableSortable && header.id !== 'spacer'), "".concat(blockClass, "__isSorted"), header === null || header === void 0 ? void 0 : header.isSorted), "".concat(blockClass, "__header-actions-column"), header === null || header === void 0 ? void 0 : header.isAction), "".concat(blockClass, "__with-slug"), header.slug && /*#__PURE__*/React__default.isValidElement(header === null || header === void 0 ? void 0 : header.slug)), headerProps.className),
|
189
199
|
key: header.id,
|
@@ -16,7 +16,7 @@ import { DatagridSlug } from './addons/Slug/DatagridSlug.js';
|
|
16
16
|
|
17
17
|
var _SkeletonText;
|
18
18
|
var _excluded = ["className"],
|
19
|
-
_excluded2 = ["children"];
|
19
|
+
_excluded2 = ["style", "children"];
|
20
20
|
var blockClass = "".concat(pkg.prefix, "--datagrid");
|
21
21
|
var rowHeights = {
|
22
22
|
xs: 24,
|
@@ -39,7 +39,8 @@ var DatagridRow = function DatagridRow(datagridState) {
|
|
39
39
|
withExpandedRows = datagridState.withExpandedRows,
|
40
40
|
withMouseHover = datagridState.withMouseHover,
|
41
41
|
setMouseOverRowIndex = datagridState.setMouseOverRowIndex,
|
42
|
-
headers = datagridState.headers
|
42
|
+
headers = datagridState.headers,
|
43
|
+
visibleColumns = datagridState.visibleColumns;
|
43
44
|
var getVisibleNestedRowCount = function getVisibleNestedRowCount(_ref) {
|
44
45
|
var isExpanded = _ref.isExpanded,
|
45
46
|
subRows = _ref.subRows;
|
@@ -115,6 +116,9 @@ var DatagridRow = function DatagridRow(datagridState) {
|
|
115
116
|
return /*#__PURE__*/isValidElement(r === null || r === void 0 || (_r$original = r.original) === null || _r$original === void 0 ? void 0 : _r$original.slug);
|
116
117
|
});
|
117
118
|
var rowClassNames = cx("".concat(blockClass, "__carbon-row"), _defineProperty(_defineProperty(_defineProperty(_defineProperty({}, "".concat(blockClass, "__carbon-row-expanded"), row.isExpanded), "".concat(blockClass, "__carbon-row-expandable"), row.canExpand), "".concat(carbon.prefix, "--data-table--selected"), row.isSelected), "".concat(blockClass, "__slug--row"), /*#__PURE__*/isValidElement(row === null || row === void 0 || (_row$original = row.original) === null || _row$original === void 0 ? void 0 : _row$original.slug)));
|
119
|
+
var withActionsColumn = headers ? !!headers.filter(function (header) {
|
120
|
+
return header.isAction;
|
121
|
+
}).length : false;
|
118
122
|
return /*#__PURE__*/React__default.createElement(React__default.Fragment, {
|
119
123
|
key: key
|
120
124
|
}, /*#__PURE__*/React__default.createElement(TableRow, _extends({}, rowProps, {
|
@@ -136,6 +140,7 @@ var DatagridRow = function DatagridRow(datagridState) {
|
|
136
140
|
var cellProps = cell.getCellProps();
|
137
141
|
// eslint-disable-next-line no-unused-vars
|
138
142
|
var _ref2 = cellProps,
|
143
|
+
style = _ref2.style,
|
139
144
|
children = _ref2.children,
|
140
145
|
restProps = _objectWithoutProperties(_ref2, _excluded2);
|
141
146
|
var columnClassname = cell === null || cell === void 0 || (_cell$column = cell.column) === null || _cell$column === void 0 ? void 0 : _cell$column.className;
|
@@ -150,9 +155,15 @@ var DatagridRow = function DatagridRow(datagridState) {
|
|
150
155
|
var associatedHeader = headers === null || headers === void 0 ? void 0 : headers.filter(function (h) {
|
151
156
|
return h.id === cell.column.id;
|
152
157
|
});
|
158
|
+
var lastVisibleIndex = withActionsColumn ? 2 : 1;
|
159
|
+
var lastVisibleFlexStyle = index === visibleColumns.length - lastVisibleIndex ? '1 1 0' : '0 0 auto';
|
160
|
+
if (style) {
|
161
|
+
style.flex = lastVisibleFlexStyle;
|
162
|
+
}
|
153
163
|
return /*#__PURE__*/React__default.createElement(TableCell, _extends({
|
154
164
|
className: cx("".concat(blockClass, "__cell"), _defineProperty(_defineProperty(_defineProperty({}, "".concat(blockClass, "__expandable-row-cell"), row.canExpand && index === 0), "".concat(blockClass, "__expandable-row-cell--is-expanded"), row.isExpanded && index === 0), "".concat(blockClass, "__slug--cell"), associatedHeader && associatedHeader.length && /*#__PURE__*/isValidElement((_associatedHeader$ = associatedHeader[0]) === null || _associatedHeader$ === void 0 ? void 0 : _associatedHeader$.slug)), columnClassname)
|
155
165
|
}, restProps, {
|
166
|
+
style: style,
|
156
167
|
key: cell.column.id,
|
157
168
|
title: title
|
158
169
|
}), content);
|
@@ -209,7 +209,12 @@ var FilterFlyout = function FilterFlyout(_ref) {
|
|
209
209
|
closeFlyout();
|
210
210
|
cancel();
|
211
211
|
});
|
212
|
-
|
212
|
+
|
213
|
+
// tableId is passed in from the event emitter from the FilterSummary component
|
214
|
+
// in DatagridContent
|
215
|
+
useSubscribeToEventEmitter(CLEAR_FILTERS, function (tableId) {
|
216
|
+
reset(tableId);
|
217
|
+
});
|
213
218
|
useEffect(function reflectLastAppliedFiltersWhenReactTableUpdates() {
|
214
219
|
lastAppliedFilters.current = JSON.stringify(reactTableFiltersState);
|
215
220
|
}, [reactTableFiltersState, lastAppliedFilters]);
|
@@ -183,7 +183,12 @@ var FilterPanel = function FilterPanel(_ref) {
|
|
183
183
|
var _filterPanelRef$curre;
|
184
184
|
(_filterPanelRef$curre = filterPanelRef.current) === null || _filterPanelRef$curre === void 0 || _filterPanelRef$curre.style.setProperty('--filter-panel-min-height', rem(filterPanelMinHeight));
|
185
185
|
}, [filterPanelMinHeight]);
|
186
|
-
|
186
|
+
|
187
|
+
// tableId is passed in from the event emitter from the FilterSummary component
|
188
|
+
// in DatagridContent
|
189
|
+
useSubscribeToEventEmitter(CLEAR_FILTERS, function (tableId) {
|
190
|
+
reset(tableId);
|
191
|
+
});
|
187
192
|
var getScrollableContainerHeight = function getScrollableContainerHeight() {
|
188
193
|
var _filterHeadingRef$cur, _filterSearchRef$curr, _actionSetRef$current;
|
189
194
|
var filterHeadingHeight = (_filterHeadingRef$cur = filterHeadingRef.current) === null || _filterHeadingRef$cur === void 0 ? void 0 : _filterHeadingRef$cur.getBoundingClientRect().height;
|
@@ -3,16 +3,18 @@ export function clearSingleFilter({ key, value }: {
|
|
3
3
|
key: any;
|
4
4
|
value: any;
|
5
5
|
}, setAllFilters: any, state: any): void;
|
6
|
-
export function FilterProvider({ children, filters, filterProps }: {
|
6
|
+
export function FilterProvider({ children, filters, filterProps, tableId }: {
|
7
7
|
children: any;
|
8
8
|
filters: any;
|
9
9
|
filterProps: any;
|
10
|
+
tableId: any;
|
10
11
|
}): import("react/jsx-runtime").JSX.Element;
|
11
12
|
export namespace FilterProvider {
|
12
13
|
namespace propTypes {
|
13
14
|
let children: PropTypes.Validator<NonNullable<NonNullable<PropTypes.ReactNodeLike>>>;
|
14
15
|
let filterProps: PropTypes.Requireable<object>;
|
15
16
|
let filters: PropTypes.Validator<(object | null | undefined)[]>;
|
17
|
+
let tableId: PropTypes.Requireable<string>;
|
16
18
|
}
|
17
19
|
}
|
18
20
|
import React from 'react';
|
@@ -156,7 +156,8 @@ var filteringReducer = function filteringReducer(state, action) {
|
|
156
156
|
var FilterProvider = function FilterProvider(_ref4) {
|
157
157
|
var children = _ref4.children,
|
158
158
|
filters = _ref4.filters,
|
159
|
-
filterProps = _ref4.filterProps
|
159
|
+
filterProps = _ref4.filterProps,
|
160
|
+
tableId = _ref4.tableId;
|
160
161
|
var _ref5 = filterProps || {},
|
161
162
|
renderDateLabel = _ref5.renderDateLabel;
|
162
163
|
var filterTags = prepareFiltersForTags(filters, renderDateLabel);
|
@@ -177,7 +178,8 @@ var FilterProvider = function FilterProvider(_ref4) {
|
|
177
178
|
panelOpen: panelOpen,
|
178
179
|
setPanelOpen: setPanelOpen,
|
179
180
|
state: state,
|
180
|
-
dispatch: dispatch
|
181
|
+
dispatch: dispatch,
|
182
|
+
tableId: tableId
|
181
183
|
};
|
182
184
|
return /*#__PURE__*/React__default.createElement(FilterContext.Provider, {
|
183
185
|
value: value
|
@@ -186,7 +188,8 @@ var FilterProvider = function FilterProvider(_ref4) {
|
|
186
188
|
FilterProvider.propTypes = {
|
187
189
|
children: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.node), PropTypes.node]).isRequired,
|
188
190
|
filterProps: PropTypes.object,
|
189
|
-
filters: PropTypes.arrayOf(PropTypes.object).isRequired
|
191
|
+
filters: PropTypes.arrayOf(PropTypes.object).isRequired,
|
192
|
+
tableId: PropTypes.string
|
190
193
|
};
|
191
194
|
|
192
195
|
export { FilterContext, FilterProvider, clearSingleFilter };
|
@@ -15,7 +15,7 @@ declare function useFilters({ updateMethod, filters, setAllFilters, variation, r
|
|
15
15
|
prevFiltersObjectArrayRef: React.MutableRefObject<string>;
|
16
16
|
prevFiltersRef: React.MutableRefObject<string>;
|
17
17
|
revertToPreviousFilters: () => void;
|
18
|
-
reset: () => void;
|
18
|
+
reset: (tableId: any) => void;
|
19
19
|
renderFilter: ({ type, column, props: components }: {
|
20
20
|
type: any;
|
21
21
|
column: any;
|
@@ -28,7 +28,8 @@ var useFilters = function useFilters(_ref) {
|
|
28
28
|
isFetching = _ref.isFetching;
|
29
29
|
var _useContext = useContext(FilterContext),
|
30
30
|
state = _useContext.state,
|
31
|
-
localDispatch = _useContext.dispatch
|
31
|
+
localDispatch = _useContext.dispatch,
|
32
|
+
contextTableId = _useContext.tableId;
|
32
33
|
var savedFilters = state.savedFilters;
|
33
34
|
/** State */
|
34
35
|
var _useState = useState(getInitialStateFromFilters(filters, variation, reactTableFiltersState)),
|
@@ -69,24 +70,28 @@ var useFilters = function useFilters(_ref) {
|
|
69
70
|
holdingLastAppliedFiltersRef.current = JSON.parse(prevFiltersObjectArrayRef.current);
|
70
71
|
holdingPrevFiltersObjectArrayRef.current = JSON.parse(lastAppliedFilters.current);
|
71
72
|
}, [setAllFilters]);
|
72
|
-
var reset = useCallback(function () {
|
73
|
-
//
|
74
|
-
|
73
|
+
var reset = useCallback(function (tableId) {
|
74
|
+
// only reset filters if tableid of the datagrid that triggered "clear filters"
|
75
|
+
// matches the table id stored in its context instance
|
76
|
+
if (tableId === contextTableId) {
|
77
|
+
// When we reset we want the "initialFilters" to be an empty array
|
78
|
+
var resetFiltersArray = [];
|
75
79
|
|
76
|
-
|
77
|
-
|
78
|
-
|
80
|
+
// Get the initial values for the filters
|
81
|
+
var initialFiltersState = getInitialStateFromFilters(filters, variation, resetFiltersArray);
|
82
|
+
var initialFiltersObjectArray = [];
|
79
83
|
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
+
// Set the state to the initial values
|
85
|
+
setFiltersState(initialFiltersState);
|
86
|
+
setFiltersObjectArray(initialFiltersObjectArray);
|
87
|
+
setAllFilters([]);
|
84
88
|
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
89
|
+
// Update their respective refs so everything is in sync
|
90
|
+
prevFiltersRef.current = JSON.stringify(initialFiltersState);
|
91
|
+
prevFiltersObjectArrayRef.current = JSON.stringify(initialFiltersObjectArray);
|
92
|
+
lastAppliedFilters.current = JSON.stringify([]);
|
93
|
+
}
|
94
|
+
}, [filters, setAllFilters, variation, contextTableId]);
|
90
95
|
var applyFilters = function applyFilters(_ref2) {
|
91
96
|
var column = _ref2.column,
|
92
97
|
value = _ref2.value,
|
@@ -19,7 +19,7 @@ import { InlineEditButton } from '../InlineEditButton/InlineEditButton.js';
|
|
19
19
|
|
20
20
|
var blockClass = "".concat(pkg.prefix, "--datagrid");
|
21
21
|
var InlineEditCell = function InlineEditCell(_ref) {
|
22
|
-
var _config$validator
|
22
|
+
var _config$validator;
|
23
23
|
var cell = _ref.cell,
|
24
24
|
config = _ref.config,
|
25
25
|
_ref$disabledCell = _ref.disabledCell,
|
@@ -447,6 +447,24 @@ var InlineEditCell = function InlineEditCell(_ref) {
|
|
447
447
|
ref: textInputRef
|
448
448
|
}));
|
449
449
|
};
|
450
|
+
var getLabel = function getLabel() {
|
451
|
+
var _value$text, _checkStaticCell;
|
452
|
+
var checkStaticCell = function checkStaticCell(val) {
|
453
|
+
if (_typeof(val) === 'object' && val !== null && val !== void 0 && val.isStaticCell) {
|
454
|
+
return val === null || val === void 0 ? void 0 : val.value;
|
455
|
+
}
|
456
|
+
};
|
457
|
+
switch (type) {
|
458
|
+
case 'selection':
|
459
|
+
checkStaticCell(value);
|
460
|
+
return (_value$text = value === null || value === void 0 ? void 0 : value.text) !== null && _value$text !== void 0 ? _value$text : value;
|
461
|
+
case 'date':
|
462
|
+
checkStaticCell(value);
|
463
|
+
return buildDate(value);
|
464
|
+
default:
|
465
|
+
return (_checkStaticCell = checkStaticCell(value)) !== null && _checkStaticCell !== void 0 ? _checkStaticCell : value;
|
466
|
+
}
|
467
|
+
};
|
450
468
|
return (
|
451
469
|
/*#__PURE__*/
|
452
470
|
// eslint-disable-next-line jsx-a11y/click-events-have-key-events, jsx-a11y/no-static-element-interactions
|
@@ -455,7 +473,7 @@ var InlineEditCell = function InlineEditCell(_ref) {
|
|
455
473
|
"data-cell-id": cellId,
|
456
474
|
"data-column-index": columnIndex,
|
457
475
|
"data-row-index": cell.row.index,
|
458
|
-
"data-disabled": disabledCell,
|
476
|
+
"data-disabled": disabledCell || nonEditCell,
|
459
477
|
"data-inline-type": type,
|
460
478
|
onClick: !nonEditCell ? handleInlineCellClick : addActiveState,
|
461
479
|
onKeyDown: !nonEditCell ? handleKeyDown : null,
|
@@ -463,7 +481,7 @@ var InlineEditCell = function InlineEditCell(_ref) {
|
|
463
481
|
}, !nonEditCell && !disabledCell && renderRegularCell(), (!inEditMode || disabledCell) && /*#__PURE__*/React__default.createElement(InlineEditButton, {
|
464
482
|
isActiveCell: cellId === activeCellId,
|
465
483
|
renderIcon: setRenderIcon(),
|
466
|
-
label:
|
484
|
+
label: getLabel(),
|
467
485
|
disabledCell: disabledCell,
|
468
486
|
labelIcon: (value === null || value === void 0 ? void 0 : value.icon) || null,
|
469
487
|
placeholder: placeholder,
|
@@ -5,10 +5,10 @@ import { RadioButtonProps } from '@carbon/react/lib/components/RadioButton/Radio
|
|
5
5
|
import { RadioButtonGroupProps } from '@carbon/react/lib/components/RadioButtonGroup/RadioButtonGroup';
|
6
6
|
import { CheckboxProps } from '@carbon/react/lib/components/Checkbox';
|
7
7
|
import { NumberInputProps } from '@carbon/react/lib/components/NumberInput/NumberInput';
|
8
|
-
import { CSSProperties, JSXElementConstructor, MutableRefObject, ReactNode, TouchEventHandler } from 'react';
|
9
|
-
import { Cell, Column, ColumnInstance, FilterValue, Filters, HeaderGroup, Meta, Row, TableCommonProps, TableDispatch, TableInstance, TableToggleAllRowsSelectedProps, UseExpandedRowProps, UseFiltersInstanceProps, UsePaginationInstanceProps, UseResizeColumnsColumnProps, UseResizeColumnsState, UseRowSelectInstanceProps, UseRowSelectRowProps, UseRowSelectState, UseSortByColumnProps, UseTableHooks } from 'react-table';
|
8
|
+
import React, { CSSProperties, ComponentType, FunctionComponent, JSXElementConstructor, MutableRefObject, ReactNode, TouchEventHandler } from 'react';
|
9
|
+
import { Cell, Column, ColumnInstance, FilterValue, Filters, HeaderGroup, Meta, Row, TableCommonProps, TableDispatch, TableInstance, TableToggleAllRowsSelectedProps, UseExpandedRowProps, UseFiltersInstanceProps, UsePaginationInstanceProps, UseResizeColumnsColumnProps, UseResizeColumnsState, UseRowSelectInstanceProps, UseRowSelectRowProps, UseRowSelectState, UseSortByColumnProps, UseSortByOptions, UseTableHooks } from 'react-table';
|
10
10
|
import { CarbonIconType } from '@carbon/react/icons';
|
11
|
-
import { type ButtonProps } from '@carbon/react';
|
11
|
+
import { IconButton, type ButtonProps } from '@carbon/react';
|
12
12
|
import { TableBatchActionsProps } from '@carbon/react/lib/components/DataTable/TableBatchActions';
|
13
13
|
export type Size = 'xs' | 'sm' | 'md' | 'lg';
|
14
14
|
export interface ResizerProps {
|
@@ -85,9 +85,10 @@ export interface DataGridToggleAllRowsProps extends TableToggleAllRowsSelectedPr
|
|
85
85
|
}
|
86
86
|
export interface DatagridTableHooks<T extends object = any> extends UseTableHooks<T> {
|
87
87
|
}
|
88
|
-
export interface DatagridColumn<T extends object = any> extends ColumnInstance<T> {
|
88
|
+
export interface DatagridColumn<T extends object = any> extends ColumnInstance<T>, UseSortByOptions<T> {
|
89
89
|
sticky?: 'left' | 'right';
|
90
90
|
className?: string;
|
91
|
+
rightAlignedColumn?: boolean;
|
91
92
|
disableSortBy?: boolean;
|
92
93
|
centerAlignedColumn?: boolean;
|
93
94
|
}
|
@@ -100,6 +101,7 @@ export interface DatagridRow<T extends object = any> extends Omit<Row<T>, 'cells
|
|
100
101
|
RowExpansionRenderer?: (state?: DataGridState) => void;
|
101
102
|
cells: Array<DataGridCell>;
|
102
103
|
isSkeleton?: boolean;
|
104
|
+
hasExpanded?: boolean;
|
103
105
|
}
|
104
106
|
export interface DataGridHeader<T extends object = any> extends ColumnInstance, UseResizeColumnsColumnProps<T>, UseSortByColumnProps<T> {
|
105
107
|
className(className: any, arg1: {
|
@@ -120,6 +122,16 @@ interface DataGridTableState extends UseResizeColumnsState<any>, UseRowSelectSta
|
|
120
122
|
}
|
121
123
|
export interface DataGridTableInstance<T extends object = any> extends TableInstance<T> {
|
122
124
|
}
|
125
|
+
export interface RowAction {
|
126
|
+
id?: string;
|
127
|
+
itemText?: string;
|
128
|
+
icon?: ComponentType | FunctionComponent;
|
129
|
+
align?: React.ComponentProps<typeof IconButton>['align'];
|
130
|
+
shouldHideMenuItem?: (...args: any[]) => void;
|
131
|
+
shouldDisableMenuItem?: (...args: any[]) => void;
|
132
|
+
disabled?: boolean;
|
133
|
+
onClick?: (...args: any[]) => void;
|
134
|
+
}
|
123
135
|
export interface DataGridState<T extends object = any> extends TableCommonProps, UsePaginationInstanceProps<T>, Omit<TableInstance<T>, 'state' | 'headers' | 'rows' | 'columns'>, Omit<UseFiltersInstanceProps<T>, 'rows'>, UseRowSelectInstanceProps<T>, Pick<UseRowSelectInstanceProps<T>, 'toggleAllRowsSelected'> {
|
124
136
|
withVirtualScroll?: boolean;
|
125
137
|
DatagridPagination?: JSXElementConstructor<any>;
|
@@ -142,6 +154,7 @@ export interface DataGridState<T extends object = any> extends TableCommonProps,
|
|
142
154
|
batchActions?: boolean;
|
143
155
|
row: DatagridRow;
|
144
156
|
rows: Array<DatagridRow<any>>;
|
157
|
+
rowActions?: RowAction[];
|
145
158
|
columns: Array<DatagridColumn>;
|
146
159
|
key?: any;
|
147
160
|
rowSize?: Size;
|
@@ -217,4 +230,5 @@ export interface ResizeHeaderProps {
|
|
217
230
|
isFetching?: boolean;
|
218
231
|
}
|
219
232
|
export type VisibleColumns<T extends object = {}> = (allColumns: Array<ColumnInstance<T>>, meta: Meta<T>) => Array<Column<T>>;
|
233
|
+
export type NodeFuncType = (props: any) => ReactNode;
|
220
234
|
export {};
|
@@ -1,2 +1,9 @@
|
|
1
|
+
/**
|
2
|
+
* Copyright IBM Corp. 2021, 2023
|
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
|
+
import { Hooks } from 'react-table';
|
8
|
+
declare const useActionsColumn: (hooks: Hooks) => void;
|
1
9
|
export default useActionsColumn;
|
2
|
-
declare function useActionsColumn(hooks: any): void;
|
@@ -17,9 +17,10 @@ var _excluded = ["align", "id", "itemText", "onClick", "icon", "shouldHideMenuIt
|
|
17
17
|
var blockClass = "".concat(pkg.prefix, "--datagrid");
|
18
18
|
var useActionsColumn = function useActionsColumn(hooks) {
|
19
19
|
var useAttachActionsOnInstance = function useAttachActionsOnInstance(instance) {
|
20
|
-
var
|
21
|
-
|
22
|
-
|
20
|
+
var _ref = instance,
|
21
|
+
rowActions = _ref.rowActions,
|
22
|
+
isFetching = _ref.isFetching,
|
23
|
+
selectedRowIds = _ref.state.selectedRowIds;
|
23
24
|
var getDisabledState = function getDisabledState(rowIndex) {
|
24
25
|
var selectedRowIndexes = Object.keys(selectedRowIds).map(function (n) {
|
25
26
|
return Number(n);
|
@@ -79,10 +80,10 @@ var useActionsColumn = function useActionsColumn(hooks) {
|
|
79
80
|
return;
|
80
81
|
}
|
81
82
|
e.stopPropagation();
|
82
|
-
_onClick(id, row, e);
|
83
|
+
_onClick === null || _onClick === void 0 || _onClick(id, row, e);
|
83
84
|
},
|
84
85
|
disabled: isDisabledByRow
|
85
|
-
}), /*#__PURE__*/React__default.createElement(Icon, null)));
|
86
|
+
}), Icon && /*#__PURE__*/React__default.createElement(Icon, null)));
|
86
87
|
})), !isFetching && (rowActions.length > 2 || isColumnSticky) && /*#__PURE__*/React__default.createElement("div", null, /*#__PURE__*/React__default.createElement(OverflowMenu, {
|
87
88
|
align: "left",
|
88
89
|
size: "sm",
|
@@ -108,7 +109,7 @@ var useActionsColumn = function useActionsColumn(hooks) {
|
|
108
109
|
disabled: isDisabledByRow,
|
109
110
|
onClick: function onClick(e) {
|
110
111
|
e.stopPropagation();
|
111
|
-
_onClick2(id, row, e);
|
112
|
+
_onClick2 === null || _onClick2 === void 0 || _onClick2(id, row, e);
|
112
113
|
},
|
113
114
|
key: id
|
114
115
|
}));
|