@builder.io/sdk-svelte 0.0.1-3 → 0.0.1-32

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 (91) hide show
  1. package/README.md +19 -0
  2. package/package.json +8 -1
  3. package/src/blocks/button/button.svelte +35 -48
  4. package/src/blocks/columns/columns.svelte +137 -103
  5. package/src/blocks/columns/component-info.js +26 -1
  6. package/src/blocks/custom-code/custom-code.svelte +58 -53
  7. package/src/blocks/embed/component-info.js +21 -1
  8. package/src/blocks/embed/embed.svelte +45 -57
  9. package/src/blocks/embed/helpers.js +9 -0
  10. package/src/blocks/form/form.svelte +313 -296
  11. package/src/blocks/fragment/fragment.svelte +9 -25
  12. package/src/blocks/image/component-info.js +48 -1
  13. package/src/blocks/image/image.helpers.js +48 -0
  14. package/src/blocks/image/image.svelte +146 -117
  15. package/src/blocks/img/img.svelte +48 -36
  16. package/src/blocks/input/input.svelte +30 -31
  17. package/src/blocks/raw-text/raw-text.svelte +12 -26
  18. package/src/blocks/section/section.svelte +30 -36
  19. package/src/blocks/select/select.svelte +30 -37
  20. package/src/blocks/submit-button/submit-button.svelte +12 -30
  21. package/src/blocks/symbol/component-info.js +1 -0
  22. package/src/blocks/symbol/symbol.svelte +88 -53
  23. package/src/blocks/text/text.svelte +8 -25
  24. package/src/blocks/textarea/textarea.svelte +16 -29
  25. package/src/blocks/util.js +7 -0
  26. package/src/blocks/video/video.svelte +88 -41
  27. package/src/components/render-block/block-styles.svelte +58 -51
  28. package/src/components/render-block/render-block.helpers.js +23 -0
  29. package/src/components/render-block/render-block.svelte +204 -160
  30. package/src/components/render-block/render-component.svelte +30 -0
  31. package/src/components/render-block/render-repeated-block.svelte +45 -0
  32. package/src/components/render-block/types.js +0 -0
  33. package/src/components/render-blocks.svelte +88 -80
  34. package/src/components/render-content/components/render-styles.svelte +59 -63
  35. package/src/components/render-content/index.js +4 -0
  36. package/src/components/render-content/render-content.svelte +316 -207
  37. package/src/components/render-inlined-styles.svelte +26 -48
  38. package/src/constants/builder-registered-components.js +51 -0
  39. package/src/constants/device-sizes.js +3 -21
  40. package/src/context/builder.context.js +7 -1
  41. package/src/functions/camel-to-kebab-case.js +4 -0
  42. package/src/functions/convert-style-object.js +6 -0
  43. package/src/functions/get-block-component-options.js +6 -1
  44. package/src/functions/get-block-styles.js +7 -4
  45. package/src/functions/get-builder-search-params/index.js +12 -1
  46. package/src/functions/get-content/ab-testing.js +38 -0
  47. package/src/functions/get-content/fn.test.js +1 -1
  48. package/src/functions/get-content/index.js +16 -58
  49. package/src/functions/get-content/types.js +0 -0
  50. package/src/functions/get-fetch.js +2 -2
  51. package/src/functions/get-processed-block.js +19 -8
  52. package/src/functions/get-processed-block.test.js +2 -1
  53. package/src/functions/register-component.js +45 -26
  54. package/src/functions/sanitize-styles.js +5 -0
  55. package/src/functions/track.js +71 -2
  56. package/src/helpers/cookie.js +59 -0
  57. package/src/helpers/css.js +12 -0
  58. package/src/helpers/flatten.js +34 -0
  59. package/src/helpers/localStorage.js +34 -0
  60. package/src/helpers/nullable.js +4 -0
  61. package/src/helpers/sessionId.js +26 -0
  62. package/src/helpers/time.js +5 -0
  63. package/src/helpers/url.js +10 -0
  64. package/src/helpers/url.test.js +15 -0
  65. package/src/helpers/uuid.js +13 -0
  66. package/src/helpers/visitorId.js +33 -0
  67. package/src/index-helpers/blocks-exports.js +10 -8
  68. package/src/scripts/init-editing.js +4 -5
  69. package/src/types/can-track.js +0 -0
  70. package/src/types/components.js +0 -0
  71. package/src/types/element.js +0 -0
  72. package/src/blocks/button/index.js +0 -7
  73. package/src/blocks/columns/index.js +0 -7
  74. package/src/blocks/custom-code/index.js +0 -7
  75. package/src/blocks/embed/index.js +0 -7
  76. package/src/blocks/form/index.js +0 -7
  77. package/src/blocks/fragment/index.js +0 -7
  78. package/src/blocks/image/index.js +0 -7
  79. package/src/blocks/img/index.js +0 -7
  80. package/src/blocks/input/index.js +0 -7
  81. package/src/blocks/raw-text/index.js +0 -7
  82. package/src/blocks/section/index.js +0 -7
  83. package/src/blocks/select/index.js +0 -7
  84. package/src/blocks/submit-button/index.js +0 -7
  85. package/src/blocks/symbol/index.js +0 -7
  86. package/src/blocks/text/index.js +0 -7
  87. package/src/blocks/textarea/index.js +0 -7
  88. package/src/blocks/video/index.js +0 -7
  89. package/src/components/error-boundary.svelte +0 -26
  90. package/src/functions/macro-eval.js +0 -5
  91. package/src/functions/previewing-model-name.js +0 -11
@@ -1,27 +1,36 @@
1
- <script>
2
-
3
-
4
-
5
-
6
- import RenderInlinedStyles, { } from '../../render-inlined-styles.svelte';
1
+ <script context="module" lang="ts">
2
+ interface CustomFont {
3
+ family?: string;
4
+ kind?: string;
5
+ fileUrl?: string;
6
+ files?: {
7
+ [key: string]: string;
8
+ };
9
+ }
10
+
11
+ interface Props {
12
+ cssCode?: string;
13
+ customFonts?: CustomFont[];
14
+ }
15
+ </script>
7
16
 
8
-
17
+ <script lang="ts">
18
+ import RenderInlinedStyles from "../../render-inlined-styles.svelte";
9
19
 
10
-
20
+ export let cssCode: Props["cssCode"];
21
+ export let customFonts: Props["customFonts"];
11
22
 
12
-
13
- export let cssCode;
14
- export let customFonts;
15
-
16
- function getCssFromFont(font) {
17
- // TODO: compute what font sizes are used and only load those.......
18
- const family = font.family + (font.kind && !font.kind.includes('#') ? ', ' + font.kind : '');
19
- const name = family.split(',')[0];
20
- const url = font.fileUrl ?? font?.files?.regular;
21
- let str = '';
23
+ const getCssFromFont = function getCssFromFont(font) {
24
+ // TODO: compute what font sizes are used and only load those.......
25
+ const family =
26
+ font.family +
27
+ (font.kind && !font.kind.includes("#") ? ", " + font.kind : "");
28
+ const name = family.split(",")[0];
29
+ const url = font.fileUrl ?? font?.files?.regular;
30
+ let str = "";
22
31
 
23
- if (url && family && name) {
24
- str += `
32
+ if (url && family && name) {
33
+ str += `
25
34
  @font-face {
26
35
  font-family: "${family}";
27
36
  src: local("${name}"), url('${url}') format('woff2');
@@ -29,21 +38,20 @@ if (url && family && name) {
29
38
  font-weight: 400;
30
39
  }
31
40
  `.trim();
32
- }
33
-
34
- if (font.files) {
35
- for (const weight in font.files) {
36
- const isNumber = String(Number(weight)) === weight;
41
+ }
37
42
 
38
- if (!isNumber) {
39
- continue;
40
- } // TODO: maybe limit number loaded
43
+ if (font.files) {
44
+ for (const weight in font.files) {
45
+ const isNumber = String(Number(weight)) === weight;
41
46
 
47
+ if (!isNumber) {
48
+ continue;
49
+ } // TODO: maybe limit number loaded
42
50
 
43
- const weightUrl = font.files[weight];
51
+ const weightUrl = font.files[weight];
44
52
 
45
- if (weightUrl && weightUrl !== url) {
46
- str += `
53
+ if (weightUrl && weightUrl !== url) {
54
+ str += `
47
55
  @font-face {
48
56
  font-family: "${family}";
49
57
  src: url('${weightUrl}') format('woff2');
@@ -51,40 +59,28 @@ if (font.files) {
51
59
  font-weight: ${weight};
52
60
  }
53
61
  `.trim();
62
+ }
63
+ }
54
64
  }
55
- }
56
- }
57
-
58
- return str;
59
- }
60
65
 
61
- function getFontCss({
62
- customFonts
63
- }) {
64
- // TODO: flag for this
65
- // if (!builder.allowCustomFonts) {
66
- // return '';
67
- // }
68
- // TODO: separate internal data from external
69
- return customFonts?.map(font => getCssFromFont(font))?.join(' ') || '';
70
- }
71
- $: injectedStyles = () => {
72
- return `
73
- ${cssCode || ''}
66
+ return str;
67
+ };
68
+
69
+ const getFontCss = function getFontCss({ customFonts }) {
70
+ // TODO: flag for this
71
+ // if (!builder.allowCustomFonts) {
72
+ // return '';
73
+ // }
74
+ // TODO: separate internal data from external
75
+ return customFonts?.map((font) => getCssFromFont(font))?.join(" ") || "";
76
+ };
77
+ $: injectedStyles = () => {
78
+ return `
79
+ ${cssCode || ""}
74
80
  ${getFontCss({
75
- customFonts: customFonts
81
+ customFonts: customFonts,
76
82
  })}`;
77
- };
78
-
79
-
80
-
81
-
82
-
83
-
84
-
85
-
86
-
87
-
88
- </script>
83
+ };
84
+ </script>
89
85
 
90
- <RenderInlinedStyles styles={injectedStyles()} ></RenderInlinedStyles>
86
+ <RenderInlinedStyles styles={injectedStyles()} />
@@ -0,0 +1,4 @@
1
+ import { default as default2 } from "./render-content.svelte";
2
+ export {
3
+ default2 as default
4
+ };