@carbon/ibm-products 2.38.0 → 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.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 +227 -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/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 +9 -5
- 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 +5 -1
- package/es/components/Checklist/ChecklistChart.js +9 -4
- package/es/components/Checklist/ChecklistIcon.d.ts +5 -1
- package/es/components/Checklist/ChecklistIcon.js +9 -4
- package/es/components/CoachmarkButton/CoachmarkButton.d.ts +19 -2
- package/es/components/CoachmarkOverlayElements/CoachmarkOverlayElements.d.ts +46 -2
- package/es/components/CoachmarkOverlayElements/CoachmarkOverlayElements.js +5 -4
- 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 +46 -31
- package/es/components/DataSpreadsheet/DataSpreadsheetHeader.d.ts +89 -2
- package/es/components/DataSpreadsheet/DataSpreadsheetHeader.js +34 -25
- package/es/components/DataSpreadsheet/types/index.d.ts +30 -0
- 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/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/index.d.ts +1 -0
- package/es/global/js/package-settings.d.ts +1 -0
- package/es/global/js/package-settings.js +1 -0
- package/es/index.js +1 -0
- package/es/settings.d.ts +1 -0
- 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 +9 -5
- 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 +5 -1
- package/lib/components/Checklist/ChecklistChart.js +14 -9
- package/lib/components/Checklist/ChecklistIcon.d.ts +5 -1
- package/lib/components/Checklist/ChecklistIcon.js +9 -4
- package/lib/components/CoachmarkButton/CoachmarkButton.d.ts +19 -2
- package/lib/components/CoachmarkOverlayElements/CoachmarkOverlayElements.d.ts +46 -2
- package/lib/components/CoachmarkOverlayElements/CoachmarkOverlayElements.js +5 -4
- 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 +46 -31
- package/lib/components/DataSpreadsheet/DataSpreadsheetHeader.d.ts +89 -2
- package/lib/components/DataSpreadsheet/DataSpreadsheetHeader.js +34 -25
- package/lib/components/DataSpreadsheet/types/index.d.ts +30 -0
- 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/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/index.d.ts +1 -0
- package/lib/global/js/package-settings.d.ts +1 -0
- package/lib/global/js/package-settings.js +1 -0
- package/lib/index.js +5 -0
- package/lib/settings.d.ts +1 -0
- package/package.json +3 -3
- 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-with-carbon.scss +1 -0
- package/scss/components/_index.scss +1 -0
- package/telemetry.yml +23 -16
@@ -19,11 +19,9 @@ import { SteppedAnimatedMedia } from '../SteppedAnimatedMedia/SteppedAnimatedMed
|
|
19
19
|
import { Carousel } from '../Carousel/Carousel.js';
|
20
20
|
|
21
21
|
var _excluded = ["className", "children", "isVisible", "media", "nextButtonText", "previousButtonLabel", "closeButtonLabel"];
|
22
|
-
|
23
22
|
// The block part of our conventional BEM class names (blockClass__E--M).
|
24
23
|
var blockClass = "".concat(pkg.prefix, "--coachmark-overlay-elements");
|
25
24
|
var componentName = 'CoachmarkOverlayElements';
|
26
|
-
|
27
25
|
// NOTE: the component SCSS is not imported here: it is rolled up separately.
|
28
26
|
|
29
27
|
// Default values can be included here and then assigned to the prop params,
|
@@ -136,8 +134,9 @@ var CoachmarkOverlayElements = /*#__PURE__*/React__default.forwardRef(function (
|
|
136
134
|
title: previousButtonLabel,
|
137
135
|
disabled: scrollPosition === 0,
|
138
136
|
onClick: function onClick() {
|
137
|
+
var _scrollRef$current, _scrollRef$current$sc;
|
139
138
|
var targetStep = clamp(currentProgStep - 1, progStepFloor, progStepCeil);
|
140
|
-
scrollRef.current.scrollToView(targetStep);
|
139
|
+
scrollRef === null || scrollRef === void 0 || (_scrollRef$current = scrollRef.current) === null || _scrollRef$current === void 0 || (_scrollRef$current$sc = _scrollRef$current.scrollToView) === null || _scrollRef$current$sc === void 0 || _scrollRef$current$sc.call(_scrollRef$current, targetStep);
|
141
140
|
setCurrentProgStep(targetStep);
|
142
141
|
}
|
143
142
|
}, previousButtonLabel), currentProgStep < progStepCeil ? /*#__PURE__*/React__default.createElement(Button, {
|
@@ -146,8 +145,9 @@ var CoachmarkOverlayElements = /*#__PURE__*/React__default.forwardRef(function (
|
|
146
145
|
title: nextButtonText,
|
147
146
|
disabled: scrollPosition === 1,
|
148
147
|
onClick: function onClick() {
|
148
|
+
var _scrollRef$current2, _scrollRef$current2$s;
|
149
149
|
var targetStep = clamp(currentProgStep + 1, progStepFloor, progStepCeil);
|
150
|
-
scrollRef.current.scrollToView(targetStep);
|
150
|
+
scrollRef === null || scrollRef === void 0 || (_scrollRef$current2 = scrollRef.current) === null || _scrollRef$current2 === void 0 || (_scrollRef$current2$s = _scrollRef$current2.scrollToView) === null || _scrollRef$current2$s === void 0 || _scrollRef$current2$s.call(_scrollRef$current2, targetStep);
|
151
151
|
setCurrentProgStep(targetStep);
|
152
152
|
}
|
153
153
|
}, nextButtonText) : closeButtonLabel && /*#__PURE__*/React__default.createElement(Button, _extends({
|
@@ -192,6 +192,7 @@ CoachmarkOverlayElements.propTypes = {
|
|
192
192
|
* If a single media element is required, use `{render}`.
|
193
193
|
* If a stepped animation is required, use `{filePaths}`.
|
194
194
|
*/
|
195
|
+
/**@ts-ignore*/
|
195
196
|
media: PropTypes.oneOfType([PropTypes.shape({
|
196
197
|
render: PropTypes.func
|
197
198
|
}), PropTypes.shape({
|
@@ -1,23 +1,61 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
1
|
+
/**
|
2
|
+
* Copyright IBM Corp. 2021, 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 { PropsWithChildren, ReactNode } from 'react';
|
8
|
+
import PropTypes from 'prop-types';
|
9
|
+
import '../../global/js/utils/props-helper';
|
10
|
+
interface Step {
|
11
|
+
introStep?: boolean;
|
12
|
+
secondaryLabel?: string;
|
13
|
+
shouldIncludeStep?: boolean;
|
14
|
+
title?: ReactNode;
|
15
|
+
}
|
16
|
+
interface CreateInfluencerProps {
|
17
|
+
/**
|
18
|
+
* Provide an optional class to be applied to the containing node.
|
19
|
+
*/
|
20
|
+
className?: string;
|
21
|
+
/**
|
22
|
+
* Provide the current step number.
|
23
|
+
*/
|
24
|
+
currentStep: number;
|
25
|
+
/**
|
26
|
+
* Provide the Set Data.
|
27
|
+
*/
|
28
|
+
stepData: Step[];
|
29
|
+
/**
|
30
|
+
* Title.
|
31
|
+
*/
|
32
|
+
title?: string | undefined;
|
33
|
+
}
|
34
|
+
export declare const CreateInfluencer: {
|
35
|
+
({ className, currentStep, stepData, title, }: PropsWithChildren<CreateInfluencerProps>): import("react/jsx-runtime").JSX.Element;
|
36
|
+
displayName: string;
|
37
|
+
propTypes: {
|
38
|
+
/**
|
39
|
+
* Provide an optional class to be applied to the containing node.
|
40
|
+
*/
|
41
|
+
className: PropTypes.Requireable<string>;
|
42
|
+
/**
|
43
|
+
* Used to mark the current step on the ProgressIndicator component
|
44
|
+
*/
|
45
|
+
currentStep: PropTypes.Validator<number>;
|
46
|
+
/**
|
47
|
+
* The step data that renders the progress items
|
48
|
+
*/
|
49
|
+
stepData: PropTypes.Requireable<(PropTypes.InferProps<{
|
13
50
|
introStep: PropTypes.Requireable<boolean>;
|
14
51
|
secondaryLabel: PropTypes.Requireable<string>;
|
15
52
|
shouldIncludeStep: PropTypes.Requireable<boolean>;
|
16
53
|
title: PropTypes.Requireable<PropTypes.ReactNodeLike>;
|
17
54
|
}> | null | undefined)[]>;
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
55
|
+
/**
|
56
|
+
* The main title of the full page, displayed in the influencer area.
|
57
|
+
*/
|
58
|
+
title: PropTypes.Requireable<string>;
|
59
|
+
};
|
60
|
+
};
|
23
61
|
export {};
|
@@ -1,5 +1,70 @@
|
|
1
1
|
/**
|
2
|
-
*
|
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.
|
3
6
|
*/
|
4
|
-
export let DataSpreadsheet: React.ForwardRefExoticComponent<React.RefAttributes<any>>;
|
5
7
|
import React from 'react';
|
8
|
+
import { Column, Size, Theme } from './types';
|
9
|
+
interface DataSpreadsheetProps {
|
10
|
+
/**
|
11
|
+
* Specifies the cell height
|
12
|
+
*/
|
13
|
+
cellSize?: Size;
|
14
|
+
/**
|
15
|
+
* Provide an optional class to be applied to the containing node.
|
16
|
+
*/
|
17
|
+
className?: string;
|
18
|
+
/**
|
19
|
+
* The data that will build the column headers
|
20
|
+
*/
|
21
|
+
columns?: readonly Column[];
|
22
|
+
/**
|
23
|
+
* The spreadsheet data that will be rendered in the body of the spreadsheet component
|
24
|
+
*/
|
25
|
+
data?: readonly object[];
|
26
|
+
/**
|
27
|
+
* Sets the number of empty rows to be created when there is no data provided
|
28
|
+
*/
|
29
|
+
defaultEmptyRowCount?: number;
|
30
|
+
/**
|
31
|
+
* The spreadsheet id
|
32
|
+
*/
|
33
|
+
id?: number | string;
|
34
|
+
/**
|
35
|
+
* The event handler that is called when the active cell changes
|
36
|
+
*/
|
37
|
+
onActiveCellChange?: () => void;
|
38
|
+
/**
|
39
|
+
* The setter fn for the data prop
|
40
|
+
*/
|
41
|
+
onDataUpdate?: ({ ...args }: {
|
42
|
+
[x: string]: any;
|
43
|
+
}) => void;
|
44
|
+
/**
|
45
|
+
* The event handler that is called when the selection area values change
|
46
|
+
*/
|
47
|
+
onSelectionAreaChange?: () => void;
|
48
|
+
/**
|
49
|
+
* The aria label applied to the Select all button
|
50
|
+
*/
|
51
|
+
selectAllAriaLabel: string;
|
52
|
+
/**
|
53
|
+
* The aria label applied to the Data spreadsheet component
|
54
|
+
*/
|
55
|
+
spreadsheetAriaLabel: string;
|
56
|
+
/**
|
57
|
+
* The theme the DataSpreadsheet should use (only used to render active cell/selection area colors on dark theme)
|
58
|
+
*/
|
59
|
+
theme?: Theme;
|
60
|
+
/**
|
61
|
+
* The total number of columns to be initially visible, additional columns will be rendered and
|
62
|
+
* visible via horizontal scrollbar
|
63
|
+
*/
|
64
|
+
totalVisibleColumns?: number;
|
65
|
+
}
|
66
|
+
/**
|
67
|
+
* DataSpreadsheet: used to organize and display large amounts of structured data, separated by columns and rows in a grid-like format.
|
68
|
+
*/
|
69
|
+
export declare let DataSpreadsheet: React.ForwardRefExoticComponent<DataSpreadsheetProps & React.RefAttributes<HTMLDivElement>>;
|
70
|
+
export {};
|
@@ -33,14 +33,12 @@ import { useMoveActiveCell } from './hooks/useMoveActiveCell.js';
|
|
33
33
|
import { useSpreadsheetEdit } from './hooks/useSpreadsheetEdit.js';
|
34
34
|
|
35
35
|
var _excluded = ["cellSize", "className", "columns", "data", "defaultEmptyRowCount", "onDataUpdate", "id", "onActiveCellChange", "onSelectionAreaChange", "selectAllAriaLabel", "spreadsheetAriaLabel", "theme", "totalVisibleColumns"];
|
36
|
-
|
37
36
|
// The block part of our conventional BEM class names (blockClass__E--M).
|
38
37
|
var blockClass = "".concat(pkg.prefix, "--data-spreadsheet");
|
39
38
|
var componentName = 'DataSpreadsheet';
|
40
39
|
|
41
40
|
// Default values for props
|
42
41
|
var defaults = {
|
43
|
-
cellSize: 'sm',
|
44
42
|
columns: Object.freeze([]),
|
45
43
|
data: Object.freeze([]),
|
46
44
|
defaultEmptyRowCount: 16,
|
@@ -49,13 +47,12 @@ var defaults = {
|
|
49
47
|
onSelectionAreaChange: Object.freeze(function () {}),
|
50
48
|
theme: 'light'
|
51
49
|
};
|
52
|
-
|
53
50
|
/**
|
54
51
|
* DataSpreadsheet: used to organize and display large amounts of structured data, separated by columns and rows in a grid-like format.
|
55
52
|
*/
|
56
53
|
var DataSpreadsheet = /*#__PURE__*/React__default.forwardRef(function (_ref, ref) {
|
57
54
|
var _ref$cellSize = _ref.cellSize,
|
58
|
-
cellSize = _ref$cellSize === void 0 ?
|
55
|
+
cellSize = _ref$cellSize === void 0 ? 'sm' : _ref$cellSize,
|
59
56
|
className = _ref.className,
|
60
57
|
_ref$columns = _ref.columns,
|
61
58
|
columns = _ref$columns === void 0 ? defaults.columns : _ref$columns,
|
@@ -75,7 +72,7 @@ var DataSpreadsheet = /*#__PURE__*/React__default.forwardRef(function (_ref, ref
|
|
75
72
|
theme = _ref.theme,
|
76
73
|
totalVisibleColumns = _ref.totalVisibleColumns,
|
77
74
|
rest = _objectWithoutProperties(_ref, _excluded);
|
78
|
-
var multiKeyTrackingRef = useRef();
|
75
|
+
var multiKeyTrackingRef = useRef(null);
|
79
76
|
var localRef = useRef();
|
80
77
|
var spreadsheetRef = ref || localRef;
|
81
78
|
var focusedElement = useActiveElement();
|
@@ -115,7 +112,7 @@ var DataSpreadsheet = /*#__PURE__*/React__default.forwardRef(function (_ref, ref
|
|
115
112
|
_useState18 = _slicedToArray(_useState17, 2),
|
116
113
|
headerCellHoldActive = _useState18[0],
|
117
114
|
setHeaderCellHoldActive = _useState18[1];
|
118
|
-
var _useState19 = useState(
|
115
|
+
var _useState19 = useState(false),
|
119
116
|
_useState20 = _slicedToArray(_useState19, 2),
|
120
117
|
isActiveHeaderCellChanged = _useState20[0],
|
121
118
|
setIsActiveHeaderCellChanged = _useState20[1];
|
@@ -126,10 +123,10 @@ var DataSpreadsheet = /*#__PURE__*/React__default.forwardRef(function (_ref, ref
|
|
126
123
|
var previousState = usePreviousValue({
|
127
124
|
activeCellCoordinates: activeCellCoordinates,
|
128
125
|
isEditing: isEditing
|
129
|
-
});
|
126
|
+
}) || {};
|
130
127
|
var cellSizeValue = getCellSize(cellSize);
|
131
128
|
var cellEditorRef = useRef();
|
132
|
-
var _useState23 = useState(),
|
129
|
+
var _useState23 = useState(null),
|
133
130
|
_useState24 = _slicedToArray(_useState23, 2),
|
134
131
|
activeCellContent = _useState24[0],
|
135
132
|
setActiveCellContent = _useState24[1];
|
@@ -180,13 +177,18 @@ var DataSpreadsheet = /*#__PURE__*/React__default.forwardRef(function (_ref, ref
|
|
180
177
|
|
181
178
|
// Removes the active cell element
|
182
179
|
var removeActiveCell = useCallback(function () {
|
183
|
-
var
|
184
|
-
activeCellHighlight.
|
180
|
+
var _current;
|
181
|
+
var activeCellHighlight = spreadsheetRef === null || spreadsheetRef === void 0 || (_current = spreadsheetRef.current) === null || _current === void 0 ? void 0 : _current.querySelector(".".concat(blockClass, "__active-cell--highlight"));
|
182
|
+
if (activeCellHighlight) {
|
183
|
+
activeCellHighlight.style.display = 'none';
|
184
|
+
}
|
185
185
|
}, [spreadsheetRef]);
|
186
186
|
var removeCellEditor = useCallback(function () {
|
187
187
|
setCellEditorValue('');
|
188
188
|
setIsEditing(false);
|
189
|
-
cellEditorRef.current
|
189
|
+
if (cellEditorRef !== null && cellEditorRef !== void 0 && cellEditorRef.current) {
|
190
|
+
cellEditorRef.current.style.display = 'none';
|
191
|
+
}
|
190
192
|
}, []);
|
191
193
|
|
192
194
|
// Remove cell editor if the active cell coordinates change and save with new cell data, this will
|
@@ -196,8 +198,10 @@ var DataSpreadsheet = /*#__PURE__*/React__default.forwardRef(function (_ref, ref
|
|
196
198
|
if (((prevCoords === null || prevCoords === void 0 ? void 0 : prevCoords.row) !== (activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.row) || (prevCoords === null || prevCoords === void 0 ? void 0 : prevCoords.column) !== (activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.column)) && isEditing) {
|
197
199
|
var cellProps = rows[prevCoords === null || prevCoords === void 0 ? void 0 : prevCoords.row].cells[prevCoords === null || prevCoords === void 0 ? void 0 : prevCoords.column];
|
198
200
|
removeCellEditor();
|
199
|
-
updateData(prevCoords === null || prevCoords === void 0 ? void 0 : prevCoords.row, cellProps.column.id);
|
200
|
-
cellEditorRulerRef.current
|
201
|
+
updateData(prevCoords === null || prevCoords === void 0 ? void 0 : prevCoords.row, cellProps.column.id, undefined);
|
202
|
+
if (cellEditorRulerRef !== null && cellEditorRulerRef !== void 0 && cellEditorRulerRef.current) {
|
203
|
+
cellEditorRulerRef.current.textContent = '';
|
204
|
+
}
|
201
205
|
}
|
202
206
|
if ((prevCoords === null || prevCoords === void 0 ? void 0 : prevCoords.row) !== (activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.row) || (prevCoords === null || prevCoords === void 0 ? void 0 : prevCoords.column) !== (activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.column)) {
|
203
207
|
if (activeCellCoordinates && (activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.row) !== 'header' && (activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.column) !== 'header') {
|
@@ -242,7 +246,6 @@ var DataSpreadsheet = /*#__PURE__*/React__default.forwardRef(function (_ref, ref
|
|
242
246
|
setActiveCellCoordinates: setActiveCellCoordinates,
|
243
247
|
setSelectionAreas: setSelectionAreas,
|
244
248
|
removeActiveCell: removeActiveCell,
|
245
|
-
removeCellSelections: removeCellSelections,
|
246
249
|
setContainerHasFocus: setContainerHasFocus,
|
247
250
|
removeCellEditor: removeCellEditor
|
248
251
|
});
|
@@ -297,6 +300,7 @@ var DataSpreadsheet = /*#__PURE__*/React__default.forwardRef(function (_ref, ref
|
|
297
300
|
}
|
298
301
|
});
|
299
302
|
removeCellSelections({
|
303
|
+
matcher: undefined,
|
300
304
|
spreadsheetRef: spreadsheetRef
|
301
305
|
});
|
302
306
|
}, [activeCellCoordinates, updateActiveCellCoordinates, spreadsheetRef, columns.length]);
|
@@ -304,7 +308,8 @@ var DataSpreadsheet = /*#__PURE__*/React__default.forwardRef(function (_ref, ref
|
|
304
308
|
return isEditing || key === 'Meta' || key === 'Control';
|
305
309
|
}, [isEditing]);
|
306
310
|
var handleArrowKeyPress = useCallback(function (arrowKey) {
|
307
|
-
|
311
|
+
var _event;
|
312
|
+
(_event = event) === null || _event === void 0 || _event.preventDefault();
|
308
313
|
handleInitialArrowPress();
|
309
314
|
var coordinatesClone = _objectSpread2({}, activeCellCoordinates);
|
310
315
|
var updatedValue;
|
@@ -407,18 +412,28 @@ var DataSpreadsheet = /*#__PURE__*/React__default.forwardRef(function (_ref, ref
|
|
407
412
|
setIsEditing(true);
|
408
413
|
setClickAndHoldActive(false);
|
409
414
|
var activeCellFullData = typeof (activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.column) === 'number' && typeof (activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.row) === 'number' ? rows[activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.row].cells[activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.column] : null;
|
410
|
-
var activeCellValue
|
415
|
+
var activeCellValue;
|
416
|
+
if (activeCellFullData && activeCellCoordinates !== null && activeCellCoordinates !== void 0 && activeCellCoordinates.column) {
|
417
|
+
var _activeCellFullData$r;
|
418
|
+
activeCellValue = activeCellFullData ? (_activeCellFullData$r = activeCellFullData.row.cells) === null || _activeCellFullData$r === void 0 || (_activeCellFullData$r = _activeCellFullData$r[activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.column]) === null || _activeCellFullData$r === void 0 ? void 0 : _activeCellFullData$r.value : null;
|
419
|
+
}
|
411
420
|
setCellEditorValue(activeCellValue || '');
|
412
|
-
cellEditorRulerRef.current
|
413
|
-
|
421
|
+
if (cellEditorRulerRef !== null && cellEditorRulerRef !== void 0 && cellEditorRulerRef.current) {
|
422
|
+
cellEditorRulerRef.current.textContent = activeCellValue;
|
423
|
+
}
|
424
|
+
if (cellEditorRef !== null && cellEditorRef !== void 0 && cellEditorRef.current && activeCellRef !== null && activeCellRef !== void 0 && activeCellRef.current) {
|
425
|
+
var _activeCellRef$curren;
|
426
|
+
cellEditorRef.current.style.width = activeCellRef === null || activeCellRef === void 0 || (_activeCellRef$curren = activeCellRef.current) === null || _activeCellRef$curren === void 0 || (_activeCellRef$curren = _activeCellRef$curren.style) === null || _activeCellRef$curren === void 0 ? void 0 : _activeCellRef$curren.width;
|
427
|
+
}
|
414
428
|
};
|
415
429
|
|
416
430
|
// Sets the initial placement of the cell editor cursor at the end of the text area
|
417
431
|
// this is not done for us by default in Safari
|
418
432
|
useEffect(function () {
|
419
433
|
if (isEditing && !(previousState !== null && previousState !== void 0 && previousState.isEditing)) {
|
420
|
-
|
421
|
-
cellEditorRef.current.
|
434
|
+
var _cellEditorRef$curren, _cellEditorRulerRef$c, _cellEditorRulerRef$c2, _cellEditorRef$curren2;
|
435
|
+
cellEditorRef === null || cellEditorRef === void 0 || (_cellEditorRef$curren = cellEditorRef.current) === null || _cellEditorRef$curren === void 0 || _cellEditorRef$curren.setSelectionRange(Number(cellEditorRulerRef === null || cellEditorRulerRef === void 0 || (_cellEditorRulerRef$c = cellEditorRulerRef.current) === null || _cellEditorRulerRef$c === void 0 || (_cellEditorRulerRef$c = _cellEditorRulerRef$c.textContent) === null || _cellEditorRulerRef$c === void 0 ? void 0 : _cellEditorRulerRef$c.length), Number(cellEditorRulerRef === null || cellEditorRulerRef === void 0 || (_cellEditorRulerRef$c2 = cellEditorRulerRef.current) === null || _cellEditorRulerRef$c2 === void 0 || (_cellEditorRulerRef$c2 = _cellEditorRulerRef$c2.textContent) === null || _cellEditorRulerRef$c2 === void 0 ? void 0 : _cellEditorRulerRef$c2.length));
|
436
|
+
cellEditorRef === null || cellEditorRef === void 0 || (_cellEditorRef$curren2 = cellEditorRef.current) === null || _cellEditorRef$curren2 === void 0 || _cellEditorRef$curren2.focus();
|
422
437
|
}
|
423
438
|
}, [isEditing, previousState === null || previousState === void 0 ? void 0 : previousState.isEditing]);
|
424
439
|
var handleActiveCellClick = function handleActiveCellClick() {
|
@@ -429,7 +444,7 @@ var DataSpreadsheet = /*#__PURE__*/React__default.forwardRef(function (_ref, ref
|
|
429
444
|
}
|
430
445
|
handleRowColumnHeaderClick({
|
431
446
|
isKeyboard: false,
|
432
|
-
index: indexValue
|
447
|
+
index: Number(indexValue)
|
433
448
|
});
|
434
449
|
}
|
435
450
|
return;
|
@@ -446,6 +461,7 @@ var DataSpreadsheet = /*#__PURE__*/React__default.forwardRef(function (_ref, ref
|
|
446
461
|
var tempMatcher = uuidv4();
|
447
462
|
setClickAndHoldActive(true);
|
448
463
|
removeCellSelections({
|
464
|
+
matcher: null,
|
449
465
|
spreadsheetRef: spreadsheetRef
|
450
466
|
});
|
451
467
|
setSelectionAreas([{
|
@@ -476,19 +492,21 @@ var DataSpreadsheet = /*#__PURE__*/React__default.forwardRef(function (_ref, ref
|
|
476
492
|
var handleRowColumnHeaderClick = function handleRowColumnHeaderClick(_ref5) {
|
477
493
|
var isKeyboard = _ref5.isKeyboard,
|
478
494
|
_ref5$index = _ref5.index,
|
479
|
-
index = _ref5$index === void 0 ?
|
495
|
+
index = _ref5$index === void 0 ? -1 : _ref5$index;
|
480
496
|
var handleHeaderCellProps = {
|
481
497
|
activeCellCoordinates: activeCellCoordinates,
|
482
498
|
rows: rows,
|
483
499
|
columns: columns,
|
500
|
+
currentMatcher: currentMatcher,
|
484
501
|
setActiveCellCoordinates: setActiveCellCoordinates,
|
485
502
|
setCurrentMatcher: setCurrentMatcher,
|
486
503
|
setSelectionAreas: setSelectionAreas,
|
487
504
|
spreadsheetRef: spreadsheetRef,
|
505
|
+
index: index,
|
488
506
|
isKeyboard: isKeyboard,
|
489
507
|
setSelectionAreaData: setSelectionAreaData,
|
490
|
-
|
491
|
-
|
508
|
+
isHoldingCommandKey: null,
|
509
|
+
isHoldingShiftKey: null
|
492
510
|
};
|
493
511
|
// Select an entire column
|
494
512
|
if ((activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.row) === 'header' && (activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.column) !== 'header') {
|
@@ -612,7 +630,6 @@ var DataSpreadsheet = /*#__PURE__*/React__default.forwardRef(function (_ref, ref
|
|
612
630
|
setContainerHasFocus: setContainerHasFocus,
|
613
631
|
selectionAreas: selectionAreas,
|
614
632
|
setSelectionAreas: setSelectionAreas,
|
615
|
-
cellSize: cellSize,
|
616
633
|
headerGroups: headerGroups,
|
617
634
|
defaultColumn: defaultColumn,
|
618
635
|
getTableBodyProps: getTableBodyProps,
|
@@ -662,10 +679,12 @@ var DataSpreadsheet = /*#__PURE__*/React__default.forwardRef(function (_ref, ref
|
|
662
679
|
}),
|
663
680
|
onChange: function onChange(event) {
|
664
681
|
setCellEditorValue(event.target.value);
|
665
|
-
cellEditorRulerRef.current
|
682
|
+
if (cellEditorRulerRef !== null && cellEditorRulerRef !== void 0 && cellEditorRulerRef.current) {
|
683
|
+
cellEditorRulerRef.current.textContent = event.target.value;
|
684
|
+
}
|
666
685
|
},
|
667
686
|
ref: cellEditorRef,
|
668
|
-
"aria-labelledby": activeCellCoordinates ? "".concat(blockClass, "__cell--").concat(activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.row, "--").concat(activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.column) :
|
687
|
+
"aria-labelledby": activeCellCoordinates ? "".concat(blockClass, "__cell--").concat(activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.row, "--").concat(activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.column) : '',
|
669
688
|
className: cx("".concat(blockClass, "__cell-editor"), "".concat(blockClass, "--interactive-cell-element"), "".concat(blockClass, "__cell-editor--").concat(cellSize), _defineProperty({}, "".concat(blockClass, "__cell-editor--active"), isEditing))
|
670
689
|
}), /*#__PURE__*/React__default.createElement("pre", {
|
671
690
|
"aria-hidden": true,
|
@@ -696,6 +715,7 @@ DataSpreadsheet.propTypes = {
|
|
696
715
|
/**
|
697
716
|
* The data that will build the column headers
|
698
717
|
*/
|
718
|
+
/**@ts-ignore */
|
699
719
|
columns: PropTypes.arrayOf(PropTypes.shape({
|
700
720
|
Header: PropTypes.string,
|
701
721
|
accessor: PropTypes.oneOfType([PropTypes.string, PropTypes.func]),
|
@@ -704,6 +724,7 @@ DataSpreadsheet.propTypes = {
|
|
704
724
|
/**
|
705
725
|
* The spreadsheet data that will be rendered in the body of the spreadsheet component
|
706
726
|
*/
|
727
|
+
/**@ts-ignore */
|
707
728
|
data: PropTypes.arrayOf(PropTypes.shape),
|
708
729
|
/**
|
709
730
|
* Sets the number of empty rows to be created when there is no data provided
|
@@ -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 {};
|