@microsoft/sp-webpart-base
Version:
SharePoint Framework support for building web parts
79 lines • 3.14 kB
JavaScript
/**
* Web part context property pane accessor. Provides some most commonly used utilities
* to access the property pane.
*
* @public
*/
var PropertyPaneAccessor = /** @class */ (function () {
function PropertyPaneAccessor(openProperytPane, closePropertyPane, refresh,
// eslint-disable-next-line @typescript-eslint/no-explicit-any
openDetails, isRenderedByWebPart, isPropertyPaneOpen, isContentPanelOpen) {
this._open = openProperytPane;
this._close = closePropertyPane;
this._refresh = refresh;
this._openDetails = openDetails;
this._isRenderedByWebPart = isRenderedByWebPart;
this._isPropertyPaneOpen = isPropertyPaneOpen;
this._isContentPanelOpen = isContentPanelOpen;
this.open = this.open.bind(this);
this.close = this.close.bind(this);
this.refresh = this.refresh.bind(this);
this.openDetails = this.openDetails.bind(this);
this.isRenderedByWebPart = this.isRenderedByWebPart.bind(this);
}
/**
* Api to open the PropertyPane/Content Panel.
*/
PropertyPaneAccessor.prototype.open = function () {
this._open();
};
/**
* Api to close the PropertyPane/Content Panel.
*/
PropertyPaneAccessor.prototype.close = function () {
this._close();
};
/**
* Api to refresh the contents of the PropertyPane or Content Panel.
* It's a no operation scenario if a web part is asking to refresh the property pane or content panel
* while some other web part is being configured.
*/
PropertyPaneAccessor.prototype.refresh = function () {
this._refresh();
};
/**
* Api to open the Details PropertyPane/Content Panel
*
* @param context - pass additional details as context to send back to the caller
*/
// eslint-disable-next-line @typescript-eslint/no-explicit-any
PropertyPaneAccessor.prototype.openDetails = function (context) {
this._openDetails(context);
};
/**
* Returns true if the current property pane or content panel source is a web part and not the Canvas or any other source.
*/
PropertyPaneAccessor.prototype.isRenderedByWebPart = function () {
return this._isRenderedByWebPart();
};
/**
* Returns true if the PropertyPane is open.
* Also true if Property Pane is rendered by Content Panel.
*
* @param instanceId - optional param to check isopen based on the supported consumer (content panel or property pane).
*/
PropertyPaneAccessor.prototype.isPropertyPaneOpen = function (instanceId) {
return this._isPropertyPaneOpen(instanceId);
};
/**
* Returns true if the Content Panel is open, regardless if the Content Panel is rendering the property pane.
* @beta
*/
PropertyPaneAccessor.prototype.isContentPanelOpen = function () {
var _a;
return !!((_a = this._isContentPanelOpen) === null || _a === void 0 ? void 0 : _a.call(this));
};
return PropertyPaneAccessor;
}());
export default PropertyPaneAccessor;
//# sourceMappingURL=PropertyPaneAccessor.js.map