UNPKG

@wordpress/block-library

Version:
134 lines (131 loc) 4.78 kB
"use strict"; var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); Object.defineProperty(exports, "__esModule", { value: true }); exports.default = ArchivesEdit; var _components = require("@wordpress/components"); var _i18n = require("@wordpress/i18n"); var _blockEditor = require("@wordpress/block-editor"); var _serverSideRender = _interopRequireDefault(require("@wordpress/server-side-render")); var _hooks = require("../utils/hooks"); var _jsxRuntime = require("react/jsx-runtime"); /** * WordPress dependencies */ /** * Internal dependencies */ function ArchivesEdit({ attributes, setAttributes }) { const { showLabel, showPostCounts, displayAsDropdown, type } = attributes; const dropdownMenuProps = (0, _hooks.useToolsPanelDropdownMenuProps)(); return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, { children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_blockEditor.InspectorControls, { children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_components.__experimentalToolsPanel, { label: (0, _i18n.__)('Settings'), resetAll: () => { setAttributes({ displayAsDropdown: false, showLabel: true, showPostCounts: false, type: 'monthly' }); }, dropdownMenuProps: dropdownMenuProps, children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_components.__experimentalToolsPanelItem, { label: (0, _i18n.__)('Display as dropdown'), isShownByDefault: true, hasValue: () => displayAsDropdown, onDeselect: () => setAttributes({ displayAsDropdown: false }), children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.ToggleControl, { __nextHasNoMarginBottom: true, label: (0, _i18n.__)('Display as dropdown'), checked: displayAsDropdown, onChange: () => setAttributes({ displayAsDropdown: !displayAsDropdown }) }) }), displayAsDropdown && /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.__experimentalToolsPanelItem, { label: (0, _i18n.__)('Show label'), isShownByDefault: true, hasValue: () => !showLabel, onDeselect: () => setAttributes({ showLabel: true }), children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.ToggleControl, { __nextHasNoMarginBottom: true, label: (0, _i18n.__)('Show label'), checked: showLabel, onChange: () => setAttributes({ showLabel: !showLabel }) }) }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.__experimentalToolsPanelItem, { label: (0, _i18n.__)('Show post counts'), isShownByDefault: true, hasValue: () => showPostCounts, onDeselect: () => setAttributes({ showPostCounts: false }), children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.ToggleControl, { __nextHasNoMarginBottom: true, label: (0, _i18n.__)('Show post counts'), checked: showPostCounts, onChange: () => setAttributes({ showPostCounts: !showPostCounts }) }) }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.__experimentalToolsPanelItem, { label: (0, _i18n.__)('Group by'), isShownByDefault: true, hasValue: () => type !== 'monthly', onDeselect: () => setAttributes({ type: 'monthly' }), children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.SelectControl, { __next40pxDefaultSize: true, __nextHasNoMarginBottom: true, label: (0, _i18n.__)('Group by'), options: [{ label: (0, _i18n.__)('Year'), value: 'yearly' }, { label: (0, _i18n.__)('Month'), value: 'monthly' }, { label: (0, _i18n.__)('Week'), value: 'weekly' }, { label: (0, _i18n.__)('Day'), value: 'daily' }], value: type, onChange: value => setAttributes({ type: value }) }) })] }) }), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", { ...(0, _blockEditor.useBlockProps)(), children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Disabled, { children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_serverSideRender.default, { block: "core/archives", skipBlockSupportAttributes: true, attributes: attributes }) }) })] }); } //# sourceMappingURL=edit.js.map