@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
package/dist/index.d.ts
CHANGED
|
@@ -1,46 +1,46 @@
|
|
|
1
|
-
export { PrismicProvider } from "./PrismicProvider";
|
|
2
|
-
export type { PrismicProviderProps, PrismicContextValue, } from "./PrismicProvider";
|
|
3
|
-
export { usePrismicContext } from "./usePrismicContext";
|
|
4
|
-
export { usePrismicClient } from "./usePrismicClient";
|
|
5
|
-
export { PrismicLink } from "./PrismicLink";
|
|
6
|
-
export type { PrismicLinkProps, LinkProps } from "./PrismicLink";
|
|
7
|
-
export { PrismicText } from "./PrismicText";
|
|
8
|
-
export type { PrismicTextProps } from "./PrismicText";
|
|
9
|
-
export { PrismicRichText } from "./PrismicRichText";
|
|
10
|
-
export type { PrismicRichTextProps } from "./PrismicRichText";
|
|
11
|
-
import { Element } from "@prismicio/richtext";
|
|
12
|
-
export { Element };
|
|
13
|
-
/**
|
|
14
|
-
* @deprecated Renamed to `Element` (without an "s").
|
|
15
|
-
*/
|
|
16
|
-
export declare const Elements: {
|
|
17
|
-
readonly heading1: "heading1";
|
|
18
|
-
readonly heading2: "heading2";
|
|
19
|
-
readonly heading3: "heading3";
|
|
20
|
-
readonly heading4: "heading4";
|
|
21
|
-
readonly heading5: "heading5";
|
|
22
|
-
readonly heading6: "heading6";
|
|
23
|
-
readonly paragraph: "paragraph";
|
|
24
|
-
readonly preformatted: "preformatted";
|
|
25
|
-
readonly strong: "strong";
|
|
26
|
-
readonly em: "em";
|
|
27
|
-
readonly listItem: "list-item";
|
|
28
|
-
readonly oListItem: "o-list-item";
|
|
29
|
-
readonly list: "group-list-item";
|
|
30
|
-
readonly oList: "group-o-list-item";
|
|
31
|
-
readonly image: "image";
|
|
32
|
-
readonly embed: "embed";
|
|
33
|
-
readonly hyperlink: "hyperlink";
|
|
34
|
-
readonly label: "label";
|
|
35
|
-
readonly span: "span";
|
|
36
|
-
};
|
|
37
|
-
export { PrismicImage } from "./PrismicImage";
|
|
38
|
-
export type { PrismicImageProps } from "./PrismicImage";
|
|
39
|
-
export { SliceZone, TODOSliceComponent } from "./SliceZone";
|
|
40
|
-
export type { SliceComponentProps, SliceComponentType, SliceLikeRestV2, SliceLikeGraphQL, SliceLike, SliceZoneComponents, SliceZoneLike, SliceZoneProps, SliceZoneResolver, } from "./SliceZone";
|
|
41
|
-
export { PrismicToolbar } from "./PrismicToolbar";
|
|
42
|
-
export type { PrismicToolbarProps } from "./PrismicToolbar";
|
|
43
|
-
export { usePrismicPreviewResolver } from "./usePrismicPreviewResolver";
|
|
44
|
-
export type { UsePrismicPreviewResolverArgs } from "./usePrismicPreviewResolver";
|
|
45
|
-
export { useAllPrismicDocumentsDangerously, useAllPrismicDocumentsByEveryTag, useAllPrismicDocumentsByIDs, useAllPrismicDocumentsBySomeTags, useAllPrismicDocumentsByTag, useAllPrismicDocumentsByType, useAllPrismicDocumentsByUIDs, useFirstPrismicDocument, usePrismicDocumentByID, usePrismicDocumentByUID, usePrismicDocuments, usePrismicDocumentsByEveryTag, usePrismicDocumentsByIDs, usePrismicDocumentsBySomeTags, usePrismicDocumentsByTag, usePrismicDocumentsByType, usePrismicDocumentsByUIDs, useSinglePrismicDocument, } from "./clientHooks";
|
|
46
|
-
export type { JSXMapSerializer, JSXFunctionSerializer, PrismicClientHookState, } from "./types";
|
|
1
|
+
export { PrismicProvider } from "./PrismicProvider";
|
|
2
|
+
export type { PrismicProviderProps, PrismicContextValue, } from "./PrismicProvider";
|
|
3
|
+
export { usePrismicContext } from "./usePrismicContext";
|
|
4
|
+
export { usePrismicClient } from "./usePrismicClient";
|
|
5
|
+
export { PrismicLink } from "./PrismicLink";
|
|
6
|
+
export type { PrismicLinkProps, LinkProps } from "./PrismicLink";
|
|
7
|
+
export { PrismicText } from "./PrismicText";
|
|
8
|
+
export type { PrismicTextProps } from "./PrismicText";
|
|
9
|
+
export { PrismicRichText } from "./PrismicRichText";
|
|
10
|
+
export type { PrismicRichTextProps } from "./PrismicRichText";
|
|
11
|
+
import { Element } from "@prismicio/richtext";
|
|
12
|
+
export { Element };
|
|
13
|
+
/**
|
|
14
|
+
* @deprecated Renamed to `Element` (without an "s").
|
|
15
|
+
*/
|
|
16
|
+
export declare const Elements: {
|
|
17
|
+
readonly heading1: "heading1";
|
|
18
|
+
readonly heading2: "heading2";
|
|
19
|
+
readonly heading3: "heading3";
|
|
20
|
+
readonly heading4: "heading4";
|
|
21
|
+
readonly heading5: "heading5";
|
|
22
|
+
readonly heading6: "heading6";
|
|
23
|
+
readonly paragraph: "paragraph";
|
|
24
|
+
readonly preformatted: "preformatted";
|
|
25
|
+
readonly strong: "strong";
|
|
26
|
+
readonly em: "em";
|
|
27
|
+
readonly listItem: "list-item";
|
|
28
|
+
readonly oListItem: "o-list-item";
|
|
29
|
+
readonly list: "group-list-item";
|
|
30
|
+
readonly oList: "group-o-list-item";
|
|
31
|
+
readonly image: "image";
|
|
32
|
+
readonly embed: "embed";
|
|
33
|
+
readonly hyperlink: "hyperlink";
|
|
34
|
+
readonly label: "label";
|
|
35
|
+
readonly span: "span";
|
|
36
|
+
};
|
|
37
|
+
export { PrismicImage } from "./PrismicImage";
|
|
38
|
+
export type { PrismicImageProps } from "./PrismicImage";
|
|
39
|
+
export { SliceZone, TODOSliceComponent } from "./SliceZone";
|
|
40
|
+
export type { SliceComponentProps, SliceComponentType, SliceLikeRestV2, SliceLikeGraphQL, SliceLike, SliceZoneComponents, SliceZoneLike, SliceZoneProps, SliceZoneResolver, } from "./SliceZone";
|
|
41
|
+
export { PrismicToolbar } from "./PrismicToolbar";
|
|
42
|
+
export type { PrismicToolbarProps } from "./PrismicToolbar";
|
|
43
|
+
export { usePrismicPreviewResolver } from "./usePrismicPreviewResolver";
|
|
44
|
+
export type { UsePrismicPreviewResolverArgs } from "./usePrismicPreviewResolver";
|
|
45
|
+
export { useAllPrismicDocumentsDangerously, useAllPrismicDocumentsByEveryTag, useAllPrismicDocumentsByIDs, useAllPrismicDocumentsBySomeTags, useAllPrismicDocumentsByTag, useAllPrismicDocumentsByType, useAllPrismicDocumentsByUIDs, useFirstPrismicDocument, usePrismicDocumentByID, usePrismicDocumentByUID, usePrismicDocuments, usePrismicDocumentsByEveryTag, usePrismicDocumentsByIDs, usePrismicDocumentsBySomeTags, usePrismicDocumentsByTag, usePrismicDocumentsByType, usePrismicDocumentsByUIDs, useSinglePrismicDocument, } from "./clientHooks";
|
|
46
|
+
export type { JSXMapSerializer, JSXFunctionSerializer, PrismicClientHookState, } from "./types";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* `true` if in the production environment, `false` otherwise.
|
|
3
|
-
*
|
|
4
|
-
* This boolean can be used to perform actions only in development environments,
|
|
5
|
-
* such as logging.
|
|
6
|
-
*/
|
|
7
|
-
export declare const __PRODUCTION__: boolean;
|
|
1
|
+
/**
|
|
2
|
+
* `true` if in the production environment, `false` otherwise.
|
|
3
|
+
*
|
|
4
|
+
* This boolean can be used to perform actions only in development environments,
|
|
5
|
+
* such as logging.
|
|
6
|
+
*/
|
|
7
|
+
export declare const __PRODUCTION__: boolean;
|
package/dist/lib/devMsg.d.ts
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Returns a `prismic.dev/msg` URL for a given message slug.
|
|
3
|
-
*
|
|
4
|
-
* @example
|
|
5
|
-
*
|
|
6
|
-
* ```ts
|
|
7
|
-
* devMsg("missing-param");
|
|
8
|
-
* // => "https://prismic.dev/msg/react/v1.2.3/missing-param.md"
|
|
9
|
-
* ```
|
|
10
|
-
*
|
|
11
|
-
* @param slug - Slug for the message. This corresponds to a Markdown file in
|
|
12
|
-
* the Git repository's `/messages` directory.
|
|
13
|
-
*
|
|
14
|
-
* @returns The `prismic.dev/msg` URL for the given slug.
|
|
15
|
-
*/
|
|
16
|
-
export declare const devMsg: (slug: string) => string;
|
|
1
|
+
/**
|
|
2
|
+
* Returns a `prismic.dev/msg` URL for a given message slug.
|
|
3
|
+
*
|
|
4
|
+
* @example
|
|
5
|
+
*
|
|
6
|
+
* ```ts
|
|
7
|
+
* devMsg("missing-param");
|
|
8
|
+
* // => "https://prismic.dev/msg/react/v1.2.3/missing-param.md"
|
|
9
|
+
* ```
|
|
10
|
+
*
|
|
11
|
+
* @param slug - Slug for the message. This corresponds to a Markdown file in
|
|
12
|
+
* the Git repository's `/messages` directory.
|
|
13
|
+
*
|
|
14
|
+
* @returns The `prismic.dev/msg` URL for the given slug.
|
|
15
|
+
*/
|
|
16
|
+
export declare const devMsg: (slug: string) => string;
|
package/dist/lib/invariant.d.ts
CHANGED
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* MIT License
|
|
3
|
-
*
|
|
4
|
-
* Copyright (c) 2019 Alexander Reardon
|
|
5
|
-
*
|
|
6
|
-
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
-
* of this software and associated documentation files (the "Software"), to deal
|
|
8
|
-
* in the Software without restriction, including without limitation the rights
|
|
9
|
-
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
-
* copies of the Software, and to permit persons to whom the Software is
|
|
11
|
-
* furnished to do so, subject to the following conditions:
|
|
12
|
-
*
|
|
13
|
-
* The above copyright notice and this permission notice shall be included in
|
|
14
|
-
* all copies or substantial portions of the Software.
|
|
15
|
-
*
|
|
16
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
-
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
-
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
-
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
-
* SOFTWARE.
|
|
23
|
-
*/
|
|
24
|
-
export declare function invariant(condition: unknown, message?: string): asserts condition;
|
|
1
|
+
/**
|
|
2
|
+
* MIT License
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) 2019 Alexander Reardon
|
|
5
|
+
*
|
|
6
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
* in the Software without restriction, including without limitation the rights
|
|
9
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
* furnished to do so, subject to the following conditions:
|
|
12
|
+
*
|
|
13
|
+
* The above copyright notice and this permission notice shall be included in
|
|
14
|
+
* all copies or substantial portions of the Software.
|
|
15
|
+
*
|
|
16
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
* SOFTWARE.
|
|
23
|
+
*/
|
|
24
|
+
export declare function invariant(condition: unknown, message?: string): asserts condition;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Determines if a URL is internal or external.
|
|
3
|
-
*
|
|
4
|
-
* @param url - The URL to check if internal or external.
|
|
5
|
-
*
|
|
6
|
-
* @returns `true` if `url` is internal, `false` otherwise.
|
|
7
|
-
*/
|
|
8
|
-
export declare const isInternalURL: (url: string) => boolean;
|
|
1
|
+
/**
|
|
2
|
+
* Determines if a URL is internal or external.
|
|
3
|
+
*
|
|
4
|
+
* @param url - The URL to check if internal or external.
|
|
5
|
+
*
|
|
6
|
+
* @returns `true` if `url` is internal, `false` otherwise.
|
|
7
|
+
*/
|
|
8
|
+
export declare const isInternalURL: (url: string) => boolean;
|
package/dist/lib/pascalCase.d.ts
CHANGED
|
@@ -1,26 +1,26 @@
|
|
|
1
|
-
type WordSeparators = "-" | "_" | " ";
|
|
2
|
-
type Split<S extends string, Delimiter extends string> = S extends `${infer Head}${Delimiter}${infer Tail}` ? [Head, ...Split<Tail, Delimiter>] : S extends Delimiter ? [] : [S];
|
|
3
|
-
type InnerCamelCaseStringArray<Parts extends readonly any[], PreviousPart> = Parts extends [`${infer FirstPart}`, ...infer RemainingParts] ? FirstPart extends undefined ? "" : FirstPart extends "" ? InnerCamelCaseStringArray<RemainingParts, PreviousPart> : `${PreviousPart extends "" ? FirstPart : Capitalize<FirstPart>}${InnerCamelCaseStringArray<RemainingParts, FirstPart>}` : "";
|
|
4
|
-
type CamelCaseStringArray<Parts extends readonly string[]> = Parts extends [
|
|
5
|
-
`${infer FirstPart}`,
|
|
6
|
-
...infer RemainingParts
|
|
7
|
-
] ? Uncapitalize<`${FirstPart}${InnerCamelCaseStringArray<RemainingParts, FirstPart>}`> : never;
|
|
8
|
-
type CamelCase<K> = K extends string ? CamelCaseStringArray<Split<K extends Uppercase<K> ? Lowercase<K> : K, WordSeparators>> : K;
|
|
9
|
-
/**
|
|
10
|
-
* Converts a string literal to Pascal case.
|
|
11
|
-
*
|
|
12
|
-
* Taken from the `type-fest` package.
|
|
13
|
-
*
|
|
14
|
-
* See:
|
|
15
|
-
* https://github.com/sindresorhus/type-fest/blob/61c35052f09caa23de5eef96d95196375d8ed498/source/pascal-case.d.ts
|
|
16
|
-
*/
|
|
17
|
-
export type PascalCase<Value> = CamelCase<Value> extends string ? Capitalize<CamelCase<Value>> : CamelCase<Value>;
|
|
18
|
-
/**
|
|
19
|
-
* Converts a string to Pascal case.
|
|
20
|
-
*
|
|
21
|
-
* @param input - The string to convert.
|
|
22
|
-
*
|
|
23
|
-
* @returns `input` as Pascal case.
|
|
24
|
-
*/
|
|
25
|
-
export declare const pascalCase: <Input extends string>(input: Input) => PascalCase<Input>;
|
|
26
|
-
export {};
|
|
1
|
+
type WordSeparators = "-" | "_" | " ";
|
|
2
|
+
type Split<S extends string, Delimiter extends string> = S extends `${infer Head}${Delimiter}${infer Tail}` ? [Head, ...Split<Tail, Delimiter>] : S extends Delimiter ? [] : [S];
|
|
3
|
+
type InnerCamelCaseStringArray<Parts extends readonly any[], PreviousPart> = Parts extends [`${infer FirstPart}`, ...infer RemainingParts] ? FirstPart extends undefined ? "" : FirstPart extends "" ? InnerCamelCaseStringArray<RemainingParts, PreviousPart> : `${PreviousPart extends "" ? FirstPart : Capitalize<FirstPart>}${InnerCamelCaseStringArray<RemainingParts, FirstPart>}` : "";
|
|
4
|
+
type CamelCaseStringArray<Parts extends readonly string[]> = Parts extends [
|
|
5
|
+
`${infer FirstPart}`,
|
|
6
|
+
...infer RemainingParts
|
|
7
|
+
] ? Uncapitalize<`${FirstPart}${InnerCamelCaseStringArray<RemainingParts, FirstPart>}`> : never;
|
|
8
|
+
type CamelCase<K> = K extends string ? CamelCaseStringArray<Split<K extends Uppercase<K> ? Lowercase<K> : K, WordSeparators>> : K;
|
|
9
|
+
/**
|
|
10
|
+
* Converts a string literal to Pascal case.
|
|
11
|
+
*
|
|
12
|
+
* Taken from the `type-fest` package.
|
|
13
|
+
*
|
|
14
|
+
* See:
|
|
15
|
+
* https://github.com/sindresorhus/type-fest/blob/61c35052f09caa23de5eef96d95196375d8ed498/source/pascal-case.d.ts
|
|
16
|
+
*/
|
|
17
|
+
export type PascalCase<Value> = CamelCase<Value> extends string ? Capitalize<CamelCase<Value>> : CamelCase<Value>;
|
|
18
|
+
/**
|
|
19
|
+
* Converts a string to Pascal case.
|
|
20
|
+
*
|
|
21
|
+
* @param input - The string to convert.
|
|
22
|
+
*
|
|
23
|
+
* @returns `input` as Pascal case.
|
|
24
|
+
*/
|
|
25
|
+
export declare const pascalCase: <Input extends string>(input: Input) => PascalCase<Input>;
|
|
26
|
+
export {};
|
package/dist/package.json.cjs
CHANGED
package/dist/package.json.js
CHANGED
package/dist/types.d.ts
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
import * as prismicR from "@prismicio/richtext";
|
|
2
|
-
/**
|
|
3
|
-
* A function mapping Rich Text block types to React Components. It is used to
|
|
4
|
-
* render Rich Text or Title fields.
|
|
5
|
-
*
|
|
6
|
-
* @see Templating rich text and title fields from Prismic {@link https://prismic.io/docs/technologies/templating-rich-text-and-title-fields-javascript}
|
|
7
|
-
*/
|
|
8
|
-
export type JSXFunctionSerializer = prismicR.RichTextFunctionSerializer<JSX.Element>;
|
|
9
|
-
/**
|
|
10
|
-
* A map of Rich Text block types to React Components. It is used to render Rich
|
|
11
|
-
* Text or Title fields.
|
|
12
|
-
*
|
|
13
|
-
* @see Templating Rich Text and Title fields from Prismic {@link https://prismic.io/docs/technologies/templating-rich-text-and-title-fields-javascript}
|
|
14
|
-
*/
|
|
15
|
-
export type JSXMapSerializer = prismicR.RichTextMapSerializer<JSX.Element>;
|
|
16
|
-
/**
|
|
17
|
-
* States of a `@prismicio/client` hook.
|
|
18
|
-
*/
|
|
19
|
-
export type PrismicClientHookState = "idle" | "loading" | "loaded" | "failed";
|
|
1
|
+
import * as prismicR from "@prismicio/richtext";
|
|
2
|
+
/**
|
|
3
|
+
* A function mapping Rich Text block types to React Components. It is used to
|
|
4
|
+
* render Rich Text or Title fields.
|
|
5
|
+
*
|
|
6
|
+
* @see Templating rich text and title fields from Prismic {@link https://prismic.io/docs/technologies/templating-rich-text-and-title-fields-javascript}
|
|
7
|
+
*/
|
|
8
|
+
export type JSXFunctionSerializer = prismicR.RichTextFunctionSerializer<JSX.Element>;
|
|
9
|
+
/**
|
|
10
|
+
* A map of Rich Text block types to React Components. It is used to render Rich
|
|
11
|
+
* Text or Title fields.
|
|
12
|
+
*
|
|
13
|
+
* @see Templating Rich Text and Title fields from Prismic {@link https://prismic.io/docs/technologies/templating-rich-text-and-title-fields-javascript}
|
|
14
|
+
*/
|
|
15
|
+
export type JSXMapSerializer = prismicR.RichTextMapSerializer<JSX.Element>;
|
|
16
|
+
/**
|
|
17
|
+
* States of a `@prismicio/client` hook.
|
|
18
|
+
*/
|
|
19
|
+
export type PrismicClientHookState = "idle" | "loading" | "loaded" | "failed";
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import type * as prismic from "@prismicio/client";
|
|
2
|
-
/**
|
|
3
|
-
* Retrieve the `@prismicio/client` instance provided to `<PrismicProvider>`
|
|
4
|
-
* higher in the React tree.
|
|
5
|
-
*
|
|
6
|
-
* @param explicitClient - An optional `@prismicio/client` instance to override
|
|
7
|
-
* the Client provided to `<PrismicProvider>`.
|
|
8
|
-
*
|
|
9
|
-
* @returns The `@prismicio/client` instance provided to `<PrismicProvider>`.
|
|
10
|
-
*/
|
|
11
|
-
export declare const usePrismicClient: (explicitClient?: prismic.Client) => prismic.Client;
|
|
1
|
+
import type * as prismic from "@prismicio/client";
|
|
2
|
+
/**
|
|
3
|
+
* Retrieve the `@prismicio/client` instance provided to `<PrismicProvider>`
|
|
4
|
+
* higher in the React tree.
|
|
5
|
+
*
|
|
6
|
+
* @param explicitClient - An optional `@prismicio/client` instance to override
|
|
7
|
+
* the Client provided to `<PrismicProvider>`.
|
|
8
|
+
*
|
|
9
|
+
* @returns The `@prismicio/client` instance provided to `<PrismicProvider>`.
|
|
10
|
+
*/
|
|
11
|
+
export declare const usePrismicClient: (explicitClient?: prismic.Client) => prismic.Client;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { PrismicContextValue } from "./PrismicProvider";
|
|
2
|
-
/**
|
|
3
|
-
* React hook used to read shared configuration for `@prismicio/react`
|
|
4
|
-
* components and hooks.
|
|
5
|
-
*
|
|
6
|
-
* @returns The closest `<PrismicProvider>` context value.
|
|
7
|
-
*/
|
|
8
|
-
export declare const usePrismicContext: () => PrismicContextValue;
|
|
1
|
+
import { PrismicContextValue } from "./PrismicProvider";
|
|
2
|
+
/**
|
|
3
|
+
* React hook used to read shared configuration for `@prismicio/react`
|
|
4
|
+
* components and hooks.
|
|
5
|
+
*
|
|
6
|
+
* @returns The closest `<PrismicProvider>` context value.
|
|
7
|
+
*/
|
|
8
|
+
export declare const usePrismicContext: () => PrismicContextValue;
|
|
@@ -1,45 +1,45 @@
|
|
|
1
|
-
import type * as prismic from "@prismicio/client";
|
|
2
|
-
import { ClientHookReturnType } from "./useStatefulPrismicClientMethod";
|
|
3
|
-
export type UsePrismicPreviewResolverArgs = {
|
|
4
|
-
/**
|
|
5
|
-
* An optional `@prismicio/client` instance to override the Client provided to
|
|
6
|
-
* `<PrismicProvider>`
|
|
7
|
-
*/
|
|
8
|
-
client?: prismic.Client;
|
|
9
|
-
/**
|
|
10
|
-
* A function that maps a Prismic document to a URL within your app.
|
|
11
|
-
*/
|
|
12
|
-
linkResolver?: Parameters<prismic.Client["resolvePreviewURL"]>[0]["linkResolver"];
|
|
13
|
-
/**
|
|
14
|
-
* A fallback URL if the Link Resolver does not return a value.
|
|
15
|
-
*/
|
|
16
|
-
defaultURL?: Parameters<prismic.Client["resolvePreviewURL"]>[0]["defaultURL"];
|
|
17
|
-
/**
|
|
18
|
-
* The preview token (also known as a ref) that will be used to query preview
|
|
19
|
-
* content from the Prismic repository.
|
|
20
|
-
*/
|
|
21
|
-
previewToken?: Parameters<prismic.Client["resolvePreviewURL"]>[0]["previewToken"];
|
|
22
|
-
/**
|
|
23
|
-
* The previewed document that will be used to determine the destination URL.
|
|
24
|
-
*/
|
|
25
|
-
documentID?: Parameters<prismic.Client["resolvePreviewURL"]>[0]["documentID"];
|
|
26
|
-
/**
|
|
27
|
-
* A function to automatically navigate to the resolved URL. If a function is
|
|
28
|
-
* not provded, `usePreviewResolver` will not navigate to the URL.
|
|
29
|
-
*
|
|
30
|
-
* @param url - The resolved preview URL.
|
|
31
|
-
*/
|
|
32
|
-
navigate?: (url: string) => unknown;
|
|
33
|
-
};
|
|
34
|
-
/**
|
|
35
|
-
* Resolve a preview session's URL. The resolved URL can be used to redirect to
|
|
36
|
-
* the previewed document.
|
|
37
|
-
*
|
|
38
|
-
* If a `navigate` function is provided, the hook will automatically navigate to
|
|
39
|
-
* the previewed document's URL.
|
|
40
|
-
*
|
|
41
|
-
* @param args - Arguments to configure how a URL is resolved.
|
|
42
|
-
*
|
|
43
|
-
* @returns A tuple containing the resolved URL and the hook's state.
|
|
44
|
-
*/
|
|
45
|
-
export declare const usePrismicPreviewResolver: (args?: UsePrismicPreviewResolverArgs) => ClientHookReturnType<string>;
|
|
1
|
+
import type * as prismic from "@prismicio/client";
|
|
2
|
+
import { ClientHookReturnType } from "./useStatefulPrismicClientMethod";
|
|
3
|
+
export type UsePrismicPreviewResolverArgs = {
|
|
4
|
+
/**
|
|
5
|
+
* An optional `@prismicio/client` instance to override the Client provided to
|
|
6
|
+
* `<PrismicProvider>`
|
|
7
|
+
*/
|
|
8
|
+
client?: prismic.Client;
|
|
9
|
+
/**
|
|
10
|
+
* A function that maps a Prismic document to a URL within your app.
|
|
11
|
+
*/
|
|
12
|
+
linkResolver?: Parameters<prismic.Client["resolvePreviewURL"]>[0]["linkResolver"];
|
|
13
|
+
/**
|
|
14
|
+
* A fallback URL if the Link Resolver does not return a value.
|
|
15
|
+
*/
|
|
16
|
+
defaultURL?: Parameters<prismic.Client["resolvePreviewURL"]>[0]["defaultURL"];
|
|
17
|
+
/**
|
|
18
|
+
* The preview token (also known as a ref) that will be used to query preview
|
|
19
|
+
* content from the Prismic repository.
|
|
20
|
+
*/
|
|
21
|
+
previewToken?: Parameters<prismic.Client["resolvePreviewURL"]>[0]["previewToken"];
|
|
22
|
+
/**
|
|
23
|
+
* The previewed document that will be used to determine the destination URL.
|
|
24
|
+
*/
|
|
25
|
+
documentID?: Parameters<prismic.Client["resolvePreviewURL"]>[0]["documentID"];
|
|
26
|
+
/**
|
|
27
|
+
* A function to automatically navigate to the resolved URL. If a function is
|
|
28
|
+
* not provded, `usePreviewResolver` will not navigate to the URL.
|
|
29
|
+
*
|
|
30
|
+
* @param url - The resolved preview URL.
|
|
31
|
+
*/
|
|
32
|
+
navigate?: (url: string) => unknown;
|
|
33
|
+
};
|
|
34
|
+
/**
|
|
35
|
+
* Resolve a preview session's URL. The resolved URL can be used to redirect to
|
|
36
|
+
* the previewed document.
|
|
37
|
+
*
|
|
38
|
+
* If a `navigate` function is provided, the hook will automatically navigate to
|
|
39
|
+
* the previewed document's URL.
|
|
40
|
+
*
|
|
41
|
+
* @param args - Arguments to configure how a URL is resolved.
|
|
42
|
+
*
|
|
43
|
+
* @returns A tuple containing the resolved URL and the hook's state.
|
|
44
|
+
*/
|
|
45
|
+
export declare const usePrismicPreviewResolver: (args?: UsePrismicPreviewResolverArgs) => ClientHookReturnType<string>;
|
|
@@ -1,44 +1,44 @@
|
|
|
1
|
-
import type * as prismic from "@prismicio/client";
|
|
2
|
-
import { PrismicClientHookState } from "./types";
|
|
3
|
-
type StateMachineState<TData> = {
|
|
4
|
-
state: PrismicClientHookState;
|
|
5
|
-
data?: TData;
|
|
6
|
-
error?: Error;
|
|
7
|
-
};
|
|
8
|
-
type UnwrapPromise<T> = T extends Promise<infer U> ? U : T;
|
|
9
|
-
type ClientPrototype = typeof prismic.Client.prototype;
|
|
10
|
-
type ClientMethod<MethodName extends keyof ClientPrototype> = ClientPrototype[MethodName] extends (...args: any[]) => any ? ClientPrototype[MethodName] : never;
|
|
11
|
-
export type ClientMethodParameters<MethodName extends keyof ClientPrototype> = Parameters<ClientMethod<MethodName>>;
|
|
12
|
-
export type HookOnlyParameters = {
|
|
13
|
-
client?: prismic.Client;
|
|
14
|
-
skip?: boolean;
|
|
15
|
-
};
|
|
16
|
-
/**
|
|
17
|
-
* The return value of a `@prismicio/client` React hook.
|
|
18
|
-
*
|
|
19
|
-
* @typeParam TData - Data returned by the client.
|
|
20
|
-
*/
|
|
21
|
-
export type ClientHookReturnType<TData = unknown> = [
|
|
22
|
-
/**
|
|
23
|
-
* Data returned by the client.
|
|
24
|
-
*/
|
|
25
|
-
data: TData | undefined,
|
|
26
|
-
/**
|
|
27
|
-
* The current state of the hook's client method call.
|
|
28
|
-
*/
|
|
29
|
-
state: Pick<StateMachineState<TData>, "state" | "error">
|
|
30
|
-
];
|
|
31
|
-
/**
|
|
32
|
-
* Creates a React hook that forwards arguments to a specific method of a
|
|
33
|
-
* `@prismicio/client` instance. The created hook has its own internal state
|
|
34
|
-
* manager to report async status, such as pending or error statuses.
|
|
35
|
-
*
|
|
36
|
-
* @param methodName - The `@prismicio/client` method to which hook arguments
|
|
37
|
-
* will be forwarded.
|
|
38
|
-
*
|
|
39
|
-
* @returns A new React hook configured for the provided method.
|
|
40
|
-
*
|
|
41
|
-
* @internal
|
|
42
|
-
*/
|
|
43
|
-
export declare const useStatefulPrismicClientMethod: <TMethodName extends "fetchFn" | "query" | "get" | "getFirst" | "dangerouslyGetAll" | "getByID" | "getByIDs" | "getAllByIDs" | "getByUID" | "getByUIDs" | "getAllByUIDs" | "getSingle" | "getByType" | "getAllByType" | "getByTag" | "getAllByTag" | "getByEveryTag" | "getAllByEveryTag" | "getBySomeTags" | "getAllBySomeTags" | "getRepository" | "getRefs" | "getRefByID" | "getRefByLabel" | "getMasterRef" | "getReleases" | "getReleaseByID" | "getReleaseByLabel" | "getTags" | "buildQueryURL" | "resolvePreviewURL" | "graphqlFetch" | "graphQLFetch", TArgs extends Parameters<ClientMethod<TMethodName>>, TData extends UnwrapPromise<ReturnType<ClientMethod<TMethodName>>>>(methodName: TMethodName, args: TArgs, explicitClient?: prismic.Client) => ClientHookReturnType<TData>;
|
|
44
|
-
export {};
|
|
1
|
+
import type * as prismic from "@prismicio/client";
|
|
2
|
+
import { PrismicClientHookState } from "./types";
|
|
3
|
+
type StateMachineState<TData> = {
|
|
4
|
+
state: PrismicClientHookState;
|
|
5
|
+
data?: TData;
|
|
6
|
+
error?: Error;
|
|
7
|
+
};
|
|
8
|
+
type UnwrapPromise<T> = T extends Promise<infer U> ? U : T;
|
|
9
|
+
type ClientPrototype = typeof prismic.Client.prototype;
|
|
10
|
+
type ClientMethod<MethodName extends keyof ClientPrototype> = ClientPrototype[MethodName] extends (...args: any[]) => any ? ClientPrototype[MethodName] : never;
|
|
11
|
+
export type ClientMethodParameters<MethodName extends keyof ClientPrototype> = Parameters<ClientMethod<MethodName>>;
|
|
12
|
+
export type HookOnlyParameters = {
|
|
13
|
+
client?: prismic.Client;
|
|
14
|
+
skip?: boolean;
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* The return value of a `@prismicio/client` React hook.
|
|
18
|
+
*
|
|
19
|
+
* @typeParam TData - Data returned by the client.
|
|
20
|
+
*/
|
|
21
|
+
export type ClientHookReturnType<TData = unknown> = [
|
|
22
|
+
/**
|
|
23
|
+
* Data returned by the client.
|
|
24
|
+
*/
|
|
25
|
+
data: TData | undefined,
|
|
26
|
+
/**
|
|
27
|
+
* The current state of the hook's client method call.
|
|
28
|
+
*/
|
|
29
|
+
state: Pick<StateMachineState<TData>, "state" | "error">
|
|
30
|
+
];
|
|
31
|
+
/**
|
|
32
|
+
* Creates a React hook that forwards arguments to a specific method of a
|
|
33
|
+
* `@prismicio/client` instance. The created hook has its own internal state
|
|
34
|
+
* manager to report async status, such as pending or error statuses.
|
|
35
|
+
*
|
|
36
|
+
* @param methodName - The `@prismicio/client` method to which hook arguments
|
|
37
|
+
* will be forwarded.
|
|
38
|
+
*
|
|
39
|
+
* @returns A new React hook configured for the provided method.
|
|
40
|
+
*
|
|
41
|
+
* @internal
|
|
42
|
+
*/
|
|
43
|
+
export declare const useStatefulPrismicClientMethod: <TMethodName extends "fetchFn" | "query" | "get" | "getFirst" | "dangerouslyGetAll" | "getByID" | "getByIDs" | "getAllByIDs" | "getByUID" | "getByUIDs" | "getAllByUIDs" | "getSingle" | "getByType" | "getAllByType" | "getByTag" | "getAllByTag" | "getByEveryTag" | "getAllByEveryTag" | "getBySomeTags" | "getAllBySomeTags" | "getRepository" | "getRefs" | "getRefByID" | "getRefByLabel" | "getMasterRef" | "getReleases" | "getReleaseByID" | "getReleaseByLabel" | "getTags" | "buildQueryURL" | "resolvePreviewURL" | "graphqlFetch" | "graphQLFetch", TArgs extends Parameters<ClientMethod<TMethodName>>, TData extends UnwrapPromise<ReturnType<ClientMethod<TMethodName>>>>(methodName: TMethodName, args: TArgs, explicitClient?: prismic.Client) => ClientHookReturnType<TData>;
|
|
44
|
+
export {};
|
package/package.json
CHANGED