@builder.io/react 6.0.2 → 6.0.4-0
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/.npmrc +1 -0
- package/CHANGELOG.md +10 -0
- package/dist/builder-react-lite.cjs.js +1 -1
- package/dist/builder-react-lite.cjs.js.map +1 -1
- package/dist/builder-react-lite.esm.js +1 -1
- package/dist/builder-react-lite.esm.js.map +1 -1
- package/dist/builder-react.browser.js +2 -2
- package/dist/builder-react.browser.js.map +1 -1
- package/dist/builder-react.cjs.js +1 -1
- package/dist/builder-react.cjs.js.map +1 -1
- package/dist/builder-react.es5.js +1 -1
- package/dist/builder-react.es5.js.map +1 -1
- package/dist/builder-react.unpkg.js +2 -2
- package/dist/builder-react.unpkg.js.map +1 -1
- package/dist/lib/package.json +1 -1
- package/dist/lib/src/blocks/PersonalizationContainer.js +20 -17
- package/dist/lib/src/blocks/PersonalizationContainer.js.map +1 -1
- package/dist/lib/src/components/builder-block.component.js +65 -52
- package/dist/lib/src/components/builder-block.component.js.map +1 -1
- package/dist/lib/src/sdk-version.js +1 -1
- package/dist/types/src/blocks/PersonalizationContainer.d.ts +1 -0
- package/dist/types/src/components/builder-block.component.d.ts +2 -1
- package/dist/types/src/sdk-version.d.ts +1 -1
- package/package.json +5 -4
- package/scripts/fix-core-version.sh +0 -0
- package/scripts/set-sdk-version.sh +0 -0
- package/src/blocks/PersonalizationContainer.tsx +16 -4
- package/src/components/builder-block.component.tsx +37 -15
- package/.yarnrc.yml +0 -1
|
@@ -20,6 +20,31 @@ const kebabCaseToCamelCase = (str = '') =>
|
|
|
20
20
|
|
|
21
21
|
const Device = { desktop: 0, tablet: 1, mobile: 2 };
|
|
22
22
|
|
|
23
|
+
// Deep clone a block but without cloning any child blocks
|
|
24
|
+
export function deepCloneWithConditions<T = any>(obj: T): T {
|
|
25
|
+
if (obj === null || typeof obj !== 'object') {
|
|
26
|
+
return obj;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
if (Array.isArray(obj)) {
|
|
30
|
+
return obj.map((item: any) => deepCloneWithConditions(item)) as T;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
if ((obj as any)['@type'] === '@builder.io/sdk:Element') {
|
|
34
|
+
return obj;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const clonedObj: any = {};
|
|
38
|
+
|
|
39
|
+
for (const key in obj) {
|
|
40
|
+
if (key !== 'meta' && Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
41
|
+
clonedObj[key] = deepCloneWithConditions(obj[key]);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
return clonedObj;
|
|
46
|
+
}
|
|
47
|
+
|
|
23
48
|
const voidElements = new Set([
|
|
24
49
|
'area',
|
|
25
50
|
'base',
|
|
@@ -135,7 +160,7 @@ export class BuilderBlock extends React.Component<
|
|
|
135
160
|
return this.props.block;
|
|
136
161
|
}
|
|
137
162
|
|
|
138
|
-
|
|
163
|
+
emotionCss(responsiveStyles: BuilderElement['responsiveStyles']) {
|
|
139
164
|
let initialAnimationStepStyles: any;
|
|
140
165
|
const { block } = this;
|
|
141
166
|
const animation = block.animations && block.animations[0];
|
|
@@ -148,15 +173,14 @@ export class BuilderBlock extends React.Component<
|
|
|
148
173
|
}
|
|
149
174
|
|
|
150
175
|
const reversedNames = sizeNames.slice().reverse();
|
|
151
|
-
const self = this.block;
|
|
152
176
|
const styles: any = {};
|
|
153
|
-
if (
|
|
177
|
+
if (responsiveStyles) {
|
|
154
178
|
for (const size of reversedNames) {
|
|
155
179
|
if (size === 'large') {
|
|
156
180
|
if (!this.props.emailMode) {
|
|
157
181
|
styles[`&.builder-block`] = Object.assign(
|
|
158
182
|
{},
|
|
159
|
-
|
|
183
|
+
responsiveStyles[size],
|
|
160
184
|
initialAnimationStepStyles
|
|
161
185
|
);
|
|
162
186
|
}
|
|
@@ -165,7 +189,7 @@ export class BuilderBlock extends React.Component<
|
|
|
165
189
|
this.privateState.context.builderContent?.meta?.breakpoints || {}
|
|
166
190
|
);
|
|
167
191
|
styles[`@media only screen and (max-width: ${sizesPerBreakpoints[size].max}px)`] = {
|
|
168
|
-
'&.builder-block':
|
|
192
|
+
'&.builder-block': responsiveStyles[size],
|
|
169
193
|
};
|
|
170
194
|
}
|
|
171
195
|
}
|
|
@@ -211,12 +235,10 @@ export class BuilderBlock extends React.Component<
|
|
|
211
235
|
}
|
|
212
236
|
|
|
213
237
|
onWindowMessage = (event: MessageEvent) => {
|
|
214
|
-
const isTrusted = Builder.isTrustedHostForEvent(event);
|
|
215
|
-
if (!isTrusted) return;
|
|
216
|
-
|
|
217
238
|
const message = event.data;
|
|
218
|
-
if (!message)
|
|
219
|
-
|
|
239
|
+
if (!message) {
|
|
240
|
+
return;
|
|
241
|
+
}
|
|
220
242
|
switch (message.type) {
|
|
221
243
|
case 'builder.selectionChange': {
|
|
222
244
|
const { data } = message;
|
|
@@ -373,9 +395,9 @@ export class BuilderBlock extends React.Component<
|
|
|
373
395
|
const TextTag: any = 'span';
|
|
374
396
|
|
|
375
397
|
let options: any = {
|
|
376
|
-
// Attributes?
|
|
377
398
|
...block.properties,
|
|
378
|
-
style: {},
|
|
399
|
+
style: {},
|
|
400
|
+
responsiveStyles: fastClone(block.responsiveStyles || {}),
|
|
379
401
|
};
|
|
380
402
|
|
|
381
403
|
options = {
|
|
@@ -384,7 +406,7 @@ export class BuilderBlock extends React.Component<
|
|
|
384
406
|
};
|
|
385
407
|
|
|
386
408
|
if (block.component) {
|
|
387
|
-
options.component =
|
|
409
|
+
options.component = deepCloneWithConditions(block.component);
|
|
388
410
|
}
|
|
389
411
|
|
|
390
412
|
// Binding should be properties to href or href?
|
|
@@ -491,7 +513,7 @@ export class BuilderBlock extends React.Component<
|
|
|
491
513
|
}
|
|
492
514
|
|
|
493
515
|
const finalOptions: { [key: string]: string } = {
|
|
494
|
-
...omit(options, ['class', 'component', 'attr']),
|
|
516
|
+
...omit(options, ['class', 'component', 'attr', 'responsiveStyles']),
|
|
495
517
|
[typeof TagName === 'string' && !TagName.includes('-') ? 'className' : 'class']:
|
|
496
518
|
`builder-block ${this.id}${block.class ? ` ${block.class}` : ''}${
|
|
497
519
|
block.component && !(['Image', 'Video', 'Banner'].indexOf(componentName) > -1)
|
|
@@ -558,7 +580,7 @@ export class BuilderBlock extends React.Component<
|
|
|
558
580
|
<ClassNames>
|
|
559
581
|
{({ css, cx }) => {
|
|
560
582
|
if (!this.props.emailMode) {
|
|
561
|
-
const addClass = ' ' + css(this.emotionCss);
|
|
583
|
+
const addClass = ' ' + css(this.emotionCss(options.responsiveStyles));
|
|
562
584
|
if (finalOptions.class) {
|
|
563
585
|
finalOptions.class += addClass;
|
|
564
586
|
}
|
package/.yarnrc.yml
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
npmPublishAccess: "public"
|