@builder.io/sdk-svelte 0.10.0 → 0.11.1

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 (32) hide show
  1. package/lib/browser/components/block/components/component-ref/component-ref.helpers.js +9 -7
  2. package/lib/browser/components/block/components/interactive-element.svelte +16 -13
  3. package/lib/browser/components/content-variants/helpers.js +1 -1
  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/functions/get-block-actions.js +1 -2
  7. package/lib/browser/functions/get-block-properties.js +1 -2
  8. package/lib/browser/types/targets.d.ts +1 -1
  9. package/lib/edge/components/block/components/component-ref/component-ref.helpers.js +9 -7
  10. package/lib/edge/components/block/components/interactive-element.svelte +16 -13
  11. package/lib/edge/components/content-variants/helpers.js +1 -1
  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/functions/get-block-actions.js +1 -2
  15. package/lib/edge/functions/get-block-properties.js +1 -2
  16. package/lib/edge/types/targets.d.ts +1 -1
  17. package/lib/node/components/block/components/component-ref/component-ref.helpers.js +9 -7
  18. package/lib/node/components/block/components/interactive-element.svelte +16 -13
  19. package/lib/node/components/content-variants/helpers.js +1 -1
  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/functions/get-block-actions.js +1 -2
  23. package/lib/node/functions/get-block-properties.js +1 -2
  24. package/lib/node/types/targets.d.ts +1 -1
  25. package/package.json +1 -1
  26. package/src/components/block/components/component-ref/component-ref.helpers.ts +9 -7
  27. package/src/components/block/components/interactive-element.svelte +22 -15
  28. package/src/components/content-variants/helpers.ts +1 -1
  29. package/src/constants/sdk-version.ts +1 -1
  30. package/src/functions/get-block-actions.ts +1 -2
  31. package/src/functions/get-block-properties.ts +1 -2
  32. package/src/types/targets.ts +1 -1
@@ -1,12 +1,6 @@
1
1
  import { getBlockProperties } from '../../../../functions/get-block-properties.js';
2
2
  export const getWrapperProps = ({ componentOptions, builderBlock, context, componentRef, includeBlockProps, isInteractive, contextValue }) => {
3
- const interactiveElementProps = {
4
- Wrapper: componentRef,
5
- block: builderBlock,
6
- context,
7
- wrapperProps: componentOptions
8
- };
9
- return isInteractive ? interactiveElementProps : {
3
+ const wrapperPropsWithAttributes = {
10
4
  ...componentOptions,
11
5
  /**
12
6
  * If `noWrap` is set to `true`, then the block's props/attributes are provided to the
@@ -19,4 +13,12 @@ export const getWrapperProps = ({ componentOptions, builderBlock, context, compo
19
13
  })
20
14
  } : {})
21
15
  };
16
+ const interactiveElementProps = {
17
+ Wrapper: componentRef,
18
+ block: builderBlock,
19
+ context,
20
+ wrapperProps: componentOptions,
21
+ includeBlockProps
22
+ };
23
+ return isInteractive ? interactiveElementProps : wrapperPropsWithAttributes;
22
24
  };
@@ -4,6 +4,7 @@
4
4
  import { getBlockProperties } from "../../../functions/get-block-properties.js";
5
5
  export let Wrapper;
6
6
  export let wrapperProps;
7
+ export let includeBlockProps;
7
8
  export let block;
8
9
  export let context;
9
10
  </script>
@@ -11,19 +12,21 @@ export let context;
11
12
  <svelte:component
12
13
  this={Wrapper}
13
14
  {...wrapperProps}
14
- attributes={{
15
- ...getBlockProperties({
16
- block: block,
17
- context: $context,
18
- }),
19
- ...getBlockActions({
20
- block: block,
21
- rootState: $context.rootState,
22
- rootSetState: $context.rootSetState,
23
- localState: $context.localState,
24
- context: $context.context,
25
- }),
26
- }}
15
+ attributes={includeBlockProps
16
+ ? {
17
+ ...getBlockProperties({
18
+ block: block,
19
+ context: $context,
20
+ }),
21
+ ...getBlockActions({
22
+ block: block,
23
+ rootState: $context.rootState,
24
+ rootSetState: $context.rootSetState,
25
+ localState: $context.localState,
26
+ context: $context.context,
27
+ }),
28
+ }
29
+ : {}}
27
30
  >
28
31
  <slot />
29
32
  </svelte:component>
@@ -33,7 +33,7 @@ export const checkShouldRenderVariants = ({ canTrack, content }) => {
33
33
  * NOTE: For Vue: after the app is hydrated, we strip the variants from the DOM (on mount) to reduce the amount of HTML in the DOM.
34
34
  * This isn't necessary, just a nice to have.
35
35
  */
36
- if (TARGET === 'vue2' || TARGET === 'vue3' || TARGET === 'svelte')
36
+ if (TARGET === 'vue' || TARGET === 'svelte')
37
37
  return true;
38
38
  if (isBrowser())
39
39
  return false;
@@ -1 +1 @@
1
- export declare const SDK_VERSION = "0.10.0";
1
+ export declare const SDK_VERSION = "0.11.1";
@@ -1 +1 @@
1
- export const SDK_VERSION = "0.10.0";
1
+ export const SDK_VERSION = "0.11.1";
@@ -13,8 +13,7 @@ export function getBlockActions(options) {
13
13
  let eventHandlerName = getEventHandlerName(key);
14
14
  if (options.stripPrefix) {
15
15
  switch (TARGET) {
16
- case 'vue2':
17
- case 'vue3':
16
+ case 'vue':
18
17
  eventHandlerName = eventHandlerName.replace('v-on:', '');
19
18
  break;
20
19
  case 'svelte':
@@ -55,8 +55,7 @@ export function getBlockProperties({ block, context }) {
55
55
  function getStyleAttribute(style) {
56
56
  switch (TARGET) {
57
57
  case 'svelte':
58
- case 'vue2':
59
- case 'vue3':
58
+ case 'vue':
60
59
  case 'solid':
61
60
  return convertStyleMapToCSSArray(style).join(' ');
62
61
  case 'qwik':
@@ -1 +1 @@
1
- export type Target = 'vue3' | 'vue2' | 'reactNative' | 'svelte' | 'qwik' | 'react' | 'solid' | 'rsc';
1
+ export type Target = 'vue' | 'reactNative' | 'svelte' | 'qwik' | 'react' | 'solid' | 'rsc';
@@ -1,12 +1,6 @@
1
1
  import { getBlockProperties } from '../../../../functions/get-block-properties.js';
2
2
  export const getWrapperProps = ({ componentOptions, builderBlock, context, componentRef, includeBlockProps, isInteractive, contextValue }) => {
3
- const interactiveElementProps = {
4
- Wrapper: componentRef,
5
- block: builderBlock,
6
- context,
7
- wrapperProps: componentOptions
8
- };
9
- return isInteractive ? interactiveElementProps : {
3
+ const wrapperPropsWithAttributes = {
10
4
  ...componentOptions,
11
5
  /**
12
6
  * If `noWrap` is set to `true`, then the block's props/attributes are provided to the
@@ -19,4 +13,12 @@ export const getWrapperProps = ({ componentOptions, builderBlock, context, compo
19
13
  })
20
14
  } : {})
21
15
  };
16
+ const interactiveElementProps = {
17
+ Wrapper: componentRef,
18
+ block: builderBlock,
19
+ context,
20
+ wrapperProps: componentOptions,
21
+ includeBlockProps
22
+ };
23
+ return isInteractive ? interactiveElementProps : wrapperPropsWithAttributes;
22
24
  };
@@ -4,6 +4,7 @@
4
4
  import { getBlockProperties } from "../../../functions/get-block-properties.js";
5
5
  export let Wrapper;
6
6
  export let wrapperProps;
7
+ export let includeBlockProps;
7
8
  export let block;
8
9
  export let context;
9
10
  </script>
@@ -11,19 +12,21 @@ export let context;
11
12
  <svelte:component
12
13
  this={Wrapper}
13
14
  {...wrapperProps}
14
- attributes={{
15
- ...getBlockProperties({
16
- block: block,
17
- context: $context,
18
- }),
19
- ...getBlockActions({
20
- block: block,
21
- rootState: $context.rootState,
22
- rootSetState: $context.rootSetState,
23
- localState: $context.localState,
24
- context: $context.context,
25
- }),
26
- }}
15
+ attributes={includeBlockProps
16
+ ? {
17
+ ...getBlockProperties({
18
+ block: block,
19
+ context: $context,
20
+ }),
21
+ ...getBlockActions({
22
+ block: block,
23
+ rootState: $context.rootState,
24
+ rootSetState: $context.rootSetState,
25
+ localState: $context.localState,
26
+ context: $context.context,
27
+ }),
28
+ }
29
+ : {}}
27
30
  >
28
31
  <slot />
29
32
  </svelte:component>
@@ -33,7 +33,7 @@ export const checkShouldRenderVariants = ({ canTrack, content }) => {
33
33
  * NOTE: For Vue: after the app is hydrated, we strip the variants from the DOM (on mount) to reduce the amount of HTML in the DOM.
34
34
  * This isn't necessary, just a nice to have.
35
35
  */
36
- if (TARGET === 'vue2' || TARGET === 'vue3' || TARGET === 'svelte')
36
+ if (TARGET === 'vue' || TARGET === 'svelte')
37
37
  return true;
38
38
  if (isBrowser())
39
39
  return false;
@@ -1 +1 @@
1
- export declare const SDK_VERSION = "0.10.0";
1
+ export declare const SDK_VERSION = "0.11.1";
@@ -1 +1 @@
1
- export const SDK_VERSION = "0.10.0";
1
+ export const SDK_VERSION = "0.11.1";
@@ -13,8 +13,7 @@ export function getBlockActions(options) {
13
13
  let eventHandlerName = getEventHandlerName(key);
14
14
  if (options.stripPrefix) {
15
15
  switch (TARGET) {
16
- case 'vue2':
17
- case 'vue3':
16
+ case 'vue':
18
17
  eventHandlerName = eventHandlerName.replace('v-on:', '');
19
18
  break;
20
19
  case 'svelte':
@@ -55,8 +55,7 @@ export function getBlockProperties({ block, context }) {
55
55
  function getStyleAttribute(style) {
56
56
  switch (TARGET) {
57
57
  case 'svelte':
58
- case 'vue2':
59
- case 'vue3':
58
+ case 'vue':
60
59
  case 'solid':
61
60
  return convertStyleMapToCSSArray(style).join(' ');
62
61
  case 'qwik':
@@ -1 +1 @@
1
- export type Target = 'vue3' | 'vue2' | 'reactNative' | 'svelte' | 'qwik' | 'react' | 'solid' | 'rsc';
1
+ export type Target = 'vue' | 'reactNative' | 'svelte' | 'qwik' | 'react' | 'solid' | 'rsc';
@@ -1,12 +1,6 @@
1
1
  import { getBlockProperties } from '../../../../functions/get-block-properties.js';
2
2
  export const getWrapperProps = ({ componentOptions, builderBlock, context, componentRef, includeBlockProps, isInteractive, contextValue }) => {
3
- const interactiveElementProps = {
4
- Wrapper: componentRef,
5
- block: builderBlock,
6
- context,
7
- wrapperProps: componentOptions
8
- };
9
- return isInteractive ? interactiveElementProps : {
3
+ const wrapperPropsWithAttributes = {
10
4
  ...componentOptions,
11
5
  /**
12
6
  * If `noWrap` is set to `true`, then the block's props/attributes are provided to the
@@ -19,4 +13,12 @@ export const getWrapperProps = ({ componentOptions, builderBlock, context, compo
19
13
  })
20
14
  } : {})
21
15
  };
16
+ const interactiveElementProps = {
17
+ Wrapper: componentRef,
18
+ block: builderBlock,
19
+ context,
20
+ wrapperProps: componentOptions,
21
+ includeBlockProps
22
+ };
23
+ return isInteractive ? interactiveElementProps : wrapperPropsWithAttributes;
22
24
  };
@@ -4,6 +4,7 @@
4
4
  import { getBlockProperties } from "../../../functions/get-block-properties.js";
5
5
  export let Wrapper;
6
6
  export let wrapperProps;
7
+ export let includeBlockProps;
7
8
  export let block;
8
9
  export let context;
9
10
  </script>
@@ -11,19 +12,21 @@ export let context;
11
12
  <svelte:component
12
13
  this={Wrapper}
13
14
  {...wrapperProps}
14
- attributes={{
15
- ...getBlockProperties({
16
- block: block,
17
- context: $context,
18
- }),
19
- ...getBlockActions({
20
- block: block,
21
- rootState: $context.rootState,
22
- rootSetState: $context.rootSetState,
23
- localState: $context.localState,
24
- context: $context.context,
25
- }),
26
- }}
15
+ attributes={includeBlockProps
16
+ ? {
17
+ ...getBlockProperties({
18
+ block: block,
19
+ context: $context,
20
+ }),
21
+ ...getBlockActions({
22
+ block: block,
23
+ rootState: $context.rootState,
24
+ rootSetState: $context.rootSetState,
25
+ localState: $context.localState,
26
+ context: $context.context,
27
+ }),
28
+ }
29
+ : {}}
27
30
  >
28
31
  <slot />
29
32
  </svelte:component>
@@ -33,7 +33,7 @@ export const checkShouldRenderVariants = ({ canTrack, content }) => {
33
33
  * NOTE: For Vue: after the app is hydrated, we strip the variants from the DOM (on mount) to reduce the amount of HTML in the DOM.
34
34
  * This isn't necessary, just a nice to have.
35
35
  */
36
- if (TARGET === 'vue2' || TARGET === 'vue3' || TARGET === 'svelte')
36
+ if (TARGET === 'vue' || TARGET === 'svelte')
37
37
  return true;
38
38
  if (isBrowser())
39
39
  return false;
@@ -1 +1 @@
1
- export declare const SDK_VERSION = "0.10.0";
1
+ export declare const SDK_VERSION = "0.11.1";
@@ -1 +1 @@
1
- export const SDK_VERSION = "0.10.0";
1
+ export const SDK_VERSION = "0.11.1";
@@ -13,8 +13,7 @@ export function getBlockActions(options) {
13
13
  let eventHandlerName = getEventHandlerName(key);
14
14
  if (options.stripPrefix) {
15
15
  switch (TARGET) {
16
- case 'vue2':
17
- case 'vue3':
16
+ case 'vue':
18
17
  eventHandlerName = eventHandlerName.replace('v-on:', '');
19
18
  break;
20
19
  case 'svelte':
@@ -55,8 +55,7 @@ export function getBlockProperties({ block, context }) {
55
55
  function getStyleAttribute(style) {
56
56
  switch (TARGET) {
57
57
  case 'svelte':
58
- case 'vue2':
59
- case 'vue3':
58
+ case 'vue':
60
59
  case 'solid':
61
60
  return convertStyleMapToCSSArray(style).join(' ');
62
61
  case 'qwik':
@@ -1 +1 @@
1
- export type Target = 'vue3' | 'vue2' | 'reactNative' | 'svelte' | 'qwik' | 'react' | 'solid' | 'rsc';
1
+ export type Target = 'vue' | 'reactNative' | 'svelte' | 'qwik' | 'react' | 'solid' | 'rsc';
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.10.0",
4
+ "version": "0.11.1",
5
5
  "type": "module",
6
6
  "files": [
7
7
  "lib",
@@ -31,13 +31,7 @@ export const getWrapperProps = ({
31
31
  }: Omit<ComponentProps, 'blockChildren' | 'registeredComponents'> & {
32
32
  contextValue: BuilderContextInterface;
33
33
  }) => {
34
- const interactiveElementProps: InteractiveElementProps = {
35
- Wrapper: componentRef,
36
- block: builderBlock,
37
- context,
38
- wrapperProps: componentOptions
39
- };
40
- return isInteractive ? interactiveElementProps : {
34
+ const wrapperPropsWithAttributes = {
41
35
  ...componentOptions,
42
36
  /**
43
37
  * If `noWrap` is set to `true`, then the block's props/attributes are provided to the
@@ -50,4 +44,12 @@ export const getWrapperProps = ({
50
44
  })
51
45
  } : {})
52
46
  };
47
+ const interactiveElementProps: InteractiveElementProps = {
48
+ Wrapper: componentRef,
49
+ block: builderBlock,
50
+ context,
51
+ wrapperProps: componentOptions,
52
+ includeBlockProps
53
+ };
54
+ return isInteractive ? interactiveElementProps : wrapperPropsWithAttributes;
53
55
  }
@@ -3,7 +3,8 @@
3
3
  Wrapper: any;
4
4
  block: BuilderBlock;
5
5
  context: Writable<BuilderContextInterface>;
6
- wrapperProps: object;
6
+ wrapperProps: Dictionary<any>;
7
+ includeBlockProps: boolean;
7
8
  };
8
9
  </script>
9
10
 
@@ -12,11 +13,15 @@
12
13
  import { getBlockActions } from "../../../functions/get-block-actions.js";
13
14
  import { getBlockProperties } from "../../../functions/get-block-properties.js";
14
15
  import type { BuilderBlock } from "../../../types/builder-block.js";
15
- import type { PropsWithChildren } from "../../../types/typescript.js";
16
+ import type {
17
+ Dictionary,
18
+ PropsWithChildren,
19
+ } from "../../../types/typescript.js";
16
20
  import type { Writable } from "svelte/store";
17
21
 
18
22
  export let Wrapper: PropsWithChildren<InteractiveElementProps>["Wrapper"];
19
23
  export let wrapperProps: PropsWithChildren<InteractiveElementProps>["wrapperProps"];
24
+ export let includeBlockProps: PropsWithChildren<InteractiveElementProps>["includeBlockProps"];
20
25
  export let block: PropsWithChildren<InteractiveElementProps>["block"];
21
26
  export let context: PropsWithChildren<InteractiveElementProps>["context"];
22
27
  </script>
@@ -24,19 +29,21 @@
24
29
  <svelte:component
25
30
  this={Wrapper}
26
31
  {...wrapperProps}
27
- attributes={{
28
- ...getBlockProperties({
29
- block: block,
30
- context: $context,
31
- }),
32
- ...getBlockActions({
33
- block: block,
34
- rootState: $context.rootState,
35
- rootSetState: $context.rootSetState,
36
- localState: $context.localState,
37
- context: $context.context,
38
- }),
39
- }}
32
+ attributes={includeBlockProps
33
+ ? {
34
+ ...getBlockProperties({
35
+ block: block,
36
+ context: $context,
37
+ }),
38
+ ...getBlockActions({
39
+ block: block,
40
+ rootState: $context.rootState,
41
+ rootSetState: $context.rootSetState,
42
+ localState: $context.localState,
43
+ context: $context.context,
44
+ }),
45
+ }
46
+ : {}}
40
47
  >
41
48
  <slot />
42
49
  </svelte:component>
@@ -42,7 +42,7 @@ export const checkShouldRenderVariants = ({
42
42
  * NOTE: For Vue: after the app is hydrated, we strip the variants from the DOM (on mount) to reduce the amount of HTML in the DOM.
43
43
  * This isn't necessary, just a nice to have.
44
44
  */
45
- if (TARGET === 'vue2' || TARGET === 'vue3' || TARGET === 'svelte') return true;
45
+ if (TARGET === 'vue' || TARGET === 'svelte') return true;
46
46
  if (isBrowser()) return false;
47
47
  return true;
48
48
  };
@@ -1 +1 @@
1
- export const SDK_VERSION = "0.10.0"
1
+ export const SDK_VERSION = "0.11.1"
@@ -21,8 +21,7 @@ export function getBlockActions(options: {
21
21
  let eventHandlerName = getEventHandlerName(key);
22
22
  if (options.stripPrefix) {
23
23
  switch (TARGET) {
24
- case 'vue2':
25
- case 'vue3':
24
+ case 'vue':
26
25
  eventHandlerName = eventHandlerName.replace('v-on:', '');
27
26
  break;
28
27
  case 'svelte':
@@ -65,8 +65,7 @@ export function getBlockProperties({
65
65
  function getStyleAttribute(style: Partial<CSSStyleDeclaration>): string | Partial<CSSStyleDeclaration> {
66
66
  switch (TARGET) {
67
67
  case 'svelte':
68
- case 'vue2':
69
- case 'vue3':
68
+ case 'vue':
70
69
  case 'solid':
71
70
  return convertStyleMapToCSSArray(style).join(' ');
72
71
  case 'qwik':
@@ -1 +1 @@
1
- export type Target = 'vue3' | 'vue2' | 'reactNative' | 'svelte' | 'qwik' | 'react' | 'solid' | 'rsc'
1
+ export type Target = 'vue' | 'reactNative' | 'svelte' | 'qwik' | 'react' | 'solid' | 'rsc'