@carbon/ibm-products 2.22.0 → 2.24.0
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +2 -1
- package/css/index-full-carbon.css +29490 -28295
- 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 +81 -104
- 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 +24399 -350
- 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 +17204 -123
- package/css/index.css.map +1 -1
- package/css/index.min.css +1 -1
- package/css/index.min.css.map +1 -1
- package/es/components/Card/Card.js +1 -2
- package/es/components/Card/CardHeader.js +2 -2
- package/es/components/Carousel/Carousel.js +5 -3
- package/es/components/Coachmark/Coachmark.js +255 -0
- package/es/components/Coachmark/CoachmarkDragbar.js +146 -0
- package/es/components/Coachmark/CoachmarkHeader.js +91 -0
- package/es/components/Coachmark/CoachmarkOverlay.js +235 -0
- package/es/components/Coachmark/CoachmarkTagline.js +97 -0
- package/es/components/Coachmark/index.js +10 -0
- package/es/components/Coachmark/utils/constants.js +76 -0
- package/es/components/Coachmark/utils/context.js +5 -0
- package/es/components/Coachmark/utils/enums.js +40 -0
- package/es/components/Coachmark/utils/helpers.js +11 -0
- package/es/components/Coachmark/utils/hooks.js +54 -0
- package/es/components/CoachmarkBeacon/CoachmarkBeacon.js +93 -0
- package/es/components/CoachmarkBeacon/index.js +8 -0
- package/es/components/CoachmarkButton/CoachmarkButton.js +90 -0
- package/es/components/CoachmarkButton/index.js +8 -0
- package/es/components/CoachmarkFixed/CoachmarkFixed.js +226 -0
- package/es/components/CoachmarkFixed/index.js +8 -0
- package/es/components/CoachmarkOverlayElement/CoachmarkOverlayElement.js +86 -0
- package/es/components/CoachmarkOverlayElement/index.js +8 -0
- package/es/components/CoachmarkOverlayElements/CoachmarkOverlayElements.js +216 -0
- package/es/components/CoachmarkOverlayElements/index.js +8 -0
- package/es/components/CoachmarkStack/CoachmarkStack.js +283 -0
- package/es/components/CoachmarkStack/CoachmarkStackHome.js +192 -0
- package/es/components/CoachmarkStack/index.js +8 -0
- package/es/components/Datagrid/Datagrid/DatagridHeaderRow.js +14 -4
- package/es/components/Datagrid/Datagrid/DatagridSelectAll.js +4 -1
- package/es/components/Datagrid/Datagrid/DraggableElement.js +1 -1
- package/es/components/Datagrid/Datagrid/addons/CustomizeColumns/ButtonWrapper.js +1 -1
- package/es/components/Datagrid/Datagrid/addons/CustomizeColumns/Columns.js +4 -1
- package/es/components/Datagrid/Datagrid/addons/CustomizeColumns/CustomizeColumnsTearsheet.js +1 -1
- package/es/components/Datagrid/Datagrid/addons/Slug/ColumnHeaderSlug.js +26 -0
- package/es/components/Datagrid/Datagrid.docs-page.js +2 -2
- package/es/components/Datagrid/useActionsColumn.js +16 -12
- package/es/components/Datagrid/useDefaultStringRenderer.js +3 -3
- package/es/components/Datagrid/useNestedRowExpander.js +2 -2
- package/es/components/Datagrid/useSortableColumns.js +15 -5
- package/es/components/EmptyStates/ErrorEmptyState/ErrorEmptyState.js +7 -2
- package/es/components/EmptyStates/NoDataEmptyState/NoDataEmptyState.js +8 -3
- package/es/components/EmptyStates/NoTagsEmptyState/NoTagsEmptyState.js +7 -2
- package/es/components/EmptyStates/NotFoundEmptyState/NotFoundEmptyState.js +7 -2
- package/es/components/EmptyStates/NotificationsEmptyState/NotificationsEmptyState.js +7 -2
- package/es/components/EmptyStates/UnauthorizedEmptyState/UnauthorizedEmptyState.js +7 -2
- package/es/components/EmptyStates/assets/ErrorIllustration.js +5 -5
- package/es/components/EmptyStates/assets/NoDataIllustration.js +5 -5
- package/es/components/EmptyStates/assets/NoTagsIllustration.js +5 -5
- package/es/components/EmptyStates/assets/NotFoundIllustration.js +5 -5
- package/es/components/EmptyStates/assets/NotificationsIllustration.js +5 -5
- package/es/components/EmptyStates/assets/UnauthorizedIllustration.js +5 -5
- package/es/components/FilterSummary/FilterSummary.js +100 -19
- package/es/components/InterstitialScreen/InterstitialScreen.js +427 -0
- package/es/components/InterstitialScreen/index.js +8 -0
- package/es/components/InterstitialScreenView/InterstitialScreenView.js +75 -0
- package/es/components/InterstitialScreenView/index.js +8 -0
- package/es/components/InterstitialScreenViewModule/InterstitialScreenViewModule.js +83 -0
- package/es/components/InterstitialScreenViewModule/index.js +8 -0
- package/es/components/PageHeader/PageHeaderUtils.js +2 -2
- package/es/components/SearchBar/SearchBar.js +227 -0
- package/es/components/SearchBar/index.js +8 -0
- package/es/components/TagSet/TagSet.js +11 -3
- package/es/components/index.js +12 -1
- package/es/global/js/hooks/useResizeObserver.js +2 -2
- package/es/global/js/package-settings.js +14 -0
- package/lib/components/Card/Card.js +3 -4
- package/lib/components/Card/CardHeader.js +2 -2
- package/lib/components/Carousel/Carousel.js +5 -3
- package/lib/components/Coachmark/Coachmark.js +264 -0
- package/lib/components/Coachmark/CoachmarkDragbar.js +151 -0
- package/lib/components/Coachmark/CoachmarkHeader.js +95 -0
- package/lib/components/Coachmark/CoachmarkOverlay.js +243 -0
- package/lib/components/Coachmark/CoachmarkTagline.js +101 -0
- package/lib/components/Coachmark/index.js +38 -0
- package/lib/components/Coachmark/utils/constants.js +81 -0
- package/lib/components/Coachmark/utils/context.js +11 -0
- package/lib/components/Coachmark/utils/enums.js +46 -0
- package/lib/components/Coachmark/utils/helpers.js +17 -0
- package/lib/components/Coachmark/utils/hooks.js +59 -0
- package/lib/components/CoachmarkBeacon/CoachmarkBeacon.js +97 -0
- package/lib/components/CoachmarkBeacon/index.js +12 -0
- package/lib/components/CoachmarkButton/CoachmarkButton.js +93 -0
- package/lib/components/CoachmarkButton/index.js +12 -0
- package/lib/components/CoachmarkFixed/CoachmarkFixed.js +232 -0
- package/lib/components/CoachmarkFixed/index.js +12 -0
- package/lib/components/CoachmarkOverlayElement/CoachmarkOverlayElement.js +90 -0
- package/lib/components/CoachmarkOverlayElement/index.js +12 -0
- package/lib/components/CoachmarkOverlayElements/CoachmarkOverlayElements.js +222 -0
- package/lib/components/CoachmarkOverlayElements/index.js +12 -0
- package/lib/components/CoachmarkStack/CoachmarkStack.js +288 -0
- package/lib/components/CoachmarkStack/CoachmarkStackHome.js +198 -0
- package/lib/components/CoachmarkStack/index.js +12 -0
- package/lib/components/Datagrid/Datagrid/DatagridHeaderRow.js +14 -4
- package/lib/components/Datagrid/Datagrid/DatagridSelectAll.js +4 -1
- package/lib/components/Datagrid/Datagrid/DraggableElement.js +1 -1
- package/lib/components/Datagrid/Datagrid/addons/CustomizeColumns/ButtonWrapper.js +1 -1
- package/lib/components/Datagrid/Datagrid/addons/CustomizeColumns/Columns.js +4 -1
- package/lib/components/Datagrid/Datagrid/addons/CustomizeColumns/CustomizeColumnsTearsheet.js +1 -1
- package/lib/components/Datagrid/Datagrid/addons/Slug/ColumnHeaderSlug.js +36 -0
- package/lib/components/Datagrid/Datagrid.docs-page.js +2 -2
- package/lib/components/Datagrid/useActionsColumn.js +15 -11
- package/lib/components/Datagrid/useDefaultStringRenderer.js +3 -3
- package/lib/components/Datagrid/useNestedRowExpander.js +2 -2
- package/lib/components/Datagrid/useSortableColumns.js +15 -5
- package/lib/components/EmptyStates/ErrorEmptyState/ErrorEmptyState.js +7 -2
- package/lib/components/EmptyStates/NoDataEmptyState/NoDataEmptyState.js +8 -3
- package/lib/components/EmptyStates/NoTagsEmptyState/NoTagsEmptyState.js +7 -2
- package/lib/components/EmptyStates/NotFoundEmptyState/NotFoundEmptyState.js +7 -2
- package/lib/components/EmptyStates/NotificationsEmptyState/NotificationsEmptyState.js +7 -2
- package/lib/components/EmptyStates/UnauthorizedEmptyState/UnauthorizedEmptyState.js +7 -2
- package/lib/components/EmptyStates/assets/ErrorIllustration.js +5 -5
- package/lib/components/EmptyStates/assets/NoDataIllustration.js +5 -5
- package/lib/components/EmptyStates/assets/NoTagsIllustration.js +5 -5
- package/lib/components/EmptyStates/assets/NotFoundIllustration.js +5 -5
- package/lib/components/EmptyStates/assets/NotificationsIllustration.js +5 -5
- package/lib/components/EmptyStates/assets/UnauthorizedIllustration.js +5 -5
- package/lib/components/FilterSummary/FilterSummary.js +103 -23
- package/lib/components/InterstitialScreen/InterstitialScreen.js +434 -0
- package/lib/components/InterstitialScreen/index.js +12 -0
- package/lib/components/InterstitialScreenView/InterstitialScreenView.js +77 -0
- package/lib/components/InterstitialScreenView/index.js +12 -0
- package/lib/components/InterstitialScreenViewModule/InterstitialScreenViewModule.js +85 -0
- package/lib/components/InterstitialScreenViewModule/index.js +12 -0
- package/lib/components/PageHeader/PageHeaderUtils.js +2 -2
- package/lib/components/SearchBar/SearchBar.js +233 -0
- package/lib/components/SearchBar/index.js +12 -0
- package/lib/components/TagSet/TagSet.js +11 -3
- package/lib/components/index.js +78 -1
- package/lib/global/js/hooks/useResizeObserver.js +2 -2
- package/lib/global/js/package-settings.js +14 -0
- package/package.json +5 -5
- package/scss/components/Card/_card.scss +6 -5
- package/scss/components/Coachmark/_carbon-imports.scss +10 -0
- package/scss/components/Coachmark/_coachmark-dragbar.scss +27 -0
- package/scss/components/Coachmark/_coachmark-header.scss +20 -0
- package/scss/components/Coachmark/_coachmark-overlay.scss +431 -0
- package/scss/components/Coachmark/_coachmark-tagline.scss +140 -0
- package/scss/components/Coachmark/_coachmark.scss +30 -0
- package/scss/components/Coachmark/_index-with-carbon.scss +9 -0
- package/scss/components/Coachmark/_index.scss +8 -0
- package/scss/components/CoachmarkBeacon/_carbon-imports.scss +9 -0
- package/scss/components/CoachmarkBeacon/_coachmark-beacon.scss +166 -0
- package/scss/components/CoachmarkBeacon/_index-with-carbon.scss +9 -0
- package/scss/components/CoachmarkBeacon/_index.scss +8 -0
- package/scss/components/CoachmarkButton/_carbon-imports.scss +9 -0
- package/scss/components/CoachmarkButton/_coachmark-button.scss +25 -0
- package/scss/components/CoachmarkButton/_index-with-carbon.scss +9 -0
- package/scss/components/CoachmarkButton/_index.scss +8 -0
- package/scss/components/CoachmarkFixed/_carbon-imports.scss +9 -0
- package/scss/components/CoachmarkFixed/_coachmark-fixed.scss +25 -0
- package/scss/components/CoachmarkFixed/_index-with-carbon.scss +9 -0
- package/scss/components/CoachmarkFixed/_index.scss +8 -0
- package/scss/components/CoachmarkOverlayElement/_carbon-imports.scss +9 -0
- package/scss/components/CoachmarkOverlayElement/_coachmark-overlay-element.scss +52 -0
- package/scss/components/CoachmarkOverlayElement/_index-with-carbon.scss +9 -0
- package/scss/components/CoachmarkOverlayElement/_index.scss +8 -0
- package/scss/components/CoachmarkOverlayElements/_carbon-imports.scss +9 -0
- package/scss/components/CoachmarkOverlayElements/_coachmark-overlay-elements.scss +47 -0
- package/scss/components/CoachmarkOverlayElements/_index-with-carbon.scss +9 -0
- package/scss/components/CoachmarkOverlayElements/_index.scss +8 -0
- package/scss/components/CoachmarkStack/_carbon-imports.scss +9 -0
- package/scss/components/CoachmarkStack/_coachmark-stack.scss +95 -0
- package/scss/components/CoachmarkStack/_index-with-carbon.scss +9 -0
- package/scss/components/CoachmarkStack/_index.scss +8 -0
- package/scss/components/CreateSidePanel/_create-side-panel.scss +1 -38
- package/scss/components/Datagrid/styles/_datagrid.scss +15 -0
- package/scss/components/EditSidePanel/_edit-side-panel.scss +0 -18
- package/scss/components/FilterSummary/_filter-summary.scss +22 -1
- package/scss/components/InterstitialScreen/_carbon-imports.scss +9 -0
- package/scss/components/InterstitialScreen/_index-with-carbon.scss +9 -0
- package/scss/components/InterstitialScreen/_index.scss +8 -0
- package/scss/components/InterstitialScreen/_interstitial-screen.scss +276 -0
- package/scss/components/InterstitialScreenView/_carbon-imports.scss +9 -0
- package/scss/components/InterstitialScreenView/_index-with-carbon.scss +9 -0
- package/scss/components/InterstitialScreenView/_index.scss +8 -0
- package/scss/components/InterstitialScreenView/_interstitial-screen-view.scss +25 -0
- package/scss/components/InterstitialScreenViewModule/_carbon-imports.scss +9 -0
- package/scss/components/InterstitialScreenViewModule/_index-with-carbon.scss +9 -0
- package/scss/components/InterstitialScreenViewModule/_index.scss +8 -0
- package/scss/components/InterstitialScreenViewModule/_interstitial-screen-view-module.scss +59 -0
- package/scss/components/PageHeader/_page-header.scss +0 -1
- package/scss/components/SearchBar/_carbon-imports.scss +9 -0
- package/scss/components/SearchBar/_index-with-carbon.scss +9 -0
- package/scss/components/SearchBar/_index.scss +8 -0
- package/scss/components/SearchBar/_search-bar.scss +26 -0
- package/scss/components/SidePanel/_side-panel.scss +12 -7
- package/scss/components/_index-with-carbon.scss +11 -0
- package/scss/components/_index.scss +11 -0
@@ -1,4 +1,3 @@
|
|
1
|
-
import _typeof from "@babel/runtime/helpers/typeof";
|
2
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
3
2
|
import _extends from "@babel/runtime/helpers/extends";
|
4
3
|
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
@@ -161,7 +160,7 @@ export var Card = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
161
160
|
var clickable = hasClickEvent && !productive || hasClickEvent && productive && clickZone === 'one';
|
162
161
|
var cardProps = _objectSpread(_objectSpread({}, rest), {}, {
|
163
162
|
ref: ref,
|
164
|
-
className: cx(blockClass, _defineProperty(_defineProperty(_defineProperty(_defineProperty({}, "".concat(blockClass, "__productive"), productive), "".concat(blockClass, "__clickable"), clickable), "".concat(blockClass, "__media-left"), mediaPosition === 'left'), "".concat(blockClass, "--has-slug"),
|
163
|
+
className: cx(blockClass, _defineProperty(_defineProperty(_defineProperty(_defineProperty({}, "".concat(blockClass, "__productive"), productive), "".concat(blockClass, "__clickable"), clickable), "".concat(blockClass, "__media-left"), mediaPosition === 'left'), "".concat(blockClass, "--has-slug"), !!slug), className)
|
165
164
|
}, clickable && clickableProps);
|
166
165
|
return cardProps;
|
167
166
|
};
|
@@ -63,9 +63,9 @@ export var CardHeader = function CardHeader(_ref) {
|
|
63
63
|
}));
|
64
64
|
var normalizedSlug;
|
65
65
|
if (slug) {
|
66
|
-
if (inClickableCard) {
|
66
|
+
if (inClickableCard || typeof slug === 'boolean') {
|
67
67
|
normalizedSlug = hollowSlugIcon;
|
68
|
-
} else
|
68
|
+
} else {
|
69
69
|
normalizedSlug = /*#__PURE__*/React.cloneElement(slug, {
|
70
70
|
size: label && title || title && titleSize === 'large' ? 'sm' : 'xs'
|
71
71
|
});
|
@@ -195,9 +195,11 @@ var Carousel = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
195
195
|
useEffect(function () {
|
196
196
|
function handleWheel(event) {
|
197
197
|
// update the scroll position
|
198
|
-
event.
|
199
|
-
|
200
|
-
|
198
|
+
if (event.shiftKey) {
|
199
|
+
event.stopPropagation();
|
200
|
+
event.preventDefault();
|
201
|
+
event.cancelBubble = false;
|
202
|
+
}
|
201
203
|
}
|
202
204
|
var scrollDiv = scrollRef.current;
|
203
205
|
if (scrollDiv) {
|
@@ -0,0 +1,255 @@
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
2
|
+
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
3
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
4
|
+
var _excluded = ["align", "children", "className", "onClose", "overlayClassName", "overlayKind", "overlayRef", "portalTarget", "positionTune", "target", "theme"];
|
5
|
+
/**
|
6
|
+
* Copyright IBM Corp. 2023, 2024
|
7
|
+
*
|
8
|
+
* This source code is licensed under the Apache-2.0 license found in the
|
9
|
+
* LICENSE file in the root directory of this source tree.
|
10
|
+
*/
|
11
|
+
|
12
|
+
import React, { forwardRef, useEffect, useRef, useState, useCallback } from 'react';
|
13
|
+
import cx from 'classnames';
|
14
|
+
import PropTypes, { Component } from 'prop-types';
|
15
|
+
import { createPortal } from 'react-dom';
|
16
|
+
import { CoachmarkOverlay } from './CoachmarkOverlay';
|
17
|
+
import { CoachmarkContext } from './utils/context';
|
18
|
+
import { COACHMARK_OVERLAY_KIND } from './utils/enums';
|
19
|
+
import { useClickOutsideElement, useWindowEvent } from './utils/hooks';
|
20
|
+
import { getDevtoolsProps } from '../../global/js/utils/devtools';
|
21
|
+
import { pkg /*, carbon */ } from '../../settings';
|
22
|
+
import { throttle } from 'lodash';
|
23
|
+
// The block part of our conventional BEM class names (blockClass__E--M).
|
24
|
+
var blockClass = "".concat(pkg.prefix, "--coachmark");
|
25
|
+
var overlayBlockClass = "".concat(blockClass, "-overlay");
|
26
|
+
var componentName = 'Coachmark';
|
27
|
+
var defaults = {
|
28
|
+
align: 'bottom',
|
29
|
+
onClose: function onClose() {},
|
30
|
+
overlayKind: 'tooltip',
|
31
|
+
theme: 'light'
|
32
|
+
};
|
33
|
+
|
34
|
+
/**
|
35
|
+
* Coachmarks are used to call out specific functionality or concepts
|
36
|
+
* within the UI that may not be intuitive but are important for the
|
37
|
+
* user to gain understanding of the product's main value and discover new use cases.
|
38
|
+
*/
|
39
|
+
|
40
|
+
export var Coachmark = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
41
|
+
var _document$querySelect;
|
42
|
+
var _ref$align = _ref.align,
|
43
|
+
align = _ref$align === void 0 ? defaults.align : _ref$align,
|
44
|
+
children = _ref.children,
|
45
|
+
className = _ref.className,
|
46
|
+
_ref$onClose = _ref.onClose,
|
47
|
+
onClose = _ref$onClose === void 0 ? defaults.onClose : _ref$onClose,
|
48
|
+
overlayClassName = _ref.overlayClassName,
|
49
|
+
_ref$overlayKind = _ref.overlayKind,
|
50
|
+
overlayKind = _ref$overlayKind === void 0 ? defaults.overlayKind : _ref$overlayKind,
|
51
|
+
overlayRef = _ref.overlayRef,
|
52
|
+
portalTarget = _ref.portalTarget,
|
53
|
+
positionTune = _ref.positionTune,
|
54
|
+
target = _ref.target,
|
55
|
+
_ref$theme = _ref.theme,
|
56
|
+
theme = _ref$theme === void 0 ? defaults.theme : _ref$theme,
|
57
|
+
rest = _objectWithoutProperties(_ref, _excluded);
|
58
|
+
var isBeacon = overlayKind === COACHMARK_OVERLAY_KIND.TOOLTIP;
|
59
|
+
var isStacked = overlayKind === COACHMARK_OVERLAY_KIND.STACKED;
|
60
|
+
var portalNode = portalTarget ? (_document$querySelect = document.querySelector(portalTarget)) !== null && _document$querySelect !== void 0 ? _document$querySelect : document.querySelector('body') : document.querySelector('body');
|
61
|
+
var _useState = useState(isStacked),
|
62
|
+
_useState2 = _slicedToArray(_useState, 2),
|
63
|
+
isOpen = _useState2[0],
|
64
|
+
setIsOpen = _useState2[1];
|
65
|
+
var _useState3 = useState(false),
|
66
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
67
|
+
shouldResetPosition = _useState4[0],
|
68
|
+
setShouldResetPosition = _useState4[1];
|
69
|
+
var _useState5 = useState(),
|
70
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
71
|
+
targetRect = _useState6[0],
|
72
|
+
setTargetRect = _useState6[1];
|
73
|
+
var _useState7 = useState({
|
74
|
+
x: 0,
|
75
|
+
y: 0
|
76
|
+
}),
|
77
|
+
_useState8 = _slicedToArray(_useState7, 2),
|
78
|
+
targetOffset = _useState8[0],
|
79
|
+
setTargetOffset = _useState8[1];
|
80
|
+
var overlayBackupRef = useRef();
|
81
|
+
var backupRef = useRef();
|
82
|
+
var _coachmarkRef = ref || backupRef;
|
83
|
+
var _overlayRef = overlayRef || overlayBackupRef;
|
84
|
+
var closeOverlay = function closeOverlay() {
|
85
|
+
setIsOpen(false);
|
86
|
+
};
|
87
|
+
var handleClose = useCallback(function () {
|
88
|
+
if (isStacked) {
|
89
|
+
// If stacked, do not unmount,
|
90
|
+
// only call its ("parent") onClose method.
|
91
|
+
onClose();
|
92
|
+
} else {
|
93
|
+
setIsOpen(false);
|
94
|
+
onClose();
|
95
|
+
}
|
96
|
+
}, [isStacked, onClose]);
|
97
|
+
var escFunction = useCallback(function (event) {
|
98
|
+
if (event.key === 'Escape') {
|
99
|
+
handleClose();
|
100
|
+
}
|
101
|
+
}, [handleClose]);
|
102
|
+
useEffect(function () {
|
103
|
+
document.addEventListener('keydown', escFunction, false);
|
104
|
+
return function () {
|
105
|
+
document.removeEventListener('keydown', escFunction, false);
|
106
|
+
};
|
107
|
+
}, [escFunction]);
|
108
|
+
var handleTargetClick = function handleTargetClick(e) {
|
109
|
+
setTargetRect(e.target.getBoundingClientRect());
|
110
|
+
setTargetOffset({
|
111
|
+
x: e.target.offsetLeft,
|
112
|
+
y: e.target.offsetTop
|
113
|
+
});
|
114
|
+
if (isBeacon) {
|
115
|
+
// toggle open/closed for beacons
|
116
|
+
setIsOpen(function (prevIsOpen) {
|
117
|
+
return !prevIsOpen;
|
118
|
+
});
|
119
|
+
} else {
|
120
|
+
// reset position for all other kinds
|
121
|
+
setIsOpen(false);
|
122
|
+
setShouldResetPosition(true);
|
123
|
+
}
|
124
|
+
};
|
125
|
+
var contextValue = {
|
126
|
+
buttonProps: {
|
127
|
+
'aria-expanded': isOpen,
|
128
|
+
tabIndex: 0,
|
129
|
+
onClick: handleTargetClick,
|
130
|
+
// Compensate for accidental open/close on double-click.
|
131
|
+
// Only open on double-click.
|
132
|
+
onDoubleClick: handleTargetClick
|
133
|
+
},
|
134
|
+
closeButtonProps: {
|
135
|
+
onClick: handleClose
|
136
|
+
},
|
137
|
+
targetRect: targetRect,
|
138
|
+
targetOffset: targetOffset,
|
139
|
+
align: align,
|
140
|
+
positionTune: positionTune
|
141
|
+
};
|
142
|
+
var handleResize = throttle(function () {
|
143
|
+
closeOverlay();
|
144
|
+
}, 2000);
|
145
|
+
|
146
|
+
// instead of toggling on/off,
|
147
|
+
// keep open and reset to original position
|
148
|
+
useEffect(function () {
|
149
|
+
if (shouldResetPosition) {
|
150
|
+
setShouldResetPosition(false);
|
151
|
+
setIsOpen(true);
|
152
|
+
}
|
153
|
+
}, [shouldResetPosition]);
|
154
|
+
|
155
|
+
// On unmount:
|
156
|
+
// - DO NOT "Close()" the coachmark.
|
157
|
+
// - This triggers a "signal" to close it forever.
|
158
|
+
// - "Closing" should only ever be a user-triggered event.
|
159
|
+
// - DO "hide" the coachmark.
|
160
|
+
// - The app is doing the action for the user.
|
161
|
+
// - The user will have the opportunity to open it again.
|
162
|
+
useEffect(function () {
|
163
|
+
return function () {
|
164
|
+
return setIsOpen(false);
|
165
|
+
};
|
166
|
+
}, []);
|
167
|
+
useClickOutsideElement(_coachmarkRef, _overlayRef, overlayKind, closeOverlay);
|
168
|
+
useWindowEvent('resize', handleResize);
|
169
|
+
return /*#__PURE__*/React.createElement(CoachmarkContext.Provider, {
|
170
|
+
value: contextValue
|
171
|
+
}, /*#__PURE__*/React.createElement("div", _extends({
|
172
|
+
className: cx(blockClass, "".concat(blockClass, "__").concat(theme), className),
|
173
|
+
ref: _coachmarkRef
|
174
|
+
}, rest, getDevtoolsProps(componentName)), target, isOpen && /*#__PURE__*/createPortal( /*#__PURE__*/React.createElement(CoachmarkOverlay, {
|
175
|
+
ref: _overlayRef,
|
176
|
+
fixedIsVisible: false,
|
177
|
+
kind: overlayKind,
|
178
|
+
onClose: handleClose,
|
179
|
+
theme: theme,
|
180
|
+
className: cx(overlayClassName, "".concat(overlayBlockClass, "--is-visible"))
|
181
|
+
}, children), portalNode)));
|
182
|
+
});
|
183
|
+
|
184
|
+
// Return a placeholder if not released and not enabled by feature flag
|
185
|
+
Coachmark = pkg.checkComponentEnabled(Coachmark, componentName);
|
186
|
+
|
187
|
+
// The display name of the component, used by React. Note that displayName
|
188
|
+
// is used in preference to relying on function.name.
|
189
|
+
Coachmark.displayName = componentName;
|
190
|
+
|
191
|
+
// The types and DocGen commentary for the component props,
|
192
|
+
// in alphabetical order (for consistency).
|
193
|
+
// See https://www.npmjs.com/package/prop-types#usage.
|
194
|
+
Coachmark.propTypes = {
|
195
|
+
/**
|
196
|
+
* Where to render the Coachmark relative to its target.
|
197
|
+
* Applies only to Floating and Tooltip Coachmarks.
|
198
|
+
* @see COACHMARK_ALIGNMENT
|
199
|
+
*/
|
200
|
+
align: PropTypes.oneOf(['bottom', 'bottom-left', 'bottom-right', 'left', 'left-top', 'left-bottom', 'right', 'right-top', 'right-bottom', 'top', 'top-left', 'top-right']),
|
201
|
+
/**
|
202
|
+
* Coachmark should use a single CoachmarkOverlayElements component as a child.
|
203
|
+
* @see CoachmarkOverlayElements
|
204
|
+
*/
|
205
|
+
children: PropTypes.node.isRequired,
|
206
|
+
/**
|
207
|
+
* Optional class name for this component.
|
208
|
+
*/
|
209
|
+
className: PropTypes.string,
|
210
|
+
/**
|
211
|
+
* Function to call when the Coachmark closes.
|
212
|
+
*/
|
213
|
+
onClose: PropTypes.func,
|
214
|
+
/**
|
215
|
+
* Optional class name for the Coachmark Overlay component.
|
216
|
+
*/
|
217
|
+
overlayClassName: PropTypes.string,
|
218
|
+
/**
|
219
|
+
* What kind or style of Coachmark to render.
|
220
|
+
*/
|
221
|
+
overlayKind: PropTypes.oneOf(['tooltip', 'floating', 'stacked']),
|
222
|
+
overlayRef: PropTypes.oneOfType([
|
223
|
+
// Either a function
|
224
|
+
PropTypes.func,
|
225
|
+
// Or the instance of a DOM native element (see the note about SSR)
|
226
|
+
PropTypes.shape({
|
227
|
+
current: PropTypes.instanceOf(Component)
|
228
|
+
})]),
|
229
|
+
/**
|
230
|
+
* By default, the Coachmark will be appended to the end of `document.body`.
|
231
|
+
* The Coachmark will remain persistent as the user navigates the app until
|
232
|
+
* the user closes the Coachmark.
|
233
|
+
*
|
234
|
+
* Alternatively, the app developer can tightly couple the Coachmark to a DOM
|
235
|
+
* element or other component by specifying a CSS selector. The Coachmark will
|
236
|
+
* remain visible as long as that element remains visible or mounted. When the
|
237
|
+
* element is hidden or component is unmounted, the Coachmark will disappear.
|
238
|
+
*/
|
239
|
+
portalTarget: PropTypes.string,
|
240
|
+
/**
|
241
|
+
* Fine tune the position of the target in pixels. Applies only to Beacons.
|
242
|
+
*/
|
243
|
+
positionTune: PropTypes.shape({
|
244
|
+
x: PropTypes.number,
|
245
|
+
y: PropTypes.number
|
246
|
+
}),
|
247
|
+
/**
|
248
|
+
* The optional button or beacon that the user will click to show the Coachmark.
|
249
|
+
*/
|
250
|
+
target: PropTypes.node,
|
251
|
+
/**
|
252
|
+
* Determines the theme of the component.
|
253
|
+
*/
|
254
|
+
theme: PropTypes.oneOf(['light', 'dark'])
|
255
|
+
};
|
@@ -0,0 +1,146 @@
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
2
|
+
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
3
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
4
|
+
var _excluded = ["a11yKeyboardHandler", "closeIconDescription", "onClose", "onDrag", "showCloseButton", "theme"];
|
5
|
+
/**
|
6
|
+
* Copyright IBM Corp. 2023, 2024
|
7
|
+
*
|
8
|
+
* This source code is licensed under the Apache-2.0 license found in the
|
9
|
+
* LICENSE file in the root directory of this source tree.
|
10
|
+
*/
|
11
|
+
|
12
|
+
// Import portions of React that are needed.
|
13
|
+
import React, { useEffect, useState } from 'react';
|
14
|
+
|
15
|
+
// Other standard imports.
|
16
|
+
import PropTypes from 'prop-types';
|
17
|
+
import cx from 'classnames';
|
18
|
+
import { Close, Draggable } from '@carbon/react/icons';
|
19
|
+
import { Button } from '@carbon/react';
|
20
|
+
import { getDevtoolsProps } from '../../global/js/utils/devtools';
|
21
|
+
import { pkg /*, carbon */ } from '../../settings';
|
22
|
+
|
23
|
+
// Carbon and package components we use.
|
24
|
+
/* TODO: @import(s) of carbon components and other package components. */
|
25
|
+
|
26
|
+
// The block part of our conventional BEM class names (blockClass__E--M).
|
27
|
+
var blockClass = "".concat(pkg.prefix, "--coachmark-dragbar");
|
28
|
+
var overlayBlockClass = "".concat(pkg.prefix, "--coachmark-overlay");
|
29
|
+
var componentName = 'CoachmarkDragbar';
|
30
|
+
var defaults = {
|
31
|
+
closeIconDescription: 'Close',
|
32
|
+
onDrag: function onDrag() {},
|
33
|
+
onClose: function onClose() {},
|
34
|
+
showCloseButton: true,
|
35
|
+
theme: 'light'
|
36
|
+
};
|
37
|
+
|
38
|
+
/**
|
39
|
+
* DO NOT USE. This component is for the exclusive use
|
40
|
+
* of other Novice to Pro components.
|
41
|
+
*/
|
42
|
+
export var CoachmarkDragbar = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
43
|
+
var a11yKeyboardHandler = _ref.a11yKeyboardHandler,
|
44
|
+
_ref$closeIconDescrip = _ref.closeIconDescription,
|
45
|
+
closeIconDescription = _ref$closeIconDescrip === void 0 ? defaults.closeIconDescription : _ref$closeIconDescrip,
|
46
|
+
_ref$onClose = _ref.onClose,
|
47
|
+
onClose = _ref$onClose === void 0 ? defaults.onClose : _ref$onClose,
|
48
|
+
_ref$onDrag = _ref.onDrag,
|
49
|
+
onDrag = _ref$onDrag === void 0 ? defaults.onDrag : _ref$onDrag,
|
50
|
+
_ref$showCloseButton = _ref.showCloseButton,
|
51
|
+
showCloseButton = _ref$showCloseButton === void 0 ? defaults.showCloseButton : _ref$showCloseButton,
|
52
|
+
_ref$theme = _ref.theme,
|
53
|
+
theme = _ref$theme === void 0 ? defaults.theme : _ref$theme,
|
54
|
+
rest = _objectWithoutProperties(_ref, _excluded);
|
55
|
+
var _useState = useState(false),
|
56
|
+
_useState2 = _slicedToArray(_useState, 2),
|
57
|
+
isDragging = _useState2[0],
|
58
|
+
setIsDragging = _useState2[1];
|
59
|
+
useEffect(function () {
|
60
|
+
var handleDragStop = function handleDragStop() {
|
61
|
+
return setIsDragging(false);
|
62
|
+
};
|
63
|
+
window.addEventListener('mouseup', handleDragStop);
|
64
|
+
return function () {
|
65
|
+
window.removeEventListener('mouseup', handleDragStop);
|
66
|
+
};
|
67
|
+
}, []);
|
68
|
+
useEffect(function () {
|
69
|
+
var handleDrag = function handleDrag(event) {
|
70
|
+
onDrag(event.movementX, event.movementY);
|
71
|
+
};
|
72
|
+
if (isDragging) {
|
73
|
+
window.addEventListener('mousemove', handleDrag);
|
74
|
+
}
|
75
|
+
return function () {
|
76
|
+
window.removeEventListener('mousemove', handleDrag);
|
77
|
+
};
|
78
|
+
}, [isDragging, onDrag]);
|
79
|
+
var handleDragStart = function handleDragStart() {
|
80
|
+
return setIsDragging(true);
|
81
|
+
};
|
82
|
+
return /*#__PURE__*/React.createElement("header", _extends({}, rest, {
|
83
|
+
className: cx(blockClass, // Apply the block class to the main HTML element
|
84
|
+
"".concat(blockClass, "__").concat(theme),
|
85
|
+
// example: `${blockClass}__template-string-class-${kind}-n-${size}`,
|
86
|
+
{
|
87
|
+
// switched classes dependant on props or state
|
88
|
+
// example: [`${blockClass}__here-if-small`]: size === 'sm',
|
89
|
+
}),
|
90
|
+
ref: ref
|
91
|
+
// role="main"
|
92
|
+
}, getDevtoolsProps(componentName)), /*#__PURE__*/React.createElement("button", {
|
93
|
+
type: "button",
|
94
|
+
className: "".concat(overlayBlockClass, "__handle"),
|
95
|
+
onMouseDown: handleDragStart,
|
96
|
+
onKeyDown: a11yKeyboardHandler
|
97
|
+
}, /*#__PURE__*/React.createElement(Draggable, {
|
98
|
+
size: "16"
|
99
|
+
})), showCloseButton && /*#__PURE__*/React.createElement(Button, {
|
100
|
+
kind: "ghost",
|
101
|
+
size: "sm",
|
102
|
+
renderIcon: Close,
|
103
|
+
iconDescription: closeIconDescription,
|
104
|
+
hasIconOnly: true,
|
105
|
+
className: "".concat(overlayBlockClass, "--close-btn"),
|
106
|
+
onClick: onClose
|
107
|
+
}));
|
108
|
+
});
|
109
|
+
|
110
|
+
// Return a placeholder if not released and not enabled by feature flag
|
111
|
+
CoachmarkDragbar = pkg.checkComponentEnabled(CoachmarkDragbar, componentName);
|
112
|
+
|
113
|
+
// The display name of the component, used by React. Note that displayName
|
114
|
+
// is used in preference to relying on function.name.
|
115
|
+
CoachmarkDragbar.displayName = componentName;
|
116
|
+
|
117
|
+
// The types and DocGen commentary for the component props,
|
118
|
+
// in alphabetical order (for consistency).
|
119
|
+
// See https://www.npmjs.com/package/prop-types#usage.
|
120
|
+
CoachmarkDragbar.propTypes = {
|
121
|
+
/**
|
122
|
+
* Handler to manage keyboard interactions with the dragbar.
|
123
|
+
*/
|
124
|
+
a11yKeyboardHandler: PropTypes.func.isRequired,
|
125
|
+
/**
|
126
|
+
* Tooltip text and aria label for the Close button icon.
|
127
|
+
*/
|
128
|
+
closeIconDescription: PropTypes.string,
|
129
|
+
/**
|
130
|
+
* Function to call when the close button is clicked.
|
131
|
+
*/
|
132
|
+
onClose: PropTypes.func,
|
133
|
+
/**
|
134
|
+
* Function to call when the user clicks and drags the Coachmark.
|
135
|
+
* For internal use only by the parent CoachmarkOverlay.
|
136
|
+
*/
|
137
|
+
onDrag: PropTypes.func,
|
138
|
+
/**
|
139
|
+
* Show/hide the "X" close button.
|
140
|
+
*/
|
141
|
+
showCloseButton: PropTypes.bool,
|
142
|
+
/**
|
143
|
+
* Determines the theme of the component.
|
144
|
+
*/
|
145
|
+
theme: PropTypes.oneOf(['light', 'dark'])
|
146
|
+
};
|
@@ -0,0 +1,91 @@
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
2
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
3
|
+
var _excluded = ["closeIconDescription", "onClose", "showCloseButton", "theme"];
|
4
|
+
/**
|
5
|
+
* Copyright IBM Corp. 2023, 2024
|
6
|
+
*
|
7
|
+
* This source code is licensed under the Apache-2.0 license found in the
|
8
|
+
* LICENSE file in the root directory of this source tree.
|
9
|
+
*/
|
10
|
+
|
11
|
+
// Import portions of React that are needed.
|
12
|
+
import React from 'react';
|
13
|
+
|
14
|
+
// Other standard imports.
|
15
|
+
import PropTypes from 'prop-types';
|
16
|
+
import cx from 'classnames';
|
17
|
+
import { Close } from '@carbon/react/icons';
|
18
|
+
import { Button } from '@carbon/react';
|
19
|
+
import { getDevtoolsProps } from '../../global/js/utils/devtools';
|
20
|
+
import { pkg /*, carbon */ } from '../../settings';
|
21
|
+
|
22
|
+
// The block part of our conventional BEM class names (blockClass__E--M).
|
23
|
+
var blockClass = "".concat(pkg.prefix, "--coachmark-header");
|
24
|
+
var overlayBlockClass = "".concat(pkg.prefix, "--coachmark-overlay");
|
25
|
+
var componentName = 'CoachmarkHeader';
|
26
|
+
var defaults = {
|
27
|
+
closeIconDescription: 'Close',
|
28
|
+
onClose: function onClose() {},
|
29
|
+
showCloseButton: true,
|
30
|
+
theme: 'light'
|
31
|
+
};
|
32
|
+
|
33
|
+
/**
|
34
|
+
* DO NOT USE. This component is for the exclusive use
|
35
|
+
* of other Novice to Pro components.
|
36
|
+
*/
|
37
|
+
export var CoachmarkHeader = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
38
|
+
var _ref$closeIconDescrip = _ref.closeIconDescription,
|
39
|
+
closeIconDescription = _ref$closeIconDescrip === void 0 ? defaults.closeIconDescription : _ref$closeIconDescrip,
|
40
|
+
_ref$onClose = _ref.onClose,
|
41
|
+
onClose = _ref$onClose === void 0 ? defaults.onClose : _ref$onClose,
|
42
|
+
_ref$showCloseButton = _ref.showCloseButton,
|
43
|
+
showCloseButton = _ref$showCloseButton === void 0 ? defaults.showCloseButton : _ref$showCloseButton,
|
44
|
+
_ref$theme = _ref.theme,
|
45
|
+
theme = _ref$theme === void 0 ? defaults.theme : _ref$theme,
|
46
|
+
rest = _objectWithoutProperties(_ref, _excluded);
|
47
|
+
return /*#__PURE__*/React.createElement("header", _extends({}, rest, {
|
48
|
+
className: cx(blockClass, "".concat(blockClass, "__").concat(theme)),
|
49
|
+
ref: ref
|
50
|
+
// role="main"
|
51
|
+
}, getDevtoolsProps(componentName)), showCloseButton && /*#__PURE__*/React.createElement("div", {
|
52
|
+
className: "".concat(overlayBlockClass, "--close-btn-container")
|
53
|
+
}, /*#__PURE__*/React.createElement(Button, {
|
54
|
+
kind: "ghost",
|
55
|
+
size: "sm",
|
56
|
+
renderIcon: Close,
|
57
|
+
iconDescription: closeIconDescription,
|
58
|
+
hasIconOnly: true,
|
59
|
+
className: "".concat(overlayBlockClass, "--close-btn"),
|
60
|
+
onClick: onClose
|
61
|
+
})));
|
62
|
+
});
|
63
|
+
|
64
|
+
// Return a placeholder if not released and not enabled by feature flag
|
65
|
+
CoachmarkHeader = pkg.checkComponentEnabled(CoachmarkHeader, componentName);
|
66
|
+
|
67
|
+
// The display name of the component, used by React. Note that displayName
|
68
|
+
// is used in preference to relying on function.name.
|
69
|
+
CoachmarkHeader.displayName = componentName;
|
70
|
+
|
71
|
+
// The types and DocGen commentary for the component props,
|
72
|
+
// in alphabetical order (for consistency).
|
73
|
+
// See https://www.npmjs.com/package/prop-types#usage.
|
74
|
+
CoachmarkHeader.propTypes = {
|
75
|
+
/**
|
76
|
+
* Tooltip text and aria label for the Close button icon.
|
77
|
+
*/
|
78
|
+
closeIconDescription: PropTypes.string,
|
79
|
+
/**
|
80
|
+
* Function to call when the close button is clicked.
|
81
|
+
*/
|
82
|
+
onClose: PropTypes.func,
|
83
|
+
/**
|
84
|
+
* Show/hide the "X" close button.
|
85
|
+
*/
|
86
|
+
showCloseButton: PropTypes.bool,
|
87
|
+
/**
|
88
|
+
* Determines the theme of the component.
|
89
|
+
*/
|
90
|
+
theme: PropTypes.oneOf(['light', 'dark'])
|
91
|
+
};
|