@carbon/ibm-products 2.39.0 → 2.40.1-canary.6
Sign up to get free protection for your applications and to get access to all the features.
- package/css/index-full-carbon.css +45 -37
- 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 +5 -0
- package/css/index-without-carbon-released-only.css.map +1 -1
- package/css/index-without-carbon-released-only.min.css +1 -1
- package/css/index-without-carbon-released-only.min.css.map +1 -1
- package/css/index-without-carbon.css +45 -37
- 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 +708 -37
- 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/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 +98 -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/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 +98 -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/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
@@ -28,13 +28,13 @@ var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
28
28
|
var cx__default = /*#__PURE__*/_interopDefaultLegacy(cx);
|
29
29
|
|
30
30
|
var _excluded = ["items", "tagComponent", "align", "showAllTagsLabel", "allTagsModalSearchLabel", "allTagsModalSearchPlaceholderText", "allTagsModalTarget", "allTagsModalTitle", "className", "containingElementRef", "measurementOffset", "maxVisible", "multiline", "overflowAlign", "overflowClassName", "overflowType", "onOverflowTagChange"],
|
31
|
-
_excluded2 = ["className", "id"]
|
31
|
+
_excluded2 = ["className", "id"],
|
32
|
+
_excluded3 = ["tagType"],
|
33
|
+
_excluded4 = ["id", "label", "tagType", "onClose"];
|
32
34
|
var blockClass = "".concat(settings.pkg.prefix, "--tag-overflow");
|
33
35
|
var componentName = 'TagOverflow';
|
34
36
|
var allTagsModalSearchThreshold = 10;
|
35
37
|
|
36
|
-
// TODO: support prop overflowType
|
37
|
-
|
38
38
|
// Default values for props
|
39
39
|
var defaults = {
|
40
40
|
items: [],
|
@@ -173,39 +173,53 @@ exports.TagOverflow = /*#__PURE__*/React__default["default"].forwardRef(function
|
|
173
173
|
visibleItemsArr = (_visibleItemsArr = visibleItemsArr) === null || _visibleItemsArr === void 0 ? void 0 : _visibleItemsArr.slice(0, maxVisible);
|
174
174
|
}
|
175
175
|
var hiddenItems = items === null || items === void 0 ? void 0 : items.slice(visibleItemsArr.length);
|
176
|
-
var overflowItemsArr = hiddenItems === null || hiddenItems === void 0 ? void 0 : hiddenItems.map(function (
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
};
|
176
|
+
var overflowItemsArr = hiddenItems === null || hiddenItems === void 0 ? void 0 : hiddenItems.map(function (_ref2) {
|
177
|
+
var tagType = _ref2.tagType,
|
178
|
+
other = _rollupPluginBabelHelpers.objectWithoutProperties(_ref2, _excluded3);
|
179
|
+
return _rollupPluginBabelHelpers.objectSpread2({
|
180
|
+
type: tagType
|
181
|
+
}, other);
|
182
182
|
});
|
183
183
|
setVisibleItems(visibleItemsArr);
|
184
184
|
setOverflowItems(overflowItemsArr);
|
185
185
|
onOverflowTagChange === null || onOverflowTagChange === void 0 || onOverflowTagChange(overflowItemsArr);
|
186
186
|
}, [containerWidth, items, maxVisible, getVisibleItems, onOverflowTagChange]);
|
187
|
+
var handleTagOnClose = React.useCallback(function (onClose, index) {
|
188
|
+
onClose === null || onClose === void 0 || onClose();
|
189
|
+
if (index <= visibleItems.length - 1) {
|
190
|
+
setPopoverOpen(false);
|
191
|
+
}
|
192
|
+
}, [visibleItems]);
|
187
193
|
return /*#__PURE__*/React__default["default"].createElement("div", _rollupPluginBabelHelpers["extends"]({}, rest, {
|
188
194
|
className: cx__default["default"](blockClass, className, "".concat(blockClass, "--align-").concat(align), _rollupPluginBabelHelpers.defineProperty({}, "".concat(blockClass, "--multiline"), multiline)),
|
189
195
|
ref: containerRef,
|
190
196
|
role: "main"
|
191
|
-
}, devtools.getDevtoolsProps(componentName)), visibleItems.length > 0 && visibleItems.map(function (item) {
|
197
|
+
}, devtools.getDevtoolsProps(componentName)), visibleItems.length > 0 && visibleItems.map(function (item, index) {
|
192
198
|
// Render custom components
|
193
199
|
if (tagComponent) {
|
194
200
|
return getCustomComponent(item);
|
195
201
|
} else {
|
202
|
+
var id = item.id,
|
203
|
+
label = item.label,
|
204
|
+
tagType = item.tagType,
|
205
|
+
_onClose = item.onClose,
|
206
|
+
other = _rollupPluginBabelHelpers.objectWithoutProperties(item, _excluded4);
|
196
207
|
// If there is no template prop, then render items as Tags
|
197
208
|
return /*#__PURE__*/React__default["default"].createElement("div", {
|
198
209
|
ref: function ref(node) {
|
199
|
-
return itemRefHandler(
|
210
|
+
return itemRefHandler(id, node);
|
200
211
|
},
|
201
|
-
key:
|
212
|
+
key: id
|
202
213
|
}, /*#__PURE__*/React__default["default"].createElement(react.Tooltip, {
|
203
|
-
align:
|
204
|
-
label:
|
205
|
-
}, /*#__PURE__*/React__default["default"].createElement(react.Tag, {
|
214
|
+
align: overflowAlign,
|
215
|
+
label: label
|
216
|
+
}, /*#__PURE__*/React__default["default"].createElement(react.Tag, _rollupPluginBabelHelpers["extends"]({}, other, {
|
206
217
|
className: "".concat(blockClass, "__item--tag"),
|
207
|
-
type:
|
208
|
-
|
218
|
+
type: tagType,
|
219
|
+
onClose: function onClose() {
|
220
|
+
return handleTagOnClose(_onClose, index);
|
221
|
+
}
|
222
|
+
}), label)));
|
209
223
|
}
|
210
224
|
}), /*#__PURE__*/React__default["default"].createElement("span", {
|
211
225
|
className: "".concat(blockClass, "__indicator"),
|
@@ -227,6 +241,7 @@ exports.TagOverflow = /*#__PURE__*/React__default["default"].forwardRef(function
|
|
227
241
|
open: showAllModalOpen,
|
228
242
|
title: allTagsModalTitle,
|
229
243
|
onClose: handleModalClose,
|
244
|
+
overflowType: overflowType,
|
230
245
|
searchLabel: allTagsModalSearchLabel,
|
231
246
|
searchPlaceholder: allTagsModalSearchPlaceholderText,
|
232
247
|
portalTarget: allTagsModalTarget
|
@@ -245,8 +260,8 @@ var tagTypes = Object.keys(constants.TYPES);
|
|
245
260
|
* The strings shown in the showAllModal are only shown if we have more than allTagsModalSearchLThreshold
|
246
261
|
* @returns null if no problems
|
247
262
|
*/
|
248
|
-
var string_required_if_more_than_10_tags = propsHelper.isRequiredIf(index["default"].string, function (
|
249
|
-
var items =
|
263
|
+
var string_required_if_more_than_10_tags = propsHelper.isRequiredIf(index["default"].string, function (_ref3) {
|
264
|
+
var items = _ref3.items;
|
250
265
|
return items && items.length > allTagsModalSearchThreshold;
|
251
266
|
});
|
252
267
|
|
@@ -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>;
|
@@ -23,8 +23,8 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'defau
|
|
23
23
|
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
24
24
|
var cx__default = /*#__PURE__*/_interopDefaultLegacy(cx);
|
25
25
|
|
26
|
-
var _excluded = ["allTags", "className", "title", "onClose", "open", "portalTarget", "searchLabel", "searchPlaceholder"],
|
27
|
-
_excluded2 = ["label", "id"];
|
26
|
+
var _excluded = ["allTags", "className", "title", "onClose", "open", "overflowType", "portalTarget", "searchLabel", "searchPlaceholder"],
|
27
|
+
_excluded2 = ["label", "id", "filter"];
|
28
28
|
var componentName = 'TagOverflowModal';
|
29
29
|
var blockClass = "".concat(settings.pkg.prefix, "--tag-overflow-modal");
|
30
30
|
|
@@ -39,6 +39,7 @@ var TagOverflowModal = function TagOverflowModal(_ref) {
|
|
39
39
|
title = _ref.title,
|
40
40
|
onClose = _ref.onClose,
|
41
41
|
open = _ref.open,
|
42
|
+
overflowType = _ref.overflowType,
|
42
43
|
portalTargetIn = _ref.portalTarget,
|
43
44
|
_ref$searchLabel = _ref.searchLabel,
|
44
45
|
searchLabel = _ref$searchLabel === void 0 ? defaults.searchLabel : _ref$searchLabel,
|
@@ -50,23 +51,13 @@ var TagOverflowModal = function TagOverflowModal(_ref) {
|
|
50
51
|
setSearch = _useState2[1];
|
51
52
|
var renderPortalUse = usePortalTarget.usePortalTarget(portalTargetIn);
|
52
53
|
var getFilteredItems = function getFilteredItems() {
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
}
|
58
|
-
var lCaseSearch = search.toLocaleLowerCase();
|
59
|
-
allTags.forEach(function (tag) {
|
60
|
-
var _tag$dataSearch, _tag$label;
|
61
|
-
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);
|
62
|
-
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);
|
63
|
-
if (dataSearch > -1 || labelSearch > -1) {
|
64
|
-
newFilteredModalTags.push(tag);
|
65
|
-
}
|
66
|
-
});
|
67
|
-
}
|
54
|
+
if (open && search) {
|
55
|
+
return allTags.filter(function (tag) {
|
56
|
+
var _tag$label;
|
57
|
+
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());
|
58
|
+
});
|
68
59
|
}
|
69
|
-
return
|
60
|
+
return allTags;
|
70
61
|
};
|
71
62
|
var handleSearch = function handleSearch(evt) {
|
72
63
|
setSearch(evt.target.value || '');
|
@@ -95,10 +86,12 @@ var TagOverflowModal = function TagOverflowModal(_ref) {
|
|
95
86
|
}, getFilteredItems().map(function (_ref2) {
|
96
87
|
var label = _ref2.label,
|
97
88
|
id = _ref2.id,
|
89
|
+
filter = _ref2.filter,
|
98
90
|
other = _rollupPluginBabelHelpers.objectWithoutProperties(_ref2, _excluded2);
|
91
|
+
var isFilterable = overflowType === 'tag' ? filter : false;
|
99
92
|
return /*#__PURE__*/React__default["default"].createElement(react.Tag, _rollupPluginBabelHelpers["extends"]({}, other, {
|
100
|
-
|
101
|
-
|
93
|
+
key: id,
|
94
|
+
filter: isFilterable
|
102
95
|
}), label);
|
103
96
|
})), /*#__PURE__*/React__default["default"].createElement("div", {
|
104
97
|
className: "".concat(blockClass, "__fade")
|
@@ -111,6 +104,7 @@ TagOverflowModal.propTypes = {
|
|
111
104
|
className: index["default"].string,
|
112
105
|
onClose: index["default"].func,
|
113
106
|
open: index["default"].bool,
|
107
|
+
overflowType: index["default"].oneOf(['default', 'tag']),
|
114
108
|
portalTarget: index["default"].node,
|
115
109
|
searchLabel: index["default"].string,
|
116
110
|
searchPlaceholder: index["default"].string,
|
@@ -22,7 +22,8 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'defau
|
|
22
22
|
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
23
23
|
var cx__default = /*#__PURE__*/_interopDefaultLegacy(cx);
|
24
24
|
|
25
|
-
var _excluded = ["allTagsModalSearchThreshold", "className", "onShowAllClick", "overflowAlign", "overflowTags", "overflowType", "showAllTagsLabel", "popoverOpen", "setPopoverOpen"]
|
25
|
+
var _excluded = ["allTagsModalSearchThreshold", "className", "onShowAllClick", "overflowAlign", "overflowTags", "overflowType", "showAllTagsLabel", "popoverOpen", "setPopoverOpen"],
|
26
|
+
_excluded2 = ["label", "id", "tagType", "filter", "onClose"];
|
26
27
|
var componentName = 'TagOverflowPopover';
|
27
28
|
var blockClass = "".concat(settings.pkg.prefix, "--tag-overflow-popover");
|
28
29
|
|
@@ -89,11 +90,25 @@ var TagOverflowPopover = /*#__PURE__*/React__default["default"].forwardRef(funct
|
|
89
90
|
className: "".concat(blockClass, "__content")
|
90
91
|
}, /*#__PURE__*/React__default["default"].createElement("ul", {
|
91
92
|
className: "".concat(blockClass, "__tag-list")
|
92
|
-
}, getOverflowPopoverItems().map(function (
|
93
|
+
}, getOverflowPopoverItems().map(function (_ref2) {
|
94
|
+
var label = _ref2.label,
|
95
|
+
id = _ref2.id,
|
96
|
+
tagType = _ref2.tagType,
|
97
|
+
filter = _ref2.filter,
|
98
|
+
_onClose = _ref2.onClose,
|
99
|
+
other = _rollupPluginBabelHelpers.objectWithoutProperties(_ref2, _excluded2);
|
100
|
+
var typeValue = overflowType === 'tag' ? 'high-contrast' : tagType;
|
101
|
+
var isFilterable = overflowType === 'tag' ? filter : false;
|
93
102
|
return /*#__PURE__*/React__default["default"].createElement("li", {
|
94
103
|
className: cx__default["default"]("".concat(blockClass, "__tag-item"), _rollupPluginBabelHelpers.defineProperty(_rollupPluginBabelHelpers.defineProperty({}, "".concat(blockClass, "__tag-item--default"), overflowType === 'default'), "".concat(blockClass, "__tag-item--tag"), overflowType === 'tag')),
|
95
|
-
key:
|
96
|
-
}, tag.
|
104
|
+
key: id
|
105
|
+
}, overflowType === 'tag' ? /*#__PURE__*/React__default["default"].createElement(react.Tag, _rollupPluginBabelHelpers["extends"]({}, other, {
|
106
|
+
onClose: function onClose() {
|
107
|
+
return _onClose === null || _onClose === void 0 ? void 0 : _onClose();
|
108
|
+
},
|
109
|
+
type: typeValue,
|
110
|
+
filter: isFilterable
|
111
|
+
}), label) : label);
|
97
112
|
})), overflowTags.length > allTagsModalSearchThreshold && /*#__PURE__*/React__default["default"].createElement(react.Link, {
|
98
113
|
className: "".concat(blockClass, "__show-all-tags-link"),
|
99
114
|
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 {};
|
@@ -23,17 +23,24 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'defau
|
|
23
23
|
|
24
24
|
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
25
25
|
|
26
|
-
var _excluded = ["influencerPosition", "influencerWidth"
|
26
|
+
var _excluded = ["influencerPosition", "influencerWidth"];
|
27
27
|
var componentName = 'Tearsheet';
|
28
28
|
|
29
29
|
// NOTE: the component SCSS is not imported here: it is rolled up separately.
|
30
30
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
31
|
+
/**
|
32
|
+
* The accessibility title for the close icon (if shown).
|
33
|
+
*
|
34
|
+
* **Note:** This prop is only required if a close icon is shown, i.e. if
|
35
|
+
* there are a no navigation actions and/or hasCloseIcon is true.
|
36
|
+
*/
|
37
|
+
|
38
|
+
// The types and DocGen commentary for the component props,
|
39
|
+
// in alphabetical order (for consistency).
|
40
|
+
// See https://www.npmjs.com/package/prop-types#usage.
|
41
|
+
|
42
|
+
// Note that the descriptions here should be kept in sync with those for the
|
43
|
+
// corresponding props for TearsheetNarrow and TearsheetShell components.
|
37
44
|
|
38
45
|
/**
|
39
46
|
* A tearsheet is a mostly full-screen type of dialog that keeps users
|
@@ -49,16 +56,13 @@ var defaults = {
|
|
49
56
|
*/
|
50
57
|
exports.Tearsheet = /*#__PURE__*/React__default["default"].forwardRef(function (_ref, ref) {
|
51
58
|
var _ref$influencerPositi = _ref.influencerPosition,
|
52
|
-
influencerPosition = _ref$influencerPositi === void 0 ?
|
59
|
+
influencerPosition = _ref$influencerPositi === void 0 ? 'left' : _ref$influencerPositi,
|
53
60
|
_ref$influencerWidth = _ref.influencerWidth,
|
54
|
-
influencerWidth = _ref$influencerWidth === void 0 ?
|
55
|
-
_ref$verticalPosition = _ref.verticalPosition,
|
56
|
-
verticalPosition = _ref$verticalPosition === void 0 ? defaults.verticalPosition : _ref$verticalPosition,
|
61
|
+
influencerWidth = _ref$influencerWidth === void 0 ? 'narrow' : _ref$influencerWidth,
|
57
62
|
rest = _rollupPluginBabelHelpers.objectWithoutProperties(_ref, _excluded);
|
58
63
|
return /*#__PURE__*/React__default["default"].createElement(TearsheetShell.TearsheetShell, _rollupPluginBabelHelpers.objectSpread2(_rollupPluginBabelHelpers.objectSpread2(_rollupPluginBabelHelpers.objectSpread2({}, devtools.getDevtoolsProps(componentName)), rest), {}, {
|
59
64
|
influencerPosition: influencerPosition,
|
60
65
|
influencerWidth: influencerWidth,
|
61
|
-
verticalPosition: verticalPosition,
|
62
66
|
ref: ref,
|
63
67
|
size: 'wide'
|
64
68
|
}));
|
@@ -103,7 +107,8 @@ exports.Tearsheet.propTypes = _rollupPluginBabelHelpers.objectSpread2({
|
|
103
107
|
*
|
104
108
|
* See https://react.carbondesignsystem.com/?path=/docs/components-button--default#component-api
|
105
109
|
*/
|
106
|
-
actions: propsHelper.allPropTypes([
|
110
|
+
actions: propsHelper.allPropTypes([/**@ts-ignore */
|
111
|
+
ActionSet.ActionSet.validateActions(function () {
|
107
112
|
return '2xl';
|
108
113
|
}), index["default"].arrayOf(index["default"].shape(_rollupPluginBabelHelpers.objectSpread2(_rollupPluginBabelHelpers.objectSpread2({}, react.Button.propTypes), {}, {
|
109
114
|
kind: index["default"].oneOf(['ghost', 'danger--ghost', 'secondary', 'danger', 'primary']),
|
@@ -127,6 +132,7 @@ exports.Tearsheet.propTypes = _rollupPluginBabelHelpers.objectSpread2({
|
|
127
132
|
* **Note:** This prop is only required if a close icon is shown, i.e. if
|
128
133
|
* there are a no navigation actions and/or hasCloseIcon is true.
|
129
134
|
*/
|
135
|
+
/**@ts-ignore */
|
130
136
|
closeIconDescription: index["default"].string.isRequired.if(function (_ref2) {
|
131
137
|
var actions = _ref2.actions,
|
132
138
|
hasCloseIcon = _ref2.hasCloseIcon;
|
@@ -144,6 +150,7 @@ exports.Tearsheet.propTypes = _rollupPluginBabelHelpers.objectSpread2({
|
|
144
150
|
* tearsheet"), and that behavior can be overridden if required by setting
|
145
151
|
* this prop to either true or false.
|
146
152
|
*/
|
153
|
+
/**@ts-ignore */
|
147
154
|
hasCloseIcon: index["default"].bool,
|
148
155
|
/**
|
149
156
|
* The content for the influencer section of the tearsheet, displayed
|
@@ -166,6 +173,10 @@ exports.Tearsheet.propTypes = _rollupPluginBabelHelpers.objectSpread2({
|
|
166
173
|
* to page of a multi-page task).
|
167
174
|
*/
|
168
175
|
label: index["default"].node,
|
176
|
+
/**
|
177
|
+
* Provide a ref to return focus to once the tearsheet is closed.
|
178
|
+
*/
|
179
|
+
launcherButtonRef: index["default"].any,
|
169
180
|
/**
|
170
181
|
* Navigation content, such as a set of tabs, to be displayed at the bottom
|
171
182
|
* of the header area of the tearsheet.
|
@@ -184,6 +195,7 @@ exports.Tearsheet.propTypes = _rollupPluginBabelHelpers.objectSpread2({
|
|
184
195
|
/**
|
185
196
|
* The DOM element that the tearsheet should be rendered within. Defaults to document.body.
|
186
197
|
*/
|
198
|
+
/**@ts-ignore */
|
187
199
|
portalTarget: TearsheetShell.portalType,
|
188
200
|
/**
|
189
201
|
* 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
|
@@ -21,6 +21,7 @@ var react = require('@carbon/react');
|
|
21
21
|
var Wrap = require('../../global/js/utils/Wrap.js');
|
22
22
|
var usePortalTarget = require('../../global/js/hooks/usePortalTarget.js');
|
23
23
|
var useFocus = require('../../global/js/hooks/useFocus.js');
|
24
|
+
var usePreviousValue = require('../../global/js/hooks/usePreviousValue.js');
|
24
25
|
var ActionSet = require('../ActionSet/ActionSet.js');
|
25
26
|
|
26
27
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
@@ -28,7 +29,7 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'defau
|
|
28
29
|
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
29
30
|
var cx__default = /*#__PURE__*/_interopDefaultLegacy(cx);
|
30
31
|
|
31
|
-
var _excluded = ["actions", "ariaLabel", "children", "className", "closeIconDescription", "description", "hasCloseIcon", "headerActions", "influencer", "influencerPosition", "influencerWidth", "label", "navigation", "onClose", "open", "portalTarget", "selectorPrimaryFocus", "size", "slug", "title", "verticalPosition"];
|
32
|
+
var _excluded = ["actions", "ariaLabel", "children", "className", "closeIconDescription", "description", "hasCloseIcon", "headerActions", "influencer", "influencerPosition", "influencerWidth", "label", "navigation", "onClose", "open", "portalTarget", "selectorPrimaryFocus", "size", "slug", "title", "verticalPosition", "launcherButtonRef"];
|
32
33
|
|
33
34
|
// The block part of our conventional BEM class names (bc__E--M).
|
34
35
|
var bc = "".concat(settings.pkg.prefix, "--tearsheet");
|
@@ -91,6 +92,7 @@ var TearsheetShell = /*#__PURE__*/React__default["default"].forwardRef(function
|
|
91
92
|
slug = _ref.slug,
|
92
93
|
title = _ref.title,
|
93
94
|
verticalPosition = _ref.verticalPosition,
|
95
|
+
launcherButtonRef = _ref.launcherButtonRef,
|
94
96
|
rest = _rollupPluginBabelHelpers.objectWithoutProperties(_ref, _excluded);
|
95
97
|
var carbonPrefix = react.usePrefix();
|
96
98
|
var bcModalHeader = "".concat(carbonPrefix, "--modal-header");
|
@@ -101,9 +103,11 @@ var TearsheetShell = /*#__PURE__*/React__default["default"].forwardRef(function
|
|
101
103
|
var modalRef = ref || localRef;
|
102
104
|
var _useResizeObserver = useResizeObserver.useResizeObserver(resizer),
|
103
105
|
width = _useResizeObserver.width;
|
104
|
-
var
|
106
|
+
var prevOpen = usePreviousValue.usePreviousValue(open);
|
107
|
+
var _useFocus = useFocus.useFocus(modalRef, selectorPrimaryFocus),
|
105
108
|
firstElement = _useFocus.firstElement,
|
106
|
-
keyDownListener = _useFocus.keyDownListener
|
109
|
+
keyDownListener = _useFocus.keyDownListener,
|
110
|
+
specifiedElement = _useFocus.specifiedElement;
|
107
111
|
var modalRefValue = modalRef.current;
|
108
112
|
var wide = size === 'wide';
|
109
113
|
|
@@ -142,17 +146,30 @@ var TearsheetShell = /*#__PURE__*/React__default["default"].forwardRef(function
|
|
142
146
|
|
143
147
|
// Callback to give the tearsheet the opportunity to claim focus
|
144
148
|
handleStackChange.claimFocus = function () {
|
149
|
+
if (selectorPrimaryFocus) {
|
150
|
+
return specifiedElement === null || specifiedElement === void 0 ? void 0 : specifiedElement.focus();
|
151
|
+
}
|
145
152
|
firstElement === null || firstElement === void 0 || firstElement.focus();
|
146
153
|
};
|
147
154
|
React.useEffect(function () {
|
148
155
|
if (open) {
|
149
|
-
// Focusing the first element
|
156
|
+
// Focusing the first element or selectorPrimaryFocus element
|
150
157
|
setTimeout(function () {
|
158
|
+
if (selectorPrimaryFocus) {
|
159
|
+
return specifiedElement === null || specifiedElement === void 0 ? void 0 : specifiedElement.focus();
|
160
|
+
}
|
151
161
|
firstElement === null || firstElement === void 0 || firstElement.focus();
|
152
162
|
}, 0);
|
153
163
|
}
|
154
164
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
155
165
|
}, [open]);
|
166
|
+
React.useEffect(function () {
|
167
|
+
if (prevOpen && !open && launcherButtonRef) {
|
168
|
+
setTimeout(function () {
|
169
|
+
launcherButtonRef.current.focus();
|
170
|
+
}, 0);
|
171
|
+
}
|
172
|
+
}, [launcherButtonRef, open, prevOpen]);
|
156
173
|
React.useEffect(function () {
|
157
174
|
if (open && position !== depth) {
|
158
175
|
setTimeout(function () {
|
@@ -411,6 +428,11 @@ TearsheetShell.propTypes = _rollupPluginBabelHelpers.objectSpread2({
|
|
411
428
|
* to page of a multi-page task).
|
412
429
|
*/
|
413
430
|
label: index["default"].node,
|
431
|
+
/**
|
432
|
+
* Provide a ref to return focus to once the tearsheet is closed.
|
433
|
+
*/
|
434
|
+
/**@ts-ignore */
|
435
|
+
launcherButtonRef: index["default"].any,
|
414
436
|
/**
|
415
437
|
* Navigation content, such as a set of tabs, to be displayed at the bottom
|
416
438
|
* 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.
|
@@ -25,7 +25,7 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'defau
|
|
25
25
|
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
26
26
|
var cx__default = /*#__PURE__*/_interopDefaultLegacy(cx);
|
27
27
|
|
28
|
-
var _excluded = ["actions", "children", "className", "closeIconDescription", "documentationLinks", "documentationLinksIconDescription", "isInitiallyOpen"];
|
28
|
+
var _excluded = ["actions", "children", "className", "closeIconDescription", "documentationLinks", "documentationLinksIconDescription", "isInitiallyOpen", "webTerminalAriaLabel"];
|
29
29
|
|
30
30
|
// The block part of our conventional BEM class names (blockClass__E--M).
|
31
31
|
var componentName = 'WebTerminal';
|
@@ -36,7 +36,8 @@ var defaults = {
|
|
36
36
|
actions: Object.freeze([]),
|
37
37
|
documentationLinks: Object.freeze([]),
|
38
38
|
documentationLinksIconDescription: 'Show documentation links',
|
39
|
-
isInitiallyOpen: false
|
39
|
+
isInitiallyOpen: false,
|
40
|
+
webTerminalAriaLabel: 'Web terminal header'
|
40
41
|
};
|
41
42
|
/**
|
42
43
|
* 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.
|
@@ -53,6 +54,8 @@ exports.WebTerminal = /*#__PURE__*/React__default["default"].forwardRef(function
|
|
53
54
|
documentationLinksIconDescription = _ref$documentationLin2 === void 0 ? defaults.documentationLinksIconDescription : _ref$documentationLin2,
|
54
55
|
_ref$isInitiallyOpen = _ref.isInitiallyOpen,
|
55
56
|
isInitiallyOpen = _ref$isInitiallyOpen === void 0 ? defaults.isInitiallyOpen : _ref$isInitiallyOpen,
|
57
|
+
_ref$webTerminalAriaL = _ref.webTerminalAriaLabel,
|
58
|
+
webTerminalAriaLabel = _ref$webTerminalAriaL === void 0 ? defaults.webTerminalAriaLabel : _ref$webTerminalAriaL,
|
56
59
|
rest = _rollupPluginBabelHelpers.objectWithoutProperties(_ref, _excluded);
|
57
60
|
var _useWebTerminal = index.useWebTerminal(),
|
58
61
|
open = _useWebTerminal.open,
|
@@ -111,6 +114,7 @@ exports.WebTerminal = /*#__PURE__*/React__default["default"].forwardRef(function
|
|
111
114
|
},
|
112
115
|
onAnimationEnd: onAnimationEnd
|
113
116
|
}), /*#__PURE__*/React__default["default"].createElement("header", {
|
117
|
+
"aria-label": webTerminalAriaLabel,
|
114
118
|
className: "".concat(blockClass, "__bar")
|
115
119
|
}, /*#__PURE__*/React__default["default"].createElement("div", {
|
116
120
|
className: "".concat(blockClass, "__actions")
|
@@ -205,5 +209,9 @@ exports.WebTerminal.propTypes = {
|
|
205
209
|
/**
|
206
210
|
* Optionally pass if the web terminal should be open by default
|
207
211
|
*/
|
208
|
-
isInitiallyOpen: index$1["default"].bool
|
212
|
+
isInitiallyOpen: index$1["default"].bool,
|
213
|
+
/**
|
214
|
+
* Specifies aria label for Web terminal
|
215
|
+
*/
|
216
|
+
webTerminalAriaLabel: index$1["default"].string
|
209
217
|
};
|
@@ -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
|
};
|