@builder.io/sdk-react-nextjs 0.17.1 → 0.17.2
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/lib/browser/blocks/text/text.cjs +1 -1
- package/lib/browser/blocks/text/text.mjs +6 -24
- package/lib/browser/components/block/block.cjs +1 -1
- package/lib/browser/components/block/block.mjs +27 -28
- package/lib/browser/components/content/components/enable-editor.cjs +1 -1
- package/lib/browser/components/content/components/enable-editor.mjs +102 -96
- package/lib/browser/constants/sdk-version.cjs +1 -1
- package/lib/browser/constants/sdk-version.mjs +1 -1
- package/lib/browser/functions/get-block-component-options.cjs +1 -1
- package/lib/browser/functions/get-block-component-options.mjs +21 -5
- package/lib/browser/functions/get-content/generate-content-url.cjs +1 -1
- package/lib/browser/functions/get-content/generate-content-url.mjs +60 -40
- package/lib/browser/functions/get-processed-block.cjs +1 -1
- package/lib/browser/functions/get-processed-block.mjs +18 -19
- package/lib/browser/helpers/flatten.cjs +1 -1
- package/lib/browser/helpers/flatten.mjs +28 -15
- package/lib/edge/blocks/text/text.cjs +1 -1
- package/lib/edge/blocks/text/text.mjs +6 -24
- package/lib/edge/components/block/block.cjs +1 -1
- package/lib/edge/components/block/block.mjs +27 -28
- package/lib/edge/components/content/components/enable-editor.cjs +1 -1
- package/lib/edge/components/content/components/enable-editor.mjs +102 -96
- package/lib/edge/constants/sdk-version.cjs +1 -1
- package/lib/edge/constants/sdk-version.mjs +1 -1
- package/lib/edge/functions/evaluate/edge-runtime/edge-runtime.cjs +5 -5
- package/lib/edge/functions/evaluate/edge-runtime/edge-runtime.mjs +25 -28
- package/lib/edge/functions/get-block-component-options.cjs +1 -1
- package/lib/edge/functions/get-block-component-options.mjs +21 -5
- package/lib/edge/functions/get-content/generate-content-url.cjs +1 -1
- package/lib/edge/functions/get-content/generate-content-url.mjs +60 -40
- package/lib/edge/functions/get-processed-block.cjs +1 -1
- package/lib/edge/functions/get-processed-block.mjs +18 -19
- package/lib/edge/helpers/flatten.cjs +1 -1
- package/lib/edge/helpers/flatten.mjs +28 -15
- package/lib/node/blocks/text/text.cjs +1 -1
- package/lib/node/blocks/text/text.mjs +6 -24
- package/lib/node/components/block/block.cjs +1 -1
- package/lib/node/components/block/block.mjs +27 -28
- package/lib/node/components/content/components/enable-editor.cjs +1 -1
- package/lib/node/components/content/components/enable-editor.mjs +102 -96
- package/lib/node/constants/sdk-version.cjs +1 -1
- package/lib/node/constants/sdk-version.mjs +1 -1
- package/lib/node/functions/get-block-component-options.cjs +1 -1
- package/lib/node/functions/get-block-component-options.mjs +21 -5
- package/lib/node/functions/get-content/generate-content-url.cjs +1 -1
- package/lib/node/functions/get-content/generate-content-url.mjs +60 -40
- package/lib/node/functions/get-processed-block.cjs +1 -1
- package/lib/node/functions/get-processed-block.mjs +18 -19
- package/lib/node/helpers/flatten.cjs +1 -1
- package/lib/node/helpers/flatten.mjs +28 -15
- package/package.json +1 -1
- package/types/cjs/constants/sdk-version.d.ts +1 -1
- package/types/cjs/functions/get-block-component-options.d.ts +2 -1
- package/types/cjs/functions/get-processed-block.d.ts +1 -6
- package/types/cjs/helpers/flatten.d.ts +6 -0
- package/types/cjs/server-index.d.ts +1 -1
- package/types/esm/constants/sdk-version.d.ts +1 -1
- package/types/esm/functions/get-block-component-options.d.ts +2 -1
- package/types/esm/functions/get-processed-block.d.ts +1 -6
- package/types/esm/helpers/flatten.d.ts +6 -0
- package/types/esm/server-index.d.ts +1 -1
|
@@ -1,59 +1,79 @@
|
|
|
1
|
-
import { flatten as
|
|
2
|
-
import { normalizeSearchParams as
|
|
3
|
-
import { DEFAULT_API_VERSION as
|
|
4
|
-
import { getBuilderSearchParamsFromWindow as
|
|
5
|
-
|
|
1
|
+
import { flatten as U, flattenMongoQuery as E, unflatten as F } from "../../helpers/flatten.mjs";
|
|
2
|
+
import { normalizeSearchParams as O } from "../../helpers/search/search.mjs";
|
|
3
|
+
import { DEFAULT_API_VERSION as J } from "../../types/api-version.mjs";
|
|
4
|
+
import { getBuilderSearchParamsFromWindow as L } from "../get-builder-search-params/index.mjs";
|
|
5
|
+
import { isBrowser as R } from "../is-browser.mjs";
|
|
6
|
+
const w = (t) => typeof t == "number" && !isNaN(t) && t >= 0, _ = (t) => {
|
|
6
7
|
const {
|
|
7
|
-
limit:
|
|
8
|
-
userAttributes:
|
|
8
|
+
limit: a = 30,
|
|
9
|
+
userAttributes: r,
|
|
9
10
|
query: h,
|
|
10
|
-
model:
|
|
11
|
-
apiKey:
|
|
12
|
-
enrich:
|
|
13
|
-
locale:
|
|
14
|
-
apiVersion:
|
|
15
|
-
fields:
|
|
16
|
-
omit:
|
|
17
|
-
offset:
|
|
18
|
-
cacheSeconds:
|
|
11
|
+
model: y,
|
|
12
|
+
apiKey: u,
|
|
13
|
+
enrich: d,
|
|
14
|
+
locale: A,
|
|
15
|
+
apiVersion: o = J,
|
|
16
|
+
fields: P,
|
|
17
|
+
omit: N,
|
|
18
|
+
offset: c,
|
|
19
|
+
cacheSeconds: l,
|
|
19
20
|
staleCacheSeconds: f,
|
|
20
21
|
sort: S,
|
|
21
|
-
includeUnpublished:
|
|
22
|
-
apiHost:
|
|
23
|
-
} =
|
|
24
|
-
if (!
|
|
22
|
+
includeUnpublished: p,
|
|
23
|
+
apiHost: v
|
|
24
|
+
} = t;
|
|
25
|
+
if (!u)
|
|
25
26
|
throw new Error("Missing API key");
|
|
26
|
-
if (!["v3"].includes(
|
|
27
|
-
throw new Error(`Invalid apiVersion: expected 'v3', received '${
|
|
28
|
-
const
|
|
29
|
-
e.searchParams.set("apiKey",
|
|
30
|
-
const
|
|
31
|
-
let i =
|
|
32
|
-
if (
|
|
33
|
-
locale:
|
|
27
|
+
if (!["v3"].includes(o))
|
|
28
|
+
throw new Error(`Invalid apiVersion: expected 'v3', received '${o}'`);
|
|
29
|
+
const k = a !== 1, I = v || "https://cdn.builder.io", e = new URL(`${I}/api/${o}/content/${y}`);
|
|
30
|
+
e.searchParams.set("apiKey", u), e.searchParams.set("limit", String(a)), e.searchParams.set("noTraverse", String(k)), e.searchParams.set("includeRefs", String(!0));
|
|
31
|
+
const m = A || (r == null ? void 0 : r.locale);
|
|
32
|
+
let i = r || {};
|
|
33
|
+
if (m && (e.searchParams.set("locale", m), i = {
|
|
34
|
+
locale: m,
|
|
34
35
|
...i
|
|
35
|
-
}),
|
|
36
|
-
const s =
|
|
36
|
+
}), d && e.searchParams.set("enrich", String(d)), e.searchParams.set("omit", N || "meta.componentsUsed"), P && e.searchParams.set("fields", P), Number.isFinite(c) && c > -1 && e.searchParams.set("offset", String(Math.floor(c))), typeof p == "boolean" && e.searchParams.set("includeUnpublished", String(p)), l && w(l) && e.searchParams.set("cacheSeconds", String(l)), f && w(f) && e.searchParams.set("staleCacheSeconds", String(f)), S) {
|
|
37
|
+
const s = U({
|
|
37
38
|
sort: S
|
|
38
39
|
});
|
|
39
|
-
for (const
|
|
40
|
-
e.searchParams.set(
|
|
40
|
+
for (const n in s)
|
|
41
|
+
e.searchParams.set(n, JSON.stringify(s[n]));
|
|
41
42
|
}
|
|
42
|
-
const
|
|
43
|
-
...
|
|
44
|
-
...
|
|
45
|
-
}
|
|
43
|
+
const b = {
|
|
44
|
+
...L(),
|
|
45
|
+
...O(t.options || {})
|
|
46
|
+
};
|
|
47
|
+
i = {
|
|
48
|
+
...i,
|
|
49
|
+
...$(b)
|
|
50
|
+
};
|
|
51
|
+
const g = U(b);
|
|
46
52
|
for (const s in g)
|
|
47
53
|
e.searchParams.set(s, String(g[s]));
|
|
48
|
-
if (i && e.searchParams.set("userAttributes", JSON.stringify(i)), h) {
|
|
54
|
+
if (Object.keys(i).length > 0 && e.searchParams.set("userAttributes", JSON.stringify(i)), h) {
|
|
49
55
|
const s = E({
|
|
50
56
|
query: h
|
|
51
57
|
});
|
|
52
|
-
for (const
|
|
53
|
-
e.searchParams.set(
|
|
58
|
+
for (const n in s)
|
|
59
|
+
e.searchParams.set(n, JSON.stringify(s[n]));
|
|
54
60
|
}
|
|
55
61
|
return e;
|
|
62
|
+
}, T = (t) => {
|
|
63
|
+
const a = {};
|
|
64
|
+
for (const r in t)
|
|
65
|
+
r.startsWith("userAttributes.") && (a[r] = t[r], delete t[r]);
|
|
66
|
+
return a;
|
|
67
|
+
}, $ = (t) => {
|
|
68
|
+
if (R() && t.preview === "BUILDER_STUDIO") {
|
|
69
|
+
t["userAttributes.urlPath"] = window.location.pathname, t["userAttributes.host"] = window.location.host;
|
|
70
|
+
const a = T(t), {
|
|
71
|
+
userAttributes: r
|
|
72
|
+
} = F(a);
|
|
73
|
+
return r;
|
|
74
|
+
}
|
|
75
|
+
return {};
|
|
56
76
|
};
|
|
57
77
|
export {
|
|
58
|
-
|
|
78
|
+
_ as generateContentUrl
|
|
59
79
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("../constants/target.cjs"),d=require("../helpers/omit.cjs"),p=require("./evaluate/evaluate.cjs"),f=require("./extract-localized-values.cjs"),g=require("./fast-clone.cjs"),m=require("./set.cjs"),y=require("./transform-block.cjs");function o(e){if(e===null||typeof e!="object")return e;if(Array.isArray(e))return e.map(n=>o(n));if(e["@type"]==="@builder.io/sdk:Element")return e;const t={};for(const n in e)n!=="meta"&&Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=o(e[n]));return t}const C=["svelte","vue","angular","qwik","solid"].includes(u.TARGET),q=e=>{if(C){const t=g.fastClone(e);return{...t,properties:{...t.properties},actions:{...t.actions}}}else{const t=o(d.omit(e,"children","meta"));return{...t,properties:{...t.properties},actions:{...t.actions},children:e.children,meta:e.meta}}},v=({block:e,context:t,localState:n,rootState:
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("../constants/target.cjs"),d=require("../helpers/omit.cjs"),p=require("./evaluate/evaluate.cjs"),f=require("./extract-localized-values.cjs"),g=require("./fast-clone.cjs"),m=require("./set.cjs"),y=require("./transform-block.cjs");function o(e){if(e===null||typeof e!="object")return e;if(Array.isArray(e))return e.map(n=>o(n));if(e["@type"]==="@builder.io/sdk:Element")return e;const t={};for(const n in e)n!=="meta"&&Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=o(e[n]));return t}const C=["svelte","vue","angular","qwik","solid"].includes(u.TARGET),q=e=>{if(C){const t=g.fastClone(e);return{...t,properties:{...t.properties},actions:{...t.actions}}}else{const t=o(d.omit(e,"children","meta"));return{...t,properties:{...t.properties},actions:{...t.actions},children:e.children,meta:e.meta}}},v=({block:e,context:t,localState:n,rootState:i,rootSetState:s})=>{if(!e.bindings)return e;const r=q(e);for(const c in e.bindings){const a=e.bindings[c],l=p.evaluate({code:a,localState:n,rootState:i,rootSetState:s,context:t});m.set(r,c,l)}return r};function B({block:e,context:t,localState:n,rootState:i,rootSetState:s}){let r=f.resolveLocalizedValues(e,i.locale);return r=y.transformBlock(r),v({block:r,localState:n,rootState:i,rootSetState:s,context:t})}exports.deepCloneWithConditions=o;exports.getProcessedBlock=B;
|
|
@@ -5,16 +5,16 @@ import { resolveLocalizedValues as f } from "./extract-localized-values.mjs";
|
|
|
5
5
|
import { fastClone as u } from "./fast-clone.mjs";
|
|
6
6
|
import { set as y } from "./set.mjs";
|
|
7
7
|
import { transformBlock as g } from "./transform-block.mjs";
|
|
8
|
-
function
|
|
8
|
+
function s(e) {
|
|
9
9
|
if (e === null || typeof e != "object")
|
|
10
10
|
return e;
|
|
11
11
|
if (Array.isArray(e))
|
|
12
|
-
return e.map((t) =>
|
|
12
|
+
return e.map((t) => s(t));
|
|
13
13
|
if (e["@type"] === "@builder.io/sdk:Element")
|
|
14
14
|
return e;
|
|
15
15
|
const r = {};
|
|
16
16
|
for (const t in e)
|
|
17
|
-
t !== "meta" && Object.prototype.hasOwnProperty.call(e, t) && (r[t] =
|
|
17
|
+
t !== "meta" && Object.prototype.hasOwnProperty.call(e, t) && (r[t] = s(e[t]));
|
|
18
18
|
return r;
|
|
19
19
|
}
|
|
20
20
|
const C = ["svelte", "vue", "angular", "qwik", "solid"].includes(l), v = (e) => {
|
|
@@ -30,7 +30,7 @@ const C = ["svelte", "vue", "angular", "qwik", "solid"].includes(l), v = (e) =>
|
|
|
30
30
|
}
|
|
31
31
|
};
|
|
32
32
|
} else {
|
|
33
|
-
const r =
|
|
33
|
+
const r = s(m(e, "children", "meta"));
|
|
34
34
|
return {
|
|
35
35
|
...r,
|
|
36
36
|
properties: {
|
|
@@ -47,42 +47,41 @@ const C = ["svelte", "vue", "angular", "qwik", "solid"].includes(l), v = (e) =>
|
|
|
47
47
|
block: e,
|
|
48
48
|
context: r,
|
|
49
49
|
localState: t,
|
|
50
|
-
rootState:
|
|
51
|
-
rootSetState:
|
|
50
|
+
rootState: i,
|
|
51
|
+
rootSetState: o
|
|
52
52
|
}) => {
|
|
53
53
|
if (!e.bindings)
|
|
54
54
|
return e;
|
|
55
|
-
const
|
|
56
|
-
for (const
|
|
57
|
-
const p = e.bindings[
|
|
55
|
+
const n = v(e);
|
|
56
|
+
for (const c in e.bindings) {
|
|
57
|
+
const p = e.bindings[c], a = d({
|
|
58
58
|
code: p,
|
|
59
59
|
localState: t,
|
|
60
|
-
rootState:
|
|
61
|
-
rootSetState:
|
|
60
|
+
rootState: i,
|
|
61
|
+
rootSetState: o,
|
|
62
62
|
context: r
|
|
63
63
|
});
|
|
64
|
-
y(
|
|
64
|
+
y(n, c, a);
|
|
65
65
|
}
|
|
66
|
-
return
|
|
66
|
+
return n;
|
|
67
67
|
};
|
|
68
68
|
function P({
|
|
69
69
|
block: e,
|
|
70
70
|
context: r,
|
|
71
|
-
|
|
72
|
-
localState: s,
|
|
71
|
+
localState: t,
|
|
73
72
|
rootState: i,
|
|
74
73
|
rootSetState: o
|
|
75
74
|
}) {
|
|
76
75
|
let n = f(e, i.locale);
|
|
77
|
-
return n = g(n),
|
|
76
|
+
return n = g(n), O({
|
|
78
77
|
block: n,
|
|
79
|
-
localState:
|
|
78
|
+
localState: t,
|
|
80
79
|
rootState: i,
|
|
81
80
|
rootSetState: o,
|
|
82
81
|
context: r
|
|
83
|
-
})
|
|
82
|
+
});
|
|
84
83
|
}
|
|
85
84
|
export {
|
|
86
|
-
|
|
85
|
+
s as deepCloneWithConditions,
|
|
87
86
|
P as getProcessedBlock
|
|
88
87
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function i(l,s=null,o="."){return Object.keys(l).reduce((n,t)=>{const e=l[t],r=[s,t].filter(Boolean).join(o);return[typeof e=="object",e!==null,!(Array.isArray(e)&&e.length===0)].every(Boolean)?{...n,...i(e,r,o)}:{...n,[r]:e}},{})}function u(l,s,o={}){for(const n in l){const t=l[n],e=s?s+"."+n:n;t&&typeof t=="object"&&!Array.isArray(t)&&!Object.keys(t).find(r=>r.startsWith("$"))?u(t,e,o):o[e]=t}return o}function c(l){const s={};for(const o in l){const n=o.split(".");let t=s;for(let e=0;e<n.length;e++){const r=n[e];e===n.length-1?t[r]=l[o]:(t[r]=t[r]||{},t=t[r])}}return s}exports.flatten=i;exports.flattenMongoQuery=u;exports.unflatten=c;
|
|
@@ -1,23 +1,36 @@
|
|
|
1
|
-
function
|
|
2
|
-
return Object.keys(
|
|
3
|
-
const
|
|
4
|
-
return [typeof
|
|
5
|
-
...
|
|
6
|
-
...
|
|
1
|
+
function c(l, s = null, o = ".") {
|
|
2
|
+
return Object.keys(l).reduce((n, t) => {
|
|
3
|
+
const e = l[t], r = [s, t].filter(Boolean).join(o);
|
|
4
|
+
return [typeof e == "object", e !== null, !(Array.isArray(e) && e.length === 0)].every(Boolean) ? {
|
|
5
|
+
...n,
|
|
6
|
+
...c(e, r, o)
|
|
7
7
|
} : {
|
|
8
|
-
...
|
|
9
|
-
[
|
|
8
|
+
...n,
|
|
9
|
+
[r]: e
|
|
10
10
|
};
|
|
11
11
|
}, {});
|
|
12
12
|
}
|
|
13
|
-
function
|
|
14
|
-
for (const
|
|
15
|
-
const
|
|
16
|
-
|
|
13
|
+
function i(l, s, o = {}) {
|
|
14
|
+
for (const n in l) {
|
|
15
|
+
const t = l[n], e = s ? s + "." + n : n;
|
|
16
|
+
t && typeof t == "object" && !Array.isArray(t) && !Object.keys(t).find((r) => r.startsWith("$")) ? i(t, e, o) : o[e] = t;
|
|
17
17
|
}
|
|
18
|
-
return
|
|
18
|
+
return o;
|
|
19
|
+
}
|
|
20
|
+
function u(l) {
|
|
21
|
+
const s = {};
|
|
22
|
+
for (const o in l) {
|
|
23
|
+
const n = o.split(".");
|
|
24
|
+
let t = s;
|
|
25
|
+
for (let e = 0; e < n.length; e++) {
|
|
26
|
+
const r = n[e];
|
|
27
|
+
e === n.length - 1 ? t[r] = l[o] : (t[r] = t[r] || {}, t = t[r]);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
return s;
|
|
19
31
|
}
|
|
20
32
|
export {
|
|
21
|
-
|
|
22
|
-
|
|
33
|
+
c as flatten,
|
|
34
|
+
i as flattenMongoQuery,
|
|
35
|
+
u as unflatten
|
|
23
36
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const
|
|
1
|
+
"use strict";const n=require("react/jsx-runtime");function r(e){var t;return n.jsx("div",{className:"builder-text",dangerouslySetInnerHTML:{__html:((t=e.text)==null?void 0:t.toString())||""},style:{outline:"none"}})}module.exports=r;
|
|
@@ -1,29 +1,11 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
return /* @__PURE__ */
|
|
1
|
+
import { jsx as n } from "react/jsx-runtime";
|
|
2
|
+
function o(e) {
|
|
3
|
+
var t;
|
|
4
|
+
return /* @__PURE__ */ n(
|
|
5
5
|
"div",
|
|
6
6
|
{
|
|
7
7
|
className: "builder-text",
|
|
8
|
-
dangerouslySetInnerHTML: { __html:
|
|
9
|
-
var e;
|
|
10
|
-
const o = t.builderContext, {
|
|
11
|
-
context: n,
|
|
12
|
-
localState: r,
|
|
13
|
-
rootState: c,
|
|
14
|
-
rootSetState: s
|
|
15
|
-
} = o;
|
|
16
|
-
return String(((e = t.text) == null ? void 0 : e.toString()) || "").replace(
|
|
17
|
-
/{{([^}]+)}}/g,
|
|
18
|
-
(d, x) => l({
|
|
19
|
-
code: x,
|
|
20
|
-
context: n,
|
|
21
|
-
localState: r,
|
|
22
|
-
rootState: c,
|
|
23
|
-
rootSetState: s
|
|
24
|
-
})
|
|
25
|
-
);
|
|
26
|
-
}() },
|
|
8
|
+
dangerouslySetInnerHTML: { __html: ((t = e.text) == null ? void 0 : t.toString()) || "" },
|
|
27
9
|
style: {
|
|
28
10
|
outline: "none"
|
|
29
11
|
}
|
|
@@ -31,5 +13,5 @@ function f(t) {
|
|
|
31
13
|
);
|
|
32
14
|
}
|
|
33
15
|
export {
|
|
34
|
-
|
|
16
|
+
o as default
|
|
35
17
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const t=require("react/jsx-runtime"),
|
|
1
|
+
"use strict";const t=require("react/jsx-runtime"),v=require("../../constants/target.cjs"),S=require("../../functions/get-block-component-options.cjs"),j=require("../../functions/get-processed-block.cjs"),P=require("../../functions/is-previewing.cjs");require("../../functions/get-fetch.cjs");const m=require("./block.helpers.cjs"),q=require("./components/block-styles.cjs"),O=require("./components/block-wrapper.cjs"),p=require("./components/component-ref/component-ref.cjs"),g=require("./components/repeated-block.cjs");function b(e){var a,C,x,h;const d=function(){return m.getRepeatItemData({block:e.block,context:e.context})},u={value:null,update:!1},c=function(){var i;if(u.value&&!u.update&&!P.isPreviewing())return u.value;const r=(i=e.block.repeat)!=null&&i.collection?e.block:j.getProcessedBlock({block:e.block,localState:e.context.localState,rootState:e.context.rootState,rootSetState:e.context.rootSetState,context:e.context.context});return u.value=r,u.update=!1,r},l=function(){return m.getComponent({block:c(),registeredComponents:e.registeredComponents,model:e.context.model})},f=function(){var i;return e.block.tagName==="a"||((i=c().properties)==null?void 0:i.href)||c().href?e.linkComponent||"a":e.block.tagName||"div"},B=function(){var s,k;if((s=e.block.repeat)!=null&&s.collection)return!!((k=d())!=null&&k.length);const r="hide"in c()?c().hide:!1;return("show"in c()?c().show:!0)&&!r},R=function(){var i,s;return!((i=l())!=null&&i.component)&&!d()?(s=c().children)!=null?s:[]:[]},n=function(){var r,i,s,k;return{blockChildren:(r=c().children)!=null?r:[],componentRef:(i=l())==null?void 0:i.component,componentOptions:{...S.getBlockComponentOptions(c(),e.context),...m.provideBuilderBlock(l(),c()),...m.provideBuilderContext(l(),e.context),...m.provideLinkComponent(l(),e.linkComponent),...m.provideRegisteredComponents(l(),e.registeredComponents,e.context.model)},context:e.context,linkComponent:e.linkComponent,registeredComponents:e.registeredComponents,builderBlock:c(),includeBlockProps:((s=l())==null?void 0:s.noWrap)===!0,isInteractive:!((k=l())!=null&&k.isRSC&&v.TARGET==="rsc")}};return t.jsx(t.Fragment,{children:B()?t.jsxs(t.Fragment,{children:[t.jsx(q,{block:c(),context:e.context}),(a=l())!=null&&a.noWrap?d()?t.jsx(t.Fragment,{children:(h=d())==null?void 0:h.map((o,r)=>t.jsx(g,{repeatContext:o.context,block:o.block,registeredComponents:e.registeredComponents,linkComponent:e.linkComponent},r))}):t.jsx(p,{componentRef:n().componentRef,componentOptions:n().componentOptions,blockChildren:n().blockChildren,context:n().context,registeredComponents:n().registeredComponents,linkComponent:n().linkComponent,builderBlock:n().builderBlock,includeBlockProps:n().includeBlockProps,isInteractive:n().isInteractive}):t.jsx(t.Fragment,{children:d()?t.jsx(t.Fragment,{children:(x=d())==null?void 0:x.map((o,r)=>t.jsx(g,{repeatContext:o.context,block:o.block,registeredComponents:e.registeredComponents,linkComponent:e.linkComponent},r))}):t.jsxs(O,{Wrapper:f(),block:c(),context:e.context,children:[t.jsx(p,{componentRef:n().componentRef,componentOptions:n().componentOptions,blockChildren:n().blockChildren,context:n().context,registeredComponents:n().registeredComponents,linkComponent:n().linkComponent,builderBlock:n().builderBlock,includeBlockProps:n().includeBlockProps,isInteractive:n().isInteractive}),(C=R())==null?void 0:C.map(o=>t.jsx(b,{block:o,registeredComponents:e.registeredComponents,linkComponent:e.linkComponent,context:e.context},o.id))]})})]}):null})}module.exports=b;
|
|
@@ -6,10 +6,10 @@ import { isPreviewing as I } from "../../functions/is-previewing.mjs";
|
|
|
6
6
|
import "../../functions/get-fetch.mjs";
|
|
7
7
|
import { getRepeatItemData as O, getComponent as w, provideBuilderBlock as W, provideBuilderContext as T, provideLinkComponent as L, provideRegisteredComponents as U } from "./block.helpers.mjs";
|
|
8
8
|
import j from "./components/block-styles.mjs";
|
|
9
|
-
import
|
|
9
|
+
import N from "./components/block-wrapper.mjs";
|
|
10
10
|
import x from "./components/component-ref/component-ref.mjs";
|
|
11
11
|
import b from "./components/repeated-block.mjs";
|
|
12
|
-
function
|
|
12
|
+
function y(e) {
|
|
13
13
|
var a, C, p, f;
|
|
14
14
|
const d = function() {
|
|
15
15
|
return O({
|
|
@@ -19,7 +19,7 @@ function N(e) {
|
|
|
19
19
|
}, s = {
|
|
20
20
|
value: null,
|
|
21
21
|
update: !1
|
|
22
|
-
},
|
|
22
|
+
}, n = function() {
|
|
23
23
|
var i;
|
|
24
24
|
if (s.value && !s.update && !I())
|
|
25
25
|
return s.value;
|
|
@@ -28,36 +28,35 @@ function N(e) {
|
|
|
28
28
|
localState: e.context.localState,
|
|
29
29
|
rootState: e.context.rootState,
|
|
30
30
|
rootSetState: e.context.rootSetState,
|
|
31
|
-
context: e.context.context
|
|
32
|
-
shouldEvaluateBindings: !0
|
|
31
|
+
context: e.context.context
|
|
33
32
|
});
|
|
34
33
|
return s.value = c, s.update = !1, c;
|
|
35
34
|
}, r = function() {
|
|
36
35
|
return w({
|
|
37
|
-
block:
|
|
36
|
+
block: n(),
|
|
38
37
|
registeredComponents: e.registeredComponents,
|
|
39
38
|
model: e.context.model
|
|
40
39
|
});
|
|
41
40
|
}, g = function() {
|
|
42
41
|
var i;
|
|
43
|
-
return e.block.tagName === "a" || ((i =
|
|
42
|
+
return e.block.tagName === "a" || ((i = n().properties) == null ? void 0 : i.href) || n().href ? e.linkComponent || "a" : e.block.tagName || "div";
|
|
44
43
|
}, B = function() {
|
|
45
44
|
var m, k;
|
|
46
45
|
if ((m = e.block.repeat) != null && m.collection)
|
|
47
46
|
return !!((k = d()) != null && k.length);
|
|
48
|
-
const c = "hide" in
|
|
49
|
-
return ("show" in
|
|
47
|
+
const c = "hide" in n() ? n().hide : !1;
|
|
48
|
+
return ("show" in n() ? n().show : !0) && !c;
|
|
50
49
|
}, R = function() {
|
|
51
50
|
var i, m;
|
|
52
|
-
return !((i = r()) != null && i.component) && !d() ? (m =
|
|
51
|
+
return !((i = r()) != null && i.component) && !d() ? (m = n().children) != null ? m : [] : [];
|
|
53
52
|
}, o = function() {
|
|
54
53
|
var c, i, m, k;
|
|
55
54
|
return {
|
|
56
|
-
blockChildren: (c =
|
|
55
|
+
blockChildren: (c = n().children) != null ? c : [],
|
|
57
56
|
componentRef: (i = r()) == null ? void 0 : i.component,
|
|
58
57
|
componentOptions: {
|
|
59
|
-
...S(
|
|
60
|
-
...W(r(),
|
|
58
|
+
...S(n(), e.context),
|
|
59
|
+
...W(r(), n()),
|
|
61
60
|
...T(r(), e.context),
|
|
62
61
|
...L(r(), e.linkComponent),
|
|
63
62
|
...U(
|
|
@@ -69,18 +68,18 @@ function N(e) {
|
|
|
69
68
|
context: e.context,
|
|
70
69
|
linkComponent: e.linkComponent,
|
|
71
70
|
registeredComponents: e.registeredComponents,
|
|
72
|
-
builderBlock:
|
|
71
|
+
builderBlock: n(),
|
|
73
72
|
includeBlockProps: ((m = r()) == null ? void 0 : m.noWrap) === !0,
|
|
74
73
|
isInteractive: !((k = r()) != null && k.isRSC && v === "rsc")
|
|
75
74
|
};
|
|
76
75
|
};
|
|
77
76
|
return /* @__PURE__ */ l(u, { children: B() ? /* @__PURE__ */ h(u, { children: [
|
|
78
|
-
/* @__PURE__ */ l(j, { block:
|
|
79
|
-
(a = r()) != null && a.noWrap ? d() ? /* @__PURE__ */ l(u, { children: (f = d()) == null ? void 0 : f.map((
|
|
77
|
+
/* @__PURE__ */ l(j, { block: n(), context: e.context }),
|
|
78
|
+
(a = r()) != null && a.noWrap ? d() ? /* @__PURE__ */ l(u, { children: (f = d()) == null ? void 0 : f.map((t, c) => /* @__PURE__ */ l(
|
|
80
79
|
b,
|
|
81
80
|
{
|
|
82
|
-
repeatContext:
|
|
83
|
-
block:
|
|
81
|
+
repeatContext: t.context,
|
|
82
|
+
block: t.block,
|
|
84
83
|
registeredComponents: e.registeredComponents,
|
|
85
84
|
linkComponent: e.linkComponent
|
|
86
85
|
},
|
|
@@ -98,20 +97,20 @@ function N(e) {
|
|
|
98
97
|
includeBlockProps: o().includeBlockProps,
|
|
99
98
|
isInteractive: o().isInteractive
|
|
100
99
|
}
|
|
101
|
-
) : /* @__PURE__ */ l(u, { children: d() ? /* @__PURE__ */ l(u, { children: (p = d()) == null ? void 0 : p.map((
|
|
100
|
+
) : /* @__PURE__ */ l(u, { children: d() ? /* @__PURE__ */ l(u, { children: (p = d()) == null ? void 0 : p.map((t, c) => /* @__PURE__ */ l(
|
|
102
101
|
b,
|
|
103
102
|
{
|
|
104
|
-
repeatContext:
|
|
105
|
-
block:
|
|
103
|
+
repeatContext: t.context,
|
|
104
|
+
block: t.block,
|
|
106
105
|
registeredComponents: e.registeredComponents,
|
|
107
106
|
linkComponent: e.linkComponent
|
|
108
107
|
},
|
|
109
108
|
c
|
|
110
109
|
)) }) : /* @__PURE__ */ h(
|
|
111
|
-
|
|
110
|
+
N,
|
|
112
111
|
{
|
|
113
112
|
Wrapper: g(),
|
|
114
|
-
block:
|
|
113
|
+
block: n(),
|
|
115
114
|
context: e.context,
|
|
116
115
|
children: [
|
|
117
116
|
/* @__PURE__ */ l(
|
|
@@ -128,15 +127,15 @@ function N(e) {
|
|
|
128
127
|
isInteractive: o().isInteractive
|
|
129
128
|
}
|
|
130
129
|
),
|
|
131
|
-
(C = R()) == null ? void 0 : C.map((
|
|
132
|
-
|
|
130
|
+
(C = R()) == null ? void 0 : C.map((t) => /* @__PURE__ */ l(
|
|
131
|
+
y,
|
|
133
132
|
{
|
|
134
|
-
block:
|
|
133
|
+
block: t,
|
|
135
134
|
registeredComponents: e.registeredComponents,
|
|
136
135
|
linkComponent: e.linkComponent,
|
|
137
136
|
context: e.context
|
|
138
137
|
},
|
|
139
|
-
|
|
138
|
+
t.id
|
|
140
139
|
))
|
|
141
140
|
]
|
|
142
141
|
}
|
|
@@ -144,5 +143,5 @@ function N(e) {
|
|
|
144
143
|
] }) : null });
|
|
145
144
|
}
|
|
146
145
|
export {
|
|
147
|
-
|
|
146
|
+
y as default
|
|
148
147
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";"use strict";const
|
|
1
|
+
"use client";"use strict";const w=require("react/jsx-runtime"),o=require("react"),F=require("../../../context/builder.context.cjs"),V=require("../../../functions/evaluate/evaluate.cjs"),M=require("../../../functions/fast-clone.cjs"),N=require("../../../functions/get-content/index.cjs"),k=require("../../../functions/is-browser.cjs"),g=require("../../../functions/is-editing.cjs"),O=require("../../../functions/is-previewing.cjs"),W=require("../../../functions/log-fetch.cjs"),A=require("../../../functions/register-component.cjs"),y=require("../../../functions/track/index.cjs"),$=require("../../../functions/track/interaction.cjs"),P=require("../../../helpers/canTrack.cjs"),z=require("../../../helpers/preview-lru-cache/set.cjs"),G=require("../../../helpers/subscribe-to-editor.cjs"),L=require("../../../scripts/init-editing.cjs"),J=require("../../block/animator.cjs"),H=require("./enable-editor.helpers.cjs"),Q=require("./styles.helpers.cjs"),X=require("next/navigation");function Y(e){var q,I,R;const l=o.useRef(null);function f(n){var i,a;const t={...e.builderContextSignal.rootState,...n};e.builderContextSignal.rootSetState?(a=(i=e.builderContextSignal).rootSetState)==null||a.call(i,t):e.builderContextSignal.rootState=t}function m(n){var i,a,r,c,d;const t={...e.builderContextSignal.content,...n,data:{...(i=e.builderContextSignal.content)==null?void 0:i.data,...n==null?void 0:n.data},meta:{...(a=e.builderContextSignal.content)==null?void 0:a.meta,...n==null?void 0:n.meta,breakpoints:((r=n==null?void 0:n.meta)==null?void 0:r.breakpoints)||((d=(c=e.builderContextSignal.content)==null?void 0:c.meta)==null?void 0:d.breakpoints)}};z.postPreviewContent({value:t,key:t.id}).then(()=>{j.refresh()})}function T(){return e.showContent?{}:{hidden:!0,"aria-hidden":!0}}const[D,Z]=o.useState(()=>e.contentWrapper||"div");function S(n){return G.createEditorListener({model:e.model,trustedHosts:e.trustedHosts,callbacks:{configureSdk:t=>{var r;const{breakpoints:i,contentId:a}=t;!a||a!==((r=e.builderContextSignal.content)==null?void 0:r.id)||i&&m({meta:{breakpoints:i}})},animation:t=>{J.triggerAnimation(t)},contentUpdate:t=>{m(t)}}})(n)}const[v,p]=o.useState(()=>({})),[b,ee]=o.useState(()=>({})),[h,K]=o.useState(()=>!1);function _(n){var t,i;if(e.builderContextSignal.content){const a=(t=e.builderContextSignal.content)==null?void 0:t.testVariationId,r=(i=e.builderContextSignal.content)==null?void 0:i.id;y._track({apiHost:e.apiHost,type:"click",canTrack:P.getDefaultCanTrack(e.canTrack),contentId:r,apiKey:e.apiKey,variationId:a!==r?a:void 0,...$.getInteractionPropertiesForEvent(n),unique:!h})}h||K(!0)}function U(){var t,i,a;const n=(a=(i=(t=e.builderContextSignal.content)==null?void 0:t.data)==null?void 0:i.httpRequests)!=null?a:{};Object.entries(n).forEach(([r,c])=>{if(!c||b[r]||v[r]&&!g.isEditing())return;b[r]=!0;const d=c.replace(/{{([^}]+)}}/g,(s,B)=>String(V.evaluate({code:B,context:e.context||{},localState:void 0,rootState:e.builderContextSignal.rootState,rootSetState:e.builderContextSignal.rootSetState})));W.logFetch(d),fetch(d).then(s=>s.json()).then(s=>{f({[r]:s}),v[r]=!0}).catch(s=>{console.error("error fetching dynamic data",c,s)}).finally(()=>{b[r]=!1})})}function u(){g.isEditing()&&window.dispatchEvent(new CustomEvent("builder:component:stateChange",{detail:{state:M.fastClone(e.builderContextSignal.rootState),ref:{name:e.model}}}))}function E(n){window.addEventListener("message",S),L.registerInsertMenu(),L.setupBrowserForEditing({...e.locale?{locale:e.locale}:{},...e.enrich?{enrich:e.enrich}:{},...e.trustedHosts?{trustedHosts:e.trustedHosts}:{}}),Object.values(e.builderContextSignal.componentInfos).forEach(t=>{var i,a;if(!e.model||!((i=t.models)!=null&&i.length)||t.models.includes(e.model)){const r=A.createRegisterComponentMessage(t);(a=window.parent)==null||a.postMessage(r,"*")}}),window.addEventListener("builder:component:stateChangeListenerActivated",u)}function x(n){var c;const t=new URL(location.href).searchParams,i=t.get("builder.preview"),a=t.get(`builder.overrides.${i}`),r=t.get("apiKey")||t.get("builder.space");(i==="BUILDER_STUDIO"||i===e.model&&r===e.apiKey&&(!e.content||a===e.content.id))&&N.fetchOneEntry({model:e.model||"",apiKey:e.apiKey,apiVersion:e.builderContextSignal.apiVersion,...i==="BUILDER_STUDIO"&&((c=e.context)!=null&&c.symbolId)?{query:{id:e.context.symbolId}}:{}}).then(d=>{d&&m(d)})}const j=X.useRouter(),C=o.useRef(!1);return C.current||(U(),u(),C.current=!0),o.useEffect(()=>{var n;return(n=l.current)==null||n.addEventListener("initeditingbldr",E),()=>{var t;return(t=l.current)==null?void 0:t.removeEventListener("initeditingbldr",E)}},[]),o.useEffect(()=>{var n;return(n=l.current)==null||n.addEventListener("initpreviewingbldr",x),()=>{var t;return(t=l.current)==null?void 0:t.removeEventListener("initpreviewingbldr",x)}},[]),o.useEffect(()=>{var n,t;if(k.isBrowser()){if(g.isEditing()&&!e.isNestedRender&&l.current&&l.current.dispatchEvent(new CustomEvent("initeditingbldr")),e.builderContextSignal.content&&P.getDefaultCanTrack(e.canTrack)){const a=(n=e.builderContextSignal.content)==null?void 0:n.testVariationId,r=(t=e.builderContextSignal.content)==null?void 0:t.id,c=e.apiKey;y._track({apiHost:e.apiHost,type:"impression",canTrack:!0,contentId:r,apiKey:c,variationId:a!==r?a:void 0})}O.isPreviewing()&&g.isEditing()}},[]),o.useEffect(()=>{},[e.content]),o.useEffect(()=>{u()},[e.builderContextSignal.rootState]),o.useEffect(()=>{e.data&&f(e.data)},[e.data]),o.useEffect(()=>{e.locale&&f({locale:e.locale})},[e.locale]),o.useEffect(()=>()=>{k.isBrowser()&&(window.removeEventListener("message",S),window.removeEventListener("builder:component:stateChangeListenerActivated",u))},[]),w.jsx(F.Provider,{value:e.builderContextSignal,children:e.builderContextSignal.content||H.needsElementRefDivForEditing()?w.jsx(D,{ref:l,onClick:n=>_(n),"builder-content-id":(q=e.builderContextSignal.content)==null?void 0:q.id,"builder-model":e.model,className:Q.getWrapperClassName(((I=e.content)==null?void 0:I.testVariationId)||((R=e.content)==null?void 0:R.id)),style:{display:!e.builderContextSignal.content&&H.needsElementRefDivForEditing()?"none":void 0},...T(),...e.contentWrapperProps,children:e.children}):null})}module.exports=Y;
|