@contentful/experiences-sdk-react 0.0.1-alpha.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/LICENSE +21 -0
- package/README.md +115 -0
- package/dist/VisualEditorInjectScript-DPer6DO3.js +38 -0
- package/dist/VisualEditorInjectScript-DPer6DO3.js.map +1 -0
- package/dist/VisualEditorLoader-CY2fhqS5.js +28 -0
- package/dist/VisualEditorLoader-CY2fhqS5.js.map +1 -0
- package/dist/index.d.ts +122 -0
- package/dist/index.js +859 -0
- package/dist/index.js.map +1 -0
- package/dist/src/ExperienceRoot.d.ts +14 -0
- package/dist/src/blocks/editor/VisualEditorInjectScript.d.ts +4 -0
- package/dist/src/blocks/editor/VisualEditorLoader.d.ts +7 -0
- package/dist/src/blocks/editor/VisualEditorRoot.d.ts +9 -0
- package/dist/src/blocks/preview/CompositionBlock.d.ts +10 -0
- package/dist/src/blocks/preview/CompositionBlock.spec.d.ts +1 -0
- package/dist/src/blocks/preview/DeprecatedPreviewDeliveryRoot.d.ts +12 -0
- package/dist/src/blocks/preview/PreviewDeliveryRoot.d.ts +8 -0
- package/dist/src/blocks/preview/PreviewDeliveryRoot.test.d.ts +1 -0
- package/dist/src/components/Assembly.d.ts +3 -0
- package/dist/src/components/ErrorBoundary.d.ts +25 -0
- package/dist/src/components/Flex.d.ts +64 -0
- package/dist/src/constants.d.ts +3 -0
- package/dist/src/core/componentRegistry.d.ts +23 -0
- package/dist/src/core/componentRegistry.test.d.ts +1 -0
- package/dist/src/core/index.d.ts +1 -0
- package/dist/src/core/preview/assemblyUtils.d.ts +10 -0
- package/dist/src/core/preview/assemblyUtils.spec.d.ts +1 -0
- package/dist/src/hooks/index.d.ts +5 -0
- package/dist/src/hooks/useBreakpoints.d.ts +4 -0
- package/dist/src/hooks/useBreakpoints.spec.d.ts +1 -0
- package/dist/src/hooks/useDetectEditorMode.d.ts +7 -0
- package/dist/src/hooks/useExperienceBuilder.d.ts +41 -0
- package/dist/src/hooks/useExperienceBuilder.test.d.ts +1 -0
- package/dist/src/hooks/useFetchByBase.d.ts +8 -0
- package/dist/src/hooks/useFetchById.d.ts +16 -0
- package/dist/src/hooks/useFetchById.spec.d.ts +1 -0
- package/dist/src/hooks/useFetchBySlug.d.ts +16 -0
- package/dist/src/hooks/useFetchBySlug.spec.d.ts +1 -0
- package/dist/src/hooks/useFetchExperience.d.ts +27 -0
- package/dist/src/hooks/useFetchExperience.test.d.ts +1 -0
- package/dist/src/hooks/useInitializeVisualEditor.d.ts +7 -0
- package/dist/src/hooks/usePrevious.d.ts +6 -0
- package/dist/src/hooks/useStyleTag.d.ts +16 -0
- package/dist/src/index.d.ts +19 -0
- package/dist/src/sdkVersion.d.ts +1 -0
- package/dist/src/utils/withComponentWrapper.d.ts +36 -0
- package/dist/src/utils/withComponentWrapper.spec.d.ts +1 -0
- package/dist/test/__fixtures__/assembly.d.ts +96 -0
- package/dist/test/__fixtures__/composition.d.ts +7 -0
- package/dist/test/__fixtures__/entities.d.ts +9 -0
- package/dist/test/components/Test.d.ts +1 -0
- package/dist/test/components/Test.spec.d.ts +1 -0
- package/dist/vite.config.d.ts +2 -0
- package/package.json +92 -0
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export { ExperienceRoot } from './ExperienceRoot';
|
|
2
|
+
export { useExperienceBuilder, useFetchExperience, useFetchById, useFetchBySlug } from './hooks';
|
|
3
|
+
export { defineComponents } from './core/componentRegistry';
|
|
4
|
+
export { calculateNodeDefaultHeight,
|
|
5
|
+
/** @deprecated use `checkIsAssemblyNode` instead. Will be removed with SDK v5. */
|
|
6
|
+
checkIsAssembly, checkIsAssemblyNode, checkIsAssemblyEntry, defineDesignTokens, supportedModes, VisualEditorMode, fetchById, fetchBySlug, createExperience, } from '@contentful/experiences-core';
|
|
7
|
+
export {
|
|
8
|
+
/** @deprecated use `CONTENTFUL_COMPONENTS.section.id` instead. This will be removed in version 4. */
|
|
9
|
+
CONTENTFUL_SECTION_ID,
|
|
10
|
+
/** @deprecated use `CONTENTFUL_COMPONENTS.container.id` instead. This will be removed in version 4. */
|
|
11
|
+
CONTENTFUL_CONTAINER_ID, CONTENTFUL_COMPONENTS, OUTGOING_EVENTS, INCOMING_EVENTS, CONTENTFUL_COMPONENT_CATEGORY, LATEST_SCHEMA_VERSION, CF_STYLE_ATTRIBUTES,
|
|
12
|
+
/** @deprecated use `ASSEMBLY_BLOCK_NODE_TYPE` instead. This will be removed in version 5. */
|
|
13
|
+
DESIGN_COMPONENT_BLOCK_NODE_TYPE,
|
|
14
|
+
/** @deprecated use `ASSEMBLY_NODE_TYPE` instead. This will be removed in version 5. */
|
|
15
|
+
DESIGN_COMPONENT_NODE_TYPE,
|
|
16
|
+
/** @deprecated use `ASSEMBLY_NODE_TYPES` instead. This will be removed in version 5. */
|
|
17
|
+
DESIGN_COMPONENT_NODE_TYPES, ASSEMBLY_BLOCK_NODE_TYPE, ASSEMBLY_NODE_TYPE, ASSEMBLY_NODE_TYPES, SCROLL_STATES, } from '@contentful/experiences-core/constants';
|
|
18
|
+
export type { InternalSDKMode, ExternalSDKMode, ComponentDefinition, } from '@contentful/experiences-core/types';
|
|
19
|
+
export { EntityStore } from '@contentful/experiences-core';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const SDK_VERSION = "0.0.1-alpha.1";
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { ComponentRegistration } from '@contentful/experiences-core/types';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
interface CFProps {
|
|
4
|
+
/**
|
|
5
|
+
* Classes to be applied to the container component if `wrapComponent` is true, or directly to the child component if false.
|
|
6
|
+
*/
|
|
7
|
+
className?: string;
|
|
8
|
+
/**
|
|
9
|
+
* Classes to be applied to the child component if `wrapComponent` is true, or directly to the child component if false.
|
|
10
|
+
*/
|
|
11
|
+
classes?: string;
|
|
12
|
+
onMouseDown?: React.MouseEventHandler;
|
|
13
|
+
onMouseUp?: React.MouseEventHandler;
|
|
14
|
+
onClick?: React.MouseEventHandler;
|
|
15
|
+
/**
|
|
16
|
+
* Prop required by Experience Builder to identify the component.
|
|
17
|
+
*/
|
|
18
|
+
'data-cf-node-id'?: string;
|
|
19
|
+
/**
|
|
20
|
+
* Prop required by Experience Builder to identify the component.
|
|
21
|
+
*/
|
|
22
|
+
'data-cf-node-block-id'?: string;
|
|
23
|
+
/**
|
|
24
|
+
* Prop required by Experience Builder to identify the component's type.
|
|
25
|
+
*/
|
|
26
|
+
'data-cf-node-block-type'?: string;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* 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.
|
|
30
|
+
* @param Component Component to be used by Experience Builder.
|
|
31
|
+
* @param options Options for the `withComponentWrapper` function.
|
|
32
|
+
* @default { wrapComponent: true, wrapContainerTag: 'div' }
|
|
33
|
+
* @returns A component that can be passed to `defineComponents`.
|
|
34
|
+
*/
|
|
35
|
+
export declare function withComponentWrapper<T extends object>(Component: React.ElementType<T>, options?: ComponentRegistration['options']): ({ classes, className, "data-cf-node-id": dataCfNodeId, "data-cf-node-block-id": dataCfNodeBlockId, "data-cf-node-block-type": dataCfNodeBlockType, onClick, onMouseDown, onMouseUp, ...props }: CFProps & T) => import("react/jsx-runtime").JSX.Element;
|
|
36
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import type { CompositionComponentNode, 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" | "2023-08-23" | "2023-07-26" | "2023-06-27";
|
|
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) => CompositionComponentNode;
|
|
96
|
+
export {};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { ExperienceEntry, SchemaVersions } from '@contentful/experiences-core/types';
|
|
2
|
+
export declare const compositionEntry: ExperienceEntry;
|
|
3
|
+
type createCompositionEntryArgs = {
|
|
4
|
+
schemaVersion: SchemaVersions;
|
|
5
|
+
};
|
|
6
|
+
export declare const createCompositionEntry: ({ schemaVersion, }: createCompositionEntryArgs) => 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 {};
|
package/package.json
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@contentful/experiences-sdk-react",
|
|
3
|
+
"version": "0.0.1-alpha.2",
|
|
4
|
+
"main": "./dist/index.js",
|
|
5
|
+
"module": "./dist/index.js",
|
|
6
|
+
"typings": "./dist/src/index.d.ts",
|
|
7
|
+
"type": "module",
|
|
8
|
+
"author": "Contentful GmbH",
|
|
9
|
+
"license": "MIT",
|
|
10
|
+
"publishConfig": {
|
|
11
|
+
"registry": "https://npm.pkg.github.com/"
|
|
12
|
+
},
|
|
13
|
+
"scripts": {
|
|
14
|
+
"clean": "rimraf dist",
|
|
15
|
+
"predev": "npm run clean",
|
|
16
|
+
"dev": "rollup -c ./rollup.config.mjs --watch --environment DEV",
|
|
17
|
+
"prepare": "node ./bin/injectSDKVersion.cjs",
|
|
18
|
+
"prebuild": "npm run clean && node ./bin/injectSDKVersion.cjs",
|
|
19
|
+
"build": "rollup -c rollup.config.mjs",
|
|
20
|
+
"watch": "vite build --watch",
|
|
21
|
+
"test": "NODE_ENV=test jest",
|
|
22
|
+
"test:watch": "NODE_ENV=test jest --watch",
|
|
23
|
+
"test:coverage": "NODE_ENV=test jest --coverage --maxWorkers 2",
|
|
24
|
+
"tsc": "tsc --noEmit",
|
|
25
|
+
"lint": "eslint ./src --ext '.ts,.tsx,.js,.jsx'",
|
|
26
|
+
"presemantic-release": "npm run build",
|
|
27
|
+
"semantic-release": "semantic-release",
|
|
28
|
+
"prettier:check": "prettier --check '**/*.{jsx,js,ts,tsx,css}'",
|
|
29
|
+
"prettier": "prettier --write '**/*.{jsx,js,ts,tsx,css}'",
|
|
30
|
+
"preview": "vite preview",
|
|
31
|
+
"depcruise": "depcruise src"
|
|
32
|
+
},
|
|
33
|
+
"dependencies": {
|
|
34
|
+
"@contentful/experiences-components-react": "0.0.1-alpha.2",
|
|
35
|
+
"@contentful/experiences-core": "0.0.1-alpha.2",
|
|
36
|
+
"@contentful/experiences-visual-editor-react": "0.0.1-alpha.2",
|
|
37
|
+
"@contentful/rich-text-types": "^16.2.1",
|
|
38
|
+
"classnames": "^2.3.2",
|
|
39
|
+
"csstype": "^3.1.2",
|
|
40
|
+
"immer": "^10.0.3",
|
|
41
|
+
"lodash-es": "^4.17.21",
|
|
42
|
+
"md5": "^2.3.0",
|
|
43
|
+
"style-inject": "^0.3.0",
|
|
44
|
+
"vite-plugin-css-injected-by-js": "^3.1.1"
|
|
45
|
+
},
|
|
46
|
+
"devDependencies": {
|
|
47
|
+
"@rollup/plugin-commonjs": "^25.0.7",
|
|
48
|
+
"@rollup/plugin-node-resolve": "^15.2.3",
|
|
49
|
+
"@rollup/plugin-terser": "^0.4.4",
|
|
50
|
+
"@rollup/plugin-typescript": "^11.1.5",
|
|
51
|
+
"@semantic-release/changelog": "^6.0.3",
|
|
52
|
+
"@testing-library/jest-dom": "^6.1.4",
|
|
53
|
+
"@testing-library/react": "^14.0.0",
|
|
54
|
+
"@testing-library/user-event": "^14.4.3",
|
|
55
|
+
"@types/jest": "^29.5.6",
|
|
56
|
+
"@types/lodash-es": "^4.17.12",
|
|
57
|
+
"@types/node": "^20.11.10",
|
|
58
|
+
"@types/react": "^18.0.28",
|
|
59
|
+
"@types/react-dom": "^18.0.11",
|
|
60
|
+
"@vitejs/plugin-react": "^4.2.1",
|
|
61
|
+
"@vitejs/plugin-react-swc": "^3.0.0",
|
|
62
|
+
"contentful": "^10.6.14",
|
|
63
|
+
"husky": "^9.0.10",
|
|
64
|
+
"jest": "^29.5.0",
|
|
65
|
+
"jest-environment-jsdom": "^29.5.0",
|
|
66
|
+
"jsdom": "^24.0.0",
|
|
67
|
+
"postcss-import": "^15.1.0",
|
|
68
|
+
"react": "^18.2.0",
|
|
69
|
+
"react-dom": "^18.2.0",
|
|
70
|
+
"relative-deps": "^1.0.7",
|
|
71
|
+
"rollup-plugin-dts": "^6.1.0",
|
|
72
|
+
"rollup-plugin-node-externals": "^7.0.1",
|
|
73
|
+
"rollup-plugin-peer-deps-external": "^2.2.4",
|
|
74
|
+
"rollup-plugin-postcss": "^4.0.2",
|
|
75
|
+
"semantic-release": "23.0.2",
|
|
76
|
+
"ts-jest": "^29.1.0",
|
|
77
|
+
"typescript": "^5.2.2",
|
|
78
|
+
"vite": "^4.3.9",
|
|
79
|
+
"vite-plugin-dts": "^3.6.1",
|
|
80
|
+
"vite-plugin-svgr": "^4.1.0"
|
|
81
|
+
},
|
|
82
|
+
"peerDependencies": {
|
|
83
|
+
"contentful": ">=10.6.0",
|
|
84
|
+
"react": ">=16.0.0",
|
|
85
|
+
"react-dom": ">=16.0.0"
|
|
86
|
+
},
|
|
87
|
+
"files": [
|
|
88
|
+
"dist",
|
|
89
|
+
"package.json"
|
|
90
|
+
],
|
|
91
|
+
"gitHead": "ed1b56b4398d7aaff1b0ea40c14514fb3a2e3d09"
|
|
92
|
+
}
|