@builder.io/sdk-solid 0.0.5 → 0.0.8-0
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/package.json +9 -2
- package/src/blocks/button/button.jsx +13 -0
- package/src/blocks/button/button.lite.tsx +20 -0
- package/src/blocks/button/component-info.js +41 -0
- package/src/blocks/button/index.js +7 -0
- package/src/blocks/columns/columns.jsx +91 -0
- package/src/blocks/{columns.lite.tsx → columns/columns.lite.tsx} +32 -26
- package/src/blocks/columns/component-info.js +217 -0
- package/src/blocks/columns/index.js +7 -0
- package/src/blocks/custom-code/component-info.js +31 -0
- package/src/blocks/{custom-code.js → custom-code/custom-code.jsx} +5 -26
- package/src/blocks/{custom-code.lite.tsx → custom-code/custom-code.lite.tsx} +3 -1
- package/src/blocks/custom-code/index.js +7 -0
- package/src/blocks/embed/component-info.js +24 -0
- package/src/blocks/embed/embed.jsx +51 -0
- package/src/blocks/{embed.lite.tsx → embed/embed.lite.tsx} +3 -1
- package/src/blocks/embed/index.js +7 -0
- package/src/blocks/form/component-info.js +262 -0
- package/src/blocks/form/form.jsx +253 -0
- package/src/blocks/{form.lite.tsx → form/form.lite.tsx} +14 -8
- package/src/blocks/form/index.js +7 -0
- package/src/blocks/fragment/component-info.js +11 -0
- package/src/blocks/fragment/fragment.jsx +5 -0
- package/src/blocks/fragment/fragment.lite.tsx +5 -0
- package/src/blocks/fragment/index.js +7 -0
- package/src/blocks/image/component-info.js +104 -0
- package/src/blocks/image/image.jsx +54 -0
- package/src/blocks/image/image.lite.tsx +83 -0
- package/src/blocks/image/index.js +7 -0
- package/src/blocks/img/component-info.js +20 -0
- package/src/blocks/img/img.jsx +10 -0
- package/src/blocks/{img.lite.tsx → img/img.lite.tsx} +4 -2
- package/src/blocks/img/index.js +7 -0
- package/src/blocks/input/component-info.js +74 -0
- package/src/blocks/input/index.js +7 -0
- package/src/blocks/input/input.jsx +7 -0
- package/src/blocks/{input.lite.tsx → input/input.lite.tsx} +4 -2
- package/src/blocks/raw-text/component-info.js +16 -0
- package/src/blocks/raw-text/index.js +7 -0
- package/src/blocks/raw-text/raw-text.jsx +5 -0
- package/src/blocks/{raw-text.lite.tsx → raw-text/raw-text.lite.tsx} +3 -1
- package/src/blocks/section/component-info.js +49 -0
- package/src/blocks/section/index.js +7 -0
- package/src/blocks/section/section.jsx +9 -0
- package/src/blocks/{section.lite.tsx → section/section.lite.tsx} +3 -1
- package/src/blocks/select/component-info.js +59 -0
- package/src/blocks/select/index.js +7 -0
- package/src/blocks/select/select.jsx +16 -0
- package/src/blocks/{select.lite.tsx → select/select.lite.tsx} +10 -5
- package/src/blocks/submit-button/component-info.js +28 -0
- package/src/blocks/submit-button/index.js +7 -0
- package/src/blocks/submit-button/submit-button.jsx +7 -0
- package/src/blocks/{submit-button.lite.tsx → submit-button/submit-button.lite.tsx} +3 -1
- package/src/blocks/symbol/component-info.js +42 -0
- package/src/blocks/symbol/index.js +7 -0
- package/src/blocks/symbol/symbol.jsx +24 -0
- package/src/blocks/{symbol.lite.tsx → symbol/symbol.lite.tsx} +6 -4
- package/src/blocks/text/component-info.js +24 -0
- package/src/blocks/text/index.js +7 -0
- package/src/blocks/{text.lite.tsx → text/text.jsx} +3 -1
- package/src/blocks/text/text.lite.tsx +5 -0
- package/src/blocks/textarea/component-info.js +47 -0
- package/src/blocks/textarea/index.js +7 -0
- package/src/blocks/textarea/textarea.jsx +5 -0
- package/src/blocks/{textarea.lite.tsx → textarea/textarea.lite.tsx} +3 -1
- package/src/blocks/video/component-info.js +106 -0
- package/src/blocks/video/index.js +7 -0
- package/src/blocks/video/video.jsx +14 -0
- package/src/blocks/{video.lite.tsx → video/video.lite.tsx} +3 -1
- package/src/components/error-boundary.jsx +5 -0
- package/src/components/error-boundary.lite.tsx +3 -1
- package/src/components/render-block/block-styles.jsx +36 -0
- package/src/components/render-block/block-styles.lite.tsx +38 -0
- package/src/components/render-block/render-block.jsx +117 -0
- package/src/components/{render-block.lite.tsx → render-block/render-block.lite.tsx} +24 -13
- package/src/components/render-blocks.jsx +57 -0
- package/src/components/render-blocks.lite.tsx +9 -6
- package/src/components/render-content/components/{render-styles.js → render-styles.jsx} +8 -15
- package/src/components/render-content/components/render-styles.lite.tsx +10 -4
- package/src/components/render-content/{render-content.js → render-content.jsx} +42 -94
- package/src/components/render-content/render-content.lite.tsx +23 -20
- package/src/components/render-inlined-styles.jsx +23 -0
- package/src/components/render-inlined-styles.lite.tsx +26 -0
- package/src/functions/evaluate.js +2 -2
- package/src/functions/get-block-actions.js +2 -2
- package/src/functions/get-builder-search-params/fn.test.js +1 -1
- package/src/functions/get-content/index.js +3 -2
- package/src/functions/get-fetch.js +29 -7
- package/src/functions/get-processed-block.js +3 -3
- package/src/functions/get-processed-block.test.js +1 -1
- package/src/functions/if-target.js +1 -1
- package/src/functions/is-editing.js +1 -1
- package/src/functions/is-iframe.js +1 -1
- package/src/functions/is-previewing.js +2 -2
- package/src/functions/on-change.test.js +1 -1
- package/src/functions/previewing-model-name.js +1 -1
- package/src/functions/register-component.js +1 -1
- package/src/functions/register.js +1 -1
- package/src/functions/set-editor-settings.js +1 -1
- package/src/functions/set.test.js +1 -1
- package/src/functions/track.js +3 -3
- package/src/index-helpers/blocks-exports.js +8 -8
- package/src/index.js +10 -13
- package/src/scripts/init-editing.js +72 -63
- package/src/blocks/button.js +0 -32
- package/src/blocks/button.lite.tsx +0 -12
- package/src/blocks/columns.js +0 -133
- package/src/blocks/embed.js +0 -62
- package/src/blocks/form.js +0 -355
- package/src/blocks/fragment.js +0 -15
- package/src/blocks/fragment.lite.tsx +0 -3
- package/src/blocks/image.js +0 -211
- package/src/blocks/image.lite.tsx +0 -169
- package/src/blocks/img.js +0 -39
- package/src/blocks/input.js +0 -45
- package/src/blocks/raw-text.js +0 -25
- package/src/blocks/section.js +0 -24
- package/src/blocks/select.js +0 -57
- package/src/blocks/submit-button.js +0 -18
- package/src/blocks/symbol.js +0 -69
- package/src/blocks/text.js +0 -15
- package/src/blocks/textarea.js +0 -34
- package/src/blocks/video.js +0 -54
- package/src/components/block-styles.js +0 -3
- package/src/components/block-styles.lite.tsx +0 -3
- package/src/components/error-boundary.js +0 -3
- package/src/components/render-block.js +0 -154
- package/src/components/render-blocks.js +0 -104
|
@@ -1,154 +0,0 @@
|
|
|
1
|
-
import { mergeProps as _$mergeProps } from "solid-js/web";
|
|
2
|
-
import { createComponent as _$createComponent } from "solid-js/web";
|
|
3
|
-
import { useContext, Show, For } from "solid-js";
|
|
4
|
-
import { Dynamic } from "solid-js/web";
|
|
5
|
-
import { createMutable } from "solid-js/store";
|
|
6
|
-
import { getBlockComponentOptions } from "../functions/get-block-component-options";
|
|
7
|
-
import { getBlockProperties } from "../functions/get-block-properties";
|
|
8
|
-
import { getBlockStyles } from "../functions/get-block-styles";
|
|
9
|
-
import { getBlockTag } from "../functions/get-block-tag";
|
|
10
|
-
import { components } from "../functions/register-component";
|
|
11
|
-
import BuilderContext from "../context/builder.context";
|
|
12
|
-
import { getBlockActions } from "../functions/get-block-actions";
|
|
13
|
-
import { getProcessedBlock } from "../functions/get-processed-block";
|
|
14
|
-
import BlockStyles from "./block-styles";
|
|
15
|
-
export default function RenderBlock(props) {
|
|
16
|
-
const state = createMutable({
|
|
17
|
-
get component() {
|
|
18
|
-
const componentName = state.useBlock.component?.name;
|
|
19
|
-
|
|
20
|
-
if (!componentName) {
|
|
21
|
-
return null;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
const ref = components[state.useBlock.component?.name];
|
|
25
|
-
|
|
26
|
-
if (componentName && !ref) {
|
|
27
|
-
// TODO: Public doc page with more info about this message
|
|
28
|
-
console.warn(`
|
|
29
|
-
Could not find a registered component named "${componentName}".
|
|
30
|
-
If you registered it, is the file that registered it imported by the file that needs to render it?`);
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
return ref;
|
|
34
|
-
},
|
|
35
|
-
|
|
36
|
-
get componentInfo() {
|
|
37
|
-
return state.component?.info;
|
|
38
|
-
},
|
|
39
|
-
|
|
40
|
-
get componentRef() {
|
|
41
|
-
return state.component?.component;
|
|
42
|
-
},
|
|
43
|
-
|
|
44
|
-
get tagName() {
|
|
45
|
-
return getBlockTag(state.useBlock);
|
|
46
|
-
},
|
|
47
|
-
|
|
48
|
-
get useBlock() {
|
|
49
|
-
return getProcessedBlock({
|
|
50
|
-
block: props.block,
|
|
51
|
-
state: builderContext.state,
|
|
52
|
-
context: builderContext.context
|
|
53
|
-
});
|
|
54
|
-
},
|
|
55
|
-
|
|
56
|
-
get propertiesAndActions() {
|
|
57
|
-
return { ...getBlockProperties(state.useBlock),
|
|
58
|
-
...getBlockActions({
|
|
59
|
-
block: state.useBlock,
|
|
60
|
-
state: builderContext.state,
|
|
61
|
-
context: builderContext.context
|
|
62
|
-
})
|
|
63
|
-
};
|
|
64
|
-
},
|
|
65
|
-
|
|
66
|
-
get css() {
|
|
67
|
-
return getBlockStyles(state.useBlock);
|
|
68
|
-
},
|
|
69
|
-
|
|
70
|
-
get componentOptions() {
|
|
71
|
-
return getBlockComponentOptions(state.useBlock);
|
|
72
|
-
},
|
|
73
|
-
|
|
74
|
-
get children() {
|
|
75
|
-
// TO-DO: When should `canHaveChildren` dictate rendering?
|
|
76
|
-
// This is currently commented out because some Builder components (e.g. Box) do not have `canHaveChildren: true`,
|
|
77
|
-
// but still receive and need to render children.
|
|
78
|
-
// return state.componentInfo?.canHaveChildren ? state.useBlock.children : [];
|
|
79
|
-
return state.useBlock.children ?? [];
|
|
80
|
-
},
|
|
81
|
-
|
|
82
|
-
get noCompRefChildren() {
|
|
83
|
-
return state.componentRef ? [] : state.children;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
});
|
|
87
|
-
const builderContext = useContext(BuilderContext);
|
|
88
|
-
return _$createComponent(Show, {
|
|
89
|
-
get when() {
|
|
90
|
-
return !state.componentInfo?.noWrap;
|
|
91
|
-
},
|
|
92
|
-
|
|
93
|
-
get children() {
|
|
94
|
-
return _$createComponent(Dynamic, _$mergeProps(() => state.propertiesAndActions, {
|
|
95
|
-
get style() {
|
|
96
|
-
return state.css;
|
|
97
|
-
},
|
|
98
|
-
|
|
99
|
-
get component() {
|
|
100
|
-
return state.tagName;
|
|
101
|
-
},
|
|
102
|
-
|
|
103
|
-
get children() {
|
|
104
|
-
return [_$createComponent(BlockStyles, {
|
|
105
|
-
get block() {
|
|
106
|
-
return state.useBlock;
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
}), _$createComponent(Show, {
|
|
110
|
-
get when() {
|
|
111
|
-
return state.componentRef;
|
|
112
|
-
},
|
|
113
|
-
|
|
114
|
-
get children() {
|
|
115
|
-
return _$createComponent(Dynamic, _$mergeProps(() => state.componentOptions, {
|
|
116
|
-
get builderBlock() {
|
|
117
|
-
return state.useBlock;
|
|
118
|
-
},
|
|
119
|
-
|
|
120
|
-
get component() {
|
|
121
|
-
return state.componentRef;
|
|
122
|
-
},
|
|
123
|
-
|
|
124
|
-
get children() {
|
|
125
|
-
return _$createComponent(For, {
|
|
126
|
-
get each() {
|
|
127
|
-
return state.children;
|
|
128
|
-
},
|
|
129
|
-
|
|
130
|
-
children: (child, index) => _$createComponent(RenderBlock, {
|
|
131
|
-
block: child
|
|
132
|
-
})
|
|
133
|
-
});
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
}));
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
}), _$createComponent(For, {
|
|
140
|
-
get each() {
|
|
141
|
-
return state.noCompRefChildren;
|
|
142
|
-
},
|
|
143
|
-
|
|
144
|
-
children: (child, index) => _$createComponent(RenderBlock, {
|
|
145
|
-
block: child
|
|
146
|
-
})
|
|
147
|
-
})];
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
}));
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
});
|
|
154
|
-
}
|
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
import { template as _$template } from "solid-js/web";
|
|
2
|
-
import { delegateEvents as _$delegateEvents } from "solid-js/web";
|
|
3
|
-
import { setAttribute as _$setAttribute } from "solid-js/web";
|
|
4
|
-
import { effect as _$effect } from "solid-js/web";
|
|
5
|
-
import { insert as _$insert } from "solid-js/web";
|
|
6
|
-
import { createComponent as _$createComponent } from "solid-js/web";
|
|
7
|
-
|
|
8
|
-
const _tmpl$ = /*#__PURE__*/_$template(`<div></div>`, 2);
|
|
9
|
-
|
|
10
|
-
import { Show, For } from "solid-js";
|
|
11
|
-
import { createMutable } from "solid-js/store";
|
|
12
|
-
import { css } from "solid-styled-components";
|
|
13
|
-
import { isEditing } from "../functions/is-editing";
|
|
14
|
-
import RenderBlock from "./render-block";
|
|
15
|
-
export default function RenderBlocks(props) {
|
|
16
|
-
const state = createMutable({
|
|
17
|
-
get className() {
|
|
18
|
-
return "builder-blocks" + (!props.blocks?.length ? " no-blocks" : "");
|
|
19
|
-
},
|
|
20
|
-
|
|
21
|
-
onClick() {
|
|
22
|
-
if (isEditing() && !props.blocks?.length) {
|
|
23
|
-
window.parent?.postMessage({
|
|
24
|
-
type: "builder.clickEmptyBlocks",
|
|
25
|
-
data: {
|
|
26
|
-
parentElementId: props.parent,
|
|
27
|
-
dataPath: props.path
|
|
28
|
-
}
|
|
29
|
-
}, "*");
|
|
30
|
-
}
|
|
31
|
-
},
|
|
32
|
-
|
|
33
|
-
onMouseEnter() {
|
|
34
|
-
if (isEditing() && !props.blocks?.length) {
|
|
35
|
-
window.parent?.postMessage({
|
|
36
|
-
type: "builder.hoverEmptyBlocks",
|
|
37
|
-
data: {
|
|
38
|
-
parentElementId: props.parent,
|
|
39
|
-
dataPath: props.path
|
|
40
|
-
}
|
|
41
|
-
}, "*");
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
});
|
|
46
|
-
return (() => {
|
|
47
|
-
const _el$ = _tmpl$.cloneNode(true);
|
|
48
|
-
|
|
49
|
-
_el$.addEventListener("mouseenter", event => state.onMouseEnter());
|
|
50
|
-
|
|
51
|
-
_el$.$$click = event => state.onClick();
|
|
52
|
-
|
|
53
|
-
_$insert(_el$, _$createComponent(Show, {
|
|
54
|
-
get when() {
|
|
55
|
-
return props.blocks;
|
|
56
|
-
},
|
|
57
|
-
|
|
58
|
-
get children() {
|
|
59
|
-
return _$createComponent(For, {
|
|
60
|
-
get each() {
|
|
61
|
-
return props.blocks;
|
|
62
|
-
},
|
|
63
|
-
|
|
64
|
-
children: (block, index) => _$createComponent(RenderBlock, {
|
|
65
|
-
get key() {
|
|
66
|
-
return block.id;
|
|
67
|
-
},
|
|
68
|
-
|
|
69
|
-
block: block
|
|
70
|
-
})
|
|
71
|
-
});
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
}));
|
|
75
|
-
|
|
76
|
-
_$effect(_p$ => {
|
|
77
|
-
const _v$ = state.className + " " + css({
|
|
78
|
-
display: "flex",
|
|
79
|
-
flexDirection: "column",
|
|
80
|
-
alignItems: "stretch"
|
|
81
|
-
}),
|
|
82
|
-
_v$2 = props.path,
|
|
83
|
-
_v$3 = props.parent,
|
|
84
|
-
_v$4 = {
|
|
85
|
-
class: state.className
|
|
86
|
-
};
|
|
87
|
-
|
|
88
|
-
_v$ !== _p$._v$ && (_el$.className = _p$._v$ = _v$);
|
|
89
|
-
_v$2 !== _p$._v$2 && _$setAttribute(_el$, "builder-path", _p$._v$2 = _v$2);
|
|
90
|
-
_v$3 !== _p$._v$3 && _$setAttribute(_el$, "builder-parent-id", _p$._v$3 = _v$3);
|
|
91
|
-
_v$4 !== _p$._v$4 && _$setAttribute(_el$, "dataset", _p$._v$4 = _v$4);
|
|
92
|
-
return _p$;
|
|
93
|
-
}, {
|
|
94
|
-
_v$: undefined,
|
|
95
|
-
_v$2: undefined,
|
|
96
|
-
_v$3: undefined,
|
|
97
|
-
_v$4: undefined
|
|
98
|
-
});
|
|
99
|
-
|
|
100
|
-
return _el$;
|
|
101
|
-
})();
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
_$delegateEvents(["click"]);
|