@carbon/ibm-products 2.43.2-canary.118 → 2.43.2-canary.122
Sign up to get free protection for your applications and to get access to all the features.
- package/es/components/CoachmarkOverlayElements/CoachmarkOverlayElements.js +2 -1
- package/es/components/CoachmarkStack/CoachmarkStack.d.ts +67 -2
- package/es/components/CoachmarkStack/CoachmarkStack.js +16 -9
- package/es/components/CoachmarkStack/CoachmarkStackHome.d.ts +71 -2
- package/es/components/CoachmarkStack/CoachmarkStackHome.js +18 -20
- package/lib/components/CoachmarkOverlayElements/CoachmarkOverlayElements.js +2 -1
- package/lib/components/CoachmarkStack/CoachmarkStack.d.ts +67 -2
- package/lib/components/CoachmarkStack/CoachmarkStack.js +16 -9
- package/lib/components/CoachmarkStack/CoachmarkStackHome.d.ts +71 -2
- package/lib/components/CoachmarkStack/CoachmarkStackHome.js +18 -20
- package/package.json +3 -3
@@ -71,7 +71,8 @@ var CoachmarkOverlayElements = /*#__PURE__*/React__default.forwardRef(function (
|
|
71
71
|
var setCurrentProgStep = function setCurrentProgStep(value) {
|
72
72
|
if (currentProgStep > 0 && value === 0 && buttonFocusRef.current) {
|
73
73
|
setTimeout(function () {
|
74
|
-
|
74
|
+
var _buttonFocusRef$curre;
|
75
|
+
(_buttonFocusRef$curre = buttonFocusRef.current) === null || _buttonFocusRef$curre === void 0 || _buttonFocusRef$curre.focus();
|
75
76
|
}, 1000);
|
76
77
|
}
|
77
78
|
_setCurrentProgStep(value);
|
@@ -1,8 +1,73 @@
|
|
1
|
+
/**
|
2
|
+
* Copyright IBM Corp. 2023, 2024
|
3
|
+
*
|
4
|
+
* This source code is licensed under the Apache-2.0 license found in the
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
6
|
+
*/
|
7
|
+
import React, { ReactNode } from 'react';
|
8
|
+
type Media = {
|
9
|
+
render?: () => ReactNode;
|
10
|
+
} | {
|
11
|
+
filePaths?: string[];
|
12
|
+
};
|
13
|
+
interface CoachmarkStackProps {
|
14
|
+
/**
|
15
|
+
* CoachmarkStack should use a single CoachmarkOverlayElements component as a child.
|
16
|
+
*/
|
17
|
+
children: ReactNode;
|
18
|
+
/**
|
19
|
+
* Provide an optional class to be applied to the containing node.
|
20
|
+
*/
|
21
|
+
className?: string;
|
22
|
+
/**
|
23
|
+
* The label for the button that will close the Stack
|
24
|
+
*/
|
25
|
+
closeButtonLabel?: string;
|
26
|
+
/**
|
27
|
+
* The description of the Coachmark.
|
28
|
+
*/
|
29
|
+
description: ReactNode;
|
30
|
+
/**
|
31
|
+
* The object describing an image in one of two shapes.
|
32
|
+
*
|
33
|
+
* If a single media element is required, use `{render}`.
|
34
|
+
*
|
35
|
+
* If a stepped animation is required, use `{filePaths}`.
|
36
|
+
*
|
37
|
+
* @see {@link MEDIA_PROP_TYPE}.
|
38
|
+
*/
|
39
|
+
media?: Media;
|
40
|
+
/**
|
41
|
+
* The labels used to link to the stackable Coachmarks.
|
42
|
+
*/
|
43
|
+
navLinkLabels: string[];
|
44
|
+
/**
|
45
|
+
* Function to call when the CoachmarkStack closes.
|
46
|
+
*/
|
47
|
+
onClose?: () => void;
|
48
|
+
/**
|
49
|
+
* Where in the DOM to render the stack.
|
50
|
+
* The default is `document.body`.
|
51
|
+
*/
|
52
|
+
portalTarget?: string;
|
53
|
+
/**
|
54
|
+
* The tagline title which will be fixed to the bottom right of the window and will serve as the display trigger.
|
55
|
+
*/
|
56
|
+
tagline: string;
|
57
|
+
/**
|
58
|
+
* Determines the theme of the component.
|
59
|
+
*/
|
60
|
+
theme?: 'light' | 'dark';
|
61
|
+
/**
|
62
|
+
* The title of the Coachmark.
|
63
|
+
*/
|
64
|
+
title: string;
|
65
|
+
}
|
1
66
|
/**
|
2
67
|
* Stacked coachmarks are used to call out specific functionality or concepts
|
3
68
|
* within the UI that may not be intuitive but are important for the
|
4
69
|
* user to gain understanding of the product's main value and discover new use cases.
|
5
70
|
* This variant allows the stacking of multiple coachmark overlays to be displayed by interacting with the tagline.
|
6
71
|
*/
|
7
|
-
export let CoachmarkStack: React.ForwardRefExoticComponent<React.RefAttributes<
|
8
|
-
|
72
|
+
export declare let CoachmarkStack: React.ForwardRefExoticComponent<CoachmarkStackProps & React.RefAttributes<HTMLDivElement>>;
|
73
|
+
export {};
|
@@ -31,7 +31,8 @@ var elementBlockClass = "".concat(pkg.prefix, "--coachmark-stack-element");
|
|
31
31
|
var defaults = {
|
32
32
|
onClose: function onClose() {},
|
33
33
|
// Pass through to CoachmarkStackHome
|
34
|
-
theme: 'light'
|
34
|
+
theme: 'light',
|
35
|
+
portalTarget: 'body'
|
35
36
|
};
|
36
37
|
|
37
38
|
// NOTE
|
@@ -63,12 +64,12 @@ var CoachmarkStack = /*#__PURE__*/React__default.forwardRef(function (_ref, ref)
|
|
63
64
|
theme = _ref$theme === void 0 ? defaults.theme : _ref$theme,
|
64
65
|
title = _ref.title,
|
65
66
|
rest = _objectWithoutProperties(_ref, _excluded);
|
66
|
-
var portalNode = useRef();
|
67
|
+
var portalNode = useRef(null);
|
67
68
|
useIsomorphicEffect(function () {
|
68
69
|
var _document$querySelect, _document, _document2, _document3;
|
69
70
|
portalNode.current = portalTarget ? (_document$querySelect = (_document = document) === null || _document === void 0 ? void 0 : _document.querySelector(portalTarget)) !== null && _document$querySelect !== void 0 ? _document$querySelect : (_document2 = document) === null || _document2 === void 0 ? void 0 : _document2.querySelector('body') : (_document3 = document) === null || _document3 === void 0 ? void 0 : _document3.querySelector('body');
|
70
71
|
}, [portalTarget]);
|
71
|
-
var stackHomeRef = useRef();
|
72
|
+
var stackHomeRef = useRef(null);
|
72
73
|
var stackedCoachmarkRefs = useRef([]);
|
73
74
|
var _useState = useState(false),
|
74
75
|
_useState2 = _slicedToArray(_useState, 2),
|
@@ -82,7 +83,7 @@ var CoachmarkStack = /*#__PURE__*/React__default.forwardRef(function (_ref, ref)
|
|
82
83
|
selectedItemNumber = _useState4[0],
|
83
84
|
setSelectedItemNumber = _useState4[1];
|
84
85
|
// // The parent height and width values to return to after unstacked
|
85
|
-
var _useState5 = useState(
|
86
|
+
var _useState5 = useState(),
|
86
87
|
_useState6 = _slicedToArray(_useState5, 2),
|
87
88
|
parentHeight = _useState6[0],
|
88
89
|
setParentHeight = _useState6[1];
|
@@ -163,14 +164,20 @@ var CoachmarkStack = /*#__PURE__*/React__default.forwardRef(function (_ref, ref)
|
|
163
164
|
if (!parentHeight) {
|
164
165
|
return;
|
165
166
|
}
|
166
|
-
stackHomeRef.current
|
167
|
+
if (stackHomeRef.current) {
|
168
|
+
stackHomeRef.current.style.height = "".concat(parentHeight, "px");
|
169
|
+
}
|
167
170
|
if (!isOpen || targetSelectedItem < 0) {
|
168
|
-
stackHomeRef.current
|
171
|
+
if (stackHomeRef.current) {
|
172
|
+
stackHomeRef.current.focus();
|
173
|
+
}
|
169
174
|
return;
|
170
175
|
}
|
171
176
|
var targetHomeHeight = stackedCoachmarkRefs.current[targetSelectedItem].clientHeight;
|
172
|
-
stackHomeRef.current
|
173
|
-
|
177
|
+
if (stackHomeRef.current) {
|
178
|
+
stackHomeRef.current.style.height = "".concat(targetHomeHeight, "px");
|
179
|
+
stackedCoachmarkRefs.current[targetSelectedItem].focus();
|
180
|
+
}
|
174
181
|
}, [selectedItemNumber, isOpen, parentHeight]);
|
175
182
|
var wrappedChildren = Children.map(childArray, function (child, idx) {
|
176
183
|
var mountedClass = mountedRef.current ? "".concat(elementBlockClass, "--is-mounted") : '';
|
@@ -258,7 +265,7 @@ CoachmarkStack.propTypes = {
|
|
258
265
|
/**
|
259
266
|
* The labels used to link to the stackable Coachmarks.
|
260
267
|
*/
|
261
|
-
navLinkLabels: PropTypes.arrayOf(PropTypes.string).isRequired,
|
268
|
+
navLinkLabels: PropTypes.arrayOf(PropTypes.string.isRequired).isRequired,
|
262
269
|
/**
|
263
270
|
* Function to call when the CoachmarkStack closes.
|
264
271
|
*/
|
@@ -1,6 +1,75 @@
|
|
1
|
+
/**
|
2
|
+
* Copyright IBM Corp. 2023, 2024
|
3
|
+
*
|
4
|
+
* This source code is licensed under the Apache-2.0 license found in the
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
6
|
+
*/
|
7
|
+
import React, { ReactNode } from 'react';
|
8
|
+
type Media = {
|
9
|
+
render?: () => ReactNode;
|
10
|
+
filePaths?: never;
|
11
|
+
} | {
|
12
|
+
render?: never;
|
13
|
+
filePaths?: string[];
|
14
|
+
};
|
15
|
+
interface CoachmarkStackHomeProps {
|
16
|
+
/**
|
17
|
+
* Optional class name for this component.
|
18
|
+
*/
|
19
|
+
className?: string;
|
20
|
+
/**
|
21
|
+
* The label for the button that will close the stack
|
22
|
+
*/
|
23
|
+
closeButtonLabel?: string;
|
24
|
+
/**
|
25
|
+
* The description of the Coachmark.
|
26
|
+
*/
|
27
|
+
description: React.ReactNode;
|
28
|
+
/**
|
29
|
+
* If the stack home is open.
|
30
|
+
*/
|
31
|
+
isOpen: boolean;
|
32
|
+
/**
|
33
|
+
* The object describing an image in one of two shapes.
|
34
|
+
*
|
35
|
+
* If a single media element is required, use `{render}`.
|
36
|
+
*
|
37
|
+
* If a stepped animation is required, use `{filePaths}`.
|
38
|
+
*
|
39
|
+
* @see {@link MEDIA_PROP_TYPE}.
|
40
|
+
*/
|
41
|
+
media?: Media;
|
42
|
+
/**
|
43
|
+
* The labels used to link to the stackable Coachmarks.
|
44
|
+
*/
|
45
|
+
navLinkLabels: string[];
|
46
|
+
/**
|
47
|
+
* For internal use only by CoachmarkStack and CoachmarkStackHome.
|
48
|
+
*/
|
49
|
+
onClickNavItem: (index: number) => void;
|
50
|
+
/**
|
51
|
+
* Function to call when the stack closes.
|
52
|
+
*/
|
53
|
+
onClose: () => void;
|
54
|
+
/**
|
55
|
+
* By default, the CoachmarkStackHome will be appended to the end of `document.body`.
|
56
|
+
* The CoachmarkStackHome will remain persistent as the user navigates the app until
|
57
|
+
* the user closes the CoachmarkStackHome.
|
58
|
+
*
|
59
|
+
* Alternatively, the app developer can tightly couple the CoachmarkStackHome to a DOM
|
60
|
+
* element or other component by specifying a CSS selector. The CoachmarkStackHome will
|
61
|
+
* remain visible as long as that element remains visible or mounted. When the
|
62
|
+
* element is hidden or component is unmounted, the CoachmarkStackHome will disappear.
|
63
|
+
*/
|
64
|
+
portalTarget?: string;
|
65
|
+
/**
|
66
|
+
* The title of the Coachmark.
|
67
|
+
*/
|
68
|
+
title: string;
|
69
|
+
}
|
1
70
|
/**
|
2
71
|
* DO NOT USE. This component is for the exclusive use
|
3
72
|
* of other Onboarding components.
|
4
73
|
*/
|
5
|
-
export let CoachmarkStackHome: React.ForwardRefExoticComponent<React.RefAttributes<
|
6
|
-
|
74
|
+
export declare let CoachmarkStackHome: React.ForwardRefExoticComponent<CoachmarkStackHomeProps & React.RefAttributes<HTMLDivElement>>;
|
75
|
+
export {};
|
@@ -20,7 +20,6 @@ import { useIsomorphicEffect } from '../../global/js/hooks/useIsomorphicEffect.j
|
|
20
20
|
import { SteppedAnimatedMedia } from '../SteppedAnimatedMedia/SteppedAnimatedMedia.js';
|
21
21
|
|
22
22
|
var _excluded = ["className", "description", "isOpen", "media", "navLinkLabels", "onClickNavItem", "onClose", "portalTarget", "closeButtonLabel", "title"];
|
23
|
-
|
24
23
|
// Carbon and package components we use.
|
25
24
|
/* TODO: @import(s) of carbon components and other package components. */
|
26
25
|
|
@@ -45,7 +44,7 @@ var CoachmarkStackHome = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
45
44
|
closeButtonLabel = _ref.closeButtonLabel,
|
46
45
|
title = _ref.title,
|
47
46
|
rest = _objectWithoutProperties(_ref, _excluded);
|
48
|
-
var buttonFocusRef = useRef();
|
47
|
+
var buttonFocusRef = useRef(null);
|
49
48
|
var _useState = useState(0),
|
50
49
|
_useState2 = _slicedToArray(_useState, 2),
|
51
50
|
linkFocusIndex = _useState2[0],
|
@@ -57,7 +56,7 @@ var CoachmarkStackHome = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
57
56
|
}
|
58
57
|
}, 100);
|
59
58
|
}, [isOpen]);
|
60
|
-
var portalNode = useRef();
|
59
|
+
var portalNode = useRef(null);
|
61
60
|
useIsomorphicEffect(function () {
|
62
61
|
var _document$querySelect, _document, _document2, _document3;
|
63
62
|
portalNode.current = portalTarget ? (_document$querySelect = (_document = document) === null || _document === void 0 ? void 0 : _document.querySelector(portalTarget)) !== null && _document$querySelect !== void 0 ? _document$querySelect : (_document2 = document) === null || _document2 === void 0 ? void 0 : _document2.querySelector('body') : (_document3 = document) === null || _document3 === void 0 ? void 0 : _document3.querySelector('body');
|
@@ -65,6 +64,20 @@ var CoachmarkStackHome = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
65
64
|
if (!navLinkLabels) {
|
66
65
|
return pconsole.warn("".concat(componentName, " is an Onboarding internal component and is not intended for general use."));
|
67
66
|
}
|
67
|
+
function renderNavLink(index, label) {
|
68
|
+
var ref = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
|
69
|
+
return /*#__PURE__*/React__default.createElement("li", {
|
70
|
+
key: index
|
71
|
+
}, /*#__PURE__*/React__default.createElement(Button, {
|
72
|
+
kind: "ghost",
|
73
|
+
size: "sm",
|
74
|
+
onClick: function onClick() {
|
75
|
+
setLinkFocusIndex(index);
|
76
|
+
onClickNavItem(index + 1);
|
77
|
+
},
|
78
|
+
ref: ref
|
79
|
+
}, label));
|
80
|
+
}
|
68
81
|
return portalNode !== null && portalNode !== void 0 && portalNode.current ? /*#__PURE__*/createPortal( /*#__PURE__*/React__default.createElement("div", _extends({}, rest, {
|
69
82
|
className: cx(blockClass, className),
|
70
83
|
ref: ref,
|
@@ -96,9 +109,8 @@ var CoachmarkStackHome = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
96
109
|
}, navLinkLabels.map(function (label, index) {
|
97
110
|
if (index === linkFocusIndex) {
|
98
111
|
return renderNavLink(index, label, buttonFocusRef);
|
99
|
-
} else {
|
100
|
-
return renderNavLink(index, label);
|
101
112
|
}
|
113
|
+
return renderNavLink(index, label);
|
102
114
|
})), closeButtonLabel && /*#__PURE__*/React__default.createElement("div", {
|
103
115
|
className: "".concat(overlayClass, "__footer")
|
104
116
|
}, /*#__PURE__*/React__default.createElement(Button, {
|
@@ -108,20 +120,6 @@ var CoachmarkStackHome = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
108
120
|
_onClose();
|
109
121
|
}
|
110
122
|
}, closeButtonLabel))))), portalNode === null || portalNode === void 0 ? void 0 : portalNode.current) : null;
|
111
|
-
function renderNavLink(index, label) {
|
112
|
-
var ref = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
|
113
|
-
return /*#__PURE__*/React__default.createElement("li", {
|
114
|
-
key: index
|
115
|
-
}, /*#__PURE__*/React__default.createElement(Button, {
|
116
|
-
kind: "ghost",
|
117
|
-
size: "sm",
|
118
|
-
onClick: function onClick() {
|
119
|
-
setLinkFocusIndex(index);
|
120
|
-
onClickNavItem(index + 1);
|
121
|
-
},
|
122
|
-
ref: ref
|
123
|
-
}, label));
|
124
|
-
}
|
125
123
|
});
|
126
124
|
|
127
125
|
// Return a placeholder if not released and not enabled by feature flag
|
@@ -168,7 +166,7 @@ CoachmarkStackHome.propTypes = {
|
|
168
166
|
/**
|
169
167
|
* The labels used to link to the stackable Coachmarks.
|
170
168
|
*/
|
171
|
-
navLinkLabels: PropTypes.arrayOf(PropTypes.string).isRequired,
|
169
|
+
navLinkLabels: PropTypes.arrayOf(PropTypes.string.isRequired).isRequired,
|
172
170
|
/**
|
173
171
|
* For internal use only by CoachmarkStack and CoachmarkStackHome.
|
174
172
|
*/
|
@@ -80,7 +80,8 @@ exports.CoachmarkOverlayElements = /*#__PURE__*/React__default["default"].forwar
|
|
80
80
|
var setCurrentProgStep = function setCurrentProgStep(value) {
|
81
81
|
if (currentProgStep > 0 && value === 0 && buttonFocusRef.current) {
|
82
82
|
setTimeout(function () {
|
83
|
-
|
83
|
+
var _buttonFocusRef$curre;
|
84
|
+
(_buttonFocusRef$curre = buttonFocusRef.current) === null || _buttonFocusRef$curre === void 0 || _buttonFocusRef$curre.focus();
|
84
85
|
}, 1000);
|
85
86
|
}
|
86
87
|
_setCurrentProgStep(value);
|
@@ -1,8 +1,73 @@
|
|
1
|
+
/**
|
2
|
+
* Copyright IBM Corp. 2023, 2024
|
3
|
+
*
|
4
|
+
* This source code is licensed under the Apache-2.0 license found in the
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
6
|
+
*/
|
7
|
+
import React, { ReactNode } from 'react';
|
8
|
+
type Media = {
|
9
|
+
render?: () => ReactNode;
|
10
|
+
} | {
|
11
|
+
filePaths?: string[];
|
12
|
+
};
|
13
|
+
interface CoachmarkStackProps {
|
14
|
+
/**
|
15
|
+
* CoachmarkStack should use a single CoachmarkOverlayElements component as a child.
|
16
|
+
*/
|
17
|
+
children: ReactNode;
|
18
|
+
/**
|
19
|
+
* Provide an optional class to be applied to the containing node.
|
20
|
+
*/
|
21
|
+
className?: string;
|
22
|
+
/**
|
23
|
+
* The label for the button that will close the Stack
|
24
|
+
*/
|
25
|
+
closeButtonLabel?: string;
|
26
|
+
/**
|
27
|
+
* The description of the Coachmark.
|
28
|
+
*/
|
29
|
+
description: ReactNode;
|
30
|
+
/**
|
31
|
+
* The object describing an image in one of two shapes.
|
32
|
+
*
|
33
|
+
* If a single media element is required, use `{render}`.
|
34
|
+
*
|
35
|
+
* If a stepped animation is required, use `{filePaths}`.
|
36
|
+
*
|
37
|
+
* @see {@link MEDIA_PROP_TYPE}.
|
38
|
+
*/
|
39
|
+
media?: Media;
|
40
|
+
/**
|
41
|
+
* The labels used to link to the stackable Coachmarks.
|
42
|
+
*/
|
43
|
+
navLinkLabels: string[];
|
44
|
+
/**
|
45
|
+
* Function to call when the CoachmarkStack closes.
|
46
|
+
*/
|
47
|
+
onClose?: () => void;
|
48
|
+
/**
|
49
|
+
* Where in the DOM to render the stack.
|
50
|
+
* The default is `document.body`.
|
51
|
+
*/
|
52
|
+
portalTarget?: string;
|
53
|
+
/**
|
54
|
+
* The tagline title which will be fixed to the bottom right of the window and will serve as the display trigger.
|
55
|
+
*/
|
56
|
+
tagline: string;
|
57
|
+
/**
|
58
|
+
* Determines the theme of the component.
|
59
|
+
*/
|
60
|
+
theme?: 'light' | 'dark';
|
61
|
+
/**
|
62
|
+
* The title of the Coachmark.
|
63
|
+
*/
|
64
|
+
title: string;
|
65
|
+
}
|
1
66
|
/**
|
2
67
|
* Stacked coachmarks are used to call out specific functionality or concepts
|
3
68
|
* within the UI that may not be intuitive but are important for the
|
4
69
|
* user to gain understanding of the product's main value and discover new use cases.
|
5
70
|
* This variant allows the stacking of multiple coachmark overlays to be displayed by interacting with the tagline.
|
6
71
|
*/
|
7
|
-
export let CoachmarkStack: React.ForwardRefExoticComponent<React.RefAttributes<
|
8
|
-
|
72
|
+
export declare let CoachmarkStack: React.ForwardRefExoticComponent<CoachmarkStackProps & React.RefAttributes<HTMLDivElement>>;
|
73
|
+
export {};
|
@@ -40,7 +40,8 @@ var elementBlockClass = "".concat(settings.pkg.prefix, "--coachmark-stack-elemen
|
|
40
40
|
var defaults = {
|
41
41
|
onClose: function onClose() {},
|
42
42
|
// Pass through to CoachmarkStackHome
|
43
|
-
theme: 'light'
|
43
|
+
theme: 'light',
|
44
|
+
portalTarget: 'body'
|
44
45
|
};
|
45
46
|
|
46
47
|
// NOTE
|
@@ -72,12 +73,12 @@ exports.CoachmarkStack = /*#__PURE__*/React__default["default"].forwardRef(funct
|
|
72
73
|
theme = _ref$theme === void 0 ? defaults.theme : _ref$theme,
|
73
74
|
title = _ref.title,
|
74
75
|
rest = _rollupPluginBabelHelpers.objectWithoutProperties(_ref, _excluded);
|
75
|
-
var portalNode = React.useRef();
|
76
|
+
var portalNode = React.useRef(null);
|
76
77
|
useIsomorphicEffect.useIsomorphicEffect(function () {
|
77
78
|
var _document$querySelect, _document, _document2, _document3;
|
78
79
|
portalNode.current = portalTarget ? (_document$querySelect = (_document = document) === null || _document === void 0 ? void 0 : _document.querySelector(portalTarget)) !== null && _document$querySelect !== void 0 ? _document$querySelect : (_document2 = document) === null || _document2 === void 0 ? void 0 : _document2.querySelector('body') : (_document3 = document) === null || _document3 === void 0 ? void 0 : _document3.querySelector('body');
|
79
80
|
}, [portalTarget]);
|
80
|
-
var stackHomeRef = React.useRef();
|
81
|
+
var stackHomeRef = React.useRef(null);
|
81
82
|
var stackedCoachmarkRefs = React.useRef([]);
|
82
83
|
var _useState = React.useState(false),
|
83
84
|
_useState2 = _rollupPluginBabelHelpers.slicedToArray(_useState, 2),
|
@@ -91,7 +92,7 @@ exports.CoachmarkStack = /*#__PURE__*/React__default["default"].forwardRef(funct
|
|
91
92
|
selectedItemNumber = _useState4[0],
|
92
93
|
setSelectedItemNumber = _useState4[1];
|
93
94
|
// // The parent height and width values to return to after unstacked
|
94
|
-
var _useState5 = React.useState(
|
95
|
+
var _useState5 = React.useState(),
|
95
96
|
_useState6 = _rollupPluginBabelHelpers.slicedToArray(_useState5, 2),
|
96
97
|
parentHeight = _useState6[0],
|
97
98
|
setParentHeight = _useState6[1];
|
@@ -172,14 +173,20 @@ exports.CoachmarkStack = /*#__PURE__*/React__default["default"].forwardRef(funct
|
|
172
173
|
if (!parentHeight) {
|
173
174
|
return;
|
174
175
|
}
|
175
|
-
stackHomeRef.current
|
176
|
+
if (stackHomeRef.current) {
|
177
|
+
stackHomeRef.current.style.height = "".concat(parentHeight, "px");
|
178
|
+
}
|
176
179
|
if (!isOpen || targetSelectedItem < 0) {
|
177
|
-
stackHomeRef.current
|
180
|
+
if (stackHomeRef.current) {
|
181
|
+
stackHomeRef.current.focus();
|
182
|
+
}
|
178
183
|
return;
|
179
184
|
}
|
180
185
|
var targetHomeHeight = stackedCoachmarkRefs.current[targetSelectedItem].clientHeight;
|
181
|
-
stackHomeRef.current
|
182
|
-
|
186
|
+
if (stackHomeRef.current) {
|
187
|
+
stackHomeRef.current.style.height = "".concat(targetHomeHeight, "px");
|
188
|
+
stackedCoachmarkRefs.current[targetSelectedItem].focus();
|
189
|
+
}
|
183
190
|
}, [selectedItemNumber, isOpen, parentHeight]);
|
184
191
|
var wrappedChildren = React.Children.map(childArray, function (child, idx) {
|
185
192
|
var mountedClass = mountedRef.current ? "".concat(elementBlockClass, "--is-mounted") : '';
|
@@ -267,7 +274,7 @@ exports.CoachmarkStack.propTypes = {
|
|
267
274
|
/**
|
268
275
|
* The labels used to link to the stackable Coachmarks.
|
269
276
|
*/
|
270
|
-
navLinkLabels: index["default"].arrayOf(index["default"].string).isRequired,
|
277
|
+
navLinkLabels: index["default"].arrayOf(index["default"].string.isRequired).isRequired,
|
271
278
|
/**
|
272
279
|
* Function to call when the CoachmarkStack closes.
|
273
280
|
*/
|
@@ -1,6 +1,75 @@
|
|
1
|
+
/**
|
2
|
+
* Copyright IBM Corp. 2023, 2024
|
3
|
+
*
|
4
|
+
* This source code is licensed under the Apache-2.0 license found in the
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
6
|
+
*/
|
7
|
+
import React, { ReactNode } from 'react';
|
8
|
+
type Media = {
|
9
|
+
render?: () => ReactNode;
|
10
|
+
filePaths?: never;
|
11
|
+
} | {
|
12
|
+
render?: never;
|
13
|
+
filePaths?: string[];
|
14
|
+
};
|
15
|
+
interface CoachmarkStackHomeProps {
|
16
|
+
/**
|
17
|
+
* Optional class name for this component.
|
18
|
+
*/
|
19
|
+
className?: string;
|
20
|
+
/**
|
21
|
+
* The label for the button that will close the stack
|
22
|
+
*/
|
23
|
+
closeButtonLabel?: string;
|
24
|
+
/**
|
25
|
+
* The description of the Coachmark.
|
26
|
+
*/
|
27
|
+
description: React.ReactNode;
|
28
|
+
/**
|
29
|
+
* If the stack home is open.
|
30
|
+
*/
|
31
|
+
isOpen: boolean;
|
32
|
+
/**
|
33
|
+
* The object describing an image in one of two shapes.
|
34
|
+
*
|
35
|
+
* If a single media element is required, use `{render}`.
|
36
|
+
*
|
37
|
+
* If a stepped animation is required, use `{filePaths}`.
|
38
|
+
*
|
39
|
+
* @see {@link MEDIA_PROP_TYPE}.
|
40
|
+
*/
|
41
|
+
media?: Media;
|
42
|
+
/**
|
43
|
+
* The labels used to link to the stackable Coachmarks.
|
44
|
+
*/
|
45
|
+
navLinkLabels: string[];
|
46
|
+
/**
|
47
|
+
* For internal use only by CoachmarkStack and CoachmarkStackHome.
|
48
|
+
*/
|
49
|
+
onClickNavItem: (index: number) => void;
|
50
|
+
/**
|
51
|
+
* Function to call when the stack closes.
|
52
|
+
*/
|
53
|
+
onClose: () => void;
|
54
|
+
/**
|
55
|
+
* By default, the CoachmarkStackHome will be appended to the end of `document.body`.
|
56
|
+
* The CoachmarkStackHome will remain persistent as the user navigates the app until
|
57
|
+
* the user closes the CoachmarkStackHome.
|
58
|
+
*
|
59
|
+
* Alternatively, the app developer can tightly couple the CoachmarkStackHome to a DOM
|
60
|
+
* element or other component by specifying a CSS selector. The CoachmarkStackHome will
|
61
|
+
* remain visible as long as that element remains visible or mounted. When the
|
62
|
+
* element is hidden or component is unmounted, the CoachmarkStackHome will disappear.
|
63
|
+
*/
|
64
|
+
portalTarget?: string;
|
65
|
+
/**
|
66
|
+
* The title of the Coachmark.
|
67
|
+
*/
|
68
|
+
title: string;
|
69
|
+
}
|
1
70
|
/**
|
2
71
|
* DO NOT USE. This component is for the exclusive use
|
3
72
|
* of other Onboarding components.
|
4
73
|
*/
|
5
|
-
export let CoachmarkStackHome: React.ForwardRefExoticComponent<React.RefAttributes<
|
6
|
-
|
74
|
+
export declare let CoachmarkStackHome: React.ForwardRefExoticComponent<CoachmarkStackHomeProps & React.RefAttributes<HTMLDivElement>>;
|
75
|
+
export {};
|
@@ -29,7 +29,6 @@ var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
29
29
|
var cx__default = /*#__PURE__*/_interopDefaultLegacy(cx);
|
30
30
|
|
31
31
|
var _excluded = ["className", "description", "isOpen", "media", "navLinkLabels", "onClickNavItem", "onClose", "portalTarget", "closeButtonLabel", "title"];
|
32
|
-
|
33
32
|
// Carbon and package components we use.
|
34
33
|
/* TODO: @import(s) of carbon components and other package components. */
|
35
34
|
|
@@ -54,7 +53,7 @@ exports.CoachmarkStackHome = /*#__PURE__*/React.forwardRef(function (_ref, ref)
|
|
54
53
|
closeButtonLabel = _ref.closeButtonLabel,
|
55
54
|
title = _ref.title,
|
56
55
|
rest = _rollupPluginBabelHelpers.objectWithoutProperties(_ref, _excluded);
|
57
|
-
var buttonFocusRef = React.useRef();
|
56
|
+
var buttonFocusRef = React.useRef(null);
|
58
57
|
var _useState = React.useState(0),
|
59
58
|
_useState2 = _rollupPluginBabelHelpers.slicedToArray(_useState, 2),
|
60
59
|
linkFocusIndex = _useState2[0],
|
@@ -66,7 +65,7 @@ exports.CoachmarkStackHome = /*#__PURE__*/React.forwardRef(function (_ref, ref)
|
|
66
65
|
}
|
67
66
|
}, 100);
|
68
67
|
}, [isOpen]);
|
69
|
-
var portalNode = React.useRef();
|
68
|
+
var portalNode = React.useRef(null);
|
70
69
|
useIsomorphicEffect.useIsomorphicEffect(function () {
|
71
70
|
var _document$querySelect, _document, _document2, _document3;
|
72
71
|
portalNode.current = portalTarget ? (_document$querySelect = (_document = document) === null || _document === void 0 ? void 0 : _document.querySelector(portalTarget)) !== null && _document$querySelect !== void 0 ? _document$querySelect : (_document2 = document) === null || _document2 === void 0 ? void 0 : _document2.querySelector('body') : (_document3 = document) === null || _document3 === void 0 ? void 0 : _document3.querySelector('body');
|
@@ -74,6 +73,20 @@ exports.CoachmarkStackHome = /*#__PURE__*/React.forwardRef(function (_ref, ref)
|
|
74
73
|
if (!navLinkLabels) {
|
75
74
|
return pconsole["default"].warn("".concat(componentName, " is an Onboarding internal component and is not intended for general use."));
|
76
75
|
}
|
76
|
+
function renderNavLink(index, label) {
|
77
|
+
var ref = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
|
78
|
+
return /*#__PURE__*/React__default["default"].createElement("li", {
|
79
|
+
key: index
|
80
|
+
}, /*#__PURE__*/React__default["default"].createElement(react.Button, {
|
81
|
+
kind: "ghost",
|
82
|
+
size: "sm",
|
83
|
+
onClick: function onClick() {
|
84
|
+
setLinkFocusIndex(index);
|
85
|
+
onClickNavItem(index + 1);
|
86
|
+
},
|
87
|
+
ref: ref
|
88
|
+
}, label));
|
89
|
+
}
|
77
90
|
return portalNode !== null && portalNode !== void 0 && portalNode.current ? /*#__PURE__*/reactDom.createPortal( /*#__PURE__*/React__default["default"].createElement("div", _rollupPluginBabelHelpers["extends"]({}, rest, {
|
78
91
|
className: cx__default["default"](blockClass, className),
|
79
92
|
ref: ref,
|
@@ -105,9 +118,8 @@ exports.CoachmarkStackHome = /*#__PURE__*/React.forwardRef(function (_ref, ref)
|
|
105
118
|
}, navLinkLabels.map(function (label, index) {
|
106
119
|
if (index === linkFocusIndex) {
|
107
120
|
return renderNavLink(index, label, buttonFocusRef);
|
108
|
-
} else {
|
109
|
-
return renderNavLink(index, label);
|
110
121
|
}
|
122
|
+
return renderNavLink(index, label);
|
111
123
|
})), closeButtonLabel && /*#__PURE__*/React__default["default"].createElement("div", {
|
112
124
|
className: "".concat(overlayClass, "__footer")
|
113
125
|
}, /*#__PURE__*/React__default["default"].createElement(react.Button, {
|
@@ -117,20 +129,6 @@ exports.CoachmarkStackHome = /*#__PURE__*/React.forwardRef(function (_ref, ref)
|
|
117
129
|
_onClose();
|
118
130
|
}
|
119
131
|
}, closeButtonLabel))))), portalNode === null || portalNode === void 0 ? void 0 : portalNode.current) : null;
|
120
|
-
function renderNavLink(index, label) {
|
121
|
-
var ref = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
|
122
|
-
return /*#__PURE__*/React__default["default"].createElement("li", {
|
123
|
-
key: index
|
124
|
-
}, /*#__PURE__*/React__default["default"].createElement(react.Button, {
|
125
|
-
kind: "ghost",
|
126
|
-
size: "sm",
|
127
|
-
onClick: function onClick() {
|
128
|
-
setLinkFocusIndex(index);
|
129
|
-
onClickNavItem(index + 1);
|
130
|
-
},
|
131
|
-
ref: ref
|
132
|
-
}, label));
|
133
|
-
}
|
134
132
|
});
|
135
133
|
|
136
134
|
// Return a placeholder if not released and not enabled by feature flag
|
@@ -177,7 +175,7 @@ exports.CoachmarkStackHome.propTypes = {
|
|
177
175
|
/**
|
178
176
|
* The labels used to link to the stackable Coachmarks.
|
179
177
|
*/
|
180
|
-
navLinkLabels: index["default"].arrayOf(index["default"].string).isRequired,
|
178
|
+
navLinkLabels: index["default"].arrayOf(index["default"].string.isRequired).isRequired,
|
181
179
|
/**
|
182
180
|
* For internal use only by CoachmarkStack and CoachmarkStackHome.
|
183
181
|
*/
|
package/package.json
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"name": "@carbon/ibm-products",
|
3
3
|
"description": "Carbon for IBM Products",
|
4
|
-
"version": "2.43.2-canary.
|
4
|
+
"version": "2.43.2-canary.122+61857e572",
|
5
5
|
"license": "Apache-2.0",
|
6
6
|
"main": "lib/index.js",
|
7
7
|
"module": "es/index.js",
|
@@ -96,7 +96,7 @@
|
|
96
96
|
"dependencies": {
|
97
97
|
"@babel/runtime": "^7.23.9",
|
98
98
|
"@carbon/feature-flags": "^0.20.0",
|
99
|
-
"@carbon/ibm-products-styles": "^2.
|
99
|
+
"@carbon/ibm-products-styles": "^2.43.0-rc.0",
|
100
100
|
"@carbon/telemetry": "^0.1.0",
|
101
101
|
"@dnd-kit/core": "^6.0.8",
|
102
102
|
"@dnd-kit/modifiers": "^7.0.0",
|
@@ -120,5 +120,5 @@
|
|
120
120
|
"react": "^16.8.6 || ^17.0.1 || ^18.2.0",
|
121
121
|
"react-dom": "^16.8.6 || ^17.0.1 || ^18.2.0"
|
122
122
|
},
|
123
|
-
"gitHead": "
|
123
|
+
"gitHead": "61857e572765408bbda4ad00aa7c320469e4a96c"
|
124
124
|
}
|