@builder.io/sdk-solid 0.0.8-12 → 0.0.8-13

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.
@@ -1,10 +0,0 @@
1
- function RawText(props) {
2
- return (
3
- <span
4
- class={props.attributes?.class || props.attributes?.className}
5
- innerHTML={props.text || ""}
6
- ></span>
7
- );
8
- }
9
-
10
- export default RawText;
@@ -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,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,9 +0,0 @@
1
- function SubmitButton(props) {
2
- return (
3
- <button {...props.attributes} type="submit">
4
- {props.text}
5
- </button>
6
- );
7
- }
8
-
9
- export default SubmitButton;
@@ -1,41 +0,0 @@
1
- import { useContext, onMount } from "solid-js";
2
-
3
- import { createMutable } from "solid-js/store";
4
-
5
- import RenderContent from "../../components/render-content/render-content.jsx";
6
- import BuilderContext from "../../context/builder.context";
7
- import { getContent } from "../../functions/get-content/index.js";
8
-
9
- function Symbol(props) {
10
- const state = createMutable({ className: "builder-symbol", content: null });
11
-
12
- const builderContext = useContext(BuilderContext);
13
-
14
- onMount(() => {
15
- state.content = props.symbol?.content;
16
- });
17
-
18
- return (
19
- <div
20
- class={state.className}
21
- {...props.attributes}
22
- dataSet={{
23
- class: state.className,
24
- }}
25
- >
26
- <RenderContent
27
- apiKey={builderContext.apiKey}
28
- context={builderContext.context}
29
- data={{
30
- ...props.symbol?.data,
31
- ...builderContext.state,
32
- ...props.symbol?.content?.data?.state,
33
- }}
34
- model={props.symbol?.model}
35
- content={state.content}
36
- ></RenderContent>
37
- </div>
38
- );
39
- }
40
-
41
- export default Symbol;
@@ -1,5 +0,0 @@
1
- function Text(props) {
2
- return <div class="builder-text" innerHTML={props.text}></div>;
3
- }
4
-
5
- export default Text;
@@ -1,13 +0,0 @@
1
- function Textarea(props) {
2
- return (
3
- <textarea
4
- {...props.attributes}
5
- placeholder={props.placeholder}
6
- name={props.name}
7
- value={props.value}
8
- defaultValue={props.defaultValue}
9
- ></textarea>
10
- );
11
- }
12
-
13
- export default Textarea;
@@ -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,5 +0,0 @@
1
- function ErrorBoundary(props) {
2
- return <></>;
3
- }
4
-
5
- export default ErrorBoundary;
@@ -1,56 +0,0 @@
1
- import { useContext, Show } from "solid-js";
2
-
3
- import { createMutable } from "solid-js/store";
4
-
5
- import { TARGET } from "../../constants/target.js";
6
- import BuilderContext from "../../context/builder.context";
7
- import { getProcessedBlock } from "../../functions/get-processed-block.js";
8
- import RenderInlinedStyles from "../render-inlined-styles.jsx";
9
-
10
- function BlockStyles(props) {
11
- const state = createMutable({
12
- get useBlock() {
13
- return getProcessedBlock({
14
- block: props.block,
15
- state: builderContext.state,
16
- context: builderContext.context,
17
- });
18
- },
19
- camelToKebabCase(string: string) {
20
- return string
21
- .replace(/([a-z0-9]|(?=[A-Z]))([A-Z])/g, "$1-$2")
22
- .toLowerCase();
23
- },
24
- get css() {
25
- // TODO: media queries
26
- const styleObject = state.useBlock.responsiveStyles?.large;
27
-
28
- if (!styleObject) {
29
- return "";
30
- }
31
-
32
- let str = `.${state.useBlock.id} {`;
33
-
34
- for (const key in styleObject) {
35
- const value = styleObject[key];
36
-
37
- if (typeof value === "string") {
38
- str += `${state.camelToKebabCase(key)}: ${value};`;
39
- }
40
- }
41
-
42
- str += "}";
43
- return str;
44
- },
45
- });
46
-
47
- const builderContext = useContext(BuilderContext);
48
-
49
- return (
50
- <Show when={TARGET === "vue" || TARGET === "svelte"}>
51
- <RenderInlinedStyles styles={state.css}></RenderInlinedStyles>
52
- </Show>
53
- );
54
- }
55
-
56
- export default BlockStyles;
@@ -1,156 +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 BuilderContext from "../../context/builder.context";
6
- import { getBlockActions } from "../../functions/get-block-actions.js";
7
- import { getBlockComponentOptions } from "../../functions/get-block-component-options.js";
8
- import { getBlockProperties } from "../../functions/get-block-properties.js";
9
- import { getBlockStyles } from "../../functions/get-block-styles.js";
10
- import { getBlockTag } from "../../functions/get-block-tag.js";
11
- import { getProcessedBlock } from "../../functions/get-processed-block.js";
12
- import BlockStyles from "./block-styles.jsx";
13
- import { isEmptyHtmlElement } from "./render-block.helpers.js";
14
- import RenderComponent from "./render-component.jsx";
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 = builderContext.registeredComponents[componentName];
26
-
27
- if (!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
- return undefined;
33
- } else {
34
- return ref;
35
- }
36
- },
37
- get componentInfo() {
38
- if (state.component) {
39
- const { component: _, ...info } = state.component;
40
- return info;
41
- } else {
42
- return undefined;
43
- }
44
- },
45
- get componentRef() {
46
- return state.component?.component;
47
- },
48
- get tagName() {
49
- return getBlockTag(state.useBlock);
50
- },
51
- get useBlock() {
52
- return getProcessedBlock({
53
- block: props.block,
54
- state: builderContext.state,
55
- context: builderContext.context,
56
- });
57
- },
58
- get attributes() {
59
- return {
60
- ...getBlockProperties(state.useBlock),
61
- ...getBlockActions({
62
- block: state.useBlock,
63
- state: builderContext.state,
64
- context: builderContext.context,
65
- }),
66
- style: getBlockStyles(state.useBlock),
67
- };
68
- },
69
- get shouldWrap() {
70
- return !state.componentInfo?.noWrap;
71
- },
72
- get componentOptions() {
73
- return {
74
- ...getBlockComponentOptions(state.useBlock),
75
-
76
- /**
77
- * These attributes are passed to the wrapper element when there is one. If `noWrap` is set to true, then
78
- * they are provided to the component itself directly.
79
- */
80
- ...(state.shouldWrap
81
- ? {}
82
- : {
83
- attributes: state.attributes,
84
- }),
85
- };
86
- },
87
- get children() {
88
- // TO-DO: When should `canHaveChildren` dictate rendering?
89
- // This is currently commented out because some Builder components (e.g. Box) do not have `canHaveChildren: true`,
90
- // but still receive and need to render children.
91
- // return state.componentInfo?.canHaveChildren ? state.useBlock.children : [];
92
- return state.useBlock.children ?? [];
93
- },
94
- get noCompRefChildren() {
95
- /**
96
- * When there is no `componentRef`, there might still be children that need to be rendered. In this case,
97
- * we render them outside of `componentRef`
98
- */
99
- return state.componentRef ? [] : state.children;
100
- },
101
- });
102
-
103
- const builderContext = useContext(BuilderContext);
104
-
105
- return (
106
- <Show
107
- fallback={
108
- <RenderComponent
109
- blockChildren={state.children}
110
- componentRef={state.componentRef}
111
- componentOptions={state.componentOptions}
112
- ></RenderComponent>
113
- }
114
- when={state.shouldWrap}
115
- >
116
- <Show
117
- fallback={
118
- <Dynamic {...state.attributes} component={state.tagName}></Dynamic>
119
- }
120
- when={!isEmptyHtmlElement(state.tagName)}
121
- >
122
- <Dynamic {...state.attributes} component={state.tagName}>
123
- <RenderComponent
124
- blockChildren={state.children}
125
- componentRef={state.componentRef}
126
- componentOptions={state.componentOptions}
127
- ></RenderComponent>
128
- <For each={state.noCompRefChildren}>
129
- {(child, _index) => {
130
- const index = _index();
131
- return (
132
- <RenderBlock
133
- key={"render-block-" + child.id}
134
- block={child}
135
- ></RenderBlock>
136
- );
137
- }}
138
- </For>
139
- <For each={state.noCompRefChildren}>
140
- {(child, _index) => {
141
- const index = _index();
142
- return (
143
- <BlockStyles
144
- key={"block-style-" + child.id}
145
- block={child}
146
- ></BlockStyles>
147
- );
148
- }}
149
- </For>
150
- </Dynamic>
151
- </Show>
152
- </Show>
153
- );
154
- }
155
-
156
- export default RenderBlock;
@@ -1,38 +0,0 @@
1
- import { Show, For } from "solid-js";
2
- import { Dynamic } from "solid-js/web";
3
-
4
- import BlockStyles from "./block-styles.jsx";
5
- import RenderBlock from "./render-block.jsx";
6
-
7
- function RenderComponent(props) {
8
- return (
9
- <Show when={props.componentRef}>
10
- <Dynamic {...props.componentOptions} component={props.componentRef}>
11
- <For each={props.blockChildren}>
12
- {(child, _index) => {
13
- const index = _index();
14
- return (
15
- <RenderBlock
16
- key={"render-block-" + child.id}
17
- block={child}
18
- ></RenderBlock>
19
- );
20
- }}
21
- </For>
22
- <For each={props.blockChildren}>
23
- {(child, _index) => {
24
- const index = _index();
25
- return (
26
- <BlockStyles
27
- key={"block-style-" + child.id}
28
- block={child}
29
- ></BlockStyles>
30
- );
31
- }}
32
- </For>
33
- </Dynamic>
34
- </Show>
35
- );
36
- }
37
-
38
- export default RenderComponent;
@@ -1,94 +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 BlockStyles from "./render-block/block-styles.jsx";
8
- import RenderBlock from "./render-block/render-block.jsx";
9
-
10
- function RenderBlocks(props) {
11
- const state = createMutable({
12
- get className() {
13
- return "builder-blocks" + (!props.blocks?.length ? " no-blocks" : "");
14
- },
15
- onClick() {
16
- if (isEditing() && !props.blocks?.length) {
17
- window.parent?.postMessage(
18
- {
19
- type: "builder.clickEmptyBlocks",
20
- data: {
21
- parentElementId: props.parent,
22
- dataPath: props.path,
23
- },
24
- },
25
- "*"
26
- );
27
- }
28
- },
29
- onMouseEnter() {
30
- if (isEditing() && !props.blocks?.length) {
31
- window.parent?.postMessage(
32
- {
33
- type: "builder.hoverEmptyBlocks",
34
- data: {
35
- parentElementId: props.parent,
36
- dataPath: props.path,
37
- },
38
- },
39
- "*"
40
- );
41
- }
42
- },
43
- });
44
-
45
- return (
46
- <div
47
- class={
48
- state.className +
49
- " " +
50
- css({
51
- display: "flex",
52
- flexDirection: "column",
53
- alignItems: "stretch",
54
- })
55
- }
56
- builder-path={props.path}
57
- builder-parent-id={props.parent}
58
- dataSet={{
59
- class: state.className,
60
- }}
61
- onClick={(event) => state.onClick()}
62
- onMouseEnter={(event) => state.onMouseEnter()}
63
- >
64
- <Show when={props.blocks}>
65
- <For each={props.blocks}>
66
- {(block, _index) => {
67
- const index = _index();
68
- return (
69
- <RenderBlock
70
- key={"render-block-" + block.id}
71
- block={block}
72
- ></RenderBlock>
73
- );
74
- }}
75
- </For>
76
- </Show>
77
- <Show when={props.blocks}>
78
- <For each={props.blocks}>
79
- {(block, _index) => {
80
- const index = _index();
81
- return (
82
- <BlockStyles
83
- key={"block-style-" + block.id}
84
- block={block}
85
- ></BlockStyles>
86
- );
87
- }}
88
- </For>
89
- </Show>
90
- </div>
91
- );
92
- }
93
-
94
- export default RenderBlocks;
@@ -1,76 +0,0 @@
1
- import { createMutable } from "solid-js/store";
2
-
3
- import RenderInlinedStyles from "../../render-inlined-styles.jsx";
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;