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