@wordpress/components
Version:
UI components for WordPress.
65 lines (64 loc) • 2.67 kB
JavaScript
;
Object.defineProperties(exports, {
__esModule: { value: true },
[Symbol.toStringTag]: { value: "Module" }
});
// \0rolldown/runtime.js
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 __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
key = keys[i];
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
get: ((k) => from[k]).bind(null, key),
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
});
}
return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
value: mod,
enumerable: true
}) : target, mod));
let clsx = require("clsx");
clsx = __toESM(clsx);
let _wordpress_primitives = require("@wordpress/primitives");
let __utils_tsx = require("./utils.cjs");
let react_jsx_runtime = require("react/jsx-runtime");
// packages/components/src/alignment-matrix-control/icon.tsx
const BASE_SIZE = 24;
const GRID_CELL_SIZE = 7;
const GRID_PADDING = 3 / 2;
const DOT_SIZE = 2;
const DOT_SIZE_SELECTED = 4;
function AlignmentMatrixControlIcon({ className, disablePointerEvents = true, size, width, height, style = {}, value = "center", ...props }) {
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_wordpress_primitives.SVG, {
xmlns: "http://www.w3.org/2000/svg",
viewBox: `0 0 ${BASE_SIZE} ${BASE_SIZE}`,
width: size ?? width ?? BASE_SIZE,
height: size ?? height ?? BASE_SIZE,
role: "presentation",
className: (0, clsx.default)("component-alignment-matrix-control-icon", className),
style: {
pointerEvents: disablePointerEvents ? "none" : void 0,
...style
},
...props,
children: __utils_tsx.ALIGNMENTS.map((align, index) => {
const dotSize = (0, __utils_tsx.getAlignmentIndex)(value) === index ? DOT_SIZE_SELECTED : DOT_SIZE;
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_wordpress_primitives.Rect, {
x: GRID_PADDING + index % 3 * GRID_CELL_SIZE + (GRID_CELL_SIZE - dotSize) / 2,
y: GRID_PADDING + Math.floor(index / 3) * GRID_CELL_SIZE + (GRID_CELL_SIZE - dotSize) / 2,
width: dotSize,
height: dotSize,
fill: "currentColor"
}, align);
})
});
}
exports.default = AlignmentMatrixControlIcon;
//# sourceMappingURL=icon.cjs.map