edit.js
96 lines
| 1 | import { SelectRadioCheckPlaceholder } from '../../components/base-select-check-radio/select-radio-check-placeholder'; |
| 2 | import SelectRadioCheck |
| 3 | from '../../components/base-select-check-radio/select-radio-check'; |
| 4 | import CustomTemplateControls |
| 5 | from '../../components/base-select-check-radio/custom-template'; |
| 6 | import preview from './preview'; |
| 7 | |
| 8 | const { |
| 9 | ToolBarFields, |
| 10 | BlockLabel, |
| 11 | BlockDescription, |
| 12 | BlockAdvancedValue, |
| 13 | BlockName, |
| 14 | AdvancedFields, |
| 15 | FieldControl, |
| 16 | SwitchPageOnChangeControls, |
| 17 | } = JetFBComponents; |
| 18 | const { |
| 19 | __, |
| 20 | } = wp.i18n; |
| 21 | const { |
| 22 | InspectorControls, |
| 23 | useBlockProps, |
| 24 | } = wp.blockEditor; |
| 25 | const { |
| 26 | ToggleControl, |
| 27 | PanelBody, |
| 28 | } = wp.components; |
| 29 | |
| 30 | const { |
| 31 | useUniqueNameOnDuplicate, |
| 32 | } = JetFBHooks; |
| 33 | |
| 34 | export default function RadioEdit( props ) { |
| 35 | |
| 36 | const { |
| 37 | isSelected, |
| 38 | attributes, |
| 39 | editProps: { uniqKey }, |
| 40 | } = props; |
| 41 | |
| 42 | const blockProps = useBlockProps(); |
| 43 | useUniqueNameOnDuplicate(); |
| 44 | |
| 45 | if ( attributes.isPreview ) { |
| 46 | return <div style={ { |
| 47 | width: '100%', |
| 48 | display: 'flex', |
| 49 | justifyContent: 'center', |
| 50 | } }> |
| 51 | { preview } |
| 52 | </div>; |
| 53 | } |
| 54 | |
| 55 | return <> |
| 56 | <ToolBarFields |
| 57 | key={ uniqKey( 'ToolBarFields' ) } |
| 58 | { ...props } |
| 59 | /> |
| 60 | <SwitchPageOnChangeControls/> |
| 61 | { isSelected && <InspectorControls |
| 62 | key={ uniqKey( 'InspectorControls' ) } |
| 63 | > |
| 64 | <PanelBody title={ __( 'General', 'jet-form-builder' ) }> |
| 65 | <BlockLabel/> |
| 66 | <BlockName/> |
| 67 | <BlockDescription/> |
| 68 | </PanelBody> |
| 69 | <PanelBody title={ __( 'Value', 'jet-form-builder' ) }> |
| 70 | <BlockAdvancedValue/> |
| 71 | </PanelBody> |
| 72 | <AdvancedFields |
| 73 | key={ uniqKey( 'AdvancedFields' ) } |
| 74 | { ...props } |
| 75 | /> |
| 76 | </InspectorControls> } |
| 77 | <div { ...blockProps } key={ uniqKey( 'viewBlock' ) }> |
| 78 | <SelectRadioCheckPlaceholder |
| 79 | key={ uniqKey( 'SelectRadioCheckPlaceholder' ) } |
| 80 | scriptData={ window.JetFormRadioFieldData } |
| 81 | { ...props } |
| 82 | /> |
| 83 | <SelectRadioCheck { ...props }> |
| 84 | <CustomTemplateControls |
| 85 | listingTypes={ window.JetFormRadioFieldData.listings_list } |
| 86 | { ...props } |
| 87 | /> |
| 88 | <FieldControl |
| 89 | type="custom_settings" |
| 90 | key={ uniqKey( 'customSettingsFields' ) } |
| 91 | { ...props } |
| 92 | /> |
| 93 | </SelectRadioCheck> |
| 94 | </div> |
| 95 | </>; |
| 96 | } |