@builder.io/sdk-vue 0.0.1-54 โ†’ 0.0.1-55

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/CHANGELOG.md CHANGED
@@ -1,3 +1,8 @@
1
+ ### 0.0.1-54
2
+
3
+ ๐Ÿ› Fix: custom components were not rendering correctly
4
+ ๐Ÿ› Fix: Image component's `srcSet` was not being set correctly
5
+
1
6
  ### 0.0.1-52
2
7
 
3
8
  ๐Ÿงจ Breaking change: the format of the `customComponents` prop has changed from `[{ component, info }]` to `[{ component, ...info }]`.
@@ -1,7 +1,7 @@
1
1
  <template>
2
- <div class="builder-columns div-16nol0lwi20" :style="columnsCssVars">
2
+ <div class="builder-columns div-1be3j8m9ewb" :style="columnsCssVars">
3
3
  <div
4
- class="builder-column div-16nol0lwi20-2"
4
+ class="builder-column div-1be3j8m9ewb-2"
5
5
  v-for="(column, index) in columns"
6
6
  :style="{
7
7
  width: getColumnCssWidth(index),
@@ -74,32 +74,32 @@ export default {
74
74
  };
75
75
  </script>
76
76
  <style scoped>
77
- .div-16nol0lwi20 {
77
+ .div-1be3j8m9ewb {
78
78
  display: flex;
79
79
  align-items: stretch;
80
80
  line-height: normal;
81
81
  }
82
82
  @media (max-width: 999px) {
83
- .div-16nol0lwi20 {
83
+ .div-1be3j8m9ewb {
84
84
  flex-direction: var(--flex-dir-tablet);
85
85
  }
86
86
  }
87
87
  @media (max-width: 639px) {
88
- .div-16nol0lwi20 {
88
+ .div-1be3j8m9ewb {
89
89
  flex-direction: var(--flex-dir);
90
90
  }
91
91
  }
92
- .div-16nol0lwi20-2 {
92
+ .div-1be3j8m9ewb-2 {
93
93
  flex-grow: 1;
94
94
  }
95
95
  @media (max-width: 999px) {
96
- .div-16nol0lwi20-2 {
96
+ .div-1be3j8m9ewb-2 {
97
97
  width: var(--column-width-tablet) !important;
98
98
  margin-left: var(--column-margin-left-tablet) !important;
99
99
  }
100
100
  }
101
101
  @media (max-width: 639px) {
102
- .div-16nol0lwi20-2 {
102
+ .div-1be3j8m9ewb-2 {
103
103
  width: var(--column-width) !important;
104
104
  margin-left: var(--column-margin-left) !important;
105
105
  }
@@ -27,7 +27,7 @@
27
27
  ></builder-blocks>
28
28
 
29
29
  <pre
30
- class="builder-form-error-text pre-4wbls88y960"
30
+ class="builder-form-error-text pre-29wpyomtntv"
31
31
  v-if="submissionState === 'error' && responseData"
32
32
  >
33
33
  {{ JSON.stringify(responseData, null, 2) }}
@@ -302,7 +302,7 @@ export default {
302
302
  };
303
303
  </script>
304
304
  <style scoped>
305
- .pre-4wbls88y960 {
305
+ .pre-29wpyomtntv {
306
306
  padding: 10px;
307
307
  color: red;
308
308
  text-align: center;
@@ -1,9 +1,9 @@
1
1
  <template>
2
- <div class="div-20351ewpue7">
2
+ <div class="div-1ifnufbde19">
3
3
  <picture>
4
4
  <img
5
5
  loading="lazy"
6
- class="img-20351ewpue7"
6
+ class="img-1ifnufbde19"
7
7
  :alt="altText"
8
8
  :role="altText ? 'presentation' : undefined"
9
9
  :style="{
@@ -23,7 +23,7 @@
23
23
  </picture>
24
24
 
25
25
  <div
26
- class="builder-image-sizer div-20351ewpue7-2"
26
+ class="builder-image-sizer div-1ifnufbde19-2"
27
27
  v-if="aspectRatio && !(fitContent && ((builderBlock && builderBlock.children) && (builderBlock && builderBlock.children).length))"
28
28
  :style="{
29
29
  paddingTop: aspectRatio * 100 + '%',
@@ -34,7 +34,7 @@
34
34
 
35
35
  <slot></slot>
36
36
 
37
- <div class="div-20351ewpue7-3" v-if="!fitContent">
37
+ <div class="div-1ifnufbde19-3" v-if="!fitContent">
38
38
  <slot></slot>
39
39
  </div>
40
40
  </div>
@@ -71,10 +71,10 @@ export default {
71
71
  };
72
72
  </script>
73
73
  <style scoped>
74
- .div-20351ewpue7 {
74
+ .div-1ifnufbde19 {
75
75
  position: relative;
76
76
  }
77
- .img-20351ewpue7 {
77
+ .img-1ifnufbde19 {
78
78
  opacity: 1;
79
79
  transition: opacity 0.2s ease-in-out;
80
80
  position: absolute;
@@ -83,12 +83,12 @@ export default {
83
83
  top: 0px;
84
84
  left: 0px;
85
85
  }
86
- .div-20351ewpue7-2 {
86
+ .div-1ifnufbde19-2 {
87
87
  width: 100%;
88
88
  pointer-events: none;
89
89
  font-size: 0;
90
90
  }
91
- .div-20351ewpue7-3 {
91
+ .div-1ifnufbde19-3 {
92
92
  display: flex;
93
93
  flex-direction: column;
94
94
  align-items: stretch;
@@ -1,7 +1,13 @@
1
1
  <template>
2
- <render-inlined-styles :styles="css"></render-inlined-styles>
2
+ <render-inlined-styles
3
+ v-if="TARGET === 'vue' || TARGET === 'svelte'"
4
+ :styles="css"
5
+ ></render-inlined-styles>
3
6
  </template>
4
7
  <script>
8
+ import { TARGET } from "../../constants/target.js";
9
+ import BuilderContext from "../../context/builder.context";
10
+ import { getProcessedBlock } from "../../functions/get-processed-block.js";
5
11
  import RenderInlinedStyles from "../render-inlined-styles";
6
12
 
7
13
  export default {
@@ -9,16 +15,29 @@ export default {
9
15
  components: { "render-inlined-styles": async () => RenderInlinedStyles },
10
16
  props: ["block"],
11
17
 
18
+ data: () => ({ TARGET }),
19
+
20
+ inject: {
21
+ builderContext: "BuilderContext",
22
+ },
23
+
12
24
  computed: {
25
+ useBlock() {
26
+ return getProcessedBlock({
27
+ block: this.block,
28
+ state: this.builderContext.state,
29
+ context: this.builderContext.context,
30
+ });
31
+ },
13
32
  css() {
14
33
  // TODO: media queries
15
- const styleObject = this.block.responsiveStyles?.large;
34
+ const styleObject = this.useBlock.responsiveStyles?.large;
16
35
 
17
36
  if (!styleObject) {
18
37
  return "";
19
38
  }
20
39
 
21
- let str = `.${this.block.id} {`;
40
+ let str = `.${this.useBlock.id} {`;
22
41
 
23
42
  for (const key in styleObject) {
24
43
  const value = styleObject[key];
@@ -1,58 +1,36 @@
1
1
  <template>
2
2
  <component
3
- v-bind="propertiesAndActions"
3
+ v-bind="attributes"
4
4
  v-if="!isEmptyHtmlElement(tagName)"
5
- :style="css"
6
5
  :is="tagName"
7
6
  >
8
- <block-styles
9
- v-if="TARGET === 'vue' || TARGET === 'svelte'"
10
- :block="useBlock"
11
- ></block-styles>
12
-
13
- <component
14
- v-bind="componentOptions"
15
- v-if="componentRef"
16
- :builderBlock="useBlock"
17
- :is="componentRef"
18
- >
19
- <render-block
20
- v-for="(child, index) in children"
21
- :block="child"
22
- :key="child.id"
23
- ></render-block>
24
- </component>
7
+ <render-component
8
+ :blockChildren="children"
9
+ :componentRef="componentRef"
10
+ :componentOptions="componentOptions"
11
+ ></render-component>
25
12
 
26
13
  <render-block
27
14
  v-for="(child, index) in noCompRefChildren"
28
15
  :block="child"
29
- :key="child.id"
16
+ :key="'render-block-' + child.id"
30
17
  ></render-block>
18
+ <block-styles
19
+ v-for="(child, index) in noCompRefChildren"
20
+ :block="child"
21
+ :key="'block-style-' + child.id"
22
+ ></block-styles>
31
23
  </component>
32
- <component
33
- v-bind="propertiesAndActions"
34
- v-else=""
35
- :style="css"
36
- :is="tagName"
37
- ></component>
24
+ <component v-bind="attributes" v-else="" :is="tagName"></component>
38
25
 
39
- <component
40
- v-bind="componentOptions"
26
+ <render-component
41
27
  v-else=""
42
- :attributes="propertiesAndActions"
43
- :builderBlock="useBlock"
44
- :style="css"
45
- :is="componentRef"
46
- >
47
- <render-block
48
- v-for="(child, index) in children"
49
- :block="child"
50
- :key="child.id"
51
- ></render-block>
52
- </component>
28
+ :blockChildren="children"
29
+ :componentRef="componentRef"
30
+ :componentOptions="componentOptions"
31
+ ></render-component>
53
32
  </template>
54
33
  <script>
55
- import { TARGET } from "../../constants/target.js";
56
34
  import BuilderContext from "../../context/builder.context";
57
35
  import { getBlockActions } from "../../functions/get-block-actions.js";
58
36
  import { getBlockComponentOptions } from "../../functions/get-block-component-options.js";
@@ -62,13 +40,17 @@ import { getBlockTag } from "../../functions/get-block-tag.js";
62
40
  import { getProcessedBlock } from "../../functions/get-processed-block.js";
63
41
  import BlockStyles from "./block-styles";
64
42
  import { isEmptyHtmlElement } from "./render-block.helpers.js";
43
+ import RenderComponent from "./render-component";
65
44
 
66
45
  export default {
67
46
  name: "render-block",
68
- components: { "block-styles": async () => BlockStyles },
47
+ components: {
48
+ "render-component": async () => RenderComponent,
49
+ "block-styles": async () => BlockStyles,
50
+ },
69
51
  props: ["block"],
70
52
 
71
- data: () => ({ TARGET, isEmptyHtmlElement }),
53
+ data: () => ({ isEmptyHtmlElement }),
72
54
 
73
55
  inject: {
74
56
  builderContext: "BuilderContext",
@@ -115,7 +97,7 @@ export default {
115
97
  context: this.builderContext.context,
116
98
  });
117
99
  },
118
- propertiesAndActions() {
100
+ attributes() {
119
101
  return {
120
102
  ...getBlockProperties(this.useBlock),
121
103
  ...getBlockActions({
@@ -123,13 +105,26 @@ export default {
123
105
  state: this.builderContext.state,
124
106
  context: this.builderContext.context,
125
107
  }),
108
+ style: getBlockStyles(this.useBlock),
126
109
  };
127
110
  },
128
- css() {
129
- return getBlockStyles(this.useBlock);
111
+ shouldWrap() {
112
+ return !this.componentInfo?.noWrap;
130
113
  },
131
114
  componentOptions() {
132
- return getBlockComponentOptions(this.useBlock);
115
+ return {
116
+ ...getBlockComponentOptions(this.useBlock),
117
+
118
+ /**
119
+ * These attributes are passed to the wrapper element when there is one. If `noWrap` is set to true, then
120
+ * they are provided to the component itself directly.
121
+ */
122
+ ...(this.shouldWrap
123
+ ? {}
124
+ : {
125
+ attributes: this.attributes,
126
+ }),
127
+ };
133
128
  },
134
129
  children() {
135
130
  // TO-DO: When should `canHaveChildren` dictate rendering?
@@ -139,6 +134,10 @@ export default {
139
134
  return this.useBlock.children ?? [];
140
135
  },
141
136
  noCompRefChildren() {
137
+ /**
138
+ * When there is no `componentRef`, there might still be children that need to be rendered. In this case,
139
+ * we render them outside of `componentRef`
140
+ */
142
141
  return this.componentRef ? [] : this.children;
143
142
  },
144
143
  },
@@ -0,0 +1,27 @@
1
+ <template>
2
+ <component v-bind="componentOptions" v-if="componentRef" :is="componentRef">
3
+ <render-block
4
+ v-for="(child, index) in blockChildren"
5
+ :block="child"
6
+ :key="'render-block-' + child.id"
7
+ ></render-block>
8
+ <block-styles
9
+ v-for="(child, index) in blockChildren"
10
+ :block="child"
11
+ :key="'block-style-' + child.id"
12
+ ></block-styles>
13
+ </component>
14
+ </template>
15
+ <script>
16
+ import BlockStyles from "./block-styles";
17
+ import RenderBlock from "./render-block";
18
+
19
+ export default {
20
+ name: "render-component",
21
+ components: {
22
+ "render-block": async () => RenderBlock,
23
+ "block-styles": async () => BlockStyles,
24
+ },
25
+ props: ["componentRef", "componentOptions", "blockChildren"],
26
+ };
27
+ </script>
@@ -13,17 +13,27 @@
13
13
  <render-block
14
14
  v-for="(block, index) in blocks"
15
15
  :block="block"
16
- :key="block.id"
16
+ :key="'render-block-' + block.id"
17
17
  ></render-block>
18
+
19
+ <block-styles
20
+ v-for="(block, index) in blocks"
21
+ :block="block"
22
+ :key="'block-style-' + block.id"
23
+ ></block-styles>
18
24
  </div>
19
25
  </template>
20
26
  <script>
21
27
  import { isEditing } from "../functions/is-editing.js";
28
+ import BlockStyles from "./render-block/block-styles";
22
29
  import RenderBlock from "./render-block/render-block";
23
30
 
24
31
  export default {
25
32
  name: "render-blocks",
26
- components: { "render-block": async () => RenderBlock },
33
+ components: {
34
+ "render-block": async () => RenderBlock,
35
+ "block-styles": async () => BlockStyles,
36
+ },
27
37
  props: ["blocks", "parent", "path"],
28
38
 
29
39
  computed: {
@@ -1,4 +1,6 @@
1
1
  var __defProp = Object.defineProperty;
2
+ var __defProps = Object.defineProperties;
3
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
2
4
  var __getOwnPropSymbols = Object.getOwnPropertySymbols;
3
5
  var __hasOwnProp = Object.prototype.hasOwnProperty;
4
6
  var __propIsEnum = Object.prototype.propertyIsEnumerable;
@@ -14,6 +16,7 @@ var __spreadValues = (a, b) => {
14
16
  }
15
17
  return a;
16
18
  };
19
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
17
20
  var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
18
21
  var __export = (target, all) => {
19
22
  __markAsModule(target);
@@ -25,5 +28,7 @@ __export(exports, {
25
28
  });
26
29
  function getBlockComponentOptions(block) {
27
30
  var _a;
28
- return __spreadValues(__spreadValues({}, (_a = block.component) == null ? void 0 : _a.options), block.options);
31
+ return __spreadProps(__spreadValues(__spreadValues({}, (_a = block.component) == null ? void 0 : _a.options), block.options), {
32
+ builderBlock: block
33
+ });
29
34
  }
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-54",
4
+ "version": "0.0.1-55",
5
5
  "dependencies": {
6
6
  "node-fetch": "^2.6.1"
7
7
  },
@@ -1,4 +1,6 @@
1
1
  var __defProp = Object.defineProperty;
2
+ var __defProps = Object.defineProperties;
3
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
2
4
  var __getOwnPropSymbols = Object.getOwnPropertySymbols;
3
5
  var __hasOwnProp = Object.prototype.hasOwnProperty;
4
6
  var __propIsEnum = Object.prototype.propertyIsEnumerable;
@@ -14,6 +16,7 @@ var __spreadValues = (a, b) => {
14
16
  }
15
17
  return a;
16
18
  };
19
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
17
20
  var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
18
21
  var __export = (target, all) => {
19
22
  __markAsModule(target);
@@ -25,5 +28,7 @@ __export(exports, {
25
28
  });
26
29
  function getBlockComponentOptions(block) {
27
30
  var _a;
28
- return __spreadValues(__spreadValues({}, (_a = block.component) == null ? void 0 : _a.options), block.options);
31
+ return __spreadProps(__spreadValues(__spreadValues({}, (_a = block.component) == null ? void 0 : _a.options), block.options), {
32
+ builderBlock: block
33
+ });
29
34
  }
@@ -1,4 +1,6 @@
1
1
  var __defProp = Object.defineProperty;
2
+ var __defProps = Object.defineProperties;
3
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
2
4
  var __getOwnPropSymbols = Object.getOwnPropertySymbols;
3
5
  var __hasOwnProp = Object.prototype.hasOwnProperty;
4
6
  var __propIsEnum = Object.prototype.propertyIsEnumerable;
@@ -14,6 +16,7 @@ var __spreadValues = (a, b) => {
14
16
  }
15
17
  return a;
16
18
  };
19
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
17
20
  var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
18
21
  var __export = (target, all) => {
19
22
  __markAsModule(target);
@@ -25,5 +28,7 @@ __export(exports, {
25
28
  });
26
29
  function getBlockComponentOptions(block) {
27
30
  var _a;
28
- return __spreadValues(__spreadValues({}, (_a = block.component) == null ? void 0 : _a.options), block.options);
31
+ return __spreadProps(__spreadValues(__spreadValues({}, (_a = block.component) == null ? void 0 : _a.options), block.options), {
32
+ builderBlock: block
33
+ });
29
34
  }