@builder.io/sdk-react-native 1.0.33 → 1.0.34
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/lib/browser/commonjs/blocks/text/text.js +1 -1
- package/lib/browser/commonjs/constants/sdk-version.js +1 -1
- package/lib/browser/commonjs/functions/evaluate/node-runtime/safeDynamicRequire.js +4 -18
- package/lib/browser/commonjs/functions/evaluate/node-runtime/safeDynamicRequire.js.map +1 -1
- package/lib/browser/commonjs/helpers/cookie.js +12 -2
- package/lib/browser/commonjs/helpers/cookie.js.map +1 -1
- package/lib/browser/module/blocks/text/text.js +1 -1
- package/lib/browser/module/blocks/text/text.js.map +1 -1
- package/lib/browser/module/constants/sdk-version.js +1 -1
- package/lib/browser/module/functions/evaluate/node-runtime/safeDynamicRequire.js +5 -18
- package/lib/browser/module/functions/evaluate/node-runtime/safeDynamicRequire.js.map +1 -1
- package/lib/browser/module/helpers/cookie.js +11 -2
- package/lib/browser/module/helpers/cookie.js.map +1 -1
- package/lib/browser/typescript/constants/sdk-version.d.ts +1 -1
- package/lib/browser/typescript/helpers/cookie.d.ts +1 -0
- package/lib/browser/typescript/helpers/cookie.d.ts.map +1 -1
- package/lib/edge/commonjs/blocks/text/text.js +1 -1
- package/lib/edge/commonjs/constants/sdk-version.js +1 -1
- package/lib/edge/commonjs/functions/evaluate/node-runtime/safeDynamicRequire.js +4 -18
- package/lib/edge/commonjs/functions/evaluate/node-runtime/safeDynamicRequire.js.map +1 -1
- package/lib/edge/commonjs/helpers/cookie.js +12 -2
- package/lib/edge/commonjs/helpers/cookie.js.map +1 -1
- package/lib/edge/module/blocks/text/text.js +1 -1
- package/lib/edge/module/blocks/text/text.js.map +1 -1
- package/lib/edge/module/constants/sdk-version.js +1 -1
- package/lib/edge/module/functions/evaluate/node-runtime/safeDynamicRequire.js +5 -18
- package/lib/edge/module/functions/evaluate/node-runtime/safeDynamicRequire.js.map +1 -1
- package/lib/edge/module/helpers/cookie.js +11 -2
- package/lib/edge/module/helpers/cookie.js.map +1 -1
- package/lib/edge/typescript/constants/sdk-version.d.ts +1 -1
- package/lib/edge/typescript/helpers/cookie.d.ts +1 -0
- package/lib/edge/typescript/helpers/cookie.d.ts.map +1 -1
- package/lib/node/commonjs/blocks/text/text.js +1 -1
- package/lib/node/commonjs/constants/sdk-version.js +1 -1
- package/lib/node/commonjs/functions/evaluate/node-runtime/safeDynamicRequire.js +4 -18
- package/lib/node/commonjs/functions/evaluate/node-runtime/safeDynamicRequire.js.map +1 -1
- package/lib/node/commonjs/helpers/cookie.js +12 -2
- package/lib/node/commonjs/helpers/cookie.js.map +1 -1
- package/lib/node/module/blocks/text/text.js +1 -1
- package/lib/node/module/blocks/text/text.js.map +1 -1
- package/lib/node/module/constants/sdk-version.js +1 -1
- package/lib/node/module/functions/evaluate/node-runtime/safeDynamicRequire.js +5 -18
- package/lib/node/module/functions/evaluate/node-runtime/safeDynamicRequire.js.map +1 -1
- package/lib/node/module/helpers/cookie.js +11 -2
- package/lib/node/module/helpers/cookie.js.map +1 -1
- package/lib/node/typescript/constants/sdk-version.d.ts +1 -1
- package/lib/node/typescript/helpers/cookie.d.ts +1 -0
- package/lib/node/typescript/helpers/cookie.d.ts.map +1 -1
- package/package.json +10 -7
- package/src/blocks/BaseText.tsx +17 -0
- package/src/blocks/accordion/accordion.tsx +181 -0
- package/src/blocks/accordion/accordion.types.ts +12 -0
- package/src/blocks/accordion/component-info.ts +124 -0
- package/src/blocks/accordion/helpers.ts +3 -0
- package/src/blocks/accordion/index.ts +1 -0
- package/src/blocks/button/button.tsx +56 -0
- package/src/blocks/button/button.types.ts +7 -0
- package/src/blocks/button/component-info.ts +35 -0
- package/src/blocks/button/index.ts +1 -0
- package/src/blocks/columns/columns.tsx +199 -0
- package/src/blocks/columns/columns.types.ts +14 -0
- package/src/blocks/columns/component-info.ts +219 -0
- package/src/blocks/columns/helpers.ts +3 -0
- package/src/blocks/columns/index.ts +1 -0
- package/src/blocks/custom-code/component-info.ts +24 -0
- package/src/blocks/custom-code/custom-code.tsx +71 -0
- package/src/blocks/custom-code/index.ts +1 -0
- package/src/blocks/embed/component-info.ts +38 -0
- package/src/blocks/embed/embed.tsx +62 -0
- package/src/blocks/embed/helpers.ts +2 -0
- package/src/blocks/embed/index.ts +1 -0
- package/src/blocks/form/form/component-info.ts +233 -0
- package/src/blocks/form/form/form.tsx +324 -0
- package/src/blocks/form/form/index.ts +1 -0
- package/src/blocks/form/input/component-info.ts +47 -0
- package/src/blocks/form/input/index.ts +1 -0
- package/src/blocks/form/input/input.tsx +49 -0
- package/src/blocks/form/select/component-info.ts +44 -0
- package/src/blocks/form/select/index.ts +1 -0
- package/src/blocks/form/select/select.tsx +54 -0
- package/src/blocks/form/submit-button/component-info.ts +27 -0
- package/src/blocks/form/submit-button/index.ts +1 -0
- package/src/blocks/form/submit-button/submit-button.tsx +34 -0
- package/src/blocks/fragment/component-info.ts +8 -0
- package/src/blocks/fragment/fragment.tsx +18 -0
- package/src/blocks/fragment/fragment.types.ts +5 -0
- package/src/blocks/fragment/index.ts +1 -0
- package/src/blocks/helpers.ts +43 -0
- package/src/blocks/image/component-info.ts +129 -0
- package/src/blocks/image/image.helpers.ts +47 -0
- package/src/blocks/image/image.tsx +65 -0
- package/src/blocks/image/image.types.ts +20 -0
- package/src/blocks/image/index.ts +1 -0
- package/src/blocks/img/component-info.ts +16 -0
- package/src/blocks/img/img.tsx +55 -0
- package/src/blocks/img/index.ts +1 -0
- package/src/blocks/raw-text/component-info.ts +11 -0
- package/src/blocks/raw-text/index.ts +1 -0
- package/src/blocks/raw-text/raw-text.tsx +1 -0
- package/src/blocks/section/component-info.ts +41 -0
- package/src/blocks/section/index.ts +1 -0
- package/src/blocks/section/section.tsx +39 -0
- package/src/blocks/section/section.types.ts +6 -0
- package/src/blocks/slot/component-info.ts +15 -0
- package/src/blocks/slot/index.ts +1 -0
- package/src/blocks/slot/slot.tsx +42 -0
- package/src/blocks/symbol/component-info.ts +35 -0
- package/src/blocks/symbol/index.ts +1 -0
- package/src/blocks/symbol/symbol.helpers.ts +47 -0
- package/src/blocks/symbol/symbol.tsx +100 -0
- package/src/blocks/symbol/symbol.types.ts +17 -0
- package/src/blocks/tabs/component-info.ts +139 -0
- package/src/blocks/tabs/index.ts +1 -0
- package/src/blocks/tabs/tabs.tsx +79 -0
- package/src/blocks/tabs/tabs.types.ts +13 -0
- package/src/blocks/text/component-info.ts +20 -0
- package/src/blocks/text/index.ts +1 -0
- package/src/blocks/text/text.tsx +105 -0
- package/src/blocks/text/text.types.ts +4 -0
- package/src/blocks/textarea/component-info.ts +38 -0
- package/src/blocks/textarea/index.ts +1 -0
- package/src/blocks/textarea/textarea.tsx +41 -0
- package/src/blocks/video/component-info.ts +83 -0
- package/src/blocks/video/index.ts +1 -0
- package/src/blocks/video/video.tsx +70 -0
- package/src/blocks/video/video.types.ts +21 -0
- package/src/components/block/animator.ts +220 -0
- package/src/components/block/block.helpers.ts +124 -0
- package/src/components/block/block.tsx +232 -0
- package/src/components/block/components/block-styles.tsx +136 -0
- package/src/components/block/components/block-wrapper.tsx +52 -0
- package/src/components/block/components/component-ref/component-ref.helpers.ts +55 -0
- package/src/components/block/components/component-ref/component-ref.tsx +66 -0
- package/src/components/block/components/interactive-element.tsx +53 -0
- package/src/components/block/components/repeated-block.tsx +37 -0
- package/src/components/block/types.ts +6 -0
- package/src/components/blocks/blocks-wrapper.tsx +93 -0
- package/src/components/blocks/blocks.tsx +57 -0
- package/src/components/blocks/blocks.types.ts +7 -0
- package/src/components/blocks/index.ts +1 -0
- package/src/components/content/components/enable-editor.tsx +472 -0
- package/src/components/content/components/styles.helpers.ts +101 -0
- package/src/components/content/components/styles.tsx +42 -0
- package/src/components/content/content.helpers.ts +40 -0
- package/src/components/content/content.tsx +150 -0
- package/src/components/content/content.types.ts +13 -0
- package/src/components/content/contentProps.types.ts +17 -0
- package/src/components/content/index.ts +1 -0
- package/src/components/content/wrap-component-ref.ts +6 -0
- package/src/components/content-variants/content-variants.tsx +146 -0
- package/src/components/content-variants/content-variants.types.ts +84 -0
- package/src/components/content-variants/helpers.ts +72 -0
- package/src/components/content-variants/index.ts +1 -0
- package/src/components/content-variants/inlined-fns.ts +22 -0
- package/src/components/dynamic-div.tsx +30 -0
- package/src/components/dynamic-renderer/dynamic-renderer.helpers.ts +7 -0
- package/src/components/dynamic-renderer/dynamic-renderer.tsx +47 -0
- package/src/components/error-boundary.tsx +38 -0
- package/src/components/inlined-script.tsx +10 -0
- package/src/components/inlined-styles.tsx +10 -0
- package/src/constants/builder-registered-components.ts +59 -0
- package/src/constants/device-sizes.ts +59 -0
- package/src/constants/extra-components.ts +1 -0
- package/src/constants/sdk-version.ts +1 -0
- package/src/constants/target.ts +3 -0
- package/src/context/builder.context.ts +15 -0
- package/src/context/components.context.ts +3 -0
- package/src/context/index.ts +1 -0
- package/src/context/types.ts +38 -0
- package/src/functions/apply-patch-with-mutation.ts +61 -0
- package/src/functions/camel-to-kebab-case.ts +1 -0
- package/src/functions/deopt.ts +6 -0
- package/src/functions/evaluate/browser-runtime/browser.ts +61 -0
- package/src/functions/evaluate/browser-runtime/index.ts +1 -0
- package/src/functions/evaluate/choose-eval.ts +23 -0
- package/src/functions/evaluate/edge-runtime/acorn-interpreter.ts +2891 -0
- package/src/functions/evaluate/edge-runtime/edge-runtime.ts +89 -0
- package/src/functions/evaluate/edge-runtime/index.ts +1 -0
- package/src/functions/evaluate/evaluate.ts +76 -0
- package/src/functions/evaluate/helpers.ts +56 -0
- package/src/functions/evaluate/index.ts +1 -0
- package/src/functions/evaluate/node-runtime/index.ts +1 -0
- package/src/functions/evaluate/node-runtime/init.ts +33 -0
- package/src/functions/evaluate/node-runtime/node-runtime.ts +176 -0
- package/src/functions/evaluate/node-runtime/safeDynamicRequire.ts +14 -0
- package/src/functions/evaluate/placeholder-runtime.ts +4 -0
- package/src/functions/evaluate/should-force-browser-runtime-in-node.ts +16 -0
- package/src/functions/event-handler-name.ts +4 -0
- package/src/functions/extract-text-styles.ts +24 -0
- package/src/functions/fast-clone.ts +4 -0
- package/src/functions/fetch-builder-props.ts +75 -0
- package/src/functions/get-block-actions-handler.ts +17 -0
- package/src/functions/get-block-actions.ts +35 -0
- package/src/functions/get-block-component-options.ts +7 -0
- package/src/functions/get-block-properties.ts +62 -0
- package/src/functions/get-builder-search-params/index.ts +33 -0
- package/src/functions/get-class-prop-name.ts +15 -0
- package/src/functions/get-content/generate-content-url.ts +88 -0
- package/src/functions/get-content/index.ts +99 -0
- package/src/functions/get-content/types.ts +157 -0
- package/src/functions/get-env.ts +5 -0
- package/src/functions/get-fetch.ts +11 -0
- package/src/functions/get-global-this.ts +16 -0
- package/src/functions/get-processed-block.ts +70 -0
- package/src/functions/get-style.ts +38 -0
- package/src/functions/get.ts +4 -0
- package/src/functions/is-browser.ts +3 -0
- package/src/functions/is-edge-runtime.ts +9 -0
- package/src/functions/is-editing.ts +8 -0
- package/src/functions/is-from-trusted-host.ts +11 -0
- package/src/functions/is-iframe.ts +4 -0
- package/src/functions/is-node-runtime.ts +8 -0
- package/src/functions/is-previewing.ts +16 -0
- package/src/functions/on-change.ts +29 -0
- package/src/functions/register-component.ts +30 -0
- package/src/functions/register.ts +44 -0
- package/src/functions/set-editor-settings.ts +15 -0
- package/src/functions/set.ts +14 -0
- package/src/functions/track/helpers.ts +51 -0
- package/src/functions/track/index.ts +131 -0
- package/src/functions/track/interaction.ts +63 -0
- package/src/functions/transform-block-properties.ts +33 -0
- package/src/functions/transform-block.ts +30 -0
- package/src/functions/transform-style-property.ts +296 -0
- package/src/helpers/ab-tests.ts +166 -0
- package/src/helpers/canTrack.ts +2 -0
- package/src/helpers/cookie.ts +109 -0
- package/src/helpers/css.ts +33 -0
- package/src/helpers/flatten.ts +41 -0
- package/src/helpers/localStorage.ts +36 -0
- package/src/helpers/logger.ts +7 -0
- package/src/helpers/nullable.ts +2 -0
- package/src/helpers/omit.ts +7 -0
- package/src/helpers/preview-lru-cache/get.ts +4 -0
- package/src/helpers/preview-lru-cache/helpers.ts +1 -0
- package/src/helpers/preview-lru-cache/init.ts +7 -0
- package/src/helpers/preview-lru-cache/set.ts +12 -0
- package/src/helpers/preview-lru-cache/types.ts +1 -0
- package/src/helpers/search/search.ts +18 -0
- package/src/helpers/sessionId.ts +37 -0
- package/src/helpers/subscribe-to-editor.ts +95 -0
- package/src/helpers/time.ts +2 -0
- package/src/helpers/url.ts +15 -0
- package/src/helpers/uuid.ts +17 -0
- package/src/helpers/visitorId.ts +37 -0
- package/src/index-helpers/blocks-exports.ts +16 -0
- package/src/index-helpers/top-of-file.ts +2 -0
- package/src/index.ts +15 -0
- package/src/scripts/init-editing.ts +119 -0
- package/src/server-index.ts +43 -0
- package/src/types/api-version.ts +2 -0
- package/src/types/builder-block.ts +89 -0
- package/src/types/builder-content.ts +47 -0
- package/src/types/builder-props.ts +12 -0
- package/src/types/can-track.ts +3 -0
- package/src/types/components.ts +119 -0
- package/src/types/deep-partial.ts +1 -0
- package/src/types/element.ts +57 -0
- package/src/types/enforced-partials.ts +19 -0
- package/src/types/input.ts +123 -0
- package/src/types/targets.ts +1 -0
- package/src/types/typescript.ts +9 -0
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import {
|
|
3
|
+
FlatList,
|
|
4
|
+
ScrollView,
|
|
5
|
+
View,
|
|
6
|
+
StyleSheet,
|
|
7
|
+
Image,
|
|
8
|
+
Text,
|
|
9
|
+
Pressable,
|
|
10
|
+
TextInput,
|
|
11
|
+
} from "react-native";
|
|
12
|
+
|
|
13
|
+
export type DropzoneProps = BuilderDataProps & {
|
|
14
|
+
name: string;
|
|
15
|
+
attributes: any;
|
|
16
|
+
};
|
|
17
|
+
import Blocks from "../../components/blocks/blocks";
|
|
18
|
+
import { deoptSignal } from "../../functions/deopt";
|
|
19
|
+
import type { BuilderBlock } from "../../types/builder-block";
|
|
20
|
+
import type { BuilderDataProps } from "../../types/builder-props";
|
|
21
|
+
|
|
22
|
+
function Slot(props: DropzoneProps) {
|
|
23
|
+
return (
|
|
24
|
+
<View
|
|
25
|
+
style={{
|
|
26
|
+
pointerEvents: "auto",
|
|
27
|
+
}}
|
|
28
|
+
{...(!props.builderContext.context?.symbolId && {
|
|
29
|
+
"builder-slot": props.name,
|
|
30
|
+
})}
|
|
31
|
+
>
|
|
32
|
+
<Blocks
|
|
33
|
+
parent={props.builderContext.context?.symbolId as string}
|
|
34
|
+
path={`symbol.data.${props.name}`}
|
|
35
|
+
context={props.builderContext}
|
|
36
|
+
blocks={props.builderContext.rootState?.[props.name] as BuilderBlock[]}
|
|
37
|
+
/>
|
|
38
|
+
</View>
|
|
39
|
+
);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export default Slot;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { ComponentInfo } from '../../types/components';
|
|
2
|
+
export const componentInfo: ComponentInfo = {
|
|
3
|
+
name: 'Symbol',
|
|
4
|
+
noWrap: true,
|
|
5
|
+
static: true,
|
|
6
|
+
isRSC: true,
|
|
7
|
+
inputs: [{
|
|
8
|
+
name: 'symbol',
|
|
9
|
+
type: 'uiSymbol'
|
|
10
|
+
}, {
|
|
11
|
+
name: 'dataOnly',
|
|
12
|
+
helperText: "Make this a data symbol that doesn't display any UI",
|
|
13
|
+
type: 'boolean',
|
|
14
|
+
defaultValue: false,
|
|
15
|
+
advanced: true,
|
|
16
|
+
hideFromUI: true
|
|
17
|
+
}, {
|
|
18
|
+
name: 'inheritState',
|
|
19
|
+
helperText: 'Inherit the parent component state and data',
|
|
20
|
+
type: 'boolean',
|
|
21
|
+
defaultValue: false,
|
|
22
|
+
advanced: true
|
|
23
|
+
}, {
|
|
24
|
+
name: 'renderToLiquid',
|
|
25
|
+
helperText: 'Render this symbols contents to liquid. Turn off to fetch with javascript and use custom targeting',
|
|
26
|
+
type: 'boolean',
|
|
27
|
+
defaultValue: false,
|
|
28
|
+
advanced: true,
|
|
29
|
+
hideFromUI: true
|
|
30
|
+
}, {
|
|
31
|
+
name: 'useChildren',
|
|
32
|
+
hideFromUI: true,
|
|
33
|
+
type: 'boolean'
|
|
34
|
+
}]
|
|
35
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './symbol'
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type { BuilderContextInterface } from '../../context/types';
|
|
2
|
+
import { fetchOneEntry } from '../../functions/get-content/index';
|
|
3
|
+
import { logger } from '../../helpers/logger';
|
|
4
|
+
import type { BuilderContent } from '../../types/builder-content';
|
|
5
|
+
export interface SymbolInfo {
|
|
6
|
+
model?: string;
|
|
7
|
+
entry?: string;
|
|
8
|
+
data?: any;
|
|
9
|
+
content?: BuilderContent;
|
|
10
|
+
inline?: boolean;
|
|
11
|
+
dynamic?: boolean;
|
|
12
|
+
}
|
|
13
|
+
export const fetchSymbolContent = async ({
|
|
14
|
+
builderContextValue,
|
|
15
|
+
symbol
|
|
16
|
+
}: {
|
|
17
|
+
symbol: SymbolInfo | undefined;
|
|
18
|
+
builderContextValue: BuilderContextInterface;
|
|
19
|
+
}) => {
|
|
20
|
+
/**
|
|
21
|
+
* If:
|
|
22
|
+
* - we have a symbol prop
|
|
23
|
+
* - yet it does not have any content
|
|
24
|
+
* - and we have not already stored content from before
|
|
25
|
+
* - and it has a model name
|
|
26
|
+
*
|
|
27
|
+
* then we want to re-fetch the symbol content.
|
|
28
|
+
*/
|
|
29
|
+
if (symbol?.model &&
|
|
30
|
+
// This is a hack, we should not need to check for this, but it is needed for Svelte.
|
|
31
|
+
builderContextValue?.apiKey) {
|
|
32
|
+
return fetchOneEntry({
|
|
33
|
+
model: symbol.model,
|
|
34
|
+
apiKey: builderContextValue.apiKey,
|
|
35
|
+
apiVersion: builderContextValue.apiVersion,
|
|
36
|
+
...(symbol?.entry && {
|
|
37
|
+
query: {
|
|
38
|
+
id: symbol.entry
|
|
39
|
+
}
|
|
40
|
+
})
|
|
41
|
+
}).catch(err => {
|
|
42
|
+
logger.error('Could not fetch symbol content: ', err);
|
|
43
|
+
return undefined;
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
return undefined;
|
|
47
|
+
}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import {
|
|
3
|
+
FlatList,
|
|
4
|
+
ScrollView,
|
|
5
|
+
View,
|
|
6
|
+
StyleSheet,
|
|
7
|
+
Image,
|
|
8
|
+
Text,
|
|
9
|
+
Pressable,
|
|
10
|
+
TextInput,
|
|
11
|
+
} from "react-native";
|
|
12
|
+
import { useState, useEffect } from "react";
|
|
13
|
+
import ContentVariants from "../../components/content-variants/index";
|
|
14
|
+
import type { BuilderContent } from "../../types/builder-content";
|
|
15
|
+
import { filterAttrs } from "../helpers";
|
|
16
|
+
import DynamicDiv from "../../components/dynamic-div";
|
|
17
|
+
import { getClassPropName } from "../../functions/get-class-prop-name";
|
|
18
|
+
import type { Nullable } from "../../types/typescript";
|
|
19
|
+
import { setAttrs } from "../helpers";
|
|
20
|
+
import { fetchSymbolContent } from "./symbol.helpers";
|
|
21
|
+
import type { SymbolProps } from "./symbol.types";
|
|
22
|
+
|
|
23
|
+
function Symbol(props: SymbolProps) {
|
|
24
|
+
function blocksWrapper() {
|
|
25
|
+
return View;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function contentWrapper() {
|
|
29
|
+
return View;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function className() {
|
|
33
|
+
return [
|
|
34
|
+
...[],
|
|
35
|
+
"builder-symbol",
|
|
36
|
+
props.symbol?.inline ? "builder-inline-symbol" : undefined,
|
|
37
|
+
props.symbol?.dynamic || props.dynamic
|
|
38
|
+
? "builder-dynamic-symbol"
|
|
39
|
+
: undefined,
|
|
40
|
+
]
|
|
41
|
+
.filter(Boolean)
|
|
42
|
+
.join(" ");
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const [contentToUse, setContentToUse] = useState(() => props.symbol?.content);
|
|
46
|
+
|
|
47
|
+
function setContent() {
|
|
48
|
+
if (contentToUse) return;
|
|
49
|
+
fetchSymbolContent({
|
|
50
|
+
symbol: props.symbol,
|
|
51
|
+
builderContextValue: props.builderContext,
|
|
52
|
+
}).then((newContent) => {
|
|
53
|
+
if (newContent) {
|
|
54
|
+
setContentToUse(newContent);
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
useEffect(() => {}, []);
|
|
60
|
+
|
|
61
|
+
useEffect(() => {
|
|
62
|
+
setContent();
|
|
63
|
+
}, [props.symbol]);
|
|
64
|
+
|
|
65
|
+
return (
|
|
66
|
+
<View
|
|
67
|
+
{...{}}
|
|
68
|
+
{...props.attributes}
|
|
69
|
+
{...{
|
|
70
|
+
dataSet: {
|
|
71
|
+
class: className(),
|
|
72
|
+
},
|
|
73
|
+
}}
|
|
74
|
+
>
|
|
75
|
+
<ContentVariants
|
|
76
|
+
isNestedRender
|
|
77
|
+
apiVersion={props.builderContext.apiVersion}
|
|
78
|
+
apiKey={props.builderContext.apiKey!}
|
|
79
|
+
context={{
|
|
80
|
+
...props.builderContext.context,
|
|
81
|
+
symbolId: props.builderBlock?.id,
|
|
82
|
+
}}
|
|
83
|
+
customComponents={Object.values(props.builderComponents)}
|
|
84
|
+
data={{
|
|
85
|
+
...props.symbol?.data,
|
|
86
|
+
...props.builderContext.localState,
|
|
87
|
+
...contentToUse?.data?.state,
|
|
88
|
+
}}
|
|
89
|
+
canTrack={props.builderContext.canTrack}
|
|
90
|
+
model={props.symbol?.model}
|
|
91
|
+
content={contentToUse}
|
|
92
|
+
linkComponent={props.builderLinkComponent}
|
|
93
|
+
blocksWrapper={blocksWrapper()}
|
|
94
|
+
contentWrapper={contentWrapper()}
|
|
95
|
+
/>
|
|
96
|
+
</View>
|
|
97
|
+
);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
export default Symbol;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { BuilderContent } from '../../types/builder-content';
|
|
2
|
+
import type { BuilderComponentsProp, BuilderDataProps, BuilderLinkComponentProp } from '../../types/builder-props';
|
|
3
|
+
interface SymbolInfo {
|
|
4
|
+
model?: string;
|
|
5
|
+
entry?: string;
|
|
6
|
+
data?: any;
|
|
7
|
+
content?: BuilderContent;
|
|
8
|
+
inline?: boolean;
|
|
9
|
+
dynamic?: boolean;
|
|
10
|
+
}
|
|
11
|
+
export interface SymbolProps extends BuilderComponentsProp, BuilderDataProps, BuilderLinkComponentProp {
|
|
12
|
+
symbol?: SymbolInfo;
|
|
13
|
+
dataOnly?: boolean;
|
|
14
|
+
dynamic?: boolean;
|
|
15
|
+
attributes?: any;
|
|
16
|
+
inheritState?: boolean;
|
|
17
|
+
}
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import type { ComponentInfo } from '../../types/components';
|
|
2
|
+
const defaultTab = {
|
|
3
|
+
'@type': '@builder.io/sdk:Element',
|
|
4
|
+
responsiveStyles: {
|
|
5
|
+
large: {
|
|
6
|
+
paddingLeft: '20px',
|
|
7
|
+
paddingRight: '20px',
|
|
8
|
+
paddingTop: '10px',
|
|
9
|
+
paddingBottom: '10px',
|
|
10
|
+
minWidth: '100px',
|
|
11
|
+
textAlign: 'center',
|
|
12
|
+
display: 'flex',
|
|
13
|
+
flexDirection: 'column',
|
|
14
|
+
cursor: 'pointer',
|
|
15
|
+
userSelect: 'none'
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
component: {
|
|
19
|
+
name: 'Text',
|
|
20
|
+
options: {
|
|
21
|
+
text: 'New tab'
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
const defaultElement = {
|
|
26
|
+
'@type': '@builder.io/sdk:Element',
|
|
27
|
+
responsiveStyles: {
|
|
28
|
+
large: {
|
|
29
|
+
height: '200px',
|
|
30
|
+
display: 'flex',
|
|
31
|
+
marginTop: '20px',
|
|
32
|
+
flexDirection: 'column'
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
component: {
|
|
36
|
+
name: 'Text',
|
|
37
|
+
options: {
|
|
38
|
+
text: 'New tab content '
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
export const componentInfo: ComponentInfo = {
|
|
43
|
+
name: 'Builder: Tabs',
|
|
44
|
+
inputs: [{
|
|
45
|
+
name: 'tabs',
|
|
46
|
+
type: 'list',
|
|
47
|
+
broadcast: true,
|
|
48
|
+
subFields: [{
|
|
49
|
+
name: 'label',
|
|
50
|
+
type: 'uiBlocks',
|
|
51
|
+
hideFromUI: true,
|
|
52
|
+
defaultValue: [defaultTab]
|
|
53
|
+
}, {
|
|
54
|
+
name: 'content',
|
|
55
|
+
type: 'uiBlocks',
|
|
56
|
+
hideFromUI: true,
|
|
57
|
+
defaultValue: [defaultElement]
|
|
58
|
+
}],
|
|
59
|
+
defaultValue: [{
|
|
60
|
+
label: [{
|
|
61
|
+
...defaultTab,
|
|
62
|
+
component: {
|
|
63
|
+
name: 'Text',
|
|
64
|
+
options: {
|
|
65
|
+
text: 'Tab 1'
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}],
|
|
69
|
+
content: [{
|
|
70
|
+
...defaultElement,
|
|
71
|
+
component: {
|
|
72
|
+
name: 'Text',
|
|
73
|
+
options: {
|
|
74
|
+
text: 'Tab 1 content'
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}]
|
|
78
|
+
}, {
|
|
79
|
+
label: [{
|
|
80
|
+
...defaultTab,
|
|
81
|
+
component: {
|
|
82
|
+
name: 'Text',
|
|
83
|
+
options: {
|
|
84
|
+
text: 'Tab 2'
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}],
|
|
88
|
+
content: [{
|
|
89
|
+
...defaultElement,
|
|
90
|
+
component: {
|
|
91
|
+
name: 'Text',
|
|
92
|
+
options: {
|
|
93
|
+
text: 'Tab 2 content'
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}]
|
|
97
|
+
}]
|
|
98
|
+
}, {
|
|
99
|
+
name: 'activeTabStyle',
|
|
100
|
+
type: 'uiStyle',
|
|
101
|
+
helperText: 'CSS styles for the active tab',
|
|
102
|
+
defaultValue: {
|
|
103
|
+
backgroundColor: 'rgba(0, 0, 0, 0.1)'
|
|
104
|
+
}
|
|
105
|
+
}, {
|
|
106
|
+
name: 'defaultActiveTab',
|
|
107
|
+
type: 'number',
|
|
108
|
+
helperText: 'Default tab to open to. Set to "1" for the first tab, "2" for the second, or choose "0" for none',
|
|
109
|
+
defaultValue: 1,
|
|
110
|
+
advanced: true
|
|
111
|
+
}, {
|
|
112
|
+
name: 'collapsible',
|
|
113
|
+
type: 'boolean',
|
|
114
|
+
helperText: 'If on, clicking an open tab closes it so no tabs are active',
|
|
115
|
+
defaultValue: false,
|
|
116
|
+
advanced: true
|
|
117
|
+
}, {
|
|
118
|
+
name: 'tabHeaderLayout',
|
|
119
|
+
type: 'enum',
|
|
120
|
+
helperText: 'Change the layout of the tab headers (uses justify-content)',
|
|
121
|
+
defaultValue: 'flex-start',
|
|
122
|
+
enum: [{
|
|
123
|
+
label: 'Center',
|
|
124
|
+
value: 'center'
|
|
125
|
+
}, {
|
|
126
|
+
label: 'Space between',
|
|
127
|
+
value: 'space-between'
|
|
128
|
+
}, {
|
|
129
|
+
label: 'Space around',
|
|
130
|
+
value: 'space-around'
|
|
131
|
+
}, {
|
|
132
|
+
label: 'Left',
|
|
133
|
+
value: 'flex-start'
|
|
134
|
+
}, {
|
|
135
|
+
label: 'Right',
|
|
136
|
+
value: 'flex-end'
|
|
137
|
+
}]
|
|
138
|
+
}]
|
|
139
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './tabs'
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import {
|
|
3
|
+
FlatList,
|
|
4
|
+
ScrollView,
|
|
5
|
+
View,
|
|
6
|
+
StyleSheet,
|
|
7
|
+
Image,
|
|
8
|
+
Text,
|
|
9
|
+
Pressable,
|
|
10
|
+
TextInput,
|
|
11
|
+
} from "react-native";
|
|
12
|
+
import { useState } from "react";
|
|
13
|
+
import Blocks from "../../components/blocks/blocks";
|
|
14
|
+
import type { BuilderBlock } from "../../types/builder-block";
|
|
15
|
+
import type { TabsProps } from "./tabs.types";
|
|
16
|
+
|
|
17
|
+
function Tabs(props: TabsProps) {
|
|
18
|
+
const [activeTab, setActiveTab] = useState(() =>
|
|
19
|
+
props.defaultActiveTab ? props.defaultActiveTab - 1 : 0
|
|
20
|
+
);
|
|
21
|
+
|
|
22
|
+
function activeTabContent(active: number) {
|
|
23
|
+
return props.tabs && props.tabs[active].content;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function onClick(index: number) {
|
|
27
|
+
if (index === activeTab && props.collapsible) {
|
|
28
|
+
setActiveTab(-1);
|
|
29
|
+
} else {
|
|
30
|
+
setActiveTab(index);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
return (
|
|
35
|
+
<View>
|
|
36
|
+
<View
|
|
37
|
+
style={{
|
|
38
|
+
display: "flex",
|
|
39
|
+
flexDirection: "row" as "row" | "column" | "column-reverse",
|
|
40
|
+
justifyContent: props.tabHeaderLayout || "flex-start",
|
|
41
|
+
overflow: "scroll" as "scroll" | "visible" | "hidden",
|
|
42
|
+
}}
|
|
43
|
+
>
|
|
44
|
+
{props.tabs?.map((tab, index) => (
|
|
45
|
+
<Pressable
|
|
46
|
+
key={index}
|
|
47
|
+
style={{
|
|
48
|
+
...(activeTab === index ? props.activeTabStyle : {}),
|
|
49
|
+
}}
|
|
50
|
+
onPress={(event) => onClick(index)}
|
|
51
|
+
>
|
|
52
|
+
<Blocks
|
|
53
|
+
parent={props.builderBlock.id}
|
|
54
|
+
path={`component.options.tabs.${index}.label`}
|
|
55
|
+
blocks={tab.label}
|
|
56
|
+
context={props.builderContext}
|
|
57
|
+
registeredComponents={props.builderComponents}
|
|
58
|
+
linkComponent={props.builderLinkComponent}
|
|
59
|
+
/>
|
|
60
|
+
</Pressable>
|
|
61
|
+
))}
|
|
62
|
+
</View>
|
|
63
|
+
{activeTabContent(activeTab) ? (
|
|
64
|
+
<View>
|
|
65
|
+
<Blocks
|
|
66
|
+
parent={props.builderBlock.id}
|
|
67
|
+
path={`component.options.tabs.${activeTab}.content`}
|
|
68
|
+
blocks={activeTabContent(activeTab)}
|
|
69
|
+
context={props.builderContext}
|
|
70
|
+
registeredComponents={props.builderComponents}
|
|
71
|
+
linkComponent={props.builderLinkComponent}
|
|
72
|
+
/>
|
|
73
|
+
</View>
|
|
74
|
+
) : null}
|
|
75
|
+
</View>
|
|
76
|
+
);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
export default Tabs;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { BuilderBlock } from '../../types/builder-block';
|
|
2
|
+
import type { BuilderComponentsProp, BuilderDataProps, BuilderLinkComponentProp } from '../../types/builder-props';
|
|
3
|
+
export interface TabsProps extends BuilderComponentsProp, BuilderLinkComponentProp, BuilderDataProps {
|
|
4
|
+
tabs: {
|
|
5
|
+
label: BuilderBlock[];
|
|
6
|
+
content: BuilderBlock[];
|
|
7
|
+
}[];
|
|
8
|
+
builderBlock: BuilderBlock;
|
|
9
|
+
defaultActiveTab?: number;
|
|
10
|
+
collapsible?: boolean;
|
|
11
|
+
tabHeaderLayout?: 'center' | 'flex-start' | 'flex-end' | 'space-between' | 'space-around' | 'space-evenly';
|
|
12
|
+
activeTabStyle?: any;
|
|
13
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { ComponentInfo } from '../../types/components';
|
|
2
|
+
export const componentInfo: ComponentInfo = {
|
|
3
|
+
name: 'Text',
|
|
4
|
+
static: true,
|
|
5
|
+
isRSC: true,
|
|
6
|
+
image: 'https://firebasestorage.googleapis.com/v0/b/builder-3b0a2.appspot.com/o/images%2Fbaseline-text_fields-24px%20(1).svg?alt=media&token=12177b73-0ee3-42ca-98c6-0dd003de1929',
|
|
7
|
+
inputs: [{
|
|
8
|
+
name: 'text',
|
|
9
|
+
type: 'html',
|
|
10
|
+
required: true,
|
|
11
|
+
autoFocus: true,
|
|
12
|
+
bubble: true,
|
|
13
|
+
defaultValue: 'Enter some text...'
|
|
14
|
+
}],
|
|
15
|
+
defaultStyles: {
|
|
16
|
+
lineHeight: 'normal',
|
|
17
|
+
height: 'auto',
|
|
18
|
+
textAlign: 'center'
|
|
19
|
+
}
|
|
20
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './text'
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { useWindowDimensions } from 'react-native';
|
|
3
|
+
import { RenderHTML } from '@builder.io/react-native-render-html';
|
|
4
|
+
import BuilderContext from '../../context/builder.context';
|
|
5
|
+
import { checkIsDefined } from '../../helpers/nullable';
|
|
6
|
+
/**
|
|
7
|
+
* @typedef {{}} BuilderBlock
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
*
|
|
12
|
+
* @param {string} string
|
|
13
|
+
* @returns {string}
|
|
14
|
+
*/
|
|
15
|
+
function camelToKebabCase(string) {
|
|
16
|
+
return string.replace(/([a-z0-9]|(?=[A-Z]))([A-Z])/g, '$1-$2').toLowerCase();
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
*
|
|
21
|
+
* @param {object} object
|
|
22
|
+
* @param {string[]} keys
|
|
23
|
+
* @returns {object}
|
|
24
|
+
*/
|
|
25
|
+
function pick(object, keys) {
|
|
26
|
+
return keys.reduce((obj, key) => {
|
|
27
|
+
// eslint-disable-next-line no-prototype-builtins
|
|
28
|
+
if (object && object.hasOwnProperty(key)) {
|
|
29
|
+
obj[key] = object[key];
|
|
30
|
+
}
|
|
31
|
+
return obj;
|
|
32
|
+
}, {});
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const PICK_STYLES = ['textAlign'];
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* @param {BuilderBlock} block
|
|
39
|
+
* @returns
|
|
40
|
+
*/
|
|
41
|
+
function getBlockStyles(block) {
|
|
42
|
+
// TODO: responsive CSS using react native viewport width hooks
|
|
43
|
+
const styles = {
|
|
44
|
+
...block.responsiveStyles?.large,
|
|
45
|
+
...block.styles,
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
if (block.responsiveStyles?.medium) {
|
|
49
|
+
Object.assign(styles, block.responsiveStyles.medium);
|
|
50
|
+
}
|
|
51
|
+
if (block.responsiveStyles?.small) {
|
|
52
|
+
Object.assign(styles, block.responsiveStyles.small);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
return styles;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
*
|
|
60
|
+
* @param {BuilderBlock} block
|
|
61
|
+
* @param {any} inheritedStyles
|
|
62
|
+
* @returns
|
|
63
|
+
*/
|
|
64
|
+
function getCss(block, inheritedStyles) {
|
|
65
|
+
const styleObject = {
|
|
66
|
+
...inheritedStyles,
|
|
67
|
+
...pick(getBlockStyles(block), PICK_STYLES),
|
|
68
|
+
};
|
|
69
|
+
if (!styleObject) {
|
|
70
|
+
return '';
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
let str = ``;
|
|
74
|
+
|
|
75
|
+
for (const key in styleObject) {
|
|
76
|
+
const value = styleObject[key];
|
|
77
|
+
if (typeof value === 'string') {
|
|
78
|
+
str += `${camelToKebabCase(key)}: ${value};`;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
return str;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
*
|
|
87
|
+
* @param {{ text: string; builderBlock: BuilderBlock}} props
|
|
88
|
+
* @returns
|
|
89
|
+
*/
|
|
90
|
+
export default function Text(props) {
|
|
91
|
+
const { width } = useWindowDimensions();
|
|
92
|
+
const builderContext = React.useContext(BuilderContext);
|
|
93
|
+
|
|
94
|
+
return (
|
|
95
|
+
<RenderHTML
|
|
96
|
+
contentWidth={width}
|
|
97
|
+
source={{
|
|
98
|
+
html: `<div style="${getCss(
|
|
99
|
+
props.builderBlock,
|
|
100
|
+
builderContext.inheritedStyles
|
|
101
|
+
)}">${checkIsDefined(props.text) ? String(props.text) : ''}</div>`,
|
|
102
|
+
}}
|
|
103
|
+
/>
|
|
104
|
+
);
|
|
105
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { ComponentInfo } from '../../types/components';
|
|
2
|
+
export const componentInfo: ComponentInfo = {
|
|
3
|
+
name: 'Form:TextArea',
|
|
4
|
+
image: 'https://cdn.builder.io/api/v1/image/assets%2FIsxPKMo2gPRRKeakUztj1D6uqed2%2Ff74a2f3de58c4c3e939204e5b6b8f6c3',
|
|
5
|
+
inputs: [{
|
|
6
|
+
advanced: true,
|
|
7
|
+
name: 'value',
|
|
8
|
+
type: 'string'
|
|
9
|
+
}, {
|
|
10
|
+
name: 'name',
|
|
11
|
+
type: 'string',
|
|
12
|
+
required: true,
|
|
13
|
+
helperText: 'Every input in a form needs a unique name describing what it gets, e.g. "email"'
|
|
14
|
+
}, {
|
|
15
|
+
name: 'defaultValue',
|
|
16
|
+
type: 'string'
|
|
17
|
+
}, {
|
|
18
|
+
name: 'placeholder',
|
|
19
|
+
type: 'string',
|
|
20
|
+
defaultValue: 'Hello there'
|
|
21
|
+
}, {
|
|
22
|
+
name: 'required',
|
|
23
|
+
type: 'boolean',
|
|
24
|
+
defaultValue: false
|
|
25
|
+
}],
|
|
26
|
+
defaultStyles: {
|
|
27
|
+
paddingTop: '10px',
|
|
28
|
+
paddingBottom: '10px',
|
|
29
|
+
paddingLeft: '10px',
|
|
30
|
+
paddingRight: '10px',
|
|
31
|
+
borderRadius: '3px',
|
|
32
|
+
borderWidth: '1px',
|
|
33
|
+
borderStyle: 'solid',
|
|
34
|
+
borderColor: '#ccc'
|
|
35
|
+
},
|
|
36
|
+
static: true,
|
|
37
|
+
noWrap: true
|
|
38
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './textarea'
|