@sitecore-content-sdk/react 1.2.0-canary.9 → 1.2.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 (104) hide show
  1. package/LICENSE.txt +202 -202
  2. package/README.md +11 -11
  3. package/dist/cjs/components/ClientEditingChromesUpdate.js +52 -0
  4. package/dist/cjs/components/DefaultEmptyFieldEditingComponents.js +4 -4
  5. package/dist/cjs/components/DesignLibrary.js +85 -103
  6. package/dist/cjs/components/EditingScripts.js +1 -0
  7. package/dist/cjs/components/ErrorBoundary.js +1 -0
  8. package/dist/cjs/components/FEaaS/BYOCServerWrapper.js +28 -0
  9. package/dist/cjs/components/{BYOCComponent.js → FEaaS/BYOCWrapper.js} +17 -28
  10. package/dist/cjs/components/FEaaS/FEaaSSeverWrapper.js +34 -0
  11. package/dist/cjs/components/FEaaS/FEaaSWrapper.js +78 -0
  12. package/dist/cjs/components/{FEaaSComponent.js → FEaaS/feaas-utils.js} +18 -35
  13. package/dist/cjs/components/FEaaS/index.js +21 -0
  14. package/dist/cjs/components/FEaaS/models.js +7 -0
  15. package/dist/cjs/components/Link.js +1 -1
  16. package/dist/cjs/components/Placeholder/AppPlaceholder.js +76 -0
  17. package/dist/cjs/components/Placeholder/ClientComponentWrapper.js +21 -0
  18. package/dist/cjs/components/Placeholder/Placeholder.js +110 -0
  19. package/dist/cjs/components/Placeholder/index.js +25 -0
  20. package/dist/cjs/components/Placeholder/models.js +18 -0
  21. package/dist/cjs/components/Placeholder/placeholder-utils.js +215 -0
  22. package/dist/cjs/components/RichText.js +1 -0
  23. package/dist/cjs/components/Text.js +1 -0
  24. package/dist/cjs/enhancers/withAppPlaceholder.js +21 -0
  25. package/dist/cjs/enhancers/withEmptyFieldEditingComponent.js +12 -5
  26. package/dist/cjs/enhancers/withPlaceholder.js +8 -6
  27. package/dist/cjs/index.js +17 -11
  28. package/dist/cjs/rsc-utils/no-rsc.js +5 -0
  29. package/dist/cjs/rsc-utils/rsc.js +5 -0
  30. package/dist/esm/components/ClientEditingChromesUpdate.js +15 -0
  31. package/dist/esm/components/DefaultEmptyFieldEditingComponents.js +4 -4
  32. package/dist/esm/components/DesignLibrary.js +85 -102
  33. package/dist/esm/components/EditingScripts.js +1 -0
  34. package/dist/esm/components/ErrorBoundary.js +1 -0
  35. package/dist/esm/components/FEaaS/BYOCServerWrapper.js +21 -0
  36. package/dist/esm/components/{BYOCComponent.js → FEaaS/BYOCWrapper.js} +15 -26
  37. package/dist/esm/components/FEaaS/FEaaSSeverWrapper.js +27 -0
  38. package/dist/esm/components/FEaaS/FEaaSWrapper.js +37 -0
  39. package/dist/esm/components/{FEaaSComponent.js → FEaaS/feaas-utils.js} +16 -30
  40. package/dist/esm/components/FEaaS/index.js +6 -0
  41. package/dist/esm/components/FEaaS/models.js +4 -0
  42. package/dist/esm/components/Link.js +1 -1
  43. package/dist/esm/components/Placeholder/AppPlaceholder.js +69 -0
  44. package/dist/esm/components/Placeholder/ClientComponentWrapper.js +14 -0
  45. package/dist/esm/components/Placeholder/Placeholder.js +103 -0
  46. package/dist/esm/components/Placeholder/index.js +4 -0
  47. package/dist/esm/components/Placeholder/models.js +15 -0
  48. package/dist/esm/components/Placeholder/placeholder-utils.js +203 -0
  49. package/dist/esm/components/RichText.js +1 -0
  50. package/dist/esm/components/Text.js +1 -0
  51. package/dist/esm/enhancers/withAppPlaceholder.js +14 -0
  52. package/dist/esm/enhancers/withEmptyFieldEditingComponent.js +12 -5
  53. package/dist/esm/enhancers/withPlaceholder.js +8 -6
  54. package/dist/esm/index.js +5 -5
  55. package/dist/esm/rsc-utils/no-rsc.js +2 -0
  56. package/dist/esm/rsc-utils/rsc.js +2 -0
  57. package/package.json +16 -4
  58. package/types/components/ClientEditingChromesUpdate.d.ts +6 -0
  59. package/types/components/Date.d.ts +1 -1
  60. package/types/components/DefaultEmptyFieldEditingComponents.d.ts +8 -2
  61. package/types/components/DesignLibrary.d.ts +13 -13
  62. package/types/components/ErrorBoundary.d.ts +0 -1
  63. package/types/components/FEaaS/BYOCServerWrapper.d.ts +3 -0
  64. package/types/components/FEaaS/BYOCWrapper.d.ts +25 -0
  65. package/types/components/FEaaS/FEaaSSeverWrapper.d.ts +8 -0
  66. package/types/components/FEaaS/FEaaSWrapper.d.ts +7 -0
  67. package/types/components/FEaaS/feaas-utils.d.ts +21 -0
  68. package/types/components/FEaaS/index.d.ts +6 -0
  69. package/types/components/FEaaS/models.d.ts +125 -0
  70. package/types/components/Image.d.ts +1 -1
  71. package/types/components/Link.d.ts +1 -1
  72. package/types/components/Placeholder/AppPlaceholder.d.ts +10 -0
  73. package/types/components/Placeholder/ClientComponentWrapper.d.ts +9 -0
  74. package/types/components/Placeholder/Placeholder.d.ts +28 -0
  75. package/types/components/Placeholder/index.d.ts +5 -0
  76. package/types/components/Placeholder/models.d.ts +140 -0
  77. package/types/components/Placeholder/placeholder-utils.d.ts +53 -0
  78. package/types/components/RichText.d.ts +1 -1
  79. package/types/components/Text.d.ts +1 -1
  80. package/types/components/sharedTypes/components.d.ts +6 -0
  81. package/types/components/sharedTypes/props.d.ts +2 -2
  82. package/types/enhancers/withAppPlaceholder.d.ts +15 -0
  83. package/types/enhancers/withEmptyFieldEditingComponent.d.ts +3 -3
  84. package/types/enhancers/withPlaceholder.d.ts +2 -1
  85. package/types/index.d.ts +4 -5
  86. package/types/rsc-utils/no-rsc.d.ts +1 -0
  87. package/types/rsc-utils/rsc.d.ts +1 -0
  88. package/dist/cjs/components/BYOCWrapper.js +0 -22
  89. package/dist/cjs/components/FEaaSWrapper.js +0 -19
  90. package/dist/cjs/components/Placeholder.js +0 -68
  91. package/dist/cjs/components/PlaceholderCommon.js +0 -176
  92. package/dist/esm/components/BYOCWrapper.js +0 -15
  93. package/dist/esm/components/FEaaSWrapper.js +0 -12
  94. package/dist/esm/components/Placeholder.js +0 -62
  95. package/dist/esm/components/PlaceholderCommon.js +0 -169
  96. package/types/components/BYOCComponent.d.ts +0 -93
  97. package/types/components/BYOCWrapper.d.ts +0 -7
  98. package/types/components/FEaaSComponent.d.ts +0 -72
  99. package/types/components/FEaaSWrapper.d.ts +0 -4
  100. package/types/components/Placeholder.d.ts +0 -20
  101. package/types/components/PlaceholderCommon.d.ts +0 -89
  102. /package/dist/cjs/components/{PlaceholderMetadata.js → Placeholder/PlaceholderMetadata.js} +0 -0
  103. /package/dist/esm/components/{PlaceholderMetadata.js → Placeholder/PlaceholderMetadata.js} +0 -0
  104. /package/types/components/{PlaceholderMetadata.d.ts → Placeholder/PlaceholderMetadata.d.ts} +0 -0
@@ -0,0 +1,7 @@
1
+ import { JSX } from 'react';
2
+ import { FEaaSComponentProps } from './models';
3
+ /**
4
+ * @param {FEaaSComponentProps} props component props
5
+ */
6
+ export declare const FEaaSComponent: (props: FEaaSComponentProps) => JSX.Element;
7
+ export declare const FEaaSWrapper: (props: FEaaSComponentProps) => JSX.Element;
@@ -0,0 +1,21 @@
1
+ import { BYOCComponentParams, BYOCServerProps, FEaaSComponentParams, FEaaSComponentServerProps, RevisionType } from './models';
2
+ /**
3
+ * Fetches server component props required for server rendering, based on rendering params.
4
+ * @param {BYOCComponentParams} params component params
5
+ */
6
+ export declare function fetchBYOCComponentServerProps(params: BYOCComponentParams): Promise<BYOCServerProps>;
7
+ /**
8
+ * Fetches server component props required for server rendering, based on rendering params.
9
+ * Component endpoint will either be retrieved from params or from endpointOverride
10
+ * @param {FEaaSComponentParams} params component params
11
+ * @param {boolean} [isPageStateNormal] whether page is in normal mode
12
+ * @param {string} [endpointOverride] optional override for component endpoint
13
+ */
14
+ export declare function fetchFEaaSComponentServerProps(params: FEaaSComponentParams, isPageStateNormal?: boolean, endpointOverride?: string): Promise<FEaaSComponentServerProps>;
15
+ /**
16
+ * Build component endpoint URL from component's params
17
+ * @param {FEaaSComponentParams} params rendering parameters for FEAAS component
18
+ * @param {RevisionType} revisionFallback fallback revision to fetch if revision is absent in params
19
+ * @returns component endpoint URL
20
+ */
21
+ export declare const composeComponentEndpoint: (params: FEaaSComponentParams, revisionFallback: RevisionType) => string;
@@ -0,0 +1,6 @@
1
+ export { FEaaSWrapper, FEaaSComponent } from './FEaaSWrapper';
2
+ export { BYOCWrapper, BYOCComponent } from './BYOCWrapper';
3
+ export { FEaaSComponentClientProps, FEaaSComponentParams, FEaaSComponentProps, FEaaSServerWrapperProps, BYOCComponentParams, BYOCComponentProps, BYOCServerWrapperProps, FEAAS_COMPONENT_RENDERING_NAME, BYOC_COMPONENT_RENDERING_NAME, FEAAS_WRAPPER_RENDERING_NAME, BYOC_WRAPPER_RENDERING_NAME, } from './models';
4
+ export { FEaaSServerWrapper } from './FEaaSSeverWrapper';
5
+ export { BYOCServerWrapper } from './BYOCServerWrapper';
6
+ export { fetchFEaaSComponentServerProps, fetchBYOCComponentServerProps } from './feaas-utils';
@@ -0,0 +1,125 @@
1
+ import * as FEAAS from '@sitecore-feaas/clientside/react';
2
+ import { ComponentFields, ComponentRendering } from '@sitecore-content-sdk/core/layout';
3
+ import { Page } from '@sitecore-content-sdk/core/client';
4
+ import { MissingComponentProps } from '../MissingComponent';
5
+ export declare const FEAAS_WRAPPER_RENDERING_NAME = "FEaaSWrapper";
6
+ export declare const FEAAS_COMPONENT_RENDERING_NAME = "FEaaSComponent";
7
+ export declare const BYOC_WRAPPER_RENDERING_NAME = "BYOCWrapper";
8
+ export declare const BYOC_COMPONENT_RENDERING_NAME = "BYOCComponent";
9
+ /**
10
+ * FEaaS props for server rendering.
11
+ */
12
+ export type BYOCServerProps = {
13
+ /**
14
+ * Fetched data from server component props for server rendering, based on rendering params.
15
+ */
16
+ fetchedData?: FEAAS.DataScopes;
17
+ };
18
+ /**
19
+ * Data from rendering params on Sitecore's BYOC rendering
20
+ */
21
+ export type BYOCComponentParams = {
22
+ /**
23
+ * Name of the component to render
24
+ */
25
+ ComponentName?: string;
26
+ /**
27
+ * JSON props to pass into rendered component
28
+ */
29
+ ComponentProps?: string;
30
+ /**
31
+ * A JSON object with data sources to be fetched and passed to the component
32
+ */
33
+ ComponentDataOverride?: string;
34
+ /**
35
+ * A string with classes that can be used to apply themes, via SXA functionality
36
+ */
37
+ styles?: string;
38
+ RenderingIdentifier?: string;
39
+ };
40
+ /**
41
+ * Props for BYOCComponent. Includes components list to load external components from.
42
+ */
43
+ export type BYOCComponentClientProps = {
44
+ /**
45
+ * rendering data
46
+ */
47
+ rendering: ComponentRendering;
48
+ /**
49
+ * rendering params
50
+ */
51
+ params?: BYOCComponentParams;
52
+ /**
53
+ * fields from datasource items to be passed as rendered child component props
54
+ */
55
+ fields?: ComponentFields;
56
+ /**
57
+ * Error component override. To be shown when Renderer or underlying component throws
58
+ */
59
+ errorComponent?: React.ComponentClass<ErrorComponentProps> | React.FC<ErrorComponentProps>;
60
+ /**
61
+ * Override to indicate missing component situations. Would be shown when BYOC component is not registered
62
+ * or ComponentName is missing
63
+ */
64
+ missingComponentComponent?: React.ComponentClass<MissingComponentProps> | React.FC<MissingComponentProps>;
65
+ };
66
+ export type BYOCServerWrapperProps = BYOCComponentProps & {
67
+ rendering: ComponentRendering;
68
+ };
69
+ export type BYOCComponentProps = BYOCComponentClientProps & BYOCServerProps;
70
+ export type ErrorComponentProps = {
71
+ [prop: string]: unknown;
72
+ error?: Error;
73
+ };
74
+ /**
75
+ * Params from a Sitecore FEaaS rendering
76
+ */
77
+ export type FEaaSComponentParams = {
78
+ LibraryId?: string;
79
+ ComponentId?: string;
80
+ ComponentVersion?: string;
81
+ ComponentRevision?: RevisionType;
82
+ ComponentHostName?: string;
83
+ ComponentInstanceId?: string;
84
+ ComponentDataOverride?: string;
85
+ ComponentHTMLOverride?: string;
86
+ styles?: string;
87
+ RenderingIdentifier?: string;
88
+ };
89
+ export type RevisionType = number | 'staged' | 'published' | 'saved';
90
+ export type FEaaSServerWrapperProps = FEaaSComponentProps & {
91
+ rendering?: ComponentRendering;
92
+ page?: Page;
93
+ };
94
+ export type FEaaSComponentProps = FEaaSComponentServerProps & FEaaSComponentClientProps;
95
+ /**
96
+ * FEaaS props for server rendering.
97
+ */
98
+ export type FEaaSComponentServerProps = {
99
+ /**
100
+ * HTML template for presentation rendered inside the component
101
+ */
102
+ template?: string;
103
+ /**
104
+ * Default revision to be fetched. Should be 'staged' for editing/preview. Can be overriden by params.ComponentRevision
105
+ */
106
+ revisionFallback?: RevisionType;
107
+ /**
108
+ * Fetched data from server component props for server rendering, based on rendering params.
109
+ */
110
+ fetchedData?: FEAAS.DataScopes;
111
+ };
112
+ /**
113
+ * FEaaS props for client side component. Should be used as fallback when server props are not provided.
114
+ * Would also be passed on server to avoid hydration issues
115
+ */
116
+ export type FEaaSComponentClientProps = {
117
+ /**
118
+ * parameters from Sitecore's FEAAS component
119
+ */
120
+ params?: FEaaSComponentParams;
121
+ /**
122
+ * field data from component's datasource
123
+ */
124
+ fields?: ComponentFields;
125
+ };
@@ -25,7 +25,7 @@ export interface ImageSizeParameters {
25
25
  /** Image scale. Defaults to 1.0 */
26
26
  sc?: number;
27
27
  }
28
- export interface ImageProps extends EditableFieldProps {
28
+ export interface ImageProps extends EditableFieldProps<ImageProps> {
29
29
  [attributeName: string]: unknown;
30
30
  /** Image field data (consistent with other field types) */
31
31
  field?: (ImageField | ImageFieldValue) & FieldMetadata;
@@ -16,7 +16,7 @@ export interface LinkFieldValue {
16
16
  export interface LinkField {
17
17
  value: LinkFieldValue;
18
18
  }
19
- export type LinkProps = EditableFieldProps & React.AnchorHTMLAttributes<HTMLAnchorElement> & RefAttributes<HTMLAnchorElement> & {
19
+ export type LinkProps = EditableFieldProps<LinkProps> & React.AnchorHTMLAttributes<HTMLAnchorElement> & RefAttributes<HTMLAnchorElement> & {
20
20
  /** The link field data. */
21
21
  field: (LinkField | LinkFieldValue) & FieldMetadata;
22
22
  /**
@@ -0,0 +1,10 @@
1
+ import { AppPlaceholderProps } from './models';
2
+ import React from 'react';
3
+ /**
4
+ * The implemention of placeholder compatible with React Server Components.
5
+ * Renders components from the layout data for the given placeholder name, with consideration for page edit mode.
6
+ * Pulls components from the provided component map.
7
+ * @param {AppPlaceholderProps} props Placeholder props
8
+ * @returns {React.ReactNode | React.ReactElement[]} rendered component(s)
9
+ */
10
+ export declare const AppPlaceholder: (props: AppPlaceholderProps) => string | number | bigint | boolean | Iterable<React.ReactNode> | Promise<string | number | bigint | boolean | React.ReactPortal | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | Iterable<React.ReactNode>> | React.JSX.Element | (string | number | bigint | boolean | Iterable<React.ReactNode> | Promise<string | number | bigint | boolean | React.ReactPortal | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | Iterable<React.ReactNode>> | React.JSX.Element)[];
@@ -0,0 +1,9 @@
1
+ import { ComponentRendering } from '@sitecore-content-sdk/core/layout';
2
+ import React from 'react';
3
+ import { AppComponentProps } from './models';
4
+ export interface ClientComponentWrapperProps {
5
+ rendering: ComponentRendering;
6
+ componentProps: AppComponentProps;
7
+ placeholderName: string;
8
+ }
9
+ export declare const ClientComponentWrapper: (props: ClientComponentWrapperProps) => React.JSX.Element;
@@ -0,0 +1,28 @@
1
+ import React from 'react';
2
+ import { PlaceholderProps } from './models';
3
+ import { ComponentRendering } from '@sitecore-content-sdk/core/layout';
4
+ export declare class PlaceholderComponent extends React.Component<PlaceholderProps> {
5
+ isEmpty: boolean;
6
+ state: Readonly<{
7
+ error?: Error;
8
+ }>;
9
+ constructor(props: PlaceholderProps);
10
+ /**
11
+ * Renders the components for the placeholder based on the provided rendering data.
12
+ * @param {PlaceholderProps} props placeholder component props
13
+ * @param {ComponentRendering[]} placeholderRenderings renderings within placeholder
14
+ * @returns {React.ReactNode | React.ReactElement[]} rendered components
15
+ */
16
+ static getRenderedComponents: (props: PlaceholderProps, placeholderRenderings: ComponentRendering[]) => React.JSX.Element[];
17
+ componentDidMount(): void;
18
+ componentDidCatch(error: Error): void;
19
+ /**
20
+ * Renders the placeholder when it is empty. The required CSS styles are applied to the placeholder in edit mode.
21
+ * @param {React.ReactNode | React.ReactElement[]} node react node
22
+ * @returns react node
23
+ * @deprecated use renderEmptyPlaceholder from react/nextjs import instead
24
+ */
25
+ renderEmptyPlaceholder(node: React.ReactNode | React.ReactElement[]): React.JSX.Element;
26
+ render(): string | number | bigint | boolean | Iterable<React.ReactNode> | Promise<string | number | bigint | boolean | React.ReactPortal | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | Iterable<React.ReactNode>> | React.JSX.Element | (string | number | bigint | boolean | Iterable<React.ReactNode> | Promise<string | number | bigint | boolean | React.ReactPortal | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | Iterable<React.ReactNode>> | React.JSX.Element)[];
27
+ }
28
+ export declare const Placeholder: (props: import("@sitecore-content-sdk/core/utils").EnhancedOmit<PlaceholderProps, keyof import("../../enhancers/withSitecore").WithSitecoreProps>) => React.JSX.Element;
@@ -0,0 +1,5 @@
1
+ export { Placeholder, PlaceholderComponent } from './Placeholder';
2
+ export { PlaceholderMetadata } from './PlaceholderMetadata';
3
+ export { PlaceholderProps, AppPlaceholderProps } from './models';
4
+ export { AppPlaceholder } from './AppPlaceholder';
5
+ export * from './placeholder-utils';
@@ -0,0 +1,140 @@
1
+ import { Page } from '@sitecore-content-sdk/core/client';
2
+ import { ComponentRendering, Field, Item, RouteData } from '@sitecore-content-sdk/core/layout';
3
+ import { ComponentType } from '@sitecore-content-sdk/core/tools';
4
+ import { ComponentMap } from '../sharedTypes';
5
+ export type { ComponentType };
6
+ type ErrorComponentProps = {
7
+ [prop: string]: unknown;
8
+ };
9
+ /** Provided for the component which represents rendering data */
10
+ export type ComponentProps = {
11
+ [key: string]: unknown;
12
+ rendering: ComponentRendering;
13
+ };
14
+ export interface AppComponentProps {
15
+ fields: {
16
+ [name: string]: Field | Item | Item[];
17
+ };
18
+ params: {
19
+ [name: string]: string;
20
+ };
21
+ rendering: ComponentRendering;
22
+ }
23
+ export interface BasePlaceholderProps {
24
+ /** Name of the placeholder to render. */
25
+ name: string;
26
+ /** Rendering data to be used when rendering the placeholder. */
27
+ rendering: ComponentRendering | RouteData;
28
+ /**
29
+ * An object of field names/values that are aggregated and propagated through the component tree created by a placeholder.
30
+ * Any component or placeholder rendered by a placeholder will have access to this data via `props.fields`.
31
+ */
32
+ fields?: {
33
+ [name: string]: Field | Item | Item[];
34
+ };
35
+ /**
36
+ * An object of rendering parameter names/values that are aggregated and propagated through the component tree created by a placeholder.
37
+ * Any component or placeholder rendered by a placeholder will have access to this data via `props.params`.
38
+ */
39
+ params?: {
40
+ [name: string]: string;
41
+ };
42
+ /**
43
+ * A component that is rendered in place of any components that are in this placeholder,
44
+ * but do not have a definition in the componentMap (i.e. don't have a React implementation)
45
+ */
46
+ missingComponentComponent?: React.ComponentClass<unknown> | React.FC<unknown>;
47
+ /**
48
+ * A component that is rendered in place of any components that are hidden
49
+ */
50
+ hiddenRenderingComponent?: React.ComponentClass<unknown> | React.FC<unknown>;
51
+ /**
52
+ * A component that is rendered in place of the placeholder when an error occurs rendering
53
+ * the placeholder
54
+ */
55
+ errorComponent?: React.ComponentClass<ErrorComponentProps> | React.FC<ErrorComponentProps>;
56
+ /**
57
+ * Page data.
58
+ * This data is passed by the SitecoreProvider.
59
+ */
60
+ page: Page;
61
+ /**
62
+ * The message that gets displayed while component is loading
63
+ */
64
+ componentLoadingMessage?: string;
65
+ /**
66
+ * If true, disables Suspense in ErrorBoundary for the placeholder.
67
+ * @default false
68
+ */
69
+ disableSuspense?: boolean;
70
+ /**
71
+ * Render props function that is called when the placeholder contains no content components.
72
+ */
73
+ renderEmpty?: (components: React.ReactNode[]) => React.ReactNode;
74
+ /**
75
+ * Render props function that is called for each non-system component added to the placeholder.
76
+ * Mutually exclusive with `render`.
77
+ */
78
+ renderEach?: (component: React.ReactNode, index: number) => React.ReactNode;
79
+ }
80
+ export interface PlaceholderProps extends BasePlaceholderProps {
81
+ [key: string]: unknown;
82
+ /**
83
+ * Component Map will be used to map Sitecore component names to app implementation
84
+ * When rendered within a <SitecoreProvider> component, defaults to the context componentMap.
85
+ * When rendered as a server placeholder, this prop must be provided. This prop is not used in AppPlaceholder.
86
+ */
87
+ componentMap?: ComponentMap;
88
+ /**
89
+ * Modify final props of component (before render) provided by rendering data.
90
+ * Can be used in case when you need to insert additional data into the component.
91
+ * @param {ComponentProps} componentProps component props to be modified
92
+ * @returns {ComponentProps} modified or initial props
93
+ */
94
+ modifyComponentProps?: (componentProps: ComponentProps) => ComponentProps;
95
+ /**
96
+ * Render props function that enables control over the rendering of the components in the placeholder.
97
+ * Useful for techniques like wrapping each child in a wrapper component.
98
+ */
99
+ render?: (components: React.ReactNode[], data: ComponentRendering[], props: PlaceholderProps) => React.ReactNode;
100
+ }
101
+ export interface AppPlaceholderProps extends BasePlaceholderProps {
102
+ /**
103
+ * Component Map will be used to map Sitecore component names to app implementation
104
+ * When rendered within a <SitecoreProvider> component, defaults to the context componentMap.
105
+ * When rendered as a server placeholder, this prop must be provided. This prop is not used in AppPlaceholder.
106
+ */
107
+ componentMap: ComponentMap;
108
+ /**
109
+ * Modify final props of component (before render) provided by rendering data.
110
+ * Can be used in case when you need to insert additional data into the component.
111
+ * @param {AppComponentProps} componentProps component props to be modified
112
+ * @returns {AppComponentProps} modified or initial props
113
+ */
114
+ modifyComponentProps?: (componentProps: AppComponentProps) => AppComponentProps;
115
+ /**
116
+ * Render props function that enables control over the rendering of the components in the placeholder.
117
+ * Useful for techniques like wrapping each child in a wrapper component.
118
+ */
119
+ render?: (components: React.ReactNode[], data: ComponentRendering[], props: AppPlaceholderProps) => React.ReactNode;
120
+ }
121
+ export type RenderedProps = Omit<PlaceholderProps, 'fields' | 'params'> & {
122
+ key: string;
123
+ fields: {
124
+ [field: string]: unknown;
125
+ };
126
+ params: {
127
+ [param: string]: unknown;
128
+ };
129
+ rendering: ComponentRendering;
130
+ };
131
+ export interface ComponentForRendering {
132
+ component: React.ComponentType<any>;
133
+ isEmpty: boolean;
134
+ dynamic?: boolean;
135
+ componentType?: ComponentType;
136
+ }
137
+ /**
138
+ * Prop names from placeholder that cannot be serialized and passed from server to client side components
139
+ */
140
+ export declare const nonSerializedPlaceholderProps: ["renderEmpty", "render", "renderEach", "errorComponent", "componentLoadingMessage", "modifyComponentProps", "componentMap", "page", "missingComponentComponent", "hiddenRenderingComponent"];
@@ -0,0 +1,53 @@
1
+ import React from 'react';
2
+ import { ComponentMap } from '../sharedTypes';
3
+ import { ComponentRendering, RouteData } from '@sitecore-content-sdk/core/layout';
4
+ import { AppComponentProps, BasePlaceholderProps, ComponentForRendering, PlaceholderProps, RenderedProps } from './models';
5
+ /**
6
+ * Get the renderings for the specified placeholder from the rendering data.
7
+ * @param {ComponentRendering | RouteData } rendering rendering data
8
+ * @param {string} name placeholder name
9
+ * @param {boolean} isEditing whether components should be rendered in editing mode
10
+ * @returns {ComponentRendering[]} array of component renderings
11
+ */
12
+ export declare const getPlaceholderRenderings: (rendering: ComponentRendering | RouteData, name: string, isEditing: boolean) => ComponentRendering<import("@sitecore-content-sdk/core/layout").ComponentFields>[];
13
+ /**
14
+ * Get SXA specific params from Sitecore rendering params
15
+ * @param {ComponentRendering} rendering rendering object
16
+ * @returns {object} converted SXA params
17
+ */
18
+ export declare const getSXAParams: (rendering: ComponentRendering) => {
19
+ styles?: undefined;
20
+ } | {
21
+ styles: string;
22
+ };
23
+ /**
24
+ * Renders the placeholder when it is empty. The required CSS styles are applied to the placeholder in edit mode.
25
+ * @param {React.ReactNode | React.ReactElement[]} node react node
26
+ * @returns react node
27
+ */
28
+ export declare const renderEmptyPlaceholder: (node: React.ReactNode | React.ReactElement[]) => React.JSX.Element;
29
+ /**
30
+ * Get component props to be passed to the rendered component.
31
+ * @param {PlaceholderProps} placeholderProps current placeholder props
32
+ * @param {ComponentRendering} componentRendering rendering to be rendered
33
+ * @param {string} renderingKey unique key to pass over to rendering props
34
+ * @returns {RenderedProps} props to be passed to the rendered component
35
+ */
36
+ export declare const getRenderedComponentProps: (placeholderProps: PlaceholderProps, componentRendering: ComponentRendering, renderingKey: string) => RenderedProps;
37
+ /**
38
+ * Merge placeholder and component field and params content props.
39
+ * @param {BasePlaceholderProps} placeholderProps placeholder props
40
+ * @param {ComponentRendering} componentRendering component rendering
41
+ * @returns {ComponentProps} merged props
42
+ */
43
+ export declare function getAppComponentProps<T extends BasePlaceholderProps>(placeholderProps: T, componentRendering: ComponentRendering): AppComponentProps;
44
+ /**
45
+ * Get component implemenation from the component map based on the rendering definition.
46
+ * @param {ComponentRendering} renderingDefinition rendering data
47
+ * @param {string} placeholderName name of current placeholder
48
+ * @param {ComponentMap} componentMap component map for the current app
49
+ * @param {React.ComponentClass} [hiddenRenderingComponent] fallback implementation in to be rendered if the rendering is hidden
50
+ * @param {React.ComponentClass} [missingComponentComponent] fallback implementation in case no component is found in the component map
51
+ * @returns {ContentSDKComponet | null} component implementation or null if no component map is provided
52
+ */
53
+ export declare const getComponentForRendering: (renderingDefinition: ComponentRendering, placeholderName: string, componentMap?: ComponentMap, hiddenRenderingComponent?: React.ComponentClass | React.FC, missingComponentComponent?: React.ComponentClass | React.FC) => ComponentForRendering;
@@ -4,7 +4,7 @@ import { FieldMetadata } from '@sitecore-content-sdk/core/layout';
4
4
  export interface RichTextField extends FieldMetadata {
5
5
  value?: string;
6
6
  }
7
- export interface RichTextProps extends EditableFieldProps {
7
+ export interface RichTextProps extends EditableFieldProps<RichTextProps> {
8
8
  [htmlAttributes: string]: unknown;
9
9
  /** The rich text field data. */
10
10
  field?: RichTextField;
@@ -4,7 +4,7 @@ import { FieldMetadata } from '@sitecore-content-sdk/core/layout';
4
4
  export interface TextField extends FieldMetadata {
5
5
  value?: string | number;
6
6
  }
7
- export interface TextProps extends EditableFieldProps {
7
+ export interface TextProps extends EditableFieldProps<TextProps> {
8
8
  [htmlAttributes: string]: unknown;
9
9
  /** The text field data. */
10
10
  field?: TextField;
@@ -1,4 +1,10 @@
1
1
  import { ComponentType } from 'react';
2
+ /**
3
+ * React component import with account for custom exports
4
+ */
5
+ export type ReactJssComponent = (ComponentType | ReactModule) & {
6
+ isClient?: boolean;
7
+ };
2
8
  /**
3
9
  * SXA uses custom default export name
4
10
  */
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Shared editing field props
3
3
  */
4
- export interface EditableFieldProps {
4
+ export interface EditableFieldProps<EmptyFieldEditingComponentProps = unknown> {
5
5
  /**
6
6
  * Can be used to explicitly disable inline editing.
7
7
  * @default true
@@ -10,5 +10,5 @@ export interface EditableFieldProps {
10
10
  /**
11
11
  * Custom element to render in Pages in edit mode if field value is empty
12
12
  */
13
- emptyFieldEditingComponent?: React.ComponentClass<unknown> | React.FC<unknown>;
13
+ emptyFieldEditingComponent?: React.ComponentClass<EmptyFieldEditingComponentProps> | React.FC<EmptyFieldEditingComponentProps>;
14
14
  }
@@ -0,0 +1,15 @@
1
+ import React from 'react';
2
+ import { ComponentType } from 'react';
3
+ import { ComponentRendering } from '@sitecore-content-sdk/core/layout';
4
+ import { Page } from '@sitecore-content-sdk/core/client';
5
+ import { ComponentMap } from '../components/sharedTypes';
6
+ export type ComponentProps = {
7
+ rendering: ComponentRendering;
8
+ placeholders: Record<string, React.ReactNode>;
9
+ };
10
+ export type WrapperProps = {
11
+ rendering: ComponentRendering;
12
+ page: Page;
13
+ componentMap: ComponentMap;
14
+ };
15
+ export declare const withAppPlaceholder: <T extends ComponentProps, W extends T & WrapperProps>(Component: ComponentType<T>) => (props: W) => React.JSX.Element;
@@ -13,15 +13,15 @@ export interface WithEmptyFieldEditingComponentOptions {
13
13
  */
14
14
  isForwardRef?: boolean;
15
15
  }
16
- interface WithEmptyFieldEditingComponentProps {
16
+ interface WithEmptyFieldEditingComponentProps<Props> {
17
17
  field?: (Partial<Field> | GenericFieldValue) & FieldMetadata;
18
18
  editable?: boolean;
19
- emptyFieldEditingComponent?: React.ComponentClass | React.FC;
19
+ emptyFieldEditingComponent?: React.ComponentClass<Props> | React.FC<Props>;
20
20
  }
21
21
  /**
22
22
  * Returns the passed field component or default component in case field value is empty and edit mode is 'metadata'
23
23
  * @param {ComponentType<FieldComponentProps>} FieldComponent the field component
24
24
  * @param {WithEmptyFieldEditingComponentProps} options the options of the HOC;
25
25
  */
26
- export declare function withEmptyFieldEditingComponent<FieldComponentProps extends WithEmptyFieldEditingComponentProps, RefElementType = HTMLElement>(FieldComponent: ComponentType<FieldComponentProps>, options: WithEmptyFieldEditingComponentOptions): React.ForwardRefExoticComponent<React.PropsWithoutRef<FieldComponentProps> & React.RefAttributes<RefElementType>> | ((props: FieldComponentProps) => React.JSX.Element);
26
+ export declare function withEmptyFieldEditingComponent<FieldComponentProps extends WithEmptyFieldEditingComponentProps<FieldComponentProps>, RefElementType = HTMLElement>(FieldComponent: ComponentType<FieldComponentProps>, options: WithEmptyFieldEditingComponentOptions): React.ForwardRefExoticComponent<React.PropsWithoutRef<FieldComponentProps> & React.RefAttributes<RefElementType>> | ((props: FieldComponentProps) => React.JSX.Element);
27
27
  export {};
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
2
  import { ComponentRendering, RouteData } from '@sitecore-content-sdk/core/layout';
3
- import { PlaceholderProps } from '../components/PlaceholderCommon';
3
+ import { PlaceholderProps } from '../components/Placeholder';
4
4
  export interface WithPlaceholderOptions {
5
5
  /**
6
6
  * Function to map incoming placeholder props into rendering data to use for the placeholder data.
@@ -28,6 +28,7 @@ export interface PlaceholderToPropMapping {
28
28
  }
29
29
  export type WithPlaceholderSpec = (string | PlaceholderToPropMapping) | (string | PlaceholderToPropMapping)[];
30
30
  /**
31
+ * HOC to provide client-side placeholder functionality to a component.
31
32
  * @param {WithPlaceholderSpec} placeholders
32
33
  * @param {WithPlaceholderOptions} [options]
33
34
  */
package/types/index.d.ts CHANGED
@@ -7,16 +7,14 @@ export { GraphQLClientError, RetryStrategy, DefaultRetryStrategy, GraphQLRequest
7
7
  export { mediaApi } from '@sitecore-content-sdk/core/media';
8
8
  export { Form } from './components/Form';
9
9
  export { ReactContentSdkComponent, ComponentMap, ReactModule } from './components/sharedTypes';
10
- export { Placeholder, PlaceholderComponentProps } from './components/Placeholder';
10
+ export { Placeholder, PlaceholderProps, PlaceholderProps as PlaceholderComponentProps, AppPlaceholder, AppPlaceholderProps, } 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
- export { FEaaSComponent, FEaaSComponentProps, FEaaSComponentParams, fetchFEaaSComponentServerProps, } from './components/FEaaSComponent';
16
- export { FEaaSWrapper } from './components/FEaaSWrapper';
15
+ export { FEaaSComponent, FEaaSComponentProps, FEaaSComponentParams, fetchFEaaSComponentServerProps, BYOCComponent, BYOCComponentParams, BYOCComponentProps, fetchBYOCComponentServerProps, BYOCWrapper, BYOCWrapper as BYOCClientWrapper, FEaaSWrapper, FEaaSWrapper as FEaaSClientWrapper, FEaaSServerWrapper, BYOCServerWrapper, } from './components/FEaaS';
17
16
  export { DesignLibrary } from './components/DesignLibrary';
18
- export { BYOCComponent, BYOCComponentParams, BYOCComponentProps, fetchBYOCComponentServerProps, } from './components/BYOCComponent';
19
- export { BYOCWrapper } from './components/BYOCWrapper';
17
+ export {} from './components/FEaaS/BYOCComponent';
20
18
  export { Link, LinkField, LinkFieldValue, LinkProps } from './components/Link';
21
19
  export { File, FileField } from './components/File';
22
20
  export { SitecoreProvider, SitecoreProviderState, SitecoreProviderReactContext, } from './components/SitecoreProvider';
@@ -28,4 +26,5 @@ export { withFieldMetadata } from './enhancers/withFieldMetadata';
28
26
  export { withEmptyFieldEditingComponent } from './enhancers/withEmptyFieldEditingComponent';
29
27
  export { EditingScripts } from './components/EditingScripts';
30
28
  export { DefaultEmptyFieldEditingComponentText, DefaultEmptyFieldEditingComponentImage, } from './components/DefaultEmptyFieldEditingComponents';
29
+ export { ClientEditingChromesUpdate } from './components/ClientEditingChromesUpdate';
31
30
  export { SitePathService, SitePathServiceConfig } from '@sitecore-content-sdk/core/site';
@@ -0,0 +1 @@
1
+ export declare const rsc = false;
@@ -0,0 +1 @@
1
+ export declare const rsc = true;
@@ -1,22 +0,0 @@
1
- "use strict";
2
- 'use client';
3
- var __importDefault = (this && this.__importDefault) || function (mod) {
4
- return (mod && mod.__esModule) ? mod : { "default": mod };
5
- };
6
- Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.BYOCWrapper = exports.BYOC_WRAPPER_RENDERING_NAME = void 0;
8
- const BYOCComponent_1 = require("./BYOCComponent");
9
- const react_1 = __importDefault(require("react"));
10
- exports.BYOC_WRAPPER_RENDERING_NAME = 'BYOCWrapper';
11
- /**
12
- * TODO: remove when framework agnostic forms implemented
13
- */
14
- const BYOCWrapper = (props) => {
15
- var _a, _b, _c;
16
- const styles = (_b = (_a = props.params) === null || _a === void 0 ? void 0 : _a.styles) === null || _b === void 0 ? void 0 : _b.trimEnd();
17
- const id = (_c = props.params) === null || _c === void 0 ? void 0 : _c.RenderingIdentifier;
18
- return (react_1.default.createElement("div", { className: styles ? styles : undefined, id: id ? id : undefined },
19
- react_1.default.createElement("div", { className: "component-content" },
20
- react_1.default.createElement(BYOCComponent_1.BYOCComponent, Object.assign({}, props)))));
21
- };
22
- exports.BYOCWrapper = BYOCWrapper;
@@ -1,19 +0,0 @@
1
- "use strict";
2
- 'use client';
3
- var __importDefault = (this && this.__importDefault) || function (mod) {
4
- return (mod && mod.__esModule) ? mod : { "default": mod };
5
- };
6
- Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.FEaaSWrapper = exports.FEAAS_WRAPPER_RENDERING_NAME = void 0;
8
- const FEaaSComponent_1 = require("./FEaaSComponent");
9
- const react_1 = __importDefault(require("react"));
10
- exports.FEAAS_WRAPPER_RENDERING_NAME = 'FEaaSWrapper';
11
- const FEaaSWrapper = (props) => {
12
- var _a, _b;
13
- const styles = `component feaas ${(_a = props.params) === null || _a === void 0 ? void 0 : _a.styles}`.trimEnd();
14
- const id = (_b = props.params) === null || _b === void 0 ? void 0 : _b.RenderingIdentifier;
15
- return (react_1.default.createElement("div", { className: styles, id: id ? id : undefined },
16
- react_1.default.createElement("div", { className: "component-content" },
17
- react_1.default.createElement(FEaaSComponent_1.FEaaSComponent, Object.assign({}, props)))));
18
- };
19
- exports.FEaaSWrapper = FEaaSWrapper;