UNPKG

@wordpress/block-library

Version:
180 lines (178 loc) 5.39 kB
"use strict"; var __defProp = Object.defineProperty; var __getOwnPropDesc = Object.getOwnPropertyDescriptor; var __getOwnPropNames = Object.getOwnPropertyNames; var __hasOwnProp = Object.prototype.hasOwnProperty; var __export = (target, all) => { for (var name in all) __defProp(target, name, { get: all[name], enumerable: true }); }; var __copyProps = (to, from, except, desc) => { if (from && typeof from === "object" || typeof from === "function") { for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); } return to; }; var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); // packages/block-library/src/tabs/deprecated.js var deprecated_exports = {}; __export(deprecated_exports, { default: () => deprecated_default }); module.exports = __toCommonJS(deprecated_exports); var import_block_editor = require("@wordpress/block-editor"); var import_blocks = require("@wordpress/blocks"); var import_jsx_runtime = require("react/jsx-runtime"); var v1Attributes = { tabsId: { type: "string", default: "" }, orientation: { type: "string", default: "horizontal", enum: ["horizontal", "vertical"] }, activeTabIndex: { type: "number", default: 0 }, tabInactiveColor: { type: "string" }, customTabInactiveColor: { type: "string" }, tabHoverColor: { type: "string" }, customTabHoverColor: { type: "string" }, tabActiveColor: { type: "string" }, customTabActiveColor: { type: "string" }, tabTextColor: { type: "string" }, customTabTextColor: { type: "string" }, tabActiveTextColor: { type: "string" }, customTabActiveTextColor: { type: "string" }, tabHoverTextColor: { type: "string" }, customTabHoverTextColor: { type: "string" } }; function v1Save({ attributes }) { const blockProps = import_block_editor.useBlockProps.save(); const innerBlocksProps = import_block_editor.useInnerBlocksProps.save({}); const title = attributes?.metadata?.name || "Tab Contents"; return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { ...blockProps, children: [ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("h3", { className: "tabs__title", children: title }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("ul", { className: "tabs__list" }), innerBlocksProps.children ] }); } function v1Migrate(attributes, innerBlocks) { const tabsMenuAttributes = { // Map inactive colors to core background/text supports backgroundColor: attributes.tabInactiveColor, textColor: attributes.tabTextColor, // Map custom inactive colors style: { color: { background: attributes.customTabInactiveColor, text: attributes.customTabTextColor } }, // Active colors activeBackgroundColor: attributes.tabActiveColor, customActiveBackgroundColor: attributes.customTabActiveColor, activeTextColor: attributes.tabActiveTextColor, customActiveTextColor: attributes.customTabActiveTextColor, // Hover colors hoverBackgroundColor: attributes.tabHoverColor, customHoverBackgroundColor: attributes.customTabHoverColor, hoverTextColor: attributes.tabHoverTextColor, customHoverTextColor: attributes.customTabHoverTextColor }; if (tabsMenuAttributes.style?.color) { if (!tabsMenuAttributes.style.color.background) { delete tabsMenuAttributes.style.color.background; } if (!tabsMenuAttributes.style.color.text) { delete tabsMenuAttributes.style.color.text; } if (Object.keys(tabsMenuAttributes.style.color).length === 0) { delete tabsMenuAttributes.style.color; } if (Object.keys(tabsMenuAttributes.style).length === 0) { delete tabsMenuAttributes.style; } } Object.keys(tabsMenuAttributes).forEach((key) => { if (tabsMenuAttributes[key] === void 0) { delete tabsMenuAttributes[key]; } }); const tabsMenuBlock = (0, import_blocks.createBlock)("core/tabs-menu", tabsMenuAttributes); const tabPanelsBlock = (0, import_blocks.createBlock)("core/tab-panels", {}, innerBlocks); const newAttributes = { tabsId: attributes.tabsId, orientation: attributes.orientation, activeTabIndex: attributes.activeTabIndex, metadata: attributes.metadata }; return [newAttributes, [tabsMenuBlock, tabPanelsBlock]]; } function v1IsEligible(attributes, innerBlocks) { return innerBlocks.some((block) => block.name === "core/tab"); } var deprecated = [ { attributes: v1Attributes, supports: { align: true, color: { text: false, background: false }, html: false, interactivity: true, spacing: { blockGap: ["horizontal", "vertical"], margin: true, padding: false }, typography: { fontSize: true, __experimentalFontFamily: true }, __experimentalBorder: { radius: true, __experimentalSkipSerialization: true, __experimentalDefaultControls: { radius: true } } }, isEligible: v1IsEligible, migrate: v1Migrate, save: v1Save } ]; var deprecated_default = deprecated; //# sourceMappingURL=deprecated.cjs.map