office-ui-fabric-react
Version:
Reusable React components for building experiences for Office 365.
59 lines • 2.6 kB
JavaScript
import * as tslib_1 from "tslib";
import * as React from 'react';
import { BaseComponent, classNamesFunction, createRef } from '../../Utilities';
import { TeachingBubbleContent } from './TeachingBubbleContent';
import { calloutStyles } from './TeachingBubble.styles';
import { Callout } from '../../Callout';
var getClassNames = classNamesFunction();
var TeachingBubbleBase = /** @class */ (function (_super) {
tslib_1.__extends(TeachingBubbleBase, _super);
// Constructor
function TeachingBubbleBase(props) {
var _this = _super.call(this, props) || this;
_this.rootElement = createRef();
_this.state = {};
_this._defaultCalloutProps = {
beakWidth: 16,
gapSpace: 0,
setInitialFocus: true,
doNotLayer: false,
directionalHint: 12 /* rightCenter */
};
return _this;
}
TeachingBubbleBase.prototype.focus = function () {
if (this.rootElement.current) {
this.rootElement.current.focus();
}
};
TeachingBubbleBase.prototype.render = function () {
var _a = this.props, setCalloutProps = _a.calloutProps, targetElement = _a.targetElement, onDismiss = _a.onDismiss, isWide = _a.isWide, styles = _a.styles, theme = _a.theme;
var calloutProps = tslib_1.__assign({}, this._defaultCalloutProps, setCalloutProps);
var stylesProps = {
theme: theme,
isWide: isWide,
calloutClassName: calloutProps ? calloutProps.className : undefined
};
var classNames = getClassNames(styles, stylesProps);
return (React.createElement(Callout, tslib_1.__assign({ target: targetElement, onDismiss: onDismiss }, calloutProps, { className: classNames.root, styles: calloutStyles(stylesProps), hideOverflow: true }),
React.createElement("div", { ref: this.rootElement },
React.createElement(TeachingBubbleContent, tslib_1.__assign({}, this.props)))));
};
TeachingBubbleBase.defaultProps = {
/**
* Default calloutProps is deprecated in favor of private _defaultCalloutProps.
* Remove in next release.
* @deprecated
*/
calloutProps: {
beakWidth: 16,
gapSpace: 0,
setInitialFocus: true,
doNotLayer: false,
directionalHint: 12 /* rightCenter */
}
};
return TeachingBubbleBase;
}(BaseComponent));
export { TeachingBubbleBase };
//# sourceMappingURL=TeachingBubble.base.js.map