@builder.io/sdk-svelte 0.11.3 → 0.11.4

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 (26) hide show
  1. package/lib/browser/components/content/components/enable-editor.svelte +28 -0
  2. package/lib/browser/components/content/components/enable-editor.svelte.d.ts +2 -1
  3. package/lib/browser/components/content/content.helpers.d.ts +1 -1
  4. package/lib/browser/components/content/content.helpers.js +1 -1
  5. package/lib/browser/components/content/content.svelte +3 -2
  6. package/lib/browser/constants/sdk-version.d.ts +1 -1
  7. package/lib/browser/constants/sdk-version.js +1 -1
  8. package/lib/edge/components/content/components/enable-editor.svelte +28 -0
  9. package/lib/edge/components/content/components/enable-editor.svelte.d.ts +2 -1
  10. package/lib/edge/components/content/content.helpers.d.ts +1 -1
  11. package/lib/edge/components/content/content.helpers.js +1 -1
  12. package/lib/edge/components/content/content.svelte +3 -2
  13. package/lib/edge/constants/sdk-version.d.ts +1 -1
  14. package/lib/edge/constants/sdk-version.js +1 -1
  15. package/lib/node/components/content/components/enable-editor.svelte +28 -0
  16. package/lib/node/components/content/components/enable-editor.svelte.d.ts +2 -1
  17. package/lib/node/components/content/content.helpers.d.ts +1 -1
  18. package/lib/node/components/content/content.helpers.js +1 -1
  19. package/lib/node/components/content/content.svelte +3 -2
  20. package/lib/node/constants/sdk-version.d.ts +1 -1
  21. package/lib/node/constants/sdk-version.js +1 -1
  22. package/package.json +1 -1
  23. package/src/components/content/components/enable-editor.svelte +29 -1
  24. package/src/components/content/content.helpers.ts +1 -1
  25. package/src/components/content/content.svelte +3 -2
  26. package/src/constants/sdk-version.ts +1 -1
@@ -28,6 +28,19 @@ export let enrich = undefined;
28
28
  export let content = undefined;
29
29
  export let showContent;
30
30
  export let contentWrapperProps = undefined;
31
+ export let data = undefined;
32
+ function mergeNewRootState(newData) {
33
+ const combinedState = {
34
+ ...$builderContextSignal.rootState,
35
+ ...newData,
36
+ };
37
+ if ($builderContextSignal.rootSetState) {
38
+ $builderContextSignal.rootSetState?.(combinedState);
39
+ }
40
+ else {
41
+ $builderContextSignal.rootState = combinedState;
42
+ }
43
+ }
31
44
  function mergeNewContent(newContent) {
32
45
  const newContentValue = {
33
46
  ...$builderContextSignal.content,
@@ -217,6 +230,7 @@ function elementRef_onInitpreviewingbldr(event) {
217
230
  }
218
231
  let elementRef;
219
232
  let forceReRenderCount = 0;
233
+ let firstRender = true;
220
234
  let lastUpdated = 0;
221
235
  let shouldSendResetCookie = false;
222
236
  let ContentWrapper = contentWrapper || "div";
@@ -277,6 +291,20 @@ function onUpdateFn_4(..._args) {
277
291
  emitStateUpdate();
278
292
  }
279
293
  $: onUpdateFn_4(...[$builderContextSignal.rootState]);
294
+ function onUpdateFn_5(..._args) {
295
+ if (data) {
296
+ mergeNewRootState(data);
297
+ }
298
+ }
299
+ $: onUpdateFn_5(...[data]);
300
+ function onUpdateFn_6(..._args) {
301
+ if (locale) {
302
+ mergeNewRootState({
303
+ locale: locale,
304
+ });
305
+ }
306
+ }
307
+ $: onUpdateFn_6(...[locale]);
280
308
  setContext(builderContext.key, builderContextSignal);
281
309
  onDestroy(() => {
282
310
  if (isBrowser()) {
@@ -1,5 +1,5 @@
1
1
  import { SvelteComponent } from "svelte";
2
- type BuilderEditorProps = Omit<ContentProps, "customComponents" | "data" | "apiVersion" | "isSsrAbTest" | "blocksWrapper" | "blocksWrapperProps"> & {
2
+ type BuilderEditorProps = Omit<ContentProps, "customComponents" | "apiVersion" | "isSsrAbTest" | "blocksWrapper" | "blocksWrapperProps"> & {
3
3
  builderContextSignal: Writable<BuilderContextInterface>;
4
4
  setBuilderContextSignal?: (signal: any) => any;
5
5
  children?: any;
@@ -21,6 +21,7 @@ declare const __propDef: {
21
21
  content?: BuilderEditorProps["content"];
22
22
  showContent: BuilderEditorProps["showContent"];
23
23
  contentWrapperProps?: BuilderEditorProps["contentWrapperProps"];
24
+ data?: BuilderEditorProps["data"];
24
25
  };
25
26
  events: {
26
27
  [evt: string]: CustomEvent<any>;
@@ -1,7 +1,7 @@
1
1
  import type { BuilderContent } from '../../types/builder-content.js';
2
2
  import type { Nullable } from '../../types/typescript.js';
3
3
  import type { ContentProps } from './content.types.js';
4
- export declare const getContextStateInitialValue: ({ content, data, locale }: Pick<ContentProps, 'content' | 'data' | 'locale'>) => {
4
+ export declare const getRootStateInitialValue: ({ content, data, locale }: Pick<ContentProps, 'content' | 'data' | 'locale'>) => {
5
5
  locale?: string | undefined;
6
6
  };
7
7
  export declare const getContentInitialValue: ({ content, data }: Pick<ContentProps, 'content' | 'data'>) => Nullable<BuilderContent>;
@@ -1,4 +1,4 @@
1
- export const getContextStateInitialValue = ({ content, data, locale }) => {
1
+ export const getRootStateInitialValue = ({ content, data, locale }) => {
2
2
  const defaultValues = {};
3
3
  const initialState = content?.data?.state || {};
4
4
  // set default values for content state inputs
@@ -9,7 +9,7 @@ import { getUpdateVariantVisibilityScript } from "../content-variants/helpers.js
9
9
  import InlinedScript from "../inlined-script.svelte";
10
10
  import EnableEditor from "./components/enable-editor.svelte";
11
11
  import ContentStyles from "./components/styles.svelte";
12
- import { getContentInitialValue, getContextStateInitialValue, } from "./content.helpers.js";
12
+ import { getContentInitialValue, getRootStateInitialValue, } from "./content.helpers.js";
13
13
  import "./wrap-component-ref.js";
14
14
  export let content = undefined;
15
15
  export let customComponents = undefined;
@@ -59,7 +59,7 @@ let builderContextSignal = writable({
59
59
  data: data,
60
60
  }),
61
61
  localState: undefined,
62
- rootState: getContextStateInitialValue({
62
+ rootState: getRootStateInitialValue({
63
63
  content: content,
64
64
  data: data,
65
65
  locale: locale,
@@ -92,6 +92,7 @@ setContext(ComponentsContext.key, {
92
92
 
93
93
  <EnableEditor
94
94
  {content}
95
+ {data}
95
96
  {model}
96
97
  {context}
97
98
  {apiKey}
@@ -1 +1 @@
1
- export declare const SDK_VERSION = "0.11.3";
1
+ export declare const SDK_VERSION = "0.11.4";
@@ -1 +1 @@
1
- export const SDK_VERSION = "0.11.3";
1
+ export const SDK_VERSION = "0.11.4";
@@ -28,6 +28,19 @@ export let enrich = undefined;
28
28
  export let content = undefined;
29
29
  export let showContent;
30
30
  export let contentWrapperProps = undefined;
31
+ export let data = undefined;
32
+ function mergeNewRootState(newData) {
33
+ const combinedState = {
34
+ ...$builderContextSignal.rootState,
35
+ ...newData,
36
+ };
37
+ if ($builderContextSignal.rootSetState) {
38
+ $builderContextSignal.rootSetState?.(combinedState);
39
+ }
40
+ else {
41
+ $builderContextSignal.rootState = combinedState;
42
+ }
43
+ }
31
44
  function mergeNewContent(newContent) {
32
45
  const newContentValue = {
33
46
  ...$builderContextSignal.content,
@@ -217,6 +230,7 @@ function elementRef_onInitpreviewingbldr(event) {
217
230
  }
218
231
  let elementRef;
219
232
  let forceReRenderCount = 0;
233
+ let firstRender = true;
220
234
  let lastUpdated = 0;
221
235
  let shouldSendResetCookie = false;
222
236
  let ContentWrapper = contentWrapper || "div";
@@ -277,6 +291,20 @@ function onUpdateFn_4(..._args) {
277
291
  emitStateUpdate();
278
292
  }
279
293
  $: onUpdateFn_4(...[$builderContextSignal.rootState]);
294
+ function onUpdateFn_5(..._args) {
295
+ if (data) {
296
+ mergeNewRootState(data);
297
+ }
298
+ }
299
+ $: onUpdateFn_5(...[data]);
300
+ function onUpdateFn_6(..._args) {
301
+ if (locale) {
302
+ mergeNewRootState({
303
+ locale: locale,
304
+ });
305
+ }
306
+ }
307
+ $: onUpdateFn_6(...[locale]);
280
308
  setContext(builderContext.key, builderContextSignal);
281
309
  onDestroy(() => {
282
310
  if (isBrowser()) {
@@ -1,5 +1,5 @@
1
1
  import { SvelteComponent } from "svelte";
2
- type BuilderEditorProps = Omit<ContentProps, "customComponents" | "data" | "apiVersion" | "isSsrAbTest" | "blocksWrapper" | "blocksWrapperProps"> & {
2
+ type BuilderEditorProps = Omit<ContentProps, "customComponents" | "apiVersion" | "isSsrAbTest" | "blocksWrapper" | "blocksWrapperProps"> & {
3
3
  builderContextSignal: Writable<BuilderContextInterface>;
4
4
  setBuilderContextSignal?: (signal: any) => any;
5
5
  children?: any;
@@ -21,6 +21,7 @@ declare const __propDef: {
21
21
  content?: BuilderEditorProps["content"];
22
22
  showContent: BuilderEditorProps["showContent"];
23
23
  contentWrapperProps?: BuilderEditorProps["contentWrapperProps"];
24
+ data?: BuilderEditorProps["data"];
24
25
  };
25
26
  events: {
26
27
  [evt: string]: CustomEvent<any>;
@@ -1,7 +1,7 @@
1
1
  import type { BuilderContent } from '../../types/builder-content.js';
2
2
  import type { Nullable } from '../../types/typescript.js';
3
3
  import type { ContentProps } from './content.types.js';
4
- export declare const getContextStateInitialValue: ({ content, data, locale }: Pick<ContentProps, 'content' | 'data' | 'locale'>) => {
4
+ export declare const getRootStateInitialValue: ({ content, data, locale }: Pick<ContentProps, 'content' | 'data' | 'locale'>) => {
5
5
  locale?: string | undefined;
6
6
  };
7
7
  export declare const getContentInitialValue: ({ content, data }: Pick<ContentProps, 'content' | 'data'>) => Nullable<BuilderContent>;
@@ -1,4 +1,4 @@
1
- export const getContextStateInitialValue = ({ content, data, locale }) => {
1
+ export const getRootStateInitialValue = ({ content, data, locale }) => {
2
2
  const defaultValues = {};
3
3
  const initialState = content?.data?.state || {};
4
4
  // set default values for content state inputs
@@ -9,7 +9,7 @@ import { getUpdateVariantVisibilityScript } from "../content-variants/helpers.js
9
9
  import InlinedScript from "../inlined-script.svelte";
10
10
  import EnableEditor from "./components/enable-editor.svelte";
11
11
  import ContentStyles from "./components/styles.svelte";
12
- import { getContentInitialValue, getContextStateInitialValue, } from "./content.helpers.js";
12
+ import { getContentInitialValue, getRootStateInitialValue, } from "./content.helpers.js";
13
13
  import "./wrap-component-ref.js";
14
14
  export let content = undefined;
15
15
  export let customComponents = undefined;
@@ -59,7 +59,7 @@ let builderContextSignal = writable({
59
59
  data: data,
60
60
  }),
61
61
  localState: undefined,
62
- rootState: getContextStateInitialValue({
62
+ rootState: getRootStateInitialValue({
63
63
  content: content,
64
64
  data: data,
65
65
  locale: locale,
@@ -92,6 +92,7 @@ setContext(ComponentsContext.key, {
92
92
 
93
93
  <EnableEditor
94
94
  {content}
95
+ {data}
95
96
  {model}
96
97
  {context}
97
98
  {apiKey}
@@ -1 +1 @@
1
- export declare const SDK_VERSION = "0.11.3";
1
+ export declare const SDK_VERSION = "0.11.4";
@@ -1 +1 @@
1
- export const SDK_VERSION = "0.11.3";
1
+ export const SDK_VERSION = "0.11.4";
@@ -28,6 +28,19 @@ export let enrich = undefined;
28
28
  export let content = undefined;
29
29
  export let showContent;
30
30
  export let contentWrapperProps = undefined;
31
+ export let data = undefined;
32
+ function mergeNewRootState(newData) {
33
+ const combinedState = {
34
+ ...$builderContextSignal.rootState,
35
+ ...newData,
36
+ };
37
+ if ($builderContextSignal.rootSetState) {
38
+ $builderContextSignal.rootSetState?.(combinedState);
39
+ }
40
+ else {
41
+ $builderContextSignal.rootState = combinedState;
42
+ }
43
+ }
31
44
  function mergeNewContent(newContent) {
32
45
  const newContentValue = {
33
46
  ...$builderContextSignal.content,
@@ -217,6 +230,7 @@ function elementRef_onInitpreviewingbldr(event) {
217
230
  }
218
231
  let elementRef;
219
232
  let forceReRenderCount = 0;
233
+ let firstRender = true;
220
234
  let lastUpdated = 0;
221
235
  let shouldSendResetCookie = false;
222
236
  let ContentWrapper = contentWrapper || "div";
@@ -277,6 +291,20 @@ function onUpdateFn_4(..._args) {
277
291
  emitStateUpdate();
278
292
  }
279
293
  $: onUpdateFn_4(...[$builderContextSignal.rootState]);
294
+ function onUpdateFn_5(..._args) {
295
+ if (data) {
296
+ mergeNewRootState(data);
297
+ }
298
+ }
299
+ $: onUpdateFn_5(...[data]);
300
+ function onUpdateFn_6(..._args) {
301
+ if (locale) {
302
+ mergeNewRootState({
303
+ locale: locale,
304
+ });
305
+ }
306
+ }
307
+ $: onUpdateFn_6(...[locale]);
280
308
  setContext(builderContext.key, builderContextSignal);
281
309
  onDestroy(() => {
282
310
  if (isBrowser()) {
@@ -1,5 +1,5 @@
1
1
  import { SvelteComponent } from "svelte";
2
- type BuilderEditorProps = Omit<ContentProps, "customComponents" | "data" | "apiVersion" | "isSsrAbTest" | "blocksWrapper" | "blocksWrapperProps"> & {
2
+ type BuilderEditorProps = Omit<ContentProps, "customComponents" | "apiVersion" | "isSsrAbTest" | "blocksWrapper" | "blocksWrapperProps"> & {
3
3
  builderContextSignal: Writable<BuilderContextInterface>;
4
4
  setBuilderContextSignal?: (signal: any) => any;
5
5
  children?: any;
@@ -21,6 +21,7 @@ declare const __propDef: {
21
21
  content?: BuilderEditorProps["content"];
22
22
  showContent: BuilderEditorProps["showContent"];
23
23
  contentWrapperProps?: BuilderEditorProps["contentWrapperProps"];
24
+ data?: BuilderEditorProps["data"];
24
25
  };
25
26
  events: {
26
27
  [evt: string]: CustomEvent<any>;
@@ -1,7 +1,7 @@
1
1
  import type { BuilderContent } from '../../types/builder-content.js';
2
2
  import type { Nullable } from '../../types/typescript.js';
3
3
  import type { ContentProps } from './content.types.js';
4
- export declare const getContextStateInitialValue: ({ content, data, locale }: Pick<ContentProps, 'content' | 'data' | 'locale'>) => {
4
+ export declare const getRootStateInitialValue: ({ content, data, locale }: Pick<ContentProps, 'content' | 'data' | 'locale'>) => {
5
5
  locale?: string | undefined;
6
6
  };
7
7
  export declare const getContentInitialValue: ({ content, data }: Pick<ContentProps, 'content' | 'data'>) => Nullable<BuilderContent>;
@@ -1,4 +1,4 @@
1
- export const getContextStateInitialValue = ({ content, data, locale }) => {
1
+ export const getRootStateInitialValue = ({ content, data, locale }) => {
2
2
  const defaultValues = {};
3
3
  const initialState = content?.data?.state || {};
4
4
  // set default values for content state inputs
@@ -9,7 +9,7 @@ import { getUpdateVariantVisibilityScript } from "../content-variants/helpers.js
9
9
  import InlinedScript from "../inlined-script.svelte";
10
10
  import EnableEditor from "./components/enable-editor.svelte";
11
11
  import ContentStyles from "./components/styles.svelte";
12
- import { getContentInitialValue, getContextStateInitialValue, } from "./content.helpers.js";
12
+ import { getContentInitialValue, getRootStateInitialValue, } from "./content.helpers.js";
13
13
  import "./wrap-component-ref.js";
14
14
  export let content = undefined;
15
15
  export let customComponents = undefined;
@@ -59,7 +59,7 @@ let builderContextSignal = writable({
59
59
  data: data,
60
60
  }),
61
61
  localState: undefined,
62
- rootState: getContextStateInitialValue({
62
+ rootState: getRootStateInitialValue({
63
63
  content: content,
64
64
  data: data,
65
65
  locale: locale,
@@ -92,6 +92,7 @@ setContext(ComponentsContext.key, {
92
92
 
93
93
  <EnableEditor
94
94
  {content}
95
+ {data}
95
96
  {model}
96
97
  {context}
97
98
  {apiKey}
@@ -1 +1 @@
1
- export declare const SDK_VERSION = "0.11.3";
1
+ export declare const SDK_VERSION = "0.11.4";
@@ -1 +1 @@
1
- export const SDK_VERSION = "0.11.3";
1
+ export const SDK_VERSION = "0.11.4";
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@builder.io/sdk-svelte",
3
3
  "description": "Builder.io SDK for Svelte",
4
- "version": "0.11.3",
4
+ "version": "0.11.4",
5
5
  "type": "module",
6
6
  "files": [
7
7
  "lib",
@@ -2,7 +2,6 @@
2
2
  type BuilderEditorProps = Omit<
3
3
  ContentProps,
4
4
  | "customComponents"
5
- | "data"
6
5
  | "apiVersion"
7
6
  | "isSsrAbTest"
8
7
  | "blocksWrapper"
@@ -38,6 +37,7 @@
38
37
  } from "../../../scripts/init-editing.js";
39
38
  import type { BuilderContent } from "../../../types/builder-content.js";
40
39
  import type { ComponentInfo } from "../../../types/components.js";
40
+ import type { Dictionary } from "../../../types/typescript.js";
41
41
  import type {
42
42
  BuilderComponentStateChange,
43
43
  ContentProps,
@@ -58,6 +58,19 @@
58
58
  export let contentWrapperProps: BuilderEditorProps["contentWrapperProps"] =
59
59
  undefined;
60
60
 
61
+ export let data: BuilderEditorProps["data"] = undefined;
62
+
63
+ function mergeNewRootState(newData: Dictionary<any>) {
64
+ const combinedState = {
65
+ ...$builderContextSignal.rootState,
66
+ ...newData,
67
+ };
68
+ if ($builderContextSignal.rootSetState) {
69
+ $builderContextSignal.rootSetState?.(combinedState);
70
+ } else {
71
+ $builderContextSignal.rootState = combinedState;
72
+ }
73
+ }
61
74
  function mergeNewContent(newContent: BuilderContent) {
62
75
  const newContentValue = {
63
76
  ...$builderContextSignal.content,
@@ -271,6 +284,7 @@
271
284
  let elementRef;
272
285
 
273
286
  let forceReRenderCount = 0;
287
+ let firstRender = true;
274
288
  let lastUpdated = 0;
275
289
  let shouldSendResetCookie = false;
276
290
  let ContentWrapper = contentWrapper || "div";
@@ -339,6 +353,20 @@
339
353
  emitStateUpdate();
340
354
  }
341
355
  $: onUpdateFn_4(...[$builderContextSignal.rootState]);
356
+ function onUpdateFn_5(..._args: any[]) {
357
+ if (data) {
358
+ mergeNewRootState(data);
359
+ }
360
+ }
361
+ $: onUpdateFn_5(...[data]);
362
+ function onUpdateFn_6(..._args: any[]) {
363
+ if (locale) {
364
+ mergeNewRootState({
365
+ locale: locale,
366
+ });
367
+ }
368
+ }
369
+ $: onUpdateFn_6(...[locale]);
342
370
 
343
371
  setContext(builderContext.key, builderContextSignal);
344
372
 
@@ -2,7 +2,7 @@ import type { BuilderRenderState } from '../../context/types.js';
2
2
  import type { BuilderContent } from '../../types/builder-content.js';
3
3
  import type { Nullable } from '../../types/typescript.js';
4
4
  import type { ContentProps } from './content.types.js';
5
- export const getContextStateInitialValue = ({
5
+ export const getRootStateInitialValue = ({
6
6
  content,
7
7
  data,
8
8
  locale
@@ -23,7 +23,7 @@
23
23
  import ContentStyles from "./components/styles.svelte";
24
24
  import {
25
25
  getContentInitialValue,
26
- getContextStateInitialValue,
26
+ getRootStateInitialValue,
27
27
  } from "./content.helpers.js";
28
28
  import type { ContentProps } from "./content.types.js";
29
29
  import { wrapComponentRef } from "./wrap-component-ref.js";
@@ -82,7 +82,7 @@
82
82
  data: data,
83
83
  }),
84
84
  localState: undefined,
85
- rootState: getContextStateInitialValue({
85
+ rootState: getRootStateInitialValue({
86
86
  content: content,
87
87
  data: data,
88
88
  locale: locale,
@@ -119,6 +119,7 @@
119
119
 
120
120
  <EnableEditor
121
121
  {content}
122
+ {data}
122
123
  {model}
123
124
  {context}
124
125
  {apiKey}
@@ -1 +1 @@
1
- export const SDK_VERSION = "0.11.3"
1
+ export const SDK_VERSION = "0.11.4"