@builder.io/sdk-solid 0.0.16 → 0.0.17
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 +5 -1
- package/package.json +17 -5
- package/solid-index.jsx +5 -0
- package/src/blocks/BaseText.jsx +9 -0
- package/src/blocks/button/button.jsx +9 -6
- package/src/blocks/columns/columns.jsx +54 -52
- package/src/blocks/columns/component-info.js +26 -1
- package/src/blocks/custom-code/custom-code.jsx +35 -38
- package/src/blocks/embed/component-info.js +21 -1
- package/src/blocks/embed/embed.jsx +37 -42
- package/src/blocks/embed/helpers.js +9 -0
- package/src/blocks/form/form.jsx +175 -176
- package/src/blocks/image/component-info.js +48 -1
- package/src/blocks/image/image.helpers.js +48 -0
- package/src/blocks/image/image.jsx +44 -13
- package/src/blocks/img/img.jsx +1 -1
- package/src/blocks/symbol/component-info.js +1 -0
- package/src/blocks/symbol/symbol.jsx +39 -12
- package/src/blocks/text/text.jsx +1 -1
- package/src/blocks/util.js +7 -0
- package/src/blocks/video/video.jsx +21 -2
- package/src/components/render-block/block-styles.jsx +41 -31
- package/src/components/render-block/render-block.helpers.js +23 -0
- package/src/components/render-block/render-block.jsx +205 -90
- package/src/components/render-block/render-component-with-context.jsx +36 -0
- package/src/components/render-block/render-component.jsx +28 -0
- package/src/components/render-block/render-repeated-block.jsx +36 -0
- package/src/components/render-block/types.js +0 -0
- package/src/components/render-blocks.jsx +42 -33
- package/src/components/render-content/components/render-styles.jsx +39 -42
- package/src/components/render-content/index.js +4 -0
- package/src/components/render-content/render-content.jsx +199 -128
- package/src/components/render-inlined-styles.jsx +21 -5
- package/src/constants/builder-registered-components.js +54 -0
- package/src/constants/device-sizes.js +3 -21
- package/src/context/builder.context.js +3 -1
- package/src/context/types.js +0 -0
- package/src/functions/camel-to-kebab-case.js +4 -0
- package/src/functions/convert-style-object.js +14 -0
- package/src/functions/evaluate.js +1 -1
- package/src/functions/extract-text-styles.js +22 -0
- package/src/functions/fast-clone.js +4 -0
- package/src/functions/get-block-actions-handler.js +12 -0
- package/src/functions/get-block-actions.js +2 -7
- package/src/functions/get-block-component-options.js +6 -1
- package/src/functions/get-block-styles.js +27 -19
- package/src/functions/get-builder-search-params/index.js +17 -2
- package/src/functions/get-content/ab-testing.js +99 -0
- package/src/functions/get-content/fn.test.js +1 -1
- package/src/functions/get-content/index.js +20 -62
- package/src/functions/get-content/types.js +0 -0
- package/src/functions/get-fetch.js +2 -2
- package/src/functions/get-processed-block.js +24 -11
- package/src/functions/get-processed-block.test.js +2 -1
- package/src/functions/mark-mutable.js +10 -0
- package/src/functions/register-component.js +45 -26
- package/src/functions/sanitize-styles.js +4 -0
- package/src/functions/track.js +108 -13
- package/src/helpers/ab-tests.js +16 -0
- package/src/helpers/cookie.js +79 -0
- package/src/helpers/css.js +28 -0
- package/src/helpers/flatten.js +34 -0
- package/src/helpers/localStorage.js +34 -0
- package/src/helpers/nullable.js +4 -0
- package/src/helpers/sessionId.js +49 -0
- package/src/helpers/time.js +5 -0
- package/src/helpers/url.js +10 -0
- package/src/helpers/url.test.js +15 -0
- package/src/helpers/uuid.js +13 -0
- package/src/helpers/visitorId.js +33 -0
- package/src/index-helpers/blocks-exports.js +11 -9
- package/src/scripts/init-editing.js +4 -5
- package/src/types/can-track.js +0 -0
- package/src/types/components.js +0 -0
- package/src/types/element.js +0 -0
- package/src/blocks/button/button.lite.tsx +0 -20
- package/src/blocks/button/index.js +0 -7
- package/src/blocks/columns/columns.lite.tsx +0 -102
- package/src/blocks/columns/index.js +0 -7
- package/src/blocks/custom-code/custom-code.lite.tsx +0 -67
- package/src/blocks/custom-code/index.js +0 -7
- package/src/blocks/embed/embed.lite.tsx +0 -59
- package/src/blocks/embed/index.js +0 -7
- package/src/blocks/form/form.lite.tsx +0 -293
- package/src/blocks/form/index.js +0 -7
- package/src/blocks/fragment/fragment.lite.tsx +0 -5
- package/src/blocks/fragment/index.js +0 -7
- package/src/blocks/image/image.lite.tsx +0 -83
- package/src/blocks/image/index.js +0 -7
- package/src/blocks/img/img.lite.tsx +0 -18
- package/src/blocks/img/index.js +0 -7
- package/src/blocks/input/index.js +0 -7
- package/src/blocks/input/input.lite.tsx +0 -20
- package/src/blocks/raw-text/index.js +0 -7
- package/src/blocks/raw-text/raw-text.lite.tsx +0 -10
- package/src/blocks/section/index.js +0 -7
- package/src/blocks/section/section.lite.tsx +0 -18
- package/src/blocks/select/index.js +0 -7
- package/src/blocks/select/select.lite.tsx +0 -28
- package/src/blocks/submit-button/index.js +0 -7
- package/src/blocks/submit-button/submit-button.lite.tsx +0 -9
- package/src/blocks/symbol/index.js +0 -7
- package/src/blocks/symbol/symbol.lite.tsx +0 -39
- package/src/blocks/text/index.js +0 -7
- package/src/blocks/text/text.lite.tsx +0 -5
- package/src/blocks/textarea/index.js +0 -7
- package/src/blocks/textarea/textarea.lite.tsx +0 -13
- package/src/blocks/video/index.js +0 -7
- package/src/blocks/video/video.lite.tsx +0 -26
- package/src/components/error-boundary.jsx +0 -5
- package/src/components/error-boundary.lite.tsx +0 -5
- package/src/components/render-block/block-styles.lite.tsx +0 -38
- package/src/components/render-block/render-block.lite.tsx +0 -119
- package/src/components/render-blocks.lite.tsx +0 -75
- package/src/components/render-content/components/render-styles.lite.tsx +0 -76
- package/src/components/render-content/render-content.lite.tsx +0 -232
- package/src/components/render-inlined-styles.lite.tsx +0 -5
- package/src/functions/macro-eval.js +0 -5
- package/src/functions/previewing-model-name.js +0 -11
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { registerComponent } from "../../functions/register-component.js";
|
|
2
|
-
import { componentInfo } from "./component-info.js";
|
|
3
|
-
import component from "./input.js";
|
|
4
|
-
var stdin_default = registerComponent(component, componentInfo);
|
|
5
|
-
export {
|
|
6
|
-
stdin_default as default
|
|
7
|
-
};
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { isEditing } from "../../functions/is-editing.js";
|
|
2
|
-
|
|
3
|
-
function FormInputComponent(props) {
|
|
4
|
-
return (
|
|
5
|
-
<input
|
|
6
|
-
{...props.attributes}
|
|
7
|
-
key={
|
|
8
|
-
isEditing() && props.defaultValue ? props.defaultValue : "default-key"
|
|
9
|
-
}
|
|
10
|
-
placeholder={props.placeholder}
|
|
11
|
-
type={props.type}
|
|
12
|
-
name={props.name}
|
|
13
|
-
value={props.value}
|
|
14
|
-
defaultValue={props.defaultValue}
|
|
15
|
-
required={props.required}
|
|
16
|
-
/>
|
|
17
|
-
);
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export default FormInputComponent;
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { registerComponent } from "../../functions/register-component.js";
|
|
2
|
-
import { componentInfo } from "./component-info.js";
|
|
3
|
-
import component from "./raw-text.js";
|
|
4
|
-
var stdin_default = registerComponent(component, componentInfo);
|
|
5
|
-
export {
|
|
6
|
-
stdin_default as default
|
|
7
|
-
};
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { registerComponent } from "../../functions/register-component.js";
|
|
2
|
-
import { componentInfo } from "./component-info.js";
|
|
3
|
-
import component from "./section.js";
|
|
4
|
-
var stdin_default = registerComponent(component, componentInfo);
|
|
5
|
-
export {
|
|
6
|
-
stdin_default as default
|
|
7
|
-
};
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
function SectionComponent(props) {
|
|
2
|
-
return (
|
|
3
|
-
<section
|
|
4
|
-
{...props.attributes}
|
|
5
|
-
style={
|
|
6
|
-
props.maxWidth && typeof props.maxWidth === "number"
|
|
7
|
-
? {
|
|
8
|
-
"max-width": props.maxWidth,
|
|
9
|
-
}
|
|
10
|
-
: undefined
|
|
11
|
-
}
|
|
12
|
-
>
|
|
13
|
-
{props.children}
|
|
14
|
-
</section>
|
|
15
|
-
);
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export default SectionComponent;
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { registerComponent } from "../../functions/register-component.js";
|
|
2
|
-
import { componentInfo } from "./component-info.js";
|
|
3
|
-
import component from "./select.js";
|
|
4
|
-
var stdin_default = registerComponent(component, componentInfo);
|
|
5
|
-
export {
|
|
6
|
-
stdin_default as default
|
|
7
|
-
};
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { For } from "solid-js";
|
|
2
|
-
|
|
3
|
-
import { isEditing } from "../../functions/is-editing.js";
|
|
4
|
-
|
|
5
|
-
function SelectComponent(props) {
|
|
6
|
-
return (
|
|
7
|
-
<select
|
|
8
|
-
{...props.attributes}
|
|
9
|
-
value={props.value}
|
|
10
|
-
key={
|
|
11
|
-
isEditing() && props.defaultValue ? props.defaultValue : "default-key"
|
|
12
|
-
}
|
|
13
|
-
defaultValue={props.defaultValue}
|
|
14
|
-
name={props.name}
|
|
15
|
-
>
|
|
16
|
-
<For each={props.options}>
|
|
17
|
-
{(option, _index) => {
|
|
18
|
-
const index = _index();
|
|
19
|
-
return (
|
|
20
|
-
<option value={option.value}>{option.name || option.value}</option>
|
|
21
|
-
);
|
|
22
|
-
}}
|
|
23
|
-
</For>
|
|
24
|
-
</select>
|
|
25
|
-
);
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
export default SelectComponent;
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { registerComponent } from "../../functions/register-component.js";
|
|
2
|
-
import { componentInfo } from "./component-info.js";
|
|
3
|
-
import component from "./submit-button.js";
|
|
4
|
-
var stdin_default = registerComponent(component, componentInfo);
|
|
5
|
-
export {
|
|
6
|
-
stdin_default as default
|
|
7
|
-
};
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { registerComponent } from "../../functions/register-component.js";
|
|
2
|
-
import { componentInfo } from "./component-info.js";
|
|
3
|
-
import component from "./symbol.js";
|
|
4
|
-
var stdin_default = registerComponent(component, componentInfo);
|
|
5
|
-
export {
|
|
6
|
-
stdin_default as default
|
|
7
|
-
};
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import { createMutable } from "solid-js/store";
|
|
2
|
-
|
|
3
|
-
import RenderContent from "../../components/render-content/render-content.js";
|
|
4
|
-
import BuilderContext from "../../context/builder.context.js";
|
|
5
|
-
import { getContent } from "../../functions/get-content/index.js";
|
|
6
|
-
|
|
7
|
-
function Symbol(props) {
|
|
8
|
-
const state = createMutable({ className: "builder-symbol", content: null });
|
|
9
|
-
|
|
10
|
-
const builderContext = useContext(BuilderContext);
|
|
11
|
-
|
|
12
|
-
onMount(() => {
|
|
13
|
-
state.content = props.symbol?.content;
|
|
14
|
-
});
|
|
15
|
-
|
|
16
|
-
return (
|
|
17
|
-
<div
|
|
18
|
-
class={state.className}
|
|
19
|
-
{...props.attributes}
|
|
20
|
-
dataSet={{
|
|
21
|
-
class: state.className,
|
|
22
|
-
}}
|
|
23
|
-
>
|
|
24
|
-
<RenderContent
|
|
25
|
-
apiKey={builderContext.apiKey}
|
|
26
|
-
context={builderContext.context}
|
|
27
|
-
data={{
|
|
28
|
-
...props.symbol?.data,
|
|
29
|
-
...builderContext.state,
|
|
30
|
-
...props.symbol?.state.content?.data?.state,
|
|
31
|
-
}}
|
|
32
|
-
model={props.symbol?.model}
|
|
33
|
-
content={state.content}
|
|
34
|
-
></RenderContent>
|
|
35
|
-
</div>
|
|
36
|
-
);
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
export default Symbol;
|
package/src/blocks/text/index.js
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { registerComponent } from "../../functions/register-component.js";
|
|
2
|
-
import { componentInfo } from "./component-info.js";
|
|
3
|
-
import component from "./text.js";
|
|
4
|
-
var stdin_default = registerComponent(component, componentInfo);
|
|
5
|
-
export {
|
|
6
|
-
stdin_default as default
|
|
7
|
-
};
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { registerComponent } from "../../functions/register-component.js";
|
|
2
|
-
import { componentInfo } from "./component-info.js";
|
|
3
|
-
import component from "./textarea.js";
|
|
4
|
-
var stdin_default = registerComponent(component, componentInfo);
|
|
5
|
-
export {
|
|
6
|
-
stdin_default as default
|
|
7
|
-
};
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { registerComponent } from "../../functions/register-component.js";
|
|
2
|
-
import { componentInfo } from "./component-info.js";
|
|
3
|
-
import component from "./video.js";
|
|
4
|
-
var stdin_default = registerComponent(component, componentInfo);
|
|
5
|
-
export {
|
|
6
|
-
stdin_default as default
|
|
7
|
-
};
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
function Video(props) {
|
|
2
|
-
return (
|
|
3
|
-
<video
|
|
4
|
-
{...props.attributes}
|
|
5
|
-
preload="none"
|
|
6
|
-
style={{
|
|
7
|
-
width: "100%",
|
|
8
|
-
height: "100%",
|
|
9
|
-
...props.attributes?.style,
|
|
10
|
-
"object-fit": props.fit,
|
|
11
|
-
"object-position": props.position,
|
|
12
|
-
// Hack to get object fit to work as expected and
|
|
13
|
-
// not have the video overflow
|
|
14
|
-
"border-radius": 1,
|
|
15
|
-
}}
|
|
16
|
-
key={props.video || "no-src"}
|
|
17
|
-
poster={props.posterImage}
|
|
18
|
-
autoPlay={props.autoPlay}
|
|
19
|
-
muted={props.muted}
|
|
20
|
-
controls={props.controls}
|
|
21
|
-
loop={props.loop}
|
|
22
|
-
></video>
|
|
23
|
-
);
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
export default Video;
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { createMutable } from "solid-js/store";
|
|
2
|
-
|
|
3
|
-
import RenderInlinedStyles from "../render-inlined-styles.js";
|
|
4
|
-
|
|
5
|
-
function BlockStyles(props) {
|
|
6
|
-
const state = createMutable({
|
|
7
|
-
camelToKebabCase(string: string) {
|
|
8
|
-
return string
|
|
9
|
-
.replace(/([a-z0-9]|(?=[A-Z]))([A-Z])/g, "$1-$2")
|
|
10
|
-
.toLowerCase();
|
|
11
|
-
},
|
|
12
|
-
get css() {
|
|
13
|
-
// TODO: media queries
|
|
14
|
-
const styleObject = props.block.responsiveStyles?.large;
|
|
15
|
-
|
|
16
|
-
if (!styleObject) {
|
|
17
|
-
return "";
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
let str = `.${props.block.id} {`;
|
|
21
|
-
|
|
22
|
-
for (const key in styleObject) {
|
|
23
|
-
const value = styleObject[key];
|
|
24
|
-
|
|
25
|
-
if (typeof value === "string") {
|
|
26
|
-
str += `${state.camelToKebabCase(key)}: ${value};`;
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
str += "}";
|
|
31
|
-
return str;
|
|
32
|
-
},
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
return <RenderInlinedStyles styles={state.css}></RenderInlinedStyles>;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
export default BlockStyles;
|
|
@@ -1,119 +0,0 @@
|
|
|
1
|
-
import { useContext, Show, For } from "solid-js";
|
|
2
|
-
import { Dynamic } from "solid-js/web";
|
|
3
|
-
import { createMutable } from "solid-js/store";
|
|
4
|
-
|
|
5
|
-
import { TARGET } from "../../constants/target.js";
|
|
6
|
-
import BuilderContext from "../../context/builder.context.js";
|
|
7
|
-
import { getBlockActions } from "../../functions/get-block-actions.js";
|
|
8
|
-
import { getBlockComponentOptions } from "../../functions/get-block-component-options.js";
|
|
9
|
-
import { getBlockProperties } from "../../functions/get-block-properties.js";
|
|
10
|
-
import { getBlockStyles } from "../../functions/get-block-styles.js";
|
|
11
|
-
import { getBlockTag } from "../../functions/get-block-tag.js";
|
|
12
|
-
import { getProcessedBlock } from "../../functions/get-processed-block.js";
|
|
13
|
-
import { components } from "../../functions/register-component.js";
|
|
14
|
-
import BlockStyles from "./block-styles.js";
|
|
15
|
-
|
|
16
|
-
function RenderBlock(props) {
|
|
17
|
-
const state = createMutable({
|
|
18
|
-
get component() {
|
|
19
|
-
const componentName = state.useBlock.component?.name;
|
|
20
|
-
|
|
21
|
-
if (!componentName) {
|
|
22
|
-
return null;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
const ref = components[componentName];
|
|
26
|
-
|
|
27
|
-
if (componentName && !ref) {
|
|
28
|
-
// TODO: Public doc page with more info about this message
|
|
29
|
-
console.warn(`
|
|
30
|
-
Could not find a registered component named "${componentName}".
|
|
31
|
-
If you registered it, is the file that registered it imported by the file that needs to render it?`);
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
return ref;
|
|
35
|
-
},
|
|
36
|
-
get componentInfo() {
|
|
37
|
-
return state.component?.info;
|
|
38
|
-
},
|
|
39
|
-
get componentRef() {
|
|
40
|
-
return state.component?.component;
|
|
41
|
-
},
|
|
42
|
-
get tagName() {
|
|
43
|
-
return getBlockTag(state.useBlock);
|
|
44
|
-
},
|
|
45
|
-
get useBlock() {
|
|
46
|
-
return getProcessedBlock({
|
|
47
|
-
block: props.block,
|
|
48
|
-
state: builderContext.state,
|
|
49
|
-
context: builderContext.context,
|
|
50
|
-
});
|
|
51
|
-
},
|
|
52
|
-
get propertiesAndActions() {
|
|
53
|
-
return {
|
|
54
|
-
...getBlockProperties(state.useBlock),
|
|
55
|
-
...getBlockActions({
|
|
56
|
-
block: state.useBlock,
|
|
57
|
-
state: builderContext.state,
|
|
58
|
-
context: builderContext.context,
|
|
59
|
-
}),
|
|
60
|
-
};
|
|
61
|
-
},
|
|
62
|
-
get css() {
|
|
63
|
-
return getBlockStyles(state.useBlock);
|
|
64
|
-
},
|
|
65
|
-
get componentOptions() {
|
|
66
|
-
return getBlockComponentOptions(state.useBlock);
|
|
67
|
-
},
|
|
68
|
-
get children() {
|
|
69
|
-
// TO-DO: When should `canHaveChildren` dictate rendering?
|
|
70
|
-
// This is currently commented out because some Builder components (e.g. Box) do not have `canHaveChildren: true`,
|
|
71
|
-
// but still receive and need to render children.
|
|
72
|
-
// return state.componentInfo?.canHaveChildren ? state.useBlock.children : [];
|
|
73
|
-
return state.useBlock.children ?? [];
|
|
74
|
-
},
|
|
75
|
-
get noCompRefChildren() {
|
|
76
|
-
return state.componentRef ? [] : state.children;
|
|
77
|
-
},
|
|
78
|
-
});
|
|
79
|
-
|
|
80
|
-
const builderContext = useContext(BuilderContext);
|
|
81
|
-
|
|
82
|
-
return (
|
|
83
|
-
<>
|
|
84
|
-
<Show when={!state.componentInfo?.noWrap}>
|
|
85
|
-
<Dynamic
|
|
86
|
-
{...state.propertiesAndActions}
|
|
87
|
-
style={state.css}
|
|
88
|
-
component={state.tagName}
|
|
89
|
-
>
|
|
90
|
-
<Show when={TARGET === "vue" || TARGET === "svelte"}>
|
|
91
|
-
<BlockStyles block={state.useBlock}></BlockStyles>
|
|
92
|
-
</Show>
|
|
93
|
-
<Show when={state.componentRef}>
|
|
94
|
-
<Dynamic
|
|
95
|
-
{...state.componentOptions}
|
|
96
|
-
builderBlock={state.useBlock}
|
|
97
|
-
component={state.componentRef}
|
|
98
|
-
>
|
|
99
|
-
<For each={state.children}>
|
|
100
|
-
{(child, _index) => {
|
|
101
|
-
const index = _index();
|
|
102
|
-
return <RenderBlock block={child}></RenderBlock>;
|
|
103
|
-
}}
|
|
104
|
-
</For>
|
|
105
|
-
</Dynamic>
|
|
106
|
-
</Show>
|
|
107
|
-
<For each={state.noCompRefChildren}>
|
|
108
|
-
{(child, _index) => {
|
|
109
|
-
const index = _index();
|
|
110
|
-
return <RenderBlock block={child}></RenderBlock>;
|
|
111
|
-
}}
|
|
112
|
-
</For>
|
|
113
|
-
</Dynamic>
|
|
114
|
-
</Show>
|
|
115
|
-
</>
|
|
116
|
-
);
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
export default RenderBlock;
|
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
import { Show, For } from "solid-js";
|
|
2
|
-
|
|
3
|
-
import { createMutable } from "solid-js/store";
|
|
4
|
-
import { css } from "solid-styled-components";
|
|
5
|
-
|
|
6
|
-
import { isEditing } from "../functions/is-editing.js";
|
|
7
|
-
import RenderBlock from "./render-block/render-block.js";
|
|
8
|
-
|
|
9
|
-
function RenderBlocks(props) {
|
|
10
|
-
const state = createMutable({
|
|
11
|
-
get className() {
|
|
12
|
-
return "builder-blocks" + (!props.blocks?.length ? " no-blocks" : "");
|
|
13
|
-
},
|
|
14
|
-
onClick() {
|
|
15
|
-
if (isEditing() && !props.blocks?.length) {
|
|
16
|
-
window.parent?.postMessage(
|
|
17
|
-
{
|
|
18
|
-
type: "builder.clickEmptyBlocks",
|
|
19
|
-
data: {
|
|
20
|
-
parentElementId: props.parent,
|
|
21
|
-
dataPath: props.path,
|
|
22
|
-
},
|
|
23
|
-
},
|
|
24
|
-
"*"
|
|
25
|
-
);
|
|
26
|
-
}
|
|
27
|
-
},
|
|
28
|
-
onMouseEnter() {
|
|
29
|
-
if (isEditing() && !props.blocks?.length) {
|
|
30
|
-
window.parent?.postMessage(
|
|
31
|
-
{
|
|
32
|
-
type: "builder.hoverEmptyBlocks",
|
|
33
|
-
data: {
|
|
34
|
-
parentElementId: props.parent,
|
|
35
|
-
dataPath: props.path,
|
|
36
|
-
},
|
|
37
|
-
},
|
|
38
|
-
"*"
|
|
39
|
-
);
|
|
40
|
-
}
|
|
41
|
-
},
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
return (
|
|
45
|
-
<div
|
|
46
|
-
class={
|
|
47
|
-
state.className +
|
|
48
|
-
" " +
|
|
49
|
-
css({
|
|
50
|
-
display: "flex",
|
|
51
|
-
flexDirection: "column",
|
|
52
|
-
alignItems: "stretch",
|
|
53
|
-
})
|
|
54
|
-
}
|
|
55
|
-
builder-path={props.path}
|
|
56
|
-
builder-parent-id={props.parent}
|
|
57
|
-
dataSet={{
|
|
58
|
-
class: state.className,
|
|
59
|
-
}}
|
|
60
|
-
onClick={(event) => state.onClick()}
|
|
61
|
-
onMouseEnter={(event) => state.onMouseEnter()}
|
|
62
|
-
>
|
|
63
|
-
<Show when={props.blocks}>
|
|
64
|
-
<For each={props.blocks}>
|
|
65
|
-
{(block, _index) => {
|
|
66
|
-
const index = _index();
|
|
67
|
-
return <RenderBlock key={block.id} block={block}></RenderBlock>;
|
|
68
|
-
}}
|
|
69
|
-
</For>
|
|
70
|
-
</Show>
|
|
71
|
-
</div>
|
|
72
|
-
);
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
export default RenderBlocks;
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
import { createMutable } from "solid-js/store";
|
|
2
|
-
|
|
3
|
-
import RenderInlinedStyles from "../../render-inlined-styles.js";
|
|
4
|
-
|
|
5
|
-
function RenderContentStyles(props) {
|
|
6
|
-
const state = createMutable({
|
|
7
|
-
getCssFromFont(font: CustomFont) {
|
|
8
|
-
// TODO: compute what font sizes are used and only load those.......
|
|
9
|
-
const family =
|
|
10
|
-
font.family +
|
|
11
|
-
(font.kind && !font.kind.includes("#") ? ", " + font.kind : "");
|
|
12
|
-
const name = family.split(",")[0];
|
|
13
|
-
const url = font.fileUrl ?? font?.files?.regular;
|
|
14
|
-
let str = "";
|
|
15
|
-
|
|
16
|
-
if (url && family && name) {
|
|
17
|
-
str += `
|
|
18
|
-
@font-face {
|
|
19
|
-
font-family: "${family}";
|
|
20
|
-
src: local("${name}"), url('${url}') format('woff2');
|
|
21
|
-
font-display: fallback;
|
|
22
|
-
font-weight: 400;
|
|
23
|
-
}
|
|
24
|
-
`.trim();
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
if (font.files) {
|
|
28
|
-
for (const weight in font.files) {
|
|
29
|
-
const isNumber = String(Number(weight)) === weight;
|
|
30
|
-
|
|
31
|
-
if (!isNumber) {
|
|
32
|
-
continue;
|
|
33
|
-
} // TODO: maybe limit number loaded
|
|
34
|
-
|
|
35
|
-
const weightUrl = font.files[weight];
|
|
36
|
-
|
|
37
|
-
if (weightUrl && weightUrl !== url) {
|
|
38
|
-
str += `
|
|
39
|
-
@font-face {
|
|
40
|
-
font-family: "${family}";
|
|
41
|
-
src: url('${weightUrl}') format('woff2');
|
|
42
|
-
font-display: fallback;
|
|
43
|
-
font-weight: ${weight};
|
|
44
|
-
}
|
|
45
|
-
`.trim();
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
return str;
|
|
51
|
-
},
|
|
52
|
-
getFontCss({ customFonts }: { customFonts?: CustomFont[] }) {
|
|
53
|
-
// TODO: flag for this
|
|
54
|
-
// if (!this.builder.allowCustomFonts) {
|
|
55
|
-
// return '';
|
|
56
|
-
// }
|
|
57
|
-
// TODO: separate internal data from external
|
|
58
|
-
return (
|
|
59
|
-
customFonts?.map((font) => this.getCssFromFont(font))?.join(" ") || ""
|
|
60
|
-
);
|
|
61
|
-
},
|
|
62
|
-
get injectedStyles() {
|
|
63
|
-
return `
|
|
64
|
-
${props.cssCode || ""}
|
|
65
|
-
${state.getFontCss({
|
|
66
|
-
customFonts: props.customFonts,
|
|
67
|
-
})}`;
|
|
68
|
-
},
|
|
69
|
-
});
|
|
70
|
-
|
|
71
|
-
return (
|
|
72
|
-
<RenderInlinedStyles styles={state.injectedStyles}></RenderInlinedStyles>
|
|
73
|
-
);
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
export default RenderContentStyles;
|