@carbon/ibm-products 2.23.0 → 2.24.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (186) hide show
  1. package/css/index-full-carbon.css +29484 -28211
  2. package/css/index-full-carbon.css.map +1 -1
  3. package/css/index-full-carbon.min.css +1 -1
  4. package/css/index-full-carbon.min.css.map +1 -1
  5. package/css/index-without-carbon-released-only.css +49 -10
  6. package/css/index-without-carbon-released-only.css.map +1 -1
  7. package/css/index-without-carbon-released-only.min.css +1 -1
  8. package/css/index-without-carbon-released-only.min.css.map +1 -1
  9. package/css/index-without-carbon.css +24418 -291
  10. package/css/index-without-carbon.css.map +1 -1
  11. package/css/index-without-carbon.min.css +1 -1
  12. package/css/index-without-carbon.min.css.map +1 -1
  13. package/css/index.css +17172 -13
  14. package/css/index.css.map +1 -1
  15. package/css/index.min.css +1 -1
  16. package/css/index.min.css.map +1 -1
  17. package/es/components/Card/Card.js +1 -2
  18. package/es/components/Card/CardHeader.js +2 -2
  19. package/es/components/Carousel/Carousel.js +5 -3
  20. package/es/components/Coachmark/Coachmark.js +255 -0
  21. package/es/components/Coachmark/CoachmarkDragbar.js +146 -0
  22. package/es/components/Coachmark/CoachmarkHeader.js +91 -0
  23. package/es/components/Coachmark/CoachmarkOverlay.js +235 -0
  24. package/es/components/Coachmark/CoachmarkTagline.js +97 -0
  25. package/es/components/Coachmark/index.js +10 -0
  26. package/es/components/Coachmark/utils/constants.js +76 -0
  27. package/es/components/Coachmark/utils/context.js +5 -0
  28. package/es/components/Coachmark/utils/enums.js +40 -0
  29. package/es/components/Coachmark/utils/helpers.js +11 -0
  30. package/es/components/Coachmark/utils/hooks.js +54 -0
  31. package/es/components/CoachmarkBeacon/CoachmarkBeacon.js +93 -0
  32. package/es/components/CoachmarkBeacon/index.js +8 -0
  33. package/es/components/CoachmarkButton/CoachmarkButton.js +90 -0
  34. package/es/components/CoachmarkButton/index.js +8 -0
  35. package/es/components/CoachmarkFixed/CoachmarkFixed.js +226 -0
  36. package/es/components/CoachmarkFixed/index.js +8 -0
  37. package/es/components/CoachmarkOverlayElement/CoachmarkOverlayElement.js +86 -0
  38. package/es/components/CoachmarkOverlayElement/index.js +8 -0
  39. package/es/components/CoachmarkOverlayElements/CoachmarkOverlayElements.js +216 -0
  40. package/es/components/CoachmarkOverlayElements/index.js +8 -0
  41. package/es/components/CoachmarkStack/CoachmarkStack.js +283 -0
  42. package/es/components/CoachmarkStack/CoachmarkStackHome.js +192 -0
  43. package/es/components/CoachmarkStack/index.js +8 -0
  44. package/es/components/Datagrid/Datagrid/DatagridSelectAll.js +4 -1
  45. package/es/components/Datagrid/Datagrid/DraggableElement.js +1 -1
  46. package/es/components/Datagrid/Datagrid/addons/CustomizeColumns/ButtonWrapper.js +1 -1
  47. package/es/components/Datagrid/Datagrid/addons/CustomizeColumns/Columns.js +4 -1
  48. package/es/components/Datagrid/Datagrid/addons/CustomizeColumns/CustomizeColumnsTearsheet.js +1 -1
  49. package/es/components/Datagrid/Datagrid.docs-page.js +2 -2
  50. package/es/components/Datagrid/useActionsColumn.js +16 -12
  51. package/es/components/Datagrid/useNestedRowExpander.js +2 -2
  52. package/es/components/EmptyStates/ErrorEmptyState/ErrorEmptyState.js +7 -2
  53. package/es/components/EmptyStates/NoDataEmptyState/NoDataEmptyState.js +8 -3
  54. package/es/components/EmptyStates/NoTagsEmptyState/NoTagsEmptyState.js +7 -2
  55. package/es/components/EmptyStates/NotFoundEmptyState/NotFoundEmptyState.js +7 -2
  56. package/es/components/EmptyStates/NotificationsEmptyState/NotificationsEmptyState.js +7 -2
  57. package/es/components/EmptyStates/UnauthorizedEmptyState/UnauthorizedEmptyState.js +7 -2
  58. package/es/components/EmptyStates/assets/ErrorIllustration.js +5 -5
  59. package/es/components/EmptyStates/assets/NoDataIllustration.js +5 -5
  60. package/es/components/EmptyStates/assets/NoTagsIllustration.js +5 -5
  61. package/es/components/EmptyStates/assets/NotFoundIllustration.js +5 -5
  62. package/es/components/EmptyStates/assets/NotificationsIllustration.js +5 -5
  63. package/es/components/EmptyStates/assets/UnauthorizedIllustration.js +5 -5
  64. package/es/components/InterstitialScreen/InterstitialScreen.js +427 -0
  65. package/es/components/InterstitialScreen/index.js +8 -0
  66. package/es/components/InterstitialScreenView/InterstitialScreenView.js +75 -0
  67. package/es/components/InterstitialScreenView/index.js +8 -0
  68. package/es/components/InterstitialScreenViewModule/InterstitialScreenViewModule.js +83 -0
  69. package/es/components/InterstitialScreenViewModule/index.js +8 -0
  70. package/es/components/PageHeader/PageHeaderUtils.js +2 -2
  71. package/es/components/SearchBar/SearchBar.js +227 -0
  72. package/es/components/SearchBar/index.js +8 -0
  73. package/es/components/index.js +12 -1
  74. package/es/global/js/package-settings.js +14 -0
  75. package/lib/components/Card/Card.js +3 -4
  76. package/lib/components/Card/CardHeader.js +2 -2
  77. package/lib/components/Carousel/Carousel.js +5 -3
  78. package/lib/components/Coachmark/Coachmark.js +264 -0
  79. package/lib/components/Coachmark/CoachmarkDragbar.js +151 -0
  80. package/lib/components/Coachmark/CoachmarkHeader.js +95 -0
  81. package/lib/components/Coachmark/CoachmarkOverlay.js +243 -0
  82. package/lib/components/Coachmark/CoachmarkTagline.js +101 -0
  83. package/lib/components/Coachmark/index.js +38 -0
  84. package/lib/components/Coachmark/utils/constants.js +81 -0
  85. package/lib/components/Coachmark/utils/context.js +11 -0
  86. package/lib/components/Coachmark/utils/enums.js +46 -0
  87. package/lib/components/Coachmark/utils/helpers.js +17 -0
  88. package/lib/components/Coachmark/utils/hooks.js +59 -0
  89. package/lib/components/CoachmarkBeacon/CoachmarkBeacon.js +97 -0
  90. package/lib/components/CoachmarkBeacon/index.js +12 -0
  91. package/lib/components/CoachmarkButton/CoachmarkButton.js +93 -0
  92. package/lib/components/CoachmarkButton/index.js +12 -0
  93. package/lib/components/CoachmarkFixed/CoachmarkFixed.js +232 -0
  94. package/lib/components/CoachmarkFixed/index.js +12 -0
  95. package/lib/components/CoachmarkOverlayElement/CoachmarkOverlayElement.js +90 -0
  96. package/lib/components/CoachmarkOverlayElement/index.js +12 -0
  97. package/lib/components/CoachmarkOverlayElements/CoachmarkOverlayElements.js +222 -0
  98. package/lib/components/CoachmarkOverlayElements/index.js +12 -0
  99. package/lib/components/CoachmarkStack/CoachmarkStack.js +288 -0
  100. package/lib/components/CoachmarkStack/CoachmarkStackHome.js +198 -0
  101. package/lib/components/CoachmarkStack/index.js +12 -0
  102. package/lib/components/Datagrid/Datagrid/DatagridSelectAll.js +4 -1
  103. package/lib/components/Datagrid/Datagrid/DraggableElement.js +1 -1
  104. package/lib/components/Datagrid/Datagrid/addons/CustomizeColumns/ButtonWrapper.js +1 -1
  105. package/lib/components/Datagrid/Datagrid/addons/CustomizeColumns/Columns.js +4 -1
  106. package/lib/components/Datagrid/Datagrid/addons/CustomizeColumns/CustomizeColumnsTearsheet.js +1 -1
  107. package/lib/components/Datagrid/Datagrid.docs-page.js +2 -2
  108. package/lib/components/Datagrid/useActionsColumn.js +15 -11
  109. package/lib/components/Datagrid/useNestedRowExpander.js +2 -2
  110. package/lib/components/EmptyStates/ErrorEmptyState/ErrorEmptyState.js +7 -2
  111. package/lib/components/EmptyStates/NoDataEmptyState/NoDataEmptyState.js +8 -3
  112. package/lib/components/EmptyStates/NoTagsEmptyState/NoTagsEmptyState.js +7 -2
  113. package/lib/components/EmptyStates/NotFoundEmptyState/NotFoundEmptyState.js +7 -2
  114. package/lib/components/EmptyStates/NotificationsEmptyState/NotificationsEmptyState.js +7 -2
  115. package/lib/components/EmptyStates/UnauthorizedEmptyState/UnauthorizedEmptyState.js +7 -2
  116. package/lib/components/EmptyStates/assets/ErrorIllustration.js +5 -5
  117. package/lib/components/EmptyStates/assets/NoDataIllustration.js +5 -5
  118. package/lib/components/EmptyStates/assets/NoTagsIllustration.js +5 -5
  119. package/lib/components/EmptyStates/assets/NotFoundIllustration.js +5 -5
  120. package/lib/components/EmptyStates/assets/NotificationsIllustration.js +5 -5
  121. package/lib/components/EmptyStates/assets/UnauthorizedIllustration.js +5 -5
  122. package/lib/components/InterstitialScreen/InterstitialScreen.js +434 -0
  123. package/lib/components/InterstitialScreen/index.js +12 -0
  124. package/lib/components/InterstitialScreenView/InterstitialScreenView.js +77 -0
  125. package/lib/components/InterstitialScreenView/index.js +12 -0
  126. package/lib/components/InterstitialScreenViewModule/InterstitialScreenViewModule.js +85 -0
  127. package/lib/components/InterstitialScreenViewModule/index.js +12 -0
  128. package/lib/components/PageHeader/PageHeaderUtils.js +2 -2
  129. package/lib/components/SearchBar/SearchBar.js +233 -0
  130. package/lib/components/SearchBar/index.js +12 -0
  131. package/lib/components/index.js +78 -1
  132. package/lib/global/js/package-settings.js +14 -0
  133. package/package.json +5 -5
  134. package/scss/components/Card/_card.scss +6 -5
  135. package/scss/components/Coachmark/_carbon-imports.scss +10 -0
  136. package/scss/components/Coachmark/_coachmark-dragbar.scss +27 -0
  137. package/scss/components/Coachmark/_coachmark-header.scss +20 -0
  138. package/scss/components/Coachmark/_coachmark-overlay.scss +431 -0
  139. package/scss/components/Coachmark/_coachmark-tagline.scss +140 -0
  140. package/scss/components/Coachmark/_coachmark.scss +30 -0
  141. package/scss/components/Coachmark/_index-with-carbon.scss +9 -0
  142. package/scss/components/Coachmark/_index.scss +8 -0
  143. package/scss/components/CoachmarkBeacon/_carbon-imports.scss +9 -0
  144. package/scss/components/CoachmarkBeacon/_coachmark-beacon.scss +166 -0
  145. package/scss/components/CoachmarkBeacon/_index-with-carbon.scss +9 -0
  146. package/scss/components/CoachmarkBeacon/_index.scss +8 -0
  147. package/scss/components/CoachmarkButton/_carbon-imports.scss +9 -0
  148. package/scss/components/CoachmarkButton/_coachmark-button.scss +25 -0
  149. package/scss/components/CoachmarkButton/_index-with-carbon.scss +9 -0
  150. package/scss/components/CoachmarkButton/_index.scss +8 -0
  151. package/scss/components/CoachmarkFixed/_carbon-imports.scss +9 -0
  152. package/scss/components/CoachmarkFixed/_coachmark-fixed.scss +25 -0
  153. package/scss/components/CoachmarkFixed/_index-with-carbon.scss +9 -0
  154. package/scss/components/CoachmarkFixed/_index.scss +8 -0
  155. package/scss/components/CoachmarkOverlayElement/_carbon-imports.scss +9 -0
  156. package/scss/components/CoachmarkOverlayElement/_coachmark-overlay-element.scss +52 -0
  157. package/scss/components/CoachmarkOverlayElement/_index-with-carbon.scss +9 -0
  158. package/scss/components/CoachmarkOverlayElement/_index.scss +8 -0
  159. package/scss/components/CoachmarkOverlayElements/_carbon-imports.scss +9 -0
  160. package/scss/components/CoachmarkOverlayElements/_coachmark-overlay-elements.scss +47 -0
  161. package/scss/components/CoachmarkOverlayElements/_index-with-carbon.scss +9 -0
  162. package/scss/components/CoachmarkOverlayElements/_index.scss +8 -0
  163. package/scss/components/CoachmarkStack/_carbon-imports.scss +9 -0
  164. package/scss/components/CoachmarkStack/_coachmark-stack.scss +95 -0
  165. package/scss/components/CoachmarkStack/_index-with-carbon.scss +9 -0
  166. package/scss/components/CoachmarkStack/_index.scss +8 -0
  167. package/scss/components/InterstitialScreen/_carbon-imports.scss +9 -0
  168. package/scss/components/InterstitialScreen/_index-with-carbon.scss +9 -0
  169. package/scss/components/InterstitialScreen/_index.scss +8 -0
  170. package/scss/components/InterstitialScreen/_interstitial-screen.scss +276 -0
  171. package/scss/components/InterstitialScreenView/_carbon-imports.scss +9 -0
  172. package/scss/components/InterstitialScreenView/_index-with-carbon.scss +9 -0
  173. package/scss/components/InterstitialScreenView/_index.scss +8 -0
  174. package/scss/components/InterstitialScreenView/_interstitial-screen-view.scss +25 -0
  175. package/scss/components/InterstitialScreenViewModule/_carbon-imports.scss +9 -0
  176. package/scss/components/InterstitialScreenViewModule/_index-with-carbon.scss +9 -0
  177. package/scss/components/InterstitialScreenViewModule/_index.scss +8 -0
  178. package/scss/components/InterstitialScreenViewModule/_interstitial-screen-view-module.scss +59 -0
  179. package/scss/components/PageHeader/_page-header.scss +0 -1
  180. package/scss/components/SearchBar/_carbon-imports.scss +9 -0
  181. package/scss/components/SearchBar/_index-with-carbon.scss +9 -0
  182. package/scss/components/SearchBar/_index.scss +8 -0
  183. package/scss/components/SearchBar/_search-bar.scss +26 -0
  184. package/scss/components/SidePanel/_side-panel.scss +12 -7
  185. package/scss/components/_index-with-carbon.scss +11 -0
  186. package/scss/components/_index.scss +11 -0
@@ -0,0 +1,90 @@
1
+ import _extends from "@babel/runtime/helpers/extends";
2
+ import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
3
+ var _excluded = ["className", "label"];
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 { getDevtoolsProps } from '../../global/js/utils/devtools';
18
+ import { pkg /*, carbon */ } from '../../settings';
19
+ import { Button } from '@carbon/react';
20
+ import { useCoachmark } from '../Coachmark';
21
+ // Carbon and package components we use.
22
+ /* TODO: @import(s) of carbon components and other package components. */
23
+
24
+ // The block part of our conventional BEM class names (blockClass__E--M).
25
+ var blockClass = "".concat(pkg.prefix, "--coachmark-button");
26
+ var componentName = 'CoachmarkButton';
27
+
28
+ // NOTE: the component SCSS is not imported here: it is rolled up separately.
29
+
30
+ // Default values can be included here and then assigned to the prop params,
31
+ // e.g. prop = defaults.prop,
32
+ // This gathers default values together neatly and ensures non-primitive
33
+ // values are initialized early to avoid react making unnecessary re-renders.
34
+ // Note that default values are not required for props that are 'required',
35
+ // nor for props where the component can apply undefined values reasonably.
36
+ // Default values should be provided when the component needs to make a choice
37
+ // or assumption when a prop is not supplied.
38
+
39
+ // Default values for props
40
+ // const defaults = {
41
+ // /* TODO: add defaults for relevant props if needed */
42
+ // };
43
+
44
+ /**
45
+ * Use CoachmarkButton for the target prop of a Coachmark component.
46
+ */
47
+ export var CoachmarkButton = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
48
+ var className = _ref.className,
49
+ label = _ref.label,
50
+ rest = _objectWithoutProperties(_ref, _excluded);
51
+ var coachmark = useCoachmark();
52
+ if (!coachmark) {
53
+ return /*#__PURE__*/React.createElement("div", null, "CoachmarkButton is to be use exclusively within the target prop of Coachmark");
54
+ }
55
+ return /*#__PURE__*/React.createElement(Button, _extends({}, rest, {
56
+ className: cx(blockClass,
57
+ // Apply the block class to the main HTML element
58
+ className,
59
+ // Apply any supplied class names to the main HTML element.
60
+ // example: `${blockClass}__template-string-class-${kind}-n-${size}`,
61
+ {
62
+ // switched classes dependant on props or state
63
+ // example: [`${blockClass}__here-if-small`]: size === 'sm',
64
+ }),
65
+ ref: ref,
66
+ role: "button",
67
+ "aria-label": label
68
+ }, getDevtoolsProps(componentName), coachmark.buttonProps), label);
69
+ });
70
+
71
+ // Return a placeholder if not released and not enabled by feature flag
72
+ CoachmarkButton = pkg.checkComponentEnabled(CoachmarkButton, componentName);
73
+
74
+ // The display name of the component, used by React. Note that displayName
75
+ // is used in preference to relying on function.name.
76
+ CoachmarkButton.displayName = componentName;
77
+
78
+ // The types and DocGen commentary for the component props,
79
+ // in alphabetical order (for consistency).
80
+ // See https://www.npmjs.com/package/prop-types#usage.
81
+ CoachmarkButton.propTypes = {
82
+ /**
83
+ * Provide an optional class to be applied to the containing node.
84
+ */
85
+ className: PropTypes.string,
86
+ /**
87
+ * The aria label.
88
+ */
89
+ label: PropTypes.string.isRequired
90
+ };
@@ -0,0 +1,8 @@
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
+
8
+ export { CoachmarkButton } from './CoachmarkButton';
@@ -0,0 +1,226 @@
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 = ["children", "className", "onClose", "portalTarget", "tagline", "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, useRef, useState, useCallback } from 'react';
14
+
15
+ // Other standard imports.
16
+ import PropTypes from 'prop-types';
17
+ import cx from 'classnames';
18
+ import { getDevtoolsProps } from '../../global/js/utils/devtools';
19
+ import { pkg /*, carbon */ } from '../../settings';
20
+ import { createPortal } from 'react-dom';
21
+ import { CoachmarkOverlay } from '../Coachmark/CoachmarkOverlay';
22
+ import { CoachmarkTagline } from '../Coachmark/CoachmarkTagline';
23
+ import { CoachmarkContext } from '../Coachmark/utils/context';
24
+ import { COACHMARK_OVERLAY_KIND } from '../Coachmark/utils/enums';
25
+ // Carbon and package components we use.
26
+ /* TODO: @import(s) of carbon components and other package components. */
27
+
28
+ // The block part of our conventional BEM class names (blockClass__E--M).
29
+ var coachmarkClass = "".concat(pkg.prefix, "--coachmark");
30
+ var blockClass = "".concat(coachmarkClass, "-fixed");
31
+ var overlayBlockClass = "".concat(coachmarkClass, "-overlay");
32
+ var componentName = 'CoachmarkFixed';
33
+ var defaults = {
34
+ onClose: function onClose() {},
35
+ theme: 'light',
36
+ tagline: ''
37
+ };
38
+
39
+ /**
40
+ * Fixed coachmarks are used to call out specific functionality or concepts
41
+ * within the UI that may not be intuitive but are important for the
42
+ * user to gain understanding of the product's main value and discover new use cases.
43
+ * This variant allows the a coachmark overlay to be displayed by interacting with the tagline.
44
+ */
45
+ export var CoachmarkFixed = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
46
+ var _document$querySelect;
47
+ var children = _ref.children,
48
+ className = _ref.className,
49
+ _ref$onClose = _ref.onClose,
50
+ onClose = _ref$onClose === void 0 ? defaults.onClose : _ref$onClose,
51
+ portalTarget = _ref.portalTarget,
52
+ _ref$tagline = _ref.tagline,
53
+ tagline = _ref$tagline === void 0 ? defaults.tagline : _ref$tagline,
54
+ _ref$theme = _ref.theme,
55
+ theme = _ref$theme === void 0 ? defaults.theme : _ref$theme,
56
+ rest = _objectWithoutProperties(_ref, _excluded);
57
+ var overlayRef = useRef();
58
+ var portalNode = portalTarget ? (_document$querySelect = document.querySelector(portalTarget)) !== null && _document$querySelect !== void 0 ? _document$querySelect : document.querySelector('body') : document.querySelector('body');
59
+ var _useState = useState(false),
60
+ _useState2 = _slicedToArray(_useState, 2),
61
+ isOpen = _useState2[0],
62
+ setIsOpen = _useState2[1];
63
+ var _useState3 = useState(false),
64
+ _useState4 = _slicedToArray(_useState3, 2),
65
+ shouldResetPosition = _useState4[0],
66
+ setShouldResetPosition = _useState4[1];
67
+ var _useState5 = useState(),
68
+ _useState6 = _slicedToArray(_useState5, 2),
69
+ targetRect = _useState6[0],
70
+ setTargetRect = _useState6[1];
71
+ var _useState7 = useState({
72
+ x: 0,
73
+ y: 0
74
+ }),
75
+ _useState8 = _slicedToArray(_useState7, 2),
76
+ targetOffset = _useState8[0],
77
+ setTargetOffset = _useState8[1];
78
+ var _useState9 = useState(false),
79
+ _useState10 = _slicedToArray(_useState9, 2),
80
+ fixedIsVisible = _useState10[0],
81
+ setFixedIsVisible = _useState10[1];
82
+ var prefersReducedMotion = window.matchMedia('(prefers-reduced-motion: reduce)');
83
+ var handleClose = useCallback(function () {
84
+ console.log('HANDLING CLOSE HERE...');
85
+ if (prefersReducedMotion.matches) {
86
+ setIsOpen(false);
87
+ } else {
88
+ setFixedIsVisible(false);
89
+ }
90
+ }, [prefersReducedMotion.matches]);
91
+ var handleTransitionEnd = function handleTransitionEnd(e) {
92
+ console.log('Hererrrrrreee at transition end... ', e.propertyName === 'transform' && !fixedIsVisible);
93
+ if (e.propertyName === 'transform' && !fixedIsVisible) {
94
+ setIsOpen(false);
95
+ onClose();
96
+ }
97
+ };
98
+ var handleTargetClick = function handleTargetClick(e) {
99
+ setTargetRect(e.target.getBoundingClientRect());
100
+ setTargetOffset({
101
+ x: e.target.offsetLeft,
102
+ y: e.target.offsetTop
103
+ });
104
+ // reset position for all other kinds
105
+ setIsOpen(false);
106
+ setShouldResetPosition(true);
107
+ };
108
+ var escFunction = useCallback(function (event) {
109
+ if (event.key === 'Escape') {
110
+ handleClose();
111
+ }
112
+ }, [handleClose]);
113
+ useEffect(function () {
114
+ document.addEventListener('keydown', escFunction, false);
115
+ return function () {
116
+ document.removeEventListener('keydown', escFunction, false);
117
+ };
118
+ }, [escFunction]);
119
+ var contextValue = {
120
+ buttonProps: {
121
+ 'aria-expanded': isOpen,
122
+ tabIndex: 0,
123
+ onClick: handleTargetClick,
124
+ // Compensate for accidental open/close on double-click.
125
+ // Only open on double-click.
126
+ onDoubleClick: handleTargetClick
127
+ },
128
+ closeButtonProps: {
129
+ onClick: handleClose
130
+ },
131
+ targetRect: targetRect,
132
+ targetOffset: targetOffset,
133
+ isOpen: isOpen,
134
+ tacos: 'tacos'
135
+ };
136
+
137
+ // instead of toggling on/off,
138
+ // keep open and reset to original position
139
+ useEffect(function () {
140
+ if (shouldResetPosition) {
141
+ setShouldResetPosition(false);
142
+ setIsOpen(true);
143
+ }
144
+ }, [shouldResetPosition]);
145
+ useEffect(function () {
146
+ setFixedIsVisible(isOpen);
147
+ }, [isOpen]);
148
+
149
+ // On unmount:
150
+ // - DO NOT "Close()" the coachmark.
151
+ // - This triggers a "signal" to close it forever.
152
+ // - "Closing" should only ever be a user-triggered event.
153
+ // - DO "hide" the coachmark.
154
+ // - The app is doing the action for the user.
155
+ // - The user will have the opportunity to open it again.
156
+ useEffect(function () {
157
+ return function () {
158
+ return setIsOpen(false);
159
+ };
160
+ }, []);
161
+ return /*#__PURE__*/React.createElement(CoachmarkContext.Provider, {
162
+ value: contextValue
163
+ }, /*#__PURE__*/React.createElement("div", _extends({}, rest, {
164
+ className: cx(blockClass, // Apply the block class to the main HTML element
165
+ "".concat(blockClass, "__").concat(theme), className // Apply any supplied class names to the main HTML element.
166
+ ),
167
+
168
+ ref: ref
169
+ }, getDevtoolsProps(componentName)), /*#__PURE__*/React.createElement(CoachmarkTagline, {
170
+ title: tagline,
171
+ onClose: onClose
172
+ }), isOpen && /*#__PURE__*/createPortal( /*#__PURE__*/React.createElement(CoachmarkOverlay, {
173
+ ref: overlayRef,
174
+ fixedIsVisible: fixedIsVisible,
175
+ kind: COACHMARK_OVERLAY_KIND.FIXED,
176
+ onClose: handleClose,
177
+ onTransitionEnd: handleTransitionEnd,
178
+ theme: theme,
179
+ className: cx(fixedIsVisible && "".concat(overlayBlockClass, "--is-visible"), overlayBlockClass)
180
+ }, children), portalNode)));
181
+ });
182
+
183
+ // Return a placeholder if not released and not enabled by feature flag
184
+ CoachmarkFixed = pkg.checkComponentEnabled(CoachmarkFixed, componentName);
185
+
186
+ // The display name of the component, used by React. Note that displayName
187
+ // is used in preference to relying on function.name.
188
+ CoachmarkFixed.displayName = componentName;
189
+
190
+ // The types and DocGen commentary for the component props,
191
+ // in alphabetical order (for consistency).
192
+ // See https://www.npmjs.com/package/prop-types#usage.
193
+ CoachmarkFixed.propTypes = {
194
+ // TODO: Add this to MDX as will be done with Coachmark
195
+ /**
196
+ * CoachmarkFixed should use a single CoachmarkOverlayElements component as a child.
197
+ */
198
+ children: PropTypes.node.isRequired,
199
+ /**
200
+ * Optional class name for this component.
201
+ */
202
+ className: PropTypes.string,
203
+ /**
204
+ * Function to call when the Coachmark closes.
205
+ */
206
+ onClose: PropTypes.func,
207
+ /**
208
+ * By default, the Coachmark will be appended to the end of `document.body`.
209
+ * The Coachmark will remain persistent as the user navigates the app until
210
+ * the user closes the Coachmark.
211
+ *
212
+ * Alternatively, the app developer can tightly couple the Coachmark to a DOM
213
+ * element or other component by specifying a CSS selector. The Coachmark will
214
+ * remain visible as long as that element remains visible or mounted. When the
215
+ * element is hidden or component is unmounted, the Coachmark will disappear.
216
+ */
217
+ portalTarget: PropTypes.string,
218
+ /**
219
+ * The tagline title which will be fixed to the bottom right of the window and will serve as the display trigger.
220
+ */
221
+ tagline: PropTypes.string.isRequired,
222
+ /**
223
+ * Determines the theme of the component.
224
+ */
225
+ theme: PropTypes.oneOf(['light', 'dark'])
226
+ };
@@ -0,0 +1,8 @@
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
+
8
+ export { CoachmarkFixed } from './CoachmarkFixed';
@@ -0,0 +1,86 @@
1
+ import _extends from "@babel/runtime/helpers/extends";
2
+ import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
3
+ var _excluded = ["button", "className", "description", "title"];
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 { getDevtoolsProps } from '../../global/js/utils/devtools';
18
+ import { pkg /*, carbon */ } from '../../settings';
19
+
20
+ // The block part of our conventional BEM class names (blockClass__E--M).
21
+ var blockClass = "".concat(pkg.prefix, "--coachmark-overlay-element");
22
+ var componentName = 'CoachmarkOverlayElement';
23
+
24
+ /**
25
+ * Component to be displayed within a CoachmarkOverlayElements container.
26
+ * Can be used 1 to N number, to display content in a Coachmark's overlay
27
+ * in a carousel fashion.
28
+ */
29
+ export var CoachmarkOverlayElement = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
30
+ var button = _ref.button,
31
+ className = _ref.className,
32
+ description = _ref.description,
33
+ title = _ref.title,
34
+ rest = _objectWithoutProperties(_ref, _excluded);
35
+ return /*#__PURE__*/React.createElement("div", _extends({}, rest, {
36
+ className: cx(blockClass,
37
+ // Apply the block class to the main HTML element
38
+ className,
39
+ // Apply any supplied class names to the main HTML element.
40
+ // example: `${blockClass}__template-string-class-${kind}-n-${size}`,
41
+ {
42
+ // switched classes dependant on props or state
43
+ // example: [`${blockClass}__here-if-small`]: size === 'sm',
44
+ }),
45
+ ref: ref
46
+ // role="main"
47
+ }, getDevtoolsProps(componentName)), /*#__PURE__*/React.createElement("div", {
48
+ className: "".concat(blockClass, "__content")
49
+ }, title && /*#__PURE__*/React.createElement("h2", {
50
+ className: "".concat(blockClass, "__title")
51
+ }, title), description && /*#__PURE__*/React.createElement("p", {
52
+ className: "".concat(blockClass, "__body")
53
+ }, description)), button && /*#__PURE__*/React.createElement("div", {
54
+ className: "".concat(blockClass, "__button")
55
+ }, button));
56
+ });
57
+
58
+ // Return a placeholder if not released and not enabled by feature flag
59
+ CoachmarkOverlayElement = pkg.checkComponentEnabled(CoachmarkOverlayElement, componentName);
60
+
61
+ // The display name of the component, used by React. Note that displayName
62
+ // is used in preference to relying on function.name.
63
+ CoachmarkOverlayElement.displayName = componentName;
64
+
65
+ // The types and DocGen commentary for the component props,
66
+ // in alphabetical order (for consistency).
67
+ // See https://www.npmjs.com/package/prop-types#usage.
68
+ CoachmarkOverlayElement.propTypes = {
69
+ /**
70
+ * An optional button can be rendered below the description.
71
+ * This can be a link, button, Coachmark button, etc.
72
+ */
73
+ button: PropTypes.node,
74
+ /**
75
+ * Optional class name for this component.
76
+ */
77
+ className: PropTypes.string,
78
+ /**
79
+ * The description of the Coachmark.
80
+ */
81
+ description: PropTypes.node.isRequired,
82
+ /**
83
+ * The title of the Coachmark.
84
+ */
85
+ title: PropTypes.string.isRequired
86
+ };
@@ -0,0 +1,8 @@
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
+
8
+ export { CoachmarkOverlayElement } from './CoachmarkOverlayElement';
@@ -0,0 +1,216 @@
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 = ["className", "children", "isVisible", "media", "nextButtonText", "previousButtonLabel", "closeButtonLabel"];
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, { Children, useEffect, useRef, useState } from 'react';
14
+
15
+ // Other standard imports.
16
+ import PropTypes from 'prop-types';
17
+ import cx from 'classnames';
18
+ import { getDevtoolsProps } from '../../global/js/utils/devtools';
19
+ import { pkg /*, carbon */ } from '../../settings';
20
+
21
+ // Carbon and package components we use.
22
+ import { Button } from '@carbon/react';
23
+ import { useCoachmark } from '../Coachmark';
24
+ import { clamp } from 'lodash';
25
+ import pconsole from '../../global/js/utils/pconsole';
26
+ //TODO THIS PATH WILL NEED TO BE UPDATED ONCE IN IBM PRODUCTS
27
+ import { Carousel } from '../Carousel';
28
+ //TODO THIS PATH WILL NEED TO BE UPDATED ONCE IN IBM PRODUCTS
29
+ import { SteppedAnimatedMedia } from '../SteppedAnimatedMedia';
30
+
31
+ // The block part of our conventional BEM class names (blockClass__E--M).
32
+ var blockClass = "".concat(pkg.prefix, "--coachmark-overlay-elements");
33
+ var componentName = 'CoachmarkOverlayElements';
34
+
35
+ // NOTE: the component SCSS is not imported here: it is rolled up separately.
36
+
37
+ // Default values can be included here and then assigned to the prop params,
38
+ // e.g. prop = defaults.prop,
39
+ // This gathers default values together neatly and ensures non-primitive
40
+ // values are initialized early to avoid react making unnecessary re-renders.
41
+ // Note that default values are not required for props that are 'required',
42
+ // nor for props where the component can apply undefined values reasonably.
43
+ // Default values should be provided when the component needs to make a choice
44
+ // or assumption when a prop is not supplied.
45
+
46
+ // Default values for props
47
+ var defaults = {
48
+ isVisible: false,
49
+ nextButtonText: 'Next',
50
+ previousButtonLabel: 'Back',
51
+ closeButtonLabel: 'Got it'
52
+ };
53
+ /**
54
+ * Composable container to allow for the displaying of CoachmarkOverlayElement
55
+ * components in a carousel fashion.
56
+ */
57
+ export var CoachmarkOverlayElements = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
58
+ var className = _ref.className,
59
+ children = _ref.children,
60
+ _ref$isVisible = _ref.isVisible,
61
+ isVisible = _ref$isVisible === void 0 ? defaults.isVisible : _ref$isVisible,
62
+ media = _ref.media,
63
+ _ref$nextButtonText = _ref.nextButtonText,
64
+ nextButtonText = _ref$nextButtonText === void 0 ? defaults.nextButtonText : _ref$nextButtonText,
65
+ _ref$previousButtonLa = _ref.previousButtonLabel,
66
+ previousButtonLabel = _ref$previousButtonLa === void 0 ? defaults.previousButtonLabel : _ref$previousButtonLa,
67
+ _ref$closeButtonLabel = _ref.closeButtonLabel,
68
+ closeButtonLabel = _ref$closeButtonLabel === void 0 ? defaults.closeButtonLabel : _ref$closeButtonLabel,
69
+ rest = _objectWithoutProperties(_ref, _excluded);
70
+ var buttonFocusRef = useRef();
71
+ var scrollRef = useRef();
72
+ var _useState = useState(0),
73
+ _useState2 = _slicedToArray(_useState, 2),
74
+ scrollPosition = _useState2[0],
75
+ setScrollPosition = _useState2[1];
76
+ var _useState3 = useState(0),
77
+ _useState4 = _slicedToArray(_useState3, 2),
78
+ currentProgStep = _useState4[0],
79
+ _setCurrentProgStep = _useState4[1];
80
+ var coachmark = useCoachmark();
81
+ var setCurrentProgStep = function setCurrentProgStep(value) {
82
+ if (currentProgStep > 0 && value === 0 && buttonFocusRef.current) {
83
+ setTimeout(function () {
84
+ buttonFocusRef.current.focus();
85
+ }, 1000);
86
+ }
87
+ _setCurrentProgStep(value);
88
+ };
89
+ var numProgSteps = Children.count(children);
90
+ var progStepFloor = 0;
91
+ var progStepCeil = numProgSteps - 1;
92
+ useEffect(function () {
93
+ // On mount, one of the two primary buttons ("next" or "close")
94
+ // will be rendered and must have focus. (a11y)
95
+ if (buttonFocusRef.current) {
96
+ buttonFocusRef.current.focus();
97
+ }
98
+ }, []);
99
+ useEffect(function () {
100
+ setTimeout(function () {
101
+ if (buttonFocusRef.current && isVisible) {
102
+ buttonFocusRef.current.focus();
103
+ }
104
+ }, 100);
105
+ }, [isVisible]);
106
+ if (!coachmark) {
107
+ return pconsole.warn("The ".concat(componentName, " is a composable container element which should be used only within the scope of a Coachmark or a CoachmarkFixed component."));
108
+ }
109
+ return /*#__PURE__*/React.createElement("section", _extends({}, rest, {
110
+ className: cx(blockClass,
111
+ // Apply the block class to the main HTML element
112
+ className,
113
+ // Apply any supplied class names to the main HTML element.
114
+ // example: `${blockClass}__template-string-class-${kind}-n-${size}`,
115
+ {
116
+ // switched classes dependant on props or state
117
+ // example: [`${blockClass}__here-if-small`]: size === 'sm',
118
+ }),
119
+ ref: ref
120
+ // role="main"
121
+ }, getDevtoolsProps(componentName)), media && (media.render ? media.render() : /*#__PURE__*/React.createElement(SteppedAnimatedMedia, {
122
+ className: "".concat(blockClass, "__element-stepped-media"),
123
+ filePaths: media.filePaths,
124
+ playStep: currentProgStep
125
+ })), numProgSteps === 1 ? /*#__PURE__*/React.createElement(React.Fragment, null, children, closeButtonLabel && /*#__PURE__*/React.createElement("div", {
126
+ className: cx("".concat(blockClass, "__footer"), 'coachmark-carousel-controls')
127
+ }, /*#__PURE__*/React.createElement(Button, _extends({
128
+ size: "sm"
129
+ }, coachmark.closeButtonProps, {
130
+ ref: buttonFocusRef
131
+ }), closeButtonLabel))) : /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Carousel, {
132
+ disableArrowScroll: true,
133
+ ref: scrollRef,
134
+ onScroll: function onScroll(scrollPercent) {
135
+ setScrollPosition(scrollPercent);
136
+ }
137
+ }, children), /*#__PURE__*/React.createElement("div", {
138
+ className: cx("".concat(blockClass, "__footer"))
139
+ }, /*#__PURE__*/React.createElement("div", {
140
+ className: "".concat(blockClass, "--controls-progress")
141
+ }, "".concat(currentProgStep + 1, " / ").concat(numProgSteps)), scrollPosition > 0 && /*#__PURE__*/React.createElement(Button, {
142
+ size: "sm",
143
+ kind: "ghost",
144
+ title: previousButtonLabel,
145
+ disabled: scrollPosition === 0,
146
+ onClick: function onClick() {
147
+ var targetStep = clamp(currentProgStep - 1, progStepFloor, progStepCeil);
148
+ scrollRef.current.scrollToView(targetStep);
149
+ setCurrentProgStep(targetStep);
150
+ }
151
+ }, previousButtonLabel), currentProgStep < progStepCeil ? /*#__PURE__*/React.createElement(Button, {
152
+ size: "sm",
153
+ ref: buttonFocusRef,
154
+ title: nextButtonText,
155
+ disabled: scrollPosition === 1,
156
+ onClick: function onClick() {
157
+ var targetStep = clamp(currentProgStep + 1, progStepFloor, progStepCeil);
158
+ scrollRef.current.scrollToView(targetStep);
159
+ setCurrentProgStep(targetStep);
160
+ }
161
+ }, nextButtonText) : closeButtonLabel && /*#__PURE__*/React.createElement(Button, _extends({
162
+ size: "sm",
163
+ ref: buttonFocusRef
164
+ }, coachmark.closeButtonProps), closeButtonLabel))));
165
+ });
166
+
167
+ // Return a placeholder if not released and not enabled by feature flag
168
+ CoachmarkOverlayElements = pkg.checkComponentEnabled(CoachmarkOverlayElements, componentName);
169
+
170
+ // The display name of the component, used by React. Note that displayName
171
+ // is used in preference to relying on function.name.
172
+ CoachmarkOverlayElements.displayName = componentName;
173
+
174
+ // The types and DocGen commentary for the component props,
175
+ // in alphabetical order (for consistency).
176
+ // See https://www.npmjs.com/package/prop-types#usage.
177
+ CoachmarkOverlayElements.propTypes = {
178
+ // TODO: UPDATE COMMENT HERE - UPDATE MDX TO HAVE DIRECTION TO USE ONLY OVERLAY ELEMENTS>...CoachmarkOverlayElements will accept only one or more CoachmarkOverlayElement as child components.
179
+
180
+ /**
181
+ * CoachmarkOverlayElements should be used with one or many CoachmarkOverlayElement components as children.
182
+ * @see CoachmarkOverlayElement
183
+ */
184
+ children: PropTypes.node.isRequired,
185
+ /**
186
+ * Optional class name for this component.
187
+ */
188
+ className: PropTypes.string,
189
+ /**
190
+ * The label for the Close button.
191
+ */
192
+ closeButtonLabel: PropTypes.string,
193
+ /**
194
+ * The visibility of CoachmarkOverlayElements is
195
+ * managed in the parent component.
196
+ */
197
+ isVisible: PropTypes.bool,
198
+ /**
199
+ * The object describing an image in one of two shapes.
200
+ * If a single media element is required, use `{render}`.
201
+ * If a stepped animation is required, use `{filePaths}`.
202
+ */
203
+ media: PropTypes.oneOfType([PropTypes.shape({
204
+ render: PropTypes.func
205
+ }), PropTypes.shape({
206
+ filePaths: PropTypes.arrayOf(PropTypes.string)
207
+ })]),
208
+ /**
209
+ * The label for the Next button.
210
+ */
211
+ nextButtonText: PropTypes.string,
212
+ /**
213
+ * The label for the Previous button.
214
+ */
215
+ previousButtonLabel: PropTypes.string
216
+ };
@@ -0,0 +1,8 @@
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
+
8
+ export { CoachmarkOverlayElements } from './CoachmarkOverlayElements';