UNPKG

@wordpress/block-library

Version:
69 lines (68 loc) 1.98 kB
// packages/block-library/src/tab/controls.js import { InspectorControls, store as blockEditorStore } from "@wordpress/block-editor"; import { PanelBody, TextControl, ToggleControl } from "@wordpress/components"; import { __ } from "@wordpress/i18n"; import { useDispatch } from "@wordpress/data"; import { decodeEntities } from "@wordpress/html-entities"; import AddTabToolbarControl from "./add-tab-toolbar-control"; import slugFromLabel from "./slug-from-label"; import { Fragment, jsx, jsxs } from "react/jsx-runtime"; function Controls({ attributes, setAttributes, tabsClientId, blockIndex, isDefaultTab }) { const { label } = attributes; const { updateBlockAttributes } = useDispatch(blockEditorStore); return /* @__PURE__ */ jsxs(Fragment, { children: [ /* @__PURE__ */ jsx( AddTabToolbarControl, { tabsClientId, attributes } ), /* @__PURE__ */ jsx(InspectorControls, { children: /* @__PURE__ */ jsxs(PanelBody, { title: __("Tab Settings"), children: [ /* @__PURE__ */ jsx( TextControl, { label: __("Tab Label"), value: decodeEntities(label), onChange: (value) => { setAttributes({ label: value, anchor: slugFromLabel(value, blockIndex) }); }, __next40pxDefaultSize: true, __nextHasNoMarginBottom: true } ), /* @__PURE__ */ jsx( ToggleControl, { label: __("Default Tab"), checked: isDefaultTab, onChange: (value) => { updateBlockAttributes(tabsClientId, { activeTabIndex: value ? blockIndex : 0 }); }, help: __( "If toggled, this tab will be selected when the page loads." ), __nextHasNoMarginBottom: true } ) ] }) }) ] }); } export { Controls as default }; //# sourceMappingURL=controls.js.map