@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,243 @@
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.CoachmarkOverlay = 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 _uuidv = _interopRequireDefault(require("../../global/js/utils/uuidv4"));
14
+ var _propTypes = _interopRequireDefault(require("prop-types"));
15
+ var _classnames = _interopRequireDefault(require("classnames"));
16
+ var _devtools = require("../../global/js/utils/devtools");
17
+ var _settings = require("../../settings");
18
+ var _CoachmarkDragbar = require("./CoachmarkDragbar");
19
+ var _CoachmarkHeader = require("./CoachmarkHeader");
20
+ var _constants = require("./utils/constants");
21
+ var _context = require("./utils/context");
22
+ var _enums = require("./utils/enums");
23
+ var _excluded = ["children", "onClose", "fixedIsVisible", "className", "kind", "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
+ // Import portions of React that are needed.
31
+ // Other standard imports.
32
+ 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); }
33
+ 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; }
34
+ // The block part of our conventional BEM class names (blockClass__E--M).
35
+ var blockClass = "".concat(_settings.pkg.prefix, "--coachmark-overlay");
36
+ var componentName = 'CoachmarkOverlay';
37
+
38
+ // NOTE: the component SCSS is not imported here: it is rolled up separately.
39
+
40
+ var defaults = {
41
+ kind: _enums.COACHMARK_OVERLAY_KIND.FLOATING,
42
+ theme: 'light'
43
+ };
44
+
45
+ /**
46
+ * DO NOT USE. This component is for the exclusive use
47
+ * of other Novice to Pro components.
48
+ */
49
+ var CoachmarkOverlay = exports.CoachmarkOverlay = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
50
+ var children = _ref.children,
51
+ onClose = _ref.onClose,
52
+ fixedIsVisible = _ref.fixedIsVisible,
53
+ className = _ref.className,
54
+ _ref$kind = _ref.kind,
55
+ kind = _ref$kind === void 0 ? defaults.kind : _ref$kind,
56
+ _ref$theme = _ref.theme,
57
+ theme = _ref$theme === void 0 ? defaults.theme : _ref$theme,
58
+ rest = (0, _objectWithoutProperties2.default)(_ref, _excluded);
59
+ var _useWindowDimensions = useWindowDimensions(),
60
+ winHeight = _useWindowDimensions.winHeight,
61
+ winWidth = _useWindowDimensions.winWidth;
62
+ var _useState = (0, _react.useState)(false),
63
+ _useState2 = (0, _slicedToArray2.default)(_useState, 2),
64
+ a11yDragMode = _useState2[0],
65
+ setA11yDragMode = _useState2[1];
66
+ var overlayRef = (0, _react.useRef)();
67
+ var coachmark = (0, _context.useCoachmark)();
68
+ var isBeacon = kind === _enums.COACHMARK_OVERLAY_KIND.TOOLTIP;
69
+ var isDraggable = kind === _enums.COACHMARK_OVERLAY_KIND.FLOATING;
70
+ var isVisible = className && className.includes('is-visible');
71
+ var handleKeyPress = function handleKeyPress(event) {
72
+ var shiftKey = event.shiftKey,
73
+ key = event.key;
74
+ if (key === 'Enter' || key === ' ') {
75
+ setA11yDragMode(function (prevVal) {
76
+ return !prevVal;
77
+ });
78
+ } else if (a11yDragMode) {
79
+ var distanceToMove = shiftKey ? 128 : 32;
80
+ switch (key) {
81
+ case 'ArrowLeft':
82
+ handleDrag(distanceToMove * -1, 0);
83
+ break;
84
+ case 'ArrowRight':
85
+ handleDrag(distanceToMove, 0);
86
+ break;
87
+ case 'ArrowUp':
88
+ handleDrag(0, distanceToMove * -1);
89
+ break;
90
+ case 'ArrowDown':
91
+ handleDrag(0, distanceToMove);
92
+ break;
93
+ default:
94
+ break;
95
+ }
96
+ }
97
+ };
98
+ var styledTune = {};
99
+ if (isBeacon || isDraggable) {
100
+ if (coachmark.targetRect) {
101
+ styledTune = {
102
+ left: coachmark.targetRect.x + window.scrollX,
103
+ top: coachmark.targetRect.y + window.scrollY
104
+ };
105
+ }
106
+ if (isBeacon) {
107
+ // Compensate for radius of beacon
108
+ styledTune.left += 16;
109
+ styledTune.top += 16;
110
+ } else if (isDraggable) {
111
+ // Compensate for width and height of target element
112
+ var offsetTune = (0, _constants.getOffsetTune)(coachmark, kind);
113
+ styledTune.left += offsetTune.left;
114
+ styledTune.top += offsetTune.top;
115
+ }
116
+ }
117
+ function handleDragBounds(x, y) {
118
+ var xRes = x;
119
+ var yRes = y;
120
+ var xMax = winWidth - 288;
121
+ var yMax = winHeight - 150;
122
+ if (xRes < 0) {
123
+ xRes = 0;
124
+ } else if (xRes > xMax) {
125
+ xRes = xMax;
126
+ }
127
+ if (yRes < 0) {
128
+ yRes = 0;
129
+ } else if (yRes > yMax) {
130
+ yRes = yMax;
131
+ }
132
+ return {
133
+ targetX: xRes,
134
+ targetY: yRes
135
+ };
136
+ }
137
+ function handleDrag(movementX, movementY) {
138
+ var overlay = overlayRef.current;
139
+ var _overlay$getBoundingC = overlay.getBoundingClientRect(),
140
+ x = _overlay$getBoundingC.x,
141
+ y = _overlay$getBoundingC.y;
142
+ var _handleDragBounds = handleDragBounds(x + movementX, y + movementY),
143
+ targetX = _handleDragBounds.targetX,
144
+ targetY = _handleDragBounds.targetY;
145
+ overlay.style.transform = 'none';
146
+ overlay.style.position = 'fixed';
147
+ overlay.style.left = "".concat(targetX, "px");
148
+ overlay.style.top = "".concat(targetY, "px");
149
+ overlay.style.bottom = 'auto';
150
+ }
151
+ var contentId = (0, _uuidv.default)();
152
+ return /*#__PURE__*/_react.default.createElement("div", (0, _extends2.default)({}, rest, {
153
+ className: (0, _classnames.default)(blockClass, "".concat(blockClass, "--").concat(kind), "".concat(blockClass, "__").concat(theme), (isBeacon || isDraggable) && "".concat(blockClass, "--").concat(coachmark.align), fixedIsVisible && "".concat(blockClass, "--is-visible"), a11yDragMode && "".concat(blockClass, "--is-dragmode"), className),
154
+ ref: overlayRef,
155
+ style: styledTune,
156
+ "aria-labelledby": contentId,
157
+ tabIndex: -1
158
+ }, (0, _devtools.getDevtoolsProps)(componentName)), isDraggable ? /*#__PURE__*/_react.default.createElement(_CoachmarkDragbar.CoachmarkDragbar, {
159
+ a11yKeyboardHandler: handleKeyPress,
160
+ onBlur: function onBlur() {
161
+ return setA11yDragMode(false);
162
+ },
163
+ onDrag: handleDrag,
164
+ theme: theme,
165
+ onClose: onClose
166
+ }) : /*#__PURE__*/_react.default.createElement(_CoachmarkHeader.CoachmarkHeader, {
167
+ onClose: onClose
168
+ }), /*#__PURE__*/_react.default.createElement("div", {
169
+ className: "".concat(blockClass, "__body"),
170
+ ref: ref,
171
+ id: contentId
172
+ }, _react.default.Children.map(children, function (child) {
173
+ return /*#__PURE__*/_react.default.cloneElement(child, {
174
+ isVisible: isVisible
175
+ });
176
+ })), isBeacon && /*#__PURE__*/_react.default.createElement("span", {
177
+ className: "".concat(blockClass, "__caret")
178
+ }));
179
+ });
180
+ function getWindowDimensions() {
181
+ var _window = window,
182
+ winWidth = _window.innerWidth,
183
+ winHeight = _window.innerHeight;
184
+ return {
185
+ winWidth: winWidth,
186
+ winHeight: winHeight
187
+ };
188
+ }
189
+ var useWindowDimensions = function useWindowDimensions() {
190
+ var _useState3 = (0, _react.useState)(getWindowDimensions()),
191
+ _useState4 = (0, _slicedToArray2.default)(_useState3, 2),
192
+ windowDimensions = _useState4[0],
193
+ setWindowDimensions = _useState4[1];
194
+ (0, _react.useEffect)(function () {
195
+ function handleResize() {
196
+ setWindowDimensions(getWindowDimensions());
197
+ }
198
+ window.addEventListener('resize', handleResize);
199
+ return function () {
200
+ return window.removeEventListener('resize', handleResize);
201
+ };
202
+ }, []);
203
+ return windowDimensions;
204
+ };
205
+
206
+ // Return a placeholder if not released and not enabled by feature flag
207
+ exports.CoachmarkOverlay = CoachmarkOverlay = _settings.pkg.checkComponentEnabled(CoachmarkOverlay, componentName);
208
+
209
+ // The display name of the component, used by React. Note that displayName
210
+ // is used in preference to relying on function.name.
211
+ CoachmarkOverlay.displayName = componentName;
212
+
213
+ // The types and DocGen commentary for the component props,
214
+ // in alphabetical order (for consistency).
215
+ // See https://www.npmjs.com/package/prop-types#usage.
216
+ CoachmarkOverlay.propTypes = {
217
+ /**
218
+ * The CoachmarkOverlayElements child components.
219
+ * Validation is handled in the parent Coachmark component.
220
+ */
221
+ children: _propTypes.default.node.isRequired,
222
+ /**
223
+ * Optional class name for this component.
224
+ */
225
+ className: _propTypes.default.string,
226
+ /**
227
+ * The visibility of CoachmarkOverlay is
228
+ * managed in the parent Coachmark component.
229
+ */
230
+ fixedIsVisible: _propTypes.default.bool.isRequired,
231
+ /**
232
+ * What kind or style of Coachmark to render.
233
+ */
234
+ kind: _propTypes.default.oneOf(Object.values(_enums.COACHMARK_OVERLAY_KIND)),
235
+ /**
236
+ * Function to call when the Coachmark closes.
237
+ */
238
+ onClose: _propTypes.default.func.isRequired,
239
+ /**
240
+ * Determines the theme of the component.
241
+ */
242
+ theme: _propTypes.default.oneOf(['light', 'dark'])
243
+ };
@@ -0,0 +1,101 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.CoachmarkTagline = 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 _iconsReact = require("@carbon/icons-react");
14
+ var _react2 = require("@carbon/react");
15
+ var _context = require("./utils/context");
16
+ var _devtools = require("../../global/js/utils/devtools");
17
+ var _settings = require("../../settings");
18
+ var _excluded = ["closeIconDescription", "onClose", "theme", "title"];
19
+ /**
20
+ * Copyright IBM Corp. 2023, 2024
21
+ *
22
+ * This source code is licensed under the Apache-2.0 license found in the
23
+ * LICENSE file in the root directory of this source tree.
24
+ */
25
+ // Import portions of React that are needed.
26
+ // Other standard imports.
27
+ // The block part of our conventional BEM class names (blockClass__E--M).
28
+ var blockClass = "".concat(_settings.pkg.prefix, "--coachmark-tagline");
29
+ var componentName = 'CoachmarkTagline';
30
+ var defaults = {
31
+ closeIconDescription: 'Close',
32
+ onClose: function onClose() {},
33
+ theme: 'light'
34
+ };
35
+
36
+ /**
37
+ * DO NOT USE. This component is for the exclusive use
38
+ * of other Novice to Pro components.
39
+ */
40
+ var CoachmarkTagline = exports.CoachmarkTagline = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref) {
41
+ var _ref$closeIconDescrip = _ref.closeIconDescription,
42
+ closeIconDescription = _ref$closeIconDescrip === void 0 ? defaults.closeIconDescription : _ref$closeIconDescrip,
43
+ _ref$onClose = _ref.onClose,
44
+ onClose = _ref$onClose === void 0 ? defaults.onClose : _ref$onClose,
45
+ _ref$theme = _ref.theme,
46
+ theme = _ref$theme === void 0 ? defaults.theme : _ref$theme,
47
+ title = _ref.title,
48
+ rest = (0, _objectWithoutProperties2.default)(_ref, _excluded);
49
+ var coachmark = (0, _context.useCoachmark)();
50
+ return /*#__PURE__*/_react.default.createElement("div", (0, _extends2.default)({}, rest, {
51
+ className: (0, _classnames.default)(blockClass, "".concat(blockClass, "__").concat(theme), coachmark.isOpen && "".concat(blockClass, "--is-open")),
52
+ ref: ref
53
+ }, (0, _devtools.getDevtoolsProps)(componentName)), /*#__PURE__*/_react.default.createElement("button", (0, _extends2.default)({
54
+ // {...rest}
55
+ className: "".concat(blockClass, "__cta"),
56
+ type: "button"
57
+ }, coachmark.buttonProps), /*#__PURE__*/_react.default.createElement("div", {
58
+ className: "".concat(blockClass, "__idea")
59
+ }, /*#__PURE__*/_react.default.createElement(_iconsReact.Idea, {
60
+ size: 16
61
+ })), /*#__PURE__*/_react.default.createElement("div", null, title)), /*#__PURE__*/_react.default.createElement("div", {
62
+ className: "".concat(blockClass, "--close-btn-container")
63
+ }, /*#__PURE__*/_react.default.createElement(_react2.Button, {
64
+ kind: "ghost",
65
+ size: "sm",
66
+ renderIcon: _iconsReact.Close,
67
+ iconDescription: closeIconDescription,
68
+ hasIconOnly: true,
69
+ className: "".concat(blockClass, "--close-btn"),
70
+ onClick: onClose
71
+ })));
72
+ });
73
+
74
+ // Return a placeholder if not released and not enabled by feature flag
75
+ exports.CoachmarkTagline = CoachmarkTagline = _settings.pkg.checkComponentEnabled(CoachmarkTagline, componentName);
76
+
77
+ // The display name of the component, used by React. Note that displayName
78
+ // is used in preference to relying on function.name.
79
+ CoachmarkTagline.displayName = componentName;
80
+
81
+ // The types and DocGen commentary for the component props,
82
+ // in alphabetical order (for consistency).
83
+ // See https://www.npmjs.com/package/prop-types#usage.
84
+ CoachmarkTagline.propTypes = {
85
+ /**
86
+ * Tooltip text and aria label for the Close button icon.
87
+ */
88
+ closeIconDescription: _propTypes.default.string,
89
+ /**
90
+ * Function to call when the close button is clicked.
91
+ */
92
+ onClose: _propTypes.default.func,
93
+ /**
94
+ * Determines the theme of the component.
95
+ */
96
+ theme: _propTypes.default.oneOf(['light', 'dark']),
97
+ /**
98
+ * The title of the tagline.
99
+ */
100
+ title: _propTypes.default.string.isRequired
101
+ };
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ Object.defineProperty(exports, "BEACON_KIND", {
7
+ enumerable: true,
8
+ get: function get() {
9
+ return _enums.BEACON_KIND;
10
+ }
11
+ });
12
+ Object.defineProperty(exports, "COACHMARK_ALIGNMENT", {
13
+ enumerable: true,
14
+ get: function get() {
15
+ return _enums.COACHMARK_ALIGNMENT;
16
+ }
17
+ });
18
+ Object.defineProperty(exports, "COACHMARK_OVERLAY_KIND", {
19
+ enumerable: true,
20
+ get: function get() {
21
+ return _enums.COACHMARK_OVERLAY_KIND;
22
+ }
23
+ });
24
+ Object.defineProperty(exports, "Coachmark", {
25
+ enumerable: true,
26
+ get: function get() {
27
+ return _Coachmark.Coachmark;
28
+ }
29
+ });
30
+ Object.defineProperty(exports, "useCoachmark", {
31
+ enumerable: true,
32
+ get: function get() {
33
+ return _context.useCoachmark;
34
+ }
35
+ });
36
+ var _Coachmark = require("./Coachmark");
37
+ var _enums = require("./utils/enums");
38
+ var _context = require("./utils/context");
@@ -0,0 +1,81 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.getOffsetTune = void 0;
7
+ var _enums = require("./enums");
8
+ /**
9
+ * If the coachmark's target is a link, button, etc. (i.e. not a beacon),
10
+ * this adjusts the coachmark's position based on the position and size of the target.
11
+ * @param {object} coachmark target reference
12
+ * @param {string} kind type of coachmark
13
+ * @returns {object} {top:number, left:number}
14
+ */
15
+
16
+ var getOffsetTune = exports.getOffsetTune = function getOffsetTune(coachmark, kind) {
17
+ // for future reference
18
+ // const coachmarkTarget = {
19
+ // x: coachmark.targetOffset.x,
20
+ // y: coachmark.targetOffset.y,
21
+ // width: coachmark.targetRect.width,
22
+ // height: coachmark.targetRect.height,
23
+ // };
24
+
25
+ var _coachmark$targetRect = coachmark.targetRect,
26
+ width = _coachmark$targetRect.width,
27
+ height = _coachmark$targetRect.height;
28
+ var distanceOffset = 24; // see also _coachmark-overlay.scss > $distance-offset
29
+ var top = 0;
30
+ var left = 0;
31
+ if (kind !== _enums.COACHMARK_OVERLAY_KIND.TOOLTIP) {
32
+ switch (coachmark.align) {
33
+ case _enums.COACHMARK_ALIGNMENT.TOP:
34
+ left = width / 2;
35
+ break;
36
+ case _enums.COACHMARK_ALIGNMENT.TOP_LEFT:
37
+ left = distanceOffset;
38
+ break;
39
+ case _enums.COACHMARK_ALIGNMENT.TOP_RIGHT:
40
+ left = width - distanceOffset;
41
+ break;
42
+ case _enums.COACHMARK_ALIGNMENT.BOTTOM:
43
+ top = height;
44
+ left = width / 2;
45
+ break;
46
+ case _enums.COACHMARK_ALIGNMENT.BOTTOM_LEFT:
47
+ top = height;
48
+ left = distanceOffset;
49
+ break;
50
+ case _enums.COACHMARK_ALIGNMENT.BOTTOM_RIGHT:
51
+ top = height;
52
+ left = width - distanceOffset;
53
+ break;
54
+ case _enums.COACHMARK_ALIGNMENT.LEFT:
55
+ top = height / 2;
56
+ break;
57
+ case _enums.COACHMARK_ALIGNMENT.LEFT_TOP:
58
+ top = distanceOffset;
59
+ break;
60
+ case _enums.COACHMARK_ALIGNMENT.LEFT_BOTTOM:
61
+ top = height - distanceOffset;
62
+ break;
63
+ case _enums.COACHMARK_ALIGNMENT.RIGHT:
64
+ top = height / 2;
65
+ left = width;
66
+ break;
67
+ case _enums.COACHMARK_ALIGNMENT.RIGHT_TOP:
68
+ top = distanceOffset;
69
+ left = width;
70
+ break;
71
+ case _enums.COACHMARK_ALIGNMENT.RIGHT_BOTTOM:
72
+ top = height - distanceOffset;
73
+ left = width;
74
+ break;
75
+ }
76
+ }
77
+ return {
78
+ top: top,
79
+ left: left
80
+ };
81
+ };
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.useCoachmark = exports.CoachmarkContext = void 0;
7
+ var _react = require("react");
8
+ var CoachmarkContext = exports.CoachmarkContext = /*#__PURE__*/(0, _react.createContext)();
9
+ var useCoachmark = exports.useCoachmark = function useCoachmark() {
10
+ return (0, _react.useContext)(CoachmarkContext);
11
+ };
@@ -0,0 +1,46 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.COACHMARK_OVERLAY_KIND = exports.COACHMARK_ALIGNMENT = exports.BEACON_KIND = void 0;
7
+ /* eslint-disable max-len */
8
+
9
+ /**
10
+ * Reserved for future expansion, i.e. "RING".
11
+ */
12
+ var BEACON_KIND = exports.BEACON_KIND = {
13
+ DEFAULT: 'default'
14
+ };
15
+
16
+ /**
17
+ * Describes the style and behavior of a Coachmark.
18
+ * @param TOOLTIP includes a caret pointing to the animated beacon.
19
+ * @param FLOATING includes a drag handle across the top.
20
+ * @param FIXED is fixed to the bottom-right of the viewport.
21
+ * @param STACKED is fixed to the bottom-right of the viewport, includes links to show more, stackable Coachmarks if included.
22
+ */
23
+ var COACHMARK_OVERLAY_KIND = exports.COACHMARK_OVERLAY_KIND = {
24
+ TOOLTIP: 'tooltip',
25
+ FLOATING: 'floating',
26
+ FIXED: 'fixed',
27
+ STACKED: 'stacked'
28
+ };
29
+ /**
30
+ * Where to render the Coachmark relative to its target.
31
+ * Applies only to Floating and Tooltip Coachmarks.
32
+ */
33
+ var COACHMARK_ALIGNMENT = exports.COACHMARK_ALIGNMENT = {
34
+ BOTTOM: 'bottom',
35
+ BOTTOM_LEFT: 'bottom-left',
36
+ BOTTOM_RIGHT: 'bottom-right',
37
+ LEFT: 'left',
38
+ LEFT_TOP: 'left-top',
39
+ LEFT_BOTTOM: 'left-bottom',
40
+ RIGHT: 'right',
41
+ RIGHT_TOP: 'right-top',
42
+ RIGHT_BOTTOM: 'right-bottom',
43
+ TOP: 'top',
44
+ TOP_LEFT: 'top-left',
45
+ TOP_RIGHT: 'top-right'
46
+ };
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.clamp = clamp;
7
+ /* eslint-disable max-len */
8
+
9
+ /**
10
+ * Clamp the given value between the upper bound `max` and the lower bound `min`
11
+ * @param {number} max
12
+ * @param {number} min
13
+ * @param {number} value
14
+ */
15
+ function clamp(max, min, value) {
16
+ return Math.min(max, Math.max(min, value));
17
+ }
@@ -0,0 +1,59 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.useClickOutsideElement = useClickOutsideElement;
7
+ exports.useWindowEvent = void 0;
8
+ var _react = require("react");
9
+ var _enums = require("./enums");
10
+ /**
11
+ * Detects when a user clicks outside of the element
12
+ * @param {object} coachmarkRef - The ref to the React element for the Coachmark to detect when the user clicks outside of its bounds.
13
+ * @param {object} overlayRef - The ref to the React element for the CoachmarkOverlay to detect when the user clicks outside of its bounds.
14
+ * @param {string} overlayKind - The overlayKind prop from the Coachmark. @see COACHMARK_OVERLAY_KIND
15
+ * @param {Function} callback The callback to call when the user mouses down.
16
+ */
17
+
18
+ function useClickOutsideElement(coachmarkRef, overlayRef, overlayKind, callback) {
19
+ var cb = (0, _react.useRef)();
20
+ var isTooltip = overlayKind === _enums.COACHMARK_OVERLAY_KIND.TOOLTIP;
21
+ (0, _react.useLayoutEffect)(function () {
22
+ cb.current = callback;
23
+ }, [callback]);
24
+ (0, _react.useEffect)(function () {
25
+ function handleClickOutside(event) {
26
+ var isOverlayOutside = overlayRef.current && !overlayRef.current.contains(event.target);
27
+ var isOutsideCoachmark = coachmarkRef.current && !coachmarkRef.current.contains(event.target);
28
+ if (isOverlayOutside && isOutsideCoachmark) {
29
+ callCallback();
30
+ }
31
+ }
32
+ function callCallback() {
33
+ if (isTooltip) {
34
+ cb.current();
35
+ }
36
+ }
37
+ document.addEventListener('mousedown', handleClickOutside);
38
+ return function () {
39
+ document.removeEventListener('mousedown', handleClickOutside);
40
+ };
41
+ }, [coachmarkRef, overlayRef, isTooltip]);
42
+ }
43
+ var useWindowEvent = exports.useWindowEvent = function useWindowEvent(eventName, callback) {
44
+ var savedCallback = (0, _react.useRef)(null);
45
+ (0, _react.useEffect)(function () {
46
+ savedCallback.current = callback;
47
+ });
48
+ (0, _react.useEffect)(function () {
49
+ function handler(event) {
50
+ if (savedCallback.current) {
51
+ savedCallback.current(event);
52
+ }
53
+ }
54
+ window.addEventListener(eventName, handler);
55
+ return function () {
56
+ window.removeEventListener(eventName, handler);
57
+ };
58
+ }, [eventName]);
59
+ };