@wordpress/block-library
Version:
Block library for the WordPress editor.
75 lines • 2.52 kB
JavaScript
/**
* WordPress dependencies
*/
import { InspectorControls, useBlockProps } from '@wordpress/block-editor';
import { ToggleControl, __experimentalToolsPanel as ToolsPanel, __experimentalToolsPanelItem as ToolsPanelItem } from '@wordpress/components';
import { __ } from '@wordpress/i18n';
/**
* Internal dependencies
*/
import { useToolsPanelDropdownMenuProps } from '../utils/hooks';
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
export default function LoginOutEdit({
attributes,
setAttributes
}) {
const {
displayLoginAsForm,
redirectToCurrent
} = attributes;
const dropdownMenuProps = useToolsPanelDropdownMenuProps();
return /*#__PURE__*/_jsxs(_Fragment, {
children: [/*#__PURE__*/_jsx(InspectorControls, {
children: /*#__PURE__*/_jsxs(ToolsPanel, {
label: __('Settings'),
resetAll: () => {
setAttributes({
displayLoginAsForm: false,
redirectToCurrent: true
});
},
dropdownMenuProps: dropdownMenuProps,
children: [/*#__PURE__*/_jsx(ToolsPanelItem, {
label: __('Display login as form'),
isShownByDefault: true,
hasValue: () => displayLoginAsForm,
onDeselect: () => setAttributes({
displayLoginAsForm: false
}),
children: /*#__PURE__*/_jsx(ToggleControl, {
__nextHasNoMarginBottom: true,
label: __('Display login as form'),
checked: displayLoginAsForm,
onChange: () => setAttributes({
displayLoginAsForm: !displayLoginAsForm
})
})
}), /*#__PURE__*/_jsx(ToolsPanelItem, {
label: __('Redirect to current URL'),
isShownByDefault: true,
hasValue: () => !redirectToCurrent,
onDeselect: () => setAttributes({
redirectToCurrent: true
}),
children: /*#__PURE__*/_jsx(ToggleControl, {
__nextHasNoMarginBottom: true,
label: __('Redirect to current URL'),
checked: redirectToCurrent,
onChange: () => setAttributes({
redirectToCurrent: !redirectToCurrent
})
})
})]
})
}), /*#__PURE__*/_jsx("div", {
...useBlockProps({
className: 'logged-in'
}),
children: /*#__PURE__*/_jsx("a", {
href: "#login-pseudo-link",
children: __('Log out')
})
})]
});
}
//# sourceMappingURL=edit.js.map