@microsoft/sp-dialog
Version:
SharePoint Framework support for displaying dialog boxes
57 lines • 2.44 kB
JavaScript
import { __extends } from "tslib";
import * as React from 'react';
import { Overlay, Spinner as SpinnerV8, SpinnerType } from '@ms/office-ui-fabric-react-bundle';
import { Spinner } from '@fluentui/react-components';
import './Placeholder.global.scss';
import { isUsingV9ForSPDialogKSActivated } from '../common/KillSwitches';
/**
* Component used to display place holder content in the web part display area.
* sealed
* @internal
*/
var PlaceholderSpinner = /** @class */ (function (_super) {
__extends(PlaceholderSpinner, _super);
function PlaceholderSpinner(props) {
var _this = _super.call(this, props) || this;
_this.showSpinner = _this.showSpinner.bind(_this);
_this.state = { showSpinner: !props.hideSpinner };
return _this;
}
PlaceholderSpinner.prototype.componentDidMount = function () {
this._isMounted = true;
};
/**
* Render the place holder user experience.
*/
PlaceholderSpinner.prototype.render = function () {
if (this.state.removePlaceholder) {
// Don't use undefined, react does not work
return null;
}
if (!isUsingV9ForSPDialogKSActivated()) {
return (React.createElement("div", { className: 'Placeholder-overlay' },
React.createElement("div", { className: 'Placeholder-spinnerContainer' }, this.state.showSpinner && React.createElement(Spinner, { size: 'small', label: this.props.label }))));
}
return (React.createElement(Overlay, { className: 'Placeholder-overlay' },
React.createElement("div", { className: 'Placeholder-spinnerContainer' }, this.state.showSpinner && React.createElement(SpinnerV8, { type: SpinnerType.large, label: this.props.label }))));
};
PlaceholderSpinner.prototype.componentWillUnmount = function () {
this._isMounted = false;
};
PlaceholderSpinner.prototype.showSpinner = function (showSpinner) {
if (this._isMounted) {
this.setState({ showSpinner: showSpinner });
}
};
/**
* Get rid of the placeholder completely from the DOM tree
*/
PlaceholderSpinner.prototype.clearPlaceholder = function () {
if (this._isMounted) {
this.setState({ removePlaceholder: true });
}
};
return PlaceholderSpinner;
}(React.Component));
export default PlaceholderSpinner;
//# sourceMappingURL=PlaceholderSpinner.js.map