@builder.io/sdk-qwik 0.0.8 → 0.0.11
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/README.md +65 -2
- package/lib/index.qwik.cjs +259 -216
- package/lib/index.qwik.mjs +260 -217
- package/package.json +4 -4
- package/src/blocks/button/button.jsx +22 -0
- package/src/blocks/button/component-info.js +41 -0
- package/src/blocks/columns/columns.jsx +97 -0
- package/src/blocks/columns/component-info.js +242 -0
- package/src/blocks/custom-code/component-info.js +31 -0
- package/src/blocks/custom-code/custom-code.jsx +71 -0
- package/src/blocks/embed/component-info.js +44 -0
- package/src/blocks/embed/embed.jsx +63 -0
- package/src/blocks/embed/helpers.js +9 -0
- package/src/blocks/form/builder-blocks.jsx +11 -0
- package/src/blocks/form/component-info.js +262 -0
- package/src/blocks/form/form.jsx +303 -0
- package/src/blocks/fragment/component-info.js +11 -0
- package/src/blocks/fragment/fragment.jsx +11 -0
- package/src/blocks/image/component-info.js +151 -0
- package/src/blocks/image/image.helpers.js +48 -0
- package/src/blocks/image/image.jsx +110 -0
- package/src/blocks/img/component-info.js +20 -0
- package/src/blocks/img/img.jsx +19 -0
- package/src/blocks/input/component-info.js +74 -0
- package/src/blocks/input/input.jsx +21 -0
- package/src/blocks/raw-text/component-info.js +16 -0
- package/src/blocks/raw-text/raw-text.jsx +12 -0
- package/src/blocks/section/component-info.js +49 -0
- package/src/blocks/section/section.jsx +20 -0
- package/src/blocks/select/component-info.js +59 -0
- package/src/blocks/select/select.jsx +24 -0
- package/src/blocks/submit-button/component-info.js +28 -0
- package/src/blocks/submit-button/submit-button.jsx +11 -0
- package/src/blocks/symbol/component-info.js +43 -0
- package/src/blocks/symbol/symbol.jsx +77 -0
- package/src/blocks/text/component-info.js +24 -0
- package/src/blocks/text/text.jsx +7 -0
- package/src/blocks/textarea/component-info.js +47 -0
- package/src/blocks/textarea/textarea.jsx +15 -0
- package/src/blocks/util.js +7 -0
- package/src/blocks/video/component-info.js +106 -0
- package/src/blocks/video/video.jsx +53 -0
- package/src/components/render-block/block-styles.jsx +60 -0
- package/src/components/render-block/render-block.helpers.js +23 -0
- package/src/components/render-block/render-block.jsx +221 -0
- package/src/components/render-block/render-component.jsx +34 -0
- package/src/components/render-block/render-repeated-block.jsx +37 -0
- package/src/components/render-block/types.js +0 -0
- package/src/components/render-blocks.jsx +93 -0
- package/src/components/render-content/components/render-styles.jsx +76 -0
- package/src/components/render-content/index.js +4 -0
- package/src/components/render-content/render-content.jsx +351 -0
- package/src/components/render-inlined-styles.jsx +25 -0
- package/src/constants/builder-registered-components.js +48 -0
- package/src/constants/device-sizes.js +21 -0
- package/src/constants/target.js +4 -0
- package/src/context/builder.context.js +5 -0
- package/src/functions/camel-to-kebab-case.js +4 -0
- package/src/functions/convert-style-object.js +6 -0
- package/src/functions/evaluate.js +28 -0
- package/src/functions/event-handler-name.js +7 -0
- package/src/functions/get-block-actions.js +23 -0
- package/src/functions/get-block-component-options.js +28 -0
- package/src/functions/get-block-properties.js +29 -0
- package/src/functions/get-block-styles.js +34 -0
- package/src/functions/get-block-tag.js +6 -0
- package/src/functions/get-builder-search-params/fn.test.js +13 -0
- package/src/functions/get-builder-search-params/index.js +33 -0
- package/src/functions/get-content/ab-testing.js +38 -0
- package/src/functions/get-content/fn.test.js +31 -0
- package/src/functions/get-content/index.js +96 -0
- package/src/functions/get-content/types.js +0 -0
- package/src/functions/get-fetch.js +34 -0
- package/src/functions/get-global-this.js +18 -0
- package/src/functions/get-processed-block.js +53 -0
- package/src/functions/get-processed-block.test.js +32 -0
- package/src/functions/if-target.js +15 -0
- package/src/functions/is-browser.js +6 -0
- package/src/functions/is-editing.js +7 -0
- package/src/functions/is-iframe.js +7 -0
- package/src/functions/is-previewing.js +14 -0
- package/src/functions/on-change.js +27 -0
- package/src/functions/on-change.test.js +19 -0
- package/src/functions/register-component.js +72 -0
- package/src/functions/register.js +29 -0
- package/src/functions/sanitize-styles.js +5 -0
- package/src/functions/set-editor-settings.js +15 -0
- package/src/functions/set.js +11 -0
- package/src/functions/set.test.js +16 -0
- package/src/functions/track.js +22 -0
- package/src/functions/transform-block.js +6 -0
- package/src/helpers/css.js +12 -0
- package/src/helpers/flatten.js +34 -0
- package/src/index-helpers/blocks-exports.js +22 -0
- package/src/index-helpers/top-of-file.js +4 -0
- package/src/index.js +10 -0
- package/src/scripts/init-editing.js +79 -0
- package/src/types/builder-block.js +0 -0
- package/src/types/builder-content.js +0 -0
- package/src/types/components.js +0 -0
- package/src/types/deep-partial.js +0 -0
- package/src/types/element.js +0 -0
- package/src/types/targets.js +0 -0
- package/src/types/typescript.js +0 -0
- package/types.d.ts +7 -12
- package/root.json +0 -1176
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
const componentInfo = {
|
|
2
|
+
name: "Symbol",
|
|
3
|
+
noWrap: true,
|
|
4
|
+
static: true,
|
|
5
|
+
builtIn: true,
|
|
6
|
+
inputs: [
|
|
7
|
+
{
|
|
8
|
+
name: "symbol",
|
|
9
|
+
type: "uiSymbol"
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
name: "dataOnly",
|
|
13
|
+
helperText: "Make this a data symbol that doesn't display any UI",
|
|
14
|
+
type: "boolean",
|
|
15
|
+
defaultValue: false,
|
|
16
|
+
advanced: true,
|
|
17
|
+
hideFromUI: true
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
name: "inheritState",
|
|
21
|
+
helperText: "Inherit the parent component state and data",
|
|
22
|
+
type: "boolean",
|
|
23
|
+
defaultValue: false,
|
|
24
|
+
advanced: true
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
name: "renderToLiquid",
|
|
28
|
+
helperText: "Render this symbols contents to liquid. Turn off to fetch with javascript and use custom targeting",
|
|
29
|
+
type: "boolean",
|
|
30
|
+
defaultValue: false,
|
|
31
|
+
advanced: true,
|
|
32
|
+
hideFromUI: true
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
name: "useChildren",
|
|
36
|
+
hideFromUI: true,
|
|
37
|
+
type: "boolean"
|
|
38
|
+
}
|
|
39
|
+
]
|
|
40
|
+
};
|
|
41
|
+
export {
|
|
42
|
+
componentInfo
|
|
43
|
+
};
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
// GENERATED BY MITOSIS
|
|
2
|
+
|
|
3
|
+
import RenderContent from "../../components/render-content/render-content";
|
|
4
|
+
import BuilderContext from "../../context/builder.context";
|
|
5
|
+
import { getContent } from "../../functions/get-content/index.js";
|
|
6
|
+
import {
|
|
7
|
+
Fragment,
|
|
8
|
+
component$,
|
|
9
|
+
h,
|
|
10
|
+
useClientEffect$,
|
|
11
|
+
useContext,
|
|
12
|
+
useStore,
|
|
13
|
+
useWatch$,
|
|
14
|
+
} from "@builder.io/qwik";
|
|
15
|
+
export const Symbol = component$((props) => {
|
|
16
|
+
const builderContext = useContext(BuilderContext);
|
|
17
|
+
const state = useStore({ className: "builder-symbol", content: null });
|
|
18
|
+
useClientEffect$(() => {
|
|
19
|
+
state.content = props.symbol?.content;
|
|
20
|
+
});
|
|
21
|
+
useWatch$(({ track }) => {
|
|
22
|
+
props.symbol && track(props.symbol, "content");
|
|
23
|
+
props.symbol && track(props.symbol, "model");
|
|
24
|
+
props.symbol && track(props.symbol, "entry");
|
|
25
|
+
state && track(state, "content");
|
|
26
|
+
const symbolToUse = props.symbol;
|
|
27
|
+
/**
|
|
28
|
+
* If:
|
|
29
|
+
* - we have a symbol prop
|
|
30
|
+
* - yet it does not have any content
|
|
31
|
+
* - and we have not already stored content from before
|
|
32
|
+
* - and it has a model name
|
|
33
|
+
*
|
|
34
|
+
* then we want to re-fetch the symbol content.
|
|
35
|
+
*/
|
|
36
|
+
|
|
37
|
+
if (
|
|
38
|
+
symbolToUse &&
|
|
39
|
+
!symbolToUse.content &&
|
|
40
|
+
!state.content &&
|
|
41
|
+
symbolToUse.model
|
|
42
|
+
) {
|
|
43
|
+
getContent({
|
|
44
|
+
model: symbolToUse.model,
|
|
45
|
+
apiKey: builderContext.apiKey,
|
|
46
|
+
query: {
|
|
47
|
+
id: symbolToUse.entry,
|
|
48
|
+
},
|
|
49
|
+
}).then((response) => {
|
|
50
|
+
state.content = response;
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
return (
|
|
55
|
+
<div
|
|
56
|
+
{...props.attributes}
|
|
57
|
+
dataSet={{
|
|
58
|
+
class: state.className,
|
|
59
|
+
}}
|
|
60
|
+
class={state.className}
|
|
61
|
+
>
|
|
62
|
+
<RenderContent
|
|
63
|
+
apiKey={builderContext.apiKey}
|
|
64
|
+
context={builderContext.context}
|
|
65
|
+
customComponents={Object.values(builderContext.registeredComponents)}
|
|
66
|
+
data={{
|
|
67
|
+
...props.symbol?.data,
|
|
68
|
+
...builderContext.state,
|
|
69
|
+
...props.symbol?.content?.data?.state,
|
|
70
|
+
}}
|
|
71
|
+
model={props.symbol?.model}
|
|
72
|
+
content={state.content}
|
|
73
|
+
></RenderContent>
|
|
74
|
+
</div>
|
|
75
|
+
);
|
|
76
|
+
});
|
|
77
|
+
export default Symbol;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
const componentInfo = {
|
|
2
|
+
name: "Text",
|
|
3
|
+
static: true,
|
|
4
|
+
builtIn: true,
|
|
5
|
+
image: "https://firebasestorage.googleapis.com/v0/b/builder-3b0a2.appspot.com/o/images%2Fbaseline-text_fields-24px%20(1).svg?alt=media&token=12177b73-0ee3-42ca-98c6-0dd003de1929",
|
|
6
|
+
inputs: [
|
|
7
|
+
{
|
|
8
|
+
name: "text",
|
|
9
|
+
type: "html",
|
|
10
|
+
required: true,
|
|
11
|
+
autoFocus: true,
|
|
12
|
+
bubble: true,
|
|
13
|
+
defaultValue: "Enter some text..."
|
|
14
|
+
}
|
|
15
|
+
],
|
|
16
|
+
defaultStyles: {
|
|
17
|
+
lineHeight: "normal",
|
|
18
|
+
height: "auto",
|
|
19
|
+
textAlign: "center"
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
export {
|
|
23
|
+
componentInfo
|
|
24
|
+
};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
const componentInfo = {
|
|
2
|
+
name: "Form:TextArea",
|
|
3
|
+
builtIn: true,
|
|
4
|
+
image: "https://cdn.builder.io/api/v1/image/assets%2FIsxPKMo2gPRRKeakUztj1D6uqed2%2Ff74a2f3de58c4c3e939204e5b6b8f6c3",
|
|
5
|
+
inputs: [
|
|
6
|
+
{
|
|
7
|
+
advanced: true,
|
|
8
|
+
name: "value",
|
|
9
|
+
type: "string"
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
name: "name",
|
|
13
|
+
type: "string",
|
|
14
|
+
required: true,
|
|
15
|
+
helperText: 'Every input in a form needs a unique name describing what it gets, e.g. "email"'
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
name: "defaultValue",
|
|
19
|
+
type: "string"
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
name: "placeholder",
|
|
23
|
+
type: "string",
|
|
24
|
+
defaultValue: "Hello there"
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
name: "required",
|
|
28
|
+
type: "boolean",
|
|
29
|
+
defaultValue: false
|
|
30
|
+
}
|
|
31
|
+
],
|
|
32
|
+
defaultStyles: {
|
|
33
|
+
paddingTop: "10px",
|
|
34
|
+
paddingBottom: "10px",
|
|
35
|
+
paddingLeft: "10px",
|
|
36
|
+
paddingRight: "10px",
|
|
37
|
+
borderRadius: "3px",
|
|
38
|
+
borderWidth: "1px",
|
|
39
|
+
borderStyle: "solid",
|
|
40
|
+
borderColor: "#ccc"
|
|
41
|
+
},
|
|
42
|
+
static: true,
|
|
43
|
+
noWrap: true
|
|
44
|
+
};
|
|
45
|
+
export {
|
|
46
|
+
componentInfo
|
|
47
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
// GENERATED BY MITOSIS
|
|
2
|
+
|
|
3
|
+
import { Fragment, component$, h } from "@builder.io/qwik";
|
|
4
|
+
export const Textarea = component$((props) => {
|
|
5
|
+
return (
|
|
6
|
+
<textarea
|
|
7
|
+
{...props.attributes}
|
|
8
|
+
placeholder={props.placeholder}
|
|
9
|
+
name={props.name}
|
|
10
|
+
value={props.value}
|
|
11
|
+
defaultValue={props.defaultValue}
|
|
12
|
+
></textarea>
|
|
13
|
+
);
|
|
14
|
+
});
|
|
15
|
+
export default Textarea;
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
const componentInfo = {
|
|
2
|
+
name: "Video",
|
|
3
|
+
canHaveChildren: true,
|
|
4
|
+
builtIn: true,
|
|
5
|
+
defaultStyles: {
|
|
6
|
+
minHeight: "20px",
|
|
7
|
+
minWidth: "20px"
|
|
8
|
+
},
|
|
9
|
+
image: "https://firebasestorage.googleapis.com/v0/b/builder-3b0a2.appspot.com/o/images%2Fbaseline-videocam-24px%20(1).svg?alt=media&token=49a84e4a-b20e-4977-a650-047f986874bb",
|
|
10
|
+
inputs: [
|
|
11
|
+
{
|
|
12
|
+
name: "video",
|
|
13
|
+
type: "file",
|
|
14
|
+
allowedFileTypes: ["mp4"],
|
|
15
|
+
bubble: true,
|
|
16
|
+
defaultValue: "https://firebasestorage.googleapis.com/v0/b/builder-3b0a2.appspot.com/o/assets%2FKQlEmWDxA0coC3PK6UvkrjwkIGI2%2F28cb070609f546cdbe5efa20e931aa4b?alt=media&token=912e9551-7a7c-4dfb-86b6-3da1537d1a7f",
|
|
17
|
+
required: true
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
name: "posterImage",
|
|
21
|
+
type: "file",
|
|
22
|
+
allowedFileTypes: ["jpeg", "png"],
|
|
23
|
+
helperText: "Image to show before the video plays"
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
name: "autoPlay",
|
|
27
|
+
type: "boolean",
|
|
28
|
+
defaultValue: true
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
name: "controls",
|
|
32
|
+
type: "boolean",
|
|
33
|
+
defaultValue: false
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
name: "muted",
|
|
37
|
+
type: "boolean",
|
|
38
|
+
defaultValue: true
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
name: "loop",
|
|
42
|
+
type: "boolean",
|
|
43
|
+
defaultValue: true
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
name: "playsInline",
|
|
47
|
+
type: "boolean",
|
|
48
|
+
defaultValue: true
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
name: "fit",
|
|
52
|
+
type: "text",
|
|
53
|
+
defaultValue: "cover",
|
|
54
|
+
enum: ["contain", "cover", "fill", "auto"]
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
name: "fitContent",
|
|
58
|
+
type: "boolean",
|
|
59
|
+
helperText: "When child blocks are provided, fit to them instead of using the aspect ratio",
|
|
60
|
+
defaultValue: true,
|
|
61
|
+
advanced: true
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
name: "position",
|
|
65
|
+
type: "text",
|
|
66
|
+
defaultValue: "center",
|
|
67
|
+
enum: [
|
|
68
|
+
"center",
|
|
69
|
+
"top",
|
|
70
|
+
"left",
|
|
71
|
+
"right",
|
|
72
|
+
"bottom",
|
|
73
|
+
"top left",
|
|
74
|
+
"top right",
|
|
75
|
+
"bottom left",
|
|
76
|
+
"bottom right"
|
|
77
|
+
]
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
name: "height",
|
|
81
|
+
type: "number",
|
|
82
|
+
advanced: true
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
name: "width",
|
|
86
|
+
type: "number",
|
|
87
|
+
advanced: true
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
name: "aspectRatio",
|
|
91
|
+
type: "number",
|
|
92
|
+
advanced: true,
|
|
93
|
+
defaultValue: 0.7004048582995948
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
name: "lazyLoad",
|
|
97
|
+
type: "boolean",
|
|
98
|
+
helperText: 'Load this video "lazily" - as in only when a user scrolls near the video. Recommended for optmized performance and bandwidth consumption',
|
|
99
|
+
defaultValue: true,
|
|
100
|
+
advanced: true
|
|
101
|
+
}
|
|
102
|
+
]
|
|
103
|
+
};
|
|
104
|
+
export {
|
|
105
|
+
componentInfo
|
|
106
|
+
};
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
// GENERATED BY MITOSIS
|
|
2
|
+
|
|
3
|
+
import { Fragment, component$, h } from "@builder.io/qwik";
|
|
4
|
+
export const videoProps = function videoProps(props, state) {
|
|
5
|
+
return {
|
|
6
|
+
...(props.autoPlay === true
|
|
7
|
+
? {
|
|
8
|
+
autoPlay: true,
|
|
9
|
+
}
|
|
10
|
+
: {}),
|
|
11
|
+
...(props.muted === true
|
|
12
|
+
? {
|
|
13
|
+
muted: true,
|
|
14
|
+
}
|
|
15
|
+
: {}),
|
|
16
|
+
...(props.controls === true
|
|
17
|
+
? {
|
|
18
|
+
controls: true,
|
|
19
|
+
}
|
|
20
|
+
: {}),
|
|
21
|
+
...(props.loop === true
|
|
22
|
+
? {
|
|
23
|
+
loop: true,
|
|
24
|
+
}
|
|
25
|
+
: {}),
|
|
26
|
+
...(props.playsInline === true
|
|
27
|
+
? {
|
|
28
|
+
playsInline: true,
|
|
29
|
+
}
|
|
30
|
+
: {}),
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
export const Video = component$((props) => {
|
|
34
|
+
const state = {};
|
|
35
|
+
return (
|
|
36
|
+
<video
|
|
37
|
+
{...videoProps(props, state)}
|
|
38
|
+
style={{
|
|
39
|
+
width: "100%",
|
|
40
|
+
height: "100%",
|
|
41
|
+
...props.attributes?.style,
|
|
42
|
+
objectFit: props.fit,
|
|
43
|
+
objectPosition: props.position,
|
|
44
|
+
// Hack to get object fit to work as expected and
|
|
45
|
+
// not have the video overflow
|
|
46
|
+
borderRadius: 1,
|
|
47
|
+
}}
|
|
48
|
+
src={props.video || "no-src"}
|
|
49
|
+
poster={props.posterImage}
|
|
50
|
+
></video>
|
|
51
|
+
);
|
|
52
|
+
});
|
|
53
|
+
export default Video;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
// GENERATED BY MITOSIS
|
|
2
|
+
|
|
3
|
+
import { getMaxWidthQueryForSize } from "../../constants/device-sizes.js";
|
|
4
|
+
import { TARGET } from "../../constants/target.js";
|
|
5
|
+
import { getProcessedBlock } from "../../functions/get-processed-block.js";
|
|
6
|
+
import { convertStyleMaptoCSS } from "../../helpers/css.js";
|
|
7
|
+
import RenderInlinedStyles from "../render-inlined-styles";
|
|
8
|
+
import { Fragment, h } from "@builder.io/qwik";
|
|
9
|
+
export const useBlock = function useBlock(props, state) {
|
|
10
|
+
return getProcessedBlock({
|
|
11
|
+
block: props.block,
|
|
12
|
+
state: props.context.state,
|
|
13
|
+
context: props.context.context,
|
|
14
|
+
evaluateBindings: true,
|
|
15
|
+
});
|
|
16
|
+
};
|
|
17
|
+
export const css = function css(props, state) {
|
|
18
|
+
const styles = useBlock(props, state).responsiveStyles;
|
|
19
|
+
const largeStyles = styles?.large;
|
|
20
|
+
const mediumStyles = styles?.medium;
|
|
21
|
+
const smallStyles = styles?.small;
|
|
22
|
+
return `
|
|
23
|
+
${
|
|
24
|
+
largeStyles
|
|
25
|
+
? `.${useBlock(props, state).id} {${convertStyleMaptoCSS(
|
|
26
|
+
largeStyles
|
|
27
|
+
)}}`
|
|
28
|
+
: ""
|
|
29
|
+
}
|
|
30
|
+
${
|
|
31
|
+
mediumStyles
|
|
32
|
+
? `${getMaxWidthQueryForSize("medium")} {
|
|
33
|
+
.${useBlock(props, state).id} {${convertStyleMaptoCSS(
|
|
34
|
+
mediumStyles
|
|
35
|
+
)}}
|
|
36
|
+
}`
|
|
37
|
+
: ""
|
|
38
|
+
}
|
|
39
|
+
${
|
|
40
|
+
smallStyles
|
|
41
|
+
? `${getMaxWidthQueryForSize("small")} {
|
|
42
|
+
.${useBlock(props, state).id} {${convertStyleMaptoCSS(
|
|
43
|
+
smallStyles
|
|
44
|
+
)}}
|
|
45
|
+
}`
|
|
46
|
+
: ""
|
|
47
|
+
}
|
|
48
|
+
}`;
|
|
49
|
+
};
|
|
50
|
+
export const BlockStyles = (props) => {
|
|
51
|
+
const state = {};
|
|
52
|
+
return (
|
|
53
|
+
<>
|
|
54
|
+
{TARGET === "vue2" || TARGET === "vue3" || TARGET === "svelte" ? (
|
|
55
|
+
<RenderInlinedStyles styles={css(props, state)}></RenderInlinedStyles>
|
|
56
|
+
) : null}
|
|
57
|
+
</>
|
|
58
|
+
);
|
|
59
|
+
};
|
|
60
|
+
export default BlockStyles;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
const EMPTY_HTML_ELEMENTS = [
|
|
2
|
+
"area",
|
|
3
|
+
"base",
|
|
4
|
+
"br",
|
|
5
|
+
"col",
|
|
6
|
+
"embed",
|
|
7
|
+
"hr",
|
|
8
|
+
"img",
|
|
9
|
+
"input",
|
|
10
|
+
"keygen",
|
|
11
|
+
"link",
|
|
12
|
+
"meta",
|
|
13
|
+
"param",
|
|
14
|
+
"source",
|
|
15
|
+
"track",
|
|
16
|
+
"wbr"
|
|
17
|
+
];
|
|
18
|
+
const isEmptyHtmlElement = (tagName) => {
|
|
19
|
+
return typeof tagName === "string" && EMPTY_HTML_ELEMENTS.includes(tagName.toLowerCase());
|
|
20
|
+
};
|
|
21
|
+
export {
|
|
22
|
+
isEmptyHtmlElement
|
|
23
|
+
};
|
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
// GENERATED BY MITOSIS
|
|
2
|
+
|
|
3
|
+
import { evaluate } from "../../functions/evaluate.js";
|
|
4
|
+
import { getBlockActions } from "../../functions/get-block-actions.js";
|
|
5
|
+
import { getBlockComponentOptions } from "../../functions/get-block-component-options.js";
|
|
6
|
+
import { getBlockProperties } from "../../functions/get-block-properties.js";
|
|
7
|
+
import { getBlockStyles } from "../../functions/get-block-styles.js";
|
|
8
|
+
import { getBlockTag } from "../../functions/get-block-tag.js";
|
|
9
|
+
import { getProcessedBlock } from "../../functions/get-processed-block.js";
|
|
10
|
+
import BlockStyles from "./block-styles";
|
|
11
|
+
import { isEmptyHtmlElement } from "./render-block.helpers.js";
|
|
12
|
+
import RenderComponent from "./render-component";
|
|
13
|
+
import RenderRepeatedBlock from "./render-repeated-block";
|
|
14
|
+
import { Fragment, h } from "@builder.io/qwik";
|
|
15
|
+
export const component = function component(props, state) {
|
|
16
|
+
const componentName = getProcessedBlock({
|
|
17
|
+
block: props.block,
|
|
18
|
+
state: props.context.state,
|
|
19
|
+
context: props.context.context,
|
|
20
|
+
evaluateBindings: false,
|
|
21
|
+
}).component?.name;
|
|
22
|
+
|
|
23
|
+
if (!componentName) {
|
|
24
|
+
return null;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const ref = props.context.registeredComponents[componentName];
|
|
28
|
+
|
|
29
|
+
if (!ref) {
|
|
30
|
+
// TODO: Public doc page with more info about this message
|
|
31
|
+
console.warn(`
|
|
32
|
+
Could not find a registered component named "${componentName}".
|
|
33
|
+
If you registered it, is the file that registered it imported by the file that needs to render it?`);
|
|
34
|
+
return undefined;
|
|
35
|
+
} else {
|
|
36
|
+
return ref;
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
export const componentInfo = function componentInfo(props, state) {
|
|
40
|
+
if (component(props, state)) {
|
|
41
|
+
const { component: _, ...info } = component(props, state);
|
|
42
|
+
return info;
|
|
43
|
+
} else {
|
|
44
|
+
return undefined;
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
export const componentRef = function componentRef(props, state) {
|
|
48
|
+
return component(props, state)?.component;
|
|
49
|
+
};
|
|
50
|
+
export const tagName = function tagName(props, state) {
|
|
51
|
+
return getBlockTag(useBlock(props, state));
|
|
52
|
+
};
|
|
53
|
+
export const useBlock = function useBlock(props, state) {
|
|
54
|
+
return repeatItemData(props, state)
|
|
55
|
+
? props.block
|
|
56
|
+
: getProcessedBlock({
|
|
57
|
+
block: props.block,
|
|
58
|
+
state: props.context.state,
|
|
59
|
+
context: props.context.context,
|
|
60
|
+
evaluateBindings: true,
|
|
61
|
+
});
|
|
62
|
+
};
|
|
63
|
+
export const attributes = function attributes(props, state) {
|
|
64
|
+
return {
|
|
65
|
+
...getBlockProperties(useBlock(props, state)),
|
|
66
|
+
...getBlockActions({
|
|
67
|
+
block: useBlock(props, state),
|
|
68
|
+
state: props.context.state,
|
|
69
|
+
context: props.context.context,
|
|
70
|
+
}),
|
|
71
|
+
style: getBlockStyles(useBlock(props, state)),
|
|
72
|
+
};
|
|
73
|
+
};
|
|
74
|
+
export const shouldWrap = function shouldWrap(props, state) {
|
|
75
|
+
return !componentInfo(props, state)?.noWrap;
|
|
76
|
+
};
|
|
77
|
+
export const componentOptions = function componentOptions(props, state) {
|
|
78
|
+
return {
|
|
79
|
+
...getBlockComponentOptions(useBlock(props, state)),
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* These attributes are passed to the wrapper element when there is one. If `noWrap` is set to true, then
|
|
83
|
+
* they are provided to the component itself directly.
|
|
84
|
+
*/
|
|
85
|
+
...(shouldWrap(props, state)
|
|
86
|
+
? {}
|
|
87
|
+
: {
|
|
88
|
+
attributes: attributes(props, state),
|
|
89
|
+
}),
|
|
90
|
+
};
|
|
91
|
+
};
|
|
92
|
+
export const renderComponentProps = function renderComponentProps(
|
|
93
|
+
props,
|
|
94
|
+
state
|
|
95
|
+
) {
|
|
96
|
+
return {
|
|
97
|
+
blockChildren: children(props, state),
|
|
98
|
+
componentRef: componentRef(props, state),
|
|
99
|
+
componentOptions: componentOptions(props, state),
|
|
100
|
+
context: props.context,
|
|
101
|
+
};
|
|
102
|
+
};
|
|
103
|
+
export const children = function children(props, state) {
|
|
104
|
+
// TO-DO: When should `canHaveChildren` dictate rendering?
|
|
105
|
+
// This is currently commented out because some Builder components (e.g. Box) do not have `canHaveChildren: true`,
|
|
106
|
+
// but still receive and need to render children.
|
|
107
|
+
// return state.componentInfo?.canHaveChildren ? state.useBlock.children : [];
|
|
108
|
+
return useBlock(props, state).children ?? [];
|
|
109
|
+
};
|
|
110
|
+
export const childrenWithoutParentComponent =
|
|
111
|
+
function childrenWithoutParentComponent(props, state) {
|
|
112
|
+
/**
|
|
113
|
+
* When there is no `componentRef`, there might still be children that need to be rendered. In this case,
|
|
114
|
+
* we render them outside of `componentRef`.
|
|
115
|
+
* NOTE: We make sure not to render this if `repeatItemData` is non-null, because that means we are rendering an array of
|
|
116
|
+
* blocks, and the children will be repeated within those blocks.
|
|
117
|
+
*/
|
|
118
|
+
const shouldRenderChildrenOutsideRef =
|
|
119
|
+
!componentRef(props, state) && !repeatItemData(props, state);
|
|
120
|
+
return shouldRenderChildrenOutsideRef ? children(props, state) : [];
|
|
121
|
+
};
|
|
122
|
+
export const repeatItemData = function repeatItemData(props, state) {
|
|
123
|
+
/**
|
|
124
|
+
* we don't use `state.useBlock` here because the processing done within its logic includes evaluating the block's bindings,
|
|
125
|
+
* which will not work if there is a repeat.
|
|
126
|
+
*/
|
|
127
|
+
const { repeat, ...blockWithoutRepeat } = props.block;
|
|
128
|
+
|
|
129
|
+
if (!repeat?.collection) {
|
|
130
|
+
return undefined;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
const itemsArray = evaluate({
|
|
134
|
+
code: repeat.collection,
|
|
135
|
+
state: props.context.state,
|
|
136
|
+
context: props.context.context,
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
if (!Array.isArray(itemsArray)) {
|
|
140
|
+
return undefined;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
const collectionName = repeat.collection.split(".").pop();
|
|
144
|
+
const itemNameToUse =
|
|
145
|
+
repeat.itemName || (collectionName ? collectionName + "Item" : "item");
|
|
146
|
+
const repeatArray = itemsArray.map((item, index) => ({
|
|
147
|
+
context: {
|
|
148
|
+
...props.context,
|
|
149
|
+
state: {
|
|
150
|
+
...props.context.state,
|
|
151
|
+
$index: index,
|
|
152
|
+
$item: item,
|
|
153
|
+
[itemNameToUse]: item,
|
|
154
|
+
[`$${itemNameToUse}Index`]: index,
|
|
155
|
+
},
|
|
156
|
+
},
|
|
157
|
+
block: blockWithoutRepeat,
|
|
158
|
+
}));
|
|
159
|
+
return repeatArray;
|
|
160
|
+
};
|
|
161
|
+
export const RenderBlock = (props) => {
|
|
162
|
+
const state = {};
|
|
163
|
+
state.tagName = tagName(props, state);
|
|
164
|
+
return (
|
|
165
|
+
<>
|
|
166
|
+
{shouldWrap(props, state) ? (
|
|
167
|
+
!isEmptyHtmlElement(tagName(props, state)) ? (
|
|
168
|
+
<state.tagName {...attributes(props, state)}>
|
|
169
|
+
{repeatItemData(props, state)
|
|
170
|
+
? (repeatItemData(props, state) || []).map((data, index) => {
|
|
171
|
+
return (
|
|
172
|
+
<RenderRepeatedBlock
|
|
173
|
+
key={index}
|
|
174
|
+
repeatContext={data.context}
|
|
175
|
+
block={data.block}
|
|
176
|
+
context={props.context}
|
|
177
|
+
></RenderRepeatedBlock>
|
|
178
|
+
);
|
|
179
|
+
})
|
|
180
|
+
: null}
|
|
181
|
+
{!repeatItemData(props, state) ? (
|
|
182
|
+
<RenderComponent
|
|
183
|
+
{...renderComponentProps(props, state)}
|
|
184
|
+
></RenderComponent>
|
|
185
|
+
) : null}
|
|
186
|
+
{(childrenWithoutParentComponent(props, state) || []).map(
|
|
187
|
+
(child) => {
|
|
188
|
+
return (
|
|
189
|
+
<RenderBlock
|
|
190
|
+
key={"render-block-" + child.id}
|
|
191
|
+
block={child}
|
|
192
|
+
context={props.context}
|
|
193
|
+
></RenderBlock>
|
|
194
|
+
);
|
|
195
|
+
}
|
|
196
|
+
)}
|
|
197
|
+
{(childrenWithoutParentComponent(props, state) || []).map(
|
|
198
|
+
(child) => {
|
|
199
|
+
return (
|
|
200
|
+
<BlockStyles
|
|
201
|
+
key={"block-style-" + child.id}
|
|
202
|
+
block={child}
|
|
203
|
+
context={props.context}
|
|
204
|
+
></BlockStyles>
|
|
205
|
+
);
|
|
206
|
+
}
|
|
207
|
+
)}
|
|
208
|
+
</state.tagName>
|
|
209
|
+
) : (
|
|
210
|
+
<state.tagName {...attributes(props, state)}></state.tagName>
|
|
211
|
+
)
|
|
212
|
+
) : (
|
|
213
|
+
<RenderComponent
|
|
214
|
+
{...renderComponentProps(props, state)}
|
|
215
|
+
context={props.context}
|
|
216
|
+
></RenderComponent>
|
|
217
|
+
)}
|
|
218
|
+
</>
|
|
219
|
+
);
|
|
220
|
+
};
|
|
221
|
+
export default RenderBlock;
|