@sitecore-content-sdk/react 1.0.0-canary.8 → 1.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.
- package/LICENSE.txt +202 -202
- package/README.md +11 -11
- package/dist/cjs/components/DesignLibrary.js +65 -7
- package/dist/cjs/components/EditingScripts.js +7 -10
- package/dist/cjs/components/ErrorBoundary.js +1 -5
- package/dist/cjs/components/Form.js +1 -1
- package/dist/cjs/components/Placeholder.js +2 -3
- package/dist/cjs/components/PlaceholderCommon.js +4 -5
- package/dist/cjs/components/SitecoreProvider.js +9 -21
- package/dist/cjs/enhancers/withDatasourceCheck.js +3 -4
- package/dist/cjs/enhancers/withPlaceholder.js +2 -2
- package/dist/cjs/enhancers/withSitecore.js +10 -14
- package/dist/cjs/index.js +2 -1
- package/dist/esm/components/DesignLibrary.js +59 -3
- package/dist/esm/components/EditingScripts.js +7 -10
- package/dist/esm/components/ErrorBoundary.js +1 -5
- package/dist/esm/components/Form.js +1 -1
- package/dist/esm/components/Placeholder.js +2 -3
- package/dist/esm/components/PlaceholderCommon.js +4 -5
- package/dist/esm/components/SitecoreProvider.js +9 -21
- package/dist/esm/enhancers/withDatasourceCheck.js +3 -4
- package/dist/esm/enhancers/withPlaceholder.js +2 -2
- package/dist/esm/enhancers/withSitecore.js +10 -14
- package/dist/esm/index.js +1 -1
- package/package.json +3 -3
- package/types/components/DesignLibrary.d.ts +7 -2
- package/types/components/EditingScripts.d.ts +1 -1
- package/types/components/ErrorBoundary.d.ts +2 -2
- package/types/components/PlaceholderCommon.d.ts +3 -3
- package/types/components/SitecoreProvider.d.ts +11 -20
- package/types/enhancers/withSitecore.d.ts +13 -16
- package/types/index.d.ts +2 -2
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React, { ComponentType } from 'react';
|
|
2
2
|
import { ComponentMap } from './sharedTypes';
|
|
3
3
|
import { ComponentRendering, RouteData, Field, Item } from '@sitecore-content-sdk/core/layout';
|
|
4
|
-
import {
|
|
4
|
+
import { Page } from '@sitecore-content-sdk/core/client';
|
|
5
5
|
type ErrorComponentProps = {
|
|
6
6
|
[prop: string]: unknown;
|
|
7
7
|
};
|
|
@@ -57,10 +57,10 @@ export interface PlaceholderProps {
|
|
|
57
57
|
*/
|
|
58
58
|
errorComponent?: React.ComponentClass<ErrorComponentProps> | React.FC<ErrorComponentProps>;
|
|
59
59
|
/**
|
|
60
|
-
* Page
|
|
60
|
+
* Page data.
|
|
61
61
|
* This data is passed by the SitecoreProvider.
|
|
62
62
|
*/
|
|
63
|
-
|
|
63
|
+
page: Page;
|
|
64
64
|
/**
|
|
65
65
|
* The message that gets displayed while component is loading
|
|
66
66
|
*/
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import { Page } from '@sitecore-content-sdk/core/client';
|
|
2
3
|
import { SitecoreConfig } from '@sitecore-content-sdk/core/config';
|
|
3
|
-
import { LayoutServiceContext, LayoutServiceData, RouteData } from '../index';
|
|
4
4
|
import { ComponentMap } from './sharedTypes';
|
|
5
5
|
export interface SitecoreProviderProps {
|
|
6
6
|
/**
|
|
@@ -12,22 +12,22 @@ export interface SitecoreProviderProps {
|
|
|
12
12
|
*/
|
|
13
13
|
componentMap: ComponentMap;
|
|
14
14
|
/**
|
|
15
|
-
* The
|
|
15
|
+
* The page data.
|
|
16
16
|
*/
|
|
17
|
-
|
|
17
|
+
page: Page;
|
|
18
18
|
children: React.ReactNode;
|
|
19
19
|
}
|
|
20
20
|
export interface SitecoreProviderState {
|
|
21
21
|
/**
|
|
22
|
-
* Method to set the page
|
|
23
|
-
* @param {
|
|
22
|
+
* Method to set the page.
|
|
23
|
+
* @param {Page} value New page value.
|
|
24
24
|
* @returns {void}
|
|
25
25
|
*/
|
|
26
|
-
|
|
26
|
+
setPage: (value: Page) => void;
|
|
27
27
|
/**
|
|
28
|
-
* The current page
|
|
28
|
+
* The current page.
|
|
29
29
|
*/
|
|
30
|
-
|
|
30
|
+
page: Page;
|
|
31
31
|
/**
|
|
32
32
|
* The API configuration defined in the `SitecoreConfig`.
|
|
33
33
|
*/
|
|
@@ -35,23 +35,14 @@ export interface SitecoreProviderState {
|
|
|
35
35
|
}
|
|
36
36
|
export declare const SitecoreProviderReactContext: React.Context<SitecoreProviderState>;
|
|
37
37
|
export declare const ComponentMapReactContext: React.Context<ComponentMap>;
|
|
38
|
-
/**
|
|
39
|
-
* The page context provided by the SitecoreProvider.
|
|
40
|
-
*/
|
|
41
|
-
export type SitecoreProviderPageContext = LayoutServiceContext & {
|
|
42
|
-
itemId?: string;
|
|
43
|
-
route?: RouteData;
|
|
44
|
-
};
|
|
45
38
|
export declare class SitecoreProvider extends React.Component<SitecoreProviderProps, SitecoreProviderState> {
|
|
46
39
|
static displayName: string;
|
|
47
40
|
constructor(props: SitecoreProviderProps);
|
|
48
|
-
constructContext(layoutData?: LayoutServiceData): SitecoreProviderPageContext;
|
|
49
41
|
componentDidUpdate(prevProps: SitecoreProviderProps): void;
|
|
50
42
|
/**
|
|
51
|
-
* Update
|
|
52
|
-
*
|
|
53
|
-
* @param {SitecoreProviderPageContext | LayoutServiceData} value New context value
|
|
43
|
+
* Update page state.
|
|
44
|
+
* @param {Page} value New page value
|
|
54
45
|
*/
|
|
55
|
-
|
|
46
|
+
setPage: (value: Page) => void;
|
|
56
47
|
render(): React.JSX.Element;
|
|
57
48
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { EnhancedOmit } from '@sitecore-content-sdk/core/utils';
|
|
3
|
-
import { SitecoreProviderState
|
|
3
|
+
import { SitecoreProviderState } from '../components/SitecoreProvider';
|
|
4
|
+
import { Page } from '@sitecore-content-sdk/core/client';
|
|
4
5
|
export interface WithSitecoreOptions {
|
|
5
6
|
/**
|
|
6
7
|
* If set to true, the `updateContext` method will be injected into the component props.
|
|
@@ -11,17 +12,17 @@ export interface WithSitecoreProps {
|
|
|
11
12
|
/**
|
|
12
13
|
* The current page context.
|
|
13
14
|
*/
|
|
14
|
-
|
|
15
|
+
page: Page;
|
|
15
16
|
/**
|
|
16
17
|
* The API configuration defined in the `SitecoreConfig`.
|
|
17
18
|
*/
|
|
18
19
|
api?: SitecoreProviderState['api'];
|
|
19
20
|
/**
|
|
20
|
-
* Method to update the page
|
|
21
|
-
* @param {
|
|
21
|
+
* Method to update the page. This is only available if `updatable` is set to true.
|
|
22
|
+
* @param {Page} value New page value.
|
|
22
23
|
* @returns {void}
|
|
23
24
|
*/
|
|
24
|
-
|
|
25
|
+
updatePage?: ((value: Page) => void) | false;
|
|
25
26
|
}
|
|
26
27
|
export type WithSitecoreHocProps<ComponentProps> = EnhancedOmit<ComponentProps, keyof WithSitecoreProps>;
|
|
27
28
|
/**
|
|
@@ -29,23 +30,19 @@ export type WithSitecoreHocProps<ComponentProps> = EnhancedOmit<ComponentProps,
|
|
|
29
30
|
*/
|
|
30
31
|
export declare function withSitecore(options?: WithSitecoreOptions): <ComponentProps extends WithSitecoreProps>(Component: React.ComponentType<ComponentProps>) => (props: WithSitecoreHocProps<ComponentProps>) => React.JSX.Element;
|
|
31
32
|
/**
|
|
32
|
-
* This hook grants acсess to the current Sitecore page
|
|
33
|
-
* by default Content SDK includes the following properties in this context:
|
|
34
|
-
* - pageEditing - Provided by Layout Service, a boolean indicating whether the route is being accessed via the Sitecore Editor.
|
|
35
|
-
* - pageState - Like pageEditing, but a string: normal, preview or edit.
|
|
36
|
-
* - site - Provided by Layout Service, an object containing the name of the current Sitecore site context.
|
|
33
|
+
* This hook grants acсess to the current Sitecore page and api.
|
|
37
34
|
* @param {WithSitecoreOptions} [options] hook options
|
|
38
35
|
* @example
|
|
39
36
|
* const EditMode = () => {
|
|
40
|
-
* const {
|
|
41
|
-
* return <span>Edit Mode is {
|
|
37
|
+
* const { page } = useSitecore();
|
|
38
|
+
* return <span>Edit Mode is {page.mode.isEditing ? 'active' : 'inactive'}</span>
|
|
42
39
|
* }
|
|
43
40
|
* @example
|
|
44
41
|
* const EditMode = () => {
|
|
45
|
-
* const {
|
|
46
|
-
* const onClick = () =>
|
|
47
|
-
* return <span onClick={onClick}>
|
|
42
|
+
* const { page, updatePage } = useSitecore({ updatable: true });
|
|
43
|
+
* const onClick = () => updatePage({ itemId: '123' });
|
|
44
|
+
* return <span onClick={onClick}>Item id is {page.itemId}</span>
|
|
48
45
|
* }
|
|
49
|
-
* @returns {object} { api,
|
|
46
|
+
* @returns {object} { api, page, updatePage }
|
|
50
47
|
*/
|
|
51
48
|
export declare function useSitecore(options?: WithSitecoreOptions): WithSitecoreProps;
|
package/types/index.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ export { EnhancedOmit } from '@sitecore-content-sdk/core/utils';
|
|
|
3
3
|
export { isEditorActive, resetEditorChromes } from '@sitecore-content-sdk/core/editing';
|
|
4
4
|
export { getContentStylesheetLink, getDesignLibraryStylesheetLinks, LayoutServiceData, LayoutServicePageState, LayoutServiceContext, LayoutServiceContextData, LayoutService, RouteData, Field, Item, getChildPlaceholder, getFieldValue, ComponentRendering, ComponentFields, ComponentParams, EditMode, } from '@sitecore-content-sdk/core/layout';
|
|
5
5
|
export { DictionaryPhrases, DictionaryService } from '@sitecore-content-sdk/core/i18n';
|
|
6
|
-
export { GraphQLClientError, RetryStrategy, DefaultRetryStrategy, GraphQLRequestClientFactoryConfig, GraphQLRequestClient, } from '@sitecore-content-sdk/core/client';
|
|
6
|
+
export { GraphQLClientError, RetryStrategy, DefaultRetryStrategy, GraphQLRequestClientFactoryConfig, GraphQLRequestClient, PageMode, ErrorPage, Page, } from '@sitecore-content-sdk/core/client';
|
|
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';
|
|
@@ -19,7 +19,7 @@ export { BYOCComponent, BYOCComponentParams, BYOCComponentProps, fetchBYOCCompon
|
|
|
19
19
|
export { BYOCWrapper } from './components/BYOCWrapper';
|
|
20
20
|
export { Link, LinkField, LinkFieldValue, LinkProps } from './components/Link';
|
|
21
21
|
export { File, FileField } from './components/File';
|
|
22
|
-
export { SitecoreProvider, SitecoreProviderState,
|
|
22
|
+
export { SitecoreProvider, SitecoreProviderState, SitecoreProviderReactContext, } from './components/SitecoreProvider';
|
|
23
23
|
export { withSitecore, useSitecore, WithSitecoreOptions, WithSitecoreProps, WithSitecoreHocProps, } from './enhancers/withSitecore';
|
|
24
24
|
export { withEditorChromes } from './enhancers/withEditorChromes';
|
|
25
25
|
export { withPlaceholder } from './enhancers/withPlaceholder';
|