@builder.io/sdk-react-native 0.0.12 → 0.0.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.
- package/package.json +1 -1
- package/src/blocks/columns/columns.js +1 -2
- package/src/blocks/symbol/symbol.js +3 -4
- package/src/blocks/text/text.js +5 -3
- package/src/components/render-block/block-styles.js +9 -3
- package/src/components/render-block/render-component.js +1 -2
- package/src/components/render-content/render-content.js +1 -2
- package/src/constants/device-sizes.js +29 -2
- package/src/scripts/init-editing.js +2 -1
package/package.json
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import { View, StyleSheet } from "react-native";
|
|
3
3
|
import RenderBlocks from "../../components/render-blocks.js";
|
|
4
|
-
import { markMutable } from "../../functions/mark-mutable";
|
|
5
4
|
function Columns(props) {
|
|
6
5
|
var _a;
|
|
7
6
|
function getGutterSize() {
|
|
@@ -48,7 +47,7 @@ function Columns(props) {
|
|
|
48
47
|
style: styles.view2,
|
|
49
48
|
key: index
|
|
50
49
|
}, /* @__PURE__ */ React.createElement(RenderBlocks, {
|
|
51
|
-
blocks:
|
|
50
|
+
blocks: column.blocks,
|
|
52
51
|
path: `component.options.columns.${index}.blocks`,
|
|
53
52
|
parent: props.builderBlock.id,
|
|
54
53
|
styleProp: {
|
|
@@ -23,7 +23,6 @@ import { useState, useContext, useEffect } from "react";
|
|
|
23
23
|
import RenderContent from "../../components/render-content/render-content.js";
|
|
24
24
|
import BuilderContext from "../../context/builder.context.js";
|
|
25
25
|
import { getContent } from "../../functions/get-content/index.js";
|
|
26
|
-
import { markMutable } from "../../functions/mark-mutable";
|
|
27
26
|
function Symbol(props) {
|
|
28
27
|
var _a, _b, _c, _d, _e;
|
|
29
28
|
const [className, setClassName] = useState(() => "builder-symbol");
|
|
@@ -54,10 +53,10 @@ function Symbol(props) {
|
|
|
54
53
|
}), /* @__PURE__ */ React.createElement(RenderContent, {
|
|
55
54
|
apiKey: builderContext.apiKey,
|
|
56
55
|
context: builderContext.context,
|
|
57
|
-
customComponents:
|
|
58
|
-
data:
|
|
56
|
+
customComponents: Object.values(builderContext.registeredComponents),
|
|
57
|
+
data: __spreadValues(__spreadValues(__spreadValues({}, (_a = props.symbol) == null ? void 0 : _a.data), builderContext.state), (_d = (_c = (_b = props.symbol) == null ? void 0 : _b.content) == null ? void 0 : _c.data) == null ? void 0 : _d.state),
|
|
59
58
|
model: (_e = props.symbol) == null ? void 0 : _e.model,
|
|
60
|
-
content:
|
|
59
|
+
content: contentToUse()
|
|
61
60
|
}));
|
|
62
61
|
}
|
|
63
62
|
export {
|
package/src/blocks/text/text.js
CHANGED
|
@@ -16,6 +16,7 @@ var __spreadValues = (a, b) => {
|
|
|
16
16
|
};
|
|
17
17
|
import * as React from "react";
|
|
18
18
|
import HTML from "react-native-render-html";
|
|
19
|
+
import BuilderContext from "../../context/builder.context";
|
|
19
20
|
function camelToKebabCase(string) {
|
|
20
21
|
return string.replace(/([a-z0-9]|(?=[A-Z]))([A-Z])/g, "$1-$2").toLowerCase();
|
|
21
22
|
}
|
|
@@ -39,8 +40,8 @@ function getBlockStyles(block) {
|
|
|
39
40
|
}
|
|
40
41
|
return styles;
|
|
41
42
|
}
|
|
42
|
-
function getCss(block) {
|
|
43
|
-
const styleObject = pick(getBlockStyles(block), PICK_STYLES);
|
|
43
|
+
function getCss(block, inheritedStyles) {
|
|
44
|
+
const styleObject = __spreadValues(__spreadValues({}, inheritedStyles), pick(getBlockStyles(block), PICK_STYLES));
|
|
44
45
|
if (!styleObject) {
|
|
45
46
|
return "";
|
|
46
47
|
}
|
|
@@ -54,9 +55,10 @@ function getCss(block) {
|
|
|
54
55
|
return str;
|
|
55
56
|
}
|
|
56
57
|
function Text(props) {
|
|
58
|
+
const builderContext = React.useContext(BuilderContext);
|
|
57
59
|
return /* @__PURE__ */ React.createElement(HTML, {
|
|
58
60
|
source: {
|
|
59
|
-
html: `<div style="${getCss(props.builderBlock)}">${props.text || ""}</div>`
|
|
61
|
+
html: `<div style="${getCss(props.builderBlock, builderContext.inheritedStyles)}">${props.text || ""}</div>`
|
|
60
62
|
}
|
|
61
63
|
});
|
|
62
64
|
}
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
getMaxWidthQueryForSize,
|
|
4
|
+
getSizesForBreakpoints
|
|
5
|
+
} from "../../constants/device-sizes.js";
|
|
3
6
|
import { TARGET } from "../../constants/target.js";
|
|
4
7
|
import { getProcessedBlock } from "../../functions/get-processed-block.js";
|
|
5
8
|
import { createCssClass } from "../../helpers/css.js";
|
|
@@ -14,7 +17,10 @@ function BlockStyles(props) {
|
|
|
14
17
|
});
|
|
15
18
|
}
|
|
16
19
|
function css() {
|
|
20
|
+
var _a;
|
|
17
21
|
const styles = useBlock().responsiveStyles;
|
|
22
|
+
const content = props.context.content;
|
|
23
|
+
const sizesWithUpdatedBreakpoints = getSizesForBreakpoints(((_a = content == null ? void 0 : content.meta) == null ? void 0 : _a.breakpoints) || {});
|
|
18
24
|
const largeStyles = styles == null ? void 0 : styles.large;
|
|
19
25
|
const mediumStyles = styles == null ? void 0 : styles.medium;
|
|
20
26
|
const smallStyles = styles == null ? void 0 : styles.small;
|
|
@@ -26,12 +32,12 @@ function BlockStyles(props) {
|
|
|
26
32
|
const mediumStylesClass = mediumStyles ? createCssClass({
|
|
27
33
|
className,
|
|
28
34
|
styles: mediumStyles,
|
|
29
|
-
mediaQuery: getMaxWidthQueryForSize("medium")
|
|
35
|
+
mediaQuery: getMaxWidthQueryForSize("medium", sizesWithUpdatedBreakpoints)
|
|
30
36
|
}) : "";
|
|
31
37
|
const smallStylesClass = smallStyles ? createCssClass({
|
|
32
38
|
className,
|
|
33
39
|
styles: smallStyles,
|
|
34
|
-
mediaQuery: getMaxWidthQueryForSize("small")
|
|
40
|
+
mediaQuery: getMaxWidthQueryForSize("small", sizesWithUpdatedBreakpoints)
|
|
35
41
|
}) : "";
|
|
36
42
|
return [largeStylesClass, mediumStylesClass, smallStylesClass].join(" ");
|
|
37
43
|
}
|
|
@@ -17,11 +17,10 @@ var __spreadValues = (a, b) => {
|
|
|
17
17
|
import * as React from "react";
|
|
18
18
|
import BlockStyles from "./block-styles.js";
|
|
19
19
|
import RenderBlock from "./render-block.js";
|
|
20
|
-
import { markPropsMutable } from "../../functions/mark-mutable.js";
|
|
21
20
|
function RenderComponent(props) {
|
|
22
21
|
var _a, _b;
|
|
23
22
|
const ComponentRefRef = props.componentRef;
|
|
24
|
-
return /* @__PURE__ */ React.createElement(React.Fragment, null, props.componentRef ? /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(ComponentRefRef, __spreadValues({},
|
|
23
|
+
return /* @__PURE__ */ React.createElement(React.Fragment, null, props.componentRef ? /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(ComponentRefRef, __spreadValues({}, props.componentOptions), (_a = props.blockChildren) == null ? void 0 : _a.map((child) => /* @__PURE__ */ React.createElement(RenderBlock, {
|
|
25
24
|
key: "render-block-" + child.id,
|
|
26
25
|
block: child,
|
|
27
26
|
context: props.context
|
|
@@ -40,7 +40,6 @@ import {
|
|
|
40
40
|
registerInsertMenu,
|
|
41
41
|
setupBrowserForEditing
|
|
42
42
|
} from "../../scripts/init-editing.js";
|
|
43
|
-
import { markMutable } from "../../functions/mark-mutable.js";
|
|
44
43
|
function RenderContent(props) {
|
|
45
44
|
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
|
|
46
45
|
const elementRef = useRef(null);
|
|
@@ -264,7 +263,7 @@ function RenderContent(props) {
|
|
|
264
263
|
cssCode: (_g = (_f = useContent == null ? void 0 : useContent()) == null ? void 0 : _f.data) == null ? void 0 : _g.cssCode,
|
|
265
264
|
customFonts: (_i = (_h = useContent == null ? void 0 : useContent()) == null ? void 0 : _h.data) == null ? void 0 : _i.customFonts
|
|
266
265
|
}) : null, /* @__PURE__ */ React.createElement(RenderBlocks, {
|
|
267
|
-
blocks:
|
|
266
|
+
blocks: (_k = (_j = useContent == null ? void 0 : useContent()) == null ? void 0 : _j.data) == null ? void 0 : _k.blocks,
|
|
268
267
|
key: forceReRenderCount
|
|
269
268
|
}))) : null);
|
|
270
269
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { fastClone } from "../functions/fast-clone";
|
|
1
2
|
const SIZES = {
|
|
2
3
|
small: {
|
|
3
4
|
min: 320,
|
|
@@ -15,7 +16,33 @@ const SIZES = {
|
|
|
15
16
|
max: 1200
|
|
16
17
|
}
|
|
17
18
|
};
|
|
18
|
-
const getMaxWidthQueryForSize = (size) => `@media (max-width: ${
|
|
19
|
+
const getMaxWidthQueryForSize = (size, sizeValues = SIZES) => `@media (max-width: ${sizeValues[size].max}px)`;
|
|
20
|
+
const getSizesForBreakpoints = ({ small, medium }) => {
|
|
21
|
+
const newSizes = fastClone(SIZES);
|
|
22
|
+
if (!small || !medium) {
|
|
23
|
+
return newSizes;
|
|
24
|
+
}
|
|
25
|
+
const smallMin = Math.floor(small / 2);
|
|
26
|
+
newSizes.small = {
|
|
27
|
+
max: small,
|
|
28
|
+
min: smallMin,
|
|
29
|
+
default: smallMin + 1
|
|
30
|
+
};
|
|
31
|
+
const mediumMin = newSizes.small.max + 1;
|
|
32
|
+
newSizes.medium = {
|
|
33
|
+
max: medium,
|
|
34
|
+
min: mediumMin,
|
|
35
|
+
default: mediumMin + 1
|
|
36
|
+
};
|
|
37
|
+
const largeMin = newSizes.medium.max + 1;
|
|
38
|
+
newSizes.large = {
|
|
39
|
+
max: 2e3,
|
|
40
|
+
min: largeMin,
|
|
41
|
+
default: largeMin + 1
|
|
42
|
+
};
|
|
43
|
+
return newSizes;
|
|
44
|
+
};
|
|
19
45
|
export {
|
|
20
|
-
getMaxWidthQueryForSize
|
|
46
|
+
getMaxWidthQueryForSize,
|
|
47
|
+
getSizesForBreakpoints
|
|
21
48
|
};
|
|
@@ -32,7 +32,8 @@ const setupBrowserForEditing = () => {
|
|
|
32
32
|
data: {
|
|
33
33
|
target: TARGET,
|
|
34
34
|
supportsPatchUpdates: false,
|
|
35
|
-
supportsAddBlockScoping: true
|
|
35
|
+
supportsAddBlockScoping: true,
|
|
36
|
+
supportsCustomBreakpoints: true
|
|
36
37
|
}
|
|
37
38
|
}, "*");
|
|
38
39
|
window.addEventListener("message", ({ data }) => {
|