@builder.io/sdk-svelte 0.0.1-12 → 0.0.1-15

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/README.md +4 -0
  2. package/package.json +1 -1
  3. package/src/blocks/button/button.svelte +1 -0
  4. package/src/blocks/columns/columns.svelte +2 -2
  5. package/src/blocks/custom-code/custom-code.svelte +1 -1
  6. package/src/blocks/embed/embed.svelte +1 -1
  7. package/src/blocks/form/form.svelte +3 -3
  8. package/src/blocks/fragment/fragment.svelte +1 -0
  9. package/src/blocks/image/image.svelte +5 -4
  10. package/src/blocks/img/img.svelte +2 -2
  11. package/src/blocks/input/input.svelte +1 -1
  12. package/src/blocks/raw-text/raw-text.svelte +1 -0
  13. package/src/blocks/section/section.svelte +1 -0
  14. package/src/blocks/select/select.svelte +1 -1
  15. package/src/blocks/submit-button/submit-button.svelte +1 -0
  16. package/src/blocks/symbol/symbol.svelte +4 -4
  17. package/src/blocks/text/text.svelte +1 -0
  18. package/src/blocks/textarea/textarea.svelte +1 -0
  19. package/src/blocks/video/video.svelte +1 -0
  20. package/src/components/error-boundary.svelte +1 -0
  21. package/src/components/render-block/block-styles.svelte +28 -8
  22. package/src/components/render-block/render-block.svelte +23 -13
  23. package/src/components/render-block/render-component.svelte +58 -0
  24. package/src/components/render-blocks.svelte +25 -6
  25. package/src/components/render-content/components/render-styles.svelte +2 -2
  26. package/src/components/render-content/render-content.svelte +16 -16
  27. package/src/components/render-inlined-styles.svelte +2 -2
  28. package/src/index-helpers/blocks-exports.js +2 -0
  29. package/src/components/render-block/render-component-and-styles.svelte +0 -61
package/README.md CHANGED
@@ -2,6 +2,10 @@
2
2
 
3
3
  This is the Svelte SDK. It is currently in beta.
4
4
 
5
+ ## Mitosis
6
+
7
+ This SDK is generated by [Mitosis](https://github.com/BuilderIO/mitosis). To see the Mitosis source-code, go [here](../../).
8
+
5
9
  ## Feature Support
6
10
 
7
11
  To check the status of the SDK, look at [these tables](../../README.md#feature-implementation).
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.0.1-12",
4
+ "version": "0.0.1-15",
5
5
  "type": "module",
6
6
  "files": [
7
7
  "src"
@@ -3,8 +3,8 @@
3
3
 
4
4
 
5
5
 
6
- import RenderBlocks, { } from '../../components/render-blocks.svelte';
7
-
6
+ import RenderBlocks from '../../components/render-blocks.svelte';
7
+
8
8
 
9
9
 
10
10
 
@@ -5,6 +5,7 @@
5
5
 
6
6
 
7
7
 
8
+
8
9
 
9
10
 
10
11
 
@@ -16,7 +17,6 @@ export let code;
16
17
  function findAndRunScripts() {
17
18
  // TODO: Move this function to standalone one in '@builder.io/utils'
18
19
  if (elem && typeof window !== 'undefined') {
19
- /** @type {HTMLScriptElement[]} */
20
20
  const scripts = elem.getElementsByTagName('script');
21
21
 
22
22
  for (let i = 0; i < scripts.length; i++) {
@@ -5,6 +5,7 @@
5
5
 
6
6
 
7
7
 
8
+
8
9
 
9
10
 
10
11
 
@@ -15,7 +16,6 @@ export let content;
15
16
  function findAndRunScripts() {
16
17
  // TODO: Move this function to standalone one in '@builder.io/utils'
17
18
  if (elem && typeof window !== 'undefined') {
18
- /** @type {HTMLScriptElement[]} */
19
19
  const scripts = elem.getElementsByTagName('script');
20
20
 
21
21
  for (let i = 0; i < scripts.length; i++) {
@@ -3,9 +3,9 @@
3
3
 
4
4
 
5
5
 
6
- import RenderBlock, { } from '../../components/render-block/render-block.svelte';
7
- import { isEditing } from '../../functions/is-editing.js';
8
-
6
+ import RenderBlock from '../../components/render-block/render-block.svelte';
7
+ import { isEditing } from '../../functions/is-editing.js';
8
+
9
9
 
10
10
 
11
11
 
@@ -5,6 +5,7 @@
5
5
 
6
6
 
7
7
 
8
+
8
9
 
9
10
 
10
11
 
@@ -34,17 +35,17 @@ export let builderBlock;
34
35
 
35
36
  </script>
36
37
 
37
- <div >
38
+ <div class="div" >
38
39
 
39
40
  <picture >
40
41
 
41
- <img loading="lazy" alt={altText} role={altText ? 'presentation' : undefined} style={{
42
+ <img loading="lazy" class="img" alt={altText} role={altText ? 'presentation' : undefined} style={{
42
43
  objectPosition: backgroundSize || 'center',
43
44
  objectFit: backgroundSize || 'cover'
44
- }} class={'builder-image' + (className ? ' ' + className : '')} src={image} srcSet={srcset} sizes={sizes} />
45
+ }} class={'builder-image' + (className ? ' ' + className : '')} src={image} srcset={srcset} sizes={sizes} />
45
46
 
46
47
 
47
- <source srcSet={srcset} />
48
+ <source srcset={srcset} />
48
49
 
49
50
  </picture>
50
51
 
@@ -3,8 +3,8 @@
3
3
 
4
4
 
5
5
 
6
- import { isEditing } from '../../functions/is-editing.js';
7
-
6
+ import { isEditing } from '../../functions/is-editing.js';
7
+
8
8
 
9
9
 
10
10
 
@@ -3,7 +3,7 @@
3
3
 
4
4
 
5
5
 
6
- import { isEditing } from '../../functions/is-editing.js';
6
+ import { isEditing } from '../../functions/is-editing.js';
7
7
 
8
8
 
9
9
 
@@ -3,7 +3,7 @@
3
3
 
4
4
 
5
5
 
6
- import { isEditing } from '../../functions/is-editing.js';
6
+ import { isEditing } from '../../functions/is-editing.js';
7
7
 
8
8
 
9
9
 
@@ -3,10 +3,10 @@
3
3
  import { afterUpdate } from 'svelte'
4
4
 
5
5
 
6
- import RenderContent, { } from '../../components/render-content/render-content.svelte';
7
- import BuilderContext, { } from '../../context/builder.context';
8
- import { getContent } from '../../functions/get-content/index.js';
9
-
6
+ import RenderContent from '../../components/render-content/render-content.svelte';
7
+ import BuilderContext from '../../context/builder.context';
8
+ import { getContent } from '../../functions/get-content/index.js';
9
+
10
10
 
11
11
 
12
12
  import { getContext, setContext } from "svelte";
@@ -3,11 +3,14 @@
3
3
 
4
4
 
5
5
 
6
- import RenderInlinedStyles, { } from '../render-inlined-styles.svelte';
7
-
6
+ import { TARGET } from '../../constants/target.js';
7
+ import BuilderContext from '../../context/builder.context';
8
+ import { getProcessedBlock } from '../../functions/get-processed-block.js';
9
+ import RenderInlinedStyles from '../render-inlined-styles.svelte';
10
+
8
11
 
9
12
 
10
-
13
+ import { getContext, setContext } from "svelte";
11
14
 
12
15
 
13
16
  export let block;
@@ -15,15 +18,23 @@
15
18
  function camelToKebabCase(string) {
16
19
  return string.replace(/([a-z0-9]|(?=[A-Z]))([A-Z])/g, '$1-$2').toLowerCase();
17
20
  }
18
- $: css = () => {
21
+ $: useBlock = () => {
22
+ return getProcessedBlock({
23
+ block: block,
24
+ state: builderContext.state,
25
+ context: builderContext.context
26
+ });
27
+ };
28
+
29
+ $: css = () => {
19
30
  // TODO: media queries
20
- const styleObject = block.responsiveStyles?.large;
31
+ const styleObject = useBlock().responsiveStyles?.large;
21
32
 
22
33
  if (!styleObject) {
23
34
  return '';
24
35
  }
25
36
 
26
- let str = `.${block.id} {`;
37
+ let str = `.${useBlock().id} {`;
27
38
 
28
39
  for (const key in styleObject) {
29
40
  const value = styleObject[key];
@@ -37,7 +48,7 @@ str += '}';
37
48
  return str;
38
49
  };
39
50
 
40
-
51
+ let builderContext = getContext(BuilderContext.key);
41
52
 
42
53
 
43
54
 
@@ -48,4 +59,13 @@ return str;
48
59
 
49
60
  </script>
50
61
 
51
- <RenderInlinedStyles styles={css()} ></RenderInlinedStyles>
62
+
63
+ {#if TARGET === 'vue' || TARGET === 'svelte' }
64
+
65
+
66
+ <RenderInlinedStyles styles={css()} ></RenderInlinedStyles>
67
+
68
+
69
+
70
+
71
+ {/if}
@@ -3,16 +3,17 @@
3
3
 
4
4
 
5
5
 
6
- import BuilderContext, { } from '../../context/builder.context';
7
- import { getBlockActions } from '../../functions/get-block-actions.js';
8
- import { getBlockComponentOptions } from '../../functions/get-block-component-options.js';
9
- import { getBlockProperties } from '../../functions/get-block-properties.js';
10
- import { getBlockStyles } from '../../functions/get-block-styles.js';
11
- import { getBlockTag } from '../../functions/get-block-tag.js';
12
- import { getProcessedBlock } from '../../functions/get-processed-block.js';
13
- import { isEmptyHtmlElement } from './render-block.helpers.js';
14
- import RenderComponentAndStyles, { } from './render-component-and-styles.svelte';
15
-
6
+ import BuilderContext from '../../context/builder.context';
7
+ import { getBlockActions } from '../../functions/get-block-actions.js';
8
+ import { getBlockComponentOptions } from '../../functions/get-block-component-options.js';
9
+ import { getBlockProperties } from '../../functions/get-block-properties.js';
10
+ import { getBlockStyles } from '../../functions/get-block-styles.js';
11
+ import { getBlockTag } from '../../functions/get-block-tag.js';
12
+ import { getProcessedBlock } from '../../functions/get-processed-block.js';
13
+ import BlockStyles from './block-styles.svelte';
14
+ import { isEmptyHtmlElement } from './render-block.helpers.js';
15
+ import RenderComponent from './render-component.svelte';
16
+
16
17
 
17
18
 
18
19
  import { getContext, setContext } from "svelte";
@@ -134,12 +135,21 @@ return componentRef() ? [] : children();
134
135
 
135
136
  <svelte:element {...attributes()} this={tagName()} >
136
137
 
137
- <RenderComponentAndStyles block={useBlock()} blockChildren={children()} componentRef={componentRef()} componentOptions={componentOptions()} ></RenderComponentAndStyles>
138
+ <RenderComponent blockChildren={children()} componentRef={componentRef()} componentOptions={componentOptions()} ></RenderComponent>
139
+
140
+
141
+
142
+
143
+
144
+ {#each noCompRefChildren() as child, index }
145
+ <svelte:self key={'render-block-' + child.id} block={child} ></svelte:self>
146
+ {/each}
147
+
138
148
 
139
149
 
140
150
 
141
151
  {#each noCompRefChildren() as child, index }
142
- <svelte:self key={child.id} block={child} ></svelte:self>
152
+ <BlockStyles key={'block-style-' + child.id} block={child} ></BlockStyles>
143
153
  {/each}
144
154
 
145
155
 
@@ -157,6 +167,6 @@ return componentRef() ? [] : children();
157
167
 
158
168
 
159
169
  {:else}
160
- <RenderComponentAndStyles block={useBlock()} blockChildren={children()} componentRef={componentRef()} componentOptions={componentOptions()} ></RenderComponentAndStyles>
170
+ <RenderComponent blockChildren={children()} componentRef={componentRef()} componentOptions={componentOptions()} ></RenderComponent>
161
171
 
162
172
  {/if}
@@ -0,0 +1,58 @@
1
+ <script>
2
+
3
+
4
+
5
+
6
+ import BlockStyles from './block-styles.svelte';
7
+ import RenderBlock from './render-block.svelte';
8
+
9
+
10
+
11
+
12
+
13
+
14
+ export let componentRef;
15
+ export let componentOptions;
16
+ export let blockChildren;
17
+
18
+
19
+
20
+
21
+
22
+
23
+
24
+
25
+
26
+
27
+
28
+
29
+
30
+ </script>
31
+
32
+
33
+ {#if componentRef }
34
+
35
+
36
+ <svelte:component {...componentOptions} this={componentRef} >
37
+
38
+
39
+
40
+
41
+ {#each blockChildren as child, index }
42
+ <RenderBlock key={'render-block-' + child.id} block={child} ></RenderBlock>
43
+ {/each}
44
+
45
+
46
+
47
+
48
+ {#each blockChildren as child, index }
49
+ <BlockStyles key={'block-style-' + child.id} block={child} ></BlockStyles>
50
+ {/each}
51
+
52
+
53
+ </svelte:component>
54
+
55
+
56
+
57
+
58
+ {/if}
@@ -3,9 +3,10 @@
3
3
 
4
4
 
5
5
 
6
- import { isEditing } from '../functions/is-editing.js';
7
- import RenderBlock, { } from './render-block/render-block.svelte';
8
-
6
+ import { isEditing } from '../functions/is-editing.js';
7
+ import BlockStyles from './render-block/block-styles.svelte';
8
+ import RenderBlock from './render-block/render-block.svelte';
9
+
9
10
 
10
11
 
11
12
 
@@ -53,9 +54,27 @@ return 'builder-blocks' + (!blocks?.length ? ' no-blocks' : '');
53
54
 
54
55
  </script>
55
56
 
56
- <div builder-path={path} builder-parent-id={parent} dataSet={{
57
+ <div class="div" class={className()} builder-path={path} builder-parent-id={parent} dataSet={{
57
58
  class: className()
58
- }} on:click="{event => onClick()}" on:mouseenter="{event => onMouseEnter()}" class={className()} >
59
+ }} on:click="{event => onClick()}" on:mouseenter="{event => onMouseEnter()}" >
60
+
61
+
62
+
63
+
64
+ {#if blocks }
65
+
66
+
67
+
68
+ {#each blocks as block, index }
69
+ <RenderBlock key={'render-block-' + block.id} block={block} ></RenderBlock>
70
+ {/each}
71
+
72
+
73
+
74
+
75
+
76
+ {/if}
77
+
59
78
 
60
79
 
61
80
  {#if blocks }
@@ -63,7 +82,7 @@ class: className()
63
82
 
64
83
 
65
84
  {#each blocks as block, index }
66
- <RenderBlock key={block.id} block={block} ></RenderBlock>
85
+ <BlockStyles key={'block-style-' + block.id} block={block} ></BlockStyles>
67
86
  {/each}
68
87
 
69
88
 
@@ -3,8 +3,8 @@
3
3
 
4
4
 
5
5
 
6
- import RenderInlinedStyles, { } from '../../render-inlined-styles.svelte';
7
-
6
+ import RenderInlinedStyles from '../../render-inlined-styles.svelte';
7
+
8
8
 
9
9
 
10
10
 
@@ -3,22 +3,22 @@
3
3
  import { afterUpdate } from 'svelte'
4
4
  import { onDestroy } from 'svelte'
5
5
 
6
- import { getDefaultRegisteredComponents } from '../../constants/builder-registered-components.js';
7
- import { TARGET } from '../../constants/target.js';
8
- import BuilderContext, { } from '../../context/builder.context';
9
- import { evaluate } from '../../functions/evaluate.js';
10
- import { convertSearchParamsToQueryObject , getBuilderSearchParams } from '../../functions/get-builder-search-params/index.js';
11
- import { getContent } from '../../functions/get-content/index.js';
12
- import { getFetch } from '../../functions/get-fetch.js';
13
- import { isBrowser } from '../../functions/is-browser.js';
14
- import { isEditing } from '../../functions/is-editing.js';
15
- import { isPreviewing } from '../../functions/is-previewing.js';
16
- import { previewingModelName } from '../../functions/previewing-model-name.js';
17
- import { components , createRegisterComponentMessage } from '../../functions/register-component.js';
18
- import { track } from '../../functions/track.js';
19
- import RenderBlocks, { } from '../render-blocks.svelte';
20
- import RenderContentStyles, { } from './components/render-styles.svelte';
21
-
6
+ import { getDefaultRegisteredComponents } from '../../constants/builder-registered-components.js';
7
+ import { TARGET } from '../../constants/target.js';
8
+ import BuilderContext from '../../context/builder.context';
9
+ import { evaluate } from '../../functions/evaluate.js';
10
+ import { convertSearchParamsToQueryObject, getBuilderSearchParams } from '../../functions/get-builder-search-params/index.js';
11
+ import { getContent } from '../../functions/get-content/index.js';
12
+ import { getFetch } from '../../functions/get-fetch.js';
13
+ import { isBrowser } from '../../functions/is-browser.js';
14
+ import { isEditing } from '../../functions/is-editing.js';
15
+ import { isPreviewing } from '../../functions/is-previewing.js';
16
+ import { previewingModelName } from '../../functions/previewing-model-name.js';
17
+ import { components, createRegisterComponentMessage } from '../../functions/register-component.js';
18
+ import { track } from '../../functions/track.js';
19
+ import RenderBlocks from '../render-blocks.svelte';
20
+ import RenderContentStyles from './components/render-styles.svelte';
21
+
22
22
 
23
23
 
24
24
  import { getContext, setContext } from "svelte";
@@ -3,8 +3,8 @@
3
3
 
4
4
 
5
5
 
6
- import { TARGET } from '../constants/target.js';
7
-
6
+ import { TARGET } from '../constants/target.js';
7
+
8
8
 
9
9
 
10
10
 
@@ -7,11 +7,13 @@ import { default as default7 } from "../blocks/button/button.svelte";
7
7
  import { default as default8 } from "../blocks/section/section.svelte";
8
8
  import { default as default9 } from "../blocks/fragment/fragment.svelte";
9
9
  import { default as default10 } from "../components/render-content/render-content.svelte";
10
+ import { default as default11 } from "../components/render-blocks.svelte";
10
11
  export {
11
12
  default7 as Button,
12
13
  default2 as Columns,
13
14
  default9 as Fragment,
14
15
  default3 as Image,
16
+ default11 as RenderBlocks,
15
17
  default10 as RenderContent,
16
18
  default8 as Section,
17
19
  default6 as Symbol,
@@ -1,61 +0,0 @@
1
- <script>
2
-
3
-
4
-
5
-
6
- import { TARGET } from '../../constants/target.js';
7
- import BlockStyles, { } from './block-styles.svelte';
8
- import RenderBlock, { } from './render-block.svelte';
9
-
10
-
11
-
12
-
13
-
14
-
15
- export let block;
16
- export let componentRef;
17
- export let componentOptions;
18
- export let blockChildren;
19
-
20
-
21
-
22
-
23
-
24
-
25
-
26
-
27
-
28
-
29
-
30
-
31
-
32
- </script>
33
-
34
-
35
-
36
-
37
- {#if TARGET === 'vue' || TARGET === 'svelte' }
38
-
39
-
40
- <BlockStyles block={block} ></BlockStyles>
41
-
42
-
43
-
44
-
45
- {/if}
46
-
47
-
48
-
49
- {#if componentRef }
50
- <svelte:component {...componentOptions} this={componentRef} >
51
-
52
-
53
- {#each blockChildren as child, index }
54
- <RenderBlock key={child.id} block={child} ></RenderBlock>
55
- {/each}
56
-
57
-
58
- </svelte:component>
59
-
60
-
61
- {/if}