@carbon/ibm-products 1.55.2 → 1.56.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (95) hide show
  1. package/css/index-full-carbon.css +579 -0
  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.css +579 -0
  6. package/css/index-without-carbon.css.map +1 -1
  7. package/css/index-without-carbon.min.css +1 -1
  8. package/css/index-without-carbon.min.css.map +1 -1
  9. package/css/index.css +579 -0
  10. package/css/index.css.map +1 -1
  11. package/css/index.min.css +1 -1
  12. package/css/index.min.css.map +1 -1
  13. package/es/components/Carousel/Carousel.js +15 -5
  14. package/es/components/Coachmark/Coachmark.js +243 -0
  15. package/es/components/Coachmark/CoachmarkDragbar.js +137 -0
  16. package/es/components/Coachmark/CoachmarkHeader.js +88 -0
  17. package/es/components/Coachmark/CoachmarkOverlay.js +139 -0
  18. package/es/components/Coachmark/CoachmarkTagline.js +93 -0
  19. package/es/components/Coachmark/index.js +10 -0
  20. package/es/components/Coachmark/utils/constants.js +76 -0
  21. package/es/components/Coachmark/utils/context.js +5 -0
  22. package/es/components/Coachmark/utils/enums.js +40 -0
  23. package/es/components/Coachmark/utils/helpers.js +11 -0
  24. package/es/components/Coachmark/utils/hooks.js +54 -0
  25. package/es/components/CoachmarkBeacon/CoachmarkBeacon.js +90 -0
  26. package/es/components/CoachmarkBeacon/index.js +8 -0
  27. package/es/components/CoachmarkButton/CoachmarkButton.js +72 -0
  28. package/es/components/CoachmarkButton/index.js +8 -0
  29. package/es/components/CoachmarkFixed/CoachmarkFixed.js +201 -0
  30. package/es/components/CoachmarkFixed/index.js +8 -0
  31. package/es/components/CoachmarkOverlayElement/CoachmarkOverlayElement.js +86 -0
  32. package/es/components/CoachmarkOverlayElement/index.js +8 -0
  33. package/es/components/CoachmarkOverlayElements/CoachmarkOverlayElements.js +175 -0
  34. package/es/components/CoachmarkOverlayElements/index.js +8 -0
  35. package/es/components/CoachmarkStack/CoachmarkStack.js +260 -0
  36. package/es/components/CoachmarkStack/CoachmarkStackHome.js +157 -0
  37. package/es/components/CoachmarkStack/index.js +8 -0
  38. package/es/components/NotificationsPanel/NotificationsPanel.js +3 -2
  39. package/es/components/index.js +7 -0
  40. package/es/global/js/package-settings.js +8 -1
  41. package/lib/components/Carousel/Carousel.js +15 -5
  42. package/lib/components/Coachmark/Coachmark.js +247 -0
  43. package/lib/components/Coachmark/CoachmarkDragbar.js +137 -0
  44. package/lib/components/Coachmark/CoachmarkHeader.js +85 -0
  45. package/lib/components/Coachmark/CoachmarkOverlay.js +139 -0
  46. package/lib/components/Coachmark/CoachmarkTagline.js +90 -0
  47. package/lib/components/Coachmark/index.js +38 -0
  48. package/lib/components/Coachmark/utils/constants.js +82 -0
  49. package/lib/components/Coachmark/utils/context.js +13 -0
  50. package/lib/components/Coachmark/utils/enums.js +49 -0
  51. package/lib/components/Coachmark/utils/helpers.js +17 -0
  52. package/lib/components/Coachmark/utils/hooks.js +60 -0
  53. package/lib/components/CoachmarkBeacon/CoachmarkBeacon.js +87 -0
  54. package/lib/components/CoachmarkBeacon/index.js +12 -0
  55. package/lib/components/CoachmarkButton/CoachmarkButton.js +69 -0
  56. package/lib/components/CoachmarkButton/index.js +12 -0
  57. package/lib/components/CoachmarkFixed/CoachmarkFixed.js +201 -0
  58. package/lib/components/CoachmarkFixed/index.js +12 -0
  59. package/lib/components/CoachmarkOverlayElement/CoachmarkOverlayElement.js +83 -0
  60. package/lib/components/CoachmarkOverlayElement/index.js +12 -0
  61. package/lib/components/CoachmarkOverlayElements/CoachmarkOverlayElements.js +176 -0
  62. package/lib/components/CoachmarkOverlayElements/index.js +12 -0
  63. package/lib/components/CoachmarkStack/CoachmarkStack.js +264 -0
  64. package/lib/components/CoachmarkStack/CoachmarkStackHome.js +160 -0
  65. package/lib/components/CoachmarkStack/index.js +12 -0
  66. package/lib/components/NotificationsPanel/NotificationsPanel.js +3 -2
  67. package/lib/components/index.js +49 -0
  68. package/lib/global/js/package-settings.js +8 -1
  69. package/package.json +2 -2
  70. package/scss/components/Carousel/_carousel.scss +3 -0
  71. package/scss/components/Coachmark/_index.scss +11 -0
  72. package/scss/components/Coachmark/_storybook-styles.scss +20 -0
  73. package/scss/components/Coachmark/styles/_coachmark-dragbar.scss +74 -0
  74. package/scss/components/Coachmark/styles/_coachmark-header.scss +58 -0
  75. package/scss/components/Coachmark/styles/_coachmark-overlay.scss +327 -0
  76. package/scss/components/Coachmark/styles/_coachmark-tagline.scss +118 -0
  77. package/scss/components/CoachmarkBeacon/_coachmark-beacon.scss +166 -0
  78. package/scss/components/CoachmarkBeacon/_index.scss +8 -0
  79. package/scss/components/CoachmarkBeacon/_storybook-styles.scss +19 -0
  80. package/scss/components/CoachmarkButton/_coachmark-button.scss +34 -0
  81. package/scss/components/CoachmarkButton/_index.scss +8 -0
  82. package/scss/components/CoachmarkButton/_storybook-styles.scss +19 -0
  83. package/scss/components/CoachmarkFixed/_coachmark-fixed.scss +34 -0
  84. package/scss/components/CoachmarkFixed/_index.scss +8 -0
  85. package/scss/components/CoachmarkFixed/_storybook-styles.scss +10 -0
  86. package/scss/components/CoachmarkOverlayElement/_coachmark-overlay-element.scss +50 -0
  87. package/scss/components/CoachmarkOverlayElement/_index.scss +8 -0
  88. package/scss/components/CoachmarkOverlayElement/_storybook-styles.scss +19 -0
  89. package/scss/components/CoachmarkOverlayElements/_coachmark-overlay-elements.scss +40 -0
  90. package/scss/components/CoachmarkOverlayElements/_index.scss +8 -0
  91. package/scss/components/CoachmarkOverlayElements/_storybook-styles.scss +19 -0
  92. package/scss/components/CoachmarkStack/_coachmark-stack.scss +85 -0
  93. package/scss/components/CoachmarkStack/_index.scss +8 -0
  94. package/scss/components/CoachmarkStack/_storybook-styles.scss +10 -0
  95. package/scss/components/_index.scss +7 -1
@@ -0,0 +1,85 @@
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 _iconsReact = require("@carbon/icons-react");
14
+ var _carbonComponentsReact = require("carbon-components-react");
15
+ var _devtools = require("../../global/js/utils/devtools");
16
+ var _settings = require("../../settings");
17
+ var _excluded = ["closeIconDescription", "onClose", "showCloseButton", "theme"];
18
+ // The block part of our conventional BEM class names (blockClass__E--M).
19
+ var blockClass = "".concat(_settings.pkg.prefix, "--coachmark-header");
20
+ var componentName = 'CoachmarkHeader';
21
+ var defaults = {
22
+ closeIconDescription: 'Close',
23
+ onClose: function onClose() {},
24
+ showCloseButton: true,
25
+ theme: 'light'
26
+ };
27
+
28
+ /**
29
+ * DO NOT USE. This component is for the exclusive use
30
+ * of other Novice to Pro components.
31
+ */
32
+ var CoachmarkHeader = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref) {
33
+ var _ref$closeIconDescrip = _ref.closeIconDescription,
34
+ closeIconDescription = _ref$closeIconDescrip === void 0 ? defaults.closeIconDescription : _ref$closeIconDescrip,
35
+ _ref$onClose = _ref.onClose,
36
+ onClose = _ref$onClose === void 0 ? defaults.onClose : _ref$onClose,
37
+ _ref$showCloseButton = _ref.showCloseButton,
38
+ showCloseButton = _ref$showCloseButton === void 0 ? defaults.showCloseButton : _ref$showCloseButton,
39
+ _ref$theme = _ref.theme,
40
+ theme = _ref$theme === void 0 ? defaults.theme : _ref$theme,
41
+ rest = (0, _objectWithoutProperties2.default)(_ref, _excluded);
42
+ return /*#__PURE__*/_react.default.createElement("header", (0, _extends2.default)({}, rest, {
43
+ className: (0, _classnames.default)(blockClass, "".concat(blockClass, "__").concat(theme)),
44
+ ref: ref
45
+ // role="main"
46
+ }, (0, _devtools.getDevtoolsProps)(componentName)), showCloseButton && /*#__PURE__*/_react.default.createElement(_carbonComponentsReact.Button, {
47
+ kind: "ghost",
48
+ size: "sm",
49
+ renderIcon: _iconsReact.Close16,
50
+ iconDescription: closeIconDescription,
51
+ hasIconOnly: true,
52
+ className: "".concat(blockClass, "--close-btn"),
53
+ onClick: onClose
54
+ }));
55
+ });
56
+
57
+ // Return a placeholder if not released and not enabled by feature flag
58
+ exports.CoachmarkHeader = CoachmarkHeader;
59
+ exports.CoachmarkHeader = CoachmarkHeader = _settings.pkg.checkComponentEnabled(CoachmarkHeader, 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
+ CoachmarkHeader.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
+ CoachmarkHeader.propTypes = {
69
+ /**
70
+ * Tooltip text and aria label for the Close button icon.
71
+ */
72
+ closeIconDescription: _propTypes.default.string,
73
+ /**
74
+ * Function to call when the close button is clicked.
75
+ */
76
+ onClose: _propTypes.default.func,
77
+ /**
78
+ * Show/hide the "X" close button.
79
+ */
80
+ showCloseButton: _propTypes.default.bool,
81
+ /**
82
+ * Determines the theme of the component.
83
+ */
84
+ theme: _propTypes.default.oneOf(['light', 'dark'])
85
+ };
@@ -0,0 +1,139 @@
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 _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
11
+ var _react = _interopRequireWildcard(require("react"));
12
+ var _propTypes = _interopRequireDefault(require("prop-types"));
13
+ var _classnames = _interopRequireDefault(require("classnames"));
14
+ var _devtools = require("../../global/js/utils/devtools");
15
+ var _settings = require("../../settings");
16
+ var _CoachmarkDragbar = require("./CoachmarkDragbar");
17
+ var _CoachmarkHeader = require("./CoachmarkHeader");
18
+ var _constants = require("./utils/constants");
19
+ var _context = require("./utils/context");
20
+ var _enums = require("./utils/enums");
21
+ var _excluded = ["children", "onClose", "fixedIsVisible", "className", "kind", "theme"];
22
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
23
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
24
+ // The block part of our conventional BEM class names (blockClass__E--M).
25
+ var blockClass = "".concat(_settings.pkg.prefix, "--coachmark-overlay");
26
+ var componentName = 'CoachmarkOverlay';
27
+
28
+ // NOTE: the component SCSS is not imported here: it is rolled up separately.
29
+
30
+ var defaults = {
31
+ kind: _enums.COACHMARK_OVERLAY_KIND.FLOATING,
32
+ theme: 'light'
33
+ };
34
+
35
+ /**
36
+ * DO NOT USE. This component is for the exclusive use
37
+ * of other Novice to Pro components.
38
+ */
39
+ var CoachmarkOverlay = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
40
+ var children = _ref.children,
41
+ onClose = _ref.onClose,
42
+ fixedIsVisible = _ref.fixedIsVisible,
43
+ className = _ref.className,
44
+ _ref$kind = _ref.kind,
45
+ kind = _ref$kind === void 0 ? defaults.kind : _ref$kind,
46
+ _ref$theme = _ref.theme,
47
+ theme = _ref$theme === void 0 ? defaults.theme : _ref$theme,
48
+ rest = (0, _objectWithoutProperties2.default)(_ref, _excluded);
49
+ var overlayRef = (0, _react.useRef)();
50
+ var coachmark = (0, _context.useCoachmark)();
51
+ var isBeacon = kind === _enums.COACHMARK_OVERLAY_KIND.TOOLTIP;
52
+ var isDraggable = kind === _enums.COACHMARK_OVERLAY_KIND.FLOATING;
53
+ var styledTune = {};
54
+ // TODO: check this... this feels like it should be in a hook with no dep array.
55
+ if (isBeacon || isDraggable) {
56
+ if (coachmark.targetRect) {
57
+ styledTune = {
58
+ left: coachmark.targetRect.x + window.scrollX,
59
+ top: coachmark.targetRect.y + window.scrollY
60
+ };
61
+ }
62
+ if (isBeacon) {
63
+ // Compensate for radius of beacon
64
+ styledTune.left += 16;
65
+ styledTune.top += 16;
66
+ } else if (isDraggable) {
67
+ // Compensate for width and height of target element
68
+ var offsetTune = (0, _constants.getOffsetTune)(coachmark, kind);
69
+ styledTune.left += offsetTune.left;
70
+ styledTune.top += offsetTune.top;
71
+ }
72
+ }
73
+ function handleDrag(movementX, movementY) {
74
+ var overlay = overlayRef.current;
75
+ var _overlay$getBoundingC = overlay.getBoundingClientRect(),
76
+ x = _overlay$getBoundingC.x,
77
+ y = _overlay$getBoundingC.y;
78
+ overlay.style.transform = 'none';
79
+ overlay.style.position = 'fixed';
80
+ overlay.style.left = "".concat(x + movementX, "px");
81
+ overlay.style.top = "".concat(y + movementY, "px");
82
+ overlay.style.bottom = 'auto';
83
+ }
84
+ return /*#__PURE__*/_react.default.createElement("div", (0, _extends2.default)({}, rest, {
85
+ 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"), className),
86
+ ref: overlayRef,
87
+ style: styledTune
88
+ }, (0, _devtools.getDevtoolsProps)(componentName)), isDraggable ? /*#__PURE__*/_react.default.createElement(_CoachmarkDragbar.CoachmarkDragbar, {
89
+ onDrag: handleDrag,
90
+ onClose: onClose
91
+ }) : /*#__PURE__*/_react.default.createElement(_CoachmarkHeader.CoachmarkHeader, {
92
+ onClose: onClose
93
+ }), /*#__PURE__*/_react.default.createElement("div", {
94
+ className: "".concat(blockClass, "__body"),
95
+ ref: ref
96
+ }, children), isBeacon && /*#__PURE__*/_react.default.createElement("span", {
97
+ className: "".concat(blockClass, "__caret")
98
+ }));
99
+ });
100
+
101
+ // Return a placeholder if not released and not enabled by feature flag
102
+ exports.CoachmarkOverlay = CoachmarkOverlay;
103
+ exports.CoachmarkOverlay = CoachmarkOverlay = _settings.pkg.checkComponentEnabled(CoachmarkOverlay, componentName);
104
+
105
+ // The display name of the component, used by React. Note that displayName
106
+ // is used in preference to relying on function.name.
107
+ CoachmarkOverlay.displayName = componentName;
108
+
109
+ // The types and DocGen commentary for the component props,
110
+ // in alphabetical order (for consistency).
111
+ // See https://www.npmjs.com/package/prop-types#usage.
112
+ CoachmarkOverlay.propTypes = {
113
+ /**
114
+ * The CoachmarkOverlayElements child components.
115
+ * Validation is handled in the parent Coachmark component.
116
+ */
117
+ children: _propTypes.default.node.isRequired,
118
+ /**
119
+ * Optional class name for this component.
120
+ */
121
+ className: _propTypes.default.string,
122
+ /**
123
+ * The visibility of CoachmarkOverlay is
124
+ * managed in the parent Coachmark component.
125
+ */
126
+ fixedIsVisible: _propTypes.default.bool.isRequired,
127
+ /**
128
+ * What kind or style of Coachmark to render.
129
+ */
130
+ kind: _propTypes.default.oneOf(Object.values(_enums.COACHMARK_OVERLAY_KIND)),
131
+ /**
132
+ * Function to call when the Coachmark closes.
133
+ */
134
+ onClose: _propTypes.default.func.isRequired,
135
+ /**
136
+ * Determines the theme of the component.
137
+ */
138
+ theme: _propTypes.default.oneOf(['light', 'dark'])
139
+ };
@@ -0,0 +1,90 @@
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 _carbonComponentsReact = require("carbon-components-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
+ // The block part of our conventional BEM class names (blockClass__E--M).
20
+ var blockClass = "".concat(_settings.pkg.prefix, "--coachmark-tagline");
21
+ var componentName = 'CoachmarkTagline';
22
+ var defaults = {
23
+ closeIconDescription: 'Close',
24
+ onClose: function onClose() {},
25
+ theme: 'light'
26
+ };
27
+
28
+ /**
29
+ * DO NOT USE. This component is for the exclusive use
30
+ * of other Novice to Pro components.
31
+ */
32
+ var CoachmarkTagline = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref) {
33
+ var _ref$closeIconDescrip = _ref.closeIconDescription,
34
+ closeIconDescription = _ref$closeIconDescrip === void 0 ? defaults.closeIconDescription : _ref$closeIconDescrip,
35
+ _ref$onClose = _ref.onClose,
36
+ onClose = _ref$onClose === void 0 ? defaults.onClose : _ref$onClose,
37
+ _ref$theme = _ref.theme,
38
+ theme = _ref$theme === void 0 ? defaults.theme : _ref$theme,
39
+ title = _ref.title,
40
+ rest = (0, _objectWithoutProperties2.default)(_ref, _excluded);
41
+ var coachmark = (0, _context.useCoachmark)();
42
+ return /*#__PURE__*/_react.default.createElement("div", (0, _extends2.default)({}, rest, {
43
+ className: (0, _classnames.default)(blockClass, "".concat(blockClass, "__").concat(theme), coachmark.isOpen && "".concat(blockClass, "--is-open")),
44
+ ref: ref
45
+ }, (0, _devtools.getDevtoolsProps)(componentName)), /*#__PURE__*/_react.default.createElement("button", (0, _extends2.default)({
46
+ // {...rest}
47
+ className: "".concat(blockClass, "__cta"),
48
+ type: "button"
49
+ }, coachmark.buttonProps), /*#__PURE__*/_react.default.createElement("div", {
50
+ className: "".concat(blockClass, "__idea")
51
+ }, /*#__PURE__*/_react.default.createElement(_iconsReact.Idea16, null)), /*#__PURE__*/_react.default.createElement("div", null, title)), /*#__PURE__*/_react.default.createElement(_carbonComponentsReact.Button, {
52
+ kind: "ghost",
53
+ size: "sm",
54
+ renderIcon: _iconsReact.Close16,
55
+ iconDescription: closeIconDescription,
56
+ hasIconOnly: true,
57
+ className: "".concat(blockClass, "--close-btn"),
58
+ onClick: onClose
59
+ }));
60
+ });
61
+
62
+ // Return a placeholder if not released and not enabled by feature flag
63
+ exports.CoachmarkTagline = CoachmarkTagline;
64
+ exports.CoachmarkTagline = CoachmarkTagline = _settings.pkg.checkComponentEnabled(CoachmarkTagline, componentName);
65
+
66
+ // The display name of the component, used by React. Note that displayName
67
+ // is used in preference to relying on function.name.
68
+ CoachmarkTagline.displayName = componentName;
69
+
70
+ // The types and DocGen commentary for the component props,
71
+ // in alphabetical order (for consistency).
72
+ // See https://www.npmjs.com/package/prop-types#usage.
73
+ CoachmarkTagline.propTypes = {
74
+ /**
75
+ * Tooltip text and aria label for the Close button icon.
76
+ */
77
+ closeIconDescription: _propTypes.default.string,
78
+ /**
79
+ * Function to call when the close button is clicked.
80
+ */
81
+ onClose: _propTypes.default.func,
82
+ /**
83
+ * Determines the theme of the component.
84
+ */
85
+ theme: _propTypes.default.oneOf(['light', 'dark']),
86
+ /**
87
+ * The title of the tagline.
88
+ */
89
+ title: _propTypes.default.string.isRequired
90
+ };
@@ -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,82 @@
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 = 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
+ };
82
+ exports.getOffsetTune = getOffsetTune;
@@ -0,0 +1,13 @@
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 = /*#__PURE__*/(0, _react.createContext)();
9
+ exports.CoachmarkContext = CoachmarkContext;
10
+ var useCoachmark = function useCoachmark() {
11
+ return (0, _react.useContext)(CoachmarkContext);
12
+ };
13
+ exports.useCoachmark = useCoachmark;
@@ -0,0 +1,49 @@
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 = {
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
+ exports.BEACON_KIND = BEACON_KIND;
24
+ var COACHMARK_OVERLAY_KIND = {
25
+ TOOLTIP: 'tooltip',
26
+ FLOATING: 'floating',
27
+ FIXED: 'fixed',
28
+ STACKED: 'stacked'
29
+ };
30
+ /**
31
+ * Where to render the Coachmark relative to its target.
32
+ * Applies only to Floating and Tooltip Coachmarks.
33
+ */
34
+ exports.COACHMARK_OVERLAY_KIND = COACHMARK_OVERLAY_KIND;
35
+ var COACHMARK_ALIGNMENT = {
36
+ BOTTOM: 'bottom',
37
+ BOTTOM_LEFT: 'bottom-left',
38
+ BOTTOM_RIGHT: 'bottom-right',
39
+ LEFT: 'left',
40
+ LEFT_TOP: 'left-top',
41
+ LEFT_BOTTOM: 'left-bottom',
42
+ RIGHT: 'right',
43
+ RIGHT_TOP: 'right-top',
44
+ RIGHT_BOTTOM: 'right-bottom',
45
+ TOP: 'top',
46
+ TOP_LEFT: 'top-left',
47
+ TOP_RIGHT: 'top-right'
48
+ };
49
+ exports.COACHMARK_ALIGNMENT = COACHMARK_ALIGNMENT;
@@ -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,60 @@
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 = 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
+ };
60
+ exports.useWindowEvent = useWindowEvent;
@@ -0,0 +1,87 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.CoachmarkBeacon = 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 _Coachmark = require("../Coachmark");
14
+ var _devtools = require("../../global/js/utils/devtools");
15
+ var _settings = require("../../settings");
16
+ var _excluded = ["label", "className", "kind"];
17
+ // The block part of our conventional BEM class names (blockClass__E--M).
18
+ var blockClass = "".concat(_settings.pkg.prefix, "--coachmark-beacon");
19
+ var componentName = 'CoachmarkBeacon';
20
+ var defaults = {
21
+ kind: 'default'
22
+ };
23
+
24
+ /**
25
+ * Use beacon for the target prop of a Coachmark component.
26
+ */
27
+ var CoachmarkBeacon = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref) {
28
+ var _coachmark$positionTu, _coachmark$positionTu2, _coachmark$positionTu3, _coachmark$positionTu4;
29
+ var label = _ref.label,
30
+ className = _ref.className,
31
+ _ref$kind = _ref.kind,
32
+ kind = _ref$kind === void 0 ? defaults.kind : _ref$kind,
33
+ rest = (0, _objectWithoutProperties2.default)(_ref, _excluded);
34
+ var coachmark = (0, _Coachmark.useCoachmark)();
35
+ if (!coachmark) {
36
+ return /*#__PURE__*/_react.default.createElement("div", null, "CoachmarkBeacon is to be use exclusively within the target prop of Coachmark");
37
+ }
38
+ var overlayPositionStyle = {
39
+ top: (_coachmark$positionTu = (_coachmark$positionTu2 = coachmark.positionTune) === null || _coachmark$positionTu2 === void 0 ? void 0 : _coachmark$positionTu2.y) !== null && _coachmark$positionTu !== void 0 ? _coachmark$positionTu : 0,
40
+ left: (_coachmark$positionTu3 = (_coachmark$positionTu4 = coachmark.positionTune) === null || _coachmark$positionTu4 === void 0 ? void 0 : _coachmark$positionTu4.x) !== null && _coachmark$positionTu3 !== void 0 ? _coachmark$positionTu3 : 0
41
+ };
42
+ return /*#__PURE__*/_react.default.createElement("span", (0, _extends2.default)({}, rest, {
43
+ className: (0, _classnames.default)(blockClass, "".concat(blockClass, "-").concat(kind), className),
44
+ ref: ref,
45
+ style: overlayPositionStyle
46
+ }, (0, _devtools.getDevtoolsProps)(componentName)), /*#__PURE__*/_react.default.createElement("button", (0, _extends2.default)({
47
+ tabIndex: 0,
48
+ type: "button"
49
+ }, coachmark.buttonProps, {
50
+ "aria-label": label,
51
+ className: "".concat(blockClass, "__target")
52
+ }), /*#__PURE__*/_react.default.createElement("svg", {
53
+ className: "".concat(blockClass, "__center")
54
+ }, /*#__PURE__*/_react.default.createElement("circle", {
55
+ r: 1,
56
+ cx: 38,
57
+ cy: 38
58
+ }))));
59
+ });
60
+
61
+ // Return a placeholder if not released and not enabled by feature flag
62
+ exports.CoachmarkBeacon = CoachmarkBeacon;
63
+ exports.CoachmarkBeacon = CoachmarkBeacon = _settings.pkg.checkComponentEnabled(CoachmarkBeacon, componentName);
64
+
65
+ // The display name of the component, used by React. Note that displayName
66
+ // is used in preference to relying on function.name.
67
+ CoachmarkBeacon.displayName = componentName;
68
+
69
+ // The types and DocGen commentary for the component props,
70
+ // in alphabetical order (for consistency).
71
+ // See https://www.npmjs.com/package/prop-types#usage.
72
+ CoachmarkBeacon.propTypes = {
73
+ /**
74
+ * Optional class name for this component.
75
+ */
76
+ className: _propTypes.default.string,
77
+ /**
78
+ * What style of beacon.
79
+ * BEACON_KIND is an exported enum from the Coachmark and can be used for this value.
80
+ * @see {@link BEACON_KIND}
81
+ */
82
+ kind: _propTypes.default.oneOf(['default']),
83
+ /**
84
+ * The aria label.
85
+ */
86
+ label: _propTypes.default.string.isRequired
87
+ };
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ Object.defineProperty(exports, "CoachmarkBeacon", {
7
+ enumerable: true,
8
+ get: function get() {
9
+ return _CoachmarkBeacon.CoachmarkBeacon;
10
+ }
11
+ });
12
+ var _CoachmarkBeacon = require("./CoachmarkBeacon");