UNPKG

@wordpress/block-editor

Version:
70 lines (57 loc) 2.1 kB
"use strict"; var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); Object.defineProperty(exports, "__esModule", { value: true }); exports.default = InspectorControlsTabs; var _element = require("@wordpress/element"); var _components = require("@wordpress/components"); 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")); /** * WordPress dependencies */ /** * Internal dependencies */ function InspectorControlsTabs({ blockName, clientId, hasBlockStyles, tabs }) { // 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 (0, _element.createElement)(_components.TabPanel, { className: "block-editor-block-inspector__tabs", tabs: tabs, initialTabName: initialTabName, key: clientId }, tab => { if (tab.name === _utils.TAB_SETTINGS.name) { return (0, _element.createElement)(_settingsTab.default, { showAdvancedControls: !!blockName }); } if (tab.name === _utils.TAB_STYLES.name) { return (0, _element.createElement)(_stylesTab.default, { blockName: blockName, clientId: clientId, hasBlockStyles: hasBlockStyles }); } if (tab.name === _utils.TAB_LIST_VIEW.name) { return (0, _element.createElement)(_inspectorControls.default.Slot, { group: "list" }); } }); } //# sourceMappingURL=index.js.map