@carbon/ibm-products 2.39.0 → 2.40.1-canary.10
Sign up to get free protection for your applications and to get access to all the features.
- package/css/index-full-carbon.css +47 -38
- 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 +7 -1
- 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 +47 -38
- 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 +710 -38
- 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/AddSelect/AddSelect.d.ts +44 -2
- package/es/components/AddSelect/AddSelect.js +8 -4
- package/es/components/AddSelect/AddSelectBody.d.ts +44 -2
- package/es/components/AddSelect/AddSelectBody.js +10 -12
- package/es/components/AddSelect/AddSelectSort.d.ts +16 -17
- package/es/components/AddSelect/AddSelectSort.js +5 -5
- package/es/components/AddSelect/types/index.d.ts +44 -0
- package/es/components/BreadcrumbWithOverflow/BreadcrumbWithOverflow.d.ts +5 -1
- package/es/components/BreadcrumbWithOverflow/BreadcrumbWithOverflow.js +12 -6
- package/es/components/Card/Card.js +1 -1
- package/es/components/ConditionBuilder/ConditionBlock/ConditionBlock.js +3 -3
- package/es/components/ConditionBuilder/ConditionBuilder.js +6 -1
- package/es/components/ConditionBuilder/ConditionBuilderAdd/ConditionBuilderAdd.js +3 -3
- package/es/components/ConditionBuilder/ConditionBuilderButton/ConditionBuilderButton.js +1 -1
- package/es/components/ConditionBuilder/ConditionBuilderContent/ConditionBuilderContent.js +2 -2
- package/es/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItem.js +3 -3
- package/es/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItemDate/ConditionBuilderItemDate.js +1 -1
- package/es/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItemNumber/ConditionBuilderItemNumber.js +1 -1
- package/es/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItemOption/ConditionBuilderItemOption.js +30 -18
- package/es/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItemText/ConditionBuilderItemText.js +3 -3
- package/es/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItemTime/ConditionBuilderItemTime.js +7 -7
- package/es/components/ConditionBuilder/ConditionConnector/ConditionConnector.js +6 -6
- package/es/components/ConditionBuilder/ConditionGroupBuilder/ConditionGroupBuilder.js +11 -11
- package/es/components/ConditionBuilder/utils/checkForHoldingKey.d.ts +1 -0
- package/es/components/ConditionBuilder/utils/checkForHoldingKey.js +16 -0
- package/es/components/ConditionBuilder/utils/handleKeyboardEvents.d.ts +1 -0
- package/es/components/ConditionBuilder/utils/handleKeyboardEvents.js +125 -0
- package/es/components/ConditionBuilder/utils/util.d.ts +1 -1
- package/es/components/ConditionBuilder/utils/util.js +34 -5
- package/es/components/CreateInfluencer/CreateInfluencer.js +1 -1
- package/es/components/CreateTearsheet/CreateTearsheetStep.d.ts +95 -2
- package/es/components/CreateTearsheet/CreateTearsheetStep.js +7 -5
- package/es/components/DataSpreadsheet/DataSpreadsheet.js +4 -3
- package/es/components/DataSpreadsheet/DataSpreadsheetHeader.js +5 -0
- package/es/components/Datagrid/Datagrid/DatagridContent.js +2 -2
- package/es/components/Datagrid/Datagrid/DatagridHeaderRow.js +3 -4
- package/es/components/Datagrid/Datagrid/DatagridVirtualBody.js +5 -1
- package/es/components/ExpressiveCard/ExpressiveCard.d.ts +2 -1
- package/es/components/Guidebanner/Guidebanner.d.ts +62 -2
- package/es/components/Guidebanner/Guidebanner.js +8 -7
- package/es/components/Guidebanner/GuidebannerElement.d.ts +30 -17
- package/es/components/Guidebanner/GuidebannerElement.js +4 -4
- package/es/components/Guidebanner/GuidebannerElementButton.d.ts +29 -15
- package/es/components/Guidebanner/GuidebannerElementButton.js +10 -4
- package/es/components/Guidebanner/GuidebannerElementLink.d.ts +20 -13
- package/es/components/Guidebanner/GuidebannerElementLink.js +3 -3
- package/es/components/InterstitialScreen/InterstitialScreen.js +3 -1
- package/es/components/MultiAddSelect/MultiAddSelect.d.ts +134 -2
- package/es/components/MultiAddSelect/MultiAddSelect.js +2 -1
- package/es/components/NotificationsPanel/NotificationsPanel.js +0 -1
- package/es/components/PageHeader/PageHeader.d.ts +298 -5
- package/es/components/PageHeader/PageHeader.js +99 -47
- package/es/components/PageHeader/PageHeaderUtils.d.ts +1 -1
- package/es/components/PageHeader/PageHeaderUtils.js +4 -1
- package/es/components/SidePanel/SidePanel.d.ts +6 -2
- package/es/components/SidePanel/SidePanel.js +17 -2
- package/es/components/SidePanel/constants.d.ts +1 -0
- package/es/components/SidePanel/constants.js +1 -0
- package/es/components/SingleAddSelect/SingleAddSelect.d.ts +69 -2
- package/es/components/SingleAddSelect/SingleAddSelect.js +2 -1
- package/es/components/TagOverflow/TagOverflow.js +35 -20
- package/es/components/TagOverflow/TagOverflowModal.d.ts +3 -1
- package/es/components/TagOverflow/TagOverflowModal.js +14 -20
- package/es/components/TagOverflow/TagOverflowPopover.js +19 -4
- package/es/components/Tearsheet/Tearsheet.d.ts +132 -6
- package/es/components/Tearsheet/Tearsheet.js +25 -13
- package/es/components/Tearsheet/TearsheetShell.d.ts +5 -1
- package/es/components/Tearsheet/TearsheetShell.js +26 -4
- package/es/components/WebTerminal/WebTerminal.d.ts +4 -0
- package/es/components/WebTerminal/WebTerminal.js +11 -3
- package/es/global/js/hooks/useFocus.d.ts +3 -1
- package/es/global/js/hooks/useFocus.js +6 -3
- package/es/global/js/hooks/useRetrieveStepData.d.ts +1 -1
- package/es/global/js/hooks/useRetrieveStepData.js +1 -1
- package/lib/components/AddSelect/AddSelect.d.ts +44 -2
- package/lib/components/AddSelect/AddSelect.js +7 -3
- package/lib/components/AddSelect/AddSelectBody.d.ts +44 -2
- package/lib/components/AddSelect/AddSelectBody.js +10 -12
- package/lib/components/AddSelect/AddSelectSort.d.ts +16 -17
- package/lib/components/AddSelect/AddSelectSort.js +5 -5
- package/lib/components/AddSelect/types/index.d.ts +44 -0
- package/lib/components/BreadcrumbWithOverflow/BreadcrumbWithOverflow.d.ts +5 -1
- package/lib/components/BreadcrumbWithOverflow/BreadcrumbWithOverflow.js +12 -6
- package/lib/components/Card/Card.js +1 -1
- package/lib/components/ConditionBuilder/ConditionBlock/ConditionBlock.js +3 -3
- package/lib/components/ConditionBuilder/ConditionBuilder.js +6 -1
- package/lib/components/ConditionBuilder/ConditionBuilderAdd/ConditionBuilderAdd.js +3 -3
- package/lib/components/ConditionBuilder/ConditionBuilderButton/ConditionBuilderButton.js +1 -1
- package/lib/components/ConditionBuilder/ConditionBuilderContent/ConditionBuilderContent.js +2 -2
- package/lib/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItem.js +3 -3
- package/lib/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItemDate/ConditionBuilderItemDate.js +1 -1
- package/lib/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItemNumber/ConditionBuilderItemNumber.js +1 -1
- package/lib/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItemOption/ConditionBuilderItemOption.js +29 -17
- package/lib/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItemText/ConditionBuilderItemText.js +3 -3
- package/lib/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItemTime/ConditionBuilderItemTime.js +7 -7
- package/lib/components/ConditionBuilder/ConditionConnector/ConditionConnector.js +6 -6
- package/lib/components/ConditionBuilder/ConditionGroupBuilder/ConditionGroupBuilder.js +11 -11
- package/lib/components/ConditionBuilder/utils/checkForHoldingKey.d.ts +1 -0
- package/lib/components/ConditionBuilder/utils/checkForHoldingKey.js +20 -0
- package/lib/components/ConditionBuilder/utils/handleKeyboardEvents.d.ts +1 -0
- package/lib/components/ConditionBuilder/utils/handleKeyboardEvents.js +129 -0
- package/lib/components/ConditionBuilder/utils/util.d.ts +1 -1
- package/lib/components/ConditionBuilder/utils/util.js +36 -4
- package/lib/components/CreateInfluencer/CreateInfluencer.js +1 -1
- package/lib/components/CreateTearsheet/CreateTearsheetStep.d.ts +95 -2
- package/lib/components/CreateTearsheet/CreateTearsheetStep.js +7 -5
- package/lib/components/DataSpreadsheet/DataSpreadsheet.js +4 -3
- package/lib/components/DataSpreadsheet/DataSpreadsheetHeader.js +5 -0
- package/lib/components/Datagrid/Datagrid/DatagridContent.js +2 -2
- package/lib/components/Datagrid/Datagrid/DatagridHeaderRow.js +3 -4
- package/lib/components/Datagrid/Datagrid/DatagridVirtualBody.js +5 -1
- package/lib/components/ExpressiveCard/ExpressiveCard.d.ts +2 -1
- package/lib/components/Guidebanner/Guidebanner.d.ts +62 -2
- package/lib/components/Guidebanner/Guidebanner.js +8 -7
- package/lib/components/Guidebanner/GuidebannerElement.d.ts +30 -17
- package/lib/components/Guidebanner/GuidebannerElement.js +4 -4
- package/lib/components/Guidebanner/GuidebannerElementButton.d.ts +29 -15
- package/lib/components/Guidebanner/GuidebannerElementButton.js +10 -4
- package/lib/components/Guidebanner/GuidebannerElementLink.d.ts +20 -13
- package/lib/components/Guidebanner/GuidebannerElementLink.js +3 -3
- package/lib/components/InterstitialScreen/InterstitialScreen.js +3 -1
- package/lib/components/MultiAddSelect/MultiAddSelect.d.ts +134 -2
- package/lib/components/MultiAddSelect/MultiAddSelect.js +2 -1
- package/lib/components/NotificationsPanel/NotificationsPanel.js +0 -1
- package/lib/components/PageHeader/PageHeader.d.ts +298 -5
- package/lib/components/PageHeader/PageHeader.js +99 -47
- package/lib/components/PageHeader/PageHeaderUtils.d.ts +1 -1
- package/lib/components/PageHeader/PageHeaderUtils.js +4 -1
- package/lib/components/SidePanel/SidePanel.d.ts +6 -2
- package/lib/components/SidePanel/SidePanel.js +17 -2
- package/lib/components/SidePanel/constants.d.ts +1 -0
- package/lib/components/SidePanel/constants.js +1 -0
- package/lib/components/SingleAddSelect/SingleAddSelect.d.ts +69 -2
- package/lib/components/SingleAddSelect/SingleAddSelect.js +2 -1
- package/lib/components/TagOverflow/TagOverflow.js +34 -19
- package/lib/components/TagOverflow/TagOverflowModal.d.ts +3 -1
- package/lib/components/TagOverflow/TagOverflowModal.js +14 -20
- package/lib/components/TagOverflow/TagOverflowPopover.js +19 -4
- package/lib/components/Tearsheet/Tearsheet.d.ts +132 -6
- package/lib/components/Tearsheet/Tearsheet.js +25 -13
- package/lib/components/Tearsheet/TearsheetShell.d.ts +5 -1
- package/lib/components/Tearsheet/TearsheetShell.js +26 -4
- package/lib/components/WebTerminal/WebTerminal.d.ts +4 -0
- package/lib/components/WebTerminal/WebTerminal.js +11 -3
- package/lib/global/js/hooks/useFocus.d.ts +3 -1
- package/lib/global/js/hooks/useFocus.js +6 -3
- package/lib/global/js/hooks/useRetrieveStepData.d.ts +1 -1
- package/lib/global/js/hooks/useRetrieveStepData.js +1 -1
- package/package.json +3 -3
- package/scss/components/CoachmarkStack/_coachmark-stack.scss +4 -2
- package/scss/components/ConditionBuilder/styles/_conditionBuilderCondition.scss +4 -4
- package/scss/components/ConditionBuilder/styles/_conditionBuilderItem.scss +34 -34
- package/scss/components/Datagrid/styles/_datagrid.scss +2 -1
- package/scss/components/SidePanel/_side-panel-variables.scss +1 -0
- package/scss/components/StringFormatter/_string-formatter.scss +1 -1
- package/scss/components/TagOverflow/_tag-overflow.scss +5 -2
- package/scss/components/_index-with-carbon.scss +1 -0
- package/telemetry.yml +2 -0
@@ -5,7 +5,7 @@
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
6
6
|
*/
|
7
7
|
|
8
|
-
import { objectWithoutProperties as _objectWithoutProperties, slicedToArray as _slicedToArray,
|
8
|
+
import { objectWithoutProperties as _objectWithoutProperties, slicedToArray as _slicedToArray, objectSpread2 as _objectSpread2, extends as _extends, defineProperty as _defineProperty } from '../../_virtual/_rollupPluginBabelHelpers.js';
|
9
9
|
import React__default, { useRef, useState, useCallback, useEffect } from 'react';
|
10
10
|
import PropTypes from '../../node_modules/prop-types/index.js';
|
11
11
|
import cx from 'classnames';
|
@@ -19,13 +19,13 @@ import { TagOverflowPopover } from './TagOverflowPopover.js';
|
|
19
19
|
import { TagOverflowModal } from './TagOverflowModal.js';
|
20
20
|
|
21
21
|
var _excluded = ["items", "tagComponent", "align", "showAllTagsLabel", "allTagsModalSearchLabel", "allTagsModalSearchPlaceholderText", "allTagsModalTarget", "allTagsModalTitle", "className", "containingElementRef", "measurementOffset", "maxVisible", "multiline", "overflowAlign", "overflowClassName", "overflowType", "onOverflowTagChange"],
|
22
|
-
_excluded2 = ["className", "id"]
|
22
|
+
_excluded2 = ["className", "id"],
|
23
|
+
_excluded3 = ["tagType"],
|
24
|
+
_excluded4 = ["id", "label", "tagType", "onClose"];
|
23
25
|
var blockClass = "".concat(pkg.prefix, "--tag-overflow");
|
24
26
|
var componentName = 'TagOverflow';
|
25
27
|
var allTagsModalSearchThreshold = 10;
|
26
28
|
|
27
|
-
// TODO: support prop overflowType
|
28
|
-
|
29
29
|
// Default values for props
|
30
30
|
var defaults = {
|
31
31
|
items: [],
|
@@ -164,39 +164,53 @@ var TagOverflow = /*#__PURE__*/React__default.forwardRef(function (_ref, ref) {
|
|
164
164
|
visibleItemsArr = (_visibleItemsArr = visibleItemsArr) === null || _visibleItemsArr === void 0 ? void 0 : _visibleItemsArr.slice(0, maxVisible);
|
165
165
|
}
|
166
166
|
var hiddenItems = items === null || items === void 0 ? void 0 : items.slice(visibleItemsArr.length);
|
167
|
-
var overflowItemsArr = hiddenItems === null || hiddenItems === void 0 ? void 0 : hiddenItems.map(function (
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
};
|
167
|
+
var overflowItemsArr = hiddenItems === null || hiddenItems === void 0 ? void 0 : hiddenItems.map(function (_ref2) {
|
168
|
+
var tagType = _ref2.tagType,
|
169
|
+
other = _objectWithoutProperties(_ref2, _excluded3);
|
170
|
+
return _objectSpread2({
|
171
|
+
type: tagType
|
172
|
+
}, other);
|
173
173
|
});
|
174
174
|
setVisibleItems(visibleItemsArr);
|
175
175
|
setOverflowItems(overflowItemsArr);
|
176
176
|
onOverflowTagChange === null || onOverflowTagChange === void 0 || onOverflowTagChange(overflowItemsArr);
|
177
177
|
}, [containerWidth, items, maxVisible, getVisibleItems, onOverflowTagChange]);
|
178
|
+
var handleTagOnClose = useCallback(function (onClose, index) {
|
179
|
+
onClose === null || onClose === void 0 || onClose();
|
180
|
+
if (index <= visibleItems.length - 1) {
|
181
|
+
setPopoverOpen(false);
|
182
|
+
}
|
183
|
+
}, [visibleItems]);
|
178
184
|
return /*#__PURE__*/React__default.createElement("div", _extends({}, rest, {
|
179
185
|
className: cx(blockClass, className, "".concat(blockClass, "--align-").concat(align), _defineProperty({}, "".concat(blockClass, "--multiline"), multiline)),
|
180
186
|
ref: containerRef,
|
181
187
|
role: "main"
|
182
|
-
}, getDevtoolsProps(componentName)), visibleItems.length > 0 && visibleItems.map(function (item) {
|
188
|
+
}, getDevtoolsProps(componentName)), visibleItems.length > 0 && visibleItems.map(function (item, index) {
|
183
189
|
// Render custom components
|
184
190
|
if (tagComponent) {
|
185
191
|
return getCustomComponent(item);
|
186
192
|
} else {
|
193
|
+
var id = item.id,
|
194
|
+
label = item.label,
|
195
|
+
tagType = item.tagType,
|
196
|
+
_onClose = item.onClose,
|
197
|
+
other = _objectWithoutProperties(item, _excluded4);
|
187
198
|
// If there is no template prop, then render items as Tags
|
188
199
|
return /*#__PURE__*/React__default.createElement("div", {
|
189
200
|
ref: function ref(node) {
|
190
|
-
return itemRefHandler(
|
201
|
+
return itemRefHandler(id, node);
|
191
202
|
},
|
192
|
-
key:
|
203
|
+
key: id
|
193
204
|
}, /*#__PURE__*/React__default.createElement(Tooltip, {
|
194
|
-
align:
|
195
|
-
label:
|
196
|
-
}, /*#__PURE__*/React__default.createElement(Tag, {
|
205
|
+
align: overflowAlign,
|
206
|
+
label: label
|
207
|
+
}, /*#__PURE__*/React__default.createElement(Tag, _extends({}, other, {
|
197
208
|
className: "".concat(blockClass, "__item--tag"),
|
198
|
-
type:
|
199
|
-
|
209
|
+
type: tagType,
|
210
|
+
onClose: function onClose() {
|
211
|
+
return handleTagOnClose(_onClose, index);
|
212
|
+
}
|
213
|
+
}), label)));
|
200
214
|
}
|
201
215
|
}), /*#__PURE__*/React__default.createElement("span", {
|
202
216
|
className: "".concat(blockClass, "__indicator"),
|
@@ -218,6 +232,7 @@ var TagOverflow = /*#__PURE__*/React__default.forwardRef(function (_ref, ref) {
|
|
218
232
|
open: showAllModalOpen,
|
219
233
|
title: allTagsModalTitle,
|
220
234
|
onClose: handleModalClose,
|
235
|
+
overflowType: overflowType,
|
221
236
|
searchLabel: allTagsModalSearchLabel,
|
222
237
|
searchPlaceholder: allTagsModalSearchPlaceholderText,
|
223
238
|
portalTarget: allTagsModalTarget
|
@@ -236,8 +251,8 @@ var tagTypes = Object.keys(TYPES);
|
|
236
251
|
* The strings shown in the showAllModal are only shown if we have more than allTagsModalSearchLThreshold
|
237
252
|
* @returns null if no problems
|
238
253
|
*/
|
239
|
-
var string_required_if_more_than_10_tags = isRequiredIf(PropTypes.string, function (
|
240
|
-
var items =
|
254
|
+
var string_required_if_more_than_10_tags = isRequiredIf(PropTypes.string, function (_ref3) {
|
255
|
+
var items = _ref3.items;
|
241
256
|
return items && items.length > allTagsModalSearchThreshold;
|
242
257
|
});
|
243
258
|
|
@@ -1,10 +1,11 @@
|
|
1
|
-
export function TagOverflowModal({ allTags, className, title, onClose, open, portalTarget: portalTargetIn, searchLabel, searchPlaceholder, ...rest }: {
|
1
|
+
export function TagOverflowModal({ allTags, className, title, onClose, open, overflowType, portalTarget: portalTargetIn, searchLabel, searchPlaceholder, ...rest }: {
|
2
2
|
[x: string]: any;
|
3
3
|
allTags: any;
|
4
4
|
className: any;
|
5
5
|
title: any;
|
6
6
|
onClose: any;
|
7
7
|
open: any;
|
8
|
+
overflowType: any;
|
8
9
|
portalTarget: any;
|
9
10
|
searchLabel?: string | undefined;
|
10
11
|
searchPlaceholder: any;
|
@@ -17,6 +18,7 @@ export namespace TagOverflowModal {
|
|
17
18
|
let className: PropTypes.Requireable<string>;
|
18
19
|
let onClose: PropTypes.Requireable<(...args: any[]) => any>;
|
19
20
|
let open: PropTypes.Requireable<boolean>;
|
21
|
+
let overflowType: PropTypes.Requireable<string>;
|
20
22
|
let portalTarget: PropTypes.Requireable<PropTypes.ReactNodeLike>;
|
21
23
|
let searchLabel: PropTypes.Requireable<string>;
|
22
24
|
let searchPlaceholder: PropTypes.Requireable<string>;
|
@@ -14,8 +14,8 @@ import { pkg } from '../../settings.js';
|
|
14
14
|
import { prepareProps } from '../../global/js/utils/props-helper.js';
|
15
15
|
import { usePortalTarget } from '../../global/js/hooks/usePortalTarget.js';
|
16
16
|
|
17
|
-
var _excluded = ["allTags", "className", "title", "onClose", "open", "portalTarget", "searchLabel", "searchPlaceholder"],
|
18
|
-
_excluded2 = ["label", "id"];
|
17
|
+
var _excluded = ["allTags", "className", "title", "onClose", "open", "overflowType", "portalTarget", "searchLabel", "searchPlaceholder"],
|
18
|
+
_excluded2 = ["label", "id", "filter"];
|
19
19
|
var componentName = 'TagOverflowModal';
|
20
20
|
var blockClass = "".concat(pkg.prefix, "--tag-overflow-modal");
|
21
21
|
|
@@ -30,6 +30,7 @@ var TagOverflowModal = function TagOverflowModal(_ref) {
|
|
30
30
|
title = _ref.title,
|
31
31
|
onClose = _ref.onClose,
|
32
32
|
open = _ref.open,
|
33
|
+
overflowType = _ref.overflowType,
|
33
34
|
portalTargetIn = _ref.portalTarget,
|
34
35
|
_ref$searchLabel = _ref.searchLabel,
|
35
36
|
searchLabel = _ref$searchLabel === void 0 ? defaults.searchLabel : _ref$searchLabel,
|
@@ -41,23 +42,13 @@ var TagOverflowModal = function TagOverflowModal(_ref) {
|
|
41
42
|
setSearch = _useState2[1];
|
42
43
|
var renderPortalUse = usePortalTarget(portalTargetIn);
|
43
44
|
var getFilteredItems = function getFilteredItems() {
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
}
|
49
|
-
var lCaseSearch = search.toLocaleLowerCase();
|
50
|
-
allTags.forEach(function (tag) {
|
51
|
-
var _tag$dataSearch, _tag$label;
|
52
|
-
var dataSearch = (_tag$dataSearch = tag['data-search']) === null || _tag$dataSearch === void 0 || (_tag$dataSearch = _tag$dataSearch.toLocaleLowerCase()) === null || _tag$dataSearch === void 0 ? void 0 : _tag$dataSearch.indexOf(lCaseSearch);
|
53
|
-
var labelSearch = (_tag$label = tag.label) === null || _tag$label === void 0 || (_tag$label = _tag$label.toLocaleLowerCase()) === null || _tag$label === void 0 ? void 0 : _tag$label.indexOf(lCaseSearch);
|
54
|
-
if (dataSearch > -1 || labelSearch > -1) {
|
55
|
-
newFilteredModalTags.push(tag);
|
56
|
-
}
|
57
|
-
});
|
58
|
-
}
|
45
|
+
if (open && search) {
|
46
|
+
return allTags.filter(function (tag) {
|
47
|
+
var _tag$label;
|
48
|
+
return (_tag$label = tag.label) === null || _tag$label === void 0 || (_tag$label = _tag$label.toLocaleLowerCase()) === null || _tag$label === void 0 ? void 0 : _tag$label.includes(search.toLocaleLowerCase());
|
49
|
+
});
|
59
50
|
}
|
60
|
-
return
|
51
|
+
return allTags;
|
61
52
|
};
|
62
53
|
var handleSearch = function handleSearch(evt) {
|
63
54
|
setSearch(evt.target.value || '');
|
@@ -86,10 +77,12 @@ var TagOverflowModal = function TagOverflowModal(_ref) {
|
|
86
77
|
}, getFilteredItems().map(function (_ref2) {
|
87
78
|
var label = _ref2.label,
|
88
79
|
id = _ref2.id,
|
80
|
+
filter = _ref2.filter,
|
89
81
|
other = _objectWithoutProperties(_ref2, _excluded2);
|
82
|
+
var isFilterable = overflowType === 'tag' ? filter : false;
|
90
83
|
return /*#__PURE__*/React__default.createElement(Tag, _extends({}, other, {
|
91
|
-
|
92
|
-
|
84
|
+
key: id,
|
85
|
+
filter: isFilterable
|
93
86
|
}), label);
|
94
87
|
})), /*#__PURE__*/React__default.createElement("div", {
|
95
88
|
className: "".concat(blockClass, "__fade")
|
@@ -102,6 +95,7 @@ TagOverflowModal.propTypes = {
|
|
102
95
|
className: PropTypes.string,
|
103
96
|
onClose: PropTypes.func,
|
104
97
|
open: PropTypes.bool,
|
98
|
+
overflowType: PropTypes.oneOf(['default', 'tag']),
|
105
99
|
portalTarget: PropTypes.node,
|
106
100
|
searchLabel: PropTypes.string,
|
107
101
|
searchPlaceholder: PropTypes.string,
|
@@ -13,7 +13,8 @@ import { Popover, Tag, PopoverContent, Link } from '@carbon/react';
|
|
13
13
|
import { pkg } from '../../settings.js';
|
14
14
|
import { useClickOutside } from '../../global/js/hooks/useClickOutside.js';
|
15
15
|
|
16
|
-
var _excluded = ["allTagsModalSearchThreshold", "className", "onShowAllClick", "overflowAlign", "overflowTags", "overflowType", "showAllTagsLabel", "popoverOpen", "setPopoverOpen"]
|
16
|
+
var _excluded = ["allTagsModalSearchThreshold", "className", "onShowAllClick", "overflowAlign", "overflowTags", "overflowType", "showAllTagsLabel", "popoverOpen", "setPopoverOpen"],
|
17
|
+
_excluded2 = ["label", "id", "tagType", "filter", "onClose"];
|
17
18
|
var componentName = 'TagOverflowPopover';
|
18
19
|
var blockClass = "".concat(pkg.prefix, "--tag-overflow-popover");
|
19
20
|
|
@@ -80,11 +81,25 @@ var TagOverflowPopover = /*#__PURE__*/React__default.forwardRef(function (_ref,
|
|
80
81
|
className: "".concat(blockClass, "__content")
|
81
82
|
}, /*#__PURE__*/React__default.createElement("ul", {
|
82
83
|
className: "".concat(blockClass, "__tag-list")
|
83
|
-
}, getOverflowPopoverItems().map(function (
|
84
|
+
}, getOverflowPopoverItems().map(function (_ref2) {
|
85
|
+
var label = _ref2.label,
|
86
|
+
id = _ref2.id,
|
87
|
+
tagType = _ref2.tagType,
|
88
|
+
filter = _ref2.filter,
|
89
|
+
_onClose = _ref2.onClose,
|
90
|
+
other = _objectWithoutProperties(_ref2, _excluded2);
|
91
|
+
var typeValue = overflowType === 'tag' ? 'high-contrast' : tagType;
|
92
|
+
var isFilterable = overflowType === 'tag' ? filter : false;
|
84
93
|
return /*#__PURE__*/React__default.createElement("li", {
|
85
94
|
className: cx("".concat(blockClass, "__tag-item"), _defineProperty(_defineProperty({}, "".concat(blockClass, "__tag-item--default"), overflowType === 'default'), "".concat(blockClass, "__tag-item--tag"), overflowType === 'tag')),
|
86
|
-
key:
|
87
|
-
}, tag.
|
95
|
+
key: id
|
96
|
+
}, overflowType === 'tag' ? /*#__PURE__*/React__default.createElement(Tag, _extends({}, other, {
|
97
|
+
onClose: function onClose() {
|
98
|
+
return _onClose === null || _onClose === void 0 ? void 0 : _onClose();
|
99
|
+
},
|
100
|
+
type: typeValue,
|
101
|
+
filter: isFilterable
|
102
|
+
}), label) : label);
|
88
103
|
})), overflowTags.length > allTagsModalSearchThreshold && /*#__PURE__*/React__default.createElement(Link, {
|
89
104
|
className: "".concat(blockClass, "__show-all-tags-link"),
|
90
105
|
href: "",
|
@@ -1,3 +1,121 @@
|
|
1
|
+
/**
|
2
|
+
* Copyright IBM Corp. 2020, 2023
|
3
|
+
*
|
4
|
+
* This source code is licensed under the Apache-2.0 license found in the
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
6
|
+
*/
|
7
|
+
/// <reference path="../../../src/custom-typings/index.d.ts" />
|
8
|
+
import React, { PropsWithChildren, ReactNode } from 'react';
|
9
|
+
import PropTypes from 'prop-types';
|
10
|
+
import { ButtonProps } from '@carbon/react';
|
11
|
+
/**
|
12
|
+
* The accessibility title for the close icon (if shown).
|
13
|
+
*
|
14
|
+
* **Note:** This prop is only required if a close icon is shown, i.e. if
|
15
|
+
* there are a no navigation actions and/or hasCloseIcon is true.
|
16
|
+
*/
|
17
|
+
export type CloseIconDescriptionTypes = {
|
18
|
+
hasCloseIcon?: false;
|
19
|
+
closeIconDescription?: string;
|
20
|
+
} | {
|
21
|
+
hasCloseIcon: true;
|
22
|
+
closeIconDescription: string;
|
23
|
+
};
|
24
|
+
interface TearsheetProps extends PropsWithChildren {
|
25
|
+
/**
|
26
|
+
* The navigation actions to be shown as buttons in the action area at the
|
27
|
+
* bottom of the tearsheet. Each action is specified as an object with
|
28
|
+
* optional fields: 'label' to supply the button label, 'kind' to select the
|
29
|
+
* button kind (must be 'primary', 'secondary' or 'ghost'), 'loading' to
|
30
|
+
* display a loading indicator, and 'onClick' to receive notifications when
|
31
|
+
* the button is clicked. Additional fields in the object will be passed to
|
32
|
+
* the Button component, and these can include 'disabled', 'ref', 'className',
|
33
|
+
* and any other Button props, except 'size'. Any other fields in the object will
|
34
|
+
* be passed through to the button element as HTML attributes.
|
35
|
+
*
|
36
|
+
* See https://react.carbondesignsystem.com/?path=/docs/components-button--default#component-api
|
37
|
+
*/
|
38
|
+
actions: ButtonProps[];
|
39
|
+
/**
|
40
|
+
* The aria-label for the tearsheet, which is optional.
|
41
|
+
* if it is not passed, the title will be used as the aria-label.
|
42
|
+
*/
|
43
|
+
ariaLabel?: string;
|
44
|
+
/**
|
45
|
+
* An optional class or classes to be added to the outermost element.
|
46
|
+
*/
|
47
|
+
className?: string;
|
48
|
+
/**
|
49
|
+
* A description of the flow, displayed in the header area of the tearsheet.
|
50
|
+
*/
|
51
|
+
description?: ReactNode;
|
52
|
+
/**
|
53
|
+
* Enable a close icon ('x') in the header area of the tearsheet. By default,
|
54
|
+
* (when this prop is omitted, or undefined or null) a tearsheet does not
|
55
|
+
* display a close icon if there are navigation actions ("transactional
|
56
|
+
* tearsheet") and displays one if there are no navigation actions ("passive
|
57
|
+
* tearsheet"), and that behavior can be overridden if required by setting
|
58
|
+
* this prop to either true or false.
|
59
|
+
*/
|
60
|
+
hasCloseIcon?: boolean;
|
61
|
+
/**
|
62
|
+
* The content for the influencer section of the tearsheet, displayed
|
63
|
+
* alongside the main content. This is typically a menu, or filter, or
|
64
|
+
* progress indicator, or similar.
|
65
|
+
*/
|
66
|
+
influencer?: ReactNode;
|
67
|
+
/**
|
68
|
+
* The position of the influencer section, 'left' or 'right'.
|
69
|
+
*/
|
70
|
+
influencerPosition?: 'left' | 'right';
|
71
|
+
/**
|
72
|
+
* The width of the influencer: 'narrow' (the default) is 256px, and 'wide'
|
73
|
+
* is 320px.
|
74
|
+
*/
|
75
|
+
influencerWidth?: 'narrow' | 'wide';
|
76
|
+
/**
|
77
|
+
* A label for the tearsheet, displayed in the header area of the tearsheet
|
78
|
+
* to maintain context for the tearsheet (e.g. as the title changes from page
|
79
|
+
* to page of a multi-page task).
|
80
|
+
*/
|
81
|
+
label?: ReactNode;
|
82
|
+
/**
|
83
|
+
* Navigation content, such as a set of tabs, to be displayed at the bottom
|
84
|
+
* of the header area of the tearsheet.
|
85
|
+
*/
|
86
|
+
navigation?: ReactNode;
|
87
|
+
/**
|
88
|
+
* An optional handler that is called when the user closes the tearsheet (by
|
89
|
+
* clicking the close button, if enabled, or clicking outside, if enabled).
|
90
|
+
* Returning `false` here prevents the modal from closing.
|
91
|
+
*/
|
92
|
+
onClose?: () => void;
|
93
|
+
/**
|
94
|
+
* Specifies whether the tearsheet is currently open.
|
95
|
+
*/
|
96
|
+
open?: boolean;
|
97
|
+
/**
|
98
|
+
* The DOM element that the tearsheet should be rendered within. Defaults to document.body.
|
99
|
+
*/
|
100
|
+
portalTarget: ReactNode;
|
101
|
+
/**
|
102
|
+
* Specify a CSS selector that matches the DOM element that should be focused when the Modal opens
|
103
|
+
*/
|
104
|
+
selectorPrimaryFocus?: string;
|
105
|
+
/**
|
106
|
+
* The main title of the tearsheet, displayed in the header area.
|
107
|
+
*/
|
108
|
+
title?: ReactNode;
|
109
|
+
/** @deprecated */
|
110
|
+
/**
|
111
|
+
* The position of the top of tearsheet in the viewport. The 'normal'
|
112
|
+
* position is a short distance down from the top of the
|
113
|
+
* viewport, leaving room at the top for a global header bar to show through
|
114
|
+
* from below. The 'lower' position (the default) provides a little extra room at the top
|
115
|
+
* to allow an action bar navigation or breadcrumbs to also show through.
|
116
|
+
*/
|
117
|
+
verticalPosition?: 'normal' | 'lower';
|
118
|
+
}
|
1
119
|
/**
|
2
120
|
* A tearsheet is a mostly full-screen type of dialog that keeps users
|
3
121
|
* in-context and focused by bringing actionable content front and center while
|
@@ -10,9 +128,17 @@
|
|
10
128
|
* panel on either the left or right side, the main content area, and a set of
|
11
129
|
* action buttons.
|
12
130
|
*/
|
13
|
-
export let Tearsheet: React.ForwardRefExoticComponent<React.RefAttributes<
|
14
|
-
export
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
131
|
+
export declare let Tearsheet: React.ForwardRefExoticComponent<(TearsheetProps & CloseIconDescriptionTypes) & React.RefAttributes<HTMLDivElement>>;
|
132
|
+
export declare const deprecatedProps: {
|
133
|
+
/**
|
134
|
+
* **Deprecated**
|
135
|
+
*
|
136
|
+
* The position of the top of tearsheet in the viewport. The 'normal'
|
137
|
+
* position is a short distance down from the top of the
|
138
|
+
* viewport, leaving room at the top for a global header bar to show through
|
139
|
+
* from below. The 'lower' position (the default) provides a little extra room at the top
|
140
|
+
* to allow an action bar navigation or breadcrumbs to also show through.
|
141
|
+
*/
|
142
|
+
verticalPosition: PropTypes.Requireable<string>;
|
143
|
+
};
|
144
|
+
export {};
|
@@ -15,17 +15,24 @@ import { Button } from '@carbon/react';
|
|
15
15
|
import { TearsheetShell, tearsheetHasCloseIcon, portalType } from './TearsheetShell.js';
|
16
16
|
import { ActionSet } from '../ActionSet/ActionSet.js';
|
17
17
|
|
18
|
-
var _excluded = ["influencerPosition", "influencerWidth"
|
18
|
+
var _excluded = ["influencerPosition", "influencerWidth"];
|
19
19
|
var componentName = 'Tearsheet';
|
20
20
|
|
21
21
|
// NOTE: the component SCSS is not imported here: it is rolled up separately.
|
22
22
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
23
|
+
/**
|
24
|
+
* The accessibility title for the close icon (if shown).
|
25
|
+
*
|
26
|
+
* **Note:** This prop is only required if a close icon is shown, i.e. if
|
27
|
+
* there are a no navigation actions and/or hasCloseIcon is true.
|
28
|
+
*/
|
29
|
+
|
30
|
+
// The types and DocGen commentary for the component props,
|
31
|
+
// in alphabetical order (for consistency).
|
32
|
+
// See https://www.npmjs.com/package/prop-types#usage.
|
33
|
+
|
34
|
+
// Note that the descriptions here should be kept in sync with those for the
|
35
|
+
// corresponding props for TearsheetNarrow and TearsheetShell components.
|
29
36
|
|
30
37
|
/**
|
31
38
|
* A tearsheet is a mostly full-screen type of dialog that keeps users
|
@@ -41,16 +48,13 @@ var defaults = {
|
|
41
48
|
*/
|
42
49
|
var Tearsheet = /*#__PURE__*/React__default.forwardRef(function (_ref, ref) {
|
43
50
|
var _ref$influencerPositi = _ref.influencerPosition,
|
44
|
-
influencerPosition = _ref$influencerPositi === void 0 ?
|
51
|
+
influencerPosition = _ref$influencerPositi === void 0 ? 'left' : _ref$influencerPositi,
|
45
52
|
_ref$influencerWidth = _ref.influencerWidth,
|
46
|
-
influencerWidth = _ref$influencerWidth === void 0 ?
|
47
|
-
_ref$verticalPosition = _ref.verticalPosition,
|
48
|
-
verticalPosition = _ref$verticalPosition === void 0 ? defaults.verticalPosition : _ref$verticalPosition,
|
53
|
+
influencerWidth = _ref$influencerWidth === void 0 ? 'narrow' : _ref$influencerWidth,
|
49
54
|
rest = _objectWithoutProperties(_ref, _excluded);
|
50
55
|
return /*#__PURE__*/React__default.createElement(TearsheetShell, _objectSpread2(_objectSpread2(_objectSpread2({}, getDevtoolsProps(componentName)), rest), {}, {
|
51
56
|
influencerPosition: influencerPosition,
|
52
57
|
influencerWidth: influencerWidth,
|
53
|
-
verticalPosition: verticalPosition,
|
54
58
|
ref: ref,
|
55
59
|
size: 'wide'
|
56
60
|
}));
|
@@ -95,7 +99,8 @@ Tearsheet.propTypes = _objectSpread2({
|
|
95
99
|
*
|
96
100
|
* See https://react.carbondesignsystem.com/?path=/docs/components-button--default#component-api
|
97
101
|
*/
|
98
|
-
actions: allPropTypes([
|
102
|
+
actions: allPropTypes([/**@ts-ignore */
|
103
|
+
ActionSet.validateActions(function () {
|
99
104
|
return '2xl';
|
100
105
|
}), PropTypes.arrayOf(PropTypes.shape(_objectSpread2(_objectSpread2({}, Button.propTypes), {}, {
|
101
106
|
kind: PropTypes.oneOf(['ghost', 'danger--ghost', 'secondary', 'danger', 'primary']),
|
@@ -119,6 +124,7 @@ Tearsheet.propTypes = _objectSpread2({
|
|
119
124
|
* **Note:** This prop is only required if a close icon is shown, i.e. if
|
120
125
|
* there are a no navigation actions and/or hasCloseIcon is true.
|
121
126
|
*/
|
127
|
+
/**@ts-ignore */
|
122
128
|
closeIconDescription: PropTypes.string.isRequired.if(function (_ref2) {
|
123
129
|
var actions = _ref2.actions,
|
124
130
|
hasCloseIcon = _ref2.hasCloseIcon;
|
@@ -136,6 +142,7 @@ Tearsheet.propTypes = _objectSpread2({
|
|
136
142
|
* tearsheet"), and that behavior can be overridden if required by setting
|
137
143
|
* this prop to either true or false.
|
138
144
|
*/
|
145
|
+
/**@ts-ignore */
|
139
146
|
hasCloseIcon: PropTypes.bool,
|
140
147
|
/**
|
141
148
|
* The content for the influencer section of the tearsheet, displayed
|
@@ -158,6 +165,10 @@ Tearsheet.propTypes = _objectSpread2({
|
|
158
165
|
* to page of a multi-page task).
|
159
166
|
*/
|
160
167
|
label: PropTypes.node,
|
168
|
+
/**
|
169
|
+
* Provide a ref to return focus to once the tearsheet is closed.
|
170
|
+
*/
|
171
|
+
launcherButtonRef: PropTypes.any,
|
161
172
|
/**
|
162
173
|
* Navigation content, such as a set of tabs, to be displayed at the bottom
|
163
174
|
* of the header area of the tearsheet.
|
@@ -176,6 +187,7 @@ Tearsheet.propTypes = _objectSpread2({
|
|
176
187
|
/**
|
177
188
|
* The DOM element that the tearsheet should be rendered within. Defaults to document.body.
|
178
189
|
*/
|
190
|
+
/**@ts-ignore */
|
179
191
|
portalTarget: portalType,
|
180
192
|
/**
|
181
193
|
* Specify a CSS selector that matches the DOM element that should be focused when the Modal opens
|
@@ -5,7 +5,7 @@
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
6
6
|
*/
|
7
7
|
/// <reference path="../../../src/custom-typings/index.d.ts" />
|
8
|
-
import React, { PropsWithChildren, ReactNode } from 'react';
|
8
|
+
import React, { PropsWithChildren, ReactNode, RefObject } from 'react';
|
9
9
|
import PropTypes from 'prop-types';
|
10
10
|
import { type ButtonProps } from '@carbon/react';
|
11
11
|
interface TearsheetShellProps extends PropsWithChildren {
|
@@ -57,6 +57,10 @@ interface TearsheetShellProps extends PropsWithChildren {
|
|
57
57
|
* to page of a multi-page task).
|
58
58
|
*/
|
59
59
|
label?: ReactNode;
|
60
|
+
/**
|
61
|
+
* Provide a ref to return focus to once the tearsheet is closed.
|
62
|
+
*/
|
63
|
+
launcherButtonRef?: RefObject<any>;
|
60
64
|
/**
|
61
65
|
* Navigation content, such as a set of tabs, to be displayed at the bottom
|
62
66
|
* of the header area of the tearsheet. NB the navigation is only applicable
|
@@ -17,9 +17,10 @@ import { Button, usePrefix, ComposedModal, ModalHeader, Layer } from '@carbon/re
|
|
17
17
|
import { Wrap } from '../../global/js/utils/Wrap.js';
|
18
18
|
import { usePortalTarget } from '../../global/js/hooks/usePortalTarget.js';
|
19
19
|
import { useFocus } from '../../global/js/hooks/useFocus.js';
|
20
|
+
import { usePreviousValue } from '../../global/js/hooks/usePreviousValue.js';
|
20
21
|
import { ActionSet } from '../ActionSet/ActionSet.js';
|
21
22
|
|
22
|
-
var _excluded = ["actions", "ariaLabel", "children", "className", "closeIconDescription", "description", "hasCloseIcon", "headerActions", "influencer", "influencerPosition", "influencerWidth", "label", "navigation", "onClose", "open", "portalTarget", "selectorPrimaryFocus", "size", "slug", "title", "verticalPosition"];
|
23
|
+
var _excluded = ["actions", "ariaLabel", "children", "className", "closeIconDescription", "description", "hasCloseIcon", "headerActions", "influencer", "influencerPosition", "influencerWidth", "label", "navigation", "onClose", "open", "portalTarget", "selectorPrimaryFocus", "size", "slug", "title", "verticalPosition", "launcherButtonRef"];
|
23
24
|
|
24
25
|
// The block part of our conventional BEM class names (bc__E--M).
|
25
26
|
var bc = "".concat(pkg.prefix, "--tearsheet");
|
@@ -82,6 +83,7 @@ var TearsheetShell = /*#__PURE__*/React__default.forwardRef(function (_ref, ref)
|
|
82
83
|
slug = _ref.slug,
|
83
84
|
title = _ref.title,
|
84
85
|
verticalPosition = _ref.verticalPosition,
|
86
|
+
launcherButtonRef = _ref.launcherButtonRef,
|
85
87
|
rest = _objectWithoutProperties(_ref, _excluded);
|
86
88
|
var carbonPrefix = usePrefix();
|
87
89
|
var bcModalHeader = "".concat(carbonPrefix, "--modal-header");
|
@@ -92,9 +94,11 @@ var TearsheetShell = /*#__PURE__*/React__default.forwardRef(function (_ref, ref)
|
|
92
94
|
var modalRef = ref || localRef;
|
93
95
|
var _useResizeObserver = useResizeObserver(resizer),
|
94
96
|
width = _useResizeObserver.width;
|
95
|
-
var
|
97
|
+
var prevOpen = usePreviousValue(open);
|
98
|
+
var _useFocus = useFocus(modalRef, selectorPrimaryFocus),
|
96
99
|
firstElement = _useFocus.firstElement,
|
97
|
-
keyDownListener = _useFocus.keyDownListener
|
100
|
+
keyDownListener = _useFocus.keyDownListener,
|
101
|
+
specifiedElement = _useFocus.specifiedElement;
|
98
102
|
var modalRefValue = modalRef.current;
|
99
103
|
var wide = size === 'wide';
|
100
104
|
|
@@ -133,17 +137,30 @@ var TearsheetShell = /*#__PURE__*/React__default.forwardRef(function (_ref, ref)
|
|
133
137
|
|
134
138
|
// Callback to give the tearsheet the opportunity to claim focus
|
135
139
|
handleStackChange.claimFocus = function () {
|
140
|
+
if (selectorPrimaryFocus) {
|
141
|
+
return specifiedElement === null || specifiedElement === void 0 ? void 0 : specifiedElement.focus();
|
142
|
+
}
|
136
143
|
firstElement === null || firstElement === void 0 || firstElement.focus();
|
137
144
|
};
|
138
145
|
useEffect(function () {
|
139
146
|
if (open) {
|
140
|
-
// Focusing the first element
|
147
|
+
// Focusing the first element or selectorPrimaryFocus element
|
141
148
|
setTimeout(function () {
|
149
|
+
if (selectorPrimaryFocus) {
|
150
|
+
return specifiedElement === null || specifiedElement === void 0 ? void 0 : specifiedElement.focus();
|
151
|
+
}
|
142
152
|
firstElement === null || firstElement === void 0 || firstElement.focus();
|
143
153
|
}, 0);
|
144
154
|
}
|
145
155
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
146
156
|
}, [open]);
|
157
|
+
useEffect(function () {
|
158
|
+
if (prevOpen && !open && launcherButtonRef) {
|
159
|
+
setTimeout(function () {
|
160
|
+
launcherButtonRef.current.focus();
|
161
|
+
}, 0);
|
162
|
+
}
|
163
|
+
}, [launcherButtonRef, open, prevOpen]);
|
147
164
|
useEffect(function () {
|
148
165
|
if (open && position !== depth) {
|
149
166
|
setTimeout(function () {
|
@@ -402,6 +419,11 @@ TearsheetShell.propTypes = _objectSpread2({
|
|
402
419
|
* to page of a multi-page task).
|
403
420
|
*/
|
404
421
|
label: PropTypes.node,
|
422
|
+
/**
|
423
|
+
* Provide a ref to return focus to once the tearsheet is closed.
|
424
|
+
*/
|
425
|
+
/**@ts-ignore */
|
426
|
+
launcherButtonRef: PropTypes.any,
|
405
427
|
/**
|
406
428
|
* Navigation content, such as a set of tabs, to be displayed at the bottom
|
407
429
|
* of the header area of the tearsheet. NB the navigation is only applicable
|
@@ -41,6 +41,10 @@ interface WebTerminalProps extends PropsWithChildren {
|
|
41
41
|
* Optionally pass if the web terminal should be open by default
|
42
42
|
*/
|
43
43
|
isInitiallyOpen?: boolean;
|
44
|
+
/**
|
45
|
+
* Specifies aria label for Web terminal
|
46
|
+
*/
|
47
|
+
webTerminalAriaLabel?: string;
|
44
48
|
}
|
45
49
|
/**
|
46
50
|
* The `WebTerminal` is prompted by the user and is persistent until dismissed. The purpose of a web terminal is to provide users with the ability to type commands manually instead of using the GUI.
|
@@ -16,7 +16,7 @@ import { moderate02 } from '@carbon/motion';
|
|
16
16
|
import { useWebTerminal } from './hooks/index.js';
|
17
17
|
import { getDevtoolsProps } from '../../global/js/utils/devtools.js';
|
18
18
|
|
19
|
-
var _excluded = ["actions", "children", "className", "closeIconDescription", "documentationLinks", "documentationLinksIconDescription", "isInitiallyOpen"];
|
19
|
+
var _excluded = ["actions", "children", "className", "closeIconDescription", "documentationLinks", "documentationLinksIconDescription", "isInitiallyOpen", "webTerminalAriaLabel"];
|
20
20
|
|
21
21
|
// The block part of our conventional BEM class names (blockClass__E--M).
|
22
22
|
var componentName = 'WebTerminal';
|
@@ -27,7 +27,8 @@ var defaults = {
|
|
27
27
|
actions: Object.freeze([]),
|
28
28
|
documentationLinks: Object.freeze([]),
|
29
29
|
documentationLinksIconDescription: 'Show documentation links',
|
30
|
-
isInitiallyOpen: false
|
30
|
+
isInitiallyOpen: false,
|
31
|
+
webTerminalAriaLabel: 'Web terminal header'
|
31
32
|
};
|
32
33
|
/**
|
33
34
|
* The `WebTerminal` is prompted by the user and is persistent until dismissed. The purpose of a web terminal is to provide users with the ability to type commands manually instead of using the GUI.
|
@@ -44,6 +45,8 @@ var WebTerminal = /*#__PURE__*/React__default.forwardRef(function (_ref, ref) {
|
|
44
45
|
documentationLinksIconDescription = _ref$documentationLin2 === void 0 ? defaults.documentationLinksIconDescription : _ref$documentationLin2,
|
45
46
|
_ref$isInitiallyOpen = _ref.isInitiallyOpen,
|
46
47
|
isInitiallyOpen = _ref$isInitiallyOpen === void 0 ? defaults.isInitiallyOpen : _ref$isInitiallyOpen,
|
48
|
+
_ref$webTerminalAriaL = _ref.webTerminalAriaLabel,
|
49
|
+
webTerminalAriaLabel = _ref$webTerminalAriaL === void 0 ? defaults.webTerminalAriaLabel : _ref$webTerminalAriaL,
|
47
50
|
rest = _objectWithoutProperties(_ref, _excluded);
|
48
51
|
var _useWebTerminal = useWebTerminal(),
|
49
52
|
open = _useWebTerminal.open,
|
@@ -102,6 +105,7 @@ var WebTerminal = /*#__PURE__*/React__default.forwardRef(function (_ref, ref) {
|
|
102
105
|
},
|
103
106
|
onAnimationEnd: onAnimationEnd
|
104
107
|
}), /*#__PURE__*/React__default.createElement("header", {
|
108
|
+
"aria-label": webTerminalAriaLabel,
|
105
109
|
className: "".concat(blockClass, "__bar")
|
106
110
|
}, /*#__PURE__*/React__default.createElement("div", {
|
107
111
|
className: "".concat(blockClass, "__actions")
|
@@ -196,7 +200,11 @@ WebTerminal.propTypes = {
|
|
196
200
|
/**
|
197
201
|
* Optionally pass if the web terminal should be open by default
|
198
202
|
*/
|
199
|
-
isInitiallyOpen: PropTypes.bool
|
203
|
+
isInitiallyOpen: PropTypes.bool,
|
204
|
+
/**
|
205
|
+
* Specifies aria label for Web terminal
|
206
|
+
*/
|
207
|
+
webTerminalAriaLabel: PropTypes.string
|
200
208
|
};
|
201
209
|
|
202
210
|
export { WebTerminal };
|
@@ -1,11 +1,13 @@
|
|
1
|
-
export function useFocus(modalRef: any): {
|
1
|
+
export function useFocus(modalRef: any, selectorPrimaryFocus: any): {
|
2
2
|
firstElement: any;
|
3
3
|
lastElement: any;
|
4
4
|
allElements: any;
|
5
|
+
specifiedElement: any;
|
5
6
|
keyDownListener: (event: any) => void;
|
6
7
|
getFocusable: () => {
|
7
8
|
first: any;
|
8
9
|
last: any;
|
9
10
|
all: any;
|
11
|
+
specifiedElement: any;
|
10
12
|
};
|
11
13
|
};
|