@prismicio/react 2.2.0 → 2.3.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/dist/index.cjs +65 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +181 -3
- package/dist/index.js +65 -1
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
- package/src/PrismicImage.tsx +185 -0
- package/src/PrismicLink.tsx +28 -23
- package/src/index.ts +3 -0
- package/src/lib/devMsg.ts +20 -0
package/dist/index.d.ts
CHANGED
|
@@ -31,7 +31,7 @@ interface LinkProps {
|
|
|
31
31
|
/**
|
|
32
32
|
* Props for `<PrismicLink>`.
|
|
33
33
|
*/
|
|
34
|
-
declare type PrismicLinkProps<InternalComponent extends React.ElementType<LinkProps> =
|
|
34
|
+
declare type PrismicLinkProps<InternalComponent extends React.ElementType<LinkProps> = typeof defaultInternalComponent, ExternalComponent extends React.ElementType<LinkProps> = typeof defaultInternalComponent, LinkResolverFunction extends prismicH.LinkResolverFunction<any> = prismicH.LinkResolverFunction> = Omit<React.ComponentPropsWithoutRef<InternalComponent> & React.ComponentPropsWithoutRef<ExternalComponent>, keyof LinkProps> & {
|
|
35
35
|
/**
|
|
36
36
|
* The Link Resolver used to resolve links.
|
|
37
37
|
*
|
|
@@ -84,7 +84,26 @@ declare type PrismicLinkProps<InternalComponent extends React.ElementType<LinkPr
|
|
|
84
84
|
*/
|
|
85
85
|
href: string | null | undefined;
|
|
86
86
|
});
|
|
87
|
-
|
|
87
|
+
/**
|
|
88
|
+
* The default component rendered for internal URLs.
|
|
89
|
+
*/
|
|
90
|
+
declare const defaultInternalComponent = "a";
|
|
91
|
+
/**
|
|
92
|
+
* React component that renders a link from a Prismic Link field.
|
|
93
|
+
*
|
|
94
|
+
* Different components can be rendered depending on whether the link is
|
|
95
|
+
* internal or external. This is helpful when integrating with client-side
|
|
96
|
+
* routers, such as a router-specific Link component.
|
|
97
|
+
*
|
|
98
|
+
* If a link is configured to open in a new window using `target="_blank"`,
|
|
99
|
+
* `rel="noopener noreferrer"` is set by default.
|
|
100
|
+
*
|
|
101
|
+
* @param props - Props for the component.
|
|
102
|
+
*
|
|
103
|
+
* @returns The internal or external link component depending on whether the
|
|
104
|
+
* link is internal or external.
|
|
105
|
+
*/
|
|
106
|
+
declare const PrismicLink: <InternalComponent extends React.ElementType<LinkProps> = "a", ExternalComponent extends React.ElementType<LinkProps> = "a", LinkResolverFunction extends prismicH.LinkResolverFunction<any> = prismicH.LinkResolverFunction<string>>(props: PrismicLinkProps<InternalComponent, ExternalComponent, LinkResolverFunction> & {
|
|
88
107
|
ref?: React.Ref<Element> | undefined;
|
|
89
108
|
}) => JSX.Element | null;
|
|
90
109
|
|
|
@@ -348,6 +367,165 @@ declare type PrismicRichTextProps<LinkResolverFunction extends prismicH.LinkReso
|
|
|
348
367
|
*/
|
|
349
368
|
declare const PrismicRichText: <LinkResolverFunction extends prismicH.LinkResolverFunction<any> = prismicH.LinkResolverFunction<string>>(props: PrismicRichTextProps<LinkResolverFunction>) => JSX.Element | null;
|
|
350
369
|
|
|
370
|
+
/**
|
|
371
|
+
* Props for `<PrismicImage>`.
|
|
372
|
+
*/
|
|
373
|
+
declare type PrismicImageProps = Omit<React.DetailedHTMLProps<React.ImgHTMLAttributes<HTMLImageElement>, HTMLImageElement>, "src" | "srcset" | "alt"> & {
|
|
374
|
+
/**
|
|
375
|
+
* The Prismic Image field or thumbnail to render.
|
|
376
|
+
*/
|
|
377
|
+
field: prismicT.ImageFieldImage | null | undefined;
|
|
378
|
+
/**
|
|
379
|
+
* An object of Imgix URL API parameters to transform the image.
|
|
380
|
+
*
|
|
381
|
+
* See: https://docs.imgix.com/apis/rendering
|
|
382
|
+
*/
|
|
383
|
+
imgixParams?: Parameters<typeof prismicH.asImageSrc>[1];
|
|
384
|
+
/**
|
|
385
|
+
* Declare an image as decorative by providing `alt=""`.
|
|
386
|
+
*
|
|
387
|
+
* See:
|
|
388
|
+
* https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/alt#decorative_images
|
|
389
|
+
*/
|
|
390
|
+
alt?: "";
|
|
391
|
+
/**
|
|
392
|
+
* Declare an image as decorative only if the Image field does not have
|
|
393
|
+
* alternative text by providing `fallbackAlt=""`.
|
|
394
|
+
*
|
|
395
|
+
* See:
|
|
396
|
+
* https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/alt#decorative_images
|
|
397
|
+
*/
|
|
398
|
+
fallbackAlt?: "";
|
|
399
|
+
} & ({
|
|
400
|
+
/**
|
|
401
|
+
* Widths used to build a `srcset` value for the Image field.
|
|
402
|
+
*
|
|
403
|
+
* If a `widths` prop is not given or `"defaults"` is passed, the
|
|
404
|
+
* following widths will be used: 640, 750, 828, 1080, 1200, 1920, 2048, 3840.
|
|
405
|
+
*
|
|
406
|
+
* If the Image field contains responsive views, each responsive view
|
|
407
|
+
* can be used as a width in the resulting `srcset` by passing
|
|
408
|
+
* `"thumbnails"` as the `widths` prop.
|
|
409
|
+
*/
|
|
410
|
+
widths?: NonNullable<Parameters<typeof prismicH.asImageWidthSrcSet>[1]>["widths"] | "defaults";
|
|
411
|
+
/**
|
|
412
|
+
* Not used when the `widths` prop is used.
|
|
413
|
+
*/
|
|
414
|
+
pixelDensities?: never;
|
|
415
|
+
} | {
|
|
416
|
+
/**
|
|
417
|
+
* Not used when the `widths` prop is used.
|
|
418
|
+
*/
|
|
419
|
+
widths?: never;
|
|
420
|
+
/**
|
|
421
|
+
* Pixel densities used to build a `srcset` value for the Image field.
|
|
422
|
+
*
|
|
423
|
+
* If a `pixelDensities` prop is passed `"defaults"`, the following
|
|
424
|
+
* pixel densities will be used: 1, 2, 3.
|
|
425
|
+
*/
|
|
426
|
+
pixelDensities: NonNullable<Parameters<typeof prismicH.asImagePixelDensitySrcSet>[1]>["pixelDensities"] | "defaults";
|
|
427
|
+
});
|
|
428
|
+
/**
|
|
429
|
+
* React component that renders an image from a Prismic Image field or one of
|
|
430
|
+
* its thumbnails. It will automatically set the `alt` attribute using the Image
|
|
431
|
+
* field's `alt` property.
|
|
432
|
+
*
|
|
433
|
+
* By default, a widths-based srcset will be used to support responsive images.
|
|
434
|
+
* This ensures only the smallest image needed for a browser is downloaded.
|
|
435
|
+
*
|
|
436
|
+
* To use a pixel-density-based srcset, use the `pixelDensities` prop. Default
|
|
437
|
+
* pixel densities can be used by using `pixelDensities="defaults"`.
|
|
438
|
+
*
|
|
439
|
+
* **Note**: If you are using a framework that has a native image component,
|
|
440
|
+
* such as Next.js and Gatsby, prefer using those image components instead. They
|
|
441
|
+
* can provide deeper framework integration than `<PrismicImage>`.
|
|
442
|
+
*
|
|
443
|
+
* @param props - Props for the component.
|
|
444
|
+
*
|
|
445
|
+
* @returns A responsive image component for the given Image field.
|
|
446
|
+
*/
|
|
447
|
+
declare const PrismicImage: React.ForwardRefExoticComponent<(Pick<Omit<React.DetailedHTMLProps<React.ImgHTMLAttributes<HTMLImageElement>, HTMLImageElement>, "alt" | "src" | "srcset"> & {
|
|
448
|
+
/**
|
|
449
|
+
* The Prismic Image field or thumbnail to render.
|
|
450
|
+
*/
|
|
451
|
+
field: prismicT.ImageFieldImage | null | undefined;
|
|
452
|
+
/**
|
|
453
|
+
* An object of Imgix URL API parameters to transform the image.
|
|
454
|
+
*
|
|
455
|
+
* See: https://docs.imgix.com/apis/rendering
|
|
456
|
+
*/
|
|
457
|
+
imgixParams?: Parameters<typeof prismicH.asImageSrc>[1];
|
|
458
|
+
/**
|
|
459
|
+
* Declare an image as decorative by providing `alt=""`.
|
|
460
|
+
*
|
|
461
|
+
* See:
|
|
462
|
+
* https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/alt#decorative_images
|
|
463
|
+
*/
|
|
464
|
+
alt?: "" | undefined;
|
|
465
|
+
/**
|
|
466
|
+
* Declare an image as decorative only if the Image field does not have
|
|
467
|
+
* alternative text by providing `fallbackAlt=""`.
|
|
468
|
+
*
|
|
469
|
+
* See:
|
|
470
|
+
* https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/alt#decorative_images
|
|
471
|
+
*/
|
|
472
|
+
fallbackAlt?: "" | undefined;
|
|
473
|
+
} & {
|
|
474
|
+
/**
|
|
475
|
+
* Widths used to build a `srcset` value for the Image field.
|
|
476
|
+
*
|
|
477
|
+
* If a `widths` prop is not given or `"defaults"` is passed, the
|
|
478
|
+
* following widths will be used: 640, 750, 828, 1080, 1200, 1920, 2048, 3840.
|
|
479
|
+
*
|
|
480
|
+
* If the Image field contains responsive views, each responsive view
|
|
481
|
+
* can be used as a width in the resulting `srcset` by passing
|
|
482
|
+
* `"thumbnails"` as the `widths` prop.
|
|
483
|
+
*/
|
|
484
|
+
widths?: NonNullable<Parameters<typeof prismicH.asImageWidthSrcSet>[1]>["widths"] | "defaults";
|
|
485
|
+
/**
|
|
486
|
+
* Not used when the `widths` prop is used.
|
|
487
|
+
*/
|
|
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"> & {
|
|
490
|
+
/**
|
|
491
|
+
* The Prismic Image field or thumbnail to render.
|
|
492
|
+
*/
|
|
493
|
+
field: prismicT.ImageFieldImage | null | undefined;
|
|
494
|
+
/**
|
|
495
|
+
* An object of Imgix URL API parameters to transform the image.
|
|
496
|
+
*
|
|
497
|
+
* See: https://docs.imgix.com/apis/rendering
|
|
498
|
+
*/
|
|
499
|
+
imgixParams?: Parameters<typeof prismicH.asImageSrc>[1];
|
|
500
|
+
/**
|
|
501
|
+
* Declare an image as decorative by providing `alt=""`.
|
|
502
|
+
*
|
|
503
|
+
* See:
|
|
504
|
+
* https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/alt#decorative_images
|
|
505
|
+
*/
|
|
506
|
+
alt?: "" | undefined;
|
|
507
|
+
/**
|
|
508
|
+
* Declare an image as decorative only if the Image field does not have
|
|
509
|
+
* alternative text by providing `fallbackAlt=""`.
|
|
510
|
+
*
|
|
511
|
+
* See:
|
|
512
|
+
* https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/alt#decorative_images
|
|
513
|
+
*/
|
|
514
|
+
fallbackAlt?: "" | undefined;
|
|
515
|
+
} & {
|
|
516
|
+
/**
|
|
517
|
+
* Not used when the `widths` prop is used.
|
|
518
|
+
*/
|
|
519
|
+
widths?: undefined;
|
|
520
|
+
/**
|
|
521
|
+
* Pixel densities used to build a `srcset` value for the Image field.
|
|
522
|
+
*
|
|
523
|
+
* If a `pixelDensities` prop is passed `"defaults"`, the following
|
|
524
|
+
* pixel densities will be used: 1, 2, 3.
|
|
525
|
+
*/
|
|
526
|
+
pixelDensities: NonNullable<Parameters<typeof prismicH.asImagePixelDensitySrcSet>[1]>["pixelDensities"] | "defaults";
|
|
527
|
+
}, "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">) & React.RefAttributes<HTMLImageElement>>;
|
|
528
|
+
|
|
351
529
|
declare type WordSeparators = "-" | "_" | " ";
|
|
352
530
|
declare type Split<S extends string, Delimiter extends string> = S extends `${infer Head}${Delimiter}${infer Tail}` ? [Head, ...Split<Tail, Delimiter>] : S extends Delimiter ? [] : [S];
|
|
353
531
|
declare 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>}` : "";
|
|
@@ -1106,4 +1284,4 @@ declare const Elements: {
|
|
|
1106
1284
|
readonly span: "span";
|
|
1107
1285
|
};
|
|
1108
1286
|
|
|
1109
|
-
export { Elements, JSXFunctionSerializer, JSXMapSerializer, LinkProps, PrismicClientHookState, PrismicContextValue, 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 };
|
|
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 };
|
package/dist/index.js
CHANGED
|
@@ -104,6 +104,9 @@ const _PrismicLink = (props, ref) => {
|
|
|
104
104
|
rel
|
|
105
105
|
}) : null;
|
|
106
106
|
};
|
|
107
|
+
if (!__PRODUCTION__) {
|
|
108
|
+
_PrismicLink.displayName = "PrismicLink";
|
|
109
|
+
}
|
|
107
110
|
const PrismicLink = React.forwardRef(_PrismicLink);
|
|
108
111
|
|
|
109
112
|
const PrismicText = (props) => {
|
|
@@ -251,6 +254,67 @@ const PrismicRichText = (props) => {
|
|
|
251
254
|
]);
|
|
252
255
|
};
|
|
253
256
|
|
|
257
|
+
var version = "2.3.0";
|
|
258
|
+
|
|
259
|
+
const devMsg = (slug) => {
|
|
260
|
+
return `https://prismic.dev/msg/react/v${version}/${slug}`;
|
|
261
|
+
};
|
|
262
|
+
|
|
263
|
+
const _PrismicImage = (props, ref) => {
|
|
264
|
+
const {
|
|
265
|
+
field,
|
|
266
|
+
alt,
|
|
267
|
+
fallbackAlt,
|
|
268
|
+
imgixParams,
|
|
269
|
+
widths,
|
|
270
|
+
pixelDensities,
|
|
271
|
+
...restProps
|
|
272
|
+
} = props;
|
|
273
|
+
if (!__PRODUCTION__) {
|
|
274
|
+
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")}`);
|
|
276
|
+
}
|
|
277
|
+
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")}`);
|
|
279
|
+
}
|
|
280
|
+
if (widths && pixelDensities) {
|
|
281
|
+
console.warn(`[PrismicImage] Only one of "widths" or "pixelDensities" props can be provided. "widths" will be used in this case.`);
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
if (prismicH.isFilled.imageThumbnail(field)) {
|
|
285
|
+
let src;
|
|
286
|
+
let srcSet;
|
|
287
|
+
if (widths || !pixelDensities) {
|
|
288
|
+
const res = prismicH.asImageWidthSrcSet(field, {
|
|
289
|
+
...imgixParams,
|
|
290
|
+
widths: widths === "defaults" ? void 0 : widths
|
|
291
|
+
});
|
|
292
|
+
src = res.src;
|
|
293
|
+
srcSet = res.srcset;
|
|
294
|
+
} else if (pixelDensities) {
|
|
295
|
+
const res = prismicH.asImagePixelDensitySrcSet(field, {
|
|
296
|
+
...imgixParams,
|
|
297
|
+
pixelDensities: pixelDensities === "defaults" ? void 0 : pixelDensities
|
|
298
|
+
});
|
|
299
|
+
src = res.src;
|
|
300
|
+
srcSet = res.srcset;
|
|
301
|
+
}
|
|
302
|
+
return /* @__PURE__ */ React.createElement("img", {
|
|
303
|
+
ref,
|
|
304
|
+
src,
|
|
305
|
+
srcSet,
|
|
306
|
+
alt: alt != null ? alt : field.alt || fallbackAlt,
|
|
307
|
+
...restProps
|
|
308
|
+
});
|
|
309
|
+
} else {
|
|
310
|
+
return null;
|
|
311
|
+
}
|
|
312
|
+
};
|
|
313
|
+
if (!__PRODUCTION__) {
|
|
314
|
+
_PrismicImage.displayName = "PrismicImage";
|
|
315
|
+
}
|
|
316
|
+
const PrismicImage = React.forwardRef(_PrismicImage);
|
|
317
|
+
|
|
254
318
|
const pascalCase = (input) => {
|
|
255
319
|
const camelCased = input.replace(/(?:-|_)(\w)/g, (_, c) => {
|
|
256
320
|
return c ? c.toUpperCase() : "";
|
|
@@ -430,5 +494,5 @@ const useAllPrismicDocumentsByEveryTag = (...args) => useStatefulPrismicClientMe
|
|
|
430
494
|
|
|
431
495
|
const Elements = Element;
|
|
432
496
|
|
|
433
|
-
export { Elements, PrismicLink, PrismicProvider, PrismicRichText, PrismicText, PrismicToolbar, SliceZone, TODOSliceComponent, useAllPrismicDocumentsByEveryTag, useAllPrismicDocumentsByIDs, useAllPrismicDocumentsBySomeTags, useAllPrismicDocumentsByTag, useAllPrismicDocumentsByType, useAllPrismicDocumentsByUIDs, useAllPrismicDocumentsDangerously, useFirstPrismicDocument, usePrismicClient, usePrismicContext, usePrismicDocumentByID, usePrismicDocumentByUID, usePrismicDocuments, usePrismicDocumentsByEveryTag, usePrismicDocumentsByIDs, usePrismicDocumentsBySomeTags, usePrismicDocumentsByTag, usePrismicDocumentsByType, usePrismicDocumentsByUIDs, usePrismicPreviewResolver, useSinglePrismicDocument };
|
|
497
|
+
export { Elements, PrismicImage, PrismicLink, PrismicProvider, PrismicRichText, PrismicText, PrismicToolbar, SliceZone, TODOSliceComponent, useAllPrismicDocumentsByEveryTag, useAllPrismicDocumentsByIDs, useAllPrismicDocumentsBySomeTags, useAllPrismicDocumentsByTag, useAllPrismicDocumentsByType, useAllPrismicDocumentsByUIDs, useAllPrismicDocumentsDangerously, useFirstPrismicDocument, usePrismicClient, usePrismicContext, usePrismicDocumentByID, usePrismicDocumentByUID, usePrismicDocuments, usePrismicDocumentsByEveryTag, usePrismicDocumentsByIDs, usePrismicDocumentsBySomeTags, usePrismicDocumentsByTag, usePrismicDocumentsByType, usePrismicDocumentsByUIDs, usePrismicPreviewResolver, useSinglePrismicDocument };
|
|
434
498
|
//# sourceMappingURL=index.js.map
|