(function ( wpI18n, wpBlocks, wpElement, wpEditor, wpComponents ) { const { __ } = wpI18n; const { Component, Fragment } = wpElement; const { registerBlockType } = wpBlocks; const { InspectorControls, PanelColorSettings } = wpEditor; const { PanelBody, RangeControl, SelectControl, TextControl } = wpComponents; const contactBlockIcon = ( ); class AdvContactForm extends Component { constructor() { super( ...arguments ); } componentWillMount() { const { attributes, setAttributes } = this.props; const currentBlockConfig = advgbDefaultConfig['advgb-contact-form']; // No override attributes of blocks inserted before if (attributes.changed !== true) { if (typeof currentBlockConfig === 'object' && currentBlockConfig !== null) { Object.keys(currentBlockConfig).map((attribute) => { if (typeof attributes[attribute] === 'boolean') { attributes[attribute] = !!currentBlockConfig[attribute]; } else { attributes[attribute] = currentBlockConfig[attribute]; } }); } // Finally set changed attribute to true, so we don't modify anything again setAttributes( { changed: true } ); } } render() { const { attributes, setAttributes } = this.props; const { nameLabel, emailLabel, msgLabel, submitLabel, successLabel, alertLabel, bgColor, textColor, borderColor, borderStyle, borderRadius, submitColor, submitBgColor, submitRadius, submitPosition, } = attributes; return ( {(typeof advgbBlocks !== 'undefined' && !parseInt(advgbBlocks.captchaEnabled)) && (

{ __( 'We strongly recommend to enable Google reCaptcha to avoid spam bot. You can enable it in Form Recaptcha in' ) } { __( 'settings' ) }.

) }

{ __('An email will be sent to the admin email (by default) whenever a contact form is submitted. You can change it in ') } { __( 'settings' ) }.

setAttributes( { nameLabel: value } ) } /> setAttributes( { emailLabel: value } ) } /> setAttributes( { msgLabel: value } ) } /> setAttributes( { submitLabel: value } ) } /> setAttributes( { alertLabel: value } ) } /> setAttributes( { successLabel: value } ) } /> setAttributes( { bgColor: value } ), }, { label: __( 'Text color' ), value: textColor, onChange: (value) => setAttributes( { textColor: value } ), }, ] } /> setAttributes( { borderColor: value } ), }, ] } /> setAttributes( { borderStyle: value } ) } /> setAttributes( { borderRadius: value } ) } min={ 0 } max={ 50 } /> setAttributes( { submitColor: value } ), }, { label: __( 'Background' ), value: submitBgColor, onChange: (value) => setAttributes( { submitBgColor: value } ), }, ] } /> setAttributes( { submitRadius: value } ) } min={ 0 } max={ 50 } /> setAttributes( { submitPosition: value } ) } />