@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/registry.js
CHANGED
|
@@ -951,6 +951,8 @@ function buildComponents(renderBlock) {
|
|
|
951
951
|
[PT_TYPES.block]: ({ value }) => {
|
|
952
952
|
const rendered = renderBlock?.(value);
|
|
953
953
|
if (rendered !== void 0) return /* @__PURE__ */ jsx3(Fragment, { children: rendered });
|
|
954
|
+
const builtIn = calloutOrToggle(value);
|
|
955
|
+
if (builtIn) return builtIn;
|
|
954
956
|
const copy = detachedComponentCopy(value);
|
|
955
957
|
if (copy) {
|
|
956
958
|
return /* @__PURE__ */ jsx3("div", { className: "bcms-block bcms-block--component", "data-bcms-component-copy": copy.componentId, "data-bcms-instance": copy.id, children: /* @__PURE__ */ jsx3(BlocksRenderer, { blocks: copy.blocks }) });
|
|
@@ -1067,6 +1069,35 @@ function runsOf(blocks) {
|
|
|
1067
1069
|
}
|
|
1068
1070
|
return runs;
|
|
1069
1071
|
}
|
|
1072
|
+
function paragraphs(text) {
|
|
1073
|
+
return text.split(/\n\s*\n/).map((p) => p.trim()).filter(Boolean).map((p, i) => /* @__PURE__ */ jsx3("p", { children: p.split("\n").map((line, j) => j === 0 ? line : [/* @__PURE__ */ jsx3("br", {}, j), line]) }, i));
|
|
1074
|
+
}
|
|
1075
|
+
var CALLOUT_TONES = /* @__PURE__ */ new Set(["info", "tip", "warning"]);
|
|
1076
|
+
function calloutOrToggle(value) {
|
|
1077
|
+
const v = value ?? {};
|
|
1078
|
+
const f = v.fields && typeof v.fields === "object" ? v.fields : {};
|
|
1079
|
+
const text = (x) => typeof x === "string" ? x.trim() : "";
|
|
1080
|
+
if (v.schemaKey === "builtin:callout") {
|
|
1081
|
+
const tone = CALLOUT_TONES.has(text(f.tone)) ? text(f.tone) : "info";
|
|
1082
|
+
const title = text(f.title);
|
|
1083
|
+
const body = paragraphs(typeof f.message === "string" ? f.message : "");
|
|
1084
|
+
if (!title && !body.length) return /* @__PURE__ */ jsx3(Fragment, {});
|
|
1085
|
+
return /* @__PURE__ */ jsxs2("div", { className: `bcms-callout bcms-callout--${tone}`, "data-rt": "callout", "data-callout": tone, role: "note", children: [
|
|
1086
|
+
title ? /* @__PURE__ */ jsx3("p", { className: "bcms-callout__title", "data-title": "", children: title }) : null,
|
|
1087
|
+
/* @__PURE__ */ jsx3("div", { className: "bcms-callout__body", "data-body": "", children: body })
|
|
1088
|
+
] });
|
|
1089
|
+
}
|
|
1090
|
+
if (v.schemaKey === "builtin:toggle") {
|
|
1091
|
+
const title = text(f.title);
|
|
1092
|
+
const body = paragraphs(typeof f.body === "string" ? f.body : "");
|
|
1093
|
+
if (!title && !body.length) return /* @__PURE__ */ jsx3(Fragment, {});
|
|
1094
|
+
return /* @__PURE__ */ jsxs2("details", { className: "bcms-toggle", "data-rt": "toggle", children: [
|
|
1095
|
+
/* @__PURE__ */ jsx3("summary", { className: "bcms-toggle__title", children: title }),
|
|
1096
|
+
/* @__PURE__ */ jsx3("div", { className: "bcms-toggle__body", "data-body": "", children: body })
|
|
1097
|
+
] });
|
|
1098
|
+
}
|
|
1099
|
+
return null;
|
|
1100
|
+
}
|
|
1070
1101
|
function PortableText({ value, bindingBase, renderBlock }) {
|
|
1071
1102
|
const blocks = React2.useMemo(() => normalizePortableText(readValue(value)), [value]);
|
|
1072
1103
|
const components = React2.useMemo(() => buildComponents(renderBlock), [renderBlock]);
|