@contentful/experiences-sdk-react 1.8.2-dev-20240625T1531-940b953.0 → 1.8.2-dev-20240625T1857-ee5ef2b.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 (52) hide show
  1. package/dist/ExperienceRoot.js +25 -0
  2. package/dist/ExperienceRoot.js.map +1 -0
  3. package/dist/{VisualEditorInjectScript-6a92528d.js → blocks/editor/VisualEditorInjectScript.js} +1 -1
  4. package/dist/blocks/editor/VisualEditorInjectScript.js.map +1 -0
  5. package/dist/{VisualEditorLoader-3839b3a6.js → blocks/editor/VisualEditorLoader.js} +2 -2
  6. package/dist/blocks/editor/VisualEditorLoader.js.map +1 -0
  7. package/dist/blocks/editor/VisualEditorRoot.js +17 -0
  8. package/dist/blocks/editor/VisualEditorRoot.js.map +1 -0
  9. package/dist/blocks/preview/CompositionBlock.js +132 -0
  10. package/dist/blocks/preview/CompositionBlock.js.map +1 -0
  11. package/dist/blocks/preview/PreviewDeliveryRoot.js +23 -0
  12. package/dist/blocks/preview/PreviewDeliveryRoot.js.map +1 -0
  13. package/dist/components/Assembly.js +13 -0
  14. package/dist/components/Assembly.js.map +1 -0
  15. package/dist/components/ErrorBoundary.js +37 -0
  16. package/dist/components/ErrorBoundary.js.map +1 -0
  17. package/dist/constants.js +5 -0
  18. package/dist/constants.js.map +1 -0
  19. package/dist/core/componentRegistry.js +291 -0
  20. package/dist/core/componentRegistry.js.map +1 -0
  21. package/dist/core/preview/assemblyUtils.js +71 -0
  22. package/dist/core/preview/assemblyUtils.js.map +1 -0
  23. package/dist/core/sdkFeatures.js +7 -0
  24. package/dist/core/sdkFeatures.js.map +1 -0
  25. package/dist/hooks/useBreakpoints.js +40 -0
  26. package/dist/hooks/useBreakpoints.js.map +1 -0
  27. package/dist/hooks/useClassName.js +42 -0
  28. package/dist/hooks/useClassName.js.map +1 -0
  29. package/dist/hooks/useDetectEditorMode.js +60 -0
  30. package/dist/hooks/useDetectEditorMode.js.map +1 -0
  31. package/dist/hooks/useFetchByBase.js +38 -0
  32. package/dist/hooks/useFetchByBase.js.map +1 -0
  33. package/dist/hooks/useFetchById.js +16 -0
  34. package/dist/hooks/useFetchById.js.map +1 -0
  35. package/dist/hooks/useFetchBySlug.js +16 -0
  36. package/dist/hooks/useFetchBySlug.js.map +1 -0
  37. package/dist/hooks/useInitializeVisualEditor.js +56 -0
  38. package/dist/hooks/useInitializeVisualEditor.js.map +1 -0
  39. package/dist/index.d.ts +1 -1
  40. package/dist/index.js +6 -5166
  41. package/dist/index.js.map +1 -1
  42. package/dist/sdkVersion.js +4 -0
  43. package/dist/sdkVersion.js.map +1 -0
  44. package/dist/src/ExperienceRoot.d.ts +1 -1
  45. package/dist/src/sdkVersion.d.ts +1 -1
  46. package/dist/styles/ErrorBoundary.css.js +7 -0
  47. package/dist/styles/ErrorBoundary.css.js.map +1 -0
  48. package/dist/utils/withComponentWrapper.js +36 -0
  49. package/dist/utils/withComponentWrapper.js.map +1 -0
  50. package/package.json +7 -5
  51. package/dist/VisualEditorInjectScript-6a92528d.js.map +0 -1
  52. package/dist/VisualEditorLoader-3839b3a6.js.map +0 -1
@@ -0,0 +1,4 @@
1
+ const SDK_VERSION = '1.8.2-dev-20240625T1857-ee5ef2b.0';
2
+
3
+ export { SDK_VERSION };
4
+ //# sourceMappingURL=sdkVersion.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sdkVersion.js","sources":["../../src/sdkVersion.ts"],"sourcesContent":["export const SDK_VERSION = '1.8.2-dev-20240625T1857-ee5ef2b.0';\n"],"names":[],"mappings":"AAAO,MAAM,WAAW,GAAG;;;;"}
@@ -2,7 +2,7 @@ import { VisualEditorMode } from '@contentful/experiences-core';
2
2
  import { EntityStore } from '@contentful/experiences-core';
3
3
  import type { Experience } from '@contentful/experiences-core/types';
4
4
  type ExperienceRootProps = {
5
- experience?: Experience<EntityStore>;
5
+ experience?: Experience<EntityStore> | string | null;
6
6
  locale: string;
7
7
  visualEditorMode?: VisualEditorMode;
8
8
  };
@@ -1 +1 @@
1
- export declare const SDK_VERSION = "1.8.2-dev-20240625T1531-940b953.0";
1
+ export declare const SDK_VERSION = "1.8.2-dev-20240625T1857-ee5ef2b.0";
@@ -0,0 +1,7 @@
1
+ import styleInject from 'style-inject';
2
+
3
+ var css_248z = ".cf-error-message {\n margin: 24px;\n font-size: var(--exp-builder-font-size-m);\n font-family: var(--exp-builder-font-stack-primary);\n color: var(--exp-builder-red800);\n padding: 16px;\n background-color: var(--exp-builder-red200);\n}\n\n.cf-error-message .title {\n margin-top: 0;\n font-size: var(--exp-builder-font-size-l);\n}\n\n.cf-error-message .more-details {\n cursor: pointer;\n color: var(--exp-builder-blue700);\n}\n";
4
+ styleInject(css_248z);
5
+
6
+ export { css_248z as default };
7
+ //# sourceMappingURL=ErrorBoundary.css.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ErrorBoundary.css.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;"}
@@ -0,0 +1,36 @@
1
+ import { jsx } from 'react/jsx-runtime';
2
+ import React from 'react';
3
+
4
+ /**
5
+ * Sets up a component to be consumed by Experience Builder. This function can be used to wrap a component with a container component, or to pass props to the component directly.
6
+ * @param Component Component to be used by Experience Builder.
7
+ * @param options Options for the `withComponentWrapper` function.
8
+ * @default { wrapComponent: true, wrapContainerTag: 'div' }
9
+ * @returns A component that can be passed to `defineComponents`.
10
+ */
11
+ function withComponentWrapper(Component, options = {
12
+ wrapComponent: true,
13
+ wrapContainerTag: 'div',
14
+ }) {
15
+ const Wrapped = ({ classes = '', className = '', 'data-cf-node-id': dataCfNodeId, 'data-cf-node-block-id': dataCfNodeBlockId, 'data-cf-node-block-type': dataCfNodeBlockType, onClick, onMouseDown, onMouseUp, ...props }) => {
16
+ const Tag = options.wrapContainerTag || 'div';
17
+ const cfProps = {
18
+ 'data-cf-node-id': dataCfNodeId,
19
+ 'data-cf-node-block-id': dataCfNodeBlockId,
20
+ 'data-cf-node-block-type': dataCfNodeBlockType,
21
+ onClick,
22
+ onMouseDown,
23
+ onMouseUp,
24
+ };
25
+ const component = options.wrapComponent ? (jsx(Tag, { className: className, ...cfProps, children: typeof Component === 'string' ? (React.createElement(Component, { className: classes, ...props })) : (jsx(Component, { className: classes, ...props })) })) : (React.createElement(Component, {
26
+ className: classes + className ? classes + ' ' + className : undefined,
27
+ ...cfProps,
28
+ ...props,
29
+ }));
30
+ return component;
31
+ };
32
+ return Wrapped;
33
+ }
34
+
35
+ export { withComponentWrapper };
36
+ //# sourceMappingURL=withComponentWrapper.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"withComponentWrapper.js","sources":["../../../src/utils/withComponentWrapper.tsx"],"sourcesContent":["import { ComponentRegistration } from '@contentful/experiences-core/types';\nimport React from 'react';\n\ninterface CFProps {\n /**\n * Classes to be applied to the container component if `wrapComponent` is true, or directly to the child component if false.\n */\n className?: string;\n /**\n * Classes to be applied to the child component if `wrapComponent` is true, or directly to the child component if false.\n */\n classes?: string;\n onMouseDown?: React.MouseEventHandler;\n onMouseUp?: React.MouseEventHandler;\n onClick?: React.MouseEventHandler;\n /**\n * Prop required by Experience Builder to identify the component.\n */\n 'data-cf-node-id'?: string;\n /**\n * Prop required by Experience Builder to identify the component.\n */\n 'data-cf-node-block-id'?: string;\n /**\n * Prop required by Experience Builder to identify the component's type.\n */\n 'data-cf-node-block-type'?: string;\n}\n\n/**\n * Sets up a component to be consumed by Experience Builder. This function can be used to wrap a component with a container component, or to pass props to the component directly.\n * @param Component Component to be used by Experience Builder.\n * @param options Options for the `withComponentWrapper` function.\n * @default { wrapComponent: true, wrapContainerTag: 'div' }\n * @returns A component that can be passed to `defineComponents`.\n */\nexport function withComponentWrapper<T extends object>(\n Component: React.ElementType<T>,\n options: ComponentRegistration['options'] = {\n wrapComponent: true,\n wrapContainerTag: 'div',\n },\n) {\n const Wrapped = ({\n classes = '',\n className = '',\n 'data-cf-node-id': dataCfNodeId,\n 'data-cf-node-block-id': dataCfNodeBlockId,\n 'data-cf-node-block-type': dataCfNodeBlockType,\n onClick,\n onMouseDown,\n onMouseUp,\n ...props\n }: CFProps & T) => {\n const Tag = options.wrapContainerTag || 'div';\n const cfProps = {\n 'data-cf-node-id': dataCfNodeId,\n 'data-cf-node-block-id': dataCfNodeBlockId,\n 'data-cf-node-block-type': dataCfNodeBlockType,\n onClick,\n onMouseDown,\n onMouseUp,\n };\n\n const component = options.wrapComponent ? (\n <Tag className={className} {...cfProps}>\n {typeof Component === 'string' ? (\n React.createElement(Component, { className: classes, ...props })\n ) : (\n <Component className={classes} {...(props as T)} />\n )}\n </Tag>\n ) : (\n React.createElement(Component, {\n className: classes + className ? classes + ' ' + className : undefined,\n ...cfProps,\n ...(props as T),\n })\n );\n return component;\n };\n\n return Wrapped;\n}\n"],"names":["_jsx"],"mappings":";;;AA6BA;;;;;;AAMG;AACa,SAAA,oBAAoB,CAClC,SAA+B,EAC/B,OAA4C,GAAA;AAC1C,IAAA,aAAa,EAAE,IAAI;AACnB,IAAA,gBAAgB,EAAE,KAAK;AACxB,CAAA,EAAA;AAED,IAAA,MAAM,OAAO,GAAG,CAAC,EACf,OAAO,GAAG,EAAE,EACZ,SAAS,GAAG,EAAE,EACd,iBAAiB,EAAE,YAAY,EAC/B,uBAAuB,EAAE,iBAAiB,EAC1C,yBAAyB,EAAE,mBAAmB,EAC9C,OAAO,EACP,WAAW,EACX,SAAS,EACT,GAAG,KAAK,EACI,KAAI;AAChB,QAAA,MAAM,GAAG,GAAG,OAAO,CAAC,gBAAgB,IAAI,KAAK,CAAC;AAC9C,QAAA,MAAM,OAAO,GAAG;AACd,YAAA,iBAAiB,EAAE,YAAY;AAC/B,YAAA,uBAAuB,EAAE,iBAAiB;AAC1C,YAAA,yBAAyB,EAAE,mBAAmB;YAC9C,OAAO;YACP,WAAW;YACX,SAAS;SACV,CAAC;AAEF,QAAA,MAAM,SAAS,GAAG,OAAO,CAAC,aAAa,IACrCA,GAAA,CAAC,GAAG,EAAA,EAAC,SAAS,EAAE,SAAS,EAAM,GAAA,OAAO,EACnC,QAAA,EAAA,OAAO,SAAS,KAAK,QAAQ,IAC5B,KAAK,CAAC,aAAa,CAAC,SAAS,EAAE,EAAE,SAAS,EAAE,OAAO,EAAE,GAAG,KAAK,EAAE,CAAC,KAEhEA,GAAC,CAAA,SAAS,IAAC,SAAS,EAAE,OAAO,EAAA,GAAO,KAAW,EAAA,CAAI,CACpD,EAAA,CACG,KAEN,KAAK,CAAC,aAAa,CAAC,SAAS,EAAE;AAC7B,YAAA,SAAS,EAAE,OAAO,GAAG,SAAS,GAAG,OAAO,GAAG,GAAG,GAAG,SAAS,GAAG,SAAS;AACtE,YAAA,GAAG,OAAO;AACV,YAAA,GAAI,KAAW;AAChB,SAAA,CAAC,CACH,CAAC;AACF,QAAA,OAAO,SAAS,CAAC;AACnB,KAAC,CAAC;AAEF,IAAA,OAAO,OAAO,CAAC;AACjB;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contentful/experiences-sdk-react",
3
- "version": "1.8.2-dev-20240625T1531-940b953.0",
3
+ "version": "1.8.2-dev-20240625T1857-ee5ef2b.0",
4
4
  "main": "./dist/index.js",
5
5
  "module": "./dist/index.js",
6
6
  "typings": "./dist/src/index.d.ts",
@@ -33,9 +33,10 @@
33
33
  "depcruise": "depcruise src"
34
34
  },
35
35
  "dependencies": {
36
- "@contentful/experiences-components-react": "1.8.2-dev-20240625T1531-940b953.0",
37
- "@contentful/experiences-core": "1.8.2-dev-20240625T1531-940b953.0",
38
- "@contentful/experiences-visual-editor-react": "1.8.2-dev-20240625T1531-940b953.0",
36
+ "@contentful/experiences-components-react": "1.8.2-dev-20240625T1857-ee5ef2b.0",
37
+ "@contentful/experiences-core": "1.8.2-dev-20240625T1857-ee5ef2b.0",
38
+ "@contentful/experiences-validators": "1.8.2-dev-20240625T1857-ee5ef2b.0",
39
+ "@contentful/experiences-visual-editor-react": "1.8.2-dev-20240625T1857-ee5ef2b.0",
39
40
  "@contentful/rich-text-types": "^16.2.1",
40
41
  "classnames": "^2.3.2",
41
42
  "csstype": "^3.1.2",
@@ -76,6 +77,7 @@
76
77
  "rollup-plugin-node-externals": "^7.0.1",
77
78
  "rollup-plugin-peer-deps-external": "^2.2.4",
78
79
  "rollup-plugin-postcss": "^4.0.2",
80
+ "rollup-plugin-preserve-directives": "^0.4.0",
79
81
  "semantic-release": "23.0.2",
80
82
  "ts-jest": "^29.1.0",
81
83
  "typescript": "^5.2.2",
@@ -92,5 +94,5 @@
92
94
  "dist",
93
95
  "package.json"
94
96
  ],
95
- "gitHead": "f06c3366003eab999e5e9c2e396476a3070c3aaa"
97
+ "gitHead": "2b09825bd457aa56aaf23674380a2f1cb8460e71"
96
98
  }
@@ -1 +0,0 @@
1
- {"version":3,"file":"VisualEditorInjectScript-6a92528d.js","sources":["../../src/blocks/editor/VisualEditorInjectScript.tsx"],"sourcesContent":["import React, { useEffect } from 'react';\nimport { VISUAL_EDITOR_CONTAINER_ID } from '@contentful/experiences-core/constants';\n\n/**\n * The version can be any semver version or dist tag\n * Examples: @latest, @dev, @pre, @0.0.1-pre-20231213T103332.0\n *\n * If the version is empty, unpkg will redirect to the latest version of the package\n */\nconst version = '@0.0.1-pre-20231213T210727.0';\n\n/**\n * CDN URL for the visual editor script\n *\n * This can be changed to a local file path for development\n *\n * TODO: Reconsider unpkg\n */\nconst scriptUrl = `https://unpkg.com/@contentful/experience-builder-visual-editor${version}/dist/renderApp.js`;\n\n/**\n * This component injects the visual editor script into the page\n */\nexport default function VisualEditorInjectScript() {\n useEffect(() => {\n const script = document.createElement('script');\n script.type = 'module';\n script.src = scriptUrl;\n script.async = true;\n\n document.body.appendChild(script);\n return () => {\n document.body.removeChild(script);\n };\n }, []);\n\n return <div id={VISUAL_EDITOR_CONTAINER_ID} />;\n}\n"],"names":["_jsx"],"mappings":";;;;AAGA;;;;;AAKG;AACH,MAAM,OAAO,GAAG,8BAA8B,CAAC;AAE/C;;;;;;AAMG;AACH,MAAM,SAAS,GAAG,CAAiE,8DAAA,EAAA,OAAO,oBAAoB,CAAC;AAE/G;;AAEG;AACW,SAAU,wBAAwB,GAAA;IAC9C,SAAS,CAAC,MAAK;QACb,MAAM,MAAM,GAAG,QAAQ,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC;AAChD,QAAA,MAAM,CAAC,IAAI,GAAG,QAAQ,CAAC;AACvB,QAAA,MAAM,CAAC,GAAG,GAAG,SAAS,CAAC;AACvB,QAAA,MAAM,CAAC,KAAK,GAAG,IAAI,CAAC;AAEpB,QAAA,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;AAClC,QAAA,OAAO,MAAK;AACV,YAAA,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;AACpC,SAAC,CAAC;KACH,EAAE,EAAE,CAAC,CAAC;AAEP,IAAA,OAAOA,GAAK,CAAA,KAAA,EAAA,EAAA,EAAE,EAAE,0BAA0B,GAAI,CAAC;AACjD;;;;"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"VisualEditorLoader-3839b3a6.js","sources":["../../src/blocks/editor/VisualEditorLoader.tsx"],"sourcesContent":["import React, { useEffect, useState } from 'react';\nimport { EntityStore, VisualEditorMode } from '@contentful/experiences-core';\nimport type { Experience } from '@contentful/experiences-core/types';\n\ntype VisualEditorLoaderProps = {\n visualEditorMode: VisualEditorMode;\n experience?: Experience<EntityStore>;\n};\n\nexport const VisualEditorLoader: React.FC<VisualEditorLoaderProps> = ({\n visualEditorMode,\n\n experience,\n}) => {\n const [VisualEditor, setVisualEditor] = useState<React.ComponentType<{\n experience?: Experience<EntityStore>;\n }> | null>(null);\n\n useEffect(() => {\n // Dynamically import the visual editor based on the configured mode\n switch (visualEditorMode) {\n case VisualEditorMode.InjectScript:\n import('./VisualEditorInjectScript').then((module) => {\n setVisualEditor(() => module.default);\n });\n break;\n\n // VisualEditorMode.LazyLoad:\n default:\n import('@contentful/experiences-visual-editor-react').then((module) => {\n setVisualEditor(() => module.default);\n });\n }\n }, [visualEditorMode]);\n\n if (!VisualEditor) return null;\n\n return <VisualEditor experience={experience} />;\n};\n\nexport default VisualEditorLoader;\n"],"names":["_jsx"],"mappings":";;;;AASa,MAAA,kBAAkB,GAAsC,CAAC,EACpE,gBAAgB,EAEhB,UAAU,GACX,KAAI;IACH,MAAM,CAAC,YAAY,EAAE,eAAe,CAAC,GAAG,QAAQ,CAErC,IAAI,CAAC,CAAC;IAEjB,SAAS,CAAC,MAAK;;QAEb,QAAQ,gBAAgB;YACtB,KAAK,gBAAgB,CAAC,YAAY;gBAChC,OAAO,wCAA4B,CAAC,CAAC,IAAI,CAAC,CAAC,MAAM,KAAI;oBACnD,eAAe,CAAC,MAAM,MAAM,CAAC,OAAO,CAAC,CAAC;AACxC,iBAAC,CAAC,CAAC;gBACH,MAAM;;AAGR,YAAA;gBACE,OAAO,6CAA6C,CAAC,CAAC,IAAI,CAAC,CAAC,MAAM,KAAI;oBACpE,eAAe,CAAC,MAAM,MAAM,CAAC,OAAO,CAAC,CAAC;AACxC,iBAAC,CAAC,CAAC;SACN;AACH,KAAC,EAAE,CAAC,gBAAgB,CAAC,CAAC,CAAC;AAEvB,IAAA,IAAI,CAAC,YAAY;AAAE,QAAA,OAAO,IAAI,CAAC;AAE/B,IAAA,OAAOA,IAAC,YAAY,EAAA,EAAC,UAAU,EAAE,UAAU,GAAI,CAAC;AAClD;;;;"}