@carbon/ibm-products 2.38.0-alpha.5 → 2.39.0
Sign up to get free protection for your applications and to get access to all the features.
- package/css/index-full-carbon.css +227 -0
- 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 +218 -0
- package/css/index-without-carbon-released-only.css.map +1 -1
- package/css/index-without-carbon-released-only.min.css +1 -1
- package/css/index-without-carbon-released-only.min.css.map +1 -1
- package/css/index-without-carbon.css +227 -0
- 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 +445 -0
- 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/ActionSet/ActionSet.js +3 -2
- package/es/components/Card/Card.js +50 -9
- package/es/components/Card/CardFooter.d.ts +5 -1
- package/es/components/Card/CardFooter.js +11 -1
- package/es/components/Carousel/Carousel.d.ts +6 -2
- package/es/components/Checklist/Checklist.d.ts +100 -2
- package/es/components/Checklist/Checklist.js +19 -15
- package/es/components/Checklist/Checklist.types.d.ts +19 -0
- package/es/components/Checklist/Checklist.types.js +22 -0
- package/es/components/Checklist/ChecklistChart.d.ts +6 -2
- package/es/components/Checklist/ChecklistChart.js +14 -33
- package/es/components/Checklist/ChecklistIcon.d.ts +5 -1
- package/es/components/Checklist/ChecklistIcon.js +9 -4
- package/es/components/Coachmark/Coachmark.d.ts +65 -2
- package/es/components/Coachmark/Coachmark.js +7 -10
- package/es/components/Coachmark/CoachmarkDragbar.d.ts +40 -2
- package/es/components/Coachmark/CoachmarkDragbar.js +3 -1
- package/es/components/Coachmark/CoachmarkHeader.d.ts +27 -2
- package/es/components/Coachmark/CoachmarkHeader.js +0 -1
- package/es/components/Coachmark/CoachmarkOverlay.d.ts +42 -2
- package/es/components/Coachmark/CoachmarkOverlay.js +18 -15
- package/es/components/Coachmark/CoachmarkTagline.d.ts +27 -2
- package/es/components/Coachmark/CoachmarkTagline.js +0 -1
- package/es/components/Coachmark/utils/enums.d.ts +20 -20
- package/es/components/Coachmark/utils/enums.js +22 -20
- package/es/components/CoachmarkButton/CoachmarkButton.d.ts +19 -2
- package/es/components/CoachmarkFixed/CoachmarkFixed.d.ts +42 -2
- package/es/components/CoachmarkFixed/CoachmarkFixed.js +4 -2
- package/es/components/CoachmarkOverlayElements/CoachmarkOverlayElements.d.ts +46 -2
- package/es/components/CoachmarkOverlayElements/CoachmarkOverlayElements.js +5 -4
- package/es/components/ConditionBuilder/ConditionBlock/ConditionBlock.d.ts +2 -1
- package/es/components/ConditionBuilder/ConditionBlock/ConditionBlock.js +25 -23
- package/es/components/ConditionBuilder/ConditionBuilderButton/ConditionBuilderButton.js +2 -2
- package/es/components/ConditionBuilder/ConditionBuilderContent/ConditionBuilderContent.js +14 -24
- package/es/components/ConditionBuilder/ConditionBuilderContext/ConditionBuilderProvider.d.ts +2 -0
- package/es/components/ConditionBuilder/ConditionBuilderContext/ConditionBuilderProvider.js +4 -1
- package/es/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItem.d.ts +3 -3
- package/es/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItem.js +11 -11
- package/es/components/ConditionBuilder/ConditionGroupBuilder/ConditionGroupBuilder.d.ts +5 -3
- package/es/components/ConditionBuilder/ConditionGroupBuilder/ConditionGroupBuilder.js +54 -44
- package/es/components/CreateInfluencer/CreateInfluencer.d.ts +55 -17
- package/es/components/DataSpreadsheet/DataSpreadsheet.d.ts +67 -2
- package/es/components/DataSpreadsheet/DataSpreadsheet.js +48 -27
- package/es/components/DataSpreadsheet/DataSpreadsheetBody.d.ts +139 -2
- package/es/components/DataSpreadsheet/DataSpreadsheetBody.js +60 -39
- package/es/components/DataSpreadsheet/DataSpreadsheetHeader.d.ts +89 -2
- package/es/components/DataSpreadsheet/DataSpreadsheetHeader.js +39 -27
- package/es/components/DataSpreadsheet/hooks/useMoveActiveCell.js +2 -1
- package/es/components/DataSpreadsheet/types/index.d.ts +30 -0
- package/es/components/EditTearsheetNarrow/EditTearsheetNarrow.d.ts +19 -2
- package/es/components/GetStartedCard/GetStartedCard.d.ts +5 -0
- package/es/components/GetStartedCard/GetStartedCard.js +82 -0
- package/es/components/GetStartedCard/index.d.ts +1 -0
- package/es/components/Guidebanner/Guidebanner.js +2 -2
- package/es/components/NotificationsPanel/NotificationsPanel.d.ts +162 -1
- package/es/components/NotificationsPanel/NotificationsPanel.js +10 -10
- package/es/components/SearchBar/SearchBar.d.ts +10 -1
- package/es/components/SearchBar/SearchBar.js +26 -20
- package/es/components/SidePanel/SidePanel.js +1 -1
- package/es/components/TagOverflow/TagOverflow.d.ts +5 -0
- package/es/components/TagOverflow/TagOverflow.js +153 -29
- package/es/components/TagOverflow/TagOverflowModal.d.ts +29 -0
- package/es/components/TagOverflow/TagOverflowModal.js +112 -0
- package/es/components/TagOverflow/TagOverflowPopover.d.ts +2 -0
- package/es/components/TagOverflow/TagOverflowPopover.js +135 -0
- package/es/components/TagSet/TagSet.d.ts +87 -3
- package/es/components/TagSet/TagSet.js +20 -9
- package/es/components/TagSet/TagSetModal.d.ts +32 -26
- package/es/components/TagSet/TagSetModal.js +5 -5
- package/es/components/TagSet/TagSetOverflow.d.ts +45 -2
- package/es/components/TagSet/TagSetOverflow.js +14 -12
- package/es/components/WebTerminal/WebTerminal.js +2 -2
- package/es/components/WebTerminal/WebTerminalContentWrapper.d.ts +15 -2
- package/es/components/WebTerminal/hooks/index.d.ts +16 -11
- package/es/components/WebTerminal/hooks/index.js +1 -1
- package/es/components/index.d.ts +1 -0
- package/es/global/js/package-settings.d.ts +2 -1
- package/es/global/js/package-settings.js +2 -1
- package/es/index.js +1 -0
- package/es/node_modules/@carbon/colors/es/index.js +4 -1
- package/es/settings.d.ts +2 -1
- package/lib/components/ActionSet/ActionSet.js +2 -1
- package/lib/components/Card/Card.js +50 -9
- package/lib/components/Card/CardFooter.d.ts +5 -1
- package/lib/components/Card/CardFooter.js +11 -1
- package/lib/components/Carousel/Carousel.d.ts +6 -2
- package/lib/components/Checklist/Checklist.d.ts +100 -2
- package/lib/components/Checklist/Checklist.js +19 -15
- package/lib/components/Checklist/Checklist.types.d.ts +19 -0
- package/lib/components/Checklist/Checklist.types.js +27 -0
- package/lib/components/Checklist/ChecklistChart.d.ts +6 -2
- package/lib/components/Checklist/ChecklistChart.js +17 -36
- package/lib/components/Checklist/ChecklistIcon.d.ts +5 -1
- package/lib/components/Checklist/ChecklistIcon.js +9 -4
- package/lib/components/Coachmark/Coachmark.d.ts +65 -2
- package/lib/components/Coachmark/Coachmark.js +6 -9
- package/lib/components/Coachmark/CoachmarkDragbar.d.ts +40 -2
- package/lib/components/Coachmark/CoachmarkDragbar.js +3 -1
- package/lib/components/Coachmark/CoachmarkHeader.d.ts +27 -2
- package/lib/components/Coachmark/CoachmarkHeader.js +0 -1
- package/lib/components/Coachmark/CoachmarkOverlay.d.ts +42 -2
- package/lib/components/Coachmark/CoachmarkOverlay.js +18 -15
- package/lib/components/Coachmark/CoachmarkTagline.d.ts +27 -2
- package/lib/components/Coachmark/CoachmarkTagline.js +0 -1
- package/lib/components/Coachmark/utils/enums.d.ts +20 -20
- package/lib/components/Coachmark/utils/enums.js +22 -20
- package/lib/components/CoachmarkButton/CoachmarkButton.d.ts +19 -2
- package/lib/components/CoachmarkFixed/CoachmarkFixed.d.ts +42 -2
- package/lib/components/CoachmarkFixed/CoachmarkFixed.js +4 -2
- package/lib/components/CoachmarkOverlayElements/CoachmarkOverlayElements.d.ts +46 -2
- package/lib/components/CoachmarkOverlayElements/CoachmarkOverlayElements.js +5 -4
- package/lib/components/ConditionBuilder/ConditionBlock/ConditionBlock.d.ts +2 -1
- package/lib/components/ConditionBuilder/ConditionBlock/ConditionBlock.js +25 -23
- package/lib/components/ConditionBuilder/ConditionBuilderButton/ConditionBuilderButton.js +2 -2
- package/lib/components/ConditionBuilder/ConditionBuilderContent/ConditionBuilderContent.js +13 -23
- package/lib/components/ConditionBuilder/ConditionBuilderContext/ConditionBuilderProvider.d.ts +2 -0
- package/lib/components/ConditionBuilder/ConditionBuilderContext/ConditionBuilderProvider.js +4 -1
- package/lib/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItem.d.ts +3 -3
- package/lib/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItem.js +11 -11
- package/lib/components/ConditionBuilder/ConditionGroupBuilder/ConditionGroupBuilder.d.ts +5 -3
- package/lib/components/ConditionBuilder/ConditionGroupBuilder/ConditionGroupBuilder.js +54 -44
- package/lib/components/CreateInfluencer/CreateInfluencer.d.ts +55 -17
- package/lib/components/DataSpreadsheet/DataSpreadsheet.d.ts +67 -2
- package/lib/components/DataSpreadsheet/DataSpreadsheet.js +48 -27
- package/lib/components/DataSpreadsheet/DataSpreadsheetBody.d.ts +139 -2
- package/lib/components/DataSpreadsheet/DataSpreadsheetBody.js +59 -38
- package/lib/components/DataSpreadsheet/DataSpreadsheetHeader.d.ts +89 -2
- package/lib/components/DataSpreadsheet/DataSpreadsheetHeader.js +39 -27
- package/lib/components/DataSpreadsheet/hooks/useMoveActiveCell.js +2 -1
- package/lib/components/DataSpreadsheet/types/index.d.ts +30 -0
- package/lib/components/EditTearsheetNarrow/EditTearsheetNarrow.d.ts +19 -2
- package/lib/components/GetStartedCard/GetStartedCard.d.ts +5 -0
- package/lib/components/GetStartedCard/GetStartedCard.js +88 -0
- package/lib/components/GetStartedCard/index.d.ts +1 -0
- package/lib/components/Guidebanner/Guidebanner.js +2 -2
- package/lib/components/NotificationsPanel/NotificationsPanel.d.ts +162 -1
- package/lib/components/NotificationsPanel/NotificationsPanel.js +10 -10
- package/lib/components/SearchBar/SearchBar.d.ts +10 -1
- package/lib/components/SearchBar/SearchBar.js +26 -18
- package/lib/components/SidePanel/SidePanel.js +1 -1
- package/lib/components/TagOverflow/TagOverflow.d.ts +5 -0
- package/lib/components/TagOverflow/TagOverflow.js +154 -28
- package/lib/components/TagOverflow/TagOverflowModal.d.ts +29 -0
- package/lib/components/TagOverflow/TagOverflowModal.js +121 -0
- package/lib/components/TagOverflow/TagOverflowPopover.d.ts +2 -0
- package/lib/components/TagOverflow/TagOverflowPopover.js +144 -0
- package/lib/components/TagSet/TagSet.d.ts +87 -3
- package/lib/components/TagSet/TagSet.js +20 -9
- package/lib/components/TagSet/TagSetModal.d.ts +32 -26
- package/lib/components/TagSet/TagSetModal.js +3 -3
- package/lib/components/TagSet/TagSetOverflow.d.ts +45 -2
- package/lib/components/TagSet/TagSetOverflow.js +14 -12
- package/lib/components/WebTerminal/WebTerminal.js +2 -2
- package/lib/components/WebTerminal/WebTerminalContentWrapper.d.ts +15 -2
- package/lib/components/WebTerminal/hooks/index.d.ts +16 -11
- package/lib/components/WebTerminal/hooks/index.js +1 -1
- package/lib/components/index.d.ts +1 -0
- package/lib/global/js/package-settings.d.ts +2 -1
- package/lib/global/js/package-settings.js +2 -1
- package/lib/index.js +5 -0
- package/lib/node_modules/@carbon/colors/es/index.js +6 -0
- package/lib/settings.d.ts +2 -1
- package/package.json +3 -3
- package/scss/components/Checklist/_carbon-imports.scss +2 -2
- package/scss/components/GetStartedCard/_carbon-imports.scss +9 -0
- package/scss/components/GetStartedCard/_get-started-card.scss +135 -0
- package/scss/components/GetStartedCard/_index-with-carbon.scss +9 -0
- package/scss/components/GetStartedCard/_index.scss +8 -0
- package/scss/components/TagOverflow/_tag-overflow.scss +157 -0
- package/scss/components/_index-released-only-with-carbon.scss +2 -1
- package/scss/components/_index-released-only.scss +2 -1
- package/scss/components/_index-with-carbon.scss +2 -0
- package/scss/components/_index.scss +1 -0
- package/telemetry.yml +28 -24
@@ -1,2 +1,139 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
/**
|
2
|
+
* Copyright IBM Corp. 2022, 2022
|
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 React, { Dispatch, SetStateAction, MutableRefObject } from 'react';
|
8
|
+
import { ActiveCellCoordinates, Column } from './types';
|
9
|
+
interface DataSpreadsheetBodyProps {
|
10
|
+
/**
|
11
|
+
* Object containing the active cell coordinates
|
12
|
+
*/
|
13
|
+
activeCellCoordinates?: ActiveCellCoordinates | null;
|
14
|
+
/**
|
15
|
+
*This is the ref of the button input, which is the active cell element
|
16
|
+
*/
|
17
|
+
activeCellRef?: MutableRefObject<HTMLElement | undefined>;
|
18
|
+
/**
|
19
|
+
* Is the user clicking and holding in the data spreadsheet body
|
20
|
+
*/
|
21
|
+
clickAndHoldActive?: boolean;
|
22
|
+
/**
|
23
|
+
* All of the spreadsheet columns
|
24
|
+
*/
|
25
|
+
columns?: readonly Column[];
|
26
|
+
/**
|
27
|
+
* This represents the id of the current cell selection area
|
28
|
+
*/
|
29
|
+
currentMatcher?: string;
|
30
|
+
/**
|
31
|
+
* Default spreadsheet sizing values
|
32
|
+
*/
|
33
|
+
defaultColumn?: Column;
|
34
|
+
/**
|
35
|
+
* Sets the number of empty rows to be created when there is no data provided
|
36
|
+
*/
|
37
|
+
defaultEmptyRowCount?: number;
|
38
|
+
/**
|
39
|
+
* Function to set table body prop values
|
40
|
+
*/
|
41
|
+
getTableBodyProps?: () => {
|
42
|
+
data: any;
|
43
|
+
};
|
44
|
+
/**
|
45
|
+
* Headers provided from useTable hook
|
46
|
+
*/
|
47
|
+
headerGroups?: any[];
|
48
|
+
/**
|
49
|
+
* The spreadsheet id
|
50
|
+
*/
|
51
|
+
id?: number | string;
|
52
|
+
/**
|
53
|
+
* The event handler that is called when the active cell changes
|
54
|
+
*/
|
55
|
+
onActiveCellChange?: () => void;
|
56
|
+
/**
|
57
|
+
* The event handler that is called to set the rows for the empty spreadsheet
|
58
|
+
*/
|
59
|
+
onDataUpdate?: ({ ...args }: {
|
60
|
+
[x: string]: any;
|
61
|
+
}) => void;
|
62
|
+
/**
|
63
|
+
* The event handler that is called when the selection areas change
|
64
|
+
*/
|
65
|
+
onSelectionAreaChange?: ({ ...args }: {
|
66
|
+
[x: string]: any;
|
67
|
+
}) => void;
|
68
|
+
/**
|
69
|
+
* Prepare row function from react-table
|
70
|
+
*/
|
71
|
+
prepareRow?: (...args: any[]) => void;
|
72
|
+
/**
|
73
|
+
* All of the spreadsheet row data
|
74
|
+
*/
|
75
|
+
rows?: any[];
|
76
|
+
/**
|
77
|
+
* The scrollbar width
|
78
|
+
*/
|
79
|
+
scrollBarSize?: number;
|
80
|
+
/**
|
81
|
+
* Array of selection area data
|
82
|
+
*/
|
83
|
+
selectionAreaData?: object[];
|
84
|
+
/**
|
85
|
+
* Array of selection areas
|
86
|
+
*/
|
87
|
+
selectionAreas?: any[];
|
88
|
+
/**
|
89
|
+
* Setter fn for activeCellCoordinates state value
|
90
|
+
*/
|
91
|
+
setActiveCellCoordinates?: Dispatch<SetStateAction<ActiveCellCoordinates | null>>;
|
92
|
+
/**
|
93
|
+
* Setter fn for active cell inside of selection area
|
94
|
+
*/
|
95
|
+
setActiveCellInsideSelectionArea?: Dispatch<SetStateAction<boolean>>;
|
96
|
+
/**
|
97
|
+
* Setter fn for clickAndHold state value
|
98
|
+
*/
|
99
|
+
setClickAndHoldActive?: Dispatch<SetStateAction<boolean>>;
|
100
|
+
/**
|
101
|
+
* Setter fn for column ordering, provided from react-table
|
102
|
+
*/
|
103
|
+
setColumnOrder?: () => void;
|
104
|
+
/**
|
105
|
+
* Setter fn for containerHasFocus state value
|
106
|
+
*/
|
107
|
+
setContainerHasFocus?: Dispatch<SetStateAction<boolean>>;
|
108
|
+
/**
|
109
|
+
* Setter fn for currentMatcher state value
|
110
|
+
*/
|
111
|
+
setCurrentMatcher?: Dispatch<SetStateAction<string>>;
|
112
|
+
/**
|
113
|
+
* Setter fn for header cell hold active value
|
114
|
+
*/
|
115
|
+
setHeaderCellHoldActive?: Dispatch<SetStateAction<boolean>>;
|
116
|
+
/**
|
117
|
+
* Setter fn for selectionAreaData state value
|
118
|
+
*/
|
119
|
+
setSelectionAreaData?: Dispatch<SetStateAction<object[]>>;
|
120
|
+
/**
|
121
|
+
* Setter fn for selectionAreas state value
|
122
|
+
*/
|
123
|
+
setSelectionAreas?: Dispatch<SetStateAction<object[]>>;
|
124
|
+
/**
|
125
|
+
* The total columns width
|
126
|
+
*/
|
127
|
+
totalColumnsWidth?: number;
|
128
|
+
/**
|
129
|
+
* The total number of columns to be initially visible, additional columns will be rendered and
|
130
|
+
* visible via horizontal scrollbar
|
131
|
+
*/
|
132
|
+
totalVisibleColumns?: number;
|
133
|
+
/**
|
134
|
+
* Prop from react-table used to reorder columns
|
135
|
+
*/
|
136
|
+
visibleColumns?: [];
|
137
|
+
}
|
138
|
+
export declare const DataSpreadsheetBody: React.ForwardRefExoticComponent<DataSpreadsheetBodyProps & React.RefAttributes<HTMLDivElement>>;
|
139
|
+
export {};
|
@@ -5,7 +5,7 @@
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
6
6
|
*/
|
7
7
|
|
8
|
-
import { slicedToArray as _slicedToArray, toConsumableArray as _toConsumableArray, extends as _extends,
|
8
|
+
import { slicedToArray as _slicedToArray, toConsumableArray as _toConsumableArray, extends as _extends, objectSpread2 as _objectSpread2, defineProperty as _defineProperty } from '../../_virtual/_rollupPluginBabelHelpers.js';
|
9
9
|
import React__default, { forwardRef, useState, useRef, useEffect, useCallback } from 'react';
|
10
10
|
import PropTypes from '../../node_modules/prop-types/index.js';
|
11
11
|
import { FixedSizeList } from 'react-window';
|
@@ -19,6 +19,7 @@ import { checkActiveHeaderCell } from './utils/checkActiveHeaderCell.js';
|
|
19
19
|
import { checkSelectedHeaderCell } from './utils/checkSelectedHeaderCell.js';
|
20
20
|
import { getSpreadsheetWidth } from './utils/getSpreadsheetWidth.js';
|
21
21
|
import { handleBodyCellClick, handleBodyCellHover, handleRowHeaderClick } from './utils/commonEventHandlers.js';
|
22
|
+
import { prepareProps } from '../../global/js/utils/props-helper.js';
|
22
23
|
import { usePreviousValue } from '../../global/js/hooks/usePreviousValue.js';
|
23
24
|
import { useSpreadsheetMouseUp } from './hooks/useSpreadsheetMouseUp.js';
|
24
25
|
|
@@ -62,21 +63,21 @@ var DataSpreadsheetBody = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
62
63
|
var previousState = usePreviousValue({
|
63
64
|
selectionAreaData: selectionAreaData,
|
64
65
|
clickAndHoldActive: clickAndHoldActive,
|
65
|
-
rowHeight: defaultColumn.rowHeight
|
66
|
-
});
|
66
|
+
rowHeight: defaultColumn === null || defaultColumn === void 0 ? void 0 : defaultColumn.rowHeight
|
67
|
+
}) || {};
|
67
68
|
|
68
69
|
// Set custom css property containing the spreadsheet total width
|
69
70
|
useEffect(function () {
|
70
|
-
ref === null || ref === void 0 || ref.current.style.setProperty("--".concat(blockClass, "--total-width"), px(totalColumnsWidth + scrollBarSize));
|
71
|
+
ref === null || ref === void 0 || ref.current.style.setProperty("--".concat(blockClass, "--total-width"), px((totalColumnsWidth || 0) + (scrollBarSize || 0)));
|
71
72
|
}, [ref, scrollBarSize, totalColumnsWidth]);
|
72
73
|
|
73
74
|
// Call the `onSelectionAreaChange` handler to send selection area data
|
74
75
|
// back to the consumer
|
75
76
|
useEffect(function () {
|
76
|
-
if (selectionAreaData.length) {
|
77
|
+
if (selectionAreaData !== null && selectionAreaData !== void 0 && selectionAreaData.length) {
|
77
78
|
var _previousState$select;
|
78
79
|
if (!clickAndHoldActive && previousState !== null && previousState !== void 0 && previousState.clickAndHoldActive || (previousState === null || previousState === void 0 || (_previousState$select = previousState.selectionAreaData) === null || _previousState$select === void 0 ? void 0 : _previousState$select.length) !== (selectionAreaData === null || selectionAreaData === void 0 ? void 0 : selectionAreaData.length)) {
|
79
|
-
onSelectionAreaChange(selectionAreaData);
|
80
|
+
onSelectionAreaChange === null || onSelectionAreaChange === void 0 || onSelectionAreaChange(selectionAreaData);
|
80
81
|
}
|
81
82
|
}
|
82
83
|
}, [previousState === null || previousState === void 0 ? void 0 : previousState.selectionAreaData, selectionAreaData, onSelectionAreaChange, clickAndHoldActive, previousState === null || previousState === void 0 ? void 0 : previousState.clickAndHoldActive]);
|
@@ -108,7 +109,7 @@ var DataSpreadsheetBody = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
108
109
|
}),
|
109
110
|
selectionId: area.matcher
|
110
111
|
};
|
111
|
-
setSelectionAreaData(function (prev) {
|
112
|
+
setSelectionAreaData === null || setSelectionAreaData === void 0 || setSelectionAreaData(function (prev) {
|
112
113
|
var prevValues = deepCloneObject(prev);
|
113
114
|
var newAreaData = prevValues.filter(function (item) {
|
114
115
|
return item.selectionId !== area.matcher;
|
@@ -166,19 +167,28 @@ var DataSpreadsheetBody = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
166
167
|
// cell also gets updated with the new size and new top placement
|
167
168
|
// value. All of the cell selections will be updated as well
|
168
169
|
useEffect(function () {
|
169
|
-
var listContainer
|
170
|
-
var activeCellButton
|
171
|
-
if (
|
170
|
+
var listContainer;
|
171
|
+
var activeCellButton;
|
172
|
+
if (spreadsheetBodyRef !== null && spreadsheetBodyRef !== void 0 && spreadsheetBodyRef.current) {
|
173
|
+
var _listContainer;
|
174
|
+
listContainer = spreadsheetBodyRef === null || spreadsheetBodyRef === void 0 ? void 0 : spreadsheetBodyRef.current;
|
175
|
+
activeCellButton = (_listContainer = listContainer) === null || _listContainer === void 0 ? void 0 : _listContainer.querySelector(".".concat(blockClass, "__active-cell--highlight"));
|
176
|
+
}
|
177
|
+
if (activeCellButton && (defaultColumn === null || defaultColumn === void 0 ? void 0 : defaultColumn.rowHeight) !== previousState.rowHeight) {
|
172
178
|
activeCellButton.style.height = "".concat(defaultColumn === null || defaultColumn === void 0 ? void 0 : defaultColumn.rowHeight, "px");
|
173
179
|
if (activeCellCoordinates) {
|
174
|
-
var activeTargetElement = ref.current.querySelector("[data-row-index=\"".concat(activeCellCoordinates.row, "\"][data-column-index=\"").concat(activeCellCoordinates.column, "\"]"));
|
175
|
-
var
|
176
|
-
var newActiveCellTopPosition
|
180
|
+
var activeTargetElement = ref === null || ref === void 0 ? void 0 : ref.current.querySelector("[data-row-index=\"".concat(activeCellCoordinates.row, "\"][data-column-index=\"").concat(activeCellCoordinates.column, "\"]"));
|
181
|
+
var _listContainer2 = ref === null || ref === void 0 ? void 0 : ref.current.querySelector(".".concat(blockClass, "__list--container"));
|
182
|
+
var newActiveCellTopPosition;
|
183
|
+
if (activeTargetElement && _listContainer2) {
|
184
|
+
newActiveCellTopPosition = (activeTargetElement === null || activeTargetElement === void 0 ? void 0 : activeTargetElement.getBoundingClientRect().top) - _listContainer2.getBoundingClientRect().top;
|
185
|
+
}
|
177
186
|
activeCellButton.style.top = px(newActiveCellTopPosition);
|
178
187
|
removeCellSelections({
|
188
|
+
matcher: undefined,
|
179
189
|
spreadsheetRef: ref
|
180
190
|
});
|
181
|
-
selectionAreas.map(function (area) {
|
191
|
+
selectionAreas === null || selectionAreas === void 0 || selectionAreas.map(function (area) {
|
182
192
|
if (!area.areaCreated && area.point1 && area.point2 && area.matcher) {
|
183
193
|
return createCellSelectionArea({
|
184
194
|
ref: ref,
|
@@ -195,22 +205,18 @@ var DataSpreadsheetBody = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
195
205
|
}
|
196
206
|
}
|
197
207
|
}, [defaultColumn, ref, activeCellCoordinates, previousState === null || previousState === void 0 ? void 0 : previousState.rowHeight, selectionAreas, setActiveCellInsideSelectionArea, setSelectionAreas, visibleColumns]);
|
198
|
-
//selectionAreas will be set when ever a selection area is made.
|
199
|
-
useEffect(function () {
|
200
|
-
removeDuplicateSelections();
|
201
|
-
}, [selectionAreas, removeDuplicateSelections]);
|
202
208
|
|
203
209
|
//this method will check for any duplicate selection area and remove.
|
204
210
|
//same selections are those have the same height, width, top, left styles. These inline styles are being set in createCellSelection util.
|
205
211
|
var removeDuplicateSelections = useCallback(function () {
|
206
212
|
var uniqueAttrArray = [],
|
207
213
|
removedSelectionAreaMatcherArr = [];
|
208
|
-
ref.current.querySelectorAll(".".concat(blockClass, "__selection-area--element")).forEach(function (selectorEl) {
|
209
|
-
var
|
210
|
-
top =
|
211
|
-
left =
|
212
|
-
height =
|
213
|
-
width =
|
214
|
+
ref === null || ref === void 0 || ref.current.querySelectorAll(".".concat(blockClass, "__selection-area--element")).forEach(function (selectorEl) {
|
215
|
+
var _style = selectorEl.style,
|
216
|
+
top = _style.top,
|
217
|
+
left = _style.left,
|
218
|
+
height = _style.height,
|
219
|
+
width = _style.width;
|
214
220
|
var uniqueAttrStr = "".concat(top).concat(left).concat(height).concat(width); // eg: 20px30px70px90px
|
215
221
|
if (uniqueAttrArray.indexOf(uniqueAttrStr) == -1) {
|
216
222
|
uniqueAttrArray.push(uniqueAttrStr);
|
@@ -222,13 +228,13 @@ var DataSpreadsheetBody = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
222
228
|
|
223
229
|
//clean the duplicate selectionAreaData and selectionArea
|
224
230
|
if (removedSelectionAreaMatcherArr.length) {
|
225
|
-
setSelectionAreas(function (prev) {
|
231
|
+
setSelectionAreas === null || setSelectionAreas === void 0 || setSelectionAreas(function (prev) {
|
226
232
|
var prevValues = deepCloneObject(prev);
|
227
233
|
return prevValues.filter(function (item) {
|
228
234
|
return !removedSelectionAreaMatcherArr.includes(item.matcher);
|
229
235
|
});
|
230
236
|
});
|
231
|
-
setSelectionAreaData(function (prev) {
|
237
|
+
setSelectionAreaData === null || setSelectionAreaData === void 0 || setSelectionAreaData(function (prev) {
|
232
238
|
var prevValues = deepCloneObject(prev);
|
233
239
|
return prevValues.filter(function (item) {
|
234
240
|
return !removedSelectionAreaMatcherArr.includes(item.selectionId);
|
@@ -237,6 +243,11 @@ var DataSpreadsheetBody = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
237
243
|
}
|
238
244
|
}, [ref, setSelectionAreas, setSelectionAreaData]);
|
239
245
|
|
246
|
+
//selectionAreas will be set when ever a selection area is made.
|
247
|
+
useEffect(function () {
|
248
|
+
removeDuplicateSelections();
|
249
|
+
}, [selectionAreas, removeDuplicateSelections]);
|
250
|
+
|
240
251
|
// onClick fn for each cell in the data spreadsheet body,
|
241
252
|
// adds the active cell highlight
|
242
253
|
|
@@ -246,14 +257,14 @@ var DataSpreadsheetBody = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
246
257
|
};
|
247
258
|
}, [currentMatcher, activeCellCoordinates, selectionAreas, setActiveCellCoordinates, setSelectionAreas, setContainerHasFocus, setClickAndHoldActive, setCurrentMatcher, ref, setSelectionAreaData, setActiveCellInsideSelectionArea, activeCellRef]);
|
248
259
|
var handleBodyScroll = function handleBodyScroll() {
|
249
|
-
var headerRowElement = ref.current.querySelector("\n .".concat(blockClass, "__header--container .").concat(blockClass, "__tr"));
|
250
|
-
headerRowElement.scrollLeft = contentScrollRef.current.scrollLeft;
|
260
|
+
var headerRowElement = ref.current.querySelector("\n .".concat(blockClass, "__header--container .").concat(blockClass, "__tr")) || new HTMLDivElement();
|
261
|
+
headerRowElement.scrollLeft = contentScrollRef === null || contentScrollRef === void 0 ? void 0 : contentScrollRef.current.scrollLeft;
|
251
262
|
};
|
252
263
|
useEffect(function () {
|
253
|
-
contentScrollRef.current.addEventListener('scroll', function (
|
264
|
+
contentScrollRef.current.addEventListener('scroll', function () {
|
254
265
|
return handleBodyScroll();
|
255
266
|
});
|
256
|
-
var contentScrollElementRef = contentScrollRef.current;
|
267
|
+
var contentScrollElementRef = contentScrollRef.current || new HTMLElement();
|
257
268
|
return function () {
|
258
269
|
contentScrollElementRef.removeEventListener('scroll', handleBodyScroll);
|
259
270
|
};
|
@@ -278,12 +289,12 @@ var DataSpreadsheetBody = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
278
289
|
_toConsumableArray(Array(defaultEmptyRowCount)).map(function () {
|
279
290
|
var _headerGroups$;
|
280
291
|
var emptyCell = {};
|
281
|
-
(_headerGroups$ = headerGroups[0]) === null || _headerGroups$ === void 0 || _headerGroups$.headers.map(function (header) {
|
292
|
+
headerGroups === null || headerGroups === void 0 || (_headerGroups$ = headerGroups[0]) === null || _headerGroups$ === void 0 || _headerGroups$.headers.map(function (header) {
|
282
293
|
emptyCell[header.id] = null;
|
283
294
|
});
|
284
295
|
emptyRowData.push(emptyCell);
|
285
296
|
});
|
286
|
-
onDataUpdate(emptyRowData);
|
297
|
+
onDataUpdate === null || onDataUpdate === void 0 || onDataUpdate(emptyRowData);
|
287
298
|
};
|
288
299
|
buildEmptyRows();
|
289
300
|
}
|
@@ -296,12 +307,15 @@ var DataSpreadsheetBody = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
296
307
|
var RenderRow = useCallback(function (_ref3) {
|
297
308
|
var index = _ref3.index,
|
298
309
|
style = _ref3.style;
|
299
|
-
var row = rows[index];
|
310
|
+
var row = rows === null || rows === void 0 ? void 0 : rows[index];
|
300
311
|
if (rows && rows.length) {
|
301
|
-
prepareRow(row);
|
302
|
-
|
312
|
+
prepareRow === null || prepareRow === void 0 || prepareRow(row);
|
313
|
+
var rowProps = prepareProps(row.getRowProps({
|
303
314
|
style: style
|
304
|
-
}),
|
315
|
+
}), 'key');
|
316
|
+
return /*#__PURE__*/React__default.createElement("div", _extends({
|
317
|
+
key: _objectSpread2({}, row.getRowProps().key)
|
318
|
+
}, rowProps, {
|
305
319
|
className: cx("".concat(blockClass, "__tr")),
|
306
320
|
"data-row-index": index,
|
307
321
|
"aria-rowindex": index + 1,
|
@@ -322,10 +336,11 @@ var DataSpreadsheetBody = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
322
336
|
}
|
323
337
|
}, index + 1)), row.cells.map(function (cell, index) {
|
324
338
|
var _cell$column;
|
339
|
+
var cellProps = prepareProps(cell.getCellProps(), 'key');
|
325
340
|
return /*#__PURE__*/React__default.createElement("div", _extends({
|
326
341
|
key: "cell_".concat(index),
|
327
342
|
"aria-colindex": index + 1
|
328
|
-
},
|
343
|
+
}, cellProps, {
|
329
344
|
role: "gridcell",
|
330
345
|
style: _objectSpread2(_objectSpread2({}, cell.getCellProps().style), {}, {
|
331
346
|
display: 'grid',
|
@@ -349,12 +364,14 @@ var DataSpreadsheetBody = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
349
364
|
return /*#__PURE__*/React__default.createElement("div", _extends({
|
350
365
|
ref: spreadsheetBodyRef,
|
351
366
|
className: cx("".concat(blockClass, "__body--container"))
|
352
|
-
}, getTableBodyProps()), /*#__PURE__*/React__default.createElement(FixedSizeList, {
|
367
|
+
}, getTableBodyProps === null || getTableBodyProps === void 0 ? void 0 : getTableBodyProps()), /*#__PURE__*/React__default.createElement(FixedSizeList, {
|
353
368
|
className: cx("".concat(blockClass, "__list--container"), "".concat(blockClass, "__list--container--").concat(id)),
|
354
369
|
height: 400,
|
355
|
-
itemCount: rows.length || defaultEmptyRowCount,
|
370
|
+
itemCount: (rows === null || rows === void 0 ? void 0 : rows.length) || defaultEmptyRowCount,
|
356
371
|
itemSize: defaultColumn === null || defaultColumn === void 0 ? void 0 : defaultColumn.rowHeight,
|
357
372
|
width: getSpreadsheetWidth({
|
373
|
+
headerGroup: undefined,
|
374
|
+
type: undefined,
|
358
375
|
scrollBarSizeValue: scrollBarSize,
|
359
376
|
totalVisibleColumns: totalVisibleColumns,
|
360
377
|
defaultColumn: defaultColumn,
|
@@ -368,6 +385,7 @@ DataSpreadsheetBody.propTypes = {
|
|
368
385
|
/**
|
369
386
|
* Object containing the active cell coordinates
|
370
387
|
*/
|
388
|
+
/**@ts-ignore */
|
371
389
|
activeCellCoordinates: PropTypes.shape({
|
372
390
|
row: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
373
391
|
column: PropTypes.oneOfType([PropTypes.string, PropTypes.number])
|
@@ -375,6 +393,7 @@ DataSpreadsheetBody.propTypes = {
|
|
375
393
|
/**
|
376
394
|
*This is the ref of the button input, which is the active cell element
|
377
395
|
*/
|
396
|
+
/**@ts-ignore */
|
378
397
|
activeCellRef: PropTypes.object,
|
379
398
|
/**
|
380
399
|
* Is the user clicking and holding in the data spreadsheet body
|
@@ -391,6 +410,7 @@ DataSpreadsheetBody.propTypes = {
|
|
391
410
|
/**
|
392
411
|
* Default spreadsheet sizing values
|
393
412
|
*/
|
413
|
+
/**@ts-ignore */
|
394
414
|
defaultColumn: PropTypes.shape({
|
395
415
|
rowHeight: PropTypes.number,
|
396
416
|
rowHeaderWidth: PropTypes.number,
|
@@ -492,6 +512,7 @@ DataSpreadsheetBody.propTypes = {
|
|
492
512
|
/**
|
493
513
|
* Prop from react-table used to reorder columns
|
494
514
|
*/
|
515
|
+
/**@ts-ignore */
|
495
516
|
visibleColumns: PropTypes.array
|
496
517
|
};
|
497
518
|
|
@@ -1,2 +1,89 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
/**
|
2
|
+
* Copyright IBM Corp. 2022, 2022
|
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 React, { Dispatch, SetStateAction } from 'react';
|
8
|
+
import { ActiveCellCoordinates, Column, ItemType, Size } from './types';
|
9
|
+
interface DataSpreadsheetHeaderProps {
|
10
|
+
/**
|
11
|
+
* Object containing the active cell coordinates
|
12
|
+
*/
|
13
|
+
activeCellCoordinates?: ActiveCellCoordinates | null;
|
14
|
+
/**
|
15
|
+
* Specifies the cell height
|
16
|
+
*/
|
17
|
+
cellSize?: Size;
|
18
|
+
/**
|
19
|
+
* All of the spreadsheet columns
|
20
|
+
*/
|
21
|
+
columns?: readonly Column[];
|
22
|
+
/**
|
23
|
+
* uuid that corresponds to the current selection area
|
24
|
+
*/
|
25
|
+
currentMatcher?: string;
|
26
|
+
/**
|
27
|
+
* Default spreadsheet sizing values
|
28
|
+
*/
|
29
|
+
defaultColumn?: Column;
|
30
|
+
/**
|
31
|
+
* Whether or not a click/hold is active on a header cell
|
32
|
+
*/
|
33
|
+
headerCellHoldActive?: boolean;
|
34
|
+
/**
|
35
|
+
* Headers provided from useTable hook
|
36
|
+
*/
|
37
|
+
headerGroups?: any[];
|
38
|
+
/**
|
39
|
+
* All of the spreadsheet row data
|
40
|
+
*/
|
41
|
+
rows?: object[];
|
42
|
+
/**
|
43
|
+
* The scrollbar width
|
44
|
+
*/
|
45
|
+
scrollBarSize?: number;
|
46
|
+
/**
|
47
|
+
* The aria label applied to the Select all button
|
48
|
+
*/
|
49
|
+
selectAllAriaLabel: string;
|
50
|
+
/**
|
51
|
+
* All of the cell selection area items
|
52
|
+
*/
|
53
|
+
selectionAreas?: ItemType[];
|
54
|
+
/**
|
55
|
+
* Setter fn for activeCellCoordinates value
|
56
|
+
*/
|
57
|
+
setActiveCellCoordinates?: Dispatch<SetStateAction<ActiveCellCoordinates | null>>;
|
58
|
+
/**
|
59
|
+
* Setter fn for currentMatcher value
|
60
|
+
*/
|
61
|
+
setCurrentMatcher?: Dispatch<SetStateAction<string>>;
|
62
|
+
/**
|
63
|
+
* Setter fn for header cell hold active value
|
64
|
+
*/
|
65
|
+
setHeaderCellHoldActive?: (arg: boolean) => void;
|
66
|
+
/**
|
67
|
+
* Setter fn for selectionAreaData state value
|
68
|
+
*/
|
69
|
+
setSelectionAreaData?: Dispatch<SetStateAction<object[]>>;
|
70
|
+
/**
|
71
|
+
* Setter fn for selectionAreas value
|
72
|
+
*/
|
73
|
+
setSelectionAreas?: Dispatch<SetStateAction<object[]>>;
|
74
|
+
/**
|
75
|
+
* The total number of columns to be initially visible, additional columns will be rendered and
|
76
|
+
* visible via horizontal scrollbar
|
77
|
+
*/
|
78
|
+
totalVisibleColumns?: number;
|
79
|
+
/**
|
80
|
+
* Function used to update the active cell coordinates
|
81
|
+
*/
|
82
|
+
updateActiveCellCoordinates?: (arg: any) => void;
|
83
|
+
/**
|
84
|
+
* Array of visible columns provided by react-table useTable hook
|
85
|
+
*/
|
86
|
+
visibleColumns?: [];
|
87
|
+
}
|
88
|
+
export declare const DataSpreadsheetHeader: React.ForwardRefExoticComponent<DataSpreadsheetHeaderProps & React.RefAttributes<HTMLDivElement>>;
|
89
|
+
export {};
|