@wordpress/block-editor
Version:
42 lines (36 loc) • 1.08 kB
JavaScript
import { createElement } from "@wordpress/element";
/**
* WordPress dependencies
*/
import { __ } from '@wordpress/i18n';
import { CheckboxControl, VisuallyHidden } from '@wordpress/components';
const noop = () => {};
const LinkControlSettings = ({
value,
onChange = noop,
settings
}) => {
if (!settings || !settings.length) {
return null;
}
const handleSettingChange = setting => newValue => {
onChange({ ...value,
[setting.id]: newValue
});
};
const theSettings = settings.map(setting => createElement(CheckboxControl, {
__nextHasNoMarginBottom: true,
className: "block-editor-link-control__setting",
key: setting.id,
label: setting.title,
onChange: handleSettingChange(setting),
checked: value ? !!value[setting.id] : false
}));
return createElement("fieldset", {
className: "block-editor-link-control__settings"
}, createElement(VisuallyHidden, {
as: "legend"
}, __('Currently selected link settings')), theSettings);
};
export default LinkControlSettings;
//# sourceMappingURL=settings.js.map