UNPKG

@wordpress/block-library

Version:
133 lines (132 loc) 4.53 kB
import { Fragment, jsx, jsxs } from "react/jsx-runtime"; 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"; import { useToolsPanelDropdownMenuProps } from "../utils/hooks"; 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, 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 } ) }) }) ] }); } export { ArchivesEdit as default }; //# sourceMappingURL=edit.js.map