@builder.io/sdk-svelte 0.0.1-2 → 0.0.1-20

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 (78) hide show
  1. package/README.md +19 -0
  2. package/package.json +22 -4
  3. package/src/blocks/button/button.svelte +1 -0
  4. package/src/blocks/columns/columns.svelte +13 -13
  5. package/src/blocks/custom-code/custom-code.svelte +3 -3
  6. package/src/blocks/embed/embed.svelte +3 -3
  7. package/src/blocks/form/form.svelte +5 -5
  8. package/src/blocks/fragment/fragment.svelte +1 -0
  9. package/src/blocks/image/image.svelte +9 -8
  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/component-info.js +1 -0
  17. package/src/blocks/symbol/symbol.svelte +11 -6
  18. package/src/blocks/text/text.svelte +1 -0
  19. package/src/blocks/textarea/textarea.svelte +1 -0
  20. package/src/blocks/video/video.svelte +1 -0
  21. package/src/components/render-block/block-styles.svelte +41 -27
  22. package/src/components/render-block/render-block.helpers.js +23 -0
  23. package/src/components/render-block/render-block.svelte +58 -49
  24. package/src/components/render-block/render-component.svelte +58 -0
  25. package/src/components/render-blocks.svelte +29 -10
  26. package/src/components/render-content/components/render-styles.svelte +6 -6
  27. package/src/components/render-content/index.js +4 -0
  28. package/src/components/render-content/render-content.svelte +72 -33
  29. package/src/components/render-inlined-styles.svelte +4 -2
  30. package/src/constants/builder-registered-components.js +45 -0
  31. package/src/constants/device-sizes.js +3 -21
  32. package/src/context/builder.context.js +1 -1
  33. package/src/functions/camel-to-kebab-case.js +4 -0
  34. package/src/functions/evaluate.js +2 -2
  35. package/src/functions/fast-clone.js +4 -0
  36. package/src/functions/get-block-actions.js +2 -2
  37. package/src/functions/get-block-component-options.js +6 -1
  38. package/src/functions/get-block-styles.js +3 -3
  39. package/src/functions/get-content/index.js +1 -1
  40. package/src/functions/get-fetch.js +1 -1
  41. package/src/functions/get-processed-block.js +3 -3
  42. package/src/functions/get-processed-block.test.js +1 -1
  43. package/src/functions/if-target.js +1 -1
  44. package/src/functions/is-editing.js +1 -1
  45. package/src/functions/is-iframe.js +1 -1
  46. package/src/functions/is-previewing.js +2 -2
  47. package/src/functions/on-change.test.js +1 -1
  48. package/src/functions/previewing-model-name.js +1 -1
  49. package/src/functions/register-component.js +30 -13
  50. package/src/functions/register.js +1 -1
  51. package/src/functions/set-editor-settings.js +1 -1
  52. package/src/functions/set.test.js +1 -1
  53. package/src/functions/track.js +3 -3
  54. package/src/helpers/css.js +12 -0
  55. package/src/index-helpers/blocks-exports.js +10 -8
  56. package/src/index.js +10 -10
  57. package/src/scripts/init-editing.js +4 -4
  58. package/src/types/components.js +0 -0
  59. package/src/types/element.js +0 -0
  60. package/src/blocks/button/index.js +0 -7
  61. package/src/blocks/columns/index.js +0 -7
  62. package/src/blocks/custom-code/index.js +0 -7
  63. package/src/blocks/embed/index.js +0 -7
  64. package/src/blocks/form/index.js +0 -7
  65. package/src/blocks/fragment/index.js +0 -7
  66. package/src/blocks/image/index.js +0 -7
  67. package/src/blocks/img/index.js +0 -7
  68. package/src/blocks/input/index.js +0 -7
  69. package/src/blocks/raw-text/index.js +0 -7
  70. package/src/blocks/section/index.js +0 -7
  71. package/src/blocks/select/index.js +0 -7
  72. package/src/blocks/submit-button/index.js +0 -7
  73. package/src/blocks/symbol/index.js +0 -7
  74. package/src/blocks/text/index.js +0 -7
  75. package/src/blocks/textarea/index.js +0 -7
  76. package/src/blocks/video/index.js +0 -7
  77. package/src/components/error-boundary.svelte +0 -26
  78. package/src/functions/macro-eval.js +0 -5
@@ -3,17 +3,17 @@
3
3
 
4
4
 
5
5
 
6
- import { TARGET } from '../../constants/target';
7
- import BuilderContext, { } from '../../context/builder.context';
8
- import { getBlockActions } from '../../functions/get-block-actions';
9
- import { getBlockComponentOptions } from '../../functions/get-block-component-options';
10
- import { getBlockProperties } from '../../functions/get-block-properties';
11
- import { getBlockStyles } from '../../functions/get-block-styles';
12
- import { getBlockTag } from '../../functions/get-block-tag';
13
- import { getProcessedBlock } from '../../functions/get-processed-block';
14
- import { components } from '../../functions/register-component';
15
- import BlockStyles, { } from './block-styles.svelte';
16
-
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
+
17
17
 
18
18
 
19
19
  import { getContext, setContext } from "svelte";
@@ -29,20 +29,29 @@ if (!componentName) {
29
29
  return null;
30
30
  }
31
31
 
32
- const ref = components[componentName];
32
+ const ref = builderContext.registeredComponents[componentName];
33
33
 
34
- if (componentName && !ref) {
34
+ if (!ref) {
35
35
  // TODO: Public doc page with more info about this message
36
36
  console.warn(`
37
37
  Could not find a registered component named "${componentName}".
38
38
  If you registered it, is the file that registered it imported by the file that needs to render it?`);
39
+ return undefined;
40
+ } else {
41
+ return ref;
39
42
  }
40
-
41
- return ref;
42
43
  };
43
44
 
44
45
  $: componentInfo = () => {
45
- return component?.()?.info;
46
+ if (component()) {
47
+ const {
48
+ component: _,
49
+ ...info
50
+ } = component();
51
+ return info;
52
+ } else {
53
+ return undefined;
54
+ }
46
55
  };
47
56
 
48
57
  $: componentRef = () => {
@@ -61,22 +70,32 @@ return getProcessedBlock({
61
70
  });
62
71
  };
63
72
 
64
- $: propertiesAndActions = () => {
73
+ $: attributes = () => {
65
74
  return { ...getBlockProperties(useBlock()),
66
75
  ...getBlockActions({
67
76
  block: useBlock(),
68
77
  state: builderContext.state,
69
78
  context: builderContext.context
70
- })
79
+ }),
80
+ style: getBlockStyles(useBlock())
71
81
  };
72
82
  };
73
83
 
74
- $: css = () => {
75
- return getBlockStyles(useBlock());
84
+ $: shouldWrap = () => {
85
+ return !componentInfo?.()?.noWrap;
76
86
  };
77
87
 
78
88
  $: componentOptions = () => {
79
- return getBlockComponentOptions(useBlock());
89
+ return { ...getBlockComponentOptions(useBlock()),
90
+
91
+ /**
92
+ * These attributes are passed to the wrapper element when there is one. If `noWrap` is set to true, then
93
+ * they are provided to the component itself directly.
94
+ */
95
+ ...(shouldWrap() ? {} : {
96
+ attributes: attributes()
97
+ })
98
+ };
80
99
  };
81
100
 
82
101
  $: children = () => {
@@ -88,6 +107,10 @@ return useBlock().children ?? [];
88
107
  };
89
108
 
90
109
  $: noCompRefChildren = () => {
110
+ /**
111
+ * When there is no `componentRef`, there might still be children that need to be rendered. In this case,
112
+ * we render them outside of `componentRef`
113
+ */
91
114
  return componentRef() ? [] : children();
92
115
  };
93
116
 
@@ -103,44 +126,30 @@ return componentRef() ? [] : children();
103
126
  </script>
104
127
 
105
128
 
129
+ {#if shouldWrap() }
130
+
106
131
 
107
132
 
108
- {#if !componentInfo?.()?.noWrap }
133
+ {#if !isEmptyHtmlElement(tagName()) }
109
134
 
110
135
 
111
- <svelte:element {...propertiesAndActions()} style={css()} this={tagName()} >
136
+ <svelte:element {...attributes()} this={tagName()} >
112
137
 
113
-
114
- {#if TARGET === 'vue' || TARGET === 'svelte' }
115
-
116
-
117
- <BlockStyles block={useBlock()} ></BlockStyles>
138
+ <RenderComponent blockChildren={children()} componentRef={componentRef()} componentOptions={componentOptions()} ></RenderComponent>
118
139
 
119
140
 
120
141
 
121
-
122
- {/if}
123
-
124
142
 
125
143
 
126
- {#if componentRef() }
127
- <svelte:component {...componentOptions()} builderBlock={useBlock()} this={componentRef()} >
128
-
129
-
130
- {#each children() as child, index }
131
- <svelte:self block={child} ></svelte:self>
144
+ {#each noCompRefChildren() as child, index }
145
+ <svelte:self key={'render-block-' + child.id} block={child} ></svelte:self>
132
146
  {/each}
133
147
 
134
148
 
135
- </svelte:component>
136
-
137
-
138
- {/if}
139
-
140
149
 
141
150
 
142
151
  {#each noCompRefChildren() as child, index }
143
- <svelte:self block={child} ></svelte:self>
152
+ <BlockStyles key={'block-style-' + child.id} block={child} ></BlockStyles>
144
153
  {/each}
145
154
 
146
155
 
@@ -150,14 +159,14 @@ return componentRef() ? [] : children();
150
159
 
151
160
 
152
161
  {:else}
153
- <svelte:component {...componentOptions()} attributes={propertiesAndActions()} builderBlock={useBlock()} style={css()} this={componentRef()} >
154
-
162
+ <svelte:element {...attributes()} this={tagName()} ></svelte:element>
155
163
 
156
- {#each children() as child, index }
157
- <svelte:self block={child} ></svelte:self>
158
- {/each}
164
+ {/if}
165
+
166
+
159
167
 
160
168
 
161
- </svelte:component>
169
+ {:else}
170
+ <RenderComponent blockChildren={children()} componentRef={componentRef()} componentOptions={componentOptions()} ></RenderComponent>
162
171
 
163
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';
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
 
@@ -15,7 +16,7 @@ import RenderBlock, { } from './render-block/render-block.svelte';
15
16
  export let parent;
16
17
  export let path;
17
18
 
18
- function onClick() {
19
+ const onClick = function onClick() {
19
20
  if (isEditing() && !blocks?.length) {
20
21
  window.parent?.postMessage({
21
22
  type: 'builder.clickEmptyBlocks',
@@ -25,9 +26,9 @@ if (isEditing() && !blocks?.length) {
25
26
  }
26
27
  }, '*');
27
28
  }
28
- }
29
+ };
29
30
 
30
- function onMouseEnter() {
31
+ const onMouseEnter = function onMouseEnter() {
31
32
  if (isEditing() && !blocks?.length) {
32
33
  window.parent?.postMessage({
33
34
  type: 'builder.hoverEmptyBlocks',
@@ -37,7 +38,7 @@ if (isEditing() && !blocks?.length) {
37
38
  }
38
39
  }, '*');
39
40
  }
40
- }
41
+ };
41
42
  $: className = () => {
42
43
  return 'builder-blocks' + (!blocks?.length ? ' no-blocks' : '');
43
44
  };
@@ -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={className() + 'div'} 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
 
@@ -13,7 +13,7 @@
13
13
  export let cssCode;
14
14
  export let customFonts;
15
15
 
16
- function getCssFromFont(font) {
16
+ const getCssFromFont = function getCssFromFont(font) {
17
17
  // TODO: compute what font sizes are used and only load those.......
18
18
  const family = font.family + (font.kind && !font.kind.includes('#') ? ', ' + font.kind : '');
19
19
  const name = family.split(',')[0];
@@ -56,9 +56,9 @@ if (font.files) {
56
56
  }
57
57
 
58
58
  return str;
59
- }
59
+ };
60
60
 
61
- function getFontCss({
61
+ const getFontCss = function getFontCss({
62
62
  customFonts
63
63
  }) {
64
64
  // TODO: flag for this
@@ -67,7 +67,7 @@ customFonts
67
67
  // }
68
68
  // TODO: separate internal data from external
69
69
  return customFonts?.map(font => getCssFromFont(font))?.join(' ') || '';
70
- }
70
+ };
71
71
  $: injectedStyles = () => {
72
72
  return `
73
73
  ${cssCode || ''}
@@ -0,0 +1,4 @@
1
+ import { default as default2 } from "./render-content.svelte";
2
+ export {
3
+ default2 as default
4
+ };
@@ -3,20 +3,22 @@
3
3
  import { afterUpdate } from 'svelte'
4
4
  import { onDestroy } from 'svelte'
5
5
 
6
- import { TARGET } from '../../constants/target';
7
- import BuilderContext, { } from '../../context/builder.context';
8
- import { evaluate } from '../../functions/evaluate';
9
- import { convertSearchParamsToQueryObject , getBuilderSearchParams } from '../../functions/get-builder-search-params';
10
- import { getContent } from '../../functions/get-content';
11
- import { getFetch } from '../../functions/get-fetch';
12
- import { isBrowser } from '../../functions/is-browser';
13
- import { isEditing } from '../../functions/is-editing';
14
- import { isPreviewing } from '../../functions/is-previewing';
15
- import { previewingModelName } from '../../functions/previewing-model-name';
16
- import { track } from '../../functions/track';
17
- import RenderBlocks, { } from '../render-blocks.svelte';
18
- import RenderContentStyles, { } from './components/render-styles.svelte';
19
-
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
+
20
22
 
21
23
 
22
24
  import { getContext, setContext } from "svelte";
@@ -24,10 +26,11 @@ import RenderContentStyles, { } from './components/render-styles.svelte';
24
26
 
25
27
  export let content;
26
28
  export let data;
29
+ export let customComponents;
27
30
  export let model;
28
31
  export let apiKey;
29
32
 
30
- function processMessage(event) {
33
+ const processMessage = function processMessage(event) {
31
34
  const {
32
35
  data
33
36
  } = event;
@@ -54,9 +57,9 @@ if (data) {
54
57
  }
55
58
  }
56
59
  }
57
- }
60
+ };
58
61
 
59
- function evaluateJsCode() {
62
+ const evaluateJsCode = function evaluateJsCode() {
60
63
  // run any dynamic JS code attached to content
61
64
  const jsCode = useContent?.()?.data?.jsCode;
62
65
 
@@ -67,17 +70,17 @@ if (jsCode) {
67
70
  state: contentState()
68
71
  });
69
72
  }
70
- }
73
+ };
71
74
 
72
- function evalExpression(expression) {
75
+ const evalExpression = function evalExpression(expression) {
73
76
  return expression.replace(/{{([^}]+)}}/g, (_match, group) => evaluate({
74
77
  code: group,
75
78
  context: context(),
76
79
  state: contentState()
77
80
  }));
78
- }
81
+ };
79
82
 
80
- function handleRequest({
83
+ const handleRequest = function handleRequest({
81
84
  url,
82
85
  key
83
86
  }) {
@@ -92,9 +95,9 @@ const fetchAndSetState = async () => {
92
95
  };
93
96
 
94
97
  fetchAndSetState();
95
- }
98
+ };
96
99
 
97
- function runHttpRequests() {
100
+ const runHttpRequests = function runHttpRequests() {
98
101
  const requests = useContent?.()?.data?.httpRequests ?? {};
99
102
  Object.entries(requests).forEach(([key, url]) => {
100
103
  if (url && (!httpReqsData()[key] || isEditing())) {
@@ -105,18 +108,20 @@ Object.entries(requests).forEach(([key, url]) => {
105
108
  });
106
109
  }
107
110
  });
108
- }
111
+ };
109
112
 
110
- function emitStateUpdate() {
111
- window.dispatchEvent(new CustomEvent('builder:component:stateChange', {
112
- detail: {
113
- state: contentState(),
114
- ref: {
115
- name: model
113
+ const emitStateUpdate = function emitStateUpdate() {
114
+ if (isEditing()) {
115
+ window.dispatchEvent(new CustomEvent('builder:component:stateChange', {
116
+ detail: {
117
+ state: contentState(),
118
+ ref: {
119
+ name: model
120
+ }
116
121
  }
117
- }
118
- }));
122
+ }));
119
123
  }
124
+ };
120
125
  $: useContent = () => {
121
126
  const mergedContent = { ...content,
122
127
  ...overrideContent,
@@ -139,6 +144,19 @@ $: context = () => {
139
144
  return {};
140
145
  };
141
146
 
147
+ $: allRegisteredComponents = () => {
148
+ const allComponentsArray = [...getDefaultRegisteredComponents(), // While this `components` object is deprecated, we must maintain support for it.
149
+ // Since users are able to override our default components, we need to make sure that we do not break such
150
+ // existing usage.
151
+ // This is why we spread `components` after the default Builder.io components, but before the `customComponents`,
152
+ // which is the new standard way of providing custom components, and must therefore take precedence.
153
+ ...components, ...(customComponents || [])];
154
+ const allComponents = allComponentsArray.reduce((acc, curr) => ({ ...acc,
155
+ [curr.name]: curr
156
+ }), {});
157
+ return allComponents;
158
+ };
159
+
142
160
  $: httpReqsData = () => {
143
161
  return {};
144
162
  };
@@ -152,6 +170,8 @@ return contentState();
152
170
  return context();
153
171
  }, get apiKey() {
154
172
  return apiKey;
173
+ }, get registeredComponents() {
174
+ return allRegisteredComponents();
155
175
  },});
156
176
  let overrideContent = null;
157
177
  let update = 0;
@@ -159,6 +179,10 @@ let overrideState = {};
159
179
 
160
180
  onMount(() => { if (isBrowser()) {
161
181
  if (isEditing()) {
182
+ Object.values(allRegisteredComponents()).forEach(registeredComponent => {
183
+ const message = createRegisterComponentMessage(registeredComponent);
184
+ window.parent?.postMessage(message, '*');
185
+ });
162
186
  window.addEventListener('message', processMessage);
163
187
  window.addEventListener('builder:component:stateChangeListenerActivated', emitStateUpdate);
164
188
  }
@@ -194,7 +218,22 @@ runHttpRequests();
194
218
  emitStateUpdate();
195
219
  } });
196
220
 
197
- afterUpdate(() => { evaluateJsCode(); });afterUpdate(() => { runHttpRequests(); });afterUpdate(() => { emitStateUpdate(); })
221
+
222
+ function onUpdateFn_0() {
223
+ evaluateJsCode();
224
+ }
225
+ $: onUpdateFn_0(...[useContent?.()?.data?.jsCode])
226
+ ;
227
+ function onUpdateFn_1() {
228
+ runHttpRequests();
229
+ }
230
+ $: onUpdateFn_1(...[useContent?.()?.data?.httpRequests])
231
+ ;
232
+ function onUpdateFn_2() {
233
+ emitStateUpdate();
234
+ }
235
+ $: onUpdateFn_2(...[contentState()])
236
+
198
237
 
199
238
  onDestroy(() => { if (isBrowser()) {
200
239
  window.removeEventListener('message', processMessage);
@@ -3,8 +3,8 @@
3
3
 
4
4
 
5
5
 
6
- import { TARGET } from '../constants/target';
7
-
6
+ import { TARGET } from '../constants/target.js';
7
+
8
8
 
9
9
 
10
10
 
@@ -38,6 +38,8 @@ return 'sty' + 'le';
38
38
  {#if TARGET === 'svelte' }
39
39
 
40
40
 
41
+
42
+
41
43
  {@html injectedStyleScript()}
42
44
 
43
45
 
@@ -0,0 +1,45 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
3
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
4
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
5
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
6
+ var __spreadValues = (a, b) => {
7
+ for (var prop in b || (b = {}))
8
+ if (__hasOwnProp.call(b, prop))
9
+ __defNormalProp(a, prop, b[prop]);
10
+ if (__getOwnPropSymbols)
11
+ for (var prop of __getOwnPropSymbols(b)) {
12
+ if (__propIsEnum.call(b, prop))
13
+ __defNormalProp(a, prop, b[prop]);
14
+ }
15
+ return a;
16
+ };
17
+ import { default as Button } from "../blocks/button/button.svelte";
18
+ import { componentInfo as buttonComponentInfo } from "../blocks/button/component-info";
19
+ import { default as Columns } from "../blocks/columns/columns.svelte";
20
+ import { componentInfo as columnsComponentInfo } from "../blocks/columns/component-info";
21
+ import { componentInfo as fragmentComponentInfo } from "../blocks/fragment/component-info";
22
+ import { default as Fragment } from "../blocks/fragment/fragment.svelte";
23
+ import { componentInfo as imageComponentInfo } from "../blocks/image/component-info";
24
+ import { default as Image } from "../blocks/image/image.svelte";
25
+ import { componentInfo as sectionComponentInfo } from "../blocks/section/component-info";
26
+ import { default as Section } from "../blocks/section/section.svelte";
27
+ import { componentInfo as symbolComponentInfo } from "../blocks/symbol/component-info";
28
+ import { default as Symbol } from "../blocks/symbol/symbol.svelte";
29
+ import { componentInfo as textComponentInfo } from "../blocks/text/component-info";
30
+ import { default as Text } from "../blocks/text/text.svelte";
31
+ import { componentInfo as videoComponentInfo } from "../blocks/video/component-info";
32
+ import { default as Video } from "../blocks/video/video.svelte";
33
+ const getDefaultRegisteredComponents = () => [
34
+ __spreadValues({ component: Columns }, columnsComponentInfo),
35
+ __spreadValues({ component: Image }, imageComponentInfo),
36
+ __spreadValues({ component: Text }, textComponentInfo),
37
+ __spreadValues({ component: Video }, videoComponentInfo),
38
+ __spreadValues({ component: Symbol }, symbolComponentInfo),
39
+ __spreadValues({ component: Button }, buttonComponentInfo),
40
+ __spreadValues({ component: Section }, sectionComponentInfo),
41
+ __spreadValues({ component: Fragment }, fragmentComponentInfo)
42
+ ];
43
+ export {
44
+ getDefaultRegisteredComponents
45
+ };
@@ -1,10 +1,4 @@
1
- const sizeNames = ["xsmall", "small", "medium", "large"];
2
- const sizes = {
3
- xsmall: {
4
- min: 0,
5
- default: 0,
6
- max: 0
7
- },
1
+ const SIZES = {
8
2
  small: {
9
3
  min: 320,
10
4
  default: 321,
@@ -19,21 +13,9 @@ const sizes = {
19
13
  min: 990,
20
14
  default: 991,
21
15
  max: 1200
22
- },
23
- getWidthForSize(size) {
24
- return this[size].default;
25
- },
26
- getSizeForWidth(width) {
27
- for (const size of sizeNames) {
28
- const value = this[size];
29
- if (width <= value.max) {
30
- return size;
31
- }
32
- }
33
- return "large";
34
16
  }
35
17
  };
18
+ const getMaxWidthQueryForSize = (size) => `@media (max-width: ${SIZES[size].max}px)`;
36
19
  export {
37
- sizeNames,
38
- sizes
20
+ getMaxWidthQueryForSize
39
21
  };
@@ -1,6 +1,6 @@
1
1
  const key = Symbol();
2
2
  var stdin_default = {
3
- Builder: { content: null, context: {}, state: {}, apiKey: null },
3
+ Builder: { content: null, context: {}, state: {}, apiKey: null, registeredComponents: {} },
4
4
  key
5
5
  };
6
6
  export {
@@ -0,0 +1,4 @@
1
+ const camelToKebabCase = (string) => string.replace(/([a-z0-9]|(?=[A-Z]))([A-Z])/g, "$1-$2").toLowerCase();
2
+ export {
3
+ camelToKebabCase
4
+ };