@wordpress/block-library
Version:
Block library for the WordPress editor.
83 lines (80 loc) • 2.81 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = LoginOutEdit;
var _blockEditor = require("@wordpress/block-editor");
var _components = require("@wordpress/components");
var _i18n = require("@wordpress/i18n");
var _hooks = require("../utils/hooks");
var _jsxRuntime = require("react/jsx-runtime");
/**
* WordPress dependencies
*/
/**
* Internal dependencies
*/
function LoginOutEdit({
attributes,
setAttributes
}) {
const {
displayLoginAsForm,
redirectToCurrent
} = 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({
displayLoginAsForm: false,
redirectToCurrent: true
});
},
dropdownMenuProps: dropdownMenuProps,
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_components.__experimentalToolsPanelItem, {
label: (0, _i18n.__)('Display login as form'),
isShownByDefault: true,
hasValue: () => displayLoginAsForm,
onDeselect: () => setAttributes({
displayLoginAsForm: false
}),
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.ToggleControl, {
__nextHasNoMarginBottom: true,
label: (0, _i18n.__)('Display login as form'),
checked: displayLoginAsForm,
onChange: () => setAttributes({
displayLoginAsForm: !displayLoginAsForm
})
})
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.__experimentalToolsPanelItem, {
label: (0, _i18n.__)('Redirect to current URL'),
isShownByDefault: true,
hasValue: () => !redirectToCurrent,
onDeselect: () => setAttributes({
redirectToCurrent: true
}),
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.ToggleControl, {
__nextHasNoMarginBottom: true,
label: (0, _i18n.__)('Redirect to current URL'),
checked: redirectToCurrent,
onChange: () => setAttributes({
redirectToCurrent: !redirectToCurrent
})
})
})]
})
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
...(0, _blockEditor.useBlockProps)({
className: 'logged-in'
}),
children: /*#__PURE__*/(0, _jsxRuntime.jsx)("a", {
href: "#login-pseudo-link",
children: (0, _i18n.__)('Log out')
})
})]
});
}
//# sourceMappingURL=edit.js.map