UNPKG

@wordpress/block-editor

Version:
102 lines (100 loc) 3.85 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-editor/src/components/duotone-control/index.js var duotone_control_exports = {}; __export(duotone_control_exports, { default: () => duotone_control_default }); module.exports = __toCommonJS(duotone_control_exports); var import_components = require("@wordpress/components"); var import_i18n = require("@wordpress/i18n"); var import_keycodes = require("@wordpress/keycodes"); var import_icons = require("@wordpress/icons"); var import_compose = require("@wordpress/compose"); var import_jsx_runtime = require("react/jsx-runtime"); function DuotoneControl({ id: idProp, colorPalette, duotonePalette, disableCustomColors, disableCustomDuotone, value, onChange }) { let toolbarIcon; if (value === "unset") { toolbarIcon = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_components.ColorIndicator, { className: "block-editor-duotone-control__unset-indicator" }); } else if (value) { toolbarIcon = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_components.DuotoneSwatch, { values: value }); } else { toolbarIcon = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_icons.Icon, { icon: import_icons.filter }); } const actionLabel = (0, import_i18n.__)("Apply duotone filter"); const id = (0, import_compose.useInstanceId)(DuotoneControl, "duotone-control", idProp); const descriptionId = `${id}__description`; return /* @__PURE__ */ (0, import_jsx_runtime.jsx)( import_components.Dropdown, { popoverProps: { className: "block-editor-duotone-control__popover", headerTitle: (0, import_i18n.__)("Duotone") }, renderToggle: ({ isOpen, onToggle }) => { const openOnArrowDown = (event) => { if (!isOpen && event.keyCode === import_keycodes.DOWN) { event.preventDefault(); onToggle(); } }; return /* @__PURE__ */ (0, import_jsx_runtime.jsx)( import_components.ToolbarButton, { showTooltip: true, onClick: onToggle, "aria-haspopup": "true", "aria-expanded": isOpen, onKeyDown: openOnArrowDown, label: actionLabel, icon: toolbarIcon } ); }, renderContent: () => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_components.MenuGroup, { label: (0, import_i18n.__)("Duotone"), children: [ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { children: (0, import_i18n.__)( "Create a two-tone color effect without losing your original image." ) }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)( import_components.DuotonePicker, { "aria-label": actionLabel, "aria-describedby": descriptionId, colorPalette, duotonePalette, disableCustomColors, disableCustomDuotone, value, onChange } ) ] }) } ); } var duotone_control_default = DuotoneControl; //# sourceMappingURL=index.js.map