@prismicio/next 2.2.0-canary.070be83 → 2.2.0-pr.123.0d5ddd7
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 → PrismicImage.cjs} +7 -7
- package/dist/PrismicImage.cjs.map +1 -0
- package/dist/{PrismicNextImage.d.cts → PrismicImage.d.cts} +6 -6
- package/dist/{PrismicNextLink.cjs → PrismicLink.cjs} +4 -4
- package/dist/PrismicLink.cjs.map +1 -0
- package/dist/{PrismicNextLink.d.cts → PrismicLink.d.cts} +9 -9
- package/dist/PrismicRichText.cjs +77 -0
- package/dist/PrismicRichText.cjs.map +1 -0
- package/dist/PrismicRichText.d.cts +45 -0
- package/dist/PrismicTable.cjs +35 -0
- package/dist/PrismicTable.cjs.map +1 -0
- package/dist/PrismicTable.d.cts +62 -0
- package/dist/index.cjs +32 -5
- package/dist/index.d.cts +6 -3
- package/dist/package.cjs +1 -1
- package/dist/pages.cjs +31 -4
- package/dist/pages.d.cts +6 -3
- package/package.json +3 -2
- package/src/{PrismicNextImage.tsx → PrismicImage.tsx} +8 -8
- package/src/{PrismicNextLink.tsx → PrismicLink.tsx} +4 -4
- package/src/PrismicRichText.tsx +89 -0
- package/src/PrismicTable.tsx +65 -0
- package/src/deprecated.ts +19 -0
- package/src/index.ts +32 -5
- package/src/pages/index.ts +31 -4
- package/dist/PrismicNextImage.cjs.map +0 -1
- package/dist/PrismicNextLink.cjs.map +0 -1
|
@@ -11,7 +11,7 @@ let next_image = require("next/image");
|
|
|
11
11
|
next_image = require_rolldown_runtime.__toESM(next_image);
|
|
12
12
|
let imgix_url_builder = require("imgix-url-builder");
|
|
13
13
|
|
|
14
|
-
//#region src/
|
|
14
|
+
//#region src/PrismicImage.tsx
|
|
15
15
|
const castInt = (input) => {
|
|
16
16
|
if (typeof input === "number" || typeof input === "undefined") return input;
|
|
17
17
|
else {
|
|
@@ -36,10 +36,10 @@ const castInt = (input) => {
|
|
|
36
36
|
*
|
|
37
37
|
* @see To learn more about `next/image`, see: https://nextjs.org/docs/api-reference/next/image
|
|
38
38
|
*/
|
|
39
|
-
const
|
|
39
|
+
const PrismicImage = (0, react.forwardRef)(function PrismicImage$1({ field, imgixParams = {}, alt, fallbackAlt, fill, width, height, fallback = null, loader = require_imgixLoader.imgixLoader, ...restProps }, ref) {
|
|
40
40
|
if (process.env.NODE_ENV === "development") {
|
|
41
|
-
if (typeof alt === "string" && alt !== "") console.warn(`[
|
|
42
|
-
if (typeof fallbackAlt === "string" && fallbackAlt !== "") console.warn(`[
|
|
41
|
+
if (typeof alt === "string" && alt !== "") console.warn(`[PrismicImage] The "alt" prop can only be used to declare an image as decorative by passing an empty string (alt="") but was provided a non-empty string. You can resolve this warning by removing the "alt" prop or changing it to alt="". For more details, see ${require_devMsg.devMsg("alt-must-be-an-empty-string")}`);
|
|
42
|
+
if (typeof fallbackAlt === "string" && fallbackAlt !== "") console.warn(`[PrismicImage] The "fallbackAlt" prop can only be used to declare an image as decorative by passing an empty string (fallbackAlt="") but was provided a non-empty string. You can resolve this warning by removing the "fallbackAlt" prop or changing it to fallbackAlt="". For more details, see ${require_devMsg.devMsg("alt-must-be-an-empty-string")}`);
|
|
43
43
|
}
|
|
44
44
|
if (!_prismicio_client.isFilled.imageThumbnail(field)) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_jsx_runtime.Fragment, { children: fallback });
|
|
45
45
|
const resolvedImgixParams = imgixParams;
|
|
@@ -53,7 +53,7 @@ const PrismicNextImage = (0, react.forwardRef)(function PrismicNextImage$1({ fie
|
|
|
53
53
|
if (castedWidth != null && castedHeight == null) resolvedHeight = castedWidth / ar;
|
|
54
54
|
else if (castedWidth == null && castedHeight != null) resolvedWidth = castedHeight * ar;
|
|
55
55
|
const resolvedAlt = alt ?? (field.alt || fallbackAlt);
|
|
56
|
-
if (process.env.NODE_ENV === "development" && typeof resolvedAlt !== "string") console.error(`[
|
|
56
|
+
if (process.env.NODE_ENV === "development" && typeof resolvedAlt !== "string") console.error(`[PrismicImage] 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
57
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_resolveDefaultExport.resolveDefaultExport(next_image.default), {
|
|
58
58
|
ref,
|
|
59
59
|
src,
|
|
@@ -67,5 +67,5 @@ const PrismicNextImage = (0, react.forwardRef)(function PrismicNextImage$1({ fie
|
|
|
67
67
|
});
|
|
68
68
|
|
|
69
69
|
//#endregion
|
|
70
|
-
exports.
|
|
71
|
-
//# sourceMappingURL=
|
|
70
|
+
exports.PrismicImage = PrismicImage;
|
|
71
|
+
//# sourceMappingURL=PrismicImage.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PrismicImage.cjs","names":["PrismicImage","imgixLoader","devMsg","isFilled","resolveDefaultExport","Image"],"sources":["../src/PrismicImage.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 PrismicImageProps = 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 PrismicImage: ForwardRefExoticComponent<\n\tPropsWithoutRef<PrismicImageProps> & RefAttributes<HTMLImageElement>\n> = forwardRef<HTMLImageElement, PrismicImageProps>(\n\tfunction PrismicImage(\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`[PrismicImage] The \"alt\" prop can only be used to declare an image as decorative by passing an empty string (alt=\"\") but was provided a non-empty string. You can resolve this warning by removing the \"alt\" prop or changing it to alt=\"\". For more details, see ${devMsg(\n\t\t\t\t\t\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`[PrismicImage] The \"fallbackAlt\" prop can only be used to declare an image as decorative by passing an empty string (fallbackAlt=\"\") but was provided a non-empty string. You can resolve this warning by removing the \"fallbackAlt\" prop or changing it to fallbackAlt=\"\". For more details, see ${devMsg(\n\t\t\t\t\t\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`[PrismicImage] 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,qCAGZ,SAASA,eACR,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,qQAAqQC,sBACpQ,8BACA,GACD;AAGF,MAAI,OAAO,gBAAgB,YAAY,gBAAgB,GACtD,SAAQ,KACP,qSAAqSA,sBACpS,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,+MACA,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"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { ForwardRefExoticComponent, PropsWithoutRef, RefAttributes } from "react";
|
|
2
|
-
import { ImageFieldImage } from "@prismicio/client";
|
|
3
2
|
import { ImageProps } from "next/image";
|
|
4
3
|
import { ImgixURLParams } from "imgix-url-builder";
|
|
4
|
+
import { ImageFieldImage } from "@prismicio/client";
|
|
5
5
|
|
|
6
|
-
//#region src/
|
|
7
|
-
type
|
|
6
|
+
//#region src/PrismicImage.d.ts
|
|
7
|
+
type PrismicImageProps = Omit<ImageProps, "src" | "alt" | "loader"> & {
|
|
8
8
|
/** The Prismic Image field or thumbnail to render. */
|
|
9
9
|
field: ImageFieldImage | null | undefined;
|
|
10
10
|
/**
|
|
@@ -51,7 +51,7 @@ type PrismicNextImageProps = Omit<ImageProps, "src" | "alt" | "loader"> & {
|
|
|
51
51
|
*
|
|
52
52
|
* @see To learn more about `next/image`, see: https://nextjs.org/docs/api-reference/next/image
|
|
53
53
|
*/
|
|
54
|
-
declare const
|
|
54
|
+
declare const PrismicImage: ForwardRefExoticComponent<PropsWithoutRef<PrismicImageProps> & RefAttributes<HTMLImageElement>>;
|
|
55
55
|
//#endregion
|
|
56
|
-
export {
|
|
57
|
-
//# sourceMappingURL=
|
|
56
|
+
export { PrismicImage, PrismicImageProps };
|
|
57
|
+
//# sourceMappingURL=PrismicImage.d.cts.map
|
|
@@ -6,8 +6,8 @@ let react_jsx_runtime = require("react/jsx-runtime");
|
|
|
6
6
|
let next_link = require("next/link");
|
|
7
7
|
next_link = require_rolldown_runtime.__toESM(next_link);
|
|
8
8
|
|
|
9
|
-
//#region src/
|
|
10
|
-
const
|
|
9
|
+
//#region src/PrismicLink.tsx
|
|
10
|
+
const PrismicLink = (0, react.forwardRef)(function PrismicLink$1(props, ref) {
|
|
11
11
|
const { field, document, linkResolver, children, ...restProps } = props;
|
|
12
12
|
const { href: computedHref, rel: computedRel, ...attrs } = (0, _prismicio_client.asLinkAttrs)(field ?? document, {
|
|
13
13
|
linkResolver,
|
|
@@ -27,5 +27,5 @@ const PrismicNextLink = (0, react.forwardRef)(function PrismicNextLink$1(props,
|
|
|
27
27
|
});
|
|
28
28
|
|
|
29
29
|
//#endregion
|
|
30
|
-
exports.
|
|
31
|
-
//# sourceMappingURL=
|
|
30
|
+
exports.PrismicLink = PrismicLink;
|
|
31
|
+
//# sourceMappingURL=PrismicLink.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PrismicLink.cjs","names":["PrismicLink","resolveDefaultExport","Link"],"sources":["../src/PrismicLink.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 PrismicLinkProps = 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 PrismicLink = forwardRef<\n\tHTMLAnchorElement,\n\tPrismicLinkProps\n>(function PrismicLink(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,oCAGX,SAASA,cAAY,OAAO,KAAK;CAClC,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"}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import * as react0 from "react";
|
|
2
2
|
import { ComponentProps } from "react";
|
|
3
|
+
import { AsLinkAttrsConfig, LinkField, LinkResolverFunction, PrismicDocument } from "@prismicio/client";
|
|
3
4
|
import * as next_link0 from "next/link";
|
|
4
5
|
import Link from "next/link";
|
|
5
|
-
import { AsLinkAttrsConfig, LinkField, LinkResolverFunction, PrismicDocument } from "@prismicio/client";
|
|
6
6
|
|
|
7
|
-
//#region src/
|
|
8
|
-
type
|
|
7
|
+
//#region src/PrismicLink.d.ts
|
|
8
|
+
type PrismicLinkProps = Omit<ComponentProps<typeof Link>, "field" | "document" | "href" | "rel"> & {
|
|
9
9
|
linkResolver?: LinkResolverFunction;
|
|
10
10
|
rel?: string | AsLinkAttrsConfig["rel"];
|
|
11
11
|
} & ({
|
|
@@ -21,9 +21,9 @@ type PrismicNextLinkProps = Omit<ComponentProps<typeof Link>, "field" | "documen
|
|
|
21
21
|
document?: never;
|
|
22
22
|
href: ComponentProps<typeof Link>["href"];
|
|
23
23
|
});
|
|
24
|
-
declare const
|
|
24
|
+
declare const PrismicLink: react0.ForwardRefExoticComponent<(Omit<Omit<Omit<react0.AnchorHTMLAttributes<HTMLAnchorElement>, keyof next_link0.LinkProps<any>> & next_link0.LinkProps<any> & {
|
|
25
25
|
children?: React.ReactNode | undefined;
|
|
26
|
-
} & react0.RefAttributes<HTMLAnchorElement>, "
|
|
26
|
+
} & react0.RefAttributes<HTMLAnchorElement>, "rel" | "field" | "href" | "document"> & {
|
|
27
27
|
linkResolver?: LinkResolverFunction;
|
|
28
28
|
rel?: string | AsLinkAttrsConfig["rel"];
|
|
29
29
|
} & {
|
|
@@ -32,7 +32,7 @@ declare const PrismicNextLink: react0.ForwardRefExoticComponent<(Omit<Omit<Omit<
|
|
|
32
32
|
href?: never;
|
|
33
33
|
}, "ref"> | Omit<Omit<Omit<react0.AnchorHTMLAttributes<HTMLAnchorElement>, keyof next_link0.LinkProps<any>> & next_link0.LinkProps<any> & {
|
|
34
34
|
children?: React.ReactNode | undefined;
|
|
35
|
-
} & react0.RefAttributes<HTMLAnchorElement>, "
|
|
35
|
+
} & react0.RefAttributes<HTMLAnchorElement>, "rel" | "field" | "href" | "document"> & {
|
|
36
36
|
linkResolver?: LinkResolverFunction;
|
|
37
37
|
rel?: string | AsLinkAttrsConfig["rel"];
|
|
38
38
|
} & {
|
|
@@ -41,7 +41,7 @@ declare const PrismicNextLink: react0.ForwardRefExoticComponent<(Omit<Omit<Omit<
|
|
|
41
41
|
href?: never;
|
|
42
42
|
}, "ref"> | Omit<Omit<Omit<react0.AnchorHTMLAttributes<HTMLAnchorElement>, keyof next_link0.LinkProps<any>> & next_link0.LinkProps<any> & {
|
|
43
43
|
children?: React.ReactNode | undefined;
|
|
44
|
-
} & react0.RefAttributes<HTMLAnchorElement>, "
|
|
44
|
+
} & react0.RefAttributes<HTMLAnchorElement>, "rel" | "field" | "href" | "document"> & {
|
|
45
45
|
linkResolver?: LinkResolverFunction;
|
|
46
46
|
rel?: string | AsLinkAttrsConfig["rel"];
|
|
47
47
|
} & {
|
|
@@ -50,5 +50,5 @@ declare const PrismicNextLink: react0.ForwardRefExoticComponent<(Omit<Omit<Omit<
|
|
|
50
50
|
href: ComponentProps<typeof Link>["href"];
|
|
51
51
|
}, "ref">) & react0.RefAttributes<HTMLAnchorElement>>;
|
|
52
52
|
//#endregion
|
|
53
|
-
export {
|
|
54
|
-
//# sourceMappingURL=
|
|
53
|
+
export { PrismicLink, PrismicLinkProps };
|
|
54
|
+
//# sourceMappingURL=PrismicLink.d.cts.map
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
const require_rolldown_runtime = require('./_virtual/rolldown_runtime.cjs');
|
|
4
|
+
const require_PrismicImage = require('./PrismicImage.cjs');
|
|
5
|
+
const require_PrismicLink = require('./PrismicLink.cjs');
|
|
6
|
+
let react_jsx_runtime = require("react/jsx-runtime");
|
|
7
|
+
let _prismicio_react = require("@prismicio/react");
|
|
8
|
+
|
|
9
|
+
//#region src/PrismicRichText.tsx
|
|
10
|
+
/**
|
|
11
|
+
* Default Next.js-optimized components for rich text rendering.
|
|
12
|
+
*
|
|
13
|
+
* These components use `<PrismicImage>` and `<PrismicLink>` from
|
|
14
|
+
* `@prismicio/next` for optimized image and link rendering.
|
|
15
|
+
*/
|
|
16
|
+
const defaultComponents = {
|
|
17
|
+
image: ({ node, key }) => {
|
|
18
|
+
const field = {
|
|
19
|
+
url: node.url,
|
|
20
|
+
alt: node.alt,
|
|
21
|
+
dimensions: node.dimensions,
|
|
22
|
+
id: "",
|
|
23
|
+
copyright: node.copyright ?? null,
|
|
24
|
+
edit: {
|
|
25
|
+
x: 0,
|
|
26
|
+
y: 0,
|
|
27
|
+
zoom: 1,
|
|
28
|
+
background: "transparent"
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
32
|
+
className: "block-img",
|
|
33
|
+
children: node.linkTo ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_PrismicLink.PrismicLink, {
|
|
34
|
+
field: node.linkTo,
|
|
35
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_PrismicImage.PrismicImage, {
|
|
36
|
+
field,
|
|
37
|
+
fallbackAlt: ""
|
|
38
|
+
})
|
|
39
|
+
}) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_PrismicImage.PrismicImage, {
|
|
40
|
+
field,
|
|
41
|
+
fallbackAlt: ""
|
|
42
|
+
})
|
|
43
|
+
}, key);
|
|
44
|
+
},
|
|
45
|
+
hyperlink: ({ node, children, key }) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_PrismicLink.PrismicLink, {
|
|
46
|
+
field: node.data,
|
|
47
|
+
children
|
|
48
|
+
}, key)
|
|
49
|
+
};
|
|
50
|
+
/**
|
|
51
|
+
* Renders content from a Prismic rich text field as React components with
|
|
52
|
+
* Next.js-optimized defaults for images and links.
|
|
53
|
+
*
|
|
54
|
+
* @example
|
|
55
|
+
*
|
|
56
|
+
* ```tsx
|
|
57
|
+
* <PrismicRichText field={slice.primary.text} />;
|
|
58
|
+
* ```
|
|
59
|
+
*
|
|
60
|
+
* @see Learn how to style rich text, use custom components, and use labels for
|
|
61
|
+
* custom formatting: {@link https://prismic.io/docs/fields/rich-text}
|
|
62
|
+
*/
|
|
63
|
+
const PrismicRichText = ({ components, ...restProps }) => {
|
|
64
|
+
const mergedComponents = {
|
|
65
|
+
...defaultComponents,
|
|
66
|
+
...components
|
|
67
|
+
};
|
|
68
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_prismicio_react.PrismicRichText, {
|
|
69
|
+
...restProps,
|
|
70
|
+
components: mergedComponents
|
|
71
|
+
});
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
//#endregion
|
|
75
|
+
exports.PrismicRichText = PrismicRichText;
|
|
76
|
+
exports.defaultComponents = defaultComponents;
|
|
77
|
+
//# sourceMappingURL=PrismicRichText.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PrismicRichText.cjs","names":["PrismicLink","PrismicImage","BasePrismicRichText"],"sources":["../src/PrismicRichText.tsx"],"sourcesContent":["\"use client\";\n\nimport type { FC } from \"react\";\nimport {\n\tPrismicRichText as BasePrismicRichText,\n\ttype PrismicRichTextProps as BasePrismicRichTextProps,\n\ttype JSXMapSerializer,\n} from \"@prismicio/react\";\n\nimport { PrismicImage } from \"./PrismicImage\";\nimport { PrismicLink } from \"./PrismicLink\";\n\n/**\n * A map of rich text block types to React Components. It is used to render\n * rich text fields.\n *\n * @see Templating rich text fields {@link https://prismic.io/docs/fields/rich-text}\n */\nexport type RichTextComponents = JSXMapSerializer;\n\n/**\n * Props for `<PrismicRichText>`.\n *\n * This component wraps `@prismicio/react`'s `<PrismicRichText>` with Next.js\n * optimized defaults for images and links.\n */\nexport type PrismicRichTextProps = Omit<\n\tBasePrismicRichTextProps,\n\t\"components\"\n> & {\n\tcomponents?: RichTextComponents;\n};\n\n/**\n * Default Next.js-optimized components for rich text rendering.\n *\n * These components use `<PrismicImage>` and `<PrismicLink>` from\n * `@prismicio/next` for optimized image and link rendering.\n */\nexport const defaultComponents: RichTextComponents = {\n\timage: ({ node, key }) => {\n\t\tconst field = {\n\t\t\turl: node.url,\n\t\t\talt: node.alt,\n\t\t\tdimensions: node.dimensions,\n\t\t\tid: \"\",\n\t\t\tcopyright: node.copyright ?? null,\n\t\t\tedit: { x: 0, y: 0, zoom: 1, background: \"transparent\" },\n\t\t};\n\n\t\treturn (\n\t\t\t<p key={key} className=\"block-img\">\n\t\t\t\t{node.linkTo ? (\n\t\t\t\t\t<PrismicLink field={node.linkTo}>\n\t\t\t\t\t\t<PrismicImage field={field} fallbackAlt=\"\" />\n\t\t\t\t\t</PrismicLink>\n\t\t\t\t) : (\n\t\t\t\t\t<PrismicImage field={field} fallbackAlt=\"\" />\n\t\t\t\t)}\n\t\t\t</p>\n\t\t);\n\t},\n\thyperlink: ({ node, children, key }) => (\n\t\t<PrismicLink key={key} field={node.data}>\n\t\t\t{children}\n\t\t</PrismicLink>\n\t),\n};\n\n/**\n * Renders content from a Prismic rich text field as React components with\n * Next.js-optimized defaults for images and links.\n *\n * @example\n *\n * ```tsx\n * <PrismicRichText field={slice.primary.text} />;\n * ```\n *\n * @see Learn how to style rich text, use custom components, and use labels for\n * custom formatting: {@link https://prismic.io/docs/fields/rich-text}\n */\nexport const PrismicRichText: FC<PrismicRichTextProps> = ({\n\tcomponents,\n\t...restProps\n}) => {\n\tconst mergedComponents = { ...defaultComponents, ...components };\n\treturn <BasePrismicRichText {...restProps} components={mergedComponents} />;\n};\n"],"mappings":";;;;;;;;;;;;;;;AAuCA,MAAa,oBAAwC;CACpD,QAAQ,EAAE,MAAM,UAAU;EACzB,MAAM,QAAQ;GACb,KAAK,KAAK;GACV,KAAK,KAAK;GACV,YAAY,KAAK;GACjB,IAAI;GACJ,WAAW,KAAK,aAAa;GAC7B,MAAM;IAAE,GAAG;IAAG,GAAG;IAAG,MAAM;IAAG,YAAY;IAAe;GACxD;AAED,SACC,2CAAC;GAAY,WAAU;aACrB,KAAK,SACL,2CAACA;IAAY,OAAO,KAAK;cACxB,2CAACC;KAAoB;KAAO,aAAY;MAAK;KAChC,GAEd,2CAACA;IAAoB;IAAO,aAAY;KAAK;KANvC,IAQJ;;CAGN,YAAY,EAAE,MAAM,UAAU,UAC7B,2CAACD;EAAsB,OAAO,KAAK;EACjC;IADgB,IAEJ;CAEf;;;;;;;;;;;;;;AAeD,MAAa,mBAA6C,EACzD,YACA,GAAG,gBACE;CACL,MAAM,mBAAmB;EAAE,GAAG;EAAmB,GAAG;EAAY;AAChE,QAAO,2CAACE;EAAoB,GAAI;EAAW,YAAY;GAAoB"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { FC } from "react";
|
|
2
|
+
import { JSXMapSerializer, PrismicRichTextProps } from "@prismicio/react";
|
|
3
|
+
|
|
4
|
+
//#region src/PrismicRichText.d.ts
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* A map of rich text block types to React Components. It is used to render
|
|
8
|
+
* rich text fields.
|
|
9
|
+
*
|
|
10
|
+
* @see Templating rich text fields {@link https://prismic.io/docs/fields/rich-text}
|
|
11
|
+
*/
|
|
12
|
+
type RichTextComponents = JSXMapSerializer;
|
|
13
|
+
/**
|
|
14
|
+
* Props for `<PrismicRichText>`.
|
|
15
|
+
*
|
|
16
|
+
* This component wraps `@prismicio/react`'s `<PrismicRichText>` with Next.js
|
|
17
|
+
* optimized defaults for images and links.
|
|
18
|
+
*/
|
|
19
|
+
type PrismicRichTextProps$1 = Omit<PrismicRichTextProps, "components"> & {
|
|
20
|
+
components?: RichTextComponents;
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* Default Next.js-optimized components for rich text rendering.
|
|
24
|
+
*
|
|
25
|
+
* These components use `<PrismicImage>` and `<PrismicLink>` from
|
|
26
|
+
* `@prismicio/next` for optimized image and link rendering.
|
|
27
|
+
*/
|
|
28
|
+
declare const defaultComponents: RichTextComponents;
|
|
29
|
+
/**
|
|
30
|
+
* Renders content from a Prismic rich text field as React components with
|
|
31
|
+
* Next.js-optimized defaults for images and links.
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
*
|
|
35
|
+
* ```tsx
|
|
36
|
+
* <PrismicRichText field={slice.primary.text} />;
|
|
37
|
+
* ```
|
|
38
|
+
*
|
|
39
|
+
* @see Learn how to style rich text, use custom components, and use labels for
|
|
40
|
+
* custom formatting: {@link https://prismic.io/docs/fields/rich-text}
|
|
41
|
+
*/
|
|
42
|
+
declare const PrismicRichText: FC<PrismicRichTextProps$1>;
|
|
43
|
+
//#endregion
|
|
44
|
+
export { PrismicRichText, PrismicRichTextProps$1 as PrismicRichTextProps, RichTextComponents, defaultComponents };
|
|
45
|
+
//# sourceMappingURL=PrismicRichText.d.cts.map
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
const require_rolldown_runtime = require('./_virtual/rolldown_runtime.cjs');
|
|
4
|
+
const require_PrismicRichText = require('./PrismicRichText.cjs');
|
|
5
|
+
let react_jsx_runtime = require("react/jsx-runtime");
|
|
6
|
+
let _prismicio_react = require("@prismicio/react");
|
|
7
|
+
|
|
8
|
+
//#region src/PrismicTable.tsx
|
|
9
|
+
/**
|
|
10
|
+
* Renders content from a Prismic table field as React components with
|
|
11
|
+
* Next.js-optimized defaults for images and links in cell content.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
*
|
|
15
|
+
* ```tsx
|
|
16
|
+
* <PrismicTable field={slice.primary.pricing_table} />;
|
|
17
|
+
* ```
|
|
18
|
+
*
|
|
19
|
+
* @see Learn how to style tables and customize table element components:
|
|
20
|
+
* {@link https://prismic.io/docs/fields/table}
|
|
21
|
+
*/
|
|
22
|
+
const PrismicTable = ({ components, ...restProps }) => {
|
|
23
|
+
const mergedComponents = {
|
|
24
|
+
...require_PrismicRichText.defaultComponents,
|
|
25
|
+
...components
|
|
26
|
+
};
|
|
27
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_prismicio_react.PrismicTable, {
|
|
28
|
+
...restProps,
|
|
29
|
+
components: mergedComponents
|
|
30
|
+
});
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
//#endregion
|
|
34
|
+
exports.PrismicTable = PrismicTable;
|
|
35
|
+
//# sourceMappingURL=PrismicTable.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PrismicTable.cjs","names":["defaultComponents","BasePrismicTable"],"sources":["../src/PrismicTable.tsx"],"sourcesContent":["\"use client\";\n\nimport type { ComponentType, FC, ReactNode } from \"react\";\nimport {\n\tPrismicTable as BasePrismicTable,\n\ttype PrismicTableProps as BasePrismicTableProps,\n} from \"@prismicio/react\";\nimport type {\n\tTableField,\n\tTableFieldHead,\n\tTableFieldBody,\n\tTableFieldHeadRow,\n\tTableFieldBodyRow,\n\tTableFieldHeaderCell,\n\tTableFieldDataCell,\n} from \"@prismicio/client\";\n\nimport type { RichTextComponents } from \"./PrismicRichText\";\nimport { defaultComponents } from \"./PrismicRichText\";\n\n/**\n * Custom components for rendering table elements.\n */\nexport type TableComponents = {\n\ttable?: ComponentType<{ table: TableField<\"filled\">; children: ReactNode }>;\n\tthead?: ComponentType<{ head: TableFieldHead; children: ReactNode }>;\n\ttbody?: ComponentType<{ body: TableFieldBody; children: ReactNode }>;\n\ttr?: ComponentType<{\n\t\trow: TableFieldHeadRow | TableFieldBodyRow;\n\t\tchildren: ReactNode;\n\t}>;\n\tth?: ComponentType<{ cell: TableFieldHeaderCell; children: ReactNode }>;\n\ttd?: ComponentType<{ cell: TableFieldDataCell; children: ReactNode }>;\n};\n\n/**\n * Props for `<PrismicTable>`.\n *\n * This component wraps `@prismicio/react`'s `<PrismicTable>` with Next.js\n * optimized defaults for images and links in cell content.\n */\nexport type PrismicTableProps = Omit<BasePrismicTableProps, \"components\"> & {\n\tcomponents?: RichTextComponents & TableComponents;\n};\n\n/**\n * Renders content from a Prismic table field as React components with\n * Next.js-optimized defaults for images and links in cell content.\n *\n * @example\n *\n * ```tsx\n * <PrismicTable field={slice.primary.pricing_table} />;\n * ```\n *\n * @see Learn how to style tables and customize table element components:\n * {@link https://prismic.io/docs/fields/table}\n */\nexport const PrismicTable: FC<PrismicTableProps> = ({\n\tcomponents,\n\t...restProps\n}) => {\n\tconst mergedComponents = { ...defaultComponents, ...components };\n\treturn <BasePrismicTable {...restProps} components={mergedComponents} />;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AA0DA,MAAa,gBAAuC,EACnD,YACA,GAAG,gBACE;CACL,MAAM,mBAAmB;EAAE,GAAGA;EAAmB,GAAG;EAAY;AAChE,QAAO,2CAACC;EAAiB,GAAI;EAAW,YAAY;GAAoB"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { RichTextComponents } from "./PrismicRichText.cjs";
|
|
2
|
+
import { ComponentType, FC, ReactNode } from "react";
|
|
3
|
+
import { TableField, TableFieldBody, TableFieldBodyRow, TableFieldDataCell, TableFieldHead, TableFieldHeadRow, TableFieldHeaderCell } from "@prismicio/client";
|
|
4
|
+
import { PrismicTableProps } from "@prismicio/react";
|
|
5
|
+
|
|
6
|
+
//#region src/PrismicTable.d.ts
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Custom components for rendering table elements.
|
|
10
|
+
*/
|
|
11
|
+
type TableComponents = {
|
|
12
|
+
table?: ComponentType<{
|
|
13
|
+
table: TableField<"filled">;
|
|
14
|
+
children: ReactNode;
|
|
15
|
+
}>;
|
|
16
|
+
thead?: ComponentType<{
|
|
17
|
+
head: TableFieldHead;
|
|
18
|
+
children: ReactNode;
|
|
19
|
+
}>;
|
|
20
|
+
tbody?: ComponentType<{
|
|
21
|
+
body: TableFieldBody;
|
|
22
|
+
children: ReactNode;
|
|
23
|
+
}>;
|
|
24
|
+
tr?: ComponentType<{
|
|
25
|
+
row: TableFieldHeadRow | TableFieldBodyRow;
|
|
26
|
+
children: ReactNode;
|
|
27
|
+
}>;
|
|
28
|
+
th?: ComponentType<{
|
|
29
|
+
cell: TableFieldHeaderCell;
|
|
30
|
+
children: ReactNode;
|
|
31
|
+
}>;
|
|
32
|
+
td?: ComponentType<{
|
|
33
|
+
cell: TableFieldDataCell;
|
|
34
|
+
children: ReactNode;
|
|
35
|
+
}>;
|
|
36
|
+
};
|
|
37
|
+
/**
|
|
38
|
+
* Props for `<PrismicTable>`.
|
|
39
|
+
*
|
|
40
|
+
* This component wraps `@prismicio/react`'s `<PrismicTable>` with Next.js
|
|
41
|
+
* optimized defaults for images and links in cell content.
|
|
42
|
+
*/
|
|
43
|
+
type PrismicTableProps$1 = Omit<PrismicTableProps, "components"> & {
|
|
44
|
+
components?: RichTextComponents & TableComponents;
|
|
45
|
+
};
|
|
46
|
+
/**
|
|
47
|
+
* Renders content from a Prismic table field as React components with
|
|
48
|
+
* Next.js-optimized defaults for images and links in cell content.
|
|
49
|
+
*
|
|
50
|
+
* @example
|
|
51
|
+
*
|
|
52
|
+
* ```tsx
|
|
53
|
+
* <PrismicTable field={slice.primary.pricing_table} />;
|
|
54
|
+
* ```
|
|
55
|
+
*
|
|
56
|
+
* @see Learn how to style tables and customize table element components:
|
|
57
|
+
* {@link https://prismic.io/docs/fields/table}
|
|
58
|
+
*/
|
|
59
|
+
declare const PrismicTable: FC<PrismicTableProps$1>;
|
|
60
|
+
//#endregion
|
|
61
|
+
export { PrismicTable, PrismicTableProps$1 as PrismicTableProps, TableComponents };
|
|
62
|
+
//# sourceMappingURL=PrismicTable.d.cts.map
|
package/dist/index.cjs
CHANGED
|
@@ -1,19 +1,46 @@
|
|
|
1
|
+
const require_rolldown_runtime = require('./_virtual/rolldown_runtime.cjs');
|
|
1
2
|
const require_exitPreview = require('./exitPreview.cjs');
|
|
2
3
|
const require_PrismicPreview = require('./PrismicPreview.cjs');
|
|
3
|
-
const
|
|
4
|
+
const require_imgixLoader = require('./imgixLoader.cjs');
|
|
5
|
+
const require_PrismicImage = require('./PrismicImage.cjs');
|
|
6
|
+
const require_PrismicLink = require('./PrismicLink.cjs');
|
|
4
7
|
const require_enableAutoPreviews = require('./enableAutoPreviews.cjs');
|
|
5
8
|
const require_redirectToPreviewURL = require('./redirectToPreviewURL.cjs');
|
|
6
|
-
const require_imgixLoader = require('./imgixLoader.cjs');
|
|
7
|
-
const require_PrismicNextImage = require('./PrismicNextImage.cjs');
|
|
8
9
|
const require_getSlices = require('./getSlices.cjs');
|
|
9
10
|
const require_SliceSimulator = require('./SliceSimulator.cjs');
|
|
10
11
|
const require_createLocaleRedirect = require('./createLocaleRedirect.cjs');
|
|
12
|
+
const require_PrismicRichText = require('./PrismicRichText.cjs');
|
|
13
|
+
const require_PrismicTable = require('./PrismicTable.cjs');
|
|
14
|
+
let _prismicio_react = require("@prismicio/react");
|
|
11
15
|
|
|
12
|
-
exports.
|
|
13
|
-
exports.
|
|
16
|
+
exports.PrismicImage = require_PrismicImage.PrismicImage;
|
|
17
|
+
exports.PrismicLink = require_PrismicLink.PrismicLink;
|
|
18
|
+
exports.PrismicNextImage = require_PrismicImage.PrismicImage;
|
|
19
|
+
exports.PrismicNextLink = require_PrismicLink.PrismicLink;
|
|
14
20
|
exports.PrismicPreview = require_PrismicPreview.PrismicPreview;
|
|
21
|
+
exports.PrismicRichText = require_PrismicRichText.PrismicRichText;
|
|
22
|
+
exports.PrismicTable = require_PrismicTable.PrismicTable;
|
|
23
|
+
Object.defineProperty(exports, 'PrismicText', {
|
|
24
|
+
enumerable: true,
|
|
25
|
+
get: function () {
|
|
26
|
+
return _prismicio_react.PrismicText;
|
|
27
|
+
}
|
|
28
|
+
});
|
|
15
29
|
exports.SliceSimulator = require_SliceSimulator.SliceSimulator;
|
|
30
|
+
Object.defineProperty(exports, 'SliceZone', {
|
|
31
|
+
enumerable: true,
|
|
32
|
+
get: function () {
|
|
33
|
+
return _prismicio_react.SliceZone;
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
Object.defineProperty(exports, 'TODOSliceComponent', {
|
|
37
|
+
enumerable: true,
|
|
38
|
+
get: function () {
|
|
39
|
+
return _prismicio_react.TODOSliceComponent;
|
|
40
|
+
}
|
|
41
|
+
});
|
|
16
42
|
exports.createLocaleRedirect = require_createLocaleRedirect.createLocaleRedirect;
|
|
43
|
+
exports.defaultComponents = require_PrismicRichText.defaultComponents;
|
|
17
44
|
exports.enableAutoPreviews = require_enableAutoPreviews.enableAutoPreviews;
|
|
18
45
|
exports.exitPreview = require_exitPreview.exitPreview;
|
|
19
46
|
exports.getSlices = require_getSlices.getSlices;
|
package/dist/index.d.cts
CHANGED
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
import { exitPreview } from "./exitPreview.cjs";
|
|
2
2
|
import { PrismicPreview, PrismicPreviewProps } from "./PrismicPreview.cjs";
|
|
3
|
-
import {
|
|
3
|
+
import { PrismicImage, PrismicImageProps } from "./PrismicImage.cjs";
|
|
4
|
+
import { PrismicLink, PrismicLinkProps } from "./PrismicLink.cjs";
|
|
4
5
|
import { EnableAutoPreviewsConfig, enableAutoPreviews } from "./enableAutoPreviews.cjs";
|
|
5
6
|
import { CreateClientConfig } from "./types.cjs";
|
|
6
7
|
import { RedirectToPreviewURLConfig, redirectToPreviewURL } from "./redirectToPreviewURL.cjs";
|
|
7
|
-
import { PrismicNextImage, PrismicNextImageProps } from "./PrismicNextImage.cjs";
|
|
8
8
|
import { SliceSimulator, SliceSimulatorParams, SliceSimulatorProps } from "./SliceSimulator.cjs";
|
|
9
9
|
import { getSlices } from "./getSlices.cjs";
|
|
10
10
|
import { imgixLoader } from "./imgixLoader.cjs";
|
|
11
11
|
import { CreateLocaleRedirectConfig, createLocaleRedirect } from "./createLocaleRedirect.cjs";
|
|
12
|
-
|
|
12
|
+
import { PrismicRichText, PrismicRichTextProps, RichTextComponents, defaultComponents } from "./PrismicRichText.cjs";
|
|
13
|
+
import { PrismicTable, PrismicTableProps, TableComponents } from "./PrismicTable.cjs";
|
|
14
|
+
import { PrismicText, PrismicTextProps, SliceComponentProps, SliceComponentType, SliceLike, SliceLikeGraphQL, SliceLikeRestV2, SliceZone, SliceZoneLike, SliceZoneProps, TODOSliceComponent } from "@prismicio/react";
|
|
15
|
+
export { type CreateClientConfig, type CreateLocaleRedirectConfig, type EnableAutoPreviewsConfig, PrismicImage, type PrismicImageProps, PrismicLink, type PrismicLinkProps, PrismicImage as PrismicNextImage, type PrismicImageProps as PrismicNextImageProps, PrismicLink as PrismicNextLink, type PrismicLinkProps as PrismicNextLinkProps, PrismicPreview, type PrismicPreviewProps, PrismicRichText, type PrismicRichTextProps, PrismicTable, type PrismicTableProps, PrismicText, type PrismicTextProps, type RedirectToPreviewURLConfig, type RichTextComponents, type SliceComponentProps, type SliceComponentType, type SliceLike, type SliceLikeGraphQL, type SliceLikeRestV2, SliceSimulator, type SliceSimulatorParams, type SliceSimulatorProps, SliceZone, type SliceZoneLike, type SliceZoneProps, TODOSliceComponent, type TableComponents, createLocaleRedirect, defaultComponents, enableAutoPreviews, exitPreview, getSlices, imgixLoader, redirectToPreviewURL };
|
package/dist/package.cjs
CHANGED
package/dist/pages.cjs
CHANGED
|
@@ -1,19 +1,46 @@
|
|
|
1
|
-
const
|
|
1
|
+
const require_rolldown_runtime = require('./_virtual/rolldown_runtime.cjs');
|
|
2
2
|
const require_imgixLoader = require('./imgixLoader.cjs');
|
|
3
|
-
const
|
|
3
|
+
const require_PrismicImage = require('./PrismicImage.cjs');
|
|
4
|
+
const require_PrismicLink = require('./PrismicLink.cjs');
|
|
4
5
|
const require_createLocaleRedirect = require('./createLocaleRedirect.cjs');
|
|
6
|
+
const require_PrismicRichText = require('./PrismicRichText.cjs');
|
|
7
|
+
const require_PrismicTable = require('./PrismicTable.cjs');
|
|
5
8
|
const require_SliceSimulator = require('./pages/SliceSimulator.cjs');
|
|
6
9
|
const require_PrismicPreview = require('./pages/PrismicPreview.cjs');
|
|
7
10
|
const require_enableAutoPreviews = require('./pages/enableAutoPreviews.cjs');
|
|
8
11
|
const require_redirectToPreviewURL = require('./pages/redirectToPreviewURL.cjs');
|
|
9
12
|
const require_exitPreview = require('./pages/exitPreview.cjs');
|
|
10
13
|
const require_setPreviewData = require('./pages/setPreviewData.cjs');
|
|
14
|
+
let _prismicio_react = require("@prismicio/react");
|
|
11
15
|
|
|
12
|
-
exports.
|
|
13
|
-
exports.
|
|
16
|
+
exports.PrismicImage = require_PrismicImage.PrismicImage;
|
|
17
|
+
exports.PrismicLink = require_PrismicLink.PrismicLink;
|
|
18
|
+
exports.PrismicNextImage = require_PrismicImage.PrismicImage;
|
|
19
|
+
exports.PrismicNextLink = require_PrismicLink.PrismicLink;
|
|
14
20
|
exports.PrismicPreview = require_PrismicPreview.PrismicPreview;
|
|
21
|
+
exports.PrismicRichText = require_PrismicRichText.PrismicRichText;
|
|
22
|
+
exports.PrismicTable = require_PrismicTable.PrismicTable;
|
|
23
|
+
Object.defineProperty(exports, 'PrismicText', {
|
|
24
|
+
enumerable: true,
|
|
25
|
+
get: function () {
|
|
26
|
+
return _prismicio_react.PrismicText;
|
|
27
|
+
}
|
|
28
|
+
});
|
|
15
29
|
exports.SliceSimulator = require_SliceSimulator.SliceSimulator;
|
|
30
|
+
Object.defineProperty(exports, 'SliceZone', {
|
|
31
|
+
enumerable: true,
|
|
32
|
+
get: function () {
|
|
33
|
+
return _prismicio_react.SliceZone;
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
Object.defineProperty(exports, 'TODOSliceComponent', {
|
|
37
|
+
enumerable: true,
|
|
38
|
+
get: function () {
|
|
39
|
+
return _prismicio_react.TODOSliceComponent;
|
|
40
|
+
}
|
|
41
|
+
});
|
|
16
42
|
exports.createLocaleRedirect = require_createLocaleRedirect.createLocaleRedirect;
|
|
43
|
+
exports.defaultComponents = require_PrismicRichText.defaultComponents;
|
|
17
44
|
exports.enableAutoPreviews = require_enableAutoPreviews.enableAutoPreviews;
|
|
18
45
|
exports.exitPreview = require_exitPreview.exitPreview;
|
|
19
46
|
exports.imgixLoader = require_imgixLoader.imgixLoader;
|
package/dist/pages.d.cts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { PrismicImage, PrismicImageProps } from "./PrismicImage.cjs";
|
|
2
|
+
import { PrismicLink, PrismicLinkProps } from "./PrismicLink.cjs";
|
|
3
3
|
import { imgixLoader } from "./imgixLoader.cjs";
|
|
4
4
|
import { CreateLocaleRedirectConfig, createLocaleRedirect } from "./createLocaleRedirect.cjs";
|
|
5
|
+
import { PrismicRichText, PrismicRichTextProps, RichTextComponents, defaultComponents } from "./PrismicRichText.cjs";
|
|
6
|
+
import { PrismicTable, PrismicTableProps, TableComponents } from "./PrismicTable.cjs";
|
|
5
7
|
import { SliceSimulator, SliceSimulatorProps, SliceSimulatorSliceZoneProps } from "./pages/SliceSimulator.cjs";
|
|
6
8
|
import { PrismicPreview, PrismicPreviewProps } from "./pages/PrismicPreview.cjs";
|
|
7
9
|
import { CreateClientConfig } from "./pages/types.cjs";
|
|
@@ -9,4 +11,5 @@ import { EnableAutoPreviewsConfig, enableAutoPreviews } from "./pages/enableAuto
|
|
|
9
11
|
import { RedirectToPreviewURLConfig, redirectToPreviewURL } from "./pages/redirectToPreviewURL.cjs";
|
|
10
12
|
import { ExitPreviewAPIRouteConfig, exitPreview } from "./pages/exitPreview.cjs";
|
|
11
13
|
import { SetPreviewDataConfig, setPreviewData } from "./pages/setPreviewData.cjs";
|
|
12
|
-
|
|
14
|
+
import { PrismicText, PrismicTextProps, SliceComponentProps, SliceComponentType, SliceLike, SliceLikeGraphQL, SliceLikeRestV2, SliceZone, SliceZoneLike, SliceZoneProps, TODOSliceComponent } from "@prismicio/react";
|
|
15
|
+
export { type CreateClientConfig, type CreateLocaleRedirectConfig, type EnableAutoPreviewsConfig, type ExitPreviewAPIRouteConfig, PrismicImage, type PrismicImageProps, PrismicLink, type PrismicLinkProps, PrismicImage as PrismicNextImage, type PrismicImageProps as PrismicNextImageProps, PrismicLink as PrismicNextLink, type PrismicLinkProps as PrismicNextLinkProps, PrismicPreview, type PrismicPreviewProps, PrismicRichText, type PrismicRichTextProps, PrismicTable, type PrismicTableProps, PrismicText, type PrismicTextProps, type RedirectToPreviewURLConfig, type RichTextComponents, type SetPreviewDataConfig, type SliceComponentProps, type SliceComponentType, type SliceLike, type SliceLikeGraphQL, type SliceLikeRestV2, SliceSimulator, type SliceSimulatorProps, type SliceSimulatorSliceZoneProps, SliceZone, type SliceZoneLike, type SliceZoneProps, TODOSliceComponent, type TableComponents, createLocaleRedirect, defaultComponents, enableAutoPreviews, exitPreview, imgixLoader, redirectToPreviewURL, setPreviewData };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@prismicio/next",
|
|
3
|
-
"version": "2.2.0-
|
|
3
|
+
"version": "2.2.0-pr.123.0d5ddd7",
|
|
4
4
|
"description": "Helpers to integrate Prismic into Next.js apps",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"typescript",
|
|
@@ -55,13 +55,14 @@
|
|
|
55
55
|
"types": "tsc --noEmit"
|
|
56
56
|
},
|
|
57
57
|
"dependencies": {
|
|
58
|
+
"@prismicio/react": "^3",
|
|
58
59
|
"@prismicio/simulator": "^0.2.0",
|
|
59
60
|
"imgix-url-builder": "^0.0.5",
|
|
60
61
|
"lz-string": "^1.5.0"
|
|
61
62
|
},
|
|
62
63
|
"devDependencies": {
|
|
63
64
|
"@playwright/test": "^1.49.1",
|
|
64
|
-
"@prismicio/client": "^7.
|
|
65
|
+
"@prismicio/client": "^7.21.3",
|
|
65
66
|
"@trivago/prettier-plugin-sort-imports": "^6.0.2",
|
|
66
67
|
"@types/node": "^22.10.2",
|
|
67
68
|
"@types/react": "^19.2.3",
|
|
@@ -33,7 +33,7 @@ const castInt = (input: string | number | undefined): number | undefined => {
|
|
|
33
33
|
}
|
|
34
34
|
};
|
|
35
35
|
|
|
36
|
-
export type
|
|
36
|
+
export type PrismicImageProps = Omit<
|
|
37
37
|
ImageProps,
|
|
38
38
|
"src" | "alt" | "loader"
|
|
39
39
|
> & {
|
|
@@ -90,10 +90,10 @@ export type PrismicNextImageProps = Omit<
|
|
|
90
90
|
* @see To learn more about `next/image`, see: https://nextjs.org/docs/api-reference/next/image
|
|
91
91
|
*/
|
|
92
92
|
// The type annotation is necessary to avoid a type reference issue.
|
|
93
|
-
export const
|
|
94
|
-
PropsWithoutRef<
|
|
95
|
-
> = forwardRef<HTMLImageElement,
|
|
96
|
-
function
|
|
93
|
+
export const PrismicImage: ForwardRefExoticComponent<
|
|
94
|
+
PropsWithoutRef<PrismicImageProps> & RefAttributes<HTMLImageElement>
|
|
95
|
+
> = forwardRef<HTMLImageElement, PrismicImageProps>(
|
|
96
|
+
function PrismicImage(
|
|
97
97
|
{
|
|
98
98
|
field,
|
|
99
99
|
imgixParams = {},
|
|
@@ -111,7 +111,7 @@ export const PrismicNextImage: ForwardRefExoticComponent<
|
|
|
111
111
|
if (process.env.NODE_ENV === "development") {
|
|
112
112
|
if (typeof alt === "string" && alt !== "") {
|
|
113
113
|
console.warn(
|
|
114
|
-
`[
|
|
114
|
+
`[PrismicImage] The "alt" prop can only be used to declare an image as decorative by passing an empty string (alt="") but was provided a non-empty string. You can resolve this warning by removing the "alt" prop or changing it to alt="". For more details, see ${devMsg(
|
|
115
115
|
"alt-must-be-an-empty-string",
|
|
116
116
|
)}`,
|
|
117
117
|
);
|
|
@@ -119,7 +119,7 @@ export const PrismicNextImage: ForwardRefExoticComponent<
|
|
|
119
119
|
|
|
120
120
|
if (typeof fallbackAlt === "string" && fallbackAlt !== "") {
|
|
121
121
|
console.warn(
|
|
122
|
-
`[
|
|
122
|
+
`[PrismicImage] The "fallbackAlt" prop can only be used to declare an image as decorative by passing an empty string (fallbackAlt="") but was provided a non-empty string. You can resolve this warning by removing the "fallbackAlt" prop or changing it to fallbackAlt="". For more details, see ${devMsg(
|
|
123
123
|
"alt-must-be-an-empty-string",
|
|
124
124
|
)}`,
|
|
125
125
|
);
|
|
@@ -162,7 +162,7 @@ export const PrismicNextImage: ForwardRefExoticComponent<
|
|
|
162
162
|
typeof resolvedAlt !== "string"
|
|
163
163
|
) {
|
|
164
164
|
console.error(
|
|
165
|
-
`[
|
|
165
|
+
`[PrismicImage] 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=""\`.`,
|
|
166
166
|
src,
|
|
167
167
|
);
|
|
168
168
|
}
|
|
@@ -12,7 +12,7 @@ import {
|
|
|
12
12
|
|
|
13
13
|
import { resolveDefaultExport } from "./lib/resolveDefaultExport";
|
|
14
14
|
|
|
15
|
-
export type
|
|
15
|
+
export type PrismicLinkProps = Omit<
|
|
16
16
|
ComponentProps<typeof Link>,
|
|
17
17
|
"field" | "document" | "href" | "rel"
|
|
18
18
|
> & {
|
|
@@ -36,10 +36,10 @@ export type PrismicNextLinkProps = Omit<
|
|
|
36
36
|
}
|
|
37
37
|
);
|
|
38
38
|
|
|
39
|
-
export const
|
|
39
|
+
export const PrismicLink = forwardRef<
|
|
40
40
|
HTMLAnchorElement,
|
|
41
|
-
|
|
42
|
-
>(function
|
|
41
|
+
PrismicLinkProps
|
|
42
|
+
>(function PrismicLink(props, ref) {
|
|
43
43
|
const { field, document, linkResolver, children, ...restProps } = props;
|
|
44
44
|
const {
|
|
45
45
|
href: computedHref,
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import type { FC } from "react";
|
|
4
|
+
import {
|
|
5
|
+
PrismicRichText as BasePrismicRichText,
|
|
6
|
+
type PrismicRichTextProps as BasePrismicRichTextProps,
|
|
7
|
+
type JSXMapSerializer,
|
|
8
|
+
} from "@prismicio/react";
|
|
9
|
+
|
|
10
|
+
import { PrismicImage } from "./PrismicImage";
|
|
11
|
+
import { PrismicLink } from "./PrismicLink";
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* A map of rich text block types to React Components. It is used to render
|
|
15
|
+
* rich text fields.
|
|
16
|
+
*
|
|
17
|
+
* @see Templating rich text fields {@link https://prismic.io/docs/fields/rich-text}
|
|
18
|
+
*/
|
|
19
|
+
export type RichTextComponents = JSXMapSerializer;
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Props for `<PrismicRichText>`.
|
|
23
|
+
*
|
|
24
|
+
* This component wraps `@prismicio/react`'s `<PrismicRichText>` with Next.js
|
|
25
|
+
* optimized defaults for images and links.
|
|
26
|
+
*/
|
|
27
|
+
export type PrismicRichTextProps = Omit<
|
|
28
|
+
BasePrismicRichTextProps,
|
|
29
|
+
"components"
|
|
30
|
+
> & {
|
|
31
|
+
components?: RichTextComponents;
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Default Next.js-optimized components for rich text rendering.
|
|
36
|
+
*
|
|
37
|
+
* These components use `<PrismicImage>` and `<PrismicLink>` from
|
|
38
|
+
* `@prismicio/next` for optimized image and link rendering.
|
|
39
|
+
*/
|
|
40
|
+
export const defaultComponents: RichTextComponents = {
|
|
41
|
+
image: ({ node, key }) => {
|
|
42
|
+
const field = {
|
|
43
|
+
url: node.url,
|
|
44
|
+
alt: node.alt,
|
|
45
|
+
dimensions: node.dimensions,
|
|
46
|
+
id: "",
|
|
47
|
+
copyright: node.copyright ?? null,
|
|
48
|
+
edit: { x: 0, y: 0, zoom: 1, background: "transparent" },
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
return (
|
|
52
|
+
<p key={key} className="block-img">
|
|
53
|
+
{node.linkTo ? (
|
|
54
|
+
<PrismicLink field={node.linkTo}>
|
|
55
|
+
<PrismicImage field={field} fallbackAlt="" />
|
|
56
|
+
</PrismicLink>
|
|
57
|
+
) : (
|
|
58
|
+
<PrismicImage field={field} fallbackAlt="" />
|
|
59
|
+
)}
|
|
60
|
+
</p>
|
|
61
|
+
);
|
|
62
|
+
},
|
|
63
|
+
hyperlink: ({ node, children, key }) => (
|
|
64
|
+
<PrismicLink key={key} field={node.data}>
|
|
65
|
+
{children}
|
|
66
|
+
</PrismicLink>
|
|
67
|
+
),
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Renders content from a Prismic rich text field as React components with
|
|
72
|
+
* Next.js-optimized defaults for images and links.
|
|
73
|
+
*
|
|
74
|
+
* @example
|
|
75
|
+
*
|
|
76
|
+
* ```tsx
|
|
77
|
+
* <PrismicRichText field={slice.primary.text} />;
|
|
78
|
+
* ```
|
|
79
|
+
*
|
|
80
|
+
* @see Learn how to style rich text, use custom components, and use labels for
|
|
81
|
+
* custom formatting: {@link https://prismic.io/docs/fields/rich-text}
|
|
82
|
+
*/
|
|
83
|
+
export const PrismicRichText: FC<PrismicRichTextProps> = ({
|
|
84
|
+
components,
|
|
85
|
+
...restProps
|
|
86
|
+
}) => {
|
|
87
|
+
const mergedComponents = { ...defaultComponents, ...components };
|
|
88
|
+
return <BasePrismicRichText {...restProps} components={mergedComponents} />;
|
|
89
|
+
};
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import type { ComponentType, FC, ReactNode } from "react";
|
|
4
|
+
import {
|
|
5
|
+
PrismicTable as BasePrismicTable,
|
|
6
|
+
type PrismicTableProps as BasePrismicTableProps,
|
|
7
|
+
} from "@prismicio/react";
|
|
8
|
+
import type {
|
|
9
|
+
TableField,
|
|
10
|
+
TableFieldHead,
|
|
11
|
+
TableFieldBody,
|
|
12
|
+
TableFieldHeadRow,
|
|
13
|
+
TableFieldBodyRow,
|
|
14
|
+
TableFieldHeaderCell,
|
|
15
|
+
TableFieldDataCell,
|
|
16
|
+
} from "@prismicio/client";
|
|
17
|
+
|
|
18
|
+
import type { RichTextComponents } from "./PrismicRichText";
|
|
19
|
+
import { defaultComponents } from "./PrismicRichText";
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Custom components for rendering table elements.
|
|
23
|
+
*/
|
|
24
|
+
export type TableComponents = {
|
|
25
|
+
table?: ComponentType<{ table: TableField<"filled">; children: ReactNode }>;
|
|
26
|
+
thead?: ComponentType<{ head: TableFieldHead; children: ReactNode }>;
|
|
27
|
+
tbody?: ComponentType<{ body: TableFieldBody; children: ReactNode }>;
|
|
28
|
+
tr?: ComponentType<{
|
|
29
|
+
row: TableFieldHeadRow | TableFieldBodyRow;
|
|
30
|
+
children: ReactNode;
|
|
31
|
+
}>;
|
|
32
|
+
th?: ComponentType<{ cell: TableFieldHeaderCell; children: ReactNode }>;
|
|
33
|
+
td?: ComponentType<{ cell: TableFieldDataCell; children: ReactNode }>;
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Props for `<PrismicTable>`.
|
|
38
|
+
*
|
|
39
|
+
* This component wraps `@prismicio/react`'s `<PrismicTable>` with Next.js
|
|
40
|
+
* optimized defaults for images and links in cell content.
|
|
41
|
+
*/
|
|
42
|
+
export type PrismicTableProps = Omit<BasePrismicTableProps, "components"> & {
|
|
43
|
+
components?: RichTextComponents & TableComponents;
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Renders content from a Prismic table field as React components with
|
|
48
|
+
* Next.js-optimized defaults for images and links in cell content.
|
|
49
|
+
*
|
|
50
|
+
* @example
|
|
51
|
+
*
|
|
52
|
+
* ```tsx
|
|
53
|
+
* <PrismicTable field={slice.primary.pricing_table} />;
|
|
54
|
+
* ```
|
|
55
|
+
*
|
|
56
|
+
* @see Learn how to style tables and customize table element components:
|
|
57
|
+
* {@link https://prismic.io/docs/fields/table}
|
|
58
|
+
*/
|
|
59
|
+
export const PrismicTable: FC<PrismicTableProps> = ({
|
|
60
|
+
components,
|
|
61
|
+
...restProps
|
|
62
|
+
}) => {
|
|
63
|
+
const mergedComponents = { ...defaultComponents, ...components };
|
|
64
|
+
return <BasePrismicTable {...restProps} components={mergedComponents} />;
|
|
65
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @deprecated Use `PrismicImage` instead.
|
|
3
|
+
*/
|
|
4
|
+
export { PrismicImage as PrismicNextImage } from "./PrismicImage";
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* @deprecated Use `PrismicImageProps` instead.
|
|
8
|
+
*/
|
|
9
|
+
export type { PrismicImageProps as PrismicNextImageProps } from "./PrismicImage";
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* @deprecated Use `PrismicLink` instead.
|
|
13
|
+
*/
|
|
14
|
+
export { PrismicLink as PrismicNextLink } from "./PrismicLink";
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* @deprecated Use `PrismicLinkProps` instead.
|
|
18
|
+
*/
|
|
19
|
+
export type { PrismicLinkProps as PrismicNextLinkProps } from "./PrismicLink";
|
package/src/index.ts
CHANGED
|
@@ -3,8 +3,16 @@ export { exitPreview } from "./exitPreview";
|
|
|
3
3
|
export { PrismicPreview } from "./PrismicPreview";
|
|
4
4
|
export type { PrismicPreviewProps } from "./PrismicPreview";
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
export
|
|
6
|
+
// New names
|
|
7
|
+
export { PrismicImage } from "./PrismicImage";
|
|
8
|
+
export type { PrismicImageProps } from "./PrismicImage";
|
|
9
|
+
|
|
10
|
+
export { PrismicLink } from "./PrismicLink";
|
|
11
|
+
export type { PrismicLinkProps } from "./PrismicLink";
|
|
12
|
+
|
|
13
|
+
// Deprecated aliases
|
|
14
|
+
export { PrismicNextImage, PrismicNextLink } from "./deprecated";
|
|
15
|
+
export type { PrismicNextImageProps, PrismicNextLinkProps } from "./deprecated";
|
|
8
16
|
|
|
9
17
|
export { enableAutoPreviews } from "./enableAutoPreviews";
|
|
10
18
|
export type { EnableAutoPreviewsConfig } from "./enableAutoPreviews";
|
|
@@ -12,9 +20,6 @@ export type { EnableAutoPreviewsConfig } from "./enableAutoPreviews";
|
|
|
12
20
|
export { redirectToPreviewURL } from "./redirectToPreviewURL";
|
|
13
21
|
export type { RedirectToPreviewURLConfig } from "./redirectToPreviewURL";
|
|
14
22
|
|
|
15
|
-
export { PrismicNextImage } from "./PrismicNextImage";
|
|
16
|
-
export type { PrismicNextImageProps } from "./PrismicNextImage";
|
|
17
|
-
|
|
18
23
|
export { SliceSimulator } from "./SliceSimulator";
|
|
19
24
|
export type {
|
|
20
25
|
SliceSimulatorProps,
|
|
@@ -29,3 +34,25 @@ export type { CreateClientConfig } from "./types";
|
|
|
29
34
|
|
|
30
35
|
export { createLocaleRedirect } from "./createLocaleRedirect";
|
|
31
36
|
export type { CreateLocaleRedirectConfig } from "./createLocaleRedirect";
|
|
37
|
+
|
|
38
|
+
// Re-exports from @prismicio/react
|
|
39
|
+
export { PrismicText } from "@prismicio/react";
|
|
40
|
+
export type { PrismicTextProps } from "@prismicio/react";
|
|
41
|
+
|
|
42
|
+
export { SliceZone, TODOSliceComponent } from "@prismicio/react";
|
|
43
|
+
export type {
|
|
44
|
+
SliceComponentProps,
|
|
45
|
+
SliceComponentType,
|
|
46
|
+
SliceLike,
|
|
47
|
+
SliceLikeGraphQL,
|
|
48
|
+
SliceLikeRestV2,
|
|
49
|
+
SliceZoneLike,
|
|
50
|
+
SliceZoneProps,
|
|
51
|
+
} from "@prismicio/react";
|
|
52
|
+
|
|
53
|
+
// Next.js-specific PrismicRichText and PrismicTable
|
|
54
|
+
export { PrismicRichText, defaultComponents } from "./PrismicRichText";
|
|
55
|
+
export type { PrismicRichTextProps, RichTextComponents } from "./PrismicRichText";
|
|
56
|
+
|
|
57
|
+
export { PrismicTable } from "./PrismicTable";
|
|
58
|
+
export type { PrismicTableProps, TableComponents } from "./PrismicTable";
|
package/src/pages/index.ts
CHANGED
|
@@ -1,8 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
export {
|
|
1
|
+
// New names
|
|
2
|
+
export { PrismicImage } from "../PrismicImage";
|
|
3
|
+
export type { PrismicImageProps } from "../PrismicImage";
|
|
3
4
|
|
|
4
|
-
export {
|
|
5
|
-
export {
|
|
5
|
+
export { PrismicLink } from "../PrismicLink";
|
|
6
|
+
export type { PrismicLinkProps } from "../PrismicLink";
|
|
7
|
+
|
|
8
|
+
// Deprecated aliases
|
|
9
|
+
export { PrismicNextImage, PrismicNextLink } from "../deprecated";
|
|
10
|
+
export type { PrismicNextImageProps, PrismicNextLinkProps } from "../deprecated";
|
|
6
11
|
|
|
7
12
|
export { SliceSimulator } from "./SliceSimulator";
|
|
8
13
|
export type {
|
|
@@ -31,3 +36,25 @@ export type { CreateClientConfig } from "./types";
|
|
|
31
36
|
|
|
32
37
|
export { createLocaleRedirect } from "../createLocaleRedirect";
|
|
33
38
|
export type { CreateLocaleRedirectConfig } from "../createLocaleRedirect";
|
|
39
|
+
|
|
40
|
+
// Re-exports from @prismicio/react
|
|
41
|
+
export { PrismicText } from "@prismicio/react";
|
|
42
|
+
export type { PrismicTextProps } from "@prismicio/react";
|
|
43
|
+
|
|
44
|
+
export { SliceZone, TODOSliceComponent } from "@prismicio/react";
|
|
45
|
+
export type {
|
|
46
|
+
SliceComponentProps,
|
|
47
|
+
SliceComponentType,
|
|
48
|
+
SliceLike,
|
|
49
|
+
SliceLikeGraphQL,
|
|
50
|
+
SliceLikeRestV2,
|
|
51
|
+
SliceZoneLike,
|
|
52
|
+
SliceZoneProps,
|
|
53
|
+
} from "@prismicio/react";
|
|
54
|
+
|
|
55
|
+
// Next.js-specific PrismicRichText and PrismicTable
|
|
56
|
+
export { PrismicRichText, defaultComponents } from "../PrismicRichText";
|
|
57
|
+
export type { PrismicRichTextProps, RichTextComponents } from "../PrismicRichText";
|
|
58
|
+
|
|
59
|
+
export { PrismicTable } from "../PrismicTable";
|
|
60
|
+
export type { PrismicTableProps, TableComponents } from "../PrismicTable";
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|