@builder.io/sdk-solid 0.0.17 → 0.0.19
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 +3 -3
- package/src/blocks/columns/columns.jsx +2 -2
- package/src/blocks/form/form.jsx +2 -2
- package/src/blocks/image/image.jsx +2 -2
- package/src/blocks/symbol/symbol.jsx +11 -9
- package/src/blocks/video/video.jsx +7 -1
- package/src/components/render-block/render-block.jsx +9 -18
- package/src/components/render-block/render-component-with-context.jsx +1 -1
- package/src/components/render-blocks.jsx +1 -1
- package/src/components/render-content/render-content.jsx +1 -1
- package/src/functions/get-react-native-block-styles.js +32 -0
- package/src/functions/sanitize-react-native-block-styles.js +66 -0
- package/src/scripts/init-editing.js +36 -34
- package/src/functions/convert-style-object.js +0 -14
- package/src/functions/get-block-styles.js +0 -50
- package/src/functions/sanitize-styles.js +0 -4
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@builder.io/sdk-solid",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.19",
|
|
4
4
|
"description": "",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./solid-index.jsx",
|
|
@@ -17,11 +17,11 @@
|
|
|
17
17
|
"solid-styled-components": "^0.27.6"
|
|
18
18
|
},
|
|
19
19
|
"peerDependencies": {
|
|
20
|
-
"solid-js": "^1.
|
|
20
|
+
"solid-js": "^1.5.7"
|
|
21
21
|
},
|
|
22
22
|
"devDependencies": {
|
|
23
23
|
"babel-preset-solid": "^1.3.17",
|
|
24
|
-
"solid-js": "^1.
|
|
24
|
+
"solid-js": "^1.5.7",
|
|
25
25
|
"vite": "^3.0.4",
|
|
26
26
|
"vite-plugin-solid": "^2.2.6"
|
|
27
27
|
}
|
|
@@ -81,8 +81,8 @@ function Columns(props) {
|
|
|
81
81
|
"margin-left": `${index === 0 ? 0 : getGutterSize()}px`,
|
|
82
82
|
...columnCssVars()
|
|
83
83
|
}} key={index}>
|
|
84
|
-
<RenderBlocks blocks={markMutable(column.blocks)} path={`component.options.columns.${index}.blocks`} parent={props.builderBlock.id}
|
|
85
|
-
|
|
84
|
+
<RenderBlocks blocks={markMutable(column.blocks)} path={`component.options.columns.${index}.blocks`} parent={props.builderBlock.id} styleProp={{
|
|
85
|
+
flexGrow: "1"
|
|
86
86
|
}}></RenderBlocks>
|
|
87
87
|
</div>;
|
|
88
88
|
}}
|
package/src/blocks/form/form.jsx
CHANGED
|
@@ -120,9 +120,9 @@ function FormComponent(props) {
|
|
|
120
120
|
|
|
121
121
|
setFormState("sending");
|
|
122
122
|
const formUrl = `${builder.env === "dev" ? "http://localhost:5000" : "https://builder.io"}/api/v1/form-submit?apiKey=${builder.apiKey}&to=${btoa(props.sendSubmissionsToEmail || "")}&name=${encodeURIComponent(props.name || "")}`;
|
|
123
|
-
fetch(props.sendSubmissionsTo === "email" ? formUrl : props.action
|
|
123
|
+
fetch(props.sendSubmissionsTo === "email" ? formUrl : props.action
|
|
124
124
|
/* TODO: throw error if no action URL */
|
|
125
|
-
{
|
|
125
|
+
, {
|
|
126
126
|
body,
|
|
127
127
|
headers,
|
|
128
128
|
method: props.method || "post"
|
|
@@ -58,8 +58,8 @@ function Image(props) {
|
|
|
58
58
|
pointerEvents: "none",
|
|
59
59
|
fontSize: "0"
|
|
60
60
|
})} style={{
|
|
61
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
62
|
-
|
|
61
|
+
"padding-top": // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
62
|
+
props.aspectRatio * 100 + "%"
|
|
63
63
|
}}></div>
|
|
64
64
|
</Show>
|
|
65
65
|
<Show when={props.builderBlock?.children?.length && props.fitContent}>
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { useContext,
|
|
1
|
+
import { useContext, on, createEffect, createSignal } from "solid-js";
|
|
2
2
|
import RenderContent from "../../components/render-content/render-content.jsx";
|
|
3
3
|
import BuilderContext from "../../context/builder.context.js";
|
|
4
4
|
import { getContent } from "../../functions/get-content/index.js";
|
|
@@ -6,11 +6,13 @@ import { markMutable } from "../../functions/mark-mutable";
|
|
|
6
6
|
|
|
7
7
|
function Symbol(props) {
|
|
8
8
|
const [className, setClassName] = createSignal("builder-symbol");
|
|
9
|
-
const [
|
|
9
|
+
const [fetchedContent, setFetchedContent] = createSignal(null);
|
|
10
|
+
|
|
11
|
+
function contentToUse() {
|
|
12
|
+
return props.symbol?.content || fetchedContent();
|
|
13
|
+
}
|
|
14
|
+
|
|
10
15
|
const builderContext = useContext(BuilderContext);
|
|
11
|
-
onMount(() => {
|
|
12
|
-
setContent(props.symbol?.content);
|
|
13
|
-
});
|
|
14
16
|
|
|
15
17
|
function onUpdateFn_0() {
|
|
16
18
|
const symbolToUse = props.symbol;
|
|
@@ -24,7 +26,7 @@ function Symbol(props) {
|
|
|
24
26
|
* then we want to re-fetch the symbol content.
|
|
25
27
|
*/
|
|
26
28
|
|
|
27
|
-
if (symbolToUse && !symbolToUse.content && !
|
|
29
|
+
if (symbolToUse && !symbolToUse.content && !fetchedContent() && symbolToUse.model) {
|
|
28
30
|
getContent({
|
|
29
31
|
model: symbolToUse.model,
|
|
30
32
|
apiKey: builderContext.apiKey,
|
|
@@ -32,19 +34,19 @@ function Symbol(props) {
|
|
|
32
34
|
id: symbolToUse.entry
|
|
33
35
|
}
|
|
34
36
|
}).then(response => {
|
|
35
|
-
|
|
37
|
+
setFetchedContent(response);
|
|
36
38
|
});
|
|
37
39
|
}
|
|
38
40
|
}
|
|
39
41
|
|
|
40
|
-
createEffect(on(() => [props.symbol,
|
|
42
|
+
createEffect(on(() => [props.symbol, fetchedContent()], onUpdateFn_0));
|
|
41
43
|
return <div class={className()} {...props.attributes} dataSet={{
|
|
42
44
|
class: className()
|
|
43
45
|
}}>
|
|
44
46
|
<RenderContent apiKey={builderContext.apiKey} context={builderContext.context} customComponents={markMutable(Object.values(builderContext.registeredComponents))} data={markMutable({ ...props.symbol?.data,
|
|
45
47
|
...builderContext.state,
|
|
46
48
|
...props.symbol?.content?.data?.state
|
|
47
|
-
})} model={props.symbol?.model} content={markMutable(
|
|
49
|
+
})} model={props.symbol?.model} content={markMutable(contentToUse())}></RenderContent>
|
|
48
50
|
</div>;
|
|
49
51
|
}
|
|
50
52
|
|
|
@@ -18,7 +18,13 @@ function Video(props) {
|
|
|
18
18
|
};
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
-
|
|
21
|
+
function spreadProps() {
|
|
22
|
+
return { ...props.attributes,
|
|
23
|
+
...videoProps()
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
return <video {...spreadProps()} style={{
|
|
22
28
|
width: "100%",
|
|
23
29
|
height: "100%",
|
|
24
30
|
...props.attributes?.style,
|
|
@@ -3,7 +3,6 @@ import { Dynamic } from "solid-js/web";
|
|
|
3
3
|
import { getBlockActions } from "../../functions/get-block-actions.js";
|
|
4
4
|
import { getBlockComponentOptions } from "../../functions/get-block-component-options.js";
|
|
5
5
|
import { getBlockProperties } from "../../functions/get-block-properties.js";
|
|
6
|
-
import { getBlockStyles } from "../../functions/get-block-styles.js";
|
|
7
6
|
import { getBlockTag } from "../../functions/get-block-tag.js";
|
|
8
7
|
import { getProcessedBlock } from "../../functions/get-processed-block.js";
|
|
9
8
|
import { evaluate } from "../../functions/evaluate.js";
|
|
@@ -14,6 +13,7 @@ import { TARGET } from "../../constants/target.js";
|
|
|
14
13
|
import { extractTextStyles } from "../../functions/extract-text-styles.js";
|
|
15
14
|
import RenderComponentWithContext from "./render-component-with-context.jsx";
|
|
16
15
|
import RenderComponent from "./render-component.jsx";
|
|
16
|
+
import { getReactNativeBlockStyles } from "../../functions/get-react-native-block-styles.js";
|
|
17
17
|
|
|
18
18
|
function RenderBlock(props) {
|
|
19
19
|
function component() {
|
|
@@ -61,10 +61,12 @@ function RenderBlock(props) {
|
|
|
61
61
|
state: props.context.state,
|
|
62
62
|
context: props.context.context
|
|
63
63
|
}),
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
64
|
+
...(TARGET === "reactNative" ? {
|
|
65
|
+
style: getReactNativeBlockStyles({
|
|
66
|
+
block: useBlock(),
|
|
67
|
+
context: props.context
|
|
68
|
+
})
|
|
69
|
+
} : {})
|
|
68
70
|
};
|
|
69
71
|
}
|
|
70
72
|
|
|
@@ -154,7 +156,7 @@ function RenderBlock(props) {
|
|
|
154
156
|
return {};
|
|
155
157
|
}
|
|
156
158
|
|
|
157
|
-
const styles =
|
|
159
|
+
const styles = getReactNativeBlockStyles({
|
|
158
160
|
block: useBlock(),
|
|
159
161
|
context: props.context
|
|
160
162
|
});
|
|
@@ -187,18 +189,7 @@ function RenderBlock(props) {
|
|
|
187
189
|
<Show when={isEmptyHtmlElement(tagName())}>
|
|
188
190
|
<Dynamic {...attributes()} component={tagName()}></Dynamic>
|
|
189
191
|
</Show>
|
|
190
|
-
<Show when={!isEmptyHtmlElement(tagName()) &&
|
|
191
|
-
<div class="vue2-root-element-workaround">
|
|
192
|
-
<For each={repeatItemData()}>
|
|
193
|
-
{(data, _index) => {
|
|
194
|
-
const index = _index();
|
|
195
|
-
|
|
196
|
-
return <RenderRepeatedBlock key={index} repeatContext={data.context} block={data.block}></RenderRepeatedBlock>;
|
|
197
|
-
}}
|
|
198
|
-
</For>
|
|
199
|
-
</div>
|
|
200
|
-
</Show>
|
|
201
|
-
<Show when={!isEmptyHtmlElement(tagName()) && TARGET !== "vue2" && repeatItemData()}>
|
|
192
|
+
<Show when={!isEmptyHtmlElement(tagName()) && repeatItemData()}>
|
|
202
193
|
<For each={repeatItemData()}>
|
|
203
194
|
{(data, _index) => {
|
|
204
195
|
const index = _index();
|
|
@@ -29,7 +29,7 @@ function RenderComponentWithContext(props) {
|
|
|
29
29
|
}
|
|
30
30
|
|
|
31
31
|
}} component={BuilderContext.Provider}>
|
|
32
|
-
<RenderComponent {
|
|
32
|
+
<RenderComponent componentRef={props.componentRef} componentOptions={props.componentOptions} blockChildren={props.blockChildren} context={props.context}></RenderComponent>
|
|
33
33
|
</Dynamic>;
|
|
34
34
|
}
|
|
35
35
|
|
|
@@ -41,7 +41,7 @@ function RenderBlocks(props) {
|
|
|
41
41
|
alignItems: "stretch"
|
|
42
42
|
})} builder-path={props.path} builder-parent-id={props.parent} dataSet={{
|
|
43
43
|
class: className()
|
|
44
|
-
}} style={props.
|
|
44
|
+
}} style={props.styleProp} onClick={event => onClick()} onMouseEnter={event => onMouseEnter()}>
|
|
45
45
|
<Show when={props.blocks}>
|
|
46
46
|
<For each={props.blocks}>
|
|
47
47
|
{(block, _index) => {
|
|
@@ -269,7 +269,7 @@ function RenderContent(props) {
|
|
|
269
269
|
|
|
270
270
|
}} component={BuilderContext.Provider}>
|
|
271
271
|
<Show when={useContent}>
|
|
272
|
-
<div ref={elementRef} onClick={event => onClick(event)} builder-content-id={useContent?.id}>
|
|
272
|
+
<div ref={elementRef} onClick={event => onClick(event)} builder-content-id={useContent?.id} builder-model={props.model}>
|
|
273
273
|
<Show when={shouldRenderContentStyles()}>
|
|
274
274
|
<RenderContentStyles cssCode={useContent?.data?.cssCode} customFonts={useContent?.data?.customFonts}></RenderContentStyles>
|
|
275
275
|
</Show>
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
3
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
4
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
5
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
6
|
+
var __spreadValues = (a, b) => {
|
|
7
|
+
for (var prop in b || (b = {}))
|
|
8
|
+
if (__hasOwnProp.call(b, prop))
|
|
9
|
+
__defNormalProp(a, prop, b[prop]);
|
|
10
|
+
if (__getOwnPropSymbols)
|
|
11
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
12
|
+
if (__propIsEnum.call(b, prop))
|
|
13
|
+
__defNormalProp(a, prop, b[prop]);
|
|
14
|
+
}
|
|
15
|
+
return a;
|
|
16
|
+
};
|
|
17
|
+
import { sanitizeReactNativeBlockStyles } from "./sanitize-react-native-block-styles.js";
|
|
18
|
+
function getReactNativeBlockStyles({
|
|
19
|
+
block,
|
|
20
|
+
context
|
|
21
|
+
}) {
|
|
22
|
+
const responsiveStyles = block.responsiveStyles;
|
|
23
|
+
if (!responsiveStyles) {
|
|
24
|
+
return {};
|
|
25
|
+
}
|
|
26
|
+
const styles = __spreadValues(__spreadValues(__spreadValues(__spreadValues({}, context.inheritedStyles), responsiveStyles.large || {}), responsiveStyles.medium || {}), responsiveStyles.small || {});
|
|
27
|
+
const newStyles = sanitizeReactNativeBlockStyles(styles);
|
|
28
|
+
return newStyles;
|
|
29
|
+
}
|
|
30
|
+
export {
|
|
31
|
+
getReactNativeBlockStyles
|
|
32
|
+
};
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defProps = Object.defineProperties;
|
|
3
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
4
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
7
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8
|
+
var __spreadValues = (a, b) => {
|
|
9
|
+
for (var prop in b || (b = {}))
|
|
10
|
+
if (__hasOwnProp.call(b, prop))
|
|
11
|
+
__defNormalProp(a, prop, b[prop]);
|
|
12
|
+
if (__getOwnPropSymbols)
|
|
13
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
14
|
+
if (__propIsEnum.call(b, prop))
|
|
15
|
+
__defNormalProp(a, prop, b[prop]);
|
|
16
|
+
}
|
|
17
|
+
return a;
|
|
18
|
+
};
|
|
19
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
|
+
const propertiesThatMustBeNumber = new Set(["lineHeight"]);
|
|
21
|
+
const displayValues = new Set(["flex", "none"]);
|
|
22
|
+
const SHOW_WARNINGS = false;
|
|
23
|
+
const normalizeNumber = (value) => {
|
|
24
|
+
if (Number.isNaN(value)) {
|
|
25
|
+
return void 0;
|
|
26
|
+
} else if (value < 0) {
|
|
27
|
+
return 0;
|
|
28
|
+
} else {
|
|
29
|
+
return value;
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
const sanitizeReactNativeBlockStyles = (styles) => {
|
|
33
|
+
return Object.keys(styles).reduce((acc, key) => {
|
|
34
|
+
const propertyValue = styles[key];
|
|
35
|
+
if (key === "display" && !displayValues.has(propertyValue)) {
|
|
36
|
+
if (SHOW_WARNINGS) {
|
|
37
|
+
console.warn(`Style value for key "display" must be "flex" or "none" but had ${propertyValue}`);
|
|
38
|
+
}
|
|
39
|
+
return acc;
|
|
40
|
+
}
|
|
41
|
+
if (propertiesThatMustBeNumber.has(key) && typeof propertyValue !== "number") {
|
|
42
|
+
if (SHOW_WARNINGS) {
|
|
43
|
+
console.warn(`Style key ${key} must be a number, but had value \`${styles[key]}\``);
|
|
44
|
+
}
|
|
45
|
+
return acc;
|
|
46
|
+
}
|
|
47
|
+
if (typeof propertyValue === "string") {
|
|
48
|
+
const isPixelUnit = propertyValue.match(/^-?(\d*)(\.?)(\d*)*px$/);
|
|
49
|
+
if (isPixelUnit) {
|
|
50
|
+
const newValue = parseFloat(propertyValue);
|
|
51
|
+
const normalizedValue = normalizeNumber(newValue);
|
|
52
|
+
if (normalizedValue) {
|
|
53
|
+
return __spreadProps(__spreadValues({}, acc), { [key]: normalizedValue });
|
|
54
|
+
} else {
|
|
55
|
+
return acc;
|
|
56
|
+
}
|
|
57
|
+
} else if (propertyValue === "0") {
|
|
58
|
+
return __spreadProps(__spreadValues({}, acc), { [key]: 0 });
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
return __spreadProps(__spreadValues({}, acc), { [key]: propertyValue });
|
|
62
|
+
}, {});
|
|
63
|
+
};
|
|
64
|
+
export {
|
|
65
|
+
sanitizeReactNativeBlockStyles
|
|
66
|
+
};
|
|
@@ -26,48 +26,50 @@ const setupBrowserForEditing = () => {
|
|
|
26
26
|
type: "builder.sdkInfo",
|
|
27
27
|
data: {
|
|
28
28
|
target: TARGET,
|
|
29
|
-
supportsPatchUpdates: false
|
|
29
|
+
supportsPatchUpdates: false,
|
|
30
|
+
supportsAddBlockScoping: true
|
|
30
31
|
}
|
|
31
32
|
}, "*");
|
|
32
33
|
window.addEventListener("message", ({ data }) => {
|
|
33
34
|
var _a2, _b;
|
|
34
|
-
if (data) {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
}, "*");
|
|
61
|
-
}).catch(console.error);
|
|
62
|
-
} else {
|
|
63
|
-
(_b = window.parent) == null ? void 0 : _b.postMessage({
|
|
35
|
+
if (!(data == null ? void 0 : data.type)) {
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
switch (data.type) {
|
|
39
|
+
case "builder.evaluate": {
|
|
40
|
+
const text = data.data.text;
|
|
41
|
+
const args = data.data.arguments || [];
|
|
42
|
+
const id = data.data.id;
|
|
43
|
+
const fn = new Function(text);
|
|
44
|
+
let result;
|
|
45
|
+
let error = null;
|
|
46
|
+
try {
|
|
47
|
+
result = fn.apply(null, args);
|
|
48
|
+
} catch (err) {
|
|
49
|
+
error = err;
|
|
50
|
+
}
|
|
51
|
+
if (error) {
|
|
52
|
+
(_a2 = window.parent) == null ? void 0 : _a2.postMessage({
|
|
53
|
+
type: "builder.evaluateError",
|
|
54
|
+
data: { id, error: error.message }
|
|
55
|
+
}, "*");
|
|
56
|
+
} else {
|
|
57
|
+
if (result && typeof result.then === "function") {
|
|
58
|
+
result.then((finalResult) => {
|
|
59
|
+
var _a3;
|
|
60
|
+
(_a3 = window.parent) == null ? void 0 : _a3.postMessage({
|
|
64
61
|
type: "builder.evaluateResult",
|
|
65
|
-
data: {
|
|
62
|
+
data: { id, result: finalResult }
|
|
66
63
|
}, "*");
|
|
67
|
-
}
|
|
64
|
+
}).catch(console.error);
|
|
65
|
+
} else {
|
|
66
|
+
(_b = window.parent) == null ? void 0 : _b.postMessage({
|
|
67
|
+
type: "builder.evaluateResult",
|
|
68
|
+
data: { result, id }
|
|
69
|
+
}, "*");
|
|
68
70
|
}
|
|
69
|
-
break;
|
|
70
71
|
}
|
|
72
|
+
break;
|
|
71
73
|
}
|
|
72
74
|
}
|
|
73
75
|
});
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
const camelCaseToDashCase = (str = "") => str.replace(/[A-Z]/g, (match) => "-" + match.toLowerCase());
|
|
2
|
-
const convertStyleObject = (obj) => {
|
|
3
|
-
if (!obj) {
|
|
4
|
-
return obj;
|
|
5
|
-
}
|
|
6
|
-
const newObj = {};
|
|
7
|
-
for (const key in obj) {
|
|
8
|
-
newObj[camelCaseToDashCase(key)] = obj[key];
|
|
9
|
-
}
|
|
10
|
-
return newObj;
|
|
11
|
-
};
|
|
12
|
-
export {
|
|
13
|
-
convertStyleObject
|
|
14
|
-
};
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
3
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
4
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
5
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
6
|
-
var __spreadValues = (a, b) => {
|
|
7
|
-
for (var prop in b || (b = {}))
|
|
8
|
-
if (__hasOwnProp.call(b, prop))
|
|
9
|
-
__defNormalProp(a, prop, b[prop]);
|
|
10
|
-
if (__getOwnPropSymbols)
|
|
11
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
12
|
-
if (__propIsEnum.call(b, prop))
|
|
13
|
-
__defNormalProp(a, prop, b[prop]);
|
|
14
|
-
}
|
|
15
|
-
return a;
|
|
16
|
-
};
|
|
17
|
-
import { getMaxWidthQueryForSize } from "../constants/device-sizes.js";
|
|
18
|
-
import { TARGET } from "../constants/target.js";
|
|
19
|
-
import { convertStyleObject } from "./convert-style-object.js";
|
|
20
|
-
import { sanitizeBlockStyles } from "./sanitize-styles.js";
|
|
21
|
-
const getStyleForTarget = ({
|
|
22
|
-
styles,
|
|
23
|
-
context
|
|
24
|
-
}) => {
|
|
25
|
-
switch (TARGET) {
|
|
26
|
-
case "reactNative": {
|
|
27
|
-
return __spreadValues(__spreadValues(__spreadValues(__spreadValues({}, context.inheritedStyles), styles.large ? convertStyleObject(styles.large) : {}), styles.medium ? convertStyleObject(styles.medium) : {}), styles.small ? convertStyleObject(styles.small) : {});
|
|
28
|
-
}
|
|
29
|
-
default:
|
|
30
|
-
return __spreadValues(__spreadValues(__spreadValues({}, styles.large ? convertStyleObject(styles.large) : {}), styles.medium ? {
|
|
31
|
-
[getMaxWidthQueryForSize("medium")]: convertStyleObject(styles.medium)
|
|
32
|
-
} : {}), styles.small ? {
|
|
33
|
-
[getMaxWidthQueryForSize("small")]: convertStyleObject(styles.small)
|
|
34
|
-
} : {});
|
|
35
|
-
}
|
|
36
|
-
};
|
|
37
|
-
function getBlockStyles({
|
|
38
|
-
block,
|
|
39
|
-
context
|
|
40
|
-
}) {
|
|
41
|
-
if (!block.responsiveStyles) {
|
|
42
|
-
return {};
|
|
43
|
-
}
|
|
44
|
-
const styles = getStyleForTarget({ styles: block.responsiveStyles, context });
|
|
45
|
-
const newStyles = sanitizeBlockStyles(styles);
|
|
46
|
-
return newStyles;
|
|
47
|
-
}
|
|
48
|
-
export {
|
|
49
|
-
getBlockStyles
|
|
50
|
-
};
|