UNPKG

@bedrock-layout/frame

Version:
30 lines (29 loc) 824 B
import { getPaddingAttributes as m } from "@bedrock-layout/spacing-constants"; import { forwardRefWithAs as d } from "@bedrock-layout/type-utils"; import p from "react"; function i(t) { return (typeof t == "string" ? t.split(/[/:]/) : t).map((r) => String(r).trim()).join("/"); } function y(t) { if (Array.isArray(t) && t.length === 2 && t.every(Number.isFinite) || typeof t == "string" && /^\d{1,1000} ?[/:] ?\d{1,1000}$/.test(t)) return i(t); } const b = d(function({ as: e = "div", ratio: r, style: n = {}, position: o, padding: a, ...s }, g) { const c = y(r), f = m(a).join(" "); return /* @__PURE__ */ p.createElement( e, { "data-br-frame": f, ref: g, style: { "--ratio": c, "--position": o, ...n }, ...s } ); }); export { b as Frame };