@sitecore-content-sdk/react 2.0.0-canary.8 → 2.0.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 (45) hide show
  1. package/LICENSE.txt +202 -202
  2. package/dist/cjs/components/DesignLibrary/DesignLibrary.js +2 -2
  3. package/dist/cjs/components/DesignLibrary/DesignLibraryErrorBoundary.js +6 -0
  4. package/dist/cjs/components/DesignLibrary/index.js +3 -3
  5. package/dist/cjs/components/ErrorBoundary.js +1 -0
  6. package/dist/cjs/components/Form.js +4 -2
  7. package/dist/cjs/components/Placeholder/PlaceholderMetadata.js +1 -0
  8. package/dist/cjs/index.js +6 -3
  9. package/dist/esm/components/DesignLibrary/DesignLibrary.js +2 -2
  10. package/dist/esm/components/DesignLibrary/DesignLibraryErrorBoundary.js +6 -0
  11. package/dist/esm/components/DesignLibrary/index.js +1 -1
  12. package/dist/esm/components/ErrorBoundary.js +1 -0
  13. package/dist/esm/components/Form.js +4 -2
  14. package/dist/esm/components/Placeholder/PlaceholderMetadata.js +1 -0
  15. package/dist/esm/index.js +3 -2
  16. package/package.json +7 -6
  17. package/types/components/DesignLibrary/DesignLibraryErrorBoundary.d.ts +13 -0
  18. package/types/components/DesignLibrary/DesignLibraryErrorBoundary.d.ts.map +1 -1
  19. package/types/components/DesignLibrary/index.d.ts +2 -1
  20. package/types/components/DesignLibrary/index.d.ts.map +1 -1
  21. package/types/components/DesignLibrary/models.d.ts +13 -55
  22. package/types/components/DesignLibrary/models.d.ts.map +1 -1
  23. package/types/components/ErrorBoundary.d.ts +1 -0
  24. package/types/components/ErrorBoundary.d.ts.map +1 -1
  25. package/types/components/Form.d.ts.map +1 -1
  26. package/types/components/Placeholder/PlaceholderMetadata.d.ts +1 -0
  27. package/types/components/Placeholder/PlaceholderMetadata.d.ts.map +1 -1
  28. package/types/index.d.ts +3 -2
  29. package/types/index.d.ts.map +1 -1
  30. package/dist/cjs/components/DesignLibrary/DesignLibraryApp.js +0 -31
  31. package/dist/cjs/components/DesignLibrary/DesignLibraryClientEvents.js +0 -139
  32. package/dist/cjs/components/DesignLibrary/DesignLibraryServer.js +0 -212
  33. package/dist/cjs/server-actions/update-server-component-action.js +0 -51
  34. package/dist/esm/components/DesignLibrary/DesignLibraryApp.js +0 -24
  35. package/dist/esm/components/DesignLibrary/DesignLibraryClientEvents.js +0 -100
  36. package/dist/esm/components/DesignLibrary/DesignLibraryServer.js +0 -169
  37. package/dist/esm/server-actions/update-server-component-action.js +0 -47
  38. package/types/components/DesignLibrary/DesignLibraryApp.d.ts +0 -14
  39. package/types/components/DesignLibrary/DesignLibraryApp.d.ts.map +0 -1
  40. package/types/components/DesignLibrary/DesignLibraryClientEvents.d.ts +0 -21
  41. package/types/components/DesignLibrary/DesignLibraryClientEvents.d.ts.map +0 -1
  42. package/types/components/DesignLibrary/DesignLibraryServer.d.ts +0 -38
  43. package/types/components/DesignLibrary/DesignLibraryServer.d.ts.map +0 -1
  44. package/types/server-actions/update-server-component-action.d.ts +0 -58
  45. package/types/server-actions/update-server-component-action.d.ts.map +0 -1
package/dist/esm/index.js CHANGED
@@ -5,7 +5,7 @@ export { DictionaryService } from '@sitecore-content-sdk/content/i18n';
5
5
  export { DefaultRetryStrategy, GraphQLRequestClient, ErrorPage, } from '@sitecore-content-sdk/content/client';
6
6
  export { mediaApi } from '@sitecore-content-sdk/content/media';
7
7
  export { Form } from './components/Form';
8
- export { Placeholder, AppPlaceholder, renderEmptyPlaceholder, } from './components/Placeholder';
8
+ export { Placeholder, AppPlaceholder, PlaceholderMetadata, renderEmptyPlaceholder, } from './components/Placeholder';
9
9
  export { Image, } from './components/Image';
10
10
  export { RichText } from './components/RichText';
11
11
  export { Text } from './components/Text';
@@ -13,10 +13,11 @@ export { DateField } from './components/Date';
13
13
  export { FEaaSComponent, fetchFEaaSComponentServerProps, BYOCComponent, fetchBYOCComponentServerProps,
14
14
  // leaving original names for backward compatibility
15
15
  BYOCWrapper, BYOCWrapper as BYOCClientWrapper, FEaaSWrapper, FEaaSWrapper as FEaaSClientWrapper, FEaaSServerWrapper, BYOCServerWrapper, } from './components/FEaaS';
16
- export { DesignLibrary, DesignLibraryApp } from './components/DesignLibrary';
16
+ export { DesignLibrary, DesignLibraryErrorBoundary, } from './components/DesignLibrary';
17
17
  export { Link } from './components/Link';
18
18
  export { File } from './components/File';
19
19
  export { SitecoreProvider, SitecoreProviderReactContext, useSitecore, } from './components/SitecoreProvider';
20
+ export { ErrorComponent } from './components/ErrorBoundary';
20
21
  export { withEditorChromes } from './enhancers/withEditorChromes';
21
22
  export { withSitecore } from './enhancers/withSitecore';
22
23
  export { withDatasourceCheck } from './enhancers/withDatasourceCheck';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sitecore-content-sdk/react",
3
- "version": "2.0.0-canary.8",
3
+ "version": "2.0.0",
4
4
  "main": "dist/cjs/index.js",
5
5
  "module": "dist/esm/index.js",
6
6
  "sideEffects": false,
@@ -70,20 +70,21 @@
70
70
  "typescript": "~5.8.3"
71
71
  },
72
72
  "peerDependencies": {
73
- "@sitecore-cloudsdk/events": "^0.5.1",
73
+ "@sitecore-content-sdk/analytics-core": "^2.0.0",
74
+ "@sitecore-content-sdk/events": "^2.0.0",
74
75
  "@sitecore-feaas/clientside": "^0.6.0",
75
76
  "react": "^19.2.1",
76
77
  "react-dom": "^19.2.1"
77
78
  },
78
79
  "dependencies": {
79
- "@sitecore-content-sdk/content": "2.0.0-canary.8",
80
- "@sitecore-content-sdk/core": "2.0.0-canary.8",
81
- "@sitecore-content-sdk/search": "0.2.0-canary.18",
80
+ "@sitecore-content-sdk/content": "^2.0.0",
81
+ "@sitecore-content-sdk/core": "^2.0.0",
82
+ "@sitecore-content-sdk/search": "^0.2.0",
82
83
  "fast-deep-equal": "^3.1.3"
83
84
  },
84
85
  "description": "",
85
86
  "types": "types/index.d.ts",
86
- "gitHead": "c8a8944d642f6c97020be92e09544b502d8c0ea9",
87
+ "gitHead": "492d7d718c965bbfe394d6c12c2e4870220cf4bf",
87
88
  "files": [
88
89
  "dist",
89
90
  "types",
@@ -1,9 +1,22 @@
1
1
  import React from 'react';
2
+ /**
3
+ * Props for the DesignLibraryErrorBoundary component.
4
+ * @property {string} uid - The unique identifier of the component being rendered.
5
+ * @property {React.ReactNode} children - The child components to render within the error boundary.
6
+ * @property {number} [renderKey] - An optional key to trigger re-rendering of the error boundary when changed.
7
+ * @internal
8
+ */
2
9
  type DesignLibraryErrorBoundaryProps = {
3
10
  uid: string;
4
11
  children: React.ReactNode;
5
12
  renderKey?: number;
6
13
  };
14
+ /**
15
+ * Error boundary for the Design Library component.
16
+ * Catches errors during rendering and sends them to the Design Library
17
+ * @param {DesignLibraryErrorBoundaryProps} props - The props for the error boundary, including the component UID and children to render.
18
+ * @internal
19
+ */
7
20
  export declare class DesignLibraryErrorBoundary extends React.Component<DesignLibraryErrorBoundaryProps> {
8
21
  state: {
9
22
  hasError: boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"DesignLibraryErrorBoundary.d.ts","sourceRoot":"","sources":["../../../src/components/DesignLibrary/DesignLibraryErrorBoundary.tsx"],"names":[],"mappings":"AACA,OAAO,KAAmB,MAAM,OAAO,CAAC;AAGxC,KAAK,+BAA+B,GAAG;IACrC,GAAG,EAAE,MAAM,CAAC;IACZ,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,qBAAa,0BAA2B,SAAQ,KAAK,CAAC,SAAS,CAAC,+BAA+B,CAAC;IAC9F,KAAK;;MAEH;IAEF,MAAM,CAAC,wBAAwB;;;IAI/B,kBAAkB,CAAC,SAAS,EAAE,+BAA+B;IAM7D,iBAAiB,CAAC,KAAK,EAAE,KAAK;IAI9B,MAAM;CAOP"}
1
+ {"version":3,"file":"DesignLibraryErrorBoundary.d.ts","sourceRoot":"","sources":["../../../src/components/DesignLibrary/DesignLibraryErrorBoundary.tsx"],"names":[],"mappings":"AACA,OAAO,KAAmB,MAAM,OAAO,CAAC;AAGxC;;;;;;GAMG;AACH,KAAK,+BAA+B,GAAG;IACrC,GAAG,EAAE,MAAM,CAAC;IACZ,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF;;;;;GAKG;AACH,qBAAa,0BAA2B,SAAQ,KAAK,CAAC,SAAS,CAAC,+BAA+B,CAAC;IAC9F,KAAK;;MAEH;IAEF,MAAM,CAAC,wBAAwB;;;IAI/B,kBAAkB,CAAC,SAAS,EAAE,+BAA+B;IAM7D,iBAAiB,CAAC,KAAK,EAAE,KAAK;IAI9B,MAAM;CAOP"}
@@ -1,3 +1,4 @@
1
1
  export { DesignLibrary } from './DesignLibrary';
2
- export { DesignLibraryApp } from './DesignLibraryApp';
2
+ export { DesignLibraryErrorBoundary } from './DesignLibraryErrorBoundary';
3
+ export { DynamicComponent, ImportMapImport } from './models';
3
4
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/DesignLibrary/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/DesignLibrary/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,0BAA0B,EAAE,MAAM,8BAA8B,CAAC;AAC1E,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC"}
@@ -1,62 +1,20 @@
1
- import { GeneratedComponentData, ImportEntry, ImportEntryInfo } from '@sitecore-content-sdk/content/codegen';
2
- import { ComponentFields, ComponentParams, ComponentRendering, RouteData } from '@sitecore-content-sdk/content/layout';
3
- import { DesignLibraryStatus } from '@sitecore-content-sdk/content/editing';
4
- import { Page } from '@sitecore-content-sdk/content/client';
5
- import { ComponentMap } from '../sharedTypes';
6
- export type ImportMapImport = {
7
- default: ImportEntry[];
8
- };
1
+ import { ComponentFields, ComponentParams } from '@sitecore-content-sdk/content/layout';
2
+ import { ImportEntry } from '@sitecore-content-sdk/content/codegen';
3
+ /**
4
+ * Model representing a dynamically generated component in the Design Library.
5
+ * This model includes the component's fields and parameters, which are used for rendering and interaction within the Design Library.
6
+ * @internal
7
+ */
9
8
  export type DynamicComponent = React.ComponentType<{
10
9
  [key: string]: unknown;
11
10
  fields?: ComponentFields;
12
11
  params?: ComponentParams;
13
12
  }>;
14
- export type DesignLibraryServerProps = {
15
- /**
16
- * Component Map will be used to map Sitecore component names to app implementation
17
- */
18
- componentMap: ComponentMap;
19
- /**
20
- * Rendering data to be used when rendering the placeholder.
21
- */
22
- rendering: ComponentRendering | RouteData;
23
- /**
24
- * Page data.
25
- */
26
- page: Page;
27
- /**
28
- * The dynamic import for sever import map to be used in variant generation mode.
29
- */
30
- loadServerImportMap: () => Promise<ImportMapImport>;
31
- };
32
- export type DesingLibraryAppProps = DesignLibraryServerProps;
33
- export type DesignLibraryServerPreviewProps = Omit<DesignLibraryServerProps, 'loadServerImportMap'>;
34
- export type DesignLibraryServerVariantGenerationProps = DesignLibraryServerProps;
35
- export type DesignLibraryPreviewEventsProps = {
36
- /**
37
- * The design library status to be posted as a message to the Design Studio.
38
- */
39
- designLibraryStatus: DesignLibraryStatus;
40
- /**
41
- * The component rendering data that is being edited in the Design Studio.
42
- */
43
- component: ComponentRendering;
44
- };
45
- export type DesignLibraryVariantGenerationEventsProps = DesignLibraryPreviewEventsProps & {
46
- /**
47
- * The import map info to be posted as a message to the Design Studio.
48
- */
49
- importMap?: ImportEntryInfo[];
50
- /**
51
- * Any error that occurred during initialization of the component:
52
- * - importMap error
53
- * - error fetching the generated component data from secured endpoint
54
- * - error during generation of the component on the server side
55
- */
56
- componentInitError?: string;
57
- /**
58
- * The generated component data received from design library.
59
- */
60
- generatedComponentData?: GeneratedComponentData;
13
+ /**
14
+ * Model representing the import map in the Design Library.
15
+ * @internal
16
+ */
17
+ export type ImportMapImport = {
18
+ default: ImportEntry[];
61
19
  };
62
20
  //# sourceMappingURL=models.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"models.d.ts","sourceRoot":"","sources":["../../../src/components/DesignLibrary/models.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,sBAAsB,EACtB,WAAW,EACX,eAAe,EAChB,MAAM,uCAAuC,CAAC;AAC/C,OAAO,EACL,eAAe,EACf,eAAe,EACf,kBAAkB,EAClB,SAAS,EACV,MAAM,sCAAsC,CAAC;AAC9C,OAAO,EAAE,mBAAmB,EAAE,MAAM,uCAAuC,CAAC;AAC5E,OAAO,EAAE,IAAI,EAAE,MAAM,sCAAsC,CAAC;AAC5D,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAE9C,MAAM,MAAM,eAAe,GAAG;IAC5B,OAAO,EAAE,WAAW,EAAE,CAAC;CACxB,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG,KAAK,CAAC,aAAa,CAAC;IACjD,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;IACvB,MAAM,CAAC,EAAE,eAAe,CAAC;IACzB,MAAM,CAAC,EAAE,eAAe,CAAC;CAC1B,CAAC,CAAC;AAEH,MAAM,MAAM,wBAAwB,GAAG;IACrC;;OAEG;IACH,YAAY,EAAE,YAAY,CAAC;IAC3B;;OAEG;IACH,SAAS,EAAE,kBAAkB,GAAG,SAAS,CAAC;IAC1C;;OAEG;IACH,IAAI,EAAE,IAAI,CAAC;IACX;;OAEG;IACH,mBAAmB,EAAE,MAAM,OAAO,CAAC,eAAe,CAAC,CAAC;CACrD,CAAC;AAEF,MAAM,MAAM,qBAAqB,GAAG,wBAAwB,CAAC;AAE7D,MAAM,MAAM,+BAA+B,GAAG,IAAI,CAAC,wBAAwB,EAAE,qBAAqB,CAAC,CAAC;AAEpG,MAAM,MAAM,yCAAyC,GAAG,wBAAwB,CAAC;AAEjF,MAAM,MAAM,+BAA+B,GAAG;IAC5C;;OAEG;IACH,mBAAmB,EAAE,mBAAmB,CAAC;IACzC;;OAEG;IACH,SAAS,EAAE,kBAAkB,CAAC;CAC/B,CAAC;AAEF,MAAM,MAAM,yCAAyC,GAAG,+BAA+B,GAAG;IACxF;;OAEG;IACH,SAAS,CAAC,EAAE,eAAe,EAAE,CAAC;IAC9B;;;;;OAKG;IACH,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B;;OAEG;IACH,sBAAsB,CAAC,EAAE,sBAAsB,CAAC;CACjD,CAAC"}
1
+ {"version":3,"file":"models.d.ts","sourceRoot":"","sources":["../../../src/components/DesignLibrary/models.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,sCAAsC,CAAC;AACxF,OAAO,EAAE,WAAW,EAAE,MAAM,uCAAuC,CAAC;AAEpE;;;;GAIG;AACH,MAAM,MAAM,gBAAgB,GAAG,KAAK,CAAC,aAAa,CAAC;IACjD,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;IACvB,MAAM,CAAC,EAAE,eAAe,CAAC;IACzB,MAAM,CAAC,EAAE,eAAe,CAAC;CAC1B,CAAC,CAAC;AAEH;;;GAGG;AACH,MAAM,MAAM,eAAe,GAAG;IAC5B,OAAO,EAAE,WAAW,EAAE,CAAC;CACxB,CAAC"}
@@ -16,6 +16,7 @@ export type ErrorBoundaryProps = {
16
16
  /**
17
17
  * Simple error component applying basic error styling.
18
18
  * @param {object} props - Either with `message` (string) or with `children` (ReactNode), but not both.
19
+ * @internal
19
20
  */
20
21
  export declare const ErrorComponent: (props: {
21
22
  message: React.ReactNode;
@@ -1 +1 @@
1
- {"version":3,"file":"ErrorBoundary.d.ts","sourceRoot":"","sources":["../../src/components/ErrorBoundary.tsx"],"names":[],"mapp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AAE,MAAM,CAAC;QAChB;;WAEG;QACH,mBAAmB,CAAC,EAAE,MAAM,CAAC;KAC9B,CAAC;CACH,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,IAAI,GAAI,uBAAuB,SAAS,sBA+DpD,CAAC"}
1
+ {"version":3,"file":"Form.d.ts","sourceRoot":"","sources":["../../src/components/Form.tsx"],"names":[],"mappings":"AACA,OAAO,KAAsC,MAAM,OAAO,CAAC;AAC3D,OAAO,EAAE,kBAAkB,EAAE,MAAM,sCAAsC,CAAC;AAU1E;;;GAGG;AACH,eAAO,MAAM,cAAc,GAAI,YAAY,GAAG,SAI7C,CAAC;AAEF;;;GAGG;AACH,MAAM,MAAM,SAAS,GAAG;IACtB,SAAS,EAAE,kBAAkB,CAAC;IAC9B,MAAM,EAAE;QACN;;WAEG;QACH,MAAM,EAAE,MAAM,CAAC;QACf;;WAEG;QACH,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB;;WAEG;QACH,mBAAmB,CAAC,EAAE,MAAM,CAAC;KAC9B,CAAC;CACH,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,IAAI,GAAI,uBAAuB,SAAS,sBA6DpD,CAAC"}
@@ -30,6 +30,7 @@ export type CodeBlockAttributes = {
30
30
  * @param {'server' | 'client'} [props.componentRuntime] Component runtime type. Used to add data-csdk-component-runtime attribute to rendering chromes.
31
31
  * @param {JSX.Element} props.children The child components or elements to be wrapped by the metadata code blocks.
32
32
  * @returns {JSX.Element} A React fragment containing open and close code blocks surrounding the children elements.
33
+ * @internal
33
34
  */
34
35
  export declare const PlaceholderMetadata: ({ rendering, placeholderName, children, componentRuntime, }: PlaceholderMetadataProps) => JSX.Element;
35
36
  //# sourceMappingURL=PlaceholderMetadata.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"PlaceholderMetadata.d.ts","sourceRoot":"","sources":["../../../src/components/Placeholder/PlaceholderMetadata.tsx"],"names":[],"mappings":"AAAA,OAAc,EAAE,SAAS,EAAE,GA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CAAC;IACb,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,6BAA6B,CAAC,EAAE,QAAQ,GAAG,QAAQ,CAAC;CACrD,CAAC;AAEF;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,mBAAmB,GAAI,6DAKjC,wBAAwB,KAAG,GAAG,CAAC,OAkEjC,CAAC"}
package/types/index.d.ts CHANGED
@@ -7,17 +7,18 @@ export { GraphQLClientError, RetryStrategy, DefaultRetryStrategy, GraphQLRequest
7
7
  export { mediaApi } from '@sitecore-content-sdk/content/media';
8
8
  export { Form } from './components/Form';
9
9
  export { ReactContentSdkComponent, ComponentMap, ReactModule } from './components/sharedTypes';
10
- export { Placeholder, PlaceholderProps, PlaceholderProps as PlaceholderComponentProps, AppPlaceholder, AppPlaceholderProps, renderEmptyPlaceholder, } from './components/Placeholder';
10
+ export { Placeholder, PlaceholderProps, PlaceholderProps as PlaceholderComponentProps, AppPlaceholder, PlaceholderMetadata, AppPlaceholderProps, renderEmptyPlaceholder, } from './components/Placeholder';
11
11
  export { Image, ImageProps, ImageField, ImageFieldValue, ImageSizeParameters, } from './components/Image';
12
12
  export { RichText, RichTextProps, RichTextField } from './components/RichText';
13
13
  export { Text, TextField } from './components/Text';
14
14
  export { DateField, DateFieldProps } from './components/Date';
15
15
  export { FEaaSComponent, FEaaSComponentProps, FEaaSComponentParams, fetchFEaaSComponentServerProps, BYOCComponent, BYOCComponentParams, BYOCComponentProps, fetchBYOCComponentServerProps, BYOCWrapper, BYOCWrapper as BYOCClientWrapper, FEaaSWrapper, FEaaSWrapper as FEaaSClientWrapper, FEaaSServerWrapper, BYOCServerWrapper, } from './components/FEaaS';
16
- export { DesignLibrary, DesignLibraryApp } from './components/DesignLibrary';
16
+ export { DesignLibrary, DesignLibraryErrorBoundary, DynamicComponent, ImportMapImport, } from './components/DesignLibrary';
17
17
  export {} from './components/FEaaS/BYOCComponent';
18
18
  export { Link, LinkField, LinkFieldValue, LinkProps } from './components/Link';
19
19
  export { File, FileField } from './components/File';
20
20
  export { SitecoreProvider, SitecoreProviderState, SitecoreProviderReactContext, useSitecore, } from './components/SitecoreProvider';
21
+ export { ErrorComponent } from './components/ErrorBoundary';
21
22
  export { withEditorChromes } from './enhancers/withEditorChromes';
22
23
  export { withSitecore } from './enhancers/withSitecore';
23
24
  export { withDatasourceCheck } from './enhancers/withDatasourceCheck';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EACT,WAAW,EACX,WAAW,EACX,WAAW,EACX,YAAY,EACZ,iBAAiB,EACjB,iBAAiB,EACjB,yBAAyB,EACzB,uBAAuB,GACxB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,YAAY,EAAE,MAAM,kCAAkC,CAAC;AAChE,OAAO,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,uCAAuC,CAAC;AAC3F,OAAO,EACL,wBAAwB,EACxB,+BAA+B,EAC/B,iBAAiB,EACjB,sBAAsB,EACtB,oBAAoB,EACpB,wBAAwB,EACxB,aAAa,EACb,SAAS,EACT,KAAK,EACL,IAAI,EACJ,mBAAmB,EACnB,aAAa,EACb,kBAAkB,EAClB,eAAe,EACf,eAAe,EACf,QAAQ,GACT,MAAM,sCAAsC,CAAC;AAC9C,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,oCAAoC,CAAC;AAC1F,OAAO,EACL,kBAAkB,EAClB,aAAa,EACb,oBAAoB,EACpB,iCAAiC,EACjC,oBAAoB,EACpB,QAAQ,EACR,SAAS,EACT,IAAI,GACL,MAAM,sCAAsC,CAAC;AAC9C,OAAO,EAAE,QAAQ,EAAE,MAAM,qCAAqC,CAAC;AAC/D,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AACzC,OAAO,EAAE,wBAAwB,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAC/F,OAAO,EACL,WAAW,EAC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A4B,CAAC;AAC5D,OAAO,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AAClE,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AACxD,OAAO,EAAE,mBAAmB,EAAE,MAAM,iCAAiC,CAAC;AACtE,OAAO,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AAClE,OAAO,EAAE,8BAA8B,EAAE,MAAM,4CAA4C,CAAC;AAC5F,OAAO,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AACpE,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAC9D,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAC7D,OAAO,EACL,qCAAqC,EACrC,sCAAsC,GACvC,MAAM,iDAAiD,CAAC;AACzD,OAAO,EAAE,0BAA0B,EAAE,MAAM,yCAAyC,CAAC;AACrF,OAAO,EAAE,eAAe,EAAE,qBAAqB,EAAE,MAAM,oCAAoC,CAAC"}
@@ -1,31 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.DesignLibraryApp = void 0;
7
- const react_1 = __importDefault(require("react"));
8
- const layout_1 = require("@sitecore-content-sdk/content/layout");
9
- const DesignLibraryServer_1 = require("./DesignLibraryServer");
10
- const DesignLibrary_1 = require("./DesignLibrary");
11
- /**
12
- * Design Library component intended to be used by the NextJs app router application
13
- * This component serves as a router between client and server component rendering modes for the Design Library.
14
- * It inspects the component type from the component map and
15
- * delegates to the appropriate rendering implementation:
16
- * - Client components are rendered using the `DesignLibrary` component
17
- * - Server components are rendered using the `DesignLibraryServer` component
18
- * @param {DesingLibraryAppProps} props - The properties for the Design Library App.
19
- * @public
20
- */
21
- const DesignLibraryApp = ({ page, componentMap, loadServerImportMap, }) => {
22
- var _a;
23
- const { route } = page.layout.sitecore;
24
- if (!route)
25
- return null;
26
- const rendering = (_a = route === null || route === void 0 ? void 0 : route.placeholders[layout_1.EDITING_COMPONENT_PLACEHOLDER]) === null || _a === void 0 ? void 0 : _a[0];
27
- const component = componentMap.get((rendering === null || rendering === void 0 ? void 0 : rendering.componentName) || '');
28
- const isClient = component && component.componentType === 'client';
29
- return (react_1.default.createElement(react_1.default.Fragment, null, isClient ? (react_1.default.createElement(DesignLibrary_1.DesignLibrary, null)) : (react_1.default.createElement(DesignLibraryServer_1.DesignLibraryServer, { page: page, componentMap: componentMap, loadServerImportMap: loadServerImportMap, rendering: route }))));
30
- };
31
- exports.DesignLibraryApp = DesignLibraryApp;
@@ -1,139 +0,0 @@
1
- "use strict";
2
- 'use client';
3
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
4
- if (k2 === undefined) k2 = k;
5
- var desc = Object.getOwnPropertyDescriptor(m, k);
6
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
7
- desc = { enumerable: true, get: function() { return m[k]; } };
8
- }
9
- Object.defineProperty(o, k2, desc);
10
- }) : (function(o, m, k, k2) {
11
- if (k2 === undefined) k2 = k;
12
- o[k2] = m[k];
13
- }));
14
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
15
- Object.defineProperty(o, "default", { enumerable: true, value: v });
16
- }) : function(o, v) {
17
- o["default"] = v;
18
- });
19
- var __importStar = (this && this.__importStar) || (function () {
20
- var ownKeys = function(o) {
21
- ownKeys = Object.getOwnPropertyNames || function (o) {
22
- var ar = [];
23
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
24
- return ar;
25
- };
26
- return ownKeys(o);
27
- };
28
- return function (mod) {
29
- if (mod && mod.__esModule) return mod;
30
- var result = {};
31
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
32
- __setModuleDefault(result, mod);
33
- return result;
34
- };
35
- })();
36
- Object.defineProperty(exports, "__esModule", { value: true });
37
- exports.DesignLibraryVariantGenerationEvents = exports.DesignLibraryPreviewEvents = exports.__mockDependencies = void 0;
38
- const react_1 = __importStar(require("react"));
39
- const dlHelpers = __importStar(require("@sitecore-content-sdk/content/editing"));
40
- const codegen = __importStar(require("@sitecore-content-sdk/content/codegen"));
41
- const update_server_component_action_1 = require("../../server-actions/update-server-component-action");
42
- const SitecoreProvider_1 = require("../SitecoreProvider");
43
- let { getDesignLibraryComponentPropsEvent, addServerComponentPreviewHandler, getDesignLibraryImportMapEvent, addStyleElement, sendErrorEvent, } = codegen;
44
- let { getDesignLibraryStatusEvent, addComponentUpdateHandler, postToDesignLibrary } = dlHelpers;
45
- let _updateComponentAction = update_server_component_action_1.updateComponentAction;
46
- let _previewComponentAction = update_server_component_action_1.previewComponentAction;
47
- const __mockDependencies = (mocks) => {
48
- postToDesignLibrary = mocks.postToDesignLibrary;
49
- addComponentUpdateHandler = mocks.addComponentUpdateHandler;
50
- _updateComponentAction = mocks.updateComponentAction;
51
- _previewComponentAction = mocks.previewComponentAction;
52
- addServerComponentPreviewHandler = mocks.addServerComponentPreviewHandler;
53
- getDesignLibraryImportMapEvent = mocks.getDesignLibraryImportMapEvent;
54
- getDesignLibraryComponentPropsEvent = mocks.getDesignLibraryComponentPropsEvent;
55
- addStyleElement = mocks.addStyleElement;
56
- sendErrorEvent = mocks.sendErrorEvent;
57
- };
58
- exports.__mockDependencies = __mockDependencies;
59
- /**
60
- * Design Library component for rendering server components in app router application.
61
- * DesignLibraryPreviewEvents component serves as a communication bridge between DesignLibraryServer and the Design Studio on the client side.
62
- * It posts messages to Design Library Studio and sets up handlers to receive updates and previews which are then passed to the server component via server function updateServerComponentAction.
63
- * @param {DesignLibraryPreviewEventsProps} props The props. {@link DesignLibraryPreviewEventsProps}
64
- * @returns {JSX.Element} empty JSX element.
65
- */
66
- const DesignLibraryPreviewEvents = ({ designLibraryStatus, component, }) => {
67
- (0, react_1.useEffect)(() => {
68
- if (!(component === null || component === void 0 ? void 0 : component.uid))
69
- return;
70
- postToDesignLibrary(getDesignLibraryStatusEvent(designLibraryStatus, component.uid, true));
71
- const unsubUpdate = addComponentUpdateHandler(component, (rendering) => {
72
- _updateComponentAction({ uid: rendering.uid, rendering });
73
- });
74
- return () => {
75
- unsubUpdate && unsubUpdate();
76
- };
77
- }, [component, designLibraryStatus]);
78
- return react_1.default.createElement(react_1.default.Fragment, null);
79
- };
80
- exports.DesignLibraryPreviewEvents = DesignLibraryPreviewEvents;
81
- /**
82
- * Design Library component for rendering server components in app router application.
83
- * DesignLibraryVariantGenerationEvents component serves as a communication bridge between DesignLibraryServer and the Design Studio on the client side in variant generation mode.
84
- * It posts messages to Design Library Studio and sets up handlers to receive updates and previews which are then passed to the server component via server function updateServerComponentAction.
85
- * If the import map is not present then the import map error will be sent to Design Studio.
86
- * @param {DesignLibraryVariantGenerationEventsProps} props The props. {@link DesignLibraryVariantGenerationEventsProps}
87
- * @returns {JSX.Element} empty JSX element.
88
- */
89
- const DesignLibraryVariantGenerationEvents = ({ designLibraryStatus, component, importMap, componentInitError, generatedComponentData, }) => {
90
- var _a;
91
- const { api } = (0, SitecoreProvider_1.useSitecore)();
92
- const edgeUrl = (_a = api === null || api === void 0 ? void 0 : api.edge) === null || _a === void 0 ? void 0 : _a.edgeUrl;
93
- (0, react_1.useEffect)(() => {
94
- var _a;
95
- if (!(component === null || component === void 0 ? void 0 : component.uid))
96
- return;
97
- postToDesignLibrary(getDesignLibraryStatusEvent(designLibraryStatus, component.uid, true));
98
- const unsubUpdate = addComponentUpdateHandler(component, (rendering) => {
99
- _updateComponentAction({
100
- uid: rendering.uid,
101
- rendering,
102
- generatedComponentData,
103
- });
104
- });
105
- const unsubPreview = addServerComponentPreviewHandler((eventArgs) => {
106
- _previewComponentAction({
107
- uid: component.uid,
108
- args: eventArgs,
109
- }, edgeUrl);
110
- });
111
- if (componentInitError) {
112
- // an error occurred during initialization of the component on the server side
113
- sendErrorEvent(component.uid, componentInitError, codegen.DesignLibraryPreviewError.RenderInit);
114
- }
115
- else {
116
- const importMapEvent = getDesignLibraryImportMapEvent(component.uid, importMap);
117
- postToDesignLibrary(importMapEvent);
118
- const propsEvent = getDesignLibraryComponentPropsEvent(component.uid, component.fields, component.params);
119
- postToDesignLibrary(propsEvent);
120
- if ((_a = generatedComponentData === null || generatedComponentData === void 0 ? void 0 : generatedComponentData.styles) === null || _a === void 0 ? void 0 : _a.content) {
121
- // the generated component has custom styles, so add the css in style element and add it to document head
122
- addStyleElement(generatedComponentData.styles.content);
123
- }
124
- }
125
- return () => {
126
- unsubUpdate && unsubUpdate();
127
- unsubPreview && unsubPreview();
128
- };
129
- }, [
130
- component,
131
- designLibraryStatus,
132
- importMap,
133
- componentInitError,
134
- generatedComponentData,
135
- edgeUrl,
136
- ]);
137
- return react_1.default.createElement(react_1.default.Fragment, null);
138
- };
139
- exports.DesignLibraryVariantGenerationEvents = DesignLibraryVariantGenerationEvents;