UNPKG

@pnp/spfx-property-controls

Version:

Reusable property pane controls for SharePoint Framework solutions

96 lines 4.13 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.PropertyFieldPeoplePicker = PropertyFieldPeoplePicker; const tslib_1 = require("tslib"); const React = tslib_1.__importStar(require("react")); const ReactDom = tslib_1.__importStar(require("react-dom")); const sp_property_pane_1 = require("@microsoft/sp-property-pane"); const PropertyFieldPeoplePickerHost_1 = tslib_1.__importDefault(require("./PropertyFieldPeoplePickerHost")); /** * Represents a PropertyFieldPeoplePicker object */ class PropertyFieldPeoplePickerBuilder { /** * Constructor method */ constructor(_targetProperty, _properties) { // Properties defined by IPropertyPaneField this.type = sp_property_pane_1.PropertyPaneFieldType.Custom; this.disabled = false; this.allowDuplicate = true; this.multiSelect = true; this.principalType = []; this.deferredValidationTime = 200; this.searchTextLimit = 3; this.render = this.render.bind(this); this.label = _properties.label; this.targetProperty = _properties.targetProperty; this.properties = _properties; this.properties.onDispose = this.dispose; this.properties.onRender = this.render; this.onPropertyChange = _properties.onPropertyChange; this.context = _properties.context; this.initialData = _properties.initialData; this.allowDuplicate = _properties.allowDuplicate; this.principalType = _properties.principalType; this.targetSiteUrl = _properties.targetSiteUrl; this.customProperties = _properties.properties; this.key = _properties.key; this.onGetErrorMessage = _properties.onGetErrorMessage; if (typeof _properties.disabled !== 'undefined') { this.disabled = _properties.disabled; } if (_properties.deferredValidationTime) { this.deferredValidationTime = _properties.deferredValidationTime; } if (typeof _properties.searchTextLimit !== 'undefined') { this.searchTextLimit = _properties.searchTextLimit; } if (typeof _properties.multiSelect !== "undefined") { this.multiSelect = _properties.multiSelect; } } /** * Renders the PeoplePicker field content */ render(elem, ctx, changeCallback) { // Construct the JSX properties const element = React.createElement(PropertyFieldPeoplePickerHost_1.default, { label: this.label, disabled: this.disabled, targetProperty: this.targetProperty, initialData: this.initialData, allowDuplicate: this.allowDuplicate, multiSelect: this.multiSelect, principalType: this.principalType, onDispose: this.dispose, onRender: this.render, onChange: changeCallback, onPropertyChange: this.onPropertyChange, context: this.context, properties: this.customProperties, targetSiteUrl: this.targetSiteUrl, key: this.key, onGetErrorMessage: this.onGetErrorMessage, deferredValidationTime: this.deferredValidationTime, searchTextLimit: this.searchTextLimit }); // Calls the REACT content generator ReactDom.render(element, elem); } /** * Disposes the current object */ dispose(elem) { } } /** * Helper method to create a People Picker on the PropertyPane. * @param targetProperty - Target property the people picker is associated to. * @param properties - Strongly typed people Picker properties. */ function PropertyFieldPeoplePicker(targetProperty, properties) { // Calls the PropertyFieldPeoplePicker builder object // This object will simulate a PropertyFieldCustom to manage his rendering process return new PropertyFieldPeoplePickerBuilder(targetProperty, Object.assign(Object.assign({}, properties), { targetProperty: targetProperty, onDispose: null, onRender: null })); } //# sourceMappingURL=PropertyFieldPeoplePicker.js.map