@prismicio/react 2.4.1 → 2.4.4
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/index.cjs +6 -6
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +14 -12
- package/dist/index.js +6 -6
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/src/PrismicLink.tsx +15 -11
- package/src/SliceZone.tsx +36 -22
- package/src/index.ts +2 -0
package/dist/index.d.ts
CHANGED
|
@@ -589,7 +589,7 @@ declare type SliceLike<SliceType extends string = string> = SliceLikeRestV2<Slic
|
|
|
589
589
|
*
|
|
590
590
|
* @typeParam TSlice - The type(s) of a Slice in the Slice Zone.
|
|
591
591
|
*/
|
|
592
|
-
declare type SliceZoneLike<TSlice extends SliceLike> = readonly TSlice[];
|
|
592
|
+
declare type SliceZoneLike<TSlice extends SliceLike = SliceLike> = readonly TSlice[];
|
|
593
593
|
/**
|
|
594
594
|
* React props for a component rendering content from a Prismic Slice using the
|
|
595
595
|
* `<SliceZone>` component.
|
|
@@ -598,7 +598,7 @@ declare type SliceZoneLike<TSlice extends SliceLike> = readonly TSlice[];
|
|
|
598
598
|
* @typeParam TContext - Arbitrary data passed to `<SliceZone>` and made
|
|
599
599
|
* available to all Slice components.
|
|
600
600
|
*/
|
|
601
|
-
declare type SliceComponentProps<TSlice extends SliceLike =
|
|
601
|
+
declare type SliceComponentProps<TSlice extends SliceLike = any, TContext = unknown> = {
|
|
602
602
|
/**
|
|
603
603
|
* Slice data for this component.
|
|
604
604
|
*/
|
|
@@ -622,11 +622,13 @@ declare type SliceComponentProps<TSlice extends SliceLike = SliceLike, TContext
|
|
|
622
622
|
* @typeParam TSlice - The type(s) of a Slice in the Slice Zone.
|
|
623
623
|
* @typeParam TContext - Arbitrary data made available to all Slice components.
|
|
624
624
|
*/
|
|
625
|
-
declare type SliceComponentType<TSlice extends SliceLike =
|
|
625
|
+
declare type SliceComponentType<TSlice extends SliceLike = any, TContext = unknown> = React.ComponentType<SliceComponentProps<TSlice, TContext>>;
|
|
626
626
|
/**
|
|
627
627
|
* A record of Slice types mapped to a React component. The component will be
|
|
628
628
|
* rendered for each instance of its Slice.
|
|
629
629
|
*
|
|
630
|
+
* @deprecated This type is no longer used by `@prismicio/react`. Prefer using
|
|
631
|
+
* `Record<string, SliceComponentType<any>>` instead.
|
|
630
632
|
* @typeParam TSlice - The type(s) of a Slice in the Slice Zone.
|
|
631
633
|
* @typeParam TContext - Arbitrary data made available to all Slice components.
|
|
632
634
|
*/
|
|
@@ -643,7 +645,7 @@ declare const TODOSliceComponent: <TSlice extends SliceLike<string>, TContext>({
|
|
|
643
645
|
/**
|
|
644
646
|
* Arguments for a `<SliceZone>` `resolver` function.
|
|
645
647
|
*/
|
|
646
|
-
declare type SliceZoneResolverArgs<TSlice extends SliceLike =
|
|
648
|
+
declare type SliceZoneResolverArgs<TSlice extends SliceLike = any> = {
|
|
647
649
|
/**
|
|
648
650
|
* The Slice to resolve to a React component.
|
|
649
651
|
*/
|
|
@@ -668,22 +670,22 @@ declare type SliceZoneResolverArgs<TSlice extends SliceLike = SliceLike> = {
|
|
|
668
670
|
*
|
|
669
671
|
* @returns The React component to render for a Slice.
|
|
670
672
|
*/
|
|
671
|
-
declare type SliceZoneResolver<TSlice extends SliceLike =
|
|
673
|
+
declare type SliceZoneResolver<TSlice extends SliceLike = any, TContext = unknown> = (args: SliceZoneResolverArgs<TSlice>) => SliceComponentType<any, TContext> | undefined | null;
|
|
672
674
|
/**
|
|
673
675
|
* React props for the `<SliceZone>` component.
|
|
674
676
|
*
|
|
675
677
|
* @typeParam TSlice - The type(s) of a Slice in the Slice Zone.
|
|
676
678
|
* @typeParam TContext - Arbitrary data made available to all Slice components.
|
|
677
679
|
*/
|
|
678
|
-
declare type SliceZoneProps<
|
|
680
|
+
declare type SliceZoneProps<TContext = unknown> = {
|
|
679
681
|
/**
|
|
680
682
|
* List of Slice data from the Slice Zone.
|
|
681
683
|
*/
|
|
682
|
-
slices?: SliceZoneLike
|
|
684
|
+
slices?: SliceZoneLike;
|
|
683
685
|
/**
|
|
684
686
|
* A record mapping Slice types to React components.
|
|
685
687
|
*/
|
|
686
|
-
components?:
|
|
688
|
+
components?: Record<string, SliceComponentType<any, TContext>>;
|
|
687
689
|
/**
|
|
688
690
|
* A function that determines the rendered React component for each Slice in
|
|
689
691
|
* the Slice Zone.
|
|
@@ -694,12 +696,12 @@ declare type SliceZoneProps<TSlice extends SliceLike = SliceLike, TContext = unk
|
|
|
694
696
|
*
|
|
695
697
|
* @returns The React component to render for a Slice.
|
|
696
698
|
*/
|
|
697
|
-
resolver?: SliceZoneResolver<
|
|
699
|
+
resolver?: SliceZoneResolver<any, TContext>;
|
|
698
700
|
/**
|
|
699
701
|
* The React component rendered if a component mapping from the `components`
|
|
700
702
|
* prop cannot be found.
|
|
701
703
|
*/
|
|
702
|
-
defaultComponent?: SliceComponentType<
|
|
704
|
+
defaultComponent?: SliceComponentType<any, TContext>;
|
|
703
705
|
/**
|
|
704
706
|
* Arbitrary data made available to all Slice components.
|
|
705
707
|
*/
|
|
@@ -720,7 +722,7 @@ declare type SliceZoneProps<TSlice extends SliceLike = SliceLike, TContext = unk
|
|
|
720
722
|
*
|
|
721
723
|
* @see Learn about Prismic Slices and Slice Zones {@link https://prismic.io/docs/core-concepts/slices}
|
|
722
724
|
*/
|
|
723
|
-
declare const SliceZone: <
|
|
725
|
+
declare const SliceZone: <TContext>({ slices, components, resolver, defaultComponent, context, }: SliceZoneProps<TContext>) => JSX.Element;
|
|
724
726
|
|
|
725
727
|
/**
|
|
726
728
|
* Props for `<PrismicToolbar>`.
|
|
@@ -1284,4 +1286,4 @@ declare const Elements: {
|
|
|
1284
1286
|
readonly span: "span";
|
|
1285
1287
|
};
|
|
1286
1288
|
|
|
1287
|
-
export { Elements, JSXFunctionSerializer, JSXMapSerializer, LinkProps, PrismicClientHookState, PrismicContextValue, PrismicImage, PrismicImageProps, PrismicLink, PrismicLinkProps, PrismicProvider, PrismicProviderProps, PrismicRichText, PrismicRichTextProps, PrismicText, PrismicTextProps, PrismicToolbar, PrismicToolbarProps, SliceComponentProps, SliceComponentType, SliceLike, SliceZone, SliceZoneComponents, SliceZoneLike, SliceZoneProps, SliceZoneResolver, TODOSliceComponent, UsePrismicPreviewResolverArgs, useAllPrismicDocumentsByEveryTag, useAllPrismicDocumentsByIDs, useAllPrismicDocumentsBySomeTags, useAllPrismicDocumentsByTag, useAllPrismicDocumentsByType, useAllPrismicDocumentsByUIDs, useAllPrismicDocumentsDangerously, useFirstPrismicDocument, usePrismicClient, usePrismicContext, usePrismicDocumentByID, usePrismicDocumentByUID, usePrismicDocuments, usePrismicDocumentsByEveryTag, usePrismicDocumentsByIDs, usePrismicDocumentsBySomeTags, usePrismicDocumentsByTag, usePrismicDocumentsByType, usePrismicDocumentsByUIDs, usePrismicPreviewResolver, useSinglePrismicDocument };
|
|
1289
|
+
export { Elements, JSXFunctionSerializer, JSXMapSerializer, LinkProps, PrismicClientHookState, PrismicContextValue, PrismicImage, PrismicImageProps, PrismicLink, PrismicLinkProps, PrismicProvider, PrismicProviderProps, PrismicRichText, PrismicRichTextProps, PrismicText, PrismicTextProps, PrismicToolbar, PrismicToolbarProps, SliceComponentProps, SliceComponentType, SliceLike, SliceLikeGraphQL, SliceLikeRestV2, SliceZone, SliceZoneComponents, SliceZoneLike, SliceZoneProps, SliceZoneResolver, TODOSliceComponent, UsePrismicPreviewResolverArgs, useAllPrismicDocumentsByEveryTag, useAllPrismicDocumentsByIDs, useAllPrismicDocumentsBySomeTags, useAllPrismicDocumentsByTag, useAllPrismicDocumentsByType, useAllPrismicDocumentsByUIDs, useAllPrismicDocumentsDangerously, useFirstPrismicDocument, usePrismicClient, usePrismicContext, usePrismicDocumentByID, usePrismicDocumentByUID, usePrismicDocuments, usePrismicDocumentsByEveryTag, usePrismicDocumentsByIDs, usePrismicDocumentsBySomeTags, usePrismicDocumentsByTag, usePrismicDocumentsByType, usePrismicDocumentsByUIDs, usePrismicPreviewResolver, useSinglePrismicDocument };
|
package/dist/index.js
CHANGED
|
@@ -58,7 +58,7 @@ const usePrismicClient = (explicitClient) => {
|
|
|
58
58
|
return client;
|
|
59
59
|
};
|
|
60
60
|
|
|
61
|
-
var version = "2.4.
|
|
61
|
+
var version = "2.4.4";
|
|
62
62
|
|
|
63
63
|
const devMsg = (slug) => {
|
|
64
64
|
return `https://prismic.dev/msg/react/v${version}/${slug}`;
|
|
@@ -76,16 +76,16 @@ const _PrismicLink = (props, ref) => {
|
|
|
76
76
|
const context = usePrismicContext();
|
|
77
77
|
if (!__PRODUCTION__) {
|
|
78
78
|
if ("field" in props && props.field) {
|
|
79
|
-
if (!
|
|
79
|
+
if (!props.field.link_type) {
|
|
80
80
|
console.error(`[PrismicLink] This "field" prop value caused an error to be thrown.
|
|
81
81
|
`, props.field);
|
|
82
|
-
throw new Error(`[PrismicLink] The provided field is missing required properties to properly render a link. The link
|
|
82
|
+
throw new Error(`[PrismicLink] The provided field is missing required properties to properly render a link. The link will not render. For more details, see ${devMsg("missing-link-properties")}`);
|
|
83
|
+
} else if (Object.keys(props.field).length > 1 && !("url" in props.field || "uid" in props.field || "id" in props.field)) {
|
|
84
|
+
console.warn(`[PrismicLink] The provided field is missing required properties to properly render a link. The link may not render correctly. For more details, see ${devMsg("missing-link-properties")}`, props.field);
|
|
83
85
|
}
|
|
84
86
|
} else if ("document" in props && props.document) {
|
|
85
87
|
if (!("url" in props.document || "id" in props.document)) {
|
|
86
|
-
console.
|
|
87
|
-
`, props.document);
|
|
88
|
-
throw new Error(`[PrismicLink] The provided document is missing required properties to properly render a link. The link may not render. For more details, see ${devMsg("missing-link-properties")}`);
|
|
88
|
+
console.warn(`[PrismicLink] The provided document is missing required properties to properly render a link. The link may not render correctly. For more details, see ${devMsg("missing-link-properties")}`, props.document);
|
|
89
89
|
}
|
|
90
90
|
}
|
|
91
91
|
}
|