@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/browser/index.jsx
CHANGED
|
@@ -41,7 +41,9 @@ var builder_context_default = createContext({
|
|
|
41
41
|
apiKey: null,
|
|
42
42
|
apiVersion: void 0,
|
|
43
43
|
componentInfos: {},
|
|
44
|
-
inheritedStyles: {}
|
|
44
|
+
inheritedStyles: {},
|
|
45
|
+
BlocksWrapper: "div",
|
|
46
|
+
BlocksWrapperProps: {}
|
|
45
47
|
});
|
|
46
48
|
|
|
47
49
|
// src/context/components.context.ts
|
|
@@ -593,83 +595,10 @@ function getBlockActions(options) {
|
|
|
593
595
|
return obj;
|
|
594
596
|
}
|
|
595
597
|
|
|
596
|
-
// src/functions/sanitize-react-native-block-styles.ts
|
|
597
|
-
var propertiesThatMustBeNumber = /* @__PURE__ */ new Set(["lineHeight"]);
|
|
598
|
-
var displayValues = /* @__PURE__ */ new Set(["flex", "none"]);
|
|
599
|
-
var SHOW_WARNINGS = false;
|
|
600
|
-
var normalizeNumber = (value) => {
|
|
601
|
-
if (Number.isNaN(value)) {
|
|
602
|
-
return void 0;
|
|
603
|
-
} else if (value < 0) {
|
|
604
|
-
return 0;
|
|
605
|
-
} else {
|
|
606
|
-
return value;
|
|
607
|
-
}
|
|
608
|
-
};
|
|
609
|
-
var sanitizeReactNativeBlockStyles = (styles) => {
|
|
610
|
-
return Object.keys(styles).reduce((acc, key) => {
|
|
611
|
-
const propertyValue = styles[key];
|
|
612
|
-
if (key === "display" && !displayValues.has(propertyValue)) {
|
|
613
|
-
if (SHOW_WARNINGS) {
|
|
614
|
-
}
|
|
615
|
-
return acc;
|
|
616
|
-
}
|
|
617
|
-
if (propertiesThatMustBeNumber.has(key) && typeof propertyValue !== "number") {
|
|
618
|
-
if (SHOW_WARNINGS) {
|
|
619
|
-
}
|
|
620
|
-
return acc;
|
|
621
|
-
}
|
|
622
|
-
if (typeof propertyValue === "string") {
|
|
623
|
-
const isPixelUnit = propertyValue.match(/^-?(\d*)(\.?)(\d*)*px$/);
|
|
624
|
-
if (isPixelUnit) {
|
|
625
|
-
const newValue = parseFloat(propertyValue);
|
|
626
|
-
const normalizedValue = normalizeNumber(newValue);
|
|
627
|
-
if (normalizedValue) {
|
|
628
|
-
return {
|
|
629
|
-
...acc,
|
|
630
|
-
[key]: normalizedValue
|
|
631
|
-
};
|
|
632
|
-
} else {
|
|
633
|
-
return acc;
|
|
634
|
-
}
|
|
635
|
-
} else if (propertyValue === "0") {
|
|
636
|
-
return {
|
|
637
|
-
...acc,
|
|
638
|
-
[key]: 0
|
|
639
|
-
};
|
|
640
|
-
}
|
|
641
|
-
}
|
|
642
|
-
return {
|
|
643
|
-
...acc,
|
|
644
|
-
[key]: propertyValue
|
|
645
|
-
};
|
|
646
|
-
}, {});
|
|
647
|
-
};
|
|
648
|
-
|
|
649
|
-
// src/functions/get-react-native-block-styles.ts
|
|
650
|
-
function getReactNativeBlockStyles({
|
|
651
|
-
block,
|
|
652
|
-
context,
|
|
653
|
-
blockStyles
|
|
654
|
-
}) {
|
|
655
|
-
const responsiveStyles = block.responsiveStyles;
|
|
656
|
-
if (!responsiveStyles) {
|
|
657
|
-
return {};
|
|
658
|
-
}
|
|
659
|
-
const styles = {
|
|
660
|
-
// recursively apply inherited styles so that they can be passed down to children `Text` blocks
|
|
661
|
-
...context.inheritedStyles,
|
|
662
|
-
...responsiveStyles.large || {},
|
|
663
|
-
...responsiveStyles.medium || {},
|
|
664
|
-
...responsiveStyles.small || {},
|
|
665
|
-
...blockStyles
|
|
666
|
-
};
|
|
667
|
-
const newStyles = sanitizeReactNativeBlockStyles(styles);
|
|
668
|
-
return newStyles;
|
|
669
|
-
}
|
|
670
|
-
|
|
671
598
|
// src/functions/transform-block-properties.ts
|
|
672
|
-
function transformBlockProperties(
|
|
599
|
+
function transformBlockProperties({
|
|
600
|
+
properties
|
|
601
|
+
}) {
|
|
673
602
|
return properties;
|
|
674
603
|
}
|
|
675
604
|
|
|
@@ -690,14 +619,11 @@ function getBlockProperties({
|
|
|
690
619
|
style: block.style ? getStyleAttribute(block.style) : void 0,
|
|
691
620
|
class: [block.id, "builder-block", block.class, block.properties?.class].filter(Boolean).join(" ")
|
|
692
621
|
};
|
|
693
|
-
|
|
694
|
-
properties
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
});
|
|
699
|
-
}
|
|
700
|
-
return transformBlockProperties(properties);
|
|
622
|
+
return transformBlockProperties({
|
|
623
|
+
properties,
|
|
624
|
+
context,
|
|
625
|
+
block
|
|
626
|
+
});
|
|
701
627
|
}
|
|
702
628
|
function getStyleAttribute(style) {
|
|
703
629
|
switch (TARGET) {
|
|
@@ -987,6 +913,7 @@ function Block(props) {
|
|
|
987
913
|
var Block_default = Block;
|
|
988
914
|
|
|
989
915
|
// src/components/blocks/blocks-wrapper.tsx
|
|
916
|
+
import { Dynamic as Dynamic4 } from "solid-js/web";
|
|
990
917
|
import { css as css2 } from "solid-styled-components";
|
|
991
918
|
function BlocksWrapper(props) {
|
|
992
919
|
function className() {
|
|
@@ -1020,7 +947,7 @@ function BlocksWrapper(props) {
|
|
|
1020
947
|
);
|
|
1021
948
|
}
|
|
1022
949
|
}
|
|
1023
|
-
return <
|
|
950
|
+
return <Dynamic4
|
|
1024
951
|
class={className() + " " + css2({
|
|
1025
952
|
display: "flex",
|
|
1026
953
|
flexDirection: "column",
|
|
@@ -1033,7 +960,9 @@ function BlocksWrapper(props) {
|
|
|
1033
960
|
onClick={(event) => onClick()}
|
|
1034
961
|
onMouseEnter={(event) => onMouseEnter()}
|
|
1035
962
|
onKeyPress={(event) => onClick()}
|
|
1036
|
-
|
|
963
|
+
{...props.BlocksWrapperProps}
|
|
964
|
+
component={props.BlocksWrapper}
|
|
965
|
+
>{props.children}</Dynamic4>;
|
|
1037
966
|
}
|
|
1038
967
|
var Blocks_wrapper_default = BlocksWrapper;
|
|
1039
968
|
|
|
@@ -1046,6 +975,8 @@ function Blocks(props) {
|
|
|
1046
975
|
parent={props.parent}
|
|
1047
976
|
path={props.path}
|
|
1048
977
|
styleProp={props.styleProp}
|
|
978
|
+
BlocksWrapper={props.context?.BlocksWrapper}
|
|
979
|
+
BlocksWrapperProps={props.context?.BlocksWrapperProps}
|
|
1049
980
|
>
|
|
1050
981
|
<Show6 when={props.blocks}><For3 each={props.blocks}>{(block, _index) => {
|
|
1051
982
|
const index = _index();
|
|
@@ -2536,6 +2467,7 @@ var Inlined_script_default = InlinedScript;
|
|
|
2536
2467
|
|
|
2537
2468
|
// src/components/content/components/enable-editor.tsx
|
|
2538
2469
|
import { Show as Show10, onMount as onMount2, on as on2, createEffect as createEffect2, createSignal as createSignal10 } from "solid-js";
|
|
2470
|
+
import { Dynamic as Dynamic5 } from "solid-js/web";
|
|
2539
2471
|
|
|
2540
2472
|
// src/helpers/preview-lru-cache/get.ts
|
|
2541
2473
|
function getPreviewContent(_searchParams) {
|
|
@@ -3017,7 +2949,7 @@ var getInteractionPropertiesForEvent = (event) => {
|
|
|
3017
2949
|
};
|
|
3018
2950
|
|
|
3019
2951
|
// src/constants/sdk-version.ts
|
|
3020
|
-
var SDK_VERSION = "0.
|
|
2952
|
+
var SDK_VERSION = "0.9.0";
|
|
3021
2953
|
|
|
3022
2954
|
// src/functions/register.ts
|
|
3023
2955
|
var registry = {};
|
|
@@ -3154,6 +3086,9 @@ function EnableEditor(props) {
|
|
|
3154
3086
|
const [forceReRenderCount, setForceReRenderCount] = createSignal10(0);
|
|
3155
3087
|
const [lastUpdated, setLastUpdated] = createSignal10(0);
|
|
3156
3088
|
const [shouldSendResetCookie, setShouldSendResetCookie] = createSignal10(false);
|
|
3089
|
+
const [ContentWrapper, setContentWrapper] = createSignal10(
|
|
3090
|
+
props.contentWrapper || "div"
|
|
3091
|
+
);
|
|
3157
3092
|
const [httpReqsData, setHttpReqsData] = createSignal10({});
|
|
3158
3093
|
const [clicked, setClicked] = createSignal10(false);
|
|
3159
3094
|
function mergeNewContent(newContent) {
|
|
@@ -3397,7 +3332,7 @@ function EnableEditor(props) {
|
|
|
3397
3332
|
emitStateUpdate();
|
|
3398
3333
|
}
|
|
3399
3334
|
createEffect2(on2(() => [props.builderContextSignal.rootState], onUpdateFn_4));
|
|
3400
|
-
return <builder_context_default.Provider value={props.builderContextSignal}><Show10 when={props.builderContextSignal.content}><
|
|
3335
|
+
return <builder_context_default.Provider value={props.builderContextSignal}><Show10 when={props.builderContextSignal.content}><Dynamic5
|
|
3401
3336
|
class={`variant-${props.content?.testVariationId || props.content?.id}`}
|
|
3402
3337
|
{...{}}
|
|
3403
3338
|
key={forceReRenderCount()}
|
|
@@ -3410,7 +3345,9 @@ function EnableEditor(props) {
|
|
|
3410
3345
|
hidden: true,
|
|
3411
3346
|
"aria-hidden": true
|
|
3412
3347
|
}}
|
|
3413
|
-
|
|
3348
|
+
{...props.contentWrapperProps}
|
|
3349
|
+
component={ContentWrapper()}
|
|
3350
|
+
>{props.children}</Dynamic5></Show10></builder_context_default.Provider>;
|
|
3414
3351
|
}
|
|
3415
3352
|
var Enable_editor_default = EnableEditor;
|
|
3416
3353
|
|
|
@@ -3600,7 +3537,9 @@ function ContentComponent(props) {
|
|
|
3600
3537
|
}),
|
|
3601
3538
|
{}
|
|
3602
3539
|
),
|
|
3603
|
-
inheritedStyles: {}
|
|
3540
|
+
inheritedStyles: {},
|
|
3541
|
+
BlocksWrapper: props.blocksWrapper || "div",
|
|
3542
|
+
BlocksWrapperProps: props.blocksWrapperProps || {}
|
|
3604
3543
|
});
|
|
3605
3544
|
function contentSetState(newRootState) {
|
|
3606
3545
|
setBuilderContextSignal((PREVIOUS_VALUE) => ({
|
|
@@ -3623,6 +3562,8 @@ function ContentComponent(props) {
|
|
|
3623
3562
|
enrich={props.enrich}
|
|
3624
3563
|
showContent={props.showContent}
|
|
3625
3564
|
builderContextSignal={builderContextSignal()}
|
|
3565
|
+
contentWrapper={props.contentWrapper}
|
|
3566
|
+
contentWrapperProps={props.contentWrapperProps}
|
|
3626
3567
|
{...{
|
|
3627
3568
|
setBuilderContextSignal
|
|
3628
3569
|
}}
|
|
@@ -3701,6 +3642,10 @@ function ContentVariants(props) {
|
|
|
3701
3642
|
includeRefs={props.includeRefs}
|
|
3702
3643
|
enrich={props.enrich}
|
|
3703
3644
|
isSsrAbTest={shouldRenderVariants()}
|
|
3645
|
+
blocksWrapper={props.blocksWrapper}
|
|
3646
|
+
blocksWrapperProps={props.blocksWrapperProps}
|
|
3647
|
+
contentWrapper={props.contentWrapper}
|
|
3648
|
+
contentWrapperProps={props.contentWrapperProps}
|
|
3704
3649
|
/>;
|
|
3705
3650
|
}}</For5>
|
|
3706
3651
|
</Show12>
|
|
@@ -3719,6 +3664,10 @@ function ContentVariants(props) {
|
|
|
3719
3664
|
includeRefs={props.includeRefs}
|
|
3720
3665
|
enrich={props.enrich}
|
|
3721
3666
|
isSsrAbTest={shouldRenderVariants()}
|
|
3667
|
+
blocksWrapper={props.blocksWrapper}
|
|
3668
|
+
blocksWrapperProps={props.blocksWrapperProps}
|
|
3669
|
+
contentWrapper={props.contentWrapper}
|
|
3670
|
+
contentWrapperProps={props.contentWrapperProps}
|
|
3722
3671
|
/>
|
|
3723
3672
|
</>;
|
|
3724
3673
|
}
|