@builder.io/sdk-react-native 0.0.1-56 → 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 +1 -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 +20 -3
- 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/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.lite.tsx +5 -1
- package/src/components/render-block/render-block.lite.tsx +6 -1
- package/src/components/render-block/render-component.lite.tsx +7 -1
- package/src/components/render-blocks.lite.tsx +7 -1
- 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/CHANGELOG.md
CHANGED
|
@@ -10,7 +10,7 @@ See [builder-registered-components.ts](/packages/sdks/src/constants/builder-regi
|
|
|
10
10
|
|
|
11
11
|
### 0.0.1-51
|
|
12
12
|
|
|
13
|
-
⚠️ Deprecation notice: Registering components via `registerComponent(component, info)` is now deprecated.
|
|
13
|
+
⚠️ Deprecation notice: Registering components via `registerComponent(component, info)` is now deprecated.
|
|
14
14
|
To register your custom components in Builder, you must now provide a `customComponents` array to the `RenderContent` component containing `[{ component, info }]`.
|
|
15
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.
|
|
16
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>
|
|
@@ -11,11 +28,11 @@ export default function Image(props) {
|
|
|
11
28
|
role={props.altText ? "presentation" : undefined}
|
|
12
29
|
style={styles.view2}
|
|
13
30
|
src={props.image}
|
|
14
|
-
|
|
31
|
+
srcset={props.srcset}
|
|
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,12 +1,16 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import { View, StyleSheet, Image, Text } from "react-native";
|
|
3
3
|
import { useContext } from "react";
|
|
4
|
+
|
|
5
|
+
export type BlockStylesProps = {
|
|
6
|
+
block: BuilderBlock;
|
|
7
|
+
};
|
|
4
8
|
import { TARGET } from "../../constants/target.js";
|
|
5
9
|
import BuilderContext from "../../context/builder.context";
|
|
6
10
|
import { getProcessedBlock } from "../../functions/get-processed-block.js";
|
|
7
11
|
import RenderInlinedStyles from "../render-inlined-styles.lite";
|
|
8
12
|
|
|
9
|
-
export default function BlockStyles(props) {
|
|
13
|
+
export default function BlockStyles(props: BlockStylesProps) {
|
|
10
14
|
function useBlock() {
|
|
11
15
|
return getProcessedBlock({
|
|
12
16
|
block: props.block,
|
|
@@ -1,6 +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
|
+
|
|
5
|
+
export type RenderBlockProps = {
|
|
6
|
+
block: BuilderBlock;
|
|
7
|
+
}; // eslint-disable-next-line @builder.io/mitosis/only-default-function-and-imports
|
|
8
|
+
|
|
4
9
|
import BuilderContext from "../../context/builder.context";
|
|
5
10
|
import { getBlockActions } from "../../functions/get-block-actions.js";
|
|
6
11
|
import { getBlockComponentOptions } from "../../functions/get-block-component-options.js";
|
|
@@ -12,7 +17,7 @@ import BlockStyles from "./block-styles.lite";
|
|
|
12
17
|
import { isEmptyHtmlElement } from "./render-block.helpers.js";
|
|
13
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
|
|
|
@@ -1,9 +1,15 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import { View, StyleSheet, Image, Text } from "react-native";
|
|
3
|
+
|
|
4
|
+
type Props = {
|
|
5
|
+
componentRef: any;
|
|
6
|
+
componentOptions: any;
|
|
7
|
+
blockChildren: BuilderBlock[];
|
|
8
|
+
};
|
|
3
9
|
import BlockStyles from "./block-styles.lite";
|
|
4
10
|
import RenderBlock from "./render-block.lite";
|
|
5
11
|
|
|
6
|
-
export default function RenderComponent(props) {
|
|
12
|
+
export default function RenderComponent(props: Props) {
|
|
7
13
|
const ComponentRefRef = props.componentRef;
|
|
8
14
|
|
|
9
15
|
return (
|
|
@@ -1,10 +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";
|
|
4
10
|
import BlockStyles from "./render-block/block-styles.lite";
|
|
5
11
|
import RenderBlock from "./render-block/render-block.lite";
|
|
6
12
|
|
|
7
|
-
export default function RenderBlocks(props) {
|
|
13
|
+
export default function RenderBlocks(props: RenderBlockProps) {
|
|
8
14
|
function className() {
|
|
9
15
|
return "builder-blocks" + (!props.blocks?.length ? " no-blocks" : "");
|
|
10
16
|
}
|
|
@@ -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
|
}
|