@prismicio/react 2.5.1 → 2.6.0-alpha.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.
Files changed (92) hide show
  1. package/dist/PrismicImage.cjs +7 -11
  2. package/dist/PrismicImage.cjs.map +1 -1
  3. package/dist/PrismicImage.d.ts +162 -163
  4. package/dist/PrismicImage.js +6 -10
  5. package/dist/PrismicImage.js.map +1 -1
  6. package/dist/PrismicLink.cjs +4 -66
  7. package/dist/PrismicLink.cjs.map +1 -1
  8. package/dist/PrismicLink.d.ts +6 -105
  9. package/dist/PrismicLink.js +4 -65
  10. package/dist/PrismicLink.js.map +1 -1
  11. package/dist/PrismicProvider.cjs.map +1 -1
  12. package/dist/PrismicProvider.d.ts +83 -84
  13. package/dist/PrismicProvider.js.map +1 -1
  14. package/dist/PrismicRichText.cjs +4 -71
  15. package/dist/PrismicRichText.cjs.map +1 -1
  16. package/dist/PrismicRichText.d.ts +4 -116
  17. package/dist/PrismicRichText.js +5 -70
  18. package/dist/PrismicRichText.js.map +1 -1
  19. package/dist/PrismicText.cjs +4 -4
  20. package/dist/PrismicText.cjs.map +1 -1
  21. package/dist/PrismicText.d.ts +39 -39
  22. package/dist/PrismicText.js +3 -3
  23. package/dist/PrismicText.js.map +1 -1
  24. package/dist/PrismicToolbar.cjs +6 -4
  25. package/dist/PrismicToolbar.cjs.map +1 -1
  26. package/dist/PrismicToolbar.d.ts +23 -21
  27. package/dist/PrismicToolbar.js +6 -4
  28. package/dist/PrismicToolbar.js.map +1 -1
  29. package/dist/SliceZone.cjs +4 -17
  30. package/dist/SliceZone.cjs.map +1 -1
  31. package/dist/SliceZone.d.ts +127 -188
  32. package/dist/SliceZone.js +4 -17
  33. package/dist/SliceZone.js.map +1 -1
  34. package/dist/clientHooks.d.ts +357 -357
  35. package/dist/index.cjs +0 -2
  36. package/dist/index.cjs.map +1 -1
  37. package/dist/index.d.ts +21 -46
  38. package/dist/index.js +1 -4
  39. package/dist/index.js.map +1 -1
  40. package/dist/lib/__PRODUCTION__.d.ts +7 -7
  41. package/dist/lib/devMsg.d.ts +16 -16
  42. package/dist/lib/invariant.d.ts +24 -24
  43. package/dist/lib/isInternalURL.d.ts +8 -8
  44. package/dist/lib/pascalCase.d.ts +26 -26
  45. package/dist/package.json.cjs +1 -1
  46. package/dist/package.json.js +1 -1
  47. package/dist/react-server/PrismicLink.cjs +59 -0
  48. package/dist/react-server/PrismicLink.cjs.map +1 -0
  49. package/dist/react-server/PrismicLink.d.ts +72 -0
  50. package/dist/react-server/PrismicLink.js +42 -0
  51. package/dist/react-server/PrismicLink.js.map +1 -0
  52. package/dist/react-server/PrismicRichText.cjs +92 -0
  53. package/dist/react-server/PrismicRichText.cjs.map +1 -0
  54. package/dist/react-server/PrismicRichText.d.ts +104 -0
  55. package/dist/react-server/PrismicRichText.js +73 -0
  56. package/dist/react-server/PrismicRichText.js.map +1 -0
  57. package/dist/react-server/index.d.ts +4 -0
  58. package/dist/react-server/unsupported.cjs +97 -0
  59. package/dist/react-server/unsupported.cjs.map +1 -0
  60. package/dist/react-server/unsupported.d.ts +22 -0
  61. package/dist/react-server/unsupported.js +97 -0
  62. package/dist/react-server/unsupported.js.map +1 -0
  63. package/dist/react-server.cjs +44 -0
  64. package/dist/react-server.cjs.map +1 -0
  65. package/dist/react-server.js +41 -0
  66. package/dist/react-server.js.map +1 -0
  67. package/dist/types.d.ts +19 -19
  68. package/dist/usePrismicClient.d.ts +11 -11
  69. package/dist/usePrismicContext.d.ts +8 -8
  70. package/dist/usePrismicPreviewResolver.d.ts +45 -45
  71. package/dist/useStatefulPrismicClientMethod.cjs +6 -0
  72. package/dist/useStatefulPrismicClientMethod.cjs.map +1 -1
  73. package/dist/useStatefulPrismicClientMethod.d.ts +44 -44
  74. package/dist/useStatefulPrismicClientMethod.js +6 -0
  75. package/dist/useStatefulPrismicClientMethod.js.map +1 -1
  76. package/package.json +42 -47
  77. package/src/PrismicImage.tsx +30 -37
  78. package/src/PrismicLink.tsx +29 -259
  79. package/src/PrismicProvider.tsx +9 -8
  80. package/src/PrismicRichText.tsx +28 -275
  81. package/src/PrismicText.tsx +4 -5
  82. package/src/PrismicToolbar.tsx +7 -6
  83. package/src/SliceZone.tsx +8 -129
  84. package/src/index.ts +1 -9
  85. package/src/react-server/PrismicLink.tsx +179 -0
  86. package/src/react-server/PrismicRichText.tsx +267 -0
  87. package/src/react-server/index.ts +38 -0
  88. package/src/react-server/unsupported.ts +98 -0
  89. package/dist/lib/pascalCase.cjs +0 -10
  90. package/dist/lib/pascalCase.cjs.map +0 -1
  91. package/dist/lib/pascalCase.js +0 -10
  92. package/dist/lib/pascalCase.js.map +0 -1
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
3
  const jsxRuntime = require("react/jsx-runtime");
4
4
  const React = require("react");
5
- const prismicH = require("@prismicio/helpers");
5
+ const prismic = require("@prismicio/client");
6
6
  const __PRODUCTION__ = require("./lib/__PRODUCTION__.cjs");
7
7
  const devMsg = require("./lib/devMsg.cjs");
8
8
  function _interopNamespaceDefault(e) {
@@ -22,8 +22,8 @@ function _interopNamespaceDefault(e) {
22
22
  return Object.freeze(n);
23
23
  }
24
24
  const React__namespace = /* @__PURE__ */ _interopNamespaceDefault(React);
25
- const prismicH__namespace = /* @__PURE__ */ _interopNamespaceDefault(prismicH);
26
- const _PrismicImage = (props, ref) => {
25
+ const prismic__namespace = /* @__PURE__ */ _interopNamespaceDefault(prismic);
26
+ const PrismicImage = React__namespace.forwardRef(function PrismicImage2(props, ref) {
27
27
  const { field, alt, fallbackAlt, imgixParams, widths, pixelDensities, ...restProps } = props;
28
28
  if (!__PRODUCTION__.__PRODUCTION__) {
29
29
  if (typeof alt === "string" && props.alt !== "") {
@@ -36,18 +36,18 @@ const _PrismicImage = (props, ref) => {
36
36
  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.`);
37
37
  }
38
38
  }
39
- if (prismicH__namespace.isFilled.imageThumbnail(field)) {
39
+ if (prismic__namespace.isFilled.imageThumbnail(field)) {
40
40
  let src;
41
41
  let srcSet;
42
42
  if (widths || !pixelDensities) {
43
- const res = prismicH__namespace.asImageWidthSrcSet(field, {
43
+ const res = prismic__namespace.asImageWidthSrcSet(field, {
44
44
  ...imgixParams,
45
45
  widths: widths === "defaults" ? void 0 : widths
46
46
  });
47
47
  src = res.src;
48
48
  srcSet = res.srcset;
49
49
  } else if (pixelDensities) {
50
- const res = prismicH__namespace.asImagePixelDensitySrcSet(field, {
50
+ const res = prismic__namespace.asImagePixelDensitySrcSet(field, {
51
51
  ...imgixParams,
52
52
  pixelDensities: pixelDensities === "defaults" ? void 0 : pixelDensities
53
53
  });
@@ -58,10 +58,6 @@ const _PrismicImage = (props, ref) => {
58
58
  } else {
59
59
  return null;
60
60
  }
61
- };
62
- if (!__PRODUCTION__.__PRODUCTION__) {
63
- _PrismicImage.displayName = "PrismicImage";
64
- }
65
- const PrismicImage = React__namespace.forwardRef(_PrismicImage);
61
+ });
66
62
  exports.PrismicImage = PrismicImage;
67
63
  //# sourceMappingURL=PrismicImage.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"PrismicImage.cjs","sources":["../../src/PrismicImage.tsx"],"sourcesContent":["import * as React from \"react\";\nimport * as prismicT from \"@prismicio/types\";\nimport * as prismicH from \"@prismicio/helpers\";\n\nimport { __PRODUCTION__ } from \"./lib/__PRODUCTION__\";\nimport { devMsg } from \"./lib/devMsg\";\n\n/**\n * Props for `<PrismicImage>`.\n */\nexport type PrismicImageProps = Omit<\n\tReact.DetailedHTMLProps<\n\t\tReact.ImgHTMLAttributes<HTMLImageElement>,\n\t\tHTMLImageElement\n\t>,\n\t\"src\" | \"srcset\" | \"alt\"\n> & {\n\t/**\n\t * The Prismic Image field or thumbnail to render.\n\t */\n\tfield: prismicT.ImageFieldImage | null | undefined;\n\n\t/**\n\t * An object of Imgix URL API parameters to transform the image.\n\t *\n\t * See: https://docs.imgix.com/apis/rendering\n\t */\n\timgixParams?: Parameters<typeof prismicH.asImageSrc>[1];\n\n\t/**\n\t * Declare an image as decorative by providing `alt=\"\"`.\n\t *\n\t * See:\n\t * https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/alt#decorative_images\n\t */\n\talt?: \"\";\n\n\t/**\n\t * Declare an image as decorative only if the Image field does not have\n\t * alternative text by providing `fallbackAlt=\"\"`.\n\t *\n\t * See:\n\t * https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/alt#decorative_images\n\t */\n\tfallbackAlt?: \"\";\n} & (\n\t\t| {\n\t\t\t\t/**\n\t\t\t\t * Widths used to build a `srcset` value for the Image field.\n\t\t\t\t *\n\t\t\t\t * If a `widths` prop is not given or `\"defaults\"` is passed, the\n\t\t\t\t * following widths will be used: 640, 750, 828, 1080, 1200, 1920, 2048,\n\t\t\t\t * 3840.\n\t\t\t\t *\n\t\t\t\t * If the Image field contains responsive views, each responsive view\n\t\t\t\t * can be used as a width in the resulting `srcset` by passing\n\t\t\t\t * `\"thumbnails\"` as the `widths` prop.\n\t\t\t\t */\n\t\t\t\twidths?:\n\t\t\t\t\t| NonNullable<\n\t\t\t\t\t\t\tParameters<typeof prismicH.asImageWidthSrcSet>[1]\n\t\t\t\t\t >[\"widths\"]\n\t\t\t\t\t| \"defaults\";\n\t\t\t\t/**\n\t\t\t\t * Not used when the `widths` prop is used.\n\t\t\t\t */\n\t\t\t\tpixelDensities?: never;\n\t\t }\n\t\t| {\n\t\t\t\t/**\n\t\t\t\t * Not used when the `widths` prop is used.\n\t\t\t\t */\n\t\t\t\twidths?: never;\n\t\t\t\t/**\n\t\t\t\t * Pixel densities used to build a `srcset` value for the Image field.\n\t\t\t\t *\n\t\t\t\t * If a `pixelDensities` prop is passed `\"defaults\"`, the following\n\t\t\t\t * pixel densities will be used: 1, 2, 3.\n\t\t\t\t */\n\t\t\t\tpixelDensities:\n\t\t\t\t\t| NonNullable<\n\t\t\t\t\t\t\tParameters<typeof prismicH.asImagePixelDensitySrcSet>[1]\n\t\t\t\t\t >[\"pixelDensities\"]\n\t\t\t\t\t| \"defaults\";\n\t\t }\n\t);\n\nconst _PrismicImage = (\n\tprops: PrismicImageProps,\n\tref: React.ForwardedRef<HTMLImageElement>,\n): JSX.Element | null => {\n\tconst {\n\t\tfield,\n\t\talt,\n\t\tfallbackAlt,\n\t\timgixParams,\n\t\twidths,\n\t\tpixelDensities,\n\t\t...restProps\n\t} = props;\n\n\tif (!__PRODUCTION__) {\n\t\tif (typeof alt === \"string\" && props.alt !== \"\") {\n\t\t\tconsole.warn(\n\t\t\t\t`[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(\n\t\t\t\t\t\"alt-must-be-an-empty-string\",\n\t\t\t\t)}`,\n\t\t\t);\n\t\t}\n\n\t\tif (typeof fallbackAlt === \"string\" && fallbackAlt !== \"\") {\n\t\t\tconsole.warn(\n\t\t\t\t`[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(\n\t\t\t\t\t\"alt-must-be-an-empty-string\",\n\t\t\t\t)}`,\n\t\t\t);\n\t\t}\n\n\t\tif (widths && pixelDensities) {\n\t\t\tconsole.warn(\n\t\t\t\t`[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.`,\n\t\t\t);\n\t\t}\n\t}\n\n\tif (prismicH.isFilled.imageThumbnail(field)) {\n\t\tlet src: string | undefined;\n\t\tlet srcSet: string | undefined;\n\n\t\tif (widths || !pixelDensities) {\n\t\t\tconst res = prismicH.asImageWidthSrcSet(field, {\n\t\t\t\t...imgixParams,\n\t\t\t\twidths: widths === \"defaults\" ? undefined : widths,\n\t\t\t});\n\n\t\t\tsrc = res.src;\n\t\t\tsrcSet = res.srcset;\n\t\t} else if (pixelDensities) {\n\t\t\tconst res = prismicH.asImagePixelDensitySrcSet(field, {\n\t\t\t\t...imgixParams,\n\t\t\t\tpixelDensities:\n\t\t\t\t\tpixelDensities === \"defaults\" ? undefined : pixelDensities,\n\t\t\t});\n\n\t\t\tsrc = res.src;\n\t\t\tsrcSet = res.srcset;\n\t\t}\n\n\t\treturn (\n\t\t\t<img\n\t\t\t\tref={ref}\n\t\t\t\tsrc={src}\n\t\t\t\tsrcSet={srcSet}\n\t\t\t\talt={alt ?? (field.alt || fallbackAlt)}\n\t\t\t\t{...restProps}\n\t\t\t/>\n\t\t);\n\t} else {\n\t\treturn null;\n\t}\n};\n\nif (!__PRODUCTION__) {\n\t_PrismicImage.displayName = \"PrismicImage\";\n}\n\n/**\n * React component that renders an image from a Prismic Image field or one of\n * its thumbnails. It will automatically set the `alt` attribute using the Image\n * field's `alt` property.\n *\n * By default, a widths-based srcset will be used to support responsive images.\n * This ensures only the smallest image needed for a browser is downloaded.\n *\n * To use a pixel-density-based srcset, use the `pixelDensities` prop. Default\n * pixel densities can be used by using `pixelDensities=\"defaults\"`.\n *\n * **Note**: If you are using a framework that has a native image component,\n * such as Next.js and Gatsby, prefer using those image components instead. They\n * can provide deeper framework integration than `<PrismicImage>`.\n *\n * @param props - Props for the component.\n *\n * @returns A responsive image component for the given Image field.\n */\nexport const PrismicImage = React.forwardRef(_PrismicImage);\n"],"names":["__PRODUCTION__","devMsg","prismicH","jsx","React"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAuFA,MAAM,gBAAgB,CACrB,OACA,QACuB;AACjB,QAAA,EACL,OACA,KACA,aACA,aACA,QACA,mBACG,UACA,IAAA;AAEJ,MAAI,CAACA,eAAAA,gBAAgB;AACpB,QAAI,OAAO,QAAQ,YAAY,MAAM,QAAQ,IAAI;AAChD,cAAQ,KACP,qQAAqQC,OACpQ,OAAA,6BAA6B,GAC3B;AAAA,IAEJ;AAED,QAAI,OAAO,gBAAgB,YAAY,gBAAgB,IAAI;AAC1D,cAAQ,KACP,qSAAqSA,OACpS,OAAA,6BAA6B,GAC3B;AAAA,IAEJ;AAED,QAAI,UAAU,gBAAgB;AAC7B,cAAQ,KACP,2MAA2M;AAAA,IAE5M;AAAA,EACD;AAED,MAAIC,oBAAS,SAAS,eAAe,KAAK,GAAG;AACxC,QAAA;AACA,QAAA;AAEA,QAAA,UAAU,CAAC,gBAAgB;AACxB,YAAA,MAAMA,oBAAS,mBAAmB,OAAO;AAAA,QAC9C,GAAG;AAAA,QACH,QAAQ,WAAW,aAAa,SAAY;AAAA,MAAA,CAC5C;AAED,YAAM,IAAI;AACV,eAAS,IAAI;AAAA,eACH,gBAAgB;AACpB,YAAA,MAAMA,oBAAS,0BAA0B,OAAO;AAAA,QACrD,GAAG;AAAA,QACH,gBACC,mBAAmB,aAAa,SAAY;AAAA,MAAA,CAC7C;AAED,YAAM,IAAI;AACV,eAAS,IAAI;AAAA,IACb;AAGA,WAAAC,2BAAA,IAAC,OACA,EAAA,KACA,KACA,QACA,KAAK,QAAQ,MAAM,OAAO,cAC1B,GAAI,UAAU,CAAA;AAAA,EAAA,OAGV;AACC,WAAA;AAAA,EACP;AACF;AAEA,IAAI,CAACH,+BAAgB;AACpB,gBAAc,cAAc;AAC5B;AAqBY,MAAA,eAAeI,iBAAM,WAAW,aAAa;;"}
1
+ {"version":3,"file":"PrismicImage.cjs","sources":["../../src/PrismicImage.tsx"],"sourcesContent":["import * as React from \"react\";\nimport * as prismic from \"@prismicio/client\";\n\nimport { __PRODUCTION__ } from \"./lib/__PRODUCTION__\";\nimport { devMsg } from \"./lib/devMsg\";\n\n/**\n * Props for `<PrismicImage>`.\n */\nexport type PrismicImageProps = Omit<\n\tReact.DetailedHTMLProps<\n\t\tReact.ImgHTMLAttributes<HTMLImageElement>,\n\t\tHTMLImageElement\n\t>,\n\t\"src\" | \"srcset\" | \"alt\"\n> & {\n\t/**\n\t * The Prismic Image field or thumbnail to render.\n\t */\n\tfield: prismic.ImageFieldImage | null | undefined;\n\n\t/**\n\t * An object of Imgix URL API parameters to transform the image.\n\t *\n\t * See: https://docs.imgix.com/apis/rendering\n\t */\n\timgixParams?: Parameters<typeof prismic.asImageSrc>[1];\n\n\t/**\n\t * Declare an image as decorative by providing `alt=\"\"`.\n\t *\n\t * See:\n\t * https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/alt#decorative_images\n\t */\n\talt?: \"\";\n\n\t/**\n\t * Declare an image as decorative only if the Image field does not have\n\t * alternative text by providing `fallbackAlt=\"\"`.\n\t *\n\t * See:\n\t * https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/alt#decorative_images\n\t */\n\tfallbackAlt?: \"\";\n} & (\n\t\t| {\n\t\t\t\t/**\n\t\t\t\t * Widths used to build a `srcset` value for the Image field.\n\t\t\t\t *\n\t\t\t\t * If a `widths` prop is not given or `\"defaults\"` is passed, the\n\t\t\t\t * following widths will be used: 640, 750, 828, 1080, 1200, 1920, 2048,\n\t\t\t\t * 3840.\n\t\t\t\t *\n\t\t\t\t * If the Image field contains responsive views, each responsive view\n\t\t\t\t * can be used as a width in the resulting `srcset` by passing\n\t\t\t\t * `\"thumbnails\"` as the `widths` prop.\n\t\t\t\t */\n\t\t\t\twidths?:\n\t\t\t\t\t| NonNullable<\n\t\t\t\t\t\t\tParameters<typeof prismic.asImageWidthSrcSet>[1]\n\t\t\t\t\t >[\"widths\"]\n\t\t\t\t\t| \"defaults\";\n\t\t\t\t/**\n\t\t\t\t * Not used when the `widths` prop is used.\n\t\t\t\t */\n\t\t\t\tpixelDensities?: never;\n\t\t }\n\t\t| {\n\t\t\t\t/**\n\t\t\t\t * Not used when the `widths` prop is used.\n\t\t\t\t */\n\t\t\t\twidths?: never;\n\t\t\t\t/**\n\t\t\t\t * Pixel densities used to build a `srcset` value for the Image field.\n\t\t\t\t *\n\t\t\t\t * If a `pixelDensities` prop is passed `\"defaults\"`, the following\n\t\t\t\t * pixel densities will be used: 1, 2, 3.\n\t\t\t\t */\n\t\t\t\tpixelDensities:\n\t\t\t\t\t| NonNullable<\n\t\t\t\t\t\t\tParameters<typeof prismic.asImagePixelDensitySrcSet>[1]\n\t\t\t\t\t >[\"pixelDensities\"]\n\t\t\t\t\t| \"defaults\";\n\t\t }\n\t);\n\n/**\n * React component that renders an image from a Prismic Image field or one of\n * its thumbnails. It will automatically set the `alt` attribute using the Image\n * field's `alt` property.\n *\n * By default, a widths-based srcset will be used to support responsive images.\n * This ensures only the smallest image needed for a browser is downloaded.\n *\n * To use a pixel-density-based srcset, use the `pixelDensities` prop. Default\n * pixel densities can be used by using `pixelDensities=\"defaults\"`.\n *\n * **Note**: If you are using a framework that has a native image component,\n * such as Next.js and Gatsby, prefer using those image components instead. They\n * can provide deeper framework integration than `<PrismicImage>`.\n *\n * @param props - Props for the component.\n *\n * @returns A responsive image component for the given Image field.\n */\nexport const PrismicImage = React.forwardRef(function PrismicImage(\n\tprops: PrismicImageProps,\n\tref: React.ForwardedRef<HTMLImageElement>,\n): JSX.Element | null {\n\tconst {\n\t\tfield,\n\t\talt,\n\t\tfallbackAlt,\n\t\timgixParams,\n\t\twidths,\n\t\tpixelDensities,\n\t\t...restProps\n\t} = props;\n\n\tif (!__PRODUCTION__) {\n\t\tif (typeof alt === \"string\" && props.alt !== \"\") {\n\t\t\tconsole.warn(\n\t\t\t\t`[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(\n\t\t\t\t\t\"alt-must-be-an-empty-string\",\n\t\t\t\t)}`,\n\t\t\t);\n\t\t}\n\n\t\tif (typeof fallbackAlt === \"string\" && fallbackAlt !== \"\") {\n\t\t\tconsole.warn(\n\t\t\t\t`[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(\n\t\t\t\t\t\"alt-must-be-an-empty-string\",\n\t\t\t\t)}`,\n\t\t\t);\n\t\t}\n\n\t\tif (widths && pixelDensities) {\n\t\t\tconsole.warn(\n\t\t\t\t`[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.`,\n\t\t\t);\n\t\t}\n\t}\n\n\tif (prismic.isFilled.imageThumbnail(field)) {\n\t\tlet src: string | undefined;\n\t\tlet srcSet: string | undefined;\n\n\t\tif (widths || !pixelDensities) {\n\t\t\tconst res = prismic.asImageWidthSrcSet(field, {\n\t\t\t\t...imgixParams,\n\t\t\t\twidths: widths === \"defaults\" ? undefined : widths,\n\t\t\t});\n\n\t\t\tsrc = res.src;\n\t\t\tsrcSet = res.srcset;\n\t\t} else if (pixelDensities) {\n\t\t\tconst res = prismic.asImagePixelDensitySrcSet(field, {\n\t\t\t\t...imgixParams,\n\t\t\t\tpixelDensities:\n\t\t\t\t\tpixelDensities === \"defaults\" ? undefined : pixelDensities,\n\t\t\t});\n\n\t\t\tsrc = res.src;\n\t\t\tsrcSet = res.srcset;\n\t\t}\n\n\t\treturn (\n\t\t\t<img\n\t\t\t\tref={ref}\n\t\t\t\tsrc={src}\n\t\t\t\tsrcSet={srcSet}\n\t\t\t\talt={alt ?? (field.alt || fallbackAlt)}\n\t\t\t\t{...restProps}\n\t\t\t/>\n\t\t);\n\t} else {\n\t\treturn null;\n\t}\n});\n"],"names":["React","PrismicImage","__PRODUCTION__","devMsg","prismic","jsx"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAyGO,MAAM,eAAeA,iBAAM,WAAW,SAASC,cACrD,OACA,KAAyC;AAEnC,QAAA,EACL,OACA,KACA,aACA,aACA,QACA,gBACA,GAAG,UACA,IAAA;AAEJ,MAAI,CAACC,eAAAA,gBAAgB;AACpB,QAAI,OAAO,QAAQ,YAAY,MAAM,QAAQ,IAAI;AAChD,cAAQ,KACP,qQAAqQC,OACpQ,OAAA,6BAA6B,GAC3B;AAAA,IAEJ;AAED,QAAI,OAAO,gBAAgB,YAAY,gBAAgB,IAAI;AAC1D,cAAQ,KACP,qSAAqSA,OACpS,OAAA,6BAA6B,GAC3B;AAAA,IAEJ;AAED,QAAI,UAAU,gBAAgB;AAC7B,cAAQ,KACP,2MAA2M;AAAA,IAE5M;AAAA,EACD;AAED,MAAIC,mBAAQ,SAAS,eAAe,KAAK,GAAG;AACvC,QAAA;AACA,QAAA;AAEA,QAAA,UAAU,CAAC,gBAAgB;AACxB,YAAA,MAAMA,mBAAQ,mBAAmB,OAAO;AAAA,QAC7C,GAAG;AAAA,QACH,QAAQ,WAAW,aAAa,SAAY;AAAA,MAAA,CAC5C;AAED,YAAM,IAAI;AACV,eAAS,IAAI;AAAA,eACH,gBAAgB;AACpB,YAAA,MAAMA,mBAAQ,0BAA0B,OAAO;AAAA,QACpD,GAAG;AAAA,QACH,gBACC,mBAAmB,aAAa,SAAY;AAAA,MAAA,CAC7C;AAED,YAAM,IAAI;AACV,eAAS,IAAI;AAAA,IACb;AAGA,WAAAC,2BAAA,IAAC,OACA,EAAA,KACA,KACA,QACA,KAAK,QAAQ,MAAM,OAAO,cAC1B,GAAI,UAAU,CAAA;AAAA,EAAA,OAGV;AACC,WAAA;AAAA,EACP;AACF,CAAC;;"}
@@ -1,163 +1,162 @@
1
- import * as React from "react";
2
- import * as prismicT from "@prismicio/types";
3
- import * as prismicH from "@prismicio/helpers";
4
- /**
5
- * Props for `<PrismicImage>`.
6
- */
7
- export type PrismicImageProps = Omit<React.DetailedHTMLProps<React.ImgHTMLAttributes<HTMLImageElement>, HTMLImageElement>, "src" | "srcset" | "alt"> & {
8
- /**
9
- * The Prismic Image field or thumbnail to render.
10
- */
11
- field: prismicT.ImageFieldImage | null | undefined;
12
- /**
13
- * An object of Imgix URL API parameters to transform the image.
14
- *
15
- * See: https://docs.imgix.com/apis/rendering
16
- */
17
- imgixParams?: Parameters<typeof prismicH.asImageSrc>[1];
18
- /**
19
- * Declare an image as decorative by providing `alt=""`.
20
- *
21
- * See:
22
- * https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/alt#decorative_images
23
- */
24
- alt?: "";
25
- /**
26
- * Declare an image as decorative only if the Image field does not have
27
- * alternative text by providing `fallbackAlt=""`.
28
- *
29
- * See:
30
- * https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/alt#decorative_images
31
- */
32
- fallbackAlt?: "";
33
- } & ({
34
- /**
35
- * Widths used to build a `srcset` value for the Image field.
36
- *
37
- * If a `widths` prop is not given or `"defaults"` is passed, the
38
- * following widths will be used: 640, 750, 828, 1080, 1200, 1920, 2048,
39
- * 3840.
40
- *
41
- * If the Image field contains responsive views, each responsive view
42
- * can be used as a width in the resulting `srcset` by passing
43
- * `"thumbnails"` as the `widths` prop.
44
- */
45
- widths?: NonNullable<Parameters<typeof prismicH.asImageWidthSrcSet>[1]>["widths"] | "defaults";
46
- /**
47
- * Not used when the `widths` prop is used.
48
- */
49
- pixelDensities?: never;
50
- } | {
51
- /**
52
- * Not used when the `widths` prop is used.
53
- */
54
- widths?: never;
55
- /**
56
- * Pixel densities used to build a `srcset` value for the Image field.
57
- *
58
- * If a `pixelDensities` prop is passed `"defaults"`, the following
59
- * pixel densities will be used: 1, 2, 3.
60
- */
61
- pixelDensities: NonNullable<Parameters<typeof prismicH.asImagePixelDensitySrcSet>[1]>["pixelDensities"] | "defaults";
62
- });
63
- /**
64
- * React component that renders an image from a Prismic Image field or one of
65
- * its thumbnails. It will automatically set the `alt` attribute using the Image
66
- * field's `alt` property.
67
- *
68
- * By default, a widths-based srcset will be used to support responsive images.
69
- * This ensures only the smallest image needed for a browser is downloaded.
70
- *
71
- * To use a pixel-density-based srcset, use the `pixelDensities` prop. Default
72
- * pixel densities can be used by using `pixelDensities="defaults"`.
73
- *
74
- * **Note**: If you are using a framework that has a native image component,
75
- * such as Next.js and Gatsby, prefer using those image components instead. They
76
- * can provide deeper framework integration than `<PrismicImage>`.
77
- *
78
- * @param props - Props for the component.
79
- *
80
- * @returns A responsive image component for the given Image field.
81
- */
82
- export declare const PrismicImage: React.ForwardRefExoticComponent<(Pick<Omit<React.DetailedHTMLProps<React.ImgHTMLAttributes<HTMLImageElement>, HTMLImageElement>, "src" | "alt" | "srcset"> & {
83
- /**
84
- * The Prismic Image field or thumbnail to render.
85
- */
86
- field: prismicT.ImageFieldImage | null | undefined;
87
- /**
88
- * An object of Imgix URL API parameters to transform the image.
89
- *
90
- * See: https://docs.imgix.com/apis/rendering
91
- */
92
- imgixParams?: Parameters<typeof prismicH.asImageSrc>[1];
93
- /**
94
- * Declare an image as decorative by providing `alt=""`.
95
- *
96
- * See:
97
- * https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/alt#decorative_images
98
- */
99
- alt?: "" | undefined;
100
- /**
101
- * Declare an image as decorative only if the Image field does not have
102
- * alternative text by providing `fallbackAlt=""`.
103
- *
104
- * See:
105
- * https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/alt#decorative_images
106
- */
107
- fallbackAlt?: "" | undefined;
108
- } & {
109
- /**
110
- * Widths used to build a `srcset` value for the Image field.
111
- *
112
- * If a `widths` prop is not given or `"defaults"` is passed, the
113
- * following widths will be used: 640, 750, 828, 1080, 1200, 1920, 2048,
114
- * 3840.
115
- *
116
- * If the Image field contains responsive views, each responsive view
117
- * can be used as a width in the resulting `srcset` by passing
118
- * `"thumbnails"` as the `widths` prop.
119
- */
120
- widths?: NonNullable<Parameters<typeof prismicH.asImageWidthSrcSet>[1]>["widths"] | "defaults";
121
- /**
122
- * Not used when the `widths` prop is used.
123
- */
124
- pixelDensities?: undefined;
125
- }, "alt" | "crossOrigin" | "decoding" | "height" | "loading" | "referrerPolicy" | "sizes" | "srcSet" | "useMap" | "width" | "key" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "className" | "contentEditable" | "contextMenu" | "dir" | "draggable" | "hidden" | "id" | "lang" | "nonce" | "placeholder" | "slot" | "spellCheck" | "style" | "tabIndex" | "title" | "translate" | "radioGroup" | "role" | "about" | "datatype" | "inlist" | "prefix" | "property" | "resource" | "typeof" | "vocab" | "autoCapitalize" | "autoCorrect" | "autoSave" | "color" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "inputMode" | "is" | "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" | "children" | "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" | "onResize" | "onResizeCapture" | "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" | "widths" | "pixelDensities" | "field" | "imgixParams" | "fallbackAlt"> | Pick<Omit<React.DetailedHTMLProps<React.ImgHTMLAttributes<HTMLImageElement>, HTMLImageElement>, "src" | "alt" | "srcset"> & {
126
- /**
127
- * The Prismic Image field or thumbnail to render.
128
- */
129
- field: prismicT.ImageFieldImage | null | undefined;
130
- /**
131
- * An object of Imgix URL API parameters to transform the image.
132
- *
133
- * See: https://docs.imgix.com/apis/rendering
134
- */
135
- imgixParams?: Parameters<typeof prismicH.asImageSrc>[1];
136
- /**
137
- * Declare an image as decorative by providing `alt=""`.
138
- *
139
- * See:
140
- * https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/alt#decorative_images
141
- */
142
- alt?: "" | undefined;
143
- /**
144
- * Declare an image as decorative only if the Image field does not have
145
- * alternative text by providing `fallbackAlt=""`.
146
- *
147
- * See:
148
- * https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/alt#decorative_images
149
- */
150
- fallbackAlt?: "" | undefined;
151
- } & {
152
- /**
153
- * Not used when the `widths` prop is used.
154
- */
155
- widths?: undefined;
156
- /**
157
- * Pixel densities used to build a `srcset` value for the Image field.
158
- *
159
- * If a `pixelDensities` prop is passed `"defaults"`, the following
160
- * pixel densities will be used: 1, 2, 3.
161
- */
162
- pixelDensities: NonNullable<Parameters<typeof prismicH.asImagePixelDensitySrcSet>[1]>["pixelDensities"] | "defaults";
163
- }, "alt" | "crossOrigin" | "decoding" | "height" | "loading" | "referrerPolicy" | "sizes" | "srcSet" | "useMap" | "width" | "key" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "className" | "contentEditable" | "contextMenu" | "dir" | "draggable" | "hidden" | "id" | "lang" | "nonce" | "placeholder" | "slot" | "spellCheck" | "style" | "tabIndex" | "title" | "translate" | "radioGroup" | "role" | "about" | "datatype" | "inlist" | "prefix" | "property" | "resource" | "typeof" | "vocab" | "autoCapitalize" | "autoCorrect" | "autoSave" | "color" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "inputMode" | "is" | "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" | "children" | "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" | "onResize" | "onResizeCapture" | "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" | "widths" | "pixelDensities" | "field" | "imgixParams" | "fallbackAlt">) & React.RefAttributes<HTMLImageElement>>;
1
+ import * as React from "react";
2
+ import * as prismic from "@prismicio/client";
3
+ /**
4
+ * Props for `<PrismicImage>`.
5
+ */
6
+ export type PrismicImageProps = Omit<React.DetailedHTMLProps<React.ImgHTMLAttributes<HTMLImageElement>, HTMLImageElement>, "src" | "srcset" | "alt"> & {
7
+ /**
8
+ * The Prismic Image field or thumbnail to render.
9
+ */
10
+ field: prismic.ImageFieldImage | null | undefined;
11
+ /**
12
+ * An object of Imgix URL API parameters to transform the image.
13
+ *
14
+ * See: https://docs.imgix.com/apis/rendering
15
+ */
16
+ imgixParams?: Parameters<typeof prismic.asImageSrc>[1];
17
+ /**
18
+ * Declare an image as decorative by providing `alt=""`.
19
+ *
20
+ * See:
21
+ * https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/alt#decorative_images
22
+ */
23
+ alt?: "";
24
+ /**
25
+ * Declare an image as decorative only if the Image field does not have
26
+ * alternative text by providing `fallbackAlt=""`.
27
+ *
28
+ * See:
29
+ * https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/alt#decorative_images
30
+ */
31
+ fallbackAlt?: "";
32
+ } & ({
33
+ /**
34
+ * Widths used to build a `srcset` value for the Image field.
35
+ *
36
+ * If a `widths` prop is not given or `"defaults"` is passed, the
37
+ * following widths will be used: 640, 750, 828, 1080, 1200, 1920, 2048,
38
+ * 3840.
39
+ *
40
+ * If the Image field contains responsive views, each responsive view
41
+ * can be used as a width in the resulting `srcset` by passing
42
+ * `"thumbnails"` as the `widths` prop.
43
+ */
44
+ widths?: NonNullable<Parameters<typeof prismic.asImageWidthSrcSet>[1]>["widths"] | "defaults";
45
+ /**
46
+ * Not used when the `widths` prop is used.
47
+ */
48
+ pixelDensities?: never;
49
+ } | {
50
+ /**
51
+ * Not used when the `widths` prop is used.
52
+ */
53
+ widths?: never;
54
+ /**
55
+ * Pixel densities used to build a `srcset` value for the Image field.
56
+ *
57
+ * If a `pixelDensities` prop is passed `"defaults"`, the following
58
+ * pixel densities will be used: 1, 2, 3.
59
+ */
60
+ pixelDensities: NonNullable<Parameters<typeof prismic.asImagePixelDensitySrcSet>[1]>["pixelDensities"] | "defaults";
61
+ });
62
+ /**
63
+ * React component that renders an image from a Prismic Image field or one of
64
+ * its thumbnails. It will automatically set the `alt` attribute using the Image
65
+ * field's `alt` property.
66
+ *
67
+ * By default, a widths-based srcset will be used to support responsive images.
68
+ * This ensures only the smallest image needed for a browser is downloaded.
69
+ *
70
+ * To use a pixel-density-based srcset, use the `pixelDensities` prop. Default
71
+ * pixel densities can be used by using `pixelDensities="defaults"`.
72
+ *
73
+ * **Note**: If you are using a framework that has a native image component,
74
+ * such as Next.js and Gatsby, prefer using those image components instead. They
75
+ * can provide deeper framework integration than `<PrismicImage>`.
76
+ *
77
+ * @param props - Props for the component.
78
+ *
79
+ * @returns A responsive image component for the given Image field.
80
+ */
81
+ export declare const PrismicImage: React.ForwardRefExoticComponent<(Omit<Omit<React.DetailedHTMLProps<React.ImgHTMLAttributes<HTMLImageElement>, HTMLImageElement>, "src" | "alt" | "srcset"> & {
82
+ /**
83
+ * The Prismic Image field or thumbnail to render.
84
+ */
85
+ field: prismic.ImageFieldImage | null | undefined;
86
+ /**
87
+ * An object of Imgix URL API parameters to transform the image.
88
+ *
89
+ * See: https://docs.imgix.com/apis/rendering
90
+ */
91
+ imgixParams?: Parameters<typeof prismic.asImageSrc>[1];
92
+ /**
93
+ * Declare an image as decorative by providing `alt=""`.
94
+ *
95
+ * See:
96
+ * https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/alt#decorative_images
97
+ */
98
+ alt?: "" | undefined;
99
+ /**
100
+ * Declare an image as decorative only if the Image field does not have
101
+ * alternative text by providing `fallbackAlt=""`.
102
+ *
103
+ * See:
104
+ * https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/alt#decorative_images
105
+ */
106
+ fallbackAlt?: "" | undefined;
107
+ } & {
108
+ /**
109
+ * Widths used to build a `srcset` value for the Image field.
110
+ *
111
+ * If a `widths` prop is not given or `"defaults"` is passed, the
112
+ * following widths will be used: 640, 750, 828, 1080, 1200, 1920, 2048,
113
+ * 3840.
114
+ *
115
+ * If the Image field contains responsive views, each responsive view
116
+ * can be used as a width in the resulting `srcset` by passing
117
+ * `"thumbnails"` as the `widths` prop.
118
+ */
119
+ widths?: NonNullable<Parameters<typeof prismic.asImageWidthSrcSet>[1]>["widths"] | "defaults";
120
+ /**
121
+ * Not used when the `widths` prop is used.
122
+ */
123
+ pixelDensities?: undefined;
124
+ }, "ref"> | Omit<Omit<React.DetailedHTMLProps<React.ImgHTMLAttributes<HTMLImageElement>, HTMLImageElement>, "src" | "alt" | "srcset"> & {
125
+ /**
126
+ * The Prismic Image field or thumbnail to render.
127
+ */
128
+ field: prismic.ImageFieldImage | null | undefined;
129
+ /**
130
+ * An object of Imgix URL API parameters to transform the image.
131
+ *
132
+ * See: https://docs.imgix.com/apis/rendering
133
+ */
134
+ imgixParams?: Parameters<typeof prismic.asImageSrc>[1];
135
+ /**
136
+ * Declare an image as decorative by providing `alt=""`.
137
+ *
138
+ * See:
139
+ * https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/alt#decorative_images
140
+ */
141
+ alt?: "" | undefined;
142
+ /**
143
+ * Declare an image as decorative only if the Image field does not have
144
+ * alternative text by providing `fallbackAlt=""`.
145
+ *
146
+ * See:
147
+ * https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/alt#decorative_images
148
+ */
149
+ fallbackAlt?: "" | undefined;
150
+ } & {
151
+ /**
152
+ * Not used when the `widths` prop is used.
153
+ */
154
+ widths?: undefined;
155
+ /**
156
+ * Pixel densities used to build a `srcset` value for the Image field.
157
+ *
158
+ * If a `pixelDensities` prop is passed `"defaults"`, the following
159
+ * pixel densities will be used: 1, 2, 3.
160
+ */
161
+ pixelDensities: NonNullable<Parameters<typeof prismic.asImagePixelDensitySrcSet>[1]>["pixelDensities"] | "defaults";
162
+ }, "ref">) & React.RefAttributes<HTMLImageElement>>;
@@ -1,9 +1,9 @@
1
1
  import { jsx } from "react/jsx-runtime";
2
2
  import * as React from "react";
3
- import * as prismicH from "@prismicio/helpers";
3
+ import * as prismic from "@prismicio/client";
4
4
  import { __PRODUCTION__ } from "./lib/__PRODUCTION__.js";
5
5
  import { devMsg } from "./lib/devMsg.js";
6
- const _PrismicImage = (props, ref) => {
6
+ const PrismicImage = React.forwardRef(function PrismicImage2(props, ref) {
7
7
  const { field, alt, fallbackAlt, imgixParams, widths, pixelDensities, ...restProps } = props;
8
8
  if (!__PRODUCTION__) {
9
9
  if (typeof alt === "string" && props.alt !== "") {
@@ -16,18 +16,18 @@ const _PrismicImage = (props, ref) => {
16
16
  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.`);
17
17
  }
18
18
  }
19
- if (prismicH.isFilled.imageThumbnail(field)) {
19
+ if (prismic.isFilled.imageThumbnail(field)) {
20
20
  let src;
21
21
  let srcSet;
22
22
  if (widths || !pixelDensities) {
23
- const res = prismicH.asImageWidthSrcSet(field, {
23
+ const res = prismic.asImageWidthSrcSet(field, {
24
24
  ...imgixParams,
25
25
  widths: widths === "defaults" ? void 0 : widths
26
26
  });
27
27
  src = res.src;
28
28
  srcSet = res.srcset;
29
29
  } else if (pixelDensities) {
30
- const res = prismicH.asImagePixelDensitySrcSet(field, {
30
+ const res = prismic.asImagePixelDensitySrcSet(field, {
31
31
  ...imgixParams,
32
32
  pixelDensities: pixelDensities === "defaults" ? void 0 : pixelDensities
33
33
  });
@@ -38,11 +38,7 @@ const _PrismicImage = (props, ref) => {
38
38
  } else {
39
39
  return null;
40
40
  }
41
- };
42
- if (!__PRODUCTION__) {
43
- _PrismicImage.displayName = "PrismicImage";
44
- }
45
- const PrismicImage = React.forwardRef(_PrismicImage);
41
+ });
46
42
  export {
47
43
  PrismicImage
48
44
  };
@@ -1 +1 @@
1
- {"version":3,"file":"PrismicImage.js","sources":["../../src/PrismicImage.tsx"],"sourcesContent":["import * as React from \"react\";\nimport * as prismicT from \"@prismicio/types\";\nimport * as prismicH from \"@prismicio/helpers\";\n\nimport { __PRODUCTION__ } from \"./lib/__PRODUCTION__\";\nimport { devMsg } from \"./lib/devMsg\";\n\n/**\n * Props for `<PrismicImage>`.\n */\nexport type PrismicImageProps = Omit<\n\tReact.DetailedHTMLProps<\n\t\tReact.ImgHTMLAttributes<HTMLImageElement>,\n\t\tHTMLImageElement\n\t>,\n\t\"src\" | \"srcset\" | \"alt\"\n> & {\n\t/**\n\t * The Prismic Image field or thumbnail to render.\n\t */\n\tfield: prismicT.ImageFieldImage | null | undefined;\n\n\t/**\n\t * An object of Imgix URL API parameters to transform the image.\n\t *\n\t * See: https://docs.imgix.com/apis/rendering\n\t */\n\timgixParams?: Parameters<typeof prismicH.asImageSrc>[1];\n\n\t/**\n\t * Declare an image as decorative by providing `alt=\"\"`.\n\t *\n\t * See:\n\t * https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/alt#decorative_images\n\t */\n\talt?: \"\";\n\n\t/**\n\t * Declare an image as decorative only if the Image field does not have\n\t * alternative text by providing `fallbackAlt=\"\"`.\n\t *\n\t * See:\n\t * https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/alt#decorative_images\n\t */\n\tfallbackAlt?: \"\";\n} & (\n\t\t| {\n\t\t\t\t/**\n\t\t\t\t * Widths used to build a `srcset` value for the Image field.\n\t\t\t\t *\n\t\t\t\t * If a `widths` prop is not given or `\"defaults\"` is passed, the\n\t\t\t\t * following widths will be used: 640, 750, 828, 1080, 1200, 1920, 2048,\n\t\t\t\t * 3840.\n\t\t\t\t *\n\t\t\t\t * If the Image field contains responsive views, each responsive view\n\t\t\t\t * can be used as a width in the resulting `srcset` by passing\n\t\t\t\t * `\"thumbnails\"` as the `widths` prop.\n\t\t\t\t */\n\t\t\t\twidths?:\n\t\t\t\t\t| NonNullable<\n\t\t\t\t\t\t\tParameters<typeof prismicH.asImageWidthSrcSet>[1]\n\t\t\t\t\t >[\"widths\"]\n\t\t\t\t\t| \"defaults\";\n\t\t\t\t/**\n\t\t\t\t * Not used when the `widths` prop is used.\n\t\t\t\t */\n\t\t\t\tpixelDensities?: never;\n\t\t }\n\t\t| {\n\t\t\t\t/**\n\t\t\t\t * Not used when the `widths` prop is used.\n\t\t\t\t */\n\t\t\t\twidths?: never;\n\t\t\t\t/**\n\t\t\t\t * Pixel densities used to build a `srcset` value for the Image field.\n\t\t\t\t *\n\t\t\t\t * If a `pixelDensities` prop is passed `\"defaults\"`, the following\n\t\t\t\t * pixel densities will be used: 1, 2, 3.\n\t\t\t\t */\n\t\t\t\tpixelDensities:\n\t\t\t\t\t| NonNullable<\n\t\t\t\t\t\t\tParameters<typeof prismicH.asImagePixelDensitySrcSet>[1]\n\t\t\t\t\t >[\"pixelDensities\"]\n\t\t\t\t\t| \"defaults\";\n\t\t }\n\t);\n\nconst _PrismicImage = (\n\tprops: PrismicImageProps,\n\tref: React.ForwardedRef<HTMLImageElement>,\n): JSX.Element | null => {\n\tconst {\n\t\tfield,\n\t\talt,\n\t\tfallbackAlt,\n\t\timgixParams,\n\t\twidths,\n\t\tpixelDensities,\n\t\t...restProps\n\t} = props;\n\n\tif (!__PRODUCTION__) {\n\t\tif (typeof alt === \"string\" && props.alt !== \"\") {\n\t\t\tconsole.warn(\n\t\t\t\t`[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(\n\t\t\t\t\t\"alt-must-be-an-empty-string\",\n\t\t\t\t)}`,\n\t\t\t);\n\t\t}\n\n\t\tif (typeof fallbackAlt === \"string\" && fallbackAlt !== \"\") {\n\t\t\tconsole.warn(\n\t\t\t\t`[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(\n\t\t\t\t\t\"alt-must-be-an-empty-string\",\n\t\t\t\t)}`,\n\t\t\t);\n\t\t}\n\n\t\tif (widths && pixelDensities) {\n\t\t\tconsole.warn(\n\t\t\t\t`[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.`,\n\t\t\t);\n\t\t}\n\t}\n\n\tif (prismicH.isFilled.imageThumbnail(field)) {\n\t\tlet src: string | undefined;\n\t\tlet srcSet: string | undefined;\n\n\t\tif (widths || !pixelDensities) {\n\t\t\tconst res = prismicH.asImageWidthSrcSet(field, {\n\t\t\t\t...imgixParams,\n\t\t\t\twidths: widths === \"defaults\" ? undefined : widths,\n\t\t\t});\n\n\t\t\tsrc = res.src;\n\t\t\tsrcSet = res.srcset;\n\t\t} else if (pixelDensities) {\n\t\t\tconst res = prismicH.asImagePixelDensitySrcSet(field, {\n\t\t\t\t...imgixParams,\n\t\t\t\tpixelDensities:\n\t\t\t\t\tpixelDensities === \"defaults\" ? undefined : pixelDensities,\n\t\t\t});\n\n\t\t\tsrc = res.src;\n\t\t\tsrcSet = res.srcset;\n\t\t}\n\n\t\treturn (\n\t\t\t<img\n\t\t\t\tref={ref}\n\t\t\t\tsrc={src}\n\t\t\t\tsrcSet={srcSet}\n\t\t\t\talt={alt ?? (field.alt || fallbackAlt)}\n\t\t\t\t{...restProps}\n\t\t\t/>\n\t\t);\n\t} else {\n\t\treturn null;\n\t}\n};\n\nif (!__PRODUCTION__) {\n\t_PrismicImage.displayName = \"PrismicImage\";\n}\n\n/**\n * React component that renders an image from a Prismic Image field or one of\n * its thumbnails. It will automatically set the `alt` attribute using the Image\n * field's `alt` property.\n *\n * By default, a widths-based srcset will be used to support responsive images.\n * This ensures only the smallest image needed for a browser is downloaded.\n *\n * To use a pixel-density-based srcset, use the `pixelDensities` prop. Default\n * pixel densities can be used by using `pixelDensities=\"defaults\"`.\n *\n * **Note**: If you are using a framework that has a native image component,\n * such as Next.js and Gatsby, prefer using those image components instead. They\n * can provide deeper framework integration than `<PrismicImage>`.\n *\n * @param props - Props for the component.\n *\n * @returns A responsive image component for the given Image field.\n */\nexport const PrismicImage = React.forwardRef(_PrismicImage);\n"],"names":[],"mappings":";;;;;AAuFA,MAAM,gBAAgB,CACrB,OACA,QACuB;AACjB,QAAA,EACL,OACA,KACA,aACA,aACA,QACA,mBACG,UACA,IAAA;AAEJ,MAAI,CAAC,gBAAgB;AACpB,QAAI,OAAO,QAAQ,YAAY,MAAM,QAAQ,IAAI;AAChD,cAAQ,KACP,qQAAqQ,OACpQ,6BAA6B,GAC3B;AAAA,IAEJ;AAED,QAAI,OAAO,gBAAgB,YAAY,gBAAgB,IAAI;AAC1D,cAAQ,KACP,qSAAqS,OACpS,6BAA6B,GAC3B;AAAA,IAEJ;AAED,QAAI,UAAU,gBAAgB;AAC7B,cAAQ,KACP,2MAA2M;AAAA,IAE5M;AAAA,EACD;AAED,MAAI,SAAS,SAAS,eAAe,KAAK,GAAG;AACxC,QAAA;AACA,QAAA;AAEA,QAAA,UAAU,CAAC,gBAAgB;AACxB,YAAA,MAAM,SAAS,mBAAmB,OAAO;AAAA,QAC9C,GAAG;AAAA,QACH,QAAQ,WAAW,aAAa,SAAY;AAAA,MAAA,CAC5C;AAED,YAAM,IAAI;AACV,eAAS,IAAI;AAAA,eACH,gBAAgB;AACpB,YAAA,MAAM,SAAS,0BAA0B,OAAO;AAAA,QACrD,GAAG;AAAA,QACH,gBACC,mBAAmB,aAAa,SAAY;AAAA,MAAA,CAC7C;AAED,YAAM,IAAI;AACV,eAAS,IAAI;AAAA,IACb;AAGA,WAAA,oBAAC,OACA,EAAA,KACA,KACA,QACA,KAAK,QAAQ,MAAM,OAAO,cAC1B,GAAI,UAAU,CAAA;AAAA,EAAA,OAGV;AACC,WAAA;AAAA,EACP;AACF;AAEA,IAAI,CAAC,gBAAgB;AACpB,gBAAc,cAAc;AAC5B;AAqBY,MAAA,eAAe,MAAM,WAAW,aAAa;"}
1
+ {"version":3,"file":"PrismicImage.js","sources":["../../src/PrismicImage.tsx"],"sourcesContent":["import * as React from \"react\";\nimport * as prismic from \"@prismicio/client\";\n\nimport { __PRODUCTION__ } from \"./lib/__PRODUCTION__\";\nimport { devMsg } from \"./lib/devMsg\";\n\n/**\n * Props for `<PrismicImage>`.\n */\nexport type PrismicImageProps = Omit<\n\tReact.DetailedHTMLProps<\n\t\tReact.ImgHTMLAttributes<HTMLImageElement>,\n\t\tHTMLImageElement\n\t>,\n\t\"src\" | \"srcset\" | \"alt\"\n> & {\n\t/**\n\t * The Prismic Image field or thumbnail to render.\n\t */\n\tfield: prismic.ImageFieldImage | null | undefined;\n\n\t/**\n\t * An object of Imgix URL API parameters to transform the image.\n\t *\n\t * See: https://docs.imgix.com/apis/rendering\n\t */\n\timgixParams?: Parameters<typeof prismic.asImageSrc>[1];\n\n\t/**\n\t * Declare an image as decorative by providing `alt=\"\"`.\n\t *\n\t * See:\n\t * https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/alt#decorative_images\n\t */\n\talt?: \"\";\n\n\t/**\n\t * Declare an image as decorative only if the Image field does not have\n\t * alternative text by providing `fallbackAlt=\"\"`.\n\t *\n\t * See:\n\t * https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/alt#decorative_images\n\t */\n\tfallbackAlt?: \"\";\n} & (\n\t\t| {\n\t\t\t\t/**\n\t\t\t\t * Widths used to build a `srcset` value for the Image field.\n\t\t\t\t *\n\t\t\t\t * If a `widths` prop is not given or `\"defaults\"` is passed, the\n\t\t\t\t * following widths will be used: 640, 750, 828, 1080, 1200, 1920, 2048,\n\t\t\t\t * 3840.\n\t\t\t\t *\n\t\t\t\t * If the Image field contains responsive views, each responsive view\n\t\t\t\t * can be used as a width in the resulting `srcset` by passing\n\t\t\t\t * `\"thumbnails\"` as the `widths` prop.\n\t\t\t\t */\n\t\t\t\twidths?:\n\t\t\t\t\t| NonNullable<\n\t\t\t\t\t\t\tParameters<typeof prismic.asImageWidthSrcSet>[1]\n\t\t\t\t\t >[\"widths\"]\n\t\t\t\t\t| \"defaults\";\n\t\t\t\t/**\n\t\t\t\t * Not used when the `widths` prop is used.\n\t\t\t\t */\n\t\t\t\tpixelDensities?: never;\n\t\t }\n\t\t| {\n\t\t\t\t/**\n\t\t\t\t * Not used when the `widths` prop is used.\n\t\t\t\t */\n\t\t\t\twidths?: never;\n\t\t\t\t/**\n\t\t\t\t * Pixel densities used to build a `srcset` value for the Image field.\n\t\t\t\t *\n\t\t\t\t * If a `pixelDensities` prop is passed `\"defaults\"`, the following\n\t\t\t\t * pixel densities will be used: 1, 2, 3.\n\t\t\t\t */\n\t\t\t\tpixelDensities:\n\t\t\t\t\t| NonNullable<\n\t\t\t\t\t\t\tParameters<typeof prismic.asImagePixelDensitySrcSet>[1]\n\t\t\t\t\t >[\"pixelDensities\"]\n\t\t\t\t\t| \"defaults\";\n\t\t }\n\t);\n\n/**\n * React component that renders an image from a Prismic Image field or one of\n * its thumbnails. It will automatically set the `alt` attribute using the Image\n * field's `alt` property.\n *\n * By default, a widths-based srcset will be used to support responsive images.\n * This ensures only the smallest image needed for a browser is downloaded.\n *\n * To use a pixel-density-based srcset, use the `pixelDensities` prop. Default\n * pixel densities can be used by using `pixelDensities=\"defaults\"`.\n *\n * **Note**: If you are using a framework that has a native image component,\n * such as Next.js and Gatsby, prefer using those image components instead. They\n * can provide deeper framework integration than `<PrismicImage>`.\n *\n * @param props - Props for the component.\n *\n * @returns A responsive image component for the given Image field.\n */\nexport const PrismicImage = React.forwardRef(function PrismicImage(\n\tprops: PrismicImageProps,\n\tref: React.ForwardedRef<HTMLImageElement>,\n): JSX.Element | null {\n\tconst {\n\t\tfield,\n\t\talt,\n\t\tfallbackAlt,\n\t\timgixParams,\n\t\twidths,\n\t\tpixelDensities,\n\t\t...restProps\n\t} = props;\n\n\tif (!__PRODUCTION__) {\n\t\tif (typeof alt === \"string\" && props.alt !== \"\") {\n\t\t\tconsole.warn(\n\t\t\t\t`[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(\n\t\t\t\t\t\"alt-must-be-an-empty-string\",\n\t\t\t\t)}`,\n\t\t\t);\n\t\t}\n\n\t\tif (typeof fallbackAlt === \"string\" && fallbackAlt !== \"\") {\n\t\t\tconsole.warn(\n\t\t\t\t`[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(\n\t\t\t\t\t\"alt-must-be-an-empty-string\",\n\t\t\t\t)}`,\n\t\t\t);\n\t\t}\n\n\t\tif (widths && pixelDensities) {\n\t\t\tconsole.warn(\n\t\t\t\t`[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.`,\n\t\t\t);\n\t\t}\n\t}\n\n\tif (prismic.isFilled.imageThumbnail(field)) {\n\t\tlet src: string | undefined;\n\t\tlet srcSet: string | undefined;\n\n\t\tif (widths || !pixelDensities) {\n\t\t\tconst res = prismic.asImageWidthSrcSet(field, {\n\t\t\t\t...imgixParams,\n\t\t\t\twidths: widths === \"defaults\" ? undefined : widths,\n\t\t\t});\n\n\t\t\tsrc = res.src;\n\t\t\tsrcSet = res.srcset;\n\t\t} else if (pixelDensities) {\n\t\t\tconst res = prismic.asImagePixelDensitySrcSet(field, {\n\t\t\t\t...imgixParams,\n\t\t\t\tpixelDensities:\n\t\t\t\t\tpixelDensities === \"defaults\" ? undefined : pixelDensities,\n\t\t\t});\n\n\t\t\tsrc = res.src;\n\t\t\tsrcSet = res.srcset;\n\t\t}\n\n\t\treturn (\n\t\t\t<img\n\t\t\t\tref={ref}\n\t\t\t\tsrc={src}\n\t\t\t\tsrcSet={srcSet}\n\t\t\t\talt={alt ?? (field.alt || fallbackAlt)}\n\t\t\t\t{...restProps}\n\t\t\t/>\n\t\t);\n\t} else {\n\t\treturn null;\n\t}\n});\n"],"names":["PrismicImage"],"mappings":";;;;;AAyGO,MAAM,eAAe,MAAM,WAAW,SAASA,cACrD,OACA,KAAyC;AAEnC,QAAA,EACL,OACA,KACA,aACA,aACA,QACA,gBACA,GAAG,UACA,IAAA;AAEJ,MAAI,CAAC,gBAAgB;AACpB,QAAI,OAAO,QAAQ,YAAY,MAAM,QAAQ,IAAI;AAChD,cAAQ,KACP,qQAAqQ,OACpQ,6BAA6B,GAC3B;AAAA,IAEJ;AAED,QAAI,OAAO,gBAAgB,YAAY,gBAAgB,IAAI;AAC1D,cAAQ,KACP,qSAAqS,OACpS,6BAA6B,GAC3B;AAAA,IAEJ;AAED,QAAI,UAAU,gBAAgB;AAC7B,cAAQ,KACP,2MAA2M;AAAA,IAE5M;AAAA,EACD;AAED,MAAI,QAAQ,SAAS,eAAe,KAAK,GAAG;AACvC,QAAA;AACA,QAAA;AAEA,QAAA,UAAU,CAAC,gBAAgB;AACxB,YAAA,MAAM,QAAQ,mBAAmB,OAAO;AAAA,QAC7C,GAAG;AAAA,QACH,QAAQ,WAAW,aAAa,SAAY;AAAA,MAAA,CAC5C;AAED,YAAM,IAAI;AACV,eAAS,IAAI;AAAA,eACH,gBAAgB;AACpB,YAAA,MAAM,QAAQ,0BAA0B,OAAO;AAAA,QACpD,GAAG;AAAA,QACH,gBACC,mBAAmB,aAAa,SAAY;AAAA,MAAA,CAC7C;AAED,YAAM,IAAI;AACV,eAAS,IAAI;AAAA,IACb;AAGA,WAAA,oBAAC,OACA,EAAA,KACA,KACA,QACA,KAAK,QAAQ,MAAM,OAAO,cAC1B,GAAI,UAAU,CAAA;AAAA,EAAA,OAGV;AACC,WAAA;AAAA,EACP;AACF,CAAC;"}
@@ -2,10 +2,7 @@
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
3
  const jsxRuntime = require("react/jsx-runtime");
4
4
  const React = require("react");
5
- const prismicH = require("@prismicio/helpers");
6
- const __PRODUCTION__ = require("./lib/__PRODUCTION__.cjs");
7
- const devMsg = require("./lib/devMsg.cjs");
8
- const isInternalURL = require("./lib/isInternalURL.cjs");
5
+ const PrismicLink$1 = require("./react-server/PrismicLink.cjs");
9
6
  const usePrismicContext = require("./usePrismicContext.cjs");
10
7
  function _interopNamespaceDefault(e) {
11
8
  const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
@@ -24,68 +21,9 @@ function _interopNamespaceDefault(e) {
24
21
  return Object.freeze(n);
25
22
  }
26
23
  const React__namespace = /* @__PURE__ */ _interopNamespaceDefault(React);
27
- const prismicH__namespace = /* @__PURE__ */ _interopNamespaceDefault(prismicH);
28
- const defaultInternalComponent = "a";
29
- const defaultExternalComponent = "a";
30
- const _PrismicLink = (props, ref) => {
24
+ const PrismicLink = React__namespace.forwardRef(function PrismicLink2(props, ref) {
31
25
  const context = usePrismicContext.usePrismicContext();
32
- if (!__PRODUCTION__.__PRODUCTION__) {
33
- if ("field" in props && props.field) {
34
- if (!props.field.link_type) {
35
- console.error(`[PrismicLink] This "field" prop value caused an error to be thrown.
36
- `, props.field);
37
- 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.devMsg("missing-link-properties")}`);
38
- } else if (Object.keys(props.field).length > 1 && !("url" in props.field || "uid" in props.field || "id" in props.field)) {
39
- 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.devMsg("missing-link-properties")}`, props.field);
40
- }
41
- } else if ("document" in props && props.document) {
42
- if (!("url" in props.document || "id" in props.document)) {
43
- 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.devMsg("missing-link-properties")}`, props.document);
44
- }
45
- }
46
- }
47
- const linkResolver = props.linkResolver || context.linkResolver;
48
- let href;
49
- if ("href" in props) {
50
- href = props.href;
51
- } else if ("document" in props && props.document) {
52
- href = prismicH__namespace.asLink(props.document, linkResolver);
53
- } else if ("field" in props && props.field) {
54
- href = prismicH__namespace.asLink(props.field, linkResolver);
55
- }
56
- const isInternal = href && isInternalURL.isInternalURL(href);
57
- const target = props.target || "field" in props && props.field && "target" in props.field && props.field.target || !isInternal && "_blank" || void 0;
58
- const rel = props.rel || (target === "_blank" ? "noopener noreferrer" : void 0);
59
- const InternalComponent = props.internalComponent || context.internalLinkComponent || defaultInternalComponent;
60
- const ExternalComponent = props.externalComponent || context.externalLinkComponent || defaultExternalComponent;
61
- const Component = isInternal ? InternalComponent : ExternalComponent;
62
- const passthroughProps = Object.assign({}, props);
63
- delete passthroughProps.linkResolver;
64
- delete passthroughProps.internalComponent;
65
- delete passthroughProps.externalComponent;
66
- delete passthroughProps.rel;
67
- delete passthroughProps.target;
68
- if ("field" in passthroughProps) {
69
- delete passthroughProps.field;
70
- } else if ("document" in passthroughProps) {
71
- delete passthroughProps.document;
72
- } else if ("href" in passthroughProps) {
73
- delete passthroughProps.href;
74
- }
75
- return href ? /* @__PURE__ */ jsxRuntime.jsx(
76
- Component,
77
- {
78
- ...passthroughProps,
79
- ref,
80
- href,
81
- target,
82
- rel
83
- }
84
- ) : null;
85
- };
86
- if (!__PRODUCTION__.__PRODUCTION__) {
87
- _PrismicLink.displayName = "PrismicLink";
88
- }
89
- const PrismicLink = React__namespace.forwardRef(_PrismicLink);
26
+ return /* @__PURE__ */ jsxRuntime.jsx(PrismicLink$1.PrismicLink, { ref, linkResolver: context.linkResolver, internalComponent: context.internalLinkComponent, externalComponent: context.externalLinkComponent, ...props });
27
+ });
90
28
  exports.PrismicLink = PrismicLink;
91
29
  //# sourceMappingURL=PrismicLink.cjs.map