@builder.io/sdk-react 0.1.3 → 0.1.5
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/dist/react/blocks/button/button.js +2 -2
- package/dist/react/blocks/columns/columns.js +6 -6
- package/dist/react/blocks/form/form.js +4 -4
- package/dist/react/blocks/image/image.js +6 -6
- package/dist/react/blocks/symbol/symbol.js +1 -1
- package/dist/react/components/render-block/block-styles.js +1 -1
- package/dist/react/components/render-block/render-block.js +21 -4
- package/dist/react/components/render-block/render-component.js +2 -2
- package/dist/react/components/render-block/render-repeated-block.js +2 -1
- package/dist/react/components/render-blocks.js +4 -4
- package/dist/react/components/render-content/components/render-styles.helpers.js +51 -0
- package/dist/react/components/render-content/components/render-styles.js +13 -55
- package/dist/react/components/render-content/index.js +1 -1
- package/dist/react/components/render-content/render-content.helpers.js +38 -0
- package/dist/react/components/render-content/render-content.js +67 -64
- package/dist/react/components/render-content/render-content.types.js +1 -0
- package/dist/react/components/render-inlined-styles.js +2 -2
- package/dist/react/constants/builder-registered-components.js +18 -18
- package/dist/react/context/builder.context.js +2 -0
- package/dist/react/index-helpers/blocks-exports.js +11 -11
- package/dist/react/types/input.js +1 -0
- package/dist/rsc/blocks/button/button.js +2 -2
- package/dist/rsc/blocks/columns/columns.js +6 -6
- package/dist/rsc/blocks/form/form.js +4 -4
- package/dist/rsc/blocks/image/image.js +6 -6
- package/dist/rsc/blocks/symbol/symbol.js +1 -1
- package/dist/rsc/components/render-block/block-styles.js +1 -1
- package/dist/rsc/components/render-block/render-block.js +21 -4
- package/dist/rsc/components/render-block/render-component.js +2 -2
- package/dist/rsc/components/render-block/render-repeated-block.js +2 -1
- package/dist/rsc/components/render-blocks.js +4 -4
- package/dist/rsc/components/render-content/builder-editing.js +47 -4
- package/dist/rsc/components/render-content/components/render-styles.helpers.js +51 -0
- package/dist/rsc/components/render-content/components/render-styles.js +12 -55
- package/dist/rsc/components/render-content/index.js +1 -1
- package/dist/rsc/components/render-content/render-content.helpers.js +38 -0
- package/dist/rsc/components/render-content/render-content.js +45 -40
- package/dist/rsc/components/render-content/render-content.types.js +1 -0
- package/dist/rsc/components/render-inlined-styles.js +2 -2
- package/dist/rsc/constants/builder-registered-components.js +18 -18
- package/dist/rsc/context/builder.context.js +2 -0
- package/dist/rsc/index-helpers/blocks-exports.js +11 -11
- package/dist/rsc/types/input.js +1 -0
- package/package.json +1 -1
- package/packages/react/src/blocks/button/button.jsx +2 -2
- package/packages/react/src/blocks/columns/columns.jsx +6 -6
- package/packages/react/src/blocks/form/form.jsx +4 -4
- package/packages/react/src/blocks/image/image.jsx +6 -6
- package/packages/react/src/blocks/symbol/symbol.jsx +1 -1
- package/packages/react/src/components/render-block/block-styles.jsx +1 -1
- package/packages/react/src/components/render-block/render-block.jsx +25 -4
- package/packages/react/src/components/render-block/render-component.jsx +2 -2
- package/packages/react/src/components/render-block/render-repeated-block.jsx +2 -1
- package/packages/react/src/components/render-blocks.jsx +4 -4
- package/packages/react/src/components/render-content/components/render-styles.helpers.js +57 -0
- package/packages/react/src/components/render-content/components/render-styles.jsx +14 -57
- package/packages/react/src/components/render-content/index.js +1 -1
- package/packages/react/src/components/render-content/render-content.helpers.js +48 -0
- package/packages/react/src/components/render-content/render-content.jsx +78 -69
- package/packages/{_rsc/src/components/render-block/types.js → react/src/components/render-content/render-content.types.js} +0 -0
- package/packages/react/src/components/render-inlined-styles.jsx +2 -2
- package/packages/react/src/constants/builder-registered-components.js +18 -18
- package/packages/react/src/context/builder.context.js +2 -0
- package/packages/react/src/index-helpers/blocks-exports.js +19 -19
- package/packages/{_rsc/src/context/types.js → react/src/types/input.js} +0 -0
- package/packages/rsc/src/blocks/button/button.jsx +2 -2
- package/packages/rsc/src/blocks/columns/columns.jsx +6 -6
- package/packages/rsc/src/blocks/form/form.jsx +4 -4
- package/packages/rsc/src/blocks/image/image.jsx +6 -6
- package/packages/rsc/src/blocks/symbol/symbol.jsx +1 -1
- package/packages/rsc/src/components/render-block/block-styles.jsx +1 -1
- package/packages/rsc/src/components/render-block/render-block.jsx +24 -4
- package/packages/rsc/src/components/render-block/render-component.jsx +2 -2
- package/packages/rsc/src/components/render-block/render-repeated-block.jsx +2 -1
- package/packages/rsc/src/components/render-blocks.jsx +4 -4
- package/packages/rsc/src/components/render-content/builder-editing.jsx +61 -4
- package/packages/rsc/src/components/render-content/components/render-styles.helpers.js +57 -0
- package/packages/rsc/src/components/render-content/components/render-styles.jsx +11 -57
- package/packages/rsc/src/components/render-content/index.js +1 -1
- package/packages/rsc/src/components/render-content/render-content.helpers.js +48 -0
- package/packages/rsc/src/components/render-content/render-content.jsx +48 -39
- package/packages/{_rsc/src/functions/get-content/types.js → rsc/src/components/render-content/render-content.types.js} +0 -0
- package/packages/rsc/src/components/render-inlined-styles.jsx +2 -4
- package/packages/rsc/src/constants/builder-registered-components.js +18 -18
- package/packages/rsc/src/context/builder.context.js +2 -0
- package/packages/rsc/src/index-helpers/blocks-exports.js +19 -19
- package/packages/{_rsc/src/types/builder-block.js → rsc/src/types/input.js} +0 -0
- package/packages/_rsc/src/blocks/BaseText.jsx +0 -10
- package/packages/_rsc/src/blocks/button/button.jsx +0 -29
- package/packages/_rsc/src/blocks/button/component-info.js +0 -41
- package/packages/_rsc/src/blocks/columns/columns.jsx +0 -172
- package/packages/_rsc/src/blocks/columns/component-info.js +0 -242
- package/packages/_rsc/src/blocks/custom-code/component-info.js +0 -31
- package/packages/_rsc/src/blocks/custom-code/custom-code.jsx +0 -55
- package/packages/_rsc/src/blocks/embed/component-info.js +0 -44
- package/packages/_rsc/src/blocks/embed/embed.jsx +0 -43
- package/packages/_rsc/src/blocks/embed/helpers.js +0 -9
- package/packages/_rsc/src/blocks/form/component-info.js +0 -262
- package/packages/_rsc/src/blocks/form/form.jsx +0 -259
- package/packages/_rsc/src/blocks/fragment/component-info.js +0 -11
- package/packages/_rsc/src/blocks/fragment/fragment.jsx +0 -7
- package/packages/_rsc/src/blocks/image/component-info.js +0 -151
- package/packages/_rsc/src/blocks/image/image.helpers.js +0 -48
- package/packages/_rsc/src/blocks/image/image.jsx +0 -124
- package/packages/_rsc/src/blocks/img/component-info.js +0 -20
- package/packages/_rsc/src/blocks/img/img.jsx +0 -19
- package/packages/_rsc/src/blocks/input/component-info.js +0 -74
- package/packages/_rsc/src/blocks/input/input.jsx +0 -21
- package/packages/_rsc/src/blocks/raw-text/component-info.js +0 -16
- package/packages/_rsc/src/blocks/raw-text/raw-text.jsx +0 -12
- package/packages/_rsc/src/blocks/section/component-info.js +0 -49
- package/packages/_rsc/src/blocks/section/section.jsx +0 -29
- package/packages/_rsc/src/blocks/select/component-info.js +0 -59
- package/packages/_rsc/src/blocks/select/select.jsx +0 -22
- package/packages/_rsc/src/blocks/submit-button/component-info.js +0 -28
- package/packages/_rsc/src/blocks/submit-button/submit-button.jsx +0 -11
- package/packages/_rsc/src/blocks/symbol/component-info.js +0 -43
- package/packages/_rsc/src/blocks/symbol/symbol.jsx +0 -56
- package/packages/_rsc/src/blocks/text/component-info.js +0 -24
- package/packages/_rsc/src/blocks/text/text.jsx +0 -12
- package/packages/_rsc/src/blocks/textarea/component-info.js +0 -47
- package/packages/_rsc/src/blocks/textarea/textarea.jsx +0 -15
- package/packages/_rsc/src/blocks/util.js +0 -8
- package/packages/_rsc/src/blocks/video/component-info.js +0 -106
- package/packages/_rsc/src/blocks/video/video.jsx +0 -61
- package/packages/_rsc/src/components/render-block/block-styles.jsx +0 -72
- package/packages/_rsc/src/components/render-block/render-block.helpers.js +0 -23
- package/packages/_rsc/src/components/render-block/render-block.jsx +0 -251
- package/packages/_rsc/src/components/render-block/render-component-with-context.jsx +0 -38
- package/packages/_rsc/src/components/render-block/render-component.jsx +0 -37
- package/packages/_rsc/src/components/render-block/render-repeated-block.jsx +0 -36
- package/packages/_rsc/src/components/render-blocks.jsx +0 -90
- package/packages/_rsc/src/components/render-content/builder-editing.jsx +0 -7
- package/packages/_rsc/src/components/render-content/components/render-styles.jsx +0 -70
- package/packages/_rsc/src/components/render-content/index.js +0 -4
- package/packages/_rsc/src/components/render-content/render-content.jsx +0 -259
- package/packages/_rsc/src/components/render-inlined-styles.jsx +0 -33
- package/packages/_rsc/src/constants/builder-registered-components.js +0 -54
- package/packages/_rsc/src/constants/device-sizes.js +0 -48
- package/packages/_rsc/src/constants/target.js +0 -4
- package/packages/_rsc/src/context/builder.context.js +0 -11
- package/packages/_rsc/src/functions/camel-to-kebab-case.js +0 -4
- package/packages/_rsc/src/functions/evaluate.js +0 -6
- package/packages/_rsc/src/functions/event-handler-name.js +0 -7
- package/packages/_rsc/src/functions/extract-text-styles.js +0 -22
- package/packages/_rsc/src/functions/fast-clone.js +0 -4
- package/packages/_rsc/src/functions/get-block-actions-handler.js +0 -11
- package/packages/_rsc/src/functions/get-block-actions.js +0 -18
- package/packages/_rsc/src/functions/get-block-component-options.js +0 -28
- package/packages/_rsc/src/functions/get-block-properties.js +0 -50
- package/packages/_rsc/src/functions/get-block-tag.js +0 -6
- package/packages/_rsc/src/functions/get-builder-search-params/fn.test.js +0 -13
- package/packages/_rsc/src/functions/get-builder-search-params/index.js +0 -38
- package/packages/_rsc/src/functions/get-content/ab-testing.js +0 -99
- package/packages/_rsc/src/functions/get-content/generate-content-url.js +0 -55
- package/packages/_rsc/src/functions/get-content/generate-content-url.test.js +0 -31
- package/packages/_rsc/src/functions/get-content/index.js +0 -65
- package/packages/_rsc/src/functions/get-fetch.js +0 -14
- package/packages/_rsc/src/functions/get-global-this.js +0 -18
- package/packages/_rsc/src/functions/get-processed-block.js +0 -59
- package/packages/_rsc/src/functions/get-processed-block.test.js +0 -32
- package/packages/_rsc/src/functions/get-react-native-block-styles.js +0 -33
- package/packages/_rsc/src/functions/if-target.js +0 -15
- package/packages/_rsc/src/functions/is-browser.js +0 -6
- package/packages/_rsc/src/functions/is-editing.js +0 -7
- package/packages/_rsc/src/functions/is-iframe.js +0 -7
- package/packages/_rsc/src/functions/is-previewing.js +0 -14
- package/packages/_rsc/src/functions/on-change.js +0 -27
- package/packages/_rsc/src/functions/on-change.test.js +0 -19
- package/packages/_rsc/src/functions/register-component.js +0 -68
- package/packages/_rsc/src/functions/register.js +0 -29
- package/packages/_rsc/src/functions/sanitize-react-native-block-styles.js +0 -66
- package/packages/_rsc/src/functions/set-editor-settings.js +0 -15
- package/packages/_rsc/src/functions/set.js +0 -11
- package/packages/_rsc/src/functions/set.test.js +0 -16
- package/packages/_rsc/src/functions/track.js +0 -124
- package/packages/_rsc/src/functions/transform-block-properties.js +0 -6
- package/packages/_rsc/src/functions/transform-block.js +0 -6
- package/packages/_rsc/src/helpers/ab-tests.js +0 -16
- package/packages/_rsc/src/helpers/cookie.js +0 -81
- package/packages/_rsc/src/helpers/css.js +0 -34
- package/packages/_rsc/src/helpers/flatten.js +0 -34
- package/packages/_rsc/src/helpers/localStorage.js +0 -35
- package/packages/_rsc/src/helpers/nullable.js +0 -4
- package/packages/_rsc/src/helpers/sessionId.js +0 -52
- package/packages/_rsc/src/helpers/time.js +0 -5
- package/packages/_rsc/src/helpers/url.js +0 -13
- package/packages/_rsc/src/helpers/url.test.js +0 -21
- package/packages/_rsc/src/helpers/uuid.js +0 -13
- package/packages/_rsc/src/helpers/visitorId.js +0 -34
- package/packages/_rsc/src/index-helpers/blocks-exports.js +0 -22
- package/packages/_rsc/src/index-helpers/top-of-file.js +0 -2
- package/packages/_rsc/src/index.js +0 -14
- package/packages/_rsc/src/scripts/init-editing.js +0 -93
- package/packages/_rsc/src/types/builder-content.js +0 -0
- package/packages/_rsc/src/types/can-track.js +0 -0
- package/packages/_rsc/src/types/components.js +0 -0
- package/packages/_rsc/src/types/deep-partial.js +0 -0
- package/packages/_rsc/src/types/element.js +0 -0
- package/packages/_rsc/src/types/targets.js +0 -0
- package/packages/_rsc/src/types/typescript.js +0 -0
|
@@ -2,8 +2,8 @@ import * as React from "react";
|
|
|
2
2
|
export default function Button(props) {
|
|
3
3
|
return (React.createElement(React.Fragment, null,
|
|
4
4
|
props.link ? (React.createElement(React.Fragment, null,
|
|
5
|
-
React.createElement("a", { role: "button", ...props.attributes, href: props.link, target: props.openLinkInNewTab ? "_blank" : undefined }, props.text))) : (React.createElement("button", { className: "button-
|
|
6
|
-
React.createElement("style", null, `.button-
|
|
5
|
+
React.createElement("a", { role: "button", ...props.attributes, href: props.link, target: props.openLinkInNewTab ? "_blank" : undefined }, props.text))) : (React.createElement("button", { className: "button-66d34b93", ...props.attributes }, props.text)),
|
|
6
|
+
React.createElement("style", null, `.button-66d34b93 {
|
|
7
7
|
all: unset;
|
|
8
8
|
}`)));
|
|
9
9
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
-
import RenderBlocks from "../../components/render-blocks
|
|
2
|
+
import RenderBlocks from "../../components/render-blocks";
|
|
3
3
|
import { getSizesForBreakpoints } from "../../constants/device-sizes";
|
|
4
|
-
import RenderInlinedStyles from "../../components/render-inlined-styles
|
|
4
|
+
import RenderInlinedStyles from "../../components/render-inlined-styles";
|
|
5
5
|
import { TARGET } from "../../constants/target.js";
|
|
6
6
|
import { convertStyleMapToCSS } from "../../helpers/css";
|
|
7
7
|
export default function Columns(props) {
|
|
@@ -105,13 +105,13 @@ export default function Columns(props) {
|
|
|
105
105
|
}
|
|
106
106
|
return (React.createElement(React.Fragment, null,
|
|
107
107
|
React.createElement("div", { className: `builder-columns ${props.builderBlock.id}-breakpoints` +
|
|
108
|
-
" div-
|
|
108
|
+
" div-46a0fd84", style: {
|
|
109
109
|
...(TARGET === "reactNative" ? reactNativeColumnsStyles() : {}),
|
|
110
110
|
...columnsCssVars(),
|
|
111
111
|
} },
|
|
112
112
|
TARGET !== "reactNative" ? (React.createElement(React.Fragment, null,
|
|
113
113
|
React.createElement(RenderInlinedStyles, { styles: columnsStyles() }))) : null,
|
|
114
|
-
props.columns?.map((column, index) => (React.createElement("div", { className: "builder-column div-
|
|
114
|
+
props.columns?.map((column, index) => (React.createElement("div", { className: "builder-column div-46a0fd84-2", style: {
|
|
115
115
|
width: getColumnCssWidth(index),
|
|
116
116
|
marginLeft: `${index === 0 ? 0 : getGutterSize()}px`,
|
|
117
117
|
...(TARGET === "reactNative" ? reactNativeColumnStyles() : {}),
|
|
@@ -120,10 +120,10 @@ export default function Columns(props) {
|
|
|
120
120
|
React.createElement(RenderBlocks, { blocks: column.blocks, path: `component.options.columns.${index}.blocks`, parent: props.builderBlock.id, styleProp: {
|
|
121
121
|
flexGrow: "1",
|
|
122
122
|
} }))))),
|
|
123
|
-
React.createElement("style", null, `.div-
|
|
123
|
+
React.createElement("style", null, `.div-46a0fd84 {
|
|
124
124
|
display: flex;
|
|
125
125
|
line-height: normal;
|
|
126
|
-
}.div-
|
|
126
|
+
}.div-46a0fd84-2 {
|
|
127
127
|
display: flex;
|
|
128
128
|
flex-direction: column;
|
|
129
129
|
align-items: stretch;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import { useState, useContext, useRef } from "react";
|
|
3
|
-
import RenderBlock from "../../components/render-block/render-block
|
|
4
|
-
import BuilderBlocks from "../../components/render-blocks
|
|
3
|
+
import RenderBlock from "../../components/render-block/render-block";
|
|
4
|
+
import BuilderBlocks from "../../components/render-blocks";
|
|
5
5
|
import { isEditing } from "../../functions/is-editing.js";
|
|
6
6
|
export default function FormComponent(props) {
|
|
7
7
|
const formRef = useRef(null);
|
|
@@ -187,7 +187,7 @@ export default function FormComponent(props) {
|
|
|
187
187
|
React.createElement(BuilderBlocks, { dataPath: "sendingMessage", blocks: props.sendingMessage }))) : null,
|
|
188
188
|
" ",
|
|
189
189
|
submissionState() === "error" && responseData ? (React.createElement(React.Fragment, null,
|
|
190
|
-
React.createElement("pre", { className: "builder-form-error-text pre-
|
|
190
|
+
React.createElement("pre", { className: "builder-form-error-text pre-0d1abaf2" },
|
|
191
191
|
" ",
|
|
192
192
|
JSON.stringify(responseData, null, 2),
|
|
193
193
|
" "))) : null,
|
|
@@ -196,6 +196,6 @@ export default function FormComponent(props) {
|
|
|
196
196
|
React.createElement(BuilderBlocks, { dataPath: "successMessage", blocks: props.successMessage }))) : null,
|
|
197
197
|
" "),
|
|
198
198
|
" ",
|
|
199
|
-
React.createElement("style", null, `.pre-
|
|
199
|
+
React.createElement("style", null, `.pre-0d1abaf2 { padding: 10px; color: red; text-align: center; }`),
|
|
200
200
|
" "));
|
|
201
201
|
}
|
|
@@ -51,25 +51,25 @@ export default function Image(props) {
|
|
|
51
51
|
...aspectRatioCss(),
|
|
52
52
|
}, className: "builder-image" +
|
|
53
53
|
(props.className ? " " + props.className : "") +
|
|
54
|
-
" img-
|
|
54
|
+
" img-54289eda", src: props.image, srcSet: srcSetToUse(), sizes: props.sizes })),
|
|
55
55
|
props.aspectRatio &&
|
|
56
56
|
!(props.builderBlock?.children?.length && props.fitContent) ? (React.createElement(React.Fragment, null,
|
|
57
|
-
React.createElement("div", { className: "builder-image-sizer div-
|
|
57
|
+
React.createElement("div", { className: "builder-image-sizer div-54289eda", style: {
|
|
58
58
|
paddingTop:
|
|
59
59
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
60
60
|
props.aspectRatio * 100 + "%",
|
|
61
61
|
} }))) : null,
|
|
62
62
|
props.builderBlock?.children?.length && props.fitContent ? (React.createElement(React.Fragment, null, props.children)) : null,
|
|
63
63
|
!props.fitContent && props.children ? (React.createElement(React.Fragment, null,
|
|
64
|
-
React.createElement("div", { className: "div-
|
|
65
|
-
React.createElement("style", null, `.img-
|
|
64
|
+
React.createElement("div", { className: "div-54289eda-2" }, props.children))) : null),
|
|
65
|
+
React.createElement("style", null, `.img-54289eda {
|
|
66
66
|
opacity: 1;
|
|
67
67
|
transition: opacity 0.2s ease-in-out;
|
|
68
|
-
}.div-
|
|
68
|
+
}.div-54289eda {
|
|
69
69
|
width: 100%;
|
|
70
70
|
pointer-events: none;
|
|
71
71
|
font-size: 0;
|
|
72
|
-
}.div-
|
|
72
|
+
}.div-54289eda-2 {
|
|
73
73
|
display: flex;
|
|
74
74
|
flex-direction: column;
|
|
75
75
|
align-items: stretch;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import { useState, useContext, useEffect } from "react";
|
|
3
|
-
import RenderContent from "../../components/render-content/render-content
|
|
3
|
+
import RenderContent from "../../components/render-content/render-content";
|
|
4
4
|
import BuilderContext from "../../context/builder.context.js";
|
|
5
5
|
import { getContent } from "../../functions/get-content/index.js";
|
|
6
6
|
import { TARGET } from "../../constants/target";
|
|
@@ -3,7 +3,7 @@ import { getMaxWidthQueryForSize, getSizesForBreakpoints, } from "../../constant
|
|
|
3
3
|
import { TARGET } from "../../constants/target.js";
|
|
4
4
|
import { getProcessedBlock } from "../../functions/get-processed-block.js";
|
|
5
5
|
import { createCssClass } from "../../helpers/css.js";
|
|
6
|
-
import RenderInlinedStyles from "../render-inlined-styles
|
|
6
|
+
import RenderInlinedStyles from "../render-inlined-styles";
|
|
7
7
|
export default function BlockStyles(props) {
|
|
8
8
|
function useBlock() {
|
|
9
9
|
return getProcessedBlock({
|
|
@@ -5,12 +5,12 @@ import { getBlockComponentOptions } from "../../functions/get-block-component-op
|
|
|
5
5
|
import { getBlockProperties } from "../../functions/get-block-properties.js";
|
|
6
6
|
import { getBlockTag } from "../../functions/get-block-tag.js";
|
|
7
7
|
import { getProcessedBlock } from "../../functions/get-processed-block.js";
|
|
8
|
-
import BlockStyles from "./block-styles
|
|
8
|
+
import BlockStyles from "./block-styles";
|
|
9
9
|
import { getComponent, getRepeatItemData, isEmptyHtmlElement, } from "./render-block.helpers.js";
|
|
10
|
-
import RenderRepeatedBlock from "./render-repeated-block
|
|
10
|
+
import RenderRepeatedBlock from "./render-repeated-block";
|
|
11
11
|
import { TARGET } from "../../constants/target.js";
|
|
12
12
|
import { extractTextStyles } from "../../functions/extract-text-styles.js";
|
|
13
|
-
import RenderComponent from "./render-component
|
|
13
|
+
import RenderComponent from "./render-component";
|
|
14
14
|
import { getReactNativeBlockStyles } from "../../functions/get-react-native-block-styles.js";
|
|
15
15
|
export default function RenderBlock(props) {
|
|
16
16
|
const [component, setComponent] = useState(() => getComponent({
|
|
@@ -30,10 +30,26 @@ export default function RenderBlock(props) {
|
|
|
30
30
|
shouldEvaluateBindings: true,
|
|
31
31
|
});
|
|
32
32
|
}
|
|
33
|
+
function proxyState() {
|
|
34
|
+
if (typeof Proxy === "undefined") {
|
|
35
|
+
console.error("no Proxy available in this environment, cannot proxy state.");
|
|
36
|
+
return props.context.state;
|
|
37
|
+
}
|
|
38
|
+
const useState = new Proxy(props.context.state, {
|
|
39
|
+
set: (obj, prop, value) => {
|
|
40
|
+
// set the value on the state object, so that the event handler instantly gets the update.
|
|
41
|
+
obj[prop] = value;
|
|
42
|
+
// set the value in the context, so that the rest of the app gets the update.
|
|
43
|
+
props.context.setState?.(obj);
|
|
44
|
+
return true;
|
|
45
|
+
},
|
|
46
|
+
});
|
|
47
|
+
return useState;
|
|
48
|
+
}
|
|
33
49
|
function actions() {
|
|
34
50
|
return getBlockActions({
|
|
35
51
|
block: useBlock(),
|
|
36
|
-
state:
|
|
52
|
+
state: proxyState(),
|
|
37
53
|
context: props.context.context,
|
|
38
54
|
});
|
|
39
55
|
}
|
|
@@ -105,6 +121,7 @@ export default function RenderBlock(props) {
|
|
|
105
121
|
state: props.context.state,
|
|
106
122
|
content: props.context.content,
|
|
107
123
|
context: props.context.context,
|
|
124
|
+
setState: props.context.setState,
|
|
108
125
|
registeredComponents: props.context.registeredComponents,
|
|
109
126
|
inheritedStyles: getInheritedTextStyles(),
|
|
110
127
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
-
import BlockStyles from "./block-styles
|
|
3
|
-
import RenderBlock from "./render-block
|
|
2
|
+
import BlockStyles from "./block-styles";
|
|
3
|
+
import RenderBlock from "./render-block";
|
|
4
4
|
export default function RenderComponent(props) {
|
|
5
5
|
const ComponentRefRef = props.componentRef;
|
|
6
6
|
return (React.createElement(React.Fragment, null, props.componentRef ? (React.createElement(React.Fragment, null,
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import { useContext } from "react";
|
|
3
3
|
import BuilderContext from "../../context/builder.context.js";
|
|
4
|
-
import RenderBlock from "./render-block
|
|
4
|
+
import RenderBlock from "./render-block";
|
|
5
5
|
export default function RenderRepeatedBlock(props) {
|
|
6
6
|
return (React.createElement(BuilderContext.Provider, { value: {
|
|
7
7
|
content: props.repeatContext.content,
|
|
8
8
|
state: props.repeatContext.state,
|
|
9
|
+
setState: props.repeatContext.setState,
|
|
9
10
|
context: props.repeatContext.context,
|
|
10
11
|
apiKey: props.repeatContext.apiKey,
|
|
11
12
|
registeredComponents: props.repeatContext.registeredComponents,
|
|
@@ -2,8 +2,8 @@ import * as React from "react";
|
|
|
2
2
|
import { useContext } from "react";
|
|
3
3
|
import BuilderContext from "../context/builder.context.js";
|
|
4
4
|
import { isEditing } from "../functions/is-editing.js";
|
|
5
|
-
import BlockStyles from "./render-block/block-styles
|
|
6
|
-
import RenderBlock from "./render-block/render-block
|
|
5
|
+
import BlockStyles from "./render-block/block-styles";
|
|
6
|
+
import RenderBlock from "./render-block/render-block";
|
|
7
7
|
export default function RenderBlocks(props) {
|
|
8
8
|
function className() {
|
|
9
9
|
return "builder-blocks" + (!props.blocks?.length ? " no-blocks" : "");
|
|
@@ -32,12 +32,12 @@ export default function RenderBlocks(props) {
|
|
|
32
32
|
}
|
|
33
33
|
const builderContext = useContext(BuilderContext);
|
|
34
34
|
return (React.createElement(React.Fragment, null,
|
|
35
|
-
React.createElement("div", { className: className() + " div-
|
|
35
|
+
React.createElement("div", { className: className() + " div-297c34fa", "builder-path": props.path, "builder-parent-id": props.parent, dataSet: {
|
|
36
36
|
class: className(),
|
|
37
37
|
}, style: props.styleProp, onClick: (event) => onClick(), onMouseEnter: (event) => onMouseEnter() },
|
|
38
38
|
props.blocks ? (React.createElement(React.Fragment, null, props.blocks?.map((block) => (React.createElement(RenderBlock, { key: "render-block-" + block.id, block: block, context: builderContext }))))) : null,
|
|
39
39
|
props.blocks ? (React.createElement(React.Fragment, null, props.blocks?.map((block) => (React.createElement(BlockStyles, { key: "block-style-" + block.id, block: block, context: builderContext }))))) : null),
|
|
40
|
-
React.createElement("style", null, `.div-
|
|
40
|
+
React.createElement("style", null, `.div-297c34fa {
|
|
41
41
|
display: flex;
|
|
42
42
|
flex-direction: column;
|
|
43
43
|
align-items: stretch;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
const getCssFromFont = (font) => {
|
|
2
|
+
var _a, _b;
|
|
3
|
+
const family = font.family + (font.kind && !font.kind.includes("#") ? ", " + font.kind : "");
|
|
4
|
+
const name = family.split(",")[0];
|
|
5
|
+
const url = (_b = font.fileUrl) != null ? _b : (_a = font == null ? void 0 : font.files) == null ? void 0 : _a.regular;
|
|
6
|
+
let str = "";
|
|
7
|
+
if (url && family && name) {
|
|
8
|
+
str += `
|
|
9
|
+
@font-face {
|
|
10
|
+
font-family: "${family}";
|
|
11
|
+
src: local("${name}"), url('${url}') format('woff2');
|
|
12
|
+
font-display: fallback;
|
|
13
|
+
font-weight: 400;
|
|
14
|
+
}
|
|
15
|
+
`.trim();
|
|
16
|
+
}
|
|
17
|
+
if (font.files) {
|
|
18
|
+
for (const weight in font.files) {
|
|
19
|
+
const isNumber = String(Number(weight)) === weight;
|
|
20
|
+
if (!isNumber) {
|
|
21
|
+
continue;
|
|
22
|
+
}
|
|
23
|
+
const weightUrl = font.files[weight];
|
|
24
|
+
if (weightUrl && weightUrl !== url) {
|
|
25
|
+
str += `
|
|
26
|
+
@font-face {
|
|
27
|
+
font-family: "${family}";
|
|
28
|
+
src: url('${weightUrl}') format('woff2');
|
|
29
|
+
font-display: fallback;
|
|
30
|
+
font-weight: ${weight};
|
|
31
|
+
}
|
|
32
|
+
`.trim();
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
return str;
|
|
37
|
+
};
|
|
38
|
+
const getFontCss = ({ customFonts }) => {
|
|
39
|
+
var _a;
|
|
40
|
+
return ((_a = customFonts == null ? void 0 : customFonts.map((font) => getCssFromFont(font))) == null ? void 0 : _a.join(" ")) || "";
|
|
41
|
+
};
|
|
42
|
+
const getCss = ({ cssCode, contentId }) => {
|
|
43
|
+
if (!cssCode) {
|
|
44
|
+
return "";
|
|
45
|
+
}
|
|
46
|
+
if (!contentId) {
|
|
47
|
+
return cssCode;
|
|
48
|
+
}
|
|
49
|
+
return (cssCode == null ? void 0 : cssCode.replace(/&/g, `div[builder-content-id="${contentId}"]`)) || "";
|
|
50
|
+
};
|
|
51
|
+
export { getCss, getFontCss };
|
|
@@ -1,59 +1,17 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
-
import
|
|
2
|
+
import { useState } from "react";
|
|
3
|
+
import RenderInlinedStyles from "../../render-inlined-styles";
|
|
4
|
+
import { getCss } from "./render-styles.helpers";
|
|
5
|
+
import { getFontCss } from "./render-styles.helpers";
|
|
3
6
|
export default function RenderContentStyles(props) {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
const url = font.fileUrl ?? font?.files?.regular;
|
|
10
|
-
let str = "";
|
|
11
|
-
if (url && family && name) {
|
|
12
|
-
str += `
|
|
13
|
-
@font-face {
|
|
14
|
-
font-family: "${family}";
|
|
15
|
-
src: local("${name}"), url('${url}') format('woff2');
|
|
16
|
-
font-display: fallback;
|
|
17
|
-
font-weight: 400;
|
|
18
|
-
}
|
|
19
|
-
`.trim();
|
|
20
|
-
}
|
|
21
|
-
if (font.files) {
|
|
22
|
-
for (const weight in font.files) {
|
|
23
|
-
const isNumber = String(Number(weight)) === weight;
|
|
24
|
-
if (!isNumber) {
|
|
25
|
-
continue;
|
|
26
|
-
}
|
|
27
|
-
// TODO: maybe limit number loaded
|
|
28
|
-
const weightUrl = font.files[weight];
|
|
29
|
-
if (weightUrl && weightUrl !== url) {
|
|
30
|
-
str += `
|
|
31
|
-
@font-face {
|
|
32
|
-
font-family: "${family}";
|
|
33
|
-
src: url('${weightUrl}') format('woff2');
|
|
34
|
-
font-display: fallback;
|
|
35
|
-
font-weight: ${weight};
|
|
36
|
-
}
|
|
37
|
-
`.trim();
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
return str;
|
|
42
|
-
}
|
|
43
|
-
function getFontCss({ customFonts }) {
|
|
44
|
-
// TODO: flag for this
|
|
45
|
-
// if (!builder.allowCustomFonts) {
|
|
46
|
-
// return '';
|
|
47
|
-
// }
|
|
48
|
-
// TODO: separate internal data from external
|
|
49
|
-
return customFonts?.map((font) => getCssFromFont(font))?.join(" ") || "";
|
|
50
|
-
}
|
|
51
|
-
function injectedStyles() {
|
|
52
|
-
return `
|
|
53
|
-
${props.cssCode || ""}
|
|
7
|
+
const [injectedStyles, setInjectedStyles] = useState(() => `
|
|
8
|
+
${getCss({
|
|
9
|
+
cssCode: props.cssCode,
|
|
10
|
+
contentId: props.contentId,
|
|
11
|
+
})}
|
|
54
12
|
${getFontCss({
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
return React.createElement(RenderInlinedStyles, { styles: injectedStyles
|
|
13
|
+
customFonts: props.customFonts,
|
|
14
|
+
})}
|
|
15
|
+
`);
|
|
16
|
+
return React.createElement(RenderInlinedStyles, { styles: injectedStyles });
|
|
59
17
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { default as default2 } from "./render-content
|
|
1
|
+
import { default as default2 } from "./render-content";
|
|
2
2
|
export { default2 as default };
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defProps = Object.defineProperties;
|
|
3
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
4
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
7
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8
|
+
var __spreadValues = (a, b) => {
|
|
9
|
+
for (var prop in b || (b = {}))
|
|
10
|
+
if (__hasOwnProp.call(b, prop))
|
|
11
|
+
__defNormalProp(a, prop, b[prop]);
|
|
12
|
+
if (__getOwnPropSymbols)
|
|
13
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
14
|
+
if (__propIsEnum.call(b, prop))
|
|
15
|
+
__defNormalProp(a, prop, b[prop]);
|
|
16
|
+
}
|
|
17
|
+
return a;
|
|
18
|
+
};
|
|
19
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
|
+
const getContextStateInitialValue = ({ content, data, locale }) => {
|
|
21
|
+
var _a, _b, _c;
|
|
22
|
+
const defaultValues = {};
|
|
23
|
+
(_b = (_a = content == null ? void 0 : content.data) == null ? void 0 : _a.inputs) == null ? void 0 : _b.forEach((input) => {
|
|
24
|
+
var _a2;
|
|
25
|
+
if (input.name && input.defaultValue !== void 0 && ((_a2 = content == null ? void 0 : content.data) == null ? void 0 : _a2.state) && content.data.state[input.name] === void 0) {
|
|
26
|
+
defaultValues[input.name] = input.defaultValue;
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
const stateToUse = __spreadValues(__spreadValues(__spreadValues({}, (_c = content == null ? void 0 : content.data) == null ? void 0 : _c.state), data), locale ? { locale } : {});
|
|
30
|
+
return __spreadValues(__spreadValues({}, defaultValues), stateToUse);
|
|
31
|
+
};
|
|
32
|
+
const getContentInitialValue = ({ content, data }) => {
|
|
33
|
+
return !content ? void 0 : __spreadProps(__spreadValues({}, content), {
|
|
34
|
+
data: __spreadValues(__spreadValues({}, content == null ? void 0 : content.data), data),
|
|
35
|
+
meta: content == null ? void 0 : content.meta
|
|
36
|
+
});
|
|
37
|
+
};
|
|
38
|
+
export { getContentInitialValue, getContextStateInitialValue };
|