@pnp/spfx-property-controls
Version:
Reusable property pane controls for SharePoint Framework solutions
44 lines • 2.22 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.PropertyFieldButtonWithCallout = PropertyFieldButtonWithCallout;
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 PropertyFieldButtonWithCalloutHost_1 = tslib_1.__importDefault(require("./PropertyFieldButtonWithCalloutHost"));
const react_1 = require("@fluentui/react");
const omit_1 = tslib_1.__importDefault(require("lodash/omit"));
/**
* Represents a PropertyFieldButtonWithCallout object
*/
class PropertyFieldButtonWithCalloutBuilder {
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;
//
// PropertyPaneButtonType is not assignable to ButtonType
//
const buttonTypeString = react_1.ButtonType[this.properties.buttonType];
const buttonType = react_1.ButtonType[buttonTypeString];
const element = React.createElement(PropertyFieldButtonWithCalloutHost_1.default, Object.assign(Object.assign({}, (0, omit_1.default)(props, ['icon', 'buttonType'])), { buttonType: buttonType }));
ReactDOM.render(element, elem);
}
_dispose(elem) {
ReactDOM.unmountComponentAtNode(elem);
}
}
/**
* Helper method to create a Button with Callout component on the PropertyPane.
* @param targetProperty - Target property the Button with Callout component is associated to.
* @param properties - Strongly typed Button with Callout component properties.
*/
function PropertyFieldButtonWithCallout(targetProperty, properties) {
return new PropertyFieldButtonWithCalloutBuilder(targetProperty, Object.assign(Object.assign({}, properties), { onRender: null, onDispose: null }));
}
//# sourceMappingURL=PropertyFieldButtonWithCallout.js.map