@microsoft/sp-webpart-base
Version:
SharePoint Framework support for building web parts
117 lines • 4.98 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var sp_component_base_1 = require("@microsoft/sp-component-base");
var sp_core_library_1 = require("@microsoft/sp-core-library");
var PropertyPaneAccessor_1 = tslib_1.__importDefault(require("./context/PropertyPaneAccessor"));
/**
* Web part context object. This object contains the contextual services available to a web part. e.g.
* a contextual instance to the http client.
*
* This base is to be extended by UI-specific WebPart's base.
*
* @public
*/
var BaseWebPartContext = /** @class */ (function (_super) {
tslib_1.__extends(BaseWebPartContext, _super);
/** @internal */
function BaseWebPartContext(parameters) {
var _this = _super.call(this, parameters) || this;
sp_core_library_1.Validate.isNotNullOrUndefined(parameters, 'webpart context');
sp_core_library_1.Validate.isNotNullOrUndefined(parameters.instanceId, 'webpart context instanceId');
sp_core_library_1.Validate.isNotNullOrUndefined(parameters.webPartTag, 'webpart context webPartTag');
sp_core_library_1.Validate.isNotNullOrUndefined(parameters.host, 'webpart context host');
sp_core_library_1.Validate.isNotNullOrUndefined(parameters.isPropertyPaneRenderedByWebPart, 'webpart context isPropertyPaneRenderedByWebPart');
sp_core_library_1.Validate.isNotNullOrUndefined(parameters.isPropertyPaneOpen, 'webpart context isPropertyPaneOpen');
sp_core_library_1.Validate.isNotNullOrUndefined(parameters.requestPropertyPaneAction, 'webpart context requestPropertyPaneAction');
sp_core_library_1.Validate.isNotNullOrUndefined(parameters.formFactor, 'webpart context form factor');
_this._webPartTag = parameters.webPartTag;
_this._host = parameters.host;
_this._requestPropertyPaneAction = parameters.requestPropertyPaneAction;
_this._isPropertyPaneRenderedByWebPart = parameters.isPropertyPaneRenderedByWebPart;
_this._isPropertyPaneOpen = parameters.isPropertyPaneOpen;
_this._isContentPanelOpen = parameters.isContentPanelOpen;
_this._privateDataUpdatedEvent = parameters._dataUpdatedEvent;
_this._formFactor = parameters.formFactor;
_this._propertyPaneAccessor = new PropertyPaneAccessor_1.default(function () {
_this._requestPropertyPaneAction(_this.instanceId, 'Open', true);
}, function () {
_this._requestPropertyPaneAction(_this.instanceId, 'Close', true);
}, function () {
_this._requestPropertyPaneAction(_this.instanceId, 'Refresh', true);
}, function (context) {
_this._requestPropertyPaneAction(_this.instanceId, 'OpenDetails', true, context);
}, function () {
return _this._isPropertyPaneRenderedByWebPart();
}, function (instanceId) {
return _this._isPropertyPaneOpen(instanceId);
}, function () {
return _this._isContentPanelOpen();
});
return _this;
}
Object.defineProperty(BaseWebPartContext.prototype, "webPartTag", {
/**
* Web part tag to be used for logging and telemetry.
*/
get: function () {
return this._webPartTag;
},
enumerable: false,
configurable: true
});
Object.defineProperty(BaseWebPartContext.prototype, "propertyPane", {
/**
* Accessor for common web part property pane operations.
*/
get: function () {
return this._propertyPaneAccessor;
},
enumerable: false,
configurable: true
});
Object.defineProperty(BaseWebPartContext.prototype, "formFactor", {
/**
* Form factor of the web part.
*
* @remarks
* Web parts may behave differently based on its form factor.
* E.g. a web part rendering as full size may want to set up different margins that when rendering in a canvas.
*
* @beta
*/
get: function () {
return this._formFactor;
},
enumerable: false,
configurable: true
});
Object.defineProperty(BaseWebPartContext.prototype, "host", {
/**
* Web part host.
*
* @alpha
*/
get: function () {
return this._host;
},
enumerable: false,
configurable: true
});
Object.defineProperty(BaseWebPartContext.prototype, "_dataUpdatedEvent", {
/**
* Web part properties updated event.
*
* @eventproperty
* @internal
*/
get: function () {
return this._privateDataUpdatedEvent;
},
enumerable: false,
configurable: true
});
return BaseWebPartContext;
}(sp_component_base_1.BaseComponentContext));
exports.default = BaseWebPartContext;
//# sourceMappingURL=BaseWebPartContext.js.map