@builder.io/react 8.2.0 → 8.2.2
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/CHANGELOG.md +12 -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 +3 -3
- package/dist/lib/src/blocks/PersonalizationContainer.js.map +1 -1
- package/dist/lib/src/blocks/Router.js +2 -2
- package/dist/lib/src/blocks/Router.js.map +1 -1
- package/dist/lib/src/blocks/Symbol.js +1 -1
- package/dist/lib/src/blocks/Symbol.js.map +1 -1
- package/dist/lib/src/blocks/forms/Form.js +6 -1
- package/dist/lib/src/blocks/forms/Form.js.map +1 -1
- package/dist/lib/src/components/builder-component.component.js +3 -3
- package/dist/lib/src/components/builder-component.component.js.map +1 -1
- package/dist/lib/src/components/builder-content.component.js +1 -1
- package/dist/lib/src/components/builder-content.component.js.map +1 -1
- package/dist/lib/src/components/variants-provider.component.js +2 -2
- package/dist/lib/src/components/variants-provider.component.js.map +1 -1
- package/dist/lib/src/sdk-version.js +1 -1
- package/dist/types/src/components/builder-component.component.d.ts +5 -0
- package/dist/types/src/components/builder-content.component.d.ts +4 -0
- package/dist/types/src/components/variants-provider.component.d.ts +2 -1
- package/dist/types/src/sdk-version.d.ts +1 -1
- package/package.json +1 -1
- package/src/blocks/PersonalizationContainer.tsx +3 -0
- package/src/blocks/Router.tsx +2 -1
- package/src/blocks/Symbol.tsx +1 -0
- package/src/blocks/forms/Form.tsx +7 -1
- package/src/components/builder-component.component.tsx +8 -0
- package/src/components/builder-content.component.tsx +5 -1
- package/src/components/variants-provider.component.tsx +3 -1
|
@@ -39,6 +39,10 @@ export type BuilderContentProps<ContentType> = {
|
|
|
39
39
|
* Required if `inline` is set to `true`.
|
|
40
40
|
*/
|
|
41
41
|
content?: Content;
|
|
42
|
+
/**
|
|
43
|
+
* CSP nonce to allow the loading and execution of a script or style tag when Content-Security-Policy is enabled.
|
|
44
|
+
*/
|
|
45
|
+
nonce?: string;
|
|
42
46
|
} & ({
|
|
43
47
|
model: string;
|
|
44
48
|
} | {
|
|
@@ -3,6 +3,7 @@ import { BuilderContent } from '@builder.io/sdk';
|
|
|
3
3
|
interface VariantsProviderProps {
|
|
4
4
|
initialContent: BuilderContent;
|
|
5
5
|
children: (variants: BuilderContent[], renderScript?: () => JSX.Element) => JSX.Element;
|
|
6
|
+
nonce?: string;
|
|
6
7
|
}
|
|
7
|
-
export declare const VariantsProvider: ({ initialContent, children }: VariantsProviderProps) => React.JSX.Element;
|
|
8
|
+
export declare const VariantsProvider: ({ initialContent, children, nonce }: VariantsProviderProps) => React.JSX.Element;
|
|
8
9
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const SDK_VERSION = "8.2.
|
|
1
|
+
export declare const SDK_VERSION = "8.2.2";
|
package/package.json
CHANGED
|
@@ -106,6 +106,7 @@ export function PersonalizationContainer(props: PersonalizationContainerProps) {
|
|
|
106
106
|
</template>
|
|
107
107
|
))}
|
|
108
108
|
<script
|
|
109
|
+
nonce={builderStore.context.nonce}
|
|
109
110
|
id={`variants-script-${props.builderBlock?.id}`}
|
|
110
111
|
dangerouslySetInnerHTML={{
|
|
111
112
|
__html: getPersonalizationScript(
|
|
@@ -123,6 +124,7 @@ export function PersonalizationContainer(props: PersonalizationContainerProps) {
|
|
|
123
124
|
/>
|
|
124
125
|
</div>
|
|
125
126
|
<script
|
|
127
|
+
nonce={builderStore.context.nonce}
|
|
126
128
|
dangerouslySetInnerHTML={{
|
|
127
129
|
__html: `
|
|
128
130
|
window.__hydrated = window.__hydrated || {};
|
|
@@ -194,6 +196,7 @@ export function PersonalizationContainer(props: PersonalizationContainerProps) {
|
|
|
194
196
|
)}
|
|
195
197
|
</div>
|
|
196
198
|
<script
|
|
199
|
+
nonce={builderStore.context.nonce}
|
|
197
200
|
dangerouslySetInnerHTML={{
|
|
198
201
|
__html: `
|
|
199
202
|
window.__hydrated = window.__hydrated || {};
|
package/src/blocks/Router.tsx
CHANGED
|
@@ -262,7 +262,7 @@ class RouterComponent extends React.Component<PropsWithChildren<RouterProps>> {
|
|
|
262
262
|
return (
|
|
263
263
|
<div className="builder-router" data-model={model}>
|
|
264
264
|
{/* TODO: move to emotion */}
|
|
265
|
-
<style>{`
|
|
265
|
+
<style nonce={state.context.nonce}>{`
|
|
266
266
|
@keyframes builderLoadingSpinner {
|
|
267
267
|
0% {
|
|
268
268
|
transform: rotate(0deg);
|
|
@@ -297,6 +297,7 @@ class RouterComponent extends React.Component<PropsWithChildren<RouterProps>> {
|
|
|
297
297
|
options={{
|
|
298
298
|
key: Builder.isEditing ? undefined : this.model + ':' + url, // TODO: other custom targets specify if should refetch components on change
|
|
299
299
|
}}
|
|
300
|
+
nonce={state.context.nonce}
|
|
300
301
|
>
|
|
301
302
|
{/* TODO: builder blocks option for loading stuff */}
|
|
302
303
|
{/* TODO: input for builder blocks for this */}
|
package/src/blocks/Symbol.tsx
CHANGED
|
@@ -172,6 +172,7 @@ class SymbolComponent extends React.Component<PropsWithChildren<SymbolProps>> {
|
|
|
172
172
|
hydrate={state.state?._hydrate}
|
|
173
173
|
builderBlock={this.props.builderBlock}
|
|
174
174
|
dataOnly={this.props.dataOnly}
|
|
175
|
+
nonce={state.context.nonce}
|
|
175
176
|
>
|
|
176
177
|
{/* TODO: builder blocks option for loading stuff */}
|
|
177
178
|
{this.props.children}
|
|
@@ -100,13 +100,19 @@ class FormComponent extends React.Component<FormProps> {
|
|
|
100
100
|
value: File | boolean | number | string | FileList;
|
|
101
101
|
}[] = Array.from(event.currentTarget.querySelectorAll('input,select,textarea'))
|
|
102
102
|
.filter(el => !!(el as HTMLInputElement).name)
|
|
103
|
+
.filter(
|
|
104
|
+
el =>
|
|
105
|
+
!!(el as HTMLInputElement).name &&
|
|
106
|
+
((el as HTMLInputElement).type !== 'radio' ||
|
|
107
|
+
(el as HTMLInputElement).checked)
|
|
108
|
+
)
|
|
103
109
|
.map(el => {
|
|
104
110
|
let value: any;
|
|
105
111
|
const key = (el as HTMLImageElement).name;
|
|
106
112
|
if (el instanceof HTMLInputElement) {
|
|
107
113
|
if (el.type === 'radio') {
|
|
108
114
|
if (el.checked) {
|
|
109
|
-
value = el.
|
|
115
|
+
value = el.value;
|
|
110
116
|
return { key, value };
|
|
111
117
|
}
|
|
112
118
|
} else if (el.type === 'checkbox') {
|
|
@@ -298,6 +298,11 @@ export interface BuilderComponentProps {
|
|
|
298
298
|
* Pass a list of custom components to register with Builder.io.
|
|
299
299
|
*/
|
|
300
300
|
customComponents?: Array<RegisteredComponent>;
|
|
301
|
+
|
|
302
|
+
/**
|
|
303
|
+
* CSP nonce to allow the loading and execution of a script or style tag when Content-Security-Policy is enabled.
|
|
304
|
+
*/
|
|
305
|
+
nonce?: string;
|
|
301
306
|
}
|
|
302
307
|
|
|
303
308
|
export interface BuilderComponentState {
|
|
@@ -439,6 +444,7 @@ export class BuilderComponent extends React.Component<
|
|
|
439
444
|
context: {
|
|
440
445
|
...props.context,
|
|
441
446
|
apiKey: this.props.apiKey || builder.apiKey,
|
|
447
|
+
nonce: this.props.nonce,
|
|
442
448
|
},
|
|
443
449
|
state: Object.assign(this.rootState, {
|
|
444
450
|
...(this.inlinedContent && this.inlinedContent.data && this.inlinedContent.data.state),
|
|
@@ -1097,6 +1103,7 @@ export class BuilderComponent extends React.Component<
|
|
|
1097
1103
|
}
|
|
1098
1104
|
contentError={this.props.contentError}
|
|
1099
1105
|
modelName={this.name || 'page'}
|
|
1106
|
+
nonce={this.props.nonce}
|
|
1100
1107
|
>
|
|
1101
1108
|
{(data, loading, fullData) => {
|
|
1102
1109
|
if (this.props.dataOnly) {
|
|
@@ -1191,6 +1198,7 @@ export class BuilderComponent extends React.Component<
|
|
|
1191
1198
|
>
|
|
1192
1199
|
{!codegen && this.getCss(data) && (
|
|
1193
1200
|
<style
|
|
1201
|
+
nonce={this.props.nonce}
|
|
1194
1202
|
ref={ref => (this.styleRef = ref)}
|
|
1195
1203
|
className="builder-custom-styles"
|
|
1196
1204
|
dangerouslySetInnerHTML={{
|
|
@@ -50,6 +50,10 @@ export type BuilderContentProps<ContentType> = {
|
|
|
50
50
|
* Required if `inline` is set to `true`.
|
|
51
51
|
*/
|
|
52
52
|
content?: Content;
|
|
53
|
+
/**
|
|
54
|
+
* CSP nonce to allow the loading and execution of a script or style tag when Content-Security-Policy is enabled.
|
|
55
|
+
*/
|
|
56
|
+
nonce?: string;
|
|
53
57
|
} & ({ model: string } | { modelName: string }); // model and modelName are aliases of the same thing¸
|
|
54
58
|
|
|
55
59
|
/**
|
|
@@ -314,7 +318,7 @@ export class BuilderContent<ContentType extends object = any> extends React.Comp
|
|
|
314
318
|
const useData: any = this.data;
|
|
315
319
|
const TagName = this.props.dataOnly ? NoWrap : 'div';
|
|
316
320
|
return (
|
|
317
|
-
<VariantsProvider initialContent={useData}>
|
|
321
|
+
<VariantsProvider initialContent={useData} nonce={this.props.nonce}>
|
|
318
322
|
{(variants, renderScript) => {
|
|
319
323
|
return (
|
|
320
324
|
<React.Fragment>
|
|
@@ -99,9 +99,10 @@ const variantsScript = (variantsString: string, contentId: string) =>
|
|
|
99
99
|
interface VariantsProviderProps {
|
|
100
100
|
initialContent: BuilderContent;
|
|
101
101
|
children: (variants: BuilderContent[], renderScript?: () => JSX.Element) => JSX.Element;
|
|
102
|
+
nonce?: string;
|
|
102
103
|
}
|
|
103
104
|
|
|
104
|
-
export const VariantsProvider = ({ initialContent, children }: VariantsProviderProps) => {
|
|
105
|
+
export const VariantsProvider = ({ initialContent, children, nonce }: VariantsProviderProps) => {
|
|
105
106
|
if (Builder.isBrowser && !builder.canTrack) {
|
|
106
107
|
return children([initialContent]);
|
|
107
108
|
}
|
|
@@ -126,6 +127,7 @@ export const VariantsProvider = ({ initialContent, children }: VariantsProviderP
|
|
|
126
127
|
);
|
|
127
128
|
const renderScript = () => (
|
|
128
129
|
<script
|
|
130
|
+
nonce={nonce}
|
|
129
131
|
id={`variants-script-${initialContent.id}`}
|
|
130
132
|
dangerouslySetInnerHTML={{
|
|
131
133
|
__html: variantsScript(variantsJson, initialContent.id!),
|