@builder.io/sdk-svelte 0.0.1-12 → 0.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.
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-13",
5
5
  "type": "module",
6
6
  "files": [
7
7
  "src"
@@ -3,11 +3,14 @@
3
3
 
4
4
 
5
5
 
6
- import RenderInlinedStyles, { } from '../render-inlined-styles.svelte';
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';
7
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}
@@ -10,8 +10,9 @@ import { getBlockProperties } from '../../functions/get-block-properties.js'
10
10
  import { getBlockStyles } from '../../functions/get-block-styles.js';
11
11
  import { getBlockTag } from '../../functions/get-block-tag.js';
12
12
  import { getProcessedBlock } from '../../functions/get-processed-block.js';
13
+ import BlockStyles, { } from './block-styles.svelte';
13
14
  import { isEmptyHtmlElement } from './render-block.helpers.js';
14
- import RenderComponentAndStyles, { } from './render-component-and-styles.svelte';
15
+ import RenderComponent, { } from './render-component.svelte';
15
16
 
16
17
 
17
18
 
@@ -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}
@@ -3,7 +3,6 @@
3
3
 
4
4
 
5
5
 
6
- import { TARGET } from '../../constants/target.js';
7
6
  import BlockStyles, { } from './block-styles.svelte';
8
7
  import RenderBlock, { } from './render-block.svelte';
9
8
 
@@ -12,8 +11,7 @@ import RenderBlock, { } from './render-block.svelte';
12
11
 
13
12
 
14
13
 
15
- export let block;
16
- export let componentRef;
14
+ export let componentRef;
17
15
  export let componentOptions;
18
16
  export let blockChildren;
19
17
 
@@ -32,30 +30,29 @@ export let blockChildren;
32
30
  </script>
33
31
 
34
32
 
35
-
36
-
37
- {#if TARGET === 'vue' || TARGET === 'svelte' }
38
-
39
-
40
- <BlockStyles block={block} ></BlockStyles>
33
+ {#if componentRef }
41
34
 
42
35
 
36
+ <svelte:component {...componentOptions} this={componentRef} >
37
+
43
38
 
39
+
44
40
 
45
- {/if}
41
+ {#each blockChildren as child, index }
42
+ <RenderBlock key={'render-block-' + child.id} block={child} ></RenderBlock>
43
+ {/each}
46
44
 
47
-
48
45
 
49
- {#if componentRef }
50
- <svelte:component {...componentOptions} this={componentRef} >
51
-
46
+
52
47
 
53
48
  {#each blockChildren as child, index }
54
- <RenderBlock key={child.id} block={child} ></RenderBlock>
49
+ <BlockStyles key={'block-style-' + child.id} block={child} ></BlockStyles>
55
50
  {/each}
56
51
 
57
52
 
58
- </svelte:component>
53
+ </svelte:component>
54
+
55
+
59
56
 
60
57
 
61
58
  {/if}
@@ -4,6 +4,7 @@
4
4
 
5
5
 
6
6
  import { isEditing } from '../functions/is-editing.js';
7
+ import BlockStyles, { } from './render-block/block-styles.svelte';
7
8
  import RenderBlock, { } from './render-block/render-block.svelte';
8
9
 
9
10
 
@@ -58,12 +59,30 @@ class: className()
58
59
  }} on:click="{event => onClick()}" on:mouseenter="{event => onMouseEnter()}" class={className()} >
59
60
 
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
+
78
+
79
+
61
80
  {#if blocks }
62
81
 
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