UNPKG

@pnp/spfx-property-controls

Version:

Reusable property pane controls for SharePoint Framework solutions

44 lines 2.21 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.PropertyFieldTextWithCallout = PropertyFieldTextWithCallout; 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 PropertyFieldTextWithCalloutHost_1 = tslib_1.__importDefault(require("./PropertyFieldTextWithCalloutHost")); const omit_1 = tslib_1.__importDefault(require("lodash/omit")); class PropertyFieldTextWithCalloutBuilder { constructor(_targetProperty, _properties) { this.type = sp_property_pane_1.PropertyPaneFieldType.Custom; this._onValidated = (errorMessage, value) => { if (!errorMessage && this._onChangeCallback) { this._onChangeCallback(this.targetProperty, value); } }; this._onChanged = (value) => { if (this._onChangeCallback) { this._onChangeCallback(this.targetProperty, value); } }; this.targetProperty = _targetProperty; this.properties = _properties; this.properties.onRender = this._render.bind(this); this.properties.onDispose = this._dispose.bind(this); this.properties.onChanged = this._onChanged.bind(this); } _render(elem, context, changeCallback) { const props = this.properties; const element = React.createElement(PropertyFieldTextWithCalloutHost_1.default, Object.assign(Object.assign({}, (0, omit_1.default)(props, ['logName'])), { onNotifyValidationResult: this._onValidated, onChanged: this._onChanged })); ReactDOM.render(element, elem); if (changeCallback) { this._onChangeCallback = changeCallback; } } _dispose(elem) { ReactDOM.unmountComponentAtNode(elem); } } function PropertyFieldTextWithCallout(targetProperty, properties) { return new PropertyFieldTextWithCalloutBuilder(targetProperty, Object.assign(Object.assign({}, properties), { onChanged: properties.onChanged, onRender: null, onDispose: null })); } //# sourceMappingURL=PropertyFieldTextWithCallout.js.map