UNPKG

@microsoft/sp-webpart-base

Version:

SharePoint Framework support for building web parts

81 lines 3.22 kB
import type { IComponentPropertyMetadata } from '@microsoft/sp-component-base'; /** * This structure is used to define metadata for web part properties as a map of string to `IWebPartPropertyMetadata` * * @remarks * The key should be a JSON path to the property in web part properties. The JSON path supports the following operators: * * - Dot `.` for selecting object members, for example `person.name` * * - Brackets `[]` for selecting array items, for example `person.photoURLs[0]` * * - Bracketed asterisk `[*]` for array elements wildcard, for example `person.websites[*]`. * * You can make combinations of these operators, for example `person.websites[*].url` * * Important Note: Only one wildcard per path is supported. * * Example: Let's assume we have a web part with properties that have the following schema: * ``` * { * title: string; * person: { * name: string; * bio: string; * photoURLs: string[]; * websites: { title: string; url: string; }[] * } * } * ``` * * We can define the metadata for the desired properties as following: * ``` * { * 'person.bio': { isRichContent: true }, * 'person.photoURLs[*]': { isImageSource: true }, * 'person.websites[*].url': { isLink: true } * } * ``` * * This will make SharePoint servers aware of the content of your properties and run services such as search indexing, * link fix-up, etc on the data. In case any of the values needs to update by these services, e.g link fix-up, the * web part property bag is automatically updated. * * @public */ interface IWebPartPropertiesMetadata { [key: string]: IWebPartPropertyMetadata; } /** * This is the structure used for map values in `IWebPartPropertiesMetadata` * * @public */ export interface IWebPartPropertyMetadata extends IComponentPropertyMetadata { /** * If specified, indicates that the property is a dynamic property and the type of * the dynamic property. * * @remarks * If a web part has properties that are dynamically * configurable, then use this flag to declare the property as a dynamic property by * specifying its type. When a property specifies its dynamic property type, then * the framework ensures that its value can be accessed using 'tryGetValue' anytime * in the life cycle of the web part. If a property is marked as DynamicProperty in * the IWebPartProperties interface, but does not appear in the IWebPartPropertiesMetadata * with a dynamicPropertyType, then the web part developer will need to manually create * the DynamicProperty themselves and assign it to the property. * * A web part can configure a default value for the property by specifying it in the * properties section of the web part's manifest. This value will be used when a * dynamic property is constructed for the property. * * Note: Web parts should be able to type cast the resultant value from the `tryGetValue` * to suit their needs. * * @public */ dynamicPropertyType?: 'boolean' | 'number' | 'string' | 'array' | 'object'; } export default IWebPartPropertiesMetadata; //# sourceMappingURL=IWebPartPropertiesMetadata.d.ts.map