@builder.io/react 1.1.53-0 → 2.0.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/=16.8 CHANGED
@@ -1,5 +1,5 @@
1
1
 
2
- added 1 package, changed 3 packages, and audited 1914 packages in 3s
2
+ up to date, audited 1914 packages in 4s
3
3
 
4
4
  46 packages are looking for funding
5
5
  run `npm fund` for details
package/README.md CHANGED
@@ -47,7 +47,7 @@ const content = await builder
47
47
  }
48
48
  })
49
49
  .promise()
50
-
50
+
51
51
  // Later, pass the fetched content to the BuilderComponent
52
52
  <BuilderComponent model={MODEL_NAME} content={content} />
53
53
  ```
@@ -62,21 +62,25 @@ For example, with Next.js, to render Builder as your homepage:
62
62
  export const getStaticProps = async () => {
63
63
  return {
64
64
  props: {
65
- builderContent: await builder.get('page', {
66
- userAttributes: {
67
- urlPath: '/' // Fetch content targeted to the homepage ("/" url)
68
- }
69
- }).promise()
70
- }
71
- }
72
- }
65
+ builderContent: await builder
66
+ .get('page', {
67
+ userAttributes: {
68
+ urlPath: '/', // Fetch content targeted to the homepage ("/" url)
69
+ },
70
+ })
71
+ .promise(),
72
+ },
73
+ };
74
+ };
73
75
 
74
76
  export default function MyHomePage({ builderContent }) {
75
- return <>
76
- <YourHeader />
77
- <BuilderComponent model="page" content={builderContent} />
78
- <YourFooter />
79
- </>
77
+ return (
78
+ <>
79
+ <YourHeader />
80
+ <BuilderComponent model="page" content={builderContent} />
81
+ <YourFooter />
82
+ </>
83
+ );
80
84
  }
81
85
  ```
82
86
 
@@ -84,21 +88,23 @@ You can also allow dynamic page building (the ability to create new pages on new
84
88
 
85
89
  ### Registering Components
86
90
 
87
- One of Builder's most powerful features is registering your own components for use in the drag and drop editor.
91
+ One of Builder's most powerful features is registering your own components for use in the drag and drop editor.
88
92
  You can choose to have these compliment the built-in components, or to be the only components allowed to be used
89
93
  (e.g. via [components-only mode](https://www.builder.io/c/docs/guides/components-only-mode))
90
94
 
91
95
  ```tsx
92
96
  import { Builder } from '@builder.io/sdk-react';
93
97
 
94
- function MyHero(props) { /* Your own hero component in your codebase */ }
98
+ function MyHero(props) {
99
+ /* Your own hero component in your codebase */
100
+ }
95
101
 
96
102
  Builder.registerComponent(MyHero, {
97
103
  name: 'Hero',
98
104
  inputs: [
99
- { name: 'title', type: 'string' } // Gets passed as the `title` prop to the Hero
100
- ]
101
- })
105
+ { name: 'title', type: 'string' }, // Gets passed as the `title` prop to the Hero
106
+ ],
107
+ });
102
108
  ```
103
109
 
104
110
  Learn more about [registering components in Builder](https://www.builder.io/c/docs/custom-react-components)
@@ -110,13 +116,12 @@ You can find the full [reference docs for the BuilderComponent props here](docs/
110
116
  ```tsx
111
117
  const MODEL_NAME = 'page';
112
118
 
113
- // Render
114
- <BuilderComponent model={MODEL_NAME} content={builderJson} />
119
+ // Render
120
+ <BuilderComponent model={MODEL_NAME} content={builderJson} />;
115
121
  ```
116
122
 
117
123
  See our guides for [Gatsby](https://github.com/BuilderIO/builder/tree/master/examples/gatsby) and [Next.js](https://github.com/BuilderIO/builder/tree/master/examples/next-js) for guides on using with those frameworks
118
124
 
119
-
120
125
  #### Passing data and functions down
121
126
 
122
127
  You can also pass [data](https://www.builder.io/c/docs/guides/connecting-api-data) and [functions](https://www.builder.io/c/docs/react/custom-actions) down to the Builder component to use in the UIs (e.g. bind
@@ -129,9 +134,10 @@ All data passed down is available in Builder [actions and bindings](https://www.
129
134
  model="page"
130
135
  data={{
131
136
  products: productsList,
132
- foo: 'bar'
133
- }}
134
- content={builderJson} />
137
+ foo: 'bar',
138
+ }}
139
+ content={builderJson}
140
+ />
135
141
  ```
136
142
 
137
143
  You can also pass down functions, complex data like custom objects and libraries you can use `context`. Similar to React context, context passes all the way down (e.g. through symbols, etc). This data is not observed for changes and mutations
@@ -142,8 +148,9 @@ You can also pass down functions, complex data like custom objects and libraries
142
148
  context={{
143
149
  addToCart: () => myService.addToCart(currentProduct),
144
150
  lodash: lodash,
145
- }}
146
- content={builderJson} />
151
+ }}
152
+ content={builderJson}
153
+ />
147
154
  ```
148
155
 
149
156
  Context is available in [actions and bindings](https://www.builder.io/c/docs/guides/custom-code) as `context.*`, such as `context.lodash` or `context.myFunction()` in the example above
@@ -204,8 +211,8 @@ Although you can already fetch data models from our Content API directly and use
204
211
  return <Spinner />
205
212
  }
206
213
  return <>
207
- /*pass values down to an example ThemeProvider, used as a wrapper in your application*/
208
- <ThemeProvider theme={data.theme} >
214
+ /*pass values down to an example ThemeProvider, used as a wrapper in your application*/
215
+ <ThemeProvider theme={data.theme} >
209
216
  {props.children}
210
217
  </ThemeProvider>
211
218
  </>
@@ -225,7 +232,7 @@ export const getStaticProps = async () => {
225
232
  }
226
233
 
227
234
  export default function MyPage({ builderDataContent }) {
228
- return <BuilderContent content={builderDataContent}>{data =>
235
+ return <BuilderContent content={builderDataContent}>{data =>
229
236
  <ThemeProvider theme={data.theme}>
230
237
  {/* ... more content ... */}
231
238
  </ThemeProvider>
@@ -233,20 +240,23 @@ export default function MyPage({ builderDataContent }) {
233
240
  }
234
241
  ```
235
242
 
236
-
237
243
  #### Usage with Page/Section Custom Fields
238
244
 
239
- Page and section models in builder can be extended with [custom fields](https://www.builder.io/c/docs/custom-fields). To enable live editing / previewing on components that uses those custom fields, you can use BuilderContent to pass input data from the model to your components that are outside the rendered content
245
+ Page and section models in builder can be extended with [custom fields](https://www.builder.io/c/docs/custom-fields). To enable live editing / previewing on components that uses those custom fields, you can use BuilderContent to pass input data from the model to your components that are outside the rendered content
246
+
247
+ ##### Example, passing Custom Field input:
240
248
 
241
- ##### Example, passing Custom Field input:
242
249
  ```tsx
243
- <BuilderContent model="landing-page">{ (data) => {
244
- /*use your data here within your custom component*/
245
- return <>
246
- <FeaturedImage image={data.featuredImage} />
247
- <BuilderComponent content={content} model="landing-page" />
248
- </>
249
- }}
250
+ <BuilderContent model="landing-page">
251
+ {data => {
252
+ /*use your data here within your custom component*/
253
+ return (
254
+ <>
255
+ <FeaturedImage image={data.featuredImage} />
256
+ <BuilderComponent content={content} model="landing-page" />
257
+ </>
258
+ );
259
+ }}
250
260
  </BuilderContent>
251
261
  ```
252
262
 
@@ -264,6 +274,7 @@ if (content) {
264
274
  ```
265
275
 
266
276
  #### Advanced querying
277
+
267
278
  When using custom [models](https://www.builder.io/c/docs/guides/getting-started-with-models) and [fields](https://www.builder.io/c/docs/custom-fields) you can do more advanced filtering of your content with [queries](<(https://www.builder.io/c/docs/custom-fields)>)
268
279
  and [targeting](https://www.builder.io/c/docs/guides/targeting-and-scheduling)
269
280
 
@@ -1,4 +1,4 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var sdk=require("@builder.io/sdk"),core=require("@emotion/core"),React=require("react"),ReactDOM=require("react-dom"),hash=require("hash-sum");function _interopDefaultLegacy(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}function _interopNamespace(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(n){if("default"!==n){var r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:function(){return e[n]}})}})),t.default=e,Object.freeze(t)}var React__default=_interopDefaultLegacy(React),React__namespace=_interopNamespace(React),ReactDOM__default=_interopDefaultLegacy(ReactDOM),hash__default=_interopDefaultLegacy(hash),version="1.1.52",_a;"undefined"!=typeof window&&(null===(_a=window.parent)||void 0===_a||_a.postMessage({type:"builder.isReactSdk",data:{value:!0,supportsPatchUpdates:"v3",priorVersion:version}},"*"))
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var sdk=require("@builder.io/sdk"),core=require("@emotion/core"),React=require("react"),ReactDOM=require("react-dom"),hash=require("hash-sum");function _interopDefaultLegacy(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}function _interopNamespace(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(n){if("default"!==n){var r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:function(){return e[n]}})}})),t.default=e,Object.freeze(t)}var React__default=_interopDefaultLegacy(React),React__namespace=_interopNamespace(React),ReactDOM__default=_interopDefaultLegacy(ReactDOM),hash__default=_interopDefaultLegacy(hash),version="1.1.53-0",_a;"undefined"!=typeof window&&(null===(_a=window.parent)||void 0===_a||_a.postMessage({type:"builder.isReactSdk",data:{value:!0,supportsPatchUpdates:"v3",priorVersion:version}},"*"))
2
2
  /*! *****************************************************************************
3
3
  Copyright (c) Microsoft Corporation.
4
4