@prismicio/react 2.3.0 → 2.4.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/index.d.ts CHANGED
@@ -444,7 +444,7 @@ declare type PrismicImageProps = Omit<React.DetailedHTMLProps<React.ImgHTMLAttri
444
444
  *
445
445
  * @returns A responsive image component for the given Image field.
446
446
  */
447
- declare const PrismicImage: React.ForwardRefExoticComponent<(Pick<Omit<React.DetailedHTMLProps<React.ImgHTMLAttributes<HTMLImageElement>, HTMLImageElement>, "alt" | "src" | "srcset"> & {
447
+ declare const PrismicImage: React.ForwardRefExoticComponent<(Pick<Omit<React.DetailedHTMLProps<React.ImgHTMLAttributes<HTMLImageElement>, HTMLImageElement>, "src" | "alt" | "srcset"> & {
448
448
  /**
449
449
  * The Prismic Image field or thumbnail to render.
450
450
  */
@@ -486,7 +486,7 @@ declare const PrismicImage: React.ForwardRefExoticComponent<(Pick<Omit<React.Det
486
486
  * Not used when the `widths` prop is used.
487
487
  */
488
488
  pixelDensities?: undefined;
489
- }, "children" | "slot" | "style" | "title" | "className" | "color" | "height" | "id" | "lang" | "width" | "role" | "tabIndex" | "crossOrigin" | "widths" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocus" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChange" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDown" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClick" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerEnterCapture" | "onPointerLeave" | "onPointerLeaveCapture" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture" | "key" | "useMap" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "contentEditable" | "contextMenu" | "dir" | "draggable" | "hidden" | "placeholder" | "spellCheck" | "translate" | "radioGroup" | "about" | "datatype" | "inlist" | "prefix" | "property" | "resource" | "typeof" | "vocab" | "autoCapitalize" | "autoCorrect" | "autoSave" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "inputMode" | "is" | "referrerPolicy" | "alt" | "loading" | "decoding" | "sizes" | "srcSet" | "field" | "pixelDensities" | "imgixParams" | "fallbackAlt"> | Pick<Omit<React.DetailedHTMLProps<React.ImgHTMLAttributes<HTMLImageElement>, HTMLImageElement>, "alt" | "src" | "srcset"> & {
489
+ }, "children" | "slot" | "style" | "title" | "className" | "color" | "height" | "id" | "lang" | "width" | "role" | "tabIndex" | "crossOrigin" | "widths" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocus" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChange" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDown" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClick" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerEnterCapture" | "onPointerLeave" | "onPointerLeaveCapture" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture" | "key" | "useMap" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "contentEditable" | "contextMenu" | "dir" | "draggable" | "hidden" | "placeholder" | "spellCheck" | "translate" | "radioGroup" | "about" | "datatype" | "inlist" | "prefix" | "property" | "resource" | "typeof" | "vocab" | "autoCapitalize" | "autoCorrect" | "autoSave" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "inputMode" | "is" | "referrerPolicy" | "alt" | "loading" | "decoding" | "sizes" | "srcSet" | "field" | "pixelDensities" | "imgixParams" | "fallbackAlt"> | Pick<Omit<React.DetailedHTMLProps<React.ImgHTMLAttributes<HTMLImageElement>, HTMLImageElement>, "src" | "alt" | "srcset"> & {
490
490
  /**
491
491
  * The Prismic Image field or thumbnail to render.
492
492
  */
@@ -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 = SliceLike, TContext = unknown> = {
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 = SliceLike, TContext = unknown> = React.ComponentType<SliceComponentProps<TSlice, TContext>>;
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 = 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 = SliceLike, TContext = unknown> = (args: SliceZoneResolverArgs<TSlice>) => SliceComponentType<TSlice, TContext> | undefined | null;
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<TSlice extends SliceLike = SliceLike, TContext = unknown> = {
680
+ declare type SliceZoneProps<TContext = unknown> = {
679
681
  /**
680
682
  * List of Slice data from the Slice Zone.
681
683
  */
682
- slices?: SliceZoneLike<TSlice>;
684
+ slices?: SliceZoneLike;
683
685
  /**
684
686
  * A record mapping Slice types to React components.
685
687
  */
686
- components?: SliceZoneComponents<TSlice, TContext>;
688
+ components?: Record<string, SliceComponentType<any>>;
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<TSlice, TContext>;
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<TSlice, TContext>;
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: <TSlice extends SliceLike<string>, TContext>({ slices, components, resolver, defaultComponent, context, }: SliceZoneProps<TSlice, TContext>) => JSX.Element;
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,6 +58,12 @@ const usePrismicClient = (explicitClient) => {
58
58
  return client;
59
59
  };
60
60
 
61
+ var version = "2.4.2";
62
+
63
+ const devMsg = (slug) => {
64
+ return `https://prismic.dev/msg/react/v${version}/${slug}`;
65
+ };
66
+
61
67
  const isInternalURL = (url) => {
62
68
  const isInternal = /^(\/(?!\/)|#)/.test(url);
63
69
  const isSpecialLink = !isInternal && !/^https?:\/\//.test(url);
@@ -68,6 +74,21 @@ const defaultInternalComponent = "a";
68
74
  const defaultExternalComponent = "a";
69
75
  const _PrismicLink = (props, ref) => {
70
76
  const context = usePrismicContext();
77
+ if (!__PRODUCTION__) {
78
+ if ("field" in props && props.field) {
79
+ if (!props.field.link_type) {
80
+ console.error(`[PrismicLink] This "field" prop value caused an error to be thrown.
81
+ `, props.field);
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 (!(prismicH.isFilled.link(props.field) && ("url" 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);
85
+ }
86
+ } else if ("document" in props && props.document) {
87
+ if (!("url" in props.document || "id" in props.document)) {
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
+ }
90
+ }
91
+ }
71
92
  const linkResolver = props.linkResolver || context.linkResolver;
72
93
  let href;
73
94
  if ("href" in props) {
@@ -77,11 +98,11 @@ const _PrismicLink = (props, ref) => {
77
98
  } else if ("field" in props && props.field) {
78
99
  href = prismicH.asLink(props.field, linkResolver);
79
100
  }
80
- const target = props.target || "field" in props && props.field && "target" in props.field && props.field.target || void 0;
101
+ const isInternal = href && isInternalURL(href);
102
+ const target = props.target || "field" in props && props.field && "target" in props.field && props.field.target || !isInternal && "_blank" || void 0;
81
103
  const rel = props.rel || (target === "_blank" ? "noopener noreferrer" : void 0);
82
104
  const InternalComponent = props.internalComponent || context.internalLinkComponent || defaultInternalComponent;
83
105
  const ExternalComponent = props.externalComponent || context.externalLinkComponent || defaultExternalComponent;
84
- const isInternal = href && isInternalURL(href);
85
106
  const Component = isInternal ? InternalComponent : ExternalComponent;
86
107
  const passthroughProps = Object.assign({}, props);
87
108
  delete passthroughProps.linkResolver;
@@ -110,6 +131,11 @@ if (!__PRODUCTION__) {
110
131
  const PrismicLink = React.forwardRef(_PrismicLink);
111
132
 
112
133
  const PrismicText = (props) => {
134
+ if (!__PRODUCTION__) {
135
+ if (typeof props.field === "string") {
136
+ throw new Error(`[PrismicText] The "field" prop only accepts a Rich Text or Title field's value but was provided a different type of field instead (e.g. a Key Text or Select field). You can resolve this error by rendering the field value inline without <PrismicText>. For more details, see ${devMsg("prismictext-works-only-with-rich-text-and-title-fields")}`);
137
+ }
138
+ }
113
139
  return React.useMemo(() => {
114
140
  if (prismicH.isFilled.richText(props.field)) {
115
141
  const text = prismicH.asText(props.field, props.separator);
@@ -254,12 +280,6 @@ const PrismicRichText = (props) => {
254
280
  ]);
255
281
  };
256
282
 
257
- var version = "2.3.0";
258
-
259
- const devMsg = (slug) => {
260
- return `https://prismic.dev/msg/react/v${version}/${slug}`;
261
- };
262
-
263
283
  const _PrismicImage = (props, ref) => {
264
284
  const {
265
285
  field,
@@ -272,13 +292,13 @@ const _PrismicImage = (props, ref) => {
272
292
  } = props;
273
293
  if (!__PRODUCTION__) {
274
294
  if (typeof alt === "string" && props.alt !== "") {
275
- console.warn(`[PrismicImage] The alt prop can only be used to declare an image as decorative by passing an empty string (alt=""). For more details, see ${devMsg("alt-must-be-an-empty-string")}`);
295
+ console.warn(`[PrismicImage] The "alt" prop can only be used to declare an image as decorative by passing an empty string (alt="") but was provided a non-empty string. You can resolve this warning by removing the "alt" prop or changing it to alt="". For more details, see ${devMsg("alt-must-be-an-empty-string")}`);
276
296
  }
277
297
  if (typeof fallbackAlt === "string" && fallbackAlt !== "") {
278
- console.warn(`[PrismicImage] The fallbackAlt prop can only be used to declare an image as decorative by passing an empty string (fallbackAlt=""). For more details, see ${devMsg("alt-must-be-an-empty-string")}`);
298
+ console.warn(`[PrismicImage] The "fallbackAlt" prop can only be used to declare an image as decorative by passing an empty string (fallbackAlt="") but was provided a non-empty string. You can resolve this warning by removing the "fallbackAlt" prop or changing it to fallbackAlt="". For more details, see ${devMsg("alt-must-be-an-empty-string")}`);
279
299
  }
280
300
  if (widths && pixelDensities) {
281
- console.warn(`[PrismicImage] Only one of "widths" or "pixelDensities" props can be provided. "widths" will be used in this case.`);
301
+ console.warn(`[PrismicImage] Only one of "widths" or "pixelDensities" props can be provided. You can resolve this warning by removing either the "widths" or "pixelDensities" prop. "widths" will be used in this case.`);
282
302
  }
283
303
  }
284
304
  if (prismicH.isFilled.imageThumbnail(field)) {
@@ -382,6 +402,9 @@ const PrismicToolbar = ({
382
402
  script.dataset.prismicToolbar = "";
383
403
  script.dataset.repositoryName = repositoryName;
384
404
  script.dataset.type = type;
405
+ if (process.env.NODE_ENV === "test") {
406
+ script._evaluateScript = false;
407
+ }
385
408
  document.body.appendChild(script);
386
409
  }
387
410
  }, [repositoryName, type, src]);