@builder.io/sdk-vue 0.0.1-68 → 0.0.1-70

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/package.json +2 -2
  2. package/vue2/src/blocks/button/button.vue +31 -5
  3. package/vue2/src/blocks/columns/columns.vue +76 -63
  4. package/vue2/src/blocks/columns/component-info.js +3 -2
  5. package/vue2/src/blocks/custom-code/custom-code.vue +70 -60
  6. package/vue2/src/blocks/embed/component-info.js +3 -2
  7. package/vue2/src/blocks/embed/embed.vue +68 -55
  8. package/vue2/src/blocks/form/form.vue +294 -260
  9. package/vue2/src/blocks/fragment/fragment.vue +31 -6
  10. package/vue2/src/blocks/image/component-info.js +3 -2
  11. package/vue2/src/blocks/image/image.vue +77 -62
  12. package/vue2/src/blocks/img/img.vue +38 -17
  13. package/vue2/src/blocks/input/input.vue +37 -18
  14. package/vue2/src/blocks/raw-text/raw-text.vue +34 -13
  15. package/vue2/src/blocks/section/section.vue +32 -6
  16. package/vue2/src/blocks/select/select.vue +35 -7
  17. package/vue2/src/blocks/submit-button/submit-button.vue +29 -5
  18. package/vue2/src/blocks/symbol/symbol.vue +102 -84
  19. package/vue2/src/blocks/text/text.vue +28 -5
  20. package/vue2/src/blocks/textarea/textarea.vue +32 -5
  21. package/vue2/src/blocks/util.js +7 -0
  22. package/vue2/src/blocks/video/video.vue +69 -57
  23. package/vue2/src/components/render-block/block-styles.vue +56 -54
  24. package/vue2/src/components/render-block/render-block.vue +168 -168
  25. package/vue2/src/components/render-block/render-component.vue +35 -9
  26. package/vue2/src/components/render-block/render-repeated-block.vue +55 -32
  27. package/vue2/src/components/render-blocks.vue +66 -52
  28. package/vue2/src/components/render-content/components/render-styles.vue +80 -56
  29. package/vue2/src/components/render-content/render-content.vue +280 -285
  30. package/vue2/src/components/render-inlined-styles.vue +39 -21
  31. package/vue2/src/constants/builder-registered-components.js +3 -0
  32. package/vue2/src/functions/get-fetch.js +2 -2
  33. package/vue2/src/functions/get-processed-block.js +10 -6
  34. package/vue2/src/functions/get-processed-block.test.js +1 -1
  35. package/vue2/src/functions/track.js +71 -2
  36. package/vue2/src/helpers/cookie.js +59 -0
  37. package/vue2/src/helpers/localStorage.js +34 -0
  38. package/vue2/src/helpers/nullable.js +4 -0
  39. package/vue2/src/helpers/sessionId.js +26 -0
  40. package/vue2/src/helpers/time.js +5 -0
  41. package/vue2/src/helpers/url.js +10 -0
  42. package/vue2/src/helpers/url.test.js +15 -0
  43. package/vue2/src/helpers/uuid.js +13 -0
  44. package/vue2/src/helpers/visitorId.js +33 -0
  45. package/vue2/src/scripts/init-editing.js +4 -5
  46. package/vue2/src/types/can-track.js +0 -0
  47. package/vue3/src/blocks/button/button.vue +32 -8
  48. package/vue3/src/blocks/columns/columns.vue +84 -73
  49. package/vue3/src/blocks/columns/component-info.js +3 -2
  50. package/vue3/src/blocks/custom-code/custom-code.vue +70 -62
  51. package/vue3/src/blocks/embed/component-info.js +3 -2
  52. package/vue3/src/blocks/embed/embed.vue +68 -57
  53. package/vue3/src/blocks/form/form.vue +297 -268
  54. package/vue3/src/blocks/fragment/fragment.vue +30 -7
  55. package/vue3/src/blocks/image/component-info.js +3 -2
  56. package/vue3/src/blocks/image/image.vue +86 -73
  57. package/vue3/src/blocks/img/img.vue +34 -15
  58. package/vue3/src/blocks/input/input.vue +37 -20
  59. package/vue3/src/blocks/raw-text/raw-text.vue +33 -14
  60. package/vue3/src/blocks/section/section.vue +31 -7
  61. package/vue3/src/blocks/select/select.vue +34 -8
  62. package/vue3/src/blocks/submit-button/submit-button.vue +28 -6
  63. package/vue3/src/blocks/symbol/symbol.vue +102 -86
  64. package/vue3/src/blocks/text/text.vue +27 -6
  65. package/vue3/src/blocks/textarea/textarea.vue +31 -6
  66. package/vue3/src/blocks/util.js +7 -0
  67. package/vue3/src/blocks/video/video.vue +69 -59
  68. package/vue3/src/components/render-block/block-styles.vue +56 -58
  69. package/vue3/src/components/render-block/render-block.vue +171 -173
  70. package/vue3/src/components/render-block/render-component.vue +35 -16
  71. package/vue3/src/components/render-block/render-repeated-block.vue +55 -34
  72. package/vue3/src/components/render-blocks.vue +65 -58
  73. package/vue3/src/components/render-content/components/render-styles.vue +80 -60
  74. package/vue3/src/components/render-content/render-content.vue +283 -287
  75. package/vue3/src/components/render-inlined-styles.vue +34 -18
  76. package/vue3/src/constants/builder-registered-components.js +3 -0
  77. package/vue3/src/functions/get-fetch.js +2 -2
  78. package/vue3/src/functions/get-processed-block.js +10 -6
  79. package/vue3/src/functions/get-processed-block.test.js +1 -1
  80. package/vue3/src/functions/track.js +71 -2
  81. package/vue3/src/helpers/cookie.js +59 -0
  82. package/vue3/src/helpers/localStorage.js +34 -0
  83. package/vue3/src/helpers/nullable.js +4 -0
  84. package/vue3/src/helpers/sessionId.js +26 -0
  85. package/vue3/src/helpers/time.js +5 -0
  86. package/vue3/src/helpers/url.js +10 -0
  87. package/vue3/src/helpers/url.test.js +15 -0
  88. package/vue3/src/helpers/uuid.js +13 -0
  89. package/vue3/src/helpers/visitorId.js +33 -0
  90. package/vue3/src/scripts/init-editing.js +4 -5
  91. package/vue3/src/types/can-track.js +0 -0
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@builder.io/sdk-vue",
3
3
  "description": "Builder.io SDK for Vue",
4
- "version": "0.0.1-68",
4
+ "version": "0.0.1-70",
5
5
  "dependencies": {
6
6
  "node-fetch": "^2.6.1"
7
7
  },
@@ -37,6 +37,6 @@
37
37
  "vue": ">= 2"
38
38
  },
39
39
  "devDependencies": {
40
- "vue": "^2.6.12"
40
+ "vue": "^2.7"
41
41
  }
42
42
  }
@@ -12,12 +12,38 @@
12
12
  {{ text }}
13
13
  </button>
14
14
  </template>
15
- <script>
16
- export default {
17
- name: "builder-button",
15
+ <script lang="ts">
18
16
 
19
- props: ["attributes", "text", "link", "openLinkInNewTab"],
20
- };
17
+
18
+
19
+
20
+
21
+
22
+
23
+ export interface ButtonProps {
24
+ attributes?: any;
25
+ text?: string;
26
+ link?: string;
27
+ openLinkInNewTab?: boolean;
28
+ }
29
+
30
+ export default {
31
+ name: 'builder-button',
32
+
33
+ props: ["attributes","text","link","openLinkInNewTab"],
34
+
35
+
36
+
37
+
38
+
39
+
40
+
41
+
42
+
43
+
44
+
45
+
46
+ }
21
47
  </script>
22
48
  <style scoped>
23
49
  .button-16nol0lwi20 {
@@ -18,70 +18,83 @@
18
18
  </div>
19
19
  </div>
20
20
  </template>
21
- <script>
22
- const RenderBlocks = () => import("../../components/render-blocks.vue");
23
-
24
- export default {
25
- name: "builder-columns",
26
- components: { "render-blocks": RenderBlocks },
27
- props: [
28
- "space",
29
- "columns",
30
- "stackColumnsAt",
31
- "reverseColumnsWhenStacked",
32
- "builderBlock",
33
- ],
34
-
35
- computed: {
36
- columnsCssVars() {
37
- const flexDir =
38
- this.stackColumnsAt === "never"
39
- ? "inherit"
40
- : this.reverseColumnsWhenStacked
41
- ? "column-reverse"
42
- : "column";
43
- return {
44
- "--flex-dir": flexDir,
45
- "--flex-dir-tablet": this.maybeApplyForTablet(flexDir),
46
- };
47
- },
48
- columnCssVars() {
49
- const width = "100%";
50
- const marginLeft = "0";
51
- return {
52
- "--column-width": width,
53
- "--column-margin-left": marginLeft,
54
- "--column-width-tablet": this.maybeApplyForTablet(width),
55
- "--column-margin-left-tablet": this.maybeApplyForTablet(marginLeft),
56
- };
57
- },
58
- },
59
-
60
- methods: {
61
- getGutterSize() {
62
- return typeof this.space === "number" ? this.space || 0 : 20;
63
- },
64
- getColumns() {
65
- return this.columns || [];
66
- },
67
- getWidth(index) {
68
- const columns = this.getColumns();
69
- return columns[index]?.width || 100 / columns.length;
70
- },
71
- getColumnCssWidth(index) {
72
- const columns = this.getColumns();
73
- const gutterSize = this.getGutterSize();
74
- const subtractWidth =
75
- (gutterSize * (columns.length - 1)) / columns.length;
76
- return `calc(${this.getWidth(index)}% - ${subtractWidth}px)`;
77
- },
78
- maybeApplyForTablet(prop) {
79
- const _stackColumnsAt = this.stackColumnsAt || "tablet";
80
-
81
- return _stackColumnsAt === "tablet" ? prop : "inherit";
82
- },
83
- },
21
+ <script lang="ts">
22
+
23
+
24
+ const RenderBlocks = () => import('../../components/render-blocks.vue')
25
+
26
+
27
+
28
+
29
+ type Column = {
30
+ blocks: any; // TODO: Implement this when support for dynamic CSS lands
31
+
32
+ width?: number;
84
33
  };
34
+ type StackColumnsAt = 'tablet' | 'mobile' | 'never';
35
+ export interface ColumnProps {
36
+ columns?: Column[];
37
+ builderBlock: BuilderBlock; // TODO: Implement this when support for dynamic CSS lands
38
+
39
+ space?: number; // TODO: Implement this when support for dynamic CSS lands
40
+
41
+ stackColumnsAt?: StackColumnsAt; // TODO: Implement this when support for dynamic CSS lands
42
+
43
+ reverseColumnsWhenStacked?: boolean;
44
+ }
45
+
46
+ export default {
47
+ name: 'builder-columns',
48
+ components: { 'render-blocks': RenderBlocks },
49
+ props: ["space","columns","stackColumnsAt","reverseColumnsWhenStacked","builderBlock"],
50
+
51
+
52
+
53
+
54
+
55
+
56
+
57
+
58
+
59
+
60
+
61
+ computed: { columnsCssVars() {
62
+ const flexDir = this.stackColumnsAt === 'never' ? 'inherit' : this.reverseColumnsWhenStacked ? 'column-reverse' : 'column';
63
+ return {
64
+ '--flex-dir': flexDir,
65
+ '--flex-dir-tablet': this.maybeApplyForTablet(flexDir)
66
+ };
67
+ }, columnCssVars() {
68
+ const width = '100%';
69
+ const marginLeft = '0';
70
+ return {
71
+ '--column-width': width,
72
+ '--column-margin-left': marginLeft,
73
+ '--column-width-tablet': this.maybeApplyForTablet(width),
74
+ '--column-margin-left-tablet': this.maybeApplyForTablet(marginLeft)
75
+ };
76
+ },},
77
+
78
+
79
+ methods: { getGutterSize() {
80
+ return typeof this.space === 'number' ? this.space || 0 : 20;
81
+ }, getColumns() {
82
+ return this.columns || [];
83
+ }, getWidth(index) {
84
+ const columns = this.getColumns();
85
+ return columns[index]?.width || 100 / columns.length;
86
+ }, getColumnCssWidth(index) {
87
+ const columns = this.getColumns();
88
+ const gutterSize = this.getGutterSize();
89
+ const subtractWidth = gutterSize * (columns.length - 1) / columns.length;
90
+ return `calc(${this.getWidth(index)}% - ${subtractWidth}px)`;
91
+ }, maybeApplyForTablet(prop) {
92
+ const _stackColumnsAt = this.stackColumnsAt || 'tablet';
93
+
94
+ return _stackColumnsAt === 'tablet' ? prop : 'inherit';
95
+ },},
96
+
97
+ }
85
98
  </script>
86
99
  <style scoped>
87
100
  .div-2fnk003dqad {
@@ -1,3 +1,4 @@
1
+ import { markSerializable } from "../util";
1
2
  const componentInfo = {
2
3
  name: "Columns",
3
4
  builtIn: true,
@@ -186,7 +187,7 @@ const componentInfo = {
186
187
  ]
187
188
  }
188
189
  ],
189
- onChange(options) {
190
+ onChange: markSerializable((options) => {
190
191
  function clearWidths() {
191
192
  columns.forEach((col) => {
192
193
  col.delete("width");
@@ -210,7 +211,7 @@ const componentInfo = {
210
211
  }
211
212
  }
212
213
  }
213
- }
214
+ })
214
215
  },
215
216
  {
216
217
  name: "space",
@@ -3,76 +3,86 @@
3
3
  ref="elem"
4
4
  :class="
5
5
  _classStringToObject(
6
- 'builder-custom-code' + (this.replaceNodes ? ' replace-nodes' : '')
6
+ 'builder-custom-code' + (replaceNodes ? ' replace-nodes' : '')
7
7
  )
8
8
  "
9
9
  v-html="code"
10
10
  ></div>
11
11
  </template>
12
- <script>
13
- export default {
14
- name: "builder-custom-code",
15
-
16
- props: ["replaceNodes", "code"],
17
-
18
- data: () => ({ scriptsInserted: [], scriptsRun: [] }),
19
-
20
- mounted() {
21
- this.findAndRunScripts();
22
- },
23
-
24
- methods: {
25
- findAndRunScripts() {
26
- // TODO: Move this function to standalone one in '@builder.io/utils'
27
- if (this.$refs.elem && typeof window !== "undefined") {
28
- const scripts = this.$refs.elem.getElementsByTagName("script");
29
-
30
- for (let i = 0; i < scripts.length; i++) {
31
- const script = scripts[i];
32
-
33
- if (script.src) {
34
- if (this.scriptsInserted.includes(script.src)) {
35
- continue;
36
- }
37
-
38
- this.scriptsInserted.push(script.src);
39
- const newScript = document.createElement("script");
40
- newScript.async = true;
41
- newScript.src = script.src;
42
- document.head.appendChild(newScript);
43
- } else if (
44
- !script.type ||
45
- [
46
- "text/javascript",
47
- "application/javascript",
48
- "application/ecmascript",
49
- ].includes(script.type)
50
- ) {
51
- if (this.scriptsRun.includes(script.innerText)) {
52
- continue;
53
- }
54
-
55
- try {
56
- this.scriptsRun.push(script.innerText);
57
- new Function(script.innerText)();
58
- } catch (error) {
59
- console.warn("`CustomCode`: Error running script:", error);
60
- }
61
- }
62
- }
12
+ <script lang="ts">
13
+
14
+
15
+
16
+
17
+
18
+
19
+
20
+ export interface CustomCodeProps {
21
+ code: string;
22
+ replaceNodes?: boolean;
23
+ }
24
+
25
+ export default {
26
+ name: 'builder-custom-code',
27
+
28
+ props: ["replaceNodes","code"],
29
+
30
+ data: () => ({ scriptsInserted: [], scriptsRun: [],}),
31
+
32
+
33
+
34
+
35
+
36
+ mounted() {
37
+ this.findAndRunScripts()
38
+ },
39
+
40
+
41
+
42
+
43
+
44
+
45
+ methods: { findAndRunScripts() {
46
+ // TODO: Move this function to standalone one in '@builder.io/utils'
47
+ if (this.$refs.elem && typeof window !== 'undefined') {
48
+ const scripts = this.$refs.elem.getElementsByTagName('script');
49
+
50
+ for (let i = 0; i < scripts.length; i++) {
51
+ const script = scripts[i];
52
+
53
+ if (script.src) {
54
+ if (this.scriptsInserted.includes(script.src)) {
55
+ continue;
63
56
  }
64
- },
65
- _classStringToObject(str) {
66
- const obj = {};
67
- if (typeof str !== "string") {
68
- return obj;
57
+
58
+ this.scriptsInserted.push(script.src);
59
+ const newScript = document.createElement('script');
60
+ newScript.async = true;
61
+ newScript.src = script.src;
62
+ document.head.appendChild(newScript);
63
+ } else if (!script.type || ['text/javascript', 'application/javascript', 'application/ecmascript'].includes(script.type)) {
64
+ if (this.scriptsRun.includes(script.innerText)) {
65
+ continue;
69
66
  }
67
+
68
+ try {
69
+ this.scriptsRun.push(script.innerText);
70
+ new Function(script.innerText)();
71
+ } catch (error) {
72
+ console.warn('`CustomCode`: Error running script:', error);
73
+ }
74
+ }
75
+ }
76
+ }
77
+ },_classStringToObject(str) {
78
+ const obj = {};
79
+ if (typeof str !== 'string') { return obj }
70
80
  const classNames = str.trim().split(/\s+/);
71
81
  for (const name of classNames) {
72
82
  obj[name] = true;
73
83
  }
74
84
  return obj;
75
- },
76
- },
77
- };
85
+ } },
86
+
87
+ }
78
88
  </script>
@@ -1,3 +1,4 @@
1
+ import { markSerializable } from "../util";
1
2
  const componentInfo = {
2
3
  name: "Embed",
3
4
  static: true,
@@ -9,7 +10,7 @@ const componentInfo = {
9
10
  required: true,
10
11
  defaultValue: "",
11
12
  helperText: "e.g. enter a youtube url, google map, etc",
12
- onChange(options) {
13
+ onChange: markSerializable((options) => {
13
14
  const url = options.get("url");
14
15
  if (url) {
15
16
  options.set("content", "Loading...");
@@ -28,7 +29,7 @@ const componentInfo = {
28
29
  } else {
29
30
  options.delete("content");
30
31
  }
31
- }
32
+ })
32
33
  },
33
34
  {
34
35
  name: "content",
@@ -1,60 +1,73 @@
1
1
  <template>
2
2
  <div class="builder-embed" ref="elem" v-html="content"></div>
3
3
  </template>
4
- <script>
5
- import { isJsScript } from "./helpers";
6
-
7
- export default {
8
- name: "builder-embed",
9
-
10
- props: ["content"],
11
-
12
- data: () => ({ scriptsInserted: [], scriptsRun: [], ranInitFn: false }),
13
-
14
- watch: {
15
- onUpdateHook0() {
16
- if (this.$refs.elem && !this.ranInitFn) {
17
- this.ranInitFn = true;
18
- this.findAndRunScripts();
19
- }
20
- },
21
- },
22
-
23
- computed: {
24
- onUpdateHook0() {
25
- return {
26
- 0: this.$refs.elem,
27
- 1: this.ranInitFn,
28
- };
29
- },
30
- },
31
-
32
- methods: {
33
- findAndRunScripts() {
34
- const scripts = this.$refs.elem.getElementsByTagName("script");
35
-
36
- for (let i = 0; i < scripts.length; i++) {
37
- const script = scripts[i];
38
-
39
- if (script.src && !this.scriptsInserted.includes(script.src)) {
40
- this.scriptsInserted.push(script.src);
41
- const newScript = document.createElement("script");
42
- newScript.async = true;
43
- newScript.src = script.src;
44
- document.head.appendChild(newScript);
45
- } else if (
46
- isJsScript(script) &&
47
- !this.scriptsRun.includes(script.innerText)
48
- ) {
49
- try {
50
- this.scriptsRun.push(script.innerText);
51
- new Function(script.innerText)();
52
- } catch (error) {
53
- console.warn("`Embed`: Error running script:", error);
54
- }
55
- }
56
- }
57
- },
58
- },
4
+ <script lang="ts">
5
+
6
+
7
+ import { isJsScript } from './helpers';
8
+
9
+
10
+
11
+
12
+ export interface EmbedProps {
13
+ content: string;
14
+ }
15
+
16
+ export default {
17
+ name: 'builder-embed',
18
+
19
+ props: ["content"],
20
+
21
+ data: () => ({ scriptsInserted: [], scriptsRun: [], ranInitFn: false,}),
22
+
23
+
24
+
25
+
26
+
27
+
28
+
29
+ watch: {
30
+ onUpdateHook0() {
31
+ if (this.$refs.elem && !this.ranInitFn) {
32
+ this.ranInitFn = true;
33
+ this.findAndRunScripts();
34
+ }
35
+ }
36
+
37
+ },
38
+
39
+
40
+
41
+ computed: { onUpdateHook0() {
42
+ return {
43
+ 0: this.$refs.elem,
44
+ 1: this.ranInitFn
59
45
  };
46
+ },},
47
+
48
+
49
+ methods: { findAndRunScripts() {
50
+ const scripts = this.$refs.elem.getElementsByTagName('script');
51
+
52
+ for (let i = 0; i < scripts.length; i++) {
53
+ const script = scripts[i];
54
+
55
+ if (script.src && !this.scriptsInserted.includes(script.src)) {
56
+ this.scriptsInserted.push(script.src);
57
+ const newScript = document.createElement('script');
58
+ newScript.async = true;
59
+ newScript.src = script.src;
60
+ document.head.appendChild(newScript);
61
+ } else if (isJsScript(script) && !this.scriptsRun.includes(script.innerText)) {
62
+ try {
63
+ this.scriptsRun.push(script.innerText);
64
+ new Function(script.innerText)();
65
+ } catch (error) {
66
+ console.warn('`Embed`: Error running script:', error);
67
+ }
68
+ }
69
+ }
70
+ },},
71
+
72
+ }
60
73
  </script>