import {
ToggleControl,
Spinner as WCSpinner,
__experimentalToolsPanel as ToolsPanel,
__experimentalToolsPanelItem as ToolsPanelItem,
} from '@wordpress/components';
import { __, sprintf } from '@wordpress/i18n';
import { InspectorControls, useBlockProps } from '@wordpress/block-editor';
import { useServerSideRender } from '@wordpress/server-side-render';
import { useDisabled } from '@wordpress/compose';
import { SelectControl } from '@wordpress/ui';
import type { BlockEditProps } from '@wordpress/blocks';
import { useToolsPanelDropdownMenuProps } from '../utils/hooks';
import HtmlRenderer from '../utils/html-renderer';
import type { ArchivesAttributes } from './types';
const ARCHIVE_TYPE_ITEMS = [
{ label: __( 'Year' ), value: 'yearly' },
{ label: __( 'Month' ), value: 'monthly' },
{ label: __( 'Week' ), value: 'weekly' },
{ label: __( 'Day' ), value: 'daily' },
];
export default function ArchivesEdit( {
attributes,
setAttributes,
name,
}: BlockEditProps< ArchivesAttributes > ) {
const { showLabel, showPostCounts, displayAsDropdown, type } = attributes;
const dropdownMenuProps = useToolsPanelDropdownMenuProps();
const { content, status, error } = useServerSideRender( {
attributes,
skipBlockSupportAttributes: true,
block: name,
} );
const disabledRef = useDisabled();
const blockProps = useBlockProps( { ref: disabledRef } );
return (
<>
{ sprintf( /* translators: %s: error message returned when rendering the block. */ __( 'Error: %s' ), error! ) }