UNPKG

@pnp/spfx-controls-react

Version:

Reusable React controls for SharePoint Framework solutions

54 lines 2.26 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.PropertyPaneListPicker = void 0; var tslib_1 = require("tslib"); var React = tslib_1.__importStar(require("react")); var ReactDom = tslib_1.__importStar(require("react-dom")); var ListPicker_1 = require("./controls/ListPicker"); var sp_property_pane_1 = require("@microsoft/sp-property-pane"); var PropertyPaneListPicker = /** @class */ (function () { function PropertyPaneListPicker(targetProperty, properties) { this.type = sp_property_pane_1.PropertyPaneFieldType.Custom; this.targetProperty = targetProperty; this.properties = { key: properties.label, label: properties.label, wpContext: properties.wpContext, onPropertyChange: properties.onPropertyChange, selectedKey: properties.selectedKey, disabled: properties.disabled, onRender: this.onRender.bind(this), onDispose: this.onDispose.bind(this) }; } PropertyPaneListPicker.prototype.render = function () { if (!this.elem) { return; } this.onRender(this.elem); }; PropertyPaneListPicker.prototype.onDispose = function (element) { ReactDom.unmountComponentAtNode(element); }; PropertyPaneListPicker.prototype.onRender = function (elem) { if (!this.elem) { this.elem = elem; } var element = React.createElement(ListPicker_1.ListPicker, { label: this.properties.label, wpContext: this.properties.wpContext, onChange: this.onChange.bind(this), selectedKey: this.properties.selectedKey, disabled: this.properties.disabled, // required to allow the component to be re-rendered by calling this.render() externally // stateKey: new Date().toString() }); ReactDom.render(element, elem); }; PropertyPaneListPicker.prototype.onChange = function (option) { this.properties.onPropertyChange(this.targetProperty, option.key); }; return PropertyPaneListPicker; }()); exports.PropertyPaneListPicker = PropertyPaneListPicker; //# sourceMappingURL=PropertyPaneListPicker.js.map