@builder.io/sdk-react 1.0.2 → 1.0.4

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.
Files changed (93) hide show
  1. package/README.md +4 -3
  2. package/lib/browser/blocks-exports.cjs +187 -0
  3. package/lib/browser/blocks-exports.mjs +3441 -0
  4. package/lib/browser/index.cjs +1 -187
  5. package/lib/browser/index.mjs +26 -3449
  6. package/lib/browser/{server-entry-a595b1cf.cjs → server-entry-093e302c.cjs} +1 -1
  7. package/lib/browser/{server-entry-f6f9bdcb.js → server-entry-7839c812.js} +1 -1
  8. package/lib/browser/server-entry.cjs +1 -1
  9. package/lib/browser/server-entry.mjs +1 -1
  10. package/lib/edge/blocks-0fc8e8d2.js +3385 -0
  11. package/lib/edge/blocks-exports.cjs +1 -0
  12. package/lib/edge/blocks-exports.mjs +16 -0
  13. package/lib/edge/blocks-f8688fcb.cjs +32 -0
  14. package/lib/edge/button-61181684.cjs +1 -0
  15. package/lib/edge/button-d9bbef90.js +29 -0
  16. package/lib/edge/columns-d152e266.cjs +28 -0
  17. package/lib/edge/columns-f7a9bca7.js +156 -0
  18. package/lib/edge/content-variants-cdcbcdd8.js +1711 -0
  19. package/lib/edge/content-variants-d2500971.cjs +133 -0
  20. package/lib/edge/custom-code-33b73ed1.js +44 -0
  21. package/lib/edge/custom-code-7390ba8b.cjs +1 -0
  22. package/lib/edge/dynamic-blocks-exports.cjs +39 -0
  23. package/lib/edge/dynamic-blocks-exports.mjs +37 -0
  24. package/lib/edge/dynamic-renderer-b5124984.js +9 -0
  25. package/lib/edge/dynamic-renderer-c00b8bcb.cjs +1 -0
  26. package/lib/edge/embed-11e03fa7.js +38 -0
  27. package/lib/edge/embed-9edce7df.cjs +1 -0
  28. package/lib/edge/form-ac531791.cjs +1 -0
  29. package/lib/edge/form-fb5fd55e.js +194 -0
  30. package/lib/edge/fragment-015b0912.js +8 -0
  31. package/lib/edge/fragment-61ef192d.cjs +1 -0
  32. package/lib/edge/get-class-prop-name-caee6506.cjs +1 -0
  33. package/lib/edge/get-class-prop-name-f22d7d53.js +18 -0
  34. package/lib/edge/image-6a3654d5.js +118 -0
  35. package/lib/edge/image-e4128296.cjs +17 -0
  36. package/lib/edge/img-317659e2.js +21 -0
  37. package/lib/edge/img-f2eeaa75.cjs +1 -0
  38. package/lib/edge/index.cjs +1 -207
  39. package/lib/edge/index.mjs +25 -5922
  40. package/lib/edge/input-526ea905.js +21 -0
  41. package/lib/edge/input-562438c4.cjs +1 -0
  42. package/lib/edge/section-68fbc212.js +26 -0
  43. package/lib/edge/section-70c8b709.cjs +1 -0
  44. package/lib/edge/select-17802399.js +21 -0
  45. package/lib/edge/select-d87a6280.cjs +1 -0
  46. package/lib/edge/server-entry-88f58ed4.cjs +2 -0
  47. package/lib/edge/{server-entry-f6f9bdcb.js → server-entry-e0830caf.js} +373 -372
  48. package/lib/edge/server-entry.cjs +1 -1
  49. package/lib/edge/server-entry.mjs +1 -1
  50. package/lib/edge/slot-39b50f6b.cjs +1 -0
  51. package/lib/edge/slot-eb244885.js +33 -0
  52. package/lib/edge/submit-button-13d8d5a7.cjs +1 -0
  53. package/lib/edge/submit-button-71dd4015.js +8 -0
  54. package/lib/edge/symbol-bf773f2a.js +78 -0
  55. package/lib/edge/symbol-ee31bb7f.cjs +1 -0
  56. package/lib/edge/text-15f0a6f4.js +18 -0
  57. package/lib/edge/text-7fdbde16.cjs +1 -0
  58. package/lib/edge/video-66b20833.js +106 -0
  59. package/lib/edge/video-702696a8.cjs +1 -0
  60. package/lib/node/blocks-exports.cjs +227 -0
  61. package/lib/node/blocks-exports.mjs +3548 -0
  62. package/lib/node/index.cjs +1 -227
  63. package/lib/node/index.mjs +27 -3556
  64. package/lib/node/{server-entry-31b5d683.cjs → server-entry-0e638a4f.cjs} +1 -1
  65. package/lib/node/{server-entry-c2b6d198.js → server-entry-e1cc0803.js} +1 -1
  66. package/lib/node/server-entry.cjs +1 -1
  67. package/lib/node/server-entry.mjs +1 -1
  68. package/package.json +19 -13
  69. package/types/blocks/button/index.d.ts +1 -0
  70. package/types/blocks/columns/index.d.ts +1 -0
  71. package/types/blocks/custom-code/index.d.ts +1 -0
  72. package/types/blocks/embed/index.d.ts +1 -0
  73. package/types/blocks/form/form/index.d.ts +1 -0
  74. package/types/blocks/form/input/index.d.ts +1 -0
  75. package/types/blocks/form/select/index.d.ts +1 -0
  76. package/types/blocks/form/submit-button/index.d.ts +1 -0
  77. package/types/blocks/fragment/index.d.ts +1 -0
  78. package/types/blocks/image/index.d.ts +1 -0
  79. package/types/blocks/img/index.d.ts +1 -0
  80. package/types/blocks/raw-text/index.d.ts +1 -0
  81. package/types/blocks/section/index.d.ts +1 -0
  82. package/types/blocks/slot/index.d.ts +1 -0
  83. package/types/blocks/symbol/index.d.ts +1 -0
  84. package/types/blocks/text/index.d.ts +1 -0
  85. package/types/blocks/textarea/index.d.ts +1 -0
  86. package/types/blocks/video/index.d.ts +1 -0
  87. package/types/components/blocks/index.d.ts +1 -0
  88. package/types/components/content-variants/index.d.ts +1 -0
  89. package/types/components/error-boundary.d.ts +11 -0
  90. package/types/constants/sdk-version.d.ts +1 -1
  91. package/types/functions/get-content/types.d.ts +1 -1
  92. package/types/index-helpers/blocks-exports.d.ts +10 -11
  93. package/lib/edge/server-entry-a595b1cf.cjs +0 -2
@@ -0,0 +1,118 @@
1
+ "use client";
2
+ import { jsxs as m, Fragment as l, jsx as a } from "react/jsx-runtime";
3
+ function g(e) {
4
+ return e.replace(/http(s)?:/, "");
5
+ }
6
+ function b(e = "", i, t) {
7
+ const n = new RegExp("([?&])" + i + "=.*?(&|$)", "i"), c = e.indexOf("?") !== -1 ? "&" : "?";
8
+ return e.match(n) ? e.replace(n, "$1" + i + "=" + encodeURIComponent(t) + "$2") : e + c + i + "=" + encodeURIComponent(t);
9
+ }
10
+ function x(e, i) {
11
+ if (!e || !(e != null && e.match(/cdn\.shopify\.com/)) || !i)
12
+ return e;
13
+ if (i === "master")
14
+ return g(e);
15
+ const t = e.match(/(_\d+x(\d+)?)?(\.(jpg|jpeg|gif|png|bmp|bitmap|tiff|tif)(\?v=\d+)?)/i);
16
+ if (t) {
17
+ const n = e.split(t[0]), c = t[3], d = i.match("x") ? i : `${i}x`;
18
+ return g(`${n[0]}_${d}${c}`);
19
+ }
20
+ return null;
21
+ }
22
+ function s(e) {
23
+ if (!e)
24
+ return e;
25
+ const i = [100, 200, 400, 800, 1200, 1600, 2e3];
26
+ if (e.match(/builder\.io/)) {
27
+ let t = e;
28
+ const n = Number(e.split("?width=")[1]);
29
+ return isNaN(n) || (t = `${t} ${n}w`), i.filter((c) => c !== n).map((c) => `${b(e, "width", c)} ${c}w`).concat([t]).join(", ");
30
+ }
31
+ return e.match(/cdn\.shopify\.com/) ? i.map((t) => [x(e, `${t}x${t}`), t]).filter(([t]) => !!t).map(([t, n]) => `${t} ${n}w`).concat([e]).join(", ") : e;
32
+ }
33
+ function v(e) {
34
+ var c, d, u, f;
35
+ function i() {
36
+ var h;
37
+ const o = e.image || e.src;
38
+ if (!o || // We can auto add srcset for cdn.builder.io and shopify
39
+ // images, otherwise you can supply this prop manually
40
+ !(o.match(/builder\.io/) || o.match(/cdn\.shopify\.com/)))
41
+ return e.srcset;
42
+ if (e.srcset && ((h = e.image) != null && h.includes("builder.io/api/v1/image"))) {
43
+ if (!e.srcset.includes(e.image.split("?")[0]))
44
+ return console.debug("Removed given srcset"), s(o);
45
+ } else if (e.image && !e.srcset)
46
+ return s(o);
47
+ return s(o);
48
+ }
49
+ function t() {
50
+ var r;
51
+ return (r = i == null ? void 0 : i()) != null && r.match(/builder\.io/) && !e.noWebp ? i().replace(/\?/g, "?format=webp&") : "";
52
+ }
53
+ function n() {
54
+ const r = {
55
+ position: "absolute",
56
+ height: "100%",
57
+ width: "100%",
58
+ left: "0px",
59
+ top: "0px"
60
+ };
61
+ return e.aspectRatio ? r : void 0;
62
+ }
63
+ return /* @__PURE__ */ m(l, { children: [
64
+ /* @__PURE__ */ m(l, { children: [
65
+ /* @__PURE__ */ m("picture", { children: [
66
+ t() ? /* @__PURE__ */ a(l, { children: /* @__PURE__ */ a("source", { type: "image/webp", srcSet: t() }) }) : null,
67
+ /* @__PURE__ */ a(
68
+ "img",
69
+ {
70
+ loading: "lazy",
71
+ alt: e.altText,
72
+ role: e.altText ? "presentation" : void 0,
73
+ style: {
74
+ objectPosition: e.backgroundPosition || "center",
75
+ objectFit: e.backgroundSize || "cover",
76
+ ...n()
77
+ },
78
+ className: "builder-image" + (e.className ? " " + e.className : "") + " img-40c70c9b",
79
+ src: e.image,
80
+ srcSet: i(),
81
+ sizes: e.sizes
82
+ }
83
+ )
84
+ ] }),
85
+ e.aspectRatio && !((d = (c = e.builderBlock) == null ? void 0 : c.children) != null && d.length && e.fitContent) ? /* @__PURE__ */ a(l, { children: /* @__PURE__ */ a(
86
+ "div",
87
+ {
88
+ className: "builder-image-sizer div-40c70c9b",
89
+ style: {
90
+ paddingTop: e.aspectRatio * 100 + "%"
91
+ }
92
+ }
93
+ ) }) : null,
94
+ (f = (u = e.builderBlock) == null ? void 0 : u.children) != null && f.length && e.fitContent ? /* @__PURE__ */ a(l, { children: e.children }) : null,
95
+ !e.fitContent && e.children ? /* @__PURE__ */ a(l, { children: /* @__PURE__ */ a("div", { className: "div-40c70c9b-2", children: e.children }) }) : null
96
+ ] }),
97
+ /* @__PURE__ */ a("style", { children: `.img-40c70c9b {
98
+ opacity: 1;
99
+ transition: opacity 0.2s ease-in-out;
100
+ }.div-40c70c9b {
101
+ width: 100%;
102
+ pointer-events: none;
103
+ font-size: 0;
104
+ }.div-40c70c9b-2 {
105
+ display: flex;
106
+ flex-direction: column;
107
+ align-items: stretch;
108
+ position: absolute;
109
+ top: 0;
110
+ left: 0;
111
+ width: 100%;
112
+ height: 100%;
113
+ }` })
114
+ ] });
115
+ }
116
+ export {
117
+ v as default
118
+ };
@@ -0,0 +1,17 @@
1
+ "use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("react/jsx-runtime");function f(e){return e.replace(/http(s)?:/,"")}function g(e="",i,t){const c=new RegExp("([?&])"+i+"=.*?(&|$)","i"),a=e.indexOf("?")!==-1?"&":"?";return e.match(c)?e.replace(c,"$1"+i+"="+encodeURIComponent(t)+"$2"):e+a+i+"="+encodeURIComponent(t)}function h(e,i){if(!e||!(e!=null&&e.match(/cdn\.shopify\.com/))||!i)return e;if(i==="master")return f(e);const t=e.match(/(_\d+x(\d+)?)?(\.(jpg|jpeg|gif|png|bmp|bitmap|tiff|tif)(\?v=\d+)?)/i);if(t){const c=e.split(t[0]),a=t[3],r=i.match("x")?i:`${i}x`;return f(`${c[0]}_${r}${a}`)}return null}function s(e){if(!e)return e;const i=[100,200,400,800,1200,1600,2e3];if(e.match(/builder\.io/)){let t=e;const c=Number(e.split("?width=")[1]);return isNaN(c)||(t=`${t} ${c}w`),i.filter(a=>a!==c).map(a=>`${g(e,"width",a)} ${a}w`).concat([t]).join(", ")}return e.match(/cdn\.shopify\.com/)?i.map(t=>[h(e,`${t}x${t}`),t]).filter(([t])=>!!t).map(([t,c])=>`${t} ${c}w`).concat([e]).join(", "):e}function b(e){var a,r,d,m;function i(){var u;const o=e.image||e.src;if(!o||!(o.match(/builder\.io/)||o.match(/cdn\.shopify\.com/)))return e.srcset;if(e.srcset&&((u=e.image)!=null&&u.includes("builder.io/api/v1/image"))){if(!e.srcset.includes(e.image.split("?")[0]))return console.debug("Removed given srcset"),s(o)}else if(e.image&&!e.srcset)return s(o);return s(o)}function t(){var l;return(l=i==null?void 0:i())!=null&&l.match(/builder\.io/)&&!e.noWebp?i().replace(/\?/g,"?format=webp&"):""}function c(){const l={position:"absolute",height:"100%",width:"100%",left:"0px",top:"0px"};return e.aspectRatio?l:void 0}return n.jsxs(n.Fragment,{children:[n.jsxs(n.Fragment,{children:[n.jsxs("picture",{children:[t()?n.jsx(n.Fragment,{children:n.jsx("source",{type:"image/webp",srcSet:t()})}):null,n.jsx("img",{loading:"lazy",alt:e.altText,role:e.altText?"presentation":void 0,style:{objectPosition:e.backgroundPosition||"center",objectFit:e.backgroundSize||"cover",...c()},className:"builder-image"+(e.className?" "+e.className:"")+" img-40c70c9b",src:e.image,srcSet:i(),sizes:e.sizes})]}),e.aspectRatio&&!((r=(a=e.builderBlock)==null?void 0:a.children)!=null&&r.length&&e.fitContent)?n.jsx(n.Fragment,{children:n.jsx("div",{className:"builder-image-sizer div-40c70c9b",style:{paddingTop:e.aspectRatio*100+"%"}})}):null,(m=(d=e.builderBlock)==null?void 0:d.children)!=null&&m.length&&e.fitContent?n.jsx(n.Fragment,{children:e.children}):null,!e.fitContent&&e.children?n.jsx(n.Fragment,{children:n.jsx("div",{className:"div-40c70c9b-2",children:e.children})}):null]}),n.jsx("style",{children:`.img-40c70c9b {
2
+ opacity: 1;
3
+ transition: opacity 0.2s ease-in-out;
4
+ }.div-40c70c9b {
5
+ width: 100%;
6
+ pointer-events: none;
7
+ font-size: 0;
8
+ }.div-40c70c9b-2 {
9
+ display: flex;
10
+ flex-direction: column;
11
+ align-items: stretch;
12
+ position: absolute;
13
+ top: 0;
14
+ left: 0;
15
+ width: 100%;
16
+ height: 100%;
17
+ }`})]})}exports.default=b;
@@ -0,0 +1,21 @@
1
+ "use client";
2
+ import { jsx as i } from "react/jsx-runtime";
3
+ import { i as e } from "./server-entry-e0830caf.js";
4
+ function o(t) {
5
+ return /* @__PURE__ */ i(
6
+ "img",
7
+ {
8
+ style: {
9
+ objectFit: t.backgroundSize || "cover",
10
+ objectPosition: t.backgroundPosition || "center"
11
+ },
12
+ alt: t.altText,
13
+ src: t.imgSrc || t.image,
14
+ ...t.attributes
15
+ },
16
+ e() && t.imgSrc || "default-key"
17
+ );
18
+ }
19
+ export {
20
+ o as default
21
+ };
@@ -0,0 +1 @@
1
+ "use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),i=require("./server-entry-88f58ed4.cjs");function n(e){return t.jsx("img",{style:{objectFit:e.backgroundSize||"cover",objectPosition:e.backgroundPosition||"center"},alt:e.altText,src:e.imgSrc||e.image,...e.attributes},i.isEditing()&&e.imgSrc||"default-key")}exports.default=n;