@builder.io/react 2.0.4-6 → 2.0.4-9

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 (64) hide show
  1. package/dist/builder-react-lite.cjs.js +1 -1
  2. package/dist/builder-react-lite.cjs.js.map +1 -1
  3. package/dist/builder-react-lite.esm.js +1 -1
  4. package/dist/builder-react-lite.esm.js.map +1 -1
  5. package/dist/builder-react.browser.js +1 -6
  6. package/dist/builder-react.browser.js.map +1 -1
  7. package/dist/builder-react.cjs.js +1 -1
  8. package/dist/builder-react.cjs.js.map +1 -1
  9. package/dist/builder-react.es5.js +1 -1
  10. package/dist/builder-react.es5.js.map +1 -1
  11. package/dist/builder-react.unpkg.js +1 -6
  12. package/dist/builder-react.unpkg.js.map +1 -1
  13. package/dist/lib/package.json +4 -2
  14. package/dist/lib/rollup.config.js +0 -2
  15. package/dist/lib/rollup.config.js.map +1 -1
  16. package/dist/lib/src/blocks/Columns.js +8 -8
  17. package/dist/lib/src/blocks/Columns.js.map +1 -1
  18. package/dist/lib/src/blocks/Image.js +12 -12
  19. package/dist/lib/src/blocks/Image.js.map +1 -1
  20. package/dist/lib/src/blocks/Mutation.js +6 -6
  21. package/dist/lib/src/blocks/Mutation.js.map +1 -1
  22. package/dist/lib/src/blocks/Router.js +9 -9
  23. package/dist/lib/src/blocks/Router.js.map +1 -1
  24. package/dist/lib/src/blocks/Section.js +6 -6
  25. package/dist/lib/src/blocks/Section.js.map +1 -1
  26. package/dist/lib/src/blocks/Slot.js +5 -5
  27. package/dist/lib/src/blocks/Slot.js.map +1 -1
  28. package/dist/lib/src/blocks/Symbol.js +8 -8
  29. package/dist/lib/src/blocks/Symbol.js.map +1 -1
  30. package/dist/lib/src/blocks/Text.js +6 -6
  31. package/dist/lib/src/blocks/Text.js.map +1 -1
  32. package/dist/lib/src/blocks/Video.js +8 -8
  33. package/dist/lib/src/blocks/Video.js.map +1 -1
  34. package/dist/lib/src/blocks/forms/Form.js +10 -10
  35. package/dist/lib/src/blocks/forms/Form.js.map +1 -1
  36. package/dist/lib/src/components/builder-block.component.js +30 -15
  37. package/dist/lib/src/components/builder-block.component.js.map +1 -1
  38. package/dist/lib/src/components/builder-blocks.component.js +7 -7
  39. package/dist/lib/src/components/builder-blocks.component.js.map +1 -1
  40. package/dist/lib/src/components/builder-component.component.js +72 -75
  41. package/dist/lib/src/components/builder-component.component.js.map +1 -1
  42. package/dist/lib/src/components/insert-spacer.component.js +7 -7
  43. package/dist/lib/src/components/insert-spacer.component.js.map +1 -1
  44. package/dist/types/src/blocks/Mutation.d.ts +2 -3
  45. package/dist/types/src/blocks/Slot.d.ts +2 -3
  46. package/dist/types/src/components/builder-block.component.d.ts +1 -2
  47. package/dist/types/src/components/builder-blocks.component.d.ts +1 -3
  48. package/dist/types/src/components/insert-spacer.component.d.ts +1 -3
  49. package/package.json +4 -2
  50. package/rollup.config.ts +0 -2
  51. package/src/blocks/Columns.tsx +1 -1
  52. package/src/blocks/Image.tsx +1 -1
  53. package/src/blocks/Mutation.tsx +1 -1
  54. package/src/blocks/Router.tsx +1 -1
  55. package/src/blocks/Section.tsx +1 -1
  56. package/src/blocks/Slot.tsx +1 -1
  57. package/src/blocks/Symbol.tsx +1 -1
  58. package/src/blocks/Text.tsx +2 -2
  59. package/src/blocks/Video.tsx +1 -1
  60. package/src/blocks/forms/Form.tsx +1 -1
  61. package/src/components/builder-block.component.tsx +25 -2
  62. package/src/components/builder-blocks.component.tsx +1 -1
  63. package/src/components/builder-component.component.tsx +1 -5
  64. package/src/components/insert-spacer.component.tsx +1 -1
@@ -1,7 +1,7 @@
1
1
  /** @jsx jsx */
2
2
 
3
3
  import { Builder, builder, BuilderElement, Component } from '@builder.io/sdk';
4
- import { ClassNames, jsx } from '@emotion/react';
4
+ import { ClassNames, jsx } from '@emotion/core';
5
5
  import React from 'react';
6
6
  import { Size, sizeNames, sizes } from '../constants/device-sizes.constant';
7
7
  import { set } from '../functions/set';
@@ -11,6 +11,7 @@ import { BuilderStoreContext } from '../store/builder-store';
11
11
  import { applyPatchWithMinimalMutationChain } from '../functions/apply-patch-with-mutation';
12
12
  import { blockToHtmlString } from '../functions/block-to-html-string';
13
13
  import { Link } from './Link';
14
+ import traverse from 'traverse';
14
15
 
15
16
  const camelCaseToKebabCase = (str?: string) =>
16
17
  str ? str.replace(/([A-Z])/g, g => `-${g[0].toLowerCase()}`) : '';
@@ -18,6 +19,21 @@ const camelCaseToKebabCase = (str?: string) =>
18
19
  const kebabCaseToCamelCase = (str = '') =>
19
20
  str.replace(/-([a-z])/g, match => match[1].toUpperCase());
20
21
 
22
+ const localizedType = '@builder.io/core:LocalizedValue';
23
+ const resolveLocalizedOptions = (options?: any, locale?: string) => {
24
+ if (!locale || !options) {
25
+ return options;
26
+ }
27
+
28
+ const result = traverse(options).map(function(el) {
29
+ if (el && el['@type'] === localizedType) {
30
+ this.update(el[locale] || el.Default)
31
+ }
32
+ });
33
+
34
+ return result;
35
+ }
36
+
21
37
  const Device = { desktop: 0, tablet: 1, mobile: 2 };
22
38
 
23
39
  const voidElements = new Set([
@@ -452,10 +468,17 @@ export class BuilderBlock extends React.Component<
452
468
  }
453
469
  }
454
470
 
471
+ const localized = resolveLocalizedOptions( (options.component || options.options) && {
472
+ ...options.options,
473
+ ...(options.component.options || options.component.data),
474
+ }, this.privateState.state.locale)
475
+
455
476
  const innerComponentProperties = (options.component || options.options) && {
456
477
  ...options.options,
457
478
  ...(options.component.options || options.component.data),
458
- };
479
+ }
480
+
481
+ console.log(' here ', localized, innerComponentProperties);
459
482
 
460
483
  const isVoid = voidElements.has(TagName);
461
484
 
@@ -1,5 +1,5 @@
1
1
  /** @jsx jsx */
2
- import { jsx } from '@emotion/react';
2
+ import { jsx } from '@emotion/core';
3
3
  import React from 'react';
4
4
  import { Builder } from '@builder.io/sdk';
5
5
  import { BuilderBlock } from './builder-block.component';
@@ -1,7 +1,6 @@
1
1
  import React from 'react';
2
2
  import ReactDOM from 'react-dom';
3
- import { jsx, css, CacheProvider } from '@emotion/react';
4
- import createCache from '@emotion/cache';
3
+ import { jsx, css } from '@emotion/core';
5
4
  import { BuilderContent, getContentWithInfo } from './builder-content.component';
6
5
  import { BuilderBlocks } from './builder-blocks.component';
7
6
  import {
@@ -101,7 +100,6 @@ const sizeMap = {
101
100
 
102
101
  const fetchCache: { [key: string]: any } = {};
103
102
 
104
- const cache = createCache({ key: 'builder'});
105
103
  export interface BuilderComponentProps {
106
104
  /**
107
105
  * @package
@@ -944,7 +942,6 @@ export class BuilderComponent extends React.Component<
944
942
  key={this.state.key}
945
943
  ref={ref => (this.ref = ref)}
946
944
  >
947
- <CacheProvider value={cache}>
948
945
  <BuilderMetaContext.Consumer>
949
946
  {value => (
950
947
  <BuilderMetaContext.Provider
@@ -1116,7 +1113,6 @@ export class BuilderComponent extends React.Component<
1116
1113
  </BuilderMetaContext.Provider>
1117
1114
  )}
1118
1115
  </BuilderMetaContext.Consumer>
1119
- </CacheProvider>
1120
1116
  </WrapComponent>
1121
1117
  );
1122
1118
  }
@@ -1,5 +1,5 @@
1
1
  /** @jsx jsx */
2
- import { jsx } from '@emotion/react';
2
+ import { jsx } from '@emotion/core';
3
3
 
4
4
  import React from 'react';
5
5
  import { Builder } from '@builder.io/sdk';