UNPKG

@wordpress/global-styles-ui

Version:
131 lines (129 loc) • 5.47 kB
"use strict"; var __create = Object.create; var __defProp = Object.defineProperty; var __getOwnPropDesc = Object.getOwnPropertyDescriptor; var __getOwnPropNames = Object.getOwnPropertyNames; var __getProtoOf = Object.getPrototypeOf; 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 __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps( // If the importer is in node compatibility mode or this is not an ESM // file that has been converted to a CommonJS file using a Babel- // compatible transform (i.e. "__esModule" has not been set), then set // "default" to the CommonJS "module.exports" for node compatibility. isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod )); var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); // packages/global-styles-ui/src/presets/preset-group.tsx var preset_group_exports = {}; __export(preset_group_exports, { default: () => PresetGroup }); module.exports = __toCommonJS(preset_group_exports); var import_components = require("@wordpress/components"); var import_i18n = require("@wordpress/i18n"); var import_icons = require("@wordpress/icons"); var import_element = require("@wordpress/element"); var import_ui = require("@wordpress/ui"); var import_subtitle = require("../subtitle.cjs"); var import_navigation_button = require("../navigation-button.cjs"); var import_lock_unlock = require("../lock-unlock.cjs"); var import_confirm_reset_dialog = __toESM(require("./dialogs/confirm-reset-dialog.cjs")); var import_jsx_runtime = require("react/jsx-runtime"); var { Menu } = (0, import_lock_unlock.unlock)(import_components.privateApis); function PresetGroup({ label, items, getEditPath, addLabel, onAdd, menuAction }) { const [isResetOpen, setIsResetOpen] = (0, import_element.useState)(false); const showMenu = !!menuAction && items.length > 0; return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_ui.Stack, { direction: "column", gap: "sm", children: [ menuAction && isResetOpen && /* @__PURE__ */ (0, import_jsx_runtime.jsx)( import_confirm_reset_dialog.default, { text: menuAction.confirmText, confirmButtonText: menuAction.confirmButtonText, isOpen: isResetOpen, toggleOpen: () => setIsResetOpen(false), onConfirm: menuAction.onConfirm } ), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_ui.Stack, { justify: "space-between", align: "flex-start", children: [ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_subtitle.Subtitle, { level: 3, children: label }), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_components.FlexItem, { children: [ addLabel && onAdd && /* @__PURE__ */ (0, import_jsx_runtime.jsx)( import_components.Button, { size: "small", icon: import_icons.plus, label: addLabel, onClick: onAdd } ), showMenu && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Menu, { children: [ /* @__PURE__ */ (0, import_jsx_runtime.jsx)( Menu.TriggerButton, { render: /* @__PURE__ */ (0, import_jsx_runtime.jsx)( import_components.Button, { size: "small", icon: import_icons.moreVertical, label: menuAction.optionsLabel } ) } ), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Menu.Popover, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)( Menu.Item, { onClick: () => setIsResetOpen(true), children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Menu.ItemLabel, { children: menuAction.label }) } ) }) ] }) ] }) ] }), items.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_components.__experimentalItemGroup, { isBordered: true, isSeparated: true, children: items.map((item) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)( import_navigation_button.NavigationButtonAsItem, { path: getEditPath(item.slug), children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)( import_ui.Stack, { direction: "row", justify: "space-between", align: "center", children: [ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_components.FlexItem, { children: item.name }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)( import_icons.Icon, { icon: (0, import_i18n.isRTL)() ? import_icons.chevronLeft : import_icons.chevronRight } ) ] } ) }, item.slug )) }) ] }); } //# sourceMappingURL=preset-group.cjs.map