@contentful/experiences-sdk-react 1.9.0-dev-20240628T2235-7a4f71f.0 → 1.9.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 (89) hide show
  1. package/dist/ExperienceRoot.js +25 -0
  2. package/dist/ExperienceRoot.js.map +1 -0
  3. package/dist/blocks/editor/VisualEditorInjectScript.js +38 -0
  4. package/dist/blocks/editor/VisualEditorInjectScript.js.map +1 -0
  5. package/dist/blocks/editor/VisualEditorLoader.js +28 -0
  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 +292 -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 +67 -0
  40. package/dist/index.js +16 -0
  41. package/dist/index.js.map +1 -0
  42. package/dist/sdkVersion.js +4 -0
  43. package/dist/sdkVersion.js.map +1 -0
  44. package/dist/src/ExperienceRoot.d.ts +10 -0
  45. package/dist/src/blocks/editor/VisualEditorInjectScript.d.ts +4 -0
  46. package/dist/src/blocks/editor/VisualEditorLoader.d.ts +9 -0
  47. package/dist/src/blocks/editor/VisualEditorRoot.d.ts +10 -0
  48. package/dist/src/blocks/preview/CompositionBlock.d.ts +11 -0
  49. package/dist/src/blocks/preview/CompositionBlock.spec.d.ts +1 -0
  50. package/dist/src/blocks/preview/PreviewDeliveryRoot.d.ts +8 -0
  51. package/dist/src/blocks/preview/PreviewDeliveryRoot.test.d.ts +1 -0
  52. package/dist/src/components/Assembly.d.ts +3 -0
  53. package/dist/src/components/ErrorBoundary.d.ts +19 -0
  54. package/dist/src/components/Flex.d.ts +64 -0
  55. package/dist/src/constants.d.ts +3 -0
  56. package/dist/src/core/componentRegistry.d.ts +32 -0
  57. package/dist/src/core/componentRegistry.test.d.ts +1 -0
  58. package/dist/src/core/index.d.ts +1 -0
  59. package/dist/src/core/preview/assemblyUtils.d.ts +10 -0
  60. package/dist/src/core/preview/assemblyUtils.spec.d.ts +1 -0
  61. package/dist/src/core/sdkFeatures.d.ts +1 -0
  62. package/dist/src/hooks/index.d.ts +3 -0
  63. package/dist/src/hooks/useBreakpoints.d.ts +4 -0
  64. package/dist/src/hooks/useBreakpoints.spec.d.ts +1 -0
  65. package/dist/src/hooks/useClassName.d.ts +13 -0
  66. package/dist/src/hooks/useClassName.spec.d.ts +1 -0
  67. package/dist/src/hooks/useDetectEditorMode.d.ts +7 -0
  68. package/dist/src/hooks/useFetchByBase.d.ts +8 -0
  69. package/dist/src/hooks/useFetchById.d.ts +17 -0
  70. package/dist/src/hooks/useFetchById.spec.d.ts +1 -0
  71. package/dist/src/hooks/useFetchBySlug.d.ts +18 -0
  72. package/dist/src/hooks/useFetchBySlug.spec.d.ts +1 -0
  73. package/dist/src/hooks/useInitializeVisualEditor.d.ts +7 -0
  74. package/dist/src/hooks/usePrevious.d.ts +6 -0
  75. package/dist/src/index.d.ts +7 -0
  76. package/dist/src/sdkVersion.d.ts +1 -0
  77. package/dist/src/utils/withComponentWrapper.d.ts +22 -0
  78. package/dist/src/utils/withComponentWrapper.spec.d.ts +1 -0
  79. package/dist/styles/ErrorBoundary.css.js +7 -0
  80. package/dist/styles/ErrorBoundary.css.js.map +1 -0
  81. package/dist/test/__fixtures__/assembly.d.ts +96 -0
  82. package/dist/test/__fixtures__/composition.d.ts +7 -0
  83. package/dist/test/__fixtures__/entities.d.ts +9 -0
  84. package/dist/test/components/Test.d.ts +1 -0
  85. package/dist/test/components/Test.spec.d.ts +1 -0
  86. package/dist/utils/withComponentWrapper.js +32 -0
  87. package/dist/utils/withComponentWrapper.js.map +1 -0
  88. package/dist/vite.config.d.ts +2 -0
  89. package/package.json +6 -6
@@ -0,0 +1,96 @@
1
+ import type { ExperienceTreeNode, SchemaVersions } from '@contentful/experiences-core/types';
2
+ type createAssemblyEntryArgs = {
3
+ schemaVersion: SchemaVersions;
4
+ id: string;
5
+ };
6
+ export declare const defaultAssemblyId = "assembly-id";
7
+ export declare const assemblyGeneratedVariableName = "text_uuid1Assembly";
8
+ export declare const createAssemblyEntry: ({ schemaVersion, id, }: createAssemblyEntryArgs) => {
9
+ sys: {
10
+ id: string;
11
+ type: string;
12
+ contentType: {
13
+ sys: {
14
+ id: string;
15
+ type: string;
16
+ linkType: string;
17
+ };
18
+ };
19
+ createdAt: string;
20
+ updatedAt: string;
21
+ revision: number;
22
+ space: {
23
+ sys: {
24
+ type: string;
25
+ linkType: string;
26
+ id: string;
27
+ };
28
+ };
29
+ environment: {
30
+ sys: {
31
+ type: string;
32
+ linkType: string;
33
+ id: string;
34
+ };
35
+ };
36
+ };
37
+ metadata: {
38
+ tags: never[];
39
+ };
40
+ fields: {
41
+ title: string;
42
+ slug: string;
43
+ componentTree: {
44
+ children: {
45
+ definitionId: string;
46
+ variables: {};
47
+ children: {
48
+ definitionId: string;
49
+ variables: {
50
+ text: {
51
+ key: string;
52
+ type: string;
53
+ };
54
+ };
55
+ children: never[];
56
+ }[];
57
+ }[];
58
+ breakpoints: {
59
+ id: string;
60
+ query: string;
61
+ previewSize: string;
62
+ displayName: string;
63
+ }[];
64
+ schemaVersion: "2023-09-28";
65
+ };
66
+ dataSource: {};
67
+ unboundValues: {
68
+ unbound_uuid1Assembly: {
69
+ value: string;
70
+ };
71
+ };
72
+ componentSettings: {
73
+ variableDefinitions: {
74
+ text_uuid1Assembly: {
75
+ displayName: string;
76
+ name: string;
77
+ type: string;
78
+ defaultValue: {
79
+ type: string;
80
+ key: string;
81
+ };
82
+ required: boolean;
83
+ };
84
+ };
85
+ };
86
+ };
87
+ };
88
+ type createAssemblyNodeArgs = {
89
+ id: string;
90
+ blockId?: string;
91
+ unboundValue?: string;
92
+ unboundValueKey?: string;
93
+ boundValueKey?: string;
94
+ };
95
+ export declare const createAssemblyNode: ({ id, blockId, unboundValue, unboundValueKey, boundValueKey, }: createAssemblyNodeArgs) => ExperienceTreeNode;
96
+ export {};
@@ -0,0 +1,7 @@
1
+ import type { ExperienceEntry, SchemaVersions } from '@contentful/experiences-core/types';
2
+ export declare const experienceEntry: ExperienceEntry;
3
+ type createExperienceEntryArgs = {
4
+ schemaVersion: SchemaVersions;
5
+ };
6
+ export declare const createExperienceEntry: ({ schemaVersion, }: createExperienceEntryArgs) => ExperienceEntry;
7
+ export {};
@@ -0,0 +1,9 @@
1
+ import { Asset, Entry } from 'contentful';
2
+ export declare const entityIds: {
3
+ ENTRY1: string;
4
+ ENTRY2: string;
5
+ ASSET1: string;
6
+ };
7
+ export declare const entries: Entry[];
8
+ export declare const assets: Asset[];
9
+ export declare const entities: Array<Entry | Asset>;
@@ -0,0 +1 @@
1
+ export declare const Test: () => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,32 @@
1
+ import { jsxs, jsx } from 'react/jsx-runtime';
2
+ import classNames from 'classnames';
3
+ import React from 'react';
4
+
5
+ /**
6
+ * 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.
7
+ * @param Component Component to be used by Experience Builder.
8
+ * @param options Options for the `withComponentWrapper` function.
9
+ * @default { wrapComponent: true, wrapContainerTag: 'div' }
10
+ * @returns A component that can be passed to `defineComponents`.
11
+ */
12
+ function withComponentWrapper(Component, options = {
13
+ wrapComponent: true,
14
+ wrapContainerTag: 'div',
15
+ wrapContainer: 'div',
16
+ }) {
17
+ const Wrapped = ({ classes = '', className = '', dragProps = {}, ...props }) => {
18
+ const { innerRef, className: dragClassName, ToolTipAndPlaceholder, ...restOfDragProps } = dragProps;
19
+ const component = options.wrapComponent ? (jsxs("div", { "data-component-wrapper": true, className: classNames(classes, className, dragClassName), ...restOfDragProps, ref: (refNode) => {
20
+ if (innerRef && refNode)
21
+ innerRef(refNode);
22
+ }, ...props, children: [ToolTipAndPlaceholder, jsx(Component, { className: classNames(classes), ...props })] })) : (React.createElement(Component, {
23
+ className: classNames(classes, className),
24
+ ...props,
25
+ }));
26
+ return component;
27
+ };
28
+ return Wrapped;
29
+ }
30
+
31
+ export { withComponentWrapper };
32
+ //# 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 classNames from 'classnames';\nimport React from 'react';\ninterface CFProps extends React.HtmlHTMLAttributes<HTMLElement> {\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 dragProps?: any;\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>(\n Component: React.ElementType,\n options: ComponentRegistration['options'] = {\n wrapComponent: true,\n wrapContainerTag: 'div',\n wrapContainer: 'div',\n },\n) {\n const Wrapped: React.FC<CFProps & T> = ({\n classes = '',\n className = '',\n dragProps = {},\n ...props\n }) => {\n const {\n innerRef,\n className: dragClassName,\n ToolTipAndPlaceholder,\n ...restOfDragProps\n } = dragProps;\n const component = options.wrapComponent ? (\n <div\n data-component-wrapper\n className={classNames(classes, className, dragClassName)}\n {...restOfDragProps}\n ref={(refNode: HTMLElement | null) => {\n if (innerRef && refNode) innerRef(refNode);\n }}\n {...props}>\n {ToolTipAndPlaceholder}\n <Component className={classNames(classes)} {...(props as T)} />\n </div>\n ) : (\n React.createElement(Component, {\n className: classNames(classes, className),\n ...(props as T),\n })\n );\n return component;\n };\n\n return Wrapped;\n}\n"],"names":["_jsxs","_jsx"],"mappings":";;;;AAeA;;;;;;AAMG;AACa,SAAA,oBAAoB,CAClC,SAA4B,EAC5B,OAA4C,GAAA;AAC1C,IAAA,aAAa,EAAE,IAAI;AACnB,IAAA,gBAAgB,EAAE,KAAK;AACvB,IAAA,aAAa,EAAE,KAAK;AACrB,CAAA,EAAA;IAED,MAAM,OAAO,GAA0B,CAAC,EACtC,OAAO,GAAG,EAAE,EACZ,SAAS,GAAG,EAAE,EACd,SAAS,GAAG,EAAE,EACd,GAAG,KAAK,EACT,KAAI;AACH,QAAA,MAAM,EACJ,QAAQ,EACR,SAAS,EAAE,aAAa,EACxB,qBAAqB,EACrB,GAAG,eAAe,EACnB,GAAG,SAAS,CAAC;AACd,QAAA,MAAM,SAAS,GAAG,OAAO,CAAC,aAAa,IACrCA,IAAA,CAAA,KAAA,EAAA,EAAA,wBAAA,EAAA,IAAA,EAEE,SAAS,EAAE,UAAU,CAAC,OAAO,EAAE,SAAS,EAAE,aAAa,CAAC,EACpD,GAAA,eAAe,EACnB,GAAG,EAAE,CAAC,OAA2B,KAAI;gBACnC,IAAI,QAAQ,IAAI,OAAO;oBAAE,QAAQ,CAAC,OAAO,CAAC,CAAC;AAC7C,aAAC,EACG,GAAA,KAAK,EACR,QAAA,EAAA,CAAA,qBAAqB,EACtBC,GAAA,CAAC,SAAS,EAAA,EAAC,SAAS,EAAE,UAAU,CAAC,OAAO,CAAC,EAAO,GAAA,KAAW,EAAI,CAAA,CAAA,EAAA,CAC3D,KAEN,KAAK,CAAC,aAAa,CAAC,SAAS,EAAE;AAC7B,YAAA,SAAS,EAAE,UAAU,CAAC,OAAO,EAAE,SAAS,CAAC;AACzC,YAAA,GAAI,KAAW;AAChB,SAAA,CAAC,CACH,CAAC;AACF,QAAA,OAAO,SAAS,CAAC;AACnB,KAAC,CAAC;AAEF,IAAA,OAAO,OAAO,CAAC;AACjB;;;;"}
@@ -0,0 +1,2 @@
1
+ declare const _default: import("vite").UserConfig;
2
+ export default _default;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contentful/experiences-sdk-react",
3
- "version": "1.9.0-dev-20240628T2235-7a4f71f.0",
3
+ "version": "1.9.0",
4
4
  "main": "./dist/index.js",
5
5
  "module": "./dist/index.js",
6
6
  "typings": "./dist/src/index.d.ts",
@@ -33,10 +33,10 @@
33
33
  "depcruise": "depcruise src"
34
34
  },
35
35
  "dependencies": {
36
- "@contentful/experiences-components-react": "1.9.0-dev-20240628T2235-7a4f71f.0",
37
- "@contentful/experiences-core": "1.9.0-dev-20240628T2235-7a4f71f.0",
38
- "@contentful/experiences-validators": "1.9.0-dev-20240628T2235-7a4f71f.0",
39
- "@contentful/experiences-visual-editor-react": "1.9.0-dev-20240628T2235-7a4f71f.0",
36
+ "@contentful/experiences-components-react": "1.9.0",
37
+ "@contentful/experiences-core": "1.9.0",
38
+ "@contentful/experiences-validators": "1.9.0",
39
+ "@contentful/experiences-visual-editor-react": "1.9.0",
40
40
  "@contentful/rich-text-types": "^16.2.1",
41
41
  "classnames": "^2.3.2",
42
42
  "csstype": "^3.1.2",
@@ -94,5 +94,5 @@
94
94
  "dist",
95
95
  "package.json"
96
96
  ],
97
- "gitHead": "2794272dc185d96f5c3a3c0ada65b2c872c744b8"
97
+ "gitHead": "28fbaa3b62e017af49094bcb16a9968c2fd01bc8"
98
98
  }