@bettercms-ai/ui 0.19.0 → 0.20.1
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 +2 -2
package/dist/index.js
CHANGED
|
@@ -1384,6 +1384,8 @@ function buildComponents(renderBlock) {
|
|
|
1384
1384
|
[PT_TYPES.block]: ({ value }) => {
|
|
1385
1385
|
const rendered = renderBlock?.(value);
|
|
1386
1386
|
if (rendered !== void 0) return /* @__PURE__ */ jsx14(Fragment2, { children: rendered });
|
|
1387
|
+
const builtIn = calloutOrToggle(value);
|
|
1388
|
+
if (builtIn) return builtIn;
|
|
1387
1389
|
const copy = detachedComponentCopy(value);
|
|
1388
1390
|
if (copy) {
|
|
1389
1391
|
return /* @__PURE__ */ jsx14("div", { className: "bcms-block bcms-block--component", "data-bcms-component-copy": copy.componentId, "data-bcms-instance": copy.id, children: /* @__PURE__ */ jsx14(BlocksRenderer, { blocks: copy.blocks }) });
|
|
@@ -1500,6 +1502,35 @@ function runsOf(blocks) {
|
|
|
1500
1502
|
}
|
|
1501
1503
|
return runs;
|
|
1502
1504
|
}
|
|
1505
|
+
function paragraphs(text) {
|
|
1506
|
+
return text.split(/\n\s*\n/).map((p) => p.trim()).filter(Boolean).map((p, i) => /* @__PURE__ */ jsx14("p", { children: p.split("\n").map((line, j) => j === 0 ? line : [/* @__PURE__ */ jsx14("br", {}, j), line]) }, i));
|
|
1507
|
+
}
|
|
1508
|
+
var CALLOUT_TONES = /* @__PURE__ */ new Set(["info", "tip", "warning"]);
|
|
1509
|
+
function calloutOrToggle(value) {
|
|
1510
|
+
const v = value ?? {};
|
|
1511
|
+
const f = v.fields && typeof v.fields === "object" ? v.fields : {};
|
|
1512
|
+
const text = (x) => typeof x === "string" ? x.trim() : "";
|
|
1513
|
+
if (v.schemaKey === "builtin:callout") {
|
|
1514
|
+
const tone = CALLOUT_TONES.has(text(f.tone)) ? text(f.tone) : "info";
|
|
1515
|
+
const title = text(f.title);
|
|
1516
|
+
const body = paragraphs(typeof f.message === "string" ? f.message : "");
|
|
1517
|
+
if (!title && !body.length) return /* @__PURE__ */ jsx14(Fragment2, {});
|
|
1518
|
+
return /* @__PURE__ */ jsxs11("div", { className: `bcms-callout bcms-callout--${tone}`, "data-rt": "callout", "data-callout": tone, role: "note", children: [
|
|
1519
|
+
title ? /* @__PURE__ */ jsx14("p", { className: "bcms-callout__title", "data-title": "", children: title }) : null,
|
|
1520
|
+
/* @__PURE__ */ jsx14("div", { className: "bcms-callout__body", "data-body": "", children: body })
|
|
1521
|
+
] });
|
|
1522
|
+
}
|
|
1523
|
+
if (v.schemaKey === "builtin:toggle") {
|
|
1524
|
+
const title = text(f.title);
|
|
1525
|
+
const body = paragraphs(typeof f.body === "string" ? f.body : "");
|
|
1526
|
+
if (!title && !body.length) return /* @__PURE__ */ jsx14(Fragment2, {});
|
|
1527
|
+
return /* @__PURE__ */ jsxs11("details", { className: "bcms-toggle", "data-rt": "toggle", children: [
|
|
1528
|
+
/* @__PURE__ */ jsx14("summary", { className: "bcms-toggle__title", children: title }),
|
|
1529
|
+
/* @__PURE__ */ jsx14("div", { className: "bcms-toggle__body", "data-body": "", children: body })
|
|
1530
|
+
] });
|
|
1531
|
+
}
|
|
1532
|
+
return null;
|
|
1533
|
+
}
|
|
1503
1534
|
function PortableText({ value, bindingBase, renderBlock }) {
|
|
1504
1535
|
const blocks = React6.useMemo(() => normalizePortableText(readValue(value)), [value]);
|
|
1505
1536
|
const components = React6.useMemo(() => buildComponents(renderBlock), [renderBlock]);
|