@prismicio/next 1.0.3 → 1.1.0-alpha.1

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 (86) hide show
  1. package/dist/PrismicNextImage.cjs +8 -19
  2. package/dist/PrismicNextImage.cjs.map +1 -1
  3. package/dist/PrismicNextImage.d.ts +2 -2
  4. package/dist/PrismicNextImage.js +8 -2
  5. package/dist/PrismicNextImage.js.map +1 -1
  6. package/dist/PrismicNextLink.cjs +39 -0
  7. package/dist/PrismicNextLink.cjs.map +1 -0
  8. package/dist/PrismicNextLink.d.ts +126 -0
  9. package/dist/PrismicNextLink.js +22 -0
  10. package/dist/PrismicNextLink.js.map +1 -0
  11. package/dist/PrismicPreview.cjs +2 -0
  12. package/dist/PrismicPreview.cjs.map +1 -1
  13. package/dist/PrismicPreview.js +2 -0
  14. package/dist/PrismicPreview.js.map +1 -1
  15. package/dist/_node_modules/@prismicio/client/dist/cookie.cjs +5 -0
  16. package/dist/_node_modules/@prismicio/client/dist/cookie.cjs.map +1 -0
  17. package/dist/_node_modules/@prismicio/client/dist/cookie.js +5 -0
  18. package/dist/_node_modules/@prismicio/client/dist/cookie.js.map +1 -0
  19. package/dist/_node_modules/@prismicio/client/dist/helpers/asLink.cjs +38 -0
  20. package/dist/_node_modules/@prismicio/client/dist/helpers/asLink.cjs.map +1 -0
  21. package/dist/_node_modules/@prismicio/client/dist/helpers/asLink.js +38 -0
  22. package/dist/_node_modules/@prismicio/client/dist/helpers/asLink.js.map +1 -0
  23. package/dist/_node_modules/@prismicio/client/dist/helpers/asLinkAttrs.cjs +28 -0
  24. package/dist/_node_modules/@prismicio/client/dist/helpers/asLinkAttrs.cjs.map +1 -0
  25. package/dist/_node_modules/@prismicio/client/dist/helpers/asLinkAttrs.js +28 -0
  26. package/dist/_node_modules/@prismicio/client/dist/helpers/asLinkAttrs.js.map +1 -0
  27. package/dist/_node_modules/@prismicio/client/dist/helpers/documentToLinkField.cjs +26 -0
  28. package/dist/_node_modules/@prismicio/client/dist/helpers/documentToLinkField.cjs.map +1 -0
  29. package/dist/_node_modules/@prismicio/client/dist/helpers/documentToLinkField.js +26 -0
  30. package/dist/_node_modules/@prismicio/client/dist/helpers/documentToLinkField.js.map +1 -0
  31. package/dist/_node_modules/@prismicio/client/dist/helpers/isFilled.cjs +14 -0
  32. package/dist/_node_modules/@prismicio/client/dist/helpers/isFilled.cjs.map +1 -0
  33. package/dist/_node_modules/@prismicio/client/dist/helpers/isFilled.js +14 -0
  34. package/dist/_node_modules/@prismicio/client/dist/helpers/isFilled.js.map +1 -0
  35. package/dist/_node_modules/@prismicio/client/dist/lib/isInternalURL.cjs +9 -0
  36. package/dist/_node_modules/@prismicio/client/dist/lib/isInternalURL.cjs.map +1 -0
  37. package/dist/_node_modules/@prismicio/client/dist/lib/isInternalURL.js +9 -0
  38. package/dist/_node_modules/@prismicio/client/dist/lib/isInternalURL.js.map +1 -0
  39. package/dist/_node_modules/@prismicio/client/dist/types/value/link.cjs +10 -0
  40. package/dist/_node_modules/@prismicio/client/dist/types/value/link.cjs.map +1 -0
  41. package/dist/_node_modules/@prismicio/client/dist/types/value/link.js +10 -0
  42. package/dist/_node_modules/@prismicio/client/dist/types/value/link.js.map +1 -0
  43. package/dist/enableAutoPreviews.cjs.map +1 -1
  44. package/dist/enableAutoPreviews.d.ts +3 -3
  45. package/dist/enableAutoPreviews.js.map +1 -1
  46. package/dist/index.cjs +2 -0
  47. package/dist/index.cjs.map +1 -1
  48. package/dist/index.d.ts +15 -7
  49. package/dist/index.js +2 -0
  50. package/dist/index.js.map +1 -1
  51. package/dist/lib/getPreviewCookieRepositoryName.cjs.map +1 -1
  52. package/dist/lib/getPreviewCookieRepositoryName.js.map +1 -1
  53. package/dist/lib/getPrismicPreviewCookie.cjs +4 -21
  54. package/dist/lib/getPrismicPreviewCookie.cjs.map +1 -1
  55. package/dist/lib/getPrismicPreviewCookie.js +2 -2
  56. package/dist/lib/getPrismicPreviewCookie.js.map +1 -1
  57. package/dist/package.json.cjs +1 -1
  58. package/dist/package.json.js +1 -1
  59. package/dist/react-server/PrismicPreview.d.ts +22 -0
  60. package/dist/react-server/index.d.ts +2 -0
  61. package/dist/react-server/unsupported.cjs +26 -0
  62. package/dist/react-server/unsupported.cjs.map +1 -0
  63. package/dist/react-server/unsupported.d.ts +6 -0
  64. package/dist/react-server/unsupported.js +26 -0
  65. package/dist/react-server/unsupported.js.map +1 -0
  66. package/dist/react-server.cjs +15 -0
  67. package/dist/react-server.cjs.map +1 -0
  68. package/dist/react-server.js +15 -0
  69. package/dist/react-server.js.map +1 -0
  70. package/dist/redirectToPreviewURL.cjs.map +1 -1
  71. package/dist/redirectToPreviewURL.d.ts +4 -5
  72. package/dist/redirectToPreviewURL.js.map +1 -1
  73. package/dist/setPreviewData.cjs +2 -19
  74. package/dist/setPreviewData.cjs.map +1 -1
  75. package/dist/setPreviewData.js +2 -2
  76. package/dist/setPreviewData.js.map +1 -1
  77. package/package.json +37 -32
  78. package/src/PrismicNextImage.tsx +5 -4
  79. package/src/PrismicNextLink.tsx +55 -0
  80. package/src/PrismicPreview.tsx +2 -0
  81. package/src/enableAutoPreviews.ts +9 -3
  82. package/src/index.ts +16 -13
  83. package/src/react-server/PrismicPreview.tsx +74 -0
  84. package/src/react-server/index.ts +11 -0
  85. package/src/react-server/unsupported.ts +26 -0
  86. package/src/redirectToPreviewURL.ts +7 -5
@@ -1,29 +1,14 @@
1
+ 'use client';
2
+ 'use client';
1
3
  "use strict";
2
4
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
5
  const jsxRuntime = require("react/jsx-runtime");
4
6
  const Image = require("next/image");
5
7
  const imgixUrlBuilder = require("imgix-url-builder");
6
- const prismicH = require("@prismicio/helpers");
7
8
  const __PRODUCTION__ = require("./lib/__PRODUCTION__.cjs");
8
9
  const devMsg = require("./lib/devMsg.cjs");
9
10
  const imgixLoader = require("./imgixLoader.cjs");
10
- function _interopNamespaceDefault(e) {
11
- const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
12
- if (e) {
13
- for (const k in e) {
14
- if (k !== "default") {
15
- const d = Object.getOwnPropertyDescriptor(e, k);
16
- Object.defineProperty(n, k, d.get ? d : {
17
- enumerable: true,
18
- get: () => e[k]
19
- });
20
- }
21
- }
22
- }
23
- n.default = e;
24
- return Object.freeze(n);
25
- }
26
- const prismicH__namespace = /* @__PURE__ */ _interopNamespaceDefault(prismicH);
11
+ const isFilled = require('./_node_modules/@prismicio/client/dist/helpers/isFilled.cjs');
27
12
  const castInt = (input) => {
28
13
  if (typeof input === "number" || typeof input === "undefined") {
29
14
  return input;
@@ -45,7 +30,7 @@ const PrismicNextImage = ({ field, imgixParams = {}, alt, fallbackAlt, fill, wid
45
30
  console.warn(`[PrismicNextImage] 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.devMsg("alt-must-be-an-empty-string")}`);
46
31
  }
47
32
  }
48
- if (prismicH__namespace.isFilled.imageThumbnail(field)) {
33
+ if (isFilled.imageThumbnail(field)) {
49
34
  const src = imgixUrlBuilder.buildURL(field.url, imgixParams);
50
35
  const ar = field.dimensions.width / field.dimensions.height;
51
36
  const castedWidth = castInt(width);
@@ -61,6 +46,10 @@ const PrismicNextImage = ({ field, imgixParams = {}, alt, fallbackAlt, fill, wid
61
46
  src,
62
47
  width: fill ? void 0 : resolvedWidth,
63
48
  height: fill ? void 0 : resolvedHeight,
49
+ // A non-null assertion is required since we
50
+ // can't statically know if an alt attribute is
51
+ // available.
52
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
64
53
  alt: alt ?? (field.alt || fallbackAlt),
65
54
  fill,
66
55
  loader: imgixLoader.imgixLoader,
@@ -1 +1 @@
1
- {"version":3,"file":"PrismicNextImage.cjs","sources":["../../src/PrismicNextImage.tsx"],"sourcesContent":["import Image, { ImageProps } from \"next/image\";\nimport { buildURL, ImgixURLParams } from \"imgix-url-builder\";\nimport * as prismicH from \"@prismicio/helpers\";\nimport * as prismicT from \"@prismicio/types\";\n\nimport { __PRODUCTION__ } from \"./lib/__PRODUCTION__\";\nimport { devMsg } from \"./lib/devMsg\";\n\nimport { imgixLoader } from \"./imgixLoader\";\n\nconst castInt = (input: string | number | undefined): number | undefined => {\n\tif (typeof input === \"number\" || typeof input === \"undefined\") {\n\t\treturn input;\n\t} else {\n\t\tconst parsed = Number.parseInt(input);\n\n\t\tif (Number.isNaN(parsed)) {\n\t\t\treturn undefined;\n\t\t} else {\n\t\t\treturn parsed;\n\t\t}\n\t}\n};\n\nexport type PrismicNextImageProps = Omit<ImageProps, \"src\" | \"alt\"> & {\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?: ImgixURLParams;\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/**\n\t * Rendered when the field is empty. If a fallback is not given, `null` will\n\t * be rendered.\n\t */\n\tfallback?: React.ReactNode;\n};\n\n/**\n * React component that renders an image from a Prismic Image field or one of\n * its thumbnails using `next/image`. It will automatically set the `alt`\n * attribute using the Image field's `alt` property.\n *\n * It uses an Imgix URL-based loader by default. A custom loader can be provided\n * with the `loader` prop. If you would like to use the Next.js Image\n * Optimization API instead, set `loader={undefined}`.\n *\n * @param props - Props for the component.\n *\n * @returns A responsive image component using `next/image` for the given Image\n * field.\n * @see To learn more about `next/image`, see: https://nextjs.org/docs/api-reference/next/image\n */\nexport const PrismicNextImage = ({\n\tfield,\n\timgixParams = {},\n\talt,\n\tfallbackAlt,\n\tfill,\n\twidth,\n\theight,\n\tfallback = null,\n\t...restProps\n}: PrismicNextImageProps): JSX.Element => {\n\tif (!__PRODUCTION__) {\n\t\tif (typeof alt === \"string\" && alt !== \"\") {\n\t\t\tconsole.warn(\n\t\t\t\t`[PrismicNextImage] 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`[PrismicNextImage] 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\t}\n\n\tif (prismicH.isFilled.imageThumbnail(field)) {\n\t\tconst src = buildURL(field.url, imgixParams);\n\n\t\tconst ar = field.dimensions.width / field.dimensions.height;\n\n\t\tconst castedWidth = castInt(width);\n\t\tconst castedHeight = castInt(height);\n\n\t\tlet resolvedWidth = castedWidth ?? field.dimensions.width;\n\t\tlet resolvedHeight = castedHeight ?? field.dimensions.height;\n\n\t\tif (castedWidth != null && castedHeight == null) {\n\t\t\tresolvedHeight = castedWidth / ar;\n\t\t} else if (castedWidth == null && castedHeight != null) {\n\t\t\tresolvedWidth = castedHeight * ar;\n\t\t}\n\n\t\treturn (\n\t\t\t<Image\n\t\t\t\tsrc={src}\n\t\t\t\twidth={fill ? undefined : resolvedWidth}\n\t\t\t\theight={fill ? undefined : resolvedHeight}\n\t\t\t\t// A non-null assertion is required since we\n\t\t\t\t// can't statically know if an alt attribute is\n\t\t\t\t// available.\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\t\talt={(alt ?? (field.alt || fallbackAlt))!}\n\t\t\t\tfill={fill}\n\t\t\t\tloader={imgixLoader}\n\t\t\t\t{...restProps}\n\t\t\t/>\n\t\t);\n\t} else {\n\t\treturn <>{fallback}</>;\n\t}\n};\n"],"names":["__PRODUCTION__","devMsg","prismicH","buildURL","_jsx","imgixLoader","_Fragment"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAUA,MAAM,UAAU,CAAC,UAA0D;AAC1E,MAAI,OAAO,UAAU,YAAY,OAAO,UAAU,aAAa;AACvD,WAAA;AAAA,EAAA,OACD;AACA,UAAA,SAAS,OAAO,SAAS,KAAK;AAEhC,QAAA,OAAO,MAAM,MAAM,GAAG;AAClB,aAAA;AAAA,IAAA,OACD;AACC,aAAA;AAAA,IACP;AAAA,EACD;AACF;AAsDO,MAAM,mBAAmB,CAAC,EAChC,OACA,cAAc,CAAA,GACd,KACA,aACA,MACA,OACA,QACA,WAAW,SACR,gBACqC;AACxC,MAAI,CAACA,eAAAA,gBAAgB;AACpB,QAAI,OAAO,QAAQ,YAAY,QAAQ,IAAI;AAC1C,cAAQ,KACP,yQAAyQC,OACxQ,OAAA,6BAA6B,GAC3B;AAAA,IAEJ;AAED,QAAI,OAAO,gBAAgB,YAAY,gBAAgB,IAAI;AAC1D,cAAQ,KACP,ySAAySA,OACxS,OAAA,6BAA6B,GAC3B;AAAA,IAEJ;AAAA,EACD;AAED,MAAIC,oBAAS,SAAS,eAAe,KAAK,GAAG;AAC5C,UAAM,MAAMC,gBAAA,SAAS,MAAM,KAAK,WAAW;AAE3C,UAAM,KAAK,MAAM,WAAW,QAAQ,MAAM,WAAW;AAE/C,UAAA,cAAc,QAAQ,KAAK;AAC3B,UAAA,eAAe,QAAQ,MAAM;AAE/B,QAAA,gBAAgB,eAAe,MAAM,WAAW;AAChD,QAAA,iBAAiB,gBAAgB,MAAM,WAAW;AAElD,QAAA,eAAe,QAAQ,gBAAgB,MAAM;AAChD,uBAAiB,cAAc;AAAA,IACrB,WAAA,eAAe,QAAQ,gBAAgB,MAAM;AACvD,sBAAgB,eAAe;AAAA,IAC/B;AAED,WACCC,WAAAA,IAAC,OAAK;AAAA,MACL;AAAA,MACA,OAAO,OAAO,SAAY;AAAA,MAC1B,QAAQ,OAAO,SAAY;AAAA,MAK3B,KAAM,QAAQ,MAAM,OAAO;AAAA,MAC3B;AAAA,MACA,QAAQC,YAAA;AAAA,MACJ,GAAA;AAAA,IAAA,CACH;AAAA,EAAA,OAEG;AACN,WAAOD,WAAA,IAAAE,WAAA,UAAA,EAAA,UAAG,SAAQ,CAAA;AAAA,EAClB;AACF;;"}
1
+ {"version":3,"file":"PrismicNextImage.cjs","sources":["../../src/PrismicNextImage.tsx"],"sourcesContent":["\"use client\";\n\nimport Image, { ImageProps } from \"next/image\";\nimport { buildURL, ImgixURLParams } from \"imgix-url-builder\";\nimport * as prismic from \"@prismicio/client\";\n\nimport { __PRODUCTION__ } from \"./lib/__PRODUCTION__\";\nimport { devMsg } from \"./lib/devMsg\";\n\nimport { imgixLoader } from \"./imgixLoader\";\n\nconst castInt = (input: string | number | undefined): number | undefined => {\n\tif (typeof input === \"number\" || typeof input === \"undefined\") {\n\t\treturn input;\n\t} else {\n\t\tconst parsed = Number.parseInt(input);\n\n\t\tif (Number.isNaN(parsed)) {\n\t\t\treturn undefined;\n\t\t} else {\n\t\t\treturn parsed;\n\t\t}\n\t}\n};\n\nexport type PrismicNextImageProps = Omit<ImageProps, \"src\" | \"alt\"> & {\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?: ImgixURLParams;\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/**\n\t * Rendered when the field is empty. If a fallback is not given, `null` will\n\t * be rendered.\n\t */\n\tfallback?: React.ReactNode;\n};\n\n/**\n * React component that renders an image from a Prismic Image field or one of\n * its thumbnails using `next/image`. It will automatically set the `alt`\n * attribute using the Image field's `alt` property.\n *\n * It uses an Imgix URL-based loader by default. A custom loader can be provided\n * with the `loader` prop. If you would like to use the Next.js Image\n * Optimization API instead, set `loader={undefined}`.\n *\n * @param props - Props for the component.\n *\n * @returns A responsive image component using `next/image` for the given Image\n * field.\n * @see To learn more about `next/image`, see: https://nextjs.org/docs/api-reference/next/image\n */\nexport const PrismicNextImage = ({\n\tfield,\n\timgixParams = {},\n\talt,\n\tfallbackAlt,\n\tfill,\n\twidth,\n\theight,\n\tfallback = null,\n\t...restProps\n}: PrismicNextImageProps): JSX.Element => {\n\tif (!__PRODUCTION__) {\n\t\tif (typeof alt === \"string\" && alt !== \"\") {\n\t\t\tconsole.warn(\n\t\t\t\t`[PrismicNextImage] 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`[PrismicNextImage] 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\t}\n\n\tif (prismic.isFilled.imageThumbnail(field)) {\n\t\tconst src = buildURL(field.url, imgixParams);\n\n\t\tconst ar = field.dimensions.width / field.dimensions.height;\n\n\t\tconst castedWidth = castInt(width);\n\t\tconst castedHeight = castInt(height);\n\n\t\tlet resolvedWidth = castedWidth ?? field.dimensions.width;\n\t\tlet resolvedHeight = castedHeight ?? field.dimensions.height;\n\n\t\tif (castedWidth != null && castedHeight == null) {\n\t\t\tresolvedHeight = castedWidth / ar;\n\t\t} else if (castedWidth == null && castedHeight != null) {\n\t\t\tresolvedWidth = castedHeight * ar;\n\t\t}\n\n\t\treturn (\n\t\t\t<Image\n\t\t\t\tsrc={src}\n\t\t\t\twidth={fill ? undefined : resolvedWidth}\n\t\t\t\theight={fill ? undefined : resolvedHeight}\n\t\t\t\t// A non-null assertion is required since we\n\t\t\t\t// can't statically know if an alt attribute is\n\t\t\t\t// available.\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\t\talt={(alt ?? (field.alt || fallbackAlt))!}\n\t\t\t\tfill={fill}\n\t\t\t\tloader={imgixLoader}\n\t\t\t\t{...restProps}\n\t\t\t/>\n\t\t);\n\t} else {\n\t\treturn <>{fallback}</>;\n\t}\n};\n"],"names":[],"mappings":";;;;;;;;;;;AAWA;AACC;AACQ;AAAA;AAED;AAEF;AACI;AAAA;AAEA;AAAA;AACP;AAEH;AAsDO;AAWN;AACC;AACC;AAGI;AAIL;AACC;AAGI;AAEJ;AAGF;AACC;AAEA;AAEM;AACA;AAEF;AACA;AAEA;AACH;AAA+B;AAE/B;AAA+B;AAGhC;AACO;AACL;AAC0B;AACC;AAAA;AAAA;AAAA;AAAA;AAKA;AAC3B;AACQ;AACJ;AACH;AAGH;AAAkB;AAEpB;;"}
@@ -1,12 +1,12 @@
1
1
  /// <reference types="react" />
2
2
  import { ImageProps } from "next/image";
3
3
  import { ImgixURLParams } from "imgix-url-builder";
4
- import * as prismicT from "@prismicio/types";
4
+ import * as prismic from "@prismicio/client";
5
5
  export type PrismicNextImageProps = Omit<ImageProps, "src" | "alt"> & {
6
6
  /**
7
7
  * The Prismic Image field or thumbnail to render.
8
8
  */
9
- field: prismicT.ImageFieldImage | null | undefined;
9
+ field: prismic.ImageFieldImage | null | undefined;
10
10
  /**
11
11
  * An object of Imgix URL API parameters to transform the image.
12
12
  *
@@ -1,10 +1,12 @@
1
+ 'use client';
2
+ 'use client';
1
3
  import { jsx, Fragment } from "react/jsx-runtime";
2
4
  import Image from "next/image";
3
5
  import { buildURL } from "imgix-url-builder";
4
- import * as prismicH from "@prismicio/helpers";
5
6
  import { __PRODUCTION__ } from "./lib/__PRODUCTION__.js";
6
7
  import { devMsg } from "./lib/devMsg.js";
7
8
  import { imgixLoader } from "./imgixLoader.js";
9
+ import { imageThumbnail } from './_node_modules/@prismicio/client/dist/helpers/isFilled.js';
8
10
  const castInt = (input) => {
9
11
  if (typeof input === "number" || typeof input === "undefined") {
10
12
  return input;
@@ -26,7 +28,7 @@ const PrismicNextImage = ({ field, imgixParams = {}, alt, fallbackAlt, fill, wid
26
28
  console.warn(`[PrismicNextImage] The "fallbackAlt" prop can only be used to declare an image as decorative by passing an empty string (fallbackAlt="") but was provided a non-empty string. You can resolve this warning by removing the "fallbackAlt" prop or changing it to fallbackAlt="". For more details, see ${devMsg("alt-must-be-an-empty-string")}`);
27
29
  }
28
30
  }
29
- if (prismicH.isFilled.imageThumbnail(field)) {
31
+ if (imageThumbnail(field)) {
30
32
  const src = buildURL(field.url, imgixParams);
31
33
  const ar = field.dimensions.width / field.dimensions.height;
32
34
  const castedWidth = castInt(width);
@@ -42,6 +44,10 @@ const PrismicNextImage = ({ field, imgixParams = {}, alt, fallbackAlt, fill, wid
42
44
  src,
43
45
  width: fill ? void 0 : resolvedWidth,
44
46
  height: fill ? void 0 : resolvedHeight,
47
+ // A non-null assertion is required since we
48
+ // can't statically know if an alt attribute is
49
+ // available.
50
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
45
51
  alt: alt ?? (field.alt || fallbackAlt),
46
52
  fill,
47
53
  loader: imgixLoader,
@@ -1 +1 @@
1
- {"version":3,"file":"PrismicNextImage.js","sources":["../../src/PrismicNextImage.tsx"],"sourcesContent":["import Image, { ImageProps } from \"next/image\";\nimport { buildURL, ImgixURLParams } from \"imgix-url-builder\";\nimport * as prismicH from \"@prismicio/helpers\";\nimport * as prismicT from \"@prismicio/types\";\n\nimport { __PRODUCTION__ } from \"./lib/__PRODUCTION__\";\nimport { devMsg } from \"./lib/devMsg\";\n\nimport { imgixLoader } from \"./imgixLoader\";\n\nconst castInt = (input: string | number | undefined): number | undefined => {\n\tif (typeof input === \"number\" || typeof input === \"undefined\") {\n\t\treturn input;\n\t} else {\n\t\tconst parsed = Number.parseInt(input);\n\n\t\tif (Number.isNaN(parsed)) {\n\t\t\treturn undefined;\n\t\t} else {\n\t\t\treturn parsed;\n\t\t}\n\t}\n};\n\nexport type PrismicNextImageProps = Omit<ImageProps, \"src\" | \"alt\"> & {\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?: ImgixURLParams;\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/**\n\t * Rendered when the field is empty. If a fallback is not given, `null` will\n\t * be rendered.\n\t */\n\tfallback?: React.ReactNode;\n};\n\n/**\n * React component that renders an image from a Prismic Image field or one of\n * its thumbnails using `next/image`. It will automatically set the `alt`\n * attribute using the Image field's `alt` property.\n *\n * It uses an Imgix URL-based loader by default. A custom loader can be provided\n * with the `loader` prop. If you would like to use the Next.js Image\n * Optimization API instead, set `loader={undefined}`.\n *\n * @param props - Props for the component.\n *\n * @returns A responsive image component using `next/image` for the given Image\n * field.\n * @see To learn more about `next/image`, see: https://nextjs.org/docs/api-reference/next/image\n */\nexport const PrismicNextImage = ({\n\tfield,\n\timgixParams = {},\n\talt,\n\tfallbackAlt,\n\tfill,\n\twidth,\n\theight,\n\tfallback = null,\n\t...restProps\n}: PrismicNextImageProps): JSX.Element => {\n\tif (!__PRODUCTION__) {\n\t\tif (typeof alt === \"string\" && alt !== \"\") {\n\t\t\tconsole.warn(\n\t\t\t\t`[PrismicNextImage] 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`[PrismicNextImage] 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\t}\n\n\tif (prismicH.isFilled.imageThumbnail(field)) {\n\t\tconst src = buildURL(field.url, imgixParams);\n\n\t\tconst ar = field.dimensions.width / field.dimensions.height;\n\n\t\tconst castedWidth = castInt(width);\n\t\tconst castedHeight = castInt(height);\n\n\t\tlet resolvedWidth = castedWidth ?? field.dimensions.width;\n\t\tlet resolvedHeight = castedHeight ?? field.dimensions.height;\n\n\t\tif (castedWidth != null && castedHeight == null) {\n\t\t\tresolvedHeight = castedWidth / ar;\n\t\t} else if (castedWidth == null && castedHeight != null) {\n\t\t\tresolvedWidth = castedHeight * ar;\n\t\t}\n\n\t\treturn (\n\t\t\t<Image\n\t\t\t\tsrc={src}\n\t\t\t\twidth={fill ? undefined : resolvedWidth}\n\t\t\t\theight={fill ? undefined : resolvedHeight}\n\t\t\t\t// A non-null assertion is required since we\n\t\t\t\t// can't statically know if an alt attribute is\n\t\t\t\t// available.\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\t\talt={(alt ?? (field.alt || fallbackAlt))!}\n\t\t\t\tfill={fill}\n\t\t\t\tloader={imgixLoader}\n\t\t\t\t{...restProps}\n\t\t\t/>\n\t\t);\n\t} else {\n\t\treturn <>{fallback}</>;\n\t}\n};\n"],"names":["_jsx","_Fragment"],"mappings":";;;;;;;AAUA,MAAM,UAAU,CAAC,UAA0D;AAC1E,MAAI,OAAO,UAAU,YAAY,OAAO,UAAU,aAAa;AACvD,WAAA;AAAA,EAAA,OACD;AACA,UAAA,SAAS,OAAO,SAAS,KAAK;AAEhC,QAAA,OAAO,MAAM,MAAM,GAAG;AAClB,aAAA;AAAA,IAAA,OACD;AACC,aAAA;AAAA,IACP;AAAA,EACD;AACF;AAsDO,MAAM,mBAAmB,CAAC,EAChC,OACA,cAAc,CAAA,GACd,KACA,aACA,MACA,OACA,QACA,WAAW,SACR,gBACqC;AACxC,MAAI,CAAC,gBAAgB;AACpB,QAAI,OAAO,QAAQ,YAAY,QAAQ,IAAI;AAC1C,cAAQ,KACP,yQAAyQ,OACxQ,6BAA6B,GAC3B;AAAA,IAEJ;AAED,QAAI,OAAO,gBAAgB,YAAY,gBAAgB,IAAI;AAC1D,cAAQ,KACP,ySAAyS,OACxS,6BAA6B,GAC3B;AAAA,IAEJ;AAAA,EACD;AAED,MAAI,SAAS,SAAS,eAAe,KAAK,GAAG;AAC5C,UAAM,MAAM,SAAS,MAAM,KAAK,WAAW;AAE3C,UAAM,KAAK,MAAM,WAAW,QAAQ,MAAM,WAAW;AAE/C,UAAA,cAAc,QAAQ,KAAK;AAC3B,UAAA,eAAe,QAAQ,MAAM;AAE/B,QAAA,gBAAgB,eAAe,MAAM,WAAW;AAChD,QAAA,iBAAiB,gBAAgB,MAAM,WAAW;AAElD,QAAA,eAAe,QAAQ,gBAAgB,MAAM;AAChD,uBAAiB,cAAc;AAAA,IACrB,WAAA,eAAe,QAAQ,gBAAgB,MAAM;AACvD,sBAAgB,eAAe;AAAA,IAC/B;AAED,WACCA,IAAC,OAAK;AAAA,MACL;AAAA,MACA,OAAO,OAAO,SAAY;AAAA,MAC1B,QAAQ,OAAO,SAAY;AAAA,MAK3B,KAAM,QAAQ,MAAM,OAAO;AAAA,MAC3B;AAAA,MACA,QAAQ;AAAA,MACJ,GAAA;AAAA,IAAA,CACH;AAAA,EAAA,OAEG;AACN,WAAOA,IAAAC,UAAA,EAAA,UAAG,SAAQ,CAAA;AAAA,EAClB;AACF;"}
1
+ {"version":3,"file":"PrismicNextImage.js","sources":["../../src/PrismicNextImage.tsx"],"sourcesContent":["\"use client\";\n\nimport Image, { ImageProps } from \"next/image\";\nimport { buildURL, ImgixURLParams } from \"imgix-url-builder\";\nimport * as prismic from \"@prismicio/client\";\n\nimport { __PRODUCTION__ } from \"./lib/__PRODUCTION__\";\nimport { devMsg } from \"./lib/devMsg\";\n\nimport { imgixLoader } from \"./imgixLoader\";\n\nconst castInt = (input: string | number | undefined): number | undefined => {\n\tif (typeof input === \"number\" || typeof input === \"undefined\") {\n\t\treturn input;\n\t} else {\n\t\tconst parsed = Number.parseInt(input);\n\n\t\tif (Number.isNaN(parsed)) {\n\t\t\treturn undefined;\n\t\t} else {\n\t\t\treturn parsed;\n\t\t}\n\t}\n};\n\nexport type PrismicNextImageProps = Omit<ImageProps, \"src\" | \"alt\"> & {\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?: ImgixURLParams;\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/**\n\t * Rendered when the field is empty. If a fallback is not given, `null` will\n\t * be rendered.\n\t */\n\tfallback?: React.ReactNode;\n};\n\n/**\n * React component that renders an image from a Prismic Image field or one of\n * its thumbnails using `next/image`. It will automatically set the `alt`\n * attribute using the Image field's `alt` property.\n *\n * It uses an Imgix URL-based loader by default. A custom loader can be provided\n * with the `loader` prop. If you would like to use the Next.js Image\n * Optimization API instead, set `loader={undefined}`.\n *\n * @param props - Props for the component.\n *\n * @returns A responsive image component using `next/image` for the given Image\n * field.\n * @see To learn more about `next/image`, see: https://nextjs.org/docs/api-reference/next/image\n */\nexport const PrismicNextImage = ({\n\tfield,\n\timgixParams = {},\n\talt,\n\tfallbackAlt,\n\tfill,\n\twidth,\n\theight,\n\tfallback = null,\n\t...restProps\n}: PrismicNextImageProps): JSX.Element => {\n\tif (!__PRODUCTION__) {\n\t\tif (typeof alt === \"string\" && alt !== \"\") {\n\t\t\tconsole.warn(\n\t\t\t\t`[PrismicNextImage] 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`[PrismicNextImage] 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\t}\n\n\tif (prismic.isFilled.imageThumbnail(field)) {\n\t\tconst src = buildURL(field.url, imgixParams);\n\n\t\tconst ar = field.dimensions.width / field.dimensions.height;\n\n\t\tconst castedWidth = castInt(width);\n\t\tconst castedHeight = castInt(height);\n\n\t\tlet resolvedWidth = castedWidth ?? field.dimensions.width;\n\t\tlet resolvedHeight = castedHeight ?? field.dimensions.height;\n\n\t\tif (castedWidth != null && castedHeight == null) {\n\t\t\tresolvedHeight = castedWidth / ar;\n\t\t} else if (castedWidth == null && castedHeight != null) {\n\t\t\tresolvedWidth = castedHeight * ar;\n\t\t}\n\n\t\treturn (\n\t\t\t<Image\n\t\t\t\tsrc={src}\n\t\t\t\twidth={fill ? undefined : resolvedWidth}\n\t\t\t\theight={fill ? undefined : resolvedHeight}\n\t\t\t\t// A non-null assertion is required since we\n\t\t\t\t// can't statically know if an alt attribute is\n\t\t\t\t// available.\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\t\talt={(alt ?? (field.alt || fallbackAlt))!}\n\t\t\t\tfill={fill}\n\t\t\t\tloader={imgixLoader}\n\t\t\t\t{...restProps}\n\t\t\t/>\n\t\t);\n\t} else {\n\t\treturn <>{fallback}</>;\n\t}\n};\n"],"names":[],"mappings":";;;;;;;;;AAWA;AACC;AACQ;AAAA;AAED;AAEF;AACI;AAAA;AAEA;AAAA;AACP;AAEH;AAsDO;AAWN;AACC;AACC;AAGI;AAIL;AACC;AAGI;AAEJ;AAGF;AACC;AAEA;AAEM;AACA;AAEF;AACA;AAEA;AACH;AAA+B;AAE/B;AAA+B;AAGhC;AACO;AACL;AAC0B;AACC;AAAA;AAAA;AAAA;AAAA;AAKA;AAC3B;AACQ;AACJ;AACH;AAGH;AAAkB;AAEpB;;;;"}
@@ -0,0 +1,39 @@
1
+ 'use client';
2
+ 'use client';
3
+ "use strict";
4
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
5
+ const jsxRuntime = require("react/jsx-runtime");
6
+ const React = require("react");
7
+ const Link = require("next/link");
8
+ const asLinkAttrs = require('./_node_modules/@prismicio/client/dist/helpers/asLinkAttrs.cjs');
9
+ function _interopNamespaceDefault(e) {
10
+ const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
11
+ if (e) {
12
+ for (const k in e) {
13
+ if (k !== "default") {
14
+ const d = Object.getOwnPropertyDescriptor(e, k);
15
+ Object.defineProperty(n, k, d.get ? d : {
16
+ enumerable: true,
17
+ get: () => e[k]
18
+ });
19
+ }
20
+ }
21
+ }
22
+ n.default = e;
23
+ return Object.freeze(n);
24
+ }
25
+ const React__namespace = /* @__PURE__ */ _interopNamespaceDefault(React);
26
+ const PrismicNextLink = React__namespace.forwardRef(function PrismicNextLink2({ field, document, linkResolver, ...restProps }, ref) {
27
+ const { href: computedHref, rel: computedRel, ...attrs } = asLinkAttrs.asLinkAttrs(field ?? document, {
28
+ linkResolver,
29
+ rel: typeof restProps.rel === "function" ? restProps.rel : void 0
30
+ });
31
+ const href = ("href" in restProps ? restProps.href : computedHref) || "";
32
+ let rel = computedRel;
33
+ if ("rel" in restProps && typeof restProps.rel !== "function") {
34
+ rel = restProps.rel;
35
+ }
36
+ return jsxRuntime.jsx(Link, { ref, ...attrs, ...restProps, href, rel });
37
+ });
38
+ exports.PrismicNextLink = PrismicNextLink;
39
+ //# sourceMappingURL=PrismicNextLink.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PrismicNextLink.cjs","sources":["../../src/PrismicNextLink.tsx"],"sourcesContent":["\"use client\";\n\nimport * as React from \"react\";\nimport * as prismic from \"@prismicio/client\";\nimport Link from \"next/link\";\n\nexport type PrismicNextLinkProps = Omit<\n\tReact.ComponentProps<typeof Link>,\n\t\"field\" | \"document\" | \"href\" | \"rel\"\n> & {\n\tlinkResolver?: prismic.LinkResolverFunction;\n\trel?: string | prismic.AsLinkAttrsConfig[\"rel\"];\n} & (\n\t\t| {\n\t\t\t\tfield: prismic.LinkField | null | undefined;\n\t\t\t\tdocument?: never;\n\t\t\t\thref?: never;\n\t\t }\n\t\t| {\n\t\t\t\tfield?: never;\n\t\t\t\tdocument: prismic.PrismicDocument | null | undefined;\n\t\t\t\thref?: never;\n\t\t }\n\t\t| {\n\t\t\t\tfield?: never;\n\t\t\t\tdocument?: never;\n\t\t\t\thref: React.ComponentProps<typeof Link>[\"href\"];\n\t\t }\n\t);\n\nexport const PrismicNextLink = React.forwardRef<\n\tHTMLAnchorElement,\n\tPrismicNextLinkProps\n>(function PrismicNextLink(\n\t{ field, document, linkResolver, ...restProps },\n\tref,\n): JSX.Element | null {\n\tconst {\n\t\thref: computedHref,\n\t\trel: computedRel,\n\t\t...attrs\n\t} = prismic.asLinkAttrs(field ?? document, {\n\t\tlinkResolver,\n\t\trel: typeof restProps.rel === \"function\" ? restProps.rel : undefined,\n\t});\n\n\tconst href = (\"href\" in restProps ? restProps.href : computedHref) || \"\";\n\n\tlet rel = computedRel;\n\tif (\"rel\" in restProps && typeof restProps.rel !== \"function\") {\n\t\trel = restProps.rel;\n\t}\n\n\treturn <Link ref={ref} {...attrs} {...restProps} href={href} rel={rel} />;\n});\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AA8BO;AAOA;AAIqC;AAC1C;AAC2D;AAG5D;AAEA;AACA;AACC;AAAgB;AAGV;AACR;;"}
@@ -0,0 +1,126 @@
1
+ /// <reference types="node" />
2
+ import * as React from "react";
3
+ import * as prismic from "@prismicio/client";
4
+ import Link from "next/link";
5
+ export type PrismicNextLinkProps = Omit<React.ComponentProps<typeof Link>, "field" | "document" | "href" | "rel"> & {
6
+ linkResolver?: prismic.LinkResolverFunction;
7
+ rel?: string | prismic.AsLinkAttrsConfig["rel"];
8
+ } & ({
9
+ field: prismic.LinkField | null | undefined;
10
+ document?: never;
11
+ href?: never;
12
+ } | {
13
+ field?: never;
14
+ document: prismic.PrismicDocument | null | undefined;
15
+ href?: never;
16
+ } | {
17
+ field?: never;
18
+ document?: never;
19
+ href: React.ComponentProps<typeof Link>["href"];
20
+ });
21
+ export declare const PrismicNextLink: React.ForwardRefExoticComponent<(Pick<Omit<Omit<React.AnchorHTMLAttributes<HTMLAnchorElement>, keyof {
22
+ href: string | import("url").UrlObject;
23
+ as?: (string | import("url").UrlObject) | undefined;
24
+ replace?: boolean | undefined;
25
+ scroll?: boolean | undefined;
26
+ shallow?: boolean | undefined;
27
+ passHref?: boolean | undefined;
28
+ prefetch?: boolean | undefined;
29
+ locale?: string | false | undefined;
30
+ legacyBehavior?: boolean | undefined;
31
+ onMouseEnter?: React.MouseEventHandler<HTMLAnchorElement> | undefined;
32
+ onTouchStart?: React.TouchEventHandler<HTMLAnchorElement> | undefined;
33
+ onClick?: React.MouseEventHandler<HTMLAnchorElement> | undefined;
34
+ }> & {
35
+ href: string | import("url").UrlObject;
36
+ as?: (string | import("url").UrlObject) | undefined;
37
+ replace?: boolean | undefined;
38
+ scroll?: boolean | undefined;
39
+ shallow?: boolean | undefined;
40
+ passHref?: boolean | undefined;
41
+ prefetch?: boolean | undefined;
42
+ locale?: string | false | undefined;
43
+ legacyBehavior?: boolean | undefined;
44
+ onMouseEnter?: React.MouseEventHandler<HTMLAnchorElement> | undefined;
45
+ onTouchStart?: React.TouchEventHandler<HTMLAnchorElement> | undefined;
46
+ onClick?: React.MouseEventHandler<HTMLAnchorElement> | undefined;
47
+ } & {
48
+ children?: React.ReactNode;
49
+ } & React.RefAttributes<HTMLAnchorElement>, "field" | "document" | "href" | "rel"> & {
50
+ linkResolver?: prismic.LinkResolverFunction | undefined;
51
+ rel?: string | prismic.AsLinkAttrsConfig["rel"];
52
+ } & {
53
+ field: prismic.LinkField | null | undefined;
54
+ document?: undefined;
55
+ href?: undefined;
56
+ }, "key" | "referrerPolicy" | "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" | "field" | "replace" | "document" | "href" | "as" | "scroll" | "shallow" | "passHref" | "prefetch" | "locale" | "legacyBehavior" | "download" | "hrefLang" | "media" | "ping" | "rel" | "target" | "type" | "linkResolver"> | Pick<Omit<Omit<React.AnchorHTMLAttributes<HTMLAnchorElement>, keyof {
57
+ href: string | import("url").UrlObject;
58
+ as?: (string | import("url").UrlObject) | undefined;
59
+ replace?: boolean | undefined;
60
+ scroll?: boolean | undefined;
61
+ shallow?: boolean | undefined;
62
+ passHref?: boolean | undefined;
63
+ prefetch?: boolean | undefined;
64
+ locale?: string | false | undefined;
65
+ legacyBehavior?: boolean | undefined;
66
+ onMouseEnter?: React.MouseEventHandler<HTMLAnchorElement> | undefined;
67
+ onTouchStart?: React.TouchEventHandler<HTMLAnchorElement> | undefined;
68
+ onClick?: React.MouseEventHandler<HTMLAnchorElement> | undefined;
69
+ }> & {
70
+ href: string | import("url").UrlObject;
71
+ as?: (string | import("url").UrlObject) | undefined;
72
+ replace?: boolean | undefined;
73
+ scroll?: boolean | undefined;
74
+ shallow?: boolean | undefined;
75
+ passHref?: boolean | undefined;
76
+ prefetch?: boolean | undefined;
77
+ locale?: string | false | undefined;
78
+ legacyBehavior?: boolean | undefined;
79
+ onMouseEnter?: React.MouseEventHandler<HTMLAnchorElement> | undefined;
80
+ onTouchStart?: React.TouchEventHandler<HTMLAnchorElement> | undefined;
81
+ onClick?: React.MouseEventHandler<HTMLAnchorElement> | undefined;
82
+ } & {
83
+ children?: React.ReactNode;
84
+ } & React.RefAttributes<HTMLAnchorElement>, "field" | "document" | "href" | "rel"> & {
85
+ linkResolver?: prismic.LinkResolverFunction | undefined;
86
+ rel?: string | prismic.AsLinkAttrsConfig["rel"];
87
+ } & {
88
+ field?: undefined;
89
+ document: prismic.PrismicDocument | null | undefined;
90
+ href?: undefined;
91
+ }, "key" | "referrerPolicy" | "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" | "field" | "replace" | "document" | "href" | "as" | "scroll" | "shallow" | "passHref" | "prefetch" | "locale" | "legacyBehavior" | "download" | "hrefLang" | "media" | "ping" | "rel" | "target" | "type" | "linkResolver"> | Pick<Omit<Omit<React.AnchorHTMLAttributes<HTMLAnchorElement>, keyof {
92
+ href: string | import("url").UrlObject;
93
+ as?: (string | import("url").UrlObject) | undefined;
94
+ replace?: boolean | undefined;
95
+ scroll?: boolean | undefined;
96
+ shallow?: boolean | undefined;
97
+ passHref?: boolean | undefined;
98
+ prefetch?: boolean | undefined;
99
+ locale?: string | false | undefined;
100
+ legacyBehavior?: boolean | undefined;
101
+ onMouseEnter?: React.MouseEventHandler<HTMLAnchorElement> | undefined;
102
+ onTouchStart?: React.TouchEventHandler<HTMLAnchorElement> | undefined;
103
+ onClick?: React.MouseEventHandler<HTMLAnchorElement> | undefined;
104
+ }> & {
105
+ href: string | import("url").UrlObject;
106
+ as?: (string | import("url").UrlObject) | undefined;
107
+ replace?: boolean | undefined;
108
+ scroll?: boolean | undefined;
109
+ shallow?: boolean | undefined;
110
+ passHref?: boolean | undefined;
111
+ prefetch?: boolean | undefined;
112
+ locale?: string | false | undefined;
113
+ legacyBehavior?: boolean | undefined;
114
+ onMouseEnter?: React.MouseEventHandler<HTMLAnchorElement> | undefined;
115
+ onTouchStart?: React.TouchEventHandler<HTMLAnchorElement> | undefined;
116
+ onClick?: React.MouseEventHandler<HTMLAnchorElement> | undefined;
117
+ } & {
118
+ children?: React.ReactNode;
119
+ } & React.RefAttributes<HTMLAnchorElement>, "field" | "document" | "href" | "rel"> & {
120
+ linkResolver?: prismic.LinkResolverFunction | undefined;
121
+ rel?: string | prismic.AsLinkAttrsConfig["rel"];
122
+ } & {
123
+ field?: undefined;
124
+ document?: undefined;
125
+ href: React.ComponentProps<typeof Link>["href"];
126
+ }, "key" | "referrerPolicy" | "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" | "field" | "replace" | "document" | "href" | "as" | "scroll" | "shallow" | "passHref" | "prefetch" | "locale" | "legacyBehavior" | "download" | "hrefLang" | "media" | "ping" | "rel" | "target" | "type" | "linkResolver">) & React.RefAttributes<HTMLAnchorElement>>;
@@ -0,0 +1,22 @@
1
+ 'use client';
2
+ 'use client';
3
+ import { jsx } from "react/jsx-runtime";
4
+ import * as React from "react";
5
+ import Link from "next/link";
6
+ import { asLinkAttrs } from './_node_modules/@prismicio/client/dist/helpers/asLinkAttrs.js';
7
+ const PrismicNextLink = React.forwardRef(function PrismicNextLink2({ field, document, linkResolver, ...restProps }, ref) {
8
+ const { href: computedHref, rel: computedRel, ...attrs } = asLinkAttrs(field ?? document, {
9
+ linkResolver,
10
+ rel: typeof restProps.rel === "function" ? restProps.rel : void 0
11
+ });
12
+ const href = ("href" in restProps ? restProps.href : computedHref) || "";
13
+ let rel = computedRel;
14
+ if ("rel" in restProps && typeof restProps.rel !== "function") {
15
+ rel = restProps.rel;
16
+ }
17
+ return jsx(Link, { ref, ...attrs, ...restProps, href, rel });
18
+ });
19
+ export {
20
+ PrismicNextLink
21
+ };
22
+ //# sourceMappingURL=PrismicNextLink.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PrismicNextLink.js","sources":["../../src/PrismicNextLink.tsx"],"sourcesContent":["\"use client\";\n\nimport * as React from \"react\";\nimport * as prismic from \"@prismicio/client\";\nimport Link from \"next/link\";\n\nexport type PrismicNextLinkProps = Omit<\n\tReact.ComponentProps<typeof Link>,\n\t\"field\" | \"document\" | \"href\" | \"rel\"\n> & {\n\tlinkResolver?: prismic.LinkResolverFunction;\n\trel?: string | prismic.AsLinkAttrsConfig[\"rel\"];\n} & (\n\t\t| {\n\t\t\t\tfield: prismic.LinkField | null | undefined;\n\t\t\t\tdocument?: never;\n\t\t\t\thref?: never;\n\t\t }\n\t\t| {\n\t\t\t\tfield?: never;\n\t\t\t\tdocument: prismic.PrismicDocument | null | undefined;\n\t\t\t\thref?: never;\n\t\t }\n\t\t| {\n\t\t\t\tfield?: never;\n\t\t\t\tdocument?: never;\n\t\t\t\thref: React.ComponentProps<typeof Link>[\"href\"];\n\t\t }\n\t);\n\nexport const PrismicNextLink = React.forwardRef<\n\tHTMLAnchorElement,\n\tPrismicNextLinkProps\n>(function PrismicNextLink(\n\t{ field, document, linkResolver, ...restProps },\n\tref,\n): JSX.Element | null {\n\tconst {\n\t\thref: computedHref,\n\t\trel: computedRel,\n\t\t...attrs\n\t} = prismic.asLinkAttrs(field ?? document, {\n\t\tlinkResolver,\n\t\trel: typeof restProps.rel === \"function\" ? restProps.rel : undefined,\n\t});\n\n\tconst href = (\"href\" in restProps ? restProps.href : computedHref) || \"\";\n\n\tlet rel = computedRel;\n\tif (\"rel\" in restProps && typeof restProps.rel !== \"function\") {\n\t\trel = restProps.rel;\n\t}\n\n\treturn <Link ref={ref} {...attrs} {...restProps} href={href} rel={rel} />;\n});\n"],"names":[],"mappings":";;;;;;AA8BO;AAOA;AAIqC;AAC1C;AAC2D;AAG5D;AAEA;AACA;AACC;AAAgB;AAGV;AACR;;;;"}
@@ -1,3 +1,5 @@
1
+ 'use client';
2
+ 'use client';
1
3
  "use strict";
2
4
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
5
  const jsxRuntime = require("react/jsx-runtime");
@@ -1 +1 @@
1
- {"version":3,"file":"PrismicPreview.cjs","sources":["../../src/PrismicPreview.tsx"],"sourcesContent":["import * as React from \"react\";\nimport { useRouter } from \"next/router\";\nimport Script from \"next/script\";\n\nimport { getPrismicPreviewCookie } from \"./lib/getPrismicPreviewCookie\";\nimport { getPreviewCookieRepositoryName } from \"./lib/getPreviewCookieRepositoryName\";\n\n/**\n * Props for `<PrismicPreview>`.\n */\nexport type PrismicPreviewProps = {\n\t/**\n\t * The name of your Prismic repository. A Prismic Toolbar will be registered\n\t * using this repository.\n\t */\n\trepositoryName: string;\n\n\t/**\n\t * The URL of your app's Prismic preview endpoint (default: `/api/preview`).\n\t * This URL will be fetched on preview update events.\n\t *\n\t * **Note**: If your `next.config.js` file contains a `basePath`, it is\n\t * automatically included.\n\t */\n\tupdatePreviewURL?: string;\n\n\t/**\n\t * The URL of your app's exit preview endpoint (default: `/api/exit-preview`).\n\t * This URL will be fetched on preview exit events.\n\t *\n\t * **Note**: If your `next.config.js` file contains a `basePath`, it is\n\t * automatically included.\n\t */\n\texitPreviewURL?: string;\n\n\t/**\n\t * Children to render adjacent to the Prismic Toolbar. The Prismic Toolbar\n\t * will be rendered last.\n\t */\n\tchildren?: React.ReactNode;\n};\n\n/**\n * React component that sets up Prismic Previews using the Prismic Toolbar. When\n * the Prismic Toolbar send events to the browser, such as on preview updates\n * and exiting, this component will automatically update the Next.js preview\n * cookie and refresh the page.\n *\n * This component can be wrapped around your app or added anywhere in your app's\n * tree. It must be rendered on every page.\n */\nexport function PrismicPreview({\n\trepositoryName,\n\tchildren,\n\tupdatePreviewURL = \"/api/preview\",\n\texitPreviewURL = \"/api/exit-preview\",\n}: PrismicPreviewProps): JSX.Element {\n\tconst router = useRouter();\n\n\tconst resolvedUpdatePreviewURL = router.basePath + updatePreviewURL;\n\tconst resolvedExitPreviewURL = router.basePath + exitPreviewURL;\n\n\tReact.useEffect(() => {\n\t\t/**\n\t\t * Starts Preview Mode and refreshes the page's props.\n\t\t */\n\t\tconst startPreviewMode = async () => {\n\t\t\t// Start Next.js Preview Mode via the given preview API endpoint.\n\t\t\tconst res = await globalThis.fetch(resolvedUpdatePreviewURL);\n\n\t\t\t// We check for `res.redirected` rather than `res.ok`\n\t\t\t// since the update preview endpoint may redirect to a\n\t\t\t// 404 page. As long as it redirects, we know the\n\t\t\t// endpoint exists and at least attempted to set\n\t\t\t// preview data.\n\t\t\tif (res.redirected) {\n\t\t\t\tglobalThis.location.reload();\n\t\t\t} else {\n\t\t\t\tconsole.error(\n\t\t\t\t\t`[<PrismicPreview>] Failed to start or update Preview Mode using the \"${resolvedUpdatePreviewURL}\" API endpoint. Does it exist?`,\n\t\t\t\t);\n\t\t\t}\n\t\t};\n\n\t\tconst handlePrismicPreviewUpdate = async (event: Event) => {\n\t\t\t// Prevent the toolbar from reloading the page.\n\t\t\tevent.preventDefault();\n\n\t\t\tawait startPreviewMode();\n\t\t};\n\n\t\tconst handlePrismicPreviewEnd = async (event: Event) => {\n\t\t\t// Prevent the toolbar from reloading the page.\n\t\t\tevent.preventDefault();\n\n\t\t\t// Exit Next.js Preview Mode via the given preview API endpoint.\n\t\t\tconst res = await globalThis.fetch(resolvedExitPreviewURL);\n\n\t\t\tif (res.ok) {\n\t\t\t\tglobalThis.location.reload();\n\t\t\t} else {\n\t\t\t\tconsole.error(\n\t\t\t\t\t`[<PrismicPreview>] Failed to exit Preview Mode using the \"${resolvedExitPreviewURL}\" API endpoint. Does it exist?`,\n\t\t\t\t);\n\t\t\t}\n\t\t};\n\n\t\tif (router.isPreview) {\n\t\t\t// Register Prismic Toolbar event handlers.\n\t\t\twindow.addEventListener(\n\t\t\t\t\"prismicPreviewUpdate\",\n\t\t\t\thandlePrismicPreviewUpdate,\n\t\t\t);\n\t\t\twindow.addEventListener(\"prismicPreviewEnd\", handlePrismicPreviewEnd);\n\t\t} else {\n\t\t\tconst prismicPreviewCookie = getPrismicPreviewCookie(\n\t\t\t\tglobalThis.document.cookie,\n\t\t\t);\n\n\t\t\tif (prismicPreviewCookie) {\n\t\t\t\t// If a Prismic preview cookie is present, but Next.js Preview\n\t\t\t\t// Mode is not active, we must activate Preview Mode manually.\n\t\t\t\t//\n\t\t\t\t// This will happen when a visitor accesses the page using a\n\t\t\t\t// Prismic preview share link.\n\n\t\t\t\t/**\n\t\t\t\t * Determines if the current location is a descendant of the app's base\n\t\t\t\t * path.\n\t\t\t\t *\n\t\t\t\t * This is used to prevent infinite refrehes; when\n\t\t\t\t * `isDescendantOfBasePath` is `false`, `router.isPreview` is also\n\t\t\t\t * `false`.\n\t\t\t\t *\n\t\t\t\t * If the app does not have a base path, this should always be `true`.\n\t\t\t\t */\n\t\t\t\tconst locationIsDescendantOfBasePath = window.location.href.startsWith(\n\t\t\t\t\twindow.location.origin + router.basePath,\n\t\t\t\t);\n\n\t\t\t\tconst prismicPreviewCookieRepositoryName =\n\t\t\t\t\tgetPreviewCookieRepositoryName(prismicPreviewCookie);\n\n\t\t\t\tif (\n\t\t\t\t\tlocationIsDescendantOfBasePath &&\n\t\t\t\t\tprismicPreviewCookieRepositoryName === repositoryName\n\t\t\t\t) {\n\t\t\t\t\tstartPreviewMode();\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// On cleanup, unregister Prismic Toolbar event handlers.\n\t\treturn () => {\n\t\t\twindow.removeEventListener(\n\t\t\t\t\"prismicPreviewUpdate\",\n\t\t\t\thandlePrismicPreviewUpdate,\n\t\t\t);\n\t\t\twindow.removeEventListener(\"prismicPreviewEnd\", handlePrismicPreviewEnd);\n\t\t};\n\t}, [\n\t\trepositoryName,\n\t\tresolvedExitPreviewURL,\n\t\tresolvedUpdatePreviewURL,\n\t\trouter.isPreview,\n\t\trouter.basePath,\n\t]);\n\n\treturn (\n\t\t<>\n\t\t\t{children}\n\t\t\t<Script\n\t\t\t\tsrc={`https://static.cdn.prismic.io/prismic.js?repo=${repositoryName}&new=true`}\n\t\t\t\tstrategy=\"lazyOnload\"\n\t\t\t/>\n\t\t</>\n\t);\n}\n"],"names":["router","useRouter","React","getPrismicPreviewCookie","getPreviewCookieRepositoryName","_jsxs","_Fragment","_jsx"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAmDgB,SAAA,eAAe,EAC9B,gBACA,UACA,mBAAmB,gBACnB,iBAAiB,uBACI;AACrB,QAAMA,WAASC,OAAAA;AAET,QAAA,2BAA2BD,SAAO,WAAW;AAC7C,QAAA,yBAAyBA,SAAO,WAAW;AAEjDE,mBAAM,UAAU,MAAK;AAIpB,UAAM,mBAAmB,YAAW;AAEnC,YAAM,MAAM,MAAM,WAAW,MAAM,wBAAwB;AAO3D,UAAI,IAAI,YAAY;AACnB,mBAAW,SAAS;aACd;AACE,gBAAA,MACP,wEAAwE,wDAAwD;AAAA,MAEjI;AAAA,IAAA;AAGI,UAAA,6BAA6B,OAAO,UAAgB;AAEzD,YAAM,eAAc;AAEpB,YAAM;;AAGD,UAAA,0BAA0B,OAAO,UAAgB;AAEtD,YAAM,eAAc;AAGpB,YAAM,MAAM,MAAM,WAAW,MAAM,sBAAsB;AAEzD,UAAI,IAAI,IAAI;AACX,mBAAW,SAAS;aACd;AACE,gBAAA,MACP,6DAA6D,sDAAsD;AAAA,MAEpH;AAAA,IAAA;AAGF,QAAIF,SAAO,WAAW;AAEd,aAAA,iBACN,wBACA,0BAA0B;AAEpB,aAAA,iBAAiB,qBAAqB,uBAAuB;AAAA,IAAA,OAC9D;AACN,YAAM,uBAAuBG,wBAAA,wBAC5B,WAAW,SAAS,MAAM;AAG3B,UAAI,sBAAsB;AAiBnB,cAAA,iCAAiC,OAAO,SAAS,KAAK,WAC3D,OAAO,SAAS,SAASH,SAAO,QAAQ;AAGnC,cAAA,qCACLI,8DAA+B,oBAAoB;AAGnD,YAAA,kCACA,uCAAuC,gBACtC;;QAED;AAAA,MACD;AAAA,IACD;AAGD,WAAO,MAAK;AACJ,aAAA,oBACN,wBACA,0BAA0B;AAEpB,aAAA,oBAAoB,qBAAqB,uBAAuB;AAAA,IAAA;AAAA,EACxE,GACE;AAAA,IACF;AAAA,IACA;AAAA,IACA;AAAA,IACAJ,SAAO;AAAA,IACPA,SAAO;AAAA,EAAA,CACP;AAED,SACCK,WAAAA,KACEC,WAAAA,UAAA,EAAA,UAAA,CAAA,UACDC,WAAAA,IAAC,UACA,KAAK,iDAAiD,2BACtD,UAAS,aACR,CAAA,CAAA,GAAA;AAGL;;"}
1
+ {"version":3,"file":"PrismicPreview.cjs","sources":["../../src/PrismicPreview.tsx"],"sourcesContent":["\"use client\";\n\nimport * as React from \"react\";\nimport { useRouter } from \"next/router\";\nimport Script from \"next/script\";\n\nimport { getPrismicPreviewCookie } from \"./lib/getPrismicPreviewCookie\";\nimport { getPreviewCookieRepositoryName } from \"./lib/getPreviewCookieRepositoryName\";\n\n/**\n * Props for `<PrismicPreview>`.\n */\nexport type PrismicPreviewProps = {\n\t/**\n\t * The name of your Prismic repository. A Prismic Toolbar will be registered\n\t * using this repository.\n\t */\n\trepositoryName: string;\n\n\t/**\n\t * The URL of your app's Prismic preview endpoint (default: `/api/preview`).\n\t * This URL will be fetched on preview update events.\n\t *\n\t * **Note**: If your `next.config.js` file contains a `basePath`, it is\n\t * automatically included.\n\t */\n\tupdatePreviewURL?: string;\n\n\t/**\n\t * The URL of your app's exit preview endpoint (default: `/api/exit-preview`).\n\t * This URL will be fetched on preview exit events.\n\t *\n\t * **Note**: If your `next.config.js` file contains a `basePath`, it is\n\t * automatically included.\n\t */\n\texitPreviewURL?: string;\n\n\t/**\n\t * Children to render adjacent to the Prismic Toolbar. The Prismic Toolbar\n\t * will be rendered last.\n\t */\n\tchildren?: React.ReactNode;\n};\n\n/**\n * React component that sets up Prismic Previews using the Prismic Toolbar. When\n * the Prismic Toolbar send events to the browser, such as on preview updates\n * and exiting, this component will automatically update the Next.js preview\n * cookie and refresh the page.\n *\n * This component can be wrapped around your app or added anywhere in your app's\n * tree. It must be rendered on every page.\n */\nexport function PrismicPreview({\n\trepositoryName,\n\tchildren,\n\tupdatePreviewURL = \"/api/preview\",\n\texitPreviewURL = \"/api/exit-preview\",\n}: PrismicPreviewProps): JSX.Element {\n\tconst router = useRouter();\n\n\tconst resolvedUpdatePreviewURL = router.basePath + updatePreviewURL;\n\tconst resolvedExitPreviewURL = router.basePath + exitPreviewURL;\n\n\tReact.useEffect(() => {\n\t\t/**\n\t\t * Starts Preview Mode and refreshes the page's props.\n\t\t */\n\t\tconst startPreviewMode = async () => {\n\t\t\t// Start Next.js Preview Mode via the given preview API endpoint.\n\t\t\tconst res = await globalThis.fetch(resolvedUpdatePreviewURL);\n\n\t\t\t// We check for `res.redirected` rather than `res.ok`\n\t\t\t// since the update preview endpoint may redirect to a\n\t\t\t// 404 page. As long as it redirects, we know the\n\t\t\t// endpoint exists and at least attempted to set\n\t\t\t// preview data.\n\t\t\tif (res.redirected) {\n\t\t\t\tglobalThis.location.reload();\n\t\t\t} else {\n\t\t\t\tconsole.error(\n\t\t\t\t\t`[<PrismicPreview>] Failed to start or update Preview Mode using the \"${resolvedUpdatePreviewURL}\" API endpoint. Does it exist?`,\n\t\t\t\t);\n\t\t\t}\n\t\t};\n\n\t\tconst handlePrismicPreviewUpdate = async (event: Event) => {\n\t\t\t// Prevent the toolbar from reloading the page.\n\t\t\tevent.preventDefault();\n\n\t\t\tawait startPreviewMode();\n\t\t};\n\n\t\tconst handlePrismicPreviewEnd = async (event: Event) => {\n\t\t\t// Prevent the toolbar from reloading the page.\n\t\t\tevent.preventDefault();\n\n\t\t\t// Exit Next.js Preview Mode via the given preview API endpoint.\n\t\t\tconst res = await globalThis.fetch(resolvedExitPreviewURL);\n\n\t\t\tif (res.ok) {\n\t\t\t\tglobalThis.location.reload();\n\t\t\t} else {\n\t\t\t\tconsole.error(\n\t\t\t\t\t`[<PrismicPreview>] Failed to exit Preview Mode using the \"${resolvedExitPreviewURL}\" API endpoint. Does it exist?`,\n\t\t\t\t);\n\t\t\t}\n\t\t};\n\n\t\tif (router.isPreview) {\n\t\t\t// Register Prismic Toolbar event handlers.\n\t\t\twindow.addEventListener(\n\t\t\t\t\"prismicPreviewUpdate\",\n\t\t\t\thandlePrismicPreviewUpdate,\n\t\t\t);\n\t\t\twindow.addEventListener(\"prismicPreviewEnd\", handlePrismicPreviewEnd);\n\t\t} else {\n\t\t\tconst prismicPreviewCookie = getPrismicPreviewCookie(\n\t\t\t\tglobalThis.document.cookie,\n\t\t\t);\n\n\t\t\tif (prismicPreviewCookie) {\n\t\t\t\t// If a Prismic preview cookie is present, but Next.js Preview\n\t\t\t\t// Mode is not active, we must activate Preview Mode manually.\n\t\t\t\t//\n\t\t\t\t// This will happen when a visitor accesses the page using a\n\t\t\t\t// Prismic preview share link.\n\n\t\t\t\t/**\n\t\t\t\t * Determines if the current location is a descendant of the app's base\n\t\t\t\t * path.\n\t\t\t\t *\n\t\t\t\t * This is used to prevent infinite refrehes; when\n\t\t\t\t * `isDescendantOfBasePath` is `false`, `router.isPreview` is also\n\t\t\t\t * `false`.\n\t\t\t\t *\n\t\t\t\t * If the app does not have a base path, this should always be `true`.\n\t\t\t\t */\n\t\t\t\tconst locationIsDescendantOfBasePath = window.location.href.startsWith(\n\t\t\t\t\twindow.location.origin + router.basePath,\n\t\t\t\t);\n\n\t\t\t\tconst prismicPreviewCookieRepositoryName =\n\t\t\t\t\tgetPreviewCookieRepositoryName(prismicPreviewCookie);\n\n\t\t\t\tif (\n\t\t\t\t\tlocationIsDescendantOfBasePath &&\n\t\t\t\t\tprismicPreviewCookieRepositoryName === repositoryName\n\t\t\t\t) {\n\t\t\t\t\tstartPreviewMode();\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// On cleanup, unregister Prismic Toolbar event handlers.\n\t\treturn () => {\n\t\t\twindow.removeEventListener(\n\t\t\t\t\"prismicPreviewUpdate\",\n\t\t\t\thandlePrismicPreviewUpdate,\n\t\t\t);\n\t\t\twindow.removeEventListener(\"prismicPreviewEnd\", handlePrismicPreviewEnd);\n\t\t};\n\t}, [\n\t\trepositoryName,\n\t\tresolvedExitPreviewURL,\n\t\tresolvedUpdatePreviewURL,\n\t\trouter.isPreview,\n\t\trouter.basePath,\n\t]);\n\n\treturn (\n\t\t<>\n\t\t\t{children}\n\t\t\t<Script\n\t\t\t\tsrc={`https://static.cdn.prismic.io/prismic.js?repo=${repositoryName}&new=true`}\n\t\t\t\tstrategy=\"lazyOnload\"\n\t\t\t/>\n\t\t</>\n\t);\n}\n"],"names":["React"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAqDgB;AAMf;AAEM;AACA;AAENA;AAIC;AAEC;AAOA;AACC;;AAEQ;AACyH;AAEjI;AAGI;AAEL;AAEA;;AAGK;AAEL;AAGA;AAEA;AACC;;AAEQ;AAC4G;AAEpH;AAGF;AAEQ;AAIA;AAA6D;AAEpE;AAIA;AAiBO;AAIA;AAIL;;;AAIA;AACD;AAIF;AACQ;AAIA;AAAgE;AAAA;AAEtE;AACF;AACA;AACA;AACO;AACA;AAGR;AASD;;"}
@@ -1,3 +1,5 @@
1
+ 'use client';
2
+ 'use client';
1
3
  import { jsxs, Fragment, jsx } from "react/jsx-runtime";
2
4
  import * as React from "react";
3
5
  import { useRouter } from "next/router";
@@ -1 +1 @@
1
- {"version":3,"file":"PrismicPreview.js","sources":["../../src/PrismicPreview.tsx"],"sourcesContent":["import * as React from \"react\";\nimport { useRouter } from \"next/router\";\nimport Script from \"next/script\";\n\nimport { getPrismicPreviewCookie } from \"./lib/getPrismicPreviewCookie\";\nimport { getPreviewCookieRepositoryName } from \"./lib/getPreviewCookieRepositoryName\";\n\n/**\n * Props for `<PrismicPreview>`.\n */\nexport type PrismicPreviewProps = {\n\t/**\n\t * The name of your Prismic repository. A Prismic Toolbar will be registered\n\t * using this repository.\n\t */\n\trepositoryName: string;\n\n\t/**\n\t * The URL of your app's Prismic preview endpoint (default: `/api/preview`).\n\t * This URL will be fetched on preview update events.\n\t *\n\t * **Note**: If your `next.config.js` file contains a `basePath`, it is\n\t * automatically included.\n\t */\n\tupdatePreviewURL?: string;\n\n\t/**\n\t * The URL of your app's exit preview endpoint (default: `/api/exit-preview`).\n\t * This URL will be fetched on preview exit events.\n\t *\n\t * **Note**: If your `next.config.js` file contains a `basePath`, it is\n\t * automatically included.\n\t */\n\texitPreviewURL?: string;\n\n\t/**\n\t * Children to render adjacent to the Prismic Toolbar. The Prismic Toolbar\n\t * will be rendered last.\n\t */\n\tchildren?: React.ReactNode;\n};\n\n/**\n * React component that sets up Prismic Previews using the Prismic Toolbar. When\n * the Prismic Toolbar send events to the browser, such as on preview updates\n * and exiting, this component will automatically update the Next.js preview\n * cookie and refresh the page.\n *\n * This component can be wrapped around your app or added anywhere in your app's\n * tree. It must be rendered on every page.\n */\nexport function PrismicPreview({\n\trepositoryName,\n\tchildren,\n\tupdatePreviewURL = \"/api/preview\",\n\texitPreviewURL = \"/api/exit-preview\",\n}: PrismicPreviewProps): JSX.Element {\n\tconst router = useRouter();\n\n\tconst resolvedUpdatePreviewURL = router.basePath + updatePreviewURL;\n\tconst resolvedExitPreviewURL = router.basePath + exitPreviewURL;\n\n\tReact.useEffect(() => {\n\t\t/**\n\t\t * Starts Preview Mode and refreshes the page's props.\n\t\t */\n\t\tconst startPreviewMode = async () => {\n\t\t\t// Start Next.js Preview Mode via the given preview API endpoint.\n\t\t\tconst res = await globalThis.fetch(resolvedUpdatePreviewURL);\n\n\t\t\t// We check for `res.redirected` rather than `res.ok`\n\t\t\t// since the update preview endpoint may redirect to a\n\t\t\t// 404 page. As long as it redirects, we know the\n\t\t\t// endpoint exists and at least attempted to set\n\t\t\t// preview data.\n\t\t\tif (res.redirected) {\n\t\t\t\tglobalThis.location.reload();\n\t\t\t} else {\n\t\t\t\tconsole.error(\n\t\t\t\t\t`[<PrismicPreview>] Failed to start or update Preview Mode using the \"${resolvedUpdatePreviewURL}\" API endpoint. Does it exist?`,\n\t\t\t\t);\n\t\t\t}\n\t\t};\n\n\t\tconst handlePrismicPreviewUpdate = async (event: Event) => {\n\t\t\t// Prevent the toolbar from reloading the page.\n\t\t\tevent.preventDefault();\n\n\t\t\tawait startPreviewMode();\n\t\t};\n\n\t\tconst handlePrismicPreviewEnd = async (event: Event) => {\n\t\t\t// Prevent the toolbar from reloading the page.\n\t\t\tevent.preventDefault();\n\n\t\t\t// Exit Next.js Preview Mode via the given preview API endpoint.\n\t\t\tconst res = await globalThis.fetch(resolvedExitPreviewURL);\n\n\t\t\tif (res.ok) {\n\t\t\t\tglobalThis.location.reload();\n\t\t\t} else {\n\t\t\t\tconsole.error(\n\t\t\t\t\t`[<PrismicPreview>] Failed to exit Preview Mode using the \"${resolvedExitPreviewURL}\" API endpoint. Does it exist?`,\n\t\t\t\t);\n\t\t\t}\n\t\t};\n\n\t\tif (router.isPreview) {\n\t\t\t// Register Prismic Toolbar event handlers.\n\t\t\twindow.addEventListener(\n\t\t\t\t\"prismicPreviewUpdate\",\n\t\t\t\thandlePrismicPreviewUpdate,\n\t\t\t);\n\t\t\twindow.addEventListener(\"prismicPreviewEnd\", handlePrismicPreviewEnd);\n\t\t} else {\n\t\t\tconst prismicPreviewCookie = getPrismicPreviewCookie(\n\t\t\t\tglobalThis.document.cookie,\n\t\t\t);\n\n\t\t\tif (prismicPreviewCookie) {\n\t\t\t\t// If a Prismic preview cookie is present, but Next.js Preview\n\t\t\t\t// Mode is not active, we must activate Preview Mode manually.\n\t\t\t\t//\n\t\t\t\t// This will happen when a visitor accesses the page using a\n\t\t\t\t// Prismic preview share link.\n\n\t\t\t\t/**\n\t\t\t\t * Determines if the current location is a descendant of the app's base\n\t\t\t\t * path.\n\t\t\t\t *\n\t\t\t\t * This is used to prevent infinite refrehes; when\n\t\t\t\t * `isDescendantOfBasePath` is `false`, `router.isPreview` is also\n\t\t\t\t * `false`.\n\t\t\t\t *\n\t\t\t\t * If the app does not have a base path, this should always be `true`.\n\t\t\t\t */\n\t\t\t\tconst locationIsDescendantOfBasePath = window.location.href.startsWith(\n\t\t\t\t\twindow.location.origin + router.basePath,\n\t\t\t\t);\n\n\t\t\t\tconst prismicPreviewCookieRepositoryName =\n\t\t\t\t\tgetPreviewCookieRepositoryName(prismicPreviewCookie);\n\n\t\t\t\tif (\n\t\t\t\t\tlocationIsDescendantOfBasePath &&\n\t\t\t\t\tprismicPreviewCookieRepositoryName === repositoryName\n\t\t\t\t) {\n\t\t\t\t\tstartPreviewMode();\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// On cleanup, unregister Prismic Toolbar event handlers.\n\t\treturn () => {\n\t\t\twindow.removeEventListener(\n\t\t\t\t\"prismicPreviewUpdate\",\n\t\t\t\thandlePrismicPreviewUpdate,\n\t\t\t);\n\t\t\twindow.removeEventListener(\"prismicPreviewEnd\", handlePrismicPreviewEnd);\n\t\t};\n\t}, [\n\t\trepositoryName,\n\t\tresolvedExitPreviewURL,\n\t\tresolvedUpdatePreviewURL,\n\t\trouter.isPreview,\n\t\trouter.basePath,\n\t]);\n\n\treturn (\n\t\t<>\n\t\t\t{children}\n\t\t\t<Script\n\t\t\t\tsrc={`https://static.cdn.prismic.io/prismic.js?repo=${repositoryName}&new=true`}\n\t\t\t\tstrategy=\"lazyOnload\"\n\t\t\t/>\n\t\t</>\n\t);\n}\n"],"names":["_jsxs","_Fragment","_jsx"],"mappings":";;;;;;AAmDgB,SAAA,eAAe,EAC9B,gBACA,UACA,mBAAmB,gBACnB,iBAAiB,uBACI;AACrB,QAAM,SAAS;AAET,QAAA,2BAA2B,OAAO,WAAW;AAC7C,QAAA,yBAAyB,OAAO,WAAW;AAEjD,QAAM,UAAU,MAAK;AAIpB,UAAM,mBAAmB,YAAW;AAEnC,YAAM,MAAM,MAAM,WAAW,MAAM,wBAAwB;AAO3D,UAAI,IAAI,YAAY;AACnB,mBAAW,SAAS;aACd;AACE,gBAAA,MACP,wEAAwE,wDAAwD;AAAA,MAEjI;AAAA,IAAA;AAGI,UAAA,6BAA6B,OAAO,UAAgB;AAEzD,YAAM,eAAc;AAEpB,YAAM;;AAGD,UAAA,0BAA0B,OAAO,UAAgB;AAEtD,YAAM,eAAc;AAGpB,YAAM,MAAM,MAAM,WAAW,MAAM,sBAAsB;AAEzD,UAAI,IAAI,IAAI;AACX,mBAAW,SAAS;aACd;AACE,gBAAA,MACP,6DAA6D,sDAAsD;AAAA,MAEpH;AAAA,IAAA;AAGF,QAAI,OAAO,WAAW;AAEd,aAAA,iBACN,wBACA,0BAA0B;AAEpB,aAAA,iBAAiB,qBAAqB,uBAAuB;AAAA,IAAA,OAC9D;AACN,YAAM,uBAAuB,wBAC5B,WAAW,SAAS,MAAM;AAG3B,UAAI,sBAAsB;AAiBnB,cAAA,iCAAiC,OAAO,SAAS,KAAK,WAC3D,OAAO,SAAS,SAAS,OAAO,QAAQ;AAGnC,cAAA,qCACL,+BAA+B,oBAAoB;AAGnD,YAAA,kCACA,uCAAuC,gBACtC;;QAED;AAAA,MACD;AAAA,IACD;AAGD,WAAO,MAAK;AACJ,aAAA,oBACN,wBACA,0BAA0B;AAEpB,aAAA,oBAAoB,qBAAqB,uBAAuB;AAAA,IAAA;AAAA,EACxE,GACE;AAAA,IACF;AAAA,IACA;AAAA,IACA;AAAA,IACA,OAAO;AAAA,IACP,OAAO;AAAA,EAAA,CACP;AAED,SACCA,KACEC,UAAA,EAAA,UAAA,CAAA,UACDC,IAAC,UACA,KAAK,iDAAiD,2BACtD,UAAS,aACR,CAAA,CAAA,GAAA;AAGL;"}
1
+ {"version":3,"file":"PrismicPreview.js","sources":["../../src/PrismicPreview.tsx"],"sourcesContent":["\"use client\";\n\nimport * as React from \"react\";\nimport { useRouter } from \"next/router\";\nimport Script from \"next/script\";\n\nimport { getPrismicPreviewCookie } from \"./lib/getPrismicPreviewCookie\";\nimport { getPreviewCookieRepositoryName } from \"./lib/getPreviewCookieRepositoryName\";\n\n/**\n * Props for `<PrismicPreview>`.\n */\nexport type PrismicPreviewProps = {\n\t/**\n\t * The name of your Prismic repository. A Prismic Toolbar will be registered\n\t * using this repository.\n\t */\n\trepositoryName: string;\n\n\t/**\n\t * The URL of your app's Prismic preview endpoint (default: `/api/preview`).\n\t * This URL will be fetched on preview update events.\n\t *\n\t * **Note**: If your `next.config.js` file contains a `basePath`, it is\n\t * automatically included.\n\t */\n\tupdatePreviewURL?: string;\n\n\t/**\n\t * The URL of your app's exit preview endpoint (default: `/api/exit-preview`).\n\t * This URL will be fetched on preview exit events.\n\t *\n\t * **Note**: If your `next.config.js` file contains a `basePath`, it is\n\t * automatically included.\n\t */\n\texitPreviewURL?: string;\n\n\t/**\n\t * Children to render adjacent to the Prismic Toolbar. The Prismic Toolbar\n\t * will be rendered last.\n\t */\n\tchildren?: React.ReactNode;\n};\n\n/**\n * React component that sets up Prismic Previews using the Prismic Toolbar. When\n * the Prismic Toolbar send events to the browser, such as on preview updates\n * and exiting, this component will automatically update the Next.js preview\n * cookie and refresh the page.\n *\n * This component can be wrapped around your app or added anywhere in your app's\n * tree. It must be rendered on every page.\n */\nexport function PrismicPreview({\n\trepositoryName,\n\tchildren,\n\tupdatePreviewURL = \"/api/preview\",\n\texitPreviewURL = \"/api/exit-preview\",\n}: PrismicPreviewProps): JSX.Element {\n\tconst router = useRouter();\n\n\tconst resolvedUpdatePreviewURL = router.basePath + updatePreviewURL;\n\tconst resolvedExitPreviewURL = router.basePath + exitPreviewURL;\n\n\tReact.useEffect(() => {\n\t\t/**\n\t\t * Starts Preview Mode and refreshes the page's props.\n\t\t */\n\t\tconst startPreviewMode = async () => {\n\t\t\t// Start Next.js Preview Mode via the given preview API endpoint.\n\t\t\tconst res = await globalThis.fetch(resolvedUpdatePreviewURL);\n\n\t\t\t// We check for `res.redirected` rather than `res.ok`\n\t\t\t// since the update preview endpoint may redirect to a\n\t\t\t// 404 page. As long as it redirects, we know the\n\t\t\t// endpoint exists and at least attempted to set\n\t\t\t// preview data.\n\t\t\tif (res.redirected) {\n\t\t\t\tglobalThis.location.reload();\n\t\t\t} else {\n\t\t\t\tconsole.error(\n\t\t\t\t\t`[<PrismicPreview>] Failed to start or update Preview Mode using the \"${resolvedUpdatePreviewURL}\" API endpoint. Does it exist?`,\n\t\t\t\t);\n\t\t\t}\n\t\t};\n\n\t\tconst handlePrismicPreviewUpdate = async (event: Event) => {\n\t\t\t// Prevent the toolbar from reloading the page.\n\t\t\tevent.preventDefault();\n\n\t\t\tawait startPreviewMode();\n\t\t};\n\n\t\tconst handlePrismicPreviewEnd = async (event: Event) => {\n\t\t\t// Prevent the toolbar from reloading the page.\n\t\t\tevent.preventDefault();\n\n\t\t\t// Exit Next.js Preview Mode via the given preview API endpoint.\n\t\t\tconst res = await globalThis.fetch(resolvedExitPreviewURL);\n\n\t\t\tif (res.ok) {\n\t\t\t\tglobalThis.location.reload();\n\t\t\t} else {\n\t\t\t\tconsole.error(\n\t\t\t\t\t`[<PrismicPreview>] Failed to exit Preview Mode using the \"${resolvedExitPreviewURL}\" API endpoint. Does it exist?`,\n\t\t\t\t);\n\t\t\t}\n\t\t};\n\n\t\tif (router.isPreview) {\n\t\t\t// Register Prismic Toolbar event handlers.\n\t\t\twindow.addEventListener(\n\t\t\t\t\"prismicPreviewUpdate\",\n\t\t\t\thandlePrismicPreviewUpdate,\n\t\t\t);\n\t\t\twindow.addEventListener(\"prismicPreviewEnd\", handlePrismicPreviewEnd);\n\t\t} else {\n\t\t\tconst prismicPreviewCookie = getPrismicPreviewCookie(\n\t\t\t\tglobalThis.document.cookie,\n\t\t\t);\n\n\t\t\tif (prismicPreviewCookie) {\n\t\t\t\t// If a Prismic preview cookie is present, but Next.js Preview\n\t\t\t\t// Mode is not active, we must activate Preview Mode manually.\n\t\t\t\t//\n\t\t\t\t// This will happen when a visitor accesses the page using a\n\t\t\t\t// Prismic preview share link.\n\n\t\t\t\t/**\n\t\t\t\t * Determines if the current location is a descendant of the app's base\n\t\t\t\t * path.\n\t\t\t\t *\n\t\t\t\t * This is used to prevent infinite refrehes; when\n\t\t\t\t * `isDescendantOfBasePath` is `false`, `router.isPreview` is also\n\t\t\t\t * `false`.\n\t\t\t\t *\n\t\t\t\t * If the app does not have a base path, this should always be `true`.\n\t\t\t\t */\n\t\t\t\tconst locationIsDescendantOfBasePath = window.location.href.startsWith(\n\t\t\t\t\twindow.location.origin + router.basePath,\n\t\t\t\t);\n\n\t\t\t\tconst prismicPreviewCookieRepositoryName =\n\t\t\t\t\tgetPreviewCookieRepositoryName(prismicPreviewCookie);\n\n\t\t\t\tif (\n\t\t\t\t\tlocationIsDescendantOfBasePath &&\n\t\t\t\t\tprismicPreviewCookieRepositoryName === repositoryName\n\t\t\t\t) {\n\t\t\t\t\tstartPreviewMode();\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// On cleanup, unregister Prismic Toolbar event handlers.\n\t\treturn () => {\n\t\t\twindow.removeEventListener(\n\t\t\t\t\"prismicPreviewUpdate\",\n\t\t\t\thandlePrismicPreviewUpdate,\n\t\t\t);\n\t\t\twindow.removeEventListener(\"prismicPreviewEnd\", handlePrismicPreviewEnd);\n\t\t};\n\t}, [\n\t\trepositoryName,\n\t\tresolvedExitPreviewURL,\n\t\tresolvedUpdatePreviewURL,\n\t\trouter.isPreview,\n\t\trouter.basePath,\n\t]);\n\n\treturn (\n\t\t<>\n\t\t\t{children}\n\t\t\t<Script\n\t\t\t\tsrc={`https://static.cdn.prismic.io/prismic.js?repo=${repositoryName}&new=true`}\n\t\t\t\tstrategy=\"lazyOnload\"\n\t\t\t/>\n\t\t</>\n\t);\n}\n"],"names":[],"mappings":";;;;;;;;AAqDgB;AAMf;AAEM;AACA;AAEN;AAIC;AAEC;AAOA;AACC;;AAEQ;AACyH;AAEjI;AAGI;AAEL;AAEA;;AAGK;AAEL;AAGA;AAEA;AACC;;AAEQ;AAC4G;AAEpH;AAGF;AAEQ;AAIA;AAA6D;AAEpE;AAIA;AAiBO;AAIA;AAIL;;;AAIA;AACD;AAIF;AACQ;AAIA;AAAgE;AAAA;AAEtE;AACF;AACA;AACA;AACO;AACA;AAGR;AASD;;;;"}
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const preview = "io.prismic.preview";
4
+ exports.preview = preview;
5
+ //# sourceMappingURL=cookie.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cookie.cjs","sources":["../../../../../node_modules/@prismicio/client/dist/cookie.js"],"sourcesContent":["const preview = \"io.prismic.preview\";\nexport {\n preview\n};\n//# sourceMappingURL=cookie.js.map\n"],"names":[],"mappings":";;AAAK,MAAC,UAAU;;","x_google_ignoreList":[0]}
@@ -0,0 +1,5 @@
1
+ const preview = "io.prismic.preview";
2
+ export {
3
+ preview
4
+ };
5
+ //# sourceMappingURL=cookie.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cookie.js","sources":["../../../../../node_modules/@prismicio/client/dist/cookie.js"],"sourcesContent":["const preview = \"io.prismic.preview\";\nexport {\n preview\n};\n//# sourceMappingURL=cookie.js.map\n"],"names":[],"mappings":"AAAK,MAAC,UAAU;","x_google_ignoreList":[0]}
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const link = require("../types/value/link.cjs");
4
+ const documentToLinkField = require("./documentToLinkField.cjs");
5
+ const asLink = (linkFieldOrDocument, linkResolver) => {
6
+ if (!linkFieldOrDocument) {
7
+ return null;
8
+ }
9
+ const linkField = (
10
+ // prettier-ignore
11
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
12
+ // @ts-ignore - Bug in TypeScript 4.9: https://github.com/microsoft/TypeScript/issues/51501
13
+ // TODO: Remove the `prettier-ignore` comment when this bug is fixed.
14
+ "link_type" in linkFieldOrDocument ? linkFieldOrDocument : documentToLinkField.documentToLinkField(linkFieldOrDocument)
15
+ );
16
+ switch (linkField.link_type) {
17
+ case link.LinkType.Media:
18
+ case link.LinkType.Web:
19
+ return "url" in linkField ? linkField.url : null;
20
+ case link.LinkType.Document: {
21
+ if ("id" in linkField && linkResolver) {
22
+ const resolvedURL = linkResolver(linkField);
23
+ if (resolvedURL != null) {
24
+ return resolvedURL;
25
+ }
26
+ }
27
+ if ("url" in linkField && linkField.url) {
28
+ return linkField.url;
29
+ }
30
+ return null;
31
+ }
32
+ case link.LinkType.Any:
33
+ default:
34
+ return null;
35
+ }
36
+ };
37
+ exports.asLink = asLink;
38
+ //# sourceMappingURL=asLink.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"asLink.cjs","sources":["../../../../../../node_modules/@prismicio/client/dist/helpers/asLink.js"],"sourcesContent":["import { LinkType } from \"../types/value/link.js\";\nimport { documentToLinkField } from \"./documentToLinkField.js\";\nconst asLink = (linkFieldOrDocument, linkResolver) => {\n if (!linkFieldOrDocument) {\n return null;\n }\n const linkField = (\n // prettier-ignore\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore - Bug in TypeScript 4.9: https://github.com/microsoft/TypeScript/issues/51501\n // TODO: Remove the `prettier-ignore` comment when this bug is fixed.\n \"link_type\" in linkFieldOrDocument ? linkFieldOrDocument : documentToLinkField(linkFieldOrDocument)\n );\n switch (linkField.link_type) {\n case LinkType.Media:\n case LinkType.Web:\n return \"url\" in linkField ? linkField.url : null;\n case LinkType.Document: {\n if (\"id\" in linkField && linkResolver) {\n const resolvedURL = linkResolver(linkField);\n if (resolvedURL != null) {\n return resolvedURL;\n }\n }\n if (\"url\" in linkField && linkField.url) {\n return linkField.url;\n }\n return null;\n }\n case LinkType.Any:\n default:\n return null;\n }\n};\nexport {\n asLink\n};\n//# sourceMappingURL=asLink.js.map\n"],"names":["documentToLinkField","LinkType"],"mappings":";;;;AAEK,MAAC,SAAS,CAAC,qBAAqB,iBAAiB;AACpD,MAAI,CAAC,qBAAqB;AACxB,WAAO;AAAA,EACR;AACD,QAAM;AAAA;AAAA;AAAA;AAAA;AAAA,IAKJ,eAAe,sBAAsB,sBAAsBA,oBAAAA,oBAAoB,mBAAmB;AAAA;AAEpG,UAAQ,UAAU,WAAS;AAAA,IACzB,KAAKC,KAAAA,SAAS;AAAA,IACd,KAAKA,KAAQ,SAAC;AACZ,aAAO,SAAS,YAAY,UAAU,MAAM;AAAA,IAC9C,KAAKA,KAAAA,SAAS,UAAU;AACtB,UAAI,QAAQ,aAAa,cAAc;AACrC,cAAM,cAAc,aAAa,SAAS;AAC1C,YAAI,eAAe,MAAM;AACvB,iBAAO;AAAA,QACR;AAAA,MACF;AACD,UAAI,SAAS,aAAa,UAAU,KAAK;AACvC,eAAO,UAAU;AAAA,MAClB;AACD,aAAO;AAAA,IACR;AAAA,IACD,KAAKA,KAAAA,SAAS;AAAA,IACd;AACE,aAAO;AAAA,EACV;AACH;;","x_google_ignoreList":[0]}
@@ -0,0 +1,38 @@
1
+ import { LinkType } from "../types/value/link.js";
2
+ import { documentToLinkField } from "./documentToLinkField.js";
3
+ const asLink = (linkFieldOrDocument, linkResolver) => {
4
+ if (!linkFieldOrDocument) {
5
+ return null;
6
+ }
7
+ const linkField = (
8
+ // prettier-ignore
9
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
10
+ // @ts-ignore - Bug in TypeScript 4.9: https://github.com/microsoft/TypeScript/issues/51501
11
+ // TODO: Remove the `prettier-ignore` comment when this bug is fixed.
12
+ "link_type" in linkFieldOrDocument ? linkFieldOrDocument : documentToLinkField(linkFieldOrDocument)
13
+ );
14
+ switch (linkField.link_type) {
15
+ case LinkType.Media:
16
+ case LinkType.Web:
17
+ return "url" in linkField ? linkField.url : null;
18
+ case LinkType.Document: {
19
+ if ("id" in linkField && linkResolver) {
20
+ const resolvedURL = linkResolver(linkField);
21
+ if (resolvedURL != null) {
22
+ return resolvedURL;
23
+ }
24
+ }
25
+ if ("url" in linkField && linkField.url) {
26
+ return linkField.url;
27
+ }
28
+ return null;
29
+ }
30
+ case LinkType.Any:
31
+ default:
32
+ return null;
33
+ }
34
+ };
35
+ export {
36
+ asLink
37
+ };
38
+ //# sourceMappingURL=asLink.js.map