@dndbuilder.com/react
Version:
Drag and drop builder for React
58 lines (57 loc) • 1.63 kB
JavaScript
import { classNames as S } from "../../../../utils.js";
const I = ({
block: e,
index: i,
isEditable: t = !1,
meta: a
}) => {
var c, r, u, o, l, h, v, m, f;
const d = e.id, n = {
className: S(
(c = e.advancedSettings) == null ? void 0 : c.cssClasses,
((r = e.advancedSettings) == null ? void 0 : r.hideOnDesktop) && "hide-on-desktop",
((u = e.advancedSettings) == null ? void 0 : u.hideOnTablet) && "hide-on-tablet",
((o = e.advancedSettings) == null ? void 0 : o.hideOnMobile) && "hide-on-mobile"
),
"data-block-id": `${d}`,
"data-block-type": `${e.type}`
};
return (l = e.advancedSettings) != null && l.cssId && (n.id = (h = e.advancedSettings) == null ? void 0 : h.cssId), (v = e.advancedSettings) != null && v.customAttributes && ((f = (m = e.advancedSettings) == null ? void 0 : m.customAttributes) == null || f.forEach((s) => {
var g;
if (!(!s.value || !s.name)) {
if (s.name === "class") {
n.className = S(
d,
(g = e.advancedSettings) == null ? void 0 : g.cssClasses,
s.value
);
return;
}
if (s.name === "id") {
n.id = s.value;
return;
}
n[s.name] = s.value;
}
})), {
...e,
index: i,
attributes: n,
isEditable: t,
meta: a
};
}, p = (e, i) => {
const t = {}, a = i[e];
return a && (t[e] = {
...a,
children: []
}, a.children && a.children.forEach((d) => {
const n = p(d, i);
t[e].children.push(n[d]);
})), t;
};
export {
I as generateBlockProps,
p as generateBlockTree
};
//# sourceMappingURL=block.js.map