/** * WordPress dependencies */ import { _x } from '@wordpress/i18n'; import { InspectorControls } from '@wordpress/block-editor'; import { CheckboxControl, ToggleControl, PanelBody, RangeControl, SelectControl, } from '@wordpress/components'; /** * Internal dependencies */ import { MapStyles } from './map-styles'; import { AddressSearch } from './address-search'; import { EditProps } from './types'; import { useGoogleMapsApiKey } from './hooks'; export const Inspector = ( { attributes: { addressAlignment, areZoomButtonsVisible, customStyle, height, isDraggable, isFullScreenButtonVisible, isMapTypeButtonVisible, isMarkerVisible, lat: centerLat, lng: centerLng, style, zoom, }, setAttributes, }: EditProps ): JSX.Element | null => { const googleMapsApiKey = useGoogleMapsApiKey(); if ( ! googleMapsApiKey ) { return null; } //end if const center = { lat: centerLat, lng: centerLng }; return ( setAttributes( { height: Math.min( Math.max( value, 20 ), 100 ), } ) } help={ _x( 'Percentage of the viewport height.', 'text', 'nelio-maps' ) } min={ 20 } max={ 100 } /> setAttributes( { zoom: Math.min( Math.max( value, 1 ), 18 ), } ) } min={ 1 } max={ 18 } /> setAttributes( { style: name, customStyle: value, } ) } /> setAttributes( { marker: center, isMarkerVisible: value, } ) } /> { isMarkerVisible && ( <> { setAttributes( { marker: { lat, lng }, } ); } } /> setAttributes( { addressAlignment: value, } ) } /> ) } setAttributes( { areZoomButtonsVisible: value, } ) } /> setAttributes( { isMapTypeButtonVisible: value, } ) } /> setAttributes( { isFullScreenButtonVisible: value, } ) } /> setAttributes( { isDraggable: value } ) } /> ); };