@microsoft/sp-webpart-base
Version:
SharePoint Framework support for building web parts
112 lines • 3.91 kB
JavaScript
import { __extends } from "tslib";
import { Validate } from '@microsoft/sp-core-library';
import BaseWebPartContext from './BaseWebPartContext';
/**
* Web part context object. This object contains the contextual services available to a web part. e.g.
* a contextual instance to the http client.
*
* @public
*/
var WebPartContext = /** @class */ (function (_super) {
__extends(WebPartContext, _super);
/** @internal */
function WebPartContext(parameters) {
var _this = _super.call(this, parameters) || this;
Validate.isNotNullOrUndefined(parameters.domElement, "webpart context domElement");
Validate.isNotNullOrUndefined(parameters.statusRenderer, 'webpart context statusRenderer');
_this._domElement = parameters.domElement;
_this._statusRenderer = parameters.statusRenderer;
_this._pageLayoutType = parameters.pageLayoutType;
// Assert the type to ignore the missing const enums in our internal teamsJs namespace
_this._teams = parameters.microsoftTeams;
_this._sdks = parameters.sdks;
_this._widthCacheKey = parameters.widthCacheKey;
_this._sdksAsync = parameters.sdksAsync;
_this._getPositionOnPage = parameters.getPositionOnPage;
return _this;
}
Object.defineProperty(WebPartContext.prototype, "domElement", {
/**
* Reference to the DOM element that hosts this client-side component.
*/
get: function () {
return this._domElement;
},
enumerable: false,
configurable: true
});
Object.defineProperty(WebPartContext.prototype, "sdks", {
/**
* {@inheritdoc ISDKs}
*/
get: function () {
return this._sdks;
},
enumerable: false,
configurable: true
});
/**
* @internal
* {@inheritdoc ISDKs}
*/
WebPartContext.prototype._getSdksAsync = function () {
return this._sdksAsync;
};
Object.defineProperty(WebPartContext.prototype, "statusRenderer", {
/**
* Web part status renderer.
*/
get: function () {
return this._statusRenderer;
},
enumerable: false,
configurable: true
});
Object.defineProperty(WebPartContext.prototype, "microsoftTeams", {
/**
* Contextual information about the current Microsoft Teams tab. This object will only be defined if
* a component is being hosted in Microsoft Teams.
*
* @remarks
* For more information, please see:
* {@link https://docs.microsoft.com/en-us/javascript/api/@microsoft/teams-js/?view=msteams-client-js-latest}
* @public
* @deprecated - This function has been deprecated
*/
get: function () {
return this._teams;
},
enumerable: false,
configurable: true
});
Object.defineProperty(WebPartContext.prototype, "widthCacheKey", {
/**
* This functions returns a key generated by web parts display mode, layout index, and section factor.
* It will return undefined if sectionFactor or display mode is undefined, else return the cache key.
*/
get: function () {
return this._widthCacheKey;
},
enumerable: false,
configurable: true
});
/**
* Type of layout on which the web part is being rendered.
*
* @internal
*/
WebPartContext.prototype._getPageLayoutType = function () {
return this._pageLayoutType;
};
/**
* @deprecated - This function has been deprecated
*
* @internal
*/
WebPartContext.prototype._setTeams = function (teams) {
this._teams = teams;
};
return WebPartContext;
}(BaseWebPartContext));
export default WebPartContext;
//# sourceMappingURL=WebPartContext.js.map