UNPKG

@microsoft/sp-webpart-base

Version:

SharePoint Framework support for building web parts

138 lines 4.43 kB
import type { DisplayMode, ServiceScope } from '@microsoft/sp-core-library'; import type { IClientSideWebPartManifest } from '@microsoft/sp-module-interfaces'; import type { _IComponentPosition } from '@microsoft/sp-component-base'; import type IWebPartHost from '../components/host/IWebPartHost'; import type IWebPartData from './IWebPartData'; import type { WebPartFormFactor } from './WebPartFormFactor'; /** * Context object that needs to be passed to the web part manager to load a web part. * * @internal */ interface IWebPartManagerContext { /** * Reference to the DOM element that contains the web part. * * @privateRemarks * MRWebPartContainer can pass its own instance or undefined instead of HTMLElement. * Keep that in mind when using HTMLElement. * See here: https://onedrive.visualstudio.com/ODSP-Web/_git/odsp-web?path=/sp-client/libraries/sp-spaces/src/core/canvas/controls/MRWebPartContainer.ts&version=GBmain&line=298&lineEnd=298&lineStartColumn=7&lineEndColumn=61&lineStyle=plain&_a=contents */ domElement: HTMLElement; /** * Web part instance id */ instanceId: string; /** * Web part manifest */ manifest: IClientSideWebPartManifest<any>; /** * The display mode as one of DisplayMode.Read or DisplayMode.Edit */ displayMode: DisplayMode; /** * Type of layout on which the web part is being rendered. */ pageLayoutType?: PageHostLayoutType | string; /** * Web psart instance data. This data should be used to render a web part. */ webPartData?: IWebPartData; /** * Host containing the web part. This host can be any container that implements the IWebPartHost interface. Some * examples of hosts are the Canvas, a single page application that contains a web part, and classic SharePoint * pages. */ host?: IWebPartHost; /** * Flag indicating whether the web part is rendered from the persisted data or not. If the web part is added * from toolbox, the value of this flag will be false. */ addedFromPersistedData?: boolean; /** * If the web part is being loaded from a different list or item than the page the isolated part is running on, * provide the `isolatedItemContext` to override the implicitly set parameters set for the isolated web part application. */ isolatedItemContext?: IIsolatedItemContext; /** * An optional scope to override the host scope passed to the web part. The host scope is still used by the manager, * and this scope will only be passed to the web part. */ serviceScope?: ServiceScope; /** * Type of the web part. */ formFactor?: WebPartFormFactor; /** * Reserved Height of the Webpart */ reservedHeight?: number; /** * Cache key to get webpart's width from cache. Used to avoid reflows */ widthCacheKey?: string | undefined; /** * Gets the position information of the web part on the page. * @returns The position information of the web part on the page. */ getPositionOnPage?: () => _IComponentPosition | undefined; } /** * @internal */ export interface IIsolatedItemContext { list: string; id: string; } /** * The interface of context used internally in loadWebPart API which is extended based on IWebPartManagerContext. * @internal */ export interface IWebPartLoadContext extends IWebPartManagerContext { /** * The unique tag of web part for variant of logs. */ webPartTag: string; /** * The web part render complete time stamp. * Note: clean the void type to undefined when graduate kill switch d2b2d5e6-4bd3-40f7-b49f-782f95ae1ae1. */ renderCompleteTime: number | void; } /** * Type of layout on which the web part is being rendered. * @internal */ export type PageHostLayoutType = /** * AppPage host page layout */ 'AppPageHostPageLayout' /** * Single web part AppPage layout */ | 'SingleWebPartAppPageLayout' /** * System AppPage host page layout */ | 'SystemAppPageHostPageLayout' /** * Hosted in Outlook */ | 'Outlook' /** * Hosted in Teams */ | 'Teams' /** * Hosted in Isolated Domain */ | 'Isolated' /** * No layout * Note: This should be removed when we remove spWebPartApplication. */ | 'None'; export default IWebPartManagerContext; //# sourceMappingURL=IWebPartManagerContext.d.ts.map