@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
@@ -56,6 +56,14 @@ interface DataSpreadsheetHeaderProps {
|
|
56
56
|
* Setter fn for activeCellCoordinates value
|
57
57
|
*/
|
58
58
|
setActiveCellCoordinates?: Dispatch<SetStateAction<ActiveCellCoordinates | null>>;
|
59
|
+
/**
|
60
|
+
* Header reordering is active
|
61
|
+
*/
|
62
|
+
selectedHeaderReorderActive?: boolean;
|
63
|
+
/**
|
64
|
+
* Set header reordering active or not
|
65
|
+
*/
|
66
|
+
setSelectedHeaderReorderActive?: Dispatch<SetStateAction<boolean>>;
|
59
67
|
/**
|
60
68
|
* Setter fn for currentMatcher value
|
61
69
|
*/
|
@@ -40,6 +40,8 @@ var DataSpreadsheetHeader = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
40
40
|
headerGroups = _ref.headerGroups,
|
41
41
|
scrollBarSize = _ref.scrollBarSize,
|
42
42
|
selectionAreas = _ref.selectionAreas,
|
43
|
+
selectedHeaderReorderActive = _ref.selectedHeaderReorderActive,
|
44
|
+
setSelectedHeaderReorderActive = _ref.setSelectedHeaderReorderActive,
|
43
45
|
setActiveCellCoordinates = _ref.setActiveCellCoordinates,
|
44
46
|
setCurrentMatcher = _ref.setCurrentMatcher,
|
45
47
|
setSelectionAreas = _ref.setSelectionAreas,
|
@@ -55,10 +57,6 @@ var DataSpreadsheetHeader = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
55
57
|
_useState2 = _rollupPluginBabelHelpers.slicedToArray(_useState, 2),
|
56
58
|
scrollBarSizeValue = _useState2[0],
|
57
59
|
setScrollBarSizeValue = _useState2[1];
|
58
|
-
var _useState3 = React.useState(false),
|
59
|
-
_useState4 = _rollupPluginBabelHelpers.slicedToArray(_useState3, 2),
|
60
|
-
selectedHeaderReorderActive = _useState4[0],
|
61
|
-
setSelectedHeaderReorderActive = _useState4[1];
|
62
60
|
var previousState = usePreviousValue.usePreviousValue({
|
63
61
|
cellSize: cellSize
|
64
62
|
}) || {};
|
@@ -116,11 +114,16 @@ var DataSpreadsheetHeader = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
116
114
|
// Remove columns, need to call handleHeaderCellSelection
|
117
115
|
return;
|
118
116
|
}
|
119
|
-
setSelectedHeaderReorderActive(true);
|
120
117
|
var selectionAreaToClone = selectionAreas === null || selectionAreas === void 0 ? void 0 : selectionAreas.filter(function (item) {
|
121
118
|
return (item === null || item === void 0 ? void 0 : item.matcher) === currentMatcher;
|
122
119
|
});
|
123
120
|
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, "\"]"));
|
121
|
+
if (selectionAreaElement) {
|
122
|
+
selectionAreaElement.classList.add("".concat(blockClass, "__selection-area--element"));
|
123
|
+
}
|
124
|
+
if (typeof setSelectedHeaderReorderActive === 'function') {
|
125
|
+
setSelectedHeaderReorderActive(true);
|
126
|
+
}
|
124
127
|
var clickXPosition = event.clientX;
|
125
128
|
var headerButtonCoords = event.target.getBoundingClientRect();
|
126
129
|
var headerIndex = event.target.getAttribute('data-column-index');
|
@@ -198,7 +201,7 @@ var DataSpreadsheetHeader = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
198
201
|
"data-column-index": index,
|
199
202
|
tabIndex: -1,
|
200
203
|
onMouseDown: selectedHeader ? handleHeaderMouseDown(index) : undefined,
|
201
|
-
onMouseUp: selectedHeader ? function () {
|
204
|
+
onMouseUp: selectedHeader && typeof setSelectedHeaderReorderActive === 'function' ? function () {
|
202
205
|
return setSelectedHeaderReorderActive(false);
|
203
206
|
} : undefined,
|
204
207
|
onClick: !selectedHeader ? handleColumnHeaderClick(index) : undefined,
|
@@ -263,6 +266,10 @@ DataSpreadsheetHeader.propTypes = {
|
|
263
266
|
* The aria label applied to the Select all button
|
264
267
|
*/
|
265
268
|
selectAllAriaLabel: index["default"].string.isRequired,
|
269
|
+
/**
|
270
|
+
* Header reordering is active
|
271
|
+
*/
|
272
|
+
selectedHeaderReorderActive: index["default"].bool,
|
266
273
|
/**
|
267
274
|
* All of the cell selection area items
|
268
275
|
*/
|
@@ -280,6 +287,10 @@ DataSpreadsheetHeader.propTypes = {
|
|
280
287
|
* Setter fn for header cell hold active value
|
281
288
|
*/
|
282
289
|
setHeaderCellHoldActive: index["default"].func,
|
290
|
+
/**
|
291
|
+
* Set header reordering active or not
|
292
|
+
*/
|
293
|
+
setSelectedHeaderReorderActive: index["default"].func,
|
283
294
|
/**
|
284
295
|
* Setter fn for selectionAreaData state value
|
285
296
|
*/
|
@@ -44,9 +44,12 @@ var useSpreadsheetMouseMove = function useSpreadsheetMouseMove(_ref) {
|
|
44
44
|
var totalSpreadsheetScrollingWidth = listContainer.scrollWidth;
|
45
45
|
var clonedSelectionWidth = clonedSelectionElement.offsetWidth;
|
46
46
|
var clonePlacement = Math.max(xPositionRelativeToSpreadsheet - offsetXValue, defaultColumn === null || defaultColumn === void 0 ? void 0 : defaultColumn.rowHeaderWidth);
|
47
|
+
var leftPosition = totalSpreadsheetScrollingWidth - clonedSelectionWidth >= clonePlacement ? clonePlacement + scrollAmount : totalSpreadsheetScrollingWidth - clonedSelectionWidth;
|
47
48
|
// Moves the position of the cloned selection area to follow mouse, and
|
48
49
|
// add the amount horizontally scrolled
|
49
|
-
|
50
|
+
if (leftPosition < spreadsheetCoords.right - 40) {
|
51
|
+
clonedSelectionElement.style.left = layout.px(leftPosition);
|
52
|
+
}
|
50
53
|
};
|
51
54
|
if (headerCellHoldActive) {
|
52
55
|
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;
|
@@ -18,6 +18,8 @@ var deepCloneObject = require('../../../global/js/utils/deepCloneObject.js');
|
|
18
18
|
var useSpreadsheetMouseUp = function useSpreadsheetMouseUp(_ref) {
|
19
19
|
var currentMatcher = _ref.currentMatcher,
|
20
20
|
setSelectionAreas = _ref.setSelectionAreas,
|
21
|
+
selectedHeaderReorderActive = _ref.selectedHeaderReorderActive,
|
22
|
+
setSelectedHeaderReorderActive = _ref.setSelectedHeaderReorderActive,
|
21
23
|
setClickAndHoldActive = _ref.setClickAndHoldActive,
|
22
24
|
setValidStartingPoint = _ref.setValidStartingPoint,
|
23
25
|
validStartingPoint = _ref.validStartingPoint,
|
@@ -34,15 +36,22 @@ var useSpreadsheetMouseUp = function useSpreadsheetMouseUp(_ref) {
|
|
34
36
|
selectionAreas = _ref.selectionAreas;
|
35
37
|
React.useEffect(function () {
|
36
38
|
var handleMouseUp = function handleMouseUp(event) {
|
39
|
+
var _selectionAreas$;
|
40
|
+
var isHoldingColumn = false;
|
41
|
+
if (selectionAreas !== null && selectionAreas !== void 0 && (_selectionAreas$ = selectionAreas[0]) !== null && _selectionAreas$ !== void 0 && _selectionAreas$.header && selectionAreas[0].header.type === 'column') {
|
42
|
+
isHoldingColumn = true;
|
43
|
+
}
|
37
44
|
// Remove the cloned selection area on mouse up
|
38
|
-
if (!validStartingPoint) {
|
45
|
+
if (!validStartingPoint && isHoldingColumn) {
|
39
46
|
setHeaderCellHoldActive(false);
|
47
|
+
var selectionAreaElement = ref.current.querySelector(".".concat(blockClass, "__selection-area--element"));
|
40
48
|
var selectionAreaCloneElement = ref.current.querySelector(".".concat(blockClass, "__selection-area--element-cloned"));
|
41
49
|
if (!selectionAreaCloneElement) {
|
42
50
|
return;
|
43
51
|
}
|
44
52
|
// Mouse up while a cloned selection area exists/a column is being reordered
|
45
53
|
if (selectionAreaCloneElement) {
|
54
|
+
var _selectionAreaElement;
|
46
55
|
var closestCell = event.target.closest(".".concat(blockClass, "--interactive-cell-element"));
|
47
56
|
var newColumnIndex = parseInt === null || parseInt === void 0 ? void 0 : parseInt(closestCell === null || closestCell === void 0 ? void 0 : closestCell.getAttribute('data-column-index'));
|
48
57
|
var originalColumnIndex = parseInt === null || parseInt === void 0 ? void 0 : parseInt(selectionAreaCloneElement === null || selectionAreaCloneElement === void 0 ? void 0 : selectionAreaCloneElement.getAttribute('data-column-index-original'));
|
@@ -85,6 +94,7 @@ var useSpreadsheetMouseUp = function useSpreadsheetMouseUp(_ref) {
|
|
85
94
|
selectionAreaClone[indexOfItemToUpdate].point1.column = Math.min.apply(Math, _rollupPluginBabelHelpers.toConsumableArray(newIndexArray));
|
86
95
|
selectionAreaClone[indexOfItemToUpdate].point2.column = Math.max.apply(Math, _rollupPluginBabelHelpers.toConsumableArray(newIndexArray));
|
87
96
|
}
|
97
|
+
selectionAreaClone[indexOfItemToUpdate].areaCreated = false;
|
88
98
|
return selectionAreaClone;
|
89
99
|
});
|
90
100
|
// Only reorder columns if the new index is _not_ part of the
|
@@ -129,11 +139,13 @@ var useSpreadsheetMouseUp = function useSpreadsheetMouseUp(_ref) {
|
|
129
139
|
var indicatorLineElement = ref.current.querySelector(".".concat(blockClass, "__reorder-indicator-line"));
|
130
140
|
indicatorLineElement === null || indicatorLineElement === void 0 || indicatorLineElement.remove();
|
131
141
|
selectionAreaCloneElement === null || selectionAreaCloneElement === void 0 || selectionAreaCloneElement.remove();
|
142
|
+
selectionAreaElement === null || selectionAreaElement === void 0 || (_selectionAreaElement = selectionAreaElement.classList) === null || _selectionAreaElement === void 0 || _selectionAreaElement.remove("".concat(blockClass, "__selection-area--element"));
|
143
|
+
setSelectedHeaderReorderActive(false);
|
132
144
|
}
|
133
145
|
}
|
134
146
|
// Mouse up was on a spreadsheet body cell which is a valid
|
135
147
|
// start/end point for creating a selection area
|
136
|
-
if (validStartingPoint) {
|
148
|
+
if (validStartingPoint || event.type === 'mouseup') {
|
137
149
|
setClickAndHoldActive(false);
|
138
150
|
setValidStartingPoint(false);
|
139
151
|
var cellButton = event.target.closest(".".concat(blockClass, "__body--td"));
|
@@ -162,7 +174,7 @@ var useSpreadsheetMouseUp = function useSpreadsheetMouseUp(_ref) {
|
|
162
174
|
return function () {
|
163
175
|
document.removeEventListener('mouseup', handleMouseUp);
|
164
176
|
};
|
165
|
-
}, [blockClass, currentMatcher, setSelectionAreas, setClickAndHoldActive, setValidStartingPoint, validStartingPoint, ref, setHeaderCellHoldActive, setColumnOrder, visibleColumns, setActiveCellCoordinates, activeCellCoordinates, rows, defaultColumn, selectionAreas]);
|
177
|
+
}, [blockClass, currentMatcher, setSelectionAreas, setClickAndHoldActive, setValidStartingPoint, validStartingPoint, selectedHeaderReorderActive, setSelectedHeaderReorderActive, ref, setHeaderCellHoldActive, setColumnOrder, visibleColumns, setActiveCellCoordinates, activeCellCoordinates, rows, defaultColumn, selectionAreas]);
|
166
178
|
};
|
167
179
|
|
168
180
|
exports.useSpreadsheetMouseUp = 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;
|
@@ -26,11 +26,43 @@ var moveColumnIndicatorLine = function moveColumnIndicatorLine(_ref) {
|
|
26
26
|
var indicatorLineElement = ref.current.querySelector(".".concat(blockClass, "__reorder-indicator-line"));
|
27
27
|
var matcherId = clonedSelectionElement === null || clonedSelectionElement === void 0 ? void 0 : clonedSelectionElement.getAttribute('data-matcher-id');
|
28
28
|
var selectionAreaOrigin = ref.current.querySelector("[data-matcher-id=\"".concat(matcherId, "\"]"));
|
29
|
+
var listContainer = ref.current.querySelector(".".concat(blockClass, "__list--container"));
|
30
|
+
var scrollSpeed = 10; // Scrolling speed
|
31
|
+
var leftEdgeThreshold = 120; // Distance from the left edge to start scrolling
|
32
|
+
var rightEdgeThreshold = 100; // Distance from the right edge to start scrolling
|
33
|
+
|
34
|
+
var _event = event,
|
35
|
+
clientX = _event.clientX;
|
36
|
+
var _listContainer$getBou = listContainer.getBoundingClientRect(),
|
37
|
+
left = _listContainer$getBou.left,
|
38
|
+
right = _listContainer$getBou.right;
|
39
|
+
|
40
|
+
// Is near left side of viewport
|
41
|
+
if (clientX < leftEdgeThreshold) {
|
42
|
+
window.scrollBy(-scrollSpeed, 0);
|
43
|
+
}
|
44
|
+
|
45
|
+
// Is near right side of viewport
|
46
|
+
if (clientX > window.innerWidth - rightEdgeThreshold) {
|
47
|
+
window.scrollBy(scrollSpeed, 0);
|
48
|
+
}
|
49
|
+
|
50
|
+
// Is near left edge of table
|
51
|
+
if (clientX > left && clientX < left + leftEdgeThreshold) {
|
52
|
+
listContainer.scrollBy(-scrollSpeed, 0);
|
53
|
+
}
|
54
|
+
|
55
|
+
// Is near right edge of table
|
56
|
+
if (clientX < right && clientX > right - rightEdgeThreshold) {
|
57
|
+
listContainer.scrollBy(scrollSpeed, 0);
|
58
|
+
}
|
29
59
|
if (Number(newColumnIndex) > Number(originalColumnIndex)) {
|
30
|
-
|
60
|
+
var leftPosition = closestCellCoords.left - spreadsheetCoords.left + closestCell.offsetWidth - 2 + leftScrollAmount;
|
61
|
+
indicatorLineElement.style.left = layout.px(leftPosition);
|
31
62
|
}
|
32
63
|
if (Number(newColumnIndex) < Number(originalColumnIndex)) {
|
33
|
-
|
64
|
+
var _leftPosition = closestCellCoords.left - spreadsheetCoords.left + leftScrollAmount;
|
65
|
+
indicatorLineElement.style.left = layout.px(_leftPosition);
|
34
66
|
}
|
35
67
|
if (Number(newColumnIndex) === Number(originalColumnIndex)) {
|
36
68
|
indicatorLineElement.style.left = selectionAreaOrigin.style.left;
|
@@ -55,7 +55,8 @@ exports.Datagrid = /*#__PURE__*/React__default["default"].forwardRef(function (_
|
|
55
55
|
};
|
56
56
|
return /*#__PURE__*/React__default["default"].createElement(FilterProvider.FilterProvider, {
|
57
57
|
filters: state === null || state === void 0 ? void 0 : state.filters,
|
58
|
-
filterProps: filterProps
|
58
|
+
filterProps: filterProps,
|
59
|
+
tableId: tableId
|
59
60
|
}, /*#__PURE__*/React__default["default"].createElement(InlineEditContext.InlineEditProvider, null, /*#__PURE__*/React__default["default"].createElement("div", _rollupPluginBabelHelpers["extends"]({}, rest, {
|
60
61
|
id: tableId,
|
61
62
|
ref: ref,
|
@@ -167,7 +167,7 @@ var DatagridContent = function DatagridContent(_ref) {
|
|
167
167
|
className: "".concat(blockClass, "__filter-summary"),
|
168
168
|
filters: filterTags,
|
169
169
|
clearFilters: function clearFilters() {
|
170
|
-
return EventEmitter.dispatch(constants.CLEAR_FILTERS);
|
170
|
+
return EventEmitter.dispatch(constants.CLEAR_FILTERS, tableId);
|
171
171
|
},
|
172
172
|
renderLabel: filterProps === null || filterProps === void 0 ? void 0 : filterProps.renderLabel,
|
173
173
|
overflowType: "tag"
|
@@ -99,7 +99,8 @@ var HeaderRow = function HeaderRow(datagridState, headRef, headerGroup) {
|
|
99
99
|
var resizerAriaLabel = datagridState.resizerAriaLabel,
|
100
100
|
isTableSortable = datagridState.isTableSortable,
|
101
101
|
rows = datagridState.rows,
|
102
|
-
isFetching = datagridState.isFetching
|
102
|
+
isFetching = datagridState.isFetching,
|
103
|
+
headers = datagridState.headers;
|
103
104
|
useInitialColumnSort.useInitialColumnSort(datagridState);
|
104
105
|
// Used to measure the height of the table and uses that value
|
105
106
|
// to display a vertical line to indicate the column you are resizing
|
@@ -161,6 +162,9 @@ var HeaderRow = function HeaderRow(datagridState, headRef, headerGroup) {
|
|
161
162
|
});
|
162
163
|
var key = headerGroupProps.key,
|
163
164
|
rowProps = _rollupPluginBabelHelpers.objectWithoutProperties(headerGroupProps, _excluded2);
|
165
|
+
var withActionsColumn = headers ? !!headers.filter(function (header) {
|
166
|
+
return header.isAction;
|
167
|
+
}).length : false;
|
164
168
|
return /*#__PURE__*/React__default["default"].createElement(react.TableRow, _rollupPluginBabelHelpers["extends"]({
|
165
169
|
key: key
|
166
170
|
}, rowProps, {
|
@@ -193,6 +197,12 @@ var HeaderRow = function HeaderRow(datagridState, headRef, headerGroup) {
|
|
193
197
|
var _header$getHeaderProp = header.getHeaderProps(),
|
194
198
|
headerProps = _rollupPluginBabelHelpers["extends"]({}, (_rollupPluginBabelHelpers.objectDestructuringEmpty(_header$getHeaderProp), _header$getHeaderProp));
|
195
199
|
var resizerProps = header === null || header === void 0 || (_header$getResizerPro = header.getResizerProps) === null || _header$getResizerPro === void 0 ? void 0 : _header$getResizerPro.call(header);
|
200
|
+
var headerStyle = headerProps === null || headerProps === void 0 ? void 0 : headerProps.style;
|
201
|
+
var lastVisibleIndex = withActionsColumn ? 2 : 1;
|
202
|
+
var lastVisibleFlexStyle = index === visibleColumns.length - lastVisibleIndex ? '1 1 0' : '0 0 auto';
|
203
|
+
if (headerStyle) {
|
204
|
+
headerStyle.flex = lastVisibleFlexStyle;
|
205
|
+
}
|
196
206
|
return /*#__PURE__*/React__default["default"].createElement(react.TableHeader, _rollupPluginBabelHelpers["extends"]({}, headerProps, {
|
197
207
|
className: cx__default["default"](header === null || header === void 0 ? void 0 : header.className, _rollupPluginBabelHelpers.defineProperty(_rollupPluginBabelHelpers.defineProperty(_rollupPluginBabelHelpers.defineProperty(_rollupPluginBabelHelpers.defineProperty(_rollupPluginBabelHelpers.defineProperty(_rollupPluginBabelHelpers.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["default"].isValidElement(header === null || header === void 0 ? void 0 : header.slug)), headerProps.className),
|
198
208
|
key: header.id,
|
@@ -25,7 +25,7 @@ var cx__default = /*#__PURE__*/_interopDefaultLegacy(cx);
|
|
25
25
|
|
26
26
|
var _SkeletonText;
|
27
27
|
var _excluded = ["className"],
|
28
|
-
_excluded2 = ["children"];
|
28
|
+
_excluded2 = ["style", "children"];
|
29
29
|
var blockClass = "".concat(settings.pkg.prefix, "--datagrid");
|
30
30
|
var rowHeights = {
|
31
31
|
xs: 24,
|
@@ -48,7 +48,8 @@ var DatagridRow = function DatagridRow(datagridState) {
|
|
48
48
|
withExpandedRows = datagridState.withExpandedRows,
|
49
49
|
withMouseHover = datagridState.withMouseHover,
|
50
50
|
setMouseOverRowIndex = datagridState.setMouseOverRowIndex,
|
51
|
-
headers = datagridState.headers
|
51
|
+
headers = datagridState.headers,
|
52
|
+
visibleColumns = datagridState.visibleColumns;
|
52
53
|
var getVisibleNestedRowCount = function getVisibleNestedRowCount(_ref) {
|
53
54
|
var isExpanded = _ref.isExpanded,
|
54
55
|
subRows = _ref.subRows;
|
@@ -124,6 +125,9 @@ var DatagridRow = function DatagridRow(datagridState) {
|
|
124
125
|
return /*#__PURE__*/React.isValidElement(r === null || r === void 0 || (_r$original = r.original) === null || _r$original === void 0 ? void 0 : _r$original.slug);
|
125
126
|
});
|
126
127
|
var rowClassNames = cx__default["default"]("".concat(blockClass, "__carbon-row"), _rollupPluginBabelHelpers.defineProperty(_rollupPluginBabelHelpers.defineProperty(_rollupPluginBabelHelpers.defineProperty(_rollupPluginBabelHelpers.defineProperty({}, "".concat(blockClass, "__carbon-row-expanded"), row.isExpanded), "".concat(blockClass, "__carbon-row-expandable"), row.canExpand), "".concat(settings.carbon.prefix, "--data-table--selected"), row.isSelected), "".concat(blockClass, "__slug--row"), /*#__PURE__*/React.isValidElement(row === null || row === void 0 || (_row$original = row.original) === null || _row$original === void 0 ? void 0 : _row$original.slug)));
|
128
|
+
var withActionsColumn = headers ? !!headers.filter(function (header) {
|
129
|
+
return header.isAction;
|
130
|
+
}).length : false;
|
127
131
|
return /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, {
|
128
132
|
key: key
|
129
133
|
}, /*#__PURE__*/React__default["default"].createElement(react.TableRow, _rollupPluginBabelHelpers["extends"]({}, rowProps, {
|
@@ -145,6 +149,7 @@ var DatagridRow = function DatagridRow(datagridState) {
|
|
145
149
|
var cellProps = cell.getCellProps();
|
146
150
|
// eslint-disable-next-line no-unused-vars
|
147
151
|
var _ref2 = cellProps,
|
152
|
+
style = _ref2.style,
|
148
153
|
children = _ref2.children,
|
149
154
|
restProps = _rollupPluginBabelHelpers.objectWithoutProperties(_ref2, _excluded2);
|
150
155
|
var columnClassname = cell === null || cell === void 0 || (_cell$column = cell.column) === null || _cell$column === void 0 ? void 0 : _cell$column.className;
|
@@ -159,9 +164,15 @@ var DatagridRow = function DatagridRow(datagridState) {
|
|
159
164
|
var associatedHeader = headers === null || headers === void 0 ? void 0 : headers.filter(function (h) {
|
160
165
|
return h.id === cell.column.id;
|
161
166
|
});
|
167
|
+
var lastVisibleIndex = withActionsColumn ? 2 : 1;
|
168
|
+
var lastVisibleFlexStyle = index === visibleColumns.length - lastVisibleIndex ? '1 1 0' : '0 0 auto';
|
169
|
+
if (style) {
|
170
|
+
style.flex = lastVisibleFlexStyle;
|
171
|
+
}
|
162
172
|
return /*#__PURE__*/React__default["default"].createElement(react.TableCell, _rollupPluginBabelHelpers["extends"]({
|
163
173
|
className: cx__default["default"]("".concat(blockClass, "__cell"), _rollupPluginBabelHelpers.defineProperty(_rollupPluginBabelHelpers.defineProperty(_rollupPluginBabelHelpers.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__*/React.isValidElement((_associatedHeader$ = associatedHeader[0]) === null || _associatedHeader$ === void 0 ? void 0 : _associatedHeader$.slug)), columnClassname)
|
164
174
|
}, restProps, {
|
175
|
+
style: style,
|
165
176
|
key: cell.column.id,
|
166
177
|
title: title
|
167
178
|
}), content);
|
@@ -218,7 +218,12 @@ var FilterFlyout = function FilterFlyout(_ref) {
|
|
218
218
|
closeFlyout();
|
219
219
|
cancel();
|
220
220
|
});
|
221
|
-
|
221
|
+
|
222
|
+
// tableId is passed in from the event emitter from the FilterSummary component
|
223
|
+
// in DatagridContent
|
224
|
+
useSubscribeToEventEmitter["default"](constants.CLEAR_FILTERS, function (tableId) {
|
225
|
+
reset(tableId);
|
226
|
+
});
|
222
227
|
React.useEffect(function reflectLastAppliedFiltersWhenReactTableUpdates() {
|
223
228
|
lastAppliedFilters.current = JSON.stringify(reactTableFiltersState);
|
224
229
|
}, [reactTableFiltersState, lastAppliedFilters]);
|
@@ -192,7 +192,12 @@ var FilterPanel = function FilterPanel(_ref) {
|
|
192
192
|
var _filterPanelRef$curre;
|
193
193
|
(_filterPanelRef$curre = filterPanelRef.current) === null || _filterPanelRef$curre === void 0 || _filterPanelRef$curre.style.setProperty('--filter-panel-min-height', layout.rem(filterPanelMinHeight));
|
194
194
|
}, [filterPanelMinHeight]);
|
195
|
-
|
195
|
+
|
196
|
+
// tableId is passed in from the event emitter from the FilterSummary component
|
197
|
+
// in DatagridContent
|
198
|
+
useSubscribeToEventEmitter["default"](constants.CLEAR_FILTERS, function (tableId) {
|
199
|
+
reset(tableId);
|
200
|
+
});
|
196
201
|
var getScrollableContainerHeight = function getScrollableContainerHeight() {
|
197
202
|
var _filterHeadingRef$cur, _filterSearchRef$curr, _actionSetRef$current;
|
198
203
|
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';
|
@@ -164,7 +164,8 @@ var filteringReducer = function filteringReducer(state, action) {
|
|
164
164
|
var FilterProvider = function FilterProvider(_ref4) {
|
165
165
|
var children = _ref4.children,
|
166
166
|
filters = _ref4.filters,
|
167
|
-
filterProps = _ref4.filterProps
|
167
|
+
filterProps = _ref4.filterProps,
|
168
|
+
tableId = _ref4.tableId;
|
168
169
|
var _ref5 = filterProps || {},
|
169
170
|
renderDateLabel = _ref5.renderDateLabel;
|
170
171
|
var filterTags = prepareFiltersForTags(filters, renderDateLabel);
|
@@ -185,7 +186,8 @@ var FilterProvider = function FilterProvider(_ref4) {
|
|
185
186
|
panelOpen: panelOpen,
|
186
187
|
setPanelOpen: setPanelOpen,
|
187
188
|
state: state,
|
188
|
-
dispatch: dispatch
|
189
|
+
dispatch: dispatch,
|
190
|
+
tableId: tableId
|
189
191
|
};
|
190
192
|
return /*#__PURE__*/React__default["default"].createElement(FilterContext.Provider, {
|
191
193
|
value: value
|
@@ -194,7 +196,8 @@ var FilterProvider = function FilterProvider(_ref4) {
|
|
194
196
|
FilterProvider.propTypes = {
|
195
197
|
children: index["default"].oneOfType([index["default"].arrayOf(index["default"].node), index["default"].node]).isRequired,
|
196
198
|
filterProps: index["default"].object,
|
197
|
-
filters: index["default"].arrayOf(index["default"].object).isRequired
|
199
|
+
filters: index["default"].arrayOf(index["default"].object).isRequired,
|
200
|
+
tableId: index["default"].string
|
198
201
|
};
|
199
202
|
|
200
203
|
exports.FilterContext = FilterContext;
|
@@ -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;
|
@@ -36,7 +36,8 @@ var useFilters = function useFilters(_ref) {
|
|
36
36
|
isFetching = _ref.isFetching;
|
37
37
|
var _useContext = React.useContext(FilterProvider.FilterContext),
|
38
38
|
state = _useContext.state,
|
39
|
-
localDispatch = _useContext.dispatch
|
39
|
+
localDispatch = _useContext.dispatch,
|
40
|
+
contextTableId = _useContext.tableId;
|
40
41
|
var savedFilters = state.savedFilters;
|
41
42
|
/** State */
|
42
43
|
var _useState = React.useState(utils.getInitialStateFromFilters(filters, variation, reactTableFiltersState)),
|
@@ -77,24 +78,28 @@ var useFilters = function useFilters(_ref) {
|
|
77
78
|
holdingLastAppliedFiltersRef.current = JSON.parse(prevFiltersObjectArrayRef.current);
|
78
79
|
holdingPrevFiltersObjectArrayRef.current = JSON.parse(lastAppliedFilters.current);
|
79
80
|
}, [setAllFilters]);
|
80
|
-
var reset = React.useCallback(function () {
|
81
|
-
//
|
82
|
-
|
81
|
+
var reset = React.useCallback(function (tableId) {
|
82
|
+
// only reset filters if tableid of the datagrid that triggered "clear filters"
|
83
|
+
// matches the table id stored in its context instance
|
84
|
+
if (tableId === contextTableId) {
|
85
|
+
// When we reset we want the "initialFilters" to be an empty array
|
86
|
+
var resetFiltersArray = [];
|
83
87
|
|
84
|
-
|
85
|
-
|
86
|
-
|
88
|
+
// Get the initial values for the filters
|
89
|
+
var initialFiltersState = utils.getInitialStateFromFilters(filters, variation, resetFiltersArray);
|
90
|
+
var initialFiltersObjectArray = [];
|
87
91
|
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
+
// Set the state to the initial values
|
93
|
+
setFiltersState(initialFiltersState);
|
94
|
+
setFiltersObjectArray(initialFiltersObjectArray);
|
95
|
+
setAllFilters([]);
|
92
96
|
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
97
|
+
// Update their respective refs so everything is in sync
|
98
|
+
prevFiltersRef.current = JSON.stringify(initialFiltersState);
|
99
|
+
prevFiltersObjectArrayRef.current = JSON.stringify(initialFiltersObjectArray);
|
100
|
+
lastAppliedFilters.current = JSON.stringify([]);
|
101
|
+
}
|
102
|
+
}, [filters, setAllFilters, variation, contextTableId]);
|
98
103
|
var applyFilters = function applyFilters(_ref2) {
|
99
104
|
var column = _ref2.column,
|
100
105
|
value = _ref2.value,
|
@@ -28,7 +28,7 @@ var cx__default = /*#__PURE__*/_interopDefaultLegacy(cx);
|
|
28
28
|
|
29
29
|
var blockClass = "".concat(settings.pkg.prefix, "--datagrid");
|
30
30
|
var InlineEditCell = function InlineEditCell(_ref) {
|
31
|
-
var _config$validator
|
31
|
+
var _config$validator;
|
32
32
|
var cell = _ref.cell,
|
33
33
|
config = _ref.config,
|
34
34
|
_ref$disabledCell = _ref.disabledCell,
|
@@ -456,6 +456,24 @@ var InlineEditCell = function InlineEditCell(_ref) {
|
|
456
456
|
ref: textInputRef
|
457
457
|
}));
|
458
458
|
};
|
459
|
+
var getLabel = function getLabel() {
|
460
|
+
var _value$text, _checkStaticCell;
|
461
|
+
var checkStaticCell = function checkStaticCell(val) {
|
462
|
+
if (_rollupPluginBabelHelpers["typeof"](val) === 'object' && val !== null && val !== void 0 && val.isStaticCell) {
|
463
|
+
return val === null || val === void 0 ? void 0 : val.value;
|
464
|
+
}
|
465
|
+
};
|
466
|
+
switch (type) {
|
467
|
+
case 'selection':
|
468
|
+
checkStaticCell(value);
|
469
|
+
return (_value$text = value === null || value === void 0 ? void 0 : value.text) !== null && _value$text !== void 0 ? _value$text : value;
|
470
|
+
case 'date':
|
471
|
+
checkStaticCell(value);
|
472
|
+
return buildDate(value);
|
473
|
+
default:
|
474
|
+
return (_checkStaticCell = checkStaticCell(value)) !== null && _checkStaticCell !== void 0 ? _checkStaticCell : value;
|
475
|
+
}
|
476
|
+
};
|
459
477
|
return (
|
460
478
|
/*#__PURE__*/
|
461
479
|
// eslint-disable-next-line jsx-a11y/click-events-have-key-events, jsx-a11y/no-static-element-interactions
|
@@ -464,7 +482,7 @@ var InlineEditCell = function InlineEditCell(_ref) {
|
|
464
482
|
"data-cell-id": cellId,
|
465
483
|
"data-column-index": columnIndex,
|
466
484
|
"data-row-index": cell.row.index,
|
467
|
-
"data-disabled": disabledCell,
|
485
|
+
"data-disabled": disabledCell || nonEditCell,
|
468
486
|
"data-inline-type": type,
|
469
487
|
onClick: !nonEditCell ? handleInlineCellClick : addActiveState,
|
470
488
|
onKeyDown: !nonEditCell ? handleKeyDown : null,
|
@@ -472,7 +490,7 @@ var InlineEditCell = function InlineEditCell(_ref) {
|
|
472
490
|
}, !nonEditCell && !disabledCell && renderRegularCell(), (!inEditMode || disabledCell) && /*#__PURE__*/React__default["default"].createElement(InlineEditButton.InlineEditButton, {
|
473
491
|
isActiveCell: cellId === activeCellId,
|
474
492
|
renderIcon: setRenderIcon(),
|
475
|
-
label:
|
493
|
+
label: getLabel(),
|
476
494
|
disabledCell: disabledCell,
|
477
495
|
labelIcon: (value === null || value === void 0 ? void 0 : value.icon) || null,
|
478
496
|
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;
|