@carbon/ibm-products 1.14.0 → 1.17.0
Sign up to get free protection for your applications and to get access to all the features.
- package/css/components/Datagrid/styles/datagrid.css +4 -0
- package/css/components/Datagrid/styles/datagrid.css.map +1 -1
- package/css/components/Datagrid/styles/index.css +5 -1
- package/css/components/Datagrid/styles/index.css.map +1 -1
- package/css/components/Datagrid/styles/useNestedRows.css +1 -1
- package/css/index-full-carbon.css +75 -16
- package/css/index-full-carbon.css.map +1 -1
- package/css/index-full-carbon.min.css +6 -3
- package/css/index-full-carbon.min.css.map +1 -1
- package/css/index-without-carbon-released-only.css +13 -7
- package/css/index-without-carbon-released-only.css.map +1 -1
- package/css/index-without-carbon-released-only.min.css +5 -2
- package/css/index-without-carbon-released-only.min.css.map +1 -1
- package/css/index-without-carbon.css +75 -16
- package/css/index-without-carbon.css.map +1 -1
- package/css/index-without-carbon.min.css +6 -3
- package/css/index-without-carbon.min.css.map +1 -1
- package/css/index.css +75 -16
- package/css/index.css.map +1 -1
- package/css/index.min.css +6 -3
- package/css/index.min.css.map +1 -1
- package/es/components/AddSelect/AddSelect.js +34 -23
- package/es/components/AddSelect/AddSelectFilter.js +52 -9
- package/es/components/DataSpreadsheet/DataSpreadsheet.js +186 -129
- package/es/components/DataSpreadsheet/DataSpreadsheetBody.js +67 -15
- package/es/components/DataSpreadsheet/DataSpreadsheetHeader.js +55 -11
- package/es/components/DataSpreadsheet/hooks/index.js +2 -1
- package/es/components/DataSpreadsheet/hooks/useMultipleKeyTracking.js +36 -8
- package/es/components/DataSpreadsheet/hooks/useSpreadsheetEdit.js +113 -0
- package/es/components/DataSpreadsheet/utils/checkSelectedHeaderCell.js +16 -0
- package/es/components/DataSpreadsheet/utils/createCellSelectionArea.js +29 -12
- package/es/components/DataSpreadsheet/utils/generateData.js +17 -9
- package/es/components/DataSpreadsheet/utils/getSelectionAreaPoints.js +18 -0
- package/es/components/DataSpreadsheet/utils/getSpreadsheetWidth.js +30 -0
- package/es/components/DataSpreadsheet/utils/handleActiveCellInSelectionEnter.js +121 -0
- package/es/components/DataSpreadsheet/utils/handleActiveCellInSelectionTab.js +108 -0
- package/es/components/DataSpreadsheet/utils/handleEditSubmit.js +87 -0
- package/es/components/DataSpreadsheet/utils/handleHeaderCellSelection.js +46 -8
- package/es/components/DataSpreadsheet/utils/handleMultipleKeys.js +153 -15
- package/es/components/DataSpreadsheet/utils/selectAllCells.js +53 -0
- package/es/components/Datagrid/Datagrid/Datagrid.js +24 -12
- package/es/components/Datagrid/Datagrid/DatagridHead.js +8 -16
- package/es/components/Datagrid/Datagrid/DatagridHeaderRow.js +10 -10
- package/es/components/Datagrid/Datagrid/DatagridRow.js +12 -2
- package/es/components/Datagrid/Datagrid/index.js +6 -7
- package/es/components/Datagrid/index.js +1 -1
- package/es/components/Datagrid/useNestedRows.js +3 -3
- package/es/components/Datagrid/useRowExpander.js +1 -1
- package/es/components/ExportModal/ExportModal.js +10 -5
- package/es/components/MultiAddSelect/MultiAddSelect.js +150 -3
- package/es/components/PageHeader/PageHeader.js +3 -1
- package/es/components/SidePanel/SidePanel.js +5 -1
- package/es/components/SingleAddSelect/SingleAddSelect.js +90 -4
- package/es/components/TagSet/TagSet.js +13 -6
- package/es/components/Tearsheet/TearsheetShell.js +34 -10
- package/es/components/WebTerminal/WebTerminal.js +36 -11
- package/es/components/WebTerminal/WebTerminalContentWrapper.js +49 -0
- package/es/components/WebTerminal/index.js +2 -1
- package/es/components/index.js +1 -1
- package/es/global/js/package-settings.js +3 -1
- package/lib/components/AddSelect/AddSelect.js +34 -23
- package/lib/components/AddSelect/AddSelectFilter.js +51 -8
- package/lib/components/DataSpreadsheet/DataSpreadsheet.js +190 -128
- package/lib/components/DataSpreadsheet/DataSpreadsheetBody.js +69 -15
- package/lib/components/DataSpreadsheet/DataSpreadsheetHeader.js +58 -12
- package/lib/components/DataSpreadsheet/hooks/index.js +9 -1
- package/lib/components/DataSpreadsheet/hooks/useMultipleKeyTracking.js +36 -8
- package/lib/components/DataSpreadsheet/hooks/useSpreadsheetEdit.js +129 -0
- package/lib/components/DataSpreadsheet/utils/checkSelectedHeaderCell.js +26 -0
- package/lib/components/DataSpreadsheet/utils/createCellSelectionArea.js +31 -13
- package/lib/components/DataSpreadsheet/utils/generateData.js +17 -9
- package/lib/components/DataSpreadsheet/utils/getSelectionAreaPoints.js +27 -0
- package/lib/components/DataSpreadsheet/utils/getSpreadsheetWidth.js +40 -0
- package/lib/components/DataSpreadsheet/utils/handleActiveCellInSelectionEnter.js +127 -0
- package/lib/components/DataSpreadsheet/utils/handleActiveCellInSelectionTab.js +118 -0
- package/lib/components/DataSpreadsheet/utils/handleEditSubmit.js +94 -0
- package/lib/components/DataSpreadsheet/utils/handleHeaderCellSelection.js +48 -8
- package/lib/components/DataSpreadsheet/utils/handleMultipleKeys.js +161 -22
- package/lib/components/DataSpreadsheet/utils/selectAllCells.js +60 -0
- package/lib/components/Datagrid/Datagrid/Datagrid.js +25 -8
- package/lib/components/Datagrid/Datagrid/DatagridHead.js +8 -16
- package/lib/components/Datagrid/Datagrid/DatagridHeaderRow.js +10 -10
- package/lib/components/Datagrid/Datagrid/DatagridRow.js +14 -2
- package/lib/components/Datagrid/Datagrid/index.js +3 -5
- package/lib/components/Datagrid/index.js +2 -2
- package/lib/components/Datagrid/useNestedRows.js +3 -3
- package/lib/components/Datagrid/useRowExpander.js +1 -1
- package/lib/components/ExportModal/ExportModal.js +9 -4
- package/lib/components/MultiAddSelect/MultiAddSelect.js +150 -2
- package/lib/components/PageHeader/PageHeader.js +3 -1
- package/lib/components/SidePanel/SidePanel.js +5 -1
- package/lib/components/SingleAddSelect/SingleAddSelect.js +91 -3
- package/lib/components/TagSet/TagSet.js +13 -6
- package/lib/components/Tearsheet/TearsheetShell.js +36 -10
- package/lib/components/WebTerminal/WebTerminal.js +36 -10
- package/lib/components/WebTerminal/WebTerminalContentWrapper.js +58 -0
- package/lib/components/WebTerminal/index.js +9 -1
- package/lib/components/index.js +6 -0
- package/lib/global/js/package-settings.js +3 -1
- package/package.json +13 -13
- package/scss/components/AboutModal/_about-modal.scss +4 -0
- package/scss/components/AddSelect/_add-select.scss +9 -2
- package/scss/components/DataSpreadsheet/_data-spreadsheet.scss +39 -2
- package/scss/components/Datagrid/styles/datagrid.scss +8 -0
- package/scss/components/Datagrid/styles/useNestedRows.scss +1 -1
- package/scss/components/ExportModal/_export-modal.scss +0 -4
- package/scss/components/SidePanel/_side-panel.scss +22 -3
- package/scss/components/WebTerminal/_storybook-styles.scss +5 -0
- package/scss/components/WebTerminal/_web-terminal.scss +14 -4
@@ -1,6 +1,6 @@
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
2
|
-
import React, { forwardRef } from 'react';
|
3
|
-
|
2
|
+
import React, { forwardRef } from 'react';
|
3
|
+
import PropTypes from 'prop-types';
|
4
4
|
import { AddSelect } from '../AddSelect';
|
5
5
|
import { getDevtoolsProps } from '../../global/js/utils/devtools';
|
6
6
|
import { pkg } from '../../settings';
|
@@ -12,5 +12,152 @@ export var MultiAddSelect = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
12
12
|
}, getDevtoolsProps(componentName)));
|
13
13
|
});
|
14
14
|
MultiAddSelect = pkg.checkComponentEnabled(MultiAddSelect, componentName);
|
15
|
-
MultiAddSelect.propTypes = {
|
15
|
+
MultiAddSelect.propTypes = {
|
16
|
+
/**
|
17
|
+
* optional class name
|
18
|
+
*/
|
19
|
+
className: PropTypes.string,
|
20
|
+
|
21
|
+
/**
|
22
|
+
* placeholder for column input filter
|
23
|
+
*/
|
24
|
+
columnInputPlaceholder: PropTypes.string,
|
25
|
+
|
26
|
+
/**
|
27
|
+
* text description that appears under the title
|
28
|
+
*/
|
29
|
+
description: PropTypes.string,
|
30
|
+
|
31
|
+
/**
|
32
|
+
* options to display in the global filter box. values are generated
|
33
|
+
* from the id which should correlate with a specific property in an
|
34
|
+
* item entry
|
35
|
+
*/
|
36
|
+
globalFilters: PropTypes.arrayOf(PropTypes.shape({
|
37
|
+
id: PropTypes.string,
|
38
|
+
label: PropTypes.string
|
39
|
+
})),
|
40
|
+
globalFiltersIconDescription: PropTypes.string,
|
41
|
+
|
42
|
+
/**
|
43
|
+
* placeholder text for the global filter dropdown
|
44
|
+
*/
|
45
|
+
globalFiltersPlaceholderText: PropTypes.string,
|
46
|
+
|
47
|
+
/**
|
48
|
+
* text for the global filter primary button
|
49
|
+
*/
|
50
|
+
globalFiltersPrimaryButtonText: PropTypes.string,
|
51
|
+
|
52
|
+
/**
|
53
|
+
* text for the global filter secondary button
|
54
|
+
*/
|
55
|
+
globalFiltersSecondaryButtonText: PropTypes.string,
|
56
|
+
|
57
|
+
/**
|
58
|
+
* label for global search input
|
59
|
+
*/
|
60
|
+
globalSearchLabel: PropTypes.string,
|
61
|
+
|
62
|
+
/**
|
63
|
+
* placeholder for global search input
|
64
|
+
*/
|
65
|
+
globalSearchPlaceholder: PropTypes.string,
|
66
|
+
|
67
|
+
/**
|
68
|
+
* title that displays in the sidebar / influencer
|
69
|
+
*/
|
70
|
+
influencerTitle: PropTypes.string,
|
71
|
+
|
72
|
+
/**
|
73
|
+
* object that contains the item data. for more information reference the
|
74
|
+
* "Structuring items" section in the docs tab
|
75
|
+
*/
|
76
|
+
items: PropTypes.shape({
|
77
|
+
modifiers: PropTypes.shape({
|
78
|
+
label: PropTypes.string,
|
79
|
+
options: PropTypes.array
|
80
|
+
}),
|
81
|
+
sortBy: PropTypes.array,
|
82
|
+
filterBy: PropTypes.array,
|
83
|
+
entries: PropTypes.arrayOf(PropTypes.shape({
|
84
|
+
avatar: PropTypes.shape({
|
85
|
+
alt: PropTypes.string,
|
86
|
+
icon: PropTypes.object,
|
87
|
+
src: PropTypes.string
|
88
|
+
}),
|
89
|
+
children: PropTypes.object,
|
90
|
+
icon: PropTypes.object,
|
91
|
+
id: PropTypes.string.isRequired,
|
92
|
+
subtitle: PropTypes.string,
|
93
|
+
title: PropTypes.string.isRequired,
|
94
|
+
value: PropTypes.string.isRequired
|
95
|
+
}))
|
96
|
+
}),
|
97
|
+
|
98
|
+
/**
|
99
|
+
* label that display above the list of items
|
100
|
+
*/
|
101
|
+
itemsLabel: PropTypes.string,
|
102
|
+
|
103
|
+
/**
|
104
|
+
* text to display when no results are found from the global search
|
105
|
+
*/
|
106
|
+
noResultsDescription: PropTypes.string,
|
107
|
+
|
108
|
+
/**
|
109
|
+
* title to display when no results are found from the global search
|
110
|
+
*/
|
111
|
+
noResultsTitle: PropTypes.string,
|
112
|
+
|
113
|
+
/**
|
114
|
+
* text body that displays in the sidebar when nothing is selected
|
115
|
+
*/
|
116
|
+
noSelectionDescription: PropTypes.string,
|
117
|
+
|
118
|
+
/**
|
119
|
+
* title that displays in the sidebar when nothing is selected
|
120
|
+
*/
|
121
|
+
noSelectionTitle: PropTypes.string,
|
122
|
+
|
123
|
+
/**
|
124
|
+
* function to call when the close button clicked
|
125
|
+
*/
|
126
|
+
onClose: PropTypes.func,
|
127
|
+
|
128
|
+
/**
|
129
|
+
* text for close button
|
130
|
+
*/
|
131
|
+
onCloseButtonText: PropTypes.string,
|
132
|
+
|
133
|
+
/**
|
134
|
+
* function to call when the submit button is clicked. returns a selection
|
135
|
+
*/
|
136
|
+
onSubmit: PropTypes.func,
|
137
|
+
|
138
|
+
/**
|
139
|
+
* text for the submit button
|
140
|
+
*/
|
141
|
+
onSubmitButtonText: PropTypes.string,
|
142
|
+
|
143
|
+
/**
|
144
|
+
* specifies if the component is open or not
|
145
|
+
*/
|
146
|
+
open: PropTypes.bool,
|
147
|
+
|
148
|
+
/**
|
149
|
+
* description for the remove item icon
|
150
|
+
*/
|
151
|
+
removeIconDescription: PropTypes.string,
|
152
|
+
|
153
|
+
/**
|
154
|
+
* text that displays when displaying filtered items
|
155
|
+
*/
|
156
|
+
searchResultsLabel: PropTypes.string,
|
157
|
+
|
158
|
+
/**
|
159
|
+
* header text
|
160
|
+
*/
|
161
|
+
title: PropTypes.string
|
162
|
+
};
|
16
163
|
MultiAddSelect.displayName = componentName;
|
@@ -499,7 +499,8 @@ var TYPES = {
|
|
499
499
|
gray: 'Gray',
|
500
500
|
'cool-gray': 'Cool-Gray',
|
501
501
|
'warm-gray': 'Warm-Gray',
|
502
|
-
'high-contrast': 'High-Contrast'
|
502
|
+
'high-contrast': 'High-Contrast',
|
503
|
+
outline: 'Outline'
|
503
504
|
};
|
504
505
|
var tagTypes = Object.keys(TYPES);
|
505
506
|
export var deprecatedProps = {
|
@@ -513,6 +514,7 @@ export var deprecatedProps = {
|
|
513
514
|
*/
|
514
515
|
hasBackgroundAlways: deprecateProp(PropTypes.bool, 'Property replaced by `withoutBackground`')
|
515
516
|
};
|
517
|
+
PageHeader.tagTypes = tagTypes;
|
516
518
|
PageHeader.propTypes = _objectSpread({
|
517
519
|
/**
|
518
520
|
* Specifies the action bar items which are the final items in the row top of the PageHeader.
|
@@ -272,13 +272,17 @@ export var SidePanel = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
272
272
|
|
273
273
|
var actionToolbarElement = document.querySelector(".".concat(blockClass, "__action-toolbar"));
|
274
274
|
|
275
|
+
var _labelText = document.querySelector(".".concat(blockClass, "__label-text"));
|
276
|
+
|
275
277
|
var _sidePanelSubtitleElementHeight = (_sidePanelSubtitleElement === null || _sidePanelSubtitleElement === void 0 ? void 0 : _sidePanelSubtitleElement.offsetHeight) || 0;
|
276
278
|
|
277
279
|
var sidePanelActionBarElementHeight = (actionToolbarElement === null || actionToolbarElement === void 0 ? void 0 : actionToolbarElement.offsetHeight) || 0;
|
278
280
|
var titleHeight = (_sidePanelTitleElement === null || _sidePanelTitleElement === void 0 ? void 0 : _sidePanelTitleElement.offsetHeight) + 24;
|
281
|
+
var labelHeight = (_labelText === null || _labelText === void 0 ? void 0 : _labelText.offsetHeight) || 0;
|
279
282
|
_sidePanelOuter === null || _sidePanelOuter === void 0 ? void 0 : _sidePanelOuter.style.setProperty("--".concat(blockClass, "--title-text-height"), "".concat(titleHeight, "px"));
|
280
283
|
_sidePanelOuter === null || _sidePanelOuter === void 0 ? void 0 : _sidePanelOuter.style.setProperty("--".concat(blockClass, "--subtitle-container-height"), "".concat(_sidePanelSubtitleElementHeight, "px"));
|
281
284
|
_sidePanelOuter === null || _sidePanelOuter === void 0 ? void 0 : _sidePanelOuter.style.setProperty("--".concat(blockClass, "--action-bar-container-height"), "".concat(sidePanelActionBarElementHeight, "px"));
|
285
|
+
_sidePanelOuter === null || _sidePanelOuter === void 0 ? void 0 : _sidePanelOuter.style.setProperty("--".concat(blockClass, "--label-text-height"), "".concat(labelHeight, "px"));
|
282
286
|
}
|
283
287
|
}, [open, animateTitle, animationComplete, shouldRender, panelHeight, title, size, reducedMotion.matches]); // click outside functionality if `includeOverlay` prop is set
|
284
288
|
|
@@ -492,7 +496,7 @@ export var SidePanel = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
492
496
|
className: "".concat(blockClass, "__visually-hidden")
|
493
497
|
}, "Focus sentinel"), !animateTitle && renderHeader(), /*#__PURE__*/React.createElement("div", {
|
494
498
|
ref: sidePanelInnerRef,
|
495
|
-
className: cx("".concat(blockClass, "__inner-content"), (_cx4 = {}, _defineProperty(_cx4, "".concat(blockClass, "__static-inner-content"), !animateTitle), _defineProperty(_cx4, "".concat(blockClass, "__inner-content-with-actions"), actions && actions.length), _cx4))
|
499
|
+
className: cx("".concat(blockClass, "__inner-content"), (_cx4 = {}, _defineProperty(_cx4, "".concat(blockClass, "__static-inner-content"), !animateTitle), _defineProperty(_cx4, "".concat(blockClass, "__static-inner-content-no-actions"), !animateTitle && !(actions !== null && actions !== void 0 && actions.length)), _defineProperty(_cx4, "".concat(blockClass, "__inner-content-with-actions"), actions && actions.length), _cx4))
|
496
500
|
}, animateTitle && renderHeader(), /*#__PURE__*/React.createElement("div", {
|
497
501
|
className: "".concat(blockClass, "__body-content")
|
498
502
|
}, children), /*#__PURE__*/React.createElement(ActionSet, {
|
@@ -1,15 +1,101 @@
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
2
|
-
import React, { forwardRef } from 'react';
|
3
|
-
|
2
|
+
import React, { forwardRef } from 'react';
|
3
|
+
import PropTypes from 'prop-types';
|
4
4
|
import { AddSelect } from '../AddSelect';
|
5
5
|
import { getDevtoolsProps } from '../../global/js/utils/devtools';
|
6
6
|
import { pkg } from '../../settings';
|
7
|
+
import { prepareProps } from '../../global/js/utils/props-helper';
|
7
8
|
var componentName = 'SingleAddSelect';
|
8
9
|
export var SingleAddSelect = /*#__PURE__*/forwardRef(function (props, ref) {
|
9
|
-
|
10
|
+
// remove multi add select specific props
|
11
|
+
var validProps = prepareProps(props, ['columnInputPlaceholder', 'globalFilters', 'globalFiltersIconDescription', 'globalFiltersPlaceholderText', 'globalFiltersPrimaryButtonText', 'globalFiltersSecondaryButtonText', 'influencerTitle', 'multi', 'noSelectionDescription', 'noSelectionTitle', 'removeIconDescription']);
|
12
|
+
return /*#__PURE__*/React.createElement(AddSelect, _extends({}, validProps, {
|
10
13
|
ref: ref
|
11
14
|
}, getDevtoolsProps(componentName)));
|
12
15
|
});
|
13
16
|
SingleAddSelect = pkg.checkComponentEnabled(SingleAddSelect, componentName);
|
14
|
-
SingleAddSelect.propTypes = {
|
17
|
+
SingleAddSelect.propTypes = {
|
18
|
+
/**
|
19
|
+
* optional class name
|
20
|
+
*/
|
21
|
+
className: PropTypes.string,
|
22
|
+
|
23
|
+
/**
|
24
|
+
* text description that appears under the title
|
25
|
+
*/
|
26
|
+
description: PropTypes.string,
|
27
|
+
|
28
|
+
/**
|
29
|
+
* label for global search input
|
30
|
+
*/
|
31
|
+
globalSearchLabel: PropTypes.string,
|
32
|
+
|
33
|
+
/**
|
34
|
+
* placeholder for global search input
|
35
|
+
*/
|
36
|
+
globalSearchPlaceholder: PropTypes.string,
|
37
|
+
|
38
|
+
/**
|
39
|
+
* object that contains the item data. for more information reference the
|
40
|
+
* "Structuring items" section in the docs tab
|
41
|
+
*/
|
42
|
+
items: PropTypes.shape({
|
43
|
+
entries: PropTypes.arrayOf(PropTypes.shape({
|
44
|
+
children: PropTypes.object,
|
45
|
+
id: PropTypes.string.isRequired,
|
46
|
+
title: PropTypes.string.isRequired,
|
47
|
+
value: PropTypes.string.isRequired
|
48
|
+
}))
|
49
|
+
}),
|
50
|
+
|
51
|
+
/**
|
52
|
+
* label that display above the list of items
|
53
|
+
*/
|
54
|
+
itemsLabel: PropTypes.string,
|
55
|
+
|
56
|
+
/**
|
57
|
+
* text to display when no results are found from the global search
|
58
|
+
*/
|
59
|
+
noResultsDescription: PropTypes.string,
|
60
|
+
|
61
|
+
/**
|
62
|
+
* title to display when no results are found from the global search
|
63
|
+
*/
|
64
|
+
noResultsTitle: PropTypes.string,
|
65
|
+
|
66
|
+
/**
|
67
|
+
* function to call when the close button clicked
|
68
|
+
*/
|
69
|
+
onClose: PropTypes.func,
|
70
|
+
|
71
|
+
/**
|
72
|
+
* text for close button
|
73
|
+
*/
|
74
|
+
onCloseButtonText: PropTypes.string,
|
75
|
+
|
76
|
+
/**
|
77
|
+
* function to call when the submit button is clicked. returns a selection
|
78
|
+
*/
|
79
|
+
onSubmit: PropTypes.func,
|
80
|
+
|
81
|
+
/**
|
82
|
+
* text for the submit button
|
83
|
+
*/
|
84
|
+
onSubmitButtonText: PropTypes.string,
|
85
|
+
|
86
|
+
/**
|
87
|
+
* specifies if the component is open or not
|
88
|
+
*/
|
89
|
+
open: PropTypes.bool,
|
90
|
+
|
91
|
+
/**
|
92
|
+
* text that displays when displaying filtered items
|
93
|
+
*/
|
94
|
+
searchResultsLabel: PropTypes.string,
|
95
|
+
|
96
|
+
/**
|
97
|
+
* header text
|
98
|
+
*/
|
99
|
+
title: PropTypes.string
|
100
|
+
};
|
15
101
|
SingleAddSelect.displayName = componentName;
|
@@ -97,9 +97,13 @@ export var TagSet = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
97
97
|
};
|
98
98
|
|
99
99
|
useEffect(function () {
|
100
|
-
|
101
|
-
|
102
|
-
|
100
|
+
if (allTagsModalTargetIn) {
|
101
|
+
setAllTagsModalTarget(allTagsModalTargetIn);
|
102
|
+
} else {
|
103
|
+
if (pkg.isFeatureEnabled('default-portal-target-body')) {
|
104
|
+
setAllTagsModalTarget(document.body);
|
105
|
+
}
|
106
|
+
}
|
103
107
|
}, [allTagsModalTargetIn]);
|
104
108
|
useEffect(function () {
|
105
109
|
var newSizingTags = []; // create sizing tags
|
@@ -237,14 +241,16 @@ export var TagSet = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
237
241
|
}, hiddenSizingTags), /*#__PURE__*/React.createElement("div", {
|
238
242
|
className: "".concat(blockClass, "__tag-container"),
|
239
243
|
ref: displayedArea
|
240
|
-
}, displayedTags)), allTagsModalTarget
|
244
|
+
}, displayedTags)), (allTagsModalTarget ? createPortal : function (children) {
|
245
|
+
return children;
|
246
|
+
})( /*#__PURE__*/React.createElement(TagSetModal, {
|
241
247
|
allTags: tags,
|
242
248
|
open: showAllModalOpen,
|
243
249
|
title: allTagsModalTitle,
|
244
250
|
onClose: handleModalClose,
|
245
251
|
searchLabel: allTagsModalSearchLabel,
|
246
252
|
searchPlaceholder: allTagsModalSearchPlaceholderText
|
247
|
-
}), allTagsModalTarget)
|
253
|
+
}), allTagsModalTarget));
|
248
254
|
}); // Return a placeholder if not released and not enabled by feature flag
|
249
255
|
|
250
256
|
TagSet = pkg.checkComponentEnabled(TagSet, componentName);
|
@@ -269,7 +275,8 @@ var TYPES = {
|
|
269
275
|
gray: 'Gray',
|
270
276
|
'cool-gray': 'Cool-Gray',
|
271
277
|
'warm-gray': 'Warm-Gray',
|
272
|
-
'high-contrast': 'High-Contrast'
|
278
|
+
'high-contrast': 'High-Contrast',
|
279
|
+
outline: 'Outline'
|
273
280
|
};
|
274
281
|
var tagTypes = Object.keys(TYPES);
|
275
282
|
TagSet.types = tagTypes;
|
@@ -2,7 +2,7 @@ import _extends from "@babel/runtime/helpers/extends";
|
|
2
2
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
3
3
|
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
4
4
|
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
5
|
-
var _excluded = ["actions", "children", "className", "closeIconDescription", "description", "hasCloseIcon", "headerActions", "influencer", "influencerPosition", "influencerWidth", "label", "navigation", "onClose", "open", "selectorPrimaryFocus", "size", "title", "verticalPosition"];
|
5
|
+
var _excluded = ["actions", "children", "className", "closeIconDescription", "description", "hasCloseIcon", "headerActions", "influencer", "influencerPosition", "influencerWidth", "label", "navigation", "onClose", "open", "selectorPrimaryFocus", "size", "portalTarget", "title", "verticalPosition"];
|
6
6
|
|
7
7
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
8
8
|
|
@@ -16,6 +16,7 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
|
|
16
16
|
*/
|
17
17
|
// Import portions of React that are needed.
|
18
18
|
import React, { useEffect, useState, useRef } from 'react';
|
19
|
+
import { createPortal } from 'react-dom';
|
19
20
|
import { useResizeDetector } from 'react-resize-detector'; // Other standard imports.
|
20
21
|
|
21
22
|
import PropTypes from 'prop-types';
|
@@ -68,10 +69,26 @@ export var TearsheetShell = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
68
69
|
open = _ref.open,
|
69
70
|
selectorPrimaryFocus = _ref.selectorPrimaryFocus,
|
70
71
|
size = _ref.size,
|
72
|
+
portalTargetIn = _ref.portalTarget,
|
71
73
|
title = _ref.title,
|
72
74
|
verticalPosition = _ref.verticalPosition,
|
73
75
|
rest = _objectWithoutProperties(_ref, _excluded);
|
74
76
|
|
77
|
+
// node the modal tearsheet is hosted in
|
78
|
+
var _useState = useState(null),
|
79
|
+
_useState2 = _slicedToArray(_useState, 2),
|
80
|
+
portalTarget = _useState2[0],
|
81
|
+
setPortalTarget = _useState2[1];
|
82
|
+
|
83
|
+
useEffect(function () {
|
84
|
+
if (portalTargetIn) {
|
85
|
+
setPortalTarget(portalTargetIn);
|
86
|
+
} else {
|
87
|
+
if (pkg.isFeatureEnabled('default-portal-target-body')) {
|
88
|
+
setPortalTarget(document.body);
|
89
|
+
}
|
90
|
+
}
|
91
|
+
}, [portalTargetIn]);
|
75
92
|
var localRef = useRef();
|
76
93
|
var modalRef = ref || localRef;
|
77
94
|
|
@@ -82,15 +99,15 @@ export var TearsheetShell = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
82
99
|
resizer = _useResizeDetector.ref; // Keep track of the stack depth and our position in it (1-based, 0=closed)
|
83
100
|
|
84
101
|
|
85
|
-
var _useState = useState(0),
|
86
|
-
_useState2 = _slicedToArray(_useState, 2),
|
87
|
-
depth = _useState2[0],
|
88
|
-
setDepth = _useState2[1];
|
89
|
-
|
90
102
|
var _useState3 = useState(0),
|
91
103
|
_useState4 = _slicedToArray(_useState3, 2),
|
92
|
-
|
93
|
-
|
104
|
+
depth = _useState4[0],
|
105
|
+
setDepth = _useState4[1];
|
106
|
+
|
107
|
+
var _useState5 = useState(0),
|
108
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
109
|
+
position = _useState6[0],
|
110
|
+
setPosition = _useState6[1]; // Keep a record of the previous value of depth.
|
94
111
|
|
95
112
|
|
96
113
|
var prevDepth = useRef();
|
@@ -176,7 +193,9 @@ export var TearsheetShell = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
176
193
|
var includeHeader = label || title || description || headerActions || navigation || effectiveHasCloseIcon; // Include an ActionSet if and only if one or more actions is given.
|
177
194
|
|
178
195
|
var includeActions = actions && (actions === null || actions === void 0 ? void 0 : actions.length) > 0;
|
179
|
-
return
|
196
|
+
return (portalTarget ? createPortal : function (children) {
|
197
|
+
return children;
|
198
|
+
})( /*#__PURE__*/React.createElement(ComposedModal, _extends({}, rest, {
|
180
199
|
"aria-label": title,
|
181
200
|
className: cx(bc, className, (_cx = {}, _defineProperty(_cx, "".concat(bc, "--stacked-").concat(position, "-of-").concat(depth), // Don't apply this on the initial open of a single tearsheet.
|
182
201
|
depth > 1 || depth === 1 && prevDepth.current > 1), _defineProperty(_cx, "".concat(bc, "--wide"), size === 'wide'), _defineProperty(_cx, "".concat(bc, "--narrow"), size !== 'wide'), _cx)),
|
@@ -237,7 +256,7 @@ export var TearsheetShell = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
237
256
|
})))), /*#__PURE__*/React.createElement("div", {
|
238
257
|
className: "".concat(bc, "__resize-detector"),
|
239
258
|
ref: resizer
|
240
|
-
}));
|
259
|
+
})), portalTarget);
|
241
260
|
} else {
|
242
261
|
pconsole.warn('Tearsheet not rendered: maximum stacking depth exceeded.');
|
243
262
|
return null;
|
@@ -377,6 +396,11 @@ TearsheetShell.propTypes = _objectSpread({
|
|
377
396
|
*/
|
378
397
|
open: PropTypes.bool,
|
379
398
|
|
399
|
+
/**
|
400
|
+
* portal target for the all tags modal
|
401
|
+
*/
|
402
|
+
portalTarget: PropTypes.node,
|
403
|
+
|
380
404
|
/**
|
381
405
|
* Specifies the width of the tearsheet, 'narrow' or 'wide'.
|
382
406
|
*/
|
@@ -22,7 +22,8 @@ import cx from 'classnames';
|
|
22
22
|
import { pkg } from '../../settings'; // Carbon and package components we use.
|
23
23
|
|
24
24
|
import { Close16 as Close, Help16 as Help } from '@carbon/icons-react';
|
25
|
-
import { Button, OverflowMenu, OverflowMenuItem } from 'carbon-components-react';
|
25
|
+
import { Button, OverflowMenu, OverflowMenuItem } from 'carbon-components-react';
|
26
|
+
import { moderate02 } from '@carbon/motion'; // The block part of our conventional BEM class names (blockClass__E--M).
|
26
27
|
|
27
28
|
var componentName = 'WebTerminal';
|
28
29
|
var blockClass = "".concat(pkg.prefix, "--web-terminal"); // Default values for props
|
@@ -33,7 +34,7 @@ var defaults = {
|
|
33
34
|
documentationLinksIconDescription: 'Show documentation links'
|
34
35
|
};
|
35
36
|
export var WebTerminal = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
36
|
-
var
|
37
|
+
var _ref3;
|
37
38
|
|
38
39
|
var _ref$actions = _ref.actions,
|
39
40
|
actions = _ref$actions === void 0 ? defaults.actions : _ref$actions,
|
@@ -53,6 +54,12 @@ export var WebTerminal = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
53
54
|
shouldRender = _useState2[0],
|
54
55
|
setRender = _useState2[1];
|
55
56
|
|
57
|
+
var _ref2 = window && window.matchMedia ? window.matchMedia('(prefers-reduced-motion: reduce)') : {
|
58
|
+
matches: true
|
59
|
+
},
|
60
|
+
prefersReducedMotion = _ref2.matches;
|
61
|
+
|
62
|
+
var webTerminalAnimationName = "".concat(open ? 'web-terminal-entrance' : 'web-terminal-exit', " ").concat(moderate02);
|
56
63
|
var showDocumentationLinks = useMemo(function () {
|
57
64
|
return documentationLinks.length > 0;
|
58
65
|
}, [documentationLinks]);
|
@@ -61,6 +68,9 @@ export var WebTerminal = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
61
68
|
setRender(true);
|
62
69
|
}
|
63
70
|
}, [open]);
|
71
|
+
/**
|
72
|
+
When the web terminal slide in animation is complete, sets render to false.
|
73
|
+
*/
|
64
74
|
|
65
75
|
var onAnimationEnd = function onAnimationEnd() {
|
66
76
|
if (!open) {
|
@@ -68,11 +78,23 @@ export var WebTerminal = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
68
78
|
}
|
69
79
|
};
|
70
80
|
|
81
|
+
var handleCloseTerminal = function handleCloseTerminal() {
|
82
|
+
/**
|
83
|
+
If the user prefers reduced motion, we have to manually set render to false
|
84
|
+
because onAnimationEnd will never be called.
|
85
|
+
*/
|
86
|
+
if (prefersReducedMotion) {
|
87
|
+
setRender(false);
|
88
|
+
}
|
89
|
+
|
90
|
+
closeTerminal();
|
91
|
+
};
|
92
|
+
|
71
93
|
return shouldRender ? /*#__PURE__*/React.createElement("div", _extends({}, rest, {
|
72
94
|
ref: ref,
|
73
|
-
className: cx([className, blockClass, (
|
95
|
+
className: cx([className, blockClass, (_ref3 = {}, _defineProperty(_ref3, "".concat(blockClass, "--open"), open), _defineProperty(_ref3, "".concat(blockClass, "--closed"), !open), _ref3)]),
|
74
96
|
style: {
|
75
|
-
animation:
|
97
|
+
animation: !prefersReducedMotion && webTerminalAnimationName
|
76
98
|
},
|
77
99
|
onAnimationEnd: onAnimationEnd
|
78
100
|
}), /*#__PURE__*/React.createElement("header", {
|
@@ -84,16 +106,16 @@ export var WebTerminal = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
84
106
|
iconDescription: documentationLinksIconDescription,
|
85
107
|
menuOptionsClass: "".concat(blockClass, "__documentation-overflow"),
|
86
108
|
size: "lg"
|
87
|
-
}, documentationLinks.map(function (
|
88
|
-
var rest = _extends({},
|
109
|
+
}, documentationLinks.map(function (_ref4, i) {
|
110
|
+
var rest = _extends({}, _ref4);
|
89
111
|
|
90
112
|
return /*#__PURE__*/React.createElement(OverflowMenuItem, _extends({
|
91
113
|
key: i
|
92
114
|
}, rest));
|
93
|
-
})), actions.map(function (
|
94
|
-
var renderIcon =
|
95
|
-
onClick =
|
96
|
-
iconDescription =
|
115
|
+
})), actions.map(function (_ref5) {
|
116
|
+
var renderIcon = _ref5.renderIcon,
|
117
|
+
onClick = _ref5.onClick,
|
118
|
+
iconDescription = _ref5.iconDescription;
|
97
119
|
return /*#__PURE__*/React.createElement(Button, {
|
98
120
|
key: iconDescription,
|
99
121
|
hasIconOnly: true,
|
@@ -107,7 +129,10 @@ export var WebTerminal = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
107
129
|
renderIcon: Close,
|
108
130
|
kind: "ghost",
|
109
131
|
iconDescription: closeIconDescription,
|
110
|
-
onClick:
|
132
|
+
onClick: handleCloseTerminal,
|
133
|
+
onAnimationEnd: function onAnimationEnd(event) {
|
134
|
+
return event.stopPropagation();
|
135
|
+
}
|
111
136
|
})), /*#__PURE__*/React.createElement("div", {
|
112
137
|
className: "".concat(blockClass, "__body")
|
113
138
|
}, children)) : null;
|
@@ -0,0 +1,49 @@
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
2
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
3
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
4
|
+
var _excluded = ["children", "isTerminalOpen"];
|
5
|
+
|
6
|
+
/**
|
7
|
+
* Copyright IBM Corp. 2020, 2021
|
8
|
+
*
|
9
|
+
* This source code is licensed under the Apache-2.0 license found in the
|
10
|
+
* LICENSE file in the root directory of this source tree.
|
11
|
+
*/
|
12
|
+
// Import portions of React that are needed.
|
13
|
+
import React from 'react'; // Other standard imports.
|
14
|
+
|
15
|
+
import PropTypes from 'prop-types';
|
16
|
+
import cx from 'classnames';
|
17
|
+
import { pkg } from '../../settings'; // The block part of our conventional BEM class names (blockClass__E--M).
|
18
|
+
|
19
|
+
var componentName = 'WebTerminalContentWrapper';
|
20
|
+
var blockClass = "".concat(pkg.prefix, "--web-terminal-content-wrapper");
|
21
|
+
export var WebTerminalContentWrapper = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
22
|
+
var children = _ref.children,
|
23
|
+
isTerminalOpen = _ref.isTerminalOpen,
|
24
|
+
rest = _objectWithoutProperties(_ref, _excluded);
|
25
|
+
|
26
|
+
return /*#__PURE__*/React.createElement("div", _extends({
|
27
|
+
ref: ref,
|
28
|
+
className: cx([blockClass, _defineProperty({}, "".concat(blockClass, "--open"), isTerminalOpen)])
|
29
|
+
}, rest), children);
|
30
|
+
}); // Return a placeholder if not released and not enabled by feature flag
|
31
|
+
|
32
|
+
WebTerminalContentWrapper = pkg.checkComponentEnabled(WebTerminalContentWrapper, componentName); // The display name of the component, used by React. Note that displayName
|
33
|
+
// is used in preference to relying on function.name.
|
34
|
+
|
35
|
+
WebTerminalContentWrapper.displayName = componentName; // The types and DocGen commentary for the component props,
|
36
|
+
// in alphabetical order (for consistency).
|
37
|
+
// See https://www.npmjs.com/package/prop-types#usage.
|
38
|
+
|
39
|
+
WebTerminalContentWrapper.propTypes = {
|
40
|
+
/**
|
41
|
+
* Pass in content as children.
|
42
|
+
*/
|
43
|
+
children: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.node), PropTypes.node]).isRequired,
|
44
|
+
|
45
|
+
/**
|
46
|
+
* A boolean to determine if the terminal is open.
|
47
|
+
*/
|
48
|
+
isTerminalOpen: PropTypes.bool.isRequired
|
49
|
+
};
|
@@ -1 +1,2 @@
|
|
1
|
-
export { WebTerminal } from './WebTerminal';
|
1
|
+
export { WebTerminal } from './WebTerminal';
|
2
|
+
export { WebTerminalContentWrapper } from './WebTerminalContentWrapper';
|
package/es/components/index.js
CHANGED
@@ -32,7 +32,7 @@ export { TagSet } from './TagSet';
|
|
32
32
|
export { Tearsheet, TearsheetNarrow } from './Tearsheet';
|
33
33
|
export { Toolbar, ToolbarButton, ToolbarGroup } from './Toolbar';
|
34
34
|
export { UserProfileImage } from './UserProfileImage';
|
35
|
-
export { WebTerminal } from './WebTerminal';
|
35
|
+
export { WebTerminal, WebTerminalContentWrapper } from './WebTerminal';
|
36
36
|
export { EditSidePanel } from './EditSidePanel';
|
37
37
|
export { OptionsTile } from './OptionsTile';
|
38
38
|
export { InlineEdit } from './InlineEdit';
|
@@ -60,6 +60,7 @@ var defaults = {
|
|
60
60
|
ToolbarButton: false,
|
61
61
|
ToolbarGroup: false,
|
62
62
|
WebTerminal: false,
|
63
|
+
WebTerminalContentWrapper: false,
|
63
64
|
EditSidePanel: false,
|
64
65
|
CancelableTextEdit: false,
|
65
66
|
InlineEdit: false,
|
@@ -70,7 +71,8 @@ var defaults = {
|
|
70
71
|
},
|
71
72
|
// feature level flags
|
72
73
|
feature: {
|
73
|
-
'a-new-feature': false
|
74
|
+
'a-new-feature': false,
|
75
|
+
'default-portal-target-body': true
|
74
76
|
}
|
75
77
|
};
|
76
78
|
|