UNPKG

@microsoft/sp-webpart-base

Version:

SharePoint Framework support for building web parts

125 lines 5.34 kB
import { DisplayMode, type ServiceScope } from '@microsoft/sp-core-library'; import type { IClientSideWebPartManifest } from '@microsoft/sp-module-interfaces'; import type { _PropertyPaneAction as PropertyPaneAction } from '@microsoft/sp-property-pane'; import type ClientSideWebPartManager from '../../core/ClientSideWebPartManager'; import type IWebPartData from '../../core/IWebPartData'; import type IWebPartHost from '../host/IWebPartHost'; import type { PageHostLayoutType } from '../../core/IWebPartManagerContext'; import type { WebPartFormFactor } from '../../core/WebPartFormFactor'; /** * Props required by the minimal web part container component. * @internal */ export interface IMinimalWebPartContainerProps { serviceScope: ServiceScope; webPartInstanceId: string; webPartData: IWebPartData; manifest: IClientSideWebPartManifest<any>; host: IWebPartHost; formFactor: WebPartFormFactor; /** * Page Host Layout Type. ex: AppPageHostPageLayout, Teams... */ pageHostLayoutType: PageHostLayoutType; /** * The display mode to initialize the web part in. This will override the * openPropertyPane setting. */ displayMode?: DisplayMode; /** * An optional flag to signal that the property pane should be displayed * in this container. Default is false. */ openPropertyPane?: boolean; /** * An optional flag to signal that the details property pane should be displayed * in this container. Default is false. */ openDetailsPropertyPane?: boolean; /** * An optional callback that will be called after the web part has been rendered and * we can get the dimensions information from it. The dimensions will be * sent to the containing application which will then resize the element that holds * this container. * An example of this scenario is when an iframe displays this container, we want * to send the dimensions to the iframe so that the iframe's dimensions * can be set accordingly. */ sendDimensionsToParent?: (height: number) => void; /** * An optional callback that will be called after the web part has * rendered, the callback function requests that the 'displayMode' be sent * to the containing application and then the container should set the accurate * 'displayMode' on the web part via the 'webPartManager'.. * This callback Should be provided if the display mode is determined before * the web part is rendered. */ requestDisplayModeStatus?: () => void; /** * An optional callback that will be called after the web part has * rendered, the callback function requests that the 'theme' be sent * to the containing application and then the container should set the accurate * 'theme' on the web part via the 'webPartManager'. */ requestTheme?: () => void; /** * Whether the web part properties are added from persisted data. If not specified, defaults to true. */ isDataAddedFromPersistedData?: boolean; } /** * A basic container component to host a web part. This is the simplest component that can * host a web part. This should be used in scenarios where performance is key. Edit mode * is currently not supported in this container. And this container does not need ReactJS. * * @internal */ export default class MinimalWebPartContainer { private readonly _props; private _domElement; private _webPartManager; private _intervalTask; constructor(props: IMinimalWebPartContainerProps); /** * Get the web part manager for this container. */ get webPartManager(): ClientSideWebPartManager; render(domElement: HTMLElement): Promise<void>; dispose(): void; setWebPartData(webPartData: IWebPartData, instanceId: string): void; /** * Invokes the ClientSideWebPartManager.serialize() function and returns the result. */ serialize(): IWebPartData; /** * Sets the display mode of the web part in this instance of the MinimalWebPartContainer via the * ClientSideWebPartManager. * * @returns A promise indicating when the mode switch is complete. There can be a delay if the property * pane chunk needs to be loaded. */ setDisplayMode(displayMode: DisplayMode): Promise<void>; /** * A call that trickle down to the PropertyPaneController to open/show the * property pane context. This is neccessary because the showPropertyPane method * in IframedWebPartController will only expose the iframed element but not take * care of showing the property pane content. */ requestPropertyPaneAction(instanceId: string, propertyPaneAction: PropertyPaneAction, webPartData?: IWebPartData): void; /** * Returns the height of the element's content including content not visible on the screen due * to overflow. */ _getHeight(): number; /** * Returns the width of the element's content including content not visible on the screen due * to overflow. */ _getWidth(): number; private _sendDimensionsCallback; private _renderWebPart; private _getWebPartManagerContext; private _isDataAddedFromPersistedData; private _validateProps; } //# sourceMappingURL=MinimalWebPartContainer.d.ts.map