@builder.io/react 1.1.52-8 → 1.1.53-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.
Files changed (142) hide show
  1. package/=16.8 +15 -0
  2. package/README.md +131 -53
  3. package/dist/builder-react-lite.cjs.js +12 -12
  4. package/dist/builder-react-lite.cjs.js.map +1 -1
  5. package/dist/builder-react-lite.esm.js +12 -12
  6. package/dist/builder-react-lite.esm.js.map +1 -1
  7. package/dist/builder-react.browser.js +21 -17
  8. package/dist/builder-react.browser.js.map +1 -1
  9. package/dist/builder-react.cjs.js +12 -12
  10. package/dist/builder-react.cjs.js.map +1 -1
  11. package/dist/builder-react.es5.js +12 -12
  12. package/dist/builder-react.es5.js.map +1 -1
  13. package/dist/builder-react.unpkg.js +21 -17
  14. package/dist/builder-react.unpkg.js.map +1 -1
  15. package/dist/lib/package.json +10 -8
  16. package/dist/lib/rollup.config.js +15 -13
  17. package/dist/lib/rollup.config.js.map +1 -1
  18. package/dist/lib/src/blocks/Button.js +5 -2
  19. package/dist/lib/src/blocks/Button.js.map +1 -1
  20. package/dist/lib/src/blocks/Columns.js +16 -13
  21. package/dist/lib/src/blocks/Columns.js.map +1 -1
  22. package/dist/lib/src/blocks/CustomCode.js +11 -7
  23. package/dist/lib/src/blocks/CustomCode.js.map +1 -1
  24. package/dist/lib/src/blocks/Embed.js +7 -4
  25. package/dist/lib/src/blocks/Embed.js.map +1 -1
  26. package/dist/lib/src/blocks/Fragment.js +5 -2
  27. package/dist/lib/src/blocks/Fragment.js.map +1 -1
  28. package/dist/lib/src/blocks/Image.js +37 -24
  29. package/dist/lib/src/blocks/Image.js.map +1 -1
  30. package/dist/lib/src/blocks/Mutation.js +3 -2
  31. package/dist/lib/src/blocks/Mutation.js.map +1 -1
  32. package/dist/lib/src/blocks/Router.js +16 -11
  33. package/dist/lib/src/blocks/Router.js.map +1 -1
  34. package/dist/lib/src/blocks/Section.js +9 -6
  35. package/dist/lib/src/blocks/Section.js.map +1 -1
  36. package/dist/lib/src/blocks/Slot.js +4 -3
  37. package/dist/lib/src/blocks/Slot.js.map +1 -1
  38. package/dist/lib/src/blocks/StateProvider.js +5 -2
  39. package/dist/lib/src/blocks/StateProvider.js.map +1 -1
  40. package/dist/lib/src/blocks/Symbol.js +13 -10
  41. package/dist/lib/src/blocks/Symbol.js.map +1 -1
  42. package/dist/lib/src/blocks/Text.js +9 -6
  43. package/dist/lib/src/blocks/Text.js.map +1 -1
  44. package/dist/lib/src/blocks/Video.js +12 -9
  45. package/dist/lib/src/blocks/Video.js.map +1 -1
  46. package/dist/lib/src/blocks/forms/Button.js +9 -2
  47. package/dist/lib/src/blocks/forms/Button.js.map +1 -1
  48. package/dist/lib/src/blocks/forms/Form.js +20 -13
  49. package/dist/lib/src/blocks/forms/Form.js.map +1 -1
  50. package/dist/lib/src/blocks/forms/Input.js +5 -2
  51. package/dist/lib/src/blocks/forms/Input.js.map +1 -1
  52. package/dist/lib/src/blocks/forms/Label.js +10 -2
  53. package/dist/lib/src/blocks/forms/Label.js.map +1 -1
  54. package/dist/lib/src/blocks/forms/Select.js +5 -2
  55. package/dist/lib/src/blocks/forms/Select.js.map +1 -1
  56. package/dist/lib/src/blocks/forms/TextArea.js +5 -2
  57. package/dist/lib/src/blocks/forms/TextArea.js.map +1 -1
  58. package/dist/lib/src/blocks/raw/Img.js +5 -2
  59. package/dist/lib/src/blocks/raw/Img.js.map +1 -1
  60. package/dist/lib/src/blocks/raw/RawText.js +21 -3
  61. package/dist/lib/src/blocks/raw/RawText.js.map +1 -1
  62. package/dist/lib/src/builder-react-lite.js +15 -12
  63. package/dist/lib/src/builder-react-lite.js.map +1 -1
  64. package/dist/lib/src/builder-react.js +58 -44
  65. package/dist/lib/src/builder-react.js.map +1 -1
  66. package/dist/lib/src/components/Link.js +3 -1
  67. package/dist/lib/src/components/Link.js.map +1 -1
  68. package/dist/lib/src/components/builder-block.component.js +37 -34
  69. package/dist/lib/src/components/builder-block.component.js.map +1 -1
  70. package/dist/lib/src/components/builder-blocks.component.js +12 -9
  71. package/dist/lib/src/components/builder-blocks.component.js.map +1 -1
  72. package/dist/lib/src/components/builder-component.component.js +54 -45
  73. package/dist/lib/src/components/builder-component.component.js.map +1 -1
  74. package/dist/lib/src/components/builder-content.component.js +16 -12
  75. package/dist/lib/src/components/builder-content.component.js.map +1 -1
  76. package/dist/lib/src/components/insert-spacer.component.js +11 -4
  77. package/dist/lib/src/components/insert-spacer.component.js.map +1 -1
  78. package/dist/lib/src/components/no-wrap.js +3 -1
  79. package/dist/lib/src/components/no-wrap.js.map +1 -1
  80. package/dist/lib/src/components/variants-provider.component.js +33 -13
  81. package/dist/lib/src/components/variants-provider.component.js.map +1 -1
  82. package/dist/lib/src/constants/device-sizes.constant.js +1 -0
  83. package/dist/lib/src/constants/device-sizes.constant.js.map +1 -1
  84. package/dist/lib/src/decorators/builder-block.decorator.js +1 -0
  85. package/dist/lib/src/decorators/builder-block.decorator.js.map +1 -1
  86. package/dist/lib/src/functions/apply-patch-with-mutation.js +12 -8
  87. package/dist/lib/src/functions/apply-patch-with-mutation.js.map +1 -1
  88. package/dist/lib/src/functions/block-to-html-string.js +10 -7
  89. package/dist/lib/src/functions/block-to-html-string.js.map +1 -1
  90. package/dist/lib/src/functions/debonce-next-tick.js +1 -0
  91. package/dist/lib/src/functions/debonce-next-tick.js.map +1 -1
  92. package/dist/lib/src/functions/get.js +3 -1
  93. package/dist/lib/src/functions/get.js.map +1 -1
  94. package/dist/lib/src/functions/no-wrap.js +3 -1
  95. package/dist/lib/src/functions/no-wrap.js.map +1 -1
  96. package/dist/lib/src/functions/safe-dynamic-require.js +1 -0
  97. package/dist/lib/src/functions/safe-dynamic-require.js.map +1 -1
  98. package/dist/lib/src/functions/set.js +3 -1
  99. package/dist/lib/src/functions/set.js.map +1 -1
  100. package/dist/lib/src/functions/string-to-function.js +6 -4
  101. package/dist/lib/src/functions/string-to-function.js.map +1 -1
  102. package/dist/lib/src/functions/throttle.js +1 -0
  103. package/dist/lib/src/functions/throttle.js.map +1 -1
  104. package/dist/lib/src/functions/update-metadata.js +1 -0
  105. package/dist/lib/src/functions/update-metadata.js.map +1 -1
  106. package/dist/lib/src/functions/with-builder.js +2 -1
  107. package/dist/lib/src/functions/with-builder.js.map +1 -1
  108. package/dist/lib/src/functions/with-children.js +3 -1
  109. package/dist/lib/src/functions/with-children.js.map +1 -1
  110. package/dist/lib/src/hooks/isPreviewing.js +16 -0
  111. package/dist/lib/src/hooks/isPreviewing.js.map +1 -0
  112. package/dist/lib/src/scripts/init-editing.js.map +1 -1
  113. package/dist/lib/src/store/builder-async-requests.js +5 -2
  114. package/dist/lib/src/store/builder-async-requests.js.map +1 -1
  115. package/dist/lib/src/store/builder-meta.js +1 -0
  116. package/dist/lib/src/store/builder-meta.js.map +1 -1
  117. package/dist/lib/src/store/builder-store.js +1 -0
  118. package/dist/lib/src/store/builder-store.js.map +1 -1
  119. package/dist/lib/test/basic.test.js +47 -31
  120. package/dist/lib/test/basic.test.js.map +1 -1
  121. package/dist/lib/test/functions/render-block.js +6 -3
  122. package/dist/lib/test/functions/render-block.js.map +1 -1
  123. package/dist/lib/test/image.test.js +20 -4
  124. package/dist/lib/test/image.test.js.map +1 -1
  125. package/dist/types/src/builder-react-lite.d.ts +1 -0
  126. package/dist/types/src/builder-react.d.ts +1 -0
  127. package/dist/types/src/components/builder-block.component.d.ts +1 -1
  128. package/dist/types/src/components/builder-component.component.d.ts +16 -2
  129. package/dist/types/src/components/builder-content.component.d.ts +1 -1
  130. package/dist/types/src/components/no-wrap.d.ts +2 -1
  131. package/dist/types/src/functions/apply-patch-with-mutation.d.ts +1 -1
  132. package/dist/types/src/hooks/isPreviewing.d.ts +1 -0
  133. package/lite.js +1 -1
  134. package/package.json +10 -8
  135. package/rollup.config.ts +2 -0
  136. package/src/blocks/Router.tsx +1 -1
  137. package/src/builder-react-lite.ts +1 -0
  138. package/src/builder-react.ts +1 -0
  139. package/src/components/builder-component.component.tsx +25 -7
  140. package/src/functions/string-to-function.ts +2 -2
  141. package/src/hooks/isPreviewing.ts +14 -0
  142. package/typedoc.js +8 -0
@@ -18,6 +18,7 @@ export { BuilderComponent as BuilderPage };
18
18
  export { BuilderComponent };
19
19
 
20
20
  export { stringToFunction } from './functions/string-to-function';
21
+ export { isPreviewing } from './hooks/isPreviewing';
21
22
 
22
23
  export { builder, Builder };
23
24
  export default builder;
@@ -49,6 +49,7 @@ export { Img } from './blocks/raw/Img';
49
49
  export { RawText } from './blocks/raw/RawText';
50
50
 
51
51
  export { stringToFunction } from './functions/string-to-function';
52
+ export { isPreviewing } from './hooks/isPreviewing';
52
53
 
53
54
  export { builder, Builder };
54
55
  export default builder;
@@ -127,6 +127,7 @@ export interface BuilderComponentProps {
127
127
  /**
128
128
  * @package
129
129
  * @deprecated use {@link model} instead.
130
+ * @hidden
130
131
  */
131
132
  modelName?: string;
132
133
  /**
@@ -136,6 +137,7 @@ export interface BuilderComponentProps {
136
137
  /**
137
138
  * @package
138
139
  * @deprecated use {@link model} instead.
140
+ * @hidden
139
141
  */
140
142
  name?: string;
141
143
  /**
@@ -174,6 +176,7 @@ export interface BuilderComponentProps {
174
176
  apiKey?: string;
175
177
  /**
176
178
  * @private
179
+ * @hidden
177
180
  */
178
181
  codegen?: boolean;
179
182
  options?: GetContentOptions;
@@ -209,6 +212,7 @@ export interface BuilderComponentProps {
209
212
  content?: Content;
210
213
  /**
211
214
  * @package
215
+ * @hidden
212
216
  *
213
217
  * Location object that provides the current url, path, etc; for server side
214
218
  * rendering.
@@ -222,10 +226,12 @@ export interface BuilderComponentProps {
222
226
  /**
223
227
  * @package
224
228
  * @deprecated
229
+ * @hidden
225
230
  */
226
231
  noAsync?: boolean;
227
232
  /**
228
233
  * @package
234
+ * @hidden
229
235
  *
230
236
  * Flag to render email content (small differences in our render logic for
231
237
  * email support).
@@ -233,6 +239,7 @@ export interface BuilderComponentProps {
233
239
  emailMode?: boolean;
234
240
  /**
235
241
  * @package
242
+ * @hidden
236
243
  *
237
244
  * Flag to render amp content (small differences in our render logic for amp
238
245
  * support)
@@ -240,6 +247,7 @@ export interface BuilderComponentProps {
240
247
  ampMode?: boolean;
241
248
  /**
242
249
  * @package
250
+ * @hidden
243
251
  *
244
252
  * Render content in-line only (can't passed from the content prop) don't
245
253
  * fetch content from our API.
@@ -248,21 +256,25 @@ export interface BuilderComponentProps {
248
256
  /**
249
257
  * @package
250
258
  * @deprecated
259
+ * @hidden
251
260
  */
252
261
  builderBlock?: BuilderElement;
253
262
  /**
254
263
  * @package
255
264
  * @deprecated
265
+ * @hidden
256
266
  */
257
267
  dataOnly?: boolean;
258
268
  /**
259
269
  * @package
260
270
  * @deprecated
271
+ * @hidden
261
272
  */
262
273
  hydrate?: boolean;
263
274
  /**
264
275
  * @package
265
276
  * @deprecated use {@link Builder.isStatic} instead
277
+ * @hidden
266
278
  */
267
279
  isStatic?: boolean;
268
280
  /**
@@ -273,9 +285,11 @@ export interface BuilderComponentProps {
273
285
  context?: any;
274
286
  /**
275
287
  * @deprecated
288
+ * @hidden
276
289
  */
277
290
  url?: string;
278
291
  /**
292
+ * @hidden
279
293
  * Set to true if this is not the root content component, for instance for symbols
280
294
  */
281
295
  isChild?: boolean;
@@ -355,7 +369,7 @@ const tryEval = (str?: string, data: any = {}, errors?: Error[]): any => {
355
369
  }).run(value.replace(/(^|;)return /, '$1'));
356
370
  // tslint:enable:comment-format
357
371
  }
358
- } catch (error) {
372
+ } catch (error: any) {
359
373
  if (errors) {
360
374
  errors.push(error);
361
375
  }
@@ -740,15 +754,19 @@ export class BuilderComponent extends React.Component<
740
754
  }
741
755
 
742
756
  if (Builder.isBrowser) {
743
- Builder.nextTick(() => {
744
- this.firstLoad = false;
745
- })
746
757
  // TODO: remove event on unload
747
758
  window.addEventListener('resize', this.resizeListener);
748
759
  if (Builder.isEditing) {
749
760
  window.addEventListener('message', this.messageListener);
750
761
  }
751
762
 
763
+ if (Builder.isEditing || Builder.isPreviewing) {
764
+ Builder.nextTick(() => {
765
+ this.firstLoad = false;
766
+ this.reload();
767
+ });
768
+ }
769
+
752
770
  setTimeout(() => {
753
771
  window.dispatchEvent(
754
772
  new CustomEvent('builder:component:load', {
@@ -1050,7 +1068,7 @@ export class BuilderComponent extends React.Component<
1050
1068
  ...(content && { initialContent: [content] }),
1051
1069
  ...(!content &&
1052
1070
  'content' in this.props &&
1053
- !this.isPreviewing && !this.firstLoad && { initialContent: [] }),
1071
+ !this.isPreviewing && { initialContent: [] }),
1054
1072
  ...(this.props.url && { url: this.props.url }),
1055
1073
  ...this.props.options,
1056
1074
  ...(this.options.codegen && {
@@ -1209,7 +1227,7 @@ export class BuilderComponent extends React.Component<
1209
1227
  try {
1210
1228
  const result = await fetch(url);
1211
1229
  json = await result.json();
1212
- } catch (err) {
1230
+ } catch (err: any) {
1213
1231
  if (this._errors) {
1214
1232
  this._errors.push(err);
1215
1233
  }
@@ -1399,7 +1417,7 @@ export class BuilderComponent extends React.Component<
1399
1417
 
1400
1418
  // TODO: allow exports = { } syntax?
1401
1419
  // TODO: do something with reuslt like view - methods, computed, actions, properties, template, etc etc
1402
- } catch (error) {
1420
+ } catch (error: any) {
1403
1421
  if (Builder.isBrowser) {
1404
1422
  console.warn(
1405
1423
  'Builder custom code error:',
@@ -89,7 +89,7 @@ export function stringToFunction(
89
89
  `
90
90
  );
91
91
  }
92
- } catch (error) {
92
+ } catch (error: any) {
93
93
  if (errors) {
94
94
  errors.push(error);
95
95
  }
@@ -131,7 +131,7 @@ export function stringToFunction(
131
131
  }).run(str.replace(/(^|;)return /, '$1'));
132
132
  // tslint:enable:comment-format
133
133
  }
134
- } catch (error) {
134
+ } catch (error: any) {
135
135
  if (Builder.isBrowser) {
136
136
  console.warn(
137
137
  'Builder custom code error:',
@@ -0,0 +1,14 @@
1
+ import { useEffect, useState } from 'react';
2
+ import { Builder } from '@builder.io/sdk';
3
+
4
+ export function isPreviewing() {
5
+ const [isPreviewing, setIsPreviewing] = useState(false);
6
+
7
+ useEffect(() => {
8
+ if (Builder.isEditing || Builder.isPreviewing) {
9
+ setIsPreviewing(true)
10
+ }
11
+ }, [])
12
+
13
+ return isPreviewing;
14
+ }
package/typedoc.js ADDED
@@ -0,0 +1,8 @@
1
+ module.exports = {
2
+ entryPoints: [
3
+ './src/components/builder-component.component.tsx',
4
+ './src/components/builder-content.component.tsx',
5
+ ],
6
+ out: 'docs',
7
+ exclude: ['**/*.test.tsx?'],
8
+ };