@bettercms-ai/ui 0.14.0 → 0.15.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/{Video-c2HnnOCp.d.ts → Video-D6jrdR2Z.d.ts} +1 -1
- package/dist/blocks.d.ts +1 -1
- package/dist/blocks.js +6 -3
- package/dist/blocks.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +37 -20
- package/dist/index.js.map +1 -1
- package/dist/registry.js +6 -3
- package/dist/registry.js.map +1 -1
- package/dist/renderer.d.ts +10 -2
- package/dist/renderer.js +37 -20
- package/dist/renderer.js.map +1 -1
- package/dist/resolve.d.ts +5 -3
- package/dist/resolve.js +51 -10
- package/dist/resolve.js.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -577,7 +577,7 @@ function Image({
|
|
|
577
577
|
}
|
|
578
578
|
|
|
579
579
|
// src/blocks/Button.tsx
|
|
580
|
-
import { buttonIconOf, buttonIconSvg, buttonVariantOf } from "@bettercms-ai/types";
|
|
580
|
+
import { LINK_RELS, buttonIconOf, buttonIconSvg, buttonVariantOf, isScriptHref } from "@bettercms-ai/types";
|
|
581
581
|
import { jsx as jsx5, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
582
582
|
function Button({
|
|
583
583
|
text,
|
|
@@ -588,6 +588,7 @@ function Button({
|
|
|
588
588
|
arrow = false,
|
|
589
589
|
icon: iconProp,
|
|
590
590
|
newTab = false,
|
|
591
|
+
rel,
|
|
591
592
|
align = "left",
|
|
592
593
|
className = "",
|
|
593
594
|
style,
|
|
@@ -618,11 +619,13 @@ function Button({
|
|
|
618
619
|
};
|
|
619
620
|
const sizeClass = size === "sm" || size === "lg" ? sizeStyles[size] : sizeStyles.md;
|
|
620
621
|
const fullClass = fullWidth === true ? "flex w-full justify-center" : "";
|
|
622
|
+
const relTokens = [...newTab === true ? ["noopener", "noreferrer"] : [], ...LINK_RELS.includes(rel) ? [rel] : []];
|
|
621
623
|
return /* @__PURE__ */ jsxs3(
|
|
622
624
|
"a",
|
|
623
625
|
{
|
|
624
|
-
href,
|
|
625
|
-
...newTab === true ? { target: "_blank"
|
|
626
|
+
href: typeof href === "string" && isScriptHref(href) ? "#" : href,
|
|
627
|
+
...newTab === true ? { target: "_blank" } : {},
|
|
628
|
+
...relTokens.length ? { rel: relTokens.join(" ") } : {},
|
|
626
629
|
"data-bcms-field": field,
|
|
627
630
|
"data-bcms-kind": kind,
|
|
628
631
|
style,
|
|
@@ -958,7 +961,7 @@ var BLOCK_REGISTRY = {
|
|
|
958
961
|
var BLOCK_TYPES = Object.keys(BLOCK_REGISTRY);
|
|
959
962
|
|
|
960
963
|
// src/renderer.tsx
|
|
961
|
-
import { splitButtonStyle } from "@bettercms-ai/types";
|
|
964
|
+
import { RESPONSIVE_CSS, hideOnAttr, splitButtonStyle, usesHideOn, visibleBlocks, windowState } from "@bettercms-ai/types";
|
|
962
965
|
|
|
963
966
|
// src/blockStyle.ts
|
|
964
967
|
import { blockStyleToCss } from "@bettercms-ai/types";
|
|
@@ -975,6 +978,12 @@ function styleOf(block) {
|
|
|
975
978
|
const { placement, paint } = splitButtonStyle(block.style);
|
|
976
979
|
return { wrapper: blockStyleToReactStyle(placement), paint: paint ? { style: paint } : {} };
|
|
977
980
|
}
|
|
981
|
+
function withHide(block, wrapperStyle, el, stampAt) {
|
|
982
|
+
const hide = hideOnAttr(block.style);
|
|
983
|
+
const state = stampAt ? windowState(block, stampAt) : "live";
|
|
984
|
+
if (!wrapperStyle && !hide && state === "live") return el;
|
|
985
|
+
return /* @__PURE__ */ jsx15("div", { style: wrapperStyle, ...hide ? { "data-bcms-hide": hide } : {}, ...state === "live" ? {} : { "data-bcms-window": state }, children: el });
|
|
986
|
+
}
|
|
978
987
|
function bindingProps(block, annotate) {
|
|
979
988
|
if (!annotate || !block.id) return {};
|
|
980
989
|
switch (block.type) {
|
|
@@ -990,7 +999,7 @@ function bindingProps(block, annotate) {
|
|
|
990
999
|
return {};
|
|
991
1000
|
}
|
|
992
1001
|
}
|
|
993
|
-
function resolveBlock(block, className, annotate = false) {
|
|
1002
|
+
function resolveBlock(block, className, annotate = false, stampAt) {
|
|
994
1003
|
const entry = BLOCK_REGISTRY[block.type];
|
|
995
1004
|
if (!entry) {
|
|
996
1005
|
return /* @__PURE__ */ jsxs11(
|
|
@@ -1007,13 +1016,14 @@ function resolveBlock(block, className, annotate = false) {
|
|
|
1007
1016
|
const Component = entry.component;
|
|
1008
1017
|
const { wrapper: blockStyle, paint } = styleOf(block);
|
|
1009
1018
|
const el = /* @__PURE__ */ jsx15(Component, { ...block.props, ...paint, className, ...bindingProps(block, annotate) });
|
|
1010
|
-
return
|
|
1019
|
+
return withHide(block, blockStyle, el, stampAt);
|
|
1011
1020
|
}
|
|
1012
1021
|
function BlockRenderer({
|
|
1013
1022
|
block,
|
|
1014
1023
|
className = "",
|
|
1015
1024
|
renderBlock,
|
|
1016
|
-
annotate = false
|
|
1025
|
+
annotate = false,
|
|
1026
|
+
stampAt
|
|
1017
1027
|
}) {
|
|
1018
1028
|
const entry = BLOCK_REGISTRY[block.type];
|
|
1019
1029
|
if (!entry) {
|
|
@@ -1029,7 +1039,7 @@ function BlockRenderer({
|
|
|
1029
1039
|
);
|
|
1030
1040
|
}
|
|
1031
1041
|
const Component = entry.component;
|
|
1032
|
-
const containerProps = CONTAINER_TYPES.has(block.type) ? { renderBlock: renderBlock ?? ((child) => resolveBlock(child, void 0, annotate)) } : {};
|
|
1042
|
+
const containerProps = CONTAINER_TYPES.has(block.type) ? { renderBlock: renderBlock ?? ((child) => resolveBlock(child, void 0, annotate, stampAt)) } : {};
|
|
1033
1043
|
const { wrapper: blockStyle, paint } = styleOf(block);
|
|
1034
1044
|
const el = /* @__PURE__ */ jsx15(
|
|
1035
1045
|
Component,
|
|
@@ -1041,24 +1051,31 @@ function BlockRenderer({
|
|
|
1041
1051
|
...bindingProps(block, annotate)
|
|
1042
1052
|
}
|
|
1043
1053
|
);
|
|
1044
|
-
return
|
|
1054
|
+
return withHide(block, blockStyle, el, stampAt);
|
|
1045
1055
|
}
|
|
1046
1056
|
function BlocksRenderer({
|
|
1047
|
-
blocks,
|
|
1057
|
+
blocks: all,
|
|
1048
1058
|
className = "",
|
|
1049
1059
|
renderBlock,
|
|
1050
|
-
annotate = false
|
|
1060
|
+
annotate = false,
|
|
1061
|
+
now
|
|
1051
1062
|
}) {
|
|
1063
|
+
const at = now ?? /* @__PURE__ */ new Date();
|
|
1064
|
+
const blocks = annotate ? all : visibleBlocks(all, at);
|
|
1052
1065
|
if (blocks.length === 0) return null;
|
|
1053
|
-
return /* @__PURE__ */
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1066
|
+
return /* @__PURE__ */ jsxs11("div", { className, children: [
|
|
1067
|
+
usesHideOn(blocks) && /* @__PURE__ */ jsx15("style", { dangerouslySetInnerHTML: { __html: RESPONSIVE_CSS } }),
|
|
1068
|
+
blocks.map((block) => /* @__PURE__ */ jsx15(
|
|
1069
|
+
BlockRenderer,
|
|
1070
|
+
{
|
|
1071
|
+
block,
|
|
1072
|
+
renderBlock,
|
|
1073
|
+
annotate,
|
|
1074
|
+
stampAt: annotate ? at : void 0
|
|
1075
|
+
},
|
|
1076
|
+
block.id
|
|
1077
|
+
))
|
|
1078
|
+
] });
|
|
1062
1079
|
}
|
|
1063
1080
|
export {
|
|
1064
1081
|
BLOCK_REGISTRY,
|