@wordpress/block-editor
Version:
87 lines (83 loc) • 3.35 kB
JavaScript
;
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = InspectorControlsTabs;
var _components = require("@wordpress/components");
var _preferences = require("@wordpress/preferences");
var _data = require("@wordpress/data");
var _utils = require("./utils");
var _settingsTab = _interopRequireDefault(require("./settings-tab"));
var _stylesTab = _interopRequireDefault(require("./styles-tab"));
var _inspectorControls = _interopRequireDefault(require("../inspector-controls"));
var _useIsListViewTabDisabled = _interopRequireDefault(require("./use-is-list-view-tab-disabled"));
var _lockUnlock = require("../../lock-unlock");
var _jsxRuntime = require("react/jsx-runtime");
/**
* WordPress dependencies
*/
/**
* Internal dependencies
*/
const {
Tabs
} = (0, _lockUnlock.unlock)(_components.privateApis);
function InspectorControlsTabs({
blockName,
clientId,
hasBlockStyles,
tabs
}) {
const showIconLabels = (0, _data.useSelect)(select => {
return select(_preferences.store).get('core', 'showIconLabels');
}, []);
// The tabs panel will mount before fills are rendered to the list view
// slot. This means the list view tab isn't initially included in the
// available tabs so the panel defaults selection to the settings tab
// which at the time is the first tab. This check allows blocks known to
// include the list view tab to set it as the tab selected by default.
const initialTabName = !(0, _useIsListViewTabDisabled.default)(blockName) ? _utils.TAB_LIST_VIEW.name : undefined;
return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
className: "block-editor-block-inspector__tabs",
children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(Tabs, {
defaultTabId: initialTabName,
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(Tabs.TabList, {
children: tabs.map(tab => showIconLabels ? /*#__PURE__*/(0, _jsxRuntime.jsx)(Tabs.Tab, {
tabId: tab.name,
children: tab.title
}, tab.name) : /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Tooltip, {
text: tab.title,
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(Tabs.Tab, {
tabId: tab.name,
"aria-label": tab.title,
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Icon, {
icon: tab.icon
})
})
}, tab.name))
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(Tabs.TabPanel, {
tabId: _utils.TAB_SETTINGS.name,
focusable: false,
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_settingsTab.default, {
showAdvancedControls: !!blockName
})
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(Tabs.TabPanel, {
tabId: _utils.TAB_STYLES.name,
focusable: false,
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_stylesTab.default, {
blockName: blockName,
clientId: clientId,
hasBlockStyles: hasBlockStyles
})
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(Tabs.TabPanel, {
tabId: _utils.TAB_LIST_VIEW.name,
focusable: false,
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_inspectorControls.default.Slot, {
group: "list"
})
})]
}, clientId)
});
}
//# sourceMappingURL=index.js.map