@builder.io/sdk-react 0.1.11 → 0.1.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (29) hide show
  1. package/dist/react/blocks/columns/columns.js +68 -73
  2. package/dist/react/blocks/symbol/symbol.js +40 -35
  3. package/dist/react/components/render-content/render-content.js +7 -0
  4. package/dist/react/context/builder.context.js +1 -0
  5. package/dist/react/functions/get-content/generate-content-url.js +5 -2
  6. package/dist/react/functions/get-content/generate-content-url.test.js +42 -0
  7. package/dist/react/types/api-version.js +1 -0
  8. package/dist/rsc/blocks/columns/columns.js +68 -75
  9. package/dist/rsc/blocks/symbol/symbol.js +46 -19
  10. package/dist/rsc/components/render-content/render-content.js +1 -0
  11. package/dist/rsc/context/builder.context.js +1 -0
  12. package/dist/rsc/functions/get-content/generate-content-url.js +5 -2
  13. package/dist/rsc/functions/get-content/generate-content-url.test.js +42 -0
  14. package/dist/rsc/types/api-version.js +1 -0
  15. package/package.json +1 -1
  16. package/packages/react/src/blocks/columns/columns.jsx +81 -79
  17. package/packages/react/src/blocks/symbol/symbol.jsx +36 -28
  18. package/packages/react/src/components/render-content/render-content.jsx +7 -0
  19. package/packages/react/src/context/builder.context.js +1 -0
  20. package/packages/react/src/functions/get-content/generate-content-url.js +6 -2
  21. package/packages/react/src/functions/get-content/generate-content-url.test.js +42 -0
  22. package/packages/react/src/types/api-version.js +0 -0
  23. package/packages/rsc/src/blocks/columns/columns.jsx +73 -78
  24. package/packages/rsc/src/blocks/symbol/symbol.jsx +51 -18
  25. package/packages/rsc/src/components/render-content/render-content.jsx +1 -0
  26. package/packages/rsc/src/context/builder.context.js +1 -0
  27. package/packages/rsc/src/functions/get-content/generate-content-url.js +6 -2
  28. package/packages/rsc/src/functions/get-content/generate-content-url.test.js +42 -0
  29. package/packages/rsc/src/types/api-version.js +0 -0
@@ -1,132 +1,127 @@
1
1
  import * as React from "react";
2
- import { useContext } from "react";
2
+ import { useState, useContext } from "react";
3
3
  import RenderBlocks from "../../components/render-blocks";
4
4
  import { getSizesForBreakpoints } from "../../constants/device-sizes";
5
5
  import RenderInlinedStyles from "../../components/render-inlined-styles";
6
6
  import { TARGET } from "../../constants/target.js";
7
- import { convertStyleMapToCSS } from "../../helpers/css";
8
7
  import BuilderContext from "../../context/builder.context.js";
9
8
  function Columns(props) {
10
- function getGutterSize() {
11
- return typeof props.space === "number" ? props.space || 0 : 20;
12
- }
13
- function getColumns() {
14
- return props.columns || [];
15
- }
9
+ const [gutterSize, setGutterSize] = useState(() => typeof props.space === "number" ? props.space || 0 : 20);
10
+ const [cols, setCols] = useState(() => props.columns || []);
11
+ const [stackAt, setStackAt] = useState(() => props.stackColumnsAt || "tablet");
16
12
  function getWidth(index) {
17
- const columns = getColumns();
18
- return columns[index]?.width || 100 / columns.length;
13
+ return cols[index]?.width || 100 / cols.length;
19
14
  }
20
15
  function getColumnCssWidth(index) {
21
- const columns = getColumns();
22
- const gutterSize = getGutterSize();
23
- const subtractWidth = (gutterSize * (columns.length - 1)) / columns.length;
16
+ const subtractWidth = (gutterSize * (cols.length - 1)) / cols.length;
24
17
  return `calc(${getWidth(index)}% - ${subtractWidth}px)`;
25
18
  }
26
- function maybeApplyForTablet(prop) {
27
- const _stackColumnsAt = props.stackColumnsAt || "tablet";
28
- return _stackColumnsAt === "tablet" ? prop : "inherit";
19
+ function getTabletStyle({ stackedStyle, desktopStyle }) {
20
+ return stackAt === "tablet" ? stackedStyle : desktopStyle;
29
21
  }
22
+ function getMobileStyle({ stackedStyle, desktopStyle }) {
23
+ return stackAt === "never" ? desktopStyle : stackedStyle;
24
+ }
25
+ const [flexDir, setFlexDir] = useState(() => props.stackColumnsAt === "never"
26
+ ? "row"
27
+ : props.reverseColumnsWhenStacked
28
+ ? "column-reverse"
29
+ : "column");
30
30
  function columnsCssVars() {
31
- const flexDir = props.stackColumnsAt === "never"
32
- ? "inherit"
33
- : props.reverseColumnsWhenStacked
34
- ? "column-reverse"
35
- : "column";
31
+ if (TARGET === "reactNative") {
32
+ return {
33
+ flexDirection: flexDir,
34
+ };
35
+ }
36
36
  return {
37
37
  "--flex-dir": flexDir,
38
- "--flex-dir-tablet": maybeApplyForTablet(flexDir),
38
+ "--flex-dir-tablet": getTabletStyle({
39
+ stackedStyle: flexDir,
40
+ desktopStyle: "row",
41
+ }),
39
42
  };
40
43
  }
41
- function columnCssVars() {
42
- const width = "100%";
43
- const marginLeft = "0";
44
+ function columnCssVars(index) {
45
+ const width = getColumnCssWidth(index);
46
+ const gutter = `${index === 0 ? 0 : gutterSize}px`;
47
+ if (TARGET === "reactNative") {
48
+ return {
49
+ width,
50
+ marginLeft: props.stackColumnsAt === "never" ? gutter : "0",
51
+ };
52
+ }
53
+ const mobileWidth = "100%";
54
+ const mobileMarginLeft = "0";
44
55
  return {
45
- "--column-width": width,
46
- "--column-margin-left": marginLeft,
47
- "--column-width-tablet": maybeApplyForTablet(width),
48
- "--column-margin-left-tablet": maybeApplyForTablet(marginLeft),
56
+ width,
57
+ "margin-left": gutter,
58
+ "--column-width-mobile": getMobileStyle({
59
+ stackedStyle: mobileWidth,
60
+ desktopStyle: width,
61
+ }),
62
+ "--column-margin-left-mobile": getMobileStyle({
63
+ stackedStyle: mobileMarginLeft,
64
+ desktopStyle: gutter,
65
+ }),
66
+ "--column-width-tablet": getTabletStyle({
67
+ stackedStyle: mobileWidth,
68
+ desktopStyle: width,
69
+ }),
70
+ "--column-margin-left-tablet": getTabletStyle({
71
+ stackedStyle: mobileMarginLeft,
72
+ desktopStyle: gutter,
73
+ }),
49
74
  };
50
75
  }
51
76
  function getWidthForBreakpointSize(size) {
52
77
  const breakpointSizes = getSizesForBreakpoints(builderContext.content?.meta?.breakpoints || {});
53
78
  return breakpointSizes[size].max;
54
79
  }
55
- function columnStyleObjects() {
56
- return {
57
- columns: {
58
- small: {
59
- flexDirection: "var(--flex-dir)",
60
- alignItems: "stretch",
61
- },
62
- medium: {
63
- flexDirection: "var(--flex-dir-tablet)",
64
- alignItems: "stretch",
65
- },
66
- },
67
- column: {
68
- small: {
69
- width: "var(--column-width) !important",
70
- marginLeft: "var(--column-margin-left) !important",
71
- },
72
- medium: {
73
- width: "var(--column-width-tablet) !important",
74
- marginLeft: "var(--column-margin-left-tablet) !important",
75
- },
76
- },
77
- };
78
- }
79
80
  function columnsStyles() {
80
81
  return `
81
82
  @media (max-width: ${getWidthForBreakpointSize("medium")}px) {
82
83
  .${props.builderBlock.id}-breakpoints {
83
- ${convertStyleMapToCSS(columnStyleObjects().columns.medium)}
84
+ flex-direction: var(--flex-dir-tablet);
85
+ align-items: stretch;
84
86
  }
85
87
 
86
88
  .${props.builderBlock.id}-breakpoints > .builder-column {
87
- ${convertStyleMapToCSS(columnStyleObjects().column.medium)}
89
+ width: var(--column-width-tablet) !important;
90
+ margin-left: var(--column-margin-left-tablet) !important;
88
91
  }
89
92
  }
90
93
 
91
94
  @media (max-width: ${getWidthForBreakpointSize("small")}px) {
92
95
  .${props.builderBlock.id}-breakpoints {
93
- ${convertStyleMapToCSS(columnStyleObjects().columns.small)}
96
+ flex-direction: var(--flex-dir);
97
+ align-items: stretch;
94
98
  }
95
99
 
96
100
  .${props.builderBlock.id}-breakpoints > .builder-column {
97
- ${convertStyleMapToCSS(columnStyleObjects().column.small)}
101
+ width: var(--column-width-mobile) !important;
102
+ margin-left: var(--column-margin-left-mobile) !important;
98
103
  }
99
104
  },
100
105
  `;
101
106
  }
102
- function reactNativeColumnsStyles() {
103
- return columnStyleObjects.columns.small;
104
- }
105
- function reactNativeColumnStyles() {
106
- return columnStyleObjects.column.small;
107
- }
108
107
  const builderContext = useContext(BuilderContext);
109
108
  return (React.createElement(React.Fragment, null,
110
109
  React.createElement("div", { className: `builder-columns ${props.builderBlock.id}-breakpoints` +
111
- " div-0a8a143e", style: {
112
- ...(TARGET === "reactNative" ? reactNativeColumnsStyles() : {}),
113
- ...columnsCssVars(),
110
+ " div-568386c4", style: columnsCssVars(), dataSet: {
111
+ "builder-block-name": "builder-columns",
114
112
  } },
115
113
  TARGET !== "reactNative" ? (React.createElement(React.Fragment, null,
116
114
  React.createElement(RenderInlinedStyles, { styles: columnsStyles() }))) : null,
117
- props.columns?.map((column, index) => (React.createElement("div", { className: "builder-column div-0a8a143e-2", style: {
118
- width: getColumnCssWidth(index),
119
- marginLeft: `${index === 0 ? 0 : getGutterSize()}px`,
120
- ...(TARGET === "reactNative" ? reactNativeColumnStyles() : {}),
121
- ...columnCssVars(),
115
+ props.columns?.map((column, index) => (React.createElement("div", { className: "builder-column div-568386c4-2", style: columnCssVars(index), dataSet: {
116
+ "builder-block-name": "builder-column",
122
117
  }, key: index },
123
118
  React.createElement(RenderBlocks, { blocks: column.blocks, path: `component.options.columns.${index}.blocks`, parent: props.builderBlock.id, styleProp: {
124
119
  flexGrow: "1",
125
120
  } }))))),
126
- React.createElement("style", null, `.div-0a8a143e {
121
+ React.createElement("style", null, `.div-568386c4 {
127
122
  display: flex;
128
123
  line-height: normal;
129
- }.div-0a8a143e-2 {
124
+ }.div-568386c4-2 {
130
125
  display: flex;
131
126
  flex-direction: column;
132
127
  align-items: stretch;
@@ -5,27 +5,20 @@ import BuilderContext from "../../context/builder.context.js";
5
5
  import { getContent } from "../../functions/get-content/index.js";
6
6
  import { TARGET } from "../../constants/target";
7
7
  function Symbol(props) {
8
- function className() {
9
- return [
10
- ...(TARGET === "vue2" || TARGET === "vue3"
11
- ? Object.keys(props.attributes.class)
12
- : [props.attributes.class]),
13
- "builder-symbol",
14
- props.symbol?.inline ? "builder-inline-symbol" : undefined,
15
- props.symbol?.dynamic || props.dynamic
16
- ? "builder-dynamic-symbol"
17
- : undefined,
18
- ]
19
- .filter(Boolean)
20
- .join(" ");
21
- }
22
- const [fetchedContent, setFetchedContent] = useState(() => null);
23
- function contentToUse() {
24
- return props.symbol?.content || fetchedContent;
25
- }
26
- const builderContext = useContext(BuilderContext);
27
- useEffect(() => {
28
- const symbolToUse = props.symbol;
8
+ const [className, setClassName] = useState(() => [
9
+ ...(TARGET === "vue2" || TARGET === "vue3"
10
+ ? Object.keys(props.attributes.class)
11
+ : [props.attributes.class]),
12
+ "builder-symbol",
13
+ props.symbol?.inline ? "builder-inline-symbol" : undefined,
14
+ props.symbol?.dynamic || props.dynamic
15
+ ? "builder-dynamic-symbol"
16
+ : undefined,
17
+ ]
18
+ .filter(Boolean)
19
+ .join(" "));
20
+ const [contentToUse, setContentToUse] = useState(() => props.symbol?.content);
21
+ function fetchContent() {
29
22
  /**
30
23
  * If:
31
24
  * - we have a symbol prop
@@ -35,30 +28,42 @@ function Symbol(props) {
35
28
  *
36
29
  * then we want to re-fetch the symbol content.
37
30
  */
38
- if (symbolToUse &&
39
- !symbolToUse.content &&
40
- !fetchedContent &&
41
- symbolToUse.model &&
31
+ if (!contentToUse &&
32
+ props.symbol?.model &&
42
33
  // This is a hack, we should not need to check for this, but it is needed for Svelte.
43
34
  builderContext?.apiKey) {
44
35
  getContent({
45
- model: symbolToUse.model,
36
+ model: props.symbol.model,
46
37
  apiKey: builderContext.apiKey,
38
+ apiVersion: builderContext.apiVersion,
47
39
  query: {
48
- id: symbolToUse.entry,
40
+ id: props.symbol.entry,
49
41
  },
50
- }).then((response) => {
51
- setFetchedContent(response);
42
+ })
43
+ .then((response) => {
44
+ if (response) {
45
+ setContentToUse(response);
46
+ }
47
+ })
48
+ .catch((err) => {
49
+ console.error("[Builder.io]: Could not fetch symbol content: ", err);
52
50
  });
53
51
  }
54
- }, [props.symbol, fetchedContent]);
52
+ }
53
+ const builderContext = useContext(BuilderContext);
54
+ useEffect(() => {
55
+ fetchContent();
56
+ }, []);
57
+ useEffect(() => {
58
+ fetchContent();
59
+ }, [props.symbol]);
55
60
  return (React.createElement("div", { ...props.attributes, dataSet: {
56
- class: className(),
57
- }, className: className() },
58
- React.createElement(RenderContent, { apiKey: builderContext.apiKey, context: builderContext.context, customComponents: Object.values(builderContext.registeredComponents), data: {
61
+ class: className,
62
+ }, className: className },
63
+ React.createElement(RenderContent, { apiVersion: builderContext.apiVersion, apiKey: builderContext.apiKey, context: builderContext.context, customComponents: Object.values(builderContext.registeredComponents), data: {
59
64
  ...props.symbol?.data,
60
65
  ...builderContext.state,
61
- ...props.symbol?.content?.data?.state,
62
- }, model: props.symbol?.model, content: contentToUse() })));
66
+ ...contentToUse?.data?.state,
67
+ }, model: props.symbol?.model, content: contentToUse })));
63
68
  }
64
69
  export default Symbol;
@@ -241,6 +241,7 @@ function RenderContent(props) {
241
241
  getContent({
242
242
  model: props.model,
243
243
  apiKey: props.apiKey,
244
+ apiVersion: props.apiVersion,
244
245
  }).then((content) => {
245
246
  if (content) {
246
247
  mergeNewContent(content);
@@ -253,6 +254,11 @@ function RenderContent(props) {
253
254
  emitStateUpdate();
254
255
  }
255
256
  }, []);
257
+ useEffect(() => {
258
+ if (props.content) {
259
+ mergeNewContent(props.content);
260
+ }
261
+ }, [props.content]);
256
262
  useEffect(() => {
257
263
  evaluateJsCode();
258
264
  }, [useContent?.data?.jsCode, contentState]);
@@ -276,6 +282,7 @@ function RenderContent(props) {
276
282
  setState: setContextState,
277
283
  context: props.context || {},
278
284
  apiKey: props.apiKey,
285
+ apiVersion: props.apiVersion,
279
286
  registeredComponents: allRegisteredComponents,
280
287
  } }, useContent ? (React.createElement(React.Fragment, null,
281
288
  React.createElement("div", { ref: elementRef, onClick: (event) => onClick(event), "builder-content-id": useContent?.id, "builder-model": props.model },
@@ -6,6 +6,7 @@ var stdin_default = createContext({
6
6
  setState() {
7
7
  },
8
8
  apiKey: null,
9
+ apiVersion: void 0,
9
10
  registeredComponents: {},
10
11
  inheritedStyles: {}
11
12
  });
@@ -17,11 +17,14 @@ var __spreadValues = (a, b) => {
17
17
  import { flatten } from "../../helpers/flatten.js";
18
18
  import { getBuilderSearchParamsFromWindow, normalizeSearchParams } from "../get-builder-search-params/index.js";
19
19
  const generateContentUrl = (options) => {
20
- const { limit = 30, userAttributes, query, noTraverse = false, model, apiKey, includeRefs = true, locale } = options;
20
+ const { limit = 30, userAttributes, query, noTraverse = false, model, apiKey, includeRefs = true, locale, apiVersion = "v2" } = options;
21
21
  if (!apiKey) {
22
22
  throw new Error("Missing API key");
23
23
  }
24
- const url = new URL(`https://cdn.builder.io/api/v2/content/${model}?apiKey=${apiKey}&limit=${limit}&noTraverse=${noTraverse}&includeRefs=${includeRefs}${locale ? `&locale=${locale}` : ""}`);
24
+ if (!["v2", "v3"].includes(apiVersion)) {
25
+ throw new Error(`Invalid apiVersion: expected 'v2' or 'v3', received '${apiVersion}'`);
26
+ }
27
+ const url = new URL(`https://cdn.builder.io/api/${apiVersion}/content/${model}?apiKey=${apiKey}&limit=${limit}&noTraverse=${noTraverse}&includeRefs=${includeRefs}${locale ? `&locale=${locale}` : ""}`);
25
28
  const queryOptions = __spreadValues(__spreadValues({}, getBuilderSearchParamsFromWindow()), normalizeSearchParams(options.options || {}));
26
29
  const flattened = flatten(queryOptions);
27
30
  for (const key in flattened) {
@@ -28,4 +28,46 @@ describe("Generate Content URL", () => {
28
28
  });
29
29
  expect(output).toMatchSnapshot();
30
30
  });
31
+ test("generate content url with apiVersion as v2", () => {
32
+ const output = generateContentUrl({
33
+ apiKey: testKey,
34
+ model: testModel,
35
+ query: { id: testId },
36
+ options,
37
+ apiVersion: "v2"
38
+ });
39
+ expect(output).toMatchSnapshot();
40
+ });
41
+ test("generate content url with apiVersion as v3", () => {
42
+ const output = generateContentUrl({
43
+ apiKey: testKey,
44
+ model: testModel,
45
+ query: { id: testId },
46
+ options,
47
+ apiVersion: "v3"
48
+ });
49
+ expect(output).toMatchSnapshot();
50
+ });
51
+ test("throw error when trying to generate content url with apiVersion as v1", () => {
52
+ expect(() => {
53
+ generateContentUrl({
54
+ apiKey: testKey,
55
+ model: testModel,
56
+ query: { id: testId },
57
+ options,
58
+ apiVersion: "v1"
59
+ });
60
+ }).toThrow(`Invalid apiVersion: expected 'v2' or 'v3', received 'v1'`);
61
+ });
62
+ test("throw error when trying to generate content url with an invalid apiVersion value", () => {
63
+ expect(() => {
64
+ generateContentUrl({
65
+ apiKey: testKey,
66
+ model: testModel,
67
+ query: { id: testId },
68
+ options,
69
+ apiVersion: "INVALID_API_VERSION"
70
+ });
71
+ }).toThrow(`Invalid apiVersion: expected 'v2' or 'v3', received 'INVALID_API_VERSION'`);
72
+ });
31
73
  });
@@ -0,0 +1 @@
1
+ "use strict";
@@ -3,134 +3,127 @@ import RenderBlocks from "../../components/render-blocks";
3
3
  import { getSizesForBreakpoints } from "../../constants/device-sizes";
4
4
  import RenderInlinedStyles from "../../components/render-inlined-styles";
5
5
  import { TARGET } from "../../constants/target.js";
6
- import { convertStyleMapToCSS } from "../../helpers/css";
7
6
  import BuilderContext from "../../context/builder.context.js";
8
7
  function Columns(props) {
9
8
  const _context = { ...props["_context"] };
10
9
  const state = {
11
- getGutterSize() {
12
- return typeof props.space === "number" ? props.space || 0 : 20;
13
- },
14
- getColumns() {
15
- return props.columns || [];
16
- },
10
+ gutterSize: typeof props.space === "number" ? props.space || 0 : 20,
11
+ cols: props.columns || [],
12
+ stackAt: props.stackColumnsAt || "tablet",
17
13
  getWidth(index) {
18
- const columns = state.getColumns();
19
- return columns[index]?.width || 100 / columns.length;
14
+ return state.cols[index]?.width || 100 / state.cols.length;
20
15
  },
21
16
  getColumnCssWidth(index) {
22
- const columns = state.getColumns();
23
- const gutterSize = state.getGutterSize();
24
- const subtractWidth = (gutterSize * (columns.length - 1)) / columns.length;
17
+ const subtractWidth = (state.gutterSize * (state.cols.length - 1)) / state.cols.length;
25
18
  return `calc(${state.getWidth(index)}% - ${subtractWidth}px)`;
26
19
  },
27
- maybeApplyForTablet(prop) {
28
- const _stackColumnsAt = props.stackColumnsAt || "tablet";
29
- return _stackColumnsAt === "tablet" ? prop : "inherit";
20
+ getTabletStyle({ stackedStyle, desktopStyle }) {
21
+ return state.stackAt === "tablet" ? stackedStyle : desktopStyle;
30
22
  },
23
+ getMobileStyle({ stackedStyle, desktopStyle }) {
24
+ return state.stackAt === "never" ? desktopStyle : stackedStyle;
25
+ },
26
+ flexDir: props.stackColumnsAt === "never"
27
+ ? "row"
28
+ : props.reverseColumnsWhenStacked
29
+ ? "column-reverse"
30
+ : "column",
31
31
  get columnsCssVars() {
32
- const flexDir = props.stackColumnsAt === "never"
33
- ? "inherit"
34
- : props.reverseColumnsWhenStacked
35
- ? "column-reverse"
36
- : "column";
32
+ if (TARGET === "reactNative") {
33
+ return {
34
+ flexDirection: state.flexDir,
35
+ };
36
+ }
37
37
  return {
38
- "--flex-dir": flexDir,
39
- "--flex-dir-tablet": state.maybeApplyForTablet(flexDir),
38
+ "--flex-dir": state.flexDir,
39
+ "--flex-dir-tablet": state.getTabletStyle({
40
+ stackedStyle: state.flexDir,
41
+ desktopStyle: "row",
42
+ }),
40
43
  };
41
44
  },
42
- get columnCssVars() {
43
- const width = "100%";
44
- const marginLeft = "0";
45
+ columnCssVars(index) {
46
+ const width = state.getColumnCssWidth(index);
47
+ const gutter = `${index === 0 ? 0 : state.gutterSize}px`;
48
+ if (TARGET === "reactNative") {
49
+ return {
50
+ width,
51
+ marginLeft: props.stackColumnsAt === "never" ? gutter : "0",
52
+ };
53
+ }
54
+ const mobileWidth = "100%";
55
+ const mobileMarginLeft = "0";
45
56
  return {
46
- "--column-width": width,
47
- "--column-margin-left": marginLeft,
48
- "--column-width-tablet": state.maybeApplyForTablet(width),
49
- "--column-margin-left-tablet": state.maybeApplyForTablet(marginLeft),
57
+ width,
58
+ "margin-left": gutter,
59
+ "--column-width-mobile": state.getMobileStyle({
60
+ stackedStyle: mobileWidth,
61
+ desktopStyle: width,
62
+ }),
63
+ "--column-margin-left-mobile": state.getMobileStyle({
64
+ stackedStyle: mobileMarginLeft,
65
+ desktopStyle: gutter,
66
+ }),
67
+ "--column-width-tablet": state.getTabletStyle({
68
+ stackedStyle: mobileWidth,
69
+ desktopStyle: width,
70
+ }),
71
+ "--column-margin-left-tablet": state.getTabletStyle({
72
+ stackedStyle: mobileMarginLeft,
73
+ desktopStyle: gutter,
74
+ }),
50
75
  };
51
76
  },
52
77
  getWidthForBreakpointSize(size) {
53
78
  const breakpointSizes = getSizesForBreakpoints(builderContext.content?.meta?.breakpoints || {});
54
79
  return breakpointSizes[size].max;
55
80
  },
56
- get columnStyleObjects() {
57
- return {
58
- columns: {
59
- small: {
60
- flexDirection: "var(--flex-dir)",
61
- alignItems: "stretch",
62
- },
63
- medium: {
64
- flexDirection: "var(--flex-dir-tablet)",
65
- alignItems: "stretch",
66
- },
67
- },
68
- column: {
69
- small: {
70
- width: "var(--column-width) !important",
71
- marginLeft: "var(--column-margin-left) !important",
72
- },
73
- medium: {
74
- width: "var(--column-width-tablet) !important",
75
- marginLeft: "var(--column-margin-left-tablet) !important",
76
- },
77
- },
78
- };
79
- },
80
81
  get columnsStyles() {
81
82
  return `
82
83
  @media (max-width: ${state.getWidthForBreakpointSize("medium")}px) {
83
84
  .${props.builderBlock.id}-breakpoints {
84
- ${convertStyleMapToCSS(state.columnStyleObjects.columns.medium)}
85
+ flex-direction: var(--flex-dir-tablet);
86
+ align-items: stretch;
85
87
  }
86
88
 
87
89
  .${props.builderBlock.id}-breakpoints > .builder-column {
88
- ${convertStyleMapToCSS(state.columnStyleObjects.column.medium)}
90
+ width: var(--column-width-tablet) !important;
91
+ margin-left: var(--column-margin-left-tablet) !important;
89
92
  }
90
93
  }
91
94
 
92
95
  @media (max-width: ${state.getWidthForBreakpointSize("small")}px) {
93
96
  .${props.builderBlock.id}-breakpoints {
94
- ${convertStyleMapToCSS(state.columnStyleObjects.columns.small)}
97
+ flex-direction: var(--flex-dir);
98
+ align-items: stretch;
95
99
  }
96
100
 
97
101
  .${props.builderBlock.id}-breakpoints > .builder-column {
98
- ${convertStyleMapToCSS(state.columnStyleObjects.column.small)}
102
+ width: var(--column-width-mobile) !important;
103
+ margin-left: var(--column-margin-left-mobile) !important;
99
104
  }
100
105
  },
101
106
  `;
102
107
  },
103
- get reactNativeColumnsStyles() {
104
- return this.columnStyleObjects.columns.small;
105
- },
106
- get reactNativeColumnStyles() {
107
- return this.columnStyleObjects.column.small;
108
- },
109
108
  };
110
109
  const builderContext = _context["BuilderContext"];
111
110
  return (React.createElement(React.Fragment, null,
112
111
  React.createElement("div", { className: `builder-columns ${props.builderBlock.id}-breakpoints` +
113
- " div-fbdb9b00", style: {
114
- ...(TARGET === "reactNative" ? state.reactNativeColumnsStyles : {}),
115
- ...state.columnsCssVars,
112
+ " div-263839f0", style: state.columnsCssVars, dataSet: {
113
+ "builder-block-name": "builder-columns",
116
114
  } },
117
115
  TARGET !== "reactNative" ? (React.createElement(React.Fragment, null,
118
116
  React.createElement(RenderInlinedStyles, { styles: state.columnsStyles, _context: _context }))) : null,
119
- props.columns?.map((column, index) => (React.createElement("div", { className: "builder-column div-fbdb9b00-2", style: {
120
- width: state.getColumnCssWidth(index),
121
- marginLeft: `${index === 0 ? 0 : state.getGutterSize()}px`,
122
- ...(TARGET === "reactNative"
123
- ? state.reactNativeColumnStyles
124
- : {}),
125
- ...state.columnCssVars,
117
+ props.columns?.map((column, index) => (React.createElement("div", { className: "builder-column div-263839f0-2", style: state.columnCssVars(index), dataSet: {
118
+ "builder-block-name": "builder-column",
126
119
  }, key: index },
127
120
  React.createElement(RenderBlocks, { blocks: column.blocks, path: `component.options.columns.${index}.blocks`, parent: props.builderBlock.id, styleProp: {
128
121
  flexGrow: "1",
129
122
  }, _context: _context }))))),
130
- React.createElement("style", null, `.div-fbdb9b00 {
123
+ React.createElement("style", null, `.div-263839f0 {
131
124
  display: flex;
132
125
  line-height: normal;
133
- }.div-fbdb9b00-2 {
126
+ }.div-263839f0-2 {
134
127
  display: flex;
135
128
  flex-direction: column;
136
129
  align-items: stretch;