@bettercms-ai/ui 0.8.3 → 0.10.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/{Video-Bl_XrTrM.d.ts → Video-lCL18gKf.d.ts} +1 -1
- package/dist/blocks.d.ts +7 -2
- package/dist/blocks.js +47 -12
- package/dist/blocks.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +47 -12
- package/dist/index.js.map +1 -1
- package/dist/registry.js +47 -12
- package/dist/registry.js.map +1 -1
- package/dist/renderer.js +47 -12
- package/dist/renderer.js.map +1 -1
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -32,7 +32,7 @@ function Heading({
|
|
|
32
32
|
import React from "react";
|
|
33
33
|
import { PortableText as PT } from "@portabletext/react";
|
|
34
34
|
|
|
35
|
-
//
|
|
35
|
+
// ../../../../bettercms-backend/packages/richtext/src/types.ts
|
|
36
36
|
var PT_TYPES = {
|
|
37
37
|
/** A generic embedded block: `{schemaKey, schemaLabel, fields}`, the successor to Lexical's BlockNode. */
|
|
38
38
|
block: "bcmsBlock",
|
|
@@ -77,8 +77,31 @@ var STORABLE_BLOCK_TYPES = /* @__PURE__ */ new Set([
|
|
|
77
77
|
PT_TYPES.file
|
|
78
78
|
]);
|
|
79
79
|
|
|
80
|
-
//
|
|
81
|
-
var STYLED_TAGS = [
|
|
80
|
+
// ../../../../bettercms-backend/packages/richtext/src/styled.ts
|
|
81
|
+
var STYLED_TAGS = [
|
|
82
|
+
"span",
|
|
83
|
+
"small",
|
|
84
|
+
"sup",
|
|
85
|
+
"sub",
|
|
86
|
+
"kbd",
|
|
87
|
+
"abbr",
|
|
88
|
+
"time",
|
|
89
|
+
"strong",
|
|
90
|
+
"b",
|
|
91
|
+
"em",
|
|
92
|
+
"i",
|
|
93
|
+
"u",
|
|
94
|
+
"s",
|
|
95
|
+
"mark",
|
|
96
|
+
"code",
|
|
97
|
+
"q",
|
|
98
|
+
"cite",
|
|
99
|
+
"dfn",
|
|
100
|
+
"var",
|
|
101
|
+
"samp",
|
|
102
|
+
"ins",
|
|
103
|
+
"del"
|
|
104
|
+
];
|
|
82
105
|
var TAG_SET = new Set(STYLED_TAGS);
|
|
83
106
|
var isStyledTag = (tag) => typeof tag === "string" && TAG_SET.has(tag);
|
|
84
107
|
var ATTR_NAMES = /* @__PURE__ */ new Set(["title", "datetime", "style", "aria-label"]);
|
|
@@ -137,7 +160,7 @@ function styledAttrEntries(attrs) {
|
|
|
137
160
|
return out;
|
|
138
161
|
}
|
|
139
162
|
|
|
140
|
-
//
|
|
163
|
+
// ../../../../bettercms-backend/packages/richtext/src/href.ts
|
|
141
164
|
var SAFE_HREF_SCHEMES = ["http:", "https:", "mailto:", "tel:"];
|
|
142
165
|
function safeHref(raw) {
|
|
143
166
|
const trimmed = raw.trim();
|
|
@@ -150,7 +173,7 @@ function safeHref(raw) {
|
|
|
150
173
|
}
|
|
151
174
|
}
|
|
152
175
|
|
|
153
|
-
//
|
|
176
|
+
// ../../../../bettercms-backend/packages/richtext/src/key.ts
|
|
154
177
|
var ALPHABET = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
|
|
155
178
|
var KEY_PATTERN = /^[A-Za-z0-9-]{1,32}$/;
|
|
156
179
|
var isValidKey = (k) => typeof k === "string" && KEY_PATTERN.test(k);
|
|
@@ -169,7 +192,7 @@ function deterministicKeys(prefix = "k") {
|
|
|
169
192
|
};
|
|
170
193
|
}
|
|
171
194
|
|
|
172
|
-
//
|
|
195
|
+
// ../../../../bettercms-backend/packages/richtext/src/table.ts
|
|
173
196
|
var isRecord = (v) => !!v && typeof v === "object" && !Array.isArray(v);
|
|
174
197
|
var isPortableTextTable = (n) => isRecord(n) && n._type === PT_TYPES.table && Array.isArray(n.rows);
|
|
175
198
|
var isBuiltInTableBlock = (n) => isRecord(n) && n._type === PT_TYPES.block && n.schemaKey === BUILTIN_TABLE_KEY;
|
|
@@ -280,7 +303,7 @@ function migrateTable(node, key = randomKey, read = asIs) {
|
|
|
280
303
|
};
|
|
281
304
|
}
|
|
282
305
|
|
|
283
|
-
//
|
|
306
|
+
// ../../../../bettercms-backend/packages/richtext/src/read.ts
|
|
284
307
|
var isRecord2 = (v) => !!v && typeof v === "object" && !Array.isArray(v);
|
|
285
308
|
function normalizePortableText(value, key = randomKey) {
|
|
286
309
|
if (!Array.isArray(value)) return [];
|
|
@@ -356,7 +379,7 @@ function Table({ value }) {
|
|
|
356
379
|
head < rows.length && /* @__PURE__ */ jsx2("tbody", { children: rendered.slice(head) })
|
|
357
380
|
] });
|
|
358
381
|
}
|
|
359
|
-
function buildComponents() {
|
|
382
|
+
function buildComponents(renderBlock) {
|
|
360
383
|
return {
|
|
361
384
|
types: {
|
|
362
385
|
[PT_TYPES.divider]: () => /* @__PURE__ */ jsx2("hr", {}),
|
|
@@ -370,9 +393,12 @@ function buildComponents() {
|
|
|
370
393
|
* A generic embedded block renders as a marker, not as content: its payload references
|
|
371
394
|
* something (a component, a media id) that has to be RESOLVED against the project, and
|
|
372
395
|
* this renderer has no project. A marker keeps the node visible and addressable rather
|
|
373
|
-
* than rendering nothing at all, which is how embedded content used to vanish.
|
|
396
|
+
* than rendering nothing at all, which is how embedded content used to vanish. A caller
|
|
397
|
+
* that CAN resolve it passes `renderBlock`.
|
|
374
398
|
*/
|
|
375
399
|
[PT_TYPES.block]: ({ value }) => {
|
|
400
|
+
const rendered = renderBlock?.(value);
|
|
401
|
+
if (rendered !== void 0) return /* @__PURE__ */ jsx2(Fragment, { children: rendered });
|
|
376
402
|
const v = value;
|
|
377
403
|
const key = typeof v.schemaKey === "string" ? v.schemaKey : "block";
|
|
378
404
|
return /* @__PURE__ */ jsx2("div", { className: "bcms-block", "data-bcms-schema-key": key });
|
|
@@ -452,9 +478,9 @@ function runsOf(blocks) {
|
|
|
452
478
|
}
|
|
453
479
|
return runs;
|
|
454
480
|
}
|
|
455
|
-
function PortableText({ value, bindingBase }) {
|
|
481
|
+
function PortableText({ value, bindingBase, renderBlock }) {
|
|
456
482
|
const blocks = React.useMemo(() => normalizePortableText(readValue(value)), [value]);
|
|
457
|
-
const components = React.useMemo(buildComponents, []);
|
|
483
|
+
const components = React.useMemo(() => buildComponents(renderBlock), [renderBlock]);
|
|
458
484
|
const listComponents = React.useMemo(() => {
|
|
459
485
|
if (!bindingBase) return null;
|
|
460
486
|
const keys = new Set(blocks.map((b) => b._key));
|
|
@@ -554,6 +580,8 @@ function Button({
|
|
|
554
580
|
text,
|
|
555
581
|
href,
|
|
556
582
|
variant = "primary",
|
|
583
|
+
size = "md",
|
|
584
|
+
fullWidth = false,
|
|
557
585
|
align = "left",
|
|
558
586
|
className = "",
|
|
559
587
|
"data-bcms-field": field,
|
|
@@ -569,13 +597,20 @@ function Button({
|
|
|
569
597
|
center: "justify-center",
|
|
570
598
|
right: "justify-end"
|
|
571
599
|
}[align];
|
|
600
|
+
const sizeStyles = {
|
|
601
|
+
sm: "px-3 py-1.5 text-xs",
|
|
602
|
+
md: "px-4 py-2",
|
|
603
|
+
lg: "px-6 py-3 text-base"
|
|
604
|
+
};
|
|
605
|
+
const sizeClass = size === "sm" || size === "lg" ? sizeStyles[size] : sizeStyles.md;
|
|
606
|
+
const fullClass = fullWidth === true ? "flex w-full justify-center" : "";
|
|
572
607
|
return /* @__PURE__ */ jsx5(
|
|
573
608
|
"a",
|
|
574
609
|
{
|
|
575
610
|
href,
|
|
576
611
|
"data-bcms-field": field,
|
|
577
612
|
"data-bcms-kind": kind,
|
|
578
|
-
className: cn(baseStyles, variantStyles[variant], alignClass,
|
|
613
|
+
className: cn(baseStyles, variantStyles[variant], alignClass, sizeClass, fullClass, className),
|
|
579
614
|
children: text
|
|
580
615
|
}
|
|
581
616
|
);
|