@pnp/spfx-property-controls
Version:
Reusable property pane controls for SharePoint Framework solutions
38 lines • 1.95 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.PropertyFieldDropdownWithCallout = PropertyFieldDropdownWithCallout;
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 PropertyFieldDropdownWithCalloutHost_1 = tslib_1.__importDefault(require("./PropertyFieldDropdownWithCalloutHost"));
const omit_1 = tslib_1.__importDefault(require("lodash/omit"));
class PropertyFieldDropdownWithCalloutBuilder {
constructor(_targetProperty, _properties) {
this.type = sp_property_pane_1.PropertyPaneFieldType.Custom;
this.targetProperty = _targetProperty;
this.properties = _properties;
this.properties.onRender = this._render.bind(this);
this.properties.onDispose = this._dispose.bind(this);
}
_render(elem, context, changeCallback) {
const props = this.properties;
const element = React.createElement(PropertyFieldDropdownWithCalloutHost_1.default, Object.assign(Object.assign({}, (0, omit_1.default)(props, ['options', 'ariaPositionInSet', 'ariaSetSize'])), { options: props.options || [], onChanged: this._onChanged.bind(this) }));
ReactDOM.render(element, elem);
if (changeCallback) {
this._onChangeCallback = changeCallback;
}
}
_dispose(elem) {
ReactDOM.unmountComponentAtNode(elem);
}
_onChanged(item) {
if (this._onChangeCallback) {
this._onChangeCallback(this.targetProperty, item.key);
}
}
}
function PropertyFieldDropdownWithCallout(targetProperty, properties) {
return new PropertyFieldDropdownWithCalloutBuilder(targetProperty, Object.assign(Object.assign({}, properties), { onRender: null, onDispose: null }));
}
//# sourceMappingURL=PropertyFieldDropdownWithCallout.js.map