@bettercms-ai/ui 0.19.0 → 0.20.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/blocks.js +31 -0
- package/dist/blocks.js.map +1 -1
- package/dist/index.js +31 -0
- package/dist/index.js.map +1 -1
- package/dist/registry.js +31 -0
- package/dist/registry.js.map +1 -1
- package/dist/renderer.js +31 -0
- package/dist/renderer.js.map +1 -1
- package/package.json +1 -1
package/dist/renderer.js
CHANGED
|
@@ -835,6 +835,8 @@ function buildComponents(renderBlock) {
|
|
|
835
835
|
[PT_TYPES.block]: ({ value }) => {
|
|
836
836
|
const rendered = renderBlock?.(value);
|
|
837
837
|
if (rendered !== void 0) return /* @__PURE__ */ jsx2(Fragment, { children: rendered });
|
|
838
|
+
const builtIn = calloutOrToggle(value);
|
|
839
|
+
if (builtIn) return builtIn;
|
|
838
840
|
const copy = detachedComponentCopy(value);
|
|
839
841
|
if (copy) {
|
|
840
842
|
return /* @__PURE__ */ jsx2("div", { className: "bcms-block bcms-block--component", "data-bcms-component-copy": copy.componentId, "data-bcms-instance": copy.id, children: /* @__PURE__ */ jsx2(BlocksRenderer, { blocks: copy.blocks }) });
|
|
@@ -951,6 +953,35 @@ function runsOf(blocks) {
|
|
|
951
953
|
}
|
|
952
954
|
return runs;
|
|
953
955
|
}
|
|
956
|
+
function paragraphs(text) {
|
|
957
|
+
return text.split(/\n\s*\n/).map((p) => p.trim()).filter(Boolean).map((p, i) => /* @__PURE__ */ jsx2("p", { children: p.split("\n").map((line, j) => j === 0 ? line : [/* @__PURE__ */ jsx2("br", {}, j), line]) }, i));
|
|
958
|
+
}
|
|
959
|
+
var CALLOUT_TONES = /* @__PURE__ */ new Set(["info", "tip", "warning"]);
|
|
960
|
+
function calloutOrToggle(value) {
|
|
961
|
+
const v = value ?? {};
|
|
962
|
+
const f = v.fields && typeof v.fields === "object" ? v.fields : {};
|
|
963
|
+
const text = (x) => typeof x === "string" ? x.trim() : "";
|
|
964
|
+
if (v.schemaKey === "builtin:callout") {
|
|
965
|
+
const tone = CALLOUT_TONES.has(text(f.tone)) ? text(f.tone) : "info";
|
|
966
|
+
const title = text(f.title);
|
|
967
|
+
const body = paragraphs(typeof f.message === "string" ? f.message : "");
|
|
968
|
+
if (!title && !body.length) return /* @__PURE__ */ jsx2(Fragment, {});
|
|
969
|
+
return /* @__PURE__ */ jsxs("div", { className: `bcms-callout bcms-callout--${tone}`, "data-rt": "callout", "data-callout": tone, role: "note", children: [
|
|
970
|
+
title ? /* @__PURE__ */ jsx2("p", { className: "bcms-callout__title", "data-title": "", children: title }) : null,
|
|
971
|
+
/* @__PURE__ */ jsx2("div", { className: "bcms-callout__body", "data-body": "", children: body })
|
|
972
|
+
] });
|
|
973
|
+
}
|
|
974
|
+
if (v.schemaKey === "builtin:toggle") {
|
|
975
|
+
const title = text(f.title);
|
|
976
|
+
const body = paragraphs(typeof f.body === "string" ? f.body : "");
|
|
977
|
+
if (!title && !body.length) return /* @__PURE__ */ jsx2(Fragment, {});
|
|
978
|
+
return /* @__PURE__ */ jsxs("details", { className: "bcms-toggle", "data-rt": "toggle", children: [
|
|
979
|
+
/* @__PURE__ */ jsx2("summary", { className: "bcms-toggle__title", children: title }),
|
|
980
|
+
/* @__PURE__ */ jsx2("div", { className: "bcms-toggle__body", "data-body": "", children: body })
|
|
981
|
+
] });
|
|
982
|
+
}
|
|
983
|
+
return null;
|
|
984
|
+
}
|
|
954
985
|
function PortableText({ value, bindingBase, renderBlock }) {
|
|
955
986
|
const blocks = React.useMemo(() => normalizePortableText(readValue(value)), [value]);
|
|
956
987
|
const components = React.useMemo(() => buildComponents(renderBlock), [renderBlock]);
|