@carbon/ibm-products 2.22.0 → 2.24.0

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