UNPKG

3.32 kBJavaScriptView Raw
1import { __assign, __extends } from "tslib";
2import * as React from 'react';
3import { initializeComponentRef, classNamesFunction } from '../../Utilities';
4import { TeachingBubbleContent } from './TeachingBubbleContent';
5import { Callout } from '../../Callout';
6import { DirectionalHint } from '../../common/DirectionalHint';
7var getClassNames = classNamesFunction();
8var TeachingBubbleBase = /** @class */ (function (_super) {
9 __extends(TeachingBubbleBase, _super);
10 // Constructor
11 function TeachingBubbleBase(props) {
12 var _this = _super.call(this, props) || this;
13 _this.rootElement = React.createRef();
14 initializeComponentRef(_this);
15 _this.state = {};
16 _this._defaultCalloutProps = {
17 beakWidth: 16,
18 gapSpace: 0,
19 setInitialFocus: true,
20 doNotLayer: false,
21 directionalHint: DirectionalHint.rightCenter,
22 };
23 return _this;
24 }
25 TeachingBubbleBase.prototype.focus = function () {
26 if (this.rootElement.current) {
27 this.rootElement.current.focus();
28 }
29 };
30 TeachingBubbleBase.prototype.render = function () {
31 var _a = this.props, setCalloutProps = _a.calloutProps,
32 // eslint-disable-next-line deprecation/deprecation
33 targetElement = _a.targetElement, onDismiss = _a.onDismiss,
34 // Default to deprecated value if provided.
35 // eslint-disable-next-line deprecation/deprecation
36 _b = _a.hasCloseButton,
37 // Default to deprecated value if provided.
38 // eslint-disable-next-line deprecation/deprecation
39 hasCloseButton = _b === void 0 ? this.props.hasCloseIcon : _b, isWide = _a.isWide, styles = _a.styles, theme = _a.theme, target = _a.target;
40 var calloutProps = __assign(__assign({}, this._defaultCalloutProps), setCalloutProps);
41 var stylesProps = {
42 theme: theme,
43 isWide: isWide,
44 calloutProps: __assign(__assign({}, calloutProps), { theme: calloutProps.theme }),
45 hasCloseButton: hasCloseButton,
46 };
47 var classNames = getClassNames(styles, stylesProps);
48 var calloutStyles = classNames.subComponentStyles
49 ? classNames.subComponentStyles.callout
50 : undefined;
51 return (React.createElement(Callout, __assign({ target: target || targetElement, onDismiss: onDismiss }, calloutProps, { className: classNames.root, styles: calloutStyles, hideOverflow: true }),
52 React.createElement("div", { ref: this.rootElement },
53 React.createElement(TeachingBubbleContent, __assign({}, this.props)))));
54 };
55 TeachingBubbleBase.defaultProps = {
56 /**
57 * Default calloutProps is deprecated in favor of private `_defaultCalloutProps`.
58 * Remove in next release.
59 * @deprecated In favor of private `_defaultCalloutProps`.
60 */
61 // eslint-disable-next-line deprecation/deprecation
62 calloutProps: {
63 beakWidth: 16,
64 gapSpace: 0,
65 setInitialFocus: true,
66 doNotLayer: false,
67 directionalHint: DirectionalHint.rightCenter,
68 },
69 };
70 return TeachingBubbleBase;
71}(React.Component));
72export { TeachingBubbleBase };
73//# sourceMappingURL=TeachingBubble.base.js.map
\No newline at end of file