@builder.io/sdk-svelte 3.0.6 → 3.0.7

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 (31) hide show
  1. package/lib/browser/components/block/components/block-styles.svelte +10 -0
  2. package/lib/browser/constants/device-sizes.d.ts +3 -2
  3. package/lib/browser/constants/device-sizes.js +20 -3
  4. package/lib/browser/constants/sdk-version.d.ts +1 -1
  5. package/lib/browser/constants/sdk-version.js +1 -1
  6. package/lib/browser/scripts/init-editing.js +1 -0
  7. package/lib/browser/types/builder-block.d.ts +0 -1
  8. package/lib/browser/types/builder-content.d.ts +1 -0
  9. package/lib/edge/components/block/components/block-styles.svelte +10 -0
  10. package/lib/edge/constants/device-sizes.d.ts +3 -2
  11. package/lib/edge/constants/device-sizes.js +20 -3
  12. package/lib/edge/constants/sdk-version.d.ts +1 -1
  13. package/lib/edge/constants/sdk-version.js +1 -1
  14. package/lib/edge/scripts/init-editing.js +1 -0
  15. package/lib/edge/types/builder-block.d.ts +0 -1
  16. package/lib/edge/types/builder-content.d.ts +1 -0
  17. package/lib/node/components/block/components/block-styles.svelte +10 -0
  18. package/lib/node/constants/device-sizes.d.ts +3 -2
  19. package/lib/node/constants/device-sizes.js +20 -3
  20. package/lib/node/constants/sdk-version.d.ts +1 -1
  21. package/lib/node/constants/sdk-version.js +1 -1
  22. package/lib/node/scripts/init-editing.js +1 -0
  23. package/lib/node/types/builder-block.d.ts +0 -1
  24. package/lib/node/types/builder-content.d.ts +1 -0
  25. package/package.json +1 -1
  26. package/src/components/block/components/block-styles.svelte +16 -0
  27. package/src/constants/device-sizes.ts +26 -7
  28. package/src/constants/sdk-version.ts +1 -1
  29. package/src/scripts/init-editing.ts +1 -0
  30. package/src/types/builder-block.ts +0 -1
  31. package/src/types/builder-content.ts +1 -0
@@ -24,9 +24,11 @@ $: css = () => {
24
24
  const styles = processedBlock.responsiveStyles;
25
25
  const content = context.content;
26
26
  const sizesWithUpdatedBreakpoints = getSizesForBreakpoints(content?.meta?.breakpoints || {});
27
+ const contentHasXSmallBreakpoint = Boolean(content?.meta?.breakpoints?.xsmall);
27
28
  const largeStyles = styles?.large;
28
29
  const mediumStyles = styles?.medium;
29
30
  const smallStyles = styles?.small;
31
+ const xsmallStyles = styles?.xsmall;
30
32
  const className = processedBlock.id;
31
33
  if (!className) {
32
34
  return "";
@@ -51,6 +53,13 @@ $: css = () => {
51
53
  mediaQuery: getMaxWidthQueryForSize("small", sizesWithUpdatedBreakpoints),
52
54
  })
53
55
  : "";
56
+ const xsmallStylesClass = xsmallStyles && contentHasXSmallBreakpoint
57
+ ? createCssClass({
58
+ className,
59
+ styles: xsmallStyles,
60
+ mediaQuery: getMaxWidthQueryForSize("xsmall", sizesWithUpdatedBreakpoints),
61
+ })
62
+ : "";
54
63
  const hoverAnimation = processedBlock.animations &&
55
64
  processedBlock.animations.find((item) => item.trigger === "hover");
56
65
  let hoverStylesClass = "";
@@ -72,6 +81,7 @@ $: css = () => {
72
81
  largeStylesClass,
73
82
  mediumStylesClass,
74
83
  smallStylesClass,
84
+ xsmallStylesClass,
75
85
  hoverStylesClass,
76
86
  ].join(" ");
77
87
  };
@@ -1,4 +1,4 @@
1
- export type SizeName = 'large' | 'medium' | 'small';
1
+ export type SizeName = 'large' | 'medium' | 'small' | 'xsmall';
2
2
  interface Size {
3
3
  min: number;
4
4
  default: number;
@@ -6,8 +6,9 @@ interface Size {
6
6
  }
7
7
  export declare const getMaxWidthQueryForSize: (size: SizeName, sizeValues?: Record<SizeName, Size>) => string;
8
8
  interface Breakpoints {
9
+ xsmall?: number;
9
10
  small?: number;
10
11
  medium?: number;
11
12
  }
12
- export declare const getSizesForBreakpoints: ({ small, medium }: Breakpoints) => Record<SizeName, Size>;
13
+ export declare const getSizesForBreakpoints: (breakpoints: Breakpoints) => Record<SizeName, Size>;
13
14
  export {};
@@ -1,7 +1,12 @@
1
1
  import { fastClone } from '../functions/fast-clone';
2
2
  const SIZES = {
3
+ xsmall: {
4
+ min: 0,
5
+ default: 160,
6
+ max: 320
7
+ },
3
8
  small: {
4
- min: 320,
9
+ min: 321,
5
10
  default: 321,
6
11
  max: 640
7
12
  },
@@ -17,12 +22,24 @@ const SIZES = {
17
22
  }
18
23
  };
19
24
  export const getMaxWidthQueryForSize = (size, sizeValues = SIZES) => `@media (max-width: ${sizeValues[size].max}px)`;
20
- export const getSizesForBreakpoints = ({ small, medium }) => {
25
+ export const getSizesForBreakpoints = (breakpoints) => {
21
26
  const newSizes = fastClone(SIZES); // Note: this helps to get a deep clone of fields like small, medium etc
27
+ if (!breakpoints) {
28
+ return newSizes;
29
+ }
30
+ const { xsmall, small, medium } = breakpoints;
31
+ if (xsmall) {
32
+ const xsmallMin = Math.floor(xsmall / 2);
33
+ newSizes.xsmall = {
34
+ max: xsmall,
35
+ min: xsmallMin,
36
+ default: xsmallMin + 1
37
+ };
38
+ }
22
39
  if (!small || !medium) {
23
40
  return newSizes;
24
41
  }
25
- const smallMin = Math.floor(small / 2);
42
+ const smallMin = xsmall ? newSizes.xsmall.max + 1 : Math.floor(small / 2);
26
43
  newSizes.small = {
27
44
  max: small,
28
45
  min: smallMin,
@@ -1 +1 @@
1
- export declare const SDK_VERSION = "3.0.6";
1
+ export declare const SDK_VERSION = "3.0.7";
@@ -1 +1 @@
1
- export const SDK_VERSION = "3.0.6";
1
+ export const SDK_VERSION = "3.0.7";
@@ -43,6 +43,7 @@ export const setupBrowserForEditing = (options = {}) => {
43
43
  // scope our '+ add block' button styling
44
44
  supportsAddBlockScoping: true,
45
45
  supportsCustomBreakpoints: true,
46
+ supportsXSmallBreakpoint: TARGET === 'reactNative' ? false : true,
46
47
  blockLevelPersonalization: true
47
48
  }
48
49
  }, '*');
@@ -37,7 +37,6 @@ export interface BuilderBlock {
37
37
  large?: Partial<CSSStyleDeclaration>;
38
38
  medium?: Partial<CSSStyleDeclaration>;
39
39
  small?: Partial<CSSStyleDeclaration>;
40
- /** @deprecated */
41
40
  xsmall?: Partial<CSSStyleDeclaration>;
42
41
  };
43
42
  component?: {
@@ -2,6 +2,7 @@ import type { BuilderBlock } from './builder-block';
2
2
  import type { Input } from './input';
3
3
  import type { Nullable } from './typescript';
4
4
  export interface Breakpoints {
5
+ xsmall?: number;
5
6
  small: number;
6
7
  medium: number;
7
8
  }
@@ -24,9 +24,11 @@ $: css = () => {
24
24
  const styles = processedBlock.responsiveStyles;
25
25
  const content = context.content;
26
26
  const sizesWithUpdatedBreakpoints = getSizesForBreakpoints(content?.meta?.breakpoints || {});
27
+ const contentHasXSmallBreakpoint = Boolean(content?.meta?.breakpoints?.xsmall);
27
28
  const largeStyles = styles?.large;
28
29
  const mediumStyles = styles?.medium;
29
30
  const smallStyles = styles?.small;
31
+ const xsmallStyles = styles?.xsmall;
30
32
  const className = processedBlock.id;
31
33
  if (!className) {
32
34
  return "";
@@ -51,6 +53,13 @@ $: css = () => {
51
53
  mediaQuery: getMaxWidthQueryForSize("small", sizesWithUpdatedBreakpoints),
52
54
  })
53
55
  : "";
56
+ const xsmallStylesClass = xsmallStyles && contentHasXSmallBreakpoint
57
+ ? createCssClass({
58
+ className,
59
+ styles: xsmallStyles,
60
+ mediaQuery: getMaxWidthQueryForSize("xsmall", sizesWithUpdatedBreakpoints),
61
+ })
62
+ : "";
54
63
  const hoverAnimation = processedBlock.animations &&
55
64
  processedBlock.animations.find((item) => item.trigger === "hover");
56
65
  let hoverStylesClass = "";
@@ -72,6 +81,7 @@ $: css = () => {
72
81
  largeStylesClass,
73
82
  mediumStylesClass,
74
83
  smallStylesClass,
84
+ xsmallStylesClass,
75
85
  hoverStylesClass,
76
86
  ].join(" ");
77
87
  };
@@ -1,4 +1,4 @@
1
- export type SizeName = 'large' | 'medium' | 'small';
1
+ export type SizeName = 'large' | 'medium' | 'small' | 'xsmall';
2
2
  interface Size {
3
3
  min: number;
4
4
  default: number;
@@ -6,8 +6,9 @@ interface Size {
6
6
  }
7
7
  export declare const getMaxWidthQueryForSize: (size: SizeName, sizeValues?: Record<SizeName, Size>) => string;
8
8
  interface Breakpoints {
9
+ xsmall?: number;
9
10
  small?: number;
10
11
  medium?: number;
11
12
  }
12
- export declare const getSizesForBreakpoints: ({ small, medium }: Breakpoints) => Record<SizeName, Size>;
13
+ export declare const getSizesForBreakpoints: (breakpoints: Breakpoints) => Record<SizeName, Size>;
13
14
  export {};
@@ -1,7 +1,12 @@
1
1
  import { fastClone } from '../functions/fast-clone';
2
2
  const SIZES = {
3
+ xsmall: {
4
+ min: 0,
5
+ default: 160,
6
+ max: 320
7
+ },
3
8
  small: {
4
- min: 320,
9
+ min: 321,
5
10
  default: 321,
6
11
  max: 640
7
12
  },
@@ -17,12 +22,24 @@ const SIZES = {
17
22
  }
18
23
  };
19
24
  export const getMaxWidthQueryForSize = (size, sizeValues = SIZES) => `@media (max-width: ${sizeValues[size].max}px)`;
20
- export const getSizesForBreakpoints = ({ small, medium }) => {
25
+ export const getSizesForBreakpoints = (breakpoints) => {
21
26
  const newSizes = fastClone(SIZES); // Note: this helps to get a deep clone of fields like small, medium etc
27
+ if (!breakpoints) {
28
+ return newSizes;
29
+ }
30
+ const { xsmall, small, medium } = breakpoints;
31
+ if (xsmall) {
32
+ const xsmallMin = Math.floor(xsmall / 2);
33
+ newSizes.xsmall = {
34
+ max: xsmall,
35
+ min: xsmallMin,
36
+ default: xsmallMin + 1
37
+ };
38
+ }
22
39
  if (!small || !medium) {
23
40
  return newSizes;
24
41
  }
25
- const smallMin = Math.floor(small / 2);
42
+ const smallMin = xsmall ? newSizes.xsmall.max + 1 : Math.floor(small / 2);
26
43
  newSizes.small = {
27
44
  max: small,
28
45
  min: smallMin,
@@ -1 +1 @@
1
- export declare const SDK_VERSION = "3.0.6";
1
+ export declare const SDK_VERSION = "3.0.7";
@@ -1 +1 @@
1
- export const SDK_VERSION = "3.0.6";
1
+ export const SDK_VERSION = "3.0.7";
@@ -43,6 +43,7 @@ export const setupBrowserForEditing = (options = {}) => {
43
43
  // scope our '+ add block' button styling
44
44
  supportsAddBlockScoping: true,
45
45
  supportsCustomBreakpoints: true,
46
+ supportsXSmallBreakpoint: TARGET === 'reactNative' ? false : true,
46
47
  blockLevelPersonalization: true
47
48
  }
48
49
  }, '*');
@@ -37,7 +37,6 @@ export interface BuilderBlock {
37
37
  large?: Partial<CSSStyleDeclaration>;
38
38
  medium?: Partial<CSSStyleDeclaration>;
39
39
  small?: Partial<CSSStyleDeclaration>;
40
- /** @deprecated */
41
40
  xsmall?: Partial<CSSStyleDeclaration>;
42
41
  };
43
42
  component?: {
@@ -2,6 +2,7 @@ import type { BuilderBlock } from './builder-block';
2
2
  import type { Input } from './input';
3
3
  import type { Nullable } from './typescript';
4
4
  export interface Breakpoints {
5
+ xsmall?: number;
5
6
  small: number;
6
7
  medium: number;
7
8
  }
@@ -24,9 +24,11 @@ $: css = () => {
24
24
  const styles = processedBlock.responsiveStyles;
25
25
  const content = context.content;
26
26
  const sizesWithUpdatedBreakpoints = getSizesForBreakpoints(content?.meta?.breakpoints || {});
27
+ const contentHasXSmallBreakpoint = Boolean(content?.meta?.breakpoints?.xsmall);
27
28
  const largeStyles = styles?.large;
28
29
  const mediumStyles = styles?.medium;
29
30
  const smallStyles = styles?.small;
31
+ const xsmallStyles = styles?.xsmall;
30
32
  const className = processedBlock.id;
31
33
  if (!className) {
32
34
  return "";
@@ -51,6 +53,13 @@ $: css = () => {
51
53
  mediaQuery: getMaxWidthQueryForSize("small", sizesWithUpdatedBreakpoints),
52
54
  })
53
55
  : "";
56
+ const xsmallStylesClass = xsmallStyles && contentHasXSmallBreakpoint
57
+ ? createCssClass({
58
+ className,
59
+ styles: xsmallStyles,
60
+ mediaQuery: getMaxWidthQueryForSize("xsmall", sizesWithUpdatedBreakpoints),
61
+ })
62
+ : "";
54
63
  const hoverAnimation = processedBlock.animations &&
55
64
  processedBlock.animations.find((item) => item.trigger === "hover");
56
65
  let hoverStylesClass = "";
@@ -72,6 +81,7 @@ $: css = () => {
72
81
  largeStylesClass,
73
82
  mediumStylesClass,
74
83
  smallStylesClass,
84
+ xsmallStylesClass,
75
85
  hoverStylesClass,
76
86
  ].join(" ");
77
87
  };
@@ -1,4 +1,4 @@
1
- export type SizeName = 'large' | 'medium' | 'small';
1
+ export type SizeName = 'large' | 'medium' | 'small' | 'xsmall';
2
2
  interface Size {
3
3
  min: number;
4
4
  default: number;
@@ -6,8 +6,9 @@ interface Size {
6
6
  }
7
7
  export declare const getMaxWidthQueryForSize: (size: SizeName, sizeValues?: Record<SizeName, Size>) => string;
8
8
  interface Breakpoints {
9
+ xsmall?: number;
9
10
  small?: number;
10
11
  medium?: number;
11
12
  }
12
- export declare const getSizesForBreakpoints: ({ small, medium }: Breakpoints) => Record<SizeName, Size>;
13
+ export declare const getSizesForBreakpoints: (breakpoints: Breakpoints) => Record<SizeName, Size>;
13
14
  export {};
@@ -1,7 +1,12 @@
1
1
  import { fastClone } from '../functions/fast-clone';
2
2
  const SIZES = {
3
+ xsmall: {
4
+ min: 0,
5
+ default: 160,
6
+ max: 320
7
+ },
3
8
  small: {
4
- min: 320,
9
+ min: 321,
5
10
  default: 321,
6
11
  max: 640
7
12
  },
@@ -17,12 +22,24 @@ const SIZES = {
17
22
  }
18
23
  };
19
24
  export const getMaxWidthQueryForSize = (size, sizeValues = SIZES) => `@media (max-width: ${sizeValues[size].max}px)`;
20
- export const getSizesForBreakpoints = ({ small, medium }) => {
25
+ export const getSizesForBreakpoints = (breakpoints) => {
21
26
  const newSizes = fastClone(SIZES); // Note: this helps to get a deep clone of fields like small, medium etc
27
+ if (!breakpoints) {
28
+ return newSizes;
29
+ }
30
+ const { xsmall, small, medium } = breakpoints;
31
+ if (xsmall) {
32
+ const xsmallMin = Math.floor(xsmall / 2);
33
+ newSizes.xsmall = {
34
+ max: xsmall,
35
+ min: xsmallMin,
36
+ default: xsmallMin + 1
37
+ };
38
+ }
22
39
  if (!small || !medium) {
23
40
  return newSizes;
24
41
  }
25
- const smallMin = Math.floor(small / 2);
42
+ const smallMin = xsmall ? newSizes.xsmall.max + 1 : Math.floor(small / 2);
26
43
  newSizes.small = {
27
44
  max: small,
28
45
  min: smallMin,
@@ -1 +1 @@
1
- export declare const SDK_VERSION = "3.0.6";
1
+ export declare const SDK_VERSION = "3.0.7";
@@ -1 +1 @@
1
- export const SDK_VERSION = "3.0.6";
1
+ export const SDK_VERSION = "3.0.7";
@@ -43,6 +43,7 @@ export const setupBrowserForEditing = (options = {}) => {
43
43
  // scope our '+ add block' button styling
44
44
  supportsAddBlockScoping: true,
45
45
  supportsCustomBreakpoints: true,
46
+ supportsXSmallBreakpoint: TARGET === 'reactNative' ? false : true,
46
47
  blockLevelPersonalization: true
47
48
  }
48
49
  }, '*');
@@ -37,7 +37,6 @@ export interface BuilderBlock {
37
37
  large?: Partial<CSSStyleDeclaration>;
38
38
  medium?: Partial<CSSStyleDeclaration>;
39
39
  small?: Partial<CSSStyleDeclaration>;
40
- /** @deprecated */
41
40
  xsmall?: Partial<CSSStyleDeclaration>;
42
41
  };
43
42
  component?: {
@@ -2,6 +2,7 @@ import type { BuilderBlock } from './builder-block';
2
2
  import type { Input } from './input';
3
3
  import type { Nullable } from './typescript';
4
4
  export interface Breakpoints {
5
+ xsmall?: number;
5
6
  small: number;
6
7
  medium: number;
7
8
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@builder.io/sdk-svelte",
3
3
  "description": "Builder.io SDK for Svelte",
4
- "version": "3.0.6",
4
+ "version": "3.0.7",
5
5
  "type": "module",
6
6
  "files": [
7
7
  "lib",
@@ -39,9 +39,13 @@
39
39
  const sizesWithUpdatedBreakpoints = getSizesForBreakpoints(
40
40
  content?.meta?.breakpoints || {}
41
41
  );
42
+ const contentHasXSmallBreakpoint = Boolean(
43
+ content?.meta?.breakpoints?.xsmall
44
+ );
42
45
  const largeStyles = styles?.large;
43
46
  const mediumStyles = styles?.medium;
44
47
  const smallStyles = styles?.small;
48
+ const xsmallStyles = styles?.xsmall;
45
49
  const className = processedBlock.id;
46
50
  if (!className) {
47
51
  return "";
@@ -72,6 +76,17 @@
72
76
  ),
73
77
  })
74
78
  : "";
79
+ const xsmallStylesClass =
80
+ xsmallStyles && contentHasXSmallBreakpoint
81
+ ? createCssClass({
82
+ className,
83
+ styles: xsmallStyles,
84
+ mediaQuery: getMaxWidthQueryForSize(
85
+ "xsmall",
86
+ sizesWithUpdatedBreakpoints
87
+ ),
88
+ })
89
+ : "";
75
90
  const hoverAnimation =
76
91
  processedBlock.animations &&
77
92
  processedBlock.animations.find((item) => item.trigger === "hover");
@@ -96,6 +111,7 @@
96
111
  largeStylesClass,
97
112
  mediumStylesClass,
98
113
  smallStylesClass,
114
+ xsmallStylesClass,
99
115
  hoverStylesClass,
100
116
  ].join(" ");
101
117
  };
@@ -1,13 +1,18 @@
1
1
  import { fastClone } from '../functions/fast-clone';
2
- export type SizeName = 'large' | 'medium' | 'small';
2
+ export type SizeName = 'large' | 'medium' | 'small' | 'xsmall';
3
3
  interface Size {
4
4
  min: number;
5
5
  default: number;
6
6
  max: number;
7
7
  }
8
8
  const SIZES: Record<SizeName, Size> = {
9
+ xsmall: {
10
+ min: 0,
11
+ default: 160,
12
+ max: 320
13
+ },
9
14
  small: {
10
- min: 320,
15
+ min: 321,
11
16
  default: 321,
12
17
  max: 640
13
18
  },
@@ -24,19 +29,33 @@ const SIZES: Record<SizeName, Size> = {
24
29
  };
25
30
  export const getMaxWidthQueryForSize = (size: SizeName, sizeValues = SIZES) => `@media (max-width: ${sizeValues[size].max}px)`;
26
31
  interface Breakpoints {
32
+ xsmall?: number;
27
33
  small?: number;
28
34
  medium?: number;
29
35
  }
30
- export const getSizesForBreakpoints = ({
31
- small,
32
- medium
33
- }: Breakpoints) => {
36
+ export const getSizesForBreakpoints = (breakpoints: Breakpoints) => {
34
37
  const newSizes = fastClone(SIZES); // Note: this helps to get a deep clone of fields like small, medium etc
35
38
 
39
+ if (!breakpoints) {
40
+ return newSizes;
41
+ }
42
+ const {
43
+ xsmall,
44
+ small,
45
+ medium
46
+ } = breakpoints;
47
+ if (xsmall) {
48
+ const xsmallMin = Math.floor(xsmall / 2);
49
+ newSizes.xsmall = {
50
+ max: xsmall,
51
+ min: xsmallMin,
52
+ default: xsmallMin + 1
53
+ };
54
+ }
36
55
  if (!small || !medium) {
37
56
  return newSizes;
38
57
  }
39
- const smallMin = Math.floor(small / 2);
58
+ const smallMin = xsmall ? newSizes.xsmall.max + 1 : Math.floor(small / 2);
40
59
  newSizes.small = {
41
60
  max: small,
42
61
  min: smallMin,
@@ -1 +1 @@
1
- export const SDK_VERSION = "3.0.6"
1
+ export const SDK_VERSION = "3.0.7"
@@ -48,6 +48,7 @@ export const setupBrowserForEditing = (options: {
48
48
  // scope our '+ add block' button styling
49
49
  supportsAddBlockScoping: true,
50
50
  supportsCustomBreakpoints: true,
51
+ supportsXSmallBreakpoint: TARGET === 'reactNative' ? false : true,
51
52
  blockLevelPersonalization: true
52
53
  }
53
54
  }, '*');
@@ -41,7 +41,6 @@ export interface BuilderBlock {
41
41
  large?: Partial<CSSStyleDeclaration>;
42
42
  medium?: Partial<CSSStyleDeclaration>;
43
43
  small?: Partial<CSSStyleDeclaration>;
44
- /** @deprecated */
45
44
  xsmall?: Partial<CSSStyleDeclaration>;
46
45
  };
47
46
  component?: {
@@ -2,6 +2,7 @@ import type { BuilderBlock } from './builder-block';
2
2
  import type { Input } from './input';
3
3
  import type { Nullable } from './typescript';
4
4
  export interface Breakpoints {
5
+ xsmall?: number;
5
6
  small: number;
6
7
  medium: number;
7
8
  }