@carbon/ibm-products 2.54.0-canary.50 → 2.54.0-canary.52

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -24,11 +24,16 @@ export interface CoachmarkOverlayElementsProps {
24
24
  * The object describing an image in one of two shapes.
25
25
  * If a single media element is required, use `{render}`.
26
26
  * If a stepped animation is required, use `{filePaths}`.
27
+ * * @deprecated please use the `renderMedia` prop
27
28
  */
28
29
  media?: {
29
30
  render?: () => ReactNode;
30
31
  filePaths?: string[];
31
32
  };
33
+ /**
34
+ * Optional prop to render any media like images or any animated media.
35
+ */
36
+ renderMedia?: (params: any) => ReactNode;
32
37
  /**
33
38
  * The label for the Next button.
34
39
  */
@@ -7,7 +7,7 @@
7
7
 
8
8
  import { objectWithoutProperties as _objectWithoutProperties, slicedToArray as _slicedToArray, extends as _extends } from '../../_virtual/_rollupPluginBabelHelpers.js';
9
9
  import { Button } from '@carbon/react';
10
- import React__default, { useRef, useState, Children, useEffect } from 'react';
10
+ import React__default, { useRef, useState, Children, useMemo, useEffect } from 'react';
11
11
  import { Carousel } from '../Carousel/Carousel.js';
12
12
  import '../Carousel/CarouselItem.js';
13
13
  import PropTypes from '../../_virtual/index.js';
@@ -20,7 +20,7 @@ import { pkg } from '../../settings.js';
20
20
  import '../Coachmark/Coachmark.js';
21
21
  import { useCoachmark } from '../Coachmark/utils/context.js';
22
22
 
23
- var _excluded = ["className", "children", "isVisible", "media", "nextButtonText", "previousButtonLabel", "closeButtonLabel"];
23
+ var _excluded = ["className", "children", "isVisible", "media", "renderMedia", "nextButtonText", "previousButtonLabel", "closeButtonLabel"];
24
24
 
25
25
  // The block part of our conventional BEM class names (blockClass__E--M).
26
26
  var blockClass = "".concat(pkg.prefix, "--coachmark-overlay-elements");
@@ -53,6 +53,7 @@ var CoachmarkOverlayElements = /*#__PURE__*/React__default.forwardRef(function (
53
53
  _ref$isVisible = _ref.isVisible,
54
54
  isVisible = _ref$isVisible === void 0 ? defaults.isVisible : _ref$isVisible,
55
55
  media = _ref.media,
56
+ renderMedia = _ref.renderMedia,
56
57
  _ref$nextButtonText = _ref.nextButtonText,
57
58
  nextButtonText = _ref$nextButtonText === void 0 ? defaults.nextButtonText : _ref$nextButtonText,
58
59
  _ref$previousButtonLa = _ref.previousButtonLabel,
@@ -71,6 +72,7 @@ var CoachmarkOverlayElements = /*#__PURE__*/React__default.forwardRef(function (
71
72
  currentProgStep = _useState4[0],
72
73
  _setCurrentProgStep = _useState4[1];
73
74
  var coachmark = useCoachmark();
75
+ var hasMedia = media || renderMedia;
74
76
  var setCurrentProgStep = function setCurrentProgStep(value) {
75
77
  if (currentProgStep > 0 && value === 0 && buttonFocusRef.current) {
76
78
  setTimeout(function () {
@@ -83,6 +85,11 @@ var CoachmarkOverlayElements = /*#__PURE__*/React__default.forwardRef(function (
83
85
  var numProgSteps = Children.count(children);
84
86
  var progStepFloor = 0;
85
87
  var progStepCeil = numProgSteps - 1;
88
+ var renderMediaContent = useMemo(function () {
89
+ return renderMedia === null || renderMedia === void 0 ? void 0 : renderMedia({
90
+ playStep: currentProgStep
91
+ });
92
+ }, [currentProgStep, renderMedia]);
86
93
  useEffect(function () {
87
94
  // On mount, one of the two primary buttons ("next" or "close")
88
95
  // will be rendered and must have focus. (a11y)
@@ -111,11 +118,13 @@ var CoachmarkOverlayElements = /*#__PURE__*/React__default.forwardRef(function (
111
118
  // example: [`${blockClass}__here-if-small`]: size === 'sm',
112
119
  }),
113
120
  ref: ref
114
- }, getDevtoolsProps(componentName)), media && (media.render ? media.render() : /*#__PURE__*/React__default.createElement(SteppedAnimatedMedia, {
121
+ }, getDevtoolsProps(componentName)), hasMedia && (media === null || media === void 0 ? void 0 : media.render) && media.render(), hasMedia && (media === null || media === void 0 ? void 0 : media.filePaths) && /*#__PURE__*/React__default.createElement(SteppedAnimatedMedia, {
115
122
  className: "".concat(blockClass, "__element-stepped-media"),
116
123
  filePaths: media.filePaths,
117
124
  playStep: currentProgStep
118
- })), numProgSteps === 1 ? /*#__PURE__*/React__default.createElement(React__default.Fragment, null, children, closeButtonLabel && /*#__PURE__*/React__default.createElement("div", {
125
+ }), hasMedia && renderMedia && /*#__PURE__*/React__default.createElement("div", {
126
+ className: "".concat(blockClass, "__element-stepped-media")
127
+ }, renderMediaContent), numProgSteps === 1 ? /*#__PURE__*/React__default.createElement(React__default.Fragment, null, children, closeButtonLabel && /*#__PURE__*/React__default.createElement("div", {
119
128
  className: cx("".concat(blockClass, "__footer"), 'coachmark-carousel-controls')
120
129
  }, /*#__PURE__*/React__default.createElement(Button, _extends({
121
130
  size: "sm"
@@ -194,6 +203,7 @@ CoachmarkOverlayElements.propTypes = {
194
203
  * The object describing an image in one of two shapes.
195
204
  * If a single media element is required, use `{render}`.
196
205
  * If a stepped animation is required, use `{filePaths}`.
206
+ * @deprecated please use the `renderMedia` prop
197
207
  */
198
208
  /**@ts-ignore*/
199
209
  media: PropTypes.oneOfType([PropTypes.shape({
@@ -208,7 +218,11 @@ CoachmarkOverlayElements.propTypes = {
208
218
  /**
209
219
  * The label for the Previous button.
210
220
  */
211
- previousButtonLabel: PropTypes.string
221
+ previousButtonLabel: PropTypes.string,
222
+ /**
223
+ * Optional prop to render any media like images or animated media.
224
+ */
225
+ renderMedia: PropTypes.func
212
226
  };
213
227
 
214
228
  export { CoachmarkOverlayElements };
@@ -39,6 +39,10 @@ interface CoachmarkStackHomeProps {
39
39
  * @see {@link MEDIA_PROP_TYPE}.
40
40
  */
41
41
  media?: Media;
42
+ /**
43
+ * Optional prop to render any media like images or any animated media.
44
+ */
45
+ renderMedia?: (params: any) => ReactNode;
42
46
  /**
43
47
  * The labels used to link to the stackable Coachmarks.
44
48
  */
@@ -17,9 +17,10 @@ import { pkg } from '../../settings.js';
17
17
  import { createPortal } from 'react-dom';
18
18
  import { CoachmarkHeader } from '../Coachmark/CoachmarkHeader.js';
19
19
  import { SteppedAnimatedMedia } from '../SteppedAnimatedMedia/SteppedAnimatedMedia.js';
20
+ import { deprecateProp } from '../../global/js/utils/props-helper.js';
20
21
  import { useIsomorphicEffect } from '../../global/js/hooks/useIsomorphicEffect.js';
21
22
 
22
- var _excluded = ["className", "description", "isOpen", "media", "navLinkLabels", "onClickNavItem", "onClose", "portalTarget", "closeButtonLabel", "title"];
23
+ var _excluded = ["className", "description", "isOpen", "media", "renderMedia", "navLinkLabels", "onClickNavItem", "onClose", "portalTarget", "closeButtonLabel", "title"];
23
24
  // Carbon and package components we use.
24
25
  /* TODO: @import(s) of carbon components and other package components. */
25
26
 
@@ -37,6 +38,7 @@ var CoachmarkStackHome = /*#__PURE__*/forwardRef(function (_ref, ref) {
37
38
  description = _ref.description,
38
39
  isOpen = _ref.isOpen,
39
40
  media = _ref.media,
41
+ renderMedia = _ref.renderMedia,
40
42
  navLinkLabels = _ref.navLinkLabels,
41
43
  onClickNavItem = _ref.onClickNavItem,
42
44
  _onClose = _ref.onClose,
@@ -49,6 +51,7 @@ var CoachmarkStackHome = /*#__PURE__*/forwardRef(function (_ref, ref) {
49
51
  _useState2 = _slicedToArray(_useState, 2),
50
52
  linkFocusIndex = _useState2[0],
51
53
  setLinkFocusIndex = _useState2[1];
54
+ var hasMedia = media || renderMedia;
52
55
  useEffect(function () {
53
56
  setTimeout(function () {
54
57
  if (isOpen && buttonFocusRef.current) {
@@ -90,13 +93,17 @@ var CoachmarkStackHome = /*#__PURE__*/forwardRef(function (_ref, ref) {
90
93
  className: "".concat(overlayClass, "__body")
91
94
  }, /*#__PURE__*/React__default.createElement("div", {
92
95
  className: "".concat(overlayClass, "-element")
93
- }, !media && /*#__PURE__*/React__default.createElement(Idea, {
96
+ }, !hasMedia && /*#__PURE__*/React__default.createElement(Idea, {
94
97
  size: 20,
95
98
  className: "".concat(blockClass, "__icon-idea")
96
- }), media && (media.render ? media.render() : /*#__PURE__*/React__default.createElement(SteppedAnimatedMedia, {
97
- className: "".concat(overlayClass, "__element-stepped-media"),
99
+ }), hasMedia && (media === null || media === void 0 ? void 0 : media.render) && media.render(), hasMedia && (media === null || media === void 0 ? void 0 : media.filePaths) && /*#__PURE__*/React__default.createElement(SteppedAnimatedMedia, {
100
+ className: "".concat(blockClass, "__element-stepped-media"),
98
101
  filePaths: media.filePaths,
99
102
  playStep: 0
103
+ }), hasMedia && renderMedia && /*#__PURE__*/React__default.createElement("div", {
104
+ className: "".concat(blockClass, "__element-stepped-media")
105
+ }, renderMedia({
106
+ playStep: 0
100
107
  })), /*#__PURE__*/React__default.createElement("div", {
101
108
  className: "".concat(overlayClass, "-element__content")
102
109
  }, title && /*#__PURE__*/React__default.createElement("h2", {
@@ -156,12 +163,13 @@ CoachmarkStackHome.propTypes = {
156
163
  * If a stepped animation is required, use `{filePaths}`.
157
164
  *
158
165
  * @see {@link MEDIA_PROP_TYPE}.
166
+ * @deprecated please use the `renderMedia` prop
159
167
  */
160
- media: PropTypes.oneOfType([PropTypes.shape({
168
+ media: deprecateProp(PropTypes.oneOfType([PropTypes.shape({
161
169
  render: PropTypes.func
162
170
  }), PropTypes.shape({
163
171
  filePaths: PropTypes.arrayOf(PropTypes.string)
164
- })]),
172
+ })]), ''),
165
173
  /**
166
174
  * The labels used to link to the stackable Coachmarks.
167
175
  */
@@ -185,6 +193,10 @@ CoachmarkStackHome.propTypes = {
185
193
  * element is hidden or component is unmounted, the CoachmarkStackHome will disappear.
186
194
  */
187
195
  portalTarget: PropTypes.string,
196
+ /**
197
+ * Optional prop to render any media like images or animated media.
198
+ */
199
+ renderMedia: PropTypes.func,
188
200
  /**
189
201
  * The title of the Coachmark.
190
202
  */
@@ -51,8 +51,13 @@ export interface InlineTipProps {
51
51
  * - If a stepped animation is required, use `{filePaths}`.
52
52
  *
53
53
  * Enabling `media` disables the `collapsible` feature.
54
+ * @deprecated please use the `renderMedia` prop
54
55
  */
55
56
  media?: MediaType;
57
+ /**
58
+ * Optional prop to render any media like images or any animated media.
59
+ */
60
+ renderMedia?: () => ReactNode;
56
61
  /**
57
62
  * Set to `true` to arrange the information in a format
58
63
  * that is easier to read in a limited space.
@@ -18,7 +18,7 @@ import { pkg } from '../../settings.js';
18
18
  import uuidv4 from '../../global/js/utils/uuidv4.js';
19
19
 
20
20
  var _Close, _Idea, _Crossroads;
21
- var _excluded = ["action", "children", "className", "closeIconDescription", "collapsible", "collapseButtonLabel", "expandButtonLabel", "media", "narrow", "onClick", "onClose", "tertiaryButtonLabel", "title", "withLeftGutter"];
21
+ var _excluded = ["action", "children", "className", "closeIconDescription", "collapsible", "collapseButtonLabel", "expandButtonLabel", "media", "renderMedia", "narrow", "onClick", "onClose", "tertiaryButtonLabel", "title", "withLeftGutter"];
22
22
 
23
23
  // The block part of our conventional BEM class names (blockClass__E--M).
24
24
  var blockClass = "".concat(pkg.prefix, "--inline-tip");
@@ -56,6 +56,7 @@ var InlineTip = /*#__PURE__*/React__default.forwardRef(function (_ref, ref) {
56
56
  _ref$expandButtonLabe = _ref.expandButtonLabel,
57
57
  expandButtonLabel = _ref$expandButtonLabe === void 0 ? defaults.expandButtonLabel : _ref$expandButtonLabe,
58
58
  media = _ref.media,
59
+ renderMedia = _ref.renderMedia,
59
60
  _ref$narrow = _ref.narrow,
60
61
  narrow = _ref$narrow === void 0 ? defaults.narrow : _ref$narrow,
61
62
  onClick = _ref.onClick,
@@ -66,6 +67,7 @@ var InlineTip = /*#__PURE__*/React__default.forwardRef(function (_ref, ref) {
66
67
  _ref$withLeftGutter = _ref.withLeftGutter,
67
68
  withLeftGutter = _ref$withLeftGutter === void 0 ? defaults.withLeftGutter : _ref$withLeftGutter,
68
69
  rest = _objectWithoutProperties(_ref, _excluded);
70
+ var hasMedia = renderMedia || media;
69
71
  var _useState = useState(collapsible),
70
72
  _useState2 = _slicedToArray(_useState, 2),
71
73
  isCollapsed = _useState2[0],
@@ -75,7 +77,7 @@ var InlineTip = /*#__PURE__*/React__default.forwardRef(function (_ref, ref) {
75
77
  return getComponentText(React__default.Children.toArray(children));
76
78
  }, [children]);
77
79
  var childrenToRender = children;
78
- if (!media && collapsible && isCollapsed) {
80
+ if (!hasMedia && collapsible && isCollapsed) {
79
81
  childrenToRender = /*#__PURE__*/React__default.createElement("p", {
80
82
  className: "".concat(blockClass, "__preview-text")
81
83
  }, previewText);
@@ -87,7 +89,7 @@ var InlineTip = /*#__PURE__*/React__default.forwardRef(function (_ref, ref) {
87
89
  }, [collapsible]);
88
90
  return /*#__PURE__*/React__default.createElement("div", _extends({}, rest, {
89
91
  "aria-labelledby": labelId,
90
- className: cx(blockClass, className, collapsible && "".concat(blockClass, "__collapsible"), isCollapsed && "".concat(blockClass, "__collapsible-collapsed"), media && "".concat(blockClass, "__has-media"), [narrow ? "".concat(blockClass, "__narrow") : "".concat(blockClass, "__wide")], withLeftGutter && !narrow && "".concat(blockClass, "__with-left-gutter")),
92
+ className: cx(blockClass, className, collapsible && "".concat(blockClass, "__collapsible"), isCollapsed && "".concat(blockClass, "__collapsible-collapsed"), hasMedia && "".concat(blockClass, "__has-media"), [narrow ? "".concat(blockClass, "__narrow") : "".concat(blockClass, "__wide")], withLeftGutter && !narrow && "".concat(blockClass, "__with-left-gutter")),
91
93
  ref: ref,
92
94
  role: "complementary"
93
95
  }, getDevtoolsProps(componentName)), /*#__PURE__*/React__default.createElement("div", {
@@ -100,7 +102,7 @@ var InlineTip = /*#__PURE__*/React__default.forwardRef(function (_ref, ref) {
100
102
  size: "lg"
101
103
  }, _Close || (_Close = /*#__PURE__*/React__default.createElement(Close, {
102
104
  size: 16
103
- })))), (!media && narrow || !narrow) && /*#__PURE__*/React__default.createElement("div", {
105
+ })))), (!hasMedia && narrow || !narrow) && /*#__PURE__*/React__default.createElement("div", {
104
106
  className: "".concat(blockClass, "__icon-idea"),
105
107
  tabIndex: -1
106
108
  }, _Idea || (_Idea = /*#__PURE__*/React__default.createElement(Idea, {
@@ -116,7 +118,7 @@ var InlineTip = /*#__PURE__*/React__default.forwardRef(function (_ref, ref) {
116
118
  className: "".concat(blockClass, "__secondary-btn")
117
119
  }, action)), (collapsible || tertiaryButtonLabel) && /*#__PURE__*/React__default.createElement("footer", {
118
120
  className: "".concat(blockClass, "__footer")
119
- }, collapsible && !media && /*#__PURE__*/React__default.createElement(Button, {
121
+ }, collapsible && !hasMedia && /*#__PURE__*/React__default.createElement(Button, {
120
122
  className: "".concat(blockClass, "__toggle-btn"),
121
123
  kind: "ghost",
122
124
  size: "md",
@@ -135,12 +137,14 @@ var InlineTip = /*#__PURE__*/React__default.forwardRef(function (_ref, ref) {
135
137
  size: 16
136
138
  }));
137
139
  }
138
- }, tertiaryButtonLabel))), media && (media.render ? /*#__PURE__*/React__default.createElement("div", {
140
+ }, tertiaryButtonLabel))), hasMedia && (media === null || media === void 0 ? void 0 : media.render) && /*#__PURE__*/React__default.createElement("div", {
139
141
  className: "".concat(blockClass, "__media")
140
- }, media.render()) : /*#__PURE__*/React__default.createElement(SteppedAnimatedMedia, {
142
+ }, media.render()), hasMedia && (media === null || media === void 0 ? void 0 : media.filePaths) && /*#__PURE__*/React__default.createElement(SteppedAnimatedMedia, {
141
143
  className: "".concat(blockClass, "__media"),
142
144
  filePaths: media.filePaths
143
- })));
145
+ }), hasMedia && renderMedia && /*#__PURE__*/React__default.createElement("div", {
146
+ className: "".concat(blockClass, "__media")
147
+ }, renderMedia()));
144
148
  });
145
149
  InlineTip = pkg.checkComponentEnabled(InlineTip, componentName);
146
150
  InlineTip.displayName = componentName;
@@ -186,6 +190,7 @@ InlineTip.propTypes = {
186
190
  * - If a stepped animation is required, use `{filePaths}`.
187
191
  *
188
192
  * Enabling `media` disables the `collapsible` feature.
193
+ * @deprecated please use the `renderMedia` prop
189
194
  */
190
195
  /**@ts-ignore*/
191
196
  media: PropTypes.oneOfType([PropTypes.shape({
@@ -206,6 +211,10 @@ InlineTip.propTypes = {
206
211
  * Function to call when the InlineTip is closed via the "X" button.
207
212
  */
208
213
  onClose: PropTypes.func,
214
+ /**
215
+ * Optional prop to render any media like images or animated media.
216
+ */
217
+ renderMedia: PropTypes.func,
209
218
  /**
210
219
  * Defining the label will show a the tertiary button with the crossroads icon.
211
220
  * You will still need to define the `onClose` method to trigger a callback.
@@ -43,6 +43,7 @@ var SteppedAnimatedMedia = /*#__PURE__*/React__default.forwardRef(function (_ref
43
43
  var backupRef = useRef(null);
44
44
  var localRef = ref !== null && ref !== void 0 ? ref : backupRef;
45
45
  var localRefValue = localRef.current;
46
+ var filePathStr = filePaths === null || filePaths === void 0 ? void 0 : filePaths.join(); //converting the array to string will avoid unwanted useEffect trigger.
46
47
  // load animation source
47
48
  useEffect(function () {
48
49
  var isJsonFile = function isJsonFile(filePath) {
@@ -85,7 +86,8 @@ var SteppedAnimatedMedia = /*#__PURE__*/React__default.forwardRef(function (_ref
85
86
  return _loadArtifact.apply(this, arguments);
86
87
  }
87
88
  loadArtifact();
88
- }, [filePaths]);
89
+ // eslint-disable-next-line
90
+ }, [filePathStr]);
89
91
  useEffect(function () {
90
92
  var _window;
91
93
  var prefersReducedMotion = (_window = window) !== null && _window !== void 0 && _window.matchMedia ? window.matchMedia('(prefers-reduced-motion: reduce)').matches : true;
@@ -24,11 +24,16 @@ export interface CoachmarkOverlayElementsProps {
24
24
  * The object describing an image in one of two shapes.
25
25
  * If a single media element is required, use `{render}`.
26
26
  * If a stepped animation is required, use `{filePaths}`.
27
+ * * @deprecated please use the `renderMedia` prop
27
28
  */
28
29
  media?: {
29
30
  render?: () => ReactNode;
30
31
  filePaths?: string[];
31
32
  };
33
+ /**
34
+ * Optional prop to render any media like images or any animated media.
35
+ */
36
+ renderMedia?: (params: any) => ReactNode;
32
37
  /**
33
38
  * The label for the Next button.
34
39
  */
@@ -22,7 +22,7 @@ var settings = require('../../settings.js');
22
22
  require('../Coachmark/Coachmark.js');
23
23
  var context = require('../Coachmark/utils/context.js');
24
24
 
25
- var _excluded = ["className", "children", "isVisible", "media", "nextButtonText", "previousButtonLabel", "closeButtonLabel"];
25
+ var _excluded = ["className", "children", "isVisible", "media", "renderMedia", "nextButtonText", "previousButtonLabel", "closeButtonLabel"];
26
26
 
27
27
  // The block part of our conventional BEM class names (blockClass__E--M).
28
28
  var blockClass = "".concat(settings.pkg.prefix, "--coachmark-overlay-elements");
@@ -55,6 +55,7 @@ exports.CoachmarkOverlayElements = /*#__PURE__*/React.forwardRef(function (_ref,
55
55
  _ref$isVisible = _ref.isVisible,
56
56
  isVisible = _ref$isVisible === void 0 ? defaults.isVisible : _ref$isVisible,
57
57
  media = _ref.media,
58
+ renderMedia = _ref.renderMedia,
58
59
  _ref$nextButtonText = _ref.nextButtonText,
59
60
  nextButtonText = _ref$nextButtonText === void 0 ? defaults.nextButtonText : _ref$nextButtonText,
60
61
  _ref$previousButtonLa = _ref.previousButtonLabel,
@@ -73,6 +74,7 @@ exports.CoachmarkOverlayElements = /*#__PURE__*/React.forwardRef(function (_ref,
73
74
  currentProgStep = _useState4[0],
74
75
  _setCurrentProgStep = _useState4[1];
75
76
  var coachmark = context.useCoachmark();
77
+ var hasMedia = media || renderMedia;
76
78
  var setCurrentProgStep = function setCurrentProgStep(value) {
77
79
  if (currentProgStep > 0 && value === 0 && buttonFocusRef.current) {
78
80
  setTimeout(function () {
@@ -85,6 +87,11 @@ exports.CoachmarkOverlayElements = /*#__PURE__*/React.forwardRef(function (_ref,
85
87
  var numProgSteps = React.Children.count(children);
86
88
  var progStepFloor = 0;
87
89
  var progStepCeil = numProgSteps - 1;
90
+ var renderMediaContent = React.useMemo(function () {
91
+ return renderMedia === null || renderMedia === void 0 ? void 0 : renderMedia({
92
+ playStep: currentProgStep
93
+ });
94
+ }, [currentProgStep, renderMedia]);
88
95
  React.useEffect(function () {
89
96
  // On mount, one of the two primary buttons ("next" or "close")
90
97
  // will be rendered and must have focus. (a11y)
@@ -113,11 +120,13 @@ exports.CoachmarkOverlayElements = /*#__PURE__*/React.forwardRef(function (_ref,
113
120
  // example: [`${blockClass}__here-if-small`]: size === 'sm',
114
121
  }),
115
122
  ref: ref
116
- }, devtools.getDevtoolsProps(componentName)), media && (media.render ? media.render() : /*#__PURE__*/React.createElement(SteppedAnimatedMedia.SteppedAnimatedMedia, {
123
+ }, devtools.getDevtoolsProps(componentName)), hasMedia && (media === null || media === void 0 ? void 0 : media.render) && media.render(), hasMedia && (media === null || media === void 0 ? void 0 : media.filePaths) && /*#__PURE__*/React.createElement(SteppedAnimatedMedia.SteppedAnimatedMedia, {
117
124
  className: "".concat(blockClass, "__element-stepped-media"),
118
125
  filePaths: media.filePaths,
119
126
  playStep: currentProgStep
120
- })), numProgSteps === 1 ? /*#__PURE__*/React.createElement(React.Fragment, null, children, closeButtonLabel && /*#__PURE__*/React.createElement("div", {
127
+ }), hasMedia && renderMedia && /*#__PURE__*/React.createElement("div", {
128
+ className: "".concat(blockClass, "__element-stepped-media")
129
+ }, renderMediaContent), numProgSteps === 1 ? /*#__PURE__*/React.createElement(React.Fragment, null, children, closeButtonLabel && /*#__PURE__*/React.createElement("div", {
121
130
  className: cx("".concat(blockClass, "__footer"), 'coachmark-carousel-controls')
122
131
  }, /*#__PURE__*/React.createElement(react.Button, _rollupPluginBabelHelpers.extends({
123
132
  size: "sm"
@@ -196,6 +205,7 @@ exports.CoachmarkOverlayElements.propTypes = {
196
205
  * The object describing an image in one of two shapes.
197
206
  * If a single media element is required, use `{render}`.
198
207
  * If a stepped animation is required, use `{filePaths}`.
208
+ * @deprecated please use the `renderMedia` prop
199
209
  */
200
210
  /**@ts-ignore*/
201
211
  media: index.default.oneOfType([index.default.shape({
@@ -210,5 +220,9 @@ exports.CoachmarkOverlayElements.propTypes = {
210
220
  /**
211
221
  * The label for the Previous button.
212
222
  */
213
- previousButtonLabel: index.default.string
223
+ previousButtonLabel: index.default.string,
224
+ /**
225
+ * Optional prop to render any media like images or animated media.
226
+ */
227
+ renderMedia: index.default.func
214
228
  };
@@ -39,6 +39,10 @@ interface CoachmarkStackHomeProps {
39
39
  * @see {@link MEDIA_PROP_TYPE}.
40
40
  */
41
41
  media?: Media;
42
+ /**
43
+ * Optional prop to render any media like images or any animated media.
44
+ */
45
+ renderMedia?: (params: any) => ReactNode;
42
46
  /**
43
47
  * The labels used to link to the stackable Coachmarks.
44
48
  */
@@ -19,9 +19,10 @@ var settings = require('../../settings.js');
19
19
  var reactDom = require('react-dom');
20
20
  var CoachmarkHeader = require('../Coachmark/CoachmarkHeader.js');
21
21
  var SteppedAnimatedMedia = require('../SteppedAnimatedMedia/SteppedAnimatedMedia.js');
22
+ var propsHelper = require('../../global/js/utils/props-helper.js');
22
23
  var useIsomorphicEffect = require('../../global/js/hooks/useIsomorphicEffect.js');
23
24
 
24
- var _excluded = ["className", "description", "isOpen", "media", "navLinkLabels", "onClickNavItem", "onClose", "portalTarget", "closeButtonLabel", "title"];
25
+ var _excluded = ["className", "description", "isOpen", "media", "renderMedia", "navLinkLabels", "onClickNavItem", "onClose", "portalTarget", "closeButtonLabel", "title"];
25
26
  // Carbon and package components we use.
26
27
  /* TODO: @import(s) of carbon components and other package components. */
27
28
 
@@ -39,6 +40,7 @@ exports.CoachmarkStackHome = /*#__PURE__*/React.forwardRef(function (_ref, ref)
39
40
  description = _ref.description,
40
41
  isOpen = _ref.isOpen,
41
42
  media = _ref.media,
43
+ renderMedia = _ref.renderMedia,
42
44
  navLinkLabels = _ref.navLinkLabels,
43
45
  onClickNavItem = _ref.onClickNavItem,
44
46
  _onClose = _ref.onClose,
@@ -51,6 +53,7 @@ exports.CoachmarkStackHome = /*#__PURE__*/React.forwardRef(function (_ref, ref)
51
53
  _useState2 = _rollupPluginBabelHelpers.slicedToArray(_useState, 2),
52
54
  linkFocusIndex = _useState2[0],
53
55
  setLinkFocusIndex = _useState2[1];
56
+ var hasMedia = media || renderMedia;
54
57
  React.useEffect(function () {
55
58
  setTimeout(function () {
56
59
  if (isOpen && buttonFocusRef.current) {
@@ -92,13 +95,17 @@ exports.CoachmarkStackHome = /*#__PURE__*/React.forwardRef(function (_ref, ref)
92
95
  className: "".concat(overlayClass, "__body")
93
96
  }, /*#__PURE__*/React.createElement("div", {
94
97
  className: "".concat(overlayClass, "-element")
95
- }, !media && /*#__PURE__*/React.createElement(icons.Idea, {
98
+ }, !hasMedia && /*#__PURE__*/React.createElement(icons.Idea, {
96
99
  size: 20,
97
100
  className: "".concat(blockClass, "__icon-idea")
98
- }), media && (media.render ? media.render() : /*#__PURE__*/React.createElement(SteppedAnimatedMedia.SteppedAnimatedMedia, {
99
- className: "".concat(overlayClass, "__element-stepped-media"),
101
+ }), hasMedia && (media === null || media === void 0 ? void 0 : media.render) && media.render(), hasMedia && (media === null || media === void 0 ? void 0 : media.filePaths) && /*#__PURE__*/React.createElement(SteppedAnimatedMedia.SteppedAnimatedMedia, {
102
+ className: "".concat(blockClass, "__element-stepped-media"),
100
103
  filePaths: media.filePaths,
101
104
  playStep: 0
105
+ }), hasMedia && renderMedia && /*#__PURE__*/React.createElement("div", {
106
+ className: "".concat(blockClass, "__element-stepped-media")
107
+ }, renderMedia({
108
+ playStep: 0
102
109
  })), /*#__PURE__*/React.createElement("div", {
103
110
  className: "".concat(overlayClass, "-element__content")
104
111
  }, title && /*#__PURE__*/React.createElement("h2", {
@@ -158,12 +165,13 @@ exports.CoachmarkStackHome.propTypes = {
158
165
  * If a stepped animation is required, use `{filePaths}`.
159
166
  *
160
167
  * @see {@link MEDIA_PROP_TYPE}.
168
+ * @deprecated please use the `renderMedia` prop
161
169
  */
162
- media: index.default.oneOfType([index.default.shape({
170
+ media: propsHelper.deprecateProp(index.default.oneOfType([index.default.shape({
163
171
  render: index.default.func
164
172
  }), index.default.shape({
165
173
  filePaths: index.default.arrayOf(index.default.string)
166
- })]),
174
+ })]), ''),
167
175
  /**
168
176
  * The labels used to link to the stackable Coachmarks.
169
177
  */
@@ -187,6 +195,10 @@ exports.CoachmarkStackHome.propTypes = {
187
195
  * element is hidden or component is unmounted, the CoachmarkStackHome will disappear.
188
196
  */
189
197
  portalTarget: index.default.string,
198
+ /**
199
+ * Optional prop to render any media like images or animated media.
200
+ */
201
+ renderMedia: index.default.func,
190
202
  /**
191
203
  * The title of the Coachmark.
192
204
  */
@@ -51,8 +51,13 @@ export interface InlineTipProps {
51
51
  * - If a stepped animation is required, use `{filePaths}`.
52
52
  *
53
53
  * Enabling `media` disables the `collapsible` feature.
54
+ * @deprecated please use the `renderMedia` prop
54
55
  */
55
56
  media?: MediaType;
57
+ /**
58
+ * Optional prop to render any media like images or any animated media.
59
+ */
60
+ renderMedia?: () => ReactNode;
56
61
  /**
57
62
  * Set to `true` to arrange the information in a format
58
63
  * that is easier to read in a limited space.
@@ -20,7 +20,7 @@ var settings = require('../../settings.js');
20
20
  var uuidv4 = require('../../global/js/utils/uuidv4.js');
21
21
 
22
22
  var _Close, _Idea, _Crossroads;
23
- var _excluded = ["action", "children", "className", "closeIconDescription", "collapsible", "collapseButtonLabel", "expandButtonLabel", "media", "narrow", "onClick", "onClose", "tertiaryButtonLabel", "title", "withLeftGutter"];
23
+ var _excluded = ["action", "children", "className", "closeIconDescription", "collapsible", "collapseButtonLabel", "expandButtonLabel", "media", "renderMedia", "narrow", "onClick", "onClose", "tertiaryButtonLabel", "title", "withLeftGutter"];
24
24
 
25
25
  // The block part of our conventional BEM class names (blockClass__E--M).
26
26
  var blockClass = "".concat(settings.pkg.prefix, "--inline-tip");
@@ -58,6 +58,7 @@ exports.InlineTip = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
58
58
  _ref$expandButtonLabe = _ref.expandButtonLabel,
59
59
  expandButtonLabel = _ref$expandButtonLabe === void 0 ? defaults.expandButtonLabel : _ref$expandButtonLabe,
60
60
  media = _ref.media,
61
+ renderMedia = _ref.renderMedia,
61
62
  _ref$narrow = _ref.narrow,
62
63
  narrow = _ref$narrow === void 0 ? defaults.narrow : _ref$narrow,
63
64
  onClick = _ref.onClick,
@@ -68,6 +69,7 @@ exports.InlineTip = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
68
69
  _ref$withLeftGutter = _ref.withLeftGutter,
69
70
  withLeftGutter = _ref$withLeftGutter === void 0 ? defaults.withLeftGutter : _ref$withLeftGutter,
70
71
  rest = _rollupPluginBabelHelpers.objectWithoutProperties(_ref, _excluded);
72
+ var hasMedia = renderMedia || media;
71
73
  var _useState = React.useState(collapsible),
72
74
  _useState2 = _rollupPluginBabelHelpers.slicedToArray(_useState, 2),
73
75
  isCollapsed = _useState2[0],
@@ -77,7 +79,7 @@ exports.InlineTip = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
77
79
  return utils.getComponentText(React.Children.toArray(children));
78
80
  }, [children]);
79
81
  var childrenToRender = children;
80
- if (!media && collapsible && isCollapsed) {
82
+ if (!hasMedia && collapsible && isCollapsed) {
81
83
  childrenToRender = /*#__PURE__*/React.createElement("p", {
82
84
  className: "".concat(blockClass, "__preview-text")
83
85
  }, previewText);
@@ -89,7 +91,7 @@ exports.InlineTip = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
89
91
  }, [collapsible]);
90
92
  return /*#__PURE__*/React.createElement("div", _rollupPluginBabelHelpers.extends({}, rest, {
91
93
  "aria-labelledby": labelId,
92
- className: cx(blockClass, className, collapsible && "".concat(blockClass, "__collapsible"), isCollapsed && "".concat(blockClass, "__collapsible-collapsed"), media && "".concat(blockClass, "__has-media"), [narrow ? "".concat(blockClass, "__narrow") : "".concat(blockClass, "__wide")], withLeftGutter && !narrow && "".concat(blockClass, "__with-left-gutter")),
94
+ className: cx(blockClass, className, collapsible && "".concat(blockClass, "__collapsible"), isCollapsed && "".concat(blockClass, "__collapsible-collapsed"), hasMedia && "".concat(blockClass, "__has-media"), [narrow ? "".concat(blockClass, "__narrow") : "".concat(blockClass, "__wide")], withLeftGutter && !narrow && "".concat(blockClass, "__with-left-gutter")),
93
95
  ref: ref,
94
96
  role: "complementary"
95
97
  }, devtools.getDevtoolsProps(componentName)), /*#__PURE__*/React.createElement("div", {
@@ -102,7 +104,7 @@ exports.InlineTip = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
102
104
  size: "lg"
103
105
  }, _Close || (_Close = /*#__PURE__*/React.createElement(icons.Close, {
104
106
  size: 16
105
- })))), (!media && narrow || !narrow) && /*#__PURE__*/React.createElement("div", {
107
+ })))), (!hasMedia && narrow || !narrow) && /*#__PURE__*/React.createElement("div", {
106
108
  className: "".concat(blockClass, "__icon-idea"),
107
109
  tabIndex: -1
108
110
  }, _Idea || (_Idea = /*#__PURE__*/React.createElement(icons.Idea, {
@@ -118,7 +120,7 @@ exports.InlineTip = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
118
120
  className: "".concat(blockClass, "__secondary-btn")
119
121
  }, action)), (collapsible || tertiaryButtonLabel) && /*#__PURE__*/React.createElement("footer", {
120
122
  className: "".concat(blockClass, "__footer")
121
- }, collapsible && !media && /*#__PURE__*/React.createElement(react.Button, {
123
+ }, collapsible && !hasMedia && /*#__PURE__*/React.createElement(react.Button, {
122
124
  className: "".concat(blockClass, "__toggle-btn"),
123
125
  kind: "ghost",
124
126
  size: "md",
@@ -137,12 +139,14 @@ exports.InlineTip = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
137
139
  size: 16
138
140
  }));
139
141
  }
140
- }, tertiaryButtonLabel))), media && (media.render ? /*#__PURE__*/React.createElement("div", {
142
+ }, tertiaryButtonLabel))), hasMedia && (media === null || media === void 0 ? void 0 : media.render) && /*#__PURE__*/React.createElement("div", {
141
143
  className: "".concat(blockClass, "__media")
142
- }, media.render()) : /*#__PURE__*/React.createElement(SteppedAnimatedMedia.SteppedAnimatedMedia, {
144
+ }, media.render()), hasMedia && (media === null || media === void 0 ? void 0 : media.filePaths) && /*#__PURE__*/React.createElement(SteppedAnimatedMedia.SteppedAnimatedMedia, {
143
145
  className: "".concat(blockClass, "__media"),
144
146
  filePaths: media.filePaths
145
- })));
147
+ }), hasMedia && renderMedia && /*#__PURE__*/React.createElement("div", {
148
+ className: "".concat(blockClass, "__media")
149
+ }, renderMedia()));
146
150
  });
147
151
  exports.InlineTip = settings.pkg.checkComponentEnabled(exports.InlineTip, componentName);
148
152
  exports.InlineTip.displayName = componentName;
@@ -188,6 +192,7 @@ exports.InlineTip.propTypes = {
188
192
  * - If a stepped animation is required, use `{filePaths}`.
189
193
  *
190
194
  * Enabling `media` disables the `collapsible` feature.
195
+ * @deprecated please use the `renderMedia` prop
191
196
  */
192
197
  /**@ts-ignore*/
193
198
  media: index.default.oneOfType([index.default.shape({
@@ -208,6 +213,10 @@ exports.InlineTip.propTypes = {
208
213
  * Function to call when the InlineTip is closed via the "X" button.
209
214
  */
210
215
  onClose: index.default.func,
216
+ /**
217
+ * Optional prop to render any media like images or animated media.
218
+ */
219
+ renderMedia: index.default.func,
211
220
  /**
212
221
  * Defining the label will show a the tertiary button with the crossroads icon.
213
222
  * You will still need to define the `onClose` method to trigger a callback.
@@ -45,6 +45,7 @@ var SteppedAnimatedMedia = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
45
45
  var backupRef = React.useRef(null);
46
46
  var localRef = ref !== null && ref !== void 0 ? ref : backupRef;
47
47
  var localRefValue = localRef.current;
48
+ var filePathStr = filePaths === null || filePaths === void 0 ? void 0 : filePaths.join(); //converting the array to string will avoid unwanted useEffect trigger.
48
49
  // load animation source
49
50
  React.useEffect(function () {
50
51
  var isJsonFile = function isJsonFile(filePath) {
@@ -87,7 +88,8 @@ var SteppedAnimatedMedia = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
87
88
  return _loadArtifact.apply(this, arguments);
88
89
  }
89
90
  loadArtifact();
90
- }, [filePaths]);
91
+ // eslint-disable-next-line
92
+ }, [filePathStr]);
91
93
  React.useEffect(function () {
92
94
  var _window;
93
95
  var prefersReducedMotion = (_window = window) !== null && _window !== void 0 && _window.matchMedia ? window.matchMedia('(prefers-reduced-motion: reduce)').matches : true;
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.54.0-canary.50+0da237232",
4
+ "version": "2.54.0-canary.52+d8c705180",
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.24.0",
99
- "@carbon/ibm-products-styles": "^2.50.0-canary.50+0da237232",
99
+ "@carbon/ibm-products-styles": "^2.50.0-canary.52+d8c705180",
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": "0da2372321bb498d78a6beed0e21f2c26626b4a8"
123
+ "gitHead": "d8c70518087e7e41fdf1aa45cbbf692389058d56"
124
124
  }