@builder.io/sdk-vue
Version:
Builder.io SDK for Vue
167 lines (166 loc) • 4.45 kB
JavaScript
import { defineComponent as u, defineAsyncComponent as g, resolveComponent as k, openBlock as n, createBlock as a, withCtx as l, renderSlot as m, resolveDynamicComponent as h, normalizeProps as f, mergeProps as b, createElementBlock as B, Fragment as W, renderList as $, createCommentVNode as v } from "vue";
import { d as C, B as y, w as S } from "./index-HR8y_fPw.js";
import { a as w, g as A } from "./get-block-properties-LchfO6Kb.js";
const R = () => import("./awaiter-VENdQO6n.js").then((e) => e.default).catch((e) => {
throw console.error(
"Error while attempting to dynamically import component Awaiter at ../../awaiter.vue",
e
), e;
}), E = u({
name: "interactive-element",
components: { Awaiter: g(R) },
props: ["wrapperProps", "block", "includeBlockProps", "context", "Wrapper"],
data() {
return { forceRenderCount: 0 };
},
watch: {
onUpdateHook0: { handler() {
}, immediate: !0 }
},
computed: {
attributes() {
return this.includeBlockProps ? {
...w({
block: this.block,
context: this.context
}),
...A({
block: this.block,
rootState: this.context.rootState,
rootSetState: this.context.rootSetState,
localState: this.context.localState,
context: this.context.context
})
} : {};
},
targetWrapperProps() {
return {
...this.wrapperProps,
...Object.keys(this.attributes).length > 0 ? {
attributes: this.attributes
} : {}
};
},
onUpdateHook0() {
var e, t;
return {
0: this.wrapperProps,
1: (t = (e = this.block) == null ? void 0 : e.component) == null ? void 0 : t.options
};
}
}
});
function I(e, t, s, i, r, c) {
const o = k("Awaiter");
return e.Wrapper.load ? (n(), a(o, {
key: 0,
load: e.Wrapper.load,
fallback: e.Wrapper.fallback,
props: e.wrapperProps,
attributes: e.attributes
}, {
default: l(() => [
m(e.$slots, "default")
]),
_: 3
}, 8, ["load", "fallback", "props", "attributes"])) : (n(), a(h(e.Wrapper), f(b({ key: 1 }, e.targetWrapperProps)), {
default: l(() => [
m(e.$slots, "default")
]),
_: 3
}, 16));
}
const d = /* @__PURE__ */ C(E, [["render", I]]), U = ({
componentOptions: e,
builderBlock: t,
context: s,
componentRef: i,
includeBlockProps: r,
isInteractive: c,
contextValue: o
}) => {
const p = {
...e,
/**
* If `noWrap` is set to `true`, then the block's props/attributes are provided to the
* component itself directly. Otherwise, they are provided to the wrapper element.
*/
...r ? {
attributes: w({
block: t,
context: o
})
} : {}
};
return c ? {
Wrapper: i,
block: t,
context: s,
wrapperProps: e,
includeBlockProps: r
} : p;
}, H = u({
name: "component-ref",
components: { Block: y, InteractiveElement: d },
props: [
"componentOptions",
"blockChildren",
"isInteractive",
"componentRef",
"builderBlock",
"context",
"linkComponent",
"includeBlockProps",
"registeredComponents"
],
data() {
return {
shouldUpdate: !1,
Wrapper: this.isInteractive ? S(d) : this.componentRef,
getWrapperProps: U
};
},
watch: {
onUpdateHook0: { handler() {
}, immediate: !0 }
},
computed: {
onUpdateHook0() {
return {
0: this.componentOptions,
1: this.blockChildren
};
}
}
});
function O(e, t, s, i, r, c) {
const o = k("Block");
return e.componentRef ? (n(), a(h(e.Wrapper), f(b(
{ key: 0 },
e.getWrapperProps({
componentOptions: e.componentOptions,
builderBlock: e.builderBlock,
context: e.context,
componentRef: e.componentRef,
linkComponent: e.linkComponent,
includeBlockProps: e.includeBlockProps,
isInteractive: e.isInteractive,
contextValue: e.context
})
)), {
default: l(() => [
(n(!0), B(W, null, $(e.blockChildren, (p, P) => (n(), a(o, {
key: p.id,
block: p,
context: e.context,
registeredComponents: e.registeredComponents,
linkComponent: e.linkComponent
}, null, 8, ["block", "context", "registeredComponents", "linkComponent"]))), 128))
]),
_: 1
}, 16)) : v("", !0);
}
const D = /* @__PURE__ */ C(H, [["render", O]]);
export {
D as default
};