@pnp/spfx-property-controls
Version:
Reusable property pane controls for SharePoint Framework solutions
52 lines • 2.5 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("tslib");
const React = tslib_1.__importStar(require("react"));
const Button_1 = require("@fluentui/react/lib/Button");
//import styles from './Component.module.scss';
class PropertyFieldButtonControl extends React.Component {
constructor(props) {
super(props);
this.state = {
isVisible: this.props.isVisible,
disabled: this.props.disabled,
isPrimary: this.props.isPrimary,
text: this.props.text,
iconProps: this.props.iconProps,
onClick: this.props.onClick,
key: this.props.key,
};
}
///
componentDidUpdate(prevProps, prevState) {
if (prevProps.isVisible !== this.props.isVisible ||
prevProps.disabled !== this.props.disabled ||
prevProps.isPrimary !== this.props.isPrimary ||
prevProps.className !== this.props.className ||
prevProps.styles !== this.props.styles ||
prevProps.text !== this.props.text ||
prevProps.iconProps !== this.props.iconProps ||
prevProps.onClick !== this.props.onClick ||
prevProps.key !== this.props.key) {
this.setState({
isVisible: this.props.isVisible,
disabled: this.props.disabled,
isPrimary: this.props.isPrimary,
className: this.props.className,
styles: this.props.styles,
text: this.props.text,
iconProps: this.props.iconProps,
onClick: this.props.onClick,
key: this.props.key,
});
}
}
render() {
if (!this.props.isVisible) {
return null;
}
return (React.createElement("div", null, this.props.isPrimary ? (React.createElement(Button_1.PrimaryButton, { text: this.state.text, key: this.state.key, disabled: this.state.disabled, className: this.state.className, styles: this.state.styles, onClick: this.state.onClick, iconProps: this.state.iconProps })) : (React.createElement(Button_1.DefaultButton, { text: this.state.text, key: this.state.key, disabled: this.state.disabled, className: this.state.className, styles: this.state.styles, onClick: this.state.onClick, iconProps: this.state.iconProps }))));
}
}
exports.default = PropertyFieldButtonControl;
//# sourceMappingURL=PropertyFieldButtonControl.js.map