@builder.io/sdk-solid 0.8.0 → 0.9.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/dist/index.d.ts +48 -19
- package/lib/browser/dev.js +118 -149
- package/lib/browser/dev.jsx +40 -93
- package/lib/browser/index.js +118 -142
- package/lib/browser/index.jsx +40 -91
- package/lib/edge/dev.js +118 -149
- package/lib/edge/dev.jsx +40 -93
- package/lib/edge/index.js +118 -142
- package/lib/edge/index.jsx +40 -91
- package/lib/node/dev.js +134 -160
- package/lib/node/dev.jsx +56 -104
- package/lib/node/index.js +132 -151
- package/lib/node/index.jsx +54 -100
- package/package.json +1 -1
package/lib/edge/dev.jsx
CHANGED
|
@@ -49,7 +49,9 @@ var builder_context_default = createContext({
|
|
|
49
49
|
apiKey: null,
|
|
50
50
|
apiVersion: void 0,
|
|
51
51
|
componentInfos: {},
|
|
52
|
-
inheritedStyles: {}
|
|
52
|
+
inheritedStyles: {},
|
|
53
|
+
BlocksWrapper: "div",
|
|
54
|
+
BlocksWrapperProps: {}
|
|
53
55
|
});
|
|
54
56
|
|
|
55
57
|
// src/context/components.context.ts
|
|
@@ -3753,85 +3755,10 @@ function getBlockActions(options) {
|
|
|
3753
3755
|
return obj;
|
|
3754
3756
|
}
|
|
3755
3757
|
|
|
3756
|
-
// src/functions/sanitize-react-native-block-styles.ts
|
|
3757
|
-
var propertiesThatMustBeNumber = /* @__PURE__ */ new Set(["lineHeight"]);
|
|
3758
|
-
var displayValues = /* @__PURE__ */ new Set(["flex", "none"]);
|
|
3759
|
-
var SHOW_WARNINGS = false;
|
|
3760
|
-
var normalizeNumber = (value) => {
|
|
3761
|
-
if (Number.isNaN(value)) {
|
|
3762
|
-
return void 0;
|
|
3763
|
-
} else if (value < 0) {
|
|
3764
|
-
return 0;
|
|
3765
|
-
} else {
|
|
3766
|
-
return value;
|
|
3767
|
-
}
|
|
3768
|
-
};
|
|
3769
|
-
var sanitizeReactNativeBlockStyles = (styles) => {
|
|
3770
|
-
return Object.keys(styles).reduce((acc, key) => {
|
|
3771
|
-
const propertyValue = styles[key];
|
|
3772
|
-
if (key === "display" && !displayValues.has(propertyValue)) {
|
|
3773
|
-
if (SHOW_WARNINGS) {
|
|
3774
|
-
console.warn(`Style value for key "display" must be "flex" or "none" but had ${propertyValue}`);
|
|
3775
|
-
}
|
|
3776
|
-
return acc;
|
|
3777
|
-
}
|
|
3778
|
-
if (propertiesThatMustBeNumber.has(key) && typeof propertyValue !== "number") {
|
|
3779
|
-
if (SHOW_WARNINGS) {
|
|
3780
|
-
console.warn(`Style key ${key} must be a number, but had value \`${styles[key]}\``);
|
|
3781
|
-
}
|
|
3782
|
-
return acc;
|
|
3783
|
-
}
|
|
3784
|
-
if (typeof propertyValue === "string") {
|
|
3785
|
-
const isPixelUnit = propertyValue.match(/^-?(\d*)(\.?)(\d*)*px$/);
|
|
3786
|
-
if (isPixelUnit) {
|
|
3787
|
-
const newValue = parseFloat(propertyValue);
|
|
3788
|
-
const normalizedValue = normalizeNumber(newValue);
|
|
3789
|
-
if (normalizedValue) {
|
|
3790
|
-
return {
|
|
3791
|
-
...acc,
|
|
3792
|
-
[key]: normalizedValue
|
|
3793
|
-
};
|
|
3794
|
-
} else {
|
|
3795
|
-
return acc;
|
|
3796
|
-
}
|
|
3797
|
-
} else if (propertyValue === "0") {
|
|
3798
|
-
return {
|
|
3799
|
-
...acc,
|
|
3800
|
-
[key]: 0
|
|
3801
|
-
};
|
|
3802
|
-
}
|
|
3803
|
-
}
|
|
3804
|
-
return {
|
|
3805
|
-
...acc,
|
|
3806
|
-
[key]: propertyValue
|
|
3807
|
-
};
|
|
3808
|
-
}, {});
|
|
3809
|
-
};
|
|
3810
|
-
|
|
3811
|
-
// src/functions/get-react-native-block-styles.ts
|
|
3812
|
-
function getReactNativeBlockStyles({
|
|
3813
|
-
block,
|
|
3814
|
-
context,
|
|
3815
|
-
blockStyles
|
|
3816
|
-
}) {
|
|
3817
|
-
const responsiveStyles = block.responsiveStyles;
|
|
3818
|
-
if (!responsiveStyles) {
|
|
3819
|
-
return {};
|
|
3820
|
-
}
|
|
3821
|
-
const styles = {
|
|
3822
|
-
// recursively apply inherited styles so that they can be passed down to children `Text` blocks
|
|
3823
|
-
...context.inheritedStyles,
|
|
3824
|
-
...responsiveStyles.large || {},
|
|
3825
|
-
...responsiveStyles.medium || {},
|
|
3826
|
-
...responsiveStyles.small || {},
|
|
3827
|
-
...blockStyles
|
|
3828
|
-
};
|
|
3829
|
-
const newStyles = sanitizeReactNativeBlockStyles(styles);
|
|
3830
|
-
return newStyles;
|
|
3831
|
-
}
|
|
3832
|
-
|
|
3833
3758
|
// src/functions/transform-block-properties.ts
|
|
3834
|
-
function transformBlockProperties(
|
|
3759
|
+
function transformBlockProperties({
|
|
3760
|
+
properties
|
|
3761
|
+
}) {
|
|
3835
3762
|
return properties;
|
|
3836
3763
|
}
|
|
3837
3764
|
|
|
@@ -3852,14 +3779,11 @@ function getBlockProperties({
|
|
|
3852
3779
|
style: block.style ? getStyleAttribute(block.style) : void 0,
|
|
3853
3780
|
class: [block.id, "builder-block", block.class, block.properties?.class].filter(Boolean).join(" ")
|
|
3854
3781
|
};
|
|
3855
|
-
|
|
3856
|
-
properties
|
|
3857
|
-
|
|
3858
|
-
|
|
3859
|
-
|
|
3860
|
-
});
|
|
3861
|
-
}
|
|
3862
|
-
return transformBlockProperties(properties);
|
|
3782
|
+
return transformBlockProperties({
|
|
3783
|
+
properties,
|
|
3784
|
+
context,
|
|
3785
|
+
block
|
|
3786
|
+
});
|
|
3863
3787
|
}
|
|
3864
3788
|
function getStyleAttribute(style) {
|
|
3865
3789
|
switch (TARGET) {
|
|
@@ -4149,6 +4073,7 @@ function Block(props) {
|
|
|
4149
4073
|
var Block_default = Block;
|
|
4150
4074
|
|
|
4151
4075
|
// src/components/blocks/blocks-wrapper.tsx
|
|
4076
|
+
import { Dynamic as Dynamic4 } from "solid-js/web";
|
|
4152
4077
|
import { css as css2 } from "solid-styled-components";
|
|
4153
4078
|
function BlocksWrapper(props) {
|
|
4154
4079
|
function className() {
|
|
@@ -4182,7 +4107,7 @@ function BlocksWrapper(props) {
|
|
|
4182
4107
|
);
|
|
4183
4108
|
}
|
|
4184
4109
|
}
|
|
4185
|
-
return <
|
|
4110
|
+
return <Dynamic4
|
|
4186
4111
|
class={className() + " " + css2({
|
|
4187
4112
|
display: "flex",
|
|
4188
4113
|
flexDirection: "column",
|
|
@@ -4195,7 +4120,9 @@ function BlocksWrapper(props) {
|
|
|
4195
4120
|
onClick={(event) => onClick()}
|
|
4196
4121
|
onMouseEnter={(event) => onMouseEnter()}
|
|
4197
4122
|
onKeyPress={(event) => onClick()}
|
|
4198
|
-
|
|
4123
|
+
{...props.BlocksWrapperProps}
|
|
4124
|
+
component={props.BlocksWrapper}
|
|
4125
|
+
>{props.children}</Dynamic4>;
|
|
4199
4126
|
}
|
|
4200
4127
|
var Blocks_wrapper_default = BlocksWrapper;
|
|
4201
4128
|
|
|
@@ -4208,6 +4135,8 @@ function Blocks(props) {
|
|
|
4208
4135
|
parent={props.parent}
|
|
4209
4136
|
path={props.path}
|
|
4210
4137
|
styleProp={props.styleProp}
|
|
4138
|
+
BlocksWrapper={props.context?.BlocksWrapper}
|
|
4139
|
+
BlocksWrapperProps={props.context?.BlocksWrapperProps}
|
|
4211
4140
|
>
|
|
4212
4141
|
<Show6 when={props.blocks}><For3 each={props.blocks}>{(block, _index) => {
|
|
4213
4142
|
const index = _index();
|
|
@@ -5702,6 +5631,7 @@ var Inlined_script_default = InlinedScript;
|
|
|
5702
5631
|
|
|
5703
5632
|
// src/components/content/components/enable-editor.tsx
|
|
5704
5633
|
import { Show as Show10, onMount as onMount2, on as on2, createEffect as createEffect2, createSignal as createSignal10 } from "solid-js";
|
|
5634
|
+
import { Dynamic as Dynamic5 } from "solid-js/web";
|
|
5705
5635
|
|
|
5706
5636
|
// src/helpers/preview-lru-cache/get.ts
|
|
5707
5637
|
function getPreviewContent(_searchParams) {
|
|
@@ -6188,7 +6118,7 @@ var getInteractionPropertiesForEvent = (event) => {
|
|
|
6188
6118
|
};
|
|
6189
6119
|
|
|
6190
6120
|
// src/constants/sdk-version.ts
|
|
6191
|
-
var SDK_VERSION = "0.
|
|
6121
|
+
var SDK_VERSION = "0.9.0";
|
|
6192
6122
|
|
|
6193
6123
|
// src/functions/register.ts
|
|
6194
6124
|
var registry = {};
|
|
@@ -6326,6 +6256,9 @@ function EnableEditor(props) {
|
|
|
6326
6256
|
const [forceReRenderCount, setForceReRenderCount] = createSignal10(0);
|
|
6327
6257
|
const [lastUpdated, setLastUpdated] = createSignal10(0);
|
|
6328
6258
|
const [shouldSendResetCookie, setShouldSendResetCookie] = createSignal10(false);
|
|
6259
|
+
const [ContentWrapper, setContentWrapper] = createSignal10(
|
|
6260
|
+
props.contentWrapper || "div"
|
|
6261
|
+
);
|
|
6329
6262
|
const [httpReqsData, setHttpReqsData] = createSignal10({});
|
|
6330
6263
|
const [clicked, setClicked] = createSignal10(false);
|
|
6331
6264
|
function mergeNewContent(newContent) {
|
|
@@ -6570,7 +6503,7 @@ function EnableEditor(props) {
|
|
|
6570
6503
|
emitStateUpdate();
|
|
6571
6504
|
}
|
|
6572
6505
|
createEffect2(on2(() => [props.builderContextSignal.rootState], onUpdateFn_4));
|
|
6573
|
-
return <builder_context_default.Provider value={props.builderContextSignal}><Show10 when={props.builderContextSignal.content}><
|
|
6506
|
+
return <builder_context_default.Provider value={props.builderContextSignal}><Show10 when={props.builderContextSignal.content}><Dynamic5
|
|
6574
6507
|
class={`variant-${props.content?.testVariationId || props.content?.id}`}
|
|
6575
6508
|
{...{}}
|
|
6576
6509
|
key={forceReRenderCount()}
|
|
@@ -6583,7 +6516,9 @@ function EnableEditor(props) {
|
|
|
6583
6516
|
hidden: true,
|
|
6584
6517
|
"aria-hidden": true
|
|
6585
6518
|
}}
|
|
6586
|
-
|
|
6519
|
+
{...props.contentWrapperProps}
|
|
6520
|
+
component={ContentWrapper()}
|
|
6521
|
+
>{props.children}</Dynamic5></Show10></builder_context_default.Provider>;
|
|
6587
6522
|
}
|
|
6588
6523
|
var Enable_editor_default = EnableEditor;
|
|
6589
6524
|
|
|
@@ -6773,7 +6708,9 @@ function ContentComponent(props) {
|
|
|
6773
6708
|
}),
|
|
6774
6709
|
{}
|
|
6775
6710
|
),
|
|
6776
|
-
inheritedStyles: {}
|
|
6711
|
+
inheritedStyles: {},
|
|
6712
|
+
BlocksWrapper: props.blocksWrapper || "div",
|
|
6713
|
+
BlocksWrapperProps: props.blocksWrapperProps || {}
|
|
6777
6714
|
});
|
|
6778
6715
|
function contentSetState(newRootState) {
|
|
6779
6716
|
setBuilderContextSignal((PREVIOUS_VALUE) => ({
|
|
@@ -6796,6 +6733,8 @@ function ContentComponent(props) {
|
|
|
6796
6733
|
enrich={props.enrich}
|
|
6797
6734
|
showContent={props.showContent}
|
|
6798
6735
|
builderContextSignal={builderContextSignal()}
|
|
6736
|
+
contentWrapper={props.contentWrapper}
|
|
6737
|
+
contentWrapperProps={props.contentWrapperProps}
|
|
6799
6738
|
{...{
|
|
6800
6739
|
setBuilderContextSignal
|
|
6801
6740
|
}}
|
|
@@ -6874,6 +6813,10 @@ function ContentVariants(props) {
|
|
|
6874
6813
|
includeRefs={props.includeRefs}
|
|
6875
6814
|
enrich={props.enrich}
|
|
6876
6815
|
isSsrAbTest={shouldRenderVariants()}
|
|
6816
|
+
blocksWrapper={props.blocksWrapper}
|
|
6817
|
+
blocksWrapperProps={props.blocksWrapperProps}
|
|
6818
|
+
contentWrapper={props.contentWrapper}
|
|
6819
|
+
contentWrapperProps={props.contentWrapperProps}
|
|
6877
6820
|
/>;
|
|
6878
6821
|
}}</For5>
|
|
6879
6822
|
</Show12>
|
|
@@ -6892,6 +6835,10 @@ function ContentVariants(props) {
|
|
|
6892
6835
|
includeRefs={props.includeRefs}
|
|
6893
6836
|
enrich={props.enrich}
|
|
6894
6837
|
isSsrAbTest={shouldRenderVariants()}
|
|
6838
|
+
blocksWrapper={props.blocksWrapper}
|
|
6839
|
+
blocksWrapperProps={props.blocksWrapperProps}
|
|
6840
|
+
contentWrapper={props.contentWrapper}
|
|
6841
|
+
contentWrapperProps={props.contentWrapperProps}
|
|
6895
6842
|
/>
|
|
6896
6843
|
</>;
|
|
6897
6844
|
}
|