@carbon/ibm-products 1.55.1 → 1.56.0
Sign up to get free protection for your applications and to get access to all the features.
- package/css/index-full-carbon.css +639 -16
- package/css/index-full-carbon.css.map +1 -1
- package/css/index-full-carbon.min.css +4 -4
- package/css/index-full-carbon.min.css.map +1 -1
- package/css/index-without-carbon.css +582 -9
- package/css/index-without-carbon.css.map +1 -1
- package/css/index-without-carbon.min.css +2 -2
- package/css/index-without-carbon.min.css.map +1 -1
- package/css/index.css +620 -12
- package/css/index.css.map +1 -1
- package/css/index.min.css +4 -4
- package/css/index.min.css.map +1 -1
- package/es/components/Carousel/Carousel.js +15 -5
- package/es/components/Coachmark/Coachmark.js +243 -0
- package/es/components/Coachmark/CoachmarkDragbar.js +137 -0
- package/es/components/Coachmark/CoachmarkHeader.js +88 -0
- package/es/components/Coachmark/CoachmarkOverlay.js +139 -0
- package/es/components/Coachmark/CoachmarkTagline.js +93 -0
- package/es/components/Coachmark/index.js +10 -0
- package/es/components/Coachmark/utils/constants.js +76 -0
- package/es/components/Coachmark/utils/context.js +5 -0
- package/es/components/Coachmark/utils/enums.js +40 -0
- package/es/components/Coachmark/utils/helpers.js +11 -0
- package/es/components/Coachmark/utils/hooks.js +54 -0
- package/es/components/CoachmarkBeacon/CoachmarkBeacon.js +90 -0
- package/es/components/CoachmarkBeacon/index.js +8 -0
- package/es/components/CoachmarkButton/CoachmarkButton.js +72 -0
- package/es/components/CoachmarkButton/index.js +8 -0
- package/es/components/CoachmarkFixed/CoachmarkFixed.js +201 -0
- package/es/components/CoachmarkFixed/index.js +8 -0
- package/es/components/CoachmarkOverlayElement/CoachmarkOverlayElement.js +86 -0
- package/es/components/CoachmarkOverlayElement/index.js +8 -0
- package/es/components/CoachmarkOverlayElements/CoachmarkOverlayElements.js +175 -0
- package/es/components/CoachmarkOverlayElements/index.js +8 -0
- package/es/components/CoachmarkStack/CoachmarkStack.js +260 -0
- package/es/components/CoachmarkStack/CoachmarkStackHome.js +157 -0
- package/es/components/CoachmarkStack/index.js +8 -0
- package/es/components/Datagrid/Datagrid/addons/CustomizeColumns/Columns.js +1 -4
- package/es/components/Datagrid/Datagrid/addons/CustomizeColumns/CustomizeColumnsTearsheet.js +2 -5
- package/es/components/Datagrid/Datagrid/addons/CustomizeColumns/DraggableItemsList.js +33 -17
- package/es/components/Datagrid/Datagrid/addons/CustomizeColumns/TearsheetWrapper.js +0 -1
- package/es/components/Datagrid/useDefaultStringRenderer.js +2 -1
- package/es/components/Datagrid/useSortableColumns.js +8 -4
- package/es/components/NotificationsPanel/NotificationsPanel.js +3 -2
- package/es/components/index.js +7 -0
- package/es/global/js/package-settings.js +8 -1
- package/es/global/js/utils/test-helper.js +3 -3
- package/lib/components/Carousel/Carousel.js +15 -5
- package/lib/components/Coachmark/Coachmark.js +247 -0
- package/lib/components/Coachmark/CoachmarkDragbar.js +137 -0
- package/lib/components/Coachmark/CoachmarkHeader.js +85 -0
- package/lib/components/Coachmark/CoachmarkOverlay.js +139 -0
- package/lib/components/Coachmark/CoachmarkTagline.js +90 -0
- package/lib/components/Coachmark/index.js +38 -0
- package/lib/components/Coachmark/utils/constants.js +82 -0
- package/lib/components/Coachmark/utils/context.js +13 -0
- package/lib/components/Coachmark/utils/enums.js +49 -0
- package/lib/components/Coachmark/utils/helpers.js +17 -0
- package/lib/components/Coachmark/utils/hooks.js +60 -0
- package/lib/components/CoachmarkBeacon/CoachmarkBeacon.js +87 -0
- package/lib/components/CoachmarkBeacon/index.js +12 -0
- package/lib/components/CoachmarkButton/CoachmarkButton.js +69 -0
- package/lib/components/CoachmarkButton/index.js +12 -0
- package/lib/components/CoachmarkFixed/CoachmarkFixed.js +201 -0
- package/lib/components/CoachmarkFixed/index.js +12 -0
- package/lib/components/CoachmarkOverlayElement/CoachmarkOverlayElement.js +83 -0
- package/lib/components/CoachmarkOverlayElement/index.js +12 -0
- package/lib/components/CoachmarkOverlayElements/CoachmarkOverlayElements.js +176 -0
- package/lib/components/CoachmarkOverlayElements/index.js +12 -0
- package/lib/components/CoachmarkStack/CoachmarkStack.js +264 -0
- package/lib/components/CoachmarkStack/CoachmarkStackHome.js +160 -0
- package/lib/components/CoachmarkStack/index.js +12 -0
- package/lib/components/Datagrid/Datagrid/addons/CustomizeColumns/Columns.js +1 -4
- package/lib/components/Datagrid/Datagrid/addons/CustomizeColumns/CustomizeColumnsTearsheet.js +2 -5
- package/lib/components/Datagrid/Datagrid/addons/CustomizeColumns/DraggableItemsList.js +33 -17
- package/lib/components/Datagrid/Datagrid/addons/CustomizeColumns/TearsheetWrapper.js +0 -1
- package/lib/components/Datagrid/useDefaultStringRenderer.js +2 -1
- package/lib/components/Datagrid/useSortableColumns.js +8 -4
- package/lib/components/NotificationsPanel/NotificationsPanel.js +3 -2
- package/lib/components/index.js +49 -0
- package/lib/global/js/package-settings.js +8 -1
- package/lib/global/js/utils/test-helper.js +3 -3
- package/package.json +8 -8
- package/scss/components/Carousel/_carousel.scss +3 -0
- package/scss/components/Coachmark/_index.scss +11 -0
- package/scss/components/Coachmark/_storybook-styles.scss +20 -0
- package/scss/components/Coachmark/styles/_coachmark-dragbar.scss +74 -0
- package/scss/components/Coachmark/styles/_coachmark-header.scss +58 -0
- package/scss/components/Coachmark/styles/_coachmark-overlay.scss +327 -0
- package/scss/components/Coachmark/styles/_coachmark-tagline.scss +118 -0
- package/scss/components/CoachmarkBeacon/_coachmark-beacon.scss +166 -0
- package/scss/components/CoachmarkBeacon/_index.scss +8 -0
- package/scss/components/CoachmarkBeacon/_storybook-styles.scss +19 -0
- package/scss/components/CoachmarkButton/_coachmark-button.scss +34 -0
- package/scss/components/CoachmarkButton/_index.scss +8 -0
- package/scss/components/CoachmarkButton/_storybook-styles.scss +19 -0
- package/scss/components/CoachmarkFixed/_coachmark-fixed.scss +34 -0
- package/scss/components/CoachmarkFixed/_index.scss +8 -0
- package/scss/components/CoachmarkFixed/_storybook-styles.scss +10 -0
- package/scss/components/CoachmarkOverlayElement/_coachmark-overlay-element.scss +50 -0
- package/scss/components/CoachmarkOverlayElement/_index.scss +8 -0
- package/scss/components/CoachmarkOverlayElement/_storybook-styles.scss +19 -0
- package/scss/components/CoachmarkOverlayElements/_coachmark-overlay-elements.scss +40 -0
- package/scss/components/CoachmarkOverlayElements/_index.scss +8 -0
- package/scss/components/CoachmarkOverlayElements/_storybook-styles.scss +19 -0
- package/scss/components/CoachmarkStack/_coachmark-stack.scss +85 -0
- package/scss/components/CoachmarkStack/_index.scss +8 -0
- package/scss/components/CoachmarkStack/_storybook-styles.scss +10 -0
- package/scss/components/Datagrid/styles/_useColumnCenterAlign.scss +9 -9
- package/scss/components/_index.scss +7 -1
@@ -0,0 +1,201 @@
|
|
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.CoachmarkFixed = 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 _reactDom = require("react-dom");
|
16
|
+
var _CoachmarkOverlay = require("../Coachmark/CoachmarkOverlay");
|
17
|
+
var _CoachmarkTagline = require("../Coachmark/CoachmarkTagline");
|
18
|
+
var _context = require("../Coachmark/utils/context");
|
19
|
+
var _enums = require("../Coachmark/utils/enums");
|
20
|
+
var _devtools = require("../../global/js/utils/devtools");
|
21
|
+
var _settings = require("../../settings");
|
22
|
+
var _excluded = ["children", "className", "onClose", "portalTarget", "tagline", "theme"];
|
23
|
+
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); }
|
24
|
+
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; }
|
25
|
+
// The block part of our conventional BEM class names (blockClass__E--M).
|
26
|
+
var blockClass = "".concat(_settings.pkg.prefix, "--coachmark-fixed");
|
27
|
+
var componentName = 'CoachmarkFixed';
|
28
|
+
var defaults = {
|
29
|
+
onClose: function onClose() {},
|
30
|
+
theme: 'light',
|
31
|
+
tagline: ''
|
32
|
+
};
|
33
|
+
|
34
|
+
/**
|
35
|
+
* Fixed coachmarks are used to call out specific functionality or concepts
|
36
|
+
* within the UI that may not be intuitive but are important for the
|
37
|
+
* user to gain understanding of the product's main value and discover new use cases.
|
38
|
+
* This variant allows the a coachmark overlay to be displayed by interacting with the tagline.
|
39
|
+
*/
|
40
|
+
var CoachmarkFixed = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref) {
|
41
|
+
var _document$querySelect;
|
42
|
+
var children = _ref.children,
|
43
|
+
className = _ref.className,
|
44
|
+
_ref$onClose = _ref.onClose,
|
45
|
+
onClose = _ref$onClose === void 0 ? defaults.onClose : _ref$onClose,
|
46
|
+
portalTarget = _ref.portalTarget,
|
47
|
+
_ref$tagline = _ref.tagline,
|
48
|
+
tagline = _ref$tagline === void 0 ? defaults.tagline : _ref$tagline,
|
49
|
+
_ref$theme = _ref.theme,
|
50
|
+
theme = _ref$theme === void 0 ? defaults.theme : _ref$theme,
|
51
|
+
rest = (0, _objectWithoutProperties2.default)(_ref, _excluded);
|
52
|
+
var overlayRef = (0, _react.useRef)();
|
53
|
+
var portalNode = portalTarget ? (_document$querySelect = document.querySelector(portalTarget)) !== null && _document$querySelect !== void 0 ? _document$querySelect : document.querySelector('body') : document.querySelector('body');
|
54
|
+
var _useState = (0, _react.useState)(false),
|
55
|
+
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
56
|
+
isOpen = _useState2[0],
|
57
|
+
setIsOpen = _useState2[1];
|
58
|
+
var _useState3 = (0, _react.useState)(false),
|
59
|
+
_useState4 = (0, _slicedToArray2.default)(_useState3, 2),
|
60
|
+
shouldResetPosition = _useState4[0],
|
61
|
+
setShouldResetPosition = _useState4[1];
|
62
|
+
var _useState5 = (0, _react.useState)(),
|
63
|
+
_useState6 = (0, _slicedToArray2.default)(_useState5, 2),
|
64
|
+
targetRect = _useState6[0],
|
65
|
+
setTargetRect = _useState6[1];
|
66
|
+
var _useState7 = (0, _react.useState)({
|
67
|
+
x: 0,
|
68
|
+
y: 0
|
69
|
+
}),
|
70
|
+
_useState8 = (0, _slicedToArray2.default)(_useState7, 2),
|
71
|
+
targetOffset = _useState8[0],
|
72
|
+
setTargetOffset = _useState8[1];
|
73
|
+
var _useState9 = (0, _react.useState)(false),
|
74
|
+
_useState10 = (0, _slicedToArray2.default)(_useState9, 2),
|
75
|
+
fixedIsVisible = _useState10[0],
|
76
|
+
setFixedIsVisible = _useState10[1];
|
77
|
+
var handleClose = function handleClose() {
|
78
|
+
setFixedIsVisible(false);
|
79
|
+
};
|
80
|
+
var handleTransitionEnd = function handleTransitionEnd(e) {
|
81
|
+
if (e.propertyName === 'transform' && !fixedIsVisible) {
|
82
|
+
setIsOpen(false);
|
83
|
+
onClose();
|
84
|
+
}
|
85
|
+
};
|
86
|
+
var handleTargetClick = function handleTargetClick(e) {
|
87
|
+
setTargetRect(e.target.getBoundingClientRect());
|
88
|
+
setTargetOffset({
|
89
|
+
x: e.target.offsetLeft,
|
90
|
+
y: e.target.offsetTop
|
91
|
+
});
|
92
|
+
// reset position for all other kinds
|
93
|
+
setIsOpen(false);
|
94
|
+
setShouldResetPosition(true);
|
95
|
+
};
|
96
|
+
var contextValue = {
|
97
|
+
buttonProps: {
|
98
|
+
'aria-expanded': isOpen,
|
99
|
+
onClick: handleTargetClick,
|
100
|
+
// Compensate for accidental open/close on double-click.
|
101
|
+
// Only open on double-click.
|
102
|
+
onDoubleClick: handleTargetClick
|
103
|
+
},
|
104
|
+
closeButtonProps: {
|
105
|
+
onClick: handleClose
|
106
|
+
},
|
107
|
+
targetRect: targetRect,
|
108
|
+
targetOffset: targetOffset,
|
109
|
+
isOpen: isOpen
|
110
|
+
};
|
111
|
+
|
112
|
+
// instead of toggling on/off,
|
113
|
+
// keep open and reset to original position
|
114
|
+
(0, _react.useEffect)(function () {
|
115
|
+
if (shouldResetPosition) {
|
116
|
+
setShouldResetPosition(false);
|
117
|
+
setIsOpen(true);
|
118
|
+
}
|
119
|
+
}, [shouldResetPosition]);
|
120
|
+
(0, _react.useEffect)(function () {
|
121
|
+
setFixedIsVisible(isOpen);
|
122
|
+
}, [isOpen]);
|
123
|
+
|
124
|
+
// On unmount:
|
125
|
+
// - DO NOT "Close()" the coachmark.
|
126
|
+
// - This triggers a "signal" to close it forever.
|
127
|
+
// - "Closing" should only ever be a user-triggered event.
|
128
|
+
// - DO "hide" the coachmark.
|
129
|
+
// - The app is doing the action for the user.
|
130
|
+
// - The user will have the opportunity to open it again.
|
131
|
+
(0, _react.useEffect)(function () {
|
132
|
+
return function () {
|
133
|
+
return setIsOpen(false);
|
134
|
+
};
|
135
|
+
}, []);
|
136
|
+
return /*#__PURE__*/_react.default.createElement(_context.CoachmarkContext.Provider, {
|
137
|
+
value: contextValue
|
138
|
+
}, /*#__PURE__*/_react.default.createElement("div", (0, _extends2.default)({}, rest, {
|
139
|
+
className: (0, _classnames.default)(blockClass, // Apply the block class to the main HTML element
|
140
|
+
"".concat(blockClass, "__").concat(theme), className // Apply any supplied class names to the main HTML element.
|
141
|
+
),
|
142
|
+
|
143
|
+
ref: ref
|
144
|
+
}, (0, _devtools.getDevtoolsProps)(componentName)), /*#__PURE__*/_react.default.createElement(_CoachmarkTagline.CoachmarkTagline, {
|
145
|
+
title: tagline,
|
146
|
+
onClose: onClose
|
147
|
+
}), isOpen && /*#__PURE__*/(0, _reactDom.createPortal)( /*#__PURE__*/_react.default.createElement(_CoachmarkOverlay.CoachmarkOverlay, {
|
148
|
+
ref: overlayRef,
|
149
|
+
fixedIsVisible: fixedIsVisible,
|
150
|
+
kind: _enums.COACHMARK_OVERLAY_KIND.FIXED,
|
151
|
+
onClose: handleClose,
|
152
|
+
onTransitionEnd: handleTransitionEnd,
|
153
|
+
theme: theme
|
154
|
+
}, children), portalNode)));
|
155
|
+
});
|
156
|
+
|
157
|
+
// Return a placeholder if not released and not enabled by feature flag
|
158
|
+
exports.CoachmarkFixed = CoachmarkFixed;
|
159
|
+
exports.CoachmarkFixed = CoachmarkFixed = _settings.pkg.checkComponentEnabled(CoachmarkFixed, componentName);
|
160
|
+
|
161
|
+
// The display name of the component, used by React. Note that displayName
|
162
|
+
// is used in preference to relying on function.name.
|
163
|
+
CoachmarkFixed.displayName = componentName;
|
164
|
+
|
165
|
+
// The types and DocGen commentary for the component props,
|
166
|
+
// in alphabetical order (for consistency).
|
167
|
+
// See https://www.npmjs.com/package/prop-types#usage.
|
168
|
+
CoachmarkFixed.propTypes = {
|
169
|
+
// TODO: Add this to MDX as will be done with Coachmark
|
170
|
+
/**
|
171
|
+
* CoachmarkFixed should use a single CoachmarkOverlayElements component as a child.
|
172
|
+
*/
|
173
|
+
children: _propTypes.default.node.isRequired,
|
174
|
+
/**
|
175
|
+
* Optional class name for this component.
|
176
|
+
*/
|
177
|
+
className: _propTypes.default.string,
|
178
|
+
/**
|
179
|
+
* Function to call when the Coachmark closes.
|
180
|
+
*/
|
181
|
+
onClose: _propTypes.default.func,
|
182
|
+
/**
|
183
|
+
* By default, the Coachmark will be appended to the end of `document.body`.
|
184
|
+
* The Coachmark will remain persistent as the user navigates the app until
|
185
|
+
* the user closes the Coachmark.
|
186
|
+
*
|
187
|
+
* Alternatively, the app developer can tightly couple the Coachmark to a DOM
|
188
|
+
* element or other component by specifying a CSS selector. The Coachmark will
|
189
|
+
* remain visible as long as that element remains visible or mounted. When the
|
190
|
+
* element is hidden or component is unmounted, the Coachmark will disappear.
|
191
|
+
*/
|
192
|
+
portalTarget: _propTypes.default.string,
|
193
|
+
/**
|
194
|
+
* The tagline title which will be fixed to the bottom right of the window and will serve as the display trigger.
|
195
|
+
*/
|
196
|
+
tagline: _propTypes.default.string.isRequired,
|
197
|
+
/**
|
198
|
+
* Determines the theme of the component.
|
199
|
+
*/
|
200
|
+
theme: _propTypes.default.oneOf(['light', 'dark'])
|
201
|
+
};
|
@@ -0,0 +1,12 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
Object.defineProperty(exports, "CoachmarkFixed", {
|
7
|
+
enumerable: true,
|
8
|
+
get: function get() {
|
9
|
+
return _CoachmarkFixed.CoachmarkFixed;
|
10
|
+
}
|
11
|
+
});
|
12
|
+
var _CoachmarkFixed = require("./CoachmarkFixed");
|
@@ -0,0 +1,83 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
5
|
+
value: true
|
6
|
+
});
|
7
|
+
exports.CoachmarkOverlayElement = 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 _devtools = require("../../global/js/utils/devtools");
|
14
|
+
var _settings = require("../../settings");
|
15
|
+
var _excluded = ["button", "className", "description", "title"];
|
16
|
+
// The block part of our conventional BEM class names (blockClass__E--M).
|
17
|
+
var blockClass = "".concat(_settings.pkg.prefix, "--coachmark-overlay-element");
|
18
|
+
var componentName = 'CoachmarkOverlayElement';
|
19
|
+
|
20
|
+
/**
|
21
|
+
* Component to be displayed within a CoachmarkOverlayElements container.
|
22
|
+
* Can be used 1 to N number, to display content in a Coachmark's overlay
|
23
|
+
* in a carousel fashion.
|
24
|
+
*/
|
25
|
+
var CoachmarkOverlayElement = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref) {
|
26
|
+
var button = _ref.button,
|
27
|
+
className = _ref.className,
|
28
|
+
description = _ref.description,
|
29
|
+
title = _ref.title,
|
30
|
+
rest = (0, _objectWithoutProperties2.default)(_ref, _excluded);
|
31
|
+
return /*#__PURE__*/_react.default.createElement("div", (0, _extends2.default)({}, rest, {
|
32
|
+
className: (0, _classnames.default)(blockClass,
|
33
|
+
// Apply the block class to the main HTML element
|
34
|
+
className,
|
35
|
+
// Apply any supplied class names to the main HTML element.
|
36
|
+
// example: `${blockClass}__template-string-class-${kind}-n-${size}`,
|
37
|
+
{
|
38
|
+
// switched classes dependant on props or state
|
39
|
+
// example: [`${blockClass}__here-if-small`]: size === 'sm',
|
40
|
+
}),
|
41
|
+
ref: ref
|
42
|
+
// role="main"
|
43
|
+
}, (0, _devtools.getDevtoolsProps)(componentName)), /*#__PURE__*/_react.default.createElement("div", {
|
44
|
+
className: "".concat(blockClass, "__content")
|
45
|
+
}, title && /*#__PURE__*/_react.default.createElement("h2", {
|
46
|
+
className: "".concat(blockClass, "__title")
|
47
|
+
}, title), description && /*#__PURE__*/_react.default.createElement("p", {
|
48
|
+
className: "".concat(blockClass, "__body")
|
49
|
+
}, description)), button && /*#__PURE__*/_react.default.createElement("div", {
|
50
|
+
className: "".concat(blockClass, "__button")
|
51
|
+
}, button));
|
52
|
+
});
|
53
|
+
|
54
|
+
// Return a placeholder if not released and not enabled by feature flag
|
55
|
+
exports.CoachmarkOverlayElement = CoachmarkOverlayElement;
|
56
|
+
exports.CoachmarkOverlayElement = CoachmarkOverlayElement = _settings.pkg.checkComponentEnabled(CoachmarkOverlayElement, componentName);
|
57
|
+
|
58
|
+
// The display name of the component, used by React. Note that displayName
|
59
|
+
// is used in preference to relying on function.name.
|
60
|
+
CoachmarkOverlayElement.displayName = componentName;
|
61
|
+
|
62
|
+
// The types and DocGen commentary for the component props,
|
63
|
+
// in alphabetical order (for consistency).
|
64
|
+
// See https://www.npmjs.com/package/prop-types#usage.
|
65
|
+
CoachmarkOverlayElement.propTypes = {
|
66
|
+
/**
|
67
|
+
* An optional button can be rendered below the description.
|
68
|
+
* This can be a link, button, Coachmark button, etc.
|
69
|
+
*/
|
70
|
+
button: _propTypes.default.node,
|
71
|
+
/**
|
72
|
+
* Optional class name for this component.
|
73
|
+
*/
|
74
|
+
className: _propTypes.default.string,
|
75
|
+
/**
|
76
|
+
* The description of the Coachmark.
|
77
|
+
*/
|
78
|
+
description: _propTypes.default.node.isRequired,
|
79
|
+
/**
|
80
|
+
* The title of the Coachmark.
|
81
|
+
*/
|
82
|
+
title: _propTypes.default.string.isRequired
|
83
|
+
};
|
@@ -0,0 +1,12 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
Object.defineProperty(exports, "CoachmarkOverlayElement", {
|
7
|
+
enumerable: true,
|
8
|
+
get: function get() {
|
9
|
+
return _CoachmarkOverlayElement.CoachmarkOverlayElement;
|
10
|
+
}
|
11
|
+
});
|
12
|
+
var _CoachmarkOverlayElement = require("./CoachmarkOverlayElement");
|
@@ -0,0 +1,176 @@
|
|
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.CoachmarkOverlayElements = 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 _carbonComponentsReact = require("carbon-components-react");
|
14
|
+
var _classnames = _interopRequireDefault(require("classnames"));
|
15
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
16
|
+
var _Coachmark = require("../Coachmark");
|
17
|
+
var _lodash = require("lodash");
|
18
|
+
var _pconsole = _interopRequireDefault(require("../../global/js/utils/pconsole"));
|
19
|
+
var _Carousel = require("../Carousel");
|
20
|
+
var _SteppedAnimatedMedia = require("../SteppedAnimatedMedia");
|
21
|
+
var _devtools = require("../../global/js/utils/devtools");
|
22
|
+
var _settings = require("../../settings");
|
23
|
+
var _excluded = ["className", "children", "media", "nextButtonText", "previousButtonLabel", "closeButtonLabel"];
|
24
|
+
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); }
|
25
|
+
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; }
|
26
|
+
// The block part of our conventional BEM class names (blockClass__E--M).
|
27
|
+
var blockClass = "".concat(_settings.pkg.prefix, "--coachmark-overlay-elements");
|
28
|
+
var componentName = 'CoachmarkOverlayElements';
|
29
|
+
var defaults = {
|
30
|
+
nextButtonText: 'Next',
|
31
|
+
previousButtonLabel: 'Back',
|
32
|
+
closeButtonLabel: 'Got it'
|
33
|
+
};
|
34
|
+
|
35
|
+
/**
|
36
|
+
* Composable container to allow for the displaying of CoachmarkOverlayElement
|
37
|
+
* components in a carousel fashion.
|
38
|
+
*/
|
39
|
+
var CoachmarkOverlayElements = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref) {
|
40
|
+
var className = _ref.className,
|
41
|
+
children = _ref.children,
|
42
|
+
media = _ref.media,
|
43
|
+
_ref$nextButtonText = _ref.nextButtonText,
|
44
|
+
nextButtonText = _ref$nextButtonText === void 0 ? defaults.nextButtonText : _ref$nextButtonText,
|
45
|
+
_ref$previousButtonLa = _ref.previousButtonLabel,
|
46
|
+
previousButtonLabel = _ref$previousButtonLa === void 0 ? defaults.previousButtonLabel : _ref$previousButtonLa,
|
47
|
+
_ref$closeButtonLabel = _ref.closeButtonLabel,
|
48
|
+
closeButtonLabel = _ref$closeButtonLabel === void 0 ? defaults.closeButtonLabel : _ref$closeButtonLabel,
|
49
|
+
rest = (0, _objectWithoutProperties2.default)(_ref, _excluded);
|
50
|
+
var buttonFocusRef = (0, _react.useRef)();
|
51
|
+
var scrollRef = (0, _react.useRef)();
|
52
|
+
var _useState = (0, _react.useState)(0),
|
53
|
+
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
54
|
+
scrollPosition = _useState2[0],
|
55
|
+
setScrollPosition = _useState2[1];
|
56
|
+
var _useState3 = (0, _react.useState)(0),
|
57
|
+
_useState4 = (0, _slicedToArray2.default)(_useState3, 2),
|
58
|
+
currentProgStep = _useState4[0],
|
59
|
+
setCurrentProgStep = _useState4[1];
|
60
|
+
var coachmark = (0, _Coachmark.useCoachmark)();
|
61
|
+
var numProgSteps = _react.Children.count(children);
|
62
|
+
var progStepFloor = 0;
|
63
|
+
var progStepCeil = numProgSteps - 1;
|
64
|
+
(0, _react.useEffect)(function () {
|
65
|
+
// On mount, one of the two primary buttons ("next" or "close")
|
66
|
+
// will be rendered and must have focus. (a11y)
|
67
|
+
if (buttonFocusRef.current) {
|
68
|
+
buttonFocusRef.current.focus();
|
69
|
+
}
|
70
|
+
}, []);
|
71
|
+
if (!coachmark) {
|
72
|
+
return _pconsole.default.warn("The ".concat(componentName, " is a composable container element which should be used only within the scope of a Coachmark or a CoachmarkFixed component."));
|
73
|
+
}
|
74
|
+
return /*#__PURE__*/_react.default.createElement("section", (0, _extends2.default)({}, rest, {
|
75
|
+
className: (0, _classnames.default)(blockClass,
|
76
|
+
// Apply the block class to the main HTML element
|
77
|
+
className,
|
78
|
+
// Apply any supplied class names to the main HTML element.
|
79
|
+
// example: `${blockClass}__template-string-class-${kind}-n-${size}`,
|
80
|
+
{
|
81
|
+
// switched classes dependant on props or state
|
82
|
+
// example: [`${blockClass}__here-if-small`]: size === 'sm',
|
83
|
+
}),
|
84
|
+
ref: ref
|
85
|
+
// role="main"
|
86
|
+
}, (0, _devtools.getDevtoolsProps)(componentName)), media && (media.render ? media.render() : /*#__PURE__*/_react.default.createElement(_SteppedAnimatedMedia.SteppedAnimatedMedia, {
|
87
|
+
className: "".concat(blockClass, "__element-stepped-media"),
|
88
|
+
filePaths: media.filePaths,
|
89
|
+
playStep: currentProgStep
|
90
|
+
})), numProgSteps === 1 ? /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, children, closeButtonLabel && /*#__PURE__*/_react.default.createElement("div", {
|
91
|
+
className: (0, _classnames.default)("".concat(blockClass, "__footer"), 'coachmark-carousel-controls')
|
92
|
+
}, /*#__PURE__*/_react.default.createElement(_carbonComponentsReact.Button, (0, _extends2.default)({
|
93
|
+
size: "sm"
|
94
|
+
}, coachmark.closeButtonProps), closeButtonLabel))) : /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_Carousel.Carousel, {
|
95
|
+
disableArrowScroll: true,
|
96
|
+
ref: scrollRef
|
97
|
+
}, children), /*#__PURE__*/_react.default.createElement("div", {
|
98
|
+
className: (0, _classnames.default)("".concat(blockClass, "__footer"))
|
99
|
+
}, /*#__PURE__*/_react.default.createElement("div", {
|
100
|
+
className: "".concat(blockClass, "--controls-progress")
|
101
|
+
}, "".concat(currentProgStep + 1, " / ").concat(numProgSteps)), scrollPosition > 0 && /*#__PURE__*/_react.default.createElement(_carbonComponentsReact.Button, {
|
102
|
+
size: "sm",
|
103
|
+
kind: "ghost",
|
104
|
+
title: previousButtonLabel,
|
105
|
+
disabled: scrollPosition === 0,
|
106
|
+
onClick: function onClick() {
|
107
|
+
var targetStep = (0, _lodash.clamp)(currentProgStep - 1, progStepFloor, progStepCeil);
|
108
|
+
scrollRef.current.scrollToView(targetStep).then(function (scrollPercentage) {
|
109
|
+
setScrollPosition(scrollPercentage);
|
110
|
+
});
|
111
|
+
setCurrentProgStep(targetStep);
|
112
|
+
}
|
113
|
+
}, previousButtonLabel), currentProgStep < progStepCeil ? /*#__PURE__*/_react.default.createElement(_carbonComponentsReact.Button, {
|
114
|
+
size: "sm",
|
115
|
+
ref: buttonFocusRef,
|
116
|
+
title: nextButtonText,
|
117
|
+
disabled: scrollPosition === 1,
|
118
|
+
onClick: function onClick() {
|
119
|
+
var targetStep = (0, _lodash.clamp)(currentProgStep + 1, progStepFloor, progStepCeil);
|
120
|
+
scrollRef.current.scrollToView(targetStep).then(function (scrollPercentage) {
|
121
|
+
setScrollPosition(scrollPercentage);
|
122
|
+
});
|
123
|
+
setCurrentProgStep(targetStep);
|
124
|
+
}
|
125
|
+
}, nextButtonText) : closeButtonLabel && /*#__PURE__*/_react.default.createElement(_carbonComponentsReact.Button, (0, _extends2.default)({
|
126
|
+
size: "sm",
|
127
|
+
ref: buttonFocusRef
|
128
|
+
}, coachmark.closeButtonProps), closeButtonLabel))));
|
129
|
+
});
|
130
|
+
|
131
|
+
// Return a placeholder if not released and not enabled by feature flag
|
132
|
+
exports.CoachmarkOverlayElements = CoachmarkOverlayElements;
|
133
|
+
exports.CoachmarkOverlayElements = CoachmarkOverlayElements = _settings.pkg.checkComponentEnabled(CoachmarkOverlayElements, componentName);
|
134
|
+
|
135
|
+
// The display name of the component, used by React. Note that displayName
|
136
|
+
// is used in preference to relying on function.name.
|
137
|
+
CoachmarkOverlayElements.displayName = componentName;
|
138
|
+
|
139
|
+
// The types and DocGen commentary for the component props,
|
140
|
+
// in alphabetical order (for consistency).
|
141
|
+
// See https://www.npmjs.com/package/prop-types#usage.
|
142
|
+
CoachmarkOverlayElements.propTypes = {
|
143
|
+
// TODO: UPDATE COMMENT HERE - UPDATE MDX TO HAVE DIRECTION TO USE ONLY OVERLAY ELEMENTS>...CoachmarkOverlayElements will accept only one or more CoachmarkOverlayElement as child components.
|
144
|
+
|
145
|
+
/**
|
146
|
+
* CoachmarkOverlayElements should be used with one or many CoachmarkOverlayElement components as children.
|
147
|
+
* @see CoachmarkOverlayElement
|
148
|
+
*/
|
149
|
+
children: _propTypes.default.node.isRequired,
|
150
|
+
/**
|
151
|
+
* Optional class name for this component.
|
152
|
+
*/
|
153
|
+
className: _propTypes.default.string,
|
154
|
+
/**
|
155
|
+
* The label for the Close button.
|
156
|
+
*/
|
157
|
+
closeButtonLabel: _propTypes.default.string,
|
158
|
+
/**
|
159
|
+
* The object describing an image in one of two shapes.
|
160
|
+
* If a single media element is required, use `{render}`.
|
161
|
+
* If a stepped animation is required, use `{filePaths}`.
|
162
|
+
*/
|
163
|
+
media: _propTypes.default.oneOfType([_propTypes.default.shape({
|
164
|
+
render: _propTypes.default.func
|
165
|
+
}), _propTypes.default.shape({
|
166
|
+
filePaths: _propTypes.default.arrayOf(_propTypes.default.string)
|
167
|
+
})]),
|
168
|
+
/**
|
169
|
+
* The label for the Next button.
|
170
|
+
*/
|
171
|
+
nextButtonText: _propTypes.default.string,
|
172
|
+
/**
|
173
|
+
* The label for the Previous button.
|
174
|
+
*/
|
175
|
+
previousButtonLabel: _propTypes.default.string
|
176
|
+
};
|
@@ -0,0 +1,12 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
Object.defineProperty(exports, "CoachmarkOverlayElements", {
|
7
|
+
enumerable: true,
|
8
|
+
get: function get() {
|
9
|
+
return _CoachmarkOverlayElements.CoachmarkOverlayElements;
|
10
|
+
}
|
11
|
+
});
|
12
|
+
var _CoachmarkOverlayElements = require("./CoachmarkOverlayElements");
|