@prismicio/next 2.3.2 → 2.3.3-canary.bab3397
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/PrismicNextImage.cjs +6 -5
- package/dist/PrismicNextImage.cjs.map +1 -1
- package/dist/PrismicNextImage.d.cts +7 -7
- package/dist/PrismicNextImage.d.cts.map +1 -1
- package/dist/PrismicNextImage.d.ts +7 -7
- package/dist/PrismicNextImage.d.ts.map +1 -1
- package/dist/PrismicNextImage.js +5 -4
- package/dist/PrismicNextImage.js.map +1 -1
- package/dist/PrismicNextLink.cjs +3 -2
- package/dist/PrismicNextLink.cjs.map +1 -1
- package/dist/PrismicNextLink.d.cts +9 -13
- package/dist/PrismicNextLink.d.cts.map +1 -1
- package/dist/PrismicNextLink.d.ts +8 -12
- package/dist/PrismicNextLink.d.ts.map +1 -1
- package/dist/PrismicNextLink.js +2 -1
- package/dist/PrismicNextLink.js.map +1 -1
- package/dist/PrismicPreview.cjs +2 -2
- package/dist/PrismicPreview.cjs.map +1 -1
- package/dist/PrismicPreview.d.cts +4 -5
- package/dist/PrismicPreview.d.cts.map +1 -1
- package/dist/PrismicPreview.d.ts +4 -5
- package/dist/PrismicPreview.d.ts.map +1 -1
- package/dist/PrismicPreview.js +1 -1
- package/dist/PrismicPreview.js.map +1 -1
- package/dist/PrismicPreviewClient.cjs +18 -13
- package/dist/PrismicPreviewClient.cjs.map +1 -1
- package/dist/PrismicPreviewClient.js +18 -12
- package/dist/PrismicPreviewClient.js.map +1 -1
- package/dist/SliceSimulator.cjs +3 -2
- package/dist/SliceSimulator.cjs.map +1 -1
- package/dist/SliceSimulator.d.cts +3 -4
- package/dist/SliceSimulator.d.cts.map +1 -1
- package/dist/SliceSimulator.d.ts +3 -4
- package/dist/SliceSimulator.d.ts.map +1 -1
- package/dist/SliceSimulator.js +2 -1
- package/dist/SliceSimulator.js.map +1 -1
- package/dist/SliceSimulatorWrapper.cjs +0 -1
- package/dist/SliceSimulatorWrapper.cjs.map +1 -1
- package/dist/SliceSimulatorWrapper.js.map +1 -1
- package/dist/_virtual/_rolldown/runtime.cjs +1 -1
- package/dist/cacheTagPrismicPages.cjs +1 -1
- package/dist/cacheTagPrismicPages.cjs.map +1 -1
- package/dist/cacheTagPrismicPages.d.cts +1 -3
- package/dist/cacheTagPrismicPages.d.cts.map +1 -1
- package/dist/cacheTagPrismicPages.d.ts +1 -3
- package/dist/cacheTagPrismicPages.d.ts.map +1 -1
- package/dist/cacheTagPrismicPages.js.map +1 -1
- package/dist/createLocaleRedirect.cjs.map +1 -1
- package/dist/createLocaleRedirect.d.cts +2 -3
- package/dist/createLocaleRedirect.d.cts.map +1 -1
- package/dist/createLocaleRedirect.d.ts +2 -3
- package/dist/createLocaleRedirect.d.ts.map +1 -1
- package/dist/createLocaleRedirect.js.map +1 -1
- package/dist/enableAutoPreviews.cjs.map +1 -1
- package/dist/enableAutoPreviews.d.cts +4 -5
- package/dist/enableAutoPreviews.d.cts.map +1 -1
- package/dist/enableAutoPreviews.d.ts +4 -5
- package/dist/enableAutoPreviews.d.ts.map +1 -1
- package/dist/enableAutoPreviews.js.map +1 -1
- package/dist/exitPreview.cjs +12 -4
- package/dist/exitPreview.cjs.map +1 -1
- package/dist/exitPreview.d.cts +1 -2
- package/dist/exitPreview.d.cts.map +1 -1
- package/dist/exitPreview.d.ts +1 -2
- package/dist/exitPreview.d.ts.map +1 -1
- package/dist/exitPreview.js +12 -3
- package/dist/exitPreview.js.map +1 -1
- package/dist/getPreviewRef.cjs +1 -2
- package/dist/getPreviewRef.cjs.map +1 -1
- package/dist/getPreviewRef.d.cts +1 -2
- package/dist/getPreviewRef.d.cts.map +1 -1
- package/dist/getPreviewRef.d.ts +1 -2
- package/dist/getPreviewRef.d.ts.map +1 -1
- package/dist/getPreviewRef.js +1 -1
- package/dist/getPreviewRef.js.map +1 -1
- package/dist/getPrismicCacheTags.cjs +4 -2
- package/dist/getPrismicCacheTags.cjs.map +1 -1
- package/dist/getPrismicCacheTags.d.cts +1 -3
- package/dist/getPrismicCacheTags.d.cts.map +1 -1
- package/dist/getPrismicCacheTags.d.ts +1 -3
- package/dist/getPrismicCacheTags.d.ts.map +1 -1
- package/dist/getPrismicCacheTags.js +4 -2
- package/dist/getPrismicCacheTags.js.map +1 -1
- package/dist/getSlices.cjs +1 -1
- package/dist/getSlices.cjs.map +1 -1
- package/dist/getSlices.d.cts +1 -3
- package/dist/getSlices.d.cts.map +1 -1
- package/dist/getSlices.d.ts +1 -3
- package/dist/getSlices.d.ts.map +1 -1
- package/dist/getSlices.js.map +1 -1
- package/dist/imgixLoader.cjs +0 -1
- package/dist/imgixLoader.cjs.map +1 -1
- package/dist/imgixLoader.d.cts +1 -3
- package/dist/imgixLoader.d.cts.map +1 -1
- package/dist/imgixLoader.d.ts +1 -3
- package/dist/imgixLoader.d.ts.map +1 -1
- package/dist/imgixLoader.js.map +1 -1
- package/dist/lib/devMsg.cjs.map +1 -1
- package/dist/lib/devMsg.js.map +1 -1
- package/dist/lib/resolveDefaultExport.cjs.map +1 -1
- package/dist/lib/resolveDefaultExport.js.map +1 -1
- package/dist/package.cjs +1 -1
- package/dist/package.js +1 -1
- package/dist/pages/PrismicPreview.cjs +1 -1
- package/dist/pages/PrismicPreview.cjs.map +1 -1
- package/dist/pages/PrismicPreview.d.cts +4 -5
- package/dist/pages/PrismicPreview.d.cts.map +1 -1
- package/dist/pages/PrismicPreview.d.ts +4 -5
- package/dist/pages/PrismicPreview.d.ts.map +1 -1
- package/dist/pages/PrismicPreview.js.map +1 -1
- package/dist/pages/SliceSimulator.cjs +0 -1
- package/dist/pages/SliceSimulator.cjs.map +1 -1
- package/dist/pages/SliceSimulator.d.cts +3 -4
- package/dist/pages/SliceSimulator.d.cts.map +1 -1
- package/dist/pages/SliceSimulator.d.ts +3 -4
- package/dist/pages/SliceSimulator.d.ts.map +1 -1
- package/dist/pages/SliceSimulator.js.map +1 -1
- package/dist/pages/enableAutoPreviews.cjs.map +1 -1
- package/dist/pages/enableAutoPreviews.d.cts +4 -5
- package/dist/pages/enableAutoPreviews.d.cts.map +1 -1
- package/dist/pages/enableAutoPreviews.d.ts +4 -5
- package/dist/pages/enableAutoPreviews.d.ts.map +1 -1
- package/dist/pages/enableAutoPreviews.js.map +1 -1
- package/dist/pages/exitPreview.cjs.map +1 -1
- package/dist/pages/exitPreview.d.cts +2 -4
- package/dist/pages/exitPreview.d.cts.map +1 -1
- package/dist/pages/exitPreview.d.ts +2 -4
- package/dist/pages/exitPreview.d.ts.map +1 -1
- package/dist/pages/exitPreview.js.map +1 -1
- package/dist/pages/redirectToPreviewURL.cjs.map +1 -1
- package/dist/pages/redirectToPreviewURL.d.cts +4 -5
- package/dist/pages/redirectToPreviewURL.d.cts.map +1 -1
- package/dist/pages/redirectToPreviewURL.d.ts +4 -5
- package/dist/pages/redirectToPreviewURL.d.ts.map +1 -1
- package/dist/pages/redirectToPreviewURL.js.map +1 -1
- package/dist/pages/setPreviewData.cjs +0 -1
- package/dist/pages/setPreviewData.cjs.map +1 -1
- package/dist/pages/setPreviewData.d.cts +2 -7
- package/dist/pages/setPreviewData.d.cts.map +1 -1
- package/dist/pages/setPreviewData.d.ts +2 -7
- package/dist/pages/setPreviewData.d.ts.map +1 -1
- package/dist/pages/setPreviewData.js.map +1 -1
- package/dist/pages/types.d.cts +3 -5
- package/dist/pages/types.d.cts.map +1 -1
- package/dist/pages/types.d.ts +3 -5
- package/dist/pages/types.d.ts.map +1 -1
- package/dist/redirectToPreviewURL.cjs +11 -2
- package/dist/redirectToPreviewURL.cjs.map +1 -1
- package/dist/redirectToPreviewURL.d.cts +4 -5
- package/dist/redirectToPreviewURL.d.cts.map +1 -1
- package/dist/redirectToPreviewURL.d.ts +4 -5
- package/dist/redirectToPreviewURL.d.ts.map +1 -1
- package/dist/redirectToPreviewURL.js +11 -1
- package/dist/redirectToPreviewURL.js.map +1 -1
- package/dist/revalidatePrismicPages.cjs +4 -2
- package/dist/revalidatePrismicPages.cjs.map +1 -1
- package/dist/revalidatePrismicPages.d.cts +1 -2
- package/dist/revalidatePrismicPages.d.cts.map +1 -1
- package/dist/revalidatePrismicPages.d.ts +1 -2
- package/dist/revalidatePrismicPages.d.ts.map +1 -1
- package/dist/revalidatePrismicPages.js +4 -1
- package/dist/revalidatePrismicPages.js.map +1 -1
- package/dist/types.d.cts +2 -4
- package/dist/types.d.cts.map +1 -1
- package/dist/types.d.ts +2 -4
- package/dist/types.d.ts.map +1 -1
- package/package.json +15 -15
- package/src/PrismicNextImage.tsx +5 -5
- package/src/PrismicNextLink.tsx +2 -2
- package/src/PrismicPreview.tsx +2 -2
- package/src/PrismicPreviewClient.tsx +26 -11
- package/src/exitPreview.ts +4 -6
- package/src/getPreviewRef.ts +3 -2
- package/src/redirectToPreviewURL.ts +10 -2
|
@@ -8,8 +8,9 @@ let react = require("react");
|
|
|
8
8
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
9
9
|
let imgix_url_builder = require("imgix-url-builder");
|
|
10
10
|
let next_image_js = require("next/image.js");
|
|
11
|
-
next_image_js = require_runtime.__toESM(next_image_js);
|
|
11
|
+
next_image_js = require_runtime.__toESM(next_image_js, 1);
|
|
12
12
|
//#region src/PrismicNextImage.tsx
|
|
13
|
+
const ResolvedImage = require_resolveDefaultExport.resolveDefaultExport(next_image_js.default);
|
|
13
14
|
const castInt = (input) => {
|
|
14
15
|
if (typeof input === "number" || typeof input === "undefined") return input;
|
|
15
16
|
else {
|
|
@@ -38,9 +39,9 @@ const PrismicNextImage = (0, react.forwardRef)(function PrismicNextImage({ field
|
|
|
38
39
|
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")}`);
|
|
39
40
|
}
|
|
40
41
|
if (!_prismicio_client.isFilled.imageThumbnail(field)) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_jsx_runtime.Fragment, { children: fallback });
|
|
41
|
-
const resolvedImgixParams = imgixParams;
|
|
42
|
-
for (const x in
|
|
43
|
-
const src = (0, imgix_url_builder.buildURL)(field.url,
|
|
42
|
+
const resolvedImgixParams = { ...imgixParams };
|
|
43
|
+
for (const x in resolvedImgixParams) if (resolvedImgixParams[x] === null) resolvedImgixParams[x] = void 0;
|
|
44
|
+
const src = (0, imgix_url_builder.buildURL)(field.url, resolvedImgixParams);
|
|
44
45
|
const ar = field.dimensions.width / field.dimensions.height;
|
|
45
46
|
const castedWidth = castInt(width);
|
|
46
47
|
const castedHeight = castInt(height);
|
|
@@ -50,7 +51,7 @@ const PrismicNextImage = (0, react.forwardRef)(function PrismicNextImage({ field
|
|
|
50
51
|
else if (castedWidth == null && castedHeight != null) resolvedWidth = castedHeight * ar;
|
|
51
52
|
const resolvedAlt = alt ?? (field.alt || fallbackAlt);
|
|
52
53
|
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);
|
|
53
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(
|
|
54
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ResolvedImage, {
|
|
54
55
|
ref,
|
|
55
56
|
src,
|
|
56
57
|
width: fill ? void 0 : resolvedWidth,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PrismicNextImage.cjs","names":["imgixLoader","devMsg","isFilled","
|
|
1
|
+
{"version":3,"file":"PrismicNextImage.cjs","names":["resolveDefaultExport","Image","forwardRef","imgixLoader","devMsg","isFilled","buildURL"],"sources":["../src/PrismicNextImage.tsx"],"sourcesContent":["\"use client\"\n\nimport type { ImageFieldImage } from \"@prismicio/client\"\nimport { isFilled } from \"@prismicio/client\"\nimport type { ImgixURLParams } from \"imgix-url-builder\"\nimport { buildURL } from \"imgix-url-builder\"\nimport type { ImageProps } from \"next/image\"\nimport Image from \"next/image\"\nimport type { ForwardRefExoticComponent, PropsWithoutRef, RefAttributes } from \"react\"\nimport { forwardRef } from \"react\"\n\nimport { imgixLoader } from \"./imgixLoader\"\nimport { devMsg } from \"./lib/devMsg\"\nimport { resolveDefaultExport } from \"./lib/resolveDefaultExport\"\n\nconst ResolvedImage = resolveDefaultExport(Image)\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\" | \"loader\"> & {\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: 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 alternative text by\n\t * providing `fallbackAlt=\"\"`.\n\t *\n\t * See: https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/alt#decorative_images\n\t */\n\tfallbackAlt?: \"\"\n\n\t/** Rendered when the field is empty. If a fallback is not given, `null` will be rendered. */\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 its thumbnails using\n * `next/image`. It will automatically set the `alt` attribute using the Image field's `alt`\n * property.\n *\n * It uses an Imgix URL-based loader by default. A custom loader can be provided with the `loader`\n * prop. If you would like to use the Next.js Image Optimization API instead, set\n * `loader={undefined}`.\n *\n * @param props - Props for the component.\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 */\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>(function PrismicNextImage(\n\t{\n\t\tfield,\n\t\timgixParams = {},\n\t\talt,\n\t\tfallbackAlt,\n\t\tfill,\n\t\twidth,\n\t\theight,\n\t\tfallback = null,\n\t\tloader = imgixLoader,\n\t\t...restProps\n\t},\n\tref,\n) {\n\tif (process.env.NODE_ENV === \"development\") {\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 (!isFilled.imageThumbnail(field)) {\n\t\treturn <>{fallback}</>\n\t}\n\n\tconst resolvedImgixParams = { ...imgixParams }\n\tfor (const x in resolvedImgixParams) {\n\t\tif (resolvedImgixParams[x as keyof typeof resolvedImgixParams] === null) {\n\t\t\tresolvedImgixParams[x as keyof typeof resolvedImgixParams] = undefined\n\t\t}\n\t}\n\n\tconst src = buildURL(field.url, resolvedImgixParams as ImgixURLParams)\n\n\tconst ar = field.dimensions.width / field.dimensions.height\n\n\tconst castedWidth = castInt(width)\n\tconst castedHeight = castInt(height)\n\n\tlet resolvedWidth = castedWidth ?? field.dimensions.width\n\tlet resolvedHeight = castedHeight ?? field.dimensions.height\n\n\tif (castedWidth != null && castedHeight == null) {\n\t\tresolvedHeight = castedWidth / ar\n\t} else if (castedWidth == null && castedHeight != null) {\n\t\tresolvedWidth = castedHeight * ar\n\t}\n\n\t// A non-null assertion is required since we can't statically\n\t// know if an alt attribute is available.\n\tconst resolvedAlt = (alt ?? (field.alt || fallbackAlt))!\n\n\tif (process.env.NODE_ENV === \"development\" && typeof resolvedAlt !== \"string\") {\n\t\tconsole.error(\n\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\tsrc,\n\t\t)\n\t}\n\n\treturn (\n\t\t<ResolvedImage\n\t\t\tref={ref}\n\t\t\tsrc={src}\n\t\t\twidth={fill ? undefined : resolvedWidth}\n\t\t\theight={fill ? undefined : resolvedHeight}\n\t\t\talt={resolvedAlt}\n\t\t\tfill={fill}\n\t\t\tloader={loader === null ? undefined : loader}\n\t\t\t{...restProps}\n\t\t/>\n\t)\n})\n"],"mappings":";;;;;;;;;;;;AAeA,MAAM,gBAAgBA,6BAAAA,qBAAqBC,cAAAA,OAAK;AAEhD,MAAM,WAAW,UAA2D;CAC3E,IAAI,OAAO,UAAU,YAAY,OAAO,UAAU,aACjD,OAAO;MACD;EACN,MAAM,SAAS,OAAO,SAAS,KAAK;EAEpC,IAAI,OAAO,MAAM,MAAM,GACtB;OAEA,OAAO;CAET;AACD;;;;;;;;;;;;;;;AAiDA,MAAa,oBAAA,GAETC,MAAAA,WAAAA,CAAoD,SAAS,iBAChE,EACC,OACA,cAAc,CAAC,GACf,KACA,aACA,MACA,OACA,QACA,WAAW,MACX,SAASC,oBAAAA,aACT,GAAG,aAEJ,KACC;CACD,IAAI,QAAQ,IAAI,aAAa,eAAe;EAC3C,IAAI,OAAO,QAAQ,YAAY,QAAQ,IACtC,QAAQ,KACP,yQAAyQC,eAAAA,OACxQ,6BACD,GACD;EAGD,IAAI,OAAO,gBAAgB,YAAY,gBAAgB,IACtD,QAAQ,KACP,ySAAySA,eAAAA,OACxS,6BACD,GACD;CAEF;CAEA,IAAI,CAACC,kBAAAA,SAAS,eAAe,KAAK,GACjC,OAAO,iBAAA,GAAA,kBAAA,IAAA,CAAA,kBAAA,UAAA,EAAA,UAAG,SAAW,CAAA;CAGtB,MAAM,sBAAsB,EAAE,GAAG,YAAY;CAC7C,KAAK,MAAM,KAAK,qBACf,IAAI,oBAAoB,OAA2C,MAClE,oBAAoB,KAAyC,KAAA;CAI/D,MAAM,OAAA,GAAMC,kBAAAA,SAAAA,CAAS,MAAM,KAAK,mBAAqC;CAErE,MAAM,KAAK,MAAM,WAAW,QAAQ,MAAM,WAAW;CAErD,MAAM,cAAc,QAAQ,KAAK;CACjC,MAAM,eAAe,QAAQ,MAAM;CAEnC,IAAI,gBAAgB,eAAe,MAAM,WAAW;CACpD,IAAI,iBAAiB,gBAAgB,MAAM,WAAW;CAEtD,IAAI,eAAe,QAAQ,gBAAgB,MAC1C,iBAAiB,cAAc;MACzB,IAAI,eAAe,QAAQ,gBAAgB,MACjD,gBAAgB,eAAe;CAKhC,MAAM,cAAe,QAAQ,MAAM,OAAO;CAE1C,IAAI,QAAQ,IAAI,aAAa,iBAAiB,OAAO,gBAAgB,UACpE,QAAQ,MACP,mNACA,GACD;CAGD,OACC,iBAAA,GAAA,kBAAA,IAAA,CAAC,eAAD;EACM;EACA;EACL,OAAO,OAAO,KAAA,IAAY;EAC1B,QAAQ,OAAO,KAAA,IAAY;EAC3B,KAAK;EACC;EACN,QAAQ,WAAW,OAAO,KAAA,IAAY;EACtC,GAAI;CACJ,CAAA;AAEH,CAAC"}
|
|
@@ -2,16 +2,16 @@ import { ForwardRefExoticComponent, PropsWithoutRef, RefAttributes } from "react
|
|
|
2
2
|
import { ImageFieldImage } from "@prismicio/client";
|
|
3
3
|
import { ImgixURLParams } from "imgix-url-builder";
|
|
4
4
|
import { ImageProps } from "next/image.js";
|
|
5
|
-
|
|
6
5
|
//#region src/PrismicNextImage.d.ts
|
|
7
|
-
type PrismicNextImageProps = Omit<ImageProps, "src" | "alt" | "loader"> & {
|
|
8
|
-
/** The Prismic Image field or thumbnail to render. */
|
|
6
|
+
export type PrismicNextImageProps = Omit<ImageProps, "src" | "alt" | "loader"> & {
|
|
7
|
+
/** The Prismic Image field or thumbnail to render. */
|
|
8
|
+
field: ImageFieldImage | null | undefined;
|
|
9
9
|
/**
|
|
10
10
|
* An object of Imgix URL API parameters to transform the image.
|
|
11
11
|
*
|
|
12
12
|
* @see https://docs.imgix.com/apis/rendering
|
|
13
13
|
*/
|
|
14
|
-
imgixParams?: { [P in keyof ImgixURLParams]: ImgixURLParams[P] | null };
|
|
14
|
+
imgixParams?: { [P in keyof ImgixURLParams]: ImgixURLParams[P] | null; };
|
|
15
15
|
/**
|
|
16
16
|
* Declare an image as decorative by providing `alt=""`.
|
|
17
17
|
*
|
|
@@ -24,7 +24,8 @@ type PrismicNextImageProps = Omit<ImageProps, "src" | "alt" | "loader"> & {
|
|
|
24
24
|
*
|
|
25
25
|
* See: https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/alt#decorative_images
|
|
26
26
|
*/
|
|
27
|
-
fallbackAlt?: "";
|
|
27
|
+
fallbackAlt?: "";
|
|
28
|
+
/** Rendered when the field is empty. If a fallback is not given, `null` will be rendered. */
|
|
28
29
|
fallback?: React.ReactNode;
|
|
29
30
|
loader?: ImageProps["loader"] | null;
|
|
30
31
|
};
|
|
@@ -42,7 +43,6 @@ type PrismicNextImageProps = Omit<ImageProps, "src" | "alt" | "loader"> & {
|
|
|
42
43
|
* field.
|
|
43
44
|
* @see To learn more about `next/image`, see: https://nextjs.org/docs/api-reference/next/image
|
|
44
45
|
*/
|
|
45
|
-
declare const PrismicNextImage: ForwardRefExoticComponent<PropsWithoutRef<PrismicNextImageProps> & RefAttributes<HTMLImageElement>>;
|
|
46
|
+
export declare const PrismicNextImage: ForwardRefExoticComponent<PropsWithoutRef<PrismicNextImageProps> & RefAttributes<HTMLImageElement>>;
|
|
46
47
|
//#endregion
|
|
47
|
-
export { PrismicNextImage, PrismicNextImageProps };
|
|
48
48
|
//# sourceMappingURL=PrismicNextImage.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PrismicNextImage.d.cts","names":[],"sources":["../src/PrismicNextImage.tsx"],"mappings":"
|
|
1
|
+
{"version":3,"file":"PrismicNextImage.d.cts","names":[],"sources":["../src/PrismicNextImage.tsx"],"mappings":";;;;;YA+BY,wBAAwB,KAAK;;EAExC,OAAO;;;;;;EAOP,iBAAiB,WAAW,iBAAiB,eAAe;;;;;;EAO5D;;;;;;;EAQA;;EAGA,WAAW,MAAM;EAEjB,SAAS;;;;;;;;;;;;;;;;qBAkBG,kBAAkB,0BAC9B,gBAAgB,yBAAyB,cAAc"}
|
|
@@ -2,16 +2,16 @@ import { ImageFieldImage } from "@prismicio/client";
|
|
|
2
2
|
import { ForwardRefExoticComponent, PropsWithoutRef, RefAttributes } from "react";
|
|
3
3
|
import { ImgixURLParams } from "imgix-url-builder";
|
|
4
4
|
import { ImageProps } from "next/image.js";
|
|
5
|
-
|
|
6
5
|
//#region src/PrismicNextImage.d.ts
|
|
7
|
-
type PrismicNextImageProps = Omit<ImageProps, "src" | "alt" | "loader"> & {
|
|
8
|
-
/** The Prismic Image field or thumbnail to render. */
|
|
6
|
+
export type PrismicNextImageProps = Omit<ImageProps, "src" | "alt" | "loader"> & {
|
|
7
|
+
/** The Prismic Image field or thumbnail to render. */
|
|
8
|
+
field: ImageFieldImage | null | undefined;
|
|
9
9
|
/**
|
|
10
10
|
* An object of Imgix URL API parameters to transform the image.
|
|
11
11
|
*
|
|
12
12
|
* @see https://docs.imgix.com/apis/rendering
|
|
13
13
|
*/
|
|
14
|
-
imgixParams?: { [P in keyof ImgixURLParams]: ImgixURLParams[P] | null };
|
|
14
|
+
imgixParams?: { [P in keyof ImgixURLParams]: ImgixURLParams[P] | null; };
|
|
15
15
|
/**
|
|
16
16
|
* Declare an image as decorative by providing `alt=""`.
|
|
17
17
|
*
|
|
@@ -24,7 +24,8 @@ type PrismicNextImageProps = Omit<ImageProps, "src" | "alt" | "loader"> & {
|
|
|
24
24
|
*
|
|
25
25
|
* See: https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/alt#decorative_images
|
|
26
26
|
*/
|
|
27
|
-
fallbackAlt?: "";
|
|
27
|
+
fallbackAlt?: "";
|
|
28
|
+
/** Rendered when the field is empty. If a fallback is not given, `null` will be rendered. */
|
|
28
29
|
fallback?: React.ReactNode;
|
|
29
30
|
loader?: ImageProps["loader"] | null;
|
|
30
31
|
};
|
|
@@ -42,7 +43,6 @@ type PrismicNextImageProps = Omit<ImageProps, "src" | "alt" | "loader"> & {
|
|
|
42
43
|
* field.
|
|
43
44
|
* @see To learn more about `next/image`, see: https://nextjs.org/docs/api-reference/next/image
|
|
44
45
|
*/
|
|
45
|
-
declare const PrismicNextImage: ForwardRefExoticComponent<PropsWithoutRef<PrismicNextImageProps> & RefAttributes<HTMLImageElement>>;
|
|
46
|
+
export declare const PrismicNextImage: ForwardRefExoticComponent<PropsWithoutRef<PrismicNextImageProps> & RefAttributes<HTMLImageElement>>;
|
|
46
47
|
//#endregion
|
|
47
|
-
export { PrismicNextImage, PrismicNextImageProps };
|
|
48
48
|
//# sourceMappingURL=PrismicNextImage.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PrismicNextImage.d.ts","names":[],"sources":["../src/PrismicNextImage.tsx"],"mappings":"
|
|
1
|
+
{"version":3,"file":"PrismicNextImage.d.ts","names":[],"sources":["../src/PrismicNextImage.tsx"],"mappings":";;;;;YA+BY,wBAAwB,KAAK;;EAExC,OAAO;;;;;;EAOP,iBAAiB,WAAW,iBAAiB,eAAe;;;;;;EAO5D;;;;;;;EAQA;;EAGA,WAAW,MAAM;EAEjB,SAAS;;;;;;;;;;;;;;;;qBAkBG,kBAAkB,0BAC9B,gBAAgB,yBAAyB,cAAc"}
|
package/dist/PrismicNextImage.js
CHANGED
|
@@ -8,6 +8,7 @@ import { Fragment, jsx } from "react/jsx-runtime";
|
|
|
8
8
|
import { buildURL } from "imgix-url-builder";
|
|
9
9
|
import Image from "next/image.js";
|
|
10
10
|
//#region src/PrismicNextImage.tsx
|
|
11
|
+
const ResolvedImage = resolveDefaultExport(Image);
|
|
11
12
|
const castInt = (input) => {
|
|
12
13
|
if (typeof input === "number" || typeof input === "undefined") return input;
|
|
13
14
|
else {
|
|
@@ -36,9 +37,9 @@ const PrismicNextImage = forwardRef(function PrismicNextImage({ field, imgixPara
|
|
|
36
37
|
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 ${devMsg("alt-must-be-an-empty-string")}`);
|
|
37
38
|
}
|
|
38
39
|
if (!isFilled.imageThumbnail(field)) return /* @__PURE__ */ jsx(Fragment, { children: fallback });
|
|
39
|
-
const resolvedImgixParams = imgixParams;
|
|
40
|
-
for (const x in
|
|
41
|
-
const src = buildURL(field.url,
|
|
40
|
+
const resolvedImgixParams = { ...imgixParams };
|
|
41
|
+
for (const x in resolvedImgixParams) if (resolvedImgixParams[x] === null) resolvedImgixParams[x] = void 0;
|
|
42
|
+
const src = buildURL(field.url, resolvedImgixParams);
|
|
42
43
|
const ar = field.dimensions.width / field.dimensions.height;
|
|
43
44
|
const castedWidth = castInt(width);
|
|
44
45
|
const castedHeight = castInt(height);
|
|
@@ -48,7 +49,7 @@ const PrismicNextImage = forwardRef(function PrismicNextImage({ field, imgixPara
|
|
|
48
49
|
else if (castedWidth == null && castedHeight != null) resolvedWidth = castedHeight * ar;
|
|
49
50
|
const resolvedAlt = alt ?? (field.alt || fallbackAlt);
|
|
50
51
|
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);
|
|
51
|
-
return /* @__PURE__ */ jsx(
|
|
52
|
+
return /* @__PURE__ */ jsx(ResolvedImage, {
|
|
52
53
|
ref,
|
|
53
54
|
src,
|
|
54
55
|
width: fill ? void 0 : resolvedWidth,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PrismicNextImage.js","names":[],"sources":["../src/PrismicNextImage.tsx"],"sourcesContent":["\"use client\"\n\nimport type { ImageFieldImage } from \"@prismicio/client\"\nimport { isFilled } from \"@prismicio/client\"\nimport type { ImgixURLParams } from \"imgix-url-builder\"\nimport { buildURL } from \"imgix-url-builder\"\nimport type { ImageProps } from \"next/image\"\nimport Image from \"next/image\"\nimport type { ForwardRefExoticComponent, PropsWithoutRef, RefAttributes } from \"react\"\nimport { forwardRef } from \"react\"\n\nimport { imgixLoader } from \"./imgixLoader\"\nimport { devMsg } from \"./lib/devMsg\"\nimport { resolveDefaultExport } from \"./lib/resolveDefaultExport\"\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\" | \"loader\"> & {\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: 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 alternative text by\n\t * providing `fallbackAlt=\"\"`.\n\t *\n\t * See: https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/alt#decorative_images\n\t */\n\tfallbackAlt?: \"\"\n\n\t/** Rendered when the field is empty. If a fallback is not given, `null` will be rendered. */\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 its thumbnails using\n * `next/image`. It will automatically set the `alt` attribute using the Image field's `alt`\n * property.\n *\n * It uses an Imgix URL-based loader by default. A custom loader can be provided with the `loader`\n * prop. If you would like to use the Next.js Image Optimization API instead, set\n * `loader={undefined}`.\n *\n * @param props - Props for the component.\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 */\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>(function PrismicNextImage(\n\t{\n\t\tfield,\n\t\timgixParams = {},\n\t\talt,\n\t\tfallbackAlt,\n\t\tfill,\n\t\twidth,\n\t\theight,\n\t\tfallback = null,\n\t\tloader = imgixLoader,\n\t\t...restProps\n\t},\n\tref,\n) {\n\tif (process.env.NODE_ENV === \"development\") {\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 (!isFilled.imageThumbnail(field)) {\n\t\treturn <>{fallback}</>\n\t}\n\n\tconst resolvedImgixParams = imgixParams\n\tfor (const x in
|
|
1
|
+
{"version":3,"file":"PrismicNextImage.js","names":[],"sources":["../src/PrismicNextImage.tsx"],"sourcesContent":["\"use client\"\n\nimport type { ImageFieldImage } from \"@prismicio/client\"\nimport { isFilled } from \"@prismicio/client\"\nimport type { ImgixURLParams } from \"imgix-url-builder\"\nimport { buildURL } from \"imgix-url-builder\"\nimport type { ImageProps } from \"next/image\"\nimport Image from \"next/image\"\nimport type { ForwardRefExoticComponent, PropsWithoutRef, RefAttributes } from \"react\"\nimport { forwardRef } from \"react\"\n\nimport { imgixLoader } from \"./imgixLoader\"\nimport { devMsg } from \"./lib/devMsg\"\nimport { resolveDefaultExport } from \"./lib/resolveDefaultExport\"\n\nconst ResolvedImage = resolveDefaultExport(Image)\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\" | \"loader\"> & {\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: 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 alternative text by\n\t * providing `fallbackAlt=\"\"`.\n\t *\n\t * See: https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/alt#decorative_images\n\t */\n\tfallbackAlt?: \"\"\n\n\t/** Rendered when the field is empty. If a fallback is not given, `null` will be rendered. */\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 its thumbnails using\n * `next/image`. It will automatically set the `alt` attribute using the Image field's `alt`\n * property.\n *\n * It uses an Imgix URL-based loader by default. A custom loader can be provided with the `loader`\n * prop. If you would like to use the Next.js Image Optimization API instead, set\n * `loader={undefined}`.\n *\n * @param props - Props for the component.\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 */\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>(function PrismicNextImage(\n\t{\n\t\tfield,\n\t\timgixParams = {},\n\t\talt,\n\t\tfallbackAlt,\n\t\tfill,\n\t\twidth,\n\t\theight,\n\t\tfallback = null,\n\t\tloader = imgixLoader,\n\t\t...restProps\n\t},\n\tref,\n) {\n\tif (process.env.NODE_ENV === \"development\") {\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 (!isFilled.imageThumbnail(field)) {\n\t\treturn <>{fallback}</>\n\t}\n\n\tconst resolvedImgixParams = { ...imgixParams }\n\tfor (const x in resolvedImgixParams) {\n\t\tif (resolvedImgixParams[x as keyof typeof resolvedImgixParams] === null) {\n\t\t\tresolvedImgixParams[x as keyof typeof resolvedImgixParams] = undefined\n\t\t}\n\t}\n\n\tconst src = buildURL(field.url, resolvedImgixParams as ImgixURLParams)\n\n\tconst ar = field.dimensions.width / field.dimensions.height\n\n\tconst castedWidth = castInt(width)\n\tconst castedHeight = castInt(height)\n\n\tlet resolvedWidth = castedWidth ?? field.dimensions.width\n\tlet resolvedHeight = castedHeight ?? field.dimensions.height\n\n\tif (castedWidth != null && castedHeight == null) {\n\t\tresolvedHeight = castedWidth / ar\n\t} else if (castedWidth == null && castedHeight != null) {\n\t\tresolvedWidth = castedHeight * ar\n\t}\n\n\t// A non-null assertion is required since we can't statically\n\t// know if an alt attribute is available.\n\tconst resolvedAlt = (alt ?? (field.alt || fallbackAlt))!\n\n\tif (process.env.NODE_ENV === \"development\" && typeof resolvedAlt !== \"string\") {\n\t\tconsole.error(\n\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\tsrc,\n\t\t)\n\t}\n\n\treturn (\n\t\t<ResolvedImage\n\t\t\tref={ref}\n\t\t\tsrc={src}\n\t\t\twidth={fill ? undefined : resolvedWidth}\n\t\t\theight={fill ? undefined : resolvedHeight}\n\t\t\talt={resolvedAlt}\n\t\t\tfill={fill}\n\t\t\tloader={loader === null ? undefined : loader}\n\t\t\t{...restProps}\n\t\t/>\n\t)\n})\n"],"mappings":";;;;;;;;;;AAeA,MAAM,gBAAgB,qBAAqB,KAAK;AAEhD,MAAM,WAAW,UAA2D;CAC3E,IAAI,OAAO,UAAU,YAAY,OAAO,UAAU,aACjD,OAAO;MACD;EACN,MAAM,SAAS,OAAO,SAAS,KAAK;EAEpC,IAAI,OAAO,MAAM,MAAM,GACtB;OAEA,OAAO;CAET;AACD;;;;;;;;;;;;;;;AAiDA,MAAa,mBAET,WAAoD,SAAS,iBAChE,EACC,OACA,cAAc,CAAC,GACf,KACA,aACA,MACA,OACA,QACA,WAAW,MACX,SAAS,aACT,GAAG,aAEJ,KACC;CACD,IAAI,QAAQ,IAAI,aAAa,eAAe;EAC3C,IAAI,OAAO,QAAQ,YAAY,QAAQ,IACtC,QAAQ,KACP,yQAAyQ,OACxQ,6BACD,GACD;EAGD,IAAI,OAAO,gBAAgB,YAAY,gBAAgB,IACtD,QAAQ,KACP,ySAAyS,OACxS,6BACD,GACD;CAEF;CAEA,IAAI,CAAC,SAAS,eAAe,KAAK,GACjC,OAAO,oBAAA,UAAA,EAAA,UAAG,SAAW,CAAA;CAGtB,MAAM,sBAAsB,EAAE,GAAG,YAAY;CAC7C,KAAK,MAAM,KAAK,qBACf,IAAI,oBAAoB,OAA2C,MAClE,oBAAoB,KAAyC,KAAA;CAI/D,MAAM,MAAM,SAAS,MAAM,KAAK,mBAAqC;CAErE,MAAM,KAAK,MAAM,WAAW,QAAQ,MAAM,WAAW;CAErD,MAAM,cAAc,QAAQ,KAAK;CACjC,MAAM,eAAe,QAAQ,MAAM;CAEnC,IAAI,gBAAgB,eAAe,MAAM,WAAW;CACpD,IAAI,iBAAiB,gBAAgB,MAAM,WAAW;CAEtD,IAAI,eAAe,QAAQ,gBAAgB,MAC1C,iBAAiB,cAAc;MACzB,IAAI,eAAe,QAAQ,gBAAgB,MACjD,gBAAgB,eAAe;CAKhC,MAAM,cAAe,QAAQ,MAAM,OAAO;CAE1C,IAAI,QAAQ,IAAI,aAAa,iBAAiB,OAAO,gBAAgB,UACpE,QAAQ,MACP,mNACA,GACD;CAGD,OACC,oBAAC,eAAD;EACM;EACA;EACL,OAAO,OAAO,KAAA,IAAY;EAC1B,QAAQ,OAAO,KAAA,IAAY;EAC3B,KAAK;EACC;EACN,QAAQ,WAAW,OAAO,KAAA,IAAY;EACtC,GAAI;CACJ,CAAA;AAEH,CAAC"}
|
package/dist/PrismicNextLink.cjs
CHANGED
|
@@ -4,8 +4,9 @@ let _prismicio_client = require("@prismicio/client");
|
|
|
4
4
|
let react = require("react");
|
|
5
5
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
6
6
|
let next_link_js = require("next/link.js");
|
|
7
|
-
next_link_js = require_runtime.__toESM(next_link_js);
|
|
7
|
+
next_link_js = require_runtime.__toESM(next_link_js, 1);
|
|
8
8
|
//#region src/PrismicNextLink.tsx
|
|
9
|
+
const ResolvedLink = require_resolveDefaultExport.resolveDefaultExport(next_link_js.default);
|
|
9
10
|
const PrismicNextLink = (0, react.forwardRef)(function PrismicNextLink(props, ref) {
|
|
10
11
|
const { field, document, linkResolver, children, ...restProps } = props;
|
|
11
12
|
const { href: computedHref, rel: computedRel, ...attrs } = (0, _prismicio_client.asLinkAttrs)(field ?? document, {
|
|
@@ -15,7 +16,7 @@ const PrismicNextLink = (0, react.forwardRef)(function PrismicNextLink(props, re
|
|
|
15
16
|
const href = ("href" in restProps ? restProps.href : computedHref) || "";
|
|
16
17
|
let rel = computedRel;
|
|
17
18
|
if ("rel" in restProps && typeof restProps.rel !== "function") rel = restProps.rel;
|
|
18
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(
|
|
19
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ResolvedLink, {
|
|
19
20
|
ref,
|
|
20
21
|
...attrs,
|
|
21
22
|
...restProps,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PrismicNextLink.cjs","names":["resolveDefaultExport","Link"],"sources":["../src/PrismicNextLink.tsx"],"sourcesContent":["import type {\n\tAsLinkAttrsConfig,\n\tLinkField,\n\tLinkResolverFunction,\n\tPrismicDocument,\n} from \"@prismicio/client\"\nimport { asLinkAttrs } from \"@prismicio/client\"\nimport Link from \"next/link\"\nimport type { ComponentProps } from \"react\"\nimport { forwardRef } from \"react\"\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<HTMLAnchorElement, PrismicNextLinkProps>(\n\tfunction PrismicNextLink(props, ref) {\n\t\tconst { field, document, linkResolver, children, ...restProps } = props\n\t\tconst {\n\t\t\thref: computedHref,\n\t\t\trel: computedRel,\n\t\t\t...attrs\n\t\t} = asLinkAttrs(field ?? document, {\n\t\t\tlinkResolver,\n\t\t\trel: typeof restProps.rel === \"function\" ? restProps.rel : undefined,\n\t\t})\n\n\t\tconst href = (\"href\" in restProps ? restProps.href : computedHref) || \"\"\n\n\t\tlet rel = computedRel\n\t\tif (\"rel\" in restProps && typeof restProps.rel !== \"function\") {\n\t\t\trel = restProps.rel\n\t\t}\n\n\t\
|
|
1
|
+
{"version":3,"file":"PrismicNextLink.cjs","names":["resolveDefaultExport","Link","forwardRef","asLinkAttrs"],"sources":["../src/PrismicNextLink.tsx"],"sourcesContent":["import type {\n\tAsLinkAttrsConfig,\n\tLinkField,\n\tLinkResolverFunction,\n\tPrismicDocument,\n} from \"@prismicio/client\"\nimport { asLinkAttrs } from \"@prismicio/client\"\nimport Link from \"next/link\"\nimport type { ComponentProps } from \"react\"\nimport { forwardRef } from \"react\"\n\nimport { resolveDefaultExport } from \"./lib/resolveDefaultExport\"\n\nconst ResolvedLink = resolveDefaultExport(Link)\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<HTMLAnchorElement, PrismicNextLinkProps>(\n\tfunction PrismicNextLink(props, ref) {\n\t\tconst { field, document, linkResolver, children, ...restProps } = props\n\t\tconst {\n\t\t\thref: computedHref,\n\t\t\trel: computedRel,\n\t\t\t...attrs\n\t\t} = asLinkAttrs(field ?? document, {\n\t\t\tlinkResolver,\n\t\t\trel: typeof restProps.rel === \"function\" ? restProps.rel : undefined,\n\t\t})\n\n\t\tconst href = (\"href\" in restProps ? restProps.href : computedHref) || \"\"\n\n\t\tlet rel = computedRel\n\t\tif (\"rel\" in restProps && typeof restProps.rel !== \"function\") {\n\t\t\trel = restProps.rel\n\t\t}\n\n\t\treturn (\n\t\t\t<ResolvedLink ref={ref} {...attrs} {...restProps} href={href} rel={rel}>\n\t\t\t\t{\"children\" in props ? children : field?.text}\n\t\t\t</ResolvedLink>\n\t\t)\n\t},\n)\n"],"mappings":";;;;;;;;AAaA,MAAM,eAAeA,6BAAAA,qBAAqBC,aAAAA,OAAI;AA0B9C,MAAa,mBAAA,GAAkBC,MAAAA,WAAAA,CAC9B,SAAS,gBAAgB,OAAO,KAAK;CACpC,MAAM,EAAE,OAAO,UAAU,cAAc,UAAU,GAAG,cAAc;CAClE,MAAM,EACL,MAAM,cACN,KAAK,aACL,GAAG,WAAA,GACAC,kBAAAA,YAAAA,CAAY,SAAS,UAAU;EAClC;EACA,KAAK,OAAO,UAAU,QAAQ,aAAa,UAAU,MAAM,KAAA;CAC5D,CAAC;CAED,MAAM,QAAQ,UAAU,YAAY,UAAU,OAAO,iBAAiB;CAEtE,IAAI,MAAM;CACV,IAAI,SAAS,aAAa,OAAO,UAAU,QAAQ,YAClD,MAAM,UAAU;CAGjB,OACC,iBAAA,GAAA,kBAAA,IAAA,CAAC,cAAD;EAAmB;EAAK,GAAI;EAAO,GAAI;EAAiB;EAAW;EACjE,UAAA,cAAc,QAAQ,WAAW,OAAO;CAC5B,CAAA;AAEhB,CACD"}
|
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
import * as _$react from "react";
|
|
2
1
|
import { ComponentProps } from "react";
|
|
3
|
-
import * as _$next_link0 from "next/link.js";
|
|
4
|
-
import Link from "next/link.js";
|
|
5
2
|
import { AsLinkAttrsConfig, LinkField, LinkResolverFunction, PrismicDocument } from "@prismicio/client";
|
|
6
|
-
|
|
3
|
+
import Link from "next/link.js";
|
|
7
4
|
//#region src/PrismicNextLink.d.ts
|
|
8
|
-
type PrismicNextLinkProps = Omit<ComponentProps<typeof Link>, "field" | "document" | "href" | "rel"> & {
|
|
5
|
+
export type PrismicNextLinkProps = Omit<ComponentProps<typeof Link>, "field" | "document" | "href" | "rel"> & {
|
|
9
6
|
linkResolver?: LinkResolverFunction;
|
|
10
7
|
rel?: string | AsLinkAttrsConfig["rel"];
|
|
11
8
|
} & ({
|
|
@@ -21,34 +18,33 @@ type PrismicNextLinkProps = Omit<ComponentProps<typeof Link>, "field" | "documen
|
|
|
21
18
|
document?: never;
|
|
22
19
|
href: ComponentProps<typeof Link>["href"];
|
|
23
20
|
});
|
|
24
|
-
declare const PrismicNextLink:
|
|
21
|
+
export declare const PrismicNextLink: import("react").ForwardRefExoticComponent<(Omit<Omit<Omit<import("react").AnchorHTMLAttributes<HTMLAnchorElement>, keyof import("next/link").LinkProps<any>> & import("next/link").LinkProps<any> & {
|
|
25
22
|
children?: React.ReactNode | undefined;
|
|
26
|
-
} &
|
|
23
|
+
} & import("react").RefAttributes<HTMLAnchorElement>, "document" | "field" | "href" | "rel"> & {
|
|
27
24
|
linkResolver?: LinkResolverFunction;
|
|
28
25
|
rel?: string | AsLinkAttrsConfig["rel"];
|
|
29
26
|
} & {
|
|
30
27
|
field: LinkField | null | undefined;
|
|
31
28
|
document?: never;
|
|
32
29
|
href?: never;
|
|
33
|
-
}, "ref"> | Omit<Omit<Omit<
|
|
30
|
+
}, "ref"> | Omit<Omit<Omit<import("react").AnchorHTMLAttributes<HTMLAnchorElement>, keyof import("next/link").LinkProps<any>> & import("next/link").LinkProps<any> & {
|
|
34
31
|
children?: React.ReactNode | undefined;
|
|
35
|
-
} &
|
|
32
|
+
} & import("react").RefAttributes<HTMLAnchorElement>, "document" | "field" | "href" | "rel"> & {
|
|
36
33
|
linkResolver?: LinkResolverFunction;
|
|
37
34
|
rel?: string | AsLinkAttrsConfig["rel"];
|
|
38
35
|
} & {
|
|
39
36
|
field?: never;
|
|
40
37
|
document: PrismicDocument | null | undefined;
|
|
41
38
|
href?: never;
|
|
42
|
-
}, "ref"> | Omit<Omit<Omit<
|
|
39
|
+
}, "ref"> | Omit<Omit<Omit<import("react").AnchorHTMLAttributes<HTMLAnchorElement>, keyof import("next/link").LinkProps<any>> & import("next/link").LinkProps<any> & {
|
|
43
40
|
children?: React.ReactNode | undefined;
|
|
44
|
-
} &
|
|
41
|
+
} & import("react").RefAttributes<HTMLAnchorElement>, "document" | "field" | "href" | "rel"> & {
|
|
45
42
|
linkResolver?: LinkResolverFunction;
|
|
46
43
|
rel?: string | AsLinkAttrsConfig["rel"];
|
|
47
44
|
} & {
|
|
48
45
|
field?: never;
|
|
49
46
|
document?: never;
|
|
50
47
|
href: ComponentProps<typeof Link>["href"];
|
|
51
|
-
}, "ref">) &
|
|
48
|
+
}, "ref">) & import("react").RefAttributes<HTMLAnchorElement>>;
|
|
52
49
|
//#endregion
|
|
53
|
-
export { PrismicNextLink, PrismicNextLinkProps };
|
|
54
50
|
//# sourceMappingURL=PrismicNextLink.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PrismicNextLink.d.cts","names":[],"sources":["../src/PrismicNextLink.tsx"],"mappings":"
|
|
1
|
+
{"version":3,"file":"PrismicNextLink.d.cts","names":[],"sources":["../src/PrismicNextLink.tsx"],"mappings":";;;;YAeY,uBAAuB,KAClC,sBAAsB;EAGtB,eAAe;EACf,eAAe;;EAGZ,OAAO;EACP;EACA;;EAGA;EACA,UAAU;EACV;;EAGA;EACA;EACA,MAAM,sBAAsB;;qBAInB,iCAAe,2BAAA,KAAA,KAAA,qBAAA,qBAAA,8CAAA,sCAAA;;;EApBZ,eAAA;EACT,eAAS;;EAGL,OAAA;EACI;EACJ;;;;;;;EAGC;EACE,UAAA;EACH;;;;;;;EAGC;EACG;EACL,MAAA,sBAAsB;6BA6B/B,cAAA"}
|
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
import { AsLinkAttrsConfig, LinkField, LinkResolverFunction, PrismicDocument } from "@prismicio/client";
|
|
2
|
-
import * as _$react from "react";
|
|
3
2
|
import { ComponentProps } from "react";
|
|
4
|
-
import * as _$next_link0 from "next/link.js";
|
|
5
3
|
import Link from "next/link.js";
|
|
6
|
-
|
|
7
4
|
//#region src/PrismicNextLink.d.ts
|
|
8
|
-
type PrismicNextLinkProps = Omit<ComponentProps<typeof Link>, "field" | "document" | "href" | "rel"> & {
|
|
5
|
+
export type PrismicNextLinkProps = Omit<ComponentProps<typeof Link>, "field" | "document" | "href" | "rel"> & {
|
|
9
6
|
linkResolver?: LinkResolverFunction;
|
|
10
7
|
rel?: string | AsLinkAttrsConfig["rel"];
|
|
11
8
|
} & ({
|
|
@@ -21,34 +18,33 @@ type PrismicNextLinkProps = Omit<ComponentProps<typeof Link>, "field" | "documen
|
|
|
21
18
|
document?: never;
|
|
22
19
|
href: ComponentProps<typeof Link>["href"];
|
|
23
20
|
});
|
|
24
|
-
declare const PrismicNextLink:
|
|
21
|
+
export declare const PrismicNextLink: import("react").ForwardRefExoticComponent<(Omit<Omit<Omit<import("react").AnchorHTMLAttributes<HTMLAnchorElement>, keyof import("next/link").LinkProps<any>> & import("next/link").LinkProps<any> & {
|
|
25
22
|
children?: React.ReactNode | undefined;
|
|
26
|
-
} &
|
|
23
|
+
} & import("react").RefAttributes<HTMLAnchorElement>, "document" | "field" | "href" | "rel"> & {
|
|
27
24
|
linkResolver?: LinkResolverFunction;
|
|
28
25
|
rel?: string | AsLinkAttrsConfig["rel"];
|
|
29
26
|
} & {
|
|
30
27
|
field: LinkField | null | undefined;
|
|
31
28
|
document?: never;
|
|
32
29
|
href?: never;
|
|
33
|
-
}, "ref"> | Omit<Omit<Omit<
|
|
30
|
+
}, "ref"> | Omit<Omit<Omit<import("react").AnchorHTMLAttributes<HTMLAnchorElement>, keyof import("next/link").LinkProps<any>> & import("next/link").LinkProps<any> & {
|
|
34
31
|
children?: React.ReactNode | undefined;
|
|
35
|
-
} &
|
|
32
|
+
} & import("react").RefAttributes<HTMLAnchorElement>, "document" | "field" | "href" | "rel"> & {
|
|
36
33
|
linkResolver?: LinkResolverFunction;
|
|
37
34
|
rel?: string | AsLinkAttrsConfig["rel"];
|
|
38
35
|
} & {
|
|
39
36
|
field?: never;
|
|
40
37
|
document: PrismicDocument | null | undefined;
|
|
41
38
|
href?: never;
|
|
42
|
-
}, "ref"> | Omit<Omit<Omit<
|
|
39
|
+
}, "ref"> | Omit<Omit<Omit<import("react").AnchorHTMLAttributes<HTMLAnchorElement>, keyof import("next/link").LinkProps<any>> & import("next/link").LinkProps<any> & {
|
|
43
40
|
children?: React.ReactNode | undefined;
|
|
44
|
-
} &
|
|
41
|
+
} & import("react").RefAttributes<HTMLAnchorElement>, "document" | "field" | "href" | "rel"> & {
|
|
45
42
|
linkResolver?: LinkResolverFunction;
|
|
46
43
|
rel?: string | AsLinkAttrsConfig["rel"];
|
|
47
44
|
} & {
|
|
48
45
|
field?: never;
|
|
49
46
|
document?: never;
|
|
50
47
|
href: ComponentProps<typeof Link>["href"];
|
|
51
|
-
}, "ref">) &
|
|
48
|
+
}, "ref">) & import("react").RefAttributes<HTMLAnchorElement>>;
|
|
52
49
|
//#endregion
|
|
53
|
-
export { PrismicNextLink, PrismicNextLinkProps };
|
|
54
50
|
//# sourceMappingURL=PrismicNextLink.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PrismicNextLink.d.ts","names":[],"sources":["../src/PrismicNextLink.tsx"],"mappings":"
|
|
1
|
+
{"version":3,"file":"PrismicNextLink.d.ts","names":[],"sources":["../src/PrismicNextLink.tsx"],"mappings":";;;;YAeY,uBAAuB,KAClC,sBAAsB;EAGtB,eAAe;EACf,eAAe;;EAGZ,OAAO;EACP;EACA;;EAGA;EACA,UAAU;EACV;;EAGA;EACA;EACA,MAAM,sBAAsB;;qBAInB,iCAAe,2BAAA,KAAA,KAAA,qBAAA,qBAAA,8CAAA,sCAAA;;;EApBZ,eAAA;EACT,eAAS;;EAGL,OAAA;EACI;EACJ;;;;;;;EAGC;EACE,UAAA;EACH;;;;;;;EAGC;EACG;EACL,MAAA,sBAAsB;6BA6B/B,cAAA"}
|
package/dist/PrismicNextLink.js
CHANGED
|
@@ -4,6 +4,7 @@ import { forwardRef } from "react";
|
|
|
4
4
|
import { jsx } from "react/jsx-runtime";
|
|
5
5
|
import Link from "next/link.js";
|
|
6
6
|
//#region src/PrismicNextLink.tsx
|
|
7
|
+
const ResolvedLink = resolveDefaultExport(Link);
|
|
7
8
|
const PrismicNextLink = forwardRef(function PrismicNextLink(props, ref) {
|
|
8
9
|
const { field, document, linkResolver, children, ...restProps } = props;
|
|
9
10
|
const { href: computedHref, rel: computedRel, ...attrs } = asLinkAttrs(field ?? document, {
|
|
@@ -13,7 +14,7 @@ const PrismicNextLink = forwardRef(function PrismicNextLink(props, ref) {
|
|
|
13
14
|
const href = ("href" in restProps ? restProps.href : computedHref) || "";
|
|
14
15
|
let rel = computedRel;
|
|
15
16
|
if ("rel" in restProps && typeof restProps.rel !== "function") rel = restProps.rel;
|
|
16
|
-
return /* @__PURE__ */ jsx(
|
|
17
|
+
return /* @__PURE__ */ jsx(ResolvedLink, {
|
|
17
18
|
ref,
|
|
18
19
|
...attrs,
|
|
19
20
|
...restProps,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PrismicNextLink.js","names":[],"sources":["../src/PrismicNextLink.tsx"],"sourcesContent":["import type {\n\tAsLinkAttrsConfig,\n\tLinkField,\n\tLinkResolverFunction,\n\tPrismicDocument,\n} from \"@prismicio/client\"\nimport { asLinkAttrs } from \"@prismicio/client\"\nimport Link from \"next/link\"\nimport type { ComponentProps } from \"react\"\nimport { forwardRef } from \"react\"\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<HTMLAnchorElement, PrismicNextLinkProps>(\n\tfunction PrismicNextLink(props, ref) {\n\t\tconst { field, document, linkResolver, children, ...restProps } = props\n\t\tconst {\n\t\t\thref: computedHref,\n\t\t\trel: computedRel,\n\t\t\t...attrs\n\t\t} = asLinkAttrs(field ?? document, {\n\t\t\tlinkResolver,\n\t\t\trel: typeof restProps.rel === \"function\" ? restProps.rel : undefined,\n\t\t})\n\n\t\tconst href = (\"href\" in restProps ? restProps.href : computedHref) || \"\"\n\n\t\tlet rel = computedRel\n\t\tif (\"rel\" in restProps && typeof restProps.rel !== \"function\") {\n\t\t\trel = restProps.rel\n\t\t}\n\n\t\
|
|
1
|
+
{"version":3,"file":"PrismicNextLink.js","names":[],"sources":["../src/PrismicNextLink.tsx"],"sourcesContent":["import type {\n\tAsLinkAttrsConfig,\n\tLinkField,\n\tLinkResolverFunction,\n\tPrismicDocument,\n} from \"@prismicio/client\"\nimport { asLinkAttrs } from \"@prismicio/client\"\nimport Link from \"next/link\"\nimport type { ComponentProps } from \"react\"\nimport { forwardRef } from \"react\"\n\nimport { resolveDefaultExport } from \"./lib/resolveDefaultExport\"\n\nconst ResolvedLink = resolveDefaultExport(Link)\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<HTMLAnchorElement, PrismicNextLinkProps>(\n\tfunction PrismicNextLink(props, ref) {\n\t\tconst { field, document, linkResolver, children, ...restProps } = props\n\t\tconst {\n\t\t\thref: computedHref,\n\t\t\trel: computedRel,\n\t\t\t...attrs\n\t\t} = asLinkAttrs(field ?? document, {\n\t\t\tlinkResolver,\n\t\t\trel: typeof restProps.rel === \"function\" ? restProps.rel : undefined,\n\t\t})\n\n\t\tconst href = (\"href\" in restProps ? restProps.href : computedHref) || \"\"\n\n\t\tlet rel = computedRel\n\t\tif (\"rel\" in restProps && typeof restProps.rel !== \"function\") {\n\t\t\trel = restProps.rel\n\t\t}\n\n\t\treturn (\n\t\t\t<ResolvedLink ref={ref} {...attrs} {...restProps} href={href} rel={rel}>\n\t\t\t\t{\"children\" in props ? children : field?.text}\n\t\t\t</ResolvedLink>\n\t\t)\n\t},\n)\n"],"mappings":";;;;;;AAaA,MAAM,eAAe,qBAAqB,IAAI;AA0B9C,MAAa,kBAAkB,WAC9B,SAAS,gBAAgB,OAAO,KAAK;CACpC,MAAM,EAAE,OAAO,UAAU,cAAc,UAAU,GAAG,cAAc;CAClE,MAAM,EACL,MAAM,cACN,KAAK,aACL,GAAG,UACA,YAAY,SAAS,UAAU;EAClC;EACA,KAAK,OAAO,UAAU,QAAQ,aAAa,UAAU,MAAM,KAAA;CAC5D,CAAC;CAED,MAAM,QAAQ,UAAU,YAAY,UAAU,OAAO,iBAAiB;CAEtE,IAAI,MAAM;CACV,IAAI,SAAS,aAAa,OAAO,UAAU,QAAQ,YAClD,MAAM,UAAU;CAGjB,OACC,oBAAC,cAAD;EAAmB;EAAK,GAAI;EAAO,GAAI;EAAiB;EAAW;EACjE,UAAA,cAAc,QAAQ,WAAW,OAAO;CAC5B,CAAA;AAEhB,CACD"}
|
package/dist/PrismicPreview.cjs
CHANGED
|
@@ -3,9 +3,10 @@ const require_resolveDefaultExport = require("./lib/resolveDefaultExport.cjs");
|
|
|
3
3
|
const require_PrismicPreviewClient = require("./PrismicPreviewClient.cjs");
|
|
4
4
|
let _prismicio_client = require("@prismicio/client");
|
|
5
5
|
let next_script_js = require("next/script.js");
|
|
6
|
-
next_script_js = require_runtime.__toESM(next_script_js);
|
|
6
|
+
next_script_js = require_runtime.__toESM(next_script_js, 1);
|
|
7
7
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
8
8
|
//#region src/PrismicPreview.tsx
|
|
9
|
+
const ResolvedScript = require_resolveDefaultExport.resolveDefaultExport(next_script_js.default);
|
|
9
10
|
/**
|
|
10
11
|
* React component that sets up Prismic Previews using the Prismic Toolbar. When the Prismic Toolbar
|
|
11
12
|
* send events to the browser, such as on preview updates and exiting, this component will
|
|
@@ -19,7 +20,6 @@ const PrismicPreview = async (props) => {
|
|
|
19
20
|
const { draftMode } = await import("next/headers.js");
|
|
20
21
|
const toolbarSrc = (0, _prismicio_client.getToolbarSrc)(repositoryName);
|
|
21
22
|
const isDraftMode = (await draftMode()).isEnabled;
|
|
22
|
-
const ResolvedScript = require_resolveDefaultExport.resolveDefaultExport(next_script_js.default);
|
|
23
23
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
|
|
24
24
|
children,
|
|
25
25
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_PrismicPreviewClient.PrismicPreviewClient, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PrismicPreview.cjs","names":["resolveDefaultExport","Script","PrismicPreviewClient"],"sources":["../src/PrismicPreview.tsx"],"sourcesContent":["import { getToolbarSrc } from \"@prismicio/client\"\nimport Script from \"next/script\"\nimport type { FC, ReactNode } from \"react\"\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 using this\n\t * repository.\n\t */\n\trepositoryName: string\n\n\t/**\n\t * The URL of your app's Prismic preview endpoint (default: `/api/preview`). This URL will be\n\t * 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`). This URL will be\n\t * 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 the Prismic Toolbar\n * send events to the browser, such as on preview updates and exiting, this component will\n * automatically refresh the page with the changes.\n *\n * This component can be wrapped around your app or added anywhere in your app's tree. It must be\n * 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\
|
|
1
|
+
{"version":3,"file":"PrismicPreview.cjs","names":["resolveDefaultExport","Script","getToolbarSrc","PrismicPreviewClient"],"sources":["../src/PrismicPreview.tsx"],"sourcesContent":["import { getToolbarSrc } from \"@prismicio/client\"\nimport Script from \"next/script\"\nimport type { FC, ReactNode } from \"react\"\n\nimport { resolveDefaultExport } from \"./lib/resolveDefaultExport\"\nimport { PrismicPreviewClient } from \"./PrismicPreviewClient\"\n\nconst ResolvedScript = resolveDefaultExport(Script)\n\n/** Props for `<PrismicPreview>`. */\nexport type PrismicPreviewProps = {\n\t/**\n\t * The name of your Prismic repository. A Prismic Toolbar will be registered using this\n\t * repository.\n\t */\n\trepositoryName: string\n\n\t/**\n\t * The URL of your app's Prismic preview endpoint (default: `/api/preview`). This URL will be\n\t * 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`). This URL will be\n\t * 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 the Prismic Toolbar\n * send events to the browser, such as on preview updates and exiting, this component will\n * automatically refresh the page with the changes.\n *\n * This component can be wrapped around your app or added anywhere in your app's tree. It must be\n * 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\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":";;;;;;;;AAOA,MAAM,iBAAiBA,6BAAAA,qBAAqBC,eAAAA,OAAM;;;;;;;;;AAkClD,MAAa,iBAA0C,OAAO,UAAU;CACvE,MAAM,EAAE,gBAAgB,UAAU,GAAG,eAAe;CAKpD,MAAM,EAAE,cAAc,MAAM,OAAO;CAEnC,MAAM,cAAA,GAAaC,kBAAAA,cAAAA,CAAc,cAAc;CAC/C,MAAM,eAAe,MAAM,UAAU,EAAA,CAAG;CAExC,OACC,iBAAA,GAAA,kBAAA,KAAA,CAAA,kBAAA,UAAA,EAAA,UAAA;EACE;EACD,iBAAA,GAAA,kBAAA,IAAA,CAACC,6BAAAA,sBAAD;GACiB;GACH;GACb,GAAI;EACJ,CAAA;EACD,iBAAA,GAAA,kBAAA,IAAA,CAAC,gBAAD;GAAgB,KAAK;GAAY,UAAS;EAAc,CAAA;CACvD,EAAA,CAAA;AAEJ"}
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { FC, ReactNode } from "react";
|
|
2
|
-
|
|
3
2
|
//#region src/PrismicPreview.d.ts
|
|
4
3
|
/** Props for `<PrismicPreview>`. */
|
|
5
|
-
type PrismicPreviewProps = {
|
|
4
|
+
export type PrismicPreviewProps = {
|
|
6
5
|
/**
|
|
7
6
|
* The name of your Prismic repository. A Prismic Toolbar will be registered using this
|
|
8
7
|
* repository.
|
|
@@ -17,7 +16,8 @@ type PrismicPreviewProps = {
|
|
|
17
16
|
* The URL of your app's exit preview endpoint (default: `/api/exit-preview`). This URL will be
|
|
18
17
|
* fetched on preview exit events.
|
|
19
18
|
*/
|
|
20
|
-
exitPreviewURL?: string;
|
|
19
|
+
exitPreviewURL?: string;
|
|
20
|
+
/** Children to render adjacent to the Prismic Toolbar. */
|
|
21
21
|
children?: ReactNode;
|
|
22
22
|
};
|
|
23
23
|
/**
|
|
@@ -28,7 +28,6 @@ type PrismicPreviewProps = {
|
|
|
28
28
|
* This component can be wrapped around your app or added anywhere in your app's tree. It must be
|
|
29
29
|
* rendered on every page.
|
|
30
30
|
*/
|
|
31
|
-
declare const PrismicPreview: FC<PrismicPreviewProps>;
|
|
31
|
+
export declare const PrismicPreview: FC<PrismicPreviewProps>;
|
|
32
32
|
//#endregion
|
|
33
|
-
export { PrismicPreview, PrismicPreviewProps };
|
|
34
33
|
//# sourceMappingURL=PrismicPreview.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PrismicPreview.d.cts","names":[],"sources":["../src/PrismicPreview.tsx"],"mappings":"
|
|
1
|
+
{"version":3,"file":"PrismicPreview.d.cts","names":[],"sources":["../src/PrismicPreview.tsx"],"mappings":";;;YAUY;;;;;EAKX;;;;;EAMA;;;;;EAMA;;EAGA,WAAW;;;;;;;;;;qBAWC,gBAAgB,GAAG"}
|
package/dist/PrismicPreview.d.ts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { FC, ReactNode } from "react";
|
|
2
|
-
|
|
3
2
|
//#region src/PrismicPreview.d.ts
|
|
4
3
|
/** Props for `<PrismicPreview>`. */
|
|
5
|
-
type PrismicPreviewProps = {
|
|
4
|
+
export type PrismicPreviewProps = {
|
|
6
5
|
/**
|
|
7
6
|
* The name of your Prismic repository. A Prismic Toolbar will be registered using this
|
|
8
7
|
* repository.
|
|
@@ -17,7 +16,8 @@ type PrismicPreviewProps = {
|
|
|
17
16
|
* The URL of your app's exit preview endpoint (default: `/api/exit-preview`). This URL will be
|
|
18
17
|
* fetched on preview exit events.
|
|
19
18
|
*/
|
|
20
|
-
exitPreviewURL?: string;
|
|
19
|
+
exitPreviewURL?: string;
|
|
20
|
+
/** Children to render adjacent to the Prismic Toolbar. */
|
|
21
21
|
children?: ReactNode;
|
|
22
22
|
};
|
|
23
23
|
/**
|
|
@@ -28,7 +28,6 @@ type PrismicPreviewProps = {
|
|
|
28
28
|
* This component can be wrapped around your app or added anywhere in your app's tree. It must be
|
|
29
29
|
* rendered on every page.
|
|
30
30
|
*/
|
|
31
|
-
declare const PrismicPreview: FC<PrismicPreviewProps>;
|
|
31
|
+
export declare const PrismicPreview: FC<PrismicPreviewProps>;
|
|
32
32
|
//#endregion
|
|
33
|
-
export { PrismicPreview, PrismicPreviewProps };
|
|
34
33
|
//# sourceMappingURL=PrismicPreview.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PrismicPreview.d.ts","names":[],"sources":["../src/PrismicPreview.tsx"],"mappings":"
|
|
1
|
+
{"version":3,"file":"PrismicPreview.d.ts","names":[],"sources":["../src/PrismicPreview.tsx"],"mappings":";;;YAUY;;;;;EAKX;;;;;EAMA;;;;;EAMA;;EAGA,WAAW;;;;;;;;;;qBAWC,gBAAgB,GAAG"}
|
package/dist/PrismicPreview.js
CHANGED
|
@@ -4,6 +4,7 @@ import { getToolbarSrc } from "@prismicio/client";
|
|
|
4
4
|
import Script from "next/script.js";
|
|
5
5
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
6
6
|
//#region src/PrismicPreview.tsx
|
|
7
|
+
const ResolvedScript = resolveDefaultExport(Script);
|
|
7
8
|
/**
|
|
8
9
|
* React component that sets up Prismic Previews using the Prismic Toolbar. When the Prismic Toolbar
|
|
9
10
|
* send events to the browser, such as on preview updates and exiting, this component will
|
|
@@ -17,7 +18,6 @@ const PrismicPreview = async (props) => {
|
|
|
17
18
|
const { draftMode } = await import("next/headers.js");
|
|
18
19
|
const toolbarSrc = getToolbarSrc(repositoryName);
|
|
19
20
|
const isDraftMode = (await draftMode()).isEnabled;
|
|
20
|
-
const ResolvedScript = resolveDefaultExport(Script);
|
|
21
21
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
22
22
|
children,
|
|
23
23
|
/* @__PURE__ */ jsx(PrismicPreviewClient, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PrismicPreview.js","names":[],"sources":["../src/PrismicPreview.tsx"],"sourcesContent":["import { getToolbarSrc } from \"@prismicio/client\"\nimport Script from \"next/script\"\nimport type { FC, ReactNode } from \"react\"\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 using this\n\t * repository.\n\t */\n\trepositoryName: string\n\n\t/**\n\t * The URL of your app's Prismic preview endpoint (default: `/api/preview`). This URL will be\n\t * 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`). This URL will be\n\t * 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 the Prismic Toolbar\n * send events to the browser, such as on preview updates and exiting, this component will\n * automatically refresh the page with the changes.\n *\n * This component can be wrapped around your app or added anywhere in your app's tree. It must be\n * 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\
|
|
1
|
+
{"version":3,"file":"PrismicPreview.js","names":[],"sources":["../src/PrismicPreview.tsx"],"sourcesContent":["import { getToolbarSrc } from \"@prismicio/client\"\nimport Script from \"next/script\"\nimport type { FC, ReactNode } from \"react\"\n\nimport { resolveDefaultExport } from \"./lib/resolveDefaultExport\"\nimport { PrismicPreviewClient } from \"./PrismicPreviewClient\"\n\nconst ResolvedScript = resolveDefaultExport(Script)\n\n/** Props for `<PrismicPreview>`. */\nexport type PrismicPreviewProps = {\n\t/**\n\t * The name of your Prismic repository. A Prismic Toolbar will be registered using this\n\t * repository.\n\t */\n\trepositoryName: string\n\n\t/**\n\t * The URL of your app's Prismic preview endpoint (default: `/api/preview`). This URL will be\n\t * 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`). This URL will be\n\t * 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 the Prismic Toolbar\n * send events to the browser, such as on preview updates and exiting, this component will\n * automatically refresh the page with the changes.\n *\n * This component can be wrapped around your app or added anywhere in your app's tree. It must be\n * 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\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":";;;;;;AAOA,MAAM,iBAAiB,qBAAqB,MAAM;;;;;;;;;AAkClD,MAAa,iBAA0C,OAAO,UAAU;CACvE,MAAM,EAAE,gBAAgB,UAAU,GAAG,eAAe;CAKpD,MAAM,EAAE,cAAc,MAAM,OAAO;CAEnC,MAAM,aAAa,cAAc,cAAc;CAC/C,MAAM,eAAe,MAAM,UAAU,EAAA,CAAG;CAExC,OACC,qBAAA,UAAA,EAAA,UAAA;EACE;EACD,oBAAC,sBAAD;GACiB;GACH;GACb,GAAI;EACJ,CAAA;EACD,oBAAC,gBAAD;GAAgB,KAAK;GAAY,UAAS;EAAc,CAAA;CACvD,EAAA,CAAA;AAEJ"}
|