@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 {};
|
@@ -23,6 +23,7 @@ var checkActiveHeaderCell = require('./utils/checkActiveHeaderCell.js');
|
|
23
23
|
var checkSelectedHeaderCell = require('./utils/checkSelectedHeaderCell.js');
|
24
24
|
var getSpreadsheetWidth = require('./utils/getSpreadsheetWidth.js');
|
25
25
|
var commonEventHandlers = require('./utils/commonEventHandlers.js');
|
26
|
+
var propsHelper = require('../../global/js/utils/props-helper.js');
|
26
27
|
var usePreviousValue = require('../../global/js/hooks/usePreviousValue.js');
|
27
28
|
var useSpreadsheetMouseUp = require('./hooks/useSpreadsheetMouseUp.js');
|
28
29
|
|
@@ -71,21 +72,21 @@ var DataSpreadsheetBody = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
71
72
|
var previousState = usePreviousValue.usePreviousValue({
|
72
73
|
selectionAreaData: selectionAreaData,
|
73
74
|
clickAndHoldActive: clickAndHoldActive,
|
74
|
-
rowHeight: defaultColumn.rowHeight
|
75
|
-
});
|
75
|
+
rowHeight: defaultColumn === null || defaultColumn === void 0 ? void 0 : defaultColumn.rowHeight
|
76
|
+
}) || {};
|
76
77
|
|
77
78
|
// Set custom css property containing the spreadsheet total width
|
78
79
|
React.useEffect(function () {
|
79
|
-
ref === null || ref === void 0 || ref.current.style.setProperty("--".concat(blockClass, "--total-width"), layout.px(totalColumnsWidth + scrollBarSize));
|
80
|
+
ref === null || ref === void 0 || ref.current.style.setProperty("--".concat(blockClass, "--total-width"), layout.px((totalColumnsWidth || 0) + (scrollBarSize || 0)));
|
80
81
|
}, [ref, scrollBarSize, totalColumnsWidth]);
|
81
82
|
|
82
83
|
// Call the `onSelectionAreaChange` handler to send selection area data
|
83
84
|
// back to the consumer
|
84
85
|
React.useEffect(function () {
|
85
|
-
if (selectionAreaData.length) {
|
86
|
+
if (selectionAreaData !== null && selectionAreaData !== void 0 && selectionAreaData.length) {
|
86
87
|
var _previousState$select;
|
87
88
|
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)) {
|
88
|
-
onSelectionAreaChange(selectionAreaData);
|
89
|
+
onSelectionAreaChange === null || onSelectionAreaChange === void 0 || onSelectionAreaChange(selectionAreaData);
|
89
90
|
}
|
90
91
|
}
|
91
92
|
}, [previousState === null || previousState === void 0 ? void 0 : previousState.selectionAreaData, selectionAreaData, onSelectionAreaChange, clickAndHoldActive, previousState === null || previousState === void 0 ? void 0 : previousState.clickAndHoldActive]);
|
@@ -117,7 +118,7 @@ var DataSpreadsheetBody = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
117
118
|
}),
|
118
119
|
selectionId: area.matcher
|
119
120
|
};
|
120
|
-
setSelectionAreaData(function (prev) {
|
121
|
+
setSelectionAreaData === null || setSelectionAreaData === void 0 || setSelectionAreaData(function (prev) {
|
121
122
|
var prevValues = deepCloneObject.deepCloneObject(prev);
|
122
123
|
var newAreaData = prevValues.filter(function (item) {
|
123
124
|
return item.selectionId !== area.matcher;
|
@@ -175,19 +176,28 @@ var DataSpreadsheetBody = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
175
176
|
// cell also gets updated with the new size and new top placement
|
176
177
|
// value. All of the cell selections will be updated as well
|
177
178
|
React.useEffect(function () {
|
178
|
-
var listContainer
|
179
|
-
var activeCellButton
|
180
|
-
if (
|
179
|
+
var listContainer;
|
180
|
+
var activeCellButton;
|
181
|
+
if (spreadsheetBodyRef !== null && spreadsheetBodyRef !== void 0 && spreadsheetBodyRef.current) {
|
182
|
+
var _listContainer;
|
183
|
+
listContainer = spreadsheetBodyRef === null || spreadsheetBodyRef === void 0 ? void 0 : spreadsheetBodyRef.current;
|
184
|
+
activeCellButton = (_listContainer = listContainer) === null || _listContainer === void 0 ? void 0 : _listContainer.querySelector(".".concat(blockClass, "__active-cell--highlight"));
|
185
|
+
}
|
186
|
+
if (activeCellButton && (defaultColumn === null || defaultColumn === void 0 ? void 0 : defaultColumn.rowHeight) !== previousState.rowHeight) {
|
181
187
|
activeCellButton.style.height = "".concat(defaultColumn === null || defaultColumn === void 0 ? void 0 : defaultColumn.rowHeight, "px");
|
182
188
|
if (activeCellCoordinates) {
|
183
|
-
var activeTargetElement = ref.current.querySelector("[data-row-index=\"".concat(activeCellCoordinates.row, "\"][data-column-index=\"").concat(activeCellCoordinates.column, "\"]"));
|
184
|
-
var
|
185
|
-
var newActiveCellTopPosition
|
189
|
+
var activeTargetElement = ref === null || ref === void 0 ? void 0 : ref.current.querySelector("[data-row-index=\"".concat(activeCellCoordinates.row, "\"][data-column-index=\"").concat(activeCellCoordinates.column, "\"]"));
|
190
|
+
var _listContainer2 = ref === null || ref === void 0 ? void 0 : ref.current.querySelector(".".concat(blockClass, "__list--container"));
|
191
|
+
var newActiveCellTopPosition;
|
192
|
+
if (activeTargetElement && _listContainer2) {
|
193
|
+
newActiveCellTopPosition = (activeTargetElement === null || activeTargetElement === void 0 ? void 0 : activeTargetElement.getBoundingClientRect().top) - _listContainer2.getBoundingClientRect().top;
|
194
|
+
}
|
186
195
|
activeCellButton.style.top = layout.px(newActiveCellTopPosition);
|
187
196
|
removeCellSelections.removeCellSelections({
|
197
|
+
matcher: undefined,
|
188
198
|
spreadsheetRef: ref
|
189
199
|
});
|
190
|
-
selectionAreas.map(function (area) {
|
200
|
+
selectionAreas === null || selectionAreas === void 0 || selectionAreas.map(function (area) {
|
191
201
|
if (!area.areaCreated && area.point1 && area.point2 && area.matcher) {
|
192
202
|
return createCellSelectionArea.createCellSelectionArea({
|
193
203
|
ref: ref,
|
@@ -204,22 +214,18 @@ var DataSpreadsheetBody = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
204
214
|
}
|
205
215
|
}
|
206
216
|
}, [defaultColumn, ref, activeCellCoordinates, previousState === null || previousState === void 0 ? void 0 : previousState.rowHeight, selectionAreas, setActiveCellInsideSelectionArea, setSelectionAreas, visibleColumns]);
|
207
|
-
//selectionAreas will be set when ever a selection area is made.
|
208
|
-
React.useEffect(function () {
|
209
|
-
removeDuplicateSelections();
|
210
|
-
}, [selectionAreas, removeDuplicateSelections]);
|
211
217
|
|
212
218
|
//this method will check for any duplicate selection area and remove.
|
213
219
|
//same selections are those have the same height, width, top, left styles. These inline styles are being set in createCellSelection util.
|
214
220
|
var removeDuplicateSelections = React.useCallback(function () {
|
215
221
|
var uniqueAttrArray = [],
|
216
222
|
removedSelectionAreaMatcherArr = [];
|
217
|
-
ref.current.querySelectorAll(".".concat(blockClass, "__selection-area--element")).forEach(function (selectorEl) {
|
218
|
-
var
|
219
|
-
top =
|
220
|
-
left =
|
221
|
-
height =
|
222
|
-
width =
|
223
|
+
ref === null || ref === void 0 || ref.current.querySelectorAll(".".concat(blockClass, "__selection-area--element")).forEach(function (selectorEl) {
|
224
|
+
var _style = selectorEl.style,
|
225
|
+
top = _style.top,
|
226
|
+
left = _style.left,
|
227
|
+
height = _style.height,
|
228
|
+
width = _style.width;
|
223
229
|
var uniqueAttrStr = "".concat(top).concat(left).concat(height).concat(width); // eg: 20px30px70px90px
|
224
230
|
if (uniqueAttrArray.indexOf(uniqueAttrStr) == -1) {
|
225
231
|
uniqueAttrArray.push(uniqueAttrStr);
|
@@ -231,13 +237,13 @@ var DataSpreadsheetBody = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
231
237
|
|
232
238
|
//clean the duplicate selectionAreaData and selectionArea
|
233
239
|
if (removedSelectionAreaMatcherArr.length) {
|
234
|
-
setSelectionAreas(function (prev) {
|
240
|
+
setSelectionAreas === null || setSelectionAreas === void 0 || setSelectionAreas(function (prev) {
|
235
241
|
var prevValues = deepCloneObject.deepCloneObject(prev);
|
236
242
|
return prevValues.filter(function (item) {
|
237
243
|
return !removedSelectionAreaMatcherArr.includes(item.matcher);
|
238
244
|
});
|
239
245
|
});
|
240
|
-
setSelectionAreaData(function (prev) {
|
246
|
+
setSelectionAreaData === null || setSelectionAreaData === void 0 || setSelectionAreaData(function (prev) {
|
241
247
|
var prevValues = deepCloneObject.deepCloneObject(prev);
|
242
248
|
return prevValues.filter(function (item) {
|
243
249
|
return !removedSelectionAreaMatcherArr.includes(item.selectionId);
|
@@ -246,6 +252,11 @@ var DataSpreadsheetBody = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
246
252
|
}
|
247
253
|
}, [ref, setSelectionAreas, setSelectionAreaData]);
|
248
254
|
|
255
|
+
//selectionAreas will be set when ever a selection area is made.
|
256
|
+
React.useEffect(function () {
|
257
|
+
removeDuplicateSelections();
|
258
|
+
}, [selectionAreas, removeDuplicateSelections]);
|
259
|
+
|
249
260
|
// onClick fn for each cell in the data spreadsheet body,
|
250
261
|
// adds the active cell highlight
|
251
262
|
|
@@ -255,14 +266,14 @@ var DataSpreadsheetBody = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
255
266
|
};
|
256
267
|
}, [currentMatcher, activeCellCoordinates, selectionAreas, setActiveCellCoordinates, setSelectionAreas, setContainerHasFocus, setClickAndHoldActive, setCurrentMatcher, ref, setSelectionAreaData, setActiveCellInsideSelectionArea, activeCellRef]);
|
257
268
|
var handleBodyScroll = function handleBodyScroll() {
|
258
|
-
var headerRowElement = ref.current.querySelector("\n .".concat(blockClass, "__header--container .").concat(blockClass, "__tr"));
|
259
|
-
headerRowElement.scrollLeft = contentScrollRef.current.scrollLeft;
|
269
|
+
var headerRowElement = ref.current.querySelector("\n .".concat(blockClass, "__header--container .").concat(blockClass, "__tr")) || new HTMLDivElement();
|
270
|
+
headerRowElement.scrollLeft = contentScrollRef === null || contentScrollRef === void 0 ? void 0 : contentScrollRef.current.scrollLeft;
|
260
271
|
};
|
261
272
|
React.useEffect(function () {
|
262
|
-
contentScrollRef.current.addEventListener('scroll', function (
|
273
|
+
contentScrollRef.current.addEventListener('scroll', function () {
|
263
274
|
return handleBodyScroll();
|
264
275
|
});
|
265
|
-
var contentScrollElementRef = contentScrollRef.current;
|
276
|
+
var contentScrollElementRef = contentScrollRef.current || new HTMLElement();
|
266
277
|
return function () {
|
267
278
|
contentScrollElementRef.removeEventListener('scroll', handleBodyScroll);
|
268
279
|
};
|
@@ -287,12 +298,12 @@ var DataSpreadsheetBody = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
287
298
|
_rollupPluginBabelHelpers.toConsumableArray(Array(defaultEmptyRowCount)).map(function () {
|
288
299
|
var _headerGroups$;
|
289
300
|
var emptyCell = {};
|
290
|
-
(_headerGroups$ = headerGroups[0]) === null || _headerGroups$ === void 0 || _headerGroups$.headers.map(function (header) {
|
301
|
+
headerGroups === null || headerGroups === void 0 || (_headerGroups$ = headerGroups[0]) === null || _headerGroups$ === void 0 || _headerGroups$.headers.map(function (header) {
|
291
302
|
emptyCell[header.id] = null;
|
292
303
|
});
|
293
304
|
emptyRowData.push(emptyCell);
|
294
305
|
});
|
295
|
-
onDataUpdate(emptyRowData);
|
306
|
+
onDataUpdate === null || onDataUpdate === void 0 || onDataUpdate(emptyRowData);
|
296
307
|
};
|
297
308
|
buildEmptyRows();
|
298
309
|
}
|
@@ -305,12 +316,15 @@ var DataSpreadsheetBody = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
305
316
|
var RenderRow = React.useCallback(function (_ref3) {
|
306
317
|
var index = _ref3.index,
|
307
318
|
style = _ref3.style;
|
308
|
-
var row = rows[index];
|
319
|
+
var row = rows === null || rows === void 0 ? void 0 : rows[index];
|
309
320
|
if (rows && rows.length) {
|
310
|
-
prepareRow(row);
|
311
|
-
|
321
|
+
prepareRow === null || prepareRow === void 0 || prepareRow(row);
|
322
|
+
var rowProps = propsHelper.prepareProps(row.getRowProps({
|
312
323
|
style: style
|
313
|
-
}),
|
324
|
+
}), 'key');
|
325
|
+
return /*#__PURE__*/React__default["default"].createElement("div", _rollupPluginBabelHelpers["extends"]({
|
326
|
+
key: _rollupPluginBabelHelpers.objectSpread2({}, row.getRowProps().key)
|
327
|
+
}, rowProps, {
|
314
328
|
className: cx__default["default"]("".concat(blockClass, "__tr")),
|
315
329
|
"data-row-index": index,
|
316
330
|
"aria-rowindex": index + 1,
|
@@ -331,10 +345,11 @@ var DataSpreadsheetBody = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
331
345
|
}
|
332
346
|
}, index + 1)), row.cells.map(function (cell, index) {
|
333
347
|
var _cell$column;
|
348
|
+
var cellProps = propsHelper.prepareProps(cell.getCellProps(), 'key');
|
334
349
|
return /*#__PURE__*/React__default["default"].createElement("div", _rollupPluginBabelHelpers["extends"]({
|
335
350
|
key: "cell_".concat(index),
|
336
351
|
"aria-colindex": index + 1
|
337
|
-
},
|
352
|
+
}, cellProps, {
|
338
353
|
role: "gridcell",
|
339
354
|
style: _rollupPluginBabelHelpers.objectSpread2(_rollupPluginBabelHelpers.objectSpread2({}, cell.getCellProps().style), {}, {
|
340
355
|
display: 'grid',
|
@@ -358,12 +373,14 @@ var DataSpreadsheetBody = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
358
373
|
return /*#__PURE__*/React__default["default"].createElement("div", _rollupPluginBabelHelpers["extends"]({
|
359
374
|
ref: spreadsheetBodyRef,
|
360
375
|
className: cx__default["default"]("".concat(blockClass, "__body--container"))
|
361
|
-
}, getTableBodyProps()), /*#__PURE__*/React__default["default"].createElement(reactWindow.FixedSizeList, {
|
376
|
+
}, getTableBodyProps === null || getTableBodyProps === void 0 ? void 0 : getTableBodyProps()), /*#__PURE__*/React__default["default"].createElement(reactWindow.FixedSizeList, {
|
362
377
|
className: cx__default["default"]("".concat(blockClass, "__list--container"), "".concat(blockClass, "__list--container--").concat(id)),
|
363
378
|
height: 400,
|
364
|
-
itemCount: rows.length || defaultEmptyRowCount,
|
379
|
+
itemCount: (rows === null || rows === void 0 ? void 0 : rows.length) || defaultEmptyRowCount,
|
365
380
|
itemSize: defaultColumn === null || defaultColumn === void 0 ? void 0 : defaultColumn.rowHeight,
|
366
381
|
width: getSpreadsheetWidth.getSpreadsheetWidth({
|
382
|
+
headerGroup: undefined,
|
383
|
+
type: undefined,
|
367
384
|
scrollBarSizeValue: scrollBarSize,
|
368
385
|
totalVisibleColumns: totalVisibleColumns,
|
369
386
|
defaultColumn: defaultColumn,
|
@@ -377,6 +394,7 @@ DataSpreadsheetBody.propTypes = {
|
|
377
394
|
/**
|
378
395
|
* Object containing the active cell coordinates
|
379
396
|
*/
|
397
|
+
/**@ts-ignore */
|
380
398
|
activeCellCoordinates: index["default"].shape({
|
381
399
|
row: index["default"].oneOfType([index["default"].string, index["default"].number]),
|
382
400
|
column: index["default"].oneOfType([index["default"].string, index["default"].number])
|
@@ -384,6 +402,7 @@ DataSpreadsheetBody.propTypes = {
|
|
384
402
|
/**
|
385
403
|
*This is the ref of the button input, which is the active cell element
|
386
404
|
*/
|
405
|
+
/**@ts-ignore */
|
387
406
|
activeCellRef: index["default"].object,
|
388
407
|
/**
|
389
408
|
* Is the user clicking and holding in the data spreadsheet body
|
@@ -400,6 +419,7 @@ DataSpreadsheetBody.propTypes = {
|
|
400
419
|
/**
|
401
420
|
* Default spreadsheet sizing values
|
402
421
|
*/
|
422
|
+
/**@ts-ignore */
|
403
423
|
defaultColumn: index["default"].shape({
|
404
424
|
rowHeight: index["default"].number,
|
405
425
|
rowHeaderWidth: index["default"].number,
|
@@ -501,6 +521,7 @@ DataSpreadsheetBody.propTypes = {
|
|
501
521
|
/**
|
502
522
|
* Prop from react-table used to reorder columns
|
503
523
|
*/
|
524
|
+
/**@ts-ignore */
|
504
525
|
visibleColumns: index["default"].array
|
505
526
|
};
|
506
527
|
|
@@ -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 {};
|