@sitecore-jss/sitecore-jss-react 22.0.0-canary.9 → 22.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 (60) hide show
  1. package/LICENSE.txt +202 -202
  2. package/README.md +10 -10
  3. package/dist/cjs/ComponentBuilder.js +25 -0
  4. package/dist/cjs/components/BYOCComponent.js +122 -0
  5. package/dist/cjs/components/BYOCWrapper.js +18 -0
  6. package/dist/cjs/components/Date.js +1 -4
  7. package/dist/cjs/components/FEaaSComponent.js +120 -61
  8. package/dist/cjs/components/FEaaSWrapper.js +18 -0
  9. package/dist/cjs/components/Image.js +6 -13
  10. package/dist/cjs/components/Link.js +8 -12
  11. package/dist/cjs/components/MissingComponent.js +6 -2
  12. package/dist/cjs/components/Placeholder.js +1 -29
  13. package/dist/cjs/components/PlaceholderCommon.js +21 -12
  14. package/dist/cjs/components/RichText.js +1 -5
  15. package/dist/cjs/components/SitecoreContext.js +2 -2
  16. package/dist/cjs/components/Text.js +1 -5
  17. package/dist/cjs/index.js +17 -3
  18. package/dist/cjs/utils.js +50 -2
  19. package/dist/esm/ComponentBuilder.js +21 -0
  20. package/dist/esm/components/BYOCComponent.js +91 -0
  21. package/dist/esm/components/BYOCWrapper.js +11 -0
  22. package/dist/esm/components/Date.js +1 -4
  23. package/dist/esm/components/FEaaSComponent.js +115 -61
  24. package/dist/esm/components/FEaaSWrapper.js +11 -0
  25. package/dist/esm/components/Image.js +6 -13
  26. package/dist/esm/components/Link.js +8 -12
  27. package/dist/esm/components/MissingComponent.js +6 -2
  28. package/dist/esm/components/Placeholder.js +2 -30
  29. package/dist/esm/components/PlaceholderCommon.js +21 -12
  30. package/dist/esm/components/RichText.js +1 -5
  31. package/dist/esm/components/SitecoreContext.js +2 -2
  32. package/dist/esm/components/Text.js +1 -5
  33. package/dist/esm/index.js +8 -4
  34. package/dist/esm/utils.js +47 -1
  35. package/package.json +9 -11
  36. package/types/ComponentBuilder.d.ts +28 -0
  37. package/types/components/BYOCComponent.d.ts +87 -0
  38. package/types/components/BYOCWrapper.d.ts +3 -0
  39. package/types/components/Date.d.ts +1 -0
  40. package/types/components/EditFrame.d.ts +1 -0
  41. package/types/components/FEaaSComponent.d.ts +59 -6
  42. package/types/components/FEaaSWrapper.d.ts +3 -0
  43. package/types/components/File.d.ts +1 -0
  44. package/types/components/HiddenRendering.d.ts +3 -1
  45. package/types/components/Image.d.ts +2 -6
  46. package/types/components/Link.d.ts +2 -1
  47. package/types/components/MissingComponent.d.ts +2 -0
  48. package/types/components/Placeholder.d.ts +1 -0
  49. package/types/components/PlaceholderCommon.d.ts +1 -0
  50. package/types/components/RichText.d.ts +1 -0
  51. package/types/components/SitecoreContext.d.ts +2 -1
  52. package/types/components/Text.d.ts +1 -0
  53. package/types/components/VisitorIdentification.d.ts +1 -0
  54. package/types/components/sharedTypes.d.ts +1 -0
  55. package/types/enhancers/withComponentFactory.d.ts +1 -0
  56. package/types/enhancers/withDatasourceCheck.d.ts +2 -1
  57. package/types/enhancers/withEditorChromes.d.ts +1 -0
  58. package/types/enhancers/withSitecoreContext.d.ts +2 -1
  59. package/types/index.d.ts +8 -4
  60. package/types/utils.d.ts +18 -1
package/dist/esm/utils.js CHANGED
@@ -1,3 +1,15 @@
1
+ var __rest = (this && this.__rest) || function (s, e) {
2
+ var t = {};
3
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
4
+ t[p] = s[p];
5
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
6
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
7
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
8
+ t[p[i]] = s[p[i]];
9
+ }
10
+ return t;
11
+ };
12
+ import { getFieldValue } from '@sitecore-jss/sitecore-jss/layout';
1
13
  import { parse as styleParse } from 'style-attr';
2
14
  // https://stackoverflow.com/a/10426674/9324
3
15
  export const convertKebabCasetoCamelCase = (str) => str.replace(/^.|-./g, (letter, index) => index === 0 ? letter.toLowerCase() : letter.substr(1).toUpperCase());
@@ -45,7 +57,7 @@ export const convertAttributesToReactProps = (attributes) => {
45
57
  /**
46
58
  * "class" property will be transformed into or appended to "className" instead.
47
59
  * @param {string} otherAttrs all other props included on the image component
48
- * * @returns {void}
60
+ * @returns {void}
49
61
  */
50
62
  export const addClassName = (otherAttrs) => {
51
63
  if (otherAttrs.class) {
@@ -61,3 +73,37 @@ export const addClassName = (otherAttrs) => {
61
73
  delete otherAttrs.class;
62
74
  }
63
75
  };
76
+ /**
77
+ * Converts the given tag attributes object to a string
78
+ * @param {Object.<string, unknown>} attributes the attributes object
79
+ * @returns {string} string representation of the attributes
80
+ */
81
+ export const getAttributesString = (attributes) => {
82
+ const { className } = attributes, restAttributes = __rest(attributes, ["className"]);
83
+ const attributesEntries = Object.entries(restAttributes).map(([key, value]) => {
84
+ if (typeof value === 'object') {
85
+ const valueString = JSON.stringify(value)
86
+ .replace(/"|{|}/g, '')
87
+ .replace(/,/g, ';');
88
+ return `${key}="${valueString}"`;
89
+ }
90
+ return `${key}="${value}"`;
91
+ });
92
+ if (className) {
93
+ attributesEntries.push(`class="${className}"`);
94
+ }
95
+ return attributesEntries.join(' ');
96
+ };
97
+ /**
98
+ * Used in FEAAS and BYOC implementations to convert datasource item field values into component props
99
+ * @param {ComponentFields} fields field collection from Sitecore
100
+ * @returns JSON object that can be used as props
101
+ */
102
+ export const getDataFromFields = (fields) => {
103
+ let data = {};
104
+ data = Object.entries(fields).reduce((acc, [key]) => {
105
+ acc[key] = getFieldValue(fields, key);
106
+ return acc;
107
+ }, data);
108
+ return data;
109
+ };
package/package.json CHANGED
@@ -1,21 +1,20 @@
1
1
  {
2
2
  "name": "@sitecore-jss/sitecore-jss-react",
3
- "version": "22.0.0-canary.9",
3
+ "version": "22.0.0",
4
4
  "main": "dist/cjs/index.js",
5
5
  "module": "dist/esm/index.js",
6
6
  "sideEffects": false,
7
7
  "scripts": {
8
8
  "build": "npm run clean && tsc -p tsconfig.json && tsc -p tsconfig-esm.json",
9
9
  "clean": "del-cli dist types",
10
- "lint": "eslint ./src/**/*.tsx ./src/**/*.ts",
10
+ "lint": "eslint \"./src/**/*.tsx\" \"./src/**/*.ts\"",
11
11
  "test": "mocha --require ts-node/register/transpile-only --require ./src/tests/shim.ts ./src/tests/jsdom-setup.ts ./src/tests/enzyme-setup.ts \"./src/**/*.test.ts\" \"./src/**/*.test.tsx\" --exit",
12
12
  "prepublishOnly": "npm run build",
13
13
  "coverage": "nyc npm test",
14
14
  "generate-docs": "npx typedoc --plugin typedoc-plugin-markdown --readme none --out ../../ref-docs/sitecore-jss-react src/index.ts --githubPages false"
15
15
  },
16
16
  "engines": {
17
- "node": ">=12",
18
- "npm": ">=6"
17
+ "node": ">=18"
19
18
  },
20
19
  "author": {
21
20
  "name": "Sitecore Corporation",
@@ -27,15 +26,14 @@
27
26
  "url": "https://github.com/sitecore/jss/issues"
28
27
  },
29
28
  "devDependencies": {
30
- "@sitecore-feaas/clientside": "^0.1.24",
29
+ "@sitecore-feaas/clientside": "^0.5.17",
31
30
  "@types/chai": "^4.3.4",
32
31
  "@types/chai-string": "^1.4.2",
33
- "@types/deep-equal": "^1.0.1",
34
32
  "@types/enzyme": "^3.10.12",
35
33
  "@types/mocha": "^10.0.1",
36
34
  "@types/node": "18.11.10",
37
35
  "@types/prop-types": "^15.7.5",
38
- "@types/react": "^18.0.27",
36
+ "@types/react": "^18.2.22",
39
37
  "@types/react-dom": "^18.0.10",
40
38
  "@types/sinon": "^10.0.13",
41
39
  "@types/sinon-chai": "^3.2.9",
@@ -58,19 +56,19 @@
58
56
  "typescript": "~4.9.3"
59
57
  },
60
58
  "peerDependencies": {
59
+ "@sitecore-feaas/clientside": "^0.5.17",
61
60
  "react": "^18.2.0",
62
61
  "react-dom": "^18.2.0"
63
62
  },
64
63
  "dependencies": {
65
- "@sitecore-jss/sitecore-jss": "^22.0.0-canary.9",
66
- "deep-equal": "^2.1.0",
67
- "html-react-parser": "^3.0.4",
64
+ "@sitecore-jss/sitecore-jss": "22.0.0",
65
+ "fast-deep-equal": "^3.1.3",
68
66
  "prop-types": "^15.8.1",
69
67
  "style-attr": "^1.3.0"
70
68
  },
71
69
  "description": "",
72
70
  "types": "types/index.d.ts",
73
- "gitHead": "f28c2255e8bc93787848a7778b6a32355590e7b4",
71
+ "gitHead": "2a5fe700fd75e19e4107b39630cce823fc1af08e",
74
72
  "files": [
75
73
  "dist",
76
74
  "types"
@@ -0,0 +1,28 @@
1
+ /// <reference types="@types/react" />
2
+ import { ComponentType } from 'react';
3
+ import { ComponentFactory } from './components/sharedTypes';
4
+ /**
5
+ * Configuration for ComponentBuilder
6
+ */
7
+ export type ComponentBuilderConfig<ComponentType> = {
8
+ /**
9
+ * List of components to be stored
10
+ */
11
+ components: Map<string, ComponentType>;
12
+ };
13
+ /**
14
+ * React implementation of component builder class for building components based on the configuration.
15
+ */
16
+ export declare class ComponentBuilder {
17
+ protected config: ComponentBuilderConfig<ComponentType>;
18
+ /**
19
+ * List of components to be stored
20
+ */
21
+ protected components: Map<string, ComponentType>;
22
+ constructor(config: ComponentBuilderConfig<ComponentType>);
23
+ /**
24
+ * Creates a new instance of component factory
25
+ * @returns {ComponentFactory} Component factory implementation
26
+ */
27
+ getComponentFactory(): ComponentFactory;
28
+ }
@@ -0,0 +1,87 @@
1
+ /// <reference types="@types/react" />
2
+ import React from 'react';
3
+ import { ComponentFields } from '@sitecore-jss/sitecore-jss/layout';
4
+ import { MissingComponentProps } from './MissingComponent';
5
+ import * as FEAAS from '@sitecore-feaas/clientside/react';
6
+ export declare const BYOC_COMPONENT_RENDERING_NAME = "BYOCComponent";
7
+ /**
8
+ * FEaaS props for server rendering.
9
+ */
10
+ type BYOCServerProps = {
11
+ /**
12
+ * Fetched data from server component props for server rendering, based on rendering params.
13
+ */
14
+ fetchedData?: FEAAS.DataScopes;
15
+ };
16
+ /**
17
+ * Data from rendering params on Sitecore's BYOC rendering
18
+ */
19
+ export type BYOCComponentParams = {
20
+ /**
21
+ * Name of the component to render
22
+ */
23
+ ComponentName?: string;
24
+ /**
25
+ * JSON props to pass into rendered component
26
+ */
27
+ ComponentProps?: string;
28
+ /**
29
+ * A JSON object with data sources to be fetched and passed to the component
30
+ */
31
+ ComponentDataOverride?: string;
32
+ /**
33
+ * A string with classes that can be used to apply themes, via SXA functionality
34
+ */
35
+ styles?: string;
36
+ RenderingIdentifier?: string;
37
+ };
38
+ /**
39
+ * Props for BYOCComponent. Includes components list to load external components from.
40
+ */
41
+ export type BYOCComponentClientProps = {
42
+ /**
43
+ * rendering params
44
+ */
45
+ params?: BYOCComponentParams;
46
+ /**
47
+ * fields from datasource items to be passed as rendered child component props
48
+ */
49
+ fields?: ComponentFields;
50
+ /**
51
+ * Error component override. To be shown when Renderer or underlying component throws
52
+ */
53
+ errorComponent?: React.ComponentClass<ErrorComponentProps> | React.FC<ErrorComponentProps>;
54
+ /**
55
+ * Override to indicate missing component situations. Would be shown when BYOC component is not registered
56
+ * or ComponentName is missing
57
+ */
58
+ missingComponentComponent?: React.ComponentClass<MissingComponentProps> | React.FC<MissingComponentProps>;
59
+ };
60
+ export type BYOCComponentProps = BYOCComponentClientProps & BYOCServerProps;
61
+ type ErrorComponentProps = {
62
+ [prop: string]: unknown;
63
+ error?: Error;
64
+ };
65
+ /**
66
+ * BYOCComponent facilitate the rendering of external components. It manages potential errors,
67
+ * missing components, and customization of error messages or alternative rendering components.
68
+ * @param {ByocComponentProps} props component props
69
+ * @returns dynamicly rendered component or Missing Component error frame
70
+ */
71
+ export declare class BYOCComponent extends React.Component<BYOCComponentProps> {
72
+ state: Readonly<{
73
+ error?: Error;
74
+ }>;
75
+ constructor(props: BYOCComponentProps);
76
+ static getDerivedStateFromError(error: Error): {
77
+ error: Error;
78
+ };
79
+ componentDidCatch(error: Error): void;
80
+ render(): React.JSX.Element;
81
+ }
82
+ /**
83
+ * Fetches server component props required for server rendering, based on rendering params.
84
+ * @param {BYOCComponentParams} params component params
85
+ */
86
+ export declare function fetchBYOCComponentServerProps(params: BYOCComponentParams): Promise<BYOCComponentProps>;
87
+ export {};
@@ -0,0 +1,3 @@
1
+ import { BYOCComponentProps } from './BYOCComponent';
2
+ export declare const BYOC_WRAPPER_RENDERING_NAME = "BYOCWrapper";
3
+ export declare const BYOCWrapper: (props: BYOCComponentProps) => JSX.Element;
@@ -1,3 +1,4 @@
1
+ /// <reference types="@types/react" />
1
2
  import React from 'react';
2
3
  export interface DateFieldProps {
3
4
  /** The date field data. */
@@ -1,3 +1,4 @@
1
+ /// <reference types="@types/react" />
1
2
  import React, { PropsWithChildren } from 'react';
2
3
  import { EditFrameDataSource, EditButtonTypes } from '@sitecore-jss/sitecore-jss/utils';
3
4
  export interface EditFrameProps {
@@ -1,18 +1,71 @@
1
- import { ComponentParams, ComponentFields } from '@sitecore-jss/sitecore-jss/layout';
1
+ import * as FEAAS from '@sitecore-feaas/clientside/react';
2
+ import { ComponentFields, LayoutServicePageState } from '@sitecore-jss/sitecore-jss/layout';
2
3
  export declare const FEAAS_COMPONENT_RENDERING_NAME = "FEaaSComponent";
3
- export declare const FEAAS_MODULE_SRC = "https://feaasstatic.blob.core.windows.net/packages/clientside/latest/browser/index.esm.js";
4
- export type FEaaSComponentParams = ComponentParams & {
4
+ /**
5
+ * Params from a Sitecore FEaaS rendering
6
+ */
7
+ export type FEaaSComponentParams = {
5
8
  LibraryId?: string;
6
9
  ComponentId?: string;
7
10
  ComponentVersion?: string;
8
- ComponentRevision?: string;
11
+ ComponentRevision?: RevisionType;
9
12
  ComponentHostName?: string;
10
13
  ComponentInstanceId?: string;
11
14
  ComponentDataOverride?: string;
12
15
  ComponentHTMLOverride?: string;
16
+ styles?: string;
17
+ RenderingIdentifier?: string;
13
18
  };
14
- export type FEaaSComponentProps = {
19
+ type RevisionType = number | 'staged' | 'published' | 'saved';
20
+ /**
21
+ * FEaaS props for server rendering.
22
+ */
23
+ type FEaaSComponentServerProps = {
24
+ /**
25
+ * HTML template for presentation rendered inside the component
26
+ */
27
+ template?: string;
28
+ /**
29
+ * Default revision to be fetched. Should be 'staged' for editing/preview. Can be overriden by params.ComponentRevision
30
+ */
31
+ revisionFallback?: RevisionType;
32
+ /**
33
+ * Fetched data from server component props for server rendering, based on rendering params.
34
+ */
35
+ fetchedData?: FEAAS.DataScopes;
36
+ };
37
+ /**
38
+ * FEaaS props for client side component. Should be used as fallback when server props are not provided.
39
+ * Would also be passed on server to avoid hydration issues
40
+ */
41
+ type FEaaSComponentClientProps = {
42
+ /**
43
+ * parameters from Sitecore's FEAAS component
44
+ */
15
45
  params?: FEaaSComponentParams;
46
+ /**
47
+ * field data from component's datasource
48
+ */
16
49
  fields?: ComponentFields;
17
50
  };
18
- export declare const FEaaSComponent: ({ params, fields }: FEaaSComponentProps) => JSX.Element;
51
+ export type FEaaSComponentProps = FEaaSComponentServerProps & FEaaSComponentClientProps;
52
+ /**
53
+ * @param {FEaaSComponentProps} props component props
54
+ */
55
+ export declare const FEaaSComponent: (props: FEaaSComponentProps) => JSX.Element;
56
+ /**
57
+ * Fetches server component props required for server rendering, based on rendering params.
58
+ * Component endpoint will either be retrieved from params or from endpointOverride
59
+ * @param {FEaaSComponentParams} params component params
60
+ * @param {LayoutServicePageState} [pageState] page state to determine which component variant to use
61
+ * @param {string} [endpointOverride] optional override for component endpoint
62
+ */
63
+ export declare function fetchFEaaSComponentServerProps(params: FEaaSComponentParams, pageState?: LayoutServicePageState, endpointOverride?: string): Promise<FEaaSComponentProps>;
64
+ /**
65
+ * Build component endpoint URL from component's params
66
+ * @param {FEaaSComponentParams} params rendering parameters for FEAAS component
67
+ * @param {RevisionType} revisionFallback fallback revision to fetch if revision is absent in params
68
+ * @returns component endpoint URL
69
+ */
70
+ export declare const composeComponentEndpoint: (params: FEaaSComponentParams, revisionFallback: RevisionType) => string;
71
+ export {};
@@ -0,0 +1,3 @@
1
+ import { FEaaSComponentProps } from './FEaaSComponent';
2
+ export declare const FEAAS_WRAPPER_RENDERING_NAME = "FEaaSWrapper";
3
+ export declare const FEaaSWrapper: (props: FEaaSComponentProps) => JSX.Element;
@@ -1,3 +1,4 @@
1
+ /// <reference types="@types/react" />
1
2
  import React from 'react';
2
3
  export interface FileFieldValue {
3
4
  [propName: string]: unknown;
@@ -1,2 +1,4 @@
1
- export declare const HiddenRendering: () => JSX.Element;
1
+ /// <reference types="@types/react" />
2
+ import React from 'react';
3
+ export declare const HiddenRendering: () => React.JSX.Element;
2
4
  export declare const HIDDEN_RENDERING_NAME = "Hidden Rendering";
@@ -1,3 +1,4 @@
1
+ /// <reference types="@types/react" />
1
2
  import React from 'react';
2
3
  export interface ImageFieldValue {
3
4
  [attributeName: string]: unknown;
@@ -26,11 +27,6 @@ export interface ImageSizeParameters {
26
27
  }
27
28
  export interface ImageProps {
28
29
  [attributeName: string]: unknown;
29
- /**
30
- * The image field data.
31
- * @deprecated use field property instead
32
- */
33
- media?: ImageField | ImageFieldValue;
34
30
  /** Image field data (consistent with other field types) */
35
31
  field?: ImageField | ImageFieldValue;
36
32
  /**
@@ -62,5 +58,5 @@ export interface ImageProps {
62
58
  * @param {ImageProps} otherProps {ImageProps} all other props included on the image component
63
59
  * @returns Experience Editor Markup
64
60
  */
65
- export declare const getEEMarkup: (imageField: ImageField, imageParams?: ImageProps['imageParams'], mediaUrlPrefix?: RegExp, otherProps?: ImageProps) => JSX.Element;
61
+ export declare const getEEMarkup: (imageField: ImageField, imageParams?: ImageProps['imageParams'], mediaUrlPrefix?: RegExp, otherProps?: ImageProps) => React.JSX.Element;
66
62
  export declare const Image: React.FC<ImageProps>;
@@ -1,3 +1,4 @@
1
+ /// <reference types="@types/react" />
1
2
  import React from 'react';
2
3
  import PropTypes from 'prop-types';
3
4
  export interface LinkFieldValue {
@@ -32,7 +33,7 @@ export type LinkProps = React.DetailedHTMLProps<React.AnchorHTMLAttributes<HTMLA
32
33
  */
33
34
  showLinkTextWithChildrenPresent?: boolean;
34
35
  };
35
- export declare const Link: React.ForwardRefExoticComponent<Pick<LinkProps, "key" | "editable" | "field" | "showLinkTextWithChildrenPresent" | keyof React.AnchorHTMLAttributes<HTMLAnchorElement>> & React.RefAttributes<HTMLAnchorElement>>;
36
+ export declare const Link: React.ForwardRefExoticComponent<Omit<LinkProps, "ref"> & React.RefAttributes<HTMLAnchorElement>>;
36
37
  export declare const LinkPropTypes: {
37
38
  field: PropTypes.Validator<NonNullable<NonNullable<PropTypes.InferProps<{
38
39
  href: PropTypes.Requireable<any>;
@@ -1,7 +1,9 @@
1
+ /// <reference types="@types/react" />
1
2
  import React from 'react';
2
3
  export interface MissingComponentProps {
3
4
  rendering?: {
4
5
  componentName?: string;
5
6
  };
7
+ errorOverride?: string;
6
8
  }
7
9
  export declare const MissingComponent: React.FC<MissingComponentProps>;
@@ -1,3 +1,4 @@
1
+ /// <reference types="@types/react" />
1
2
  import React from 'react';
2
3
  import { PlaceholderProps } from './PlaceholderCommon';
3
4
  import { ComponentRendering, HtmlElementRendering } from '@sitecore-jss/sitecore-jss/layout';
@@ -1,3 +1,4 @@
1
+ /// <reference types="@types/react" />
1
2
  import React, { ComponentType } from 'react';
2
3
  import PropTypes from 'prop-types';
3
4
  import { ComponentFactory } from './sharedTypes';
@@ -1,3 +1,4 @@
1
+ /// <reference types="@types/react" />
1
2
  import React from 'react';
2
3
  import PropTypes from 'prop-types';
3
4
  export interface RichTextField {
@@ -1,3 +1,4 @@
1
+ /// <reference types="@types/react" />
1
2
  import React from 'react';
2
3
  import PropTypes from 'prop-types';
3
4
  import { ComponentFactory } from './sharedTypes';
@@ -38,5 +39,5 @@ export declare class SitecoreContext extends React.Component<SitecoreContextProp
38
39
  * @param {SitecoreContextValue | LayoutServiceData} value New context value
39
40
  */
40
41
  setContext: (value: SitecoreContextValue | LayoutServiceData) => void;
41
- render(): JSX.Element;
42
+ render(): React.JSX.Element;
42
43
  }
@@ -1,3 +1,4 @@
1
+ /// <reference types="@types/react" />
1
2
  import { FunctionComponent } from 'react';
2
3
  export interface TextField {
3
4
  value?: string | number;
@@ -1,3 +1,4 @@
1
+ /// <reference types="@types/react" />
1
2
  import React from 'react';
2
3
  interface VisitorIdentificationProps {
3
4
  defer?: boolean;
@@ -1,3 +1,4 @@
1
+ /// <reference types="@types/react" />
1
2
  import { ComponentType } from 'react';
2
3
  /**
3
4
  * @param {string} componentName component to be imported from the component factory
@@ -1,3 +1,4 @@
1
+ /// <reference types="@types/react" />
1
2
  import React from 'react';
2
3
  import { ComponentFactory } from '../components/sharedTypes';
3
4
  export interface ComponentFactoryProps {
@@ -1,3 +1,4 @@
1
+ /// <reference types="@types/react" />
1
2
  import React from 'react';
2
3
  import { ComponentRendering } from '@sitecore-jss/sitecore-jss/layout';
3
4
  export declare const DefaultEditingError: () => JSX.Element;
@@ -18,4 +19,4 @@ export interface WithDatasourceCheckOptions {
18
19
  * The wrapped component, if a datasource is present.
19
20
  * A null component (in normal mode) or an error component (in editing mode), if a datasource is not present.
20
21
  */
21
- export declare function withDatasourceCheck(options?: WithDatasourceCheckOptions): <ComponentProps extends WithDatasourceCheckProps>(Component: React.ComponentType<ComponentProps>) => (props: ComponentProps) => JSX.Element;
22
+ export declare function withDatasourceCheck(options?: WithDatasourceCheckOptions): <ComponentProps extends WithDatasourceCheckProps>(Component: React.ComponentType<ComponentProps>) => (props: ComponentProps) => React.JSX.Element;
@@ -1,2 +1,3 @@
1
+ /// <reference types="@types/react" />
1
2
  import React from 'react';
2
3
  export declare const withEditorChromes: (WrappedComponent: React.ComponentClass<unknown> | React.FC<unknown>) => React.ComponentClass<{}, any>;
@@ -1,3 +1,4 @@
1
+ /// <reference types="@types/react" />
1
2
  import React, { ReactNode } from 'react';
2
3
  import { SitecoreContextValue } from '../components/SitecoreContext';
3
4
  export interface WithSitecoreContextOptions {
@@ -14,7 +15,7 @@ export type WithSitecoreContextHocProps<ComponentProps> = Pick<ComponentProps, E
14
15
  /**
15
16
  * @param {WithSitecoreContextOptions} [options]
16
17
  */
17
- export declare function withSitecoreContext(options?: WithSitecoreContextOptions): <ComponentProps extends ComponentConsumerProps>(Component: React.ComponentType<ComponentProps>) => (props: WithSitecoreContextHocProps<ComponentProps>) => JSX.Element;
18
+ export declare function withSitecoreContext(options?: WithSitecoreContextOptions): <ComponentProps extends ComponentConsumerProps>(Component: React.ComponentType<ComponentProps>) => (props: WithSitecoreContextHocProps<ComponentProps>) => React.JSX.Element;
18
19
  /**
19
20
  * This hook grants acсess to the current Sitecore page context
20
21
  * by default JSS includes the following properties in this context:
package/types/index.d.ts CHANGED
@@ -1,17 +1,20 @@
1
- export { constants, enableDebug } from '@sitecore-jss/sitecore-jss';
1
+ export { constants, enableDebug, ClientError } from '@sitecore-jss/sitecore-jss';
2
2
  export { isEditorActive, resetEditorChromes, DefaultEditFrameButton, DefaultEditFrameButtons, EditFrameDataSource, FieldEditButton, WebEditButton, EditButtonTypes, } from '@sitecore-jss/sitecore-jss/utils';
3
- export { LayoutService, LayoutServiceData, LayoutServicePageState, LayoutServiceContext, LayoutServiceContextData, GraphQLLayoutService, RestLayoutService, RouteData, Field, Item, HtmlElementRendering, getChildPlaceholder, getFieldValue, ComponentRendering, ComponentFields, ComponentParams, } from '@sitecore-jss/sitecore-jss/layout';
3
+ export { getContentStylesheetLink, getComponentLibraryStylesheetLinks, LayoutService, LayoutServiceData, LayoutServicePageState, LayoutServiceContext, LayoutServiceContextData, GraphQLLayoutService, RestLayoutService, RouteData, Field, Item, HtmlElementRendering, getChildPlaceholder, getFieldValue, ComponentRendering, ComponentFields, ComponentParams, } from '@sitecore-jss/sitecore-jss/layout';
4
4
  export { trackingApi, TrackingRequestOptions, CampaignInstance, GoalInstance, OutcomeInstance, EventInstance, PageViewInstance, } from '@sitecore-jss/sitecore-jss/tracking';
5
5
  export { DictionaryPhrases, DictionaryService, GraphQLDictionaryService, RestDictionaryService, } from '@sitecore-jss/sitecore-jss/i18n';
6
+ export { GraphQLClientError, RetryStrategy, DefaultRetryStrategy, GraphQLRequestClientFactoryConfig, GraphQLRequestClient, } from '@sitecore-jss/sitecore-jss/graphql';
6
7
  export { mediaApi } from '@sitecore-jss/sitecore-jss/media';
7
- export { getFEAASLibraryStylesheetLinks } from '@sitecore-jss/sitecore-jss/feaas';
8
8
  export { ComponentFactory } from './components/sharedTypes';
9
9
  export { Placeholder, PlaceholderComponentProps } from './components/Placeholder';
10
10
  export { Image, ImageProps, ImageField, getEEMarkup, ImageFieldValue, ImageSizeParameters, } from './components/Image';
11
11
  export { RichText, RichTextProps, RichTextPropTypes, RichTextField } from './components/RichText';
12
12
  export { Text, TextField } from './components/Text';
13
13
  export { DateField, DateFieldProps } from './components/Date';
14
- export { FEaaSComponent, FEaaSComponentProps } from './components/FEaaSComponent';
14
+ export { FEaaSComponent, FEaaSComponentProps, FEaaSComponentParams, fetchFEaaSComponentServerProps, } from './components/FEaaSComponent';
15
+ export { FEaaSWrapper } from './components/FEaaSWrapper';
16
+ export { BYOCComponent, BYOCComponentParams, BYOCComponentProps, fetchBYOCComponentServerProps, } from './components/BYOCComponent';
17
+ export { BYOCWrapper } from './components/BYOCWrapper';
15
18
  export { Link, LinkField, LinkFieldValue, LinkProps, LinkPropTypes } from './components/Link';
16
19
  export { File, FileField } from './components/File';
17
20
  export { VisitorIdentification } from './components/VisitorIdentification';
@@ -21,3 +24,4 @@ export { withEditorChromes } from './enhancers/withEditorChromes';
21
24
  export { withPlaceholder } from './enhancers/withPlaceholder';
22
25
  export { withDatasourceCheck } from './enhancers/withDatasourceCheck';
23
26
  export { EditFrameProps, EditFrame } from './components/EditFrame';
27
+ export { ComponentBuilder, ComponentBuilderConfig } from './ComponentBuilder';
package/types/utils.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import { ComponentFields } from '@sitecore-jss/sitecore-jss/layout';
1
2
  export declare const convertKebabCasetoCamelCase: (str: string) => string;
2
3
  /**
3
4
  * https://facebook.github.io/react/docs/dom-elements.html
@@ -18,8 +19,24 @@ export declare const convertAttributesToReactProps: (attributes: {
18
19
  /**
19
20
  * "class" property will be transformed into or appended to "className" instead.
20
21
  * @param {string} otherAttrs all other props included on the image component
21
- * * @returns {void}
22
+ * @returns {void}
22
23
  */
23
24
  export declare const addClassName: (otherAttrs: {
24
25
  [key: string]: unknown;
25
26
  }) => void;
27
+ /**
28
+ * Converts the given tag attributes object to a string
29
+ * @param {Object.<string, unknown>} attributes the attributes object
30
+ * @returns {string} string representation of the attributes
31
+ */
32
+ export declare const getAttributesString: (attributes: {
33
+ [key: string]: unknown;
34
+ }) => string;
35
+ /**
36
+ * Used in FEAAS and BYOC implementations to convert datasource item field values into component props
37
+ * @param {ComponentFields} fields field collection from Sitecore
38
+ * @returns JSON object that can be used as props
39
+ */
40
+ export declare const getDataFromFields: (fields: ComponentFields) => {
41
+ [key: string]: unknown;
42
+ };