@builder.io/sdk-svelte 0.7.4 → 0.7.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.
@@ -27,7 +27,7 @@ $: repeatItem = () => {
27
27
  });
28
28
  };
29
29
  $: processedBlock = () => {
30
- return repeatItem()
30
+ return block.repeat?.collection
31
31
  ? block
32
32
  : getProcessedBlock({
33
33
  block: block,
@@ -48,6 +48,9 @@ $: canShowBlock = () => {
48
48
  if ("show" in processedBlock()) {
49
49
  return processedBlock().show;
50
50
  }
51
+ if (block.repeat?.collection && !repeatItem?.()?.length) {
52
+ return false;
53
+ }
51
54
  return true;
52
55
  };
53
56
  $: childrenWithoutParentComponent = () => {
@@ -2,6 +2,6 @@ import type { BuilderContent } from '../../types/builder-content.js';
2
2
  import type { Nullable } from '../../types/typescript.js';
3
3
  import type { ContentProps } from './content.types.js';
4
4
  export declare const getContextStateInitialValue: ({ content, data, locale }: Pick<ContentProps, 'content' | 'data' | 'locale'>) => {
5
- [x: string]: unknown;
5
+ locale?: string | undefined;
6
6
  };
7
7
  export declare const getContentInitialValue: ({ content, data }: Pick<ContentProps, 'content' | 'data'>) => Nullable<BuilderContent>;
@@ -1,22 +1,20 @@
1
1
  export const getContextStateInitialValue = ({ content, data, locale }) => {
2
2
  const defaultValues = {};
3
+ const initialState = content?.data?.state || {};
3
4
  // set default values for content state inputs
4
5
  content?.data?.inputs?.forEach(input => {
5
- if (input.name && input.defaultValue !== undefined && content?.data?.state && content.data.state[input.name] === undefined) {
6
+ if (input.name && input.defaultValue !== undefined) {
6
7
  defaultValues[input.name] = input.defaultValue;
7
8
  }
8
9
  });
9
- const stateToUse = {
10
- ...content?.data?.state,
10
+ return {
11
+ ...defaultValues,
12
+ ...initialState,
11
13
  ...data,
12
14
  ...(locale ? {
13
15
  locale
14
16
  } : {})
15
17
  };
16
- return {
17
- ...defaultValues,
18
- ...stateToUse
19
- };
20
18
  };
21
19
  export const getContentInitialValue = ({ content, data }) => {
22
20
  return !content ? undefined : {
@@ -1 +1 @@
1
- export declare const SDK_VERSION = "0.7.4";
1
+ export declare const SDK_VERSION = "0.7.5";
@@ -1 +1 @@
1
- export const SDK_VERSION = "0.7.4";
1
+ export const SDK_VERSION = "0.7.5";
@@ -27,7 +27,7 @@ $: repeatItem = () => {
27
27
  });
28
28
  };
29
29
  $: processedBlock = () => {
30
- return repeatItem()
30
+ return block.repeat?.collection
31
31
  ? block
32
32
  : getProcessedBlock({
33
33
  block: block,
@@ -48,6 +48,9 @@ $: canShowBlock = () => {
48
48
  if ("show" in processedBlock()) {
49
49
  return processedBlock().show;
50
50
  }
51
+ if (block.repeat?.collection && !repeatItem?.()?.length) {
52
+ return false;
53
+ }
51
54
  return true;
52
55
  };
53
56
  $: childrenWithoutParentComponent = () => {
@@ -2,6 +2,6 @@ import type { BuilderContent } from '../../types/builder-content.js';
2
2
  import type { Nullable } from '../../types/typescript.js';
3
3
  import type { ContentProps } from './content.types.js';
4
4
  export declare const getContextStateInitialValue: ({ content, data, locale }: Pick<ContentProps, 'content' | 'data' | 'locale'>) => {
5
- [x: string]: unknown;
5
+ locale?: string | undefined;
6
6
  };
7
7
  export declare const getContentInitialValue: ({ content, data }: Pick<ContentProps, 'content' | 'data'>) => Nullable<BuilderContent>;
@@ -1,22 +1,20 @@
1
1
  export const getContextStateInitialValue = ({ content, data, locale }) => {
2
2
  const defaultValues = {};
3
+ const initialState = content?.data?.state || {};
3
4
  // set default values for content state inputs
4
5
  content?.data?.inputs?.forEach(input => {
5
- if (input.name && input.defaultValue !== undefined && content?.data?.state && content.data.state[input.name] === undefined) {
6
+ if (input.name && input.defaultValue !== undefined) {
6
7
  defaultValues[input.name] = input.defaultValue;
7
8
  }
8
9
  });
9
- const stateToUse = {
10
- ...content?.data?.state,
10
+ return {
11
+ ...defaultValues,
12
+ ...initialState,
11
13
  ...data,
12
14
  ...(locale ? {
13
15
  locale
14
16
  } : {})
15
17
  };
16
- return {
17
- ...defaultValues,
18
- ...stateToUse
19
- };
20
18
  };
21
19
  export const getContentInitialValue = ({ content, data }) => {
22
20
  return !content ? undefined : {
@@ -1 +1 @@
1
- export declare const SDK_VERSION = "0.7.4";
1
+ export declare const SDK_VERSION = "0.7.5";
@@ -1 +1 @@
1
- export const SDK_VERSION = "0.7.4";
1
+ export const SDK_VERSION = "0.7.5";
@@ -27,7 +27,7 @@ $: repeatItem = () => {
27
27
  });
28
28
  };
29
29
  $: processedBlock = () => {
30
- return repeatItem()
30
+ return block.repeat?.collection
31
31
  ? block
32
32
  : getProcessedBlock({
33
33
  block: block,
@@ -48,6 +48,9 @@ $: canShowBlock = () => {
48
48
  if ("show" in processedBlock()) {
49
49
  return processedBlock().show;
50
50
  }
51
+ if (block.repeat?.collection && !repeatItem?.()?.length) {
52
+ return false;
53
+ }
51
54
  return true;
52
55
  };
53
56
  $: childrenWithoutParentComponent = () => {
@@ -2,6 +2,6 @@ import type { BuilderContent } from '../../types/builder-content.js';
2
2
  import type { Nullable } from '../../types/typescript.js';
3
3
  import type { ContentProps } from './content.types.js';
4
4
  export declare const getContextStateInitialValue: ({ content, data, locale }: Pick<ContentProps, 'content' | 'data' | 'locale'>) => {
5
- [x: string]: unknown;
5
+ locale?: string | undefined;
6
6
  };
7
7
  export declare const getContentInitialValue: ({ content, data }: Pick<ContentProps, 'content' | 'data'>) => Nullable<BuilderContent>;
@@ -1,22 +1,20 @@
1
1
  export const getContextStateInitialValue = ({ content, data, locale }) => {
2
2
  const defaultValues = {};
3
+ const initialState = content?.data?.state || {};
3
4
  // set default values for content state inputs
4
5
  content?.data?.inputs?.forEach(input => {
5
- if (input.name && input.defaultValue !== undefined && content?.data?.state && content.data.state[input.name] === undefined) {
6
+ if (input.name && input.defaultValue !== undefined) {
6
7
  defaultValues[input.name] = input.defaultValue;
7
8
  }
8
9
  });
9
- const stateToUse = {
10
- ...content?.data?.state,
10
+ return {
11
+ ...defaultValues,
12
+ ...initialState,
11
13
  ...data,
12
14
  ...(locale ? {
13
15
  locale
14
16
  } : {})
15
17
  };
16
- return {
17
- ...defaultValues,
18
- ...stateToUse
19
- };
20
18
  };
21
19
  export const getContentInitialValue = ({ content, data }) => {
22
20
  return !content ? undefined : {
@@ -1 +1 @@
1
- export declare const SDK_VERSION = "0.7.4";
1
+ export declare const SDK_VERSION = "0.7.5";
@@ -1 +1 @@
1
- export const SDK_VERSION = "0.7.4";
1
+ export const SDK_VERSION = "0.7.5";
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": "0.7.4",
4
+ "version": "0.7.5",
5
5
  "type": "module",
6
6
  "files": [
7
7
  "lib",
@@ -48,7 +48,7 @@
48
48
  });
49
49
  };
50
50
  $: processedBlock = () => {
51
- return repeatItem()
51
+ return block.repeat?.collection
52
52
  ? block
53
53
  : getProcessedBlock({
54
54
  block: block,
@@ -69,6 +69,9 @@
69
69
  if ("show" in processedBlock()) {
70
70
  return processedBlock().show;
71
71
  }
72
+ if (block.repeat?.collection && !repeatItem?.()?.length) {
73
+ return false;
74
+ }
72
75
  return true;
73
76
  };
74
77
  $: childrenWithoutParentComponent = () => {
@@ -8,24 +8,22 @@ export const getContextStateInitialValue = ({
8
8
  locale
9
9
  }: Pick<ContentProps, 'content' | 'data' | 'locale'>) => {
10
10
  const defaultValues: BuilderRenderState = {};
11
+ const initialState = content?.data?.state || {};
11
12
 
12
13
  // set default values for content state inputs
13
14
  content?.data?.inputs?.forEach(input => {
14
- if (input.name && input.defaultValue !== undefined && content?.data?.state && content.data.state[input.name] === undefined) {
15
+ if (input.name && input.defaultValue !== undefined) {
15
16
  defaultValues[input.name] = input.defaultValue;
16
17
  }
17
18
  });
18
- const stateToUse: BuilderRenderState = {
19
- ...content?.data?.state,
19
+ return {
20
+ ...defaultValues,
21
+ ...initialState,
20
22
  ...data,
21
23
  ...(locale ? {
22
24
  locale
23
25
  } : {})
24
26
  };
25
- return {
26
- ...defaultValues,
27
- ...stateToUse
28
- };
29
27
  };
30
28
  export const getContentInitialValue = ({
31
29
  content,
@@ -1 +1 @@
1
- export const SDK_VERSION = "0.7.4"
1
+ export const SDK_VERSION = "0.7.5"