@dndbuilder.com/react
Version:
Drag and drop builder for React
60 lines (59 loc) • 3.07 kB
JavaScript
"use client";
import { jsx as e, jsxs as p } from "react/jsx-runtime";
import { BuilderConfiguration as b } from "../../config/builder.config.js";
import { getBlock as B } from "../../../../../store/selectors.js";
import { BlockType as y } from "../../types/block.js";
import { generateBlockProps as h } from "../../utils/block.js";
import { useAppSelector as g } from "../../hooks/use-app-selector.js";
import { ErrorBoundary as x } from "../../../../../node_modules/.pnpm/react-error-boundary@5.0.0_react@19.0.0/node_modules/react-error-boundary/dist/react-error-boundary.esm.js";
import { memo as c, Suspense as l } from "react";
import N from "./block-wrapper.js";
import { ErrorFallback as I } from "../shared/error-fallback.js";
import P from "./editor-block-wrapper.js";
import { LicenseManager as a } from "../../licensing/index.js";
import { FiLock as R } from "../../../../../node_modules/.pnpm/react-icons@5.5.0_react@19.0.0/node_modules/react-icons/fi/index.js";
const M = c((r) => {
const { block: o, index: n, isEditable: m, meta: t } = r;
return typeof o == "string" ? /* @__PURE__ */ e(u, { blockId: o, index: n, isEditable: m, meta: t }) : /* @__PURE__ */ e(d, { block: o, index: n, isEditable: m, meta: t });
}), d = c(({ block: r, index: o, isEditable: n, meta: m }) => {
const t = b.getBlock(r.type);
if (!t)
return null;
const { component: s } = t, i = h({ block: r, index: o, isEditable: n, meta: m }), f = a.isBlockPremium(r.type), k = a.canUseBlock(r.type);
return f && !k ? /* @__PURE__ */ e("div", { className: "rounded-sm border border-dashed border-amber-500 bg-amber-50 px-4 py-4 text-center text-amber-700", children: /* @__PURE__ */ p("div", { className: "flex flex-col items-center justify-center", children: [
/* @__PURE__ */ e(R, { size: 24, className: "mb-2" }),
/* @__PURE__ */ e("p", { className: "font-medium", children: "Premium Block" }),
/* @__PURE__ */ p("p", { className: "mt-1 text-sm", children: [
"This ",
r.type,
" block requires a premium license"
] }),
/* @__PURE__ */ e(
"button",
{
className: "mt-3 rounded bg-amber-500 px-3 py-1 text-white transition-colors hover:bg-amber-600",
onClick: () => window.open("https://your-upgrade-url.com", "_blank"),
children: "Upgrade to Premium"
}
)
] }) }) : r.type === y.CONTAINER ? /* @__PURE__ */ e(x, { fallbackRender: I, children: /* @__PURE__ */ e(l, { children: /* @__PURE__ */ e(s, { ...i }) }) }) : /* @__PURE__ */ e(l, { children: /* @__PURE__ */ e(
n ? P : N,
{
index: o,
blockId: r.id,
parentId: r.parentId,
blockType: r.type,
attributes: i.attributes,
children: /* @__PURE__ */ e(s, { ...i })
}
) });
}), u = c(({ blockId: r, index: o, isEditable: n, meta: m }) => {
const t = g(B(r));
return t ? /* @__PURE__ */ e(d, { block: t, index: o, isEditable: n, meta: m }) : null;
});
u.displayName = "RenderBlockFromId";
export {
M as EditorRenderBlock,
M as default
};
//# sourceMappingURL=editor-render-block.js.map