@prismicio/next 2.0.1 → 2.0.2-canary.6f580fa

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (92) hide show
  1. package/dist/PrismicNextImage.cjs +66 -56
  2. package/dist/PrismicNextImage.cjs.map +1 -1
  3. package/dist/PrismicNextImage.d.cts +57 -0
  4. package/dist/PrismicNextLink.cjs +29 -21
  5. package/dist/PrismicNextLink.cjs.map +1 -1
  6. package/dist/PrismicNextLink.d.cts +54 -0
  7. package/dist/PrismicNextRichText.cjs +34 -0
  8. package/dist/PrismicNextRichText.cjs.map +1 -0
  9. package/dist/PrismicNextRichText.d.cts +11 -0
  10. package/dist/PrismicPreview.cjs +38 -36
  11. package/dist/PrismicPreview.cjs.map +1 -1
  12. package/dist/PrismicPreview.d.cts +36 -0
  13. package/dist/PrismicPreviewClient.cjs +71 -65
  14. package/dist/PrismicPreviewClient.cjs.map +1 -1
  15. package/dist/_virtual/rolldown_runtime.cjs +29 -0
  16. package/dist/createLocaleRedirect.cjs +11 -5
  17. package/dist/createLocaleRedirect.cjs.map +1 -1
  18. package/dist/createLocaleRedirect.d.cts +14 -0
  19. package/dist/enableAutoPreviews.cjs +27 -48
  20. package/dist/enableAutoPreviews.cjs.map +1 -1
  21. package/dist/enableAutoPreviews.d.cts +18 -0
  22. package/dist/exitPreview.cjs +24 -32
  23. package/dist/exitPreview.cjs.map +1 -1
  24. package/dist/{exitPreview.d.ts → exitPreview.d.cts} +5 -1
  25. package/dist/imgixLoader.cjs +21 -14
  26. package/dist/imgixLoader.cjs.map +1 -1
  27. package/dist/{imgixLoader.d.ts → imgixLoader.d.cts} +7 -1
  28. package/dist/index.cjs +19 -19
  29. package/dist/index.d.cts +11 -0
  30. package/dist/lib/devMsg.cjs +22 -5
  31. package/dist/lib/devMsg.cjs.map +1 -1
  32. package/dist/lib/resolveDefaultExport.cjs +23 -4
  33. package/dist/lib/resolveDefaultExport.cjs.map +1 -1
  34. package/dist/package.cjs +12 -0
  35. package/dist/package.cjs.map +1 -0
  36. package/dist/pages/PrismicPreview.cjs +71 -59
  37. package/dist/pages/PrismicPreview.cjs.map +1 -1
  38. package/dist/pages/PrismicPreview.d.cts +36 -0
  39. package/dist/pages/enableAutoPreviews.cjs +21 -14
  40. package/dist/pages/enableAutoPreviews.cjs.map +1 -1
  41. package/dist/pages/enableAutoPreviews.d.cts +37 -0
  42. package/dist/pages/exitPreview.cjs +24 -7
  43. package/dist/pages/exitPreview.cjs.map +1 -1
  44. package/dist/pages/exitPreview.d.cts +38 -0
  45. package/dist/pages/redirectToPreviewURL.cjs +13 -13
  46. package/dist/pages/redirectToPreviewURL.cjs.map +1 -1
  47. package/dist/pages/redirectToPreviewURL.d.cts +48 -0
  48. package/dist/pages/setPreviewData.cjs +10 -8
  49. package/dist/pages/setPreviewData.cjs.map +1 -1
  50. package/dist/pages/setPreviewData.d.cts +26 -0
  51. package/dist/pages/types.d.cts +36 -0
  52. package/dist/pages.cjs +21 -21
  53. package/dist/pages.d.cts +12 -0
  54. package/dist/redirectToPreviewURL.cjs +21 -43
  55. package/dist/redirectToPreviewURL.cjs.map +1 -1
  56. package/dist/redirectToPreviewURL.d.cts +33 -0
  57. package/dist/types.d.cts +31 -0
  58. package/package.json +34 -49
  59. package/src/PrismicNextImage.tsx +10 -6
  60. package/src/PrismicNextLink.tsx +5 -3
  61. package/src/PrismicNextRichText.tsx +41 -0
  62. package/src/PrismicPreviewClient.tsx +2 -3
  63. package/src/createLocaleRedirect.ts +1 -1
  64. package/src/imgixLoader.ts +3 -2
  65. package/src/index.ts +3 -0
  66. package/src/lib/devMsg.ts +1 -1
  67. package/src/pages/PrismicPreview.tsx +2 -1
  68. package/src/pages/index.ts +3 -0
  69. package/src/pages/types.ts +2 -3
  70. package/src/redirectToPreviewURL.ts +1 -1
  71. package/dist/PrismicNextImage.d.ts +0 -54
  72. package/dist/PrismicNextLink.d.ts +0 -125
  73. package/dist/PrismicPreview.d.ts +0 -31
  74. package/dist/PrismicPreviewClient.d.ts +0 -9
  75. package/dist/createLocaleRedirect.d.ts +0 -10
  76. package/dist/enableAutoPreviews.d.ts +0 -13
  77. package/dist/index.cjs.map +0 -1
  78. package/dist/index.d.ts +0 -15
  79. package/dist/lib/devMsg.d.ts +0 -16
  80. package/dist/lib/resolveDefaultExport.d.ts +0 -18
  81. package/dist/package.json.cjs +0 -5
  82. package/dist/package.json.cjs.map +0 -1
  83. package/dist/pages/PrismicPreview.d.ts +0 -31
  84. package/dist/pages/enableAutoPreviews.d.ts +0 -31
  85. package/dist/pages/exitPreview.d.ts +0 -33
  86. package/dist/pages/index.d.ts +0 -18
  87. package/dist/pages/redirectToPreviewURL.d.ts +0 -43
  88. package/dist/pages/setPreviewData.d.ts +0 -18
  89. package/dist/pages/types.d.ts +0 -30
  90. package/dist/pages.cjs.map +0 -1
  91. package/dist/redirectToPreviewURL.d.ts +0 -28
  92. package/dist/types.d.ts +0 -26
@@ -1,61 +1,71 @@
1
1
  "use client";
2
- "use strict";
3
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
4
- const jsxRuntime = require("react/jsx-runtime");
5
- const react = require("react");
6
- const Image = require("next/image");
7
- const imgixUrlBuilder = require("imgix-url-builder");
8
- const client = require("@prismicio/client");
9
- const devMsg = require("./lib/devMsg.cjs");
10
- const resolveDefaultExport = require("./lib/resolveDefaultExport.cjs");
11
- const imgixLoader = require("./imgixLoader.cjs");
2
+
3
+ const require_rolldown_runtime = require('./_virtual/rolldown_runtime.cjs');
4
+ const require_resolveDefaultExport = require('./lib/resolveDefaultExport.cjs');
5
+ const require_devMsg = require('./lib/devMsg.cjs');
6
+ const require_imgixLoader = require('./imgixLoader.cjs');
7
+ let _prismicio_client = require("@prismicio/client");
8
+ let react = require("react");
9
+ let react_jsx_runtime = require("react/jsx-runtime");
10
+ let next_image = require("next/image");
11
+ next_image = require_rolldown_runtime.__toESM(next_image);
12
+ let imgix_url_builder = require("imgix-url-builder");
13
+
14
+ //#region src/PrismicNextImage.tsx
12
15
  const castInt = (input) => {
13
- if (typeof input === "number" || typeof input === "undefined") {
14
- return input;
15
- } else {
16
- const parsed = Number.parseInt(input);
17
- if (Number.isNaN(parsed)) {
18
- return void 0;
19
- } else {
20
- return parsed;
21
- }
22
- }
16
+ if (typeof input === "number" || typeof input === "undefined") return input;
17
+ else {
18
+ const parsed = Number.parseInt(input);
19
+ if (Number.isNaN(parsed)) return;
20
+ else return parsed;
21
+ }
23
22
  };
24
- const PrismicNextImage = react.forwardRef(function PrismicNextImage2({ field, imgixParams = {}, alt, fallbackAlt, fill, width, height, fallback = null, loader = imgixLoader.imgixLoader, ...restProps }, ref) {
25
- if (process.env.NODE_ENV === "development") {
26
- if (typeof alt === "string" && alt !== "") {
27
- console.warn(`[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.devMsg("alt-must-be-an-empty-string")}`);
28
- }
29
- if (typeof fallbackAlt === "string" && fallbackAlt !== "") {
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")}`);
31
- }
32
- }
33
- if (!client.isFilled.imageThumbnail(field)) {
34
- return jsxRuntime.jsx(jsxRuntime.Fragment, { children: fallback });
35
- }
36
- const resolvedImgixParams = imgixParams;
37
- for (const x in imgixParams) {
38
- if (resolvedImgixParams[x] === null) {
39
- resolvedImgixParams[x] = void 0;
40
- }
41
- }
42
- const src = imgixUrlBuilder.buildURL(field.url, imgixParams);
43
- const ar = field.dimensions.width / field.dimensions.height;
44
- const castedWidth = castInt(width);
45
- const castedHeight = castInt(height);
46
- let resolvedWidth = castedWidth ?? field.dimensions.width;
47
- let resolvedHeight = castedHeight ?? field.dimensions.height;
48
- if (castedWidth != null && castedHeight == null) {
49
- resolvedHeight = castedWidth / ar;
50
- } else if (castedWidth == null && castedHeight != null) {
51
- resolvedWidth = castedHeight * ar;
52
- }
53
- const resolvedAlt = alt ?? (field.alt || fallbackAlt);
54
- if (process.env.NODE_ENV === "development" && typeof resolvedAlt !== "string") {
55
- console.error(`[PrismicNextImage] The following image is missing an "alt" property. Please add Alternative Text to the image in Prismic. To mark the image as decorative instead, add one of \`alt=""\` or \`fallbackAlt=""\`.`, src);
56
- }
57
- const ResolvedImage = resolveDefaultExport.resolveDefaultExport(Image);
58
- return jsxRuntime.jsx(ResolvedImage, { ref, src, width: fill ? void 0 : resolvedWidth, height: fill ? void 0 : resolvedHeight, alt: resolvedAlt, fill, loader: loader === null ? void 0 : loader, ...restProps });
23
+ /**
24
+ * React component that renders an image from a Prismic Image field or one of
25
+ * its thumbnails using `next/image`. It will automatically set the `alt`
26
+ * attribute using the Image field's `alt` property.
27
+ *
28
+ * It uses an Imgix URL-based loader by default. A custom loader can be provided
29
+ * with the `loader` prop. If you would like to use the Next.js Image
30
+ * Optimization API instead, set `loader={undefined}`.
31
+ *
32
+ * @param props - Props for the component.
33
+ *
34
+ * @returns A responsive image component using `next/image` for the given Image
35
+ * field.
36
+ *
37
+ * @see To learn more about `next/image`, see: https://nextjs.org/docs/api-reference/next/image
38
+ */
39
+ const PrismicNextImage = (0, react.forwardRef)(function PrismicNextImage$1({ field, imgixParams = {}, alt, fallbackAlt, fill, width, height, fallback = null, loader = require_imgixLoader.imgixLoader, ...restProps }, ref) {
40
+ if (process.env.NODE_ENV === "development") {
41
+ if (typeof alt === "string" && alt !== "") console.warn(`[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 ${require_devMsg.devMsg("alt-must-be-an-empty-string")}`);
42
+ if (typeof fallbackAlt === "string" && fallbackAlt !== "") 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 ${require_devMsg.devMsg("alt-must-be-an-empty-string")}`);
43
+ }
44
+ if (!_prismicio_client.isFilled.imageThumbnail(field)) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_jsx_runtime.Fragment, { children: fallback });
45
+ const resolvedImgixParams = imgixParams;
46
+ for (const x in imgixParams) if (resolvedImgixParams[x] === null) resolvedImgixParams[x] = void 0;
47
+ const src = (0, imgix_url_builder.buildURL)(field.url, imgixParams);
48
+ const ar = field.dimensions.width / field.dimensions.height;
49
+ const castedWidth = castInt(width);
50
+ const castedHeight = castInt(height);
51
+ let resolvedWidth = castedWidth ?? field.dimensions.width;
52
+ let resolvedHeight = castedHeight ?? field.dimensions.height;
53
+ if (castedWidth != null && castedHeight == null) resolvedHeight = castedWidth / ar;
54
+ else if (castedWidth == null && castedHeight != null) resolvedWidth = castedHeight * ar;
55
+ const resolvedAlt = alt ?? (field.alt || fallbackAlt);
56
+ if (process.env.NODE_ENV === "development" && typeof resolvedAlt !== "string") console.error(`[PrismicNextImage] The following image is missing an "alt" property. Please add Alternative Text to the image in Prismic. To mark the image as decorative instead, add one of \`alt=""\` or \`fallbackAlt=""\`.`, src);
57
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_resolveDefaultExport.resolveDefaultExport(next_image.default), {
58
+ ref,
59
+ src,
60
+ width: fill ? void 0 : resolvedWidth,
61
+ height: fill ? void 0 : resolvedHeight,
62
+ alt: resolvedAlt,
63
+ fill,
64
+ loader: loader === null ? void 0 : loader,
65
+ ...restProps
66
+ });
59
67
  });
68
+
69
+ //#endregion
60
70
  exports.PrismicNextImage = PrismicNextImage;
61
- //# sourceMappingURL=PrismicNextImage.cjs.map
71
+ //# sourceMappingURL=PrismicNextImage.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"PrismicNextImage.cjs","sources":["../src/PrismicNextImage.tsx"],"sourcesContent":["\"use client\";\n\nimport {\n\tforwardRef,\n\tForwardRefExoticComponent,\n\tPropsWithoutRef,\n\tRefAttributes,\n} from \"react\";\nimport Image, { ImageProps } from \"next/image\";\nimport { buildURL, ImgixURLParams } from \"imgix-url-builder\";\nimport { ImageFieldImage, isFilled } from \"@prismicio/client\";\n\nimport { devMsg } from \"./lib/devMsg\";\nimport { resolveDefaultExport } from \"./lib/resolveDefaultExport\";\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<\n\tImageProps,\n\t\"src\" | \"alt\" | \"loader\"\n> & {\n\t/** The Prismic Image field or thumbnail to render. */\n\tfield: 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?: { [P in keyof ImgixURLParams]: ImgixURLParams[P] | null };\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\tloader?: ImageProps[\"loader\"] | null;\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 *\n * @see To learn more about `next/image`, see: https://nextjs.org/docs/api-reference/next/image\n */\n// The type annotation is necessary to avoid a type reference issue.\nexport const PrismicNextImage: ForwardRefExoticComponent<\n\tPropsWithoutRef<PrismicNextImageProps> & RefAttributes<HTMLImageElement>\n> = forwardRef<HTMLImageElement, PrismicNextImageProps>(\n\tfunction PrismicNextImage(\n\t\t{\n\t\t\tfield,\n\t\t\timgixParams = {},\n\t\t\talt,\n\t\t\tfallbackAlt,\n\t\t\tfill,\n\t\t\twidth,\n\t\t\theight,\n\t\t\tfallback = null,\n\t\t\tloader = imgixLoader,\n\t\t\t...restProps\n\t\t},\n\t\tref,\n\t) {\n\t\tif (process.env.NODE_ENV === \"development\") {\n\t\t\tif (typeof alt === \"string\" && alt !== \"\") {\n\t\t\t\tconsole.warn(\n\t\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\t\"alt-must-be-an-empty-string\",\n\t\t\t\t\t)}`,\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tif (typeof fallbackAlt === \"string\" && fallbackAlt !== \"\") {\n\t\t\t\tconsole.warn(\n\t\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\t\"alt-must-be-an-empty-string\",\n\t\t\t\t\t)}`,\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\n\t\tif (!isFilled.imageThumbnail(field)) {\n\t\t\treturn <>{fallback}</>;\n\t\t}\n\n\t\tconst resolvedImgixParams = imgixParams;\n\t\tfor (const x in imgixParams) {\n\t\t\tif (resolvedImgixParams[x as keyof typeof resolvedImgixParams] === null) {\n\t\t\t\tresolvedImgixParams[x as keyof typeof resolvedImgixParams] = undefined;\n\t\t\t}\n\t\t}\n\n\t\tconst src = buildURL(field.url, imgixParams as ImgixURLParams);\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\t// A non-null assertion is required since we can't statically\n\t\t// know if an alt attribute is available.\n\t\tconst resolvedAlt = (alt ?? (field.alt || fallbackAlt))!;\n\n\t\tif (\n\t\t\tprocess.env.NODE_ENV === \"development\" &&\n\t\t\ttypeof resolvedAlt !== \"string\"\n\t\t) {\n\t\t\tconsole.error(\n\t\t\t\t`[PrismicNextImage] The following image is missing an \"alt\" property. Please add Alternative Text to the image in Prismic. To mark the image as decorative instead, add one of \\`alt=\"\"\\` or \\`fallbackAlt=\"\"\\`.`,\n\t\t\t\tsrc,\n\t\t\t);\n\t\t}\n\n\t\tconst ResolvedImage = resolveDefaultExport(Image);\n\n\t\treturn (\n\t\t\t<ResolvedImage\n\t\t\t\tref={ref}\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\talt={resolvedAlt}\n\t\t\t\tfill={fill}\n\t\t\t\tloader={loader === null ? undefined : loader}\n\t\t\t\t{...restProps}\n\t\t\t/>\n\t\t);\n\t},\n);\n"],"names":["forwardRef","PrismicNextImage","imgixLoader","devMsg","isFilled","_jsx","_Fragment","buildURL","resolveDefaultExport"],"mappings":";;;;;;;;;;;AAiBA,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,IAAA;AAAA,EACR;AAEF;AA2Da,MAAA,mBAETA,MAAAA,WACH,SAASC,kBACR,EACC,OACA,cAAc,CAAA,GACd,KACA,aACA,MACA,OACA,QACA,WAAW,MACX,SAASC,yBACT,GAAG,UAAS,GAEb,KAAG;AAEC,MAAA,QAAQ,IAAI,aAAa,eAAe;AAC3C,QAAI,OAAO,QAAQ,YAAY,QAAQ,IAAI;AAC1C,cAAQ,KACP,yQAAyQC,OAAAA,OACxQ,6BAA6B,CAC7B,EAAE;AAAA,IAAA;AAIL,QAAI,OAAO,gBAAgB,YAAY,gBAAgB,IAAI;AAC1D,cAAQ,KACP,ySAAySA,OAAAA,OACxS,6BAA6B,CAC7B,EAAE;AAAA,IAAA;AAAA,EAEL;AAGD,MAAI,CAACC,OAAA,SAAS,eAAe,KAAK,GAAG;AACpC,WAAOC,WAAA,IAAAC,WAAA,UAAA,EAAA,UAAG,UAAQ;AAAA,EAAA;AAGnB,QAAM,sBAAsB;AAC5B,aAAW,KAAK,aAAa;AACxB,QAAA,oBAAoB,CAAqC,MAAM,MAAM;AACxE,0BAAoB,CAAqC,IAAI;AAAA,IAAA;AAAA,EAC9D;AAGD,QAAM,MAAMC,gBAAA,SAAS,MAAM,KAAK,WAA6B;AAE7D,QAAM,KAAK,MAAM,WAAW,QAAQ,MAAM,WAAW;AAE/C,QAAA,cAAc,QAAQ,KAAK;AAC3B,QAAA,eAAe,QAAQ,MAAM;AAE/B,MAAA,gBAAgB,eAAe,MAAM,WAAW;AAChD,MAAA,iBAAiB,gBAAgB,MAAM,WAAW;AAElD,MAAA,eAAe,QAAQ,gBAAgB,MAAM;AAChD,qBAAiB,cAAc;AAAA,EACrB,WAAA,eAAe,QAAQ,gBAAgB,MAAM;AACvD,oBAAgB,eAAe;AAAA,EAAA;AAK1B,QAAA,cAAe,QAAQ,MAAM,OAAO;AAE1C,MACC,QAAQ,IAAI,aAAa,iBACzB,OAAO,gBAAgB,UACtB;AACO,YAAA,MACP,mNACA,GAAG;AAAA,EAAA;AAIC,QAAA,gBAAgBC,0CAAqB,KAAK;AAG/C,SAAAH,eAAC,eAAa,EACb,KACA,KACA,OAAO,OAAO,SAAY,eAC1B,QAAQ,OAAO,SAAY,gBAC3B,KAAK,aACL,MACA,QAAQ,WAAW,OAAO,SAAY,QAAM,GACxC,UAAA,CAAS;AAGhB,CAAC;;"}
1
+ {"version":3,"file":"PrismicNextImage.cjs","names":["PrismicNextImage","imgixLoader","devMsg","isFilled","resolveDefaultExport","Image"],"sources":["../src/PrismicNextImage.tsx"],"sourcesContent":["\"use client\";\n\nimport type {\n\tForwardRefExoticComponent,\n\tPropsWithoutRef,\n\tRefAttributes} from \"react\";\nimport {\n\tforwardRef\n} from \"react\";\nimport type { ImageProps } from \"next/image\";\nimport Image from \"next/image\";\nimport type { ImgixURLParams } from \"imgix-url-builder\";\nimport { buildURL } from \"imgix-url-builder\";\nimport type { ImageFieldImage} from \"@prismicio/client\";\nimport { isFilled } from \"@prismicio/client\";\n\nimport { devMsg } from \"./lib/devMsg\";\nimport { resolveDefaultExport } from \"./lib/resolveDefaultExport\";\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<\n\tImageProps,\n\t\"src\" | \"alt\" | \"loader\"\n> & {\n\t/** The Prismic Image field or thumbnail to render. */\n\tfield: 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?: { [P in keyof ImgixURLParams]: ImgixURLParams[P] | null };\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\tloader?: ImageProps[\"loader\"] | null;\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 *\n * @see To learn more about `next/image`, see: https://nextjs.org/docs/api-reference/next/image\n */\n// The type annotation is necessary to avoid a type reference issue.\nexport const PrismicNextImage: ForwardRefExoticComponent<\n\tPropsWithoutRef<PrismicNextImageProps> & RefAttributes<HTMLImageElement>\n> = forwardRef<HTMLImageElement, PrismicNextImageProps>(\n\tfunction PrismicNextImage(\n\t\t{\n\t\t\tfield,\n\t\t\timgixParams = {},\n\t\t\talt,\n\t\t\tfallbackAlt,\n\t\t\tfill,\n\t\t\twidth,\n\t\t\theight,\n\t\t\tfallback = null,\n\t\t\tloader = imgixLoader,\n\t\t\t...restProps\n\t\t},\n\t\tref,\n\t) {\n\t\tif (process.env.NODE_ENV === \"development\") {\n\t\t\tif (typeof alt === \"string\" && alt !== \"\") {\n\t\t\t\tconsole.warn(\n\t\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\t\"alt-must-be-an-empty-string\",\n\t\t\t\t\t)}`,\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tif (typeof fallbackAlt === \"string\" && fallbackAlt !== \"\") {\n\t\t\t\tconsole.warn(\n\t\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\t\"alt-must-be-an-empty-string\",\n\t\t\t\t\t)}`,\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\n\t\tif (!isFilled.imageThumbnail(field)) {\n\t\t\treturn <>{fallback}</>;\n\t\t}\n\n\t\tconst resolvedImgixParams = imgixParams;\n\t\tfor (const x in imgixParams) {\n\t\t\tif (resolvedImgixParams[x as keyof typeof resolvedImgixParams] === null) {\n\t\t\t\tresolvedImgixParams[x as keyof typeof resolvedImgixParams] = undefined;\n\t\t\t}\n\t\t}\n\n\t\tconst src = buildURL(field.url, imgixParams as ImgixURLParams);\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\t// A non-null assertion is required since we can't statically\n\t\t// know if an alt attribute is available.\n\t\tconst resolvedAlt = (alt ?? (field.alt || fallbackAlt))!;\n\n\t\tif (\n\t\t\tprocess.env.NODE_ENV === \"development\" &&\n\t\t\ttypeof resolvedAlt !== \"string\"\n\t\t) {\n\t\t\tconsole.error(\n\t\t\t\t`[PrismicNextImage] The following image is missing an \"alt\" property. Please add Alternative Text to the image in Prismic. To mark the image as decorative instead, add one of \\`alt=\"\"\\` or \\`fallbackAlt=\"\"\\`.`,\n\t\t\t\tsrc,\n\t\t\t);\n\t\t}\n\n\t\tconst ResolvedImage = resolveDefaultExport(Image);\n\n\t\treturn (\n\t\t\t<ResolvedImage\n\t\t\t\tref={ref}\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\talt={resolvedAlt}\n\t\t\t\tfill={fill}\n\t\t\t\tloader={loader === null ? undefined : loader}\n\t\t\t\t{...restProps}\n\t\t\t/>\n\t\t);\n\t},\n);\n"],"mappings":";;;;;;;;;;;;;;AAqBA,MAAM,WAAW,UAA2D;AAC3E,KAAI,OAAO,UAAU,YAAY,OAAO,UAAU,YACjD,QAAO;MACD;EACN,MAAM,SAAS,OAAO,SAAS,MAAM;AAErC,MAAI,OAAO,MAAM,OAAO,CACvB;MAEA,QAAO;;;;;;;;;;;;;;;;;;;AA8DV,MAAa,yCAGZ,SAASA,mBACR,EACC,OACA,cAAc,EAAE,EAChB,KACA,aACA,MACA,OACA,QACA,WAAW,MACX,SAASC,iCACT,GAAG,aAEJ,KACC;AACD,KAAI,QAAQ,IAAI,aAAa,eAAe;AAC3C,MAAI,OAAO,QAAQ,YAAY,QAAQ,GACtC,SAAQ,KACP,yQAAyQC,sBACxQ,8BACA,GACD;AAGF,MAAI,OAAO,gBAAgB,YAAY,gBAAgB,GACtD,SAAQ,KACP,ySAAySA,sBACxS,8BACA,GACD;;AAIH,KAAI,CAACC,2BAAS,eAAe,MAAM,CAClC,QAAO,mFAAG,WAAY;CAGvB,MAAM,sBAAsB;AAC5B,MAAK,MAAM,KAAK,YACf,KAAI,oBAAoB,OAA2C,KAClE,qBAAoB,KAAyC;CAI/D,MAAM,sCAAe,MAAM,KAAK,YAA8B;CAE9D,MAAM,KAAK,MAAM,WAAW,QAAQ,MAAM,WAAW;CAErD,MAAM,cAAc,QAAQ,MAAM;CAClC,MAAM,eAAe,QAAQ,OAAO;CAEpC,IAAI,gBAAgB,eAAe,MAAM,WAAW;CACpD,IAAI,iBAAiB,gBAAgB,MAAM,WAAW;AAEtD,KAAI,eAAe,QAAQ,gBAAgB,KAC1C,kBAAiB,cAAc;UACrB,eAAe,QAAQ,gBAAgB,KACjD,iBAAgB,eAAe;CAKhC,MAAM,cAAe,QAAQ,MAAM,OAAO;AAE1C,KACC,QAAQ,IAAI,aAAa,iBACzB,OAAO,gBAAgB,SAEvB,SAAQ,MACP,mNACA,IACA;AAKF,QACC,2CAHqBC,kDAAqBC,mBAAM;EAI1C;EACA;EACL,OAAO,OAAO,SAAY;EAC1B,QAAQ,OAAO,SAAY;EAC3B,KAAK;EACC;EACN,QAAQ,WAAW,OAAO,SAAY;EACtC,GAAI;GACH;EAGJ"}
@@ -0,0 +1,57 @@
1
+ import { ForwardRefExoticComponent, PropsWithoutRef, RefAttributes } from "react";
2
+ import { ImageFieldImage } from "@prismicio/client";
3
+ import { ImageProps } from "next/image";
4
+ import { ImgixURLParams } from "imgix-url-builder";
5
+
6
+ //#region src/PrismicNextImage.d.ts
7
+ type PrismicNextImageProps = Omit<ImageProps, "src" | "alt" | "loader"> & {
8
+ /** The Prismic Image field or thumbnail to render. */
9
+ field: ImageFieldImage | null | undefined;
10
+ /**
11
+ * An object of Imgix URL API parameters to transform the image.
12
+ *
13
+ * @see https://docs.imgix.com/apis/rendering
14
+ */
15
+ imgixParams?: { [P in keyof ImgixURLParams]: ImgixURLParams[P] | null };
16
+ /**
17
+ * Declare an image as decorative by providing `alt=""`.
18
+ *
19
+ * See:
20
+ * https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/alt#decorative_images
21
+ */
22
+ alt?: "";
23
+ /**
24
+ * Declare an image as decorative only if the Image field does not have
25
+ * alternative text by providing `fallbackAlt=""`.
26
+ *
27
+ * See:
28
+ * https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/alt#decorative_images
29
+ */
30
+ fallbackAlt?: "";
31
+ /**
32
+ * Rendered when the field is empty. If a fallback is not given, `null` will
33
+ * be rendered.
34
+ */
35
+ fallback?: React.ReactNode;
36
+ loader?: ImageProps["loader"] | null;
37
+ };
38
+ /**
39
+ * React component that renders an image from a Prismic Image field or one of
40
+ * its thumbnails using `next/image`. It will automatically set the `alt`
41
+ * attribute using the Image field's `alt` property.
42
+ *
43
+ * It uses an Imgix URL-based loader by default. A custom loader can be provided
44
+ * with the `loader` prop. If you would like to use the Next.js Image
45
+ * Optimization API instead, set `loader={undefined}`.
46
+ *
47
+ * @param props - Props for the component.
48
+ *
49
+ * @returns A responsive image component using `next/image` for the given Image
50
+ * field.
51
+ *
52
+ * @see To learn more about `next/image`, see: https://nextjs.org/docs/api-reference/next/image
53
+ */
54
+ declare const PrismicNextImage: ForwardRefExoticComponent<PropsWithoutRef<PrismicNextImageProps> & RefAttributes<HTMLImageElement>>;
55
+ //#endregion
56
+ export { PrismicNextImage, PrismicNextImageProps };
57
+ //# sourceMappingURL=PrismicNextImage.d.cts.map
@@ -1,23 +1,31 @@
1
- "use strict";
2
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const jsxRuntime = require("react/jsx-runtime");
4
- const react = require("react");
5
- const Link = require("next/link");
6
- const client = require("@prismicio/client");
7
- const resolveDefaultExport = require("./lib/resolveDefaultExport.cjs");
8
- const PrismicNextLink = react.forwardRef(function PrismicNextLink2(props, ref) {
9
- const { field, document, linkResolver, children, ...restProps } = props;
10
- const { href: computedHref, rel: computedRel, ...attrs } = client.asLinkAttrs(field ?? document, {
11
- linkResolver,
12
- rel: typeof restProps.rel === "function" ? restProps.rel : void 0
13
- });
14
- const href = ("href" in restProps ? restProps.href : computedHref) || "";
15
- let rel = computedRel;
16
- if ("rel" in restProps && typeof restProps.rel !== "function") {
17
- rel = restProps.rel;
18
- }
19
- const ResolvedLink = resolveDefaultExport.resolveDefaultExport(Link);
20
- return jsxRuntime.jsx(ResolvedLink, { ref, ...attrs, ...restProps, href, rel, children: "children" in props ? children : field == null ? void 0 : field.text });
1
+ const require_rolldown_runtime = require('./_virtual/rolldown_runtime.cjs');
2
+ const require_resolveDefaultExport = require('./lib/resolveDefaultExport.cjs');
3
+ let _prismicio_client = require("@prismicio/client");
4
+ let react = require("react");
5
+ let react_jsx_runtime = require("react/jsx-runtime");
6
+ let next_link = require("next/link");
7
+ next_link = require_rolldown_runtime.__toESM(next_link);
8
+
9
+ //#region src/PrismicNextLink.tsx
10
+ const PrismicNextLink = (0, react.forwardRef)(function PrismicNextLink$1(props, ref) {
11
+ const { field, document, linkResolver, children, ...restProps } = props;
12
+ const { href: computedHref, rel: computedRel, ...attrs } = (0, _prismicio_client.asLinkAttrs)(field ?? document, {
13
+ linkResolver,
14
+ rel: typeof restProps.rel === "function" ? restProps.rel : void 0
15
+ });
16
+ const href = ("href" in restProps ? restProps.href : computedHref) || "";
17
+ let rel = computedRel;
18
+ if ("rel" in restProps && typeof restProps.rel !== "function") rel = restProps.rel;
19
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_resolveDefaultExport.resolveDefaultExport(next_link.default), {
20
+ ref,
21
+ ...attrs,
22
+ ...restProps,
23
+ href,
24
+ rel,
25
+ children: "children" in props ? children : field?.text
26
+ });
21
27
  });
28
+
29
+ //#endregion
22
30
  exports.PrismicNextLink = PrismicNextLink;
23
- //# sourceMappingURL=PrismicNextLink.cjs.map
31
+ //# sourceMappingURL=PrismicNextLink.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"PrismicNextLink.cjs","sources":["../src/PrismicNextLink.tsx"],"sourcesContent":["import { ComponentProps, forwardRef } from \"react\";\nimport Link from \"next/link\";\nimport {\n\tAsLinkAttrsConfig,\n\tLinkField,\n\tLinkResolverFunction,\n\tPrismicDocument,\n\tasLinkAttrs,\n} from \"@prismicio/client\";\n\nimport { resolveDefaultExport } from \"./lib/resolveDefaultExport\";\n\nexport type PrismicNextLinkProps = Omit<\n\tComponentProps<typeof Link>,\n\t\"field\" | \"document\" | \"href\" | \"rel\"\n> & {\n\tlinkResolver?: LinkResolverFunction;\n\trel?: string | AsLinkAttrsConfig[\"rel\"];\n} & (\n\t\t| {\n\t\t\t\tfield: 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: 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: ComponentProps<typeof Link>[\"href\"];\n\t\t }\n\t);\n\nexport const PrismicNextLink = forwardRef<\n\tHTMLAnchorElement,\n\tPrismicNextLinkProps\n>(function PrismicNextLink(props, ref) {\n\tconst { field, document, linkResolver, children, ...restProps } = props;\n\tconst {\n\t\thref: computedHref,\n\t\trel: computedRel,\n\t\t...attrs\n\t} = 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\tconst ResolvedLink = resolveDefaultExport(Link);\n\n\treturn (\n\t\t<ResolvedLink ref={ref} {...attrs} {...restProps} href={href} rel={rel}>\n\t\t\t{\"children\" in props ? children : field?.text}\n\t\t</ResolvedLink>\n\t);\n});\n"],"names":["forwardRef","PrismicNextLink","asLinkAttrs","resolveDefaultExport","_jsx"],"mappings":";;;;;;;AAoCO,MAAM,kBAAkBA,MAAAA,WAG7B,SAASC,iBAAgB,OAAO,KAAG;AACpC,QAAM,EAAE,OAAO,UAAU,cAAc,UAAU,GAAG,cAAc;AAC5D,QAAA,EACL,MAAM,cACN,KAAK,aACL,GAAG,UACAC,OAAAA,YAAY,SAAS,UAAU;AAAA,IAClC;AAAA,IACA,KAAK,OAAO,UAAU,QAAQ,aAAa,UAAU,MAAM;AAAA,EAAA,CAC3D;AAED,QAAM,QAAQ,UAAU,YAAY,UAAU,OAAO,iBAAiB;AAEtE,MAAI,MAAM;AACV,MAAI,SAAS,aAAa,OAAO,UAAU,QAAQ,YAAY;AAC9D,UAAM,UAAU;AAAA,EAAA;AAGX,QAAA,eAAeC,0CAAqB,IAAI;AAE9C,SACCC,WAAAA,IAAC,cAAY,EAAC,KAAc,GAAA,UAAW,WAAW,MAAY,eAC5D,cAAc,QAAQ,WAAW,+BAAO,MAAI;AAGhD,CAAC;;"}
1
+ {"version":3,"file":"PrismicNextLink.cjs","names":["PrismicNextLink","resolveDefaultExport","Link"],"sources":["../src/PrismicNextLink.tsx"],"sourcesContent":["import type { ComponentProps} from \"react\";\nimport { forwardRef } from \"react\";\nimport Link from \"next/link\";\nimport type {\n\tAsLinkAttrsConfig,\n\tLinkField,\n\tLinkResolverFunction,\n\tPrismicDocument} from \"@prismicio/client\";\nimport {\n\tasLinkAttrs,\n} from \"@prismicio/client\";\n\nimport { resolveDefaultExport } from \"./lib/resolveDefaultExport\";\n\nexport type PrismicNextLinkProps = Omit<\n\tComponentProps<typeof Link>,\n\t\"field\" | \"document\" | \"href\" | \"rel\"\n> & {\n\tlinkResolver?: LinkResolverFunction;\n\trel?: string | AsLinkAttrsConfig[\"rel\"];\n} & (\n\t\t| {\n\t\t\t\tfield: 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: 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: ComponentProps<typeof Link>[\"href\"];\n\t\t }\n\t);\n\nexport const PrismicNextLink = forwardRef<\n\tHTMLAnchorElement,\n\tPrismicNextLinkProps\n>(function PrismicNextLink(props, ref) {\n\tconst { field, document, linkResolver, children, ...restProps } = props;\n\tconst {\n\t\thref: computedHref,\n\t\trel: computedRel,\n\t\t...attrs\n\t} = 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\tconst ResolvedLink = resolveDefaultExport(Link);\n\n\treturn (\n\t\t<ResolvedLink ref={ref} {...attrs} {...restProps} href={href} rel={rel}>\n\t\t\t{\"children\" in props ? children : field?.text}\n\t\t</ResolvedLink>\n\t);\n});\n"],"mappings":";;;;;;;;;AAsCA,MAAa,wCAGX,SAASA,kBAAgB,OAAO,KAAK;CACtC,MAAM,EAAE,OAAO,UAAU,cAAc,UAAU,GAAG,cAAc;CAClE,MAAM,EACL,MAAM,cACN,KAAK,aACL,GAAG,6CACY,SAAS,UAAU;EAClC;EACA,KAAK,OAAO,UAAU,QAAQ,aAAa,UAAU,MAAM;EAC3D,CAAC;CAEF,MAAM,QAAQ,UAAU,YAAY,UAAU,OAAO,iBAAiB;CAEtE,IAAI,MAAM;AACV,KAAI,SAAS,aAAa,OAAO,UAAU,QAAQ,WAClD,OAAM,UAAU;AAKjB,QACC,2CAHoBC,kDAAqBC,kBAAK;EAG3B;EAAK,GAAI;EAAO,GAAI;EAAiB;EAAW;YACjE,cAAc,QAAQ,WAAW,OAAO;GAC3B;EAEf"}
@@ -0,0 +1,54 @@
1
+ import * as react0 from "react";
2
+ import { ComponentProps } from "react";
3
+ import * as next_link0 from "next/link";
4
+ import Link from "next/link";
5
+ import { AsLinkAttrsConfig, LinkField, LinkResolverFunction, PrismicDocument } from "@prismicio/client";
6
+
7
+ //#region src/PrismicNextLink.d.ts
8
+ type PrismicNextLinkProps = Omit<ComponentProps<typeof Link>, "field" | "document" | "href" | "rel"> & {
9
+ linkResolver?: LinkResolverFunction;
10
+ rel?: string | AsLinkAttrsConfig["rel"];
11
+ } & ({
12
+ field: LinkField | null | undefined;
13
+ document?: never;
14
+ href?: never;
15
+ } | {
16
+ field?: never;
17
+ document: PrismicDocument | null | undefined;
18
+ href?: never;
19
+ } | {
20
+ field?: never;
21
+ document?: never;
22
+ href: ComponentProps<typeof Link>["href"];
23
+ });
24
+ declare const PrismicNextLink: react0.ForwardRefExoticComponent<(Omit<Omit<Omit<react0.AnchorHTMLAttributes<HTMLAnchorElement>, keyof next_link0.LinkProps<any>> & next_link0.LinkProps<any> & {
25
+ children?: React.ReactNode | undefined;
26
+ } & react0.RefAttributes<HTMLAnchorElement>, "rel" | "field" | "href" | "document"> & {
27
+ linkResolver?: LinkResolverFunction;
28
+ rel?: string | AsLinkAttrsConfig["rel"];
29
+ } & {
30
+ field: LinkField | null | undefined;
31
+ document?: never;
32
+ href?: never;
33
+ }, "ref"> | Omit<Omit<Omit<react0.AnchorHTMLAttributes<HTMLAnchorElement>, keyof next_link0.LinkProps<any>> & next_link0.LinkProps<any> & {
34
+ children?: React.ReactNode | undefined;
35
+ } & react0.RefAttributes<HTMLAnchorElement>, "rel" | "field" | "href" | "document"> & {
36
+ linkResolver?: LinkResolverFunction;
37
+ rel?: string | AsLinkAttrsConfig["rel"];
38
+ } & {
39
+ field?: never;
40
+ document: PrismicDocument | null | undefined;
41
+ href?: never;
42
+ }, "ref"> | Omit<Omit<Omit<react0.AnchorHTMLAttributes<HTMLAnchorElement>, keyof next_link0.LinkProps<any>> & next_link0.LinkProps<any> & {
43
+ children?: React.ReactNode | undefined;
44
+ } & react0.RefAttributes<HTMLAnchorElement>, "rel" | "field" | "href" | "document"> & {
45
+ linkResolver?: LinkResolverFunction;
46
+ rel?: string | AsLinkAttrsConfig["rel"];
47
+ } & {
48
+ field?: never;
49
+ document?: never;
50
+ href: ComponentProps<typeof Link>["href"];
51
+ }, "ref">) & react0.RefAttributes<HTMLAnchorElement>>;
52
+ //#endregion
53
+ export { PrismicNextLink, PrismicNextLinkProps };
54
+ //# sourceMappingURL=PrismicNextLink.d.cts.map
@@ -0,0 +1,34 @@
1
+ const require_rolldown_runtime = require('./_virtual/rolldown_runtime.cjs');
2
+ const require_PrismicNextLink = require('./PrismicNextLink.cjs');
3
+ const require_PrismicNextImage = require('./PrismicNextImage.cjs');
4
+ let react_jsx_runtime = require("react/jsx-runtime");
5
+ let _prismicio_react = require("@prismicio/react");
6
+
7
+ //#region src/PrismicNextRichText.tsx
8
+ const defaultComponents = {
9
+ image: ({ node }) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
10
+ className: "block-img",
11
+ children: node.linkTo ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_PrismicNextLink.PrismicNextLink, {
12
+ field: node.linkTo,
13
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_PrismicNextImage.PrismicNextImage, { field: node })
14
+ }) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_PrismicNextImage.PrismicNextImage, { field: node })
15
+ }),
16
+ hyperlink: ({ node, children }) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_PrismicNextLink.PrismicNextLink, {
17
+ field: node.data,
18
+ children
19
+ })
20
+ };
21
+ const PrismicNextRichText = (props) => {
22
+ const { components, ...restProps } = props;
23
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_prismicio_react.PrismicRichText, {
24
+ components: {
25
+ ...defaultComponents,
26
+ ...components
27
+ },
28
+ ...restProps
29
+ });
30
+ };
31
+
32
+ //#endregion
33
+ exports.PrismicNextRichText = PrismicNextRichText;
34
+ //# sourceMappingURL=PrismicNextRichText.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PrismicNextRichText.cjs","names":["PrismicNextLink","PrismicNextImage","PrismicRichText"],"sources":["../src/PrismicNextRichText.tsx"],"sourcesContent":["import type { FC } from \"react\";\nimport { PrismicRichText } from \"@prismicio/react\";\nimport type { PrismicRichTextProps, JSXMapSerializer } from \"@prismicio/react\";\n\nimport { PrismicNextImage } from \"./PrismicNextImage\";\nimport { PrismicNextLink } from \"./PrismicNextLink\";\n\nexport type PrismicNextRichTextProps = Omit<\n\tPrismicRichTextProps,\n\t\"components\"\n> & {\n\tcomponents?: JSXMapSerializer;\n};\n\nconst defaultComponents: JSXMapSerializer = {\n\timage: ({ node }) => (\n\t\t<p className=\"block-img\">\n\t\t\t{node.linkTo ? (\n\t\t\t\t<PrismicNextLink field={node.linkTo}>\n\t\t\t\t\t<PrismicNextImage field={node} />\n\t\t\t\t</PrismicNextLink>\n\t\t\t) : (\n\t\t\t\t<PrismicNextImage field={node} />\n\t\t\t)}\n\t\t</p>\n\t),\n\thyperlink: ({ node, children }) => (\n\t\t<PrismicNextLink field={node.data}>{children}</PrismicNextLink>\n\t),\n};\n\nexport const PrismicNextRichText: FC<PrismicNextRichTextProps> = (props) => {\n\tconst { components, ...restProps } = props;\n\n\treturn (\n\t\t<PrismicRichText\n\t\t\tcomponents={{ ...defaultComponents, ...components }}\n\t\t\t{...restProps}\n\t\t/>\n\t);\n};\n"],"mappings":";;;;;;;AAcA,MAAM,oBAAsC;CAC3C,QAAQ,EAAE,WACT,2CAAC;EAAE,WAAU;YACX,KAAK,SACL,2CAACA;GAAgB,OAAO,KAAK;aAC5B,2CAACC,6CAAiB,OAAO,OAAQ;IAChB,GAElB,2CAACA,6CAAiB,OAAO,OAAQ;GAE/B;CAEL,YAAY,EAAE,MAAM,eACnB,2CAACD;EAAgB,OAAO,KAAK;EAAO;GAA2B;CAEhE;AAED,MAAa,uBAAqD,UAAU;CAC3E,MAAM,EAAE,YAAY,GAAG,cAAc;AAErC,QACC,2CAACE;EACA,YAAY;GAAE,GAAG;GAAmB,GAAG;GAAY;EACnD,GAAI;GACH"}
@@ -0,0 +1,11 @@
1
+ import { FC } from "react";
2
+ import { JSXMapSerializer, PrismicRichTextProps } from "@prismicio/react";
3
+
4
+ //#region src/PrismicNextRichText.d.ts
5
+ type PrismicNextRichTextProps = Omit<PrismicRichTextProps, "components"> & {
6
+ components?: JSXMapSerializer;
7
+ };
8
+ declare const PrismicNextRichText: FC<PrismicNextRichTextProps>;
9
+ //#endregion
10
+ export { PrismicNextRichText, PrismicNextRichTextProps };
11
+ //# sourceMappingURL=PrismicNextRichText.d.cts.map
@@ -1,39 +1,41 @@
1
- "use strict";
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __copyProps = (to, from, except, desc) => {
9
- if (from && typeof from === "object" || typeof from === "function") {
10
- for (let key of __getOwnPropNames(from))
11
- if (!__hasOwnProp.call(to, key) && key !== except)
12
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
13
- }
14
- return to;
15
- };
16
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
17
- // If the importer is in node compatibility mode or this is not an ESM
18
- // file that has been converted to a CommonJS file using a Babel-
19
- // compatible transform (i.e. "__esModule" has not been set), then set
20
- // "default" to the CommonJS "module.exports" for node compatibility.
21
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
22
- mod
23
- ));
24
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
25
- const jsxRuntime = require("react/jsx-runtime");
26
- const Script = require("next/script");
27
- const client = require("@prismicio/client");
28
- const resolveDefaultExport = require("./lib/resolveDefaultExport.cjs");
29
- const PrismicPreviewClient = require("./PrismicPreviewClient.cjs");
1
+ const require_rolldown_runtime = require('./_virtual/rolldown_runtime.cjs');
2
+ const require_resolveDefaultExport = require('./lib/resolveDefaultExport.cjs');
3
+ const require_PrismicPreviewClient = require('./PrismicPreviewClient.cjs');
4
+ let next_script = require("next/script");
5
+ next_script = require_rolldown_runtime.__toESM(next_script);
6
+ let _prismicio_client = require("@prismicio/client");
7
+ let react_jsx_runtime = require("react/jsx-runtime");
8
+
9
+ //#region src/PrismicPreview.tsx
10
+ /**
11
+ * React component that sets up Prismic Previews using the Prismic Toolbar. When
12
+ * the Prismic Toolbar send events to the browser, such as on preview updates
13
+ * and exiting, this component will automatically refresh the page with the
14
+ * changes.
15
+ *
16
+ * This component can be wrapped around your app or added anywhere in your app's
17
+ * tree. It must be rendered on every page.
18
+ */
30
19
  const PrismicPreview = async (props) => {
31
- const { repositoryName, children, ...otherProps } = props;
32
- const { draftMode } = await import("next/headers");
33
- const toolbarSrc = client.getToolbarSrc(repositoryName);
34
- const isDraftMode = (await draftMode()).isEnabled;
35
- const ResolvedScript = resolveDefaultExport.resolveDefaultExport(Script);
36
- return jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [children, jsxRuntime.jsx(PrismicPreviewClient.PrismicPreviewClient, { repositoryName, isDraftMode, ...otherProps }), jsxRuntime.jsx(ResolvedScript, { src: toolbarSrc, strategy: "lazyOnload" })] });
20
+ const { repositoryName, children, ...otherProps } = props;
21
+ const { draftMode } = await import("next/headers");
22
+ const toolbarSrc = (0, _prismicio_client.getToolbarSrc)(repositoryName);
23
+ const isDraftMode = (await draftMode()).isEnabled;
24
+ const ResolvedScript = require_resolveDefaultExport.resolveDefaultExport(next_script.default);
25
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
26
+ children,
27
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_PrismicPreviewClient.PrismicPreviewClient, {
28
+ repositoryName,
29
+ isDraftMode,
30
+ ...otherProps
31
+ }),
32
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ResolvedScript, {
33
+ src: toolbarSrc,
34
+ strategy: "lazyOnload"
35
+ })
36
+ ] });
37
37
  };
38
+
39
+ //#endregion
38
40
  exports.PrismicPreview = PrismicPreview;
39
- //# sourceMappingURL=PrismicPreview.cjs.map
41
+ //# sourceMappingURL=PrismicPreview.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"PrismicPreview.cjs","sources":["../src/PrismicPreview.tsx"],"sourcesContent":["import type { FC, ReactNode } from \"react\";\nimport Script from \"next/script\";\nimport { getToolbarSrc } from \"@prismicio/client\";\n\nimport { resolveDefaultExport } from \"./lib/resolveDefaultExport\";\nimport { PrismicPreviewClient } from \"./PrismicPreviewClient\";\n\n/** Props for `<PrismicPreview>`. */\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\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\texitPreviewURL?: string;\n\n\t/** Children to render adjacent to the Prismic Toolbar. */\n\tchildren?: 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 refresh the page with the\n * changes.\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 const PrismicPreview: FC<PrismicPreviewProps> = async (props) => {\n\tconst { repositoryName, children, ...otherProps } = props;\n\n\t// Need this to avoid the following Next.js build-time error:\n\t// You're importing a component that needs next/headers. That only works\n\t// in a Server Component which is not supported in the pages/ directory.\n\tconst { draftMode } = await import(\"next/headers\");\n\n\tconst toolbarSrc = getToolbarSrc(repositoryName);\n\tconst isDraftMode = (await draftMode()).isEnabled;\n\n\tconst ResolvedScript = resolveDefaultExport(Script);\n\n\treturn (\n\t\t<>\n\t\t\t{children}\n\t\t\t<PrismicPreviewClient\n\t\t\t\trepositoryName={repositoryName}\n\t\t\t\tisDraftMode={isDraftMode}\n\t\t\t\t{...otherProps}\n\t\t\t/>\n\t\t\t<ResolvedScript src={toolbarSrc} strategy=\"lazyOnload\" />\n\t\t</>\n\t);\n};\n"],"names":["getToolbarSrc","resolveDefaultExport","_jsxs","_Fragment","_jsx","PrismicPreviewClient"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwCa,MAAA,iBAA0C,OAAO,UAAS;AACtE,QAAM,EAAE,gBAAgB,UAAU,GAAG,WAAe,IAAA;AAKpD,QAAM,EAAE,UAAA,IAAc,MAAM,OAAO,cAAc;AAE3C,QAAA,aAAaA,qBAAc,cAAc;AACzC,QAAA,eAAe,MAAM,UAAA,GAAa;AAElC,QAAA,iBAAiBC,0CAAqB,MAAM;AAGjD,SAAAC,WAAA,KAAAC,qBAAA,EAAA,UAAA,CACE,UACDC,eAACC,qBAAAA,sBACA,EAAA,gBACA,aAAwB,GACpB,YAAU,GAEfD,eAAC,gBAAc,EAAC,KAAK,YAAY,UAAS,cAAe,CAAA,GAAA;AAG5D;;"}
1
+ {"version":3,"file":"PrismicPreview.cjs","names":["resolveDefaultExport","Script","PrismicPreviewClient"],"sources":["../src/PrismicPreview.tsx"],"sourcesContent":["import type { FC, ReactNode } from \"react\";\nimport Script from \"next/script\";\nimport { getToolbarSrc } from \"@prismicio/client\";\n\nimport { resolveDefaultExport } from \"./lib/resolveDefaultExport\";\nimport { PrismicPreviewClient } from \"./PrismicPreviewClient\";\n\n/** Props for `<PrismicPreview>`. */\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\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\texitPreviewURL?: string;\n\n\t/** Children to render adjacent to the Prismic Toolbar. */\n\tchildren?: 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 refresh the page with the\n * changes.\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 const PrismicPreview: FC<PrismicPreviewProps> = async (props) => {\n\tconst { repositoryName, children, ...otherProps } = props;\n\n\t// Need this to avoid the following Next.js build-time error:\n\t// You're importing a component that needs next/headers. That only works\n\t// in a Server Component which is not supported in the pages/ directory.\n\tconst { draftMode } = await import(\"next/headers\");\n\n\tconst toolbarSrc = getToolbarSrc(repositoryName);\n\tconst isDraftMode = (await draftMode()).isEnabled;\n\n\tconst ResolvedScript = resolveDefaultExport(Script);\n\n\treturn (\n\t\t<>\n\t\t\t{children}\n\t\t\t<PrismicPreviewClient\n\t\t\t\trepositoryName={repositoryName}\n\t\t\t\tisDraftMode={isDraftMode}\n\t\t\t\t{...otherProps}\n\t\t\t/>\n\t\t\t<ResolvedScript src={toolbarSrc} strategy=\"lazyOnload\" />\n\t\t</>\n\t);\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAwCA,MAAa,iBAA0C,OAAO,UAAU;CACvE,MAAM,EAAE,gBAAgB,UAAU,GAAG,eAAe;CAKpD,MAAM,EAAE,cAAc,MAAM,OAAO;CAEnC,MAAM,kDAA2B,eAAe;CAChD,MAAM,eAAe,MAAM,WAAW,EAAE;CAExC,MAAM,iBAAiBA,kDAAqBC,oBAAO;AAEnD,QACC;EACE;EACD,2CAACC;GACgB;GACH;GACb,GAAI;IACH;EACF,2CAAC;GAAe,KAAK;GAAY,UAAS;IAAe;KACvD"}
@@ -0,0 +1,36 @@
1
+ import { FC, ReactNode } from "react";
2
+
3
+ //#region src/PrismicPreview.d.ts
4
+ /** Props for `<PrismicPreview>`. */
5
+ type PrismicPreviewProps = {
6
+ /**
7
+ * The name of your Prismic repository. A Prismic Toolbar will be registered
8
+ * using this repository.
9
+ */
10
+ repositoryName: string;
11
+ /**
12
+ * The URL of your app's Prismic preview endpoint (default: `/api/preview`).
13
+ * This URL will be fetched on preview update events.
14
+ */
15
+ updatePreviewURL?: string;
16
+ /**
17
+ * The URL of your app's exit preview endpoint (default: `/api/exit-preview`).
18
+ * This URL will be fetched on preview exit events.
19
+ */
20
+ exitPreviewURL?: string;
21
+ /** Children to render adjacent to the Prismic Toolbar. */
22
+ children?: ReactNode;
23
+ };
24
+ /**
25
+ * React component that sets up Prismic Previews using the Prismic Toolbar. When
26
+ * the Prismic Toolbar send events to the browser, such as on preview updates
27
+ * and exiting, this component will automatically refresh the page with the
28
+ * changes.
29
+ *
30
+ * This component can be wrapped around your app or added anywhere in your app's
31
+ * tree. It must be rendered on every page.
32
+ */
33
+ declare const PrismicPreview: FC<PrismicPreviewProps>;
34
+ //#endregion
35
+ export { PrismicPreview, PrismicPreviewProps };
36
+ //# sourceMappingURL=PrismicPreview.d.cts.map