| 1 |
/** |
| 2 |
* WordPress dependencies. |
| 3 |
*/ |
| 4 |
import { InspectorControls, useBlockProps } from '@wordpress/block-editor'; |
| 5 |
import { Disabled, PanelBody, ToggleControl } from '@wordpress/components'; |
| 6 |
import { __ } from '@wordpress/i18n'; |
| 7 |
import ServerSideRender from '@wordpress/server-side-render'; |
| 8 |
|
| 9 |
/** |
| 10 |
* Internal dependencies. |
| 11 |
*/ |
| 12 |
import EmptyResponsePlaceholder from '../common/components/empty-response-placeholder'; |
| 13 |
import LoadingResponsePlaceholder from '../common/components/loading-response-placeholder'; |
| 14 |
|
| 15 |
const FacetDate = (props) => { |
| 16 |
const blockProps = useBlockProps(); |
| 17 |
const { attributes, name, setAttributes } = props; |
| 18 |
const { displayCustomDate } = attributes; |
| 19 |
|
| 20 |
return ( |
| 21 |
<> |
| 22 |
<InspectorControls> |
| 23 |
<PanelBody title={__('Settings', 'elasticpress')}> |
| 24 |
<ToggleControl |
| 25 |
label={__('Display custom date option', 'elasticpress')} |
| 26 |
checked={displayCustomDate} |
| 27 |
onChange={(displayCustomDate) => setAttributes({ displayCustomDate })} |
| 28 |
/> |
| 29 |
</PanelBody> |
| 30 |
</InspectorControls> |
| 31 |
|
| 32 |
<div {...blockProps}> |
| 33 |
<Disabled> |
| 34 |
<ServerSideRender |
| 35 |
attributes={{ |
| 36 |
...attributes, |
| 37 |
isPreview: true, |
| 38 |
}} |
| 39 |
block={name} |
| 40 |
EmptyResponsePlaceholder={EmptyResponsePlaceholder} |
| 41 |
LoadingResponsePlaceholder={LoadingResponsePlaceholder} |
| 42 |
skipBlockSupportAttributes |
| 43 |
/> |
| 44 |
</Disabled> |
| 45 |
</div> |
| 46 |
</> |
| 47 |
); |
| 48 |
}; |
| 49 |
|
| 50 |
export default FacetDate; |
| 51 |
|