@bettercms-ai/ui 0.11.0 → 0.13.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/index.js CHANGED
@@ -555,7 +555,8 @@ function Image({
555
555
  "data-bcms-field": field,
556
556
  "data-bcms-kind": kind
557
557
  }) {
558
- return /* @__PURE__ */ jsxs2("figure", { className: cn("w-full", className), children: [
558
+ const sized = typeof width === "number" && width > 0;
559
+ return /* @__PURE__ */ jsxs2("figure", { className: cn(sized ? "max-w-full" : "w-full", className), children: [
559
560
  /* @__PURE__ */ jsx4(
560
561
  "img",
561
562
  {
@@ -566,7 +567,8 @@ function Image({
566
567
  sizes,
567
568
  "data-bcms-field": field,
568
569
  "data-bcms-kind": kind,
569
- className: "w-full h-auto rounded-md object-cover",
570
+ style: sized ? { width: `${width}px`, maxWidth: "100%", height: "auto" } : void 0,
571
+ className: cn(!sized && "w-full", "h-auto rounded-md object-cover"),
570
572
  loading: "lazy"
571
573
  }
572
574
  ),
@@ -585,8 +587,10 @@ function Button({
585
587
  fullWidth = false,
586
588
  arrow = false,
587
589
  icon: iconProp,
590
+ newTab = false,
588
591
  align = "left",
589
592
  className = "",
593
+ style,
590
594
  "data-bcms-field": field,
591
595
  "data-bcms-kind": kind
592
596
  }) {
@@ -618,8 +622,10 @@ function Button({
618
622
  "a",
619
623
  {
620
624
  href,
625
+ ...newTab === true ? { target: "_blank", rel: "noopener noreferrer" } : {},
621
626
  "data-bcms-field": field,
622
627
  "data-bcms-kind": kind,
628
+ style,
623
629
  className: cn(baseStyles, variantStyles[buttonVariantOf(variant)], alignClass, sizeClass, fullClass, className),
624
630
  children: [
625
631
  icon && /* @__PURE__ */ jsx5("span", { className: "mr-2 inline-flex", dangerouslySetInnerHTML: { __html: buttonIconSvg(icon, "bcms-btn-icon") } }),
@@ -951,6 +957,9 @@ var BLOCK_REGISTRY = {
951
957
  };
952
958
  var BLOCK_TYPES = Object.keys(BLOCK_REGISTRY);
953
959
 
960
+ // src/renderer.tsx
961
+ import { splitButtonStyle } from "@bettercms-ai/types";
962
+
954
963
  // src/blockStyle.ts
955
964
  import { blockStyleToCss } from "@bettercms-ai/types";
956
965
  function blockStyleToReactStyle(style) {
@@ -961,6 +970,11 @@ function blockStyleToReactStyle(style) {
961
970
  import "react";
962
971
  import { jsx as jsx15, jsxs as jsxs11 } from "react/jsx-runtime";
963
972
  var CONTAINER_TYPES = /* @__PURE__ */ new Set(["columns", "section", "slider", "tabs"]);
973
+ function styleOf(block) {
974
+ if (block.type !== "button") return { wrapper: blockStyleToReactStyle(block.style), paint: {} };
975
+ const { placement, paint } = splitButtonStyle(block.style);
976
+ return { wrapper: blockStyleToReactStyle(placement), paint: paint ? { style: paint } : {} };
977
+ }
964
978
  function bindingProps(block, annotate) {
965
979
  if (!annotate || !block.id) return {};
966
980
  switch (block.type) {
@@ -991,8 +1005,8 @@ function resolveBlock(block, className, annotate = false) {
991
1005
  );
992
1006
  }
993
1007
  const Component = entry.component;
994
- const blockStyle = blockStyleToReactStyle(block.style);
995
- const el = /* @__PURE__ */ jsx15(Component, { ...block.props, className, ...bindingProps(block, annotate) });
1008
+ const { wrapper: blockStyle, paint } = styleOf(block);
1009
+ const el = /* @__PURE__ */ jsx15(Component, { ...block.props, ...paint, className, ...bindingProps(block, annotate) });
996
1010
  return blockStyle ? /* @__PURE__ */ jsx15("div", { style: blockStyle, children: el }) : el;
997
1011
  }
998
1012
  function BlockRenderer({
@@ -1016,11 +1030,12 @@ function BlockRenderer({
1016
1030
  }
1017
1031
  const Component = entry.component;
1018
1032
  const containerProps = CONTAINER_TYPES.has(block.type) ? { renderBlock: renderBlock ?? ((child) => resolveBlock(child, void 0, annotate)) } : {};
1019
- const blockStyle = blockStyleToReactStyle(block.style);
1033
+ const { wrapper: blockStyle, paint } = styleOf(block);
1020
1034
  const el = /* @__PURE__ */ jsx15(
1021
1035
  Component,
1022
1036
  {
1023
1037
  ...block.props,
1038
+ ...paint,
1024
1039
  className,
1025
1040
  ...containerProps,
1026
1041
  ...bindingProps(block, annotate)