@builder.io/sdk-react-native 0.0.1-54 โ 0.0.1-57
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/CHANGELOG.md +11 -1
- package/README.md +4 -0
- package/package.json +1 -1
- package/src/blocks/button/button.lite.tsx +8 -1
- package/src/blocks/columns/columns.lite.tsx +18 -1
- package/src/blocks/custom-code/custom-code.js +1 -1
- package/src/blocks/custom-code/custom-code.lite.tsx +7 -4
- package/src/blocks/embed/embed.js +1 -1
- package/src/blocks/embed/embed.lite.tsx +6 -4
- package/src/blocks/form/form.js +1 -1
- package/src/blocks/form/form.lite.tsx +56 -3
- package/src/blocks/fragment/fragment.lite.tsx +7 -1
- package/src/blocks/image/image.lite.tsx +19 -2
- package/src/blocks/img/img.lite.tsx +19 -1
- package/src/blocks/input/input.lite.tsx +12 -1
- package/src/blocks/raw-text/raw-text.lite.tsx +6 -1
- package/src/blocks/section/section.lite.tsx +8 -1
- package/src/blocks/select/select.lite.tsx +13 -1
- package/src/blocks/submit-button/submit-button.lite.tsx +6 -1
- package/src/blocks/symbol/component-info.js +1 -0
- package/src/blocks/symbol/symbol.lite.tsx +20 -1
- package/src/blocks/text/text.lite.tsx +1 -1
- package/src/blocks/textarea/textarea.lite.tsx +9 -1
- package/src/blocks/video/video.lite.tsx +27 -1
- package/src/components/error-boundary.lite.tsx +1 -1
- package/src/components/render-block/block-styles.js +16 -4
- package/src/components/render-block/block-styles.lite.tsx +30 -4
- package/src/components/render-block/render-block.js +44 -31
- package/src/components/render-block/render-block.lite.tsx +52 -38
- package/src/components/render-block/render-component.js +33 -0
- package/src/components/render-block/render-component.lite.tsx +32 -0
- package/src/components/render-blocks.js +10 -6
- package/src/components/render-blocks.lite.tsx +17 -2
- package/src/components/render-content/components/render-styles.lite.tsx +15 -1
- package/src/components/render-content/render-content.lite.tsx +28 -1
- package/src/components/render-inlined-styles.lite.tsx +6 -1
- package/src/functions/get-block-component-options.js +6 -1
- package/src/functions/get-block-styles.js +1 -1
- package/src/functions/macro-eval.js +0 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,16 @@
|
|
|
1
|
+
### 0.0.1-55
|
|
2
|
+
|
|
3
|
+
๐ Fix: custom components were not rendering correctly
|
|
4
|
+
๐ Fix: Image component's `srcSet` was not being set correctly
|
|
5
|
+
|
|
6
|
+
### 0.0.1-52
|
|
7
|
+
|
|
8
|
+
๐งจ Breaking change: the format of the `customComponents` prop has changed from `[{ component, info }]` to `[{ component, ...info }]`.
|
|
9
|
+
See [builder-registered-components.ts](/packages/sdks/src/constants/builder-registered-components.ts) for examples of how to do so, or see the example provided for this SDK.
|
|
10
|
+
|
|
1
11
|
### 0.0.1-51
|
|
2
12
|
|
|
3
|
-
โ ๏ธ Deprecation notice: Registering components via `registerComponent(component, info)` is now deprecated.
|
|
13
|
+
โ ๏ธ Deprecation notice: Registering components via `registerComponent(component, info)` is now deprecated.
|
|
4
14
|
To register your custom components in Builder, you must now provide a `customComponents` array to the `RenderContent` component containing `[{ component, info }]`.
|
|
5
15
|
See [builder-registered-components.ts](/packages/sdks/src/constants/builder-registered-components.ts) for examples of how to do so, or see the example provided for this SDK.
|
|
6
16
|
|
package/README.md
CHANGED
|
@@ -2,6 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
This is the React-Native SDK. It is currently in beta.
|
|
4
4
|
|
|
5
|
+
## Mitosis
|
|
6
|
+
|
|
7
|
+
This SDK is generated by [Mitosis](https://github.com/BuilderIO/mitosis). To see the Mitosis source-code, go [here](../../).
|
|
8
|
+
|
|
5
9
|
## Feature Support
|
|
6
10
|
|
|
7
11
|
To check the status of the SDK, look at [these tables](../../README.md#feature-implementation).
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@builder.io/sdk-react-native",
|
|
3
3
|
"description": "Builder.io SDK for React Native",
|
|
4
|
-
"version": "0.0.1-
|
|
4
|
+
"version": "0.0.1-57",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"release:dev": "npm version prerelease --no-git-tag-version && npm publish --tag dev --access public"
|
|
@@ -1,7 +1,14 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import { View, StyleSheet, Image, Text } from "react-native";
|
|
3
3
|
|
|
4
|
-
export
|
|
4
|
+
export interface ButtonProps {
|
|
5
|
+
attributes?: any;
|
|
6
|
+
text?: string;
|
|
7
|
+
link?: string;
|
|
8
|
+
openLinkInNewTab?: boolean;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export default function Button(props: ButtonProps) {
|
|
5
12
|
return (
|
|
6
13
|
<>
|
|
7
14
|
{props.link ? (
|
|
@@ -1,8 +1,25 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import { View, StyleSheet, Image, Text } from "react-native";
|
|
3
|
+
|
|
4
|
+
type Column = {
|
|
5
|
+
blocks: any; // TODO: Implement this when support for dynamic CSS lands
|
|
6
|
+
|
|
7
|
+
width?: number;
|
|
8
|
+
};
|
|
9
|
+
type StackColumnsAt = "tablet" | "mobile" | "never";
|
|
10
|
+
export interface ColumnProps {
|
|
11
|
+
columns?: Column[]; // TODO: Implement this when support for dynamic CSS lands
|
|
12
|
+
|
|
13
|
+
space?: number; // TODO: Implement this when support for dynamic CSS lands
|
|
14
|
+
|
|
15
|
+
stackColumnsAt?: StackColumnsAt; // TODO: Implement this when support for dynamic CSS lands
|
|
16
|
+
|
|
17
|
+
reverseColumnsWhenStacked?: boolean;
|
|
18
|
+
}
|
|
19
|
+
|
|
3
20
|
import RenderBlocks from "../../components/render-blocks.lite";
|
|
4
21
|
|
|
5
|
-
export default function Columns(props) {
|
|
22
|
+
export default function Columns(props: ColumnProps) {
|
|
6
23
|
function getGutterSize() {
|
|
7
24
|
return typeof props.space === "number" ? props.space || 0 : 20;
|
|
8
25
|
}
|
|
@@ -2,6 +2,7 @@ import * as React from "react";
|
|
|
2
2
|
import { View } from "react-native";
|
|
3
3
|
import { useState, useRef, useEffect } from "react";
|
|
4
4
|
function CustomCode(props) {
|
|
5
|
+
const elem = useRef(null);
|
|
5
6
|
const [scriptsInserted, setScriptsInserted] = useState(() => []);
|
|
6
7
|
const [scriptsRun, setScriptsRun] = useState(() => []);
|
|
7
8
|
function findAndRunScripts() {
|
|
@@ -36,7 +37,6 @@ function CustomCode(props) {
|
|
|
36
37
|
}
|
|
37
38
|
}
|
|
38
39
|
}
|
|
39
|
-
const elem = useRef();
|
|
40
40
|
useEffect(() => {
|
|
41
41
|
findAndRunScripts();
|
|
42
42
|
}, []);
|
|
@@ -2,7 +2,13 @@ import * as React from "react";
|
|
|
2
2
|
import { View, StyleSheet, Image, Text } from "react-native";
|
|
3
3
|
import { useState, useRef, useEffect } from "react";
|
|
4
4
|
|
|
5
|
-
export
|
|
5
|
+
export interface CustomCodeProps {
|
|
6
|
+
code: string;
|
|
7
|
+
replaceNodes?: boolean;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export default function CustomCode(props: CustomCodeProps) {
|
|
11
|
+
const elem = useRef<HTMLDivElement>(null);
|
|
6
12
|
const [scriptsInserted, setScriptsInserted] = useState(() => []);
|
|
7
13
|
|
|
8
14
|
const [scriptsRun, setScriptsRun] = useState(() => []);
|
|
@@ -10,7 +16,6 @@ export default function CustomCode(props) {
|
|
|
10
16
|
function findAndRunScripts() {
|
|
11
17
|
// TODO: Move this function to standalone one in '@builder.io/utils'
|
|
12
18
|
if (elem.current && typeof window !== "undefined") {
|
|
13
|
-
/** @type {HTMLScriptElement[]} */
|
|
14
19
|
const scripts = elem.current.getElementsByTagName("script");
|
|
15
20
|
|
|
16
21
|
for (let i = 0; i < scripts.length; i++) {
|
|
@@ -49,8 +54,6 @@ export default function CustomCode(props) {
|
|
|
49
54
|
}
|
|
50
55
|
}
|
|
51
56
|
|
|
52
|
-
const elem = useRef();
|
|
53
|
-
|
|
54
57
|
useEffect(() => {
|
|
55
58
|
findAndRunScripts();
|
|
56
59
|
}, []);
|
|
@@ -2,6 +2,7 @@ import * as React from "react";
|
|
|
2
2
|
import { View } from "react-native";
|
|
3
3
|
import { useState, useRef, useEffect } from "react";
|
|
4
4
|
function Embed(props) {
|
|
5
|
+
const elem = useRef(null);
|
|
5
6
|
const [scriptsInserted, setScriptsInserted] = useState(() => []);
|
|
6
7
|
const [scriptsRun, setScriptsRun] = useState(() => []);
|
|
7
8
|
function findAndRunScripts() {
|
|
@@ -36,7 +37,6 @@ function Embed(props) {
|
|
|
36
37
|
}
|
|
37
38
|
}
|
|
38
39
|
}
|
|
39
|
-
const elem = useRef();
|
|
40
40
|
useEffect(() => {
|
|
41
41
|
findAndRunScripts();
|
|
42
42
|
}, []);
|
|
@@ -2,7 +2,12 @@ import * as React from "react";
|
|
|
2
2
|
import { View, StyleSheet, Image, Text } from "react-native";
|
|
3
3
|
import { useState, useRef, useEffect } from "react";
|
|
4
4
|
|
|
5
|
-
export
|
|
5
|
+
export interface EmbedProps {
|
|
6
|
+
content: string;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export default function Embed(props: EmbedProps) {
|
|
10
|
+
const elem = useRef<HTMLDivElement>(null);
|
|
6
11
|
const [scriptsInserted, setScriptsInserted] = useState(() => []);
|
|
7
12
|
|
|
8
13
|
const [scriptsRun, setScriptsRun] = useState(() => []);
|
|
@@ -10,7 +15,6 @@ export default function Embed(props) {
|
|
|
10
15
|
function findAndRunScripts() {
|
|
11
16
|
// TODO: Move this function to standalone one in '@builder.io/utils'
|
|
12
17
|
if (elem.current && typeof window !== "undefined") {
|
|
13
|
-
/** @type {HTMLScriptElement[]} */
|
|
14
18
|
const scripts = elem.current.getElementsByTagName("script");
|
|
15
19
|
|
|
16
20
|
for (let i = 0; i < scripts.length; i++) {
|
|
@@ -49,8 +53,6 @@ export default function Embed(props) {
|
|
|
49
53
|
}
|
|
50
54
|
}
|
|
51
55
|
|
|
52
|
-
const elem = useRef();
|
|
53
|
-
|
|
54
56
|
useEffect(() => {
|
|
55
57
|
findAndRunScripts();
|
|
56
58
|
}, []);
|
package/src/blocks/form/form.js
CHANGED
|
@@ -44,6 +44,7 @@ import RenderBlock from "../../components/render-block/render-block.js";
|
|
|
44
44
|
import { isEditing } from "../../functions/is-editing.js";
|
|
45
45
|
function FormComponent(props) {
|
|
46
46
|
var _a, _b;
|
|
47
|
+
const formRef = useRef(null);
|
|
47
48
|
const [formState, setFormState] = useState(() => "unsubmitted");
|
|
48
49
|
const [responseData, setResponseData] = useState(() => null);
|
|
49
50
|
const [formErrorMessage, setFormErrorMessage] = useState(() => "");
|
|
@@ -190,7 +191,6 @@ function FormComponent(props) {
|
|
|
190
191
|
});
|
|
191
192
|
}
|
|
192
193
|
}
|
|
193
|
-
const formRef = useRef();
|
|
194
194
|
return /* @__PURE__ */ React.createElement(View, __spreadProps(__spreadValues({}, props.attributes), {
|
|
195
195
|
validate: props.validate,
|
|
196
196
|
ref: formRef,
|
|
@@ -1,10 +1,64 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import { View, StyleSheet, Image, Text } from "react-native";
|
|
3
3
|
import { useState, useRef } from "react";
|
|
4
|
+
|
|
5
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
6
|
+
// @ts-nocheck
|
|
7
|
+
|
|
8
|
+
/* eslint-disable */
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* This component was copied over from the old SDKs and has a lot of code pointing to invalid functions/env vars. It needs
|
|
12
|
+
* to be cleaned up before the component can actually be usable.
|
|
13
|
+
*/
|
|
14
|
+
export type FormState = "unsubmitted" | "sending" | "success" | "error";
|
|
15
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
16
|
+
// @ts-nocheck
|
|
17
|
+
|
|
18
|
+
/* eslint-disable */
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* This component was copied over from the old SDKs and has a lot of code pointing to invalid functions/env vars. It needs
|
|
22
|
+
* to be cleaned up before the component can actually be usable.
|
|
23
|
+
*/
|
|
24
|
+
interface BuilderElement {}
|
|
25
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
26
|
+
// @ts-nocheck
|
|
27
|
+
|
|
28
|
+
/* eslint-disable */
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* This component was copied over from the old SDKs and has a lot of code pointing to invalid functions/env vars. It needs
|
|
32
|
+
* to be cleaned up before the component can actually be usable.
|
|
33
|
+
*/
|
|
34
|
+
export interface FormProps {
|
|
35
|
+
attributes?: any;
|
|
36
|
+
name?: string;
|
|
37
|
+
action?: string;
|
|
38
|
+
validate?: boolean;
|
|
39
|
+
method?: string;
|
|
40
|
+
builderBlock?: BuilderElement;
|
|
41
|
+
sendSubmissionsTo?: string;
|
|
42
|
+
sendSubmissionsToEmail?: string;
|
|
43
|
+
sendWithJs?: boolean;
|
|
44
|
+
contentType?: string;
|
|
45
|
+
customHeaders?: {
|
|
46
|
+
[key: string]: string;
|
|
47
|
+
};
|
|
48
|
+
successUrl?: string;
|
|
49
|
+
previewState?: FormState;
|
|
50
|
+
successMessage?: BuilderElement[];
|
|
51
|
+
errorMessage?: BuilderElement[];
|
|
52
|
+
sendingMessage?: BuilderElement[];
|
|
53
|
+
resetFormOnSubmit?: boolean;
|
|
54
|
+
errorMessagePath?: string;
|
|
55
|
+
}
|
|
56
|
+
|
|
4
57
|
import RenderBlock from "../../components/render-block/render-block.lite";
|
|
5
58
|
import { isEditing } from "../../functions/is-editing.js";
|
|
6
59
|
|
|
7
|
-
export default function FormComponent(props) {
|
|
60
|
+
export default function FormComponent(props: FormProps) {
|
|
61
|
+
const formRef = useRef(null);
|
|
8
62
|
const [formState, setFormState] = useState(() => "unsubmitted");
|
|
9
63
|
|
|
10
64
|
const [responseData, setResponseData] = useState(() => null);
|
|
@@ -142,7 +196,7 @@ export default function FormComponent(props) {
|
|
|
142
196
|
get(body, props.errorMessagePath);
|
|
143
197
|
if (message) {
|
|
144
198
|
if (typeof message !== "string") {
|
|
145
|
-
/* TODO: ideally convert json to yaml so it woul dbe like
|
|
199
|
+
/* TODO: ideally convert json to yaml so it woul dbe like error: - email has been taken */ message =
|
|
146
200
|
JSON.stringify(message);
|
|
147
201
|
}
|
|
148
202
|
setFormErrorMessage(message);
|
|
@@ -198,7 +252,6 @@ export default function FormComponent(props) {
|
|
|
198
252
|
);
|
|
199
253
|
}
|
|
200
254
|
}
|
|
201
|
-
const formRef = useRef();
|
|
202
255
|
return (
|
|
203
256
|
<View
|
|
204
257
|
{...props.attributes}
|
|
@@ -1,7 +1,13 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import { View, StyleSheet, Image, Text } from "react-native";
|
|
3
3
|
|
|
4
|
-
export
|
|
4
|
+
export interface FragmentProps {
|
|
5
|
+
maxWidth?: number;
|
|
6
|
+
attributes?: any;
|
|
7
|
+
children?: any;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export default function FragmentComponent(props: FragmentProps) {
|
|
5
11
|
return (
|
|
6
12
|
<View>
|
|
7
13
|
<Text>{props.children}</Text>
|
|
@@ -1,7 +1,24 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import { View, StyleSheet, Image, Text } from "react-native";
|
|
3
3
|
|
|
4
|
-
export
|
|
4
|
+
export interface ImageProps {
|
|
5
|
+
className?: string;
|
|
6
|
+
image: string;
|
|
7
|
+
sizes?: string;
|
|
8
|
+
lazy?: boolean;
|
|
9
|
+
height?: number;
|
|
10
|
+
width?: number;
|
|
11
|
+
altText?: string;
|
|
12
|
+
backgroundSize?: string;
|
|
13
|
+
backgroundPosition?: string;
|
|
14
|
+
srcset?: string;
|
|
15
|
+
aspectRatio?: number;
|
|
16
|
+
children?: any;
|
|
17
|
+
fitContent?: boolean;
|
|
18
|
+
builderBlock?: any;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export default function Image(props: ImageProps) {
|
|
5
22
|
return (
|
|
6
23
|
<View style={styles.view1}>
|
|
7
24
|
<View>
|
|
@@ -15,7 +32,7 @@ export default function Image(props) {
|
|
|
15
32
|
sizes={props.sizes}
|
|
16
33
|
/>
|
|
17
34
|
|
|
18
|
-
<View
|
|
35
|
+
<View srcset={props.srcset} />
|
|
19
36
|
</View>
|
|
20
37
|
|
|
21
38
|
{props.aspectRatio &&
|
|
@@ -1,8 +1,26 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import { View, StyleSheet, Image, Text } from "react-native";
|
|
3
|
+
|
|
4
|
+
export interface ImgProps {
|
|
5
|
+
attributes?: any;
|
|
6
|
+
imgSrc?: string;
|
|
7
|
+
altText?: string;
|
|
8
|
+
backgroundSize?: "cover" | "contain";
|
|
9
|
+
backgroundPosition?:
|
|
10
|
+
| "center"
|
|
11
|
+
| "top"
|
|
12
|
+
| "left"
|
|
13
|
+
| "right"
|
|
14
|
+
| "bottom"
|
|
15
|
+
| "top left"
|
|
16
|
+
| "top right"
|
|
17
|
+
| "bottom left"
|
|
18
|
+
| "bottom right";
|
|
19
|
+
}
|
|
20
|
+
|
|
3
21
|
import { isEditing } from "../../functions/is-editing.js";
|
|
4
22
|
|
|
5
|
-
export default function ImgComponent(props) {
|
|
23
|
+
export default function ImgComponent(props: ImgProps) {
|
|
6
24
|
return (
|
|
7
25
|
<View
|
|
8
26
|
{...props.attributes}
|
|
@@ -1,8 +1,19 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import { View, StyleSheet, Image, Text } from "react-native";
|
|
3
|
+
|
|
4
|
+
export interface FormInputProps {
|
|
5
|
+
type?: string;
|
|
6
|
+
attributes?: any;
|
|
7
|
+
name?: string;
|
|
8
|
+
value?: string;
|
|
9
|
+
placeholder?: string;
|
|
10
|
+
defaultValue?: string;
|
|
11
|
+
required?: boolean;
|
|
12
|
+
}
|
|
13
|
+
|
|
3
14
|
import { isEditing } from "../../functions/is-editing.js";
|
|
4
15
|
|
|
5
|
-
export default function FormInputComponent(props) {
|
|
16
|
+
export default function FormInputComponent(props: FormInputProps) {
|
|
6
17
|
return (
|
|
7
18
|
<View
|
|
8
19
|
{...props.attributes}
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import { View, StyleSheet, Image, Text } from "react-native";
|
|
3
3
|
|
|
4
|
-
export
|
|
4
|
+
export interface RawTextProps {
|
|
5
|
+
attributes?: any;
|
|
6
|
+
text?: string; // builderBlock?: any;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export default function RawText(props: RawTextProps) {
|
|
5
10
|
return <View dangerouslySetInnerHTML={{ __html: props.text || "" }} />;
|
|
6
11
|
}
|
|
@@ -1,7 +1,14 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import { View, StyleSheet, Image, Text } from "react-native";
|
|
3
3
|
|
|
4
|
-
export
|
|
4
|
+
export interface SectionProps {
|
|
5
|
+
maxWidth?: number;
|
|
6
|
+
attributes?: any;
|
|
7
|
+
children?: any;
|
|
8
|
+
builderBlock?: any;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export default function SectionComponent(props: SectionProps) {
|
|
5
12
|
return (
|
|
6
13
|
<View
|
|
7
14
|
{...props.attributes}
|
|
@@ -1,8 +1,20 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import { View, StyleSheet, Image, Text } from "react-native";
|
|
3
|
+
|
|
4
|
+
export interface FormSelectProps {
|
|
5
|
+
options?: {
|
|
6
|
+
name?: string;
|
|
7
|
+
value: string;
|
|
8
|
+
}[];
|
|
9
|
+
attributes?: any;
|
|
10
|
+
name?: string;
|
|
11
|
+
value?: string;
|
|
12
|
+
defaultValue?: string;
|
|
13
|
+
}
|
|
14
|
+
|
|
3
15
|
import { isEditing } from "../../functions/is-editing.js";
|
|
4
16
|
|
|
5
|
-
export default function SelectComponent(props) {
|
|
17
|
+
export default function SelectComponent(props: FormSelectProps) {
|
|
6
18
|
return (
|
|
7
19
|
<View
|
|
8
20
|
{...props.attributes}
|
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import { View, StyleSheet, Image, Text } from "react-native";
|
|
3
3
|
|
|
4
|
-
export
|
|
4
|
+
export interface ButtonProps {
|
|
5
|
+
attributes?: any;
|
|
6
|
+
text?: string;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export default function SubmitButton(props: ButtonProps) {
|
|
5
10
|
return (
|
|
6
11
|
<View {...props.attributes} type="submit">
|
|
7
12
|
<Text>{props.text}</Text>
|
|
@@ -1,11 +1,30 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import { View, StyleSheet, Image, Text } from "react-native";
|
|
3
3
|
import { useState, useContext, useEffect } from "react";
|
|
4
|
+
|
|
5
|
+
export interface SymbolInfo {
|
|
6
|
+
model?: string;
|
|
7
|
+
entry?: string;
|
|
8
|
+
data?: any;
|
|
9
|
+
content?: any;
|
|
10
|
+
inline?: boolean;
|
|
11
|
+
dynamic?: boolean;
|
|
12
|
+
}
|
|
13
|
+
export interface SymbolProps {
|
|
14
|
+
symbol?: SymbolInfo;
|
|
15
|
+
dataOnly?: boolean;
|
|
16
|
+
dynamic?: boolean;
|
|
17
|
+
builderBlock?: any; // TODO: BuilderElement
|
|
18
|
+
|
|
19
|
+
attributes?: any;
|
|
20
|
+
inheritState?: boolean;
|
|
21
|
+
}
|
|
22
|
+
|
|
4
23
|
import RenderContent from "../../components/render-content/render-content.lite";
|
|
5
24
|
import BuilderContext from "../../context/builder.context";
|
|
6
25
|
import { getContent } from "../../functions/get-content/index.js";
|
|
7
26
|
|
|
8
|
-
export default function Symbol(props) {
|
|
27
|
+
export default function Symbol(props: SymbolProps) {
|
|
9
28
|
const [className, setClassName] = useState(() => "builder-symbol");
|
|
10
29
|
|
|
11
30
|
const [content, setContent] = useState(() => null);
|
|
@@ -1,7 +1,15 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import { View, StyleSheet, Image, Text } from "react-native";
|
|
3
3
|
|
|
4
|
-
export
|
|
4
|
+
export interface TextareaProps {
|
|
5
|
+
attributes?: any;
|
|
6
|
+
name?: string;
|
|
7
|
+
value?: string;
|
|
8
|
+
defaultValue?: string;
|
|
9
|
+
placeholder?: string;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export default function Textarea(props: TextareaProps) {
|
|
5
13
|
return (
|
|
6
14
|
<View
|
|
7
15
|
{...props.attributes}
|
|
@@ -1,7 +1,33 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import { View, StyleSheet, Image, Text } from "react-native";
|
|
3
3
|
|
|
4
|
-
export
|
|
4
|
+
export interface VideoProps {
|
|
5
|
+
attributes?: any;
|
|
6
|
+
video?: string;
|
|
7
|
+
autoPlay?: boolean;
|
|
8
|
+
controls?: boolean;
|
|
9
|
+
muted?: boolean;
|
|
10
|
+
loop?: boolean;
|
|
11
|
+
playsInline?: boolean;
|
|
12
|
+
aspectRatio?: number;
|
|
13
|
+
width?: number;
|
|
14
|
+
height?: number;
|
|
15
|
+
fit?: "contain" | "cover" | "fill";
|
|
16
|
+
position?:
|
|
17
|
+
| "center"
|
|
18
|
+
| "top"
|
|
19
|
+
| "left"
|
|
20
|
+
| "right"
|
|
21
|
+
| "bottom"
|
|
22
|
+
| "top left"
|
|
23
|
+
| "top right"
|
|
24
|
+
| "bottom left"
|
|
25
|
+
| "bottom right";
|
|
26
|
+
posterImage?: string;
|
|
27
|
+
lazyLoad?: boolean;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export default function Video(props: VideoProps) {
|
|
5
31
|
return (
|
|
6
32
|
<View
|
|
7
33
|
{...props.attributes}
|
|
@@ -1,16 +1,27 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
+
import { useContext } from "react";
|
|
3
|
+
import { TARGET } from "../../constants/target.js";
|
|
4
|
+
import BuilderContext from "../../context/builder.context";
|
|
5
|
+
import { getProcessedBlock } from "../../functions/get-processed-block.js";
|
|
2
6
|
import RenderInlinedStyles from "../render-inlined-styles.js";
|
|
3
7
|
function BlockStyles(props) {
|
|
8
|
+
function useBlock() {
|
|
9
|
+
return getProcessedBlock({
|
|
10
|
+
block: props.block,
|
|
11
|
+
state: builderContext.state,
|
|
12
|
+
context: builderContext.context
|
|
13
|
+
});
|
|
14
|
+
}
|
|
4
15
|
function camelToKebabCase(string) {
|
|
5
16
|
return string.replace(/([a-z0-9]|(?=[A-Z]))([A-Z])/g, "$1-$2").toLowerCase();
|
|
6
17
|
}
|
|
7
18
|
function css() {
|
|
8
19
|
var _a;
|
|
9
|
-
const styleObject = (_a =
|
|
20
|
+
const styleObject = (_a = useBlock().responsiveStyles) == null ? void 0 : _a.large;
|
|
10
21
|
if (!styleObject) {
|
|
11
22
|
return "";
|
|
12
23
|
}
|
|
13
|
-
let str = `.${
|
|
24
|
+
let str = `.${useBlock().id} {`;
|
|
14
25
|
for (const key in styleObject) {
|
|
15
26
|
const value = styleObject[key];
|
|
16
27
|
if (typeof value === "string") {
|
|
@@ -20,9 +31,10 @@ function BlockStyles(props) {
|
|
|
20
31
|
str += "}";
|
|
21
32
|
return str;
|
|
22
33
|
}
|
|
23
|
-
|
|
34
|
+
const builderContext = useContext(BuilderContext);
|
|
35
|
+
return /* @__PURE__ */ React.createElement(React.Fragment, null, TARGET === "vue" || TARGET === "svelte" ? /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(RenderInlinedStyles, {
|
|
24
36
|
styles: css()
|
|
25
|
-
});
|
|
37
|
+
})) : null);
|
|
26
38
|
}
|
|
27
39
|
export {
|
|
28
40
|
BlockStyles as default
|
|
@@ -1,8 +1,24 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import { View, StyleSheet, Image, Text } from "react-native";
|
|
3
|
+
import { useContext } from "react";
|
|
4
|
+
|
|
5
|
+
export type BlockStylesProps = {
|
|
6
|
+
block: BuilderBlock;
|
|
7
|
+
};
|
|
8
|
+
import { TARGET } from "../../constants/target.js";
|
|
9
|
+
import BuilderContext from "../../context/builder.context";
|
|
10
|
+
import { getProcessedBlock } from "../../functions/get-processed-block.js";
|
|
3
11
|
import RenderInlinedStyles from "../render-inlined-styles.lite";
|
|
4
12
|
|
|
5
|
-
export default function BlockStyles(props) {
|
|
13
|
+
export default function BlockStyles(props: BlockStylesProps) {
|
|
14
|
+
function useBlock() {
|
|
15
|
+
return getProcessedBlock({
|
|
16
|
+
block: props.block,
|
|
17
|
+
state: builderContext.state,
|
|
18
|
+
context: builderContext.context,
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
|
|
6
22
|
function camelToKebabCase(string) {
|
|
7
23
|
return string
|
|
8
24
|
.replace(/([a-z0-9]|(?=[A-Z]))([A-Z])/g, "$1-$2")
|
|
@@ -11,13 +27,13 @@ export default function BlockStyles(props) {
|
|
|
11
27
|
|
|
12
28
|
function css() {
|
|
13
29
|
// TODO: media queries
|
|
14
|
-
const styleObject =
|
|
30
|
+
const styleObject = useBlock().responsiveStyles?.large;
|
|
15
31
|
|
|
16
32
|
if (!styleObject) {
|
|
17
33
|
return "";
|
|
18
34
|
}
|
|
19
35
|
|
|
20
|
-
let str = `.${
|
|
36
|
+
let str = `.${useBlock().id} {`;
|
|
21
37
|
|
|
22
38
|
for (const key in styleObject) {
|
|
23
39
|
const value = styleObject[key];
|
|
@@ -31,5 +47,15 @@ export default function BlockStyles(props) {
|
|
|
31
47
|
return str;
|
|
32
48
|
}
|
|
33
49
|
|
|
34
|
-
|
|
50
|
+
const builderContext = useContext(BuilderContext);
|
|
51
|
+
|
|
52
|
+
return (
|
|
53
|
+
<>
|
|
54
|
+
{TARGET === "vue" || TARGET === "svelte" ? (
|
|
55
|
+
<>
|
|
56
|
+
<RenderInlinedStyles styles={css()} />
|
|
57
|
+
</>
|
|
58
|
+
) : null}
|
|
59
|
+
</>
|
|
60
|
+
);
|
|
35
61
|
}
|
|
@@ -17,9 +17,20 @@ var __spreadValues = (a, b) => {
|
|
|
17
17
|
return a;
|
|
18
18
|
};
|
|
19
19
|
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
|
+
var __objRest = (source, exclude) => {
|
|
21
|
+
var target = {};
|
|
22
|
+
for (var prop in source)
|
|
23
|
+
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
24
|
+
target[prop] = source[prop];
|
|
25
|
+
if (source != null && __getOwnPropSymbols)
|
|
26
|
+
for (var prop of __getOwnPropSymbols(source)) {
|
|
27
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
28
|
+
target[prop] = source[prop];
|
|
29
|
+
}
|
|
30
|
+
return target;
|
|
31
|
+
};
|
|
20
32
|
import * as React from "react";
|
|
21
33
|
import { useContext } from "react";
|
|
22
|
-
import { TARGET } from "../../constants/target.js";
|
|
23
34
|
import BuilderContext from "../../context/builder.context";
|
|
24
35
|
import { getBlockActions } from "../../functions/get-block-actions.js";
|
|
25
36
|
import { getBlockComponentOptions } from "../../functions/get-block-component-options.js";
|
|
@@ -29,8 +40,9 @@ import { getBlockTag } from "../../functions/get-block-tag.js";
|
|
|
29
40
|
import { getProcessedBlock } from "../../functions/get-processed-block.js";
|
|
30
41
|
import BlockStyles from "./block-styles.js";
|
|
31
42
|
import { isEmptyHtmlElement } from "./render-block.helpers.js";
|
|
43
|
+
import RenderComponent from "./render-component.js";
|
|
32
44
|
function RenderBlock(props) {
|
|
33
|
-
var _a, _b
|
|
45
|
+
var _a, _b;
|
|
34
46
|
function component() {
|
|
35
47
|
var _a2;
|
|
36
48
|
const componentName = (_a2 = useBlock().component) == null ? void 0 : _a2.name;
|
|
@@ -48,8 +60,12 @@ function RenderBlock(props) {
|
|
|
48
60
|
}
|
|
49
61
|
}
|
|
50
62
|
function componentInfo() {
|
|
51
|
-
|
|
52
|
-
|
|
63
|
+
if (component()) {
|
|
64
|
+
const _a2 = component(), { component: _ } = _a2, info = __objRest(_a2, ["component"]);
|
|
65
|
+
return info;
|
|
66
|
+
} else {
|
|
67
|
+
return void 0;
|
|
68
|
+
}
|
|
53
69
|
}
|
|
54
70
|
function componentRef() {
|
|
55
71
|
var _a2;
|
|
@@ -65,18 +81,23 @@ function RenderBlock(props) {
|
|
|
65
81
|
context: builderContext.context
|
|
66
82
|
});
|
|
67
83
|
}
|
|
68
|
-
function
|
|
69
|
-
return __spreadValues(__spreadValues({}, getBlockProperties(useBlock())), getBlockActions({
|
|
84
|
+
function attributes() {
|
|
85
|
+
return __spreadProps(__spreadValues(__spreadValues({}, getBlockProperties(useBlock())), getBlockActions({
|
|
70
86
|
block: useBlock(),
|
|
71
87
|
state: builderContext.state,
|
|
72
88
|
context: builderContext.context
|
|
73
|
-
}))
|
|
89
|
+
})), {
|
|
90
|
+
style: getBlockStyles(useBlock())
|
|
91
|
+
});
|
|
74
92
|
}
|
|
75
|
-
function
|
|
76
|
-
|
|
93
|
+
function shouldWrap() {
|
|
94
|
+
var _a2;
|
|
95
|
+
return !((_a2 = componentInfo == null ? void 0 : componentInfo()) == null ? void 0 : _a2.noWrap);
|
|
77
96
|
}
|
|
78
97
|
function componentOptions() {
|
|
79
|
-
return getBlockComponentOptions(useBlock())
|
|
98
|
+
return __spreadValues(__spreadValues({}, getBlockComponentOptions(useBlock())), shouldWrap() ? {} : {
|
|
99
|
+
attributes: attributes()
|
|
100
|
+
});
|
|
80
101
|
}
|
|
81
102
|
function children() {
|
|
82
103
|
var _a2;
|
|
@@ -86,30 +107,22 @@ function RenderBlock(props) {
|
|
|
86
107
|
return componentRef() ? [] : children();
|
|
87
108
|
}
|
|
88
109
|
const builderContext = useContext(BuilderContext);
|
|
89
|
-
const ComponentRefRef = componentRef();
|
|
90
110
|
const TagNameRef = tagName();
|
|
91
|
-
return /* @__PURE__ */ React.createElement(React.Fragment, null,
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
}))
|
|
96
|
-
|
|
97
|
-
}), (_b = children()) == null ? void 0 : _b.map((child) => /* @__PURE__ */ React.createElement(RenderBlock, {
|
|
98
|
-
key: child.id,
|
|
99
|
-
block: child
|
|
100
|
-
}))) : null, (_c = noCompRefChildren()) == null ? void 0 : _c.map((child) => /* @__PURE__ */ React.createElement(RenderBlock, {
|
|
101
|
-
key: child.id,
|
|
111
|
+
return /* @__PURE__ */ React.createElement(React.Fragment, null, shouldWrap() ? /* @__PURE__ */ React.createElement(React.Fragment, null, !isEmptyHtmlElement(tagName()) ? /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(TagNameRef, __spreadValues({}, attributes()), /* @__PURE__ */ React.createElement(RenderComponent, {
|
|
112
|
+
blockChildren: children(),
|
|
113
|
+
componentRef: componentRef(),
|
|
114
|
+
componentOptions: componentOptions()
|
|
115
|
+
}), (_a = noCompRefChildren()) == null ? void 0 : _a.map((child) => /* @__PURE__ */ React.createElement(RenderBlock, {
|
|
116
|
+
key: "render-block-" + child.id,
|
|
102
117
|
block: child
|
|
103
|
-
})))) : /* @__PURE__ */ React.createElement(
|
|
104
|
-
|
|
105
|
-
}))) : /* @__PURE__ */ React.createElement(ComponentRefRef, __spreadProps(__spreadValues({}, componentOptions()), {
|
|
106
|
-
attributes: propertiesAndActions(),
|
|
107
|
-
builderBlock: useBlock(),
|
|
108
|
-
style: css()
|
|
109
|
-
}), (_d = children()) == null ? void 0 : _d.map((child) => /* @__PURE__ */ React.createElement(RenderBlock, {
|
|
110
|
-
key: child.id,
|
|
118
|
+
})), (_b = noCompRefChildren()) == null ? void 0 : _b.map((child) => /* @__PURE__ */ React.createElement(BlockStyles, {
|
|
119
|
+
key: "block-style-" + child.id,
|
|
111
120
|
block: child
|
|
112
|
-
}))))
|
|
121
|
+
})))) : /* @__PURE__ */ React.createElement(TagNameRef, __spreadValues({}, attributes()))) : /* @__PURE__ */ React.createElement(RenderComponent, {
|
|
122
|
+
blockChildren: children(),
|
|
123
|
+
componentRef: componentRef(),
|
|
124
|
+
componentOptions: componentOptions()
|
|
125
|
+
}));
|
|
113
126
|
}
|
|
114
127
|
export {
|
|
115
128
|
RenderBlock as default
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import { View, StyleSheet, Image, Text } from "react-native";
|
|
3
3
|
import { useContext } from "react";
|
|
4
|
-
|
|
4
|
+
|
|
5
|
+
export type RenderBlockProps = {
|
|
6
|
+
block: BuilderBlock;
|
|
7
|
+
}; // eslint-disable-next-line @builder.io/mitosis/only-default-function-and-imports
|
|
8
|
+
|
|
5
9
|
import BuilderContext from "../../context/builder.context";
|
|
6
10
|
import { getBlockActions } from "../../functions/get-block-actions.js";
|
|
7
11
|
import { getBlockComponentOptions } from "../../functions/get-block-component-options.js";
|
|
@@ -11,8 +15,9 @@ import { getBlockTag } from "../../functions/get-block-tag.js";
|
|
|
11
15
|
import { getProcessedBlock } from "../../functions/get-processed-block.js";
|
|
12
16
|
import BlockStyles from "./block-styles.lite";
|
|
13
17
|
import { isEmptyHtmlElement } from "./render-block.helpers.js";
|
|
18
|
+
import RenderComponent from "./render-component.lite";
|
|
14
19
|
|
|
15
|
-
export default function RenderBlock(props) {
|
|
20
|
+
export default function RenderBlock(props: RenderBlockProps) {
|
|
16
21
|
function component() {
|
|
17
22
|
const componentName = useBlock().component?.name;
|
|
18
23
|
|
|
@@ -34,7 +39,12 @@ export default function RenderBlock(props) {
|
|
|
34
39
|
}
|
|
35
40
|
|
|
36
41
|
function componentInfo() {
|
|
37
|
-
|
|
42
|
+
if (component()) {
|
|
43
|
+
const { component: _, ...info } = component();
|
|
44
|
+
return info;
|
|
45
|
+
} else {
|
|
46
|
+
return undefined;
|
|
47
|
+
}
|
|
38
48
|
}
|
|
39
49
|
|
|
40
50
|
function componentRef() {
|
|
@@ -53,7 +63,7 @@ export default function RenderBlock(props) {
|
|
|
53
63
|
});
|
|
54
64
|
}
|
|
55
65
|
|
|
56
|
-
function
|
|
66
|
+
function attributes() {
|
|
57
67
|
return {
|
|
58
68
|
...getBlockProperties(useBlock()),
|
|
59
69
|
...getBlockActions({
|
|
@@ -61,15 +71,28 @@ export default function RenderBlock(props) {
|
|
|
61
71
|
state: builderContext.state,
|
|
62
72
|
context: builderContext.context,
|
|
63
73
|
}),
|
|
74
|
+
style: getBlockStyles(useBlock()),
|
|
64
75
|
};
|
|
65
76
|
}
|
|
66
77
|
|
|
67
|
-
function
|
|
68
|
-
return
|
|
78
|
+
function shouldWrap() {
|
|
79
|
+
return !componentInfo?.()?.noWrap;
|
|
69
80
|
}
|
|
70
81
|
|
|
71
82
|
function componentOptions() {
|
|
72
|
-
return
|
|
83
|
+
return {
|
|
84
|
+
...getBlockComponentOptions(useBlock()),
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* These attributes are passed to the wrapper element when there is one. If `noWrap` is set to true, then
|
|
88
|
+
* they are provided to the component itself directly.
|
|
89
|
+
*/
|
|
90
|
+
...(shouldWrap()
|
|
91
|
+
? {}
|
|
92
|
+
: {
|
|
93
|
+
attributes: attributes(),
|
|
94
|
+
}),
|
|
95
|
+
};
|
|
73
96
|
}
|
|
74
97
|
|
|
75
98
|
function children() {
|
|
@@ -81,58 +104,49 @@ export default function RenderBlock(props) {
|
|
|
81
104
|
}
|
|
82
105
|
|
|
83
106
|
function noCompRefChildren() {
|
|
107
|
+
/**
|
|
108
|
+
* When there is no `componentRef`, there might still be children that need to be rendered. In this case,
|
|
109
|
+
* we render them outside of `componentRef`
|
|
110
|
+
*/
|
|
84
111
|
return componentRef() ? [] : children();
|
|
85
112
|
}
|
|
86
113
|
|
|
87
114
|
const builderContext = useContext(BuilderContext);
|
|
88
115
|
|
|
89
|
-
const ComponentRefRef = componentRef();
|
|
90
116
|
const TagNameRef = tagName();
|
|
91
117
|
|
|
92
118
|
return (
|
|
93
119
|
<>
|
|
94
|
-
{
|
|
120
|
+
{shouldWrap() ? (
|
|
95
121
|
<>
|
|
96
122
|
{!isEmptyHtmlElement(tagName()) ? (
|
|
97
123
|
<>
|
|
98
|
-
<TagNameRef {...
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
{
|
|
106
|
-
<
|
|
107
|
-
|
|
108
|
-
builderBlock={useBlock()}
|
|
109
|
-
>
|
|
110
|
-
{children()?.map((child) => (
|
|
111
|
-
<RenderBlock key={child.id} block={child} />
|
|
112
|
-
))}
|
|
113
|
-
</ComponentRefRef>
|
|
114
|
-
) : null}
|
|
124
|
+
<TagNameRef {...attributes()}>
|
|
125
|
+
<RenderComponent
|
|
126
|
+
blockChildren={children()}
|
|
127
|
+
componentRef={componentRef()}
|
|
128
|
+
componentOptions={componentOptions()}
|
|
129
|
+
/>
|
|
130
|
+
|
|
131
|
+
{noCompRefChildren()?.map((child) => (
|
|
132
|
+
<RenderBlock key={"render-block-" + child.id} block={child} />
|
|
133
|
+
))}
|
|
115
134
|
|
|
116
135
|
{noCompRefChildren()?.map((child) => (
|
|
117
|
-
<
|
|
136
|
+
<BlockStyles key={"block-style-" + child.id} block={child} />
|
|
118
137
|
))}
|
|
119
138
|
</TagNameRef>
|
|
120
139
|
</>
|
|
121
140
|
) : (
|
|
122
|
-
<TagNameRef {...
|
|
141
|
+
<TagNameRef {...attributes()} />
|
|
123
142
|
)}
|
|
124
143
|
</>
|
|
125
144
|
) : (
|
|
126
|
-
<
|
|
127
|
-
{
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
>
|
|
132
|
-
{children()?.map((child) => (
|
|
133
|
-
<RenderBlock key={child.id} block={child} />
|
|
134
|
-
))}
|
|
135
|
-
</ComponentRefRef>
|
|
145
|
+
<RenderComponent
|
|
146
|
+
blockChildren={children()}
|
|
147
|
+
componentRef={componentRef()}
|
|
148
|
+
componentOptions={componentOptions()}
|
|
149
|
+
/>
|
|
136
150
|
)}
|
|
137
151
|
</>
|
|
138
152
|
);
|
|
@@ -0,0 +1,33 @@
|
|
|
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 * as React from "react";
|
|
18
|
+
import BlockStyles from "./block-styles.js";
|
|
19
|
+
import RenderBlock from "./render-block.js";
|
|
20
|
+
function RenderComponent(props) {
|
|
21
|
+
var _a, _b;
|
|
22
|
+
const ComponentRefRef = props.componentRef;
|
|
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, {
|
|
24
|
+
key: "render-block-" + child.id,
|
|
25
|
+
block: child
|
|
26
|
+
})), (_b = props.blockChildren) == null ? void 0 : _b.map((child) => /* @__PURE__ */ React.createElement(BlockStyles, {
|
|
27
|
+
key: "block-style-" + child.id,
|
|
28
|
+
block: child
|
|
29
|
+
})))) : null);
|
|
30
|
+
}
|
|
31
|
+
export {
|
|
32
|
+
RenderComponent as default
|
|
33
|
+
};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { View, StyleSheet, Image, Text } from "react-native";
|
|
3
|
+
|
|
4
|
+
type Props = {
|
|
5
|
+
componentRef: any;
|
|
6
|
+
componentOptions: any;
|
|
7
|
+
blockChildren: BuilderBlock[];
|
|
8
|
+
};
|
|
9
|
+
import BlockStyles from "./block-styles.lite";
|
|
10
|
+
import RenderBlock from "./render-block.lite";
|
|
11
|
+
|
|
12
|
+
export default function RenderComponent(props: Props) {
|
|
13
|
+
const ComponentRefRef = props.componentRef;
|
|
14
|
+
|
|
15
|
+
return (
|
|
16
|
+
<>
|
|
17
|
+
{props.componentRef ? (
|
|
18
|
+
<>
|
|
19
|
+
<ComponentRefRef {...props.componentOptions}>
|
|
20
|
+
{props.blockChildren?.map((child) => (
|
|
21
|
+
<RenderBlock key={"render-block-" + child.id} block={child} />
|
|
22
|
+
))}
|
|
23
|
+
|
|
24
|
+
{props.blockChildren?.map((child) => (
|
|
25
|
+
<BlockStyles key={"block-style-" + child.id} block={child} />
|
|
26
|
+
))}
|
|
27
|
+
</ComponentRefRef>
|
|
28
|
+
</>
|
|
29
|
+
) : null}
|
|
30
|
+
</>
|
|
31
|
+
);
|
|
32
|
+
}
|
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import { View, StyleSheet } from "react-native";
|
|
3
3
|
import { isEditing } from "../functions/is-editing.js";
|
|
4
|
+
import BlockStyles from "./render-block/block-styles.js";
|
|
4
5
|
import RenderBlock from "./render-block/render-block.js";
|
|
5
6
|
function RenderBlocks(props) {
|
|
6
|
-
var _a;
|
|
7
|
+
var _a, _b;
|
|
7
8
|
function className() {
|
|
8
9
|
var _a2;
|
|
9
10
|
return "builder-blocks" + (!((_a2 = props.blocks) == null ? void 0 : _a2.length) ? " no-blocks" : "");
|
|
10
11
|
}
|
|
11
12
|
function onClick() {
|
|
12
|
-
var _a2,
|
|
13
|
+
var _a2, _b2;
|
|
13
14
|
if (isEditing() && !((_a2 = props.blocks) == null ? void 0 : _a2.length)) {
|
|
14
|
-
(
|
|
15
|
+
(_b2 = window.parent) == null ? void 0 : _b2.postMessage({
|
|
15
16
|
type: "builder.clickEmptyBlocks",
|
|
16
17
|
data: {
|
|
17
18
|
parentElementId: props.parent,
|
|
@@ -21,9 +22,9 @@ function RenderBlocks(props) {
|
|
|
21
22
|
}
|
|
22
23
|
}
|
|
23
24
|
function onMouseEnter() {
|
|
24
|
-
var _a2,
|
|
25
|
+
var _a2, _b2;
|
|
25
26
|
if (isEditing() && !((_a2 = props.blocks) == null ? void 0 : _a2.length)) {
|
|
26
|
-
(
|
|
27
|
+
(_b2 = window.parent) == null ? void 0 : _b2.postMessage({
|
|
27
28
|
type: "builder.hoverEmptyBlocks",
|
|
28
29
|
data: {
|
|
29
30
|
parentElementId: props.parent,
|
|
@@ -42,7 +43,10 @@ function RenderBlocks(props) {
|
|
|
42
43
|
onMouseEnter: (event) => onMouseEnter(),
|
|
43
44
|
style: styles.view1
|
|
44
45
|
}, props.blocks ? /* @__PURE__ */ React.createElement(React.Fragment, null, (_a = props.blocks) == null ? void 0 : _a.map((block) => /* @__PURE__ */ React.createElement(RenderBlock, {
|
|
45
|
-
key: block.id,
|
|
46
|
+
key: "render-block-" + block.id,
|
|
47
|
+
block
|
|
48
|
+
}))) : null, props.blocks ? /* @__PURE__ */ React.createElement(React.Fragment, null, (_b = props.blocks) == null ? void 0 : _b.map((block) => /* @__PURE__ */ React.createElement(BlockStyles, {
|
|
49
|
+
key: "block-style-" + block.id,
|
|
46
50
|
block
|
|
47
51
|
}))) : null);
|
|
48
52
|
}
|
|
@@ -1,9 +1,16 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import { View, StyleSheet, Image, Text } from "react-native";
|
|
3
|
+
|
|
4
|
+
export type RenderBlockProps = {
|
|
5
|
+
blocks?: BuilderBlock[];
|
|
6
|
+
parent?: string;
|
|
7
|
+
path?: string;
|
|
8
|
+
};
|
|
3
9
|
import { isEditing } from "../functions/is-editing.js";
|
|
10
|
+
import BlockStyles from "./render-block/block-styles.lite";
|
|
4
11
|
import RenderBlock from "./render-block/render-block.lite";
|
|
5
12
|
|
|
6
|
-
export default function RenderBlocks(props) {
|
|
13
|
+
export default function RenderBlocks(props: RenderBlockProps) {
|
|
7
14
|
function className() {
|
|
8
15
|
return "builder-blocks" + (!props.blocks?.length ? " no-blocks" : "");
|
|
9
16
|
}
|
|
@@ -52,7 +59,15 @@ export default function RenderBlocks(props) {
|
|
|
52
59
|
{props.blocks ? (
|
|
53
60
|
<>
|
|
54
61
|
{props.blocks?.map((block) => (
|
|
55
|
-
<RenderBlock key={block.id} block={block} />
|
|
62
|
+
<RenderBlock key={"render-block-" + block.id} block={block} />
|
|
63
|
+
))}
|
|
64
|
+
</>
|
|
65
|
+
) : null}
|
|
66
|
+
|
|
67
|
+
{props.blocks ? (
|
|
68
|
+
<>
|
|
69
|
+
{props.blocks?.map((block) => (
|
|
70
|
+
<BlockStyles key={"block-style-" + block.id} block={block} />
|
|
56
71
|
))}
|
|
57
72
|
</>
|
|
58
73
|
) : null}
|
|
@@ -1,8 +1,22 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import { View, StyleSheet, Image, Text } from "react-native";
|
|
3
|
+
|
|
4
|
+
interface CustomFont {
|
|
5
|
+
family?: string;
|
|
6
|
+
kind?: string;
|
|
7
|
+
fileUrl?: string;
|
|
8
|
+
files?: {
|
|
9
|
+
[key: string]: string;
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
interface Props {
|
|
13
|
+
cssCode?: string;
|
|
14
|
+
customFonts?: CustomFont[];
|
|
15
|
+
}
|
|
16
|
+
|
|
3
17
|
import RenderInlinedStyles from "../../render-inlined-styles.lite";
|
|
4
18
|
|
|
5
|
-
export default function RenderContentStyles(props) {
|
|
19
|
+
export default function RenderContentStyles(props: Props) {
|
|
6
20
|
function getCssFromFont(font) {
|
|
7
21
|
// TODO: compute what font sizes are used and only load those.......
|
|
8
22
|
const family =
|
|
@@ -1,6 +1,33 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import { View, StyleSheet, Image, Text } from "react-native";
|
|
3
3
|
import { useState, useContext, useEffect } from "react";
|
|
4
|
+
|
|
5
|
+
export type RenderContentProps = {
|
|
6
|
+
content?: BuilderContent;
|
|
7
|
+
model?: string;
|
|
8
|
+
data?: {
|
|
9
|
+
[key: string]: any;
|
|
10
|
+
};
|
|
11
|
+
context?: {
|
|
12
|
+
[key: string]: any;
|
|
13
|
+
};
|
|
14
|
+
apiKey: string;
|
|
15
|
+
customComponents?: RegisteredComponent[];
|
|
16
|
+
};
|
|
17
|
+
interface BuilderComponentStateChange {
|
|
18
|
+
state: {
|
|
19
|
+
[key: string]: any;
|
|
20
|
+
};
|
|
21
|
+
ref: {
|
|
22
|
+
name?: string;
|
|
23
|
+
props?: {
|
|
24
|
+
builderBlock?: {
|
|
25
|
+
id?: string;
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
|
|
4
31
|
import { getDefaultRegisteredComponents } from "../../constants/builder-registered-components.js";
|
|
5
32
|
import { TARGET } from "../../constants/target.js";
|
|
6
33
|
import BuilderContext from "../../context/builder.context";
|
|
@@ -23,7 +50,7 @@ import { track } from "../../functions/track.js";
|
|
|
23
50
|
import RenderBlocks from "../render-blocks.lite";
|
|
24
51
|
import RenderContentStyles from "./components/render-styles.lite";
|
|
25
52
|
|
|
26
|
-
export default function RenderContent(props) {
|
|
53
|
+
export default function RenderContent(props: RenderContentProps) {
|
|
27
54
|
function useContent() {
|
|
28
55
|
const mergedContent = {
|
|
29
56
|
...props.content,
|
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import { View, StyleSheet, Image, Text } from "react-native";
|
|
3
|
+
|
|
4
|
+
interface Props {
|
|
5
|
+
styles: string;
|
|
6
|
+
}
|
|
7
|
+
|
|
3
8
|
import { TARGET } from "../constants/target.js";
|
|
4
9
|
|
|
5
|
-
export default function RenderInlinedStyles(props) {
|
|
10
|
+
export default function RenderInlinedStyles(props: Props) {
|
|
6
11
|
function injectedStyleScript() {
|
|
7
12
|
return `<${tagName()}>${props.styles}</${tagName()}>`;
|
|
8
13
|
}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
var __defProp = Object.defineProperty;
|
|
3
|
+
var __defProps = Object.defineProperties;
|
|
4
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
3
5
|
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
4
6
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
7
|
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
@@ -15,9 +17,12 @@ var __spreadValues = (a, b) => {
|
|
|
15
17
|
}
|
|
16
18
|
return a;
|
|
17
19
|
};
|
|
20
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
18
21
|
function getBlockComponentOptions(block) {
|
|
19
22
|
var _a;
|
|
20
|
-
return __spreadValues(__spreadValues({}, (_a = block.component) == null ? void 0 : _a.options), block.options)
|
|
23
|
+
return __spreadProps(__spreadValues(__spreadValues({}, (_a = block.component) == null ? void 0 : _a.options), block.options), {
|
|
24
|
+
builderBlock: block
|
|
25
|
+
});
|
|
21
26
|
}
|
|
22
27
|
export {
|
|
23
28
|
getBlockComponentOptions
|
|
@@ -27,7 +27,7 @@ function validateReactNativeStyles(styles) {
|
|
|
27
27
|
}
|
|
28
28
|
delete styles[key];
|
|
29
29
|
}
|
|
30
|
-
if (typeof propertyValue === "string" && propertyValue.match(
|
|
30
|
+
if (typeof propertyValue === "string" && propertyValue.match(/^-?\d/)) {
|
|
31
31
|
const newValue = parseFloat(propertyValue);
|
|
32
32
|
if (!isNaN(newValue)) {
|
|
33
33
|
styles[key] = newValue;
|