@builder.io/react 8.2.4 → 8.2.6

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.
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@builder.io/react",
3
- "version": "8.2.4",
3
+ "version": "8.2.6",
4
4
  "description": "",
5
5
  "keywords": [],
6
6
  "main": "dist/builder-react.cjs.js",
@@ -26,6 +26,17 @@ var __assign = (this && this.__assign) || function () {
26
26
  };
27
27
  return __assign.apply(this, arguments);
28
28
  };
29
+ var __rest = (this && this.__rest) || function (s, e) {
30
+ var t = {};
31
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
32
+ t[p] = s[p];
33
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
34
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
35
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
36
+ t[p[i]] = s[p[i]];
37
+ }
38
+ return t;
39
+ };
29
40
  var __importDefault = (this && this.__importDefault) || function (mod) {
30
41
  return (mod && mod.__esModule) ? mod : { "default": mod };
31
42
  };
@@ -55,12 +66,18 @@ var ImgComponent = /** @class */ (function (_super) {
55
66
  ImgComponent.prototype.render = function () {
56
67
  var attributes = this.props.attributes || {};
57
68
  var srcset = this.getSrcSet();
58
- return (react_1.default.createElement("img", __assign({ loading: "lazy" }, this.props.attributes, { src: this.props.image || attributes.src, srcSet: srcset })));
69
+ var userStyle = attributes.style, restAttributes = __rest(attributes, ["style"]);
70
+ var defaultStyle = {
71
+ objectFit: this.props.backgroundSize,
72
+ objectPosition: this.props.backgroundPosition,
73
+ aspectRatio: this.props.aspectRatio,
74
+ };
75
+ var mergedStyle = __assign(__assign({}, defaultStyle), userStyle);
76
+ return (react_1.default.createElement("img", __assign({ loading: "lazy" }, restAttributes, { src: this.props.image || attributes.src, srcSet: srcset, alt: this.props.altText, title: this.props.title, style: mergedStyle, className: "builder-raw-img" })));
59
77
  };
60
78
  return ImgComponent;
61
79
  }(react_1.default.Component));
62
80
  exports.Img = (0, with_builder_1.withBuilder)(ImgComponent, {
63
- // friendlyName?
64
81
  name: 'Raw:Img',
65
82
  hideFromInsertMenu: true,
66
83
  image: 'https://firebasestorage.googleapis.com/v0/b/builder-3b0a2.appspot.com/o/images%2Fbaseline-insert_photo-24px.svg?alt=media&token=4e5d0ef4-f5e8-4e57-b3a9-38d63a9b9dc4',
@@ -72,8 +89,57 @@ exports.Img = (0, with_builder_1.withBuilder)(ImgComponent, {
72
89
  allowedFileTypes: file_types_constant_1.IMAGE_FILE_TYPES,
73
90
  required: true,
74
91
  },
92
+ {
93
+ name: 'backgroundSize',
94
+ type: 'text',
95
+ defaultValue: 'cover',
96
+ enum: [
97
+ {
98
+ label: 'contain',
99
+ value: 'contain',
100
+ helperText: 'The image should never get cropped',
101
+ },
102
+ {
103
+ label: 'cover',
104
+ value: 'cover',
105
+ helperText: "The image should fill it's box, cropping when needed",
106
+ },
107
+ ],
108
+ },
109
+ {
110
+ name: 'backgroundPosition',
111
+ type: 'text',
112
+ defaultValue: 'center',
113
+ enum: [
114
+ 'center',
115
+ 'top',
116
+ 'left',
117
+ 'right',
118
+ 'bottom',
119
+ 'top left',
120
+ 'top right',
121
+ 'bottom left',
122
+ 'bottom right',
123
+ ],
124
+ },
125
+ {
126
+ name: 'altText',
127
+ type: 'string',
128
+ helperText: 'Text to display when the user has images off',
129
+ },
130
+ {
131
+ name: 'title',
132
+ type: 'string',
133
+ helperText: 'Text to display when hovering over the asset',
134
+ },
135
+ {
136
+ name: 'aspectRatio',
137
+ type: 'number',
138
+ helperText: "This is the ratio of height/width, e.g. set to 1.5 for a 300px wide and 200px tall photo. Set to 0 to not force the image to maintain it's aspect ratio",
139
+ advanced: true,
140
+ defaultValue: 0.7041,
141
+ },
75
142
  ],
76
143
  noWrap: true,
77
- static: true,
78
144
  });
79
145
  //# sourceMappingURL=Img.js.map
@@ -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,EAAE,QAAQ;YACd,UAAU,EAAE,8CAA8C;SAC3D;QACD;YACE,IAAI,EAAE,aAAa;YACnB,IAAI,EAAE,QAAQ;YACd,UAAU,EACR,yJAAyJ;YAC3J,QAAQ,EAAE,IAAI;YACd,YAAY,EAAE,MAAM;SACrB;KACF;IAED,MAAM,EAAE,IAAI;CACb,CAAC,CAAC"}
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.SDK_VERSION = void 0;
4
- exports.SDK_VERSION = '8.2.4';
4
+ exports.SDK_VERSION = '8.2.6';
5
5
  //# sourceMappingURL=sdk-version.js.map
@@ -3,5 +3,10 @@ export interface ImgProps {
3
3
  attributes?: any;
4
4
  image?: string;
5
5
  builderBlock?: BuilderElement;
6
+ aspectRatio?: number;
7
+ backgroundSize?: string;
8
+ backgroundPosition?: string;
9
+ altText?: string;
10
+ title?: string;
6
11
  }
7
12
  export declare const Img: Function;
@@ -1 +1 @@
1
- export declare const SDK_VERSION = "8.2.4";
1
+ export declare const SDK_VERSION = "8.2.6";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@builder.io/react",
3
- "version": "8.2.4",
3
+ "version": "8.2.6",
4
4
  "description": "",
5
5
  "keywords": [],
6
6
  "main": "dist/builder-react.cjs.js",
@@ -97,7 +97,7 @@
97
97
  "react-dom": ">=16.8.0 || ^19.0.0-rc"
98
98
  },
99
99
  "dependencies": {
100
- "@builder.io/sdk": "6.1.0",
100
+ "@builder.io/sdk": "6.1.2",
101
101
  "@emotion/core": "^10.0.17",
102
102
  "hash-sum": "^2.0.0",
103
103
  "isolated-vm": "^5.0.0",
@@ -9,6 +9,11 @@ export interface ImgProps {
9
9
  attributes?: any;
10
10
  image?: string;
11
11
  builderBlock?: BuilderElement;
12
+ aspectRatio?: number;
13
+ backgroundSize?: string;
14
+ backgroundPosition?: string;
15
+ altText?: string;
16
+ title?: string;
12
17
  }
13
18
 
14
19
  // TODO: srcset, alt text input, object size/position input, etc
@@ -31,21 +36,39 @@ class ImgComponent extends React.Component<ImgProps> {
31
36
  render() {
32
37
  const attributes = this.props.attributes || {};
33
38
  const srcset = this.getSrcSet();
39
+
40
+ const { style: userStyle, ...restAttributes } = attributes;
41
+
42
+ const defaultStyle: React.CSSProperties = {
43
+ objectFit: this.props.backgroundSize as React.CSSProperties['objectFit'],
44
+ objectPosition: this.props.backgroundPosition as React.CSSProperties['objectPosition'],
45
+ aspectRatio: this.props.aspectRatio as unknown as React.CSSProperties['aspectRatio'],
46
+ };
47
+
48
+ const mergedStyle = {
49
+ ...defaultStyle,
50
+ ...(userStyle as React.CSSProperties),
51
+ };
52
+
34
53
  return (
35
54
  <img
36
55
  loading="lazy"
37
- {...this.props.attributes}
56
+ {...restAttributes}
38
57
  src={this.props.image || attributes.src}
39
58
  srcSet={srcset}
59
+ alt={this.props.altText}
60
+ title={this.props.title}
61
+ style={mergedStyle}
62
+ className="builder-raw-img"
40
63
  />
41
64
  );
42
65
  }
43
66
  }
44
67
 
45
68
  export const Img = withBuilder(ImgComponent, {
46
- // friendlyName?
47
69
  name: 'Raw:Img',
48
70
  hideFromInsertMenu: true,
71
+
49
72
  image:
50
73
  'https://firebasestorage.googleapis.com/v0/b/builder-3b0a2.appspot.com/o/images%2Fbaseline-insert_photo-24px.svg?alt=media&token=4e5d0ef4-f5e8-4e57-b3a9-38d63a9b9dc4',
51
74
  inputs: [
@@ -56,7 +79,58 @@ export const Img = withBuilder(ImgComponent, {
56
79
  allowedFileTypes: IMAGE_FILE_TYPES,
57
80
  required: true,
58
81
  },
82
+ {
83
+ name: 'backgroundSize',
84
+ type: 'text',
85
+ defaultValue: 'cover',
86
+ enum: [
87
+ {
88
+ label: 'contain',
89
+ value: 'contain',
90
+ helperText: 'The image should never get cropped',
91
+ },
92
+ {
93
+ label: 'cover',
94
+ value: 'cover',
95
+ helperText: "The image should fill it's box, cropping when needed",
96
+ },
97
+ ],
98
+ },
99
+ {
100
+ name: 'backgroundPosition',
101
+ type: 'text',
102
+ defaultValue: 'center',
103
+ enum: [
104
+ 'center',
105
+ 'top',
106
+ 'left',
107
+ 'right',
108
+ 'bottom',
109
+ 'top left',
110
+ 'top right',
111
+ 'bottom left',
112
+ 'bottom right',
113
+ ],
114
+ },
115
+ {
116
+ name: 'altText',
117
+ type: 'string',
118
+ helperText: 'Text to display when the user has images off',
119
+ },
120
+ {
121
+ name: 'title',
122
+ type: 'string',
123
+ helperText: 'Text to display when hovering over the asset',
124
+ },
125
+ {
126
+ name: 'aspectRatio',
127
+ type: 'number',
128
+ helperText:
129
+ "This is the ratio of height/width, e.g. set to 1.5 for a 300px wide and 200px tall photo. Set to 0 to not force the image to maintain it's aspect ratio",
130
+ advanced: true,
131
+ defaultValue: 0.7041,
132
+ },
59
133
  ],
134
+
60
135
  noWrap: true,
61
- static: true,
62
136
  });