UNPKG

@wordpress/block-library

Version:
126 lines (125 loc) 4.15 kB
/** * WordPress dependencies */ import { ToggleControl, SelectControl, Disabled, __experimentalToolsPanel as ToolsPanel, __experimentalToolsPanelItem as ToolsPanelItem } from '@wordpress/components'; import { __ } from '@wordpress/i18n'; import { InspectorControls, useBlockProps } from '@wordpress/block-editor'; import ServerSideRender from '@wordpress/server-side-render'; /** * Internal dependencies */ import { useToolsPanelDropdownMenuProps } from '../utils/hooks'; import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime"; export default function ArchivesEdit({ attributes, setAttributes }) { const { showLabel, showPostCounts, displayAsDropdown, type } = attributes; const dropdownMenuProps = useToolsPanelDropdownMenuProps(); return /*#__PURE__*/_jsxs(_Fragment, { children: [/*#__PURE__*/_jsx(InspectorControls, { children: /*#__PURE__*/_jsxs(ToolsPanel, { label: __('Settings'), resetAll: () => { setAttributes({ displayAsDropdown: false, showLabel: true, showPostCounts: false, type: 'monthly' }); }, dropdownMenuProps: dropdownMenuProps, children: [/*#__PURE__*/_jsx(ToolsPanelItem, { label: __('Display as dropdown'), isShownByDefault: true, hasValue: () => displayAsDropdown, onDeselect: () => setAttributes({ displayAsDropdown: false }), children: /*#__PURE__*/_jsx(ToggleControl, { __nextHasNoMarginBottom: true, label: __('Display as dropdown'), checked: displayAsDropdown, onChange: () => setAttributes({ displayAsDropdown: !displayAsDropdown }) }) }), displayAsDropdown && /*#__PURE__*/_jsx(ToolsPanelItem, { label: __('Show label'), isShownByDefault: true, hasValue: () => !showLabel, onDeselect: () => setAttributes({ showLabel: true }), children: /*#__PURE__*/_jsx(ToggleControl, { __nextHasNoMarginBottom: true, label: __('Show label'), checked: showLabel, onChange: () => setAttributes({ showLabel: !showLabel }) }) }), /*#__PURE__*/_jsx(ToolsPanelItem, { label: __('Show post counts'), isShownByDefault: true, hasValue: () => showPostCounts, onDeselect: () => setAttributes({ showPostCounts: false }), children: /*#__PURE__*/_jsx(ToggleControl, { __nextHasNoMarginBottom: true, label: __('Show post counts'), checked: showPostCounts, onChange: () => setAttributes({ showPostCounts: !showPostCounts }) }) }), /*#__PURE__*/_jsx(ToolsPanelItem, { label: __('Group by'), isShownByDefault: true, hasValue: () => type !== 'monthly', onDeselect: () => setAttributes({ type: 'monthly' }), children: /*#__PURE__*/_jsx(SelectControl, { __next40pxDefaultSize: true, __nextHasNoMarginBottom: true, label: __('Group by'), options: [{ label: __('Year'), value: 'yearly' }, { label: __('Month'), value: 'monthly' }, { label: __('Week'), value: 'weekly' }, { label: __('Day'), value: 'daily' }], value: type, onChange: value => setAttributes({ type: value }) }) })] }) }), /*#__PURE__*/_jsx("div", { ...useBlockProps(), children: /*#__PURE__*/_jsx(Disabled, { children: /*#__PURE__*/_jsx(ServerSideRender, { block: "core/archives", skipBlockSupportAttributes: true, attributes: attributes }) }) })] }); } //# sourceMappingURL=edit.js.map