@prismicio/react 2.5.1 → 2.5.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/PrismicImage.d.ts +163 -163
- package/dist/PrismicLink.cjs +1 -1
- package/dist/PrismicLink.cjs.map +1 -1
- package/dist/PrismicLink.d.ts +105 -105
- package/dist/PrismicLink.js +1 -1
- package/dist/PrismicLink.js.map +1 -1
- package/dist/PrismicProvider.d.ts +84 -84
- package/dist/PrismicRichText.d.ts +116 -116
- package/dist/PrismicText.d.ts +39 -39
- package/dist/PrismicToolbar.d.ts +21 -21
- package/dist/SliceZone.d.ts +188 -188
- package/dist/clientHooks.d.ts +357 -357
- package/dist/index.d.ts +46 -46
- package/dist/lib/__PRODUCTION__.d.ts +7 -7
- package/dist/lib/devMsg.d.ts +16 -16
- package/dist/lib/invariant.d.ts +24 -24
- package/dist/lib/isInternalURL.d.ts +8 -8
- package/dist/lib/pascalCase.d.ts +26 -26
- package/dist/package.json.cjs +1 -1
- package/dist/package.json.js +1 -1
- package/dist/types.d.ts +19 -19
- package/dist/usePrismicClient.d.ts +11 -11
- package/dist/usePrismicContext.d.ts +8 -8
- package/dist/usePrismicPreviewResolver.d.ts +45 -45
- package/dist/useStatefulPrismicClientMethod.d.ts +44 -44
- package/package.json +1 -1
- package/src/PrismicLink.tsx +0 -1
|
@@ -1,116 +1,116 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
|
-
import * as prismicT from "@prismicio/types";
|
|
3
|
-
import * as prismicH from "@prismicio/helpers";
|
|
4
|
-
import { JSXFunctionSerializer, JSXMapSerializer } from "./types";
|
|
5
|
-
import { PrismicLinkProps } from "./PrismicLink";
|
|
6
|
-
/**
|
|
7
|
-
* Props for `<PrismicRichText>`.
|
|
8
|
-
*/
|
|
9
|
-
export type PrismicRichTextProps<LinkResolverFunction extends prismicH.LinkResolverFunction<any> = prismicH.LinkResolverFunction> = {
|
|
10
|
-
/**
|
|
11
|
-
* The Prismic Rich Text field to render.
|
|
12
|
-
*/
|
|
13
|
-
field: prismicT.RichTextField | null | undefined;
|
|
14
|
-
/**
|
|
15
|
-
* The Link Resolver used to resolve links.
|
|
16
|
-
*
|
|
17
|
-
* @remarks
|
|
18
|
-
* If your app uses Route Resolvers when querying for your Prismic
|
|
19
|
-
* repository's content, a Link Resolver does not need to be provided.
|
|
20
|
-
* @see Learn about Link Resolvers and Route Resolvers {@link https://prismic.io/docs/core-concepts/link-resolver-route-resolver}
|
|
21
|
-
*/
|
|
22
|
-
linkResolver?: LinkResolverFunction;
|
|
23
|
-
/**
|
|
24
|
-
* A function that maps a Rich Text block to a React component.
|
|
25
|
-
*
|
|
26
|
-
* @deprecated Use the `components` prop instead. Prefer using a map
|
|
27
|
-
* serializer when possible.
|
|
28
|
-
* @see Learn about Rich Text serializers {@link https://prismic.io/docs/core-concepts/html-serializer}
|
|
29
|
-
*/
|
|
30
|
-
htmlSerializer?: JSXFunctionSerializer;
|
|
31
|
-
/**
|
|
32
|
-
* A map or function that maps a Rich Text block to a React component.
|
|
33
|
-
*
|
|
34
|
-
* @remarks
|
|
35
|
-
* Prefer using a map serializer over the function serializer when possible.
|
|
36
|
-
* The map serializer is simpler to maintain.
|
|
37
|
-
* @example A map serializer.
|
|
38
|
-
*
|
|
39
|
-
* ```jsx
|
|
40
|
-
* {
|
|
41
|
-
* heading1: ({children}) => <Heading>{children}</Heading>
|
|
42
|
-
* }
|
|
43
|
-
* ```
|
|
44
|
-
*
|
|
45
|
-
* @example A function serializer.
|
|
46
|
-
*
|
|
47
|
-
* ```jsx
|
|
48
|
-
* (type, node, content, children) => {
|
|
49
|
-
* switch (type) {
|
|
50
|
-
* case "heading1": {
|
|
51
|
-
* return <Heading>{children}</Heading>;
|
|
52
|
-
* }
|
|
53
|
-
* }
|
|
54
|
-
* };
|
|
55
|
-
* ```
|
|
56
|
-
*/
|
|
57
|
-
components?: JSXMapSerializer | JSXFunctionSerializer;
|
|
58
|
-
/**
|
|
59
|
-
* The React component rendered for links when the URL is internal.
|
|
60
|
-
*
|
|
61
|
-
* @defaultValue `<a>`
|
|
62
|
-
*/
|
|
63
|
-
internalLinkComponent?: PrismicLinkProps["internalComponent"];
|
|
64
|
-
/**
|
|
65
|
-
* The React component rendered for links when the URL is external.
|
|
66
|
-
*
|
|
67
|
-
* @defaultValue `<a>`
|
|
68
|
-
*/
|
|
69
|
-
externalLinkComponent?: PrismicLinkProps["externalComponent"];
|
|
70
|
-
/**
|
|
71
|
-
* The value to be rendered when the field is empty. If a fallback is not
|
|
72
|
-
* given, `null` will be rendered.
|
|
73
|
-
*/
|
|
74
|
-
fallback?: React.ReactNode;
|
|
75
|
-
};
|
|
76
|
-
/**
|
|
77
|
-
* React component that renders content from a Prismic Rich Text field. By
|
|
78
|
-
* default, HTML elements are rendered for each piece of content. A `heading1`
|
|
79
|
-
* block will render an `<h1>` HTML element, for example. Links will use
|
|
80
|
-
* `<PrismicLink>` by default which can be customized using the
|
|
81
|
-
* `internalLinkComponent` and `externalLinkComponent` props.
|
|
82
|
-
*
|
|
83
|
-
* To customize the components that are rendered, provide a map or function
|
|
84
|
-
* serializer to the `components` prop.
|
|
85
|
-
*
|
|
86
|
-
* Components can also be provided in a centralized location using the
|
|
87
|
-
* `<PrismicProvider>` React context provider.
|
|
88
|
-
*
|
|
89
|
-
* @remarks
|
|
90
|
-
* This component returns a React fragment with no wrapping element around the
|
|
91
|
-
* content. If you need a wrapper, add a component around `<PrismicRichText>`.
|
|
92
|
-
* @example Rendering a Rich Text field using the default HTMl elements.
|
|
93
|
-
*
|
|
94
|
-
* ```jsx
|
|
95
|
-
* <PrismicRichText field={document.data.content} />;
|
|
96
|
-
* ```
|
|
97
|
-
*
|
|
98
|
-
* @example Rendering a Rich Text field using a custom set of React components.
|
|
99
|
-
*
|
|
100
|
-
* ```jsx
|
|
101
|
-
* <PrismicRichText
|
|
102
|
-
* field={document.data.content}
|
|
103
|
-
* components={{
|
|
104
|
-
* heading1: ({ children }) => <Heading>{children}</Heading>,
|
|
105
|
-
* }}
|
|
106
|
-
* />;
|
|
107
|
-
* ```
|
|
108
|
-
*
|
|
109
|
-
* @param props - Props for the component.
|
|
110
|
-
*
|
|
111
|
-
* @returns The Rich Text field's content as React components.
|
|
112
|
-
*
|
|
113
|
-
* @see Learn about Rich Text fields {@link https://prismic.io/docs/core-concepts/rich-text-title}
|
|
114
|
-
* @see Learn about Rich Text serializers {@link https://prismic.io/docs/core-concepts/html-serializer}
|
|
115
|
-
*/
|
|
116
|
-
export declare const PrismicRichText: <LinkResolverFunction extends prismicH.LinkResolverFunction<any> = prismicH.LinkResolverFunction<string>>(props: PrismicRichTextProps<LinkResolverFunction>) => JSX.Element | null;
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import * as prismicT from "@prismicio/types";
|
|
3
|
+
import * as prismicH from "@prismicio/helpers";
|
|
4
|
+
import { JSXFunctionSerializer, JSXMapSerializer } from "./types";
|
|
5
|
+
import { PrismicLinkProps } from "./PrismicLink";
|
|
6
|
+
/**
|
|
7
|
+
* Props for `<PrismicRichText>`.
|
|
8
|
+
*/
|
|
9
|
+
export type PrismicRichTextProps<LinkResolverFunction extends prismicH.LinkResolverFunction<any> = prismicH.LinkResolverFunction> = {
|
|
10
|
+
/**
|
|
11
|
+
* The Prismic Rich Text field to render.
|
|
12
|
+
*/
|
|
13
|
+
field: prismicT.RichTextField | null | undefined;
|
|
14
|
+
/**
|
|
15
|
+
* The Link Resolver used to resolve links.
|
|
16
|
+
*
|
|
17
|
+
* @remarks
|
|
18
|
+
* If your app uses Route Resolvers when querying for your Prismic
|
|
19
|
+
* repository's content, a Link Resolver does not need to be provided.
|
|
20
|
+
* @see Learn about Link Resolvers and Route Resolvers {@link https://prismic.io/docs/core-concepts/link-resolver-route-resolver}
|
|
21
|
+
*/
|
|
22
|
+
linkResolver?: LinkResolverFunction;
|
|
23
|
+
/**
|
|
24
|
+
* A function that maps a Rich Text block to a React component.
|
|
25
|
+
*
|
|
26
|
+
* @deprecated Use the `components` prop instead. Prefer using a map
|
|
27
|
+
* serializer when possible.
|
|
28
|
+
* @see Learn about Rich Text serializers {@link https://prismic.io/docs/core-concepts/html-serializer}
|
|
29
|
+
*/
|
|
30
|
+
htmlSerializer?: JSXFunctionSerializer;
|
|
31
|
+
/**
|
|
32
|
+
* A map or function that maps a Rich Text block to a React component.
|
|
33
|
+
*
|
|
34
|
+
* @remarks
|
|
35
|
+
* Prefer using a map serializer over the function serializer when possible.
|
|
36
|
+
* The map serializer is simpler to maintain.
|
|
37
|
+
* @example A map serializer.
|
|
38
|
+
*
|
|
39
|
+
* ```jsx
|
|
40
|
+
* {
|
|
41
|
+
* heading1: ({children}) => <Heading>{children}</Heading>
|
|
42
|
+
* }
|
|
43
|
+
* ```
|
|
44
|
+
*
|
|
45
|
+
* @example A function serializer.
|
|
46
|
+
*
|
|
47
|
+
* ```jsx
|
|
48
|
+
* (type, node, content, children) => {
|
|
49
|
+
* switch (type) {
|
|
50
|
+
* case "heading1": {
|
|
51
|
+
* return <Heading>{children}</Heading>;
|
|
52
|
+
* }
|
|
53
|
+
* }
|
|
54
|
+
* };
|
|
55
|
+
* ```
|
|
56
|
+
*/
|
|
57
|
+
components?: JSXMapSerializer | JSXFunctionSerializer;
|
|
58
|
+
/**
|
|
59
|
+
* The React component rendered for links when the URL is internal.
|
|
60
|
+
*
|
|
61
|
+
* @defaultValue `<a>`
|
|
62
|
+
*/
|
|
63
|
+
internalLinkComponent?: PrismicLinkProps["internalComponent"];
|
|
64
|
+
/**
|
|
65
|
+
* The React component rendered for links when the URL is external.
|
|
66
|
+
*
|
|
67
|
+
* @defaultValue `<a>`
|
|
68
|
+
*/
|
|
69
|
+
externalLinkComponent?: PrismicLinkProps["externalComponent"];
|
|
70
|
+
/**
|
|
71
|
+
* The value to be rendered when the field is empty. If a fallback is not
|
|
72
|
+
* given, `null` will be rendered.
|
|
73
|
+
*/
|
|
74
|
+
fallback?: React.ReactNode;
|
|
75
|
+
};
|
|
76
|
+
/**
|
|
77
|
+
* React component that renders content from a Prismic Rich Text field. By
|
|
78
|
+
* default, HTML elements are rendered for each piece of content. A `heading1`
|
|
79
|
+
* block will render an `<h1>` HTML element, for example. Links will use
|
|
80
|
+
* `<PrismicLink>` by default which can be customized using the
|
|
81
|
+
* `internalLinkComponent` and `externalLinkComponent` props.
|
|
82
|
+
*
|
|
83
|
+
* To customize the components that are rendered, provide a map or function
|
|
84
|
+
* serializer to the `components` prop.
|
|
85
|
+
*
|
|
86
|
+
* Components can also be provided in a centralized location using the
|
|
87
|
+
* `<PrismicProvider>` React context provider.
|
|
88
|
+
*
|
|
89
|
+
* @remarks
|
|
90
|
+
* This component returns a React fragment with no wrapping element around the
|
|
91
|
+
* content. If you need a wrapper, add a component around `<PrismicRichText>`.
|
|
92
|
+
* @example Rendering a Rich Text field using the default HTMl elements.
|
|
93
|
+
*
|
|
94
|
+
* ```jsx
|
|
95
|
+
* <PrismicRichText field={document.data.content} />;
|
|
96
|
+
* ```
|
|
97
|
+
*
|
|
98
|
+
* @example Rendering a Rich Text field using a custom set of React components.
|
|
99
|
+
*
|
|
100
|
+
* ```jsx
|
|
101
|
+
* <PrismicRichText
|
|
102
|
+
* field={document.data.content}
|
|
103
|
+
* components={{
|
|
104
|
+
* heading1: ({ children }) => <Heading>{children}</Heading>,
|
|
105
|
+
* }}
|
|
106
|
+
* />;
|
|
107
|
+
* ```
|
|
108
|
+
*
|
|
109
|
+
* @param props - Props for the component.
|
|
110
|
+
*
|
|
111
|
+
* @returns The Rich Text field's content as React components.
|
|
112
|
+
*
|
|
113
|
+
* @see Learn about Rich Text fields {@link https://prismic.io/docs/core-concepts/rich-text-title}
|
|
114
|
+
* @see Learn about Rich Text serializers {@link https://prismic.io/docs/core-concepts/html-serializer}
|
|
115
|
+
*/
|
|
116
|
+
export declare const PrismicRichText: <LinkResolverFunction extends prismicH.LinkResolverFunction<any> = prismicH.LinkResolverFunction<string>>(props: PrismicRichTextProps<LinkResolverFunction>) => JSX.Element | null;
|
package/dist/PrismicText.d.ts
CHANGED
|
@@ -1,39 +1,39 @@
|
|
|
1
|
-
import * as prismicT from "@prismicio/types";
|
|
2
|
-
/**
|
|
3
|
-
* Props for `<PrismicText>`.
|
|
4
|
-
*/
|
|
5
|
-
export type PrismicTextProps = {
|
|
6
|
-
/**
|
|
7
|
-
* The Prismic Rich Text field to render.
|
|
8
|
-
*/
|
|
9
|
-
field: prismicT.RichTextField | null | undefined;
|
|
10
|
-
/**
|
|
11
|
-
* The string rendered when the field is empty. If a fallback is not given,
|
|
12
|
-
* `null` will be rendered.
|
|
13
|
-
*/
|
|
14
|
-
fallback?: string;
|
|
15
|
-
/**
|
|
16
|
-
* The separator used between blocks. Defaults to `\n`.
|
|
17
|
-
*/
|
|
18
|
-
separator?: string;
|
|
19
|
-
};
|
|
20
|
-
/**
|
|
21
|
-
* React component that renders content from a Prismic Rich Text field as plain
|
|
22
|
-
* text.
|
|
23
|
-
*
|
|
24
|
-
* @remarks
|
|
25
|
-
* This component returns a React fragment with no wrapping element around the
|
|
26
|
-
* content. If you need a wrapper, add a component around `<PrismicText>`.
|
|
27
|
-
* @example Rendering a Rich Text field as plain text.
|
|
28
|
-
*
|
|
29
|
-
* ```jsx
|
|
30
|
-
* <PrismicText field={document.data.content} />;
|
|
31
|
-
* ```
|
|
32
|
-
*
|
|
33
|
-
* @param props - Props for the component.
|
|
34
|
-
*
|
|
35
|
-
* @returns The Rich Text field's content as plain text.
|
|
36
|
-
*
|
|
37
|
-
* @see Learn about Rich Text fields {@link https://prismic.io/docs/core-concepts/rich-text-title}
|
|
38
|
-
*/
|
|
39
|
-
export declare const PrismicText: (props: PrismicTextProps) => JSX.Element | null;
|
|
1
|
+
import * as prismicT from "@prismicio/types";
|
|
2
|
+
/**
|
|
3
|
+
* Props for `<PrismicText>`.
|
|
4
|
+
*/
|
|
5
|
+
export type PrismicTextProps = {
|
|
6
|
+
/**
|
|
7
|
+
* The Prismic Rich Text field to render.
|
|
8
|
+
*/
|
|
9
|
+
field: prismicT.RichTextField | null | undefined;
|
|
10
|
+
/**
|
|
11
|
+
* The string rendered when the field is empty. If a fallback is not given,
|
|
12
|
+
* `null` will be rendered.
|
|
13
|
+
*/
|
|
14
|
+
fallback?: string;
|
|
15
|
+
/**
|
|
16
|
+
* The separator used between blocks. Defaults to `\n`.
|
|
17
|
+
*/
|
|
18
|
+
separator?: string;
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* React component that renders content from a Prismic Rich Text field as plain
|
|
22
|
+
* text.
|
|
23
|
+
*
|
|
24
|
+
* @remarks
|
|
25
|
+
* This component returns a React fragment with no wrapping element around the
|
|
26
|
+
* content. If you need a wrapper, add a component around `<PrismicText>`.
|
|
27
|
+
* @example Rendering a Rich Text field as plain text.
|
|
28
|
+
*
|
|
29
|
+
* ```jsx
|
|
30
|
+
* <PrismicText field={document.data.content} />;
|
|
31
|
+
* ```
|
|
32
|
+
*
|
|
33
|
+
* @param props - Props for the component.
|
|
34
|
+
*
|
|
35
|
+
* @returns The Rich Text field's content as plain text.
|
|
36
|
+
*
|
|
37
|
+
* @see Learn about Rich Text fields {@link https://prismic.io/docs/core-concepts/rich-text-title}
|
|
38
|
+
*/
|
|
39
|
+
export declare const PrismicText: (props: PrismicTextProps) => JSX.Element | null;
|
package/dist/PrismicToolbar.d.ts
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Props for `<PrismicToolbar>`.
|
|
3
|
-
*/
|
|
4
|
-
export type PrismicToolbarProps = {
|
|
5
|
-
/**
|
|
6
|
-
* The name of the Prismic repository. For example, `"my-repo"` if the
|
|
7
|
-
* repository URL is `my-repo.prismic.io`.
|
|
8
|
-
*/
|
|
9
|
-
repositoryName: string;
|
|
10
|
-
/**
|
|
11
|
-
* The type of toolbar needed for the repository. Defaults to `"new"`.
|
|
12
|
-
*
|
|
13
|
-
* @see To check which version you need, view the Prismic Toolbar documentation {@link https://prismic.io/docs/technologies/previews-and-the-prismic-toolbar-reactjs}
|
|
14
|
-
*/
|
|
15
|
-
type?: "new" | "legacy";
|
|
16
|
-
};
|
|
17
|
-
/**
|
|
18
|
-
* React component that injects the Prismic Toolbar into the app. This component
|
|
19
|
-
* can be placed anywhere in the React tree.
|
|
20
|
-
*/
|
|
21
|
-
export declare const PrismicToolbar: ({ repositoryName, type, }: PrismicToolbarProps) => null;
|
|
1
|
+
/**
|
|
2
|
+
* Props for `<PrismicToolbar>`.
|
|
3
|
+
*/
|
|
4
|
+
export type PrismicToolbarProps = {
|
|
5
|
+
/**
|
|
6
|
+
* The name of the Prismic repository. For example, `"my-repo"` if the
|
|
7
|
+
* repository URL is `my-repo.prismic.io`.
|
|
8
|
+
*/
|
|
9
|
+
repositoryName: string;
|
|
10
|
+
/**
|
|
11
|
+
* The type of toolbar needed for the repository. Defaults to `"new"`.
|
|
12
|
+
*
|
|
13
|
+
* @see To check which version you need, view the Prismic Toolbar documentation {@link https://prismic.io/docs/technologies/previews-and-the-prismic-toolbar-reactjs}
|
|
14
|
+
*/
|
|
15
|
+
type?: "new" | "legacy";
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* React component that injects the Prismic Toolbar into the app. This component
|
|
19
|
+
* can be placed anywhere in the React tree.
|
|
20
|
+
*/
|
|
21
|
+
export declare const PrismicToolbar: ({ repositoryName, type, }: PrismicToolbarProps) => null;
|